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] [day] [month] [year] [list]
Message-ID: <20250714164142.341e37a2@kernel.org>
Date: Mon, 14 Jul 2025 16:41:42 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
 <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Simon Horman
 <horms@...nel.org>, kernel@...gutronix.de, linux-kernel@...r.kernel.org,
 netdev@...r.kernel.org, Maxime Chevallier <maxime.chevallier@...tlin.com>
Subject: Re: [PATCH net-next v2 1/1] net: selftests: add PHY-loopback test
 for bad TCP checksums

On Fri, 11 Jul 2025 09:24:49 +0200 Oleksij Rempel wrote:
> +			/* To avoid sparse warnings about operating on
> +			 * restricted __sum16/__be16 types, explicitly cast the
> +			 * checksum to a plain u16, perform the manipulation,
> +			 * and then cast the result back.
> +			 */
> +			csum = (__force u16)thdr->check;
> +
> +			/* Mangle the checksum by flipping the LSB. */
> +			csum ^= 1;
> +			/* If mangling resulted in 0, use the raw value for a
> +			 * mangled-zero checksum. We use the literal 0xffff
> +			 * because CSUM_MANGLED_0 has a restricted type.
> +			 */
> +			if (!csum)
> +				csum = 0xffff;
> +
> +			/* Cast the final integer value back to the restricted
> +			 * type
> +			 */
> +			thdr->check = (__force __sum16)csum;

Way to manny lines of code for something this simple.
Can csum_add() help you get rid of all these casts and comments?
-- 
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ