From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796079291; b=H8YyXomLkYqHNyC/rzzJLgwYGiBPNa0a+khqfy4ZY40fbYOn/HUvRRUyWGZemWHbsTUt VmjeW/WPCXPLr0MTW6/BRMpFq2W2IHx8Vls0mdiUxJCgfeO0r92LIawnVf8UIlkvtZFWi 3+c8777zu1iM84u7+A6LRUYvQdDJRm3TSzoiMy/xohrRfSpZCBoWWQ7+4FzEsqYg0k9jf e0BJc23dRbsvbcTH8QGPXB+l7uN9P+UjepJy8wuTmIUNyVdiSpqdb3Xxfi3vdh035JX84 /+AoqpuUYbUHD+Jz/p1/yR6Tk5HI7aOiCaVSO2QqVVtFVw0hjRJSIZk7fpipgmqgMwQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796079291; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:User-Agent:MIME-Version:Content-Type: X-TM-AS-GCONF:X-Proofpoint-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=/BuFklTz2KxJWSOc9Q9aPDX5FT52cvDU40EfIl4bmIM=; b=2UWVo4t4YCm7PGrk3zvJMC9C1o9M57fMKoLbvp/+JMhKQ9TZFygMVTh5D1ugqNb6c5r9 xfKO5em+RiV2eZg3EJ9Vtr0T91DcEOf/JKSwk0F+dC94W4Gu55Q3tt08abfx4hI2iH2Bm DZRr4tKwU/wogee7EPEtY5ZYnPzEflxEmllvkNnRTmnd8phRaay9e1w3DVEQ8qehsSKnt u6UPidPD9npL8LgTq96VbzG78sTYsOjO/28tM99cLAehKfBpzAJpLoe5KXbHd+fdKDcyX S6ac83qh/5c9lKJrD3HfqjTrNZu0bt7zftkB/leuguK7dNyBAtA/t7zkiLVqmcMwwyQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=tWM3LHGE; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49D0E606A31A; Mon, 30 Nov 2026 22:54:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 49D0E606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=tWM3LHGE Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUI4gO63837197; Mon, 30 Nov 2026 22:54:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=/BuFklTz2KxJWSOc9Q9aPDX5FT52cv DU40EfIl4bmIM=; b=tWM3LHGEfNISgbpaPXTnR1hVMeelzkdETdkq8CW1wZFPh4 yvrFtbt60nbIOddyjy5DevsQWW6q2zRH4ZC2D14VxZeXFi4z7JvzakmIsUptS3Fp d9E8n//mCAuvDtEJIVnUOacXh/LTBWC5F21YFEz5BbTp31c1yyXZsQ/TgKpOJm8c DRgySAU+sjkehKsnE4uDyy6dRyeJlIU7YxNQ/o3Frwc5xalma0dyPqFN6/Fwz89Y eTdkFQ6Xkljt5JTKRaW9brLOM4RPN1ETXSiymSM6cAiRImCB9yi+uii64AWxxZEy vf650ekqzzAQfpDyTtbfM0YucXzevG6cII7nPI6A== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pp5t60f-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 30 Nov 2026 22:54:50 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUMNQZI3826185; Mon, 30 Nov 2026 22:54:49 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j89nvew3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2026 22:54:49 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6AUMsmoI31195652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2026 22:54:48 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 572355805D; Mon, 30 Nov 2026 22:54:48 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 343F458056; Mon, 30 Nov 2026 22:54:48 +0000 (GMT) Received: from e (unknown [9.61.86.58]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTPS; Mon, 30 Nov 2026 22:54:48 +0000 (GMT) From: Dave Marquardt To: sashiko-reviews@lists.linux.dev Cc: linux-scsi@vger.kernel.org Subject: Re: [PATCH v20 03/13] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation In-Reply-To: References: <20261130-ibmvfc-fpin-support-v20-0-50beb6e4b62a@linux.ibm.com> <20261130-ibmvfc-fpin-support-v20-3-50beb6e4b62a@linux.ibm.com> Date: Mon, 30 Nov 2026 16:54:47 -0600 Message-ID: <87ld6a9bgo.fsf@linux.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: I-mF8pgVEtBKuU1T9kdq3jcSXCicKj9P X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA5MSBTYWx0ZWRfX/zBF/rkBK7gh 5Xdir3mZxD81LycWmmo6ZELXbSfN0qbsyl/vVQsO+ixjISEbQE/TEatFYvXJrjZ96zB4SSs4Yqc nEoJlFQss/KOzfjSREQnX00xfWw0chw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA5MSBTYWx0ZWRfX7I5NRSU9AaZ0 OXqcdpjrHvU82xNJuGcrwnotbG7BQROAZh8YKb89nkTivcA5Lh3PYpsQva9KOab67d1GinA24r9 UtwuUKm9OvC6Vx0dvWbx071r6K6EwHfxcsAkC5V40XQD4+GDTOL1uetYy40aNOOzqGKyBcb+7LS MPNnww8fZQvgo5uN9xYRHgdHdkpIvqeTdiWMyc335Yedw8GEQJb0fuqSNEbCeTYdtD8XPblTYDq ITSF8U4Fa8oMHjGARxSXlmQOrWa/jCqHuupHnfHPZAcHuL3Rp8c2UfQMc5Mb9hiUx91Sdw104YK KrZhER/+5qwCfnv+l5pQe7SVp1QXHEc7pbkpA2Z7CuwT9Y0YthiDK9YDWt7rJ54p9VbEHMkqrhN ygv6jRInOo3H66vKZ/R+D0I7w+Ro4BrPaGo6WBdaqfERyZ3NOAN4fwKNCJSjOd21BjgAOSNJMJP YaHuZbKb6hVhz+FicVw== X-Authority-Analysis: v=2.4 cv=Ae8kjHXG c=1 sm=1 tr=0 ts=6b0dfeba cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=f3WuMqOMEYtoiA1X3J4A:9 X-Proofpoint-ORIG-GUID: I-mF8pgVEtBKuU1T9kdq3jcSXCicKj9P X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_05,2026-11-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300091 sashiko-bot@kernel.org writes: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Low] scsi: ibmvfc: missing Fixes trailer on channel deregistration > fix > -- > > commit 6a6a081a8ea79753e2cb80ab983eaa4a2d12332a > Author: Tyrel Datwyler > >> scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation >> >> Guard ibmvfc_deregister_channel() against calling H_FREE_SUB_CRQ on a >> queue that was never registered and against memsetting a buffer that was >> never allocated. >> >> Add an scrq->cookie guard around the H_FREE_SUB_CRQ hypercall so it is >> only issued when the cookie is non-zero; clear scrq->cookie to zero on >> success to prevent double-free if the function is called again during >> reset or teardown. Add scrq->cookie = 0 in the ibmvfc_register_channel() >> irq_failed: cleanup path for the same reason. Guard the memset() of the >> queue message buffer behind a check of scrq->msgs.handle to prevent a >> NULL dereference when the function is called on a queue that was never >> allocated, such as async_sub_crq when multi-queue is disabled or >> initialization failed before ibmvfc_alloc_queue() was reached. Update the >> error message to include channels->protocol so failures can be >> distinguished across SCSI, NVMe, and async sub-CRQ channels. >> >> Expose ibmvfc_deregister_channel() via VISIBLE_IF_KUNIT and >> EXPORT_SYMBOL_IF_KUNIT and add a kernel-doc header to support KUnit >> testing. >> >> Add ibmvfc_get_first_vhost() to retrieve the first registered ibmvfc >> adapter with a reference held; expose it via VISIBLE_IF_KUNIT and >> EXPORT_SYMBOL_IF_KUNIT for use by KUnit tests. >> >> Add SCSI_IBMVFC_KUNIT_TEST Kconfig entry and Makefile line, and create >> ibmvfc_kunit.c with an ibmvfc-channel-test suite containing >> ibmvfc_deregister_channel_guard_test(). The test verifies that calling >> ibmvfc_deregister_channel() on a queue with cookie == 0 and >> msgs.handle == NULL issues no hypercall, performs no memset, and leaves >> the queue state unchanged. >> >> Signed-off-by: Dave Marquardt >> Signed-off-by: Tyrel Datwyler > > [Severity: Low] > This fixes the unguarded H_FREE_SUB_CRQ hypercall and queue buffer > memset() in ibmvfc_deregister_channel(). Should the commit message > include Fixes tags for the commits that introduced them: > > Fixes: 3034ebe26389 ("scsi: ibmvfc: Add alloc/dealloc routines for SCSI Sub-CRQ Channels") > Fixes: 72ea7fe0db73 ("scsi: ibmvfc: Allocate/free queue resource only during probe/remove") Thanks. I traced both. The unguarded H_FREE_SUB_CRQ was written in 3034ebe26389, but there allocation and registration were coupled, so only registered queues were deregistered. It became reachable with cookie == 0, and as a double free of already-deregistered queues, once 72ea7fe0db73 split allocation from registration: a registration failure leaves allocated-but-unregistered queues that teardown then deregisters. I'll add Fixes: 72ea7fe0db73 for v21. The unguarded memset was also added by 72ea7fe0db73 , but I couldn't find a path in the base where msgs.crq is NULL there, so the msgs.handle check is hardening for the async channel set added later in this series. -Dave