1 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
4 #include <bsm/audit_session.h>
11 #include <darwintest.h>
12 #include <darwintest_utils.h>
14 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
16 T_DECL(invalid_setaudit_57414044
,
17 "Verify that auditing a setaudit_addr syscall which has an invalid "
18 "at_type field does not panic",
19 T_META_CHECK_LEAKS(false))
23 int cond
, ret
= auditon(A_GETCOND
, &cond
, sizeof(cond
));
24 if (ret
== -1 && errno
== ENOSYS
) {
25 T_SKIP("no kernel support for auditing; can't test");
27 T_ASSERT_POSIX_SUCCESS(ret
, "auditon A_GETCOND");
28 if (cond
!= AUC_AUDITING
) {
29 T_SKIP("auditing is not enabled; can't test");
32 /* set up auditing to audit `setaudit_addr` */
33 auditpinfo_addr_t pinfo_addr
= {.ap_pid
= getpid()};
34 T_ASSERT_POSIX_SUCCESS(auditon(A_GETPINFO_ADDR
, &pinfo_addr
, sizeof(pinfo_addr
)), NULL
);
35 auditpinfo_t pinfo
= {.ap_pid
= getpid(), .ap_mask
= pinfo_addr
.ap_mask
};
36 pinfo
.ap_mask
.am_failure
|= 0x800; /* man 5 audit_class */
37 T_ASSERT_POSIX_SUCCESS(auditon(A_SETPMASK
, &pinfo
, sizeof(pinfo
)), NULL
);
41 struct auditinfo_addr a
;
42 memset(&a
, 0, sizeof(a
));
43 a
.ai_termid
.at_type
= 999;
44 T_ASSERT_POSIX_FAILURE(setaudit_addr(&a
, sizeof(a
)), EINVAL
,
45 "setaudit_addr should fail due to invalid at_type");