From: "Ware, Ryan R" <ryan.r.ware@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>,
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: Tue, 28 Feb 2012 12:46:13 +0900 [thread overview]
Message-ID: <CAGGTEhP=jbA664fbbZaVEN5Bxq9_3iiV84ME8QSTUohv2JLkqw@mail.gmail.com> (raw)
In-Reply-To: <20120227144602.07f5ec33.akpm@linux-foundation.org>
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:
>
> > +/*
> > + * Callback for security_inode_init_security() for acquiring xattrs.
> > + */
> > +static int shmem_initxattrs(struct inode *inode,
> > + const struct xattr *xattr_array,
> > + void *fs_info)
> > +{
> > + struct shmem_inode_info *info = SHMEM_I(inode);
> > + const struct xattr *xattr;
> > + struct shmem_xattr *new_xattr;
> > + size_t len;
> > +
> > + for (xattr = xattr_array; xattr->name != NULL; xattr++) {
> > + new_xattr = shmem_xattr_alloc(xattr->value,
> > xattr->value_len);
> > + if (!new_xattr)
> > + return -ENOMEM;
> > +
> > + len = strlen(xattr->name) + 1;
> > + new_xattr->name = kmalloc(XATTR_SECURITY_PREFIX_LEN + len,
> > + GFP_KERNEL);
> > + 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.
Ryan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-02-28 3:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-23 9:46 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:44 ` Ware, Ryan R
2012-02-28 4:10 ` Hugh Dickins
2012-02-28 5:51 ` Sakkinen, Jarkko
2012-02-28 3:46 ` Ware, Ryan R [this message]
-- 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='CAGGTEhP=jbA664fbbZaVEN5Bxq9_3iiV84ME8QSTUohv2JLkqw@mail.gmail.com' \
--to=ryan.r.ware@intel.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--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 \
/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