From nobody Sat Jun 13 22:14:12 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11C4C47F2FD; Tue, 5 May 2026 10:56:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978596; cv=none; b=BIH6CSKupJOO8PgrkLg9pBDurBnfIUyi/hXLPtYjGTOtZQQRYn7uvNq3AS7DkeeQ6NZjnp5sCzXnmkPEBsRm09YhjIdLReo+9fgcT6NnUqIks/vf/sD0ZGJVNlpoXRfWHYb3l3NPsXBWJcJWVaNG4sN32n4IqgUQUfhH2PAWBdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978596; c=relaxed/simple; bh=6SghnqA8ExM8ktmlOSq8rq24ZpD4bU/2q3KyEHLvNt0=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=UZQSGRPdzwOSMfuPuI/cMFq33NIRiVuibYNa+cucqMIBxJdpc4p5QuBO1Q/Gm0UcsqIKIkpryqfsCvrsqgBs5sKpVFUhVscsT/NrNHeTOCcUsW219QNTXoo5OXeaxpjJYeTdZYPz2pTgpNv0SRF1mE0ood5MB20BqB1kFSp5a+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=eWMrAAAm; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+SazVRYj; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eWMrAAAm"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+SazVRYj" Date: Tue, 05 May 2026 10:56:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777978593; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AfRszbxQe/mGRJa995z86Y+PUcsTijS295HdC5LHzdE=; b=eWMrAAAmqLHmaNvBRU7QS9q1LxzcFvkTH0jYCWJw8BgxXDymUwpucGxdq5HE6r81xz1yIx 6rOi3coSt+SFpiJ7OwEFzV8ZipvYK0fPyetI6oKtFaLPwJOtgK8yqEFFXrmw5CHi81JCWk VhpDCzEwHBbRzX9qITU5ibt84CjDCxgF8qyLzg7AgVl2V4U6VP7naHrb6Q4slSctffrdcP uomLBzT7UYALeT9EaOrLFlKqWcsSjDmZvjAsOtw7cOJq7RMQKfR7rlHWRcNdDwuDNnJU4y EqFbYcGzWN4kticMn6cvP98S39Pi/qLHQ8enOoL/8vqFclI70lmF+EjXyGrh9w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777978593; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AfRszbxQe/mGRJa995z86Y+PUcsTijS295HdC5LHzdE=; b=+SazVRYjadYj1FNAf+0KGV+U9NZnW/F7/hfisYcZ7zE+I4SXrEvPIafUh1wf0AaXjvkdpO TiKmMOj/y3Bl5lAw== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool/klp: Fix pointer comparisons for rodata objects Cc: Song Liu , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177797859224.424702.15930061171043913341.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the objtool/core branch of tip: Commit-ID: d5b0f025281f287759820f57b7ba1bac7827b338 Gitweb: https://git.kernel.org/tip/d5b0f025281f287759820f57b7ba1bac7= 827b338 Author: Josh Poimboeuf AuthorDate: Tue, 28 Apr 2026 14:34:23 -07:00 Committer: Josh Poimboeuf CommitterDate: Mon, 04 May 2026 21:16:02 -07:00 objtool/klp: Fix pointer comparisons for rodata objects klp-diff treats all rodata as uncorrelated, so any reference to it uses a duplicated copy rather than using a KLP reloc. For the contents of the data itself, a duplicated copy is fine. However, pointer comparisons (e.g., f->f_op =3D=3D &foo_ops) are broken. Fix it by correlating non-anonymous rodata objects. Also, use a new find_symbol_containing_inclusive() helper for matching the end of a symbol so bounds calculations don't get broken, for the case where an array or other symbol's ending address is used as part of a bounds calculation. While these are really two distinct changes, they need to be done in the same patch so as to avoid introducing bisection regressions. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 14 ++++++++++++++ tools/objtool/include/objtool/elf.h | 1 + tools/objtool/klp-diff.c | 15 +++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 87c6e00..5a20dab 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -208,6 +208,20 @@ struct symbol *find_symbol_containing(const struct sec= tion *sec, unsigned long o } =20 /* + * Also match the symbol end address which can be used for a bounds compar= ison. + */ +struct symbol *find_symbol_containing_inclusive(const struct section *sec, + unsigned long offset) +{ + struct symbol *sym =3D find_symbol_containing(sec, offset); + + if (!sym && offset) + sym =3D find_symbol_containing(sec, offset - 1); + + return sym; +} + +/* * Returns size of hole starting at @offset. */ int find_symbol_hole_containing(const struct section *sec, unsigned long o= ffset) diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index ab5f701..8a543ce 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -211,6 +211,7 @@ struct symbol *find_symbol_by_offset(struct section *se= c, unsigned long offset); struct symbol *find_symbol_by_name(const struct elf *elf, const char *name= ); struct symbol *find_global_symbol_by_name(const struct elf *elf, const cha= r *name); struct symbol *find_symbol_containing(const struct section *sec, unsigned = long offset); +struct symbol *find_symbol_containing_inclusive(const struct section *sec,= unsigned long offset); int find_symbol_hole_containing(const struct section *sec, unsigned long o= ffset); struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *se= c, unsigned long offset); struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct secti= on *sec, diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c index 78633c9..bf37c65 100644 --- a/tools/objtool/klp-diff.c +++ b/tools/objtool/klp-diff.c @@ -386,6 +386,7 @@ static bool dont_correlate(struct symbol *sym) is_uncorrelated_static_local(sym) || is_local_label(sym) || is_string_sec(sym->sec) || + (is_rodata_sec(sym->sec) && !is_object_sym(sym)) || is_initcall_sym(sym) || is_addressable_sym(sym) || is_special_section(sym->sec) || @@ -979,7 +980,7 @@ static int convert_reloc_secsym_to_sym(struct elf *elf,= struct reloc *reloc) goto found_sym; =20 /* No dedicated section; find the symbol manually */ - sym =3D find_symbol_containing(sec, arch_adjusted_addend(reloc)); + sym =3D find_symbol_containing_inclusive(sec, arch_adjusted_addend(reloc)= ); if (!sym) { /* * This is presumably an .altinstr_replacement section which is @@ -989,6 +990,17 @@ static int convert_reloc_secsym_to_sym(struct elf *elf= , struct reloc *reloc) return 1; =20 /* + * .rodata is a mixed bag of named objects and anonymous data. + * + * Convert section symbol references to named object symbols + * when possible, to preserve pointer identity for const + * structs like file_operations. Otherwise a section symbol is + * fine. + */ + if (is_rodata_sec(sec)) + return 0; + + /* * This can happen for special section references to weak code * whose symbol has been stripped by the linker. */ @@ -1009,7 +1021,6 @@ found_sym: static bool is_uncorrelated_section(struct section *sec) { return is_string_sec(sec) || - strstarts(sec->name, ".rodata") || strstarts(sec->name, ".data..Lubsan") || /* GCC */ strstarts(sec->name, ".data..L__unnamed_"); /* Clang */ }