selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpolicy: Allow attribute assignment to attributes
@ 2025-06-23 10:25 Vit Mojzis
  2025-06-23 10:56 ` Christian Göttsche
  0 siblings, 1 reply; 8+ messages in thread
From: Vit Mojzis @ 2025-06-23 10:25 UTC (permalink / raw)
  To: selinux

Allow "typeattribute <attribute> <attribute>" to pass checkpolicy,
since (typeattributeset <attribute> <attribute>) is valid in CIL.

Fixes:
  $ cat myattributetest.te
  policy_module(attributetest, 1.0.0)

  gen_require(`
  	attribute domain;
  ')

  attribute myattribute;

  typeattribute myattribute domain;

  $ make -f /usr/share/selinux/devel/Makefile attributetest.pp                                                                                                                            2 ↵
  Compiling targeted attributetest module
  attributetest.te:9:ERROR 'unknown type myattribute' at token ';' on line 3418:
  typeattribute myattribute domain;

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
After some simple tests with CIL policies, it seems that attribute
assignment works as expected. Is there a reason checkpolicy does not
recognise it?

$ cat a.cil
(typeattribute a)
(typeattribute b)
(typeattribute c)
(type mytype_t)
(typeattributeset a b)
(typeattributeset b c)
(typeattributeset c mytype_t)
(allow a user_home_t (dir (getattr open search)))
(allow b tmp_t (dir (getattr open search)))
(allow c etc_t (dir (getattr open search)))

$semodule -i a.cil

$sesearch -A -s mytype_t
allow a user_home_t:dir { getattr open search };
allow b tmp_t:dir { getattr open search };
allow c etc_t:dir { getattr open search };

$seinfo -xa a                       

Type Attributes: 1
   attribute a;
	mytype_t


 checkpolicy/policy_define.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
index 4e0ddcc6..be788e8e 100644
--- a/checkpolicy/policy_define.c
+++ b/checkpolicy/policy_define.c
@@ -1440,7 +1440,7 @@ int define_typeattribute(void)
 		return -1;
 	}
 	t = hashtab_search(policydbp->p_types.table, id);
-	if (!t || t->flavor == TYPE_ATTRIB) {
+	if (!t) {
 		yyerror2("unknown type %s", id);
 		free(id);
 		return -1;
-- 
2.49.0


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

end of thread, other threads:[~2025-08-04 17:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 10:25 [PATCH] checkpolicy: Allow attribute assignment to attributes Vit Mojzis
2025-06-23 10:56 ` Christian Göttsche
2025-06-23 11:28   ` Vit Mojzis
2025-06-23 18:06     ` James Carter
2025-06-23 18:21       ` James Carter
2025-06-23 19:24         ` Vit Mojzis
2025-07-16 14:16           ` [PATCH] secilc: Add test for " Vit Mojzis
2025-08-04 17:03             ` [PATCH v2] " Vit Mojzis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).