Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2403120ybf; Mon, 2 Mar 2020 07:58:58 -0800 (PST) X-Google-Smtp-Source: ADFU+vv2BFn1U7sgMWqTKmk91ubPHRQCJWWWFgayKhZIjyB8Uo9QIagka+PKiMdRfU7lDZPOD8d3 X-Received: by 2002:aca:1903:: with SMTP id l3mr140686oii.16.1583164738104; Mon, 02 Mar 2020 07:58:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583164738; cv=none; d=google.com; s=arc-20160816; b=CxWKStemuXBa2deq/wzMQOmJGx+NhLjw3ri1gz4Bb53whcMzwrjhwjai0Di3SIfLPm u8J1OWKO0g+RnY8vdddHZOi+MDW6cCideojotZ4nY+nlL2cl56Go2QiSyJnD1QdohADs PJidKwkQTeKK8hK0YdgGKYYTtEl1ciPWHU4Yy209WHg1/iVfH3qx1RlwqCzq5NzYsEXs /KxLSV0rgxW2wdEIeZTQtRqfllQhcdBZZKNi2T4PuUSJjsx15qPz/p0fsXGUC+dfGqcF Fw3hW+YjFbIYJqiWvm9ZS/0EMleBMDuWNd8PX3zdakHd/BhlNi6hThLbGOAwpZtwL0Nh cXwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=4lRi9KELbjp6COZ58tk42PLML2j41Invq+nXKKmP0a0=; b=e83QN6FaXJrhWS8NyyvhIYEzHuoNJ/ujZ4YLWUd73iJGgcOpIuCxcS92uxEbdb9n7H sgh16AmaTuG/bHBkAKJjbJbi89IVBbL605yDLVXkQGnIRaJyVq9Yb47ucIEKAJ2/MyvM N8uBwhIzqp4NaD5l5luAFLb4UNvM9nAb/HonKB5HFvbBxWWYl4ay6t9eGwCxtbeZy6n6 vP1mmNzpY0ZjgoWq1ZFrkmZlDvyRQJoEpxMW2lIC7KCh7Z4VMcwMtiAGZED9FCHG20SQ T50H9x7sVOIv8nPHnFF5kwhTW5EVBsKwytM84BREIqGqQQ00WhkrtYSqiNeBW1UGSsfo ghOQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si2695492oto.195.2020.03.02.07.58.46; Mon, 02 Mar 2020 07:58:58 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727304AbgCBP6Y (ORCPT + 99 others); Mon, 2 Mar 2020 10:58:24 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:3400 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbgCBP6Y (ORCPT ); Mon, 2 Mar 2020 10:58:24 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 022FnsAe036178 for ; Mon, 2 Mar 2020 10:58:23 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yfmwvc1md-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 02 Mar 2020 10:58:23 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Mar 2020 15:58:20 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 2 Mar 2020 15:58:17 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 022FwGrd51118282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Mar 2020 15:58:16 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D24CFA4062; Mon, 2 Mar 2020 15:58:16 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AD0AA405B; Mon, 2 Mar 2020 15:58:16 +0000 (GMT) Received: from spoke.zurich.ibm.com (unknown [9.4.69.152]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Mar 2020 15:58:16 +0000 (GMT) From: Bernard Metzler To: dledford@redhat.com, jgg@ziepe.ca, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Cc: Bernard Metzler Subject: [Patch for-rc v2] RDMA/siw: Fix failure handling during device creation Date: Mon, 2 Mar 2020 16:58:14 +0100 X-Mailer: git-send-email 2.17.2 X-TM-AS-GCONF: 00 x-cbid: 20030215-0008-0000-0000-000003587D7C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20030215-0009-0000-0000-00004A79A9BE Message-Id: <20200302155814.9896-1-bmt@zurich.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-02_05:2020-03-02,2020-03-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003020112 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A failing call to ib_device_set_netdev() during device creation caused system crash due to xa_destroy of uninitialized xarray hit by device deallocation. Fixed by moving xarray initialization before potential device deallocation. Fixes: bdcf26bf9b3a (rdma/siw: network and RDMA core interface) Reported-by: syzbot+2e80962bedd9559fe0b3@syzkaller.appspotmail.com Signed-off-by: Bernard Metzler --- v1 -> v2: - Fix here only potential system crash during failing device creation, but not missing correct error propagation. drivers/infiniband/sw/siw/siw_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c index 96ed349c0939..5cd40fb9e20c 100644 --- a/drivers/infiniband/sw/siw/siw_main.c +++ b/drivers/infiniband/sw/siw/siw_main.c @@ -388,6 +388,9 @@ static struct siw_device *siw_device_create(struct net_device *netdev) { .max_segment_size = SZ_2G }; base_dev->num_comp_vectors = num_possible_cpus(); + xa_init_flags(&sdev->qp_xa, XA_FLAGS_ALLOC1); + xa_init_flags(&sdev->mem_xa, XA_FLAGS_ALLOC1); + ib_set_device_ops(base_dev, &siw_device_ops); rv = ib_device_set_netdev(base_dev, netdev, 1); if (rv) @@ -415,9 +418,6 @@ static struct siw_device *siw_device_create(struct net_device *netdev) sdev->attrs.max_srq_wr = SIW_MAX_SRQ_WR; sdev->attrs.max_srq_sge = SIW_MAX_SGE; - xa_init_flags(&sdev->qp_xa, XA_FLAGS_ALLOC1); - xa_init_flags(&sdev->mem_xa, XA_FLAGS_ALLOC1); - INIT_LIST_HEAD(&sdev->cep_list); INIT_LIST_HEAD(&sdev->qp_list); -- 2.17.2