* [PATCH][V2] ima: Fix sizeof mismatches
@ 2020-10-13 16:53 ` Colin King
0 siblings, 0 replies; 2+ messages in thread
From: Colin King @ 2020-10-13 16:53 UTC (permalink / raw)
To: Mimi Zohar, Dmitry Kasatkin, James Morris, Serge E . Hallyn,
Roberto Sassu, linux-integrity, linux-security-module
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
An incorrect sizeof is being used, sizeof(*fields) is not correct,
it should be sizeof(**fields). This is not causing a problem since
the size of these is the same. Fix this.
Also replace kmalloc_array and memcpy with a kmemdup.
Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: 1bd7face7439 ("ima: allocate field pointers array on demand in template_desc_init_fields()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: Replace kmalloc_array and memcpy with kmemdup as suggested by
Joe Perches.
---
security/integrity/ima/ima_template.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index 1e89e2d3851f..83886e767678 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -216,11 +216,10 @@ int template_desc_init_fields(const char *template_fmt,
}
if (fields && num_fields) {
- *fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL);
+ *fields = kmemdup(found_fields, i * sizeof(**fields), GFP_KERNEL);
if (*fields == NULL)
return -ENOMEM;
- memcpy(*fields, found_fields, i * sizeof(*fields));
*num_fields = i;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH][V2] ima: Fix sizeof mismatches
@ 2020-10-13 16:53 ` Colin King
0 siblings, 0 replies; 2+ messages in thread
From: Colin King @ 2020-10-13 16:53 UTC (permalink / raw)
To: Mimi Zohar, Dmitry Kasatkin, James Morris, Serge E . Hallyn,
Roberto Sassu, linux-integrity, linux-security-module
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
An incorrect sizeof is being used, sizeof(*fields) is not correct,
it should be sizeof(**fields). This is not causing a problem since
the size of these is the same. Fix this.
Also replace kmalloc_array and memcpy with a kmemdup.
Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: 1bd7face7439 ("ima: allocate field pointers array on demand in template_desc_init_fields()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: Replace kmalloc_array and memcpy with kmemdup as suggested by
Joe Perches.
---
security/integrity/ima/ima_template.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index 1e89e2d3851f..83886e767678 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -216,11 +216,10 @@ int template_desc_init_fields(const char *template_fmt,
}
if (fields && num_fields) {
- *fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL);
+ *fields = kmemdup(found_fields, i * sizeof(**fields), GFP_KERNEL);
if (*fields = NULL)
return -ENOMEM;
- memcpy(*fields, found_fields, i * sizeof(*fields));
*num_fields = i;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-13 16:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 16:53 [PATCH][V2] ima: Fix sizeof mismatches Colin King
2020-10-13 16:53 ` Colin King
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.