]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
afs: Fix the afs.cell and afs.volume xattr handlers
authorDavid Howells <dhowells@redhat.com>
Wed, 1 May 2019 12:27:09 +0000 (13:27 +0100)
committerDavid Howells <dhowells@redhat.com>
Tue, 7 May 2019 15:48:44 +0000 (16:48 +0100)
Fix the ->get handlers for the afs.cell and afs.volume xattrs to pass the
source data size to memcpy() rather than target buffer size.

Overcopying the source data occasionally causes the kernel to oops.

Fixes: d3e3b7eac886 ("afs: Add metadata xattrs")
Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/xattr.c

index a2cdf25573e2419592b7460aafc7a6da019293a9..4ea7e53752dc91c1012da10c6e572b2a91280677 100644 (file)
@@ -50,7 +50,7 @@ static int afs_xattr_get_cell(const struct xattr_handler *handler,
                return namelen;
        if (namelen > size)
                return -ERANGE;
-       memcpy(buffer, cell->name, size);
+       memcpy(buffer, cell->name, namelen);
        return namelen;
 }
 
@@ -104,7 +104,7 @@ static int afs_xattr_get_volume(const struct xattr_handler *handler,
                return namelen;
        if (namelen > size)
                return -ERANGE;
-       memcpy(buffer, volname, size);
+       memcpy(buffer, volname, namelen);
        return namelen;
 }