lkml.org 
[lkml]   [2021]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] block: Check ADMIN before NICE for IOPRIO_CLASS_RT
Date
From: Alistair Delva
> Sent: 15 November 2021 19:09
...
> > > - if (!capable(CAP_SYS_NICE) && !capable(CAP_SYS_ADMIN))
> > > + if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_NICE))
> > > return -EPERM;

Isn't the real problem that you actually want to test:
if (!capable(CAP_SYS_NICE | CAP_SYS_ADMIN))
return -EPERM;
so that you only get the fail 'splat' when neither is set.

This will be true whenever more than one capability enables something.

Possibly this needs something like:
int capabale_or(unsigned int, ...);
#define capabale_or(...) capabable_or(__VA_LIST__, ~0u)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
\
 
 \ /
  Last update: 2021-11-16 10:30    [W:0.085 / U:0.848 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site