aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-09 20:04:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-09 20:04:10 -0400
commitc18bb396d3d261ebbb4efbc05129c5d354c541e4 (patch)
tree058a1413dd34fe4e1d9a998a43d56f3358b93e36 /net
parentfd3b36d275660c905da9900b078eea341847d5e4 (diff)
parenta2ac99905f1ea8b15997a6ec39af69aa28a3653b (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) The sockmap code has to free socket memory on close if there is corked data, from John Fastabend. 2) Tunnel names coming from userspace need to be length validated. From Eric Dumazet. 3) arp_filter() has to take VRFs properly into account, from Miguel Fadon Perlines. 4) Fix oops in error path of tcf_bpf_init(), from Davide Caratti. 5) Missing idr_remove() in u32_delete_key(), from Cong Wang. 6) More syzbot stuff. Several use of uninitialized value fixes all over, from Eric Dumazet. 7) Do not leak kernel memory to userspace in sctp, also from Eric Dumazet. 8) Discard frames from unused ports in DSA, from Andrew Lunn. 9) Fix DMA mapping and reset/failover problems in ibmvnic, from Thomas Falcon. 10) Do not access dp83640 PHY registers prematurely after reset, from Esben Haabendal. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (46 commits) vhost-net: set packet weight of tx polling to 2 * vq size net: thunderx: rework mac addresses list to u64 array inetpeer: fix uninit-value in inet_getpeer dp83640: Ensure against premature access to PHY registers after reset devlink: convert occ_get op to separate registration ARM: dts: ls1021a: Specify TBIPA register address net/fsl_pq_mdio: Allow explicit speficition of TBIPA address ibmvnic: Do not reset CRQ for Mobility driver resets ibmvnic: Fix failover case for non-redundant configuration ibmvnic: Fix reset scheduler error handling ibmvnic: Zero used TX descriptor counter on reset ibmvnic: Fix DMA mapping mistakes tipc: use the right skb in tipc_sk_fill_sock_diag() sctp: sctp_sockaddr_af must check minimal addr length for AF_INET6 net: dsa: Discard frames from unused ports sctp: do not leak kernel memory to user space soreuseport: initialise timewait reuseport field ipv4: fix uninit-value in ip_route_output_key_hash_rcu() dccp: initialize ireq->ir_mark net: fix uninit-value in __hw_addr_add_ex() ...
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_conn.c29
-rw-r--r--net/bluetooth/hci_event.c15
-rw-r--r--net/bluetooth/l2cap_core.c2
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/dev_addr_lists.c4
-rw-r--r--net/core/devlink.c74
-rw-r--r--net/core/skbuff.c1
-rw-r--r--net/dccp/ipv4.c1
-rw-r--r--net/dccp/ipv6.c1
-rw-r--r--net/dsa/dsa_priv.h8
-rw-r--r--net/ipv4/arp.c2
-rw-r--r--net/ipv4/inet_timewait_sock.c1
-rw-r--r--net/ipv4/inetpeer.c1
-rw-r--r--net/ipv4/ip_tunnel.c11
-rw-r--r--net/ipv4/route.c11
-rw-r--r--net/ipv6/ip6_gre.c8
-rw-r--r--net/ipv6/ip6_output.c7
-rw-r--r--net/ipv6/ip6_tunnel.c11
-rw-r--r--net/ipv6/ip6_vti.c7
-rw-r--r--net/ipv6/sit.c8
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/sched/act_bpf.c12
-rw-r--r--net/sched/cls_u32.c1
-rw-r--r--net/sctp/ipv6.c4
-rw-r--r--net/sctp/socket.c13
-rw-r--r--net/tipc/diag.c2
-rw-r--r--net/tipc/socket.c6
-rw-r--r--net/tipc/socket.h4
28 files changed, 181 insertions, 67 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index a9682534c377..45ff5dc124cc 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -749,18 +749,31 @@ static bool conn_use_rpa(struct hci_conn *conn)
749} 749}
750 750
751static void hci_req_add_le_create_conn(struct hci_request *req, 751static void hci_req_add_le_create_conn(struct hci_request *req,
752 struct hci_conn *conn) 752 struct hci_conn *conn,
753 bdaddr_t *direct_rpa)
753{ 754{
754 struct hci_cp_le_create_conn cp; 755 struct hci_cp_le_create_conn cp;
755 struct hci_dev *hdev = conn->hdev; 756 struct hci_dev *hdev = conn->hdev;
756 u8 own_addr_type; 757 u8 own_addr_type;
757 758
758 /* Update random address, but set require_privacy to false so 759 /* If direct address was provided we use it instead of current
759 * that we never connect with an non-resolvable address. 760 * address.
760 */ 761 */
761 if (hci_update_random_address(req, false, conn_use_rpa(conn), 762 if (direct_rpa) {
762 &own_addr_type)) 763 if (bacmp(&req->hdev->random_addr, direct_rpa))
763 return; 764 hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6,
765 direct_rpa);
766
767 /* direct address is always RPA */
768 own_addr_type = ADDR_LE_DEV_RANDOM;
769 } else {
770 /* Update random address, but set require_privacy to false so
771 * that we never connect with an non-resolvable address.
772 */
773 if (hci_update_random_address(req, false, conn_use_rpa(conn),
774 &own_addr_type))
775 return;
776 }
764 777
765 memset(&cp, 0, sizeof(cp)); 778 memset(&cp, 0, sizeof(cp));
766 779
@@ -825,7 +838,7 @@ static void hci_req_directed_advertising(struct hci_request *req,
825 838
826struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, 839struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
827 u8 dst_type, u8 sec_level, u16 conn_timeout, 840 u8 dst_type, u8 sec_level, u16 conn_timeout,
828 u8 role) 841 u8 role, bdaddr_t *direct_rpa)
829{ 842{
830 struct hci_conn_params *params; 843 struct hci_conn_params *params;
831 struct hci_conn *conn; 844 struct hci_conn *conn;
@@ -940,7 +953,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
940 hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); 953 hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
941 } 954 }
942 955
943 hci_req_add_le_create_conn(&req, conn); 956 hci_req_add_le_create_conn(&req, conn, direct_rpa);
944 957
945create_conn: 958create_conn:
946 err = hci_req_run(&req, create_le_conn_complete); 959 err = hci_req_run(&req, create_le_conn_complete);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index cd3bbb766c24..139707cd9d35 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -4648,7 +4648,8 @@ static void hci_le_conn_update_complete_evt(struct hci_dev *hdev,
4648/* This function requires the caller holds hdev->lock */ 4648/* This function requires the caller holds hdev->lock */
4649static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, 4649static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
4650 bdaddr_t *addr, 4650 bdaddr_t *addr,
4651 u8 addr_type, u8 adv_type) 4651 u8 addr_type, u8 adv_type,
4652 bdaddr_t *direct_rpa)
4652{ 4653{
4653 struct hci_conn *conn; 4654 struct hci_conn *conn;
4654 struct hci_conn_params *params; 4655 struct hci_conn_params *params;
@@ -4699,7 +4700,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
4699 } 4700 }
4700 4701
4701 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, 4702 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
4702 HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER); 4703 HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER,
4704 direct_rpa);
4703 if (!IS_ERR(conn)) { 4705 if (!IS_ERR(conn)) {
4704 /* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned 4706 /* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned
4705 * by higher layer that tried to connect, if no then 4707 * by higher layer that tried to connect, if no then
@@ -4808,8 +4810,13 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
4808 bdaddr_type = irk->addr_type; 4810 bdaddr_type = irk->addr_type;
4809 } 4811 }
4810 4812
4811 /* Check if we have been requested to connect to this device */ 4813 /* Check if we have been requested to connect to this device.
4812 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type); 4814 *
4815 * direct_addr is set only for directed advertising reports (it is NULL
4816 * for advertising reports) and is already verified to be RPA above.
4817 */
4818 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type,
4819 direct_addr);
4813 if (conn && type == LE_ADV_IND) { 4820 if (conn && type == LE_ADV_IND) {
4814 /* Store report for later inclusion by 4821 /* Store report for later inclusion by
4815 * mgmt_device_connected 4822 * mgmt_device_connected
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index fc6615d59165..9b7907ebfa01 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7156,7 +7156,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7156 hcon = hci_connect_le(hdev, dst, dst_type, 7156 hcon = hci_connect_le(hdev, dst, dst_type,
7157 chan->sec_level, 7157 chan->sec_level,
7158 HCI_LE_CONN_TIMEOUT, 7158 HCI_LE_CONN_TIMEOUT,
7159 HCI_ROLE_SLAVE); 7159 HCI_ROLE_SLAVE, NULL);
7160 else 7160 else
7161 hcon = hci_connect_le_scan(hdev, dst, dst_type, 7161 hcon = hci_connect_le_scan(hdev, dst, dst_type,
7162 chan->sec_level, 7162 chan->sec_level,
diff --git a/net/core/dev.c b/net/core/dev.c
index 9b04a9fd1dfd..969462ebb296 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1027,7 +1027,7 @@ bool dev_valid_name(const char *name)
1027{ 1027{
1028 if (*name == '\0') 1028 if (*name == '\0')
1029 return false; 1029 return false;
1030 if (strlen(name) >= IFNAMSIZ) 1030 if (strnlen(name, IFNAMSIZ) == IFNAMSIZ)
1031 return false; 1031 return false;
1032 if (!strcmp(name, ".") || !strcmp(name, "..")) 1032 if (!strcmp(name, ".") || !strcmp(name, ".."))
1033 return false; 1033 return false;
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index c0548d268e1a..e3e6a3e2ca22 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -57,8 +57,8 @@ static int __hw_addr_add_ex(struct netdev_hw_addr_list *list,
57 return -EINVAL; 57 return -EINVAL;
58 58
59 list_for_each_entry(ha, &list->list, list) { 59 list_for_each_entry(ha, &list->list, list) {
60 if (!memcmp(ha->addr, addr, addr_len) && 60 if (ha->type == addr_type &&
61 ha->type == addr_type) { 61 !memcmp(ha->addr, addr, addr_len)) {
62 if (global) { 62 if (global) {
63 /* check if addr is already used as global */ 63 /* check if addr is already used as global */
64 if (ha->global_use) 64 if (ha->global_use)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 9236e421bd62..ad1317376798 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -2405,6 +2405,16 @@ devlink_resource_size_params_put(struct devlink_resource *resource,
2405 return 0; 2405 return 0;
2406} 2406}
2407 2407
2408static int devlink_resource_occ_put(struct devlink_resource *resource,
2409 struct sk_buff *skb)
2410{
2411 if (!resource->occ_get)
2412 return 0;
2413 return nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_OCC,
2414 resource->occ_get(resource->occ_get_priv),
2415 DEVLINK_ATTR_PAD);
2416}
2417
2408static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb, 2418static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
2409 struct devlink_resource *resource) 2419 struct devlink_resource *resource)
2410{ 2420{
@@ -2425,11 +2435,8 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
2425 if (resource->size != resource->size_new) 2435 if (resource->size != resource->size_new)
2426 nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, 2436 nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW,
2427 resource->size_new, DEVLINK_ATTR_PAD); 2437 resource->size_new, DEVLINK_ATTR_PAD);
2428 if (resource->resource_ops && resource->resource_ops->occ_get) 2438 if (devlink_resource_occ_put(resource, skb))
2429 if (nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_OCC, 2439 goto nla_put_failure;
2430 resource->resource_ops->occ_get(devlink),
2431 DEVLINK_ATTR_PAD))
2432 goto nla_put_failure;
2433 if (devlink_resource_size_params_put(resource, skb)) 2440 if (devlink_resource_size_params_put(resource, skb))
2434 goto nla_put_failure; 2441 goto nla_put_failure;
2435 if (list_empty(&resource->resource_list)) 2442 if (list_empty(&resource->resource_list))
@@ -3162,15 +3169,13 @@ EXPORT_SYMBOL_GPL(devlink_dpipe_table_unregister);
3162 * @resource_id: resource's id 3169 * @resource_id: resource's id
3163 * @parent_reosurce_id: resource's parent id 3170 * @parent_reosurce_id: resource's parent id
3164 * @size params: size parameters 3171 * @size params: size parameters
3165 * @resource_ops: resource ops
3166 */ 3172 */
3167int devlink_resource_register(struct devlink *devlink, 3173int devlink_resource_register(struct devlink *devlink,
3168 const char *resource_name, 3174 const char *resource_name,
3169 u64 resource_size, 3175 u64 resource_size,
3170 u64 resource_id, 3176 u64 resource_id,
3171 u64 parent_resource_id, 3177 u64 parent_resource_id,
3172 const struct devlink_resource_size_params *size_params, 3178 const struct devlink_resource_size_params *size_params)
3173 const struct devlink_resource_ops *resource_ops)
3174{ 3179{
3175 struct devlink_resource *resource; 3180 struct devlink_resource *resource;
3176 struct list_head *resource_list; 3181 struct list_head *resource_list;
@@ -3213,7 +3218,6 @@ int devlink_resource_register(struct devlink *devlink,
3213 resource->size = resource_size; 3218 resource->size = resource_size;
3214 resource->size_new = resource_size; 3219 resource->size_new = resource_size;
3215 resource->id = resource_id; 3220 resource->id = resource_id;
3216 resource->resource_ops = resource_ops;
3217 resource->size_valid = true; 3221 resource->size_valid = true;
3218 memcpy(&resource->size_params, size_params, 3222 memcpy(&resource->size_params, size_params,
3219 sizeof(resource->size_params)); 3223 sizeof(resource->size_params));
@@ -3315,6 +3319,58 @@ out:
3315} 3319}
3316EXPORT_SYMBOL_GPL(devlink_dpipe_table_resource_set); 3320EXPORT_SYMBOL_GPL(devlink_dpipe_table_resource_set);
3317 3321
3322/**
3323 * devlink_resource_occ_get_register - register occupancy getter
3324 *
3325 * @devlink: devlink
3326 * @resource_id: resource id
3327 * @occ_get: occupancy getter callback
3328 * @occ_get_priv: occupancy getter callback priv
3329 */
3330void devlink_resource_occ_get_register(struct devlink *devlink,
3331 u64 resource_id,
3332 devlink_resource_occ_get_t *occ_get,
3333 void *occ_get_priv)
3334{
3335 struct devlink_resource *resource;
3336
3337 mutex_lock(&devlink->lock);
3338 resource = devlink_resource_find(devlink, NULL, resource_id);
3339 if (WARN_ON(!resource))
3340 goto out;
3341 WARN_ON(resource->occ_get);
3342
3343 resource->occ_get = occ_get;
3344 resource->occ_get_priv = occ_get_priv;
3345out:
3346 mutex_unlock(&devlink->lock);
3347}
3348EXPORT_SYMBOL_GPL(devlink_resource_occ_get_register);
3349
3350/**
3351 * devlink_resource_occ_get_unregister - unregister occupancy getter
3352 *
3353 * @devlink: devlink
3354 * @resource_id: resource id
3355 */
3356void devlink_resource_occ_get_unregister(struct devlink *devlink,
3357 u64 resource_id)
3358{
3359 struct devlink_resource *resource;
3360
3361 mutex_lock(&devlink->lock);
3362 resource = devlink_resource_find(devlink, NULL, resource_id);
3363 if (WARN_ON(!resource))
3364 goto out;
3365 WARN_ON(!resource->occ_get);
3366
3367 resource->occ_get = NULL;
3368 resource->occ_get_priv = NULL;
3369out:
3370 mutex_unlock(&devlink->lock);
3371}
3372EXPORT_SYMBOL_GPL(devlink_resource_occ_get_unregister);
3373
3318static int __init devlink_module_init(void) 3374static int __init devlink_module_init(void)
3319{ 3375{
3320 return genl_register_family(&devlink_nl_family); 3376 return genl_register_family(&devlink_nl_family);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1bca1e0fc8f7..345b51837ca8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -857,6 +857,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
857 n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len; 857 n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len;
858 n->cloned = 1; 858 n->cloned = 1;
859 n->nohdr = 0; 859 n->nohdr = 0;
860 n->peeked = 0;
860 n->destructor = NULL; 861 n->destructor = NULL;
861 C(tail); 862 C(tail);
862 C(end); 863 C(end);
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index e65fcb45c3f6..b08feb219b44 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -614,6 +614,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
614 ireq = inet_rsk(req); 614 ireq = inet_rsk(req);
615 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr); 615 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
616 sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr); 616 sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
617 ireq->ir_mark = inet_request_mark(sk, skb);
617 ireq->ireq_family = AF_INET; 618 ireq->ireq_family = AF_INET;
618 ireq->ir_iif = sk->sk_bound_dev_if; 619 ireq->ir_iif = sk->sk_bound_dev_if;
619 620
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 5df7857fc0f3..6344f1b18a6a 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -351,6 +351,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
351 ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr; 351 ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
352 ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr; 352 ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
353 ireq->ireq_family = AF_INET6; 353 ireq->ireq_family = AF_INET6;
354 ireq->ir_mark = inet_request_mark(sk, skb);
354 355
355 if (ipv6_opt_accepted(sk, skb, IP6CB(skb)) || 356 if (ipv6_opt_accepted(sk, skb, IP6CB(skb)) ||
356 np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || 357 np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 70de7895e5b8..053731473c99 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -126,6 +126,7 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
126 struct dsa_port *cpu_dp = dev->dsa_ptr; 126 struct dsa_port *cpu_dp = dev->dsa_ptr;
127 struct dsa_switch_tree *dst = cpu_dp->dst; 127 struct dsa_switch_tree *dst = cpu_dp->dst;
128 struct dsa_switch *ds; 128 struct dsa_switch *ds;
129 struct dsa_port *slave_port;
129 130
130 if (device < 0 || device >= DSA_MAX_SWITCHES) 131 if (device < 0 || device >= DSA_MAX_SWITCHES)
131 return NULL; 132 return NULL;
@@ -137,7 +138,12 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
137 if (port < 0 || port >= ds->num_ports) 138 if (port < 0 || port >= ds->num_ports)
138 return NULL; 139 return NULL;
139 140
140 return ds->ports[port].slave; 141 slave_port = &ds->ports[port];
142
143 if (unlikely(slave_port->type != DSA_PORT_TYPE_USER))
144 return NULL;
145
146 return slave_port->slave;
141} 147}
142 148
143/* port.c */ 149/* port.c */
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index be4c595edccb..bf6c2d4d4fdc 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -437,7 +437,7 @@ static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev)
437 /*unsigned long now; */ 437 /*unsigned long now; */
438 struct net *net = dev_net(dev); 438 struct net *net = dev_net(dev);
439 439
440 rt = ip_route_output(net, sip, tip, 0, 0); 440 rt = ip_route_output(net, sip, tip, 0, l3mdev_master_ifindex_rcu(dev));
441 if (IS_ERR(rt)) 441 if (IS_ERR(rt))
442 return 1; 442 return 1;
443 if (rt->dst.dev != dev) { 443 if (rt->dst.dev != dev) {
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index c3ea4906d237..88c5069b5d20 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -178,6 +178,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
178 tw->tw_dport = inet->inet_dport; 178 tw->tw_dport = inet->inet_dport;
179 tw->tw_family = sk->sk_family; 179 tw->tw_family = sk->sk_family;
180 tw->tw_reuse = sk->sk_reuse; 180 tw->tw_reuse = sk->sk_reuse;
181 tw->tw_reuseport = sk->sk_reuseport;
181 tw->tw_hash = sk->sk_hash; 182 tw->tw_hash = sk->sk_hash;
182 tw->tw_ipv6only = 0; 183 tw->tw_ipv6only = 0;
183 tw->tw_transparent = inet->transparent; 184 tw->tw_transparent = inet->transparent;
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 1f04bd91fc2e..d757b9642d0d 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -211,6 +211,7 @@ struct inet_peer *inet_getpeer(struct inet_peer_base *base,
211 p = kmem_cache_alloc(peer_cachep, GFP_ATOMIC); 211 p = kmem_cache_alloc(peer_cachep, GFP_ATOMIC);
212 if (p) { 212 if (p) {
213 p->daddr = *daddr; 213 p->daddr = *daddr;
214 p->dtime = (__u32)jiffies;
214 refcount_set(&p->refcnt, 2); 215 refcount_set(&p->refcnt, 2);
215 atomic_set(&p->rid, 0); 216 atomic_set(&p->rid, 0);
216 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW; 217 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index de6d94482fe7..6b0e362cc99b 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -253,13 +253,14 @@ static struct net_device *__ip_tunnel_create(struct net *net,
253 struct net_device *dev; 253 struct net_device *dev;
254 char name[IFNAMSIZ]; 254 char name[IFNAMSIZ];
255 255
256 if (parms->name[0]) 256 err = -E2BIG;
257 if (parms->name[0]) {
258 if (!dev_valid_name(parms->name))
259 goto failed;
257 strlcpy(name, parms->name, IFNAMSIZ); 260 strlcpy(name, parms->name, IFNAMSIZ);
258 else { 261 } else {
259 if (strlen(ops->kind) > (IFNAMSIZ - 3)) { 262 if (strlen(ops->kind) > (IFNAMSIZ - 3))
260 err = -E2BIG;
261 goto failed; 263 goto failed;
262 }
263 strlcpy(name, ops->kind, IFNAMSIZ); 264 strlcpy(name, ops->kind, IFNAMSIZ);
264 strncat(name, "%d", 2); 265 strncat(name, "%d", 2);
265 } 266 }
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 594a1c605c92..ccb25d80f679 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2296,13 +2296,14 @@ struct rtable *ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
2296 const struct sk_buff *skb) 2296 const struct sk_buff *skb)
2297{ 2297{
2298 __u8 tos = RT_FL_TOS(fl4); 2298 __u8 tos = RT_FL_TOS(fl4);
2299 struct fib_result res; 2299 struct fib_result res = {
2300 .type = RTN_UNSPEC,
2301 .fi = NULL,
2302 .table = NULL,
2303 .tclassid = 0,
2304 };
2300 struct rtable *rth; 2305 struct rtable *rth;
2301 2306
2302 res.tclassid = 0;
2303 res.fi = NULL;
2304 res.table = NULL;
2305
2306 fl4->flowi4_iif = LOOPBACK_IFINDEX; 2307 fl4->flowi4_iif = LOOPBACK_IFINDEX;
2307 fl4->flowi4_tos = tos & IPTOS_RT_MASK; 2308 fl4->flowi4_tos = tos & IPTOS_RT_MASK;
2308 fl4->flowi4_scope = ((tos & RTO_ONLINK) ? 2309 fl4->flowi4_scope = ((tos & RTO_ONLINK) ?
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index f8a103bdbd60..69727bc168cb 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -335,11 +335,13 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
335 if (t || !create) 335 if (t || !create)
336 return t; 336 return t;
337 337
338 if (parms->name[0]) 338 if (parms->name[0]) {
339 if (!dev_valid_name(parms->name))
340 return NULL;
339 strlcpy(name, parms->name, IFNAMSIZ); 341 strlcpy(name, parms->name, IFNAMSIZ);
340 else 342 } else {
341 strcpy(name, "ip6gre%d"); 343 strcpy(name, "ip6gre%d");
342 344 }
343 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, 345 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
344 ip6gre_tunnel_setup); 346 ip6gre_tunnel_setup);
345 if (!dev) 347 if (!dev)
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index b8ee50e94af3..2e891d2c30ef 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -375,6 +375,11 @@ static int ip6_forward_proxy_check(struct sk_buff *skb)
375static inline int ip6_forward_finish(struct net *net, struct sock *sk, 375static inline int ip6_forward_finish(struct net *net, struct sock *sk,
376 struct sk_buff *skb) 376 struct sk_buff *skb)
377{ 377{
378 struct dst_entry *dst = skb_dst(skb);
379
380 __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
381 __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len);
382
378 return dst_output(net, sk, skb); 383 return dst_output(net, sk, skb);
379} 384}
380 385
@@ -569,8 +574,6 @@ int ip6_forward(struct sk_buff *skb)
569 574
570 hdr->hop_limit--; 575 hdr->hop_limit--;
571 576
572 __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
573 __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len);
574 return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, 577 return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
575 net, NULL, skb, skb->dev, dst->dev, 578 net, NULL, skb, skb->dev, dst->dev,
576 ip6_forward_finish); 579 ip6_forward_finish);
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index df4c29f7d59f..da66aaac51ce 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -297,13 +297,16 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
297 struct net_device *dev; 297 struct net_device *dev;
298 struct ip6_tnl *t; 298 struct ip6_tnl *t;
299 char name[IFNAMSIZ]; 299 char name[IFNAMSIZ];
300 int err = -ENOMEM; 300 int err = -E2BIG;
301 301
302 if (p->name[0]) 302 if (p->name[0]) {
303 if (!dev_valid_name(p->name))
304 goto failed;
303 strlcpy(name, p->name, IFNAMSIZ); 305 strlcpy(name, p->name, IFNAMSIZ);
304 else 306 } else {
305 sprintf(name, "ip6tnl%%d"); 307 sprintf(name, "ip6tnl%%d");
306 308 }
309 err = -ENOMEM;
307 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, 310 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
308 ip6_tnl_dev_setup); 311 ip6_tnl_dev_setup);
309 if (!dev) 312 if (!dev)
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 6ebb2e8777f4..c214ffec02f0 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -212,10 +212,13 @@ static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p
212 char name[IFNAMSIZ]; 212 char name[IFNAMSIZ];
213 int err; 213 int err;
214 214
215 if (p->name[0]) 215 if (p->name[0]) {
216 if (!dev_valid_name(p->name))
217 goto failed;
216 strlcpy(name, p->name, IFNAMSIZ); 218 strlcpy(name, p->name, IFNAMSIZ);
217 else 219 } else {
218 sprintf(name, "ip6_vti%%d"); 220 sprintf(name, "ip6_vti%%d");
221 }
219 222
220 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, vti6_dev_setup); 223 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, vti6_dev_setup);
221 if (!dev) 224 if (!dev)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 1522bcfd253f..2afce37a7177 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -250,11 +250,13 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
250 if (!create) 250 if (!create)
251 goto failed; 251 goto failed;
252 252
253 if (parms->name[0]) 253 if (parms->name[0]) {
254 if (!dev_valid_name(parms->name))
255 goto failed;
254 strlcpy(name, parms->name, IFNAMSIZ); 256 strlcpy(name, parms->name, IFNAMSIZ);
255 else 257 } else {
256 strcpy(name, "sit%d"); 258 strcpy(name, "sit%d");
257 259 }
258 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, 260 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
259 ipip6_tunnel_setup); 261 ipip6_tunnel_setup);
260 if (!dev) 262 if (!dev)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index fa556fdef57d..55342c4d5cec 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1844,6 +1844,8 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
1844 1844
1845 if (msg->msg_namelen) { 1845 if (msg->msg_namelen) {
1846 err = -EINVAL; 1846 err = -EINVAL;
1847 if (msg->msg_namelen < sizeof(struct sockaddr_nl))
1848 goto out;
1847 if (addr->nl_family != AF_NETLINK) 1849 if (addr->nl_family != AF_NETLINK)
1848 goto out; 1850 goto out;
1849 dst_portid = addr->nl_pid; 1851 dst_portid = addr->nl_pid;
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index 9092531d45d8..18089c02e557 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c
@@ -248,10 +248,14 @@ static int tcf_bpf_init_from_efd(struct nlattr **tb, struct tcf_bpf_cfg *cfg)
248 248
249static void tcf_bpf_cfg_cleanup(const struct tcf_bpf_cfg *cfg) 249static void tcf_bpf_cfg_cleanup(const struct tcf_bpf_cfg *cfg)
250{ 250{
251 if (cfg->is_ebpf) 251 struct bpf_prog *filter = cfg->filter;
252 bpf_prog_put(cfg->filter); 252
253 else 253 if (filter) {
254 bpf_prog_destroy(cfg->filter); 254 if (cfg->is_ebpf)
255 bpf_prog_put(filter);
256 else
257 bpf_prog_destroy(filter);
258 }
255 259
256 kfree(cfg->bpf_ops); 260 kfree(cfg->bpf_ops);
257 kfree(cfg->bpf_name); 261 kfree(cfg->bpf_name);
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index ed8b6a24b9e9..bac47b5d18fd 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -489,6 +489,7 @@ static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key)
489 RCU_INIT_POINTER(*kp, key->next); 489 RCU_INIT_POINTER(*kp, key->next);
490 490
491 tcf_unbind_filter(tp, &key->res); 491 tcf_unbind_filter(tp, &key->res);
492 idr_remove(&ht->handle_idr, key->handle);
492 tcf_exts_get_net(&key->exts); 493 tcf_exts_get_net(&key->exts);
493 call_rcu(&key->rcu, u32_delete_key_freepf_rcu); 494 call_rcu(&key->rcu, u32_delete_key_freepf_rcu);
494 return 0; 495 return 0;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 6dd976c8ab61..31083b5035ec 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -757,8 +757,10 @@ static int sctp_v6_addr_to_user(struct sctp_sock *sp, union sctp_addr *addr)
757 sctp_v6_map_v4(addr); 757 sctp_v6_map_v4(addr);
758 } 758 }
759 759
760 if (addr->sa.sa_family == AF_INET) 760 if (addr->sa.sa_family == AF_INET) {
761 memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
761 return sizeof(struct sockaddr_in); 762 return sizeof(struct sockaddr_in);
763 }
762 return sizeof(struct sockaddr_in6); 764 return sizeof(struct sockaddr_in6);
763} 765}
764 766
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 2a2e094560de..80835ac26d2c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -357,11 +357,14 @@ static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt,
357 if (!opt->pf->af_supported(addr->sa.sa_family, opt)) 357 if (!opt->pf->af_supported(addr->sa.sa_family, opt))
358 return NULL; 358 return NULL;
359 359
360 /* V4 mapped address are really of AF_INET family */ 360 if (addr->sa.sa_family == AF_INET6) {
361 if (addr->sa.sa_family == AF_INET6 && 361 if (len < SIN6_LEN_RFC2133)
362 ipv6_addr_v4mapped(&addr->v6.sin6_addr) && 362 return NULL;
363 !opt->pf->af_supported(AF_INET, opt)) 363 /* V4 mapped address are really of AF_INET family */
364 return NULL; 364 if (ipv6_addr_v4mapped(&addr->v6.sin6_addr) &&
365 !opt->pf->af_supported(AF_INET, opt))
366 return NULL;
367 }
365 368
366 /* If we get this far, af is valid. */ 369 /* If we get this far, af is valid. */
367 af = sctp_get_af_specific(addr->sa.sa_family); 370 af = sctp_get_af_specific(addr->sa.sa_family);
diff --git a/net/tipc/diag.c b/net/tipc/diag.c
index 46d9cd62f781..aaabb0b776dd 100644
--- a/net/tipc/diag.c
+++ b/net/tipc/diag.c
@@ -59,7 +59,7 @@ static int __tipc_add_sock_diag(struct sk_buff *skb,
59 if (!nlh) 59 if (!nlh)
60 return -EMSGSIZE; 60 return -EMSGSIZE;
61 61
62 err = tipc_sk_fill_sock_diag(skb, tsk, req->tidiag_states, 62 err = tipc_sk_fill_sock_diag(skb, cb, tsk, req->tidiag_states,
63 __tipc_diag_gen_cookie); 63 __tipc_diag_gen_cookie);
64 if (err) 64 if (err)
65 return err; 65 return err;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index cee6674a3bf4..1fd1c8b5ce03 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -3257,8 +3257,8 @@ out:
3257} 3257}
3258EXPORT_SYMBOL(tipc_nl_sk_walk); 3258EXPORT_SYMBOL(tipc_nl_sk_walk);
3259 3259
3260int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct tipc_sock *tsk, 3260int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb,
3261 u32 sk_filter_state, 3261 struct tipc_sock *tsk, u32 sk_filter_state,
3262 u64 (*tipc_diag_gen_cookie)(struct sock *sk)) 3262 u64 (*tipc_diag_gen_cookie)(struct sock *sk))
3263{ 3263{
3264 struct sock *sk = &tsk->sk; 3264 struct sock *sk = &tsk->sk;
@@ -3280,7 +3280,7 @@ int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct tipc_sock *tsk,
3280 nla_put_u32(skb, TIPC_NLA_SOCK_TIPC_STATE, (u32)sk->sk_state) || 3280 nla_put_u32(skb, TIPC_NLA_SOCK_TIPC_STATE, (u32)sk->sk_state) ||
3281 nla_put_u32(skb, TIPC_NLA_SOCK_INO, sock_i_ino(sk)) || 3281 nla_put_u32(skb, TIPC_NLA_SOCK_INO, sock_i_ino(sk)) ||
3282 nla_put_u32(skb, TIPC_NLA_SOCK_UID, 3282 nla_put_u32(skb, TIPC_NLA_SOCK_UID,
3283 from_kuid_munged(sk_user_ns(NETLINK_CB(skb).sk), 3283 from_kuid_munged(sk_user_ns(NETLINK_CB(cb->skb).sk),
3284 sock_i_uid(sk))) || 3284 sock_i_uid(sk))) ||
3285 nla_put_u64_64bit(skb, TIPC_NLA_SOCK_COOKIE, 3285 nla_put_u64_64bit(skb, TIPC_NLA_SOCK_COOKIE,
3286 tipc_diag_gen_cookie(sk), 3286 tipc_diag_gen_cookie(sk),
diff --git a/net/tipc/socket.h b/net/tipc/socket.h
index aae3fd4cd06c..aff9b2ae5a1f 100644
--- a/net/tipc/socket.h
+++ b/net/tipc/socket.h
@@ -61,8 +61,8 @@ int tipc_sk_rht_init(struct net *net);
61void tipc_sk_rht_destroy(struct net *net); 61void tipc_sk_rht_destroy(struct net *net);
62int tipc_nl_sk_dump(struct sk_buff *skb, struct netlink_callback *cb); 62int tipc_nl_sk_dump(struct sk_buff *skb, struct netlink_callback *cb);
63int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb); 63int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb);
64int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct tipc_sock *tsk, 64int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb,
65 u32 sk_filter_state, 65 struct tipc_sock *tsk, u32 sk_filter_state,
66 u64 (*tipc_diag_gen_cookie)(struct sock *sk)); 66 u64 (*tipc_diag_gen_cookie)(struct sock *sk));
67int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb, 67int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb,
68 int (*skb_handler)(struct sk_buff *skb, 68 int (*skb_handler)(struct sk_buff *skb,