Thread (43 messages) 43 messages, 7 authors, 2018-07-03

Re: [RFC PATCH for 4.18] rseq: use __u64 for rseq_cs fields, validate user inputs

flat view

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2018-07-02 22:45:17
Also in: lkml

On Mon, Jul 2, 2018 at 3:31 PM Mathieu Desnoyers
[off-list ref] wrote:
Change the rseq ABI so rseq_cs start_ip, post_commit_offset and abort_ip
fields are seen as 64-bit fields by both 32-bit and 64-bit kernels rather
that ignoring the 32 upper bits on 32-bit kernels. This ensures we have a
consistent behavior for a 32-bit binary executed on 32-bit kernels and in
compat mode on 64-bit kernels.
Actually, now that I see this again, I react to:

quoted hunk ↗ jump to hunk
+static int check_rseq_cs_padding(struct task_struct *t)
+{
+       u32 pad;
+       int ret;
+
+       ret = __get_user(pad, &t->rseq->rseq_cs_padding);
+       if (ret)
+               return ret;
+       if (pad)
+               return -EINVAL;
+       return 0;
+}
This is all wrong.

Just make "rseq_cs" be an __u64" too. That will clean up everything,
and user space will have a much easier time filling it in too, since
it's just one field. Instead of having to remember about the "let's
fill in padding for 32-bit cases".

Then the rseq_get_rseq_cs() will be

        __u64 rseq_cs;

        ret = get_user(rseq_cs, &t->rseq->rseq_cs);
        if (ret)
                return ret;
        ptr = (void *)rseq_cs;
        if (rseq_cs != (unsigned long)ptr)
                return -EINVAL;

and it's all good, no #ifdef's etc needed.

Hmm?

Sorry for the bike-shedding, but this is now the last remaining user
of that LINUX_FIELD_u32_u64, so let's just get rid of it entirely, ok?

Then we can also get rid of that silly uapi/linux/types_32_64.h header
file entirely.

That would be *lovely*. Simpler code, simpler and less error-prone
interfaces, and one less specialized header file.

              Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help