mailing list of musl libc
 help / color / mirror / code / Atom feed
* seccomp causes pthread_join() to hang
@ 2019-06-25 23:18 Radostin Stoyanov
  2019-06-25 23:26 ` Rich Felker
  0 siblings, 1 reply; 6+ messages in thread
From: Radostin Stoyanov @ 2019-06-25 23:18 UTC (permalink / raw)
  To: musl; +Cc: dalias

Hello,

In the test suite of CRIU [1] we have noticed an interesting bug which 
is caused by commit 8f11e6127fe93093f81a52b15bb1537edc3fc8af ("track all 
live threads in an AS-safe, fully-consistent linked list") [2].

When seccomp is used in a multithreaded application it may cause 
pthread_join() to hang.

This is a minimal application to reproduce the issue:


#include <errno.h>
#include <seccomp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>

static void *fn()
{
     scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_KILL);
     if (!ctx) {
         perror("seccomp_init");
         goto err;
     }

     if (seccomp_load(ctx) < 0) {
         perror("seccomp_load");
         goto err;
     }

     /* This should cause SIG_KILL */
     getpid();
err:
     return (void *)1;
}

int main()
{
     pthread_t t1;

     if (pthread_create(&t1, NULL, fn, NULL)) {
         perror("pthread_create");
         return -1;
     }

     if (pthread_join(t1, NULL)) {
         perror("pthread_join");
         return -1;
     }

     return 0;
}


Expected behaviour: Thread t1 should receive SIG_KILL and the main 
thread should return 0.
Actual behaviour: pthread_join() hangs.
Reproducibility: Always
Regression: Yes


This bug can be reproduced with Alpine 3.10 ($ docker run -it 
alpine:3.10 sh).


[1] https://criu.org/
[2] 
https://git.musl-libc.org/cgit/musl/commit/?id=8f11e6127fe93093f81a52b15bb1537edc3fc8af


Kind regards,
Radostin


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-26 15:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 23:18 seccomp causes pthread_join() to hang Radostin Stoyanov
2019-06-25 23:26 ` Rich Felker
2019-06-26  7:30   ` Radostin Stoyanov
2019-06-26 11:25     ` Szabolcs Nagy
2019-06-26 13:43       ` Radostin Stoyanov
2019-06-26 15:33     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).