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: <20240905041358.5vzb3rsklbvzx73e@treble>
Date: Wed, 4 Sep 2024 21:13:58 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Song Liu <song@...nel.org>
Cc: live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
	x86@...nel.org, Miroslav Benes <mbenes@...e.cz>,
	Petr Mladek <pmladek@...e.com>,
	Joe Lawrence <joe.lawrence@...hat.com>,
	Jiri Kosina <jikos@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Marcos Paulo de Souza <mpdesouza@...e.com>
Subject: Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

On Wed, Sep 04, 2024 at 01:59:51PM -0700, Josh Poimboeuf wrote:
> On Wed, Sep 04, 2024 at 01:23:55PM -0700, Song Liu wrote:
> > [ 7285.260195] livepatch: nothing to patch!

This seems to be tripping up on an awful hack I had for silencing
modpost warnings.  Apparently it doesn't work with your config.

Try the below.  You can ignore the modpost warnings for now:

  WARNING: modpost: "__stop_klp_objects" [/home/jpoimboe/git/linux/klp-tmp/out/livepatch.ko] undefined!
  WARNING: modpost: "__start_klp_objects" [/home/jpoimboe/git/linux/klp-tmp/out/livepatch.ko] undefined!

diff --git a/scripts/livepatch/module.c b/scripts/livepatch/module.c
index 101cabf6b2f1..7e4a8477231f 100644
--- a/scripts/livepatch/module.c
+++ b/scripts/livepatch/module.c
@@ -14,16 +14,13 @@
 // TODO livepatch could recognize these sections directly
 // TODO use function checksums instead of sympos
 
-extern char __start_klp_objects, __stop_klp_objects;
 
 /*
  * Create weak versions of the linker-created symbols to prevent modpost from
  * warning about unresolved symbols.
  */
-__weak char __start_klp_objects = 0;
-__weak char __stop_klp_objects  = 0;
-struct klp_object_ext *__start_objs = (struct klp_object_ext *)&__start_klp_objects;
-struct klp_object_ext *__stop_objs  = (struct klp_object_ext *)&__stop_klp_objects;
+extern struct klp_object_ext __start_klp_objects[];
+extern struct klp_object_ext __stop_klp_objects[];
 
 static struct klp_patch *patch;
 
@@ -33,9 +30,9 @@ static int __init livepatch_mod_init(void)
 	unsigned int nr_objs;
 	int ret;
 
-	nr_objs = __stop_objs - __start_objs;
+	nr_objs = __stop_klp_objects - __start_klp_objects;
 
-	if (!__start_klp_objects || !nr_objs) {
+	if (!!nr_objs) {
 		pr_err("nothing to patch!\n");
 		ret = -EINVAL;
 		goto err;
@@ -54,7 +51,7 @@ static int __init livepatch_mod_init(void)
 	}
 
 	for (int i = 0; i < nr_objs; i++) {
-		struct klp_object_ext *obj_ext = __start_objs + i;
+		struct klp_object_ext *obj_ext = __start_klp_objects;
 		struct klp_func_ext *funcs_ext = obj_ext->funcs;
 		unsigned int nr_funcs = obj_ext->nr_funcs;
 		struct klp_func *funcs = objs[i].funcs;
@@ -105,7 +102,7 @@ static void __exit livepatch_mod_exit(void)
 {
 	unsigned int nr_objs;
 
-	nr_objs = __stop_objs - __start_objs;
+	nr_objs = __stop_klp_objects - __start_klp_objects;
 
 	for (int i = 0; i < nr_objs; i++)
 		kfree(patch->objs[i].funcs);
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index f48d72d22dc2..20d0f03025b3 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1739,7 +1739,7 @@ static void check_exports(struct module *mod)
 		exp = find_symbol(s->name);
 		if (!exp) {
 			if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS)
-				modpost_log(warn_unresolved ? LOG_WARN : LOG_ERROR,
+				modpost_log(LOG_WARN,
 					    "\"%s\" [%s.ko] undefined!\n",
 					    s->name, mod->name);
 			continue;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ