Module Name: src Committed By: thorpej Date: Tue Sep 28 14:52:22 UTC 2021
Modified Files: src/sys/kern: kern_exec.c Log Message: In the exec path, multi-LWP programs dispose of their robust futexes by calling exit_lwps(), except for the last LWP. So, dispose of that LWP's robust futexes right before calling lwp_ctl_exit(). Fixes a "WARNING: ... : unmapped robust futex list head" message when running bash under Linux emulation on aarch64. Root caused and patch proposed by ryo@. I have tweaked it slightly, just to add a comment and a KASSERT(). To generate a diff of this commit: cvs rdiff -u -r1.506 -r1.507 src/sys/kern/kern_exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.506 src/sys/kern/kern_exec.c:1.507 --- src/sys/kern/kern_exec.c:1.506 Fri Jun 11 12:54:22 2021 +++ src/sys/kern/kern_exec.c Tue Sep 28 14:52:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.506 2021/06/11 12:54:22 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.507 2021/09/28 14:52:22 thorpej Exp $ */ /*- * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.506 2021/06/11 12:54:22 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.507 2021/09/28 14:52:22 thorpej Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -87,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_exec.c, #include <sys/acct.h> #include <sys/atomic.h> #include <sys/exec.h> +#include <sys/futex.h> #include <sys/ktrace.h> #include <sys/uidinfo.h> #include <sys/wait.h> @@ -1204,6 +1205,16 @@ execve_runproc(struct lwp *l, struct exe } KDASSERT(p->p_nlwps == 1); + /* + * All of the other LWPs got rid of their robust futexes + * when they exited above, but we might still have some + * to dispose of. Do that now. + */ + if (__predict_false(l->l_robust_head != 0)) { + KASSERT((l->l_lid & FUTEX_TID_MASK) == l->l_lid); + futex_release_all_lwp(l, l->l_lid); + } + /* Destroy any lwpctl info. */ if (p->p_lwpctl != NULL) lwp_ctl_exit();