From nobody Mon Aug 26 13:27:35 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 4Wss134pDgz5Sw2v; Mon, 26 Aug 2024 13:27:35 +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 4Wss134FGhz4YwK; Mon, 26 Aug 2024 13:27:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724678855; 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=jlNoG4+h0srj+0Hcz/GnISzNWFRybTYMgtq2NkQdH9s=; b=X21cUnkzhwGQAtnka9bCmcRqsCqEuCTjt49vhL5j9ye86nkcEQ6cO4NFtePrv+QgvdT0aa /t3LBYrAlkZ3GFzErsxhoFjvX1Qobn98l4mmKEkqLlp1KJIrXdILtEU90YC9JaAX+3rt3v 1Sbm8K7wYa1PIjybKzNzE6EGQ0hmR0zoD3OHaDDuCNtZzHoKThEbVcvbdzN0mHP/o+zuH4 Xcz4agdjD/iB99rKr7gWGt5NNN4hdKf3Fps0bD+//64ssPEkvHRXm+e1b23dDsEPDNh3Iq y04nevBOpJ6fWQg21Z5yza3i3/hNk1OZfiN5p9O7JQ1tTCilxs0eEcxIr/pz0Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724678855; a=rsa-sha256; cv=none; b=Dqmy2AWNEGvB14nxrPeuX7Eht1m1WUQepoPQEzcaN9NKb6AY2qBD+utr8y3OAOtgFhc5Hi 36Kx2eupFJp1+tsDl5YnFMNO9Pl4SHuqOudM0sx1AlRNbYIPxLpEqbJwvriFeMhv3aUpwl T2tgmXB5DmD0Neek1QHiqux9WCfMsYdFizt29VvTcXZqpLioeTQslRUr96MucXLcT2+x5F xg0+e1jDJ14hPwVYOjl5r8Tm5GcQlCxXrIn6crDuD1H334J0iYK7+wmLTjLKD6gBJS33A6 i2dU73jbD+IwG4HUtjKsBo03PTYb6ZtfIX86+pnweY5FPpui0lnBw+q3Bx5NcQ== 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=1724678855; 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=jlNoG4+h0srj+0Hcz/GnISzNWFRybTYMgtq2NkQdH9s=; b=L3lKcyIZzaRFI6Snpj91+RRkWaZjf3U9vs5WQXWEjEI5G/kdvSXF03AMr52dHilcGTr7mp LK0i9kiyZNn2Nxbm3s1t6jmr4MkbavzE/TCvRjxaX74q7G9Y7paXy6VG8P2U5iMqcvoLNX dOdkknmXH/KGhPRkT56sxrAvr2s8iqnSUR1HyRz/MGfbCzd1Vi/E2xbRTUjo1tnvc0o+2C KwP8Q5mvpijHijvXnlx7htVYmR/o7Q8AFiRuU83VvAcTPRTunPcwTPXlMSz5q+Y++5Qm93 abVYadTON7p4aK4vxOT+sl0iYRoRhs+/+7MPSOZa7pux3wqqA71feancs8HumQ== 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 4Wss133dPgz17fN; Mon, 26 Aug 2024 13:27:35 +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 47QDRZuD066958; Mon, 26 Aug 2024 13:27:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47QDRZXH066955; Mon, 26 Aug 2024 13:27:35 GMT (envelope-from git) Date: Mon, 26 Aug 2024 13:27:35 GMT Message-Id: <202408261327.47QDRZXH066955@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: 131b7dcb2fbf - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 131b7dcb2fbf8f15815387f60536d9cc16585b0d Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=131b7dcb2fbf8f15815387f60536d9cc16585b0d commit 131b7dcb2fbf8f15815387f60536d9cc16585b0d Author: Ed Maste AuthorDate: 2024-08-20 18:12:47 +0000 Commit: Ed Maste CommitDate: 2024-08-26 13:23:37 +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) --- 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 a315c5ef7df3..1d5e13ad4671 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -9340,14 +9340,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.