From nobody Sun Feb 8 20:31:12 2026 Received: from forward102b.mail.yandex.net (forward102b.mail.yandex.net [178.154.239.149]) (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 A9B12130E57; Wed, 6 Mar 2024 13:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709733031; cv=none; b=E3DclQ4nirgP41j8A2HUNXV8it/IWWqBcx0o2fI9AtYHhLVMVmvo8VaSfpEfHEGHe5uL21QwniILYRQVYNG8bpq8MquU6oo/YHYO9hKthXGsz7v/FPzSIIsnLlH5YElQPI47XvblUd7e3VU3ta2rTVnFwkfCbgjh5uD8PgoejGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709733031; c=relaxed/simple; bh=Rz/7QeGwGWVQ23cVl//CoUspDWwVdJjOPTplV8dC39E=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ifBVpXLoOTGuMzeINMXbhVl2gnb1s7+JlIvxkoQRP6UYIwk+QZsEqzeJOySLUquOYnJBbDqjx9WfgMfdLWskXRGA6FyQ4NIjDuhgxH9n+/5ogBhmcmWqByURAftrQqk8GVtyyEBN9JmUU1UOMIAq1AVplRdW0P9KRRa5BvG9bB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=D1VN1cyu; arc=none smtp.client-ip=178.154.239.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="D1VN1cyu" Received: from mail-nwsmtp-smtp-production-main-38.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-38.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:601e:0:640:ac7:0]) by forward102b.mail.yandex.net (Yandex) with ESMTPS id E70F16090D; Wed, 6 Mar 2024 16:50:26 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-38.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id Bogo8U46U0U0-5x8x78mU; Wed, 06 Mar 2024 16:50:25 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1709733025; bh=si9CmxfbTTi+fzS7ZgV1gg2/IENW5eLorkGc5P/t0aU=; h=Message-Id:Date:Cc:Subject:To:From; b=D1VN1cyuNsIj1u2ombhbQGZLwl6NLZWBoBjvpgF+oBQ0bDbD0i8wrI8SljgXvkQyj 2Vba3U5tDUZqR7YBvxEzfLgA3EL9TI32Roii1o59KBOcyR+ZHoPEuG4d7vhHNF5CDf aDXNkMROmIdi0tuSn0/SyooTY7XBsmqJ6li6omLw= Authentication-Results: mail-nwsmtp-smtp-production-main-38.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Mikhail Ukhin To: Dave Kleikamp , Christian Brauner , Jens Axboe , Jan Kara , Greg Kroah-Hartman Cc: Mikhail Ukhin , jfs-discussion@lists.sourceforge.net, stable@vger.kernel.org, lvc-project@linuxtesting.org, linux-kernel@vger.kernel.org, Pavel Koshutin , Artem Sadovnikov , Mikhail Ivanov Subject: [PATCH 5.10/5.15] scsi: add a length check for VARIABLE_LENGTH_CMD commands Date: Wed, 6 Mar 2024 16:50:10 +0300 Message-Id: <20240306135010.9250-1-mish.uxin2012@yandex.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fuzzing of 5.10 stable branch reports a slab-out-of-bounds error in ata_scsi_pass_thru. The error is fixed in 5.18 by commit ce70fd9a551af7424a7dace2a1ba05a7de8eae27. Backporting this commit would require significant changes to the code so it is bettter to use a simple fix for that particular error. The problem is that the length of the received SCSI command is not validated if scsi_op =3D=3D VARIABLE_LENGTH_CMD. It can lead to out-of-boun= ds reading if the user sends a request with SCSI command of length less than 32. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Signed-off-by: Artem Sadovnikov Signed-off-by: Mikhail Ivanov --- drivers/ata/libata-scsi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index dfa090ccd21c..77589e911d3d 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -4065,6 +4065,9 @@ int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struc= t ata_device *dev) =20 if (unlikely(!scmd->cmd_len)) goto bad_cdb_len; + + if (scsi_op =3D=3D VARIABLE_LENGTH_CMD && scmd->cmd_len < 32) + goto bad_cdb_len; =20 if (dev->class =3D=3D ATA_DEV_ATA || dev->class =3D=3D ATA_DEV_ZAC) { if (unlikely(scmd->cmd_len > dev->cdb_len)) --=20 2.25.1