From: Piotr Figiel <figiel@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Kees Cook <keescook@chromium.org>,
Alexey Gladkov <gladkov.alexey@gmail.com>,
Michel Lespinasse <walken@google.com>,
Bernd Edlinger <bernd.edlinger@hotmail.de>,
Andrei Vagin <avagin@gmail.com>,
mathieu.desnoyers@efficios.com, viro@zeniv.linux.org.uk,
peterz@infradead.org, paulmck@kernel.org, boqun.feng@gmail.com,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
posk@google.com, kyurtsever@google.com, ckennelly@google.com,
pjt@google.com
Subject: Re: [PATCH v3] fs/proc: Expose RSEQ configuration
Date: Wed, 27 Jan 2021 16:07:09 +0100 [thread overview]
Message-ID: <YBGBnQWJDVZ7Y7s6@google.com> (raw)
In-Reply-To: <20210126112547.d3f18b6a2abe864e8bfa7fcd@linux-foundation.org>
On Tue, Jan 26, 2021 at 11:25:47AM -0800, Andrew Morton wrote:
> On Tue, 26 Jan 2021 19:54:12 +0100 Piotr Figiel <figiel@google.com> wrote:
> > To achieve above goals expose the RSEQ structure address and the
> > signature value with the new per-thread procfs file "rseq".
> Using "/proc/<pid>/rseq" would be more informative.
>
> > fs/exec.c | 2 ++
> > fs/proc/base.c | 22 ++++++++++++++++++++++
> > kernel/rseq.c | 4 ++++
>
> A Documentation/ update would be appropriate.
>
> > + task_lock(current);
> > rseq_execve(current);
> > + task_unlock(current);
>
> There's a comment over the task_lock() implementation which explains
> what things it locks. An update to that would be helpful.
Agreed I'll include fixes for above comments in v4.
> > --- a/fs/proc/base.c
> > +++ b/fs/proc/base.c
> > @@ -662,6 +662,22 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
> >
> > return 0;
> > }
> > +
> > +#ifdef CONFIG_RSEQ
> > +static int proc_pid_rseq(struct seq_file *m, struct pid_namespace *ns,
> > + struct pid *pid, struct task_struct *task)
> > +{
> > + int res = lock_trace(task);
> > +
> > + if (res)
> > + return res;
> > + task_lock(task);
> > + seq_printf(m, "%px %08x\n", task->rseq, task->rseq_sig);
> > + task_unlock(task);
> > + unlock_trace(task);
> > + return 0;
> > +}
>
> Do we actually need task_lock() for this purpose? Would
> exec_update_lock() alone be adequate and appropriate?
Now rseq syscall which modifies those fields isn't synchronised with
exec_update_lock. So either a new lock or task_lock() could be used or
exec_update_lock could be reused in the syscall. I decided against
exec_update_lock reuse in the syscall because it's normally used to
guard access checks against concurrent setuid exec. This could be
potentially confusing as it's not relevant for the the rseq syscall
code.
I think task_lock usage here is also consistent with how it's used
across the kernel.
Whether we need consistent rseq and rseq_sig pairs in the proc output, I
think there's some argument for it (discussed also in parallel thread
with Mathieu Desnoyers).
Best regards,
Piotr.
next prev parent reply other threads:[~2021-01-27 15:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 18:54 [PATCH v3] fs/proc: Expose RSEQ configuration Piotr Figiel
2021-01-26 19:25 ` Andrew Morton
2021-01-27 15:07 ` Piotr Figiel [this message]
2021-01-26 20:58 ` Mathieu Desnoyers
2021-01-27 15:14 ` Piotr Figiel
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=YBGBnQWJDVZ7Y7s6@google.com \
--to=figiel@google.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=bernd.edlinger@hotmail.de \
--cc=boqun.feng@gmail.com \
--cc=ckennelly@google.com \
--cc=ebiederm@xmission.com \
--cc=gladkov.alexey@gmail.com \
--cc=keescook@chromium.org \
--cc=kyurtsever@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=posk@google.com \
--cc=viro@zeniv.linux.org.uk \
--cc=walken@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.