Re: [PATCH 16/32] staging: gasket: always allow root open for write
From: Joe Perches
Date: Tue Jul 17 2018 - 14:51:05 EST
On Tue, 2018-07-17 at 13:22 +0300, Dan Carpenter wrote:
> On Mon, Jul 16, 2018 at 07:09:10PM -0700, Todd Poynor wrote:
> > --- a/drivers/staging/gasket/apex_driver.c
> > +++ b/drivers/staging/gasket/apex_driver.c
> > @@ -630,13 +630,10 @@ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev)
> > static uint apex_ioctl_check_permissions(struct file *filp, uint cmd)
>
> This function name is a bit of out of date.
>
> > {
> > 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;
> > + return write;
>
> This doesn't match the comment because it returns 0x2 or zero.
>
> return !!(filp->f_mode & FMODE_WRITE);
Or maybe change the functions to return bool