]> www.infradead.org Git - users/jedix/linux-maple.git/commit
kunit/overflow: fix UB in overflow_allocation_test
authorIvan Orlov <ivan.orlov0322@gmail.com>
Thu, 15 Aug 2024 00:04:31 +0000 (01:04 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 17 Aug 2024 00:51:42 +0000 (17:51 -0700)
commit8e1aa267f430f80f91002cef3f3e55e8f0aa01bd
treeaf46ea1a037e82265030a9bcbef9bdd24e949692
parenta19fed0e1d040a22786184b51c5cc35ecb881a0b
kunit/overflow: fix UB in overflow_allocation_test

The 'device_name' array doesn't exist out of the
'overflow_allocation_test' function scope.  However, it is being used
as a driver name when calling 'kunit_driver_create' from
'kunit_device_register'.  It produces the kernel panic with KASAN
enabled due to undefined behaviour.

Since this variable is used in one place only, remove it and pass the
device name into kunit_device_register directly as an ascii string.

Link: https://lkml.kernel.org/r/20240815000431.401869-1-ivan.orlov0322@gmail.com
Fixes: ca90800a91ba ("test_overflow: Add memory allocation overflow tests")
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Tested-by: Erhard Furtner <erhard_f@mailbox.org>
Reviewed-by: David Gow <davidgow@google.com>
Cc: Kees Cook <kees@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/overflow_kunit.c