Re: [PATCH 16/32] staging: gasket: always allow root open for write

From: Todd Poynor
Date: Tue Jul 17 2018 - 15:04:35 EST


On Tue, Jul 17, 2018 at 11:50 AM, Joe Perches <joe@xxxxxxxxxxx> wrote:
> 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.

Will fix, I noticed this earlier and forgot to address it.

>>
>> return !!(filp->f_mode & FMODE_WRITE);
>
> Or maybe change the functions to return bool

And there's another patch farther down in the stack that does that,
too, will keep them separate and fix up this intermediate patch for
now.

Thanks -- Todd