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: <90de2e70-1802-b26b-798e-74421389180e@kernel.org>
Date:   Fri, 4 Nov 2022 07:25:01 +0100
From:   Jiri Slaby <jirislaby@...nel.org>
To:     TGSP <tgsp002@...il.com>, rafael@...nel.org, len.brown@...el.com,
        pavel@....cz, huanglei@...inos.cn
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        xiongxin <xiongxin@...inos.cn>, stable@...r.kernel.org
Subject: Re: [PATCH v2 2/2] PM: hibernate: add check of preallocate mem for
 image size pages

On 04. 11. 22, 6:41, TGSP wrote:
> From: xiongxin <xiongxin@...inos.cn>
> 
> Added a check on the return value of preallocate_image_highmem(). If
> memory preallocate is insufficient, S4 cannot be done;
> 
> I am playing 4K video on a machine with AMD or other graphics card and
> only 8GiB memory, and the kernel is not configured with CONFIG_HIGHMEM.
> When doing the S4 test, the analysis found that when the pages get from
> minimum_image_size() is large enough, The preallocate_image_memory() and
> preallocate_image_highmem() calls failed to obtain enough memory. Add
> the judgment that memory preallocate is insufficient;
> 
> The detailed debugging data is as follows:
> 
> image_size: 3225923584, totalram_pages: 1968948 in
> hibernate_reserved_size_init();
> 
> in hibernate_preallocate_memory():
> code pages = minimum_image_size(saveable) = 717992, at this time(line):
> count: 2030858
> avail_normal: 2053753
> highmem: 0
> totalreserve_pages: 22895
> max_size: 1013336
> size: 787579
> saveable: 1819905
> 
> When the code executes to:
> pages = preallocate_image_memory(alloc, avail_normal), at that
> time(line):
> pages_highmem: 0
> avail_normal: 1335761
> alloc: 1017522
> pages: 1017522
> 
> So enter the else branch judged by (pages < alloc), When executed to
> size = preallocate_image_memory(alloc, avail_normal):
> alloc = max_size - size = 225757;
> size = preallocate_image_memory(alloc, avail_normal) = 168671, That is,
> preallocate_image_memory() does not apply for all alloc memory pages,
> because highmem is not enabled, and size_highmem will return 0 here, so
> there is a memory page that has not been preallocated, so I think a
> judgment needs to be added here.
> 
> But what I can't understand is that although pages are not preallocated
> enough, "pages -= free_unnecessary_pages()" in the code below can also
> discard some pages that have been preallocated, so I am not sure whether
> it is appropriate to add a judgment here.
> 
> Cc: stable@...r.kernel.org
> Signed-off-by: xiongxin <xiongxin@...inos.cn>
> Signed-off-by: huanglei <huanglei@...inos.cn>
> ---
>   kernel/power/snapshot.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
> index c20ca5fb9adc..546d544cf7de 100644
> --- a/kernel/power/snapshot.c
> +++ b/kernel/power/snapshot.c
> @@ -1854,6 +1854,8 @@ int hibernate_preallocate_memory(void)
>   		alloc = (count - pages) - size;
>   		pages += preallocate_image_highmem(alloc);
>   	} else {
> +		unsigned long size_highmem = 0;

This needs not be initialized, right?

> @@ -1863,8 +1865,13 @@ int hibernate_preallocate_memory(void)
>   		pages_highmem += size;
>   		alloc -= size;
>   		size = preallocate_image_memory(alloc, avail_normal);
> -		pages_highmem += preallocate_image_highmem(alloc - size);
> -		pages += pages_highmem + size;
> +		size_highmem = preallocate_image_highmem(alloc - size);
> +		if (size_highmem < (alloc - size)) {
> +			pr_err("Image allocation is %lu pages short, exit\n",
> +				alloc - size - pages_highmem);
> +			goto err_out;
> +		}
> +		pages += pages_highmem + size_highmem + size;
>   	}
>   
>   	/*

-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ