diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2021-09-29 17:05:26 -0500 |
---|---|---|
committer | John Johansen <john.johansen@canonical.com> | 2021-11-03 15:57:19 -0700 |
commit | f4a2d282cca57607a0d6718fafa1ab2d62703254 (patch) | |
tree | 16fb63da1fc76313944707c9be9061f218f81c3c /security/apparmor/label.c | |
parent | 4d47fbbe54bf75b72eac3f5a0caa664300937620 (diff) |
apparmor: Use struct_size() helper in kzalloc()
Make use of the struct_size() helper instead of an open-coded version,
in order to avoid any potential type mistakes or integer overflows that,
in the worse scenario, could lead to heap overflows.
Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security/apparmor/label.c')
-rw-r--r-- | security/apparmor/label.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/security/apparmor/label.c b/security/apparmor/label.c index f5eb9ac07e9b..1c89b056337b 100644 --- a/security/apparmor/label.c +++ b/security/apparmor/label.c @@ -424,8 +424,7 @@ struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp) AA_BUG(size < 1); /* + 1 for null terminator entry on vec */ - new = kzalloc(sizeof(*new) + sizeof(struct aa_profile *) * (size + 1), - gfp); + new = kzalloc(struct_size(new, vec, size + 1), gfp); AA_DEBUG("%s (%p)\n", __func__, new); if (!new) goto fail; |