mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
posix-clocks: Check write permissions in posix syscalls
pc_clock_settime() and pc_clock_adjtime() do not check whether the fd was opened in write mode, so a clock can be set with a read only fd. [ tglx: We deliberately do not return -EPERM as we want this to be distingushable from the capability based permission check ] Signed-off-by: Torben Hohn <[email protected]> LKML-Reference: <[email protected]> Cc: Richard Cochran <[email protected]> Cc: John Stultz <[email protected]> Cc: Thomas Gleixner <[email protected]>
This commit is contained in:
parent
a9e7acfff0
commit
6e6823d17b
1 changed files with 12 additions and 2 deletions
|
|
@ -287,11 +287,16 @@ static int pc_clock_adjtime(clockid_t id, struct timex *tx)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
if ((cd.fp->f_mode & FMODE_WRITE) == 0) {
|
||||
err = -EACCES;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cd.clk->ops.clock_adjtime)
|
||||
err = cd.clk->ops.clock_adjtime(cd.clk, tx);
|
||||
else
|
||||
err = -EOPNOTSUPP;
|
||||
|
||||
out:
|
||||
put_clock_desc(&cd);
|
||||
|
||||
return err;
|
||||
|
|
@ -344,11 +349,16 @@ static int pc_clock_settime(clockid_t id, const struct timespec *ts)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
if ((cd.fp->f_mode & FMODE_WRITE) == 0) {
|
||||
err = -EACCES;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cd.clk->ops.clock_settime)
|
||||
err = cd.clk->ops.clock_settime(cd.clk, ts);
|
||||
else
|
||||
err = -EOPNOTSUPP;
|
||||
|
||||
out:
|
||||
put_clock_desc(&cd);
|
||||
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue