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: <2d85ebb8ea2248c8a14f038a0c60297e@AcuMS.aculab.com>
Date:   Wed, 22 Jul 2020 09:27:32 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Al Viro' <viro@...IV.linux.org.uk>,
        Linus Torvalds <torvalds@...ux-foundation.org>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>
Subject: RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead
 of 0 as initial sum

From: Al Viro
> Sent: 21 July 2020 21:26
> Preparation for the change of calling conventions; right now all
> callers pass 0 as initial sum.  Passing 0xffffffff instead yields
> the values comparable mod 0xffff and guarantees that 0 will not
> be returned on success.
> 
> Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
> ---
>  lib/iov_iter.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 7405922caaec..d5b7e204fea6 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1451,7 +1451,7 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum,
>  		int err = 0;
>  		next = csum_and_copy_from_user(v.iov_base,
>  					       (to += v.iov_len) - v.iov_len,
> -					       v.iov_len, 0, &err);
> +					       v.iov_len, ~0U, &err);
>  		if (!err) {
>  			sum = csum_block_add(sum, next, off);
>  			off += v.iov_len;

Can't you remove the csum_block_add() by passing the
old 'sum' in instead of the ~0U ?
You'll need to keep track of whether the buffer fragment
is odd/even aligned.
After an odd length fragment a bswap32() or 8 bit rotate will
fix things (and maybe one right at the end).

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ