[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALQRfL6OQKuBqbUoC7_yH7W4qabYSamRYUqjM-HE1gj2r_CaHQ@mail.gmail.com>
Date: Fri, 4 Dec 2020 07:58:14 -0800
From: "Andrew G. Morgan" <morgan@...nel.org>
To: James Morris <jmorris@...ei.org>
Cc: "Serge E. Hallyn" <serge@...lyn.com>,
lkml <linux-kernel@...r.kernel.org>,
Hervé Guillemet <herve@...llemet.org>,
Casey Schaufler <casey@...aufler-ca.com>
Subject: Re: [PATCH] fix namespaced fscaps when !CONFIG_SECURITY
The correct bug reference for this patch is:
https://bugzilla.kernel.org/show_bug.cgi?id=209689
Reviewed-by: Andrew G. Morgan <morgan@...nel.org>
On Mon, Nov 30, 2020 at 6:58 PM James Morris <jmorris@...ei.org> wrote:
>
> On Sun, 29 Nov 2020, Serge E. Hallyn wrote:
>
> > Hi James,
> >
> > would you mind adding this to the security tree? (You can cherrypick
> > from https://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux.git/commit/?h=2020-11-29/fix-nscaps )
>
> Sure.
>
> >
> > thanks,
> > -serge
> >
> > On Tue, Nov 17, 2020 at 08:09:59AM -0800, Andrew G. Morgan wrote:
> > > Signed-off-by: Andrew G. Morgan <morgan@...nel.org>
> > >
> > >
> > > On Tue, Nov 17, 2020 at 7:09 AM Serge E. Hallyn <serge@...lyn.com> wrote:
> > >
> > > > Namespaced file capabilities were introduced in 8db6c34f1dbc .
> > > > When userspace reads an xattr for a namespaced capability, a
> > > > virtualized representation of it is returned if the caller is
> > > > in a user namespace owned by the capability's owning rootid.
> > > > The function which performs this virtualization was not hooked
> > > > up if CONFIG_SECURITY=n. Therefore in that case the original
> > > > xattr was shown instead of the virtualized one.
> > > >
> > > > To test this using libcap-bin (*1),
> > > >
> > > > $ v=$(mktemp)
> > > > $ unshare -Ur setcap cap_sys_admin-eip $v
> > > > $ unshare -Ur setcap -v cap_sys_admin-eip $v
> > > > /tmp/tmp.lSiIFRvt8Y: OK
> > > >
> > > > "setcap -v" verifies the values instead of setting them, and
> > > > will check whether the rootid value is set. Therefore, with
> > > > this bug un-fixed, and with CONFIG_SECURITY=n, setcap -v will
> > > > fail:
> > > >
> > > > $ v=$(mktemp)
> > > > $ unshare -Ur setcap cap_sys_admin=eip $v
> > > > $ unshare -Ur setcap -v cap_sys_admin=eip $v
> > > > nsowner[got=1000, want=0],/tmp/tmp.HHDiOOl9fY differs in []
> > > >
> > > > Fix this bug by calling cap_inode_getsecurity() in
> > > > security_inode_getsecurity() instead of returning
> > > > -EOPNOTSUPP, when CONFIG_SECURITY=n.
> > > >
> > > > *1 - note, if libcap is too old for getcap to have the '-n'
> > > > option, then use verify-caps instead.
> > > >
> > > > Signed-off-by: Serge Hallyn <serge@...lyn.com>
> > > > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1593431
> > > > Cc: Hervé Guillemet <herve@...llemet.org>
> > > > Cc: Andrew G. Morgan <morgan@...nel.org>
> > > > Cc: Casey Schaufler <casey@...aufler-ca.com>
> > > > ---
> > > > include/linux/security.h | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/include/linux/security.h b/include/linux/security.h
> > > > index bc2725491560..39642626a707 100644
> > > > --- a/include/linux/security.h
> > > > +++ b/include/linux/security.h
> > > > @@ -869,7 +869,7 @@ static inline int security_inode_killpriv(struct
> > > > dentry *dentry)
> > > >
> > > > static inline int security_inode_getsecurity(struct inode *inode, const
> > > > char *name, void **buffer, bool alloc)
> > > > {
> > > > - return -EOPNOTSUPP;
> > > > + return cap_inode_getsecurity(inode, name, buffer, alloc);
> > > > }
> > > >
> > > > static inline int security_inode_setsecurity(struct inode *inode, const
> > > > char *name, const void *value, size_t size, int flags)
> > > > --
> > > > 2.25.1
> > > >
> > > >
> >
>
> --
> James Morris
> <jmorris@...ei.org>
Powered by blists - more mailing lists