Skip to content

Commit 50b2abe

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: packet: fix possible dev refcnt leak when bind fail netem: dont call vfree() under spinlock and BH disabled netfilter: ctnetlink: fix scheduling while atomic if helper is autoloaded netfilter: ctnetlink: fix return value of ctnetlink_get_expect()
2 parents 7578ed0 + aef950b commit 50b2abe

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

net/netfilter/nf_conntrack_netlink.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,12 +1358,15 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
13581358
nf_ct_protonum(ct));
13591359
if (helper == NULL) {
13601360
rcu_read_unlock();
1361+
spin_unlock_bh(&nf_conntrack_lock);
13611362
#ifdef CONFIG_MODULES
13621363
if (request_module("nfct-helper-%s", helpname) < 0) {
1364+
spin_lock_bh(&nf_conntrack_lock);
13631365
err = -EOPNOTSUPP;
13641366
goto err1;
13651367
}
13661368

1369+
spin_lock_bh(&nf_conntrack_lock);
13671370
rcu_read_lock();
13681371
helper = __nf_conntrack_helper_find(helpname,
13691372
nf_ct_l3num(ct),
@@ -1869,25 +1872,30 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
18691872

18701873
err = -ENOMEM;
18711874
skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1872-
if (skb2 == NULL)
1875+
if (skb2 == NULL) {
1876+
nf_ct_expect_put(exp);
18731877
goto out;
1878+
}
18741879

18751880
rcu_read_lock();
18761881
err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
18771882
nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp);
18781883
rcu_read_unlock();
1884+
nf_ct_expect_put(exp);
18791885
if (err <= 0)
18801886
goto free;
18811887

1882-
nf_ct_expect_put(exp);
1888+
err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
1889+
if (err < 0)
1890+
goto out;
18831891

1884-
return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
1892+
return 0;
18851893

18861894
free:
18871895
kfree_skb(skb2);
18881896
out:
1889-
nf_ct_expect_put(exp);
1890-
return err;
1897+
/* this avoids a loop in nfnetlink. */
1898+
return err == -EAGAIN ? -ENOBUFS : err;
18911899
}
18921900

18931901
static int

net/packet/af_packet.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2448,8 +2448,12 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
24482448
{
24492449
struct packet_sock *po = pkt_sk(sk);
24502450

2451-
if (po->fanout)
2451+
if (po->fanout) {
2452+
if (dev)
2453+
dev_put(dev);
2454+
24522455
return -EINVAL;
2456+
}
24532457

24542458
lock_sock(sk);
24552459

net/sched/sch_netem.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
488488
return -EINVAL;
489489

490490
s = sizeof(struct disttable) + n * sizeof(s16);
491-
d = kmalloc(s, GFP_KERNEL);
491+
d = kmalloc(s, GFP_KERNEL | __GFP_NOWARN);
492492
if (!d)
493493
d = vmalloc(s);
494494
if (!d)
@@ -501,9 +501,10 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
501501
root_lock = qdisc_root_sleeping_lock(sch);
502502

503503
spin_lock_bh(root_lock);
504-
dist_free(q->delay_dist);
505-
q->delay_dist = d;
504+
swap(q->delay_dist, d);
506505
spin_unlock_bh(root_lock);
506+
507+
dist_free(d);
507508
return 0;
508509
}
509510

0 commit comments

Comments
 (0)