Received: by 10.223.185.116 with SMTP id b49csp1010843wrg; Wed, 21 Feb 2018 10:31:26 -0800 (PST) X-Google-Smtp-Source: AH8x227S1Hm3vFV6ByN0BFYUG1l5WbldeBZwE0hMs1i2Lha3EewunNYU2PO1KCFUHyLL2lA5JiZ9 X-Received: by 2002:a17:902:7d83:: with SMTP id a3-v6mr3985552plm.184.1519237886310; Wed, 21 Feb 2018 10:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519237886; cv=none; d=google.com; s=arc-20160816; b=gF5sgetcAE6drSJbpgKo+rkGHFkdNtpakYgC+WCe+d4a3imnMwNH+ApRsiqDIGwBX4 cmLkiJZHJglsU7Lt6h6YbFmDo6eC8zwFzUciKkz2f23FXpgaTbH7USfwUGfOKVIyr7YY it5ciI8ePQaVJPsiRSDocxE/1e7HOGMT5+fMgw3evqVPCB+PsKEcWwqY76XRr3RUhNDj KQVuGbdyIKAZP4a4He2NkWDtDh4eC1wp5pcgxOPyVQMDQy4KIRt6hCN+8NEVl0CB06W5 M4Rde1CAsW6cK9nXcZEPys2+6U9fl3DF+QMcbbNhb5U6oHxvBezHT3FAC9V6Xa7jid+S 74Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UE1yJcAZyIh0qf04OFskT53N90bMAJNuprhLwilFTRk=; b=ms0fJArN9vdXbFocm9SzHCiuzbro4mOovMVyCL9ddIANM3J6Jw/a8mq2PG64yOo85+ NY2BbzVXbqnjZHbx30DCPsQkK4JCG2UZ4vu587ey/cXFwKhjeYtuNZugCMlR8E+BzxUH G+Okt5LvDHFQST/c5gtSAPR8IQvGInRGq5hGIH5TP/FEotW4akmNDU+i7a/p6g2gpBrO nOVevkjQvZN8YGl4mA9RoH/fztQDyXca9+07btc4EPTrzEw+WUTOs7a8d9EPcp/pYZvJ 4aPf0Ps2hEkLt9uKXB6FK6yZGdp9AE2W9LspPJOdLq3VXbmvaQJigjDgApHy93mcRzTO BNWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v29si1804484pgc.526.2018.02.21.10.31.11; Wed, 21 Feb 2018 10:31:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964942AbeBUNGB (ORCPT + 99 others); Wed, 21 Feb 2018 08:06:01 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40514 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964913AbeBUNF7 (ORCPT ); Wed, 21 Feb 2018 08:05:59 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B47AE11CD; Wed, 21 Feb 2018 13:05:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Moni Shoua , Doug Ledford Subject: [PATCH 4.15 012/163] RDMA/rxe: Fix rxe_qp_cleanup() Date: Wed, 21 Feb 2018 13:47:21 +0100 Message-Id: <20180221124530.703836813@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche commit bb3ffb7ad48a21e98a5c64eb21103a74fd9f03f6 upstream. rxe_qp_cleanup() can sleep so it must be run in thread context and not in atomic context. This patch avoids that the following bug is triggered: Kernel BUG at 00000000560033f3 [verbose debug info unavailable] BUG: sleeping function called from invalid context at net/core/sock.c:2761 in_atomic(): 1, irqs_disabled(): 0, pid: 7, name: ksoftirqd/0 INFO: lockdep is turned off. Preemption disabled at: [<00000000b6e69628>] __do_softirq+0x4e/0x540 CPU: 0 PID: 7 Comm: ksoftirqd/0 Not tainted 4.15.0-rc7-dbg+ #4 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 Call Trace: dump_stack+0x85/0xbf ___might_sleep+0x177/0x260 lock_sock_nested+0x1d/0x90 inet_shutdown+0x2e/0xd0 rxe_qp_cleanup+0x107/0x140 [rdma_rxe] rxe_elem_release+0x18/0x80 [rdma_rxe] rxe_requester+0x1cf/0x11b0 [rdma_rxe] rxe_do_task+0x78/0xf0 [rdma_rxe] tasklet_action+0x99/0x270 __do_softirq+0xc0/0x540 run_ksoftirqd+0x1c/0x70 smpboot_thread_fn+0x1be/0x270 kthread+0x117/0x130 ret_from_fork+0x24/0x30 Signed-off-by: Bart Van Assche Cc: Moni Shoua Signed-off-by: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/rxe/rxe_qp.c | 12 ++++++++++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -824,9 +824,9 @@ void rxe_qp_destroy(struct rxe_qp *qp) } /* called when the last reference to the qp is dropped */ -void rxe_qp_cleanup(struct rxe_pool_entry *arg) +static void rxe_qp_do_cleanup(struct work_struct *work) { - struct rxe_qp *qp = container_of(arg, typeof(*qp), pelem); + struct rxe_qp *qp = container_of(work, typeof(*qp), cleanup_work.work); rxe_drop_all_mcast_groups(qp); @@ -859,3 +859,11 @@ void rxe_qp_cleanup(struct rxe_pool_entr kernel_sock_shutdown(qp->sk, SHUT_RDWR); sock_release(qp->sk); } + +/* called when the last reference to the qp is dropped */ +void rxe_qp_cleanup(struct rxe_pool_entry *arg) +{ + struct rxe_qp *qp = container_of(arg, typeof(*qp), pelem); + + execute_in_process_context(rxe_qp_do_cleanup, &qp->cleanup_work); +} --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -35,6 +35,7 @@ #define RXE_VERBS_H #include +#include #include #include "rxe_pool.h" #include "rxe_task.h" @@ -281,6 +282,8 @@ struct rxe_qp { struct timer_list rnr_nak_timer; spinlock_t state_lock; /* guard requester and completer */ + + struct execute_work cleanup_work; }; enum rxe_mem_state {