Skip to contentSkip to conversation

timer updates for 3.4-rc

GIT PULL Thomas Gleixner 3 participants 5 messages Apr 6, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Linus,

please pull the latest timers-core-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-core-for-linus

Thanks,

tglx

------------------>
Martin Schwidefsky (1):
proc: stats: Use arch_idle_time for idle and iowait times if available

Sasikantha babu (1):
itimer: Schedule silent NULL pointer fixup in setitimer() for removal

Thomas Gleixner (1):
tick: Document TICK_ONESHOT config option

 Documentation/feature-removal-schedule.txt |    8 ++++++
 fs/proc/stat.c                             |   34 +++++++++++++++++++++++-----
 kernel/itimer.c                            |    5 +++-
 kernel/time/Kconfig                        |    4 +++
 4 files changed, 44 insertions(+), 7 deletions(-)
Documentation/feature-removal-schedule.txt +8 -0
index 0cad480..32fae81 100644
@@ -529,3 +529,11 @@ When:	3.5
 Why:	The old kmap_atomic() with two arguments is deprecated, we only
 	keep it for backward compatibility for few cycles and then drop it.
 Who:	Cong Wang <[email protected]>
+
+----------------------------
+
+What:	setitimer accepts user NULL pointer (value)
+When:	3.6
+Why:	setitimer is not returning -EFAULT if user pointer is NULL. This
+	violates the spec.
+Who:	Sasikantha Babu <[email protected]>
fs/proc/stat.c +28 -6
index 6a0c62d..64c3b31 100644
@@ -18,19 +18,39 @@
 #ifndef arch_irq_stat
 #define arch_irq_stat() 0
 #endif
-#ifndef arch_idle_time
-#define arch_idle_time(cpu) 0
-#endif
+
+#ifdef arch_idle_time
+
+static cputime64_t get_idle_time(int cpu)
+{
+	cputime64_t idle;
+
+	idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
+	if (cpu_online(cpu) && !nr_iowait_cpu(cpu))
+		idle += arch_idle_time(cpu);
+	return idle;
+}
+
+static cputime64_t get_iowait_time(int cpu)
+{
+	cputime64_t iowait;
+
+	iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
+	if (cpu_online(cpu) && nr_iowait_cpu(cpu))
+		iowait += arch_idle_time(cpu);
+	return iowait;
+}
+
+#else
 
 static u64 get_idle_time(int cpu)
 {
 	u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL);
 
-	if (idle_time == -1ULL) {
+	if (idle_time == -1ULL)
 		/* !NO_HZ so we can rely on cpustat.idle */
 		idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
-		idle += arch_idle_time(cpu);
-	} else
+	else
 		idle = usecs_to_cputime64(idle_time);
 
 	return idle;
@@ -49,6 +69,8 @@ static u64 get_iowait_time(int cpu)
 	return iowait;
 }
 
+#endif
+
 static int show_stat(struct seq_file *p, void *v)
 {
 	int i, j;
kernel/itimer.c +4 -1
index 22000c3..c70369a 100644
@@ -284,8 +284,11 @@ SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
 	if (value) {
 		if(copy_from_user(&set_buffer, value, sizeof(set_buffer)))
 			return -EFAULT;
-	} else
+	} else {
 		memset((char *) &set_buffer, 0, sizeof(set_buffer));
+		WARN_ONCE(1, "setitimer: new_value pointer is NULL."
+			  " Misfeature support will be removed\n");
+	}
 
 	error = do_setitimer(which, &set_buffer, ovalue ? &get_buffer : NULL);
 	if (error || !ovalue)
kernel/time/Kconfig +4 -0
index 2cf9cc7..a20dc8a 100644
@@ -1,6 +1,10 @@
 #
 # Timer subsystem related configuration options
 #
+
+# Core internal switch. Selected by NO_HZ / HIGH_RES_TIMERS. This is
+# only related to the tick functionality. Oneshot clockevent devices
+# are supported independ of this.
 config TICK_ONESHOT
 	bool
 
#1 lore raw
Quoted 7 lines · Thomas Gleixner
kernel/itimer.c +0 -0
index 22000c3..c70369a 100644
@@ -284,8 +284,11 @@ SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
 	if (value) {
 		if(copy_from_user(&set_buffer, value, sizeof(set_buffer)))

kernel/itimer.c SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, · line 294

Quoted 10 lines
kernel/itimer.c +4 -1
 			return -EFAULT;
-	} else
+	} else {
 		memset((char *) &set_buffer, 0, sizeof(set_buffer));
+		WARN_ONCE(1, "setitimer: new_value pointer is NULL."
+			  " Misfeature support will be removed\n");
+	}
 
 	error = do_setitimer(which, &set_buffer, ovalue ? &get_buffer : NULL);
 	if (error || !ovalue)

When I tried doing this for the deprecated /proc/pid/oom_adj there was a complaint that WARN_ONCE() screws up log parsing scripts that think there is a kernel issue so I had to change it to printk_once() and include get_task_comm(current) and current->pid. See
http://lkml.indiana.edu/hypermail/linux/kernel/1108.0/00446.html

#2 lore raw
Quoted 17 lines · David Rientjes
Quoted 15 lines · Thomas Gleixner
kernel/itimer.c +4 -1
index 22000c3..c70369a 100644
@@ -284,8 +284,11 @@ SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
 	if (value) {
 		if(copy_from_user(&set_buffer, value, sizeof(set_buffer)))
 			return -EFAULT;
-	} else
+	} else {
 		memset((char *) &set_buffer, 0, sizeof(set_buffer));
+		WARN_ONCE(1, "setitimer: new_value pointer is NULL."
+			  " Misfeature support will be removed\n");
+	}
 
Quoted 8 lines

kernel/itimer.c SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, · line 294

Quoted 2 lines
kernel/itimer.c +0 -0
 	error = do_setitimer(which, &set_buffer, ovalue ? &get_buffer : NULL);
 	if (error || !ovalue)

When I tried doing this for the deprecated /proc/pid/oom_adj there was a complaint that WARN_ONCE() screws up log parsing scripts that think there is a kernel issue so I had to change it to printk_once() and include get_task_comm(current) and current->pid. See
http://lkml.indiana.edu/hypermail/linux/kernel/1108.0/00446.html

Bah.

#3 lore raw
Quoted 28 lines · On Sat, 7 Apr 2012 01:48:51 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 17 lines · David Rientjes
Quoted 15 lines · Thomas Gleixner
kernel/itimer.c +4 -1
index 22000c3..c70369a 100644
@@ -284,8 +284,11 @@ SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
 	if (value) {
 		if(copy_from_user(&set_buffer, value, sizeof(set_buffer)))
 			return -EFAULT;
-	} else
+	} else {
 		memset((char *) &set_buffer, 0, sizeof(set_buffer));
+		WARN_ONCE(1, "setitimer: new_value pointer is NULL."
+			  " Misfeature support will be removed\n");
+	}
 
Quoted 8 lines

kernel/itimer.c SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, · line 294

Quoted 2 lines
kernel/itimer.c +0 -0
 	error = do_setitimer(which, &set_buffer, ovalue ? &get_buffer : NULL);
 	if (error || !ovalue)

When I tried doing this for the deprecated /proc/pid/oom_adj there was a complaint that WARN_ONCE() screws up log parsing scripts that think there is a kernel issue so I had to change it to printk_once() and include get_task_comm(current) and current->pid. See
http://lkml.indiana.edu/hypermail/linux/kernel/1108.0/00446.html

Quoted 1 line

Bah.

It gives you a chance to remove the unneeded cast from the memset call ;)

#4 lore raw
Quoted 31 lines · Andrew Morton
Quoted 28 lines · On Sat, 7 Apr 2012 01:48:51 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 25 lines · David Rientjes
Quoted 7 lines · Thomas Gleixner
kernel/itimer.c +0 -0
index 22000c3..c70369a 100644
@@ -284,8 +284,11 @@ SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
 	if (value) {
 		if(copy_from_user(&set_buffer, value, sizeof(set_buffer)))

kernel/itimer.c SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, · line 294

Quoted 10 lines
kernel/itimer.c +4 -1
 			return -EFAULT;
-	} else
+	} else {
 		memset((char *) &set_buffer, 0, sizeof(set_buffer));
+		WARN_ONCE(1, "setitimer: new_value pointer is NULL."
+			  " Misfeature support will be removed\n");
+	}
 
 	error = do_setitimer(which, &set_buffer, ovalue ? &get_buffer : NULL);
 	if (error || !ovalue)

When I tried doing this for the deprecated /proc/pid/oom_adj there was a complaint that WARN_ONCE() screws up log parsing scripts that think there is a kernel issue so I had to change it to printk_once() and include get_task_comm(current) and current->pid. See
http://lkml.indiana.edu/hypermail/linux/kernel/1108.0/00446.html

Quoted 3 lines
Quoted 1 line

Bah.

It gives you a chance to remove the unneeded cast from the memset call ;)

Will do :)