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: <9bfd5683-0eb6-4566-939d-fff01454849f@lucifer.local>
Date: Thu, 28 Aug 2025 19:02:59 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-kernel@...r.kernel.org, Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>,
        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, Marco Elver <elver@...gle.com>,
        Marek Szyprowski <m.szyprowski@...sung.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 v1 32/36] crypto: remove nth_page() usage within SG entry

On Thu, Aug 28, 2025 at 12:01:36AM +0200, David Hildenbrand wrote:
> It's no longer required to use nth_page() when iterating pages within a
> single SG entry, so let's drop the nth_page() usage.
>
> Cc: Herbert Xu <herbert@...dor.apana.org.au>
> Cc: "David S. Miller" <davem@...emloft.net>
> Signed-off-by: David Hildenbrand <david@...hat.com>

LGTM, so:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>

> ---
>  crypto/ahash.c               | 4 ++--
>  crypto/scompress.c           | 8 ++++----
>  include/crypto/scatterwalk.h | 4 ++--
>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/crypto/ahash.c b/crypto/ahash.c
> index a227793d2c5b5..dfb4f5476428f 100644
> --- a/crypto/ahash.c
> +++ b/crypto/ahash.c
> @@ -88,7 +88,7 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)
>
>  	sg = walk->sg;
>  	walk->offset = sg->offset;
> -	walk->pg = nth_page(sg_page(walk->sg), (walk->offset >> PAGE_SHIFT));
> +	walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
>  	walk->offset = offset_in_page(walk->offset);
>  	walk->entrylen = sg->length;
>
> @@ -226,7 +226,7 @@ int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
>  	if (!IS_ENABLED(CONFIG_HIGHMEM))
>  		return crypto_shash_digest(desc, data, nbytes, req->result);
>
> -	page = nth_page(page, offset >> PAGE_SHIFT);
> +	page += offset >> PAGE_SHIFT;
>  	offset = offset_in_page(offset);
>
>  	if (nbytes > (unsigned int)PAGE_SIZE - offset)
> diff --git a/crypto/scompress.c b/crypto/scompress.c
> index c651e7f2197a9..1a7ed8ae65b07 100644
> --- a/crypto/scompress.c
> +++ b/crypto/scompress.c
> @@ -198,7 +198,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
>  		} else
>  			return -ENOSYS;
>
> -		dpage = nth_page(dpage, doff / PAGE_SIZE);
> +		dpage += doff / PAGE_SIZE;
>  		doff = offset_in_page(doff);
>
>  		n = (dlen - 1) / PAGE_SIZE;
> @@ -220,12 +220,12 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
>  			} else
>  				break;
>
> -			spage = nth_page(spage, soff / PAGE_SIZE);
> +			spage = spage + soff / PAGE_SIZE;
>  			soff = offset_in_page(soff);
>
>  			n = (slen - 1) / PAGE_SIZE;
>  			n += (offset_in_page(slen - 1) + soff) / PAGE_SIZE;
> -			if (PageHighMem(nth_page(spage, n)) &&
> +			if (PageHighMem(spage + n) &&
>  			    size_add(soff, slen) > PAGE_SIZE)
>  				break;
>  			src = kmap_local_page(spage) + soff;
> @@ -270,7 +270,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
>  			if (dlen <= PAGE_SIZE)
>  				break;
>  			dlen -= PAGE_SIZE;
> -			dpage = nth_page(dpage, 1);
> +			dpage++;

Can't help but chuckle when I see this simplification each time, really nice! :)

>  		}
>  	}
>
> diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
> index 15ab743f68c8f..83d14376ff2bc 100644
> --- a/include/crypto/scatterwalk.h
> +++ b/include/crypto/scatterwalk.h
> @@ -159,7 +159,7 @@ static inline void scatterwalk_map(struct scatter_walk *walk)
>  	if (IS_ENABLED(CONFIG_HIGHMEM)) {
>  		struct page *page;
>
> -		page = nth_page(base_page, offset >> PAGE_SHIFT);
> +		page = base_page + (offset >> PAGE_SHIFT);
>  		offset = offset_in_page(offset);
>  		addr = kmap_local_page(page) + offset;
>  	} else {
> @@ -259,7 +259,7 @@ static inline void scatterwalk_done_dst(struct scatter_walk *walk,
>  		end += (offset_in_page(offset) + offset_in_page(nbytes) +
>  			PAGE_SIZE - 1) >> PAGE_SHIFT;
>  		for (i = start; i < end; i++)
> -			flush_dcache_page(nth_page(base_page, i));
> +			flush_dcache_page(base_page + i);
>  	}
>  	scatterwalk_advance(walk, nbytes);
>  }
> --
> 2.50.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ