Skip to content

Commit eb04a73

Browse files
Michal Hockogregkh
authored andcommitted
fs/xattr.c: zero out memory copied to userspace in getxattr
commit 81be3dee96346fbe08c31be5ef74f03f6b63cf68 upstream. getxattr uses vmalloc to allocate memory if kzalloc fails. This is filled by vfs_getxattr and then copied to the userspace. vmalloc, however, doesn't zero out the memory so if the specific implementation of the xattr handler is sloppy we can theoretically expose a kernel memory. There is no real sign this is really the case but let's make sure this will not happen and use vzalloc instead. Fixes: 779302e ("fs/xattr.c:getxattr(): improve handling of allocation failures") Link: http://lkml.kernel.org/r/20170306103327.2766-1-mhocko@kernel.org Acked-by: Kees Cook <keescook@chromium.org> Reported-by: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a3e6be0 commit eb04a73

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/xattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
442442
size = XATTR_SIZE_MAX;
443443
kvalue = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
444444
if (!kvalue) {
445-
vvalue = vmalloc(size);
445+
vvalue = vzalloc(size);
446446
if (!vvalue)
447447
return -ENOMEM;
448448
kvalue = vvalue;

0 commit comments

Comments
 (0)