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 5CD0280027 for ; Tue, 24 Nov 2026 05:09:06 +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 6AO57uA4010013; Tue, 24 Nov 2026 08:07:57 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AO57uA4010013 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="oDZ3odCc" Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AO57rA2009985 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 24 Nov 2026 08:07:53 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AO57rA2009985 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6b6fb975053so3842400a12.0 for ; Mon, 23 Nov 2026 21:07:53 -0800 (PST) X-Gm-Message-State: APuU4Z9fNASOOsm03wB5Vq2I8RK8akH1xicqXco5anV5anfmVGjD9Swz 8q9T6iLce9JB1D7l0cF04JhdMnUO5RyzojubGl2n2NE8DLkrYCK8zDdho/c3FTw2oqAwmgt9YO0 8cYMC68zkaOvFAXcclullgbhVN9GCvxIVhyNp8WQ26wdmOiLUMRTrhA== X-Gm-Gg: AZFdTZfi0EBJlwyzMsDNFKvJeHUQ0UBXWRhP8lDjaU2jpT3pqhUz4tP2RrKKuZyt4V7 matP06ajySHKi5o0X+iduvj+3uQrV1DhIasadiwLoY3U06hF/475rWaheBzmFAlPWCeuHbjgNwX PlWF5oFXFZUd7RDqbG2cYtIHYeIbTs1iqibIwMXCeg+T7VUFkDe1X1YEL/LPNIwVvr+RGaQFjhW sljMUYGkcW82JR4qRBGLJmesCacxPs4dKnLZdd6aSwZ1aBsntMA0ZK2ejkL85oASzfZc1EdCZ7q QwJ7UM4Cb9R9L6Ye7l7qpZYL/xD+JhwdGf7/U8X0QO3RvfRm5IpV9U+9m92nHqkGFXuw4MhstJQ 0FSL2u+cFR5VwkMpDfBi/ip8Q X-Received: by 2002:a05:6402:c88e:20b0:6ac:73f8:2e4f with SMTP id 4fb4d7f45d1cf-6baeabf0025mr939524a12.29.1795496872981; Mon, 23 Nov 2026 21:07:52 -0800 (PST) X-Received: by 2002:a05:6402:c88e:20b0:6ac:73f8:2e4f with SMTP id 4fb4d7f45d1cf-6baeabf0025mr939518a12.29.1795496872564; Mon, 23 Nov 2026 21:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795496872; cv=none; d=google.com; s=arc-20260327; b=jFSodvUzbjhU5HuTuQuCkKyqt4cDCIS0Raii4jGBUfZNoQOwvhva6W096GwN99f43s D0OyRjmu7bJ6SRMgOn5Tx5bNSX+6FWdkQyztAJQdiV4VF4QciK8JCaWa/86mTS1m8vWy fm4ecoRATfGKXrxIsagH7iTgYF1x51ys+SfggfirYTpxutPVstCQugsQqBhdD31ig38q he9nMJXK1g69eu+sj45LfhmTU3JyJjE/ppYzdbrry2yduLFZrw8RjNcyGgovJQuFhKaT 3lZE5rVRILaQ+2pnaQbSXIi+ctYOi3PiBIWRh2j9POXrdYqRFRG3E4pNNJFkREHkRcpX uYlw== 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=kOnYrHwfbiT9uP7j9Xw2u1HDvZY92HTLVe6xb+GC0naUgePHUNwt/YqJXK8GYRoHyE /sPY7G3e1FxmVyMxuv++wkvampGr/3dbaKUwMg2/rPjfG3SygBsTs8KNKG69Z5EpYcvK VM33k6A4nGTzWm5CbjgcM4SnOUkfIXskI9rXVuT7adhSXBzuP7FxCtDcrw3cPc+cY9bU HqMCHhiH9ORPQnw/3myl88h427yDd99QOSDsVeHf4APYDKJx6ZBfmqBUYAg0akwhWx3C Ala+ojbWrV3XvB8dTzaxVD+J5Yp08pnmeRFfAdnJBwQFBYXlk3OnsWULWHSGSza3cDtl mm+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=oDZ3odCc; 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 4fb4d7f45d1cf-6ba6f749c16si7837964a12.265.2026.11.23.21.07.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 21:07:52 -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=oDZ3odCc; 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=oDZ3odCczEnb 0Y20FEdyEoWG1oFCs6pxjgO+bgUCfshnVWqOGvREbSEVul/9zpeC2lOmDqsQ0E3s76dw8wwlDEAoK PObeJLEaS5qwUeR7FUwzmVETlyLp2KX0mxSRyDNZWufDGVZomZRql8AhzxgryI/n6je/HPTwIhsyP r8D9GJRrkOwb50SeCGhjRKMtudW/w3ZuLaXAjUK65vZUHJH4zrsEECC21Dguyd6/Ym327jsWrzj1O wRIjfri2EyzdzNIh8XLiUY5v1DH6xnQnAs/gj6dNvcFUCMCu1BglH0V+ul55l1i0/+3WtHqVVYWWM DHnuDtjpeDfzUOmGFGEBgQ==; 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 1xVik0-00CaJZ-1W; Tue, 24 Nov 2026 06:06:52 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Tue, 24 Nov 2026 07:01:02 +0200 Message-ID: <20261124050655.1853940-14-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261124050655.1853940-1-eva.kurchatova@virtuozzo.com> References: <20261124050655.1853940-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 13/17] 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