mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [GIT PULL][PATCH 0/3] Few small timekeeping updates for 4.7
@ 2016-04-22 19:03 John Stultz
  2016-04-22 19:03 ` [PATCH 1/3] clocksource: Add missing include of of.h John Stultz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: John Stultz @ 2016-04-22 19:03 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Serge Hallyn, James Morris, Serge E. Hallyn,
	Paul Moore, Stephen Smalley, Kees Cook, Prarit Bhargava,
	Richard Cochran, Thomas Gleixner, Ingo Molnar

Hey Thomas,
  Just wanted to send you my current queue for 4.7. Its fairly small.

The one unusal bit is the security_settime64() patch, which was
ok'ed to go in via the -tip tree by both Kees and Serge.

Let me know if you have any objections.

thanks
-john

Cc: Serge Hallyn <serge.hallyn@canonical.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Paul Moore <pmoore@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Kees Cook <keescook@chromium.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>

If you prefer to pull:

The following changes since commit 9735a22799b9214d17d3c231fe377fc852f042e9:

  Linux 4.6-rc2 (2016-04-03 09:09:40 -0500)

are available in the git repository at:

  https://git.linaro.org/people/john.stultz/linux.git fortglx/4.7/time

for you to fetch changes up to 86d3473224b004f920c107206d181d37db735145:

  time: Introduce do_sys_settimeofday64() (2016-04-22 11:49:04 -0700)

----------------------------------------------------------------
Baolin Wang (2):
      security: Introduce security_settime64()
      time: Introduce do_sys_settimeofday64()

David Lechner (1):
      clocksource: Add missing include of of.h.

 include/linux/clocksource.h |  1 +
 include/linux/lsm_hooks.h   |  5 +++--
 include/linux/security.h    | 20 +++++++++++++++++---
 include/linux/timekeeping.h | 17 +++++++++++++++--
 kernel/time/time.c          |  8 ++++----
 security/commoncap.c        |  2 +-
 security/security.c         |  2 +-
 7 files changed, 42 insertions(+), 13 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] clocksource: Add missing include of of.h.
  2016-04-22 19:03 [GIT PULL][PATCH 0/3] Few small timekeeping updates for 4.7 John Stultz
@ 2016-04-22 19:03 ` John Stultz
  2016-04-22 19:03 ` [PATCH 2/3] security: Introduce security_settime64() John Stultz
  2016-04-22 19:03 ` [PATCH 3/3] time: Introduce do_sys_settimeofday64() John Stultz
  2 siblings, 0 replies; 4+ messages in thread
From: John Stultz @ 2016-04-22 19:03 UTC (permalink / raw)
  To: lkml
  Cc: David Lechner, Prarit Bhargava, Richard Cochran, Thomas Gleixner,
	Ingo Molnar, John Stultz

From: David Lechner <david@lechnology.com>

This header uses OF_DELCARE_1 which is defined in linux/of.h.

This fixes getting unhelpful compiler error messages about missing ')'
before a string constant.

Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 include/linux/clocksource.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index a307bf6..44a1aff 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -15,6 +15,7 @@
 #include <linux/cache.h>
 #include <linux/timer.h>
 #include <linux/init.h>
+#include <linux/of.h>
 #include <asm/div64.h>
 #include <asm/io.h>
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] security: Introduce security_settime64()
  2016-04-22 19:03 [GIT PULL][PATCH 0/3] Few small timekeeping updates for 4.7 John Stultz
  2016-04-22 19:03 ` [PATCH 1/3] clocksource: Add missing include of of.h John Stultz
@ 2016-04-22 19:03 ` John Stultz
  2016-04-22 19:03 ` [PATCH 3/3] time: Introduce do_sys_settimeofday64() John Stultz
  2 siblings, 0 replies; 4+ messages in thread
From: John Stultz @ 2016-04-22 19:03 UTC (permalink / raw)
  To: lkml
  Cc: Baolin Wang, Serge Hallyn, James Morris, Serge E. Hallyn,
	Paul Moore, Stephen Smalley, Kees Cook, Prarit Bhargava,
	Richard Cochran, Thomas Gleixner, Ingo Molnar, John Stultz

From: Baolin Wang <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.

This patch then moves security_settime() to the header file as an
inline helper function so that existing users can be iteratively
converted.

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

Cc: Serge Hallyn <serge.hallyn@canonical.com>,
Cc: James Morris <james.l.morris@oracle.com>,
Cc: "Serge E. Hallyn" <serge@hallyn.com>,
Cc: Paul Moore <pmoore@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Kees Cook <keescook@chromium.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
[jstultz: Reworded commit message]
Signed-off-by: John Stultz <john.stultz@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 cdee11c..41ab466 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -1190,7 +1190,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.
@@ -1327,7 +1328,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 157f0cb..35ac8d9 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -71,7 +71,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);
@@ -208,7 +208,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);
@@ -462,10 +468,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 48071ed..2074bf6 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 3644b03..8c44a64 100644
--- a/security/security.c
+++ b/security/security.c
@@ -208,7 +208,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.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] time: Introduce do_sys_settimeofday64()
  2016-04-22 19:03 [GIT PULL][PATCH 0/3] Few small timekeeping updates for 4.7 John Stultz
  2016-04-22 19:03 ` [PATCH 1/3] clocksource: Add missing include of of.h John Stultz
  2016-04-22 19:03 ` [PATCH 2/3] security: Introduce security_settime64() John Stultz
@ 2016-04-22 19:03 ` John Stultz
  2 siblings, 0 replies; 4+ messages in thread
From: John Stultz @ 2016-04-22 19:03 UTC (permalink / raw)
  To: lkml
  Cc: Baolin Wang, Prarit Bhargava, Richard Cochran, Thomas Gleixner,
	Ingo Molnar, John Stultz

From: Baolin Wang <baolin.wang@linaro.org>

The do_sys_settimeofday() function uses a timespec, which is not year
2038 safe on 32bit systems.

Thus this patch introduces do_sys_settimeofday64(), which allows us to
transition users of do_sys_settimeofday() to using 64bit time types.

Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
[jstultz: Include errno-base.h to avoid build issue on some arches]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 include/linux/timekeeping.h | 17 +++++++++++++++--
 kernel/time/time.c          |  8 ++++----
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 96f37be..37dbacf 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -1,6 +1,8 @@
 #ifndef _LINUX_TIMEKEEPING_H
 #define _LINUX_TIMEKEEPING_H
 
+#include <asm-generic/errno-base.h>
+
 /* Included from linux/ktime.h */
 
 void timekeeping_init(void);
@@ -11,8 +13,19 @@ extern int timekeeping_suspended;
  */
 extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
-extern int do_sys_settimeofday(const struct timespec *tv,
-			       const struct timezone *tz);
+extern int do_sys_settimeofday64(const struct timespec64 *tv,
+				 const struct timezone *tz);
+static inline int do_sys_settimeofday(const struct timespec *tv,
+				      const struct timezone *tz)
+{
+	struct timespec64 ts64;
+
+	if (!tv)
+		return -EINVAL;
+
+	ts64 = timespec_to_timespec64(*tv);
+	return do_sys_settimeofday64(&ts64, tz);
+}
 
 /*
  * Kernel time accessors
diff --git a/kernel/time/time.c b/kernel/time/time.c
index be115b0..a4064b6 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -160,15 +160,15 @@ static inline void warp_clock(void)
  * various programs will get confused when the clock gets warped.
  */
 
-int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
+int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz)
 {
 	static int firsttime = 1;
 	int error = 0;
 
-	if (tv && !timespec_valid(tv))
+	if (tv && !timespec64_valid(tv))
 		return -EINVAL;
 
-	error = security_settime(tv, tz);
+	error = security_settime64(tv, tz);
 	if (error)
 		return error;
 
@@ -186,7 +186,7 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
 		}
 	}
 	if (tv)
-		return do_settimeofday(tv);
+		return do_settimeofday64(tv);
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-22 19:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-22 19:03 [GIT PULL][PATCH 0/3] Few small timekeeping updates for 4.7 John Stultz
2016-04-22 19:03 ` [PATCH 1/3] clocksource: Add missing include of of.h John Stultz
2016-04-22 19:03 ` [PATCH 2/3] security: Introduce security_settime64() John Stultz
2016-04-22 19:03 ` [PATCH 3/3] time: Introduce do_sys_settimeofday64() John Stultz

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®