Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a63ba13e authored by Karl Beldan's avatar Karl Beldan Committed by David S. Miller
Browse files

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: default avatarKarl Beldan <karl.beldan@rivierawaves.com>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8fc96351
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
#include <linux/export.h>
#include <net/ip.h>
#include <net/tso.h>
#include <asm/unaligned.h>

/* Calculate expected number of TX descriptors */
int tso_count_descs(struct sk_buff *skb)
@@ -23,7 +24,7 @@ void tso_build_hdr(struct sk_buff *skb, char *hdr, struct tso_t *tso,
	iph->id = htons(tso->ip_id);
	iph->tot_len = htons(size + hdr_len - mac_hdr_len);
	tcph = (struct tcphdr *)(hdr + skb_transport_offset(skb));
	tcph->seq = htonl(tso->tcp_seq);
	put_unaligned_be32(tso->tcp_seq, &tcph->seq);
	tso->ip_id++;

	if (!is_last) {