Re: [PATCH v2] ptrace: add PTRACE_GET_RSEQ_CONFIGURATION request

From
Piotr Figiel <hidden>
Date
2021-02-26 16:07:39
Also in
linux-api, lkml
Reply to
Mathieu Desnoyers, 2021-02-26
Hi,

On Fri, Feb 26, 2021 at 10:32:35AM -0500, Mathieu Desnoyers wrote:
quoted
+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.
Thread (10 messages) 10 messages, 5 authors, last reply 2021-03-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help