From patchwork Mon Oct 24 11:30:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp430729wru; Mon, 24 Oct 2022 05:42:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6rGvXZ7HzE+FbrMmdN6xdcQhiuLPvrLIPlUr2bmsuEngbyaDcTzWJTGQYyeDzOF1xNWjjF X-Received: by 2002:a63:5b05:0:b0:460:a6a:ec38 with SMTP id p5-20020a635b05000000b004600a6aec38mr27468000pgb.485.1666615330832; Mon, 24 Oct 2022 05:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615330; cv=none; d=google.com; s=arc-20160816; b=XmKyLw7RQ8Fl/HA2NlYGEBh39BLcxxkUrfytUO2RNFSIbbBdEh2Nss+EaC4bBuciIx xhaUM2fMd5270NYEwGmS9rAT1iL1tr+kSekUhoFuCjz01ZAfaCyLl1mr8F1LZECTtK1W I7GhATIvFkdYbX613wZ4dma/+DfnLbir2kTdQtWbej7B7iLTV407EhruHv0wjw1lqAJT Zs6ujR84P0AvKJmnIsrPHSav5qtBIeCS0UY6ObuUwsEPRSDD8uZnd14R/XfNEcaApqJ+ qA7q4glbK7gBmhqe9dZo0jR5Ar7sr154vDhtI/tNDkq6aLFOCkw22kN5EilhzkQkk0Qm 5zyA== 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=ulWHEYPdNAwn/dIrelnomw6rVfo+liDEnScvzVGC7AU=; b=NZ+tz74R+ufY7NhbgXx3oR0NkYg+wDzVHAw5CkWHOP2hv/R/ITF2BPaSnge2QYVFdy dK/TkoLkne031MDEYEjmsVi1C+Sj3BGYH7pTCICJI0kxDkbG/4UtdLzhsu7G2rCj8u83 CSI+PdgUpFBdFTuAoY1WhEC2w6g41bBepnPFvIGnVDRbes7w2sa9zc+V+JE1vkquVk0r YdrsaEo8rCjIUElx0j01jt4RFjMa21W6UcV+RBcmZRXylCRRWsoYOqOmM91psNoL9pfA 3ZA0vyIn6Jg0AQJ5wXdnnfY4GZI+5/e5wXmymdilJXr9R7cA4w1ZmeJPrbqC84YvPqdQ J55A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hkht0Y9S; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a63ee0c000000b0042b16d0cbf9si35441460pgi.638.2022.10.24.05.41.56; Mon, 24 Oct 2022 05:42:10 -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=Hkht0Y9S; 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 S230156AbiJXMdF (ORCPT + 99 others); Mon, 24 Oct 2022 08:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234037AbiJXM3N (ORCPT ); Mon, 24 Oct 2022 08:29:13 -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 0CAB386FA1; Mon, 24 Oct 2022 05:03:06 -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 59E5DB8120C; Mon, 24 Oct 2022 12:00:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB8B6C433D6; Mon, 24 Oct 2022 12:00:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612817; bh=oW7cK+FgFeRGM8uvw9N6ZCn4rBD7IY418OcUHQF2Ln4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hkht0Y9ST+iEJk0Z1cuNJ9KhYf/9kcHxQfVLRbwvVMzsOLr5HiGqPSQ6R384PaIcm vG9me0VGO8FlK4ORTutPiuFbrr8cWypdUiVdMhPRQ+YbUT103tMRUGPIWWFrZhoMKj AkQj8zz3ncTYAUz0GMOJ2HF+XhJq6cL+tDIDResc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+ab99dc4c6e961eed8b8e@syzkaller.appspotmail.com, Zhu Yanjun , Li Zhijian , Bob Pearson , Leon Romanovsky , Sasha Levin Subject: [PATCH 4.19 131/229] RDMA/rxe: Fix "kernel NULL pointer dereference" error Date: Mon, 24 Oct 2022 13:30:50 +0200 Message-Id: <20221024113003.240809208@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747572837318913381?= X-GMAIL-MSGID: =?utf-8?q?1747572837318913381?= From: Zhu Yanjun [ Upstream commit a625ca30eff806395175ebad3ac1399014bdb280 ] When rxe_queue_init in the function rxe_qp_init_req fails, both qp->req.task.func and qp->req.task.arg are not initialized. Because of creation of qp fails, the function rxe_create_qp will call rxe_qp_do_cleanup to handle allocated resource. Before calling __rxe_do_task, both qp->req.task.func and qp->req.task.arg should be checked. Fixes: 8700e3e7c485 ("Soft RoCE driver") Link: https://lore.kernel.org/r/20220822011615.805603-2-yanjun.zhu@linux.dev Reported-by: syzbot+ab99dc4c6e961eed8b8e@syzkaller.appspotmail.com Signed-off-by: Zhu Yanjun Reviewed-by: Li Zhijian Reviewed-by: Bob Pearson Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_qp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index a4b5374deac8..476871c8ae44 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -799,7 +799,9 @@ void rxe_qp_destroy(struct rxe_qp *qp) rxe_cleanup_task(&qp->comp.task); /* flush out any receive wr's or pending requests */ - __rxe_do_task(&qp->req.task); + if (qp->req.task.func) + __rxe_do_task(&qp->req.task); + if (qp->sq.queue) { __rxe_do_task(&qp->comp.task); __rxe_do_task(&qp->req.task);