* [PATCH] devres: Use kmalloc_size_roundup() to match ksize() usage
@ 2022-10-18 9:04 Kees Cook
0 siblings, 0 replies; only message in thread
From: Kees Cook @ 2022-10-18 9:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kees Cook, Rafael J. Wysocki, linux-kernel, linux-hardening
Round up allocations with kmalloc_size_roundup() so that devres's use
of ksize() is always accurate and no special handling of the memory is
needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/base/devres.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 4ab2b50ee38f..c0e100074aa3 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -101,6 +101,9 @@ static bool check_dr_size(size_t size, size_t *tot_size)
size, tot_size)))
return false;
+ /* Actually allocate the full kmalloc bucket size. */
+ *tot_size = kmalloc_size_roundup(*tot_size);
+
return true;
}
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-18 9:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-18 9:04 [PATCH] devres: Use kmalloc_size_roundup() to match ksize() usage Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox