Skip to content

Commit d1041cd

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix use-after-free in IPSEC input parsing, desintation address pointer was loaded before pskb_may_pull() which can change the SKB data pointers. From Florian Westphal. 2) Stack out-of-bounds read in xfrm_state_find(), from Steffen Klassert. 3) IPVS state of SKB is not properly reset when moving between namespaces, from Ye Yin. 4) Fix crash in asix driver suspend and resume, from Andrey Konovalov. 5) Don't deliver ipv6 l2tp tunnel packets to ipv4 l2tp tunnels, and vice versa, from Guillaume Nault. 6) Fix DSACK undo on non-dup ACKs, from Priyaranjan Jha. 7) Fix regression in bond_xmit_hash()'s behavior after the TCP port selection changes back in 4.2, from Hangbin Liu. 8) Two divide by zero bugs in USB networking drivers when parsing descriptors, from Bjorn Mork. 9) Fix bonding slaves being stuck in BOND_LINK_FAIL state, from Jay Vosburgh. 10) Missing skb_reset_mac_header() in qmi_wwan, from Kristian Evensen. 11) Fix the destruction of tc action object races properly, from Cong Wang. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (31 commits) cls_u32: use tcf_exts_get_net() before call_rcu() cls_tcindex: use tcf_exts_get_net() before call_rcu() cls_rsvp: use tcf_exts_get_net() before call_rcu() cls_route: use tcf_exts_get_net() before call_rcu() cls_matchall: use tcf_exts_get_net() before call_rcu() cls_fw: use tcf_exts_get_net() before call_rcu() cls_flower: use tcf_exts_get_net() before call_rcu() cls_flow: use tcf_exts_get_net() before call_rcu() cls_cgroup: use tcf_exts_get_net() before call_rcu() cls_bpf: use tcf_exts_get_net() before call_rcu() cls_basic: use tcf_exts_get_net() before call_rcu() net_sched: introduce tcf_exts_get_net() and tcf_exts_put_net() Revert "net_sched: hold netns refcnt for each action" net: usb: asix: fill null-ptr-deref in asix_suspend Revert "net: usb: asix: fill null-ptr-deref in asix_suspend" qmi_wwan: Add missing skb_reset_mac_header-call bonding: fix slave stuck in BOND_LINK_FAIL state qrtr: Move to postcore_initcall net: qmi_wwan: fix divide by 0 on bad descriptors net: cdc_ether: fix divide by 0 on bad descriptors ...
2 parents 87df261 + 6a17280 commit d1041cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+285
-146
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,7 @@ static int bond_miimon_inspect(struct bonding *bond)
20422042

20432043
bond_for_each_slave_rcu(bond, slave, iter) {
20442044
slave->new_link = BOND_LINK_NOCHANGE;
2045+
slave->link_new_state = slave->link;
20452046

20462047
link_state = bond_check_dev_link(bond, slave->dev, 0);
20472048

@@ -3253,7 +3254,7 @@ u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb)
32533254
hash ^= (hash >> 16);
32543255
hash ^= (hash >> 8);
32553256

3256-
return hash;
3257+
return hash >> 1;
32573258
}
32583259

32593260
/*-------------------------- Device entry points ----------------------------*/

drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#define T4FW_VERSION_MAJOR 0x01
3939
#define T4FW_VERSION_MINOR 0x10
40-
#define T4FW_VERSION_MICRO 0x2D
40+
#define T4FW_VERSION_MICRO 0x3F
4141
#define T4FW_VERSION_BUILD 0x00
4242

4343
#define T4FW_MIN_VERSION_MAJOR 0x01
@@ -46,7 +46,7 @@
4646

4747
#define T5FW_VERSION_MAJOR 0x01
4848
#define T5FW_VERSION_MINOR 0x10
49-
#define T5FW_VERSION_MICRO 0x2D
49+
#define T5FW_VERSION_MICRO 0x3F
5050
#define T5FW_VERSION_BUILD 0x00
5151

5252
#define T5FW_MIN_VERSION_MAJOR 0x00
@@ -55,7 +55,7 @@
5555

5656
#define T6FW_VERSION_MAJOR 0x01
5757
#define T6FW_VERSION_MINOR 0x10
58-
#define T6FW_VERSION_MICRO 0x2D
58+
#define T6FW_VERSION_MICRO 0x3F
5959
#define T6FW_VERSION_BUILD 0x00
6060

6161
#define T6FW_MIN_VERSION_MAJOR 0x00

drivers/net/ethernet/marvell/mvpp2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6747,6 +6747,9 @@ static int mvpp2_irqs_init(struct mvpp2_port *port)
67476747
for (i = 0; i < port->nqvecs; i++) {
67486748
struct mvpp2_queue_vector *qv = port->qvecs + i;
67496749

6750+
if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE)
6751+
irq_set_status_flags(qv->irq, IRQ_NO_BALANCING);
6752+
67506753
err = request_irq(qv->irq, mvpp2_isr, 0, port->dev->name, qv);
67516754
if (err)
67526755
goto err;
@@ -6776,6 +6779,7 @@ static void mvpp2_irqs_deinit(struct mvpp2_port *port)
67766779
struct mvpp2_queue_vector *qv = port->qvecs + i;
67776780

67786781
irq_set_affinity_hint(qv->irq, NULL);
6782+
irq_clear_status_flags(qv->irq, IRQ_NO_BALANCING);
67796783
free_irq(qv->irq, qv);
67806784
}
67816785
}

drivers/net/ethernet/mellanox/mlx5/core/en_fs.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,29 +365,32 @@ static void mlx5e_execute_l2_action(struct mlx5e_priv *priv,
365365
struct mlx5e_l2_hash_node *hn)
366366
{
367367
u8 action = hn->action;
368+
u8 mac_addr[ETH_ALEN];
368369
int l2_err = 0;
369370

371+
ether_addr_copy(mac_addr, hn->ai.addr);
372+
370373
switch (action) {
371374
case MLX5E_ACTION_ADD:
372375
mlx5e_add_l2_flow_rule(priv, &hn->ai, MLX5E_FULLMATCH);
373-
if (!is_multicast_ether_addr(hn->ai.addr)) {
374-
l2_err = mlx5_mpfs_add_mac(priv->mdev, hn->ai.addr);
376+
if (!is_multicast_ether_addr(mac_addr)) {
377+
l2_err = mlx5_mpfs_add_mac(priv->mdev, mac_addr);
375378
hn->mpfs = !l2_err;
376379
}
377380
hn->action = MLX5E_ACTION_NONE;
378381
break;
379382

380383
case MLX5E_ACTION_DEL:
381-
if (!is_multicast_ether_addr(hn->ai.addr) && hn->mpfs)
382-
l2_err = mlx5_mpfs_del_mac(priv->mdev, hn->ai.addr);
384+
if (!is_multicast_ether_addr(mac_addr) && hn->mpfs)
385+
l2_err = mlx5_mpfs_del_mac(priv->mdev, mac_addr);
383386
mlx5e_del_l2_flow_rule(priv, &hn->ai);
384387
mlx5e_del_l2_from_hash(hn);
385388
break;
386389
}
387390

388391
if (l2_err)
389392
netdev_warn(priv->netdev, "MPFS, failed to %s mac %pM, err(%d)\n",
390-
action == MLX5E_ACTION_ADD ? "add" : "del", hn->ai.addr, l2_err);
393+
action == MLX5E_ACTION_ADD ? "add" : "del", mac_addr, l2_err);
391394
}
392395

393396
static void mlx5e_sync_netdev_addr(struct mlx5e_priv *priv)

drivers/net/usb/asix_devices.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ static int asix_suspend(struct usb_interface *intf, pm_message_t message)
626626
struct usbnet *dev = usb_get_intfdata(intf);
627627
struct asix_common_private *priv = dev->driver_priv;
628628

629-
if (priv->suspend)
629+
if (priv && priv->suspend)
630630
priv->suspend(dev);
631631

632632
return usbnet_suspend(intf, message);
@@ -678,7 +678,7 @@ static int asix_resume(struct usb_interface *intf)
678678
struct usbnet *dev = usb_get_intfdata(intf);
679679
struct asix_common_private *priv = dev->driver_priv;
680680

681-
if (priv->resume)
681+
if (priv && priv->resume)
682682
priv->resume(dev);
683683

684684
return usbnet_resume(intf);

drivers/net/usb/cdc_ether.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
230230
goto bad_desc;
231231
}
232232

233-
if (header.usb_cdc_ether_desc) {
233+
if (header.usb_cdc_ether_desc && info->ether->wMaxSegmentSize) {
234234
dev->hard_mtu = le16_to_cpu(info->ether->wMaxSegmentSize);
235235
/* because of Zaurus, we may be ignoring the host
236236
* side link address we were given.

drivers/net/usb/qmi_wwan.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
499499
return 1;
500500
}
501501
if (rawip) {
502+
skb_reset_mac_header(skb);
502503
skb->dev = dev->net; /* normally set by eth_type_trans */
503504
skb->protocol = proto;
504505
return 1;
@@ -681,7 +682,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
681682
}
682683

683684
/* errors aren't fatal - we can live with the dynamic address */
684-
if (cdc_ether) {
685+
if (cdc_ether && cdc_ether->wMaxSegmentSize) {
685686
dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
686687
usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
687688
}

include/linux/skbuff.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,6 +3770,13 @@ static inline void nf_reset_trace(struct sk_buff *skb)
37703770
#endif
37713771
}
37723772

3773+
static inline void ipvs_reset(struct sk_buff *skb)
3774+
{
3775+
#if IS_ENABLED(CONFIG_IP_VS)
3776+
skb->ipvs_property = 0;
3777+
#endif
3778+
}
3779+
37733780
/* Note: This doesn't put any conntrack and bridge info in dst. */
37743781
static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src,
37753782
bool copy)

include/net/act_api.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
struct tcf_idrinfo {
1515
spinlock_t lock;
1616
struct idr action_idr;
17-
struct net *net;
1817
};
1918

2019
struct tc_action_ops;
@@ -106,15 +105,14 @@ struct tc_action_net {
106105

107106
static inline
108107
int tc_action_net_init(struct tc_action_net *tn,
109-
const struct tc_action_ops *ops, struct net *net)
108+
const struct tc_action_ops *ops)
110109
{
111110
int err = 0;
112111

113112
tn->idrinfo = kmalloc(sizeof(*tn->idrinfo), GFP_KERNEL);
114113
if (!tn->idrinfo)
115114
return -ENOMEM;
116115
tn->ops = ops;
117-
tn->idrinfo->net = net;
118116
spin_lock_init(&tn->idrinfo->lock);
119117
idr_init(&tn->idrinfo->action_idr);
120118
return err;

include/net/pkt_cls.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct tcf_exts {
9494
__u32 type; /* for backward compat(TCA_OLD_COMPAT) */
9595
int nr_actions;
9696
struct tc_action **actions;
97+
struct net *net;
9798
#endif
9899
/* Map to export classifier specific extension TLV types to the
99100
* generic extensions API. Unsupported extensions must be set to 0.
@@ -107,6 +108,7 @@ static inline int tcf_exts_init(struct tcf_exts *exts, int action, int police)
107108
#ifdef CONFIG_NET_CLS_ACT
108109
exts->type = 0;
109110
exts->nr_actions = 0;
111+
exts->net = NULL;
110112
exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *),
111113
GFP_KERNEL);
112114
if (!exts->actions)
@@ -117,6 +119,28 @@ static inline int tcf_exts_init(struct tcf_exts *exts, int action, int police)
117119
return 0;
118120
}
119121

122+
/* Return false if the netns is being destroyed in cleanup_net(). Callers
123+
* need to do cleanup synchronously in this case, otherwise may race with
124+
* tc_action_net_exit(). Return true for other cases.
125+
*/
126+
static inline bool tcf_exts_get_net(struct tcf_exts *exts)
127+
{
128+
#ifdef CONFIG_NET_CLS_ACT
129+
exts->net = maybe_get_net(exts->net);
130+
return exts->net != NULL;
131+
#else
132+
return true;
133+
#endif
134+
}
135+
136+
static inline void tcf_exts_put_net(struct tcf_exts *exts)
137+
{
138+
#ifdef CONFIG_NET_CLS_ACT
139+
if (exts->net)
140+
put_net(exts->net);
141+
#endif
142+
}
143+
120144
static inline void tcf_exts_to_list(const struct tcf_exts *exts,
121145
struct list_head *actions)
122146
{

net/core/skbuff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4864,6 +4864,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
48644864
if (!xnet)
48654865
return;
48664866

4867+
ipvs_reset(skb);
48674868
skb_orphan(skb);
48684869
skb->mark = 0;
48694870
}

net/ipv4/tcp_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int sysctl_tcp_invalid_ratelimit __read_mostly = HZ/2;
115115

116116
#define FLAG_ACKED (FLAG_DATA_ACKED|FLAG_SYN_ACKED)
117117
#define FLAG_NOT_DUP (FLAG_DATA|FLAG_WIN_UPDATE|FLAG_ACKED)
118-
#define FLAG_CA_ALERT (FLAG_DATA_SACKED|FLAG_ECE)
118+
#define FLAG_CA_ALERT (FLAG_DATA_SACKED|FLAG_ECE|FLAG_DSACKING_ACK)
119119
#define FLAG_FORWARD_PROGRESS (FLAG_ACKED|FLAG_DATA_SACKED)
120120

121121
#define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH)

net/l2tp/l2tp_ip.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static int l2tp_ip_recv(struct sk_buff *skb)
123123
unsigned char *ptr, *optr;
124124
struct l2tp_session *session;
125125
struct l2tp_tunnel *tunnel = NULL;
126+
struct iphdr *iph;
126127
int length;
127128

128129
if (!pskb_may_pull(skb, 4))
@@ -178,24 +179,17 @@ static int l2tp_ip_recv(struct sk_buff *skb)
178179
goto discard;
179180

180181
tunnel_id = ntohl(*(__be32 *) &skb->data[4]);
181-
tunnel = l2tp_tunnel_find(net, tunnel_id);
182-
if (tunnel) {
183-
sk = tunnel->sock;
184-
sock_hold(sk);
185-
} else {
186-
struct iphdr *iph = (struct iphdr *) skb_network_header(skb);
187-
188-
read_lock_bh(&l2tp_ip_lock);
189-
sk = __l2tp_ip_bind_lookup(net, iph->daddr, iph->saddr,
190-
inet_iif(skb), tunnel_id);
191-
if (!sk) {
192-
read_unlock_bh(&l2tp_ip_lock);
193-
goto discard;
194-
}
182+
iph = (struct iphdr *)skb_network_header(skb);
195183

196-
sock_hold(sk);
184+
read_lock_bh(&l2tp_ip_lock);
185+
sk = __l2tp_ip_bind_lookup(net, iph->daddr, iph->saddr, inet_iif(skb),
186+
tunnel_id);
187+
if (!sk) {
197188
read_unlock_bh(&l2tp_ip_lock);
189+
goto discard;
198190
}
191+
sock_hold(sk);
192+
read_unlock_bh(&l2tp_ip_lock);
199193

200194
if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
201195
goto discard_put;

net/l2tp/l2tp_ip6.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
136136
unsigned char *ptr, *optr;
137137
struct l2tp_session *session;
138138
struct l2tp_tunnel *tunnel = NULL;
139+
struct ipv6hdr *iph;
139140
int length;
140141

141142
if (!pskb_may_pull(skb, 4))
@@ -192,24 +193,17 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
192193
goto discard;
193194

194195
tunnel_id = ntohl(*(__be32 *) &skb->data[4]);
195-
tunnel = l2tp_tunnel_find(net, tunnel_id);
196-
if (tunnel) {
197-
sk = tunnel->sock;
198-
sock_hold(sk);
199-
} else {
200-
struct ipv6hdr *iph = ipv6_hdr(skb);
201-
202-
read_lock_bh(&l2tp_ip6_lock);
203-
sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, &iph->saddr,
204-
inet6_iif(skb), tunnel_id);
205-
if (!sk) {
206-
read_unlock_bh(&l2tp_ip6_lock);
207-
goto discard;
208-
}
196+
iph = ipv6_hdr(skb);
209197

210-
sock_hold(sk);
198+
read_lock_bh(&l2tp_ip6_lock);
199+
sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, &iph->saddr,
200+
inet6_iif(skb), tunnel_id);
201+
if (!sk) {
211202
read_unlock_bh(&l2tp_ip6_lock);
203+
goto discard;
212204
}
205+
sock_hold(sk);
206+
read_unlock_bh(&l2tp_ip6_lock);
213207

214208
if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
215209
goto discard_put;

net/qrtr/qrtr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ static int __init qrtr_proto_init(void)
10851085

10861086
return 0;
10871087
}
1088-
module_init(qrtr_proto_init);
1088+
postcore_initcall(qrtr_proto_init);
10891089

10901090
static void __exit qrtr_proto_fini(void)
10911091
{

net/sched/act_api.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ static void tcf_idr_remove(struct tcf_idrinfo *idrinfo, struct tc_action *p)
7878
spin_lock_bh(&idrinfo->lock);
7979
idr_remove_ext(&idrinfo->action_idr, p->tcfa_index);
8080
spin_unlock_bh(&idrinfo->lock);
81-
put_net(idrinfo->net);
8281
gen_kill_estimator(&p->tcfa_rate_est);
8382
free_tcf(p);
8483
}
@@ -337,7 +336,6 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
337336
p->idrinfo = idrinfo;
338337
p->ops = ops;
339338
INIT_LIST_HEAD(&p->list);
340-
get_net(idrinfo->net);
341339
*a = p;
342340
return 0;
343341
}

net/sched/act_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static __net_init int bpf_init_net(struct net *net)
398398
{
399399
struct tc_action_net *tn = net_generic(net, bpf_net_id);
400400

401-
return tc_action_net_init(tn, &act_bpf_ops, net);
401+
return tc_action_net_init(tn, &act_bpf_ops);
402402
}
403403

404404
static void __net_exit bpf_exit_net(struct net *net)

net/sched/act_connmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static __net_init int connmark_init_net(struct net *net)
206206
{
207207
struct tc_action_net *tn = net_generic(net, connmark_net_id);
208208

209-
return tc_action_net_init(tn, &act_connmark_ops, net);
209+
return tc_action_net_init(tn, &act_connmark_ops);
210210
}
211211

212212
static void __net_exit connmark_exit_net(struct net *net)

net/sched/act_csum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ static __net_init int csum_init_net(struct net *net)
626626
{
627627
struct tc_action_net *tn = net_generic(net, csum_net_id);
628628

629-
return tc_action_net_init(tn, &act_csum_ops, net);
629+
return tc_action_net_init(tn, &act_csum_ops);
630630
}
631631

632632
static void __net_exit csum_exit_net(struct net *net)

net/sched/act_gact.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static __net_init int gact_init_net(struct net *net)
232232
{
233233
struct tc_action_net *tn = net_generic(net, gact_net_id);
234234

235-
return tc_action_net_init(tn, &act_gact_ops, net);
235+
return tc_action_net_init(tn, &act_gact_ops);
236236
}
237237

238238
static void __net_exit gact_exit_net(struct net *net)

net/sched/act_ife.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ static __net_init int ife_init_net(struct net *net)
818818
{
819819
struct tc_action_net *tn = net_generic(net, ife_net_id);
820820

821-
return tc_action_net_init(tn, &act_ife_ops, net);
821+
return tc_action_net_init(tn, &act_ife_ops);
822822
}
823823

824824
static void __net_exit ife_exit_net(struct net *net)

0 commit comments

Comments
 (0)