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).
Showing the changes to kernel/module.c (1 of 4 files). Show all
Unified · Split
| @@ -692,8 +692,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) · 691 unmodified lines | ||
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /* 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) { | |
| 697 | 696 | forced = try_force_unload(flags); |
| 698 | 697 | if (!forced) { |
| 699 | 698 | /* 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 | ||
| 741 | 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 | 743 | if (mod->init != NULL && mod->exit == NULL) { |
| 750 | 744 | printed_something = 1; |
| 751 | 745 | seq_printf(m, "[permanent],"); |
| @@ -2011,15 +2005,10 @@ sys_init_module(void __user *umod, · 1259 unmodified lines | ||
| 2011 | 2005 | buggy refcounters. */ |
| 2012 | 2006 | mod->state = MODULE_STATE_GOING; |
| 2013 | 2007 | 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); | |
| 2023 | 2012 | return ret; |
| 2024 | 2013 | } |
| 2025 | 2014 | |