From: Karl Beldan Date: Tue, 21 Oct 2014 14:06:05 +0000 (+0200) Subject: net: tso: fix unaligned access to crafted TCP header in helper API X-Git-Tag: v4.9.8~5423^2~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a63ba13eec092b70d4e5522d692eaeb2f9747387;p=platform%2Fkernel%2Flinux-rpi3.git 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 Cc: Ezequiel Garcia Signed-off-by: David S. Miller --- diff --git a/net/core/tso.c b/net/core/tso.c index 8c3203c..630b30b 100644 --- a/net/core/tso.c +++ b/net/core/tso.c @@ -1,6 +1,7 @@ #include #include #include +#include /* 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) {