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

From: Ingo Molnar
Date: Sat Feb 22 2025 - 09:13:05 EST



* 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.

Thanks,

Ingo