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
418418 set_thread_flag(TIF_RESTORE_SIGMASK);
419419 WARN_ON(!test_thread_flag(TIF_SIGPENDING));
420420 }
421+
422+static inline void clear_tsk_restore_sigmask(struct task_struct *tsk)
423+{
424+ clear_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK);
425+}
426+
421427 static inline void clear_restore_sigmask(void)
422428 {
423429 clear_thread_flag(TIF_RESTORE_SIGMASK);
424430 }
431+static inline bool test_tsk_restore_sigmask(struct task_struct *tsk)
432+{
433+ return test_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK);
434+}
425435 static inline bool test_restore_sigmask(void)
426436 {
427437 return test_thread_flag(TIF_RESTORE_SIGMASK);
@@ -439,6 +449,10 @@ static inline void set_restore_sigmask(void) · 11 unmodified lines
439449 current->restore_sigmask = true;
440450 WARN_ON(!test_thread_flag(TIF_SIGPENDING));
441451 }
452+static inline void clear_tsk_restore_sigmask(struct task_struct *tsk)
453+{
454+ tsk->restore_sigmask = false;
455+}
442456 static inline void clear_restore_sigmask(void)
443457 {
444458 current->restore_sigmask = false;
@@ -447,6 +461,10 @@ static inline bool test_restore_sigmask(void) · 2 unmodified lines
447461 {
448462 return current->restore_sigmask;
449463 }
464+static inline bool test_tsk_restore_sigmask(struct task_struct *tsk)
465+{
466+ return tsk->restore_sigmask;
467+}
450468 static inline bool test_and_clear_restore_sigmask(void)
451469 {
452470 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