Skip to content

Commit d0fdb36

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec
Steffen Klassert says: ==================== pull request (net): ipsec 2018-07-27 1) Fix PMTU handling of vti6. We update the PMTU on the xfrm dst_entry which is not cached anymore after the flowchache removal. So update the PMTU of the original dst_entry instead. From Eyal Birger. 2) Fix a leak of kernel memory to userspace. From Eric Dumazet. 3) Fix a possible dst_entry memleak in xfrm_lookup_route. From Tommi Rantala. 4) Fix a skb leak in case we can't call nlmsg_multicast from xfrm_nlmsg_multicast. From Florian Westphal. 5) Fix a leak of a temporary buffer in the error path of esp6_input. From Zhen Lei. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 101f0cd + 7284fdf commit d0fdb36

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

net/ipv6/esp6.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,10 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
669669

670670
sg_init_table(sg, nfrags);
671671
ret = skb_to_sgvec(skb, sg, 0, skb->len);
672-
if (unlikely(ret < 0))
672+
if (unlikely(ret < 0)) {
673+
kfree(tmp);
673674
goto out;
675+
}
674676

675677
skb->ip_summed = CHECKSUM_NONE;
676678

net/ipv6/ip6_vti.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,6 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
480480
goto tx_err_dst_release;
481481
}
482482

483-
skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev)));
484-
skb_dst_set(skb, dst);
485-
skb->dev = skb_dst(skb)->dev;
486-
487483
mtu = dst_mtu(dst);
488484
if (!skb->ignore_df && skb->len > mtu) {
489485
skb_dst_update_pmtu(skb, mtu);
@@ -498,9 +494,14 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
498494
htonl(mtu));
499495
}
500496

501-
return -EMSGSIZE;
497+
err = -EMSGSIZE;
498+
goto tx_err_dst_release;
502499
}
503500

501+
skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev)));
502+
skb_dst_set(skb, dst);
503+
skb->dev = skb_dst(skb)->dev;
504+
504505
err = dst_output(t->net, skb->sk, skb);
505506
if (net_xmit_eval(err) == 0) {
506507
struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);

net/xfrm/xfrm_policy.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,9 @@ struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
22862286
if (IS_ERR(dst) && PTR_ERR(dst) == -EREMOTE)
22872287
return make_blackhole(net, dst_orig->ops->family, dst_orig);
22882288

2289+
if (IS_ERR(dst))
2290+
dst_release(dst_orig);
2291+
22892292
return dst;
22902293
}
22912294
EXPORT_SYMBOL(xfrm_lookup_route);

net/xfrm/xfrm_user.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,10 +1025,12 @@ static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb,
10251025
{
10261026
struct sock *nlsk = rcu_dereference(net->xfrm.nlsk);
10271027

1028-
if (nlsk)
1029-
return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC);
1030-
else
1031-
return -1;
1028+
if (!nlsk) {
1029+
kfree_skb(skb);
1030+
return -EPIPE;
1031+
}
1032+
1033+
return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC);
10321034
}
10331035

10341036
static inline unsigned int xfrm_spdinfo_msgsize(void)
@@ -1671,9 +1673,11 @@ static inline unsigned int userpolicy_type_attrsize(void)
16711673
#ifdef CONFIG_XFRM_SUB_POLICY
16721674
static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
16731675
{
1674-
struct xfrm_userpolicy_type upt = {
1675-
.type = type,
1676-
};
1676+
struct xfrm_userpolicy_type upt;
1677+
1678+
/* Sadly there are two holes in struct xfrm_userpolicy_type */
1679+
memset(&upt, 0, sizeof(upt));
1680+
upt.type = type;
16771681

16781682
return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
16791683
}

0 commit comments

Comments
 (0)