From patchwork Tue Jan 22 07:18:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 10774983 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7C2213B5 for ; Tue, 22 Jan 2019 07:12:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BF362A991 for ; Tue, 22 Jan 2019 07:12:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E1C32AB41; Tue, 22 Jan 2019 07:12:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18EAD2A991 for ; Tue, 22 Jan 2019 07:12:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727179AbfAVHM7 (ORCPT ); Tue, 22 Jan 2019 02:12:59 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57656 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbfAVHM6 (ORCPT ); Tue, 22 Jan 2019 02:12:58 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0M797WY161597; Tue, 22 Jan 2019 07:12:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2018-07-02; bh=Vapst0VUt2Z99uNeRgAzEJRN5Yyvw9vW/Wyo1CW4/Yg=; b=N5p97ukEp+HPScE/uc6i5VW0u8nYNU4Dja7pInRSwJmXij/tpf23ui4plz+eZvFVAr8W sduta3GPsNVn/Q56ZT3iwsMIR57mQXKDUeO/xlUFyF+AOHyjJPtI8WDJRkyEsxAxFFdM K7KXHWwcKNlIwy52erGFp81SN5pU2fdK3TfYjctKGZF4PbKDThIW/O5LuH0uzRSu08Io X7/VBq1spxyd8pTQjrPLzAmy2mjt5eZa0RmkwDjX2sh6ljSoX8gJ7GOoXxNJbcyUOSbb 5fMKePaoyliRwcfzrW0yhfahvfcitmsZuow9YabiXdAp6P9/Oe2G3wT1/DskQUq+xrEm AA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2q3vhrhpw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jan 2019 07:12:54 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0M7CsDK016374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jan 2019 07:12:54 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0M7CrRF016125; Tue, 22 Jan 2019 07:12:53 GMT Received: from shipboat.cn.oracle.com (/10.182.69.89) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 Jan 2019 23:12:53 -0800 From: Zhu Yanjun To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, haakon.bugge@oracle.com, junxiao.bi@oracle.com Subject: [PATCH 1/1] RDMA/core: avoid kernel NULL pointer error Date: Tue, 22 Jan 2019 02:18:21 -0500 Message-Id: <20190122071821.16174-1-yanjun.zhu@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9143 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=946 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901220059 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the interface related with IB device is set to down/up over and over again, the following call trace will pop out. " Call Trace: [] ib_mad_completion_handler+0x7d/0xa0 [ib_mad] [] process_one_work+0x151/0x4b0 [] worker_thread+0x120/0x480 [] kthread+0xce/0xf0 [] ret_from_fork+0x42/0x70 RIP [] ib_mad_recv_done_handler+0x26/0x610 [ib_mad] " From vmcore, we can find the following: " crash7lates> struct ib_mad_list_head ffff881fb3713400 struct ib_mad_list_head { list = { next = 0xffff881fb3713800, prev = 0xffff881fe01395c0 }, mad_queue = 0x0 } " Before the call trace, a lot of ib_cancel_mad is sent to the sender. So it is necessary to check mad_queue in struct ib_mad_list_head to avoid "kernel NULL pointer" error. Signed-off-by: Zhu Yanjun --- drivers/infiniband/core/mad.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 7870823bac47..ab5a7d1152ca 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -2250,6 +2250,17 @@ static void ib_mad_recv_done(struct ib_cq *cq, struct ib_wc *wc) return; } + if (unlikely(!mad_list->mad_queue)) { + /* + * When the interface related with IB device is set to down/up, + * a lot of ib_cancel_mad packets are sent to the sender. In + * sender, the mad packets are cancelled. The receiver will + * find mad_queue NULL. If the receiver does not test mad_queue, + * the receiver will crash with "kernel NULL pointer" error. + */ + return; + } + qp_info = mad_list->mad_queue->qp_info; dequeue_mad(mad_list);