History

ptrace: take into account saved_sigmask in PTRACE{GET,SET}SIGMASK

There are a few system calls (pselect, ppoll, etc) which replace a task sigmask while they are running in a kernel-space When a task calls one of these syscalls, the kernel saves a current sigmask in task->saved_sigmask and sets a syscall sigmask. On syscall-exit-stop, ptrace traps a task before restoring the saved_sigmask, so PTRACE_GETSIGMASK returns the syscall sigmask and PTRACE_SETSIGMASK does nothing, because its sigmask is replaced by saved_sigmask, when the task returns to user-space. This patch fixes this problem. PTRACE_GETSIGMASK returns saved_sigmask if it's set. PTRACE_SETSIGMASK drops the TIF_RESTORE_SIGMASK flag.

Andrei Vagin committed 7 years ago

Commit fcfc2aa1 parent eebf3642 files · +31 −2Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/sched/signal.h+18−0
@@ -418,10 +418,20 @@ static inline void set_restore_sigmask(void) · 417 unmodified lines
418 set_thread_flag(TIF_RESTORE_SIGMASK);418 set_thread_flag(TIF_RESTORE_SIGMASK);
419 WARN_ON(!test_thread_flag(TIF_SIGPENDING));419 WARN_ON(!test_thread_flag(TIF_SIGPENDING));
420}420}
421
422static inline void clear_tsk_restore_sigmask(struct task_struct *tsk)
423{
424 clear_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK);
425}
426
421static inline void clear_restore_sigmask(void)427static inline void clear_restore_sigmask(void)
422{428{
423 clear_thread_flag(TIF_RESTORE_SIGMASK);429 clear_thread_flag(TIF_RESTORE_SIGMASK);
424}430}
431static inline bool test_tsk_restore_sigmask(struct task_struct *tsk)
432{
433 return test_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK);
434}
425static inline bool test_restore_sigmask(void)435static inline bool test_restore_sigmask(void)
426{436{
427 return test_thread_flag(TIF_RESTORE_SIGMASK);437 return test_thread_flag(TIF_RESTORE_SIGMASK);
@@ -439,6 +449,10 @@ static inline void set_restore_sigmask(void) · 11 unmodified lines
439 current->restore_sigmask = true;449 current->restore_sigmask = true;
440 WARN_ON(!test_thread_flag(TIF_SIGPENDING));450 WARN_ON(!test_thread_flag(TIF_SIGPENDING));
441}451}
452static inline void clear_tsk_restore_sigmask(struct task_struct *tsk)
453{
454 tsk->restore_sigmask = false;
455}
442static inline void clear_restore_sigmask(void)456static inline void clear_restore_sigmask(void)
443{457{
444 current->restore_sigmask = false;458 current->restore_sigmask = false;
@@ -447,6 +461,10 @@ static inline bool test_restore_sigmask(void) · 2 unmodified lines
447{461{
448 return current->restore_sigmask;462 return current->restore_sigmask;
449}463}
464static inline bool test_tsk_restore_sigmask(struct task_struct *tsk)
465{
466 return tsk->restore_sigmask;
467}
450static inline bool test_and_clear_restore_sigmask(void)468static inline bool test_and_clear_restore_sigmask(void)
451{469{
452 if (!current->restore_sigmask)470 if (!current->restore_sigmask)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t