Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
seccomp: Add tgid and tid into seccomp_data
Browse files Browse the repository at this point in the history
Add the current thread and thread group IDs into the data
available for seccomp-bpf programs to work on.  This allows
installation of filters that police syscalls based on thread
or process ID, e.g. tgkill(2)/kill(2)/prctl(2).
  • Loading branch information
daviddrysdale committed May 7, 2014
1 parent 13499e6 commit e163c63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/uapi/linux/seccomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@
* @instruction_pointer: at the time of the system call.
* @args: up to 6 system call arguments always stored as 64-bit values
* regardless of the architecture.
* @tgid: thread group ID of the thread executing the BPF program.
* @tid: thread ID of the thread executing the BPF program.
*/
struct seccomp_data {
int nr;
__u32 arch;
__u64 instruction_pointer;
__u64 args[6];
__u32 tgid;
__u32 tid;
};

#endif /* _UAPI_LINUX_SECCOMP_H */
4 changes: 4 additions & 0 deletions kernel/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ u32 seccomp_bpf_load(int off)
return get_u32(KSTK_EIP(current), 0);
if (off == BPF_DATA(instruction_pointer) + sizeof(u32))
return get_u32(KSTK_EIP(current), 1);
if (off == BPF_DATA(tgid))
return task_tgid_vnr(current);
if (off == BPF_DATA(tid))
return task_pid_vnr(current);
/* seccomp_check_filter should make this impossible. */
BUG();
}
Expand Down

0 comments on commit e163c63

Please sign in to comment.