From nobody Mon Aug 26 13:28:37 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 4Wss2F5GSDz5SvvP; Mon, 26 Aug 2024 13:28:37 +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 4Wss2F4n1Jz4ZLs; Mon, 26 Aug 2024 13:28:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724678917; 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=t9ph4z1Ms+IaXWfrAPPa2WJIWtUR2GcUc4VDNy7M0SI=; b=FQSchJK3BKMsN2d1EuEAeJ1zN90uGbaOu6AsTCL267dcHA6cBPBcxhp/rMHiOI08jM6DEW 1CTCRE7jXGM/SNSg1Q64yaGTeza9k/oBTQ+YQM8wFJ1qs07OcuVAX9RKf4yO/bJoMH7i3h 9QpobDNpFHZkSgPXP2SNa6mN3a+iiCMiz1LzDmxD1yoarMTpmJqtgb/7H7tSMLBGjEIgn0 1QmiJVMbjt6q64nvfAvuzuwzZlkI8YqDkWTH6MybzYfMn3Z3Di1/sHQr7LJjFn91M0ZYMa H94dKVYatyMEmNMW+KwneeiyQB/yR71jfH8q2WRNujH8ffOUhCBU0DKdZGqCcg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724678917; a=rsa-sha256; cv=none; b=ya6sFZ4nDjLMB7Od8eZE2b30hV21/ERoPmo02M6cow5WhE/SUimE9xETLBzus+Ty0g0xlp EY4vEnbMi4DnKtZK2YhuWbCdiRXXDa7MumvFwnBoLz1lqpnNrfcNpe9A1Bw2BiQleywP2X F3mIOnBQYSrFoQ8k5eKBZYeKtHC/3F5cshLkuMboSWs1TNQb3eW+XV7sOeYLvRDTjzKwTH 12GEx39LEudPODauW/nM+7GD/ikJHLindlAz1vCQ+qlFSVavUo+pS71cbwJx0nWf9hjStz Qr61fh4JhoXsGUlJ1zemJQEvXJGwX4pGjAd67M2D6HFwxlZkmU5gbS557LIUOg== 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=1724678917; 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=t9ph4z1Ms+IaXWfrAPPa2WJIWtUR2GcUc4VDNy7M0SI=; b=kKzM2oqvlsRpL0r1YZYEnWHP01kMbbZLiP7gEzRUlUZRzCiZqgcGxCvMSpZYFCeqV6GyjU O2MqJCNwat2DpYKJgGHApt0ZCCZ9UdHS3eeslHSsR/WO5COSAQ0mXAg6R7KefmI6voDI6k 40aGJ/YVJrsKOowkfhkOs1mLJP9LCF3Wt12gY1kg2OpRwZXzfRLW54PCDiPrfB6mRl8GRM oVBmMKnbThaGoON24xTt6STKO+IO1/8rox+vRvkDWtgDvHWPhjKXhngx6KrTJ2MDScPHC2 428Bg1eUDcMT3dy7HJEixkPlxykIAP0W0uPByaAKUa9CzmfUEGA2XM4QEyYRrg== 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 4Wss2F4L40z17Q9; Mon, 26 Aug 2024 13:28:37 +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 47QDSbZw067216; Mon, 26 Aug 2024 13:28:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47QDSbvx067213; Mon, 26 Aug 2024 13:28:37 GMT (envelope-from git) Date: Mon, 26 Aug 2024 13:28:37 GMT Message-Id: <202408261328.47QDSbvx067213@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: 51768dc31df6 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 51768dc31df6379aa4a1447a15f054508d16b4b1 Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=51768dc31df6379aa4a1447a15f054508d16b4b1 commit 51768dc31df6379aa4a1447a15f054508d16b4b1 Author: Ed Maste AuthorDate: 2024-08-20 18:12:47 +0000 Commit: Ed Maste CommitDate: 2024-08-26 13:28:17 +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) --- 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.