Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp352413lqs; Tue, 5 Mar 2024 04:14:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTmBRgV+//USY2VZS30QtOOvSGN7s9qbfoGrE4OLgMuWiYbciS4yM1mXHj1tKV1i7jIHGn1SKfoz8QSWeh0W/6y1I8eDxom1yKgPbw0w== X-Google-Smtp-Source: AGHT+IFFy8VWKgk27ko8ht0+77VrIRiFRMtjiXgOYemNS0rlZWZ6BuIljErWCcMj6Dvc9h+PB1bW X-Received: by 2002:a05:6358:70b:b0:178:e2b3:98da with SMTP id e11-20020a056358070b00b00178e2b398damr1464762rwj.28.1709640892860; Tue, 05 Mar 2024 04:14:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709640892; cv=pass; d=google.com; s=arc-20160816; b=eaE5dgU0MdVI5FD9rLat6kaKMmxWKZjx7kUrjRFSemS/2ScGT4519erEMSwEoWBx4A P95FzsEYcn2lq/xoHrrvdl+j7a+1/QxSXHUSmSPJ82XHxVjbEhxlco7gRH2tPpYwQlwi W8VtJU7nQ4+pzLdrJkB6d3kvlUE5DbjoiuhEimxeai3Z0QPpvPm5Ug2zxI7eZXnGE22E mY8/2psSp1b3l22UXb4JQGSjSSrtHUIGnq+zr/0KM6U1ddLzGWJYuUax241GIyDdgsO7 MHBJL+RAtX4ipwcJh9tbudMZyz3DxExKC9s5qrc51tGWu/InUbCnorGmjqwr54TG/CFz ZS4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=0JSSs1/ECQnp69yxT4x70rgh4SNZT8QM+eo7Dzqxqt0=; fh=H6rmwDZMVUjoM6BOFVsNh1NEiip45yDRxVTbuPyLXhY=; b=0yeo2r7kOPkCn18QRp/sttn2j5D+IXjbdZ4Qv4EHXlCZXUqnkS02mb219x66MOTWpC SGz7aFRL36ttBE3vaYzTSepaxzJHaWqo4k1btDPFRAc2srIczWTE8BlolbSitZXhLNFY n7hL/r2Yy42SZYeArhmSTV4KEmhd4ydXappV0p23VIbMA35Lqh+q28jV60vwwdb8//sw ZwFWU/6f/zReYaTeVgPEQR+eksRE+4T2FibM+dljMd3oDmVQ+16zbfuVHOp0N33cfQ3G fhQ9evtpy9Ju5bZgB8sGCpX3NuiIPOF03IUkwtOmcbUiVDsvtFRLdcw3vybxWdLnC2e3 Bk3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eLOgbIcw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-92336-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92336-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u12-20020ad45aac000000b0068fb7e2785dsi12362043qvg.517.2024.03.05.04.14.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:14:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92336-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eLOgbIcw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-92336-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92336-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 7E5291C2445F for ; Tue, 5 Mar 2024 12:14:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1D2C5A4CF; Tue, 5 Mar 2024 12:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eLOgbIcw" Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 850315A114; Tue, 5 Mar 2024 12:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640874; cv=none; b=i3UatXFoGqZ+JrasRoPmb7sdljN8PlBkBr4U7Bf+PxIWsMArWXPd2pkFGOI+j56s4mYhITj1kLJEz5E9rLZZOWKk/PFz688hlMEjuWty2nIhDKYLQ5bN/Q2yRGtUaudFNxD4pYlHzaqX8q/dzTxx0F/p99g0YA7v2zpgSz6IGGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709640874; c=relaxed/simple; bh=0JSSs1/ECQnp69yxT4x70rgh4SNZT8QM+eo7Dzqxqt0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=s6fqvvAFufcbF9Bj758jarO4cCQTRwnw22v2B7RJB6B2PgeTnLypQNozCaS0oo3KB3j2z/tO8gfdVZ4YDXX86Xj6MJnzmy9ZHba1+su4/9MUgzpDHOL1nS6tfnuO+a0zFOARc9z8YscPAXmS8XCzhpFwpqRXdOTB/U6s5exkbIc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eLOgbIcw; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-29a2545a1e7so3779411a91.2; Tue, 05 Mar 2024 04:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709640872; x=1710245672; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0JSSs1/ECQnp69yxT4x70rgh4SNZT8QM+eo7Dzqxqt0=; b=eLOgbIcwhfT5oiYhF4SuUwv1+HQgWThVEEKgPZlQqf2FtIqL47qWQvc76p6ZPdULMP iKKt4dMcEVllUHVXYuMENqHWgj9K/Ekq1/FLPdidgVk8slUe/xOINfmfQE3qUqYKLwit uwiLmJA+84Lxfn92G/Mvi275Zha1hvryaxe7ksRv+Ria1j/2gQ3COLfqxJ2MpZl9zkDP Z8X4zbDedLuhfApp+0vzIlMmV2u2Bk2QC4ZYcyksR7+Mgw7Bne2iW45i2weZJml7KfU4 pDt9+lkHx2dQiClxfX4Qr5s4mx2KupX7XeEH5nw8PT2S6L56Vkobt2Z3Y17qjvcDAdw7 O9HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640872; x=1710245672; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0JSSs1/ECQnp69yxT4x70rgh4SNZT8QM+eo7Dzqxqt0=; b=Rz/rYWNY9I1rKe54hRgt9M6Tid4YN9VjZq25HXNOD0NZ5lxX8etopj+fpXYvoIZy3U tB5mMiNLHLwcaYgOyMi6wRdB1y3r8OV3/fOGLBpkGcJKu1XFatVRG1zjchyjp1LWpnND FceOUN2JfTamA+6eX41MR1phgjJQC9oHMImkfXdAKpXSZfthG/FwbBhhhRPabm+84Wjo +fXHVuF8Iygm83gKjdo+kvN+E+fR36DUyMxtBOaqbVZljUbjyLSTnRkS6LMP/GcA+tpE Sw3EcIZvjNxRiGXTjpvN3J42chgBgj3necPjTHfUGIms1BT/CYFc8fUDaXtcurXtL+oq Darw== X-Forwarded-Encrypted: i=1; AJvYcCWLFu5KNtJa+Xjv+qqK6TVKLC2DBrlbtckq3xHx1KaeU+EOKqgxxVM0VeiEX5isisLhPZfrpiDTZYw6DPC27rXhZ/m3FQTi4Gln5R3lCGgPLaVmHwaMzzZetRsiM/6BZ+bf4gqdZSFzmR9KFZEdtcR9aqePNJ3w/vElbo85IpdomzMmmB8lfJh8aLw= X-Gm-Message-State: AOJu0Yzai8Dc4AIfZplBAqfrydh3GsAX1K6//BNeCUUO/8I8JKGs7Ghe E19RgBjdifrGg1eBpCDmcPJLlp41RJKHyycW4Xgoe54Tdt+ekLaulHrhVBXfVaZzF+xLJSM3s1G 4QfzUf3VeGTKZLZdHZc4RVLFJfac= X-Received: by 2002:a17:90b:192:b0:29a:67fa:7bb7 with SMTP id t18-20020a17090b019200b0029a67fa7bb7mr8058251pjs.47.1709640871794; Tue, 05 Mar 2024 04:14:31 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240305-shadow-call-stack-v2-1-c7b4a3f4d616@google.com> In-Reply-To: <20240305-shadow-call-stack-v2-1-c7b4a3f4d616@google.com> From: Miguel Ojeda Date: Tue, 5 Mar 2024 13:14:19 +0100 Message-ID: Subject: Re: [PATCH v2] rust: add flags for shadow call stack sanitizer To: Alice Ryhl Cc: Catalin Marinas , Will Deacon , Jamie Cunliffe , Sami Tolvanen , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Ard Biesheuvel , Marc Zyngier , Mark Rutland , Mark Brown , Nick Desaulniers , Kees Cook , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 5, 2024 at 12:58=E2=80=AFPM Alice Ryhl w= rote: > > Add flags to support the shadow call stack sanitizer, both in the > dynamic and non-dynamic modes. > > Right now, the compiler will emit the warning "unknown feature specified > for `-Ctarget-feature`: `reserve-x18`". However, the compiler still > passes it to the codegen backend, so the flag will work just fine. Once > rustc starts recognizing the flag (or provides another way to enable the > feature), it will stop emitting this warning. See [1] for the relevant > issue. > > Currently, the compiler thinks that the aarch64-unknown-none target > doesn't support -Zsanitizer=3Dshadow-call-stack, so the build will fail i= f > you enable shadow call stack in non-dynamic mode. However, I still think > it is reasonable to add the flag now, as it will at least fail the build > when using an invalid configuration, until the Rust compiler is fixed to > list -Zsanitizer=3Dshadow-call-stack as supported for the target. See [2] > for the feature request to add this. > > I have tested this change with Rust Binder on an Android device using > CONFIG_DYNAMIC_SCS. Without the -Ctarget-feature=3D+reserve-x18 flag, the > phone crashes immediately on boot, and with the flag, the phone appears > to work normally. > > This contains a TODO to add the -Zuse-sync-unwind=3Dn flag. The flag > defaults to n, so it isn't a problem today, but the flag is unstable, so > the default could change in a future compiler release. > > Link: https://github.com/rust-lang/rust/issues/121970 [1] > Link: https://github.com/rust-lang/rust/issues/121972 [2] > Signed-off-by: Alice Ryhl > --- > This patch raises the question of whether we should change the Rust > aarch64 support to use a custom target.json specification. If we do > that, then we can fix both the warning for dynamic SCS and the > build-failure for non-dynamic SCS without waiting for a new version of > rustc with the mentioned issues fixed. If the arm64 maintainers are OK with the warning being triggered in that ca= se: Acked-by: Miguel Ojeda Otherwise partially reverting to the `target.json` approach sounds good too= . I added the `-Zuse-sync-unwind=3Dn` to the list at https://github.com/Rust-for-Linux/linux/issues/2. Given the default is what we want, I have put it in the "Good to have" section. Cheers, Miguel