From nobody Wed Sep 04 20:29:45 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 4WzYy13tJNz5VKkT; Wed, 04 Sep 2024 20:29:45 +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 4WzYy11KSrz4JFV; Wed, 4 Sep 2024 20:29:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725481785; 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=/mXvWT1D28j9UyIsDl+c9UPT3OLfHmh+a97C2iKcTRA=; b=FghvKspi07TdKImuWN1+I0ELzmrJz0moDWiU3YOtAhpIGn6Y8xz9YHgOLES8bXVPdyd8uw 0j5RvkGVNF+cWazInbsulQuXkkIWaTms+Htq6bmEtfhkMV2uealE2Iy4Hx2U309ZfY+yCy ujLoVRLTd7fPAIDkgV0qlaHHlzLNFGxkomdup1GIXFngMEbTRKVnp+0HgZJ5DZkuXQ4FIY eksu2hdmlu7hmFt8CV5kTCFN29OizqtXYQ3FJKKbtK2h/laq1+GYf13/bkHLkIb2CewC9w 1bdD5MsmPuhQcUhCpVAfrQU2QDXLnJXTdpSaV4BnGpDmzEJHuKyWTH3uz8LrYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725481785; a=rsa-sha256; cv=none; b=sBGYyTDzfCq7gSlwwi3kHLPdUE+LeGs75vn2OPWIemXIXZMh29jWO5/mnoorbVtfVKjawf NhFTOuS2/MOuKGTScvequPZTLp4mimTFBg6LBG/MpPS2t2lH8PhC5CzqIZxJWepHkBayyA leWVHE5RJTnXWn4/dUJ+++uiwX2KZKlkQKQqYobFRWZviPzgRi4YRe8Vg8toF3FrDUQGWF uzknQNacpm3tEybHRLw74CqW18hgEYvWtBHGXOxJT6oMN8zLi6QNRgmPYwy80+vPCJgpeN 16j+UhmhPrQ24qP7mU8IMgwsm/Xn6k8QLn0vYZMlgtzq8rS6S6d9GQ9CGqXfOA== 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=1725481785; 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=/mXvWT1D28j9UyIsDl+c9UPT3OLfHmh+a97C2iKcTRA=; b=C9QRcqOuF455E2x82Hv+/s4GerXMYs3jK68iAHZicpNqhses8nAUUXPmv9KncdMZE9xDOs FJfTd+u6Nrjkd8XFT3jgRgJ3rBjQOu4Tfkdui5IzRh1L029EfiqbRuX7h8MDGJ1niUN1vp wAsp3VlJMnj1184yc2oK6mH1ivHWrhlYduVNpUcRM2XxBQv8ll1TMM1Q5m6rx7U2Wep1yd fJWRws/YobZbwdCFUbJ2Xe3FAbY/MnsvflYRGi0lXKYOP2EKiVSOSFdsevp1Uapy69cKmV J0QrMAwIy2JIwaA9kcOboPj+cjWngOwnMYOOBXmITRfzPFpJMSmtuARq9hglVQ== 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 4WzYy10vyzzfgm; Wed, 4 Sep 2024 20:29:45 +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 484KTjkb082689; Wed, 4 Sep 2024 20:29:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484KTjJb082686; Wed, 4 Sep 2024 20:29:45 GMT (envelope-from git) Date: Wed, 4 Sep 2024 20:29:45 GMT Message-Id: <202409042029.484KTjJb082686@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: 639494a3c1e6 - releng/13.3 - 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.3 X-Git-Reftype: branch X-Git-Commit: 639494a3c1e6d4e9341ecd551573e403bfc8c6d4 Auto-Submitted: auto-generated The branch releng/13.3 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=639494a3c1e6d4e9341ecd551573e403bfc8c6d4 commit 639494a3c1e6d4e9341ecd551573e403bfc8c6d4 Author: Ed Maste AuthorDate: 2024-08-20 18:12:47 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:29:19 +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: 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 5d4dbd295f20..b0f34cafac80 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -9341,14 +9341,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.