Skip to content

Commit 53c59be

Browse files
authored
Clear thread pflags in _do_execve (#1394)
* sys/kern/exec.c: clear pflags right after mcontext_init * include/sys/thread.h: add comment for TDP_* flags
1 parent bc09e0f commit 53c59be

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/sys/thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ typedef enum {
7070
} td_flags_t;
7171

7272
typedef enum {
73+
/* After user context setup in execve TDP_* flags that should not be inherited
74+
* should be cleared */
7375
TDP_OLDSIGMASK = 0x01, /* Pass td_oldsigmask as return mask to send_sig(). */
7476
TDP_FPUCTXSAVED = 0x02, /* FPU context was saved by `ctx_switch`. */
7577
TDP_FPUINUSE = 0x04 /* FPU is in use and its context should be saved &

sys/kern/exec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ static int _do_execve(exec_args_t *args) {
411411
/* Set up user context. */
412412
mcontext_init(td->td_uctx, (void *)eh.e_entry, (void *)stack_top);
413413

414+
/* All thread pflags that should not be inherited should be cleared */
415+
td->td_pflags = 0;
416+
414417
WITH_PROC_LOCK(p) {
415418
sig_onexec(p);
416419
/* Set new credentials if needed */

0 commit comments

Comments
 (0)