From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9026CC35FE7 for ; Sun, 15 Sep 2024 07:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IeRHQu+yKzQUqrXbd5lul2wLwuoHFUxcLP2h5VUYKXk=; b=Xaib/pVEt1FLCcmd28rezM6lvT XboFa59bx7RGL1+kCLJ34chYgR/Y15cgExEaOaxcAnPO8soHLIk1JlWMqhTHnq6Z3RfFFjaePrlii gVZAmv269C0FaZjI3i3CiCILqnIcz0mPx09h/YmcOjk941jGTZq6Q0npZowzcIO4vwhcAxBNeUwP4 Z+bydFBy6RsRLf6p8w0MZZ3HW7QFjBmdLnKmo+ihzWO1lPgB2TZhxLZZoYWhO8xFQnnRmr98j6M4E cxJLhG5Bcceik/6N/VcpGb2Z0dLJaXJ6TO/nw02B2MLl+fG0OVAK1Cs7Eg+qhH7mOMLem1Jko3A+I hnHzGvqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1spjld-00000001jUE-1em7; Sun, 15 Sep 2024 07:33:57 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1spjkY-00000001jNX-06MJ; Sun, 15 Sep 2024 07:32:51 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a8a7b1c2f2bso566728766b.0; Sun, 15 Sep 2024 00:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726385568; x=1726990368; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=IeRHQu+yKzQUqrXbd5lul2wLwuoHFUxcLP2h5VUYKXk=; b=XjAq5RC2X8/iPD2UGRx65CUyToxLRNSIGRknh/fbVRlUp38BhIzP5nA00CZlbUedEC UiKR7MLYLty5ckxwlGCyFEIMZaKPlOwh3om2Su8V4ayw6qK1lukipEulDwl9RYhjMMit +PF6ZkA8pdyEvEo+H/8Rm1PBMWTTseC1s/gUMCA1OZTiXraFBvyJc1DcGrE+7MridNAW ixg6LQy79dbtZ80vl9WeIdkcnJtAr1qzr4ce+nTXM0ttiGngdmTWf9WJanmf/rWEj5Z5 Nb3gtnectFXsoXO8sMnRKKSs5mijug6M5m1ofsIBSDia8VHH7+ERqlGrAffstNQeC2lD bJ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726385568; x=1726990368; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IeRHQu+yKzQUqrXbd5lul2wLwuoHFUxcLP2h5VUYKXk=; b=WbWXDYFToDwokuVGrs4VXBf597EOlf2+c9Mzqk+wDOeBQ7JACYRZIsqGFmKaCfYjAF Cw7WPEqcUoF5jgOM9N9jPR7dBxNMOSb0ajrOICldVZBtIMjqODtlkCfxPUAiNcmGglGa hVqFU4p2LuEt4DmgMDbDT1LXuXxk4uW/ym4hv2h0oF7Her7O05s8Fj+DtTBdpzXNHsuS 8m2emySsvoZ5Pfm2NbiKkuZ6wxiJMjq+00A5+p+IsxnO0PJ7kYP+ZFn40Sh4ybdw4GRe 7Pbdjoecg8jTTXK5+UXJgjSBMhb96/phkf822203NX7kKvyhehnzjhU6yLxY2wVLD9rg yVrQ== X-Forwarded-Encrypted: i=1; AJvYcCU2neoMG2TZ/frmGrMKiWy0GiBOPl5QJkBc0mMUAPp45jXUwd2+lypktaL2NhkokrivsGyEepXNdMVrJfTG4R4B@lists.infradead.org, AJvYcCWfG3Vr1L1wVmUJTac9peMFy/WJLSS/ndLcr59oj0Si1F1FyqVn++vsL8RswA4J8iYxTZUIwkGWLXCqPLg=@lists.infradead.org X-Gm-Message-State: AOJu0Yxdnm/E+hONtw+lRVdgE2yezYLG4fmct8//8XJS887iwP8eyWVm MaZ3mT/cmS2ijRWsq1bRkzQMFOTIXKom1AH7CmM/IAmIVWodEuWH X-Google-Smtp-Source: AGHT+IGlHUAsnPjOFFuTn/tXNwH8GByOCS4k9zUVf6iXg3eJnbjo7p2RPWPflOmT8NKEozFzWvNMPQ== X-Received: by 2002:a17:907:e28f:b0:a8d:2ab2:c99e with SMTP id a640c23a62f3a-a9029730615mr1197571366b.55.1726385566847; Sun, 15 Sep 2024 00:32:46 -0700 (PDT) Received: from ?IPV6:2003:df:bf21:aa00:bafe:d6:9476:f8d4? (p200300dfbf21aa00bafe00d69476f8d4.dip0.t-ipconnect.de. [2003:df:bf21:aa00:bafe:d6:9476:f8d4]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90613205b8sm163145166b.188.2024.09.15.00.32.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 Sep 2024 00:32:46 -0700 (PDT) Message-ID: Date: Sun, 15 Sep 2024 09:32:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7] rust: support for shadow call stack sanitizer To: Alice Ryhl , Conor Dooley Cc: Miguel Ojeda , Paul Walmsley , Palmer Dabbelt , Albert Ou , Catalin Marinas , Will Deacon , Ard Biesheuvel , Jamie Cunliffe , Sami Tolvanen , Nathan Chancellor , Kees Cook , Masahiro Yamada , Nicolas Schier , Marc Zyngier , Mark Rutland , Mark Brown , Nick Desaulniers , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Valentin Obst , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rust-for-linux@vger.kernel.org, linux-riscv References: <20240829-shadow-call-stack-v7-1-2f62a4432abf@google.com> <20240913-shack-estate-b376a65921b1@spud> Content-Language: en-US From: Dirk Behme In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240915_003250_092113_C7930735 X-CRM114-Status: GOOD ( 26.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Am 13.09.24 um 23:44 schrieb Alice Ryhl: > On Fri, Sep 13, 2024 at 11:18 PM Conor Dooley wrote: >> >> On Fri, Sep 13, 2024 at 12:08:20AM +0200, Miguel Ojeda wrote: >>> On Thu, Aug 29, 2024 at 10:23 AM Alice Ryhl wrote: >>>> >>>> Add all of the flags that are needed to support the shadow call stack >>>> (SCS) sanitizer with Rust, and updates Kconfig to allow only >>>> configurations that work. >>> >>> Applied to `rust-next` -- thanks everyone! >>> >>> Paul/Palmer/Albert/RISC-V: I think you were not Cc'd (at least in this >>> version?), so please shout if you have a problem with this. >> >> For some reason I deleted the series from my mailbox, must've been in >> dt-binding review mode and hit ctrl + d. I've been away and busy, so my >> apologies Alice for not trying this out sooner. >> It's sorta annoying to test rust + scs on riscv, cos you need (unless I >> am mistaken) llvm-19. llvm-18 + rust built fine, but has no SCS. >> >> llvm-19 + rust failed to build for me riscv, producing: >> >> In file included from /stuff/linux/rust/helpers/helpers.c:22: >> /stuff/linux/rust/helpers/spinlock.c:10:23: error: call to undeclared function 'spinlock_check'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] >> __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG); >> ^ >> /stuff/linux/rust/helpers/spinlock.c:10:23: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Wint-conversion] >> __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG); >> ^~~~~~~~~~~~~~~~~~~~ >> /stuff/linux/include/linux/spinlock.h:101:52: note: passing argument to parameter 'lock' here >> extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name, >> ^ >> 2 errors generated. >> >> This occurs because I have DEBUG_SPINLOCK enabled. I didn't check why, >> but Andreas seems to have introduced that code - luckily he's already on >> CC here :) >> >> With that disabled, there are dozens of warnings along the lines of: >> /stuff/linux/rust/helpers/err.c:6:14: warning: symbol 'rust_helper_ERR_PTR' was not declared. Should it be static? >> If those are okay for rust code, it would be rather helpful if the >> warnings could be disabled - otherwise they should really be fixed. >> >> Following that, I got a build error: >> >> error[E0425]: cannot find function `__mutex_init` in crate `bindings` >> --> /stuff/linux/rust/kernel/sync/lock/mutex.rs:104:28 >> | >> 104 | unsafe { bindings::__mutex_init(ptr, name, key) } >> | ^^^^^^^^^^^^ help: a function with a similar name exists: `__mutex_rt_init` >> | >> ::: /stuff/brsdk/work/linux/rust/bindings/bindings_generated.rs:12907:5 >> | >> 12907 | / pub fn __mutex_rt_init( >> 12908 | | lock: *mut mutex, >> 12909 | | name: *const core::ffi::c_char, >> 12910 | | key: *mut lock_class_key, >> 12911 | | ); >> | |_____- similarly named function `__mutex_rt_init` defined here >> >> error: aborting due to 1 previous error > > This looks like an unrelated problem to me. Yes, it is unrelated to this change. It is PREEMPT_RT usage related. I think we could add something like #ifdef CONFIG_PREEMPT_RT void rust_helper___mutex_init(struct mutex *mutex, const char *name, struct lock_class_key *key) { return __mutex_init(mutex, name, key); } #endif to helpers to fix https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/rust/kernel/sync/lock/mutex.rs?&id=6d20d629c6d8575be98eeebe49a16fb2d7b32350 ? Explanation: Looking at https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/mutex.h?#n52 we have (simplified) #ifndef CONFIG_PREEMPT_RT extern void __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key); #else #define __mutex_init(mutex, name, key) \ do { \ rt_mutex_base_init(&(mutex)->rtmutex); \ __mutex_rt_init((mutex), name, key); \ } while (0) #endif So in the CONFIG_PREEMPT_RT case bindgen doesn't resolve the macro what could be fixed by adding a helper. Dirk > This patch only changes > the rustc flags, but these errors have to do with the Rust > helpers/bindings, which get generated before the rustc flags are used > at all. Most likely, there is a problem under the particular > configuration you are using. Were you able to reproduce these errors > without this patch? > >> I stopped there, Space Marine 2 awaits. >> >> Hopefully I'll get to say hello next week, >> Conor. > > Thanks for taking a look, and see you at Plumbers! > > Alice >