From: Andrew Morton <akpm@linux-foundation.org>
To: Hugh Dickins <hughd@google.com>
Cc: 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 14:46:02 -0800 [thread overview]
Message-ID: <20120227144602.07f5ec33.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.LSU.2.00.1202241904070.22389@eggly.anvils>
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?
next prev parent reply other threads:[~2012-02-27 22:46 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 [this message]
2012-02-28 3:46 ` Ware, Ryan R
[not found] ` <CAGGTEhPQ6OLgqZbbAwE=3Xj8qE2iNhLOk5LdkGU13WxbY=qb2w@mail.gmail.com>
2012-02-28 4:10 ` Hugh Dickins
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=20120227144602.07f5ec33.akpm@linux-foundation.org \
--to=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;
as well as URLs for NNTP newsgroup(s).