Re: [PATCH] kernel/sysctl-test: Fix potential null dereference in sysctl-test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 10, 2025 at 06:07:48PM +0800, Charles Han wrote:
> kunit_kzalloc() may return a NULL pointer, dereferencing it without
> NULL check may lead to NULL dereference.
> Add a NULL check for buffer.

Please address the 0-day comments.
> 
> Fixes: 2cb80dbbbaba ("kernel/sysctl-test: Add null pointer test for sysctl.c:proc_dointvec()")
> Signed-off-by: Charles Han <hanchunchao@xxxxxxxxxx>
> ---
...
>  	unsigned long abs_of_less_than_min = (unsigned long)INT_MAX
>  					     - (INT_MAX + INT_MIN) + 1;
> @@ -354,6 +363,7 @@ static void sysctl_test_api_dointvec_write_single_greater_int_max(
>  	size_t max_len = 32, len = max_len;
>  	loff_t pos = 0;
>  	char *buffer = kunit_kzalloc(test, max_len, GFP_USER);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buffer);
>  	char __user *user_buffer = (char __user *)buffer;
>  	unsigned long greater_than_max = (unsigned long)INT_MAX + 1;
>  
> -- 
> 2.45.2
> 

best
-- 

Joel Granados




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux