Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6825027rwn; Tue, 13 Sep 2022 09:28:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR4UdSu1pfQhFYghs5JmSIkFwmXLtgmRA0opSxOV2VmiIdkmxU0wo5wTU5nlYO/56CpXJMK0 X-Received: by 2002:a17:903:2cb:b0:171:4f0d:beb6 with SMTP id s11-20020a17090302cb00b001714f0dbeb6mr32042153plk.53.1663086481441; Tue, 13 Sep 2022 09:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086481; cv=none; d=google.com; s=arc-20160816; b=GzeE7rVW8y/NhaXurChP5uuctoEOCkXMOfmWuRqqo4raH2KrlrT2lWyotMkd/FtYaU HzBRgKuICEaNQhfwkGB1NYi4kZk8SAO75j1wk/wxC0zad5cJP+Ux84IZ4Y1vh7vzFomC M8sSmogFK7OTjeiCuhVfxBvatTL9brfo2hgIzquYc5lqXhD/YriDQ6zshLbBFGQTrM9Z yYXyqFULwXrbd2I5mHvM2aHxB7sHz7CoU8rXQ7qtYDgrJWlTKoQXZxxoTQGmbwaSZtIF 6ch5yVg0tHgjZX5+tJKmvlCjKj+Q2dd99pMbm9OpiwSjOdhRz8W+p7Ji4UnLvNkZI0/T 2TjA== 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=HfzHqWllK3WknJXfWRepowHl72t+Dej8qRg5bRumypg=; b=bi8R9OjiXzwQAOdN5oYE4uriZMLD1CM9DZwKgWfMUmGwFW9BY48uOO1MeF/1Ki3BeE nT/EOo3n4n+BBR/5Mf14NreT40EGkfZpSTH13PVJX547kGod9ueNsIcbh8Z/9ok04PTX AOrUXKECDo5u+kZgf02KJGHbXV7N13ln2bc8PgEclen6gGJTsldM4LU2CToPimzx0YNO zGn/t8f/SI9yx5bnX1lhO1hu1QhKC9JxCuN/PgwVfdg5QxUM57Y3Bz2uZiyXojzbaDsz NMjIxYgvDHMeIK2/I+R1Vak4UWAP4illSBta1gJ1WE85AowrsMAnmwy/QUGpRdDYdoef VbFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IkpkthNk; 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 u1-20020a17090341c100b00176d6e8c127si13107673ple.126.2022.09.13.09.27.49; Tue, 13 Sep 2022 09:28:01 -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=IkpkthNk; 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 S232223AbiIMO7m (ORCPT + 99 others); Tue, 13 Sep 2022 10:59:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234829AbiIMO47 (ORCPT ); Tue, 13 Sep 2022 10:56:59 -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 4101A73319; Tue, 13 Sep 2022 07:27:51 -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 3D1ED614D2; Tue, 13 Sep 2022 14:20:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57632C433C1; Tue, 13 Sep 2022 14:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078824; bh=B+tXHmShi2K/eDzM41fWdvTpBinpQU1npj0mHyqDyUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IkpkthNktIMzHRyslD1/mA6henKO2uFwjGJtgQ7MwTGSQGZaME4hmfNXnOtXv+A7n xTT4rk0J5tKkdF959J9AHRtP9bbDhpa1CA3XXzE/9qwCclfDROO7DHaBvLmITRZ3jx Rvkc3CMcyQfgX3HFXzJX3qNvY5eKC/syc6Ff6qSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiao Yang , Bart Van Assche , Leon Romanovsky , Sasha Levin Subject: [PATCH 5.15 070/121] RDMA/srp: Set scmnd->result only when scmnd is not NULL Date: Tue, 13 Sep 2022 16:04:21 +0200 Message-Id: <20220913140400.374728274@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@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: yangx.jy@fujitsu.com [ Upstream commit 12f35199a2c0551187edbf8eb01379f0598659fa ] This change fixes the following kernel NULL pointer dereference which is reproduced by blktests srp/007 occasionally. BUG: kernel NULL pointer dereference, address: 0000000000000170 PGD 0 P4D 0 Oops: 0002 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 9 Comm: kworker/0:1H Kdump: loaded Not tainted 6.0.0-rc1+ #37 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-29-g6a62e0cb0dfe-prebuilt.qemu.org 04/01/2014 Workqueue: 0x0 (kblockd) RIP: 0010:srp_recv_done+0x176/0x500 [ib_srp] Code: 00 4d 85 ff 0f 84 52 02 00 00 48 c7 82 80 02 00 00 00 00 00 00 4c 89 df 4c 89 14 24 e8 53 d3 4a f6 4c 8b 14 24 41 0f b6 42 13 <41> 89 87 70 01 00 00 41 0f b6 52 12 f6 c2 02 74 44 41 8b 42 1c b9 RSP: 0018:ffffaef7c0003e28 EFLAGS: 00000282 RAX: 0000000000000000 RBX: ffff9bc9486dea60 RCX: 0000000000000000 RDX: 0000000000000102 RSI: ffffffffb76bbd0e RDI: 00000000ffffffff RBP: ffff9bc980099a00 R08: 0000000000000001 R09: 0000000000000001 R10: ffff9bca53ef0000 R11: ffff9bc980099a10 R12: ffff9bc956e14000 R13: ffff9bc9836b9cb0 R14: ffff9bc9557b4480 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff9bc97ec00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000170 CR3: 0000000007e04000 CR4: 00000000000006f0 Call Trace: __ib_process_cq+0xb7/0x280 [ib_core] ib_poll_handler+0x2b/0x130 [ib_core] irq_poll_softirq+0x93/0x150 __do_softirq+0xee/0x4b8 irq_exit_rcu+0xf7/0x130 sysvec_apic_timer_interrupt+0x8e/0xc0 Fixes: ad215aaea4f9 ("RDMA/srp: Make struct scsi_cmnd and struct srp_request adjacent") Link: https://lore.kernel.org/r/20220831081626.18712-1-yangx.jy@fujitsu.com Signed-off-by: Xiao Yang Acked-by: Bart Van Assche Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/srp/ib_srp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 5d416ec228717..473b3a08cf96d 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1955,7 +1955,8 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) if (scmnd) { req = scsi_cmd_priv(scmnd); scmnd = srp_claim_req(ch, req, NULL, scmnd); - } else { + } + if (!scmnd) { shost_printk(KERN_ERR, target->scsi_host, "Null scmnd for RSP w/tag %#016llx received on ch %td / QP %#x\n", rsp->tag, ch - target->ch, ch->qp->qp_num); -- 2.35.1