Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3512457rwa; Tue, 23 Aug 2022 06:05:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5iXR3g/FLt/YSB67bXzwtE9hkfUMF10YWyjPJB1rBYQx5lBZLh8V7dWiR1c23p1zcmx7aJ X-Received: by 2002:a17:902:aa47:b0:172:ef81:782d with SMTP id c7-20020a170902aa4700b00172ef81782dmr8208230plr.173.1661259904648; Tue, 23 Aug 2022 06:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661259904; cv=none; d=google.com; s=arc-20160816; b=KuVQUzyyxgMQYpMYt5RoDiB4WGJwLN5g2ZahJarfNxvAaBvoEn9oikz2MYDDe+8Afc AAzcoMyHjqUQe2cRfxV4S5+9KVBQKGaQMHDdf7BTCUyOPkEJWsa3q6J8FKqCiu8f1jwc hKZoMZN0N8U/RYzI5uu7+FHQEMj4Tum0fjdKYH1PlyEctsBrtjZT3F4itExB1VwbU3pf qOsRCS7/6EFbYjxDYGl4LmVX75QSqrVcmgki6sObYmsDFDifIlnpCwskdwrXAQXPrFxO Fp9p2z81lvLKP0f4T6fpV9U7bnYIH+5g9zHtX97fULbFkC+UEBxCogpCNy6Q5brZlvEM EJEQ== 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=hqacaUGmn0TkawEcoMN9pEkl2mhIosEqUexYdiO6xt4=; b=egi8HwIZgqFB/D7ZN0EMIpbw1YRKVScl0nyR5g3wjah8dtcvD/FqmiEw+0BJVea0Cx sLeRvHDaZ4K54TpbKAx8mPhaI3IBnvbHXyWpeltwxSH73lRDvuRzRMOs74SWAqwhpmd9 ij6A2UzL58F4IHLIcuTgOKWFbXJdZEg+kLZcrNun9dYjsOkVbaroUc8iRxVqXrq5lcSH Qqo6pl5mDxxu1zGJukYdeW5zAGUE1ZgNrvBcFeRvuu+HMRkrcQGtCygb9kPJjxpB7MUS hsJDIfbGJBo5olHbSBQGxh+cGW3fRuy7pmmrHNeGcRkTYLnH5Uiia9J9Zqd+foZt0QOy k2/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RRGDXLiN; 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 ng9-20020a17090b1a8900b001fadba632bfsi15578419pjb.2.2022.08.23.06.04.28; Tue, 23 Aug 2022 06:05:04 -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=RRGDXLiN; 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 S1357835AbiHWLjS (ORCPT + 99 others); Tue, 23 Aug 2022 07:39:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358053AbiHWLcT (ORCPT ); Tue, 23 Aug 2022 07:32:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE3976766; Tue, 23 Aug 2022 02:26:42 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 22F306126A; Tue, 23 Aug 2022 09:26:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0D86C433D6; Tue, 23 Aug 2022 09:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246801; bh=5lKGN2oaAVcYLUHRmRQw6FQNrS5NbTnpyleZkf5ojeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RRGDXLiN40SL524tM3dkH2HTKFKWwU76E9iz7aUOwO7KobeC2wwlpd2KroYf6VQGv athx2auM0YHUJINhChLa3yF9RL3bhnHPxup5nhenRUJy177diTNh/fdDX0md8ooJPI m+46tcesXFZRreuUs7bXJd6j/1XsfT4YecF8xmdA= 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.4 197/389] RDMA/rxe: Fix error unwind in rxe_create_qp() Date: Tue, 23 Aug 2022 10:24:35 +0200 Message-Id: <20220823080123.869751969@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@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 53166b9ae67e..57f111fe5443 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -211,6 +211,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); } @@ -268,7 +276,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, @@ -318,9 +325,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