Skip to content

Commit 7e703ec

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: "Things seem to be settling down as far as networking is concerned, let's hope this trend continues... 1) Add iov_iter_revert() and use it to fix the behavior of skb_copy_datagram_msg() et al., from Al Viro. 2) Fix the protocol used in the synthetic SKB we cons up for the purposes of doing a simulated route lookup for RTM_GETROUTE requests. From Florian Larysch. 3) Don't add noop_qdisc to the per-device qdisc hashes, from Cong Wang. 4) Don't call netdev_change_features with the team lock held, from Xin Long. 5) Revert TCP F-RTO extension to catch more spurious timeouts because it interacts very badly with some middle-boxes. From Yuchung Cheng. 6) Fix the loss of error values in l2tp {s,g}etsockopt calls, from Guillaume Nault. 7) ctnetlink uses bit positions where it should be using bit masks, fix from Liping Zhang. 8) Missing RCU locking in netfilter helper code, from Gao Feng. 9) Avoid double frees and use-after-frees in tcp_disconnect(), from Eric Dumazet. 10) Don't do a changelink before we register the netdevice in bridging, from Ido Schimmel. 11) Lock the ipv6 device address list properly, from Rabin Vincent" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (29 commits) netfilter: ipt_CLUSTERIP: Fix wrong conntrack netns refcnt usage netfilter: nft_hash: do not dump the auto generated seed drivers: net: usb: qmi_wwan: add QMI_QUIRK_SET_DTR for Telit PID 0x1201 ipv6: Fix idev->addr_list corruption net: xdp: don't export dev_change_xdp_fd() bridge: netlink: register netdevice before executing changelink bridge: implement missing ndo_uninit() bpf: reference may_access_skb() from __bpf_prog_run() tcp: clear saved_syn in tcp_disconnect() netfilter: nf_ct_expect: use proper RCU list traversal/update APIs netfilter: ctnetlink: skip dumping expect when nfct_help(ct) is NULL netfilter: make it safer during the inet6_dev->addr_list traversal netfilter: ctnetlink: make it safer when checking the ct helper name netfilter: helper: Add the rcu lock when call __nf_conntrack_helper_find netfilter: ctnetlink: using bit to represent the ct event netfilter: xt_TCPMSS: add more sanity tests on tcph->doff net: tcp: Increase TCP_MIB_OUTRSTS even though fail to alloc skb l2tp: don't mask errors in pppol2tp_getsockopt() l2tp: don't mask errors in pppol2tp_setsockopt() tcp: restrict F-RTO to work-around broken middle-boxes ...
2 parents 9117439 + f4c13c8 commit 7e703ec

File tree

31 files changed

+238
-91
lines changed

31 files changed

+238
-91
lines changed

drivers/net/can/ifi_canfd/ifi_canfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota)
557557
int work_done = 0;
558558

559559
u32 stcmd = readl(priv->base + IFI_CANFD_STCMD);
560-
u32 rxstcmd = readl(priv->base + IFI_CANFD_STCMD);
560+
u32 rxstcmd = readl(priv->base + IFI_CANFD_RXSTCMD);
561561
u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR);
562562

563563
/* Handle bus state changes */

drivers/net/can/rcar/rcar_can.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,7 @@ static int rcar_can_probe(struct platform_device *pdev)
826826

827827
devm_can_led_init(ndev);
828828

829-
dev_info(&pdev->dev, "device registered (regs @ %p, IRQ%d)\n",
830-
priv->regs, ndev->irq);
829+
dev_info(&pdev->dev, "device registered (IRQ%d)\n", ndev->irq);
831830

832831
return 0;
833832
fail_candev:

drivers/net/team/team.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ static void team_port_disable(struct team *team,
990990
#define TEAM_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \
991991
NETIF_F_RXCSUM | NETIF_F_ALL_TSO)
992992

993-
static void ___team_compute_features(struct team *team)
993+
static void __team_compute_features(struct team *team)
994994
{
995995
struct team_port *port;
996996
u32 vlan_features = TEAM_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL;
@@ -1023,16 +1023,10 @@ static void ___team_compute_features(struct team *team)
10231023
team->dev->priv_flags |= IFF_XMIT_DST_RELEASE;
10241024
}
10251025

1026-
static void __team_compute_features(struct team *team)
1027-
{
1028-
___team_compute_features(team);
1029-
netdev_change_features(team->dev);
1030-
}
1031-
10321026
static void team_compute_features(struct team *team)
10331027
{
10341028
mutex_lock(&team->lock);
1035-
___team_compute_features(team);
1029+
__team_compute_features(team);
10361030
mutex_unlock(&team->lock);
10371031
netdev_change_features(team->dev);
10381032
}
@@ -1641,6 +1635,7 @@ static void team_uninit(struct net_device *dev)
16411635
team_notify_peers_fini(team);
16421636
team_queue_override_fini(team);
16431637
mutex_unlock(&team->lock);
1638+
netdev_change_features(dev);
16441639
}
16451640

16461641
static void team_destructor(struct net_device *dev)
@@ -1928,6 +1923,10 @@ static int team_add_slave(struct net_device *dev, struct net_device *port_dev)
19281923
mutex_lock(&team->lock);
19291924
err = team_port_add(team, port_dev);
19301925
mutex_unlock(&team->lock);
1926+
1927+
if (!err)
1928+
netdev_change_features(dev);
1929+
19311930
return err;
19321931
}
19331932

@@ -1939,6 +1938,10 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev)
19391938
mutex_lock(&team->lock);
19401939
err = team_port_del(team, port_dev);
19411940
mutex_unlock(&team->lock);
1941+
1942+
if (!err)
1943+
netdev_change_features(dev);
1944+
19421945
return err;
19431946
}
19441947

drivers/net/usb/qmi_wwan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ static const struct usb_device_id products[] = {
908908
{QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
909909
{QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */
910910
{QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
911-
{QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */
911+
{QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */
912912
{QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */
913913
{QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */
914914
{QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */

drivers/net/usb/usbnet.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
19291929
" value=0x%04x index=0x%04x size=%d\n",
19301930
cmd, reqtype, value, index, size);
19311931

1932-
if (data) {
1932+
if (size) {
19331933
buf = kmalloc(size, GFP_KERNEL);
19341934
if (!buf)
19351935
goto out;
@@ -1938,8 +1938,13 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
19381938
err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
19391939
cmd, reqtype, value, index, buf, size,
19401940
USB_CTRL_GET_TIMEOUT);
1941-
if (err > 0 && err <= size)
1942-
memcpy(data, buf, err);
1941+
if (err > 0 && err <= size) {
1942+
if (data)
1943+
memcpy(data, buf, err);
1944+
else
1945+
netdev_dbg(dev->net,
1946+
"Huh? Data requested but thrown away.\n");
1947+
}
19431948
kfree(buf);
19441949
out:
19451950
return err;
@@ -1960,7 +1965,13 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
19601965
buf = kmemdup(data, size, GFP_KERNEL);
19611966
if (!buf)
19621967
goto out;
1963-
}
1968+
} else {
1969+
if (size) {
1970+
WARN_ON_ONCE(1);
1971+
err = -EINVAL;
1972+
goto out;
1973+
}
1974+
}
19641975

19651976
err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
19661977
cmd, reqtype, value, index, buf, size,

include/linux/uio.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ struct iov_iter {
3939
};
4040
union {
4141
unsigned long nr_segs;
42-
int idx;
42+
struct {
43+
int idx;
44+
int start_idx;
45+
};
4346
};
4447
};
4548

@@ -81,6 +84,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
8184
size_t iov_iter_copy_from_user_atomic(struct page *page,
8285
struct iov_iter *i, unsigned long offset, size_t bytes);
8386
void iov_iter_advance(struct iov_iter *i, size_t bytes);
87+
void iov_iter_revert(struct iov_iter *i, size_t bytes);
8488
int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes);
8589
size_t iov_iter_single_seg_count(const struct iov_iter *i);
8690
size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,

kernel/bpf/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,12 +1162,12 @@ static unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn)
11621162
LD_ABS_W: /* BPF_R0 = ntohl(*(u32 *) (skb->data + imm32)) */
11631163
off = IMM;
11641164
load_word:
1165-
/* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are
1166-
* only appearing in the programs where ctx ==
1167-
* skb. All programs keep 'ctx' in regs[BPF_REG_CTX]
1168-
* == BPF_R6, bpf_convert_filter() saves it in BPF_R6,
1169-
* internal BPF verifier will check that BPF_R6 ==
1170-
* ctx.
1165+
/* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are only
1166+
* appearing in the programs where ctx == skb
1167+
* (see may_access_skb() in the verifier). All programs
1168+
* keep 'ctx' in regs[BPF_REG_CTX] == BPF_R6,
1169+
* bpf_convert_filter() saves it in BPF_R6, internal BPF
1170+
* verifier will check that BPF_R6 == ctx.
11711171
*
11721172
* BPF_ABS and BPF_IND are wrappers of function calls,
11731173
* so they scratch BPF_R1-BPF_R5 registers, preserve

lib/iov_iter.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,68 @@ void iov_iter_advance(struct iov_iter *i, size_t size)
786786
}
787787
EXPORT_SYMBOL(iov_iter_advance);
788788

789+
void iov_iter_revert(struct iov_iter *i, size_t unroll)
790+
{
791+
if (!unroll)
792+
return;
793+
i->count += unroll;
794+
if (unlikely(i->type & ITER_PIPE)) {
795+
struct pipe_inode_info *pipe = i->pipe;
796+
int idx = i->idx;
797+
size_t off = i->iov_offset;
798+
while (1) {
799+
size_t n = off - pipe->bufs[idx].offset;
800+
if (unroll < n) {
801+
off -= (n - unroll);
802+
break;
803+
}
804+
unroll -= n;
805+
if (!unroll && idx == i->start_idx) {
806+
off = 0;
807+
break;
808+
}
809+
if (!idx--)
810+
idx = pipe->buffers - 1;
811+
off = pipe->bufs[idx].offset + pipe->bufs[idx].len;
812+
}
813+
i->iov_offset = off;
814+
i->idx = idx;
815+
pipe_truncate(i);
816+
return;
817+
}
818+
if (unroll <= i->iov_offset) {
819+
i->iov_offset -= unroll;
820+
return;
821+
}
822+
unroll -= i->iov_offset;
823+
if (i->type & ITER_BVEC) {
824+
const struct bio_vec *bvec = i->bvec;
825+
while (1) {
826+
size_t n = (--bvec)->bv_len;
827+
i->nr_segs++;
828+
if (unroll <= n) {
829+
i->bvec = bvec;
830+
i->iov_offset = n - unroll;
831+
return;
832+
}
833+
unroll -= n;
834+
}
835+
} else { /* same logics for iovec and kvec */
836+
const struct iovec *iov = i->iov;
837+
while (1) {
838+
size_t n = (--iov)->iov_len;
839+
i->nr_segs++;
840+
if (unroll <= n) {
841+
i->iov = iov;
842+
i->iov_offset = n - unroll;
843+
return;
844+
}
845+
unroll -= n;
846+
}
847+
}
848+
}
849+
EXPORT_SYMBOL(iov_iter_revert);
850+
789851
/*
790852
* Return the count of just the current iov_iter segment.
791853
*/
@@ -839,6 +901,7 @@ void iov_iter_pipe(struct iov_iter *i, int direction,
839901
i->idx = (pipe->curbuf + pipe->nrbufs) & (pipe->buffers - 1);
840902
i->iov_offset = 0;
841903
i->count = count;
904+
i->start_idx = i->idx;
842905
}
843906
EXPORT_SYMBOL(iov_iter_pipe);
844907

net/bridge/br_device.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ static int br_dev_init(struct net_device *dev)
119119
return err;
120120
}
121121

122+
static void br_dev_uninit(struct net_device *dev)
123+
{
124+
struct net_bridge *br = netdev_priv(dev);
125+
126+
br_multicast_uninit_stats(br);
127+
br_vlan_flush(br);
128+
free_percpu(br->stats);
129+
}
130+
122131
static int br_dev_open(struct net_device *dev)
123132
{
124133
struct net_bridge *br = netdev_priv(dev);
@@ -332,6 +341,7 @@ static const struct net_device_ops br_netdev_ops = {
332341
.ndo_open = br_dev_open,
333342
.ndo_stop = br_dev_stop,
334343
.ndo_init = br_dev_init,
344+
.ndo_uninit = br_dev_uninit,
335345
.ndo_start_xmit = br_dev_xmit,
336346
.ndo_get_stats64 = br_get_stats64,
337347
.ndo_set_mac_address = br_set_mac_address,
@@ -356,14 +366,6 @@ static const struct net_device_ops br_netdev_ops = {
356366
.ndo_features_check = passthru_features_check,
357367
};
358368

359-
static void br_dev_free(struct net_device *dev)
360-
{
361-
struct net_bridge *br = netdev_priv(dev);
362-
363-
free_percpu(br->stats);
364-
free_netdev(dev);
365-
}
366-
367369
static struct device_type br_type = {
368370
.name = "bridge",
369371
};
@@ -376,7 +378,7 @@ void br_dev_setup(struct net_device *dev)
376378
ether_setup(dev);
377379

378380
dev->netdev_ops = &br_netdev_ops;
379-
dev->destructor = br_dev_free;
381+
dev->destructor = free_netdev;
380382
dev->ethtool_ops = &br_ethtool_ops;
381383
SET_NETDEV_DEVTYPE(dev, &br_type);
382384
dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE;

net/bridge/br_if.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)
311311

312312
br_fdb_delete_by_port(br, NULL, 0, 1);
313313

314-
br_vlan_flush(br);
315314
br_multicast_dev_del(br);
316315
cancel_delayed_work_sync(&br->gc_work);
317316

0 commit comments

Comments
 (0)