lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue, 13 Nov 2007 13:31:42 -0500
From:	Chuck Lever <chuck.lever@...cle.com>
To:	nfs@...ts.sourceforge.net
Cc:	netdev@...r.kernel.org
Subject: [PATCH 08/25] NFS: Expand server address storage in nfs_client struct

Prepare for managing larger addresses in the NFS client by widening the
nfs_client struct's cl_addr field and adding a field to store the address's
length.

Signed-off-by: Chuck Lever <chuck.lever@...cle.com>
Cc: Aurelien Charbon <aurelien.charbon@....bull.net>
---

 fs/nfs/client.c           |   11 +++++++----
 fs/nfs/super.c            |    9 ++++++---
 include/linux/nfs_fs_sb.h |    3 ++-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 5ab1ca1..53bf8ab 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -117,7 +117,8 @@ static struct nfs_client *nfs_alloc_client(const char *hostname,
 	atomic_set(&clp->cl_count, 1);
 	clp->cl_cons_state = NFS_CS_INITING;
 
-	memcpy(&clp->cl_addr, addr, sizeof(clp->cl_addr));
+	clp->cl_addrlen = sizeof(*addr);	/* for now */
+	memcpy(&clp->cl_addr, addr, clp->cl_addrlen);
 
 	if (hostname) {
 		clp->cl_hostname = kstrdup(hostname, GFP_KERNEL);
@@ -214,6 +215,8 @@ static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr,
 	struct nfs_client *clp;
 
 	list_for_each_entry(clp, &nfs_client_list, cl_share_link) {
+		struct sockaddr_in *clap = (struct sockaddr_in *)&clp->cl_addr;
+
 		/* Don't match clients that failed to initialise properly */
 		if (clp->cl_cons_state < 0)
 			continue;
@@ -222,10 +225,10 @@ static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr,
 		if (clp->rpc_ops->version != nfsversion)
 			continue;
 
-		if (clp->cl_addr.sin_addr.s_addr != addr->sin_addr.s_addr)
+		if (clap->sin_addr.s_addr != addr->sin_addr.s_addr)
 			continue;
 
-		if (!match_port || clp->cl_addr.sin_port == addr->sin_port)
+		if (!match_port || clap->sin_port == addr->sin_port)
 			goto found;
 	}
 
@@ -380,7 +383,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp, int proto,
 	struct rpc_create_args args = {
 		.protocol	= proto,
 		.address	= (struct sockaddr *)&clp->cl_addr,
-		.addrsize	= sizeof(clp->cl_addr),
+		.addrsize	= clp->cl_addrlen,
 		.timeout	= &timeparms,
 		.servername	= clp->cl_hostname,
 		.program	= &nfs_program,
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 5a742a8..6258a19 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1332,10 +1332,13 @@ static int nfs_compare_super(struct super_block *sb, void *data)
 	struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb);
 	int mntflags = sb_mntdata->mntflags;
 
-	if (memcmp(&old->nfs_client->cl_addr,
-				&server->nfs_client->cl_addr,
-				sizeof(old->nfs_client->cl_addr)) != 0)
+	/* Check family, address, and port */
+	if (old->nfs_client->cl_addrlen != server->nfs_client->cl_addrlen)
 		return 0;
+	if (memcmp(&old->nfs_client->cl_addr, &server->nfs_client->cl_addr,
+		   old->nfs_client->cl_addrlen) != 0)
+		return 0;
+
 	/* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
 	if (old->flags & NFS_MOUNT_UNSHARED)
 		return 0;
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index f2a0f20..5e3a43b 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -20,7 +20,8 @@ struct nfs_client {
 #define NFS_CS_IDMAP		2		/* - idmap started */
 #define NFS_CS_RENEWD		3		/* - renewd started */
 
-	struct sockaddr_in	cl_addr;	/* server identifier */
+	struct sockaddr_storage	cl_addr;	/* server identifier */
+	size_t			cl_addrlen;
 	char *			cl_hostname;	/* hostname of server */
 	struct list_head	cl_share_link;	/* link in global client list */
 	struct list_head	cl_superblocks;	/* List of nfs_server structs */

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ