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: <20250621064600.035b83b3@kernel.org>
Date: Sat, 21 Jun 2025 06:46:00 -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 v4 0/4] net: selftest: improve test string
 formatting and checksum handling

On Fri, 20 Jun 2025 12:53:23 +0200 Oleksij Rempel wrote:
> > What device are you talking about? How is this a problem with 
> > the selftest and not with the stack? If the test is flaky I'd 
> > think real traffic will suffer too. We pass these selftest packets
> > thru xmit validation AFAICT, so the stack should compute checksum
> > for the if the device can't.
> >   
> 
> Let me first describe the setup where this issue was observed and my findings.
> The problem occurs on a system utilizing a Microchip DSA driver with an STMMAC
> Ethernet controller attached to the CPU port.
> 
> In the current selftest implementation, the TCP checksum validation fails,
> while the UDP test passes. The existing code prepares the skb for hardware
> checksum offload by setting skb->ip_summed = CHECKSUM_PARTIAL. For TCP, it sets
> the thdr->check field to the complement of the pseudo-header checksum, and for
> UDP, it uses udp4_hwcsum. If I understand it correct, this configuration tells
> the kernel that the hardware should perform the checksum calculation.
> 
> However, during testing, I noticed that "rx-checksumming" is enabled by default
> on the CPU port, and this leads to the TCP test failure.  Only after disabling
> "rx-checksumming" on the CPU port did the selftest pass. This suggests that the
> issue is specifically related to the hardware checksum offload mechanism in
> this particular setup. The behavior indicates that something on the path
> recalculated the checksum incorrectly.

Interesting, that sounds like the smoking gun. When rx-checksumming 
is enabled the packet still reaches the stack right?
If so does the frame enter the stack with CHECKSUM_COMPLETE or
UNNECESSARY?

> When examining the loopbacked frames, I observed that the TCP checksum was
> incorrect. Upon further investigation, the xmit helper in net/dsa/tag_ksz.c
> includes the following:
> 
> if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
>     return NULL;
> 
> I assume skb_checksum_help() is intended to calculate the proper checksum when
> CHECKSUM_PARTIAL is set, indicating that the software should complete the
> checksum before handing it to the hardware. My understanding is that the STMMAC
> hardware then calculates the checksum for egress frames if CHECKSUM_PARTIAL is
> used.

stmmac shouldn't touch the frame, note that skb_checksum_help() sets
skb->ip_summed = CHECKSUM_NONE; so the skb should no longer be considered
for csum offload.

> Since these egress frames are passed from the DSA framework with a
> tailtag, the checksum calculated by the hardware would then be incorrect for
> the original packet. The STMMAC then seems to drop ingress packets if they have
> an incorrect checksum.
> 
> I'm still trying to grasp the full picture of checksumming in such complex
> environments. I would be grateful for your guidance on how this problem should
> be addressed properly.
> 
> Regarding the current patch series, do these tests and the csum_mode
> implementation make sense to you in this context? I believe it would be good
> practice to have selftests that can detect these kinds of checksum
> inconsistencies in drivers.

Not yet, at least. Once we figure out the problem you're seeing we can
decide whether we should adjust the tests or the tests are failing
because they are doing their job.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ