Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3017966rwb; Mon, 15 Aug 2022 16:14:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR5LDHW02JB+GjJvrRZSp9WuM+vsJPrKEIlpAYHn4nFVkYzjoge9eNC35BbBFP2nm6dDe7WE X-Received: by 2002:a17:907:6d8b:b0:730:c160:1f9c with SMTP id sb11-20020a1709076d8b00b00730c1601f9cmr11908350ejc.342.1660605280227; Mon, 15 Aug 2022 16:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605280; cv=none; d=google.com; s=arc-20160816; b=XBOffAt08QJi7dM5jpdgp5+T4U4TXb4s26CGQKpQWfedSBDZ3zb5/wO/ENBnUSF8AQ eU8+v5SPCmXUWq6IFlF7tbpJHWQMSAosZoDEjWGpeMCZdqU76KHVBS30VIr4mXr0U6Gr hdVtGd7fSaj34/J6OREgrOQjp6BpKHkzCJTBE0k62wzUmhJU74c3UcewtiA6fSBz5Rxm kMYNDZsr6VeBtNx1QkctaPKtvE1BNMIrHQd0vOjVV8PQxarveGVEJSeL8d3BAEJGWj2g Ha8ujUp42f7xUYjMifSw6oErylVgeyZYbS9nyePaKcr4R+Tybjv2Ol8Btng50ekNkHw2 l6lA== 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=om8Tip/OfeRbW1wJE4jO1O/eiEcP6gsCODYihAwGexU=; b=GSoU3d7Rp+32uy+Oa+GVMpkb0Kj0aXF2tZLydbGL186rhSKFeZswK6qaIFquiRhQWX o0FxahQBjYRaz5R8XohRgMY9L+bZLHBjulJm4OyGpH/+JhcX+vaU2M88EdfpdshrXhcS KtR39D0yUduPZ9KheBh+k0HMt871gPpFvNgpLrZFZAVKJ9aFoLTE4jci54rm1u52cF53 sIfi3y+0rnPTGdyPM5iRo3vdsA006iHfFTWIh2IiscmQ1tk+yq25iCO1+FMOyhmiYz20 ixRN7IVsf0jX7nuzLrG7PLxuG4D3hwTEaF/54LWii0cpkw8CWojRViw2DcJ0maH/3EIZ bvkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AujAacXa; 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 w24-20020aa7da58000000b0044301c7c7easi7533512eds.613.2022.08.15.16.14.15; Mon, 15 Aug 2022 16:14:40 -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=AujAacXa; 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 S1350861AbiHOW1P (ORCPT + 99 others); Mon, 15 Aug 2022 18:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348074AbiHOWUn (ORCPT ); Mon, 15 Aug 2022 18:20:43 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9F8912422E; Mon, 15 Aug 2022 12:43:25 -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 sin.source.kernel.org (Postfix) with ESMTPS id 6DB92CE12C4; Mon, 15 Aug 2022 19:43:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BB2EC433D6; Mon, 15 Aug 2022 19:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592601; bh=SWJJmdINFVcc3BT0UqIxnJ+boj5QJ5bET70RPyAduao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AujAacXaBP5iKtbTCkU0cr5hFactR0TZAxw9ZY6UZyghSzvg2+bLUEfEebhUywLhA bcKHMteMjtarhMQ/Y49F/txonzydBod3hYD58n7X4sxEKZZwrxMX0wzRvHfAro46uO FcuIt60Yt1xTZkaU5YJCm67fiwX9DKlyV+hxW1B0= 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.18 0814/1095] RDMA/rxe: Fix error unwind in rxe_create_qp() Date: Mon, 15 Aug 2022 20:03:33 +0200 Message-Id: <20220815180502.952224633@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 7d0c4432d3fd..4889dcae0cc8 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -186,6 +186,14 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp, 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); } @@ -245,7 +253,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, @@ -296,9 +303,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