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] [day] [month] [year] [list]
Message-ID: <87v7ye20lt.ffs@tglx>
Date: Sun, 29 Sep 2024 12:52:30 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Remington Brasga <rbrasga@....edu>, Christian Heusel
 <christian@...sel.eu>, Shuah Khan <skhan@...uxfoundation.org>, "Ahmed S .
 Darwish" <darwi@...utronix.de>
Cc: linux-kernel@...r.kernel.org,
 linux-kernel-mentees@...ts.linuxfoundation.org, Remington Brasga
 <rbrasga@....edu>
Subject: Re: [PATCH] kcpuid: Fix potential dereferencing of null pointers

On Thu, Sep 26 2024 at 22:35, Remington Brasga wrote:
>  	if (!func->leafs) {
>  		func->leafs = malloc(sizeof(struct subleaf));
> -		if (!func->leafs)
> +		if (!func->leafs) {
>  			perror("malloc func leaf");
> +			return false; // On malloc failure

Please get rid of these horrible and pointless tail comments.

Returning false here does not make sense. This simply should terminate
the program.

> +		}
>  
>  		func->nr = 1;
>  	} else {
>  		s = func->nr;
>  		func->leafs = realloc(func->leafs, (s + 1) * sizeof(*leaf));
> -		if (!func->leafs)
> +		if (!func->leafs) {
>  			perror("realloc f->leafs");
> +			return false; // On realloc failure
> +		}
>  
>  		func->nr++;
>  	}
>  
> +	// Check for valid index
> +	if (s >= func->nr) {

What's the point of this? s is guaranteed to be < func->nr, no?

Thanks,

        tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ