Skip to contentSkip to conversation

module and parameter patches

GIT PULL Rusty Russell 1 participant 1 message Mar 28, 2009

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

The following changes since commit 5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a:
Linus Torvalds (1):

        Merge git://git.kernel.org/.../davem/net-2.6                                     

are available in the git repository at:

ssh://master.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param.git master

Américo Wang (1):
kernel/module.c: fix an unused goto label

Anders Kaseorg (1):
Ksplice: Add functions for walking kallsyms symbols

Arjan van de Ven (3):
module: create a request_module_nowait()
use the new request_module_nowait() in the hid driver use the new request_module_nowait() in drivers/media

Rusty Russell (7):
param: fix charp parameters set via sysfs
module: __module_address
module: remove module_text_address()
module: clarify the force-loading taint message.
module: remove the SHF_ALLOC flag on the __versions section.
module: include other structures in module version check
module: don't use stop_machine on module load

Tim Abbott (2):
module: Make find_symbol return a struct kernel_symbol
module: Export symbols needed for Ksplice

 drivers/hid/hid-core.c                     |   19 +--
 drivers/media/video/bt8xx/bttv-driver.c    |    8 +-
 drivers/media/video/bt8xx/bttvp.h          |    3 -
 drivers/media/video/cx88/cx88-mpeg.c       |   14 +--
 drivers/media/video/cx88/cx88.h            |    1 -
 drivers/media/video/em28xx/em28xx-cards.c  |   17 +--
 drivers/media/video/em28xx/em28xx.h        |    2 -
 drivers/media/video/saa7134/saa7134-core.c |   19 +--
 drivers/media/video/saa7134/saa7134.h      |    2 -
 drivers/mtd/nand/nand_base.c               |    4 +-
 include/linux/kallsyms.h                   |   15 ++
 include/linux/kmod.h                       |   11 +-
 include/linux/module.h                     |   63 ++++++-
 include/linux/moduleparam.h                |   10 +
 kernel/extable.c                           |    6 +-
 kernel/kallsyms.c                          |   19 ++
 kernel/kmod.c                              |   10 +-
 kernel/module.c                            |  263 +++++++++++++++++-----------
 kernel/params.c                            |   26 +++-
 scripts/mod/modpost.c                      |    4 +-
 20 files changed, 317 insertions(+), 199 deletions(-)

commit 73d3e96bb9b6530e394630c1656715e5f67f3d1c

Author: Rusty Russell <[email protected]>
Date:   Sat Mar 28 23:12:50 2009 -0600

param: fix charp parameters set via sysfs

Impact: fix crash on reading from /sys/module/.../ieee80211_default_rc_algo

The module_param type "charp" simply sets a char * pointer in the module to the parameter in the commandline string: this is why we keep the (mangled) module command line around. But when set via sysfs (as about 11 charp parameters can be) this memory is freed on the way out of the write(). Future reads hit random mem.

So we kstrdup instead: we have to check we're not in early commandline parsing, and we have to note when we've used it so we can reliably kfree the parameter when it's next overwritten, and also on module unload.

(Thanks to Randy Dunlap for CONFIG_SYSFS=n fixes)

 include/linux/module.h      |    4 ++++
 include/linux/moduleparam.h |   10 ++++++++++
 kernel/module.c             |   14 ++++++++------
 kernel/params.c             |   26 +++++++++++++++++++++++++-
 4 files changed, 47 insertions(+), 7 deletions(-)

commit 5421acc2cb93aaa9c8f47ea31e4a2bba7c730ff2

Author: Américo Wang <[email protected]>
Date:   Wed Mar 25 00:07:19 2009 +0800

kernel/module.c: fix an unused goto label

Impact: cleanup

Label 'free_init' is only used when defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP), so move it inside to shut up gcc.

 kernel/module.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

commit ebb7dbcaa0bd58b3f10cb03693966a82d1cace39

Author: Tim Abbott <[email protected]>
Date:   Fri Dec 5 19:03:56 2008 -0500

module: Make find_symbol return a struct kernel_symbol

Impact: Cleanup, internal API change

Ksplice needs access to the kernel_symbol structure in order to support modifications to the exported symbol table.

 kernel/module.c |   75 +++++++++++++++++++++++++++----------------------------
 1 files changed, 37 insertions(+), 38 deletions(-)

commit ebb32e28691e27d13584105306ffea6fca1b6284

Author: Rusty Russell <[email protected]>
Date:   Sat Mar 28 23:12:51 2009 -0600

module: __module_address

Impact: New API, cleanup

ksplice wants to know the bounds of a module, not just the module text.

It makes sense to have __module_address. We then implement is_module_address and __module_text_address in terms of this (and change is_module_text_address() to bool while we're at it).

Also, add proper kerneldoc for them all.

Cc Anders Kaseorg <[email protected]>
Cc Jeff Arnold <[email protected]>
Cc Tim Abbott <[email protected]>
 include/linux/module.h |   20 +++++++++---
 kernel/module.c        |   76 ++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 73 insertions(+), 23 deletions(-)

commit feef3a4101a239e71d91eb53446588a4a6426ac3

Author: Rusty Russell <[email protected]>
Date:   Sat Mar 28 23:12:52 2009 -0600

module: remove module_text_address()

Impact: Replace and remove risky (non-EXPORTed) API

module_text_address() returns a pointer to the module, which given locking improvements in module.c, is useless except to test for NULL:

1) If the module can't go away, use __module_text_address.
2) Otherwise, just use is_module_text_address().

 drivers/mtd/nand/nand_base.c |    4 ++--
 include/linux/module.h       |    7 -------
 kernel/extable.c             |    6 +++---
 kernel/module.c              |   17 ++++-------------
 4 files changed, 9 insertions(+), 25 deletions(-)

commit 553d052231210f4b4f328708096dd4d1a5b051a6

Author: Anders Kaseorg <[email protected]>
Date:   Fri Dec 5 19:03:58 2008 -0500

Ksplice: Add functions for walking kallsyms symbols

Impact: New API

kallsyms_lookup_name only returns the first match that it finds. Ksplice needs information about all symbols with a given name in order to correctly resolve local symbols.

kallsyms_on_each_symbol provides a generic mechanism for iterating over the kallsyms table.

 include/linux/kallsyms.h |   15 +++++++++++++++
 include/linux/module.h   |   12 ++++++++++++
 kernel/kallsyms.c        |   19 +++++++++++++++++++
 kernel/module.c          |   19 +++++++++++++++++++
 4 files changed, 65 insertions(+), 0 deletions(-)

commit dd3a6593757881ae9d0f3c79621bd78d3b549f2b

Author: Tim Abbott <[email protected]>
Date:   Fri Dec 5 19:03:59 2008 -0500

module: Export symbols needed for Ksplice

Impact: Expose some module.c symbols

Ksplice uses several functions from module.c in order to resolve symbols and implement dependency handling. Calling these functions requires holding module_mutex, so it is exported.

(This is just the module part of a bigger add-exports patch from Tim).

 include/linux/module.h |   28 ++++++++++++++++++++++++++++
 kernel/module.c        |   43 +++++++++++++++++++------------------------
 2 files changed, 47 insertions(+), 24 deletions(-)

commit cabafb1afbdffc6f86a77e79ca52791be4820b00

Author: Rusty Russell <[email protected]>
Date:   Sat Mar 28 23:12:55 2009 -0600

module: clarify the force-loading taint message.

Impact: Message cleanup

Two of three callers of try_to_force_load() are not because of a missing version, so change the messages:

Old:
<modname>: no version for "magic" found: kernel tainted.
New:
<modname>: bad vermagic: kernel tainted.

Old:
<modname>: no version for "nocrc" found: kernel tainted.
New:
<modname>: no versions for exported symbols: kernel tainted.

Old:
<modname>: no version for "<symname>" found: kernel tainted.
New:
<modname>: <symname>: kernel tainted.

 kernel/module.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

commit 8a50039ec1d358a34474d86f80323cbb0c9e8409

Author: Rusty Russell <[email protected]>
Date:   Sat Mar 28 23:12:56 2009 -0600

module: remove the SHF_ALLOC flag on the __versions section.

Impact: reduce kernel memory usage

This patch just takes off the SHF_ALLOC flag on __versions so we don't keep them around after module load.

This saves about 7% of module memory if CONFIG_MODVERSIONS=y.

 kernel/module.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

commit f25d049563820ef472732511d20cdf684632c574

Author: Rusty Russell <[email protected]>
Date:   Sat Mar 28 23:12:57 2009 -0600

module: include other structures in module version check

With CONFIG_MODVERSIONS, we version 'struct module' using a dummy export, but other things matter too:

1) 'struct modversion_info' determines the layout of the __versions section,
2) 'struct kernel_param' determines the layout of the __params section,
3) 'struct kernel_symbol' determines __ksymtab*.
4) 'struct marker' determines __markers.
5) 'struct tracepoint' determines __tracepoints.

So we rename 'struct_module' to 'module_layout' and include these in the signature. Now it's general we can add others later on without confusion.

 kernel/module.c       |   18 +++++++++++++-----
 scripts/mod/modpost.c |    4 ++--
 2 files changed, 15 insertions(+), 7 deletions(-)

commit ff5b866b7ba3a8aebd8584236ac52a240dc58b57

Author: Arjan van de Ven <[email protected]>
Date:   Sun Feb 8 10:42:01 2009 -0800

module: create a request_module_nowait()

There seems to be a common pattern in the kernel where drivers want to call request_module() from inside a module_init() function. Currently this would deadlock.

As a result, several drivers go through hoops like scheduling things via kevent, or creating custom work queues (because kevent can deadlock on them).

This patch changes this to use a request_module_nowait() function macro instead, which just fires the modprobe off but doesn't wait for it, and thus avoids the original deadlock entirely.

On my laptop this already results in one less kernel thread running..

(Includes Jiri's patch to use enum umh_wait)

 include/linux/kmod.h |   11 ++++++++---
 kernel/kmod.c        |   10 ++++++----
 2 files changed, 14 insertions(+), 7 deletions(-)

commit 8231f6b16a8f515792a68f6a4ee22a6945285e80

Author: Arjan van de Ven <[email protected]>
Date:   Sun Feb 8 10:42:40 2009 -0800

use the new request_module_nowait() in the hid driver

From b8c36ec88e272ba2e755e6104579f1e751ee81f8 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Sun, 1 Feb 2009 12:02:39 -0800
Subject: [PATCH] use the new request_module_nowait() in the hid driver

Now that there is a request_module_nowait(), use it in the hid driver. This gets rid of a kernel thread, and also greatly simplifies the code...

 drivers/hid/hid-core.c |   19 +------------------
 1 files changed, 1 insertions(+), 18 deletions(-)

commit b34e2115ad122dd569e9fa51b8aceb089917d3e4

Author: Arjan van de Ven <[email protected]>
Date:   Sat Mar 28 23:13:02 2009 -0600

use the new request_module_nowait() in drivers/media

Several drivers/media/video drivers use keventd to load modules to avoid the "load a module from the module init code" deadlock.

Now that we have request_module_nowait() this can be simplified greatly.

 drivers/media/video/bt8xx/bttv-driver.c    |    8 +-------
 drivers/media/video/bt8xx/bttvp.h          |    3 ---
 drivers/media/video/cx88/cx88-mpeg.c       |   14 +++-----------
 drivers/media/video/cx88/cx88.h            |    1 -
 drivers/media/video/em28xx/em28xx-cards.c  |   17 ++++-------------
 drivers/media/video/em28xx/em28xx.h        |    2 --
 drivers/media/video/saa7134/saa7134-core.c |   19 ++++++-------------
 drivers/media/video/saa7134/saa7134.h      |    2 --
 8 files changed, 14 insertions(+), 52 deletions(-)

commit 036b9c665720c033fb09d07ca93282203540a568

Author: Rusty Russell <[email protected]>
Date:   Sat Mar 28 23:13:02 2009 -0600

module: don't use stop_machine on module load

Kay Sievers <[email protected]> discovered that boot times are slowed by about half a second because all the stop_machine_create() calls, and he only probes about 40 modules (I have 125 loaded on this laptop).

We only do stop_machine_create() so we can unlink the module if something goes wrong, but it's overkill (and buggy anyway: if stop_machine_create() fails we still call stop_machine_destroy()).

Since we are only protecting against kallsyms (esp. oops) walking the list, synchronize_sched() is sufficient (synchronize_rcu() is probably sufficient, but we're not in a hurry).

Kay says of this patch:
... no module takes more than 40 millisecs to link now, most of them are between 3 and 8 millisecs.

That looks very different to the numbers without this patch and the otherwise same setup, where we get heavy noise in the traces and many delays of up to 200 millisecs until linking, most of them taking 30+ millisecs.

 kernel/module.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)
drivers/hid/hid-core.c +1 -18
index 1cc9674..483fa0d 100644
@@ -1813,15 +1813,6 @@ void hid_unregister_driver(struct hid_driver *hdrv)
 }
 EXPORT_SYMBOL_GPL(hid_unregister_driver);
 
-#ifdef CONFIG_HID_COMPAT
-static void hid_compat_load(struct work_struct *ws)
-{
-	request_module("hid-dummy");
-}
-static DECLARE_WORK(hid_compat_work, hid_compat_load);
-static struct workqueue_struct *hid_compat_wq;
-#endif
-
 static int __init hid_init(void)
 {
 	int ret;
@@ -1837,12 +1828,7 @@ static int __init hid_init(void)
 		goto err_bus;
 
 #ifdef CONFIG_HID_COMPAT
-	hid_compat_wq = create_singlethread_workqueue("hid_compat");
-	if (!hid_compat_wq) {
-		hidraw_exit();
-		goto err;
-	}
-	queue_work(hid_compat_wq, &hid_compat_work);
+	request_module_nowait("hid-dummy");
 #endif
 
 	return 0;
@@ -1854,9 +1840,6 @@ err:
 
 static void __exit hid_exit(void)
 {
-#ifdef CONFIG_HID_COMPAT
-	destroy_workqueue(hid_compat_wq);
-#endif
 	hidraw_exit();
 	bus_unregister(&hid_bus_type);
 }
drivers/media/video/bt8xx/bttv-driver.c +1 -7
index c71f394..7b23d87 100644
@@ -175,15 +175,9 @@ static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
 /* ----------------------------------------------------------------------- */
 /* dvb auto-load setup                                                     */
 #if defined(CONFIG_MODULES) && defined(MODULE)
-static void request_module_async(struct work_struct *work)
-{
-	request_module("dvb-bt8xx");
-}
-
 static void request_modules(struct bttv *dev)
 {
-	INIT_WORK(&dev->request_module_wk, request_module_async);
-	schedule_work(&dev->request_module_wk);
+	request_module_nowait("dvb-bt8xx");
 }
 #else
 #define request_modules(dev)
drivers/media/video/bt8xx/bttvp.h +0 -3
index 199a4d2..767d483 100644
@@ -439,9 +439,6 @@ struct bttv {
 	unsigned int users;
 	struct bttv_fh init;
 
-	/* used to make dvb-bt8xx autoloadable */
-	struct work_struct request_module_wk;
-
 	/* Default (0) and current (1) video capturing and overlay
 	   cropping parameters in bttv_tvnorm.cropcap units. Protected
 	   by bttv.lock. */
drivers/media/video/cx88/cx88-mpeg.c +3 -11
index b295b76..683d6cc 100644
@@ -50,20 +50,12 @@ MODULE_PARM_DESC(debug,"enable debug messages [mpeg]");
 	printk(KERN_DEBUG "%s/2-mpeg: " fmt, core->name, ## arg)
 
 #if defined(CONFIG_MODULES) && defined(MODULE)
-static void request_module_async(struct work_struct *work)
+static void request_modules(struct cx8802_dev *dev)
 {
-	struct cx8802_dev *dev=container_of(work, struct cx8802_dev, request_module_wk);
-
 	if (dev->core->board.mpeg & CX88_MPEG_DVB)
-		request_module("cx88-dvb");
+		request_module_nowait("cx88-dvb");
 	if (dev->core->board.mpeg & CX88_MPEG_BLACKBIRD)
-		request_module("cx88-blackbird");
-}
-
-static void request_modules(struct cx8802_dev *dev)
-{
-	INIT_WORK(&dev->request_module_wk, request_module_async);
-	schedule_work(&dev->request_module_wk);
+		request_module_nowait("cx88-blackbird");
 }
 #else
 #define request_modules(dev)
drivers/media/video/cx88/cx88.h +0 -1
index 6025fdd..242cd62 100644
@@ -510,7 +510,6 @@ struct cx8802_dev {
 
 	/* List of attached drivers */
 	struct list_head	   drvlist;
-	struct work_struct	   request_module_wk;
 };
 
 /* ----------------------------------------------------------- */
drivers/media/video/em28xx/em28xx-cards.c +4 -13
index 3b3ca3f..dc00102 100644
@@ -1809,24 +1809,15 @@ void em28xx_card_setup(struct em28xx *dev)
 
 
 #if defined(CONFIG_MODULES) && defined(MODULE)
-static void request_module_async(struct work_struct *work)
+static void request_modules(struct em28xx *dev)
 {
-	struct em28xx *dev = container_of(work,
-			     struct em28xx, request_module_wk);
-
 	if (dev->has_audio_class)
-		request_module("snd-usb-audio");
+		request_module_nowait("snd-usb-audio");
 	else if (dev->has_alsa_audio)
-		request_module("em28xx-alsa");
+		request_module_nowait("em28xx-alsa");
 
 	if (dev->board.has_dvb)
-		request_module("em28xx-dvb");
-}
-
-static void request_modules(struct em28xx *dev)
-{
-	INIT_WORK(&dev->request_module_wk, request_module_async);
-	schedule_work(&dev->request_module_wk);
+		request_module_nowait("em28xx-dvb");
 }
 #else
 #define request_modules(dev)
drivers/media/video/em28xx/em28xx.h +0 -2
index dd2cd36..164a543 100644
@@ -498,8 +498,6 @@ struct em28xx {
 	enum em28xx_dev_state state;
 	enum em28xx_io_method io;
 
-	struct work_struct         request_module_wk;
-
 	/* locks */
 	struct mutex lock;
 	struct mutex ctrl_urb_lock;	/* protects urb_buf */
drivers/media/video/saa7134/saa7134-core.c +6 -13
index 99221d7..a4bc939 100644
@@ -149,23 +149,16 @@ void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)
 /* delayed request_module                                      */
 
 #if defined(CONFIG_MODULES) && defined(MODULE)
-
-static void request_module_async(struct work_struct *work){
-	struct saa7134_dev* dev = container_of(work, struct saa7134_dev, request_module_wk);
+static void request_submodules(struct saa7134_dev *dev)
+{
 	if (card_is_empress(dev))
-		request_module("saa7134-empress");
+		request_module_nowait("saa7134-empress");
 	if (card_is_dvb(dev))
-		request_module("saa7134-dvb");
+		request_module_nowait("saa7134-dvb");
 	if (alsa)
-		request_module("saa7134-alsa");
+		request_module_nowait("saa7134-alsa");
 	if (oss)
-		request_module("saa7134-oss");
-}
-
-static void request_submodules(struct saa7134_dev *dev)
-{
-	INIT_WORK(&dev->request_module_wk, request_module_async);
-	schedule_work(&dev->request_module_wk);
+		request_module_nowait("saa7134-oss");
 }
 
 #else
drivers/media/video/saa7134/saa7134.h +0 -2
index 14ee265..d13d16f 100644
@@ -482,8 +482,6 @@ struct saa7134_dev {
 	struct mutex               lock;
 	spinlock_t                 slock;
 	struct v4l2_prio_state     prio;
-	/* workstruct for loading modules */
-	struct work_struct request_module_wk;
 
 	/* insmod option/autodetected */
 	int                        autodetected;
drivers/mtd/nand/nand_base.c +2 -2
index 0c3afcc..5f71371 100644
@@ -2720,14 +2720,14 @@ int nand_scan_tail(struct mtd_info *mtd)
 	return chip->scan_bbt(mtd);
 }
 
-/* module_text_address() isn't exported, and it's mostly a pointless
+/* is_module_text_address() isn't exported, and it's mostly a pointless
    test if this is a module _anyway_ -- they'd have to try _really_ hard
    to call us from in-kernel code if the core NAND support is modular. */
 #ifdef MODULE
 #define caller_is_module() (1)
 #else
 #define caller_is_module() \
-	module_text_address((unsigned long)__builtin_return_address(0))
+	is_module_text_address((unsigned long)__builtin_return_address(0))
 #endif
 
 /**
include/linux/kallsyms.h +15 -0
index f3fe343..7922742 100644
@@ -13,10 +13,17 @@
 #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
 			 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
 
+struct module;
+
 #ifdef CONFIG_KALLSYMS
 /* Lookup the address for a symbol. Returns 0 if not found. */
 unsigned long kallsyms_lookup_name(const char *name);
 
+/* Call a function on each kallsyms symbol in the core kernel */
+int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
+				      unsigned long),
+			    void *data);
+
 extern int kallsyms_lookup_size_offset(unsigned long addr,
 				  unsigned long *symbolsize,
 				  unsigned long *offset);
@@ -43,6 +50,14 @@ static inline unsigned long kallsyms_lookup_name(const char *name)
 	return 0;
 }
 
+static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *,
+						    struct module *,
+						    unsigned long),
+					  void *data)
+{
+	return 0;
+}
+
 static inline int kallsyms_lookup_size_offset(unsigned long addr,
 					      unsigned long *symbolsize,
 					      unsigned long *offset)
include/linux/kmod.h +8 -3
index 92213a9..d5fa565 100644
@@ -29,10 +29,15 @@
 #ifdef CONFIG_MODULES
 /* modprobe exit status on success, -ve on error.  Return value
  * usually useless though. */
-extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2)));
-#define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))
+extern int __request_module(bool wait, const char *name, ...) \
+	__attribute__((format(printf, 2, 3)));
+#define request_module(mod...) __request_module(true, mod)
+#define request_module_nowait(mod...) __request_module(false, mod)
+#define try_then_request_module(x, mod...) \
+	((x) ?: (__request_module(false, mod), (x)))
 #else
-static inline int request_module(const char * name, ...) { return -ENOSYS; }
+static inline int request_module(const char *name, ...) { return -ENOSYS; }
+static inline int request_module_nowait(const char *name, ...) { return -ENOSYS; }
 #define try_then_request_module(x, mod...) (x)
 #endif
 
include/linux/module.h +55 -8

122 lines not on this page · raw message

include/linux/moduleparam.h +10 -0
index e4af339..a4f0b93 100644
@@ -138,6 +138,16 @@ extern int parse_args(const char *name,
 		      unsigned num,
 		      int (*unknown)(char *param, char *val));
 
+/* Called by module remove. */
+#ifdef CONFIG_SYSFS
+extern void destroy_params(const struct kernel_param *params, unsigned num);
+#else
+static inline void destroy_params(const struct kernel_param *params,
+				  unsigned num)
+{
+}
+#endif /* !CONFIG_SYSFS */
+
 /* All the helper functions */
 /* The macros to do compile-time type checking stolen from Jakub
    Jelinek, who IIRC came up with this idea for the 2.4 module init code. */
kernel/extable.c +3 -3
index e136ed8..384f0da 100644
@@ -58,14 +58,14 @@ __notrace_funcgraph int __kernel_text_address(unsigned long addr)
 {
 	if (core_kernel_text(addr))
 		return 1;
-	return __module_text_address(addr) != NULL;
+	return is_module_text_address(addr);
 }
 
 int kernel_text_address(unsigned long addr)
 {
 	if (core_kernel_text(addr))
 		return 1;
-	return module_text_address(addr) != NULL;
+	return is_module_text_address(addr);
 }
 
 /*
@@ -81,5 +81,5 @@ int func_ptr_is_kernel_text(void *ptr)
 	addr = (unsigned long) dereference_function_descriptor(ptr);
 	if (core_kernel_text(addr))
 		return 1;
-	return module_text_address(addr) != NULL;
+	return is_module_text_address(addr);
 }
kernel/kallsyms.c +19 -0
index 7b8b0f2..374faf9 100644
@@ -161,6 +161,25 @@ unsigned long kallsyms_lookup_name(const char *name)
 	return module_kallsyms_lookup_name(name);
 }
 
+int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
+				      unsigned long),
+			    void *data)
+{
+	char namebuf[KSYM_NAME_LEN];
+	unsigned long i;
+	unsigned int off;
+	int ret;
+
+	for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
+		off = kallsyms_expand_symbol(off, namebuf);
+		ret = fn(data, namebuf, NULL, kallsyms_addresses[i]);
+		if (ret != 0)
+			return ret;
+	}
+	return module_kallsyms_on_each_symbol(fn, data);
+}
+EXPORT_SYMBOL_GPL(kallsyms_on_each_symbol);
+
 static unsigned long get_symbol_pos(unsigned long addr,
 				    unsigned long *symbolsize,
 				    unsigned long *offset)
kernel/kmod.c +6 -4
index a27a5f6..dc13dd4 100644
@@ -50,7 +50,8 @@ static struct workqueue_struct *khelper_wq;
 char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
 
 /**
- * request_module - try to load a kernel module
+ * __request_module - try to load a kernel module
+ * @wait: wait (or not) for the operation to complete
  * @fmt: printf style format string for the name of the module
  * @...: arguments as specified in the format string
  *
@@ -63,7 +64,7 @@ char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
  * If module auto-loading support is disabled then this function
  * becomes a no-operation.
  */
-int request_module(const char *fmt, ...)
+int __request_module(bool wait, const char *fmt, ...)
 {
 	va_list args;
 	char module_name[MODULE_NAME_LEN];
@@ -108,11 +109,12 @@ int request_module(const char *fmt, ...)
 		return -ENOMEM;
 	}
 
-	ret = call_usermodehelper(modprobe_path, argv, envp, 1);
+	ret = call_usermodehelper(modprobe_path, argv, envp,
+			wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
 	atomic_dec(&kmod_concurrent);
 	return ret;
 }
-EXPORT_SYMBOL(request_module);
+EXPORT_SYMBOL(__request_module);
 #endif /* CONFIG_MODULES */
 
 struct subprocess_info {
kernel/module.c +157 -106

536 lines not on this page · raw message

kernel/params.c +25 -1
index a1e3025..de273ec 100644
@@ -24,6 +24,9 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 
+/* We abuse the high bits of "perm" to record whether we kmalloc'ed. */
+#define KPARAM_KMALLOCED	0x80000000
+
 #if 0
 #define DEBUGP printk
 #else
@@ -217,7 +220,19 @@ int param_set_charp(const char *val, struct kernel_param *kp)
 		return -ENOSPC;
 	}
 
-	*(char **)kp->arg = (char *)val;
+	if (kp->perm & KPARAM_KMALLOCED)
+		kfree(*(char **)kp->arg);
+
+	/* This is a hack.  We can't need to strdup in early boot, and we
+	 * don't need to; this mangled commandline is preserved. */
+	if (slab_is_available()) {
+		kp->perm |= KPARAM_KMALLOCED;
+		*(char **)kp->arg = kstrdup(val, GFP_KERNEL);
+		if (!kp->arg)
+			return -ENOMEM;
+	} else
+		*(const char **)kp->arg = val;
+
 	return 0;
 }
 
@@ -571,6 +586,15 @@ void module_param_sysfs_remove(struct module *mod)
 }
 #endif
 
+void destroy_params(const struct kernel_param *params, unsigned num)
+{
+	unsigned int i;
+
+	for (i = 0; i < num; i++)
+		if (params[i].perm & KPARAM_KMALLOCED)
+			kfree(*(char **)params[i].arg);
+}
+
 static void __init kernel_add_sysfs_param(const char *name,
 					  struct kernel_param *kparam,
 					  unsigned int name_skip)
scripts/mod/modpost.c +2 -2
index 8892161..164ba2d 100644
@@ -1604,12 +1604,12 @@ static void read_symbols(char *modname)
 
 	parse_elf_finish(&info);
 
-	/* Our trick to get versioning for struct_module - it's
+	/* Our trick to get versioning for module struct etc. - it's
 	 * never passed as an argument to an exported function, so
 	 * the automatic versioning doesn't pick it up, but it's really
 	 * important anyhow */
 	if (modversions)
-		mod->unres = alloc_symbol("struct_module", 0, mod->unres);
+		mod->unres = alloc_symbol("module_layout", 0, mod->unres);
 }
 
 #define SZ 500