linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module: Issue warnings when tainting kernel
@ 2016-04-12  6:50 Libor Pechacek
  2016-04-13  1:37 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Libor Pechacek @ 2016-04-12  6:50 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel

While most of the locations where a kernel taint bit is set are accompanied
with a warning message, there are two which set their bits silently.  If
the tainting module gets unloaded later on, it is almost impossible to tell
what was the reason for setting the flag.

Signed-off-by: Libor Pechacek <lpechacek@suse.com>
---
 kernel/module.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/module.c b/kernel/module.c
index 041200ca4a2d..e2d83d77a0e9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2812,8 +2812,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
 		return -ENOEXEC;
 	}
 
-	if (!get_modinfo(info, "intree"))
+	if (!get_modinfo(info, "intree")) {
+		if (!test_taint(TAINT_OOT_MODULE))
+			pr_warn("%s: loading out-of-tree module taints kernel.\n",
+				mod->name);
 		add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
+	}
 
 	if (get_modinfo(info, "staging")) {
 		add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
@@ -2978,6 +2982,8 @@ static int move_module(struct module *mod, struct load_info *info)
 
 static int check_module_license_and_versions(struct module *mod)
 {
+	int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE);
+
 	/*
 	 * ndiswrapper is under GPL by itself, but loads proprietary modules.
 	 * Don't use add_taint_module(), as it would prevent ndiswrapper from
@@ -2996,6 +3002,9 @@ static int check_module_license_and_versions(struct module *mod)
 		add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
 				 LOCKDEP_NOW_UNRELIABLE);
 
+	if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
+		pr_warn("%s: module license taints kernel.\n", mod->name);
+
 #ifdef CONFIG_MODVERSIONS
 	if ((mod->num_syms && !mod->crcs)
 	    || (mod->num_gpl_syms && !mod->gpl_crcs)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] module: Issue warnings when tainting kernel
  2016-04-12  6:50 [PATCH] module: Issue warnings when tainting kernel Libor Pechacek
@ 2016-04-13  1:37 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2016-04-13  1:37 UTC (permalink / raw)
  To: Libor Pechacek; +Cc: linux-kernel

Libor Pechacek <lpechacek@suse.com> writes:
> While most of the locations where a kernel taint bit is set are accompanied
> with a warning message, there are two which set their bits silently.  If
> the tainting module gets unloaded later on, it is almost impossible to tell
> what was the reason for setting the flag.
>
> Signed-off-by: Libor Pechacek <lpechacek@suse.com>

Applied, thanks!

Cheers,
Rusty.

> ---
>  kernel/module.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 041200ca4a2d..e2d83d77a0e9 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -2812,8 +2812,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
>  		return -ENOEXEC;
>  	}
>  
> -	if (!get_modinfo(info, "intree"))
> +	if (!get_modinfo(info, "intree")) {
> +		if (!test_taint(TAINT_OOT_MODULE))
> +			pr_warn("%s: loading out-of-tree module taints kernel.\n",
> +				mod->name);
>  		add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
> +	}
>  
>  	if (get_modinfo(info, "staging")) {
>  		add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
> @@ -2978,6 +2982,8 @@ static int move_module(struct module *mod, struct load_info *info)
>  
>  static int check_module_license_and_versions(struct module *mod)
>  {
> +	int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE);
> +
>  	/*
>  	 * ndiswrapper is under GPL by itself, but loads proprietary modules.
>  	 * Don't use add_taint_module(), as it would prevent ndiswrapper from
> @@ -2996,6 +3002,9 @@ static int check_module_license_and_versions(struct module *mod)
>  		add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
>  				 LOCKDEP_NOW_UNRELIABLE);
>  
> +	if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
> +		pr_warn("%s: module license taints kernel.\n", mod->name);
> +
>  #ifdef CONFIG_MODVERSIONS
>  	if ((mod->num_syms && !mod->crcs)
>  	    || (mod->num_gpl_syms && !mod->gpl_crcs)
> -- 
> 1.7.12.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-13  1:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12  6:50 [PATCH] module: Issue warnings when tainting kernel Libor Pechacek
2016-04-13  1:37 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).