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]
Date: Tue, 18 Jun 2024 14:02:20 +0300
From: Mike Rapoport <rppt@...nel.org>
To: James Gowans <jgowans@...zon.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, Alex Graf <graf@...zon.de>
Subject: Re: [PATCH] memblocks: Move late alloc warning down to phys alloc

On Fri, Jun 14, 2024 at 03:30:16PM +0200, James Gowans wrote:
> Subject: [PATCH] memblocks: Move late alloc warning down to phys alloc

Nit: memblock

> If a driver/subsystem tries to do an allocation after memblocks have
> been freed and the memory handed to the buddy allocator, it will not
> actually be legal to use that allocation - the buddy allocator owns the
> memory. This is handled by the memblocks function which does allocations
> and returns virtual addresses by printing a warning and doing a kmalloc
> instead. However, the physical allocation function does not to do this
> check - callers of the physical alloc function are unprotected against
> mis-use.

Did you see such misuse or this is a theoretical issue?
 
> Improve the error catching here by moving the check into the physical
> allocation function which is used by the virtual addr allocation
> function.
> 
> Signed-off-by: James Gowans <jgowans@...zon.com>
> Cc: Mike Rapoport <rppt@...nel.org>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Alex Graf <graf@...zon.de>
> ---
>  mm/memblock.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/memblock.c b/mm/memblock.c
> index d09136e040d3..dd4f237dc1fc 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -1457,6 +1457,17 @@ phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
>  		align = SMP_CACHE_BYTES;
>  	}
>  
> +	/*
> +	 * Detect any accidental use of these APIs after slab is ready, as at
> +	 * this moment memblock may be deinitialized already and its
> +	 * internal data may be destroyed (after execution of memblock_free_all)
> +	 */
> +	if (WARN_ON_ONCE(slab_is_available())) {
> +		void *vaddr = kzalloc_node(size, GFP_NOWAIT, nid);
> +
> +		return vaddr ? virt_to_phys(vaddr) : 0;
> +	}

I'd move this before alignment check.

> +
>  again:
>  	found = memblock_find_in_range_node(size, align, start, end, nid,
>  					    flags);
> @@ -1576,13 +1587,6 @@ static void * __init memblock_alloc_internal(
>  {
>  	phys_addr_t alloc;
>  
> -	/*
> -	 * Detect any accidental use of these APIs after slab is ready, as at
> -	 * this moment memblock may be deinitialized already and its
> -	 * internal data may be destroyed (after execution of memblock_free_all)
> -	 */
> -	if (WARN_ON_ONCE(slab_is_available()))
> -		return kzalloc_node(size, GFP_NOWAIT, nid);
>  
>  	if (max_addr > memblock.current_limit)
>  		max_addr = memblock.current_limit;
> -- 
> 2.34.1
> 

-- 
Sincerely yours,
Mike.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ