All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Günther Noack" <gnoack@google.com>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: "Günther Noack" <gnoack3000@gmail.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Oleg Nesterov" <oleg@redhat.com>, "Tejun Heo" <tj@kernel.org>,
	"Bart Van Assche" <bvanassche@acm.org>,
	"Cen Zhang" <blbllhy@gmail.com>,
	"James Morris" <jmorris@namei.org>,
	"Lee Seong Hyeon" <ihopenre@gmail.com>,
	"Marco Elver" <elver@google.com>, NeilBrown <neil@brown.name>,
	"Nickolai Zeldovich" <nickolai@csail.mit.edu>,
	"Paul Moore" <paul@paul-moore.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Serge E . Hallyn" <serge@hallyn.com>,
	"Yihan Ding" <dingyihan@uniontech.com>,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] landlock: Do not hold exec_update_lock across the TSYNC wait
Date: Tue, 24 Nov 2026 17:02:44 +0100	[thread overview]
Message-ID: <awW1JBtrZUoBcwJq@google.com> (raw)
In-Reply-To: <20261123.RailieV3ePah@digikod.net>

On Mon, Nov 23, 2026 at 10:37:22AM +0100, Mickaël Salaün wrote:
> On Sat, Nov 21, 2026 at 10:46:49PM +0100, Günther Noack wrote:
> > On Fri, Nov 20, 2026 at 04:15:52PM +0100, Mickaël Salaün wrote:
> > > landlock_restrict_sibling_threads() write-locks
> > > current->signal->exec_update_lock to serialize TSYNC callers, and holds
> > > it until every sibling thread has run its task_work.  This wait is
> > > unbounded: TWA_SIGNAL does not wake a TASK_KILLABLE sleeper, so a
> > > sibling blocked as a vfork() parent runs it only once its child execs or
> > > exits.
> > > 
> > > Meanwhile, readers of this lock block, mostly in D state:
> > > /proc/<pid>/stat, mm_access(), pidfd_getfd(), kcmp(), perf_event_open(),
> > > etc.  An unprivileged process can thus stall tools run by other users,
> > > including root, such as ps and top.
> > > 
> > > Only a per-process "TSYNC in progress" marker is needed.  Use an unused
> > > signal_struct.flags bit, protected by sighand->siglock, which is held
> > > only to set or clear the marker.  A second caller still restarts the
> > > syscall, and a cleanup class releases the marker on every return.
> > > 
> > > Like de_thread(), treat a group exit or an ongoing exec as a held
> > > marker: a group exit may overwrite the flags, and both kill the other
> > > threads, which the restart lets the caller handle.
> > > 
> > > Add KUnit tests for taking a free marker and for rejecting a held one.
> > > A concurrent TSYNC caller cannot be started deterministically from user
> > > space, but a KUnit thread has no sibling and can hold the marker itself.
> > > 
> > > Cc: Christian Brauner <brauner@kernel.org>
> > > Cc: Günther Noack <gnoack@google.com>
> > > Cc: Nickolai Zeldovich <nickolai@csail.mit.edu>
> > > Cc: Oleg Nesterov <oleg@redhat.com>
> > > Cc: Tejun Heo <tj@kernel.org>
> > > Cc: Yihan Ding <dingyihan@uniontech.com>
> > > Cc: stable@vger.kernel.org
> > > Reported-by: Lee Seong Hyeon <ihopenre@gmail.com>
> > > Suggested-by: Lee Seong Hyeon <ihopenre@gmail.com>
> > > Fixes: ff88df67dbf7 ("landlock: Serialize TSYNC thread restriction")
> > > Signed-off-by: Mickaël Salaün <mic@digikod.net>
> > > ---
> > > 
> > > Changes since the initial report from Lee Seong Hyeon:
> > > - Rewrite the fix, storing the marker in an unused signal_struct.flags
> > >   bit protected by sighand->siglock instead of adding a signal_struct
> > >   field.
> > > - Treat group exit and ongoing exec as a held marker, because group exit
> > >   may overwrite the flags.
> > > - Release the marker with a cleanup class.
> > 
> > It's not clear to me why the cleanup class and the fix are bundled in
> > one commit here.  (I do find the cleanup class useful, but shouldn't a
> > bugfix commit be as minimal as possible so that it is easy for people
> > to apply to their downstream kernels?)
> 
> I included the cleanup class because we needed to change the up_write()
> call anyway, so it's a good opportunity to use an automatic cleanup
> mechanism instead of replacing it with an explicit lock + flag change.
> 
> I also moved the initial check before the initialization because it
> makes more sense there and it was a good opportunity to do it now (I
> updated the comment as well).
> 
> This extra cleanup doesn't have any impact on backporting.

Fair enough, sounds good.

Acked-by: Günther Noack <gnoack@google.com>

—Günther

  reply	other threads:[~2026-11-24 16:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 15:15 [PATCH] landlock: Do not hold exec_update_lock across the TSYNC wait Mickaël Salaün
2026-11-20 15:22 ` sashiko-bot
2026-11-21 21:46 ` Günther Noack
2026-11-23  9:37   ` Mickaël Salaün
2026-11-24 16:02     ` Günther Noack [this message]
2026-11-22 17:35 ` Oleg Nesterov
2026-11-23 13:15   ` Mickaël Salaün
2026-11-23 13:49     ` Oleg Nesterov
2026-11-24 15:09 ` Christian Brauner

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=awW1JBtrZUoBcwJq@google.com \
    --to=gnoack@google.com \
    --cc=blbllhy@gmail.com \
    --cc=brauner@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=dingyihan@uniontech.com \
    --cc=elver@google.com \
    --cc=gnoack3000@gmail.com \
    --cc=ihopenre@gmail.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=neil@brown.name \
    --cc=nickolai@csail.mit.edu \
    --cc=oleg@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=peterz@infradead.org \
    --cc=serge@hallyn.com \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    /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.