Re: [PATCH v13 1/3] syscall_user_dispatch: helper function to operate on given task

From: Thomas Gleixner
Date: Tue Mar 21 2023 - 15:47:32 EST


On Tue, Mar 21 2023 at 12:55, Gregory Price wrote:
> On Tue, Mar 21, 2023 at 04:41:37PM +0100, Thomas Gleixner wrote:
>> On Wed, Mar 01 2023 at 15:58, Gregory Price wrote:
>> > +static int task_set_syscall_user_dispatch(struct task_struct *task, unsigned long mode,
>> > + unsigned long offset, unsigned long len,
>> > + char __user *selector)
>> > {
>> > switch (mode) {
>> > case PR_SYS_DISPATCH_OFF:
>> ...
>>
>> case PR_SYS_DISPATCH_ON:
>> if (selector && !access_ok(selector, sizeof(*selector)))
>> return -EFAULT;
>>
>> I'm not seing how this can work on ARM64 when user pointer tagging is
>> enabled in the tracee, but not in the tracer. In such a case, if the
>> pointer is tagged, access_ok() will fail because access_ok() wont untag
>> it.
>
> I see that untagged_addr(x) is available to clear tags, I don't see an
> immediate issues with converting to:
>
> !access_ok(untagged_addr(selector), sizeof(*selector))

If this would be correct, then access_ok() on arm64 would
unconditionally untag the checked address, but it does not. Simply
because untagging is only valid if the task enabled pointer tagging. If
it didn't a tagged pointer is obviously invalid.

Why would ptrace make this suddenly valid?

Just because it's in the way of what you want to achieve is not a really
sufficient justification.

Thanks,

tglx