lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ab7a484c-64b6-9c4a-744e-a8ad181acd2a@linux-m68k.org>
Date: Thu, 1 May 2025 13:40:34 +1000 (AEST)
From: Finn Thain <fthain@...ux-m68k.org>
To: Rand Deeb <rand.sec96@...il.com>
cc: Michael Schmitz <schmitzmic@...il.com>, 
    "James E.J. Bottomley" <James.Bottomley@...senPartnership.com>, 
    "Martin K. Petersen" <martin.petersen@...cle.com>, 
    "open list:NCR 5380 SCSI DRIVERS" <linux-scsi@...r.kernel.org>, 
    open list <linux-kernel@...r.kernel.org>, deeb.rand@...fident.ru, 
    lvc-project@...uxtesting.org, voskresenski.stanislav@...fident.ru
Subject: Re: [PATCH] scsi: NCR5380: Prevent potential out-of-bounds read in
 spi_print_msg()


On Wed, 30 Apr 2025, Rand Deeb wrote:

> spi_print_msg() assumes that the input buffer is large enough to
> contain the full SCSI message, including extended messages which may
> access msg[2], msg[3], msg[7], and beyond based on message type.
> 
> NCR5380_reselect() currently allocates a 3-byte buffer for 'msg'
> and reads only a single byte from the SCSI bus before passing it to
> spi_print_msg(), which can result in a potential out-of-bounds read
> if the message is malformed or declares a longer length.
> 
> This patch increases the buffer size to 16 bytes and reads up to
> 16 bytes from the SCSI bus. A length check is also added to ensure
> the message is well-formed before passing it to spi_print_msg().
> 
> This ensures safe handling of all valid SCSI messages and prevents
> undefined behavior due to malformed or malicious input.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 

I happen to agree with James that there is no value in trying to defend 
against hostile SPI controllers, buses and targets. But I see a lot of 
value in static checking so I'm not against removing theoretical issues 
from the code if it makes static checking easier.

AFAIK the error path in question doesn't get executed in practice, like 
James said. So you could drop the spi_print_msg() call in favour of this:

shost_printk(KERN_ERR, instance,
             "expecting IDENTIFY message, got 0x%02x\n", msg[0]);

But it's not clear to me that you can sidestep the API issue that way. Do 
the other callers of spi_print_msg() not have the same issue?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ