Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp881557rwl; Wed, 29 Mar 2023 09:36:01 -0700 (PDT) X-Google-Smtp-Source: AKy350Z9F3AI4CMYffWwN3K7PvkSzjtJ1gzvX532IlVDoU6qUijnIFXskig09XwXPE53qrqOasuK X-Received: by 2002:a17:902:c7d2:b0:19e:dc0e:1269 with SMTP id r18-20020a170902c7d200b0019edc0e1269mr14904383pla.7.1680107760893; Wed, 29 Mar 2023 09:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680107760; cv=none; d=google.com; s=arc-20160816; b=LUR/nY9jOmyiwU3G9AmFpN2OXf/qTb8fd8nrGFCRbjsllmU7CobhAOYaksp1S/UYva gOdhGQmXC+aBsrt2PpbxhaIWoUOuGDycFchcIDhtKTlgfxFvkPSQRwCJxna/XVtn10z0 K/LmVh9coJh7PxDTeHKuTOdLgqtg7cSkQaVRI3ZrStxHFmLA/3W5ZW0ihO4CXhH5paHM Hw041ZFtoo0aMBhtzKrktVMlMlJRkozqzOELT8t62g056m+np3g9jBQHz8JgW6RT2a1f A4vAWHkxszIjYbIp9+z5eZrkjQDd2tdUfB5QqhFI5qFTHpk3mMcPMMhtrmvnoRVYc7xr L0Cw== 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=lYkj0Tjijru9ffiO6B1DY6rFtZ1HIAJ4EvU5cV9rAKI=; b=WFZGMV8tPXUsBjDk+TFtjhS7P8j9NP7SAcJQ9H/PBBYBLrVF4Onfvy3Gn7fmrdqsZQ ng12gCS2LYrFWSrZ+fULjl5chk+HSK3YXH8VmBO39L3p0ZOTiJ0dieHwunSwOrWkisDz E9XVjMCE/sKxTBOMYwq0Xe/8f6VifoxGYcy+X8YCuzYHukIUumvhdTf+AA8P6et+41K6 Fxa/MmAOPog+W6zJrPCAMnPIWkA87YP+nRNeE0N292UtmXkhGYoms1SYiFd8bGE/TeN+ CCgKbCrRXgPJvRLVVIGCiFSp+oGKp8eTWv1KpaZnjBKB+HzVQQXeAPkeDeOfELqeKld6 LRVA== 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 x9-20020a170902e04900b001a0520df029si30748751plx.366.2023.03.29.09.35.48; Wed, 29 Mar 2023 09:36:00 -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 S229647AbjC2QXE (ORCPT + 99 others); Wed, 29 Mar 2023 12:23:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjC2QXC (ORCPT ); Wed, 29 Mar 2023 12:23:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D333C06; Wed, 29 Mar 2023 09:22:56 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 609FB61D89; Wed, 29 Mar 2023 16:22:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 967AEC433EF; Wed, 29 Mar 2023 16:22:52 +0000 (UTC) Date: Wed, 29 Mar 2023 17:22:49 +0100 From: Catalin Marinas To: Gregory Price Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.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, will@kernel.org, mark.rutland@arm.com, tongtiangen@huawei.com, robin.murphy@arm.com, Gregory Price Subject: Re: [PATCH v14 1/4] asm-generic,arm64: create task variant of access_ok Message-ID: References: <20230328164811.2451-1-gregory.price@memverge.com> <20230328164811.2451-2-gregory.price@memverge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230328164811.2451-2-gregory.price@memverge.com> X-Spam-Status: No, score=-4.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,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 Tue, Mar 28, 2023 at 12:48:08PM -0400, Gregory Price wrote: > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > index 5c7b2f9d5913..1a51a54f264f 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -35,7 +35,9 @@ static inline int __access_ok(const void __user *ptr, unsigned long size); > * This is equivalent to the following test: > * (u65)addr + (u65)size <= (u65)TASK_SIZE_MAX > */ > -static inline int access_ok(const void __user *addr, unsigned long size) > +static inline int task_access_ok(struct task_struct *task, > + const void __user *addr, > + unsigned long size) > { > /* > * Asynchronous I/O running in a kernel thread does not have the > @@ -43,11 +45,18 @@ static inline int access_ok(const void __user *addr, unsigned long size) > * the user address before checking. > */ > if (IS_ENABLED(CONFIG_ARM64_TAGGED_ADDR_ABI) && > - (current->flags & PF_KTHREAD || test_thread_flag(TIF_TAGGED_ADDR))) > + (task->flags & PF_KTHREAD || test_ti_thread_flag(task, TIF_TAGGED_ADDR))) > addr = untagged_addr(addr); > > return likely(__access_ok(addr, size)); > } > + > +static inline int access_ok(const void __user *addr, unsigned long size) > +{ > + return task_access_ok(current, addr, size); > +} > + > +#define task_access_ok task_access_ok I'd not bother with this at all. In the generic code you can either do an __access_ok() check directly or just access_ok(untagged_addr(selector), ...) with a comment that address tagging of the ptraced task may not be enabled. -- Catalin