Commit af49d924 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds
Browse files

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: default avatarRusty Russell <rusty@rustcorp.com.au>
Acked-by: default avatarShannon Nelson <shannon.nelson@intel.com>
Acked-by: default avatarDan Williams <dan.j.williams@intel.com>
Acked-by: default avatarVlad Yasevich <vladislav.yasevich@hp.com>
Cc: Sridhar Samudrala <sri@us.ibm.com>
Cc: Adrian Bunk <bunk@stusta.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d9c9bef1
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -1446,21 +1446,20 @@ static struct platform_driver iop_adma_driver = {


static int __init iop_adma_init (void)
static int __init iop_adma_init (void)
{
{
	/* it's currently unsafe to unload this module */
	/* if forced, worst case is that rmmod hangs */
	__unsafe(THIS_MODULE);

	return platform_driver_register(&iop_adma_driver);
	return platform_driver_register(&iop_adma_driver);
}
}


/* it's currently unsafe to unload this module */
#if 0
static void __exit iop_adma_exit (void)
static void __exit iop_adma_exit (void)
{
{
	platform_driver_unregister(&iop_adma_driver);
	platform_driver_unregister(&iop_adma_driver);
	return;
	return;
}
}
module_exit(iop_adma_exit);
#endif


module_init(iop_adma_init);
module_init(iop_adma_init);
module_exit(iop_adma_exit);


MODULE_AUTHOR("Intel Corporation");
MODULE_AUTHOR("Intel Corporation");
MODULE_DESCRIPTION("IOP ADMA Engine Driver");
MODULE_DESCRIPTION("IOP ADMA Engine Driver");
+0 −15
Original line number Original line Diff line number Diff line
@@ -312,9 +312,6 @@ struct module
	/* Arch-specific module values */
	/* Arch-specific module values */
	struct mod_arch_specific arch;
	struct mod_arch_specific arch;


	/* Am I unsafe to unload? */
	int unsafe;

	unsigned int taints;	/* same bits as kernel:tainted */
	unsigned int taints;	/* same bits as kernel:tainted */


#ifdef CONFIG_GENERIC_BUG
#ifdef CONFIG_GENERIC_BUG
@@ -441,16 +438,6 @@ static inline void __module_get(struct module *module)
	__mod ? __mod->name : "kernel";		\
	__mod ? __mod->name : "kernel";		\
})
})


#define __unsafe(mod)							     \
do {									     \
	if (mod && !(mod)->unsafe) {					     \
		printk(KERN_WARNING					     \
		       "Module %s cannot be unloaded due to unsafe usage in" \
		       " %s:%u\n", (mod)->name, __FILE__, __LINE__);	     \
		(mod)->unsafe = 1;					     \
	}								     \
} while(0)

/* For kallsyms to ask for address resolution.  NULL means not found. */
/* For kallsyms to ask for address resolution.  NULL means not found. */
const char *module_address_lookup(unsigned long addr,
const char *module_address_lookup(unsigned long addr,
				  unsigned long *symbolsize,
				  unsigned long *symbolsize,
@@ -518,8 +505,6 @@ static inline void module_put(struct module *module)


#define module_name(mod) "kernel"
#define module_name(mod) "kernel"


#define __unsafe(mod)

/* For kallsyms to ask for address resolution.  NULL means not found. */
/* For kallsyms to ask for address resolution.  NULL means not found. */
static inline const char *module_address_lookup(unsigned long addr,
static inline const char *module_address_lookup(unsigned long addr,
						unsigned long *symbolsize,
						unsigned long *symbolsize,
+5 −16
Original line number Original line Diff line number Diff line
@@ -692,8 +692,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
	}
	}


	/* If it has an init func, it must have an exit func to unload */
	/* If it has an init func, it must have an exit func to unload */
	if ((mod->init != NULL && mod->exit == NULL)
	if (mod->init && !mod->exit) {
	    || mod->unsafe) {
		forced = try_force_unload(flags);
		forced = try_force_unload(flags);
		if (!forced) {
		if (!forced) {
			/* This module can't be removed */
			/* This module can't be removed */
@@ -741,11 +740,6 @@ static void print_unload_info(struct seq_file *m, struct module *mod)
		seq_printf(m, "%s,", use->module_which_uses->name);
		seq_printf(m, "%s,", use->module_which_uses->name);
	}
	}


	if (mod->unsafe) {
		printed_something = 1;
		seq_printf(m, "[unsafe],");
	}

	if (mod->init != NULL && mod->exit == NULL) {
	if (mod->init != NULL && mod->exit == NULL) {
		printed_something = 1;
		printed_something = 1;
		seq_printf(m, "[permanent],");
		seq_printf(m, "[permanent],");
@@ -2011,15 +2005,10 @@ sys_init_module(void __user *umod,
                   buggy refcounters. */
                   buggy refcounters. */
		mod->state = MODULE_STATE_GOING;
		mod->state = MODULE_STATE_GOING;
		synchronize_sched();
		synchronize_sched();
		if (mod->unsafe)
			printk(KERN_ERR "%s: module is now stuck!\n",
			       mod->name);
		else {
		module_put(mod);
		module_put(mod);
		mutex_lock(&module_mutex);
		mutex_lock(&module_mutex);
		free_module(mod);
		free_module(mod);
		mutex_unlock(&module_mutex);
		mutex_unlock(&module_mutex);
		}
		return ret;
		return ret;
	}
	}


+0 −1
Original line number Original line Diff line number Diff line
@@ -1228,7 +1228,6 @@ SCTP_STATIC __init int sctp_init(void)
	if (status)
	if (status)
		goto err_v6_add_protocol;
		goto err_v6_add_protocol;


	__unsafe(THIS_MODULE);
	status = 0;
	status = 0;
out:
out:
	return status;
	return status;