From nobody Mon Aug 26 18:30:14 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WszkG5kN3z5TP81; Mon, 26 Aug 2024 18:30:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WszkG55qNz4CMy; Mon, 26 Aug 2024 18:30:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724697014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ha4v50D6O81rn96lpE0sMBBm8rX9r6As2V66eRN7WN4=; b=qdRKodHsX2nFd+I8emyRvPWbavSJa/bSHI6Xqq/+1MoV5qnrr3IFyoSoUPZSJotRyFCWH6 hK73rLzECxFV8QQ/1Lw2Rq4tCozuQnyEJjQeZlo4/cHVcQfp2g0xXbcIqa/gifAEO0pmaA mwcpGZtT3QXzkQjhPo9lnUEg82IaJCpIAzm8Zzh8XbXdVka1pP7BXNfAiFedEPVjZeqqdc yEe61RymxbXJMNUY5BhnGHQhtz23VJK9LyMx4Zw5ESdJFr8gTj/hBYciraqMdaUqPylBLT 8elj6a4Sm6x7P7Iis84DK/SdR1hcCjqJy5d5zmznczbWczf6DZkqNMibAmAAvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724697014; a=rsa-sha256; cv=none; b=udTMz4Z7pbi6pcN5jOFgRMicPIImEQyUFb1gZGedXV4YZBcYG/LZYOTfWeu6+hLg8VWeSV +FL98lm4hnBDtORMSvr3zGkSFRtWonQr0fvOu5li4xKbSTanpuevC7H4McmcfzhYElTN52 YLFoKueJRyUmw1XZyNILPEctpbpCOX1KxBYtaTqXkO74uXARvA5Fij0UGToLSuL68YjTzg N6OswpJOixfrvcikf1qIremXRw7V7ClvtvZPMv6BWulBulYLmjF2Hgx1P/+uG9xlX1qXuW ONKdpiWpWRRmcXrRgeBANRv71PXAcK+/wf1dvMCVJF2999sodNoJCFonnv0rcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724697014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ha4v50D6O81rn96lpE0sMBBm8rX9r6As2V66eRN7WN4=; b=vxYzlk5grr4BwAYMJt1DMPhLeXAST6McdTfgVcN1X9lXruzOX4s5iVfMzTlntAgupUr+id qjmEJZiX/60l49QYcwJFtPEZVlch5x1mryi/wcY/jrGY9kzgm8frjEgQbqK+3Ce/k+MoV+ o5IxuTF4axAcjLQ10q/TKBmT/l6UhMZueVz4EXXs9F4N4sI0J8NpgtyWB2sG9vBI5dVpEo gcB7PfWXTdFVyPzg8Yu//eb+a+WZ77RS2mQY8+QTodRijwrk7o8r+B4hY3FrjTkdmcaZ0i BH++H0zG6Z0566Z/IqC1PnclZ7G2AKKivd+RwHmHmDurczLcI8cvFlCrm2Po6A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WszkG4jJGzHqG; Mon, 26 Aug 2024 18:30:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47QIUEep084057; Mon, 26 Aug 2024 18:30:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47QIUE1e084040; Mon, 26 Aug 2024 18:30:14 GMT (envelope-from git) Date: Mon, 26 Aug 2024 18:30:14 GMT Message-Id: <202408261830.47QIUE1e084040@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 27777283da79 - releng/13.4 - ctl: avoid heap info leak in ctl_request_sense List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.4 X-Git-Reftype: branch X-Git-Commit: 27777283da79cbfa39ba10b65c748f49884be7fe Auto-Submitted: auto-generated The branch releng/13.4 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=27777283da79cbfa39ba10b65c748f49884be7fe commit 27777283da79cbfa39ba10b65c748f49884be7fe Author: Ed Maste AuthorDate: 2024-08-20 18:12:47 +0000 Commit: Ed Maste CommitDate: 2024-08-26 18:29:40 +0000 ctl: avoid heap info leak in ctl_request_sense Previously 3 bytes of data from the heap could be leaked to ctl consumers. Reported by: Synacktiv Reviewed by: asomers, mav Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46091 (cherry picked from commit db87c98168b1605f067d283fa36a710369c3849d) (cherry picked from commit 131b7dcb2fbf8f15815387f60536d9cc16585b0d) (cherry picked from commit 51768dc31df6379aa4a1447a15f054508d16b4b1) Approved by: re (cperciva) --- sys/cam/ctl/ctl.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index a31bbd3c8342..7a04a668e823 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -9339,14 +9339,8 @@ ctl_request_sense(struct ctl_scsiio *ctsio) sense_ptr = (struct scsi_sense_data *)ctsio->kern_data_ptr; ctsio->kern_sg_entries = 0; ctsio->kern_rel_offset = 0; - - /* - * struct scsi_sense_data, which is currently set to 256 bytes, is - * larger than the largest allowed value for the length field in the - * REQUEST SENSE CDB, which is 252 bytes as of SPC-4. - */ - ctsio->kern_data_len = cdb->length; - ctsio->kern_total_len = cdb->length; + ctsio->kern_data_len = ctsio->kern_total_len = + MIN(cdb->length, sizeof(*sense_ptr)); /* * If we don't have a LUN, we don't have any pending sense.