[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZCRl2ZDsNK2nKAfy@arm.com>
Date: Wed, 29 Mar 2023 17:22:49 +0100
From: Catalin Marinas <catalin.marinas@....com>
To: Gregory Price <gourry.memverge@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-arch@...r.kernel.org,
oleg@...hat.com, avagin@...il.com, peterz@...radead.org,
luto@...nel.org, krisman@...labora.com, tglx@...utronix.de,
corbet@....net, shuah@...nel.org, arnd@...db.de, will@...nel.org,
mark.rutland@....com, tongtiangen@...wei.com, robin.murphy@....com,
Gregory Price <gregory.price@...verge.com>
Subject: Re: [PATCH v14 1/4] asm-generic,arm64: create task variant of
access_ok
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
Powered by blists - more mailing lists