diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-17 02:26:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:49 -0400 |
commit | af49d9248fca6f26cbdb01918334f71d9040df80 (patch) | |
tree | 5d6a7f4d5ca55ff17fbfc98cacac37be62c7a4a3 | |
parent | d9c9bef1345e5d9258febce2a37e4d40319fa728 (diff) |
Remove "unsafe" from module struct
Adrian Bunk points out that "unsafe" was used to mark modules touched by
the deprecated MOD_INC_USE_COUNT interface, which has long gone. It's time
to remove the member from the module structure, as well.
If you want a module which can't unload, don't register an exit function.
(Vlad Yasevich says SCTP is now safe to unload, so just remove the
__unsafe there).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Cc: Sridhar Samudrala <sri@us.ibm.com>
Cc: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/dma/iop-adma.c | 9 | ||||
-rw-r--r-- | include/linux/module.h | 15 | ||||
-rw-r--r-- | kernel/module.c | 21 | ||||
-rw-r--r-- | net/sctp/protocol.c | 1 |
4 files changed, 9 insertions, 37 deletions
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c index 5a1d426744d6..e5c62b75f36f 100644 --- a/drivers/dma/iop-adma.c +++ b/drivers/dma/iop-adma.c | |||
@@ -1446,21 +1446,20 @@ static struct platform_driver iop_adma_driver = { | |||
1446 | 1446 | ||
1447 | static int __init iop_adma_init (void) | 1447 | static int __init iop_adma_init (void) |
1448 | { | 1448 | { |
1449 | /* it's currently unsafe to unload this module */ | ||
1450 | /* if forced, worst case is that rmmod hangs */ | ||
1451 | __unsafe(THIS_MODULE); | ||
1452 | |||
1453 | return platform_driver_register(&iop_adma_driver); | 1449 | return platform_driver_register(&iop_adma_driver); |
1454 | } | 1450 | } |
1455 | 1451 | ||
1452 | /* it's currently unsafe to unload this module */ | ||
1453 | #if 0 | ||
1456 | static void __exit iop_adma_exit (void) | 1454 | static void __exit iop_adma_exit (void) |
1457 | { | 1455 | { |
1458 | platform_driver_unregister(&iop_adma_driver); | 1456 | platform_driver_unregister(&iop_adma_driver); |
1459 | return; | 1457 | return; |
1460 | } | 1458 | } |
1459 | module_exit(iop_adma_exit); | ||
1460 | #endif | ||
1461 | 1461 | ||
1462 | module_init(iop_adma_init); | 1462 | module_init(iop_adma_init); |
1463 | module_exit(iop_adma_exit); | ||
1464 | 1463 | ||
1465 | MODULE_AUTHOR("Intel Corporation"); | 1464 | MODULE_AUTHOR("Intel Corporation"); |
1466 | MODULE_DESCRIPTION("IOP ADMA Engine Driver"); | 1465 | MODULE_DESCRIPTION("IOP ADMA Engine Driver"); |
diff --git a/include/linux/module.h b/include/linux/module.h index b6a646cea1cb..5523e10fb2f0 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -312,9 +312,6 @@ struct module | |||
312 | /* Arch-specific module values */ | 312 | /* Arch-specific module values */ |
313 | struct mod_arch_specific arch; | 313 | struct mod_arch_specific arch; |
314 | 314 | ||
315 | /* Am I unsafe to unload? */ | ||
316 | int unsafe; | ||
317 | |||
318 | unsigned int taints; /* same bits as kernel:tainted */ | 315 | unsigned int taints; /* same bits as kernel:tainted */ |
319 | 316 | ||
320 | #ifdef CONFIG_GENERIC_BUG | 317 | #ifdef CONFIG_GENERIC_BUG |
@@ -441,16 +438,6 @@ static inline void __module_get(struct module *module) | |||
441 | __mod ? __mod->name : "kernel"; \ | 438 | __mod ? __mod->name : "kernel"; \ |
442 | }) | 439 | }) |
443 | 440 | ||
444 | #define __unsafe(mod) \ | ||
445 | do { \ | ||
446 | if (mod && !(mod)->unsafe) { \ | ||
447 | printk(KERN_WARNING \ | ||
448 | "Module %s cannot be unloaded due to unsafe usage in" \ | ||
449 | " %s:%u\n", (mod)->name, __FILE__, __LINE__); \ | ||
450 | (mod)->unsafe = 1; \ | ||
451 | } \ | ||
452 | } while(0) | ||
453 | |||
454 | /* For kallsyms to ask for address resolution. NULL means not found. */ | 441 | /* For kallsyms to ask for address resolution. NULL means not found. */ |
455 | const char *module_address_lookup(unsigned long addr, | 442 | const char *module_address_lookup(unsigned long addr, |
456 | unsigned long *symbolsize, | 443 | unsigned long *symbolsize, |
@@ -518,8 +505,6 @@ static inline void module_put(struct module *module) | |||
518 | 505 | ||
519 | #define module_name(mod) "kernel" | 506 | #define module_name(mod) "kernel" |
520 | 507 | ||
521 | #define __unsafe(mod) | ||
522 | |||
523 | /* For kallsyms to ask for address resolution. NULL means not found. */ | 508 | /* For kallsyms to ask for address resolution. NULL means not found. */ |
524 | static inline const char *module_address_lookup(unsigned long addr, | 509 | static inline const char *module_address_lookup(unsigned long addr, |
525 | unsigned long *symbolsize, | 510 | unsigned long *symbolsize, |
diff --git a/kernel/module.c b/kernel/module.c index db0ead0363e2..35246a61a7e9 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -692,8 +692,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) | |||
692 | } | 692 | } |
693 | 693 | ||
694 | /* If it has an init func, it must have an exit func to unload */ | 694 | /* If it has an init func, it must have an exit func to unload */ |
695 | if ((mod->init != NULL && mod->exit == NULL) | 695 | if (mod->init && !mod->exit) { |
696 | || mod->unsafe) { | ||
697 | forced = try_force_unload(flags); | 696 | forced = try_force_unload(flags); |
698 | if (!forced) { | 697 | if (!forced) { |
699 | /* This module can't be removed */ | 698 | /* This module can't be removed */ |
@@ -741,11 +740,6 @@ static void print_unload_info(struct seq_file *m, struct module *mod) | |||
741 | seq_printf(m, "%s,", use->module_which_uses->name); | 740 | seq_printf(m, "%s,", use->module_which_uses->name); |
742 | } | 741 | } |
743 | 742 | ||
744 | if (mod->unsafe) { | ||
745 | printed_something = 1; | ||
746 | seq_printf(m, "[unsafe],"); | ||
747 | } | ||
748 | |||
749 | if (mod->init != NULL && mod->exit == NULL) { | 743 | if (mod->init != NULL && mod->exit == NULL) { |
750 | printed_something = 1; | 744 | printed_something = 1; |
751 | seq_printf(m, "[permanent],"); | 745 | seq_printf(m, "[permanent],"); |
@@ -2011,15 +2005,10 @@ sys_init_module(void __user *umod, | |||
2011 | buggy refcounters. */ | 2005 | buggy refcounters. */ |
2012 | mod->state = MODULE_STATE_GOING; | 2006 | mod->state = MODULE_STATE_GOING; |
2013 | synchronize_sched(); | 2007 | synchronize_sched(); |
2014 | if (mod->unsafe) | 2008 | module_put(mod); |
2015 | printk(KERN_ERR "%s: module is now stuck!\n", | 2009 | mutex_lock(&module_mutex); |
2016 | mod->name); | 2010 | free_module(mod); |
2017 | else { | 2011 | mutex_unlock(&module_mutex); |
2018 | module_put(mod); | ||
2019 | mutex_lock(&module_mutex); | ||
2020 | free_module(mod); | ||
2021 | mutex_unlock(&module_mutex); | ||
2022 | } | ||
2023 | return ret; | 2012 | return ret; |
2024 | } | 2013 | } |
2025 | 2014 | ||
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 81b26c5ffd4b..f5cd96f5fe74 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1228,7 +1228,6 @@ SCTP_STATIC __init int sctp_init(void) | |||
1228 | if (status) | 1228 | if (status) |
1229 | goto err_v6_add_protocol; | 1229 | goto err_v6_add_protocol; |
1230 | 1230 | ||
1231 | __unsafe(THIS_MODULE); | ||
1232 | status = 0; | 1231 | status = 0; |
1233 | out: | 1232 | out: |
1234 | return status; | 1233 | return status; |