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: <20200117150323.21801-17-pmladek@suse.com>
Date:   Fri, 17 Jan 2020 16:03:16 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     Jiri Kosina <jikos@...nel.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Miroslav Benes <mbenes@...e.cz>
Cc:     Joe Lawrence <joe.lawrence@...hat.com>,
        Kamalesh Babulal <kamalesh@...ux.vnet.ibm.com>,
        Nicolai Stange <nstange@...e.de>,
        live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
        Petr Mladek <pmladek@...e.com>
Subject: [POC 16/23] livepatch: Add patch into the global list early

The objects for livepatched modules need to be loaded before the livepatch
gets enabled. klp_add_module() has to find the patch. The code is easier
when the being-enabled patch can be found in the global list.

Fortunately, there is no problem to add patch into the list already
in the early init. klp_free_patch_start() will remove it in case
of any later error.

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

diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 688ad81def14..06676ec63ba7 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -852,6 +852,7 @@ static int klp_init_object_early(struct klp_patch *patch,
 static int klp_init_patch_early(struct klp_patch *patch)
 {
 	struct klp_object *obj = patch->obj;
+	int ret;
 
 	/* Main patch module is always for vmlinux */
 	if (obj->name)
@@ -865,7 +866,11 @@ static int klp_init_patch_early(struct klp_patch *patch)
 	INIT_WORK(&patch->free_work, klp_free_patch_work_fn);
 	init_completion(&patch->finish);
 
-	return klp_init_object_early(patch, obj);
+	ret = klp_init_object_early(patch, obj);
+	if (!ret)
+		list_add_tail(&patch->list, &klp_patches);
+
+	return ret;
 }
 
 static int klp_init_patch(struct klp_patch *patch)
@@ -889,8 +894,6 @@ static int klp_init_patch(struct klp_patch *patch)
 			return ret;
 	}
 
-	list_add_tail(&patch->list, &klp_patches);
-
 	return 0;
 }
 
-- 
2.16.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ