From: Hugh Dickins <hughd@google.com>
To: "Ware, Ryan R" <ryan.r.ware@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jarkko Sakkinen <jarkko.sakkinen@intel.com>,
James Morris <jmorris@namei.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: Re: [PATCH] tmpfs: security xattr setting on inode creation
Date: Mon, 27 Feb 2012 20:10:53 -0800 (PST) [thread overview]
Message-ID: <alpine.LSU.2.00.1202272003380.1574@eggly.anvils> (raw)
In-Reply-To: <CAGGTEhPQ6OLgqZbbAwE=3Xj8qE2iNhLOk5LdkGU13WxbY=qb2w@mail.gmail.com>
On Tue, 28 Feb 2012, Ware, Ryan R wrote:
> On Tue, Feb 28, 2012 at 7:46 AM, Andrew Morton <akpm@linux-foundation.org>wrote:
> > On Fri, 24 Feb 2012 19:19:22 -0800 (PST)
> > Hugh Dickins <hughd@google.com> wrote:
> >...
> > > + if (!new_xattr->name) {
> > > + kfree(new_xattr);
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + memcpy(new_xattr->name, XATTR_SECURITY_PREFIX,
> > > + XATTR_SECURITY_PREFIX_LEN);
> > > + memcpy(new_xattr->name + XATTR_SECURITY_PREFIX_LEN,
> > > + xattr->name, len);
> > > +
> > > + spin_lock(&info->lock);
> > > + list_add(&new_xattr->list, &info->xattr_list);
> > > + spin_unlock(&info->lock);
> > > + }
> > > +
> > > + return 0;
> > > +}
> >
> > So if there's a kmalloc failure partway through the array, we leave a
> > partially xattrified inode in place.
> >
> > Are we sure this is OK?
> >
>
> I'm guessing Jarkko can clean that up a bit. It wouldn't be a good idea to
> leave inaccurate data structures laying around during failure cases.
Andrew raises a good concern, but Jarkko got it just right and no
change is needed: any xattrs already allocated are properly linked
on info->xattr_list, then when security_inode_init_security() fails
(with an error other than EOPNOTSUPP) the failing inode is iput(),
which ends up in shmem_evict_inode(), which kfree()s those xattrs
(and their names) on info->xattr_list.
Hugh
next prev parent reply other threads:[~2012-02-28 4:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-23 9:46 [PATCH] tmpfs: security xattr setting on inode creation Jarkko Sakkinen
2012-02-24 8:13 ` James Morris
2012-02-25 3:19 ` Hugh Dickins
2012-02-25 7:03 ` Sakkinen, Jarkko
2012-02-27 22:46 ` Andrew Morton
2012-02-28 3:46 ` Ware, Ryan R
[not found] ` <CAGGTEhPQ6OLgqZbbAwE=3Xj8qE2iNhLOk5LdkGU13WxbY=qb2w@mail.gmail.com>
2012-02-28 4:10 ` Hugh Dickins [this message]
2012-02-28 5:51 ` Sakkinen, Jarkko
-- strict thread matches above, loose matches on Subject: below --
2012-02-22 7:48 Jarkko Sakkinen
2012-02-22 17:46 ` Sakkinen, Jarkko
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.1202272003380.1574@eggly.anvils \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=jarkko.sakkinen@intel.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=ryan.r.ware@intel.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;
as well as URLs for NNTP newsgroup(s).