LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Éric Piel" <Eric.Piel@tremplin-utc.net>
To: len.brown@intel.com
Cc: Sergey Vlasov <vsu@altlinux.ru>, Christoph Hellwig <hch@lst.de>,
	dsdt@gaugusch.at, linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@osdl.org>,
	trenn@suse.de
Subject: [PATCH] Allow populate_rootfs() to be called early (resent, with sob)
Date: Sat, 23 Feb 2008 20:40:19 +0100	[thread overview]
Message-ID: <47C076A3.7060508@tremplin-utc.net> (raw)
In-Reply-To: <47BDCACC.2030302@tremplin-utc.net>

21/02/08 20:02, Éric Piel wrote/a écrit:
> 12/02/08 00:41, Éric Piel wrote/a écrit:
>> 11/02/08 14:47, Sergey Vlasov wrote/a écrit:
>>>> Would that seem an acceptable solution? Or what other way exists?
>>> Disabling call_usermodehelper() until all core initializers had
>>> completed would fix the problem too; will such change be acceptable?
>> Yes, that looks like a nice way. Actually, I discovered that for suspend
>> and resume, there is exactly the same need, and a special flag is
>> already available: usermodehelper_disabled.
>>
>> So here is a proposal patch leveraging this flag. The rootfs is
>> populated early but user land execution is forbidden until we reach a
>> sufficient initialization state.  I think it even has the bonus of
>> doing _explicitly_ what we want (avoid user land execution).
>>
>> Does this look good? (if so, I can probably make it even cleaner by
>> renaming/removing the rootfs_initcall level)
> 
> It's been a week and no one has screamed, so I guess the idea looks fine
> to everyone :-) 
> 
> Here is a boot tested patch for integration. In addition to the previous
> version, it removes also rootfs_initcall(), and uses fs_initcall_sync().
> There should be absolutely no difference in behaviour as there was no
> user of fs_initcall_sync() in the kernel.
> 
> I'm not sure what should be the best tree to go through. Maybe the ACPI
> tree, as all this is needed for CONFIG_ACPI_CUSTOM_DSDT_INITRD...
> 
Len has reminded me that I have to add a s-o-b line to my patches :-)
Here is a corrected version (against 2.6.25-rc2).

Eric 
--

For ACPI table override, we need the rootfs available early. So this patch
* removes the kludge calling populate_rootfs early _sometimes_
* leverage the usermodehelper_disabled variable to prevent too early userspace
  execution would could lead to oops if the kernel subsystem are not yet initialised

Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net>
---
 include/asm-generic/vmlinux.lds.h |    1 -
 include/linux/init.h              |    1 -
 init/initramfs.c                  |    7 -------
 init/main.c                       |    4 ----
 kernel/kmod.c                     |   15 +++++++++++----
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index f784d2f..19ddbae 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -335,7 +335,6 @@
   	*(.initcall4s.init)						\
   	*(.initcall5.init)						\
   	*(.initcall5s.init)						\
-	*(.initcallrootfs.init)						\
   	*(.initcall6.init)						\
   	*(.initcall6s.init)						\
   	*(.initcall7.init)						\
diff --git a/include/linux/init.h b/include/linux/init.h
index a404a00..ecd05cd 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -183,7 +183,6 @@ void prepare_namespace(void);
 #define subsys_initcall_sync(fn)	__define_initcall("4s",fn,4s)
 #define fs_initcall(fn)			__define_initcall("5",fn,5)
 #define fs_initcall_sync(fn)		__define_initcall("5s",fn,5s)
-#define rootfs_initcall(fn)		__define_initcall("rootfs",fn,rootfs)
 #define device_initcall(fn)		__define_initcall("6",fn,6)
 #define device_initcall_sync(fn)	__define_initcall("6s",fn,6s)
 #define late_initcall(fn)		__define_initcall("7",fn,7)
diff --git a/init/initramfs.c b/init/initramfs.c
index c0b1e05..b74e845 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -577,10 +577,3 @@ int __init populate_rootfs(void)
 	}
 	return 0;
 }
-#ifndef CONFIG_ACPI_CUSTOM_DSDT_INITRD
-/*
- * if this option is enabled, populate_rootfs() is called _earlier_ in the
- * boot sequence. This insures that the ACPI initialisation can find the file.
- */
-rootfs_initcall(populate_rootfs);
-#endif
diff --git a/init/main.c b/init/main.c
index 8b19820..703ded0 100644
--- a/init/main.c
+++ b/init/main.c
@@ -102,11 +102,7 @@ static inline void mark_rodata_ro(void) { }
 extern void tc_init(void);
 #endif
 
-#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
 extern int populate_rootfs(void);
-#else
-static inline void populate_rootfs(void) {}
-#endif
 
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);
diff --git a/kernel/kmod.c b/kernel/kmod.c
index bb7df2a..112b261 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -267,14 +267,23 @@ static void __call_usermodehelper(struct work_struct *work)
 	}
 }
 
-#ifdef CONFIG_PM
 /*
  * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
  * (used for preventing user land processes from being created after the user
  * land has been frozen during a system-wide hibernation or suspend operation).
+ * It is also used at boot up to avoid calling a user land process before all
+ * the kernel subsystems are initialised (such as pipefs).
  */
-static int usermodehelper_disabled;
+static int usermodehelper_disabled = 1;
 
+static int __init enable_usermodehelper(void)
+{
+	usermodehelper_disabled = 0;
+	return 0;
+}
+fs_initcall_sync(enable_usermodehelper);
+
+#ifdef CONFIG_PM
 /* Number of helpers running */
 static atomic_t running_helpers = ATOMIC_INIT(0);
 
@@ -342,8 +351,6 @@ static void register_pm_notifier_callback(void)
 	pm_notifier(usermodehelper_pm_callback, 0);
 }
 #else /* CONFIG_PM */
-#define usermodehelper_disabled	0
-
 static inline void helper_lock(void) {}
 static inline void helper_unlock(void) {}
 static inline void register_pm_notifier_callback(void) {}


  parent reply	other threads:[~2008-02-23 19:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10  7:12 acpi dsts loading and populate_rootfs Christoph Hellwig
2008-02-10  7:14 ` Christoph Hellwig
2008-02-10 11:58   ` Eric Piel
2008-02-11 13:47     ` Sergey Vlasov
2008-02-11 23:41       ` Éric Piel
2008-02-21 19:02         ` [PATCH] Allow populate_rootfs() to be called early (was: acpi dsts loading and populate_rootfs) Éric Piel
2008-02-21 19:04           ` Christoph Hellwig
2008-02-21 21:27             ` [PATCH] Allow populate_rootfs() to be called early Éric Piel
2008-02-23 19:40           ` Éric Piel [this message]
2008-02-12  5:37     ` acpi dsts loading and populate_rootfs Christoph Hellwig
2008-02-21 18:46       ` Éric Piel
2008-02-22  8:51         ` Thomas Renninger
2008-02-22  9:05           ` Thomas Renninger
2008-02-22  9:53           ` Andi Kleen
2008-02-23 19:34         ` [PATCH] Use userland-like functions for reading the ACPI table Éric Piel
2008-02-23 20:45           ` Linus Torvalds
2008-02-24  1:31             ` Christoph Hellwig
2008-02-24 19:02               ` Éric Piel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47C076A3.7060508@tremplin-utc.net \
    --to=eric.piel@tremplin-utc.net \
    --cc=dsdt@gaugusch.at \
    --cc=hch@lst.de \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=trenn@suse.de \
    --cc=vsu@altlinux.ru \
    --subject='Re: [PATCH] Allow populate_rootfs() to be called early (resent, with sob)' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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