|
|
Subscribe / Log in / New account

Re: [patch for-3.7] fs, xattr: fix bug when removing a name not in xattr list

From:  Hugh Dickins <hughd-AT-google.com>
To:  David Rientjes <rientjes-AT-google.com>
Subject:  Re: [patch for-3.7] fs, xattr: fix bug when removing a name not in xattr list
Date:  Wed, 17 Oct 2012 20:55:49 -0700 (PDT)
Message-ID:  <alpine.LSU.2.00.1210172052420.20979@eggly.anvils>
Cc:  Linus Torvalds <torvalds-AT-linux-foundation.org>, Al Viro <viro-AT-zeniv.linux.org.uk>, Fengguang Wu <fengguang.wu-AT-intel.com>, Li Zefan <lizefan-AT-huawei.com>, Aristeu Rozanski <aris-AT-redhat.com>, Tejun Heo <tj-AT-kernel.org>, Mimi Zohar <zohar-AT-linux.vnet.ibm.com>, James Morris <jmorris-AT-namei.org>, Dmitry Kasatkin <dmitry.kasatkin-AT-intel.com>, linux-security-module-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org, Konrad Rzeszutek Wilk <konrad.wilk-AT-oracle.com>
Archive‑link:  Article

On Wed, 17 Oct 2012, David Rientjes wrote:

> Commit 38f38657444d ("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>

Thank you both: a fine example of the danger of uninitialized_var()!

> ---
>  fs/xattr.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xattr.c b/fs/xattr.c
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -846,7 +846,7 @@ static int __simple_xattr_set(struct simple_xattrs *xattrs, const char
*name,
>  			      const void *value, size_t size, int flags)
>  {
>  	struct simple_xattr *xattr;
> -	struct simple_xattr *uninitialized_var(new_xattr);
> +	struct simple_xattr *new_xattr = NULL;
>  	int err = 0;
>  
>  	/* value == NULL means remove */
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




to post comments


Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds