All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 02/32] selinux: drop event filtering from AVC callbacks
@ 2026-09-28 17:46 Christian Göttsche
  2026-09-28 17:46 ` [RFC PATCH 03/32] selinux: use kfree_strarray() Christian Göttsche
                   ` (32 more replies)
  0 siblings, 33 replies; 96+ messages in thread
From: Christian Göttsche @ 2026-09-28 17:46 UTC (permalink / raw)
  To: selinux
  Cc: Paul Moore, Stephen Smalley, Ondrej Mosnacek,
	Christian Göttsche

From: Christian Göttsche <cgzones@googlemail.com>

All AVC callbacks are registered for AVC_CALLBACK_RESET only, and it is
the only event ever dispatched.  Drop the events mask, the event
argument and the redundant event checks in the callbacks.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 security/selinux/avc.c           | 23 +++++++++--------------
 security/selinux/hooks.c         | 28 +++++++++++-----------------
 security/selinux/include/audit.h |  7 +++----
 security/selinux/include/avc.h   |  4 +---
 security/selinux/ss/services.c   |  6 ++----
 5 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index 936e116b01fb..9edbc324121e 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -78,8 +78,7 @@ struct avc_cache {
 };
 
 struct avc_callback_node {
-	int (*callback) (u32 event);
-	u32 events;
+	int (*callback)(void);
 	struct avc_callback_node *next;
 };
 
@@ -785,15 +784,14 @@ noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass,
 }
 
 /**
- * avc_add_callback - Register a callback for security events.
+ * avc_add_callback - Register a callback for AVC resets.
  * @callback: callback function
- * @events: security events
  *
- * Register a callback function for events in the set @events.
+ * Register a callback function to be called on every AVC reset.
  * Returns %0 on success or -%ENOMEM if insufficient memory
  * exists to add the callback.
  */
-int __init avc_add_callback(int (*callback)(u32 event), u32 events)
+int __init avc_add_callback(int (*callback)(void))
 {
 	struct avc_callback_node *c;
 	int rc = 0;
@@ -805,7 +803,6 @@ int __init avc_add_callback(int (*callback)(u32 event), u32 events)
 	}
 
 	c->callback = callback;
-	c->events = events;
 	c->next = avc_callbacks;
 	avc_callbacks = c;
 out:
@@ -953,13 +950,11 @@ int avc_ss_reset(u32 seqno)
 	avc_flush();
 
 	for (c = avc_callbacks; c; c = c->next) {
-		if (c->events & AVC_CALLBACK_RESET) {
-			tmprc = c->callback(AVC_CALLBACK_RESET);
-			/* save the first error encountered for the return
-			   value and continue processing the callbacks */
-			if (!rc)
-				rc = tmprc;
-		}
+		tmprc = c->callback();
+		/* save the first error encountered for the return
+		   value and continue processing the callbacks */
+		if (!rc)
+			rc = tmprc;
 	}
 
 	avc_latest_notif_update(seqno, 0);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 035aaf113d1d..9444c4d0b901 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -188,24 +188,19 @@ static int selinux_peerlbl_enabled(void)
 		netlbl_enabled() || selinux_xfrm_enabled());
 }
 
-static int selinux_netcache_avc_callback(u32 event)
+static int selinux_netcache_avc_callback(void)
 {
-	if (event == AVC_CALLBACK_RESET) {
-		sel_netif_flush();
-		sel_netnode_flush();
-		sel_netport_flush();
-		synchronize_net();
-	}
+	sel_netif_flush();
+	sel_netnode_flush();
+	sel_netport_flush();
+	synchronize_net();
 	return 0;
 }
 
-static int selinux_lsm_notifier_avc_callback(u32 event)
+static int selinux_lsm_notifier_avc_callback(void)
 {
-	if (event == AVC_CALLBACK_RESET) {
-		sel_ib_pkey_flush();
-		call_blocking_lsm_notifier(LSM_POLICY_CHANGE, NULL);
-	}
-
+	sel_ib_pkey_flush();
+	call_blocking_lsm_notifier(LSM_POLICY_CHANGE, NULL);
 	return 0;
 }
 
@@ -7886,14 +7881,13 @@ static __init int selinux_init(void)
 	security_add_hooks(selinux_hooks, ARRAY_SIZE(selinux_hooks),
 			   &selinux_lsmid);
 
-	if (avc_add_callback(selinux_netcache_avc_callback, AVC_CALLBACK_RESET))
+	if (avc_add_callback(selinux_netcache_avc_callback))
 		panic("SELinux: Unable to register AVC netcache callback\n");
 
-	if (avc_add_callback(selinux_lsm_notifier_avc_callback, AVC_CALLBACK_RESET))
+	if (avc_add_callback(selinux_lsm_notifier_avc_callback))
 		panic("SELinux: Unable to register AVC LSM notifier callback\n");
 
-	if (avc_add_callback(selinux_audit_rule_avc_callback,
-			     AVC_CALLBACK_RESET))
+	if (avc_add_callback(selinux_audit_rule_avc_callback))
 		panic("SELinux: Unable to register AVC audit callback\n");
 
 	if (selinux_enforcing_boot)
diff --git a/security/selinux/include/audit.h b/security/selinux/include/audit.h
index 85a531ac737b..3103a5784ee2 100644
--- a/security/selinux/include/audit.h
+++ b/security/selinux/include/audit.h
@@ -16,13 +16,12 @@
 #include <linux/types.h>
 
 /**
- * selinux_audit_rule_avc_callback - update the audit LSM rules on AVC events.
- * @event: the AVC event
+ * selinux_audit_rule_avc_callback - update the audit LSM rules on AVC reset.
  *
- * Update any audit LSM rules based on the AVC event specified in @event.
+ * Update any audit LSM rules after the AVC has been reset.
  * Returns 0 on success, negative values otherwise.
  */
-int selinux_audit_rule_avc_callback(u32 event);
+int selinux_audit_rule_avc_callback(void);
 
 /**
  * selinux_audit_rule_init - alloc/init an selinux audit rule structure.
diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
index 0f788dfc66e9..8cfc4255be36 100644
--- a/security/selinux/include/avc.h
+++ b/security/selinux/include/avc.h
@@ -149,9 +149,7 @@ int avc_has_extended_perms(u32 ssid, u32 tsid, u16 tclass, u32 requested,
 
 u32 avc_policy_seqno(void);
 
-#define AVC_CALLBACK_RESET		8
-
-int avc_add_callback(int (*callback)(u32 event), u32 events);
+int avc_add_callback(int (*callback)(void));
 
 /* Exported to selinuxfs */
 int avc_get_hash_stats(char *page);
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index da77ad769c83..3cfe9c7b28c6 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -3462,11 +3462,9 @@ struct selinux_audit_rule {
 	struct context au_ctxt;
 };
 
-int selinux_audit_rule_avc_callback(u32 event)
+int selinux_audit_rule_avc_callback(void)
 {
-	if (event == AVC_CALLBACK_RESET)
-		return audit_update_lsm_rules();
-	return 0;
+	return audit_update_lsm_rules();
 }
 
 void selinux_audit_rule_free(void *vrule)
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 96+ messages in thread

end of thread, other threads:[~2026-12-05  3:29 UTC | newest]

Thread overview: 96+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28 17:46 [RFC PATCH 02/32] selinux: drop event filtering from AVC callbacks Christian Göttsche
2026-09-28 17:46 ` [RFC PATCH 03/32] selinux: use kfree_strarray() Christian Göttsche
2026-09-29 15:26   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 3/32] " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 04/32] selinux: use vmemdup_user() for policy loading Christian Göttsche
2026-09-29 15:29   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 4/32] " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 05/32] selinux: use kmemdup_array() for conditional expressions Christian Göttsche
2026-09-29 15:30   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 5/32] " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 06/32] selinux: use memcpy_{from,to}_le32() in avtab Christian Göttsche
2026-09-29 15:31   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 6/32] " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 07/32] selinux: drop constant value parameter of ebitmap_set_bit() Christian Göttsche
2026-09-29 15:32   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 7/32] " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 08/32] selinux: use rounddown() and roundup() in ebitmap Christian Göttsche
2026-09-29 15:35   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 8/32] " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 09/32] selinux: factor out sel_make_files() Christian Göttsche
2026-09-29 15:36   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 9/32] " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 10/32] selinux: use struct_size() and isdigit() Christian Göttsche
2026-09-29 15:36   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 11/32] selinux: use file table names to mark selinuxfs inodes immutable Christian Göttsche
2026-09-29 15:37   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 12/32] selinux: avoid context string allocation on getxattr size query Christian Göttsche
2026-09-29 15:38   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 13/32] selinux: remove unused SECSID_WILD and sidtab_search_force() Christian Göttsche
2026-09-29 15:39   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 14/32] selinux: make sidtab_init() return void Christian Göttsche
2026-09-29 15:40   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 15/32] selinux: make mls_level_isvalid() static Christian Göttsche
2026-09-29 15:41   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 16/32] selinux: drop unused policydb parameter of perm_read() Christian Göttsche
2026-09-29 15:46   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 17/32] selinux: drop redundant last_class_ino parameter Christian Göttsche
2026-09-29 15:47   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 18/32] selinux: drop dead NULL check in sel_open_policy() Christian Göttsche
2026-09-29 15:49   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 19/32] selinux: drop no-op gotos in ocontext SID lookups Christian Göttsche
2026-09-29 15:50   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 20/32] selinux: consolidate MLS context copy helpers Christian Göttsche
2026-09-29 15:51   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 21/32] selinux: simplify mls_context_glblub() and mls_context_equal() Christian Göttsche
2026-09-29 15:52   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 22/32] selinux: factor out constraint_list_destroy() Christian Göttsche
2026-09-29 15:53   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 23/32] selinux: simplify nlmsg_perm() Christian Göttsche
2026-09-29 15:55   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 24/32] selinux: factor out sel_sid_to_payload() Christian Göttsche
2026-09-29 15:56   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 25/32] selinux: share implementation of relabel and member transactions Christian Göttsche
2026-09-29 15:56   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 26/32] selinux: drop page_mkwrite handler for the policy mapping Christian Göttsche
2026-09-29 16:01   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 27/32] selinux: fail mount if status or policy cannot be marked immutable Christian Göttsche
2026-09-29 16:03   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 28/32] selinux: pass inode number by value to sel_make_dir() Christian Göttsche
2026-09-29 16:04   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 29/32] selinux: drop sb member of struct selinux_fs_info Christian Göttsche
2026-09-29 16:05   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 30/32] selinux: add level_val_to_struct[] for sensitivity lookups Christian Göttsche
2026-09-29 16:07   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 31/32] selinux: add policydb_class_datum() helper Christian Göttsche
2026-09-29 16:10   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 32/32] selinux: drop unused policydb parameter of context_write() Christian Göttsche
2026-09-29 16:11   ` Stephen Smalley
2026-12-05  3:29   ` [PATCH RFC " Paul Moore
2026-09-28 17:46 ` [RFC PATCH 01/32] selinux: remove unused AVC update events Christian Göttsche
2026-09-29 15:23   ` Stephen Smalley
2026-12-05  3:28   ` [PATCH RFC 1/32] " Paul Moore
2026-09-29 15:24 ` [RFC PATCH 02/32] selinux: drop event filtering from AVC callbacks Stephen Smalley
2026-12-05  3:28 ` [PATCH RFC 2/32] " Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.