Re: [PATCH] rseq: update kernel fields in lockstep with CONFIG_DEBUG_RSEQ

From: Michael Jeanson
Date: Mon Feb 24 2025 - 15:41:41 EST


On 2025-02-22 09:12, Ingo Molnar wrote:
>
> * Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> wrote:
>
>>>> - unsafe_put_user(cpu_id, &rseq->cpu_id_start, efault_end);
>>>> - unsafe_put_user(cpu_id, &rseq->cpu_id, efault_end);
>>>> - unsafe_put_user(node_id, &rseq->node_id, efault_end);
>>>> - unsafe_put_user(mm_cid, &rseq->mm_cid, efault_end);
>>>> +
>>>> + unsafe_rseq_set_field(t, cpu_id_start, cpu_id, efault_end);
>>>> + unsafe_rseq_set_field(t, cpu_id, cpu_id, efault_end);
>>>> + unsafe_rseq_set_field(t, node_id, node_id, efault_end);
>>>> + unsafe_rseq_set_field(t, mm_cid, mm_cid, efault_end);
>>>
>>> Could we please name the new wrapper rseq_unsafe_put_user(), to make it
>>> clear it's a wrapper around unsafe_put_user()?
>>
>> If we do this then need to make sure the order of arguments becomes
>> similar to unsafe_put_user for consistency.
>
> Absolutely.
>
>> I always find it odd that the "source" argument comes first and
>> the "destination" argument comes second in all put_user() APIs,
>> compared to memcpy, WRITE_ONCE() and all assignments (e.g.
>> operator "=" LHS vs RHS). Choosing a different argument order
>> therefore made sense with a naming different from "*put_user",
>> but not so much if we use a derived naming.
>
> Yeah, put_user()'s oddity is a random historic idiosyncrasy that we
> want to preserve in derived naming to reduce the potential for
> confusion.

Would that be ok?

rseq_unsafe_put_user(t, value, field, error_label)

>
> Thanks,
>
> Ingo