Re: [PATCH v2] ptrace: add PTRACE_GET_RSEQ_CONFIGURATION request

From: Piotr Figiel
Date: Fri Feb 26 2021 - 11:07:39 EST


Hi,

On Fri, Feb 26, 2021 at 10:32:35AM -0500, Mathieu Desnoyers wrote:
> > +static long ptrace_get_rseq_configuration(struct task_struct *task,
> > + unsigned long size, void __user *data)
> > +{
> > + struct ptrace_rseq_configuration conf = {
> > + .rseq_abi_pointer = (u64)(uintptr_t)task->rseq,
> > + .rseq_abi_size = sizeof(*task->rseq),
> > + .signature = task->rseq_sig,
> > + .flags = 0,
> > + };
> > +
> > + size = min_t(unsigned long, size, sizeof(conf));
> > + if (copy_to_user(data, &conf, size))
> > + return -EFAULT;
> > + return sizeof(conf);
> > +}
>
> I think what Florian was after would be:
>
> struct ptrace_rseq_configuration {
> __u32 size; /* size of struct ptrace_rseq_configuration */
> __u32 flags;
> __u64 rseq_abi_pointer;
> __u32 signature;
> __u32 pad;
> };
>
> where:
>
> .size = sizeof(struct ptrace_rseq_configuration),
>
> This way, the configuration structure can be expanded in the future. The
> rseq ABI structure is by definition fixed-size, so there is no point in
> having its size here.

Still rseq syscall accepts the rseq ABI structure size as a paremeter.
I think this way the information returned from ptrace is consistent with
the userspace view of the rseq state and allows expansion in case the
ABI structure would have to be extended (in spite of it's current
definition).

The configuration structure still can be expanded as its size is
reported to userspace as return value from the request (in line with
Dmitry's comments).

Best regards, Piotr.