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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8c4b0068-92be-427b-8bfc-9926eea6aa09@samsung.com>
Date: Fri, 22 Aug 2025 10:15:14 +0200
From: Marek Szyprowski <m.szyprowski@...sung.com>
To: David Hildenbrand <david@...hat.com>, linux-kernel@...r.kernel.org
Cc: Alexander Potapenko <glider@...gle.com>, Andrew Morton
	<akpm@...ux-foundation.org>, Brendan Jackman <jackmanb@...gle.com>,
	Christoph Lameter <cl@...two.org>, Dennis Zhou <dennis@...nel.org>, Dmitry
	Vyukov <dvyukov@...gle.com>, dri-devel@...ts.freedesktop.org,
	intel-gfx@...ts.freedesktop.org, iommu@...ts.linux.dev,
	io-uring@...r.kernel.org, Jason Gunthorpe <jgg@...dia.com>, Jens Axboe
	<axboe@...nel.dk>, Johannes Weiner <hannes@...xchg.org>, John Hubbard
	<jhubbard@...dia.com>, kasan-dev@...glegroups.com, kvm@...r.kernel.org,
	"Liam R. Howlett" <Liam.Howlett@...cle.com>, Linus Torvalds
	<torvalds@...ux-foundation.org>, linux-arm-kernel@...s.com,
	linux-arm-kernel@...ts.infradead.org, linux-crypto@...r.kernel.org,
	linux-ide@...r.kernel.org, linux-kselftest@...r.kernel.org,
	linux-mips@...r.kernel.org, linux-mmc@...r.kernel.org, linux-mm@...ck.org,
	linux-riscv@...ts.infradead.org, linux-s390@...r.kernel.org,
	linux-scsi@...r.kernel.org, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
	Marco Elver <elver@...gle.com>, Michal Hocko <mhocko@...e.com>, Mike
	Rapoport <rppt@...nel.org>, Muchun Song <muchun.song@...ux.dev>,
	netdev@...r.kernel.org, Oscar Salvador <osalvador@...e.de>, Peter Xu
	<peterx@...hat.com>, Robin Murphy <robin.murphy@....com>, Suren Baghdasaryan
	<surenb@...gle.com>, Tejun Heo <tj@...nel.org>,
	virtualization@...ts.linux.dev, Vlastimil Babka <vbabka@...e.cz>,
	wireguard@...ts.zx2c4.com, x86@...nel.org, Zi Yan <ziy@...dia.com>
Subject: Re: [PATCH RFC 23/35] scatterlist: disallow non-contigous page
 ranges in a single SG entry

On 21.08.2025 22:06, David Hildenbrand wrote:
> The expectation is that there is currently no user that would pass in
> non-contigous page ranges: no allocator, not even VMA, will hand these
> out.
>
> The only problematic part would be if someone would provide a range
> obtained directly from memblock, or manually merge problematic ranges.
> If we find such cases, we should fix them to create separate
> SG entries.
>
> Let's check in sg_set_page() that this is really the case. No need to
> check in sg_set_folio(), as pages in a folio are guaranteed to be
> contiguous.
>
> We can now drop the nth_page() usage in sg_page_iter_page().
>
> Signed-off-by: David Hildenbrand <david@...hat.com>
Acked-by: Marek Szyprowski <m.szyprowski@...sung.com>
> ---
>   include/linux/scatterlist.h | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 6f8a4965f9b98..8196949dfc82c 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -6,6 +6,7 @@
>   #include <linux/types.h>
>   #include <linux/bug.h>
>   #include <linux/mm.h>
> +#include <linux/mm_inline.h>
>   #include <asm/io.h>
>   
>   struct scatterlist {
> @@ -158,6 +159,7 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
>   static inline void sg_set_page(struct scatterlist *sg, struct page *page,
>   			       unsigned int len, unsigned int offset)
>   {
> +	VM_WARN_ON_ONCE(!page_range_contiguous(page, ALIGN(len + offset, PAGE_SIZE) / PAGE_SIZE));
>   	sg_assign_page(sg, page);
>   	sg->offset = offset;
>   	sg->length = len;
> @@ -600,7 +602,7 @@ void __sg_page_iter_start(struct sg_page_iter *piter,
>    */
>   static inline struct page *sg_page_iter_page(struct sg_page_iter *piter)
>   {
> -	return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
> +	return sg_page(piter->sg) + piter->sg_pgoffset;
>   }
>   
>   /**

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ