lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1418148307-21434-2-git-send-email-pmladek@suse.cz>
Date:	Tue,  9 Dec 2014 19:05:02 +0100
From:	Petr Mladek <pmladek@...e.cz>
To:	Seth Jennings <sjenning@...hat.com>,
	Josh Poimboeuf <jpoimboe@...hat.com>,
	Jiri Kosina <jkosina@...e.cz>,
	Vojtech Pavlik <vojtech@...e.cz>,
	Steven Rostedt <rostedt@...dmis.org>,
	Miroslav Benes <mbenes@...e.cz>,
	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc:	Christoph Hellwig <hch@...radead.org>,
	Greg KH <gregkh@...uxfoundation.org>,
	Andy Lutomirski <luto@...capital.net>,
	live-patching@...r.kernel.org, x86@...nel.org, kpatch@...hat.com,
	linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.cz>
Subject: [PATCH 1/6] livepatch v5: avoid race when checking for state of the patch

klp_patch_enable() and klp_patch_disable() should check the current state
of the patch under the klp_lock. Otherwise, it might detect that the operation
is valid but the situation might change before it takes the lock.

Signed-off-by: Petr Mladek <pmladek@...e.cz>
---
 kernel/livepatch/core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index d6d0f50e81f8..b848069e44cc 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -425,11 +425,13 @@ int klp_disable_patch(struct klp_patch *patch)
 {
 	int ret;
 
-	if (!klp_is_enabled())
-		return -ENODEV;
-
 	mutex_lock(&klp_mutex);
 
+	if (!klp_is_enabled()) {
+		ret = -ENODEV;
+		goto err;
+	}
+
 	if (!klp_patch_is_registered(patch)) {
 		ret = -EINVAL;
 		goto err;
@@ -489,11 +491,13 @@ int klp_enable_patch(struct klp_patch *patch)
 {
 	int ret;
 
-	if (!klp_is_enabled())
-		return -ENODEV;
-
 	mutex_lock(&klp_mutex);
 
+	if (!klp_is_enabled()) {
+		ret = -ENODEV;
+		goto err;
+	}
+
 	if (!klp_patch_is_registered(patch)) {
 		ret = -EINVAL;
 		goto err;
-- 
1.8.5.2

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ