From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381001; b=RwfgAIIbpcJWY6edV9vCb2DixMU+JPinB1ouwz15HfETVAaLSn+j+QtzCQMzemLFMazN MWh6eLJkXSiX02TMXIn1W9/v4E3Qu4bW69ClRqffMxQ4xQzPioL6BqzLDwodg6goqKwxL iaQzpEEUwby+Tm7Eu7RztnTkMltFJXqjNTmKzq9fDXc2wWpArw453fll9ppLj8vNKVuD3 aKX6BNwSQEj6N47jGA2ngzwXa6/NO6FLkT67az+hnvEuyHZZUaMfCiLvofjZzBjIXXQds Eq4lPNUj+5FsUxzhkCU97rX5Q062iOoGfYbC0Yr0RXLuLHcMX3ml579+FMT/zMYKCkg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381001; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=T/8UclU/kPxgT4v/VjqB/kckMlywE4kZhlfhspFQWRw=; b=3Pl3bgDZAQp87z8zTuVKu/HrZZ3rLi/tp/bnK73ESKEE/iRcqjVFFGn0FvBRxLbYfezo urNuJGloMZPCDk1ks/HrMl4qpxwkv+Pira6e//9iY8bNVX7pahd+M6uAm4t9yLtWBPb4F kGpIGSK4Vmo4ozuxMeQq0C4KM6Ti5gArN+lnEp2XAEZx7FgT1xlt9VBG6gTEBXqDBe0QE bzAo7+KPsgy94n47PbGSu8h2gCWoP+tp99YaI9hAXgBG0/uzWWDbXRBetMay9+J3OY+44 ND+EsF2OB54iaIrN6kARRaxuckz6OVCJH7U5H/rdDS/KHpdzsS74/Mz0QxCtPDfVBUw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0hAz1qKb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5C6A606A322; Fri, 4 Dec 2026 10:43:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0hAz1qKb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F61C1F000C2; Fri, 4 Dec 2026 10:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381001; bh=T/8UclU/kPxgT4v/VjqB/kckMlywE4kZhlfhspFQWRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0hAz1qKbsz7JGemgFCny0NVBfpyrCxDyx0aNlS5JToGlugP46rr7ynbLzVTn3FXSg s/PvMFas1C3TGRuM7FEBNJiYVARCfw4wqrLi1otPjqUm/SFS95N2cRBpcBhw0F27RD XUUTanTq4r8x1z2uaJLW3rXKSpNzHCePUkltFguY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alice Ryhl , Gary Guo , Sami Tolvanen , Miguel Ojeda Subject: [PATCH 7.3 514/742] kbuild: rust: disable function merging unconditionally Date: Fri, 4 Dec 2026 19:06:18 +0900 Message-ID: <20261204100648.806318653@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alice Ryhl commit 73bdf8773de4af2c2b7f49370191ae6d5aeddea5 upstream. Function merging causes various different issues: * For CONFIG_CFI there's an LLVM bug causing functions with different CFI hashes to get merged. This can lead to crashes at runtime. * For gendwarfksyms it causes functions with different CRCs to get merged. This leads to broken MODVERSIONS information if the function changes in the future so that it can no longer be merged. * Wrong backtraces when a crash occurs in a merged function. * Possibly also issues with pahole/BTF as the merged function's debug info is lost. These issues are new to Rust because in clang, function merging is off by default, so these things have never come up before. Because of this, turn this option off for all configurations. [ The LLVM bug is tracked at [1]. Nick asked what function merging refers to here, and Alice writes [2]: No, this isn't linker ICF. rustc doesn't pass --icf, and in any case kbuild invokes rustc with --emit=obj and does the final link itself, so rustc's linker arguments never come into play. What I'm referring to is LLVM's MergeFunctions IR pass (llvm/lib/Transforms/IPO/MergeFunctions.cpp). It runs as part of the optimization pipeline, within a single codegen unit, before any object file is emitted. Clang only enables it with the cc1-only flag -fmerge-functions, which the kernel never passes, so C code in the kernel never sees it. rustc, however, enables it by default whenever optimizing for speed or size (opt-level 2, 3, s or z), which covers both kernel configurations. It uses the "aliases" mode: when two functions have identical bodies, one is deleted and its symbol becomes a GlobalAlias to the other. You can turn it off with -Zmerge-functions=disabled. - Miguel ] Link: https://lore.kernel.org/all/avy_9SPRaPSKD8b4@google.com/ Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS") Signed-off-by: Alice Ryhl Cc: stable@vger.kernel.org Reviewed-by: Gary Guo Reviewed-by: Sami Tolvanen Link: https://github.com/llvm/llvm-project/issues/217629 [1] Link: https://lore.kernel.org/rust-for-linux/CAH5fLgidhnPbP=xXQ3162w6q0U6rWHPZ9Mu6-E5va4_CXyanOg@mail.gmail.com/ [2] Link: https://patch.msgid.link/20261118-rust-merge-functions-v1-1-fe86126522b9@google.com Signed-off-by: Miguel Ojeda Signed-off-by: Greg Kroah-Hartman --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/Makefile +++ b/Makefile @@ -617,6 +617,7 @@ KBUILD_RUSTFLAGS := $(rust_common_flags) -Csymbol-mangling-version=v0 \ -Crelocation-model=static \ -Zfunction-sections=n \ + -Zmerge-functions=disabled \ -Wclippy::float_arithmetic KBUILD_RUSTFLAGS_OPTION_CHKS := @@ -1129,8 +1130,7 @@ endif ifdef CONFIG_RUST # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects # CONFIG_CFI_ICALL_NORMALIZE_INTEGERS. - # Disable function merging as LLVM incorrectly merges functions with different KCFI types. - RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled + RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers KBUILD_RUSTFLAGS += $(RUSTC_FLAGS_CFI) export RUSTC_FLAGS_CFI endif