All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
	Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 4/6] ms/objtool/klp: Explicitly disallow patching or referencing init code/data
Date: Thu, 26 Nov 2026 22:51:19 +0100	[thread overview]
Message-ID: <20261126-khorenko-vstor-157128-more-klp-build-fixes-v1-4-69a0363954e4@virtuozzo.com> (raw)
In-Reply-To: <20261126-khorenko-vstor-157128-more-klp-build-fixes-v1-0-69a0363954e4@virtuozzo.com>

From: Josh Poimboeuf <jpoimboe@kernel.org>

Explicitly disallow the patching and referencing of init code/data.
Otherwise it could potentially introduce some odd edge cases depending
on whether the target object's init section has been freed yet (note
that the init code still exists in the target module when doing late
module patching).

Such edge cases include sympos calculation and the patching and/or
referencing of non-existent (init-freed) code/data.  Not to mention the
inherent differences in behavior that occur when the init code is only
patched *some* of the time depending on module loading order or kernel
config.

Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Acked-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/516e14f84cfbffa27dc19d3dcf35097504097966.1786138493.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
(cherry picked from commit 69f361b8a7a2f65c1bb236ea0899cdaad7267653)

https://virtuozzo.atlassian.net/browse/VSTOR-157437
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/objtool/klp-sympos.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/objtool/klp-sympos.c b/tools/objtool/klp-sympos.c
index bbfae516d3395..dfca9dd746812 100644
--- a/tools/objtool/klp-sympos.c
+++ b/tools/objtool/klp-sympos.c
@@ -367,6 +367,11 @@ static unsigned long find_vmlinux_sympos(struct symbol *sym)
 	return sympos;
 }
 
+static bool is_init_sym(struct symbol *sym)
+{
+	return strstarts(sym->sec->name, ".init");
+}
+
 /*
  * "sympos" is used by livepatch to disambiguate duplicate symbol names.
  */
@@ -376,6 +381,11 @@ unsigned long klp_find_sympos(struct elf *elf, struct symbol *sym)
 	bool has_dup = false;
 	struct symbol *s;
 
+	if (is_init_sym(sym)) {
+		ERROR("%s: can't patch or reference init code/data", sym->name);
+		return ULONG_MAX;
+	}
+
 	if (sym->bind != STB_LOCAL)
 		return 0;
 

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-26 21:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 21:51 [Devel] [PATCH hci-8.2 0/6] objtool/klp: more upstream klp-build fixes for the 8.2 kernel Konstantin Khorenko
2026-11-26 21:51 ` [Devel] [PATCH hci-8.2 1/6] ms/objtool/klp: Fix bug table handling for __WARN_printf() Konstantin Khorenko
2026-12-01  0:41   ` no-reply
2026-11-26 21:51 ` [Devel] [PATCH hci-8.2 2/6] ms/objtool/klp: Fix extraction of text annotations for alternatives Konstantin Khorenko
2026-12-01  0:41   ` no-reply
2026-11-26 21:51 ` [Devel] [PATCH hci-8.2 3/6] ms/objtool/klp: Fix false module dependencies caused by dead relocs Konstantin Khorenko
2026-12-01  0:43   ` no-reply
2026-11-26 21:51 ` Konstantin Khorenko [this message]
2026-12-01  0:43   ` [Devel] [PATCH hci-8.2 4/6] ms/objtool/klp: Explicitly disallow patching or referencing init code/data no-reply
2026-11-26 21:51 ` [Devel] [PATCH hci-8.2 5/6] ms/klp-build: Fix wrong index in funcs cleanup error path Konstantin Khorenko
2026-12-01  0:44   ` no-reply
2026-11-26 21:51 ` [Devel] [PATCH hci-8.2 6/6] ms/objtool/klp: Fix checksums for constant pool references Konstantin Khorenko
2026-12-01  0:45   ` no-reply
2026-11-27 14:42 ` [Devel] [PATCH hci-8.2 0/6] objtool/klp: more upstream klp-build fixes for the 8.2 kernel Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126-khorenko-vstor-157128-more-klp-build-fixes-v1-4-69a0363954e4@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=eva.kurchatova@virtuozzo.com \
    --cc=vasileios.almpanis@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.