Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: tso: fix unaligned access to crafted TCP header in helper API

The crafted header start address is from a driver supplied buffer, which
one can reasonably expect to be aligned on a 4-bytes boundary.
However ATM the TSO helper API is only used by ethernet drivers and
the tcp header will then be aligned to a 2-bytes only boundary from the
header start address.

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Karl Beldan and committed by
David S. Miller
a63ba13e 8fc96351

+2 -1
+2 -1
net/core/tso.c
··· 1 1 #include <linux/export.h> 2 2 #include <net/ip.h> 3 3 #include <net/tso.h> 4 + #include <asm/unaligned.h> 4 5 5 6 /* Calculate expected number of TX descriptors */ 6 7 int tso_count_descs(struct sk_buff *skb) ··· 24 23 iph->id = htons(tso->ip_id); 25 24 iph->tot_len = htons(size + hdr_len - mac_hdr_len); 26 25 tcph = (struct tcphdr *)(hdr + skb_transport_offset(skb)); 27 - tcph->seq = htonl(tso->tcp_seq); 26 + put_unaligned_be32(tso->tcp_seq, &tcph->seq); 28 27 tso->ip_id++; 29 28 30 29 if (!is_last) {