[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1429572637-30234-3-git-send-email-mcgrof@do-not-panic.com>
Date: Mon, 20 Apr 2015 16:30:33 -0700
From: "Luis R. Rodriguez" <mcgrof@...not-panic.com>
To: rusty@...tcorp.com.au
Cc: linux-kernel@...r.kernel.org, linux-wireless@...r.kernel.org,
keescook@...omium.org, casey@...aufler-ca.com,
cocci@...teme.lip6.fr, "Luis R. Rodriguez" <mcgrof@...e.com>,
Jani Nikula <jani.nikula@...el.com>,
Christoph Hellwig <hch@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Hannes Reinecke <hare@...e.de>, Tejun Heo <tj@...nel.org>,
Ingo Molnar <mingo@...nel.org>
Subject: [PATCH v1 2/6] kernel/module.c: use generic module param operaters for sig_enforce
From: "Luis R. Rodriguez" <mcgrof@...e.com>
We're directly checking and modifying sig_enforce when needed instead
of using the generic helpers. This prevents us from generalizing this
helper so that others can use it. Use indirect helpers to allow us
to generalize this code a bit and to make it a bit more clear what
this is doing.
Cc: Rusty Russell <rusty@...tcorp.com.au>
Cc: Jani Nikula <jani.nikula@...el.com>
Cc: Christoph Hellwig <hch@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Hannes Reinecke <hare@...e.de>
Cc: Kees Cook <keescook@...omium.org>
Cc: Tejun Heo <tj@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: cocci@...teme.lip6.fr
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@...e.com>
---
kernel/module.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/kernel/module.c b/kernel/module.c
index 42a1d2a..de12c4a 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -114,23 +114,25 @@ static bool sig_enforce = false;
static int param_set_bool_enable_only(const char *val,
const struct kernel_param *kp)
{
- int err;
- bool test;
+ int err = 0;
+ bool new_value;
+ bool orig_value = *(bool *)kp->arg;
struct kernel_param dummy_kp = *kp;
- dummy_kp.arg = &test;
+ dummy_kp.arg = &new_value;
err = param_set_bool(val, &dummy_kp);
if (err)
return err;
/* Don't let them unset it once it's set! */
- if (!test && sig_enforce)
+ if (!new_value && orig_value)
return -EROFS;
- if (test)
- sig_enforce = true;
- return 0;
+ if (new_value)
+ err = param_set_bool(val, kp);
+
+ return err;
}
static const struct kernel_param_ops param_ops_bool_enable_only = {
--
2.3.2.209.gd67f9d5.dirty
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists