linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: serge.hallyn@canonical.com
Cc: arnd@arndb.de, tglx@linutronix.de, linux-kernel@vger.kernel.org,
	james.l.morris@oracle.com, serge@hallyn.com, paul@paul-moore.com,
	john.johansen@canonical.com, sds@tycho.nsa.gov,
	casey@schaufler-ca.com, penguin-kernel@I-love.SAKURA.ne.jp,
	neilb@suse.de, edumazet@google.com, jlayton@primarydata.com,
	linux-security-module@vger.kernel.org, baolin.wang@linaro.org,
	y2038@lists.linaro.org
Subject: [PATCH v2 3/5] security: Introduce security_settime64()
Date: Wed, 29 Jul 2015 20:13:21 +0800	[thread overview]
Message-ID: <50b61ce23a73b68c3c55d6d9aa416af29001205a.1438170155.git.baolin.wang@linaro.org> (raw)
In-Reply-To: <cover.1438170154.git.baolin.wang@linaro.org>

security_settime() uses a timespec, which is not year 2038 safe
on 32bit systems. Thus this patch introduces the security_settime64()
function with timespec64 type. We also convert the cap_settime() helper
function to use the 64bit types.

Move the security_settime() to the head file as a inline function for
removing that inline helper when following up patches are fixed the
call sites.

None of the existing hooks is using the timespec argument and therefor
the patch is not doing any functional changes.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/linux/lsm_hooks.h |    5 +++--
 include/linux/security.h  |   20 +++++++++++++++++---
 security/commoncap.c      |    2 +-
 security/security.c       |    2 +-
 4 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index 9429f05..d791f35 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -1191,7 +1191,8 @@
  *	Return 0 if permission is granted.
  * @settime:
  *	Check permission to change the system time.
- *	struct timespec and timezone are defined in include/linux/time.h
+ *	struct timespec64 is defined in include/linux/time64.h and timezone
+ *	is defined in include/linux/time.h
  *	@ts contains new time
  *	@tz contains new timezone
  *	Return 0 if permission is granted.
@@ -1324,7 +1325,7 @@ union security_list_options {
 	int (*quotactl)(int cmds, int type, int id, struct super_block *sb);
 	int (*quota_on)(struct dentry *dentry);
 	int (*syslog)(int type);
-	int (*settime)(const struct timespec *ts, const struct timezone *tz);
+	int (*settime)(const struct timespec64 *ts, const struct timezone *tz);
 	int (*vm_enough_memory)(struct mm_struct *mm, long pages);
 
 	int (*bprm_set_creds)(struct linux_binprm *bprm);
diff --git a/include/linux/security.h b/include/linux/security.h
index 79d85dd..105fc27 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -69,7 +69,7 @@ struct timezone;
 /* These functions are in security/commoncap.c */
 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
 		       int cap, int audit);
-extern int cap_settime(const struct timespec *ts, const struct timezone *tz);
+extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
 extern int cap_ptrace_traceme(struct task_struct *parent);
 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -206,7 +206,13 @@ int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
 int security_quota_on(struct dentry *dentry);
 int security_syslog(int type);
-int security_settime(const struct timespec *ts, const struct timezone *tz);
+int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
+static inline int security_settime(const struct timespec *ts, const struct timezone *tz)
+{
+	struct timespec64 ts64 = timespec_to_timespec64(*ts);
+
+	return security_settime64(&ts64, tz);
+}
 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
 int security_bprm_set_creds(struct linux_binprm *bprm);
 int security_bprm_check(struct linux_binprm *bprm);
@@ -457,10 +463,18 @@ static inline int security_syslog(int type)
 	return 0;
 }
 
+static inline int security_settime64(const struct timespec64 *ts,
+				     const struct timezone *tz)
+{
+	return cap_settime(ts, tz);
+}
+
 static inline int security_settime(const struct timespec *ts,
 				   const struct timezone *tz)
 {
-	return cap_settime(ts, tz);
+	struct timespec64 ts64 = timespec_to_timespec64(*ts);
+
+	return cap_settime(&ts64, tz);
 }
 
 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
diff --git a/security/commoncap.c b/security/commoncap.c
index d103f5a4..17b1f79 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -111,7 +111,7 @@ int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
  * Determine whether the current process may set the system clock and timezone
  * information, returning 0 if permission granted, -ve if denied.
  */
-int cap_settime(const struct timespec *ts, const struct timezone *tz)
+int cap_settime(const struct timespec64 *ts, const struct timezone *tz)
 {
 	if (!capable(CAP_SYS_TIME))
 		return -EPERM;
diff --git a/security/security.c b/security/security.c
index 595fffa..8d0dbd6 100644
--- a/security/security.c
+++ b/security/security.c
@@ -213,7 +213,7 @@ int security_syslog(int type)
 	return call_int_hook(syslog, 0, type);
 }
 
-int security_settime(const struct timespec *ts, const struct timezone *tz)
+int security_settime64(const struct timespec64 *ts, const struct timezone *tz)
 {
 	return call_int_hook(settime, 0, ts, tz);
 }
-- 
1.7.9.5


  parent reply	other threads:[~2015-07-29 12:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30  1:44 [PATCH v2 0/5] Introduce 64bit accessors and structures required to address y2038 issues in the posix_clock subsystem Baolin Wang
2015-07-29 11:58 ` [PATCH v2 1/5] time: Introduce struct itimerspec64 Baolin Wang
2015-07-29 12:09 ` [PATCH v2 2/5] timekeeping: Introduce current_kernel_time64() Baolin Wang
2015-07-29 12:13 ` Baolin Wang [this message]
2015-07-30  8:23   ` [PATCH v2 3/5] security: Introduce security_settime64() James Morris
2016-04-18 16:01   ` [RESEND PATCH " Arnd Bergmann
2016-04-18 16:31     ` Mark Brown
2016-04-19  1:57       ` Baolin Wang
2016-04-18 16:54   ` John Stultz
2016-04-18 17:04     ` Kees Cook
2016-04-19 19:59       ` Serge E. Hallyn
2016-04-19  2:02     ` Baolin Wang
2015-07-29 12:16 ` [PATCH v2 4/5] time: Introduce do_sys_settimeofday64() Baolin Wang
2015-07-29 12:18 ` [PATCH v2 5/5] time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64() Baolin Wang

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=50b61ce23a73b68c3c55d6d9aa416af29001205a.1438170155.git.baolin.wang@linaro.org \
    --to=baolin.wang@linaro.org \
    --cc=arnd@arndb.de \
    --cc=casey@schaufler-ca.com \
    --cc=edumazet@google.com \
    --cc=james.l.morris@oracle.com \
    --cc=jlayton@primarydata.com \
    --cc=john.johansen@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=sds@tycho.nsa.gov \
    --cc=serge.hallyn@canonical.com \
    --cc=serge@hallyn.com \
    --cc=tglx@linutronix.de \
    --cc=y2038@lists.linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).