Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5789144rwl; Tue, 4 Apr 2023 03:47:31 -0700 (PDT) X-Google-Smtp-Source: AKy350aevBPFmWurVL6zk8pPSt6xNkzly/a7vx6f96WjTxrS0VZgrhtazeH7G6WVSdeiJG9JK8+J X-Received: by 2002:aa7:cd65:0:b0:502:32b7:ced with SMTP id ca5-20020aa7cd65000000b0050232b70cedmr1942109edb.15.1680605251493; Tue, 04 Apr 2023 03:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605251; cv=none; d=google.com; s=arc-20160816; b=whhxkX8+dS+LvYb/0cjoMUG+yp31Tbi4SryMxLYOr99K9ozwtlW9O7j1B38wqntGi0 8A9ThaDhQOXwrvBvXcvx3ncuyB+iKmls+JXX/U56gwW0BahlJkVZkauhu30l0eHaCAM0 /rWJ10NFZw6stlOwS8foMmMk303NV3KLBovpcl7TvCoFH+2FIXeWmOqj2FVITilEpz0P NzQ8by2yv0sFwFTQOhfYC3HMP3zgsy/ZxUJqJ+TrLYqNkM2Yo4RJQYzV+0EPjXKWOVJJ dIy7SoGp+hE9sCSswKfKGUGjJ4XTt8bp+cONkGgPPmlSK0va93yMAwqnG8XQsg5vjeQI Rr1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KlvAHwxh15I5CJgOz3iBO5tT4tChRwyHMt1NQ+o3LIA=; b=DeB3Ef1cA/nwqn18VQmAwMw3bk5EwEc6Q+ymLO10xabHSmh00Te/v6veKBMh9CRxi2 H9fADAclla0Ey4KJ4hSDQRLqQqTwhln0zYv4wXMO8MI4YBbwLGW6+JzVK5GMy45234Sf DZNmZR/+2ZM9L7BgUaCsOqiYTO25ydBgCi089eniZ+vDNErW6okwqnfUcP1CeaTZPEP9 pIUy6PghRyvgSZTdv2f2rrmXQvzUiyw3/NVDXZhhPwGg0IfjWugPF595V9/UcXWQzqfW kqlK1pGjdE5TOdHg4YTXj7v4Eg4OdT5cbE9X6yg1h0kU1Czh8hiGaoPyOo8uISIO5AyJ 6mQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Uez/INBm"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a19-20020aa7cf13000000b005002f0fab74si1701607edy.527.2023.04.04.03.47.06; Tue, 04 Apr 2023 03:47:31 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Uez/INBm"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234504AbjDDKqR (ORCPT + 99 others); Tue, 4 Apr 2023 06:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234419AbjDDKqP (ORCPT ); Tue, 4 Apr 2023 06:46:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77DBA1BD7 for ; Tue, 4 Apr 2023 03:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680605124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KlvAHwxh15I5CJgOz3iBO5tT4tChRwyHMt1NQ+o3LIA=; b=Uez/INBmjghPiiZ5WId+k0xgbr6xYkMA63N7q0tRMOKeMXuQ8xbueZyhFgyd+ynBogXB6J gj8cAeQPW+GnGbBhRyLr3LpEI+GYgwHDtOccrAA00LE0RCtbNSMuJqVi+LOc9P8xsTmSEM rWw+07/+z1kXhedow9vGgHEfrshigyU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-648-KKW9AEdFMjO660zewoQhLg-1; Tue, 04 Apr 2023 06:45:19 -0400 X-MC-Unique: KKW9AEdFMjO660zewoQhLg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3BBB80D190; Tue, 4 Apr 2023 10:45:18 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.199]) by smtp.corp.redhat.com (Postfix) with SMTP id 7493B40C6EC4; Tue, 4 Apr 2023 10:45:15 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 4 Apr 2023 12:45:10 +0200 (CEST) Date: Tue, 4 Apr 2023 12:45:06 +0200 From: Oleg Nesterov To: Catalin Marinas Cc: Gregory Price , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, 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: <20230404104506.GA24740@redhat.com> 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: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Catalin, doesn't this mean that access_ok() on arm64 could use untagged_addr(addr) unconditionally without any security risk? On 03/30, Catalin Marinas wrote: > > 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 >