Message ID | 20240223-perjury-preshow-fc2cf73d552e@spud |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp588781dyb; Fri, 23 Feb 2024 05:39:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFJvsc5kKOMBGuPC7q++ZHJAWcoBGqrJcwD+av0j5hqKLk7KP4fQuh3sKyMypAr2e03jcgvdj2ci/oxbh6o8pWPeu34Q== X-Google-Smtp-Source: AGHT+IHX6V3C9jq0k6X772DswnNfIG9pd1nZEc2+zmOll/ThSwSTmlpd/ww70vuAj9OrQp59uRG8 X-Received: by 2002:a37:e30a:0:b0:787:680b:120b with SMTP id y10-20020a37e30a000000b00787680b120bmr1966283qki.23.1708695576102; Fri, 23 Feb 2024 05:39:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708695576; cv=pass; d=google.com; s=arc-20160816; b=LWatKew9FJ7myzZ6TKnTwQtPRsRtBRa0BonHrOUpE4yjiE4PQAOtcNqJKsc84Mve4X 2qFx+QdIQPYFBdPr8V+Lr0lA78ngItatutZCjbWGPy+16N72USnrXkKo4+jXPt9Q+2D9 s66USZ3Ws6A4JhiPWyNaKPso7HSBabWk7XlK2njrCZhVrPlzHPJe6OaDAgfcCNZoARby d6sQ68LjTqZJxy9tZqvU6Gx5i6Ko0ZfeWSJn/UZozhBzMc6pnd7F/X+XG5cbjqqEUtN0 buFjU3J7hl0UQ48e5UCs4kC1q4EhbD+5MZXNAH6eTeypC8rosKobYKQZrqLewU9WLn1B 7npQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5hqF9w8DFgVKR/Eyrd2ddO5zxVEwtUx0qQpGMlIJntQ=; fh=jXAL6cDlEDHkZNd0n3MBuX9Vxi0pyun7LxUg18Vx5PA=; b=A+DlUIRhq66WBdy/T2Nfp3dU/o9HCVZKYEN+3wLxQ4CN8vOEz2DNtws7diFzDmUFrq RX3h8/2k2vjMzlhPgU+s//cDoKh47gZPHhzCQjY8qzLbDpTs0PxpGjN+Tii2vfHkFqA1 k9PlFPjyUDWfQFztVXtUbbD2jE2mWCM5w/mYqTUFseWj+y+NrGwQpYFTjeKfgZBUVB+T QG0EMwfpBBJt5JfqzLjo7RETu/+f1oSZP/tTV92SJPQM98hauLDnNPd2RxX3ivqr1Fh0 1qiEaelHTid4kpdgfKUFMiGGCNoZtyiIzll2yn09IRkpCk+Jr3u605PCXA4RrFXJZOC+ 1wMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Na5p+TP8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v10-20020a05620a0a8a00b00787b7f02325si596429qkg.428.2024.02.23.05.39.35 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:39:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Na5p+TP8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DE77A1C21AFB for <ouuuleilei@gmail.com>; Fri, 23 Feb 2024 13:39:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 390F781ABE; Fri, 23 Feb 2024 13:38:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Na5p+TP8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 84B137FBA7; Fri, 23 Feb 2024 13:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695517; cv=none; b=kBZSFmSfE/Jn3LdahfFsWEAwaF7nRMeGOwzPWlo5WCGZGbWC+jZVMC19g5mAXtHYBlUwW1OCChZTzj5tr3r7XmX3OfWwzu+qT7xV0Jm+kNw73u9cXmzlkzh+or7CjQwbwdZowrMlSXdOce8UzFbaZhSL+AWBgcVsXZAOSw9Az/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695517; c=relaxed/simple; bh=VltUvQLlmLwkpl8kRnLO58R3H1pbUYjiNeAYAhm4vK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QaJ/c/2exwFYr1WSrg1BoI1QlYDXCqk0PchzXrx/RWF8J1/TPYimKKSI+VjDa67THgBilCwWf6dJ0jucvN6y9fcuk/T16lBSh4Tyv5DNVL8V+NGF8H060BAU4pTDMqQo6hI3AE68nxlnPwYa3r+mmCMN/x3ZYuqeqoIYEmjHiB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Na5p+TP8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 611A5C433A6; Fri, 23 Feb 2024 13:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708695517; bh=VltUvQLlmLwkpl8kRnLO58R3H1pbUYjiNeAYAhm4vK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Na5p+TP86HhyZXIS9INaL8dQBTOiswdRzULSa5FNq46+4a22pnBtTtloyqFR8cWc8 n8yn1MMy2W7P2cqPCBcS0OBpjP8xSadnJJcXmWRnWauvwKGLaTU4cll8SATYAhUv17 cYr9GnNe6g5JhklC6GcTpLtBe8w85TjlaGno0uWLbIrlH/aNG/uJRDYpZM3bkdYj3O 6K09xONc0jMaq1Kpvw0KdV/Jv/lw63QSQ/NRvdyygkYqtcjNvcy+e76orulwxLVITl SAMd1plaBCYXZCO4bQkgBlK3+NOpjLRsMt5hBqFLEl/aBsq/mk/quDjslSCEZG5OE4 rVGmCyn2+AIGw== From: Conor Dooley <conor@kernel.org> To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley <conor.dooley@microchip.com>, Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com>, Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Jonathan Corbet <corbet@lwn.net>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, stable@vger.kernel.org Subject: [PATCH v2 1/3] rust: make mutually exclusive with CFI_CLANG Date: Fri, 23 Feb 2024 13:38:03 +0000 Message-ID: <20240223-perjury-preshow-fc2cf73d552e@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223-leverage-walmart-5424542cd8bd@spud> References: <20240223-leverage-walmart-5424542cd8bd@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1069; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=CGpXuPYcXKOyMHoYWd5SM3467xfR+bc0vpqwYOI3iyQ=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDKk35u8JtHm+ZsH5Sc/CPbpmzj1yYUtL5lVNtfKQGyezj SYVXz8p0FHKwiDGwSArpsiSeLuvRWr9H5cdzj1vYeawMoEMYeDiFICJzJRhZHj+yWvHNJapDg0f b5+5HpMl+Cir0HdTfvXKf1lxFjVqwf4M/4v2a3lvq1kyS7umuGfKg7ig3pUBuwU4+zsuViUvVFZ YygsA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791697172579580783 X-GMAIL-MSGID: 1791697172579580783 |
Series |
RISC-V: enable rust
|
|
Commit Message
Conor Dooley
Feb. 23, 2024, 1:38 p.m. UTC
From: Conor Dooley <conor.dooley@microchip.com> On RISC-V, and presumably x86/arm64, if CFI_CLANG is enabled loading a rust module will trigger a kernel panic. Support for sanitisers, including kcfi (CFI_CLANG), is in the works, but for now they're nightly-only options in rustc. Make RUST depend on !CFI_CLANG to prevent configuring a kernel without symmetrical support for kfi. Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support") cc: stable@vger.kernel.org Signed-off-by: Conor Dooley <conor.dooley@microchip.com> --- This probably needs to go to stable. The correct fixes tag for that I am not sure of however, but since CFI_CLANG predates RUST, I blamed the commit adding rust support. --- init/Kconfig | 1 + 1 file changed, 1 insertion(+)
Comments
On Fri, Feb 23, 2024 at 2:38 PM Conor Dooley <conor@kernel.org> wrote: > > configuring a kernel without symmetrical support for kfi. Nit: typo. > This probably needs to go to stable. The correct fixes tag for that I am > not sure of however, but since CFI_CLANG predates RUST, I blamed the > commit adding rust support. Cc'ing Matthew et al. in case this is a problem for them, but I guess we can relax it later as needed. Cheers, Miguel
On Fri, Feb 23, 2024 at 03:45:10PM +0100, Miguel Ojeda wrote: > On Fri, Feb 23, 2024 at 2:38 PM Conor Dooley <conor@kernel.org> wrote: > > > > configuring a kernel without symmetrical support for kfi. > > Nit: typo. > > > This probably needs to go to stable. The correct fixes tag for that I am > > not sure of however, but since CFI_CLANG predates RUST, I blamed the > > commit adding rust support. > > Cc'ing Matthew et al. in case this is a problem for them, but I guess > we can relax it later as needed. I suspect that nobody has actually sat down and tried it. I did try to test it but I ran into too many toolchain issues - my older copies of LLVM (pre 17) are not multiarch as I built them by hand with PGO for x86 and RISC-V. My LLVM 17 is from kernel.org and has no libclang. And then the copy of LLVM 18 on kernel.org apparently does not support kcfi at all. I gave up there, but I don't see how this would not be a problem on other arches, given rustc never gets told to enable kcfi. Cheers, Conor.
On Tue, Feb 27, 2024 at 11:54 AM Conor Dooley <conor.dooley@microchip.com> wrote: > > I did try to test it but I ran into too many toolchain issues - my > older copies of LLVM (pre 17) are not multiarch as I built them by hand > with PGO for x86 and RISC-V. My LLVM 17 is from kernel.org and has no > libclang. And then the copy of LLVM 18 on kernel.org apparently does not > support kcfi at all. I gave up there, but I don't see how this would not I asked Nathan to add libclang a few days ago, and he very quickly did it for LLVM 18 -- though I don't know the plan for the others. I just pinged in that thread. Cheers, Miguel
On Tue, Feb 27, 2024 at 01:34:14PM +0100, Miguel Ojeda wrote: > On Tue, Feb 27, 2024 at 11:54 AM Conor Dooley > <conor.dooley@microchip.com> wrote: > > > > I did try to test it but I ran into too many toolchain issues - my > > older copies of LLVM (pre 17) are not multiarch as I built them by hand > > with PGO for x86 and RISC-V. My LLVM 17 is from kernel.org and has no > > libclang. And then the copy of LLVM 18 on kernel.org apparently does not > > support kcfi at all. I gave up there, but I don't see how this would not > > I asked Nathan to add libclang a few days ago, and he very quickly did > it for LLVM 18 -- though I don't know the plan for the others. I just > pinged in that thread. I had actually said it to him on IRC already (although he is CCed here) but I just noticed that this was my fault - I symlinked incorrectly after downloading the toolchain. kcfi is detected fine with llvm18. I'll give testing another try.
On Tue, Feb 27, 2024 at 01:02:17PM +0000, Conor Dooley wrote:
> I'll give testing another try.
Yah, it is (as expected) broken on arm64 too:
CFI failure at do_one_initcall+0xec/0x26c (target: __rust_minimal_init+0x0/0x64; expected type: 0x36b1c5a6)
Internal error: Oops - CFI: 00000000f2008233 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.8.0-rc3-00002-g724a75ac9542 #10
Hardware name: linux,dummy-virt (DT)
pstate: a0000005 (NzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : do_one_initcall+0xec/0x26c
lr : do_initcall_level+0x8c/0xb0
sp : ffff80008000bab0
x29: ffff80008000bda0 x28: 0000000000000000 x27: 0000000000000000
x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
x23: 0000000000000000 x22: 0000000000000000 x21: ffff18d941cb0000
x20: ffffb8f6d6d9f000 x19: ffffb8f6d63e8b18 x18: 0000000000000002
x17: 0000000036b1c5a6 x16: 00000000d65f03c0 x15: 0000000000000000
x14: ffff18d9420280b1 x13: 0000000065dde380 x12: 0000000000000017
x11: 0000000000000000 x10: 0000000000000000 x9 : d4db8c0058e7e300
x8 : 0000000000000000 x7 : 0000000001f4c18b x6 : 0000000001f4c18b
x5 : ffffb8f6d6d300a0 x4 : ffff80008000ba78 x3 : ffff18d942019860
x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffb8f6d63e8b18
Call trace:
do_one_initcall+0xec/0x26c
do_initcall_level+0x8c/0xb0
do_initcalls+0x54/0x94
do_basic_setup+0x68/0x78
kernel_init_freeable+0x100/0x16c
kernel_init+0x20/0x1a0
ret_from_fork+0x10/0x20
Code: 7298b4d1 72a6d631 6b11021f 54000040 (d4304660)
---[ end trace 0000000000000000 ]---
note: swapper/0[1] exited with irqs disabled
note: swapper/0[1] exited with preempt_count 1
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
Kernel Offset: 0x38f655800000 from 0xffff800080000000
PHYS_OFFSET: 0xffffe72700000000
CPU features: 0x0,88000203,3c020000,0100421b
Memory Limit: none
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
Cheers,
Conor.
diff --git a/init/Kconfig b/init/Kconfig index 8d4e836e1b6b..6cf05824859e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1895,6 +1895,7 @@ config RUST bool "Rust support" depends on HAVE_RUST depends on RUST_IS_AVAILABLE + depends on !CFI_CLANG depends on !MODVERSIONS depends on !GCC_PLUGINS depends on !RANDSTRUCT