Skip to content

Commit f60c826

Browse files
alexdewarmimizohar
authored andcommitted
ima: Use kmemdup rather than kmalloc+memcpy
Issue identified with Coccinelle. Signed-off-by: Alex Dewar <alex.dewar90@gmail.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent 8c2f516 commit f60c826

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

security/integrity/ima/ima_policy.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,14 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry)
353353
struct ima_rule_entry *nentry;
354354
int i;
355355

356-
nentry = kmalloc(sizeof(*nentry), GFP_KERNEL);
357-
if (!nentry)
358-
return NULL;
359-
360356
/*
361357
* Immutable elements are copied over as pointers and data; only
362358
* lsm rules can change
363359
*/
364-
memcpy(nentry, entry, sizeof(*nentry));
360+
nentry = kmemdup(entry, sizeof(*nentry), GFP_KERNEL);
361+
if (!nentry)
362+
return NULL;
363+
365364
memset(nentry->lsm, 0, sizeof_field(struct ima_rule_entry, lsm));
366365

367366
for (i = 0; i < MAX_LSM_RULES; i++) {

0 commit comments

Comments
 (0)