* [PATCH net v1 1/1] net: selftests: initialize TCP header and skb payload with zero
@ 2025-04-16 16:01 Oleksij Rempel
2025-04-21 13:29 ` Simon Horman
2025-04-22 23:59 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Oleksij Rempel @ 2025-04-16 16:01 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman
Cc: Oleksij Rempel, stable, kernel, linux-kernel, netdev,
Maxime Chevallier
Zero-initialize TCP header via memset() to avoid garbage values that
may affect checksum or behavior during test transmission.
Also zero-fill allocated payload and padding regions using memset()
after skb_put(), ensuring deterministic content for all outgoing
test packets.
Fixes: 3e1e58d64c3d ("net: add generic selftest support")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: stable@vger.kernel.org
---
net/core/selftests.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/net/core/selftests.c b/net/core/selftests.c
index e99ae983fca9..35f807ea9952 100644
--- a/net/core/selftests.c
+++ b/net/core/selftests.c
@@ -100,10 +100,10 @@ static struct sk_buff *net_test_get_skb(struct net_device *ndev,
ehdr->h_proto = htons(ETH_P_IP);
if (attr->tcp) {
+ memset(thdr, 0, sizeof(*thdr));
thdr->source = htons(attr->sport);
thdr->dest = htons(attr->dport);
thdr->doff = sizeof(struct tcphdr) / 4;
- thdr->check = 0;
} else {
uhdr->source = htons(attr->sport);
uhdr->dest = htons(attr->dport);
@@ -144,10 +144,18 @@ static struct sk_buff *net_test_get_skb(struct net_device *ndev,
attr->id = net_test_next_id;
shdr->id = net_test_next_id++;
- if (attr->size)
- skb_put(skb, attr->size);
- if (attr->max_size && attr->max_size > skb->len)
- skb_put(skb, attr->max_size - skb->len);
+ if (attr->size) {
+ void *payload = skb_put(skb, attr->size);
+
+ memset(payload, 0, attr->size);
+ }
+
+ if (attr->max_size && attr->max_size > skb->len) {
+ size_t pad_len = attr->max_size - skb->len;
+ void *pad = skb_put(skb, pad_len);
+
+ memset(pad, 0, pad_len);
+ }
skb->csum = 0;
skb->ip_summed = CHECKSUM_PARTIAL;
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v1 1/1] net: selftests: initialize TCP header and skb payload with zero
2025-04-16 16:01 [PATCH net v1 1/1] net: selftests: initialize TCP header and skb payload with zero Oleksij Rempel
@ 2025-04-21 13:29 ` Simon Horman
2025-04-22 23:59 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-04-21 13:29 UTC (permalink / raw)
To: Oleksij Rempel
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
stable, kernel, linux-kernel, netdev, Maxime Chevallier
On Wed, Apr 16, 2025 at 06:01:25PM +0200, Oleksij Rempel wrote:
> Zero-initialize TCP header via memset() to avoid garbage values that
> may affect checksum or behavior during test transmission.
>
> Also zero-fill allocated payload and padding regions using memset()
> after skb_put(), ensuring deterministic content for all outgoing
> test packets.
>
> Fixes: 3e1e58d64c3d ("net: add generic selftest support")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> Cc: stable@vger.kernel.org
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v1 1/1] net: selftests: initialize TCP header and skb payload with zero
2025-04-16 16:01 [PATCH net v1 1/1] net: selftests: initialize TCP header and skb payload with zero Oleksij Rempel
2025-04-21 13:29 ` Simon Horman
@ 2025-04-22 23:59 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-04-22 23:59 UTC (permalink / raw)
To: Oleksij Rempel
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman, stable,
kernel, linux-kernel, netdev, Maxime Chevallier
On Wed, 16 Apr 2025 18:01:25 +0200 Oleksij Rempel wrote:
> Zero-initialize TCP header via memset() to avoid garbage values that
> may affect checksum or behavior during test transmission.
>
> Also zero-fill allocated payload and padding regions using memset()
> after skb_put(), ensuring deterministic content for all outgoing
> test packets.
This has been applied, thanks!
patchwork-but is down, it seems, and it's out of our control :(
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-22 23:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 16:01 [PATCH net v1 1/1] net: selftests: initialize TCP header and skb payload with zero Oleksij Rempel
2025-04-21 13:29 ` Simon Horman
2025-04-22 23:59 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).