From: Peter Zijlstra <peterz@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-kernel@vger.kernel.org,
"Paul E . McKenney" <paulmck@kernel.org>,
Boqun Feng <boqun.feng@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Peter Oskolkov <posk@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Marco Elver <elver@google.com>,
Florian Weimer <fweimer@redhat.com>,
Carlos O'Donell <carlos@redhat.com>, DJ Delorie <dj@redhat.com>,
libc-alpha@sourceware.org
Subject: Re: [PATCH v1 1/1] rseq: Validate read-only fields under DEBUG_RSEQ config
Date: Tue, 12 Nov 2024 15:47:39 +0100 [thread overview]
Message-ID: <20241112144739.GJ6497@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <f76b79c0-070a-44d6-ac8b-71d063f2357a@efficios.com>
On Tue, Nov 12, 2024 at 09:27:23AM -0500, Mathieu Desnoyers wrote:
> Your approach looks indeed better than mine, I'll steal it with your
> permission. :)
Ofc.
> > > +#ifdef CONFIG_DEBUG_RSEQ
> > > + /*
> > > + * Initialize the in-kernel rseq fields copy for validation of
> > > + * read-only fields.
> > > + */
> > > + if (get_user(rseq_kernel_fields(current)->cpu_id_start, &rseq->cpu_id_start) ||
> > > + get_user(rseq_kernel_fields(current)->cpu_id, &rseq->cpu_id) ||
> > > + get_user(rseq_kernel_fields(current)->node_id, &rseq->node_id) ||
> > > + get_user(rseq_kernel_fields(current)->mm_cid, &rseq->mm_cid))
> > > + return -EFAULT;
> > > +#endif
> >
> > So I didn't change the above, but wouldn't it make more sense to do
> > rseq_reset_rseq_cpu_node_id() here, but without the validation?
>
> Indeed we could do this (for both DEBUG_RSEQ={y,n}), but it would add extra
> useless stores to those userspace fields on rseq registration, which is
> performed on every thread creation starting from glibc 2.35. The
> rseq_set_notify_resume() invoked at the end of registration ensures that
> those fields get populated before return to userspace.
>
> So I am not against a more robust approach, but I'm reluctant to add redundant
> work on thread creation.
Ah, indeed. Oh well..
prev parent reply other threads:[~2024-11-12 14:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-11 19:22 Mathieu Desnoyers
2024-11-12 10:04 ` Peter Zijlstra
2024-11-12 14:27 ` Mathieu Desnoyers
2024-11-12 14:47 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241112144739.GJ6497@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=boqun.feng@gmail.com \
--cc=carlos@redhat.com \
--cc=dj@redhat.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=posk@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®