From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id EE6C880031 for ; Thu, 26 Nov 2026 06:13:20 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AQ6C7bq006029; Thu, 26 Nov 2026 09:12:08 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AQ6C7bq006029 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="v5B2piiN" Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AQ685iM005397 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 26 Nov 2026 09:08:05 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AQ685iM005397 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-c505eecba6cso527367366b.1 for ; Wed, 25 Nov 2026 22:08:05 -0800 (PST) X-Gm-Message-State: APuU4Z/xMevaRWykC155w9R87LQ/kMZjtlBx4htu3DNu+3Apuo0v+2zh ukRwS8hMdIsbeGV7sapDD29SToGrnjIw8wE/C4vK3TF/Oh4vp5AcZTNuQQ9FqnbJy5ULX7ip8K1 c1M9IeTeYuE4fkGcPW7XV7uEf6YpC/vDTVV+S1CfuItRq3DVvVHmRHQ== X-Gm-Gg: AZFdTZdHnZbSUFzqvRNl7+Fve8YXQr2jHxmfVHqts5bYn3G6GVxwzix3Fez0HbtFN5F Q7KUfLKYOfFzO2bacJmDvXZpqeIr9KJJMYa0OhDWxrl4C1FTfpKzWeiBNRWKZ6at5b5CcuwvVjN G1LJ7dmxa1FhmLEEL3Mnhyt/pLRH1UJdMn2tSlJRoAsk422eB+bqRP7vfWriu52pKl5phETGsDk 4OI69po03+vPbsezEKeZIWUKbC7HFCETtYLfJSKDWeBTN0bHnmALyNCsr00hI080jljJhvpaKKT BP8bqSMi4Wqjss4ICNuxVzYYGOpZYQZnG6m308hTsk0xwdPtxbMBv8OPO1W7ktB81z0c5DBn1b0 HwwxrYegdyWp7HvFFSE6vJ16c X-Received: by 2002:a17:907:9625:b0:c49:c76f:dad4 with SMTP id a640c23a62f3a-c513ab36170mr1787089666b.31.1795673285097; Wed, 25 Nov 2026 22:08:05 -0800 (PST) X-Received: by 2002:a17:907:9625:b0:c49:c76f:dad4 with SMTP id a640c23a62f3a-c513ab36170mr1787087966b.31.1795673284570; Wed, 25 Nov 2026 22:08:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795673284; cv=none; d=google.com; s=arc-20260327; b=Xa9fTeSMLw5lKdHm5huQxUQXxTm7X7HkzBlwWi6+rmgvTmCNEPbp9v+K/7yZjSpJOC bj9cuGtonOWdrEZd+vVi56RvVg3/tMECqchLL46oxnIUzEqwRtv7lglIpLQEgpCTJ4NK 8RF/q7zjUOBmutFcCtVdRZQwXxpGEGWL0b451KoUtqvWPIcqcUqImZEkqK2OOXuff+oI l16xEBSNTWbs5HElxHmsRsBTpuhOxRpuFzyZmztaRpbgqcgw6O2bBvhvZBrYF4pvWNdp BjyqNlLg8iBoGa2EltMMlnnZ40xIbB4WWe8xHGeJn6cLkyRYeV3Uf7BN81PrtmxNANGr SZaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hRVDlwencSQBc0v6V9U/a95QcHD8NkZ1Hk7eOnR+dgU=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=SA9UYkwlJ0o6rGcioT6LOftRz34aOJMvLlZ8F6kmZObagMS/TFtC3dErQOyc9A9F9L 9tjYmsPHvBvmsknx/5CdvBLZsBWNrox6yrgET7Mm9Spar+3uvdpamTEl3hl688AgbeCs zQ6iUDKrWt/b6bIsLKWpS7IXpNCzfvquBNR/o+5NSDJyPpgy8sT7XGR8axsUAUqCX71J FLyGiq93ccwE61mXMHX/IYLO9xx1UhV+qzXEm36qvtdnhYIWkV8gLxuyeGtf9/dWGMbr hzmKt+HFLW6KCySPDQJeUJwLDWrd9E9h8IeghCHkkjSgWvgQFbtcLUox6TfrqQVacjSz f/lQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=v5B2piiN; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id a640c23a62f3a-c513afe3a4esi1281794566b.66.2026.11.25.22.08.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 22:08:04 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=v5B2piiN; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=hRVDlwencSQBc0v6V9U/a95QcHD8NkZ1Hk7eOnR+dgU=; b=v5B2piiNWkAl cAb9OrRRRwMWwGGGRQUJZ/iSgRgEpLVallFavOyID99IJGVv+/rmWQl3atQKcjlol/I8VbOD8wARl JVe8oGnml20i0BAWl86+30XXk757N/xXuwopNiVtb1t6OxBFZTzVfK4HkPj6qWZaAU5rpscawH4Hm k5M3QdC0XjXkeXBAfTpc7o5IiXklCok8r4GPdDIyl5qDFhyaWZ1ktHElT35S1O2Z5FRACTwGgburK /9aGeJLp2sFKqeASAUVfMhALhrS+cxrBZpc2iukcrE2Js+OmZFMm0sdtOKzNIE+f5fosClzqOCU/+ 9y5BNRJl4ZLnRTKDZuZxqQ==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xWScp-00E8nT-1p; Thu, 26 Nov 2026 07:06:42 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Thu, 26 Nov 2026 07:07:12 +0200 Message-ID: <20261126060620.2126341-15-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126060620.2126341-2-eva.kurchatova@virtuozzo.com> References: <20261126060620.2126341-2-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v2 13/28] ms/objtool/klp: Fix pointer comparisons for rodata objects X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Josh Poimboeuf 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 == &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 (cherry picked from commit d5b0f025281f287759820f57b7ba1bac7827b338) https://virtuozzo.atlassian.net/browse/VSTOR-128510 Feature: klp-build support Signed-off-by: Eva Kurchatova --- 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 a1cbaba7e1c1..9f1ebb643686 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -223,6 +223,20 @@ struct symbol *find_symbol_containing(const struct section *sec, unsigned long o return sym; } +/* + * Also match the symbol end address which can be used for a bounds comparison. + */ +struct symbol *find_symbol_containing_inclusive(const struct section *sec, + unsigned long offset) +{ + struct symbol *sym = find_symbol_containing(sec, offset); + + if (!sym && offset) + sym = find_symbol_containing(sec, offset - 1); + + return sym; +} + /* * Returns size of hole starting at @offset. */ diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index fd2afbbee903..bc1f604fc67a 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -186,6 +186,7 @@ struct symbol *find_symbol_by_offset(struct section *sec, 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 char *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 offset); struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset); struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec, diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c index 55208c6edfc6..2f1cedf9632b 100644 --- a/tools/objtool/klp-diff.c +++ b/tools/objtool/klp-diff.c @@ -352,6 +352,7 @@ static bool dont_correlate(struct symbol *sym) is_uncorrelated_static_local(sym) || is_clang_tmp_label(sym) || is_string_sec(sym->sec) || + (is_rodata_sec(sym->sec) && !is_object_sym(sym)) || is_special_section(sym->sec) || is_special_section_aux(sym->sec) || strstarts(sym->name, "__initcall__"); @@ -837,7 +838,7 @@ static int convert_reloc_secsym_to_sym(struct elf *elf, struct reloc *reloc) goto found_sym; /* No dedicated section; find the symbol manually */ - sym = find_symbol_containing(sec, arch_adjusted_addend(reloc)); + sym = find_symbol_containing_inclusive(sec, arch_adjusted_addend(reloc)); if (!sym) { /* * This is presumably an .altinstr_replacement section which is @@ -846,6 +847,17 @@ static int convert_reloc_secsym_to_sym(struct elf *elf, struct reloc *reloc) if (!sec_size(sec)) return 1; + /* + * .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. @@ -867,7 +879,6 @@ static int convert_reloc_secsym_to_sym(struct elf *elf, struct reloc *reloc) 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 */ } -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel