Re: [PATCH V3] cpuidle: Add a sysfs entry to disable specific Cstate for debug purpose.
From: Henrique de Moraes Holschuh
Date: Tue Mar 13 2012 - 16:49:18 EST
On Tue, 13 Mar 2012, Yanmin Zhang wrote:
> > > > > +static ssize_t store_state_##_name(struct cpuidle_state *state, \
> > > > > + const char *buf, size_t size) \
> > > > > +{ \
> > > > > + int value; \
> > > > > + sscanf(buf, "%d", &value); \
> > > > > + if (value) \
> > > > > + state->disable = 1; \
> > > > > + else \
> > > > > + state->disable = 0; \
> > > > > + return size; \
> > > > > +}
> > > >
> > > > Isn't this missing a check for capabilities? Disabling cpuidle states is
> > > > not something random Joe (and IMHO that does mean random capability-
> > > > restricted Joe root) should be doing...
> > > Sorry. Could you elaborate it?
> >
> > Sure. Should any user be able to disable a C state, therefore causing
> > the system to consume more power?
> Here we use the simple way to check access. Only root could change it.
Yea, but capabilities are supposed to constrain root as well :-)
> > I am pretty sure the answer is NO, in which case you should check for
> > the appropriate user credentials before you allow a write to these
> > "debug" controls to succeed. "capability" here is one of the CAP_*
> > capabilities tested through capable(), which are supposed to limit even
> > root.
> We would add below check.
>
> if (!capable(CAP_SYS_ADMIN))
> return -EPERM;
Looks good.
Thanks!
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/