[Linux-cachefs] "Bug" in nfs_server_get_key() ?

David Howells dhowells at redhat.com
Thu Sep 25 13:21:05 UTC 2014


James Pearson <james-p at moving-picture.com> wrote:

>         key->nfsversion = clp->rpc_ops->version;
>         key->family = clp->cl_addr.ss_family;
> 
>         memset(key, 0, len);

Yeah, stupid bug.  Patch below.

David
---
commit 8c8890287ea8e34a1e57648b6cb7a298c276f82b
Author: David Howells <dhowells at redhat.com>
Date:   Thu Sep 25 14:17:50 2014 +0100

    NFS: Fabricate fscache server index key correctly
    
    When fabricating a server index key for fscache, we should clear the index key
    buffer before starting to fill it in, not in the middle.
    
    Reported-by: James Pearson <james-p at moving-picture.com>
    Signed-off-by: David Howells <dhowells at redhat.com>

diff --git a/fs/nfs/fscache-index.c b/fs/nfs/fscache-index.c
index 7cf2c4699b08..777b055063f6 100644
--- a/fs/nfs/fscache-index.c
+++ b/fs/nfs/fscache-index.c
@@ -74,11 +74,10 @@ static uint16_t nfs_server_get_key(const void *cookie_netfs_data,
 	struct nfs_server_key *key = buffer;
 	uint16_t len = sizeof(struct nfs_server_key);
 
+	memset(key, 0, len);
 	key->nfsversion = clp->rpc_ops->version;
 	key->family = clp->cl_addr.ss_family;
 
-	memset(key, 0, len);
-
 	switch (clp->cl_addr.ss_family) {
 	case AF_INET:
 		key->port = sin->sin_port;





More information about the Linux-cachefs mailing list