From: Greg Kroah-Hartman Date: Sun, 24 Feb 2019 13:36:38 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.9.161~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c64b4b73feadfa0e53eab5f473a08f34c61dd0ff;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: batman-adv-fix-uninit-value-in-batadv_interface_tx.patch inet_diag-fix-reporting-cgroup-classid-and-fallback-to-priority.patch ipv6-propagate-genlmsg_reply-return-code.patch keys-always-initialize-keyring_index_key-desc_len.patch keys-user-align-the-payload-buffer.patch net-mlx4_en-force-checksum_none-for-short-ethernet-frames.patch net-mlx5e-don-t-overwrite-pedit-action-when-multiple-pedit-used.patch net-packet-fix-4gb-buffer-limit-due-to-overflow-check.patch net-sfp-do-not-probe-sfp-module-before-we-re-attached.patch rdma-srp-rework-scsi-device-reset-handling.patch sctp-call-gso_reset_checksum-when-computing-checksum-in-sctp_gso_segment.patch sit-check-if-ipv6-enabled-before-calling-ip6_err_gen_icmpv6_unreach.patch team-avoid-complex-list-operations-in-team_nl_cmd_options_set.patch --- diff --git a/queue-4.14/batman-adv-fix-uninit-value-in-batadv_interface_tx.patch b/queue-4.14/batman-adv-fix-uninit-value-in-batadv_interface_tx.patch new file mode 100644 index 00000000000..c7d662792d6 --- /dev/null +++ b/queue-4.14/batman-adv-fix-uninit-value-in-batadv_interface_tx.patch @@ -0,0 +1,99 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Eric Dumazet +Date: Mon, 11 Feb 2019 14:41:22 -0800 +Subject: batman-adv: fix uninit-value in batadv_interface_tx() + +From: Eric Dumazet + +[ Upstream commit 4ffcbfac60642f63ae3d80891f573ba7e94a265c ] + +KMSAN reported batadv_interface_tx() was possibly using a +garbage value [1] + +batadv_get_vid() does have a pskb_may_pull() call +but batadv_interface_tx() does not actually make sure +this did not fail. + +[1] +BUG: KMSAN: uninit-value in batadv_interface_tx+0x908/0x1e40 net/batman-adv/soft-interface.c:231 +CPU: 0 PID: 10006 Comm: syz-executor469 Not tainted 4.20.0-rc7+ #5 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 +Call Trace: + __dump_stack lib/dump_stack.c:77 [inline] + dump_stack+0x173/0x1d0 lib/dump_stack.c:113 + kmsan_report+0x12e/0x2a0 mm/kmsan/kmsan.c:613 + __msan_warning+0x82/0xf0 mm/kmsan/kmsan_instr.c:313 + batadv_interface_tx+0x908/0x1e40 net/batman-adv/soft-interface.c:231 + __netdev_start_xmit include/linux/netdevice.h:4356 [inline] + netdev_start_xmit include/linux/netdevice.h:4365 [inline] + xmit_one net/core/dev.c:3257 [inline] + dev_hard_start_xmit+0x607/0xc40 net/core/dev.c:3273 + __dev_queue_xmit+0x2e42/0x3bc0 net/core/dev.c:3843 + dev_queue_xmit+0x4b/0x60 net/core/dev.c:3876 + packet_snd net/packet/af_packet.c:2928 [inline] + packet_sendmsg+0x8306/0x8f30 net/packet/af_packet.c:2953 + sock_sendmsg_nosec net/socket.c:621 [inline] + sock_sendmsg net/socket.c:631 [inline] + __sys_sendto+0x8c4/0xac0 net/socket.c:1788 + __do_sys_sendto net/socket.c:1800 [inline] + __se_sys_sendto+0x107/0x130 net/socket.c:1796 + __x64_sys_sendto+0x6e/0x90 net/socket.c:1796 + do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291 + entry_SYSCALL_64_after_hwframe+0x63/0xe7 +RIP: 0033:0x441889 +Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 bb 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00 +RSP: 002b:00007ffdda6fd468 EFLAGS: 00000216 ORIG_RAX: 000000000000002c +RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 0000000000441889 +RDX: 000000000000000e RSI: 00000000200000c0 RDI: 0000000000000003 +RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000 +R10: 0000000000000000 R11: 0000000000000216 R12: 00007ffdda6fd4c0 +R13: 00007ffdda6fd4b0 R14: 0000000000000000 R15: 0000000000000000 + +Uninit was created at: + kmsan_save_stack_with_flags mm/kmsan/kmsan.c:204 [inline] + kmsan_internal_poison_shadow+0x92/0x150 mm/kmsan/kmsan.c:158 + kmsan_kmalloc+0xa6/0x130 mm/kmsan/kmsan_hooks.c:176 + kmsan_slab_alloc+0xe/0x10 mm/kmsan/kmsan_hooks.c:185 + slab_post_alloc_hook mm/slab.h:446 [inline] + slab_alloc_node mm/slub.c:2759 [inline] + __kmalloc_node_track_caller+0xe18/0x1030 mm/slub.c:4383 + __kmalloc_reserve net/core/skbuff.c:137 [inline] + __alloc_skb+0x309/0xa20 net/core/skbuff.c:205 + alloc_skb include/linux/skbuff.h:998 [inline] + alloc_skb_with_frags+0x1c7/0xac0 net/core/skbuff.c:5220 + sock_alloc_send_pskb+0xafd/0x10e0 net/core/sock.c:2083 + packet_alloc_skb net/packet/af_packet.c:2781 [inline] + packet_snd net/packet/af_packet.c:2872 [inline] + packet_sendmsg+0x661a/0x8f30 net/packet/af_packet.c:2953 + sock_sendmsg_nosec net/socket.c:621 [inline] + sock_sendmsg net/socket.c:631 [inline] + __sys_sendto+0x8c4/0xac0 net/socket.c:1788 + __do_sys_sendto net/socket.c:1800 [inline] + __se_sys_sendto+0x107/0x130 net/socket.c:1796 + __x64_sys_sendto+0x6e/0x90 net/socket.c:1796 + do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291 + entry_SYSCALL_64_after_hwframe+0x63/0xe7 + +Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol") +Signed-off-by: Eric Dumazet +Reported-by: syzbot +Cc: Marek Lindner +Cc: Simon Wunderlich +Cc: Antonio Quartulli +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/batman-adv/soft-interface.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/net/batman-adv/soft-interface.c ++++ b/net/batman-adv/soft-interface.c +@@ -219,6 +219,8 @@ static int batadv_interface_tx(struct sk + + switch (ntohs(ethhdr->h_proto)) { + case ETH_P_8021Q: ++ if (!pskb_may_pull(skb, sizeof(*vhdr))) ++ goto dropped; + vhdr = vlan_eth_hdr(skb); + + /* drop batman-in-batman packets to prevent loops */ diff --git a/queue-4.14/inet_diag-fix-reporting-cgroup-classid-and-fallback-to-priority.patch b/queue-4.14/inet_diag-fix-reporting-cgroup-classid-and-fallback-to-priority.patch new file mode 100644 index 00000000000..87ddfb23e2b --- /dev/null +++ b/queue-4.14/inet_diag-fix-reporting-cgroup-classid-and-fallback-to-priority.patch @@ -0,0 +1,111 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Konstantin Khlebnikov +Date: Sat, 9 Feb 2019 13:35:52 +0300 +Subject: inet_diag: fix reporting cgroup classid and fallback to priority + +From: Konstantin Khlebnikov + +[ Upstream commit 1ec17dbd90f8b638f41ee650558609c1af63dfa0 ] + +Field idiag_ext in struct inet_diag_req_v2 used as bitmap of requested +extensions has only 8 bits. Thus extensions starting from DCTCPINFO +cannot be requested directly. Some of them included into response +unconditionally or hook into some of lower 8 bits. + +Extension INET_DIAG_CLASS_ID has not way to request from the beginning. + +This patch bundle it with INET_DIAG_TCLASS (ipv6 tos), fixes space +reservation, and documents behavior for other extensions. + +Also this patch adds fallback to reporting socket priority. This filed +is more widely used for traffic classification because ipv4 sockets +automatically maps TOS to priority and default qdisc pfifo_fast knows +about that. But priority could be changed via setsockopt SO_PRIORITY so +INET_DIAG_TOS isn't enough for predicting class. + +Also cgroup2 obsoletes net_cls classid (it always zero), but we cannot +reuse this field for reporting cgroup2 id because it is 64-bit (ino+gen). + +So, after this patch INET_DIAG_CLASS_ID will report socket priority +for most common setup when net_cls isn't set and/or cgroup2 in use. + +Fixes: 0888e372c37f ("net: inet: diag: expose sockets cgroup classid") +Signed-off-by: Konstantin Khlebnikov +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + include/uapi/linux/inet_diag.h | 16 +++++++++++----- + net/ipv4/inet_diag.c | 10 +++++++++- + net/sctp/sctp_diag.c | 1 + + 3 files changed, 21 insertions(+), 6 deletions(-) + +--- a/include/uapi/linux/inet_diag.h ++++ b/include/uapi/linux/inet_diag.h +@@ -135,15 +135,21 @@ enum { + INET_DIAG_TCLASS, + INET_DIAG_SKMEMINFO, + INET_DIAG_SHUTDOWN, +- INET_DIAG_DCTCPINFO, +- INET_DIAG_PROTOCOL, /* response attribute only */ ++ ++ /* ++ * Next extenstions cannot be requested in struct inet_diag_req_v2: ++ * its field idiag_ext has only 8 bits. ++ */ ++ ++ INET_DIAG_DCTCPINFO, /* request as INET_DIAG_VEGASINFO */ ++ INET_DIAG_PROTOCOL, /* response attribute only */ + INET_DIAG_SKV6ONLY, + INET_DIAG_LOCALS, + INET_DIAG_PEERS, + INET_DIAG_PAD, +- INET_DIAG_MARK, +- INET_DIAG_BBRINFO, +- INET_DIAG_CLASS_ID, ++ INET_DIAG_MARK, /* only with CAP_NET_ADMIN */ ++ INET_DIAG_BBRINFO, /* request as INET_DIAG_VEGASINFO */ ++ INET_DIAG_CLASS_ID, /* request as INET_DIAG_TCLASS */ + INET_DIAG_MD5SIG, + __INET_DIAG_MAX, + }; +--- a/net/ipv4/inet_diag.c ++++ b/net/ipv4/inet_diag.c +@@ -109,6 +109,7 @@ static size_t inet_sk_attr_size(struct s + + nla_total_size(1) /* INET_DIAG_TOS */ + + nla_total_size(1) /* INET_DIAG_TCLASS */ + + nla_total_size(4) /* INET_DIAG_MARK */ ++ + nla_total_size(4) /* INET_DIAG_CLASS_ID */ + + nla_total_size(sizeof(struct inet_diag_meminfo)) + + nla_total_size(sizeof(struct inet_diag_msg)) + + nla_total_size(SK_MEMINFO_VARS * sizeof(u32)) +@@ -288,12 +289,19 @@ int inet_sk_diag_fill(struct sock *sk, s + goto errout; + } + +- if (ext & (1 << (INET_DIAG_CLASS_ID - 1))) { ++ if (ext & (1 << (INET_DIAG_CLASS_ID - 1)) || ++ ext & (1 << (INET_DIAG_TCLASS - 1))) { + u32 classid = 0; + + #ifdef CONFIG_SOCK_CGROUP_DATA + classid = sock_cgroup_classid(&sk->sk_cgrp_data); + #endif ++ /* Fallback to socket priority if class id isn't set. ++ * Classful qdiscs use it as direct reference to class. ++ * For cgroup2 classid is always zero. ++ */ ++ if (!classid) ++ classid = sk->sk_priority; + + if (nla_put_u32(skb, INET_DIAG_CLASS_ID, classid)) + goto errout; +--- a/net/sctp/sctp_diag.c ++++ b/net/sctp/sctp_diag.c +@@ -225,6 +225,7 @@ static size_t inet_assoc_attr_size(struc + + nla_total_size(1) /* INET_DIAG_TOS */ + + nla_total_size(1) /* INET_DIAG_TCLASS */ + + nla_total_size(4) /* INET_DIAG_MARK */ ++ + nla_total_size(4) /* INET_DIAG_CLASS_ID */ + + nla_total_size(addrlen * asoc->peer.transport_count) + + nla_total_size(addrlen * addrcnt) + + nla_total_size(sizeof(struct inet_diag_meminfo)) diff --git a/queue-4.14/ipv6-propagate-genlmsg_reply-return-code.patch b/queue-4.14/ipv6-propagate-genlmsg_reply-return-code.patch new file mode 100644 index 00000000000..d7cac9b4654 --- /dev/null +++ b/queue-4.14/ipv6-propagate-genlmsg_reply-return-code.patch @@ -0,0 +1,32 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Li RongQing +Date: Mon, 11 Feb 2019 19:32:20 +0800 +Subject: ipv6: propagate genlmsg_reply return code + +From: Li RongQing + +[ Upstream commit d1f20798a119be71746949ba9b2e2ff330fdc038 ] + +genlmsg_reply can fail, so propagate its return code + +Fixes: 915d7e5e593 ("ipv6: sr: add code base for control plane support of SR-IPv6") +Signed-off-by: Li RongQing +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/ipv6/seg6.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/net/ipv6/seg6.c ++++ b/net/ipv6/seg6.c +@@ -220,9 +220,7 @@ static int seg6_genl_get_tunsrc(struct s + rcu_read_unlock(); + + genlmsg_end(msg, hdr); +- genlmsg_reply(msg, info); +- +- return 0; ++ return genlmsg_reply(msg, info); + + nla_put_failure: + rcu_read_unlock(); diff --git a/queue-4.14/keys-always-initialize-keyring_index_key-desc_len.patch b/queue-4.14/keys-always-initialize-keyring_index_key-desc_len.patch new file mode 100644 index 00000000000..e40b5ac9567 --- /dev/null +++ b/queue-4.14/keys-always-initialize-keyring_index_key-desc_len.patch @@ -0,0 +1,105 @@ +From ede0fa98a900e657d1fcd80b50920efc896c1a4c Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Fri, 22 Feb 2019 15:36:18 +0000 +Subject: KEYS: always initialize keyring_index_key::desc_len + +From: Eric Biggers + +commit ede0fa98a900e657d1fcd80b50920efc896c1a4c upstream. + +syzbot hit the 'BUG_ON(index_key->desc_len == 0);' in __key_link_begin() +called from construct_alloc_key() during sys_request_key(), because the +length of the key description was never calculated. + +The problem is that we rely on ->desc_len being initialized by +search_process_keyrings(), specifically by search_nested_keyrings(). +But, if the process isn't subscribed to any keyrings that never happens. + +Fix it by always initializing keyring_index_key::desc_len as soon as the +description is set, like we already do in some places. + +The following program reproduces the BUG_ON() when it's run as root and +no session keyring has been installed. If it doesn't work, try removing +pam_keyinit.so from /etc/pam.d/login and rebooting. + + #include + #include + #include + + int main(void) + { + int id = add_key("keyring", "syz", NULL, 0, KEY_SPEC_USER_KEYRING); + + keyctl_setperm(id, KEY_OTH_WRITE); + setreuid(5000, 5000); + request_key("user", "desc", "", id); + } + +Reported-by: syzbot+ec24e95ea483de0a24da@syzkaller.appspotmail.com +Fixes: b2a4df200d57 ("KEYS: Expand the capacity of a keyring") +Signed-off-by: Eric Biggers +Signed-off-by: David Howells +Cc: stable@vger.kernel.org +Signed-off-by: James Morris +Signed-off-by: Greg Kroah-Hartman + +--- + security/keys/keyring.c | 4 +--- + security/keys/proc.c | 3 +-- + security/keys/request_key.c | 1 + + security/keys/request_key_auth.c | 2 +- + 4 files changed, 4 insertions(+), 6 deletions(-) + +--- a/security/keys/keyring.c ++++ b/security/keys/keyring.c +@@ -661,9 +661,6 @@ static bool search_nested_keyrings(struc + BUG_ON((ctx->flags & STATE_CHECKS) == 0 || + (ctx->flags & STATE_CHECKS) == STATE_CHECKS); + +- if (ctx->index_key.description) +- ctx->index_key.desc_len = strlen(ctx->index_key.description); +- + /* Check to see if this top-level keyring is what we are looking for + * and whether it is valid or not. + */ +@@ -921,6 +918,7 @@ key_ref_t keyring_search(key_ref_t keyri + struct keyring_search_context ctx = { + .index_key.type = type, + .index_key.description = description, ++ .index_key.desc_len = strlen(description), + .cred = current_cred(), + .match_data.cmp = key_default_cmp, + .match_data.raw_data = description, +--- a/security/keys/proc.c ++++ b/security/keys/proc.c +@@ -188,8 +188,7 @@ static int proc_keys_show(struct seq_fil + int rc; + + struct keyring_search_context ctx = { +- .index_key.type = key->type, +- .index_key.description = key->description, ++ .index_key = key->index_key, + .cred = m->file->f_cred, + .match_data.cmp = lookup_user_key_possessed, + .match_data.raw_data = key, +--- a/security/keys/request_key.c ++++ b/security/keys/request_key.c +@@ -545,6 +545,7 @@ struct key *request_key_and_link(struct + struct keyring_search_context ctx = { + .index_key.type = type, + .index_key.description = description, ++ .index_key.desc_len = strlen(description), + .cred = current_cred(), + .match_data.cmp = key_default_cmp, + .match_data.raw_data = description, +--- a/security/keys/request_key_auth.c ++++ b/security/keys/request_key_auth.c +@@ -246,7 +246,7 @@ struct key *key_get_instantiation_authke + struct key *authkey; + key_ref_t authkey_ref; + +- sprintf(description, "%x", target_id); ++ ctx.index_key.desc_len = sprintf(description, "%x", target_id); + + authkey_ref = search_process_keyrings(&ctx); + diff --git a/queue-4.14/keys-user-align-the-payload-buffer.patch b/queue-4.14/keys-user-align-the-payload-buffer.patch new file mode 100644 index 00000000000..9a5882101ea --- /dev/null +++ b/queue-4.14/keys-user-align-the-payload-buffer.patch @@ -0,0 +1,43 @@ +From cc1780fc42c76c705dd07ea123f1143dc5057630 Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Wed, 20 Feb 2019 13:32:11 +0000 +Subject: KEYS: user: Align the payload buffer + +From: Eric Biggers + +commit cc1780fc42c76c705dd07ea123f1143dc5057630 upstream. + +Align the payload of "user" and "logon" keys so that users of the +keyrings service can access it as a struct that requires more than +2-byte alignment. fscrypt currently does this which results in the read +of fscrypt_key::size being misaligned as it needs 4-byte alignment. + +Align to __alignof__(u64) rather than __alignof__(long) since in the +future it's conceivable that people would use structs beginning with +u64, which on some platforms would require more than 'long' alignment. + +Reported-by: Aaro Koskinen +Fixes: 2aa349f6e37c ("[PATCH] Keys: Export user-defined keyring operations") +Fixes: 88bd6ccdcdd6 ("ext4 crypto: add encryption key management facilities") +Cc: stable@vger.kernel.org +Signed-off-by: Eric Biggers +Tested-by: Aaro Koskinen +Signed-off-by: David Howells +Signed-off-by: James Morris +Signed-off-by: Greg Kroah-Hartman + +--- + include/keys/user-type.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/keys/user-type.h ++++ b/include/keys/user-type.h +@@ -31,7 +31,7 @@ + struct user_key_payload { + struct rcu_head rcu; /* RCU destructor */ + unsigned short datalen; /* length of this data */ +- char data[0]; /* actual data */ ++ char data[0] __aligned(__alignof__(u64)); /* actual data */ + }; + + extern struct key_type key_type_user; diff --git a/queue-4.14/net-mlx4_en-force-checksum_none-for-short-ethernet-frames.patch b/queue-4.14/net-mlx4_en-force-checksum_none-for-short-ethernet-frames.patch new file mode 100644 index 00000000000..091cb4bd287 --- /dev/null +++ b/queue-4.14/net-mlx4_en-force-checksum_none-for-short-ethernet-frames.patch @@ -0,0 +1,80 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Saeed Mahameed +Date: Mon, 11 Feb 2019 18:04:17 +0200 +Subject: net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames + +From: Saeed Mahameed + +[ Upstream commit 29dded89e80e3fff61efb34f07a8a3fba3ea146d ] + +When an ethernet frame is padded to meet the minimum ethernet frame +size, the padding octets are not covered by the hardware checksum. +Fortunately the padding octets are usually zero's, which don't affect +checksum. However, it is not guaranteed. For example, switches might +choose to make other use of these octets. +This repeatedly causes kernel hardware checksum fault. + +Prior to the cited commit below, skb checksum was forced to be +CHECKSUM_NONE when padding is detected. After it, we need to keep +skb->csum updated. However, fixing up CHECKSUM_COMPLETE requires to +verify and parse IP headers, it does not worth the effort as the packets +are so small that CHECKSUM_COMPLETE has no significant advantage. + +Future work: when reporting checksum complete is not an option for +IP non-TCP/UDP packets, we can actually fallback to report checksum +unnecessary, by looking at cqe IPOK bit. + +Fixes: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends") +Cc: Eric Dumazet +Signed-off-by: Saeed Mahameed +Signed-off-by: Tariq Toukan +Reviewed-by: Eric Dumazet +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/mellanox/mlx4/en_rx.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c ++++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c +@@ -623,13 +623,27 @@ static int get_fixed_ipv6_csum(__wsum hw + return 0; + } + #endif ++ ++#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN) ++ + static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va, + netdev_features_t dev_features) + { + __wsum hw_checksum = 0; ++ void *hdr; + +- void *hdr = (u8 *)va + sizeof(struct ethhdr); ++ /* CQE csum doesn't cover padding octets in short ethernet ++ * frames. And the pad field is appended prior to calculating ++ * and appending the FCS field. ++ * ++ * Detecting these padded frames requires to verify and parse ++ * IP headers, so we simply force all those small frames to skip ++ * checksum complete. ++ */ ++ if (short_frame(skb->len)) ++ return -EINVAL; + ++ hdr = (u8 *)va + sizeof(struct ethhdr); + hw_checksum = csum_unfold((__force __sum16)cqe->checksum); + + if (cqe->vlan_my_qpn & cpu_to_be32(MLX4_CQE_CVLAN_PRESENT_MASK) && +@@ -817,6 +831,11 @@ xdp_drop_no_cnt: + skb_record_rx_queue(skb, cq_ring); + + if (likely(dev->features & NETIF_F_RXCSUM)) { ++ /* TODO: For IP non TCP/UDP packets when csum complete is ++ * not an option (not supported or any other reason) we can ++ * actually check cqe IPOK status bit and report ++ * CHECKSUM_UNNECESSARY rather than CHECKSUM_NONE ++ */ + if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_TCP | + MLX4_CQE_STATUS_UDP)) { + if ((cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) && diff --git a/queue-4.14/net-mlx5e-don-t-overwrite-pedit-action-when-multiple-pedit-used.patch b/queue-4.14/net-mlx5e-don-t-overwrite-pedit-action-when-multiple-pedit-used.patch new file mode 100644 index 00000000000..9e4b7777183 --- /dev/null +++ b/queue-4.14/net-mlx5e-don-t-overwrite-pedit-action-when-multiple-pedit-used.patch @@ -0,0 +1,99 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Tonghao Zhang +Date: Mon, 28 Jan 2019 15:28:06 -0800 +Subject: net/mlx5e: Don't overwrite pedit action when multiple pedit used + +From: Tonghao Zhang + +[ Upstream commit 218d05ce326f9e1b40a56085431fa1068b43d5d9 ] + +In some case, we may use multiple pedit actions to modify packets. +The command shown as below: the last pedit action is effective. + +$ tc filter add dev netdev_rep parent ffff: protocol ip prio 1 \ + flower skip_sw ip_proto icmp dst_ip 3.3.3.3 \ + action pedit ex munge ip dst set 192.168.1.100 pipe \ + action pedit ex munge eth src set 00:00:00:00:00:01 pipe \ + action pedit ex munge eth dst set 00:00:00:00:00:02 pipe \ + action csum ip pipe \ + action tunnel_key set src_ip 1.1.1.100 dst_ip 1.1.1.200 dst_port 4789 id 100 \ + action mirred egress redirect dev vxlan0 + +To fix it, we add max_mod_hdr_actions to mlx5e_tc_flow_parse_attr struction, +max_mod_hdr_actions will store the max pedit action number we support and +num_mod_hdr_actions indicates how many pedit action we used, and store all +pedit action to mod_hdr_actions. + +Fixes: d79b6df6b10a ("net/mlx5e: Add parsing of TC pedit actions to HW format") +Cc: Or Gerlitz +Signed-off-by: Tonghao Zhang +Reviewed-by: Or Gerlitz +Acked-by: Saeed Mahameed +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 25 ++++++++++++++---------- + 1 file changed, 15 insertions(+), 10 deletions(-) + +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +@@ -81,6 +81,7 @@ struct mlx5e_tc_flow_parse_attr { + struct ip_tunnel_info tun_info; + struct mlx5_flow_spec spec; + int num_mod_hdr_actions; ++ int max_mod_hdr_actions; + void *mod_hdr_actions; + int mirred_ifindex; + }; +@@ -1128,9 +1129,9 @@ static struct mlx5_fields fields[] = { + OFFLOAD(UDP_DPORT, 2, udp.dest, 0), + }; + +-/* On input attr->num_mod_hdr_actions tells how many HW actions can be parsed at +- * max from the SW pedit action. On success, it says how many HW actions were +- * actually parsed. ++/* On input attr->max_mod_hdr_actions tells how many HW actions can be parsed at ++ * max from the SW pedit action. On success, attr->num_mod_hdr_actions ++ * says how many HW actions were actually parsed. + */ + static int offload_pedit_fields(struct pedit_headers *masks, + struct pedit_headers *vals, +@@ -1153,9 +1154,11 @@ static int offload_pedit_fields(struct p + add_vals = &vals[TCA_PEDIT_KEY_EX_CMD_ADD]; + + action_size = MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto); +- action = parse_attr->mod_hdr_actions; +- max_actions = parse_attr->num_mod_hdr_actions; +- nactions = 0; ++ action = parse_attr->mod_hdr_actions + ++ parse_attr->num_mod_hdr_actions * action_size; ++ ++ max_actions = parse_attr->max_mod_hdr_actions; ++ nactions = parse_attr->num_mod_hdr_actions; + + for (i = 0; i < ARRAY_SIZE(fields); i++) { + f = &fields[i]; +@@ -1260,7 +1263,7 @@ static int alloc_mod_hdr_actions(struct + if (!parse_attr->mod_hdr_actions) + return -ENOMEM; + +- parse_attr->num_mod_hdr_actions = max_actions; ++ parse_attr->max_mod_hdr_actions = max_actions; + return 0; + } + +@@ -1304,9 +1307,11 @@ static int parse_tc_pedit_action(struct + goto out_err; + } + +- err = alloc_mod_hdr_actions(priv, a, namespace, parse_attr); +- if (err) +- goto out_err; ++ if (!parse_attr->mod_hdr_actions) { ++ err = alloc_mod_hdr_actions(priv, a, namespace, parse_attr); ++ if (err) ++ goto out_err; ++ } + + err = offload_pedit_fields(masks, vals, parse_attr); + if (err < 0) diff --git a/queue-4.14/net-packet-fix-4gb-buffer-limit-due-to-overflow-check.patch b/queue-4.14/net-packet-fix-4gb-buffer-limit-due-to-overflow-check.patch new file mode 100644 index 00000000000..0044c8d1c75 --- /dev/null +++ b/queue-4.14/net-packet-fix-4gb-buffer-limit-due-to-overflow-check.patch @@ -0,0 +1,34 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Kal Conley +Date: Sun, 10 Feb 2019 09:57:11 +0100 +Subject: net/packet: fix 4gb buffer limit due to overflow check + +From: Kal Conley + +[ Upstream commit fc62814d690cf62189854464f4bd07457d5e9e50 ] + +When calculating rb->frames_per_block * req->tp_block_nr the result +can overflow. Check it for overflow without limiting the total buffer +size to UINT_MAX. + +This change fixes support for packet ring buffers >= UINT_MAX. + +Fixes: 8f8d28e4d6d8 ("net/packet: fix overflow in check for tp_frame_nr") +Signed-off-by: Kal Conley +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/packet/af_packet.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/packet/af_packet.c ++++ b/net/packet/af_packet.c +@@ -4313,7 +4313,7 @@ static int packet_set_ring(struct sock * + rb->frames_per_block = req->tp_block_size / req->tp_frame_size; + if (unlikely(rb->frames_per_block == 0)) + goto out; +- if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr)) ++ if (unlikely(rb->frames_per_block > UINT_MAX / req->tp_block_nr)) + goto out; + if (unlikely((rb->frames_per_block * req->tp_block_nr) != + req->tp_frame_nr)) diff --git a/queue-4.14/net-sfp-do-not-probe-sfp-module-before-we-re-attached.patch b/queue-4.14/net-sfp-do-not-probe-sfp-module-before-we-re-attached.patch new file mode 100644 index 00000000000..95d91d18db6 --- /dev/null +++ b/queue-4.14/net-sfp-do-not-probe-sfp-module-before-we-re-attached.patch @@ -0,0 +1,138 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Russell King +Date: Wed, 6 Feb 2019 10:52:30 +0000 +Subject: net: sfp: do not probe SFP module before we're attached + +From: Russell King + +[ Upstream commit b5bfc21af5cb3d53f9cee0ef82eaa43762a90f81 ] + +When we probe a SFP module, we expect to be able to call the upstream +device's module_insert() function so that the upstream link can be +configured. However, when the upstream device is delayed, we currently +may end up probing the module before the upstream device is available, +and lose the module_insert() call. + +Avoid this by holding off probing the module until the SFP bus is +properly connected to both the SFP socket driver and the upstream +driver. + +Signed-off-by: Russell King +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/phy/sfp-bus.c | 2 ++ + drivers/net/phy/sfp.c | 30 +++++++++++++++++++++--------- + drivers/net/phy/sfp.h | 2 ++ + 3 files changed, 25 insertions(+), 9 deletions(-) + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -276,6 +276,7 @@ static int sfp_register_bus(struct sfp_b + return ret; + } + } ++ bus->socket_ops->attach(bus->sfp); + if (bus->started) + bus->socket_ops->start(bus->sfp); + bus->registered = true; +@@ -289,6 +290,7 @@ static void sfp_unregister_bus(struct sf + if (bus->registered) { + if (bus->started) + bus->socket_ops->stop(bus->sfp); ++ bus->socket_ops->detach(bus->sfp); + if (bus->phydev && ops && ops->disconnect_phy) + ops->disconnect_phy(bus->upstream); + } +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -114,6 +114,7 @@ struct sfp { + + struct gpio_desc *gpio[GPIO_MAX]; + ++ bool attached; + unsigned int state; + struct delayed_work poll; + struct delayed_work timeout; +@@ -500,7 +501,7 @@ static void sfp_sm_event(struct sfp *sfp + */ + switch (sfp->sm_mod_state) { + default: +- if (event == SFP_E_INSERT) { ++ if (event == SFP_E_INSERT && sfp->attached) { + sfp_module_tx_disable(sfp); + sfp_sm_ins_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT); + } +@@ -628,6 +629,19 @@ static void sfp_sm_event(struct sfp *sfp + mutex_unlock(&sfp->sm_mutex); + } + ++static void sfp_attach(struct sfp *sfp) ++{ ++ sfp->attached = true; ++ if (sfp->state & SFP_F_PRESENT) ++ sfp_sm_event(sfp, SFP_E_INSERT); ++} ++ ++static void sfp_detach(struct sfp *sfp) ++{ ++ sfp->attached = false; ++ sfp_sm_event(sfp, SFP_E_REMOVE); ++} ++ + static void sfp_start(struct sfp *sfp) + { + sfp_sm_event(sfp, SFP_E_DEV_UP); +@@ -687,6 +701,8 @@ static int sfp_module_eeprom(struct sfp + } + + static const struct sfp_socket_ops sfp_module_ops = { ++ .attach = sfp_attach, ++ .detach = sfp_detach, + .start = sfp_start, + .stop = sfp_stop, + .module_info = sfp_module_info, +@@ -829,10 +845,6 @@ static int sfp_probe(struct platform_dev + sfp->set_state = sfp_gpio_set_state; + } + +- sfp->sfp_bus = sfp_register_socket(sfp->dev, sfp, &sfp_module_ops); +- if (!sfp->sfp_bus) +- return -ENOMEM; +- + /* Get the initial state, and always signal TX disable, + * since the network interface will not be up. + */ +@@ -843,10 +855,6 @@ static int sfp_probe(struct platform_dev + sfp->state |= SFP_F_RATE_SELECT; + sfp_set_state(sfp, sfp->state); + sfp_module_tx_disable(sfp); +- rtnl_lock(); +- if (sfp->state & SFP_F_PRESENT) +- sfp_sm_event(sfp, SFP_E_INSERT); +- rtnl_unlock(); + + for (i = 0; i < GPIO_MAX; i++) { + if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i]) +@@ -879,6 +887,10 @@ static int sfp_remove(struct platform_de + + sfp_unregister_socket(sfp->sfp_bus); + ++ sfp->sfp_bus = sfp_register_socket(sfp->dev, sfp, &sfp_module_ops); ++ if (!sfp->sfp_bus) ++ return -ENOMEM; ++ + return 0; + } + +--- a/drivers/net/phy/sfp.h ++++ b/drivers/net/phy/sfp.h +@@ -7,6 +7,8 @@ + struct sfp; + + struct sfp_socket_ops { ++ void (*attach)(struct sfp *sfp); ++ void (*detach)(struct sfp *sfp); + void (*start)(struct sfp *sfp); + void (*stop)(struct sfp *sfp); + int (*module_info)(struct sfp *sfp, struct ethtool_modinfo *modinfo); diff --git a/queue-4.14/rdma-srp-rework-scsi-device-reset-handling.patch b/queue-4.14/rdma-srp-rework-scsi-device-reset-handling.patch new file mode 100644 index 00000000000..3fc7ab1ef0e --- /dev/null +++ b/queue-4.14/rdma-srp-rework-scsi-device-reset-handling.patch @@ -0,0 +1,67 @@ +From 48396e80fb6526ea5ed267bd84f028bae56d2f9e Mon Sep 17 00:00:00 2001 +From: Bart Van Assche +Date: Wed, 30 Jan 2019 14:05:55 -0800 +Subject: RDMA/srp: Rework SCSI device reset handling + +From: Bart Van Assche + +commit 48396e80fb6526ea5ed267bd84f028bae56d2f9e upstream. + +Since .scsi_done() must only be called after scsi_queue_rq() has +finished, make sure that the SRP initiator driver does not call +.scsi_done() while scsi_queue_rq() is in progress. Although +invoking sg_reset -d while I/O is in progress works fine with kernel +v4.20 and before, that is not the case with kernel v5.0-rc1. This +patch avoids that the following crash is triggered with kernel +v5.0-rc1: + +BUG: unable to handle kernel NULL pointer dereference at 0000000000000138 +CPU: 0 PID: 360 Comm: kworker/0:1H Tainted: G B 5.0.0-rc1-dbg+ #1 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 +Workqueue: kblockd blk_mq_run_work_fn +RIP: 0010:blk_mq_dispatch_rq_list+0x116/0xb10 +Call Trace: + blk_mq_sched_dispatch_requests+0x2f7/0x300 + __blk_mq_run_hw_queue+0xd6/0x180 + blk_mq_run_work_fn+0x27/0x30 + process_one_work+0x4f1/0xa20 + worker_thread+0x67/0x5b0 + kthread+0x1cf/0x1f0 + ret_from_fork+0x24/0x30 + +Cc: +Fixes: 94a9174c630c ("IB/srp: reduce lock coverage of command completion") +Signed-off-by: Bart Van Assche +Signed-off-by: Jason Gunthorpe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/infiniband/ulp/srp/ib_srp.c | 10 ---------- + 1 file changed, 10 deletions(-) + +--- a/drivers/infiniband/ulp/srp/ib_srp.c ++++ b/drivers/infiniband/ulp/srp/ib_srp.c +@@ -2669,7 +2669,6 @@ static int srp_reset_device(struct scsi_ + { + struct srp_target_port *target = host_to_target(scmnd->device->host); + struct srp_rdma_ch *ch; +- int i, j; + u8 status; + + shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n"); +@@ -2681,15 +2680,6 @@ static int srp_reset_device(struct scsi_ + if (status) + return FAILED; + +- for (i = 0; i < target->ch_count; i++) { +- ch = &target->ch[i]; +- for (j = 0; j < target->req_ring_size; ++j) { +- struct srp_request *req = &ch->req_ring[j]; +- +- srp_finish_req(ch, req, scmnd->device, DID_RESET << 16); +- } +- } +- + return SUCCESS; + } + diff --git a/queue-4.14/sctp-call-gso_reset_checksum-when-computing-checksum-in-sctp_gso_segment.patch b/queue-4.14/sctp-call-gso_reset_checksum-when-computing-checksum-in-sctp_gso_segment.patch new file mode 100644 index 00000000000..23b198a82ec --- /dev/null +++ b/queue-4.14/sctp-call-gso_reset_checksum-when-computing-checksum-in-sctp_gso_segment.patch @@ -0,0 +1,69 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Xin Long +Date: Tue, 12 Feb 2019 18:47:30 +0800 +Subject: sctp: call gso_reset_checksum when computing checksum in sctp_gso_segment + +From: Xin Long + +[ Upstream commit fc228abc2347e106a44c0e9b29ab70b712c4ca51 ] + +Jianlin reported a panic when running sctp gso over gre over vlan device: + + [ 84.772930] RIP: 0010:do_csum+0x6d/0x170 + [ 84.790605] Call Trace: + [ 84.791054] csum_partial+0xd/0x20 + [ 84.791657] gre_gso_segment+0x2c3/0x390 + [ 84.792364] inet_gso_segment+0x161/0x3e0 + [ 84.793071] skb_mac_gso_segment+0xb8/0x120 + [ 84.793846] __skb_gso_segment+0x7e/0x180 + [ 84.794581] validate_xmit_skb+0x141/0x2e0 + [ 84.795297] __dev_queue_xmit+0x258/0x8f0 + [ 84.795949] ? eth_header+0x26/0xc0 + [ 84.796581] ip_finish_output2+0x196/0x430 + [ 84.797295] ? skb_gso_validate_network_len+0x11/0x80 + [ 84.798183] ? ip_finish_output+0x169/0x270 + [ 84.798875] ip_output+0x6c/0xe0 + [ 84.799413] ? ip_append_data.part.50+0xc0/0xc0 + [ 84.800145] iptunnel_xmit+0x144/0x1c0 + [ 84.800814] ip_tunnel_xmit+0x62d/0x930 [ip_tunnel] + [ 84.801699] gre_tap_xmit+0xac/0xf0 [ip_gre] + [ 84.802395] dev_hard_start_xmit+0xa5/0x210 + [ 84.803086] sch_direct_xmit+0x14f/0x340 + [ 84.803733] __dev_queue_xmit+0x799/0x8f0 + [ 84.804472] ip_finish_output2+0x2e0/0x430 + [ 84.805255] ? skb_gso_validate_network_len+0x11/0x80 + [ 84.806154] ip_output+0x6c/0xe0 + [ 84.806721] ? ip_append_data.part.50+0xc0/0xc0 + [ 84.807516] sctp_packet_transmit+0x716/0xa10 [sctp] + [ 84.808337] sctp_outq_flush+0xd7/0x880 [sctp] + +It was caused by SKB_GSO_CB(skb)->csum_start not set in sctp_gso_segment. +sctp_gso_segment() calls skb_segment() with 'feature | NETIF_F_HW_CSUM', +which causes SKB_GSO_CB(skb)->csum_start not to be set in skb_segment(). + +For TCP/UDP, when feature supports HW_CSUM, CHECKSUM_PARTIAL will be set +and gso_reset_checksum will be called to set SKB_GSO_CB(skb)->csum_start. + +So SCTP should do the same as TCP/UDP, to call gso_reset_checksum() when +computing checksum in sctp_gso_segment. + +Reported-by: Jianlin Shi +Signed-off-by: Xin Long +Acked-by: Neil Horman +Acked-by: Marcelo Ricardo Leitner +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/sctp/offload.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/net/sctp/offload.c ++++ b/net/sctp/offload.c +@@ -36,6 +36,7 @@ static __le32 sctp_gso_make_checksum(str + { + skb->ip_summed = CHECKSUM_NONE; + skb->csum_not_inet = 0; ++ gso_reset_checksum(skb, ~0); + return sctp_compute_cksum(skb, skb_transport_offset(skb)); + } + diff --git a/queue-4.14/series b/queue-4.14/series index 0daa27ffbf7..4e5c1c3d27a 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -42,3 +42,16 @@ bpf-bpf_setsockopt-reset-sock-dst-on-so_mark-changes.patch mlxsw-spectrum_switchdev-do-not-treat-static-fdb-ent.patch net-mlx5e-fix-wrong-zero-tx-drop-counter-indication-.patch isdn-avm-fix-string-plus-integer-warning-from-clang.patch +batman-adv-fix-uninit-value-in-batadv_interface_tx.patch +ipv6-propagate-genlmsg_reply-return-code.patch +net-mlx5e-don-t-overwrite-pedit-action-when-multiple-pedit-used.patch +net-packet-fix-4gb-buffer-limit-due-to-overflow-check.patch +net-sfp-do-not-probe-sfp-module-before-we-re-attached.patch +sctp-call-gso_reset_checksum-when-computing-checksum-in-sctp_gso_segment.patch +team-avoid-complex-list-operations-in-team_nl_cmd_options_set.patch +sit-check-if-ipv6-enabled-before-calling-ip6_err_gen_icmpv6_unreach.patch +net-mlx4_en-force-checksum_none-for-short-ethernet-frames.patch +inet_diag-fix-reporting-cgroup-classid-and-fallback-to-priority.patch +rdma-srp-rework-scsi-device-reset-handling.patch +keys-user-align-the-payload-buffer.patch +keys-always-initialize-keyring_index_key-desc_len.patch diff --git a/queue-4.14/sit-check-if-ipv6-enabled-before-calling-ip6_err_gen_icmpv6_unreach.patch b/queue-4.14/sit-check-if-ipv6-enabled-before-calling-ip6_err_gen_icmpv6_unreach.patch new file mode 100644 index 00000000000..bbf547e94cc --- /dev/null +++ b/queue-4.14/sit-check-if-ipv6-enabled-before-calling-ip6_err_gen_icmpv6_unreach.patch @@ -0,0 +1,46 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Hangbin Liu +Date: Thu, 7 Feb 2019 18:36:11 +0800 +Subject: sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach() + +From: Hangbin Liu + +[ Upstream commit 173656accaf583698bac3f9e269884ba60d51ef4 ] + +If we disabled IPv6 from the kernel command line (ipv6.disable=1), we should +not call ip6_err_gen_icmpv6_unreach(). This: + + ip link add sit1 type sit local 192.0.2.1 remote 192.0.2.2 ttl 1 + ip link set sit1 up + ip addr add 198.51.100.1/24 dev sit1 + ping 198.51.100.2 + +if IPv6 is disabled at boot time, will crash the kernel. + +v2: there's no need to use in6_dev_get(), use __in6_dev_get() instead, + as we only need to check that idev exists and we are under + rcu_read_lock() (from netif_receive_skb_internal()). + +Reported-by: Jianlin Shi +Fixes: ca15a078bd90 ("sit: generate icmpv6 error when receiving icmpv4 error") +Cc: Oussama Ghorbel +Signed-off-by: Hangbin Liu +Reviewed-by: Stefano Brivio +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/ipv6/sit.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/net/ipv6/sit.c ++++ b/net/ipv6/sit.c +@@ -540,7 +540,8 @@ static int ipip6_err(struct sk_buff *skb + } + + err = 0; +- if (!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4, type, data_len)) ++ if (__in6_dev_get(skb->dev) && ++ !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4, type, data_len)) + goto out; + + if (t->parms.iph.daddr == 0) diff --git a/queue-4.14/team-avoid-complex-list-operations-in-team_nl_cmd_options_set.patch b/queue-4.14/team-avoid-complex-list-operations-in-team_nl_cmd_options_set.patch new file mode 100644 index 00000000000..4aea379fb0f --- /dev/null +++ b/queue-4.14/team-avoid-complex-list-operations-in-team_nl_cmd_options_set.patch @@ -0,0 +1,113 @@ +From foo@baz Sun Feb 24 08:42:25 CET 2019 +From: Cong Wang +Date: Mon, 11 Feb 2019 21:59:51 -0800 +Subject: team: avoid complex list operations in team_nl_cmd_options_set() + +From: Cong Wang + +[ Upstream commit 2fdeee2549231b1f989f011bb18191f5660d3745 ] + +The current opt_inst_list operations inside team_nl_cmd_options_set() +is too complex to track: + + LIST_HEAD(opt_inst_list); + nla_for_each_nested(...) { + list_for_each_entry(opt_inst, &team->option_inst_list, list) { + if (__team_option_inst_tmp_find(&opt_inst_list, opt_inst)) + continue; + list_add(&opt_inst->tmp_list, &opt_inst_list); + } + } + team_nl_send_event_options_get(team, &opt_inst_list); + +as while we retrieve 'opt_inst' from team->option_inst_list, it could +be added to the local 'opt_inst_list' for multiple times. The +__team_option_inst_tmp_find() doesn't work, as the setter +team_mode_option_set() still calls team->ops.exit() which uses +->tmp_list too in __team_options_change_check(). + +Simplify the list operations by moving the 'opt_inst_list' and +team_nl_send_event_options_get() into the nla_for_each_nested() loop so +that it can be guranteed that we won't insert a same list entry for +multiple times. Therefore, __team_option_inst_tmp_find() can be removed +too. + +Fixes: 4fb0534fb7bb ("team: avoid adding twice the same option to the event list") +Fixes: 2fcdb2c9e659 ("team: allow to send multiple set events in one message") +Reported-by: syzbot+4d4af685432dc0e56c91@syzkaller.appspotmail.com +Reported-by: syzbot+68ee510075cf64260cc4@syzkaller.appspotmail.com +Cc: Jiri Pirko +Cc: Paolo Abeni +Signed-off-by: Cong Wang +Acked-by: Jiri Pirko +Reviewed-by: Paolo Abeni +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/team/team.c | 27 +++++---------------------- + 1 file changed, 5 insertions(+), 22 deletions(-) + +--- a/drivers/net/team/team.c ++++ b/drivers/net/team/team.c +@@ -261,17 +261,6 @@ static void __team_option_inst_mark_remo + } + } + +-static bool __team_option_inst_tmp_find(const struct list_head *opts, +- const struct team_option_inst *needle) +-{ +- struct team_option_inst *opt_inst; +- +- list_for_each_entry(opt_inst, opts, tmp_list) +- if (opt_inst == needle) +- return true; +- return false; +-} +- + static int __team_options_register(struct team *team, + const struct team_option *option, + size_t option_count) +@@ -2457,7 +2446,6 @@ static int team_nl_cmd_options_set(struc + int err = 0; + int i; + struct nlattr *nl_option; +- LIST_HEAD(opt_inst_list); + + rtnl_lock(); + +@@ -2477,6 +2465,7 @@ static int team_nl_cmd_options_set(struc + struct nlattr *opt_attrs[TEAM_ATTR_OPTION_MAX + 1]; + struct nlattr *attr; + struct nlattr *attr_data; ++ LIST_HEAD(opt_inst_list); + enum team_option_type opt_type; + int opt_port_ifindex = 0; /* != 0 for per-port options */ + u32 opt_array_index = 0; +@@ -2581,23 +2570,17 @@ static int team_nl_cmd_options_set(struc + if (err) + goto team_put; + opt_inst->changed = true; +- +- /* dumb/evil user-space can send us duplicate opt, +- * keep only the last one +- */ +- if (__team_option_inst_tmp_find(&opt_inst_list, +- opt_inst)) +- continue; +- + list_add(&opt_inst->tmp_list, &opt_inst_list); + } + if (!opt_found) { + err = -ENOENT; + goto team_put; + } +- } + +- err = team_nl_send_event_options_get(team, &opt_inst_list); ++ err = team_nl_send_event_options_get(team, &opt_inst_list); ++ if (err) ++ break; ++ } + + team_put: + team_nl_team_put(team);