lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f80fafaf-41b2-4b69-a574-424c9de18fd9@collabora.com>
Date: Sat, 30 Dec 2023 12:17:49 +0500
From: Muhammad Usama Anjum <usama.anjum@...labora.com>
To: Richard Fitzgerald <rf@...nsource.cirrus.com>, brendan.higgins@...ux.dev,
 davidgow@...gle.com, rmoar@...gle.com
Cc: Muhammad Usama Anjum <usama.anjum@...labora.com>,
 linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com,
 linux-kernel@...r.kernel.org, patches@...nsource.cirrus.com
Subject: Re: [PATCH] kunit: Protect string comparisons against NULL

On 12/20/23 8:52 PM, Richard Fitzgerald wrote:
> Add NULL checks to KUNIT_BINARY_STR_ASSERTION() so that it will fail
> cleanly if either pointer is NULL, instead of causing a NULL pointer
> dereference in the strcmp().
> 
> A test failure could be that a string is unexpectedly NULL. This could
> be trapped by KUNIT_ASSERT_NOT_NULL() but that would terminate the test
> at that point. It's preferable that the KUNIT_EXPECT_STR*() macros can
> handle NULL pointers as a failure.
> 
> Signed-off-by: Richard Fitzgerald <rf@...nsource.cirrus.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@...labora.com>

> ---
>  include/kunit/test.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index b163b9984b33..c2ce379c329b 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -758,7 +758,7 @@ do {									       \
>  		.right_text = #right,					       \
>  	};								       \
>  									       \
> -	if (likely(strcmp(__left, __right) op 0))			       \
> +	if (likely((__left) && (__right) && (strcmp(__left, __right) op 0)))   \
>  		break;							       \
>  									       \
>  									       \

-- 
BR,
Muhammad Usama Anjum

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ