Skip to content

Commit 1087a63

Browse files
author
sewardj
committed
PRE(sys_prctl): handle PR_SET_SECCOMP.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14994 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent 00fb886 commit 1087a63

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

coregrind/m_syswrap/syswrap-linux.c

+15
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,21 @@ PRE(sys_prctl)
10181018
case VKI_PR_SET_PTRACER:
10191019
PRE_REG_READ2(int, "prctl", int, option, int, ptracer_process_ID);
10201020
break;
1021+
case VKI_PR_SET_SECCOMP:
1022+
/* This is a bit feeble in that it uses |option| before checking
1023+
it, but at least both sides of the conditional check it. */
1024+
if (ARG2 == VKI_SECCOMP_MODE_FILTER) {
1025+
PRE_REG_READ3(int, "prctl", int, option, int, mode, char*, filter);
1026+
if (ARG3) {
1027+
/* Should check that ARG3 points at a valid struct sock_fprog.
1028+
Sounds complex; hence be lame. */
1029+
PRE_MEM_READ( "prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, filter)",
1030+
ARG3, 1 );
1031+
}
1032+
} else {
1033+
PRE_REG_READ2(int, "prctl", int, option, int, mode);
1034+
}
1035+
break;
10211036
default:
10221037
PRE_REG_READ5(long, "prctl",
10231038
int, option, unsigned long, arg2, unsigned long, arg3,

include/vki/vki-linux.h

+9
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,9 @@ struct vki_vt_consize {
25082508
# define VKI_PR_ENDIAN_BIG 0
25092509
# define VKI_PR_ENDIAN_LITTLE 1 /* True little endian mode */
25102510
# define VKI_PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */
2511+
2512+
#define VKI_PR_SET_SECCOMP 22
2513+
25112514
#define VKI_PR_SET_PTRACER 0x59616d61
25122515

25132516
//----------------------------------------------------------------------
@@ -4601,6 +4604,12 @@ enum vki_kcmp_type {
46014604
VKI_KCMP_TYPES
46024605
};
46034606

4607+
//----------------------------------------------------------------------
4608+
// From linux-3.19-rc5/include/uapi/linux/seccomp.h
4609+
//----------------------------------------------------------------------
4610+
4611+
#define VKI_SECCOMP_MODE_FILTER 2
4612+
46044613
#endif // __VKI_LINUX_H
46054614

46064615
/*--------------------------------------------------------------------*/

0 commit comments

Comments
 (0)