linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Graziano <david.graziano@rockwellcollins.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-security-module@vger.kernel.org,
	Paul Moore <paul@paul-moore.com>,
	agruenba@redhat.com, linux-mm@kvack.org,
	Stephen Smalley <sds@tycho.nsa.gov>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/3] xattr: add simple initxattrs function
Date: Mon, 9 Jan 2017 09:41:03 -0600	[thread overview]
Message-ID: <CA+RmS-9Pu0yK17Liwz0fqnDH-_1ejvLXRgD3y9WnZG56eoMGxA@mail.gmail.com> (raw)
In-Reply-To: <20170108095511.GB4203@infradead.org>

On Sun, Jan 8, 2017 at 3:55 AM, Christoph Hellwig <hch@infradead.org> wrote:
>> +/*
>> + * Callback for security_inode_init_security() for acquiring xattrs.
>> + */
>> +int simple_xattr_initxattrs(struct inode *inode,
>> +                         const struct xattr *xattr_array,
>> +                         void *fs_info)
>> +{
>> +     struct simple_xattrs *xattrs;
>> +     const struct xattr *xattr;
>> +     struct simple_xattr *new_xattr;
>> +     size_t len;
>> +
>> +     if (!fs_info)
>> +             return -ENOMEM;
>
> This probablt should be an EINVAL, and also a WARN_ON_ONCE.

I will change the return value to -EINVAL and add the WARN_ON_ONCE.
In the next version of the patchset.

>
>> +     xattrs = (struct simple_xattrs *) fs_info;
>
> No need for the cast.  In fact we should probably just declarate it
> as struct simple_xattrs *xattrs in the protoype and thus be type safe.

I don't think the prototype can be changed to "struct simple_xattrs" as the
security_inode_init_security() function in security/security.c which calls
this is asumming an initxattrs function with following prototype
int (*initxattrs)  (struct inode *inode, const struct xattr
*xattr_array, void *fs_data)

>
>> +
>> +     for (xattr = xattr_array; xattr->name != NULL; xattr++) {
>> +             new_xattr = simple_xattr_alloc(xattr->value, xattr->value_len);
>> +             if (!new_xattr)
>> +                     return -ENOMEM;
>
> We'll need to unwind the previous allocations here.

This patchset essentially relocates the shmem_initxattrs() function from
mm/shmem.c and uses the relocated function for both tmpfs and mqueuefs.
That inital function didn't attempt to unwind the previous allocations. If the
consensus is to unwind any allocations made by this function I can look
at adding it.

  reply	other threads:[~2017-01-09 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05 22:03 [PATCH v4 0/3] initxattr callback update for mqueue xattr support David Graziano
2017-01-05 22:03 ` [PATCH v4 1/3] xattr: add simple initxattrs function David Graziano
2017-01-08  9:55   ` Christoph Hellwig
2017-01-09 15:41     ` David Graziano [this message]
2017-01-05 22:03 ` [PATCH v4 2/3] shmem: use simple initxattrs callback David Graziano
2017-01-05 22:03 ` [PATCH v4 3/3] mqueue: Implement generic xattr support David Graziano

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=CA+RmS-9Pu0yK17Liwz0fqnDH-_1ejvLXRgD3y9WnZG56eoMGxA@mail.gmail.com \
    --to=david.graziano@rockwellcollins.com \
    --cc=agruenba@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=sds@tycho.nsa.gov \
    /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).