History

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

Rusty Russell committed 19 years ago

Commit af49d921 parent d9c9bef4 files · +9 −37Browse files

Unified · Split

4 files
  1. drivers/dma/iop-adma.c +4 −5
  2. include/linux/module.h +0 −15
  3. kernel/module.c +5 −16
  4. net/sctp/protocol.c +0 −1
drivers/dma/iop-adma.c+4−5
@@ -1446,21 +1446,20 @@ static struct platform_driver iop_adma_driver = { · 1445 unmodified lines
14461446
14471447 static int __init iop_adma_init (void)
14481448 {
1449− /* it's currently unsafe to unload this module */
1450− /* if forced, worst case is that rmmod hangs */
1451− __unsafe(THIS_MODULE);
1452−
14531449 return platform_driver_register(&iop_adma_driver);
14541450 }
14551451
1452+/* it's currently unsafe to unload this module */
1453+#if 0
14561454 static void __exit iop_adma_exit (void)
14571455 {
14581456 platform_driver_unregister(&iop_adma_driver);
14591457 return;
14601458 }
1459+module_exit(iop_adma_exit);
1460+#endif
14611461
14621462 module_init(iop_adma_init);
1463−module_exit(iop_adma_exit);
14641463
14651464 MODULE_AUTHOR("Intel Corporation");
14661465 MODULE_DESCRIPTION("IOP ADMA Engine Driver");
include/linux/module.h+0−15
@@ -312,9 +312,6 @@ struct module · 311 unmodified lines
312312 /* Arch-specific module values */
313313 struct mod_arch_specific arch;
314314
315− /* Am I unsafe to unload? */
316− int unsafe;
317−
318315 unsigned int taints; /* same bits as kernel:tainted */
319316
320317 #ifdef CONFIG_GENERIC_BUG
@@ -441,16 +438,6 @@ static inline void __module_get(struct module *module) · 120 unmodified lines
441438 __mod ? __mod->name : "kernel"; \
442439 })
443440
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−
454441 /* For kallsyms to ask for address resolution. NULL means not found. */
455442 const char *module_address_lookup(unsigned long addr,
456443 unsigned long *symbolsize,
@@ -518,8 +505,6 @@ static inline void module_put(struct module *module) · 61 unmodified lines
518505
519506 #define module_name(mod) "kernel"
520507
521−#define __unsafe(mod)
522−
523508 /* For kallsyms to ask for address resolution. NULL means not found. */
524509 static inline const char *module_address_lookup(unsigned long addr,
525510 unsigned long *symbolsize,
kernel/module.c+5−16
@@ -692,8 +692,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) · 691 unmodified lines
692692 }
693693
694694 /* If it has an init func, it must have an exit func to unload */
695− if ((mod->init != NULL && mod->exit == NULL)
696− || mod->unsafe) {
695+ if (mod->init && !mod->exit) {
697696 forced = try_force_unload(flags);
698697 if (!forced) {
699698 /* This module can't be removed */
@@ -741,11 +740,6 @@ static void print_unload_info(struct seq_file *m, struct module *mod) · 41 unmodified lines
741740 seq_printf(m, "%s,", use->module_which_uses->name);
742741 }
743742
744− if (mod->unsafe) {
745− printed_something = 1;
746− seq_printf(m, "[unsafe],");
747− }
748−
749743 if (mod->init != NULL && mod->exit == NULL) {
750744 printed_something = 1;
751745 seq_printf(m, "[permanent],");
@@ -2011,15 +2005,10 @@ sys_init_module(void __user *umod, · 1259 unmodified lines
20112005 buggy refcounters. */
20122006 mod->state = MODULE_STATE_GOING;
20132007 synchronize_sched();
2014− if (mod->unsafe)
2015− printk(KERN_ERR "%s: module is now stuck!\n",
2016− mod->name);
2017− else {
2018− module_put(mod);
2019− mutex_lock(&module_mutex);
2020− free_module(mod);
2021− mutex_unlock(&module_mutex);
2022− }
2008+ module_put(mod);
2009+ mutex_lock(&module_mutex);
2010+ free_module(mod);
2011+ mutex_unlock(&module_mutex);
20232012 return ret;
20242013 }
20252014
net/sctp/protocol.c+0−1
@@ -1228,7 +1228,6 @@ SCTP_STATIC __init int sctp_init(void) · 1227 unmodified lines
12281228 if (status)
12291229 goto err_v6_add_protocol;
12301230
1231− __unsafe(THIS_MODULE);
12321231 status = 0;
12331232 out:
12341233 return status;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t