All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charlie Jenkins <charlie@rivosinc.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Helge Deller <deller@gmx.de>,
	"James E . J . Bottomley" <James.Bottomley@hansenpartnership.com>,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Palmer Dabbelt <palmer@rivosinc.com>
Subject: Re: [PATCH] parisc: Fix csum_ipv6_magic on 32-bit systems
Date: Tue, 13 Feb 2024 20:15:19 -0500	[thread overview]
Message-ID: <ZcwUJzD9eGF+AIP0@ghost> (raw)
In-Reply-To: <20240210191556.3761064-1-linux@roeck-us.net>

On Sat, Feb 10, 2024 at 11:15:56AM -0800, Guenter Roeck wrote:
> Calculating the IPv6 checksum on 32-bit systems missed overflows when
> adding the proto+len fields into the checksum. This results in the
> following unit test failure.
> 
>     # test_csum_ipv6_magic: ASSERTION FAILED at lib/checksum_kunit.c:506
>     Expected ( u64)csum_result == ( u64)expected, but
>         ( u64)csum_result == 46722 (0xb682)
>         ( u64)expected == 46721 (0xb681)
>     not ok 5 test_csum_ipv6_magic
> 
> This is probably rarely seen in the real world because proto+len are
> usually small values which will rarely result in overflows when calculating
> the checksum. However, the unit test code uses large values for the length
> field, causing the test to fail.
> 
> Fix the problem by adding the missing carry into the final checksum.
> 
> Cc: Charlie Jenkins <charlie@rivosinc.com>
> Cc: Palmer Dabbelt <palmer@rivosinc.com>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  arch/parisc/include/asm/checksum.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/parisc/include/asm/checksum.h b/arch/parisc/include/asm/checksum.h
> index f705e5dd1074..e619e67440db 100644
> --- a/arch/parisc/include/asm/checksum.h
> +++ b/arch/parisc/include/asm/checksum.h
> @@ -163,7 +163,8 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
>  "	ldw,ma		4(%2), %7\n"	/* 4th daddr */
>  "	addc		%6, %0, %0\n"
>  "	addc		%7, %0, %0\n"
> -"	addc		%3, %0, %0\n"	/* fold in proto+len, catch carry */
> +"	addc		%3, %0, %0\n"	/* fold in proto+len */
> +"	addc		0, %0, %0\n"	/* add carry */
>  
>  #endif
>  	: "=r" (sum), "=r" (saddr), "=r" (daddr), "=r" (len),
> -- 
> 2.39.2
> 

Looks good!

Tested-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>


      parent reply	other threads:[~2024-02-14  1:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-10 19:15 [PATCH] parisc: Fix csum_ipv6_magic on 32-bit systems Guenter Roeck
2024-02-11 13:57 ` David Laight
2024-02-11 14:09   ` Guenter Roeck
2024-02-14  1:15 ` Charlie Jenkins [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZcwUJzD9eGF+AIP0@ghost \
    --to=charlie@rivosinc.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=deller@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=palmer@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.