]> git.baikalelectronics.ru Git - kernel.git/commit
fs, xattr: fix bug when removing a name not in xattr list
authorDavid Rientjes <rientjes@google.com>
Thu, 18 Oct 2012 03:41:15 +0000 (20:41 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 18 Oct 2012 19:35:58 +0000 (12:35 -0700)
commit9e6103c47ea49bbf0ac6617bebc4efe81c208130
treeb485e28471a2f785681679a5ca92b11e27658bdd
parent3913843bbf948cde57c53e7c3b5cf3a91f87cef8
fs, xattr: fix bug when removing a name not in xattr list

Commit 5c7580e4125f ("xattr: extract simple_xattr code from tmpfs") moved
some code from tmpfs but introduced a subtle bug along the way.

If the name passed to simple_xattr_remove() does not exist in the list of
xattrs, then it is possible to call kfree(new_xattr) when new_xattr is
actually initialized to itself on the stack via uninitialized_var().

This causes a BUG() since the memory was not allocated via the slab
allocator and was not bypassed through to the page allocator because it
was too large.

Initialize the local variable to NULL so the kfree() never takes place.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Aristeu Rozanski <aris@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/xattr.c