@@ -15369,6 +15369,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux.git
F: Documentation/ABI/obsolete/sysfs-selinux-checkreqprot
F: Documentation/ABI/obsolete/sysfs-selinux-disable
F: Documentation/admin-guide/LSM/SELinux.rst
+F: include/trace/events/selinux.h
F: include/uapi/linux/selinux_netlink.h
F: scripts/selinux/
F: security/selinux/
new file mode 100644
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM selinux
+
+#if !defined(_TRACE_SELINUX_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SELINUX_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT_CONDITION(selinux_denied,
+
+ TP_PROTO(struct selinux_audit_data *sad, pid_t pid),
+
+ TP_ARGS(sad, pid),
+
+ TP_CONDITION(sad->denied),
+
+ TP_STRUCT__entry(
+ __field(pid_t, pid)
+ __field(int, tclass)
+ __field(int, audited)
+ ),
+
+ TP_fast_assign(
+ __entry->pid = pid;
+ __entry->tclass = sad->tclass;
+ __entry->audited = sad->audited;
+ ),
+
+ TP_printk("denied pid=%d tclass=%x audited=%x",
+ __entry->pid,
+ __entry->tclass,
+ __entry->audited)
+);
+
+#endif
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
@@ -31,6 +31,9 @@
#include "avc_ss.h"
#include "classmap.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/selinux.h>
+
#define AVC_CACHE_SLOTS 512
#define AVC_DEF_CACHE_THRESHOLD 512
#define AVC_CACHE_RECLAIM 16
@@ -665,6 +668,8 @@ static void avc_audit_pre_callback(struct audit_buffer *ab, void *a)
const char **perms;
int i, perm;
+ trace_selinux_denied(sad, task_tgid_nr(current));
+
audit_log_format(ab, "avc: %s ", sad->denied ? "denied" : "granted");
if (av == 0) {