Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1856841rwb; Fri, 19 Aug 2022 10:31:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hgRm2PKdINUhxFQoo3a9KNikrPfWpvB8pG39v7j9qyupXlECLaZbYyoMxc3qZosecEkmc X-Received: by 2002:a05:6a00:80b:b0:52e:c38f:f2c9 with SMTP id m11-20020a056a00080b00b0052ec38ff2c9mr8877143pfk.66.1660930291066; Fri, 19 Aug 2022 10:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930291; cv=none; d=google.com; s=arc-20160816; b=GGGpPhfqvB7XrQqteWQ6tQZ5fz2SUxQSCxXZhS9+qHqlOK47fkQIGQw4LVtYumYgDj yHOc319PdvK25BMlX4r+tebgGXUZeEOWz26Vwkd/SSw88H5rvYliebvp31s7oBN8Rt68 I9Jn1Hwa5TL3PvrfhEe7OppRzuf9XvUki8/D6m+XdFx2/f1RGrk6125kU2Nz8DemNto+ EvZp3pPyHomVEwQG3LyJbTF1YC9s+BDIrF+4W/9q7wz5dJgIQfQeNBwWJbI3lOsuPkAg n/ycnXuvoflz7EJcC1dUd8GzuSubY7wXoU+PsZWYYyFfkicoSsuu5vpbMIfP2M8gmoPu 6Akw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Dm9AQyseOSI5B/myzmpDrxoRIjhlVpUQUCh6bpTcDRw=; b=latI4jK7K6EZEl/B/ZfZ3vznJbBYXHStK+ZZrbE17fh3wqf44eNpQeVv1tDiHX09Xo VFCSFJcA7VMf6QIEOJjDBtXfjVlTOYwHcnZkYQiTibF9FlxOfk2LftFypETRI2GcWhe/ HyIJKX6RmOolyO8v6Kp3C1fRVgmxgMlLWETti0dlxr+vhBBWJdYBqZG8ULeOc8VzS/VP Ns1qJLAQohhSbqUfkhgaOfPLHhIRkxJEnxeT/wunHIVsZoc2MardxnwZWw8qQozH/d5H 7rs2lzLxJ+a+ZyeE+OCJt6o0gR+LbsVtr/h/PuJt0LNaWoaPMU8RkxhJ+o8Ag8hwmyoe oONA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CeLq+KJC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u186-20020a6385c3000000b00429fb1ac37dsi1540625pgd.222.2022.08.19.10.31.19; Fri, 19 Aug 2022 10:31:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CeLq+KJC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352852AbiHSQ2d (ORCPT + 99 others); Fri, 19 Aug 2022 12:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352896AbiHSQZs (ORCPT ); Fri, 19 Aug 2022 12:25:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CF82B6D75; Fri, 19 Aug 2022 09:03:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 30229B82802; Fri, 19 Aug 2022 16:03:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E966C433C1; Fri, 19 Aug 2022 16:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925014; bh=rH4/5QZYBSyBtSC5tRu7KwpcfHv88JeoQnMUlVOMGM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CeLq+KJCuar0FkKe23JGhIFv9G3CyrnsynRsRsy3vgFVBSDXCZQok6b6uB6vOa/ty xojpCMxCoR7NEgy3o9tJWBWtSV+L0/AIZzjMcLBJ5rKhwKcqyCZKFXo7xK+UOM5+ug Pb80ZjYAwXg1WVN1rG/fSKnmdsR0NUUS5B4IIcu8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+833061116fa28df97f3b@syzkaller.appspotmail.com, Zhu Yanjun , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 356/545] RDMA/rxe: Fix error unwind in rxe_create_qp() Date: Fri, 19 Aug 2022 17:42:06 +0200 Message-Id: <20220819153845.318534120@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhu Yanjun [ Upstream commit fd5382c5805c4bcb50fd25b7246247d3f7114733 ] In the function rxe_create_qp(), rxe_qp_from_init() is called to initialize qp, internally things like the spin locks are not setup until rxe_qp_init_req(). If an error occures before this point then the unwind will call rxe_cleanup() and eventually to rxe_qp_do_cleanup()/rxe_cleanup_task() which will oops when trying to access the uninitialized spinlock. Move the spinlock initializations earlier before any failures. Fixes: 8700e3e7c485 ("Soft RoCE driver") Link: https://lore.kernel.org/r/20220731063621.298405-1-yanjun.zhu@linux.dev Reported-by: syzbot+833061116fa28df97f3b@syzkaller.appspotmail.com Signed-off-by: Zhu Yanjun Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_qp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index a1b79015e6f2..2847ab4d9a5f 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -184,6 +184,14 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp, spin_lock_init(&qp->grp_lock); spin_lock_init(&qp->state_lock); + spin_lock_init(&qp->req.task.state_lock); + spin_lock_init(&qp->resp.task.state_lock); + spin_lock_init(&qp->comp.task.state_lock); + + spin_lock_init(&qp->sq.sq_lock); + spin_lock_init(&qp->rq.producer_lock); + spin_lock_init(&qp->rq.consumer_lock); + atomic_set(&qp->ssn, 0); atomic_set(&qp->skb_out, 0); } @@ -239,7 +247,6 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, qp->req.opcode = -1; qp->comp.opcode = -1; - spin_lock_init(&qp->sq.sq_lock); skb_queue_head_init(&qp->req_pkts); rxe_init_task(rxe, &qp->req.task, qp, @@ -289,9 +296,6 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp, } } - spin_lock_init(&qp->rq.producer_lock); - spin_lock_init(&qp->rq.consumer_lock); - skb_queue_head_init(&qp->resp_pkts); rxe_init_task(rxe, &qp->resp.task, qp, -- 2.35.1