linux/security/integrity/ima
Gustavo A. R. Silva 2a7f0e53da ima: ima_api: Use struct_size() in kzalloc()
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct ima_template_entry {
	...
        struct ima_field_data template_data[0]; /* template related data */
};

instance = kzalloc(sizeof(struct ima_template_entry) + count * sizeof(struct ima_field_data), GFP_NOFS);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kzalloc(struct_size(instance, entry, count), GFP_NOFS);

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
2019-08-29 14:23:30 -04:00
..
ima_api.c ima: ima_api: Use struct_size() in kzalloc() 2019-08-29 14:23:30 -04:00
ima_appraise.c ima: Collect modsig 2019-08-05 18:40:24 -04:00
ima_crypto.c ima: fix freeing ongoing ahash_request 2019-08-05 18:40:28 -04:00
ima_fs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
ima_init.c Merge branch 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity 2019-07-08 20:28:59 -07:00
ima_kexec.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ima_main.c ima: Store the measurement again when appraising a modsig 2019-08-05 18:40:26 -04:00
ima_modsig.c ima: Fix use after free in ima_read_modsig() 2019-08-28 15:01:24 -04:00
ima_mok.c Revert "Merge tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs" 2019-07-10 18:43:43 -07:00
ima_policy.c ima: Define ima-modsig template 2019-08-05 18:40:25 -04:00
ima_queue.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
ima_template_lib.c ima: Define ima-modsig template 2019-08-05 18:40:25 -04:00
ima_template_lib.h ima: Define ima-modsig template 2019-08-05 18:40:25 -04:00
ima_template.c ima: use struct_size() in kzalloc() 2019-08-29 14:23:22 -04:00
ima.h ima: Store the measurement again when appraising a modsig 2019-08-05 18:40:26 -04:00
Kconfig ima: Implement support for module-style appended signatures 2019-08-05 18:40:23 -04:00
Makefile ima: Add modsig appraise_type option for module-style appended signatures 2019-08-05 18:40:21 -04:00