From nobody Wed Aug 21 13:32:55 2024 X-Original-To: dev-commits-src-main@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 4WpnMW5Y24z5Tthf; Wed, 21 Aug 2024 13:32:55 +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 4WpnMW4r7Bz4941; Wed, 21 Aug 2024 13:32:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724247175; 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=o9y5Dw1dmN4f+aQc7Jd2WU9KTnSPyqnCHm33LDxC0Fs=; b=wLhqiuqfKBi+XdoTfV/jzOi02bzdSNJT0Il51wVpNiJLOBctyjH+ihziFv2NwF0SJ/deOS kjmttyR7GBBD2FhQIlr5TJWVcvWV5YrsnYc1hgL8rd5IgIJ0B6HUHOf+G3POW0WGTmvUU4 JObBzWfuqwxAk2Nm9kCQ9n5a3kd+I0t8snqZLBQQYK9JLIV8vKnjAvN18AdXMpjoHazhBK RVZO6M8mi5LNyPgIWmIRviHoLX1vqCUvSJTSqKOHgy78lRHQd31CkFt/Mp/+8yxX+ajn2a YuZuWHz5sLGO+sNhaowoWad8OXKXJN0fwFy+e5vc2ro3420/tuoDcbbTjsZ44Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724247175; a=rsa-sha256; cv=none; b=C+g2VSWgLtE1MSq5CzM2uJ/7TvrnXpKgWklhHyMieW8IRkQ0BWTBj/QcnyxTqWqLJ9OOkj wdqqMKrxzRVYgf+ntuC3zS3oXM9Mw80tOkuOEfn8p4J1O5t2p1+irTWCtFeH5FxuuC0gN9 iTJhpupMD/X+lHkfv+j5JDK4FmUS5OKFWH0P2F0fe7mA3ZNHDo3SVOUsmF0XgEzeZAabF0 N/SNzX1J+Ci5RDUcXVCT/Sf2ozdXDpbk6mPcAqVf0g3J0ky4TzKYCGKEtvcqwD7C8E7pD9 0bytQ0/2bnDm4ckUroO7oLJvF3VlKiDXD6hTRtHFbY5J2rY9Yb5Su409a7v6tQ== 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=1724247175; 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=o9y5Dw1dmN4f+aQc7Jd2WU9KTnSPyqnCHm33LDxC0Fs=; b=jdwbL5n+7ZYTGfkEHk1fQbnNqVPG5yt8r24VJAYkMcUbccGiyRknGm3qZgYo8CQ8tEMwVc lUkmL9X0byRmyo1vCyDBPHyJ2z0qTifL0DoW/dC+fQ1t13rsEcoDcG47Wa35YwItF+P45I EW+SqYk6HLF+rG+sa4LKriKOgd6N6jWKIOncUiyByJbLjAf5+vMMXRugJeQzT6P6IJ3JDY lTIVfR6uJO5jWosd06j30FRRDFnrEKwaOEaNR3zpE00I72y8jxlMvRMBxSXNFK/+HtolMM zkPxIw3BQKxxGsq4FLAKr0RVJtiIs4LrfdQPldcdG7gSkJ+o8GYJnQD5g0OT1g== 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 4WpnMW4RSNzmRP; Wed, 21 Aug 2024 13:32:55 +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 47LDWtvE082802; Wed, 21 Aug 2024 13:32:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47LDWtf3082799; Wed, 21 Aug 2024 13:32:55 GMT (envelope-from git) Date: Wed, 21 Aug 2024 13:32:55 GMT Message-Id: <202408211332.47LDWtf3082799@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: db87c98168b1 - main - ctl: avoid heap info leak in ctl_request_sense List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: db87c98168b1605f067d283fa36a710369c3849d Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=db87c98168b1605f067d283fa36a710369c3849d commit db87c98168b1605f067d283fa36a710369c3849d Author: Ed Maste AuthorDate: 2024-08-20 18:12:47 +0000 Commit: Ed Maste CommitDate: 2024-08-21 13:32:41 +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 --- 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 fac65e155890..845cffe77a5d 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -9304,14 +9304,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.