Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5013835rdb; Tue, 12 Dec 2023 16:51:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFh4rCAfRTFO2m6JPPN9Mxlr01u/JrQsq9v7LrvyhlJ2QlS8wQ7C5FTIrGdAWPYfDj5IEBg X-Received: by 2002:a05:6870:1711:b0:1fa:f387:e0ab with SMTP id h17-20020a056870171100b001faf387e0abmr7139443oae.46.1702428672458; Tue, 12 Dec 2023 16:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702428672; cv=none; d=google.com; s=arc-20160816; b=MDb9Vl5AyTwXhO6nvpZmvTmRvMaNkSDX7hTz8fAY7QZtXzXcR+tsCidfCufpen2Zb5 0wihAQMDOb9cZmrZiigAD77+BMGNgGig3Qp8PVhiW10TSxbZZtB3accZhoBK+nvXLpCp VxRuBICNQYeAcfYyvYW6J+LXitGhfV6SuDyrvrCa7dABsbm5wUt0vdZLNY1g2RJ0WHBK nI0RSD6v81cOtzALpVvU1sOWGgEs/QWqX+xAbQqGCri0KV++29ClC29PsfYkugnoW2zU 017jrbAcj9ZX4mfA6BZqjxHwqHAuHa8SS5M8XNkvMOk9wEyysCNGHzLubSWQO60gYKvQ LXKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=IsP6D8T5vC4K0WLWKELqerL/h2k2GCGETaeygCJbK5E=; fh=txQbuk242FAPPEhu1HwwgZJLRYSPZEMBV0FwN7E4ncU=; b=A/xznqX2xFimTLjqYKgwY5q4rHq5C+UitbN51mMUj66Xxzq0ahn4mD9b6IPtlYOY6+ s1V6lRIerwQYYLOI0U4DNWHRh4gOq2ID4tYpUaAc+RYrCFO7mXYUGPSv7k56WyeAe6mK eJn5D3uy4AM5kAvRzLlFeGDCfJXNMzbmxX81sUC12ULGZaRbKDbaP9pNHI6wn389o9Pi Fr2KtAgagr+dzRDAG+SczuTnJqE6wo0qEeSARFykRn/K/m6fTgkZOzu7rAXc1Wk/aDPE ttmR6oams/oJ/+GPOUrCI2fZmlTGBIcPFR7umsiuyB4bCxfmCfKOFs2l1MKdffndgY80 IlJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=sG7bZwXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z4-20020a656644000000b005c67e10f238si8552500pgv.492.2023.12.12.16.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 16:51:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=sG7bZwXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id ABCC080A9AB8; Tue, 12 Dec 2023 16:51:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377896AbjLMAur (ORCPT + 99 others); Tue, 12 Dec 2023 19:50:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbjLMAup (ORCPT ); Tue, 12 Dec 2023 19:50:45 -0500 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30687BD for ; Tue, 12 Dec 2023 16:50:51 -0800 (PST) Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-dbccfd048d4so84668276.3 for ; Tue, 12 Dec 2023 16:50:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702428649; x=1703033449; 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=IsP6D8T5vC4K0WLWKELqerL/h2k2GCGETaeygCJbK5E=; b=sG7bZwXGvGujWU/Kv07//ZUVZexawR/0ceUWve54iYCKQGNMF8FAbNrrX0aufq9CAv am/BawKeDgKccgvSp/NTP+KRMZ6BZK7v9OYycEgi6hv2ybuLe2iPCCkx3PShmxDN4RmV EaupRUteZGx1Ox/AVwFLXtxIymHvBmJxib2CMOEP72c5OIeu7h7Q201dXqvwIC3R2HeJ VWCFhWgA2Bxfml2Z357GzFJTFQWvXXqaXbxttX89vCDkMKD0fnYBb7Mn2+VTROtmHJXt LUlRdVtkzOSWYNKbYKWbNhHZgufupPR3VYg4GMzTY/ymsFtUEYN562QyUvQnH71juucq RVBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702428649; x=1703033449; 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=IsP6D8T5vC4K0WLWKELqerL/h2k2GCGETaeygCJbK5E=; b=ZhtLKdEZoDmXovHbYQBJChmGtNA5L/Muz7wKlDDB5YvQ9qaLPAKQWKUpFUYRilDwOe h84qAnNpESRehep6fSCEa8nGWHB8TsTQBQv6VKrm6FO1WZVa1fs2ryjH7WwIoZwKr5pW 2HiSJwhPXh6aDfpDy8sB8kNs6htrnxwvAYzRoex6FXPYEKveVMEXH8wC+TNZA1bgYCdW +JFNWodHtfyO5a8Tqyjsz75u9EXV7hN41ECptZ9gjHLUm+E2WXLvk7vAa666uBuDdwvZ +XwJdk7VzlSEPuwQVD1pIVYROSrOQvYsq4JIUl3J6AHaFs2rSte7MOtfhXPI8+LVRuz4 oxJQ== X-Gm-Message-State: AOJu0YxtPXk4e5UKIt3uyyOrIV8DGH1pS72N7L2XSM2yZBK5oCt1TYmL T7qKdRWjVfa0yvLjrgv496OdhyHHLLm1mWq9iKwglQ== X-Received: by 2002:a25:8051:0:b0:db7:e91c:eb1d with SMTP id a17-20020a258051000000b00db7e91ceb1dmr4411297ybn.102.1702428649654; Tue, 12 Dec 2023 16:50:49 -0800 (PST) MIME-Version: 1.0 References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> <20231122-arm64-gcs-v7-2-201c483bd775@kernel.org> In-Reply-To: From: Deepak Gupta Date: Tue, 12 Dec 2023 16:50:38 -0800 Message-ID: Subject: Re: [PATCH v7 02/39] prctl: arch-agnostic prctl for shadow stack To: Mark Brown Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Ard Biesheuvel , Szabolcs Nagy , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 16:51:09 -0800 (PST) On Tue, Dec 12, 2023 at 11:23=E2=80=AFAM Mark Brown wr= ote: > > On Tue, Dec 12, 2023 at 11:17:11AM -0800, Deepak Gupta wrote: > > On Wed, Nov 22, 2023 at 1:43=E2=80=AFAM Mark Brown = wrote: > > > > +/* > > > + * Set the current shadow stack configuration. Enabling the shadow > > > + * stack will cause a shadow stack to be allocated for the thread. > > > + */ > > > +#define PR_SET_SHADOW_STACK_STATUS 72 > > > +# define PR_SHADOW_STACK_ENABLE (1UL << 0) > > > Other architecture may require disabling shadow stack if glibc > > tunables is set to permissive mode. > > In permissive mode, if glibc encounters `dlopen` on an object which > > doesn't support shadow stack, > > glibc should be able to issue PR_SHADOW_STACK_DISABLE. > > > Architectures can choose to implement or not but I think arch agnostic > > code should enumerate this. > > The current implementation for arm64 and therefore API for the prctl() > is that whatever combination of flags is specified will be set, this > means that setting the status to something that does not include _ENABLE > will result in disabling and we don't need a separate flag for disable. > We have use cases that make active use of disabling at runtime. A theoretical scenario (no current workloads should've this case because no shadow stack) - User mode did _ENABLE on the main thread. Shadow stack was allocated for the current thread. - User mode created a bunch worker threads to run untrusted contained code. They shadow stack too. - main thread had to do dlopen and now need to disable shadow stack on itself due to incompatibility of incoming object in address space. - main thread controls worker threads and knows they're contained and should still be running with a shadow stack. Although once in a while the main thread needs to perform writes to a shadow stack of worker threads for some fixup (in the same addr space). main thread doesn't want to delegate this responsibility of ss writes to worker threads because they're untrus= ted. How will it do that (currently _ENABLE is married to _WRITE and _PUSH) ? Please note that I am making up this scenario just for sake of discussion And don't know if software would be using it in this manner. > > Please delete unneeded context from replies, it makes it much easier to > find new content. Sorry about that. Noted.