Skip to content

Commit 0e78999

Browse files
stephensmalleygregkh
authored andcommitted
selinux: switch two allocations to use kzalloc_objs()
[ Upstream commit cf6a513 ] 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>
1 parent 2c10b14 commit 0e78999

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

security/selinux/ss/conditional.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void cond_policydb_destroy(struct policydb *p)
165165
int cond_init_bool_indexes(struct policydb *p)
166166
{
167167
kfree(p->bool_val_to_struct);
168-
p->bool_val_to_struct = kmalloc_array(
168+
p->bool_val_to_struct = kcalloc(
169169
p->p_bools.nprim, sizeof(*p->bool_val_to_struct), GFP_KERNEL);
170170
if (!p->bool_val_to_struct)
171171
return -ENOMEM;
@@ -706,9 +706,8 @@ static int duplicate_policydb_bools(struct policydb *newdb,
706706
struct cond_bool_datum **cond_bool_array;
707707
int rc;
708708

709-
cond_bool_array = kmalloc_array(orig->p_bools.nprim,
710-
sizeof(*orig->bool_val_to_struct),
711-
GFP_KERNEL);
709+
cond_bool_array = kcalloc(orig->p_bools.nprim,
710+
sizeof(*orig->bool_val_to_struct), GFP_KERNEL);
712711
if (!cond_bool_array)
713712
return -ENOMEM;
714713

0 commit comments

Comments
 (0)