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:   Wed, 13 Sep 2023 22:45:31 -0400
From:   Zi Yan <ziy@...dia.com>
To:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        linux-mips@...r.kernel.org
Cc:     Zi Yan <ziy@...dia.com>, Andrew Morton <akpm@...ux-foundation.org>,
        Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
        "\"Matthew Wilcox (Oracle)\"" <willy@...radead.org>,
        David Hildenbrand <david@...hat.com>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Muchun Song <muchun.song@...ux.dev>,
        "\"Mike Rapoport (IBM)\"" <rppt@...nel.org>,
        stable@...r.kernel.org, Muchun Song <songmuchun@...edance.com>
Subject: Re: [PATCH v3 4/5] use nth_page() in place of direct struct page
 manipulation.

On 13 Sep 2023, at 16:12, Zi Yan wrote:

> From: Zi Yan <ziy@...dia.com>
>
> When dealing with hugetlb pages, struct page is not guaranteed to be
> contiguous on SPARSEMEM without VMEMMAP. Use nth_page() to handle it
> properly.
>
> Fixes: 38c1ddbde6c6 ("hugetlbfs: improve read HWPOISON hugepage")
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Zi Yan <ziy@...dia.com>
> Reviewed-by: Muchun Song <songmuchun@...edance.com>
> ---
>  fs/hugetlbfs/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 7083fa0caaab..14d3d28e41b0 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -295,7 +295,7 @@ static size_t adjust_range_hwpoison(struct page *page, size_t offset, size_t byt
>  	size_t res = 0;
>
>  	/* First subpage to start the loop. */
> -	page += offset / PAGE_SIZE;
> +	page = nth_page(page, offset / PAGE_SIZE);
>  	offset %= PAGE_SIZE;
>  	while (1) {
>  		if (is_raw_hwpoison_page_in_hugepage(page))
> @@ -309,7 +309,7 @@ static size_t adjust_range_hwpoison(struct page *page, size_t offset, size_t byt
>  			break;
>  		offset += n;
>  		if (offset == PAGE_SIZE) {
> -			page++;
> +			page = nth_page(page, 1);
>  			offset = 0;
>  		}
>  	}
> -- 
> 2.40.1

Without the fix, a wrong subpage might be checked for HWPoison, causing wrong
number of bytes of a page copied to user space. No bug is reported. The fix
comes from code inspection.

--
Best Regards,
Yan, Zi

Download attachment "signature.asc" of type "application/pgp-signature" (855 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ