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: Fri, 1 Mar 2024 18:27:58 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Barry Song <21cnbao@...il.com>
Cc: davem@...emloft.net, linux-crypto@...r.kernel.org,
	akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
	hannes@...xchg.org, chriscli@...gle.com, chrisl@...nel.org,
	sjenning@...hat.com, vitaly.wool@...sulko.com,
	Barry Song <v-songbaohua@...o.com>, Nhat Pham <nphamcs@...il.com>,
	Yosry Ahmed <yosryahmed@...gle.com>,
	Chengming Zhou <zhouchengming@...edance.com>,
	Matthew Wilcox <willy@...radead.org>,
	Kent Overstreet <kent.overstreet@...ux.dev>,
	"Darrick J. Wong" <djwong@...nel.org>,
	Christoph Hellwig <hch@....de>, Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH v6] crypto: scompress: remove memcpy if sg_nents is 1 and
 pages are lowmem

On Thu, Feb 22, 2024 at 03:06:17PM +1300, Barry Song wrote:
>
> -	scatterwalk_map_and_copy(scratch->src, req->src, 0, req->slen, 0);
> +	if (sg_nents(req->src) == 1 && !PageHighMem(sg_page(req->src))) {
> +		src = page_to_virt(sg_page(req->src)) + req->src->offset;

Incidentally this made me look at other uses of PageHighMem in
the kernel.

The one in copy_page_from_iter_atomic looks buggy because it assumes
that the kmap never maps a page if PageHighMem is false, which is not
the case for CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP.

> @@ -152,8 +165,12 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
>  			ret = -ENOSPC;
>  			goto out;
>  		}
> -		scatterwalk_map_and_copy(scratch->dst, req->dst, 0, req->dlen,
> -					 1);
> +		if (dst == scratch->dst) {
> +			scatterwalk_map_and_copy(scratch->dst, req->dst, 0,
> +						 req->dlen, 1);
> +		} else {
> +			flush_dcache_page(sg_page(req->dst));

I think this is still wrong for the > PAGE_SIZE case.  The existing
code flushes each page sequentially  but the new code only flushes the
first page.

Thanks,
-- 
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ