From 01c2253a0fbdccb58cd79d4ff9ab39964bfb4474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 16 Dec 2024 17:40:07 +0100 Subject: selinux: make more use of str_read() when loading the policy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the call sites, and enable future string validation in a single place. Signed-off-by: Christian Göttsche [PM: subject tweak] Signed-off-by: Paul Moore --- security/selinux/ss/conditional.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'security/selinux/ss/conditional.c') diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index d8dcaf2ca88f..1bebfcb9c6a1 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -230,17 +230,11 @@ int cond_read_bool(struct policydb *p, struct symtab *s, struct policy_file *fp) goto err; len = le32_to_cpu(buf[2]); - if (((len == 0) || (len == (u32)-1))) - goto err; - rc = -ENOMEM; - key = kmalloc(len + 1, GFP_KERNEL); - if (!key) - goto err; - rc = next_entry(key, fp, len); + rc = str_read(&key, GFP_KERNEL, fp, len); if (rc) goto err; - key[len] = '\0'; + rc = symtab_insert(s, key, booldatum); if (rc) goto err; -- cgit v1.2.3