]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.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)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit c73aa4102f5b9f261a907c3b3df94cd2c478504d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/afs/xattr.c

index cfcc674e64a55bc52be024d873a5b70fa85fafc1..411f67c79f09064e987d6ed4d8551847cd5af622 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;
 }