aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-12 14:09:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-12 14:09:05 -0400
commit5d1365940a68dd57b031b6e3c07d7d451cd69daf (patch)
tree1d94923756eb792f54cfde22495980c5d3977b0c /net
parent67a7a8fff8aef69579cd4426dca1ccb865b93167 (diff)
parent0c84cee8f131a090f77f5a3dea5d6a7bd99c00db (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) In ip_gre tunnel, handle the conflict between TUNNEL_{SEQ,CSUM} and GSO/LLTX properly. From Sabrina Dubroca. 2) Stop properly on error in lan78xx_read_otp(), from Phil Elwell. 3) Don't uncompress in slip before rstate is initialized, from Tejaswi Tanikella. 4) When using 1.x firmware on aquantia, issue a deinit before we hardware reset the chip, otherwise we break dirty wake WOL. From Igor Russkikh. 5) Correct log check in vhost_vq_access_ok(), from Stefan Hajnoczi. 6) Fix ethtool -x crashes in bnxt_en, from Michael Chan. 7) Fix races in l2tp tunnel creation and duplicate tunnel detection, from Guillaume Nault. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (22 commits) l2tp: fix race in duplicate tunnel detection l2tp: fix races in tunnel creation tun: send netlink notification when the device is modified tun: set the flags before registering the netdevice lan78xx: Don't reset the interface on open bnxt_en: Fix NULL pointer dereference at bnxt_free_irq(). bnxt_en: Need to include RDMA rings in bnxt_check_rings(). bnxt_en: Support max-mtu with VF-reps bnxt_en: Ignore src port field in decap filter nodes bnxt_en: do not allow wildcard matches for L2 flows bnxt_en: Fix ethtool -x crash when device is down. vhost: return bool from *_access_ok() functions vhost: fix vhost_vq_access_ok() log check vhost: Fix vhost_copy_to_user() net: aquantia: oops when shutdown on already stopped device net: aquantia: Regression on reset with 1.x firmware cdc_ether: flag the Cinterion AHS8 modem by gemalto as WWAN slip: Check if rstate is initialized before uncompressing lan78xx: Avoid spurious kevent 4 "error" lan78xx: Correctly indicate invalid OTP ...
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_gre.c6
-rw-r--r--net/l2tp/l2tp_core.c225
-rw-r--r--net/l2tp/l2tp_core.h4
-rw-r--r--net/l2tp/l2tp_netlink.c22
-rw-r--r--net/l2tp/l2tp_ppp.c9
-rw-r--r--net/rds/send.c15
6 files changed, 139 insertions, 142 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index a8772a978224..9c169bb2444d 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -781,8 +781,14 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu)
781 tunnel->encap.type == TUNNEL_ENCAP_NONE) { 781 tunnel->encap.type == TUNNEL_ENCAP_NONE) {
782 dev->features |= NETIF_F_GSO_SOFTWARE; 782 dev->features |= NETIF_F_GSO_SOFTWARE;
783 dev->hw_features |= NETIF_F_GSO_SOFTWARE; 783 dev->hw_features |= NETIF_F_GSO_SOFTWARE;
784 } else {
785 dev->features &= ~NETIF_F_GSO_SOFTWARE;
786 dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
784 } 787 }
785 dev->features |= NETIF_F_LLTX; 788 dev->features |= NETIF_F_LLTX;
789 } else {
790 dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
791 dev->features &= ~(NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE);
786 } 792 }
787} 793}
788 794
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 14b67dfacc4b..0fbd3ee26165 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -335,26 +335,6 @@ err_tlock:
335} 335}
336EXPORT_SYMBOL_GPL(l2tp_session_register); 336EXPORT_SYMBOL_GPL(l2tp_session_register);
337 337
338/* Lookup a tunnel by id
339 */
340struct l2tp_tunnel *l2tp_tunnel_find(const struct net *net, u32 tunnel_id)
341{
342 struct l2tp_tunnel *tunnel;
343 struct l2tp_net *pn = l2tp_pernet(net);
344
345 rcu_read_lock_bh();
346 list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
347 if (tunnel->tunnel_id == tunnel_id) {
348 rcu_read_unlock_bh();
349 return tunnel;
350 }
351 }
352 rcu_read_unlock_bh();
353
354 return NULL;
355}
356EXPORT_SYMBOL_GPL(l2tp_tunnel_find);
357
358struct l2tp_tunnel *l2tp_tunnel_find_nth(const struct net *net, int nth) 338struct l2tp_tunnel *l2tp_tunnel_find_nth(const struct net *net, int nth)
359{ 339{
360 struct l2tp_net *pn = l2tp_pernet(net); 340 struct l2tp_net *pn = l2tp_pernet(net);
@@ -1436,74 +1416,11 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
1436{ 1416{
1437 struct l2tp_tunnel *tunnel = NULL; 1417 struct l2tp_tunnel *tunnel = NULL;
1438 int err; 1418 int err;
1439 struct socket *sock = NULL;
1440 struct sock *sk = NULL;
1441 struct l2tp_net *pn;
1442 enum l2tp_encap_type encap = L2TP_ENCAPTYPE_UDP; 1419 enum l2tp_encap_type encap = L2TP_ENCAPTYPE_UDP;
1443 1420
1444 /* Get the tunnel socket from the fd, which was opened by
1445 * the userspace L2TP daemon. If not specified, create a
1446 * kernel socket.
1447 */
1448 if (fd < 0) {
1449 err = l2tp_tunnel_sock_create(net, tunnel_id, peer_tunnel_id,
1450 cfg, &sock);
1451 if (err < 0)
1452 goto err;
1453 } else {
1454 sock = sockfd_lookup(fd, &err);
1455 if (!sock) {
1456 pr_err("tunl %u: sockfd_lookup(fd=%d) returned %d\n",
1457 tunnel_id, fd, err);
1458 err = -EBADF;
1459 goto err;
1460 }
1461
1462 /* Reject namespace mismatches */
1463 if (!net_eq(sock_net(sock->sk), net)) {
1464 pr_err("tunl %u: netns mismatch\n", tunnel_id);
1465 err = -EINVAL;
1466 goto err;
1467 }
1468 }
1469
1470 sk = sock->sk;
1471
1472 if (cfg != NULL) 1421 if (cfg != NULL)
1473 encap = cfg->encap; 1422 encap = cfg->encap;
1474 1423
1475 /* Quick sanity checks */
1476 err = -EPROTONOSUPPORT;
1477 if (sk->sk_type != SOCK_DGRAM) {
1478 pr_debug("tunl %hu: fd %d wrong socket type\n",
1479 tunnel_id, fd);
1480 goto err;
1481 }
1482 switch (encap) {
1483 case L2TP_ENCAPTYPE_UDP:
1484 if (sk->sk_protocol != IPPROTO_UDP) {
1485 pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
1486 tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP);
1487 goto err;
1488 }
1489 break;
1490 case L2TP_ENCAPTYPE_IP:
1491 if (sk->sk_protocol != IPPROTO_L2TP) {
1492 pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
1493 tunnel_id, fd, sk->sk_protocol, IPPROTO_L2TP);
1494 goto err;
1495 }
1496 break;
1497 }
1498
1499 /* Check if this socket has already been prepped */
1500 tunnel = l2tp_tunnel(sk);
1501 if (tunnel != NULL) {
1502 /* This socket has already been prepped */
1503 err = -EBUSY;
1504 goto err;
1505 }
1506
1507 tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL); 1424 tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL);
1508 if (tunnel == NULL) { 1425 if (tunnel == NULL) {
1509 err = -ENOMEM; 1426 err = -ENOMEM;
@@ -1520,72 +1437,126 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
1520 rwlock_init(&tunnel->hlist_lock); 1437 rwlock_init(&tunnel->hlist_lock);
1521 tunnel->acpt_newsess = true; 1438 tunnel->acpt_newsess = true;
1522 1439
1523 /* The net we belong to */
1524 tunnel->l2tp_net = net;
1525 pn = l2tp_pernet(net);
1526
1527 if (cfg != NULL) 1440 if (cfg != NULL)
1528 tunnel->debug = cfg->debug; 1441 tunnel->debug = cfg->debug;
1529 1442
1530 /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
1531 tunnel->encap = encap; 1443 tunnel->encap = encap;
1532 if (encap == L2TP_ENCAPTYPE_UDP) {
1533 struct udp_tunnel_sock_cfg udp_cfg = { };
1534
1535 udp_cfg.sk_user_data = tunnel;
1536 udp_cfg.encap_type = UDP_ENCAP_L2TPINUDP;
1537 udp_cfg.encap_rcv = l2tp_udp_encap_recv;
1538 udp_cfg.encap_destroy = l2tp_udp_encap_destroy;
1539
1540 setup_udp_tunnel_sock(net, sock, &udp_cfg);
1541 } else {
1542 sk->sk_user_data = tunnel;
1543 }
1544 1444
1545 /* Bump the reference count. The tunnel context is deleted
1546 * only when this drops to zero. A reference is also held on
1547 * the tunnel socket to ensure that it is not released while
1548 * the tunnel is extant. Must be done before sk_destruct is
1549 * set.
1550 */
1551 refcount_set(&tunnel->ref_count, 1); 1445 refcount_set(&tunnel->ref_count, 1);
1552 sock_hold(sk);
1553 tunnel->sock = sk;
1554 tunnel->fd = fd; 1446 tunnel->fd = fd;
1555 1447
1556 /* Hook on the tunnel socket destructor so that we can cleanup
1557 * if the tunnel socket goes away.
1558 */
1559 tunnel->old_sk_destruct = sk->sk_destruct;
1560 sk->sk_destruct = &l2tp_tunnel_destruct;
1561 lockdep_set_class_and_name(&sk->sk_lock.slock, &l2tp_socket_class, "l2tp_sock");
1562
1563 sk->sk_allocation = GFP_ATOMIC;
1564
1565 /* Init delete workqueue struct */ 1448 /* Init delete workqueue struct */
1566 INIT_WORK(&tunnel->del_work, l2tp_tunnel_del_work); 1449 INIT_WORK(&tunnel->del_work, l2tp_tunnel_del_work);
1567 1450
1568 /* Add tunnel to our list */
1569 INIT_LIST_HEAD(&tunnel->list); 1451 INIT_LIST_HEAD(&tunnel->list);
1570 spin_lock_bh(&pn->l2tp_tunnel_list_lock);
1571 list_add_rcu(&tunnel->list, &pn->l2tp_tunnel_list);
1572 spin_unlock_bh(&pn->l2tp_tunnel_list_lock);
1573 1452
1574 err = 0; 1453 err = 0;
1575err: 1454err:
1576 if (tunnelp) 1455 if (tunnelp)
1577 *tunnelp = tunnel; 1456 *tunnelp = tunnel;
1578 1457
1579 /* If tunnel's socket was created by the kernel, it doesn't
1580 * have a file.
1581 */
1582 if (sock && sock->file)
1583 sockfd_put(sock);
1584
1585 return err; 1458 return err;
1586} 1459}
1587EXPORT_SYMBOL_GPL(l2tp_tunnel_create); 1460EXPORT_SYMBOL_GPL(l2tp_tunnel_create);
1588 1461
1462static int l2tp_validate_socket(const struct sock *sk, const struct net *net,
1463 enum l2tp_encap_type encap)
1464{
1465 if (!net_eq(sock_net(sk), net))
1466 return -EINVAL;
1467
1468 if (sk->sk_type != SOCK_DGRAM)
1469 return -EPROTONOSUPPORT;
1470
1471 if ((encap == L2TP_ENCAPTYPE_UDP && sk->sk_protocol != IPPROTO_UDP) ||
1472 (encap == L2TP_ENCAPTYPE_IP && sk->sk_protocol != IPPROTO_L2TP))
1473 return -EPROTONOSUPPORT;
1474
1475 if (sk->sk_user_data)
1476 return -EBUSY;
1477
1478 return 0;
1479}
1480
1481int l2tp_tunnel_register(struct l2tp_tunnel *tunnel, struct net *net,
1482 struct l2tp_tunnel_cfg *cfg)
1483{
1484 struct l2tp_tunnel *tunnel_walk;
1485 struct l2tp_net *pn;
1486 struct socket *sock;
1487 struct sock *sk;
1488 int ret;
1489
1490 if (tunnel->fd < 0) {
1491 ret = l2tp_tunnel_sock_create(net, tunnel->tunnel_id,
1492 tunnel->peer_tunnel_id, cfg,
1493 &sock);
1494 if (ret < 0)
1495 goto err;
1496 } else {
1497 sock = sockfd_lookup(tunnel->fd, &ret);
1498 if (!sock)
1499 goto err;
1500
1501 ret = l2tp_validate_socket(sock->sk, net, tunnel->encap);
1502 if (ret < 0)
1503 goto err_sock;
1504 }
1505
1506 sk = sock->sk;
1507
1508 sock_hold(sk);
1509 tunnel->sock = sk;
1510 tunnel->l2tp_net = net;
1511
1512 pn = l2tp_pernet(net);
1513
1514 spin_lock_bh(&pn->l2tp_tunnel_list_lock);
1515 list_for_each_entry(tunnel_walk, &pn->l2tp_tunnel_list, list) {
1516 if (tunnel_walk->tunnel_id == tunnel->tunnel_id) {
1517 spin_unlock_bh(&pn->l2tp_tunnel_list_lock);
1518
1519 ret = -EEXIST;
1520 goto err_sock;
1521 }
1522 }
1523 list_add_rcu(&tunnel->list, &pn->l2tp_tunnel_list);
1524 spin_unlock_bh(&pn->l2tp_tunnel_list_lock);
1525
1526 if (tunnel->encap == L2TP_ENCAPTYPE_UDP) {
1527 struct udp_tunnel_sock_cfg udp_cfg = {
1528 .sk_user_data = tunnel,
1529 .encap_type = UDP_ENCAP_L2TPINUDP,
1530 .encap_rcv = l2tp_udp_encap_recv,
1531 .encap_destroy = l2tp_udp_encap_destroy,
1532 };
1533
1534 setup_udp_tunnel_sock(net, sock, &udp_cfg);
1535 } else {
1536 sk->sk_user_data = tunnel;
1537 }
1538
1539 tunnel->old_sk_destruct = sk->sk_destruct;
1540 sk->sk_destruct = &l2tp_tunnel_destruct;
1541 lockdep_set_class_and_name(&sk->sk_lock.slock, &l2tp_socket_class,
1542 "l2tp_sock");
1543 sk->sk_allocation = GFP_ATOMIC;
1544
1545 if (tunnel->fd >= 0)
1546 sockfd_put(sock);
1547
1548 return 0;
1549
1550err_sock:
1551 if (tunnel->fd < 0)
1552 sock_release(sock);
1553 else
1554 sockfd_put(sock);
1555err:
1556 return ret;
1557}
1558EXPORT_SYMBOL_GPL(l2tp_tunnel_register);
1559
1589/* This function is used by the netlink TUNNEL_DELETE command. 1560/* This function is used by the netlink TUNNEL_DELETE command.
1590 */ 1561 */
1591void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel) 1562void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
index 2718d0b284d0..ba33cbec71eb 100644
--- a/net/l2tp/l2tp_core.h
+++ b/net/l2tp/l2tp_core.h
@@ -220,12 +220,14 @@ struct l2tp_session *l2tp_session_get(const struct net *net,
220struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth); 220struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth);
221struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net, 221struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net,
222 const char *ifname); 222 const char *ifname);
223struct l2tp_tunnel *l2tp_tunnel_find(const struct net *net, u32 tunnel_id);
224struct l2tp_tunnel *l2tp_tunnel_find_nth(const struct net *net, int nth); 223struct l2tp_tunnel *l2tp_tunnel_find_nth(const struct net *net, int nth);
225 224
226int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, 225int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id,
227 u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg, 226 u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg,
228 struct l2tp_tunnel **tunnelp); 227 struct l2tp_tunnel **tunnelp);
228int l2tp_tunnel_register(struct l2tp_tunnel *tunnel, struct net *net,
229 struct l2tp_tunnel_cfg *cfg);
230
229void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel); 231void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel);
230void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel); 232void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel);
231struct l2tp_session *l2tp_session_create(int priv_size, 233struct l2tp_session *l2tp_session_create(int priv_size,
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index e7ea9c4b89ff..b05dbd9ffcb2 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -236,12 +236,6 @@ static int l2tp_nl_cmd_tunnel_create(struct sk_buff *skb, struct genl_info *info
236 if (info->attrs[L2TP_ATTR_DEBUG]) 236 if (info->attrs[L2TP_ATTR_DEBUG])
237 cfg.debug = nla_get_u32(info->attrs[L2TP_ATTR_DEBUG]); 237 cfg.debug = nla_get_u32(info->attrs[L2TP_ATTR_DEBUG]);
238 238
239 tunnel = l2tp_tunnel_find(net, tunnel_id);
240 if (tunnel != NULL) {
241 ret = -EEXIST;
242 goto out;
243 }
244
245 ret = -EINVAL; 239 ret = -EINVAL;
246 switch (cfg.encap) { 240 switch (cfg.encap) {
247 case L2TP_ENCAPTYPE_UDP: 241 case L2TP_ENCAPTYPE_UDP:
@@ -251,9 +245,19 @@ static int l2tp_nl_cmd_tunnel_create(struct sk_buff *skb, struct genl_info *info
251 break; 245 break;
252 } 246 }
253 247
254 if (ret >= 0) 248 if (ret < 0)
255 ret = l2tp_tunnel_notify(&l2tp_nl_family, info, 249 goto out;
256 tunnel, L2TP_CMD_TUNNEL_CREATE); 250
251 l2tp_tunnel_inc_refcount(tunnel);
252 ret = l2tp_tunnel_register(tunnel, net, &cfg);
253 if (ret < 0) {
254 kfree(tunnel);
255 goto out;
256 }
257 ret = l2tp_tunnel_notify(&l2tp_nl_family, info, tunnel,
258 L2TP_CMD_TUNNEL_CREATE);
259 l2tp_tunnel_dec_refcount(tunnel);
260
257out: 261out:
258 return ret; 262 return ret;
259} 263}
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index d6deca11da19..896bbca9bdaa 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -698,6 +698,15 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
698 error = l2tp_tunnel_create(sock_net(sk), fd, ver, tunnel_id, peer_tunnel_id, &tcfg, &tunnel); 698 error = l2tp_tunnel_create(sock_net(sk), fd, ver, tunnel_id, peer_tunnel_id, &tcfg, &tunnel);
699 if (error < 0) 699 if (error < 0)
700 goto end; 700 goto end;
701
702 l2tp_tunnel_inc_refcount(tunnel);
703 error = l2tp_tunnel_register(tunnel, sock_net(sk),
704 &tcfg);
705 if (error < 0) {
706 kfree(tunnel);
707 goto end;
708 }
709 drop_tunnel = true;
701 } 710 }
702 } else { 711 } else {
703 /* Error if we can't find the tunnel */ 712 /* Error if we can't find the tunnel */
diff --git a/net/rds/send.c b/net/rds/send.c
index acad04243b41..94c7f74909be 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 Oracle. All rights reserved. 2 * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -1017,10 +1017,15 @@ static int rds_send_mprds_hash(struct rds_sock *rs, struct rds_connection *conn)
1017 if (conn->c_npaths == 0 && hash != 0) { 1017 if (conn->c_npaths == 0 && hash != 0) {
1018 rds_send_ping(conn, 0); 1018 rds_send_ping(conn, 0);
1019 1019
1020 if (conn->c_npaths == 0) { 1020 /* The underlying connection is not up yet. Need to wait
1021 wait_event_interruptible(conn->c_hs_waitq, 1021 * until it is up to be sure that the non-zero c_path can be
1022 (conn->c_npaths != 0)); 1022 * used. But if we are interrupted, we have to use the zero
1023 } 1023 * c_path in case the connection ends up being non-MP capable.
1024 */
1025 if (conn->c_npaths == 0)
1026 if (wait_event_interruptible(conn->c_hs_waitq,
1027 conn->c_npaths != 0))
1028 hash = 0;
1024 if (conn->c_npaths == 1) 1029 if (conn->c_npaths == 1)
1025 hash = 0; 1030 hash = 0;
1026 } 1031 }