Few small timekeeping updates for 4.7
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
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(-)
Signature · 1 line
1.9.1
PATCH 2/3 security: Introduce security_settime64()
From: Baolin Wang <[email protected]>
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.
--- 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(-)
include/linux/lsm_hooks.h +3 -2
@@ -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);
include/linux/security.h +17 -3
@@ -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)
security/commoncap.c +1 -1
@@ -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 ;
security/security.c +1 -1
@@ -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); }
Signature · 1 line
1.9.1
PATCH 3/3 time: Introduce do_sys_settimeofday64()
In reply to John StultzFrom: Baolin Wang <[email protected]>
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.
--- include/linux/timekeeping.h | 17 +++++++++++++++-- kernel/time/time.c | 8 ++++---- 2 files changed, 19 insertions(+), 6 deletions(-)
include/linux/timekeeping.h +15 -2
@@ -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
kernel/time/time.c +4 -4
@@ -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 ; }
Signature · 1 line
1.9.1
PATCH 1/3 clocksource: Add missing include of of.h.
In reply to John StultzFrom: David Lechner <[email protected]>
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.
--- include/linux/clocksource.h | 1 + 1 file changed, 1 insertion(+)
include/linux/clocksource.h +1 -0
@@ -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>
Signature · 1 line
1.9.1