LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] reject taskset for kernel threads
@ 2007-03-21 20:53 Olaf Hering
  2007-03-21 21:50 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2007-03-21 20:53 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel


Do not allow taskset for kernel threads.
These commands will cause oopses due to stack corruption:

ls /proc/*/task | grep -v ^/ | xargs echo | xargs -n1 taskset -pc 2-9
taskset -pc 1 $$
taskset -pc 0 $((pidof john))

Possible fix in userland:

for i in ` ls /proc/*/task | grep -v ^/ `
do
	e=/proc/*/task/$i/exe
	if test -e $e
	then
		taskset -pc 2-9	$i
	fi
done


Signed-off-by: Olaf Hering <olaf@aepfle.de>

---
 kernel/sched.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-2.6.20/kernel/sched.c
===================================================================
--- linux-2.6.20.orig/kernel/sched.c
+++ linux-2.6.20/kernel/sched.c
@@ -4310,6 +4310,8 @@ long sched_setaffinity(pid_t pid, cpumas
 	read_unlock(&tasklist_lock);
 
 	retval = -EPERM;
+	if (!p->mm)
+		goto out_unlock;
 	if ((current->euid != p->euid) && (current->euid != p->uid) &&
 			!capable(CAP_SYS_NICE))
 		goto out_unlock;

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

end of thread, other threads:[~2007-03-22 23:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21 20:53 [PATCH] reject taskset for kernel threads Olaf Hering
2007-03-21 21:50 ` Andrew Morton
2007-03-22 21:28   ` Olaf Hering
2007-03-22 23:01   ` Olaf Hering

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).