lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 15 Jul 2018 12:53:09 +0300
From:   Dmitry Torokhov <dtor@...omium.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     devel@...verdev.osuosl.org, toddpoynor@...il.com,
        frankhu@...omium.org, jnjoseph@...gle.com,
        lkml <linux-kernel@...r.kernel.org>,
        Simon Que <sque@...omium.org>, rspringer@...gle.com,
        Guenter Roeck <groeck@...omium.org>, toddpoynor@...gle.com
Subject: Re: [PATCH 11/18] staging: gasket: always allow root open for write

On Sun, Jul 15, 2018 at 12:32 PM Greg Kroah-Hartman
<gregkh@...uxfoundation.org> wrote:
>
> On Sun, Jul 15, 2018 at 12:11:47PM +0300, Dmitry Torokhov wrote:
> > On Sun, Jul 15, 2018 at 12:05 PM Greg Kroah-Hartman
> > <gregkh@...uxfoundation.org> wrote:
> > >
> > > On Fri, Jul 13, 2018 at 10:58:09PM -0700, Todd Poynor wrote:
> > > > From: Todd Poynor <toddpoynor@...gle.com>
> > > >
> > > > Always allow root to open device for writing.
> > > >
> > > > Drop special-casing of ioctl permissions for root vs. owner.
> > > >
> > > > Reported-by: Dmitry Torokhov <dtor@...omium.org>
> > > > Signed-off-by: Zhongze Hu <frankhu@...omium.org>
> > > > Signed-off-by: Todd Poynor <toddpoynor@...gle.com>
> > > > ---
> > > >  drivers/staging/gasket/apex_driver.c  |  9 +++------
> > > >  drivers/staging/gasket/gasket_core.c  |  8 +++++---
> > > >  drivers/staging/gasket/gasket_ioctl.c | 15 ++++++---------
> > > >  3 files changed, 14 insertions(+), 18 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c
> > > > index b1318482ba65..ffe11d8168ea 100644
> > > > --- a/drivers/staging/gasket/apex_driver.c
> > > > +++ b/drivers/staging/gasket/apex_driver.c
> > > > @@ -644,13 +644,10 @@ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev)
> > > >  static uint apex_ioctl_check_permissions(struct file *filp, uint cmd)
> > > >  {
> > > >       struct gasket_dev *gasket_dev = filp->private_data;
> > > > -     int root = capable(CAP_SYS_ADMIN);
> > > > -     int is_owner = gasket_dev->dev_info.ownership.is_owned &&
> > > > -                    current->tgid == gasket_dev->dev_info.ownership.owner;
> > > > +     fmode_t write;
> > > >
> > > > -     if (root || is_owner)
> > > > -             return 1;
> > > > -     return 0;
> > > > +     write = filp->f_mode & FMODE_WRITE;
> > >
> > > Ok, this is insane.  You don't change, or check, the permissions on a
> > > file handle while it is already open, as you only check the permissions
> > > on OPEN, not on WRITE.  See the recent rant from Linus on the linux-api
> > > list for yet-another-long-threaad in which he explains this.
> > >
> > > So this whole ioctl can just be removed, it is totally crazy and wrong
> > > and should just be removed.
> >
> > No, the code checks whether the requested ioctl command is compatible
> > with the mode the file handle was open with. There are some ioctls
> > that are allowed on file handle opened for read and others that
> > require file handle to be opened for write. That is all. It does not
> > change permissions past open.
>
> That's really not obvious here :)
>
> And is odd on a whole other set of "crazy design", but ok, let's let it
> live for now.

Are you talking about ioctl still or something else? Because such
ioctl handling is quite common, take a look at blkdev for example,
where disacrd ioctl is only allowed when device is open for writing.

>
> I can't wait for people to just realize this whole "new" subsystem can
> be replaced with UIO, but that's a topic for a different thread...

Yes, that is true and that is why I am not sure why we are going
through all this staging exercise.

As far as I understand we'd still need to have quite a bit of kernel
code so that we can safely program DMA controller (it does not look
like uio_dmem_genirq.c is sufficient as is for gasket needs), but that
should be solvable.

Thanks,
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ