summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Smalley <stephen.smalley.work@gmail.com>2026-04-29 15:18:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-09-02 14:26:43 +0200
commit774e7769ea01a2472902a3d98ed8281e029e570c (patch)
treeb259dc7f0168e2a574af21336a7f102b10ef2125
parentafb942a5c521df5051bd0fc79053a063d9c6f31f (diff)
downloadlinux-stable-774e7769ea01a2472902a3d98ed8281e029e570c.tar.gz
linux-stable-774e7769ea01a2472902a3d98ed8281e029e570c.zip
selinux: switch two allocations to use kzalloc_objs()
[ Upstream commit cf6a513f1937581eb012a217b29817e025a1a0ef ] These were the only two allocations in the policy loading logic that were not already using kzalloc_objs() for the policy data structures. Fix these to be consistent with the rest and to protect against ill-formed policy. Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--security/selinux/ss/conditional.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index 865611127357..240b350f2327 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -166,9 +166,9 @@ void cond_policydb_destroy(struct policydb *p)
int cond_init_bool_indexes(struct policydb *p)
{
kfree(p->bool_val_to_struct);
- p->bool_val_to_struct = kmalloc_array(p->p_bools.nprim,
- sizeof(*p->bool_val_to_struct),
- GFP_KERNEL);
+ p->bool_val_to_struct = kcalloc(p->p_bools.nprim,
+ sizeof(*p->bool_val_to_struct),
+ GFP_KERNEL);
if (!p->bool_val_to_struct)
return -ENOMEM;
return 0;
@@ -714,9 +714,9 @@ static int duplicate_policydb_bools(struct policydb *newdb,
struct cond_bool_datum **cond_bool_array;
int rc;
- cond_bool_array = kmalloc_array(orig->p_bools.nprim,
- sizeof(*orig->bool_val_to_struct),
- GFP_KERNEL);
+ cond_bool_array = kcalloc(orig->p_bools.nprim,
+ sizeof(*orig->bool_val_to_struct),
+ GFP_KERNEL);
if (!cond_bool_array)
return -ENOMEM;