mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][RFC] Remove CLONE_FILES from init kernel thread creation
@ 2003-11-17 20:00 James Morris
  2003-11-17 20:49 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: James Morris @ 2003-11-17 20:00 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Stephen Smalley, Alexander Viro, linux-kernel, Russell Coker

The patch below removes the CLONE_FILES flag from the kernel_thread() call
which starts init.

This is to prevent other kernel threads from sharing file descriptors 
opened by init (try 'lsof /dev/initctl' on a 2.6 system :-).

The reason this patch is being proposed is so that usermode helper apps
launched via kernel threads (e.g. modprobe, hotplug) do not then inherit
any such file descriptors.  This is not a problem in itself so far (other
than being messy), but it is a problem for SELinux, which will otherwise
need to grant access to /dev/initctl by modprobe and hotplug, a somewhat
undesirable scenario.

As far as I can tell, there is no reason why init needs to be spawned with
CLONE_FILES.  Please let me know if there are any objections to the
change, which I would like to propose for 2.6.0+ as a cleanup.


- James
-- 
James Morris
<jmorris@redhat.com>

diff -urN -X dontdiff linux-2.6.0-test9-mm3.orig/init/main.c linux-2.6.0-test9-mm3.w1/init/main.c
--- linux-2.6.0-test9-mm3.orig/init/main.c	2003-11-17 10:30:41.000000000 -0500
+++ linux-2.6.0-test9-mm3.w1/init/main.c	2003-11-17 14:27:07.000000000 -0500
@@ -375,7 +375,7 @@
 
 static void rest_init(void)
 {
-	kernel_thread(init, NULL, CLONE_KERNEL);
+	kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND);
 	unlock_kernel();
  	cpu_idle();
 } 


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

end of thread, other threads:[~2003-11-17 21:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-17 20:00 [PATCH][RFC] Remove CLONE_FILES from init kernel thread creation James Morris
2003-11-17 20:49 ` Andrew Morton
2003-11-17 21:18   ` James Morris
2003-11-17 21:25   ` Chris Wright

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®