File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1227,14 +1227,19 @@ static inline int
1227
1227
ip4ip6_tnl_xmit (struct sk_buff * skb , struct net_device * dev )
1228
1228
{
1229
1229
struct ip6_tnl * t = netdev_priv (dev );
1230
- const struct iphdr * iph = ip_hdr ( skb ) ;
1230
+ const struct iphdr * iph ;
1231
1231
int encap_limit = -1 ;
1232
1232
struct flowi6 fl6 ;
1233
1233
__u8 dsfield ;
1234
1234
__u32 mtu ;
1235
1235
u8 tproto ;
1236
1236
int err ;
1237
1237
1238
+ /* ensure we can access the full inner ip header */
1239
+ if (!pskb_may_pull (skb , sizeof (struct iphdr )))
1240
+ return -1 ;
1241
+
1242
+ iph = ip_hdr (skb );
1238
1243
memset (& (IPCB (skb )-> opt ), 0 , sizeof (IPCB (skb )-> opt ));
1239
1244
1240
1245
tproto = ACCESS_ONCE (t -> parms .proto );
@@ -1298,7 +1303,7 @@ static inline int
1298
1303
ip6ip6_tnl_xmit (struct sk_buff * skb , struct net_device * dev )
1299
1304
{
1300
1305
struct ip6_tnl * t = netdev_priv (dev );
1301
- struct ipv6hdr * ipv6h = ipv6_hdr ( skb ) ;
1306
+ struct ipv6hdr * ipv6h ;
1302
1307
int encap_limit = -1 ;
1303
1308
__u16 offset ;
1304
1309
struct flowi6 fl6 ;
@@ -1307,6 +1312,10 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
1307
1312
u8 tproto ;
1308
1313
int err ;
1309
1314
1315
+ if (unlikely (!pskb_may_pull (skb , sizeof (* ipv6h ))))
1316
+ return -1 ;
1317
+
1318
+ ipv6h = ipv6_hdr (skb );
1310
1319
tproto = ACCESS_ONCE (t -> parms .proto );
1311
1320
if ((tproto != IPPROTO_IPV6 && tproto != 0 ) ||
1312
1321
ip6_tnl_addr_conflict (t , ipv6h ))
You can’t perform that action at this time.
0 commit comments