Date: Fri, 14 Jul 2017 09:34:44 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320982 - in head/sys: compat/freebsd32 kern netinet sys Message-ID: <201707140934.v6E9Yivq086290@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Fri Jul 14 09:34:44 2017 New Revision: 320982 URL: https://svnweb.freebsd.org/changeset/base/320982 Log: Correct sysent flags for dynamically loaded syscalls. Using the https://github.com/google/capsicum-test/ suite, the PosixMqueue.CapModeForked test was failing due to an ECAPMODE after calling kmq_notify(). On further inspection, the dynamically loaded syscall entry was initialized with sy_flags zeroed out, since SYSCALL_INIT_HELPER() left sysent.sy_flags with the default value. Add a new helper SYSCALL{,32}_INIT_HELPER_F() which takes an additional argument to specify the sy_flags value. Submitted by: Siva Mahadevan <smahadevan@freebsdfoundation.org> Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D11576 Modified: head/sys/compat/freebsd32/freebsd32_util.h head/sys/kern/capabilities.conf head/sys/kern/uipc_mqueue.c head/sys/netinet/sctp_syscalls.c head/sys/sys/sysent.h Modified: head/sys/compat/freebsd32/freebsd32_util.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_util.h Fri Jul 14 07:42:57 2017 (r320981) +++ head/sys/compat/freebsd32/freebsd32_util.h Fri Jul 14 09:34:44 2017 (r320982) @@ -79,23 +79,30 @@ SYSCALL32_MODULE(syscallname, & syscallname##_syscall32, & syscallname##_sysent32,\ NULL, NULL); -#define SYSCALL32_INIT_HELPER(syscallname) { \ +#define SYSCALL32_INIT_HELPER_F(syscallname, flags) { \ .new_sysent = { \ .sy_narg = (sizeof(struct syscallname ## _args ) \ / sizeof(register_t)), \ .sy_call = (sy_call_t *)& syscallname, \ + .sy_flags = (flags) \ }, \ .syscall_no = FREEBSD32_SYS_##syscallname \ } -#define SYSCALL32_INIT_HELPER_COMPAT(syscallname) { \ +#define SYSCALL32_INIT_HELPER_COMPAT_F(syscallname, flags) { \ .new_sysent = { \ .sy_narg = (sizeof(struct syscallname ## _args ) \ / sizeof(register_t)), \ .sy_call = (sy_call_t *)& sys_ ## syscallname, \ + .sy_flags = (flags) \ }, \ .syscall_no = FREEBSD32_SYS_##syscallname \ } + +#define SYSCALL32_INIT_HELPER(syscallname) \ + SYSCALL32_INIT_HELPER_F(syscallname, 0) +#define SYSCALL32_INIT_HELPER_COMPAT(syscallname) \ + SYSCALL32_INIT_HELPER_COMPAT_F(syscallname, 0) int syscall32_register(int *offset, struct sysent *new_sysent, struct sysent *old_sysent, int flags); Modified: head/sys/kern/capabilities.conf ============================================================================== --- head/sys/kern/capabilities.conf Fri Jul 14 07:42:57 2017 (r320981) +++ head/sys/kern/capabilities.conf Fri Jul 14 09:34:44 2017 (r320982) @@ -350,6 +350,8 @@ kill ## ## Allow message queue operations on file descriptors, subject to capability ## rights. +## NOTE: Corresponding sysents are initialized in sys/kern/uipc_mqueue.c with +## SYF_CAPENABLED. ## kmq_notify kmq_setattr @@ -545,6 +547,8 @@ sched_yield ## ## Allow I/O-related file descriptors, subject to capability rights. +## NOTE: Corresponding sysents are initialized in sys/netinet/sctp_syscalls.c +## with SYF_CAPENABLED. ## sctp_generic_recvmsg sctp_generic_sendmsg Modified: head/sys/kern/uipc_mqueue.c ============================================================================== --- head/sys/kern/uipc_mqueue.c Fri Jul 14 07:42:57 2017 (r320981) +++ head/sys/kern/uipc_mqueue.c Fri Jul 14 09:34:44 2017 (r320982) @@ -2708,10 +2708,10 @@ static struct vfsconf mqueuefs_vfsconf = { static struct syscall_helper_data mq_syscalls[] = { SYSCALL_INIT_HELPER(kmq_open), - SYSCALL_INIT_HELPER(kmq_setattr), - SYSCALL_INIT_HELPER(kmq_timedsend), - SYSCALL_INIT_HELPER(kmq_timedreceive), - SYSCALL_INIT_HELPER(kmq_notify), + SYSCALL_INIT_HELPER_F(kmq_setattr, SYF_CAPENABLED), + SYSCALL_INIT_HELPER_F(kmq_timedsend, SYF_CAPENABLED), + SYSCALL_INIT_HELPER_F(kmq_timedreceive, SYF_CAPENABLED), + SYSCALL_INIT_HELPER_F(kmq_notify, SYF_CAPENABLED), SYSCALL_INIT_HELPER(kmq_unlink), SYSCALL_INIT_LAST }; @@ -2870,10 +2870,10 @@ freebsd32_kmq_notify(struct thread *td, struct freebsd static struct syscall_helper_data mq32_syscalls[] = { SYSCALL32_INIT_HELPER(freebsd32_kmq_open), - SYSCALL32_INIT_HELPER(freebsd32_kmq_setattr), - SYSCALL32_INIT_HELPER(freebsd32_kmq_timedsend), - SYSCALL32_INIT_HELPER(freebsd32_kmq_timedreceive), - SYSCALL32_INIT_HELPER(freebsd32_kmq_notify), + SYSCALL32_INIT_HELPER_F(freebsd32_kmq_setattr, SYF_CAPENABLED), + SYSCALL32_INIT_HELPER_F(freebsd32_kmq_timedsend, SYF_CAPENABLED), + SYSCALL32_INIT_HELPER_F(freebsd32_kmq_timedreceive, SYF_CAPENABLED), + SYSCALL32_INIT_HELPER_F(freebsd32_kmq_notify, SYF_CAPENABLED), SYSCALL32_INIT_HELPER_COMPAT(kmq_unlink), SYSCALL_INIT_LAST }; Modified: head/sys/netinet/sctp_syscalls.c ============================================================================== --- head/sys/netinet/sctp_syscalls.c Fri Jul 14 07:42:57 2017 (r320981) +++ head/sys/netinet/sctp_syscalls.c Fri Jul 14 09:34:44 2017 (r320982) @@ -82,10 +82,10 @@ __FBSDID("$FreeBSD$"); #include <netinet/sctp_peeloff.h> static struct syscall_helper_data sctp_syscalls[] = { - SYSCALL_INIT_HELPER(sctp_peeloff), - SYSCALL_INIT_HELPER(sctp_generic_sendmsg), - SYSCALL_INIT_HELPER(sctp_generic_sendmsg_iov), - SYSCALL_INIT_HELPER(sctp_generic_recvmsg), + SYSCALL_INIT_HELPER_F(sctp_peeloff, SYF_CAPENABLED), + SYSCALL_INIT_HELPER_F(sctp_generic_sendmsg, SYF_CAPENABLED), + SYSCALL_INIT_HELPER_F(sctp_generic_sendmsg_iov, SYF_CAPENABLED), + SYSCALL_INIT_HELPER_F(sctp_generic_recvmsg, SYF_CAPENABLED), SYSCALL_INIT_LAST }; Modified: head/sys/sys/sysent.h ============================================================================== --- head/sys/sys/sysent.h Fri Jul 14 07:42:57 2017 (r320981) +++ head/sys/sys/sysent.h Fri Jul 14 09:34:44 2017 (r320982) @@ -230,24 +230,30 @@ struct syscall_helper_data { int syscall_no; int registered; }; -#define SYSCALL_INIT_HELPER(syscallname) { \ +#define SYSCALL_INIT_HELPER_F(syscallname, flags) { \ .new_sysent = { \ .sy_narg = (sizeof(struct syscallname ## _args ) \ / sizeof(register_t)), \ .sy_call = (sy_call_t *)& sys_ ## syscallname, \ - .sy_auevent = SYS_AUE_##syscallname \ + .sy_auevent = SYS_AUE_##syscallname, \ + .sy_flags = (flags) \ }, \ .syscall_no = SYS_##syscallname \ } -#define SYSCALL_INIT_HELPER_COMPAT(syscallname) { \ +#define SYSCALL_INIT_HELPER_COMPAT_F(syscallname, flags) { \ .new_sysent = { \ .sy_narg = (sizeof(struct syscallname ## _args ) \ / sizeof(register_t)), \ .sy_call = (sy_call_t *)& syscallname, \ - .sy_auevent = SYS_AUE_##syscallname \ + .sy_auevent = SYS_AUE_##syscallname, \ + .sy_flags = (flags) \ }, \ .syscall_no = SYS_##syscallname \ } +#define SYSCALL_INIT_HELPER(syscallname) \ + SYSCALL_INIT_HELPER_F(syscallname, 0) +#define SYSCALL_INIT_HELPER_COMPAT(syscallname) \ + SYSCALL_INIT_HELPER_COMPAT_F(syscallname, 0) #define SYSCALL_INIT_LAST { \ .syscall_no = NO_SYSCALL \ }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707140934.v6E9Yivq086290>