From nobody Wed Sep 4 21:07:33 2024 X-Original-To: dev-commits-src-branches@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 4WzZnd6njCz5VNmL; Wed, 04 Sep 2024 21:07:33 +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 4WzZnd4DQYz4VgG; Wed, 4 Sep 2024 21:07:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725484053; 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=fBhSwltYQSeZtIphC+u8w4VrIbecW2yxITjl37HD0m8=; b=KW4TPC4mbVD+K6UQzXwJAbCBfY7EkkyJ096tgkWHSqfa1xi+QGdekCp8DKyBRn783UwNQD PWdrdGTe8iNHIvpyI+TDf6klV8UdNLpeEEpNuzmbln6U0SVHYsJOzASDn5Lx+Iqm2R8DIJ Zivxd5r6UDm5IgiiTadYP9KfOcJvGeLbiGWvOHUymiT+GMopSc2N+Vg0mPyAYhabGtovCB lVbyBkNhp1Qjf4WOz1nsVjS3P7rKDrrHb68+YbaULY6DlS57qNOepAVatICvtODqghp2kC yvfSS/qx9xdwA+iyW6a6zUiRtoQ/MDyGOvKlqOZWvAWIrh08xYeyscu71dordg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725484053; a=rsa-sha256; cv=none; b=uCrKjRquWVMgnr5tiHAYoJNBZkw3V3tA7kBJA9q6wLN0qzIlvJJxYSKQpgzJAoFUZKulkF 2OmXcWxEEp37fOF1hcK65C+6a9Tm6Ebchfo4MjTkQfIXOTcLeqYrLCKsM1mXAL2kgAoSh1 YADEjHZXEWM34tob1PkxwGL6WPnQ9vp71KSluzoHHqjFi9EuHGYHZsIe1aV0p4LfcuLmvE kjs+0J0DoHiZT/ys7QBBfKMcpTzurNdXg6dAb9u/QC9iADGkBBLuXmrkw3Uc0U8zy4FJ8W a/cX4m7tBmwk8i4pL32CVVFkXu0GESjoTQ9osjJ91+t0nLIkcnYCt3wr0V/7sA== 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=1725484053; 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=fBhSwltYQSeZtIphC+u8w4VrIbecW2yxITjl37HD0m8=; b=c11/yLIFe7w3H+3r4/AdkIB8fKp9iPCZb7kyVHHzJfww0y/0hGTC1mXQcnedzRflW2lXka uvXdjAdyim9mi/hKdTZBOqTR7PVK9ibA/v1pZVgnhnE6GzxVAdU/RVwbkfDraphLlGK6bm U8Jq92yHjqXdvQcwscplXANujSKp8+NOI2LpMNfhc7NyIMKtpvq8aklLwm9uw7A5zIiyO8 QfEHboOTp17kqOBDR44PmkVPLd4Ks+/2UTWZxlA9516MshjZ8xk6wFG+O3m040GFa4+vQh RIiprNh29cC6F2dbW/ODpX38TaqED2IenioteULSpiNnCuU2p5uWMcO8ve/gBQ== 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 4WzZnd3qz9zgg3; Wed, 4 Sep 2024 21:07:33 +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 484L7XpB053342; Wed, 4 Sep 2024 21:07:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484L7Xd9053339; Wed, 4 Sep 2024 21:07:33 GMT (envelope-from git) Date: Wed, 4 Sep 2024 21:07:33 GMT Message-Id: <202409042107.484L7Xd9053339@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: d30ffde0806e - releng/14.1 - ctl: avoid heap info leak in ctl_request_sense List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/14.1 X-Git-Reftype: branch X-Git-Commit: d30ffde0806e8738b6548d2a890a9eb7d06c18fb Auto-Submitted: auto-generated The branch releng/14.1 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d30ffde0806e8738b6548d2a890a9eb7d06c18fb commit d30ffde0806e8738b6548d2a890a9eb7d06c18fb Author: Ed Maste AuthorDate: 2024-08-20 18:12:47 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:46:54 +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) Approved by: so --- 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 ede6b7d88b94..0e0d79d15d8f 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -9342,14 +9342,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.