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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7B03C48BEB for ; Wed, 21 Feb 2024 21:13:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F3906B0089; Wed, 21 Feb 2024 16:13:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 57CA86B008A; Wed, 21 Feb 2024 16:13:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CF7F6B008C; Wed, 21 Feb 2024 16:13:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 27A926B0089 for ; Wed, 21 Feb 2024 16:13:29 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 02612140B94 for ; Wed, 21 Feb 2024 21:13:28 +0000 (UTC) X-FDA: 81817062138.01.51997E5 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf02.hostedemail.com (Postfix) with ESMTP id 36A2280016 for ; Wed, 21 Feb 2024 21:13:25 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iQCKWcJu; spf=pass (imf02.hostedemail.com: domain of hjl.tools@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=hjl.tools@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708550006; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oOe8CQ1Fe+hIMHxzKX7XWlTimkc/iuaovpymvDphgj4=; b=tfDXw0U376MZFTF2jqdwS/3AajIjvtoQpH2+rTejg+Xf6qNoMCIUFvh+T9hXJ2dIRZ7XV0 Pu2m7maMCLJXvfwsht9C8MeoS7c/iJm0LAg7ieyg8nfWvGeWuk6F1kymB3JsTBmRAJR8jj ra7HSoubf0jbgXlL5L+5okQM+9OTjr4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iQCKWcJu; spf=pass (imf02.hostedemail.com: domain of hjl.tools@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=hjl.tools@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708550006; a=rsa-sha256; cv=none; b=3DX/gbeU0+fguEN5TzLQZj3T9cs3/Cq+/0nXgYU0n5rxld3BUMxOSHoAADXlDWg6mw5XH4 XV2HFOxqUbSkrIaglqmJqXPVZhJRcRyKCJtu1tn25Z5Nf8SDxKxJRt6obKZXfGmUr25euG p9HHmeyunhg2ejvOOmMKRvWn8ll3NIc= Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso847030a12.3 for ; Wed, 21 Feb 2024 13:13:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708550005; x=1709154805; darn=kvack.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=oOe8CQ1Fe+hIMHxzKX7XWlTimkc/iuaovpymvDphgj4=; b=iQCKWcJugx+xrm0tK7QQjKoJJ7eWxfjoE6IXFEI0OZMX0/MY6VRRBLwJ/8sHLSq3XX gfsvn0E8HuDcNQi6rXzLlbqhVVe3Q5oCq15701GKIJfFpnVfHeoVXd96C8EtDnTm7G0S LVhfgS/d4j6uhLkYWKI1bRpphPefjN/QbP4fShH+skCLeq2FlMLG8QCNTUzategjP3sc kGnFN+C7FfWWAsqAneP5RL13w3ErC1QBhCpXzgXcKIHxshUe0DRzawjpS70Wtepa44sf BgCdqY2KWmoCALJOxirP6/DEPQ3bH6NDR6fJByLsXdvA8U5TrB/myl2XS71A/Ql/dlww pq2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708550005; x=1709154805; 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=oOe8CQ1Fe+hIMHxzKX7XWlTimkc/iuaovpymvDphgj4=; b=o3I0k/mrtHcLv3njh9nVL/LItaV+8oSDZcSoz6LxGiO9Y102dmDkthbdCE10nFVe2a Py9Cl8kD+wGDV2haaby0aX9mPxeQcR0HE5mywV2VeFDMHdNfwh/P4VmuUwCu5757OIPZ YyLMWH5Qo8feEwBnxB6899CYoqMtwXLe1NFPEX0Lk7E26WfbaIGWFEepmoNbFpNjjfu8 bXR/vTxS/FB2BTFaI5DNyLIxZ9UllIWK5fyFafT/cadxtKSHp6KM/H7fy4BJCaHu1jI3 WuY8pnOMhsXUlHJV0CdFGJ7C4en2In2+Z9qZIcx8iC94zaBWymu8Z2iFk7g6SF9pmAn+ A+Jw== X-Forwarded-Encrypted: i=1; AJvYcCXHMCq/RaeIQvwQ5Cx9jNeobV6f2VNi6wTyuva8faWyR108x/azs8DfVANgUAK7dNhIUvUoibQr/QvA1F2tTWlVcCs= X-Gm-Message-State: AOJu0YxDyzpKHNVWF1fwO6d71GvXSTeQVqLvA+13BuFBaR4G1QX04XvE 24/l1n3JVU2a7zyp0NMn8AGbT5kuyYsH0j6BKtwIJcV3PdY1vLtPY1BV+PfAF53g2NCO1gJH7W7 nOFwNuGuSUHsx2NhL6zvLHdoly0k= X-Google-Smtp-Source: AGHT+IGhaBTSHgXe8Ob108OXBWpnIgIuyMFeVcBje1ELrXkN/4PqTmNclSgXiBJchbcFk4tPPGc/HanP+MFeXILDTxM= X-Received: by 2002:a17:90a:d911:b0:299:e9d1:fc52 with SMTP id c17-20020a17090ad91100b00299e9d1fc52mr6242900pjv.0.1708550004870; Wed, 21 Feb 2024 13:13:24 -0800 (PST) MIME-Version: 1.0 References: <20240220235415.GP4163@brightrain.aerifal.cx> <20240221012736.GQ4163@brightrain.aerifal.cx> <20240221145800.GR4163@brightrain.aerifal.cx> <4a3809e8-61b2-4341-a868-292ba6e64e8a@sirena.org.uk> <20240221175717.GS4163@brightrain.aerifal.cx> <20240221183055.GT4163@brightrain.aerifal.cx> <20240221190639.GU4163@brightrain.aerifal.cx> In-Reply-To: From: "H.J. Lu" Date: Wed, 21 Feb 2024 13:12:47 -0800 Message-ID: Subject: Re: [musl] Re: [PATCH v8 00/38] arm64/gcs: Provide support for GCS in userspace To: "Edgecombe, Rick P" Cc: "dalias@libc.org" , "linux-arch@vger.kernel.org" , "suzuki.poulose@arm.com" , "Szabolcs.Nagy@arm.com" , "musl@lists.openwall.com" , "linux-fsdevel@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "kvmarm@lists.linux.dev" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "catalin.marinas@arm.com" , "broonie@kernel.org" , "oliver.upton@linux.dev" , "palmer@dabbelt.com" , "debug@rivosinc.com" , "aou@eecs.berkeley.edu" , "shuah@kernel.org" , "arnd@arndb.de" , "maz@kernel.org" , "oleg@redhat.com" , "fweimer@redhat.com" , "keescook@chromium.org" , "james.morse@arm.com" , "ebiederm@xmission.com" , "will@kernel.org" , "brauner@kernel.org" , "linux-kselftest@vger.kernel.org" , "paul.walmsley@sifive.com" , "ardb@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mm@kvack.org" , "thiago.bauermann@linaro.org" , "akpm@linux-foundation.org" , "sorear@fastmail.com" , "linux-doc@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 36A2280016 X-Rspam-User: X-Stat-Signature: ztq4sugcjz4srcr53ghqh6iey9iyui8j X-Rspamd-Server: rspam01 X-HE-Tag: 1708550005-616070 X-HE-Meta: U2FsdGVkX1/iWDSN1oo195FP8r/fw07HSOv4TDhiYOC+uwe5ngNklg1syVJuyD9rO/IOG+cjEnzOhF7HZJOCt9o8TyUj4xhNysxZK4LrySZ4mD4GEJSTSY5MtnKAS/W8NQAc5xwzn6lKxJV1mCY+xSqeBzyJQBnW9iJHoZJ/ActwT7AAGESP3ZGNxrv5Xf2jgBZnxmQ9XPdz7hQ8QXlWsetKKYb1OC2oIASZ6SlhZHjoj97adzG3JUj4BBSfkXGajkjsH1paTsND28Q9A+LntuhGCJuSCdcLtVVnJzhM7nyMBPKCuEPo7QQenjLe7Oa4YNQ0vCN2No1/bVzVTqin4m7niBp0B0glb8WwBnOfjPZEh/1ZL5APdVNUS6f7GKjx2dSughTRWT4b258zLXr2G5koyoOJprKf9VPvEaTGZ/gLX6Vg5idZzUs1HDWr3aT7b/UmSDRqiemHKMwMUbPzshBH2NsyR+/IE6dwMys4LL0n1xBtCZHr6HC4Bqx2lsr3Jfxf6JR0BvHqLVahB76CaHawceCSjjYDqauRcJ7MuXTt1jdBhN0lAQiCqAX5h7Vphr7eUX5nTFjiMEPsWUfFJu36QWFCYcxyArcivVGwoc84G/J8PUX/+EvZA8VfxI944kiV6EWApLUuf7n7uEHkqaMK5Dzz6hdCqWJcVo50YRsIumitaGNxk8R0kuTODJN2A3+MfRTp2NEyDqVScmzelpi4PawS84IIajaFvAQpUt+bXq6LJr7gQaURJOqi0eh3qt0lTqQJIr/XSA6QI1yrvBXYbobC3BCeLZJIV+hMLysOvqvQQu8QV+4PHsULNgy3DXqiCaJoU2M5pY3kYN5xWXvnyCyGgqgL41pCi6cveFAU4GZbpodyhRmvv5ttqP+QLXrc6CHCGuC/RWKz1a/3b9i0wwXao50IqwbXpac4HuG3F/SlEp50eWv5w0/7MClzANBiFXS2dle6y9JL+7p fj/rM5tl P7Wv3lYf9Ib8aykwxBdguZcvyfpJJgp+rgRIBUadwObImx0zDpeWsrpEN99D4D0I8993xvqVikp8QHwRnj30rblAMH934SV7cRVPn7NMiSiZzCnc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.001820, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Feb 21, 2024 at 12:25=E2=80=AFPM H.J. Lu wrot= e: > > On Wed, Feb 21, 2024 at 12:18=E2=80=AFPM H.J. Lu wr= ote: > > > > On Wed, Feb 21, 2024 at 11:22=E2=80=AFAM Edgecombe, Rick P > > wrote: > > > > > > On Wed, 2024-02-21 at 14:06 -0500, dalias@libc.org wrote: > > > > Due to arbitrarily nestable signal frames, no, this does not suffic= e. > > > > An interrupted operation using the lock could be arbitrarily delaye= d, > > > > even never execute again, making any call to dlopen deadlock. > > > > > > Doh! Yep, it is not robust to this. The only thing that could be done > > > would be a timeout in dlopen(). Which would make the whole thing just > > > better than nothing. > > > > > > > > > > > > > > > > > > > > It's fine to turn RDSSP into an actual emulated read of the SSP, or > > > > at > > > > least an emulated load of zero so that uninitialized data is not le= ft > > > > in the target register. > > > > > > We can't intercept RDSSP, but it becomes a NOP by default. (disclaime= r > > > x86-only knowledge). > > > > > > > If doing the latter, code working with the > > > > shadow stack just needs to be prepared for the possibility that it > > > > could be async-disabled, and check the return value. > > > > > > > > I have not looked at all the instructions that become #UD but I > > > > suspect they all have reasonable trivial ways to implement a > > > > "disabled" version of them that userspace can act upon reasonably. > > > > > > This would have to be thought through functionally and performance > > > wise. I'm not opposed if can come up with a fully fleshed out plan. H= ow > > > serious are you in pursuing musl support, if we had something like > > > this? > > > > > > HJ, any thoughts on whether glibc would use this as well? > > > > Assuming that we are talking about permissive mode, if kernel can > > suppress UD, we don't need to disable SHSTK. Glibc can enable > > ARCH_SHSTK_SUPPRESS_UD instead. > > Kernel must suppress all possible SHSTK UDs. If SHSTK is disabled by kernel, not by glibc, there can be 2 issues: 1. Glibc and kernel may be out of sync on SHSTK. 2. When kernel disables SHSTK, glibc may be in the middle of reading shadow stack in longjmp, searching for a restore token. > > > It is probably worth mentioning that from the security side (as Mark > > > mentioned there is always tension in the tradeoffs on these features)= , > > > permissive mode is seen by some as something that weakens security to= o > > > much. Apps could call dlopen() on a known unsupported DSO before doin= g > > > ROP. I don't know if you have any musl users with specific shadow sta= ck > > > use cases to ask about this. > > > > > > > > -- > > H.J. > > > > -- > H.J. --=20 H.J.