From patchwork Mon Apr 21 08:16:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Boris Belyavtsev X-Patchwork-Id: 882968 Received: from mx2.usergate.com (mx2.usergate.com [46.229.79.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6C432561A3; Mon, 21 Apr 2025 08:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.229.79.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745225197; cv=none; b=uXsw8Sw+6mXdyik4LMDjmPHEwsOOz9KqD6BWNWPsKur+copG9E64Tf8qAEvBwG5h36EgukoLPnkBO76mNCuw9ad6qVAEV7T9ureF8e4rldNAZv1HkakXBpUHCRBWojezWhLpWR9W+mDR4F5IhraKTMBN2dGiLfoZjBWMbu6Kp0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745225197; c=relaxed/simple; bh=fPqmdjETCCWklCCMwOmlRIK5VXLxkCYZqQ3Pvxqd4g0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=esd4kUe1c+3+CFXtW3soeE2+PreW7tcAqlm9RiFUEmgV6u1tnu5HiuQ10z2qvpUFin4QLeQBNIDWc+0vS9sucaFWvJ1tdo84vsj8AVG/ADUQGBNOBgM2c90XJyNfwkkOqJ0DBcuSKdD9a634MTVw8XKxLfmkvh9hnh6xcxwqOA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=usergate.com; spf=pass smtp.mailfrom=usergate.com; arc=none smtp.client-ip=46.229.79.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=usergate.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=usergate.com Received: from mail.usergate.com[192.168.90.36] by mx2.usergate.com with ESMTP id 39C1A7449E01451F800655EBCDF4548A; Mon, 21 Apr 2025 15:16:11 +0700 From: Boris Belyavtsev To: CC: , , , Boris Belyavtsev Subject: [PATCH 6.1 v2 1/3] scsi: aic79xx: check for non-NULL scb in ahd_handle_seqint Date: Mon, 21 Apr 2025 15:16:02 +0700 Message-ID: <20250421081604.655282-2-bbelyavtsev@usergate.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250421081604.655282-1-bbelyavtsev@usergate.com> References: <20250421081604.655282-1-bbelyavtsev@usergate.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: ESLSRV-EXCH-01.esafeline.com (192.168.90.36) To nsk02-mbx01.esafeline.com (10.10.1.35) X-Message-Id: A32569B8126F4F42A80012AA9EDE5AA0 X-MailFileId: F64FAD1BD91046728E5398E8D134C494 NULL pointer dereference is possible when compiled with AHD_DEBUG and AHD_SHOW_RECOVERY is set if data in SCBPTR и SCBPTR+1 ports is incorrect. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Boris Belyavtsev --- drivers/scsi/aic7xxx/aic79xx_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index f9372a81cd4e..a4d5376123d3 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -2205,13 +2205,16 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) ahd_print_path(ahd, scb); printk("data overrun detected %s. Tag == 0x%x.\n", ahd_lookup_phase_entry(lastphase)->phasemsg, - SCB_GET_TAG(scb)); + scb != NULL ? SCB_GET_TAG(scb) : 0); ahd_print_path(ahd, scb); printk("%s seen Data Phase. Length = %ld. " "NumSGs = %d.\n", ahd_inb(ahd, SEQ_FLAGS) & DPHASE ? "Have" : "Haven't", - ahd_get_transfer_length(scb), scb->sg_count); + scb != NULL ? ahd_get_transfer_length(scb) : -1, + scb != NULL ? scb->sg_count : -1); + if (scb == NULL) + break; ahd_dump_sglist(scb); } #endif From patchwork Mon Apr 21 08:16:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Belyavtsev X-Patchwork-Id: 882967 Received: from mx2.usergate.com (mx2.usergate.com [46.229.79.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17364213E7B; Mon, 21 Apr 2025 08:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.229.79.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745225217; cv=none; b=J1q7B3AKGxMFmKcLQbDfmeKb9E11u47+lZ2bgEi1aXzJNULtGQ2bfkG8/pw9khLSmRZKUz3FIaBeNAsKmqtaVpHSYpgespHznVJ6QihpzqGaxJ35On+IJhO9Y9LQL49O1Q7jIVwMMm00a2VvIxc+v6bIqJOn2rF5xb1dXGWL838= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745225217; c=relaxed/simple; bh=SoJeIQUy1n6bUnB19h8yR/7XX7MWJlNMbKKm5fg8pIk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GiU17ZVNr5O87R4jmnFxFC4HKijoBJ9bNuV2OM4K7muChsez6FeMg8k4fV0usNG25rhfOGUA807mv3JOBdZOxIvamDRNc5jv7yXyMCj7NlwUu9ai1R3WP6JzY7t09LMflh7uUvTM0tbKWLllnMHuH+EDCE27AU59UWYF7nqtEsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=usergate.com; spf=pass smtp.mailfrom=usergate.com; arc=none smtp.client-ip=46.229.79.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=usergate.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=usergate.com Received: from mail.usergate.com[192.168.90.36] by mx2.usergate.com with ESMTP id A1860D7338844D3D93CD65BC0D89C5A1; Mon, 21 Apr 2025 15:16:12 +0700 From: Boris Belyavtsev To: CC: , , , Boris Belyavtsev Subject: [PATCH 6.1 v2 3/3] scsi: aic79xx: check for non-NULL scb in ahd_linux_queue_abort_cmd Date: Mon, 21 Apr 2025 15:16:04 +0700 Message-ID: <20250421081604.655282-4-bbelyavtsev@usergate.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250421081604.655282-1-bbelyavtsev@usergate.com> References: <20250421081604.655282-1-bbelyavtsev@usergate.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: ESLSRV-EXCH-01.esafeline.com (192.168.90.36) To nsk02-mbx01.esafeline.com (10.10.1.35) X-Message-Id: C194A9C2D7CC43F79E41C138F3D97A56 X-MailFileId: D495EA50165E4907B18C65B67EF3FA0D possible NULL pointer dereference in case hardware returns invalid scb index. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 73a254621007 ("[SCSI] aic79xx: update to use scsi_transport_spi") Signed-off-by: Boris Belyavtsev --- drivers/scsi/aic7xxx/aic79xx_osm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 17dfc3c72110..f2ae202d2641 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -2265,7 +2265,8 @@ ahd_linux_queue_abort_cmd(struct scsi_cmnd *cmd) * and hope that the target responds. */ pending_scb = ahd_lookup_scb(ahd, active_scbptr); - pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT; + if (pending_scb != NULL) + pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT; ahd_outb(ahd, MSG_OUT, HOST_MSG); ahd_outb(ahd, SCSISIGO, last_phase|ATNO); scmd_printk(KERN_INFO, cmd, "Device is active, asserting ATN\n");