[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHC9VhQ6kVroFZri+=DTewcecZASsH9VGZKi_zY4MzbbSmkEng@mail.gmail.com>
Date: Wed, 23 Feb 2022 16:43:25 -0500
From: Paul Moore <paul@...l-moore.com>
To: Richard Haines <richard_c_haines@...nternet.com>
Cc: Ondrej Mosnacek <omosnace@...hat.com>,
Stephen Smalley <stephen.smalley.work@...il.com>,
Eric Paris <eparis@...isplace.org>, demiobenour@...il.com,
SElinux list <selinux@...r.kernel.org>,
Linux kernel mailing list <linux-kernel@...r.kernel.org>,
selinux-refpolicy@...r.kernel.org,
Jeff Vander Stoep <jeffv@...gle.com>
Subject: Re: [PATCH V2] security/selinux: Always allow FIOCLEX and FIONCLEX
On Wed, Feb 23, 2022 at 4:36 PM Paul Moore <paul@...l-moore.com> wrote:
> On Wed, Feb 23, 2022 at 7:43 AM Richard Haines
> <richard_c_haines@...nternet.com> wrote:
> > On Wed, 2022-02-23 at 13:12 +0100, Ondrej Mosnacek wrote:
> > > On Wed, Feb 23, 2022 at 12:58 PM Richard Haines
> > > <richard_c_haines@...nternet.com> wrote:
> > > > On Tue, 2022-02-22 at 18:28 -0500, Paul Moore wrote:
> > > > > On Mon, Feb 21, 2022 at 8:15 AM Richard Haines
> > > > > <richard_c_haines@...nternet.com> wrote:
> > > > > >
> > > > > > These ioctls are equivalent to fcntl(fd, F_SETFD, flags), which
> > > > > > SELinux
> > > > > > always allows too. Furthermore, a failed FIOCLEX could result
> > > > > > in a
> > > > > > file
> > > > > > descriptor being leaked to a process that should not have
> > > > > > access to
> > > > > > it.
> > > > > >
> > > > > > As this patch removes access controls, a policy capability
> > > > > > needs to
> > > > > > be
> > > > > > enabled in policy to always allow these ioctls.
> > > > > >
> > > > > > Based-on-patch-by: Demi Marie Obenour <demiobenour@...il.com>
> > > > > > Signed-off-by: Richard Haines <richard_c_haines@...nternet.com>
> > > > > > ---
> > > > > > V2 Change: Control via a policy capability. See this thread for
> > > > > > discussion:
> > > > > > https://lore.kernel.org/selinux/CAHC9VhQEPxYP_KU56gAGNHKQaxucY8gSsHiUB42PVgADBAccRQ@mail.gmail.com/T/#t
> > > > > >
> > > > > > With this patch and the polcap enabled, the selinux-testsuite
> > > > > > will
> > > > > > fail:
> > > > > > ioctl/test at line 47 - Will need a fix.
> > > > > >
> > > > > > security/selinux/hooks.c | 7 +++++++
> > > > > > security/selinux/include/policycap.h | 1 +
> > > > > > security/selinux/include/policycap_names.h | 3 ++-
> > > > > > security/selinux/include/security.h | 7 +++++++
> > > > > > 4 files changed, 17 insertions(+), 1 deletion(-)
> > > > >
> > > > > Thanks Richard for putting together the v2 of this patch.
> > > > >
> > > > > As far as the test is concerned, it seems like the quick-n-dirty
> > > > > fix
> > > > > is to simply remove the ioctl(FIOCLEX) test in test_noioctl.c; is
> > > > > everyone okay with that? At least that is what I'm going to do
> > > > > with
> > > > > my local copy that I use to validate the kernel-secnext builds
> > > > > unless
> > > > > someone has a better patch :)
> > > >
> > > > To fix this I was planning to submit a patch that would change the
> > > > ioctl(FIOCLEX) tests to ioctl(FS_IOC_GETFSLABEL) as that would
> > > > continue
> > > > to test the xperms.
> > >
> > > That one seems to be implemented only by some filesystems. Is there
> > > any more generic one we could use?
> >
> > What about FS_IOC_GETFLAGS
>
> Unless I'm mistaken, FIGETBSZ should be largely fs independent.
Bah, nevermind, FIGETBSZ ends up in a FILE__GETATTR check.
FS_IOC_GETFLAGS has the same problem.
How about FIOQSIZE?
--
paul-moore.com
Powered by blists - more mailing lists