Skip to content

Commit ced14f6

Browse files
hormsdavem330
authored andcommitted
net: Correct comparisons and calculations using skb->tail and skb-transport_header
This corrects an regression introduced by "net: Use 16bits for *_headers fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In that case skb->tail will be a pointer whereas skb->transport_header will be an offset from head. This is corrected by using wrappers that ensure that comparisons and calculations are always made using pointers. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent be8b678 commit ced14f6

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎include/net/inet_ecn.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,14 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb)
134134
{
135135
switch (skb->protocol) {
136136
case cpu_to_be16(ETH_P_IP):
137-
if (skb->network_header + sizeof(struct iphdr) <= skb->tail)
137+
if (skb_network_header(skb) + sizeof(struct iphdr) <=
138+
skb_tail_pointer(skb))
138139
return IP_ECN_set_ce(ip_hdr(skb));
139140
break;
140141

141142
case cpu_to_be16(ETH_P_IPV6):
142-
if (skb->network_header + sizeof(struct ipv6hdr) <= skb->tail)
143+
if (skb_network_header(skb) + sizeof(struct ipv6hdr) <=
144+
skb_tail_pointer(skb))
143145
return IP6_ECN_set_ce(ipv6_hdr(skb));
144146
break;
145147
}

‎net/core/dev.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
17241724
skb_reset_mac_header(skb2);
17251725

17261726
if (skb_network_header(skb2) < skb2->data ||
1727-
skb2->network_header > skb2->tail) {
1727+
skb_network_header(skb2) > skb_tail_pointer(skb2)) {
17281728
net_crit_ratelimited("protocol %04x is buggy, dev %s\n",
17291729
ntohs(skb2->protocol),
17301730
dev->name);
@@ -3892,7 +3892,7 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
38923892
NAPI_GRO_CB(skb)->frag0 = NULL;
38933893
NAPI_GRO_CB(skb)->frag0_len = 0;
38943894

3895-
if (skb->mac_header == skb->tail &&
3895+
if (skb_mac_header(skb) == skb_tail_pointer(skb) &&
38963896
pinfo->nr_frags &&
38973897
!PageHighMem(skb_frag_page(frag0))) {
38983898
NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0);

0 commit comments

Comments
 (0)