Commit 6e6823d1 authored by Torben Hohn's avatar Torben Hohn Committed by Thomas Gleixner

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: default avatarTorben Hohn <torbenh@gmx.de>
LKML-Reference: <1299173174-348-4-git-send-email-torbenh@gmx.de>
Cc: Richard Cochran <richard.cochran@omicron.at>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
parent a9e7acff
...@@ -287,11 +287,16 @@ static int pc_clock_adjtime(clockid_t id, struct timex *tx) ...@@ -287,11 +287,16 @@ static int pc_clock_adjtime(clockid_t id, struct timex *tx)
if (err) if (err)
return err; return err;
if ((cd.fp->f_mode & FMODE_WRITE) == 0) {
err = -EACCES;
goto out;
}
if (cd.clk->ops.clock_adjtime) if (cd.clk->ops.clock_adjtime)
err = cd.clk->ops.clock_adjtime(cd.clk, tx); err = cd.clk->ops.clock_adjtime(cd.clk, tx);
else else
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
out:
put_clock_desc(&cd); put_clock_desc(&cd);
return err; return err;
...@@ -344,11 +349,16 @@ static int pc_clock_settime(clockid_t id, const struct timespec *ts) ...@@ -344,11 +349,16 @@ static int pc_clock_settime(clockid_t id, const struct timespec *ts)
if (err) if (err)
return err; return err;
if ((cd.fp->f_mode & FMODE_WRITE) == 0) {
err = -EACCES;
goto out;
}
if (cd.clk->ops.clock_settime) if (cd.clk->ops.clock_settime)
err = cd.clk->ops.clock_settime(cd.clk, ts); err = cd.clk->ops.clock_settime(cd.clk, ts);
else else
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
out:
put_clock_desc(&cd); put_clock_desc(&cd);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment