Skip to content

Commit 7ba3ebf

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: "Hopefully this is the last batch of networking fixes for 4.14 Fingers crossed... 1) Fix stmmac to use the proper sized OF property read, from Bhadram Varka. 2) Fix use after free in net scheduler tc action code, from Cong Wang. 3) Fix SKB control block mangling in tcp_make_synack(). 4) Use proper locking in fib_dump_info(), from Florian Westphal. 5) Fix IPG encodings in systemport driver, from Florian Fainelli. 6) Fix division by zero in NV TCP congestion control module, from Konstantin Khlebnikov. 7) Fix use after free in nf_reject_ipv4, from Tejaswi Tanikella" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: net: systemport: Correct IPG length settings tcp: do not mangle skb->cb[] in tcp_make_synack() fib: fib_dump_info can no longer use __in_dev_get_rtnl stmmac: use of_property_read_u32 instead of read_u8 net_sched: hold netns refcnt for each action net_sched: acquire RTNL in tc_action_net_exit() net: vrf: correct FRA_L3MDEV encode type tcp_nv: fix division by zero in tcpnv_acked() netfilter: nf_reject_ipv4: Fix use-after-free in send_reset netfilter: nft_set_hash: disable fast_ops for 2-len keys
2 parents f0395d5 + 93824c8 commit 7ba3ebf

27 files changed

Lines changed: 60 additions & 50 deletions

drivers/net/ethernet/broadcom/bcmsysport.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,15 +1809,17 @@ static inline void bcm_sysport_mask_all_intrs(struct bcm_sysport_priv *priv)
18091809

18101810
static inline void gib_set_pad_extension(struct bcm_sysport_priv *priv)
18111811
{
1812-
u32 __maybe_unused reg;
1812+
u32 reg;
18131813

1814-
/* Include Broadcom tag in pad extension */
1814+
reg = gib_readl(priv, GIB_CONTROL);
1815+
/* Include Broadcom tag in pad extension and fix up IPG_LENGTH */
18151816
if (netdev_uses_dsa(priv->netdev)) {
1816-
reg = gib_readl(priv, GIB_CONTROL);
18171817
reg &= ~(GIB_PAD_EXTENSION_MASK << GIB_PAD_EXTENSION_SHIFT);
18181818
reg |= ENET_BRCM_TAG_LEN << GIB_PAD_EXTENSION_SHIFT;
1819-
gib_writel(priv, reg, GIB_CONTROL);
18201819
}
1820+
reg &= ~(GIB_IPG_LEN_MASK << GIB_IPG_LEN_SHIFT);
1821+
reg |= 12 << GIB_IPG_LEN_SHIFT;
1822+
gib_writel(priv, reg, GIB_CONTROL);
18211823
}
18221824

18231825
static int bcm_sysport_open(struct net_device *dev)

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
168168
}
169169

170170
/* Processing RX queues common config */
171-
if (of_property_read_u8(rx_node, "snps,rx-queues-to-use",
172-
&plat->rx_queues_to_use))
171+
if (of_property_read_u32(rx_node, "snps,rx-queues-to-use",
172+
&plat->rx_queues_to_use))
173173
plat->rx_queues_to_use = 1;
174174

175175
if (of_property_read_bool(rx_node, "snps,rx-sched-sp"))
@@ -191,8 +191,8 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
191191
else
192192
plat->rx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
193193

194-
if (of_property_read_u8(q_node, "snps,map-to-dma-channel",
195-
&plat->rx_queues_cfg[queue].chan))
194+
if (of_property_read_u32(q_node, "snps,map-to-dma-channel",
195+
&plat->rx_queues_cfg[queue].chan))
196196
plat->rx_queues_cfg[queue].chan = queue;
197197
/* TODO: Dynamic mapping to be included in the future */
198198

@@ -222,8 +222,8 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
222222
}
223223

224224
/* Processing TX queues common config */
225-
if (of_property_read_u8(tx_node, "snps,tx-queues-to-use",
226-
&plat->tx_queues_to_use))
225+
if (of_property_read_u32(tx_node, "snps,tx-queues-to-use",
226+
&plat->tx_queues_to_use))
227227
plat->tx_queues_to_use = 1;
228228

229229
if (of_property_read_bool(tx_node, "snps,tx-sched-wrr"))
@@ -244,8 +244,8 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
244244
if (queue >= plat->tx_queues_to_use)
245245
break;
246246

247-
if (of_property_read_u8(q_node, "snps,weight",
248-
&plat->tx_queues_cfg[queue].weight))
247+
if (of_property_read_u32(q_node, "snps,weight",
248+
&plat->tx_queues_cfg[queue].weight))
249249
plat->tx_queues_cfg[queue].weight = 0x10 + queue;
250250

251251
if (of_property_read_bool(q_node, "snps,dcb-algorithm")) {

drivers/net/vrf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ static int vrf_fib_rule(const struct net_device *dev, __u8 family, bool add_it)
11651165
frh->family = family;
11661166
frh->action = FR_ACT_TO_TBL;
11671167

1168-
if (nla_put_u32(skb, FRA_L3MDEV, 1))
1168+
if (nla_put_u8(skb, FRA_L3MDEV, 1))
11691169
goto nla_put_failure;
11701170

11711171
if (nla_put_u32(skb, FRA_PRIORITY, FIB_RULE_PREF))

include/linux/stmmac.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ struct stmmac_axi {
126126

127127
struct stmmac_rxq_cfg {
128128
u8 mode_to_use;
129-
u8 chan;
129+
u32 chan;
130130
u8 pkt_route;
131131
bool use_prio;
132132
u32 prio;
133133
};
134134

135135
struct stmmac_txq_cfg {
136-
u8 weight;
136+
u32 weight;
137137
u8 mode_to_use;
138138
/* Credit Base Shaper parameters */
139139
u32 send_slope;
@@ -168,8 +168,8 @@ struct plat_stmmacenet_data {
168168
int unicast_filter_entries;
169169
int tx_fifo_size;
170170
int rx_fifo_size;
171-
u8 rx_queues_to_use;
172-
u8 tx_queues_to_use;
171+
u32 rx_queues_to_use;
172+
u32 tx_queues_to_use;
173173
u8 rx_sched_algorithm;
174174
u8 tx_sched_algorithm;
175175
struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];

include/net/act_api.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
struct tcf_idrinfo {
1515
spinlock_t lock;
1616
struct idr action_idr;
17+
struct net *net;
1718
};
1819

1920
struct tc_action_ops;
@@ -105,14 +106,15 @@ struct tc_action_net {
105106

106107
static inline
107108
int tc_action_net_init(struct tc_action_net *tn,
108-
const struct tc_action_ops *ops)
109+
const struct tc_action_ops *ops, struct net *net)
109110
{
110111
int err = 0;
111112

112113
tn->idrinfo = kmalloc(sizeof(*tn->idrinfo), GFP_KERNEL);
113114
if (!tn->idrinfo)
114115
return -ENOMEM;
115116
tn->ops = ops;
117+
tn->idrinfo->net = net;
116118
spin_lock_init(&tn->idrinfo->lock);
117119
idr_init(&tn->idrinfo->action_idr);
118120
return err;
@@ -123,7 +125,9 @@ void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
123125

124126
static inline void tc_action_net_exit(struct tc_action_net *tn)
125127
{
128+
rtnl_lock();
126129
tcf_idrinfo_destroy(tn->ops, tn->idrinfo);
130+
rtnl_unlock();
127131
kfree(tn->idrinfo);
128132
}
129133

net/ipv4/fib_semantics.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,19 +1365,21 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
13651365
nla_put_in_addr(skb, RTA_PREFSRC, fi->fib_prefsrc))
13661366
goto nla_put_failure;
13671367
if (fi->fib_nhs == 1) {
1368-
struct in_device *in_dev;
1369-
13701368
if (fi->fib_nh->nh_gw &&
13711369
nla_put_in_addr(skb, RTA_GATEWAY, fi->fib_nh->nh_gw))
13721370
goto nla_put_failure;
13731371
if (fi->fib_nh->nh_oif &&
13741372
nla_put_u32(skb, RTA_OIF, fi->fib_nh->nh_oif))
13751373
goto nla_put_failure;
13761374
if (fi->fib_nh->nh_flags & RTNH_F_LINKDOWN) {
1377-
in_dev = __in_dev_get_rtnl(fi->fib_nh->nh_dev);
1375+
struct in_device *in_dev;
1376+
1377+
rcu_read_lock();
1378+
in_dev = __in_dev_get_rcu(fi->fib_nh->nh_dev);
13781379
if (in_dev &&
13791380
IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev))
13801381
rtm->rtm_flags |= RTNH_F_DEAD;
1382+
rcu_read_unlock();
13811383
}
13821384
if (fi->fib_nh->nh_flags & RTNH_F_OFFLOAD)
13831385
rtm->rtm_flags |= RTNH_F_OFFLOAD;
@@ -1400,18 +1402,20 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
14001402
goto nla_put_failure;
14011403

14021404
for_nexthops(fi) {
1403-
struct in_device *in_dev;
1404-
14051405
rtnh = nla_reserve_nohdr(skb, sizeof(*rtnh));
14061406
if (!rtnh)
14071407
goto nla_put_failure;
14081408

14091409
rtnh->rtnh_flags = nh->nh_flags & 0xFF;
14101410
if (nh->nh_flags & RTNH_F_LINKDOWN) {
1411-
in_dev = __in_dev_get_rtnl(nh->nh_dev);
1411+
struct in_device *in_dev;
1412+
1413+
rcu_read_lock();
1414+
in_dev = __in_dev_get_rcu(nh->nh_dev);
14121415
if (in_dev &&
14131416
IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev))
14141417
rtnh->rtnh_flags |= RTNH_F_DEAD;
1418+
rcu_read_unlock();
14151419
}
14161420
rtnh->rtnh_hops = nh->nh_weight - 1;
14171421
rtnh->rtnh_ifindex = nh->nh_oif;

net/ipv4/netfilter/nf_reject_ipv4.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ void nf_send_reset(struct net *net, struct sk_buff *oldskb, int hook)
132132
if (ip_route_me_harder(net, nskb, RTN_UNSPEC))
133133
goto free_nskb;
134134

135+
niph = ip_hdr(nskb);
136+
135137
/* "Never happens" */
136138
if (nskb->len > dst_mtu(skb_dst(nskb)))
137139
goto free_nskb;

net/ipv4/tcp_nv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static void tcpnv_acked(struct sock *sk, const struct ack_sample *sample)
252252

253253
/* rate in 100's bits per second */
254254
rate64 = ((u64)sample->in_flight) * 8000000;
255-
rate = (u32)div64_u64(rate64, (u64)(avg_rtt * 100));
255+
rate = (u32)div64_u64(rate64, (u64)(avg_rtt ?: 1) * 100);
256256

257257
/* Remember the maximum rate seen during this RTT
258258
* Note: It may be more than one RTT. This function should be

net/ipv4/tcp_output.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,13 +3180,8 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
31803180
th->source = htons(ireq->ir_num);
31813181
th->dest = ireq->ir_rmt_port;
31823182
skb->mark = ireq->ir_mark;
3183-
/* Setting of flags are superfluous here for callers (and ECE is
3184-
* not even correctly set)
3185-
*/
3186-
tcp_init_nondata_skb(skb, tcp_rsk(req)->snt_isn,
3187-
TCPHDR_SYN | TCPHDR_ACK);
3188-
3189-
th->seq = htonl(TCP_SKB_CB(skb)->seq);
3183+
skb->ip_summed = CHECKSUM_PARTIAL;
3184+
th->seq = htonl(tcp_rsk(req)->snt_isn);
31903185
/* XXX data is queued and acked as is. No buffer/window check */
31913186
th->ack_seq = htonl(tcp_rsk(req)->rcv_nxt);
31923187

net/netfilter/nft_set_hash.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ nft_hash_select_ops(const struct nft_ctx *ctx, const struct nft_set_desc *desc,
643643
{
644644
if (desc->size) {
645645
switch (desc->klen) {
646-
case 2:
647646
case 4:
648647
return &nft_hash_fast_ops;
649648
default:

0 commit comments

Comments
 (0)