From: Aristeu Rozanski <aris@redhat.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>,
Hugh Dickins <hughd@google.com>, Li Zefan <lizefan@huawei.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>,
Sasha Levin <levinsasha928@gmail.com>
Subject: Re: [patch for-3.7] fs, xattr: fix bug when removing a name not in xattr list
Date: Thu, 18 Oct 2012 09:43:53 -0400 [thread overview]
Message-ID: <20121018134353.GM29956@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1210172021320.32271@chino.kir.corp.google.com>
On Wed, Oct 17, 2012 at 08:41:15PM -0700, 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>
> ---
> 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 */
I think Sasha Levin was working on that (Cc'd) along with the smatch fix.
Anyway, __simple_xattr_set is too confusing and rewriting it is in my TODO list
which will shut up smatch too.
Acked-by: Aristeu Rozanski <aris@redhat.com>
--
Aristeu
prev parent reply other threads:[~2012-10-18 13:44 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
2012-10-18 4:33 ` Al Viro
2012-10-18 12:43 ` Hillf Danton
2012-10-18 13:43 ` Aristeu Rozanski [this message]
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=20121018134353.GM29956@redhat.com \
--to=aris@redhat.com \
--cc=dmitry.kasatkin@intel.com \
--cc=fengguang.wu@intel.com \
--cc=hughd@google.com \
--cc=jmorris@namei.org \
--cc=konrad.wilk@oracle.com \
--cc=levinsasha928@gmail.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