From: Sasha Levin Date: Sun, 8 Mar 2020 18:13:07 +0000 (-0400) Subject: fixes for 4.14 X-Git-Tag: v4.4.216~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=408d8898a3850d4b2f945e8406caa07ef873e511;p=thirdparty%2Fkernel%2Fstable-queue.git fixes for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/kprobes-fix-optimize_kprobe-unoptimize_kprobe-cancel.patch b/queue-4.14/kprobes-fix-optimize_kprobe-unoptimize_kprobe-cancel.patch new file mode 100644 index 00000000000..98e0910e331 --- /dev/null +++ b/queue-4.14/kprobes-fix-optimize_kprobe-unoptimize_kprobe-cancel.patch @@ -0,0 +1,166 @@ +From 55cc9cb5b986d53dcf32319fadb1647e346864f3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 7 Jan 2020 23:42:24 +0900 +Subject: kprobes: Fix optimize_kprobe()/unoptimize_kprobe() cancellation logic + +From: Masami Hiramatsu + +[ Upstream commit e4add247789e4ba5e08ad8256183ce2e211877d4 ] + +optimize_kprobe() and unoptimize_kprobe() cancels if a given kprobe +is on the optimizing_list or unoptimizing_list already. However, since +the following commit: + + f66c0447cca1 ("kprobes: Set unoptimized flag after unoptimizing code") + +modified the update timing of the KPROBE_FLAG_OPTIMIZED, it doesn't +work as expected anymore. + +The optimized_kprobe could be in the following states: + +- [optimizing]: Before inserting jump instruction + op.kp->flags has KPROBE_FLAG_OPTIMIZED and + op->list is not empty. + +- [optimized]: jump inserted + op.kp->flags has KPROBE_FLAG_OPTIMIZED and + op->list is empty. + +- [unoptimizing]: Before removing jump instruction (including unused + optprobe) + op.kp->flags has KPROBE_FLAG_OPTIMIZED and + op->list is not empty. + +- [unoptimized]: jump removed + op.kp->flags doesn't have KPROBE_FLAG_OPTIMIZED and + op->list is empty. + +Current code mis-expects [unoptimizing] state doesn't have +KPROBE_FLAG_OPTIMIZED, and that can cause incorrect results. + +To fix this, introduce optprobe_queued_unopt() to distinguish [optimizing] +and [unoptimizing] states and fixes the logic in optimize_kprobe() and +unoptimize_kprobe(). + +[ mingo: Cleaned up the changelog and the code a bit. ] + +Signed-off-by: Masami Hiramatsu +Reviewed-by: Steven Rostedt (VMware) +Cc: Alexei Starovoitov +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Cc: bristot@redhat.com +Fixes: f66c0447cca1 ("kprobes: Set unoptimized flag after unoptimizing code") +Link: https://lkml.kernel.org/r/157840814418.7181.13478003006386303481.stgit@devnote2 +Signed-off-by: Ingo Molnar +Signed-off-by: Sasha Levin +--- + kernel/kprobes.c | 67 +++++++++++++++++++++++++++++++----------------- + 1 file changed, 43 insertions(+), 24 deletions(-) + +diff --git a/kernel/kprobes.c b/kernel/kprobes.c +index 48bf93bbb22e2..66f1818d47620 100644 +--- a/kernel/kprobes.c ++++ b/kernel/kprobes.c +@@ -625,6 +625,18 @@ void wait_for_kprobe_optimizer(void) + mutex_unlock(&kprobe_mutex); + } + ++static bool optprobe_queued_unopt(struct optimized_kprobe *op) ++{ ++ struct optimized_kprobe *_op; ++ ++ list_for_each_entry(_op, &unoptimizing_list, list) { ++ if (op == _op) ++ return true; ++ } ++ ++ return false; ++} ++ + /* Optimize kprobe if p is ready to be optimized */ + static void optimize_kprobe(struct kprobe *p) + { +@@ -646,17 +658,21 @@ static void optimize_kprobe(struct kprobe *p) + return; + + /* Check if it is already optimized. */ +- if (op->kp.flags & KPROBE_FLAG_OPTIMIZED) ++ if (op->kp.flags & KPROBE_FLAG_OPTIMIZED) { ++ if (optprobe_queued_unopt(op)) { ++ /* This is under unoptimizing. Just dequeue the probe */ ++ list_del_init(&op->list); ++ } + return; ++ } + op->kp.flags |= KPROBE_FLAG_OPTIMIZED; + +- if (!list_empty(&op->list)) +- /* This is under unoptimizing. Just dequeue the probe */ +- list_del_init(&op->list); +- else { +- list_add(&op->list, &optimizing_list); +- kick_kprobe_optimizer(); +- } ++ /* On unoptimizing/optimizing_list, op must have OPTIMIZED flag */ ++ if (WARN_ON_ONCE(!list_empty(&op->list))) ++ return; ++ ++ list_add(&op->list, &optimizing_list); ++ kick_kprobe_optimizer(); + } + + /* Short cut to direct unoptimizing */ +@@ -678,30 +694,33 @@ static void unoptimize_kprobe(struct kprobe *p, bool force) + return; /* This is not an optprobe nor optimized */ + + op = container_of(p, struct optimized_kprobe, kp); +- if (!kprobe_optimized(p)) { +- /* Unoptimized or unoptimizing case */ +- if (force && !list_empty(&op->list)) { +- /* +- * Only if this is unoptimizing kprobe and forced, +- * forcibly unoptimize it. (No need to unoptimize +- * unoptimized kprobe again :) +- */ +- list_del_init(&op->list); +- force_unoptimize_kprobe(op); +- } ++ if (!kprobe_optimized(p)) + return; +- } + + if (!list_empty(&op->list)) { +- /* Dequeue from the optimization queue */ +- list_del_init(&op->list); ++ if (optprobe_queued_unopt(op)) { ++ /* Queued in unoptimizing queue */ ++ if (force) { ++ /* ++ * Forcibly unoptimize the kprobe here, and queue it ++ * in the freeing list for release afterwards. ++ */ ++ force_unoptimize_kprobe(op); ++ list_move(&op->list, &freeing_list); ++ } ++ } else { ++ /* Dequeue from the optimizing queue */ ++ list_del_init(&op->list); ++ op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED; ++ } + return; + } ++ + /* Optimized kprobe case */ +- if (force) ++ if (force) { + /* Forcibly update the code: this is a special case */ + force_unoptimize_kprobe(op); +- else { ++ } else { + list_add(&op->list, &unoptimizing_list); + kick_kprobe_optimizer(); + } +-- +2.20.1 + diff --git a/queue-4.14/net-dsa-bcm_sf2-forcibly-configure-imp-port-for-1gb-.patch b/queue-4.14/net-dsa-bcm_sf2-forcibly-configure-imp-port-for-1gb-.patch new file mode 100644 index 00000000000..f798d1bc654 --- /dev/null +++ b/queue-4.14/net-dsa-bcm_sf2-forcibly-configure-imp-port-for-1gb-.patch @@ -0,0 +1,41 @@ +From 6dad98b00fc18bea8b2a97c588db1ad737f642de Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Feb 2020 15:56:32 -0800 +Subject: net: dsa: bcm_sf2: Forcibly configure IMP port for 1Gb/sec + +From: Florian Fainelli + +[ Upstream commit 98c5f7d44fef309e692c24c6d71131ee0f0871fb ] + +We are still experiencing some packet loss with the existing advanced +congestion buffering (ACB) settings with the IMP port configured for +2Gb/sec, so revert to conservative link speeds that do not produce +packet loss until this is resolved. + +Fixes: 8f1880cbe8d0 ("net: dsa: bcm_sf2: Configure IMP port for 2Gb/sec") +Fixes: de34d7084edd ("net: dsa: bcm_sf2: Only 7278 supports 2Gb/sec IMP port") +Signed-off-by: Florian Fainelli +Reviewed-by: Vivien Didelot +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/dsa/bcm_sf2.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c +index 747062f04bb5e..6bca42e34a53d 100644 +--- a/drivers/net/dsa/bcm_sf2.c ++++ b/drivers/net/dsa/bcm_sf2.c +@@ -138,8 +138,7 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port) + /* Force link status for IMP port */ + reg = core_readl(priv, offset); + reg |= (MII_SW_OR | LINK_STS); +- if (priv->type == BCM7278_DEVICE_ID) +- reg |= GMII_SPEED_UP_2G; ++ reg &= ~GMII_SPEED_UP_2G; + core_writel(priv, reg, offset); + + /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ +-- +2.20.1 + diff --git a/queue-4.14/rdma-core-fix-pkey-and-port-assignment-in-get_new_pp.patch b/queue-4.14/rdma-core-fix-pkey-and-port-assignment-in-get_new_pp.patch new file mode 100644 index 00000000000..fe737674f5d --- /dev/null +++ b/queue-4.14/rdma-core-fix-pkey-and-port-assignment-in-get_new_pp.patch @@ -0,0 +1,107 @@ +From 137394a02976cb8b4b640823cfa8b31545a46208 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Feb 2020 14:57:28 +0200 +Subject: RDMA/core: Fix pkey and port assignment in get_new_pps + +From: Maor Gottlieb + +[ Upstream commit 801b67f3eaafd3f2ec8b65d93142d4ffedba85df ] + +When port is part of the modify mask, then we should take it from the +qp_attr and not from the old pps. Same for PKEY. Otherwise there are +panics in some configurations: + + RIP: 0010:get_pkey_idx_qp_list+0x50/0x80 [ib_core] + Code: c7 18 e8 13 04 30 ef 0f b6 43 06 48 69 c0 b8 00 00 00 48 03 85 a0 04 00 00 48 8b 50 20 48 8d 48 20 48 39 ca 74 1a 0f b7 73 04 <66> 39 72 10 75 08 eb 10 66 39 72 10 74 0a 48 8b 12 48 39 ca 75 f2 + RSP: 0018:ffffafb3480932f0 EFLAGS: 00010203 + RAX: ffff98059ababa10 RBX: ffff980d926e8cc0 RCX: ffff98059ababa30 + RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff98059ababa28 + RBP: ffff98059b940000 R08: 00000000000310c0 R09: ffff97fe47c07480 + R10: 0000000000000036 R11: 0000000000000200 R12: 0000000000000071 + R13: ffff98059b940000 R14: ffff980d87f948a0 R15: 0000000000000000 + FS: 00007f88deb31740(0000) GS:ffff98059f600000(0000) knlGS:0000000000000000 + CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 + CR2: 0000000000000010 CR3: 0000000853e26001 CR4: 00000000001606e0 + Call Trace: + port_pkey_list_insert+0x3d/0x1b0 [ib_core] + ? kmem_cache_alloc_trace+0x215/0x220 + ib_security_modify_qp+0x226/0x3a0 [ib_core] + _ib_modify_qp+0xcf/0x390 [ib_core] + ipoib_init_qp+0x7f/0x200 [ib_ipoib] + ? rvt_modify_port+0xd0/0xd0 [rdmavt] + ? ib_find_pkey+0x99/0xf0 [ib_core] + ipoib_ib_dev_open_default+0x1a/0x200 [ib_ipoib] + ipoib_ib_dev_open+0x96/0x130 [ib_ipoib] + ipoib_open+0x44/0x130 [ib_ipoib] + __dev_open+0xd1/0x160 + __dev_change_flags+0x1ab/0x1f0 + dev_change_flags+0x23/0x60 + do_setlink+0x328/0xe30 + ? __nla_validate_parse+0x54/0x900 + __rtnl_newlink+0x54e/0x810 + ? __alloc_pages_nodemask+0x17d/0x320 + ? page_fault+0x30/0x50 + ? _cond_resched+0x15/0x30 + ? kmem_cache_alloc_trace+0x1c8/0x220 + rtnl_newlink+0x43/0x60 + rtnetlink_rcv_msg+0x28f/0x350 + ? kmem_cache_alloc+0x1fb/0x200 + ? _cond_resched+0x15/0x30 + ? __kmalloc_node_track_caller+0x24d/0x2d0 + ? rtnl_calcit.isra.31+0x120/0x120 + netlink_rcv_skb+0xcb/0x100 + netlink_unicast+0x1e0/0x340 + netlink_sendmsg+0x317/0x480 + ? __check_object_size+0x48/0x1d0 + sock_sendmsg+0x65/0x80 + ____sys_sendmsg+0x223/0x260 + ? copy_msghdr_from_user+0xdc/0x140 + ___sys_sendmsg+0x7c/0xc0 + ? skb_dequeue+0x57/0x70 + ? __inode_wait_for_writeback+0x75/0xe0 + ? fsnotify_grab_connector+0x45/0x80 + ? __dentry_kill+0x12c/0x180 + __sys_sendmsg+0x58/0xa0 + do_syscall_64+0x5b/0x200 + entry_SYSCALL_64_after_hwframe+0x44/0xa9 + RIP: 0033:0x7f88de467f10 + +Link: https://lore.kernel.org/r/20200227125728.100551-1-leon@kernel.org +Cc: +Fixes: 1dd017882e01 ("RDMA/core: Fix protection fault in get_pkey_idx_qp_list") +Signed-off-by: Maor Gottlieb +Signed-off-by: Leon Romanovsky +Tested-by: Mike Marciniszyn +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/core/security.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c +index 9b82766913294..61aff69e9f67b 100644 +--- a/drivers/infiniband/core/security.c ++++ b/drivers/infiniband/core/security.c +@@ -339,11 +339,15 @@ static struct ib_ports_pkeys *get_new_pps(const struct ib_qp *qp, + return NULL; + + if (qp_attr_mask & IB_QP_PORT) +- new_pps->main.port_num = +- (qp_pps) ? qp_pps->main.port_num : qp_attr->port_num; ++ new_pps->main.port_num = qp_attr->port_num; ++ else if (qp_pps) ++ new_pps->main.port_num = qp_pps->main.port_num; ++ + if (qp_attr_mask & IB_QP_PKEY_INDEX) +- new_pps->main.pkey_index = (qp_pps) ? qp_pps->main.pkey_index : +- qp_attr->pkey_index; ++ new_pps->main.pkey_index = qp_attr->pkey_index; ++ else if (qp_pps) ++ new_pps->main.pkey_index = qp_pps->main.pkey_index; ++ + if ((qp_attr_mask & IB_QP_PKEY_INDEX) && (qp_attr_mask & IB_QP_PORT)) + new_pps->main.state = IB_PORT_PKEY_VALID; + +-- +2.20.1 + diff --git a/queue-4.14/rdma-core-fix-use-of-logical-or-in-get_new_pps.patch b/queue-4.14/rdma-core-fix-use-of-logical-or-in-get_new_pps.patch new file mode 100644 index 00000000000..6aea340cf1a --- /dev/null +++ b/queue-4.14/rdma-core-fix-use-of-logical-or-in-get_new_pps.patch @@ -0,0 +1,47 @@ +From c412ba1fe010beec5ce697e508b36e3fdca56a06 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 17 Feb 2020 13:43:18 -0700 +Subject: RDMA/core: Fix use of logical OR in get_new_pps + +From: Nathan Chancellor + +[ Upstream commit 4ca501d6aaf21de31541deac35128bbea8427aa6 ] + +Clang warns: + +../drivers/infiniband/core/security.c:351:41: warning: converting the +enum constant to a boolean [-Wint-in-bool-context] + if (!(qp_attr_mask & (IB_QP_PKEY_INDEX || IB_QP_PORT)) && qp_pps) { + ^ +1 warning generated. + +A bitwise OR should have been used instead. + +Fixes: 1dd017882e01 ("RDMA/core: Fix protection fault in get_pkey_idx_qp_list") +Link: https://lore.kernel.org/r/20200217204318.13609-1-natechancellor@gmail.com +Link: https://github.com/ClangBuiltLinux/linux/issues/889 +Reported-by: Dan Carpenter +Signed-off-by: Nathan Chancellor +Reviewed-by: Leon Romanovsky +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/core/security.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c +index 61aff69e9f67b..ce8e3009344a5 100644 +--- a/drivers/infiniband/core/security.c ++++ b/drivers/infiniband/core/security.c +@@ -351,7 +351,7 @@ static struct ib_ports_pkeys *get_new_pps(const struct ib_qp *qp, + if ((qp_attr_mask & IB_QP_PKEY_INDEX) && (qp_attr_mask & IB_QP_PORT)) + new_pps->main.state = IB_PORT_PKEY_VALID; + +- if (!(qp_attr_mask & (IB_QP_PKEY_INDEX || IB_QP_PORT)) && qp_pps) { ++ if (!(qp_attr_mask & (IB_QP_PKEY_INDEX | IB_QP_PORT)) && qp_pps) { + new_pps->main.port_num = qp_pps->main.port_num; + new_pps->main.pkey_index = qp_pps->main.pkey_index; + if (qp_pps->main.state != IB_PORT_PKEY_NOT_VALID) +-- +2.20.1 + diff --git a/queue-4.14/series b/queue-4.14/series index e5bf2bb594f..b1d442e452f 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -67,3 +67,7 @@ audit-always-check-the-netlink-payload-length-in-aud.patch vhost-check-docket-sk_family-instead-of-call-getname.patch x86-mce-handle-varying-mca-bank-counts.patch edac-amd64-set-grain-per-dimm.patch +net-dsa-bcm_sf2-forcibly-configure-imp-port-for-1gb-.patch +rdma-core-fix-pkey-and-port-assignment-in-get_new_pp.patch +rdma-core-fix-use-of-logical-or-in-get_new_pps.patch +kprobes-fix-optimize_kprobe-unoptimize_kprobe-cancel.patch