mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Torben Hohn <torbenh@gmx.de>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	torbenh@gmx.de, johnstul@us.ibm.com, tglx@linutronix.de,
	richard.cochran@omicron.at
Subject: [tip:timers/core] posix-clocks: Check write permissions in posix syscalls
Date: Sat, 12 Mar 2011 20:30:50 GMT	[thread overview]
Message-ID: <tip-6e6823d17b157f185be09f4c70181299f9273f0b@git.kernel.org> (raw)
In-Reply-To: <1299173174-348-4-git-send-email-torbenh@gmx.de>

Commit-ID:  6e6823d17b157f185be09f4c70181299f9273f0b
Gitweb:     http://git.kernel.org/tip/6e6823d17b157f185be09f4c70181299f9273f0b
Author:     Torben Hohn <torbenh@gmx.de>
AuthorDate: Thu, 3 Mar 2011 18:26:14 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 12 Mar 2011 21:27:07 +0100

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 <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>
---
 kernel/time/posix-clock.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 04498cb..25028dd 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -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;

  parent reply	other threads:[~2011-03-12 20:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03 17:26 some patches for the ptp framework Torben Hohn
2011-03-03 17:26 ` [PATCH 1/3] remove __cpuinit from mwait_usable() Torben Hohn
2011-03-03 17:26 ` [PATCH 2/3] ptp: add a software clock based on clock_monotonic_raw Torben Hohn
2011-03-03 19:34   ` john stultz
2011-03-04  6:46     ` Richard Cochran
2011-03-04 11:06       ` torbenh
2011-03-05 20:08       ` john stultz
2011-03-06 13:28         ` Richard Cochran
2011-03-11 11:13           ` torbenh
2011-03-11 11:37             ` Christian Riesch
2011-03-11 13:38               ` torbenh
2011-03-11 11:56             ` Christian Riesch
2011-03-04  6:42   ` Richard Cochran
2011-03-04 11:30     ` torbenh
2011-03-04 16:10       ` Richard Cochran
2011-03-03 17:26 ` [PATCH 3/3] Check for write permission on FD based posix-clocks Torben Hohn
2011-03-04  7:22   ` Richard Cochran
2011-03-04  9:55     ` Arnd Bergmann
2011-03-04 10:13     ` torbenh
2011-03-11 19:46     ` Thomas Gleixner
2011-03-12 17:23       ` Richard Cochran
2011-03-12 17:35         ` Thomas Gleixner
2011-03-12 20:30   ` tip-bot for Torben Hohn [this message]
2011-03-04  6:21 ` some patches for the ptp framework Richard Cochran
2011-03-10  7:02   ` Richard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-6e6823d17b157f185be09f4c70181299f9273f0b@git.kernel.org \
    --to=torbenh@gmx.de \
    --cc=hpa@zytor.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=richard.cochran@omicron.at \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®