Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp261811rwl; Thu, 30 Mar 2023 15:43:26 -0700 (PDT) X-Google-Smtp-Source: AKy350ZiVTLmvlfQtoXIzIWSc47P8SY4AtUS5KZkQVb9+gvr8Z+qEm7ZFkysrvoW5Yrk7W9AHqHg X-Received: by 2002:a17:90a:d195:b0:236:7144:669f with SMTP id fu21-20020a17090ad19500b002367144669fmr20766883pjb.2.1680216205835; Thu, 30 Mar 2023 15:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680216205; cv=none; d=google.com; s=arc-20160816; b=ErdpPorua8Wiru4N4z+1nM/SpwAYcxi7YA+Xb83XKUwj52owhes3iqZGnb4KlhtQ1B zLaedSRKqrg5+xgwEag2IrP3i1zKSlN2jcN4xIkqgu0JKVrPdx82i116w9BhjpKen5zE /pYVnpnVMHfbOtlO3h4vTrzFQp2Qfu4lVkbpAOXMGHKQ6O3dAL0saJicbDf+OFb1xi7R G2lVZ1ujUHyvZjTaSxz1Y0WbALgTM5cCvYaLRu3yFIjuGVmZTWmxPT28svpSyKC5ssi1 2UzScDhI6i4/Bml7JZn1x9dulQ6UVgj2mTG8kowTRb2BI7NP9n4mD0f8YcrZV1fCQaGj BAiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fY2iYVvnGwhfJSSuTtSlY/HKVdA6UHdFqyFNPn5+GRE=; b=HE2u6d0dlz8tTT34jKdQFFKXSF52wORtPaNnKbDsw6C8ouOEHOjXnXhzkwIlC80SuR KHI23RR7aNuldyhwckWHxzXs613sT86T+/Ese+19J1Uh5B2k/DjbI62xhA8wCjeRMOh6 trvCD0g6ujx79pDwhrqDt+/nEz0vEUX52iekCe+dZyNOTe/Ccp2LeHKrSGDKCqx4pDOj Dh45vDlWjNO6CLcomOW8xRL5sfUsFUaCOAwVjtrpVHwJOQtuJx0+DyqungX3lwv79NZZ m8DZCfRJaLzZA/BSihQFNH9JewPAnjRjJngai5kiK7OADZi3BtrvELfc8TRpbcKLsZpV lWkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t17-20020a17090ad15100b0023f37564a38si3118204pjw.177.2023.03.30.15.43.14; Thu, 30 Mar 2023 15:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230334AbjC3WlT (ORCPT + 99 others); Thu, 30 Mar 2023 18:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbjC3WlL (ORCPT ); Thu, 30 Mar 2023 18:41:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA312EB52; Thu, 30 Mar 2023 15:41:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7C34AB82A60; Thu, 30 Mar 2023 22:41:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B61F3C433D2; Thu, 30 Mar 2023 22:41:02 +0000 (UTC) Date: Thu, 30 Mar 2023 23:40:59 +0100 From: Catalin Marinas To: Gregory Price Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, oleg@redhat.com, avagin@gmail.com, peterz@infradead.org, luto@kernel.org, krisman@collabora.com, tglx@linutronix.de, corbet@lwn.net, shuah@kernel.org, arnd@arndb.de, Gregory Price Subject: Re: [PATCH v15 2/4] syscall user dispatch: untag selector addresses before access_ok Message-ID: References: <20230330212121.1688-1-gregory.price@memverge.com> <20230330212121.1688-3-gregory.price@memverge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230330212121.1688-3-gregory.price@memverge.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 30, 2023 at 05:21:22PM -0400, Gregory Price wrote: > diff --git a/kernel/entry/syscall_user_dispatch.c b/kernel/entry/syscall_user_dispatch.c > index 22396b234854..16086226b41c 100644 > --- a/kernel/entry/syscall_user_dispatch.c > +++ b/kernel/entry/syscall_user_dispatch.c > @@ -87,7 +87,18 @@ static int task_set_syscall_user_dispatch(struct task_struct *task, unsigned lon > if (offset && offset + len <= offset) > return -EINVAL; > > - if (selector && !access_ok(selector, sizeof(*selector))) > + /* > + * access_ok will clear memory tags for tagged addresses on tasks where > + * memory tagging is enabled. To enable a tracer to set a tracee's > + * selector not in the same tagging state, the selector address must be > + * untagged for access_ok, otherwise an untagged tracer will always fail > + * to set a tagged tracee's selector. > + * > + * The result of this is that a tagged tracer may be capable of setting > + * an invalid address, and the tracee will SIGSEGV on the next syscall. > + * This is equivalent to a task setting a bad selector (selector=0x1). > + */ I'd drop the last paragraph above. Even without tagged pointers, a tracer can set an invalid address (as you already mentioned) but the phrasing some implies (to me) that if we did it differently, the tracer would not be able to set an invalid pointer. Either way, Reviewed-by: Catalin Marinas -- Catalin