From: James Morris <james.l.morris@oracle.com>
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Colin King <colin.king@canonical.com>,
linux-security-module@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][capabilities-next] commoncap: move assignment of fs_ns to avoid null pointer dereference
Date: Thu, 12 Oct 2017 10:30:36 +1100 (AEDT) [thread overview]
Message-ID: <alpine.LFD.2.20.1710121030190.16516@t440.gateway.2wire.net> (raw)
In-Reply-To: <20171011204809.GD8207@mail.hallyn.com>
On Wed, 11 Oct 2017, Serge E. Hallyn wrote:
> Hi James,
>
> it doesn't look like this has been picked up yet. Assuming I'm not looking
> in the wrong place, can you pull it into the security tree?
Sure, Colin, can you please resend this?
>
> Quoting Serge E. Hallyn (serge@hallyn.com):
> > On Mon, Sep 04, 2017 at 06:50:05PM +0100, Colin King wrote:
> > > From: Colin Ian King <colin.king@canonical.com>
> > >
> > > The pointer fs_ns is assigned from inode->i_ib->s_user_ns before
> > > a null pointer check on inode, hence if inode is actually null we
> > > will get a null pointer dereference on this assignment. Fix this
> > > by only dereferencing inode after the null pointer check on
> > > inode.
> > >
> > > Detected by CoverityScan CID#1455328 ("Dereference before null check")
> > >
> > > Fixes: 8db6c34f1dbc ("Introduce v3 namespaced file capabilities")
> > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> > thanks!
> >
> > Acked-by: Serge Hallyn <serge@hallyn.com>
> >
> > > ---
> > > security/commoncap.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/security/commoncap.c b/security/commoncap.c
> > > index c25e0d27537f..fc46f5b85251 100644
> > > --- a/security/commoncap.c
> > > +++ b/security/commoncap.c
> > > @@ -585,13 +585,14 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
> > > struct vfs_ns_cap_data data, *nscaps = &data;
> > > struct vfs_cap_data *caps = (struct vfs_cap_data *) &data;
> > > kuid_t rootkuid;
> > > - struct user_namespace *fs_ns = inode->i_sb->s_user_ns;
> > > + struct user_namespace *fs_ns;
> > >
> > > memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data));
> > >
> > > if (!inode)
> > > return -ENODATA;
> > >
> > > + fs_ns = inode->i_sb->s_user_ns;
> > > size = __vfs_getxattr((struct dentry *)dentry, inode,
> > > XATTR_NAME_CAPS, &data, XATTR_CAPS_SZ);
> > > if (size == -ENODATA || size == -EOPNOTSUPP)
> > > --
> > > 2.14.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2017-10-11 23:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 17:50 Colin King
2017-09-04 18:53 ` Serge E. Hallyn
2017-10-11 20:48 ` Serge E. Hallyn
2017-10-11 23:30 ` James Morris [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=alpine.LFD.2.20.1710121030190.16516@t440.gateway.2wire.net \
--to=james.l.morris@oracle.com \
--cc=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.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
all inboxes | Powered by JetHome®