lib: packing: catch kunit_kzalloc() failure in the pack() test
Subsystems (4)
PATCH 1/1 lib: packing: catch kunit_kzalloc() failure in the pack() test
kunit_kzalloc() may fail. Other call sites verify that this is the case, either using a direct comparison with the NULL pointer, or the KUNIT_ASSERT_NOT_NULL() or KUNIT_ASSERT_NOT_ERR_OR_NULL().
Pick KUNIT_ASSERT_NOT_NULL() as the error handling method that made most sense to me. It's an unlikely thing to happen, but at least we call __kunit_abort() instead of dereferencing this NULL pointer.
--- lib/packing_test.c | 1 + 1 file changed, 1 insertion(+)
lib/packing_test.c +1 -0
@@ -375,6 +375,7 @@ static void packing_test_pack(struct kunit *test)int err; pbuf =kunit_kzalloc (test, params->pbuf_size,GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, pbuf); err =pack (pbuf, params->uval, params->start_bit, params->end_bit, params->pbuf_size, params->quirks);
Signature · 1 line
2.43.0
Quoted 40 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Friday, October 4, 2024 4:00 AM
To: [email protected]
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Keller, Jacob E <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]
Subject: [PATCH net-next] lib: packing: catchkunit_kzalloc()failure in thepack()test
kunit_kzalloc()may fail. Other call sites verify that this is the case, either using a direct comparison with the NULL pointer, or theKUNIT_ASSERT_NOT_NULL()orKUNIT_ASSERT_NOT_ERR_OR_NULL().Pick
KUNIT_ASSERT_NOT_NULL()as the error handling method that made most sense to me. It's an unlikely thing to happen, but at least we call__kunit_abort()instead of dereferencing this NULL pointer.Fixes e9502ea6db8a ("lib: packing: add KUnit tests adapted from selftests")Signed-off-by Vladimir Oltean <[email protected]>--- lib/packing_test.c | 1 + 1 file changed, 1 insertion(+)lib/packing_test.c +1
-1@@ -375,6 +375,7 @@ static void packing_test_pack(struct kunit *test)int err; pbuf =kunit_kzalloc (test, params->pbuf_size,GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, pbuf); err =pack (pbuf, params->uval, params->start_bit, params->end_bit, params->pbuf_size, params->quirks); --
Quoted 1 line
2.43.0
Oh good catch! I guess I had assumed that kunit_kzalloc would itself detect and fail instead of continuing....
Quoted 37 lines · Jacob E
Quoted 37 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Friday, October 4, 2024 4:00 AM
To: [email protected]
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Keller, Jacob E <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]
Subject: [PATCH net-next] lib: packing: catchkunit_kzalloc()failure in thepack()test
kunit_kzalloc()may fail. Other call sites verify that this is the case, either using a direct comparison with the NULL pointer, or theKUNIT_ASSERT_NOT_NULL()orKUNIT_ASSERT_NOT_ERR_OR_NULL().Pick
KUNIT_ASSERT_NOT_NULL()as the error handling method that made most sense to me. It's an unlikely thing to happen, but at least we call__kunit_abort()instead of dereferencing this NULL pointer.Fixes e9502ea6db8a ("lib: packing: add KUnit tests adapted from selftests")Signed-off-by Vladimir Oltean <[email protected]>--- lib/packing_test.c | 1 + 1 file changed, 1 insertion(+)lib/packing_test.c +1
-0@@ -375,6 +375,7 @@ static void packing_test_pack(struct kunit *test)int err; pbuf =kunit_kzalloc (test, params->pbuf_size,GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, pbuf);
Quoted 6 lines
Quoted 4 lines
lib/packing_test.c +0
-1err =pack (pbuf, params->uval, params->start_bit, params->end_bit, params->pbuf_size, params->quirks); --2.43.0
Oh good catch! I guess I had assumed that
kunit_kzallocwould itself detect and fail instead of continuing....
that would be great
kunit_*alloc gives kunit-managed resources though
Quoted 57 lines
-----Original Message-----
From: Kitszel, Przemyslaw <[email protected]>
Sent: Wednesday, October 9, 2024 3:21 AM
To: Keller, Jacob E <[email protected]>; Vladimir Oltean <[email protected]>
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH net-next] lib: packing: catchkunit_kzalloc()failure in thepack()testQuoted 37 lines · Jacob E
Quoted 37 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Friday, October 4, 2024 4:00 AM
To: [email protected]
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Keller, Jacob E <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]
Subject: [PATCH net-next] lib: packing: catchkunit_kzalloc()failure in thepack()test
kunit_kzalloc()may fail. Other call sites verify that this is the case, either using a direct comparison with the NULL pointer, or theKUNIT_ASSERT_NOT_NULL()orKUNIT_ASSERT_NOT_ERR_OR_NULL().Pick
KUNIT_ASSERT_NOT_NULL()as the error handling method that made most sense to me. It's an unlikely thing to happen, but at least we call__kunit_abort()instead of dereferencing this NULL pointer.Fixes e9502ea6db8a ("lib: packing: add KUnit tests adapted from selftests")Signed-off-by Vladimir Oltean <[email protected]>--- lib/packing_test.c | 1 + 1 file changed, 1 insertion(+)lib/packing_test.c +1
-0@@ -375,6 +375,7 @@ static void packing_test_pack(struct kunit *test)int err; pbuf =kunit_kzalloc (test, params->pbuf_size,GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, pbuf);Quoted 6 lines
Quoted 4 lines
lib/packing_test.c +0
-1err =pack (pbuf, params->uval, params->start_bit, params->end_bit, params->pbuf_size, params->quirks); --2.43.0
Oh good catch! I guess I had assumed that
kunit_kzallocwould itself detect and
Quoted 5 lines
fail instead of continuing....
that would be great
kunit_*alloc gives kunit-managed resources though
Yep, just a misunderstanding on my part 😊
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 4 Oct 2024 14:00:12 +0300 you wrote:
kunit_kzalloc()may fail. Other call sites verify that this is the case, either using a direct comparison with the NULL pointer, or theKUNIT_ASSERT_NOT_NULL()orKUNIT_ASSERT_NOT_ERR_OR_NULL().Pick
KUNIT_ASSERT_NOT_NULL()as the error handling method that made most sense to me. It's an unlikely thing to happen, but at least we call__kunit_abort()instead of dereferencing this NULL pointer.[...]
Here is the summary with links:
- [net-next] lib: packing: catch kunit_kzalloc() failure in the pack() test
https://git.kernel.org/netdev/net-next/c/1405981bbba0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html