mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: David Rientjes <rientjes@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Fengguang Wu <fengguang.wu@intel.com>,
	Li Zefan <lizefan@huawei.com>, Aristeu Rozanski <aris@redhat.com>,
	Tejun Heo <tj@kernel.org>, Mimi Zohar <zohar@linux.vnet.ibm.com>,
	James Morris <jmorris@namei.org>,
	Dmitry Kasatkin <dmitry.kasatkin@intel.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.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)	[thread overview]
Message-ID: <alpine.LSU.2.00.1210172052420.20979@eggly.anvils> (raw)
In-Reply-To: <alpine.DEB.2.00.1210172021320.32271@chino.kir.corp.google.com>

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 */
> 

  reply	other threads:[~2012-10-18  3:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18  2:43 [ima_inode_post_setattr] kernel BUG at mm/slub.c:3479! Fengguang Wu
2012-10-18  3:07 ` Mimi Zohar
2012-10-18  3:07 ` David Rientjes
2012-10-18  3:41   ` [patch for-3.7] fs, xattr: fix bug when removing a name not in xattr list David Rientjes
2012-10-18  3:55     ` Hugh Dickins [this message]
2012-10-18  4:33       ` Al Viro
2012-10-18 12:43     ` Hillf Danton
2012-10-18 13:43     ` Aristeu Rozanski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.00.1210172052420.20979@eggly.anvils \
    --to=hughd@google.com \
    --cc=aris@redhat.com \
    --cc=dmitry.kasatkin@intel.com \
    --cc=fengguang.wu@intel.com \
    --cc=jmorris@namei.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=rientjes@google.com \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®