lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 6 Oct 2022 21:40:38 -0400
From:   "Theodore Ts'o" <>
To:     Kees Cook <>
Cc:     Jorge Merlino <>,
        Christian Brauner <>,
        Eric Biederman <>,
        Jann Horn <>,
        Alexander Viro <>,
        Thomas Gleixner <>,
        Andy Lutomirski <>,
        Sebastian Andrzej Siewior <>,
        Andrew Morton <>,,,
        John Johansen <>,
        Paul Moore <>,
        James Morris <>,
        "Serge E. Hallyn" <>,
        Stephen Smalley <>,
        Eric Paris <>,
        Richard Haines <>,
        Casey Schaufler <>,
        Xin Long <>,
        "David S. Miller" <>,
        Todd Kjos <>,
        Ondrej Mosnacek <>,
        Prashanth Prahlad <>,
        Micah Morton <>,
        Fenghua Yu <>,
        Andrei Vagin <>,,,,,
Subject: Re: [PATCH] Fix race condition when exec'ing setuid files

On Thu, Oct 06, 2022 at 01:20:35PM -0700, Kees Cook wrote:
> So the question, then, is "why are they trying to exec while actively
> spawning new threads?" That appears to be the core problem here, and as
> far as I can tell, the kernel has behaved this way for a very long time.
> I don't think the kernel should fix this, either, because it leads to a
> very weird state for userspace, where the thread spawner may suddenly
> die due to the exec happening in another thread. This really looks like
> something userspace needs to handle correctly (i.e. don't try to exec
> while actively spawning threads).

One of the classic failure modes is when a threaded program calls a
library, and that library might try to do a fork/exec (or call
system(3) to run some command.  e.g., such as running "lvm create ..."
or to spawn some kind of helper daemon.

There are a number of stack overflow questions about this, and there
are some solutions to _some_ of the problems, such as using
pthread_atfork(), and knowing that you are about to call fork/exec,
and use some out of band mechanism to to make sure no threads get
spawned until the fork/exec is completed --- but if you don't know
that a library is going to do a fork/exec, well, life is tough. 

One technique even advocated by a stack overflow article is "avoid
using threads whenver possible".  :-/

	       	       	  	   - Ted

Powered by blists - more mailing lists