Skip to contentSkip to conversation

selinux: support name based type transitions in conditional policies

RFC PATCH New Christian Göttsche 1 participant 1 message Jun 2, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 selinux: support name based type transitions in conditional policies

With the move of name based type transitions to the avtab structure such statements are candidate to be used in conditional policies. They are already read into the policy database (which might be seen as a mistake as referencing them after a boolean change causes a use-after-free).

Copy the avtab_trans structures on boolean changes to keep them available.

---
Based on patcheset by Juraj Marcin [1]

[1]: https://patchwork.kernel.org/project/selinux/list/?series=752711

---
 security/selinux/ss/avtab.c       |  2 +-
 security/selinux/ss/avtab.h       |  2 +
 security/selinux/ss/conditional.c | 96 ++++++++++++++++++++++++++++---
 3 files changed, 92 insertions(+), 8 deletions(-)
security/selinux/ss/avtab.c +1 -1
index d3c027e5c0da..8068c9b4d1e6 100644
@@ -297,7 +297,7 @@ static int avtab_trans_destroy_helper(void *k, void *d, void *args)
 	return 0;
 }
 
-static void avtab_trans_destroy(struct avtab_trans *trans)
+void avtab_trans_destroy(struct avtab_trans *trans)
 {
 	hashtab_map(&trans->name_trans.table, avtab_trans_destroy_helper, NULL);
 	hashtab_destroy(&trans->name_trans.table);
security/selinux/ss/avtab.h +2 -0
index 929e322715d1..eb19d7719b72 100644
@@ -125,6 +125,8 @@ struct avtab_node *avtab_search_node_next(struct avtab_node *node, int specified
 #define MAX_AVTAB_HASH_BITS 16
 #define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS)
 
+void avtab_trans_destroy(struct avtab_trans *trans);
+
 /* policydb filename transitions compatibility */
 
 int avtab_filename_trans_read(struct avtab *a, void *fp, struct policydb *p);
security/selinux/ss/conditional.c +89 -7

121 lines not on this page · raw message

Signature · 1 line
2.40.1