Message ID | 1484057900-17871-6-git-send-email-stefanb@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show
Return-Path: <tpmdd-devel-bounces@lists.sourceforge.net> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tyYzp0fXcz9t0X for <incoming@patchwork.ozlabs.org>; Wed, 11 Jan 2017 01:19:02 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from <tpmdd-devel-bounces@lists.sourceforge.net>) id 1cQxGK-00054J-C3; Tue, 10 Jan 2017 14:18:56 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from <stefanb@linux.vnet.ibm.com>) id 1cQxGJ-000548-Kk for tpmdd-devel@lists.sourceforge.net; Tue, 10 Jan 2017 14:18:55 +0000 X-ACL-Warn: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1cQxGF-0000Ba-Np for tpmdd-devel@lists.sourceforge.net; Tue, 10 Jan 2017 14:18:55 +0000 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id v0AEEEKE050612 for <tpmdd-devel@lists.sourceforge.net>; Tue, 10 Jan 2017 09:18:46 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 27vv8j4yv3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for <tpmdd-devel@lists.sourceforge.net>; Tue, 10 Jan 2017 09:18:46 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for <tpmdd-devel@lists.sourceforge.net> from <stefanb@linux.vnet.ibm.com>; Tue, 10 Jan 2017 07:18:45 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Jan 2017 07:18:43 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 5115919D8048; Tue, 10 Jan 2017 07:18:00 -0700 (MST) Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v0AEIhHE11403522; Tue, 10 Jan 2017 07:18:43 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21D636A03D; Tue, 10 Jan 2017 07:18:43 -0700 (MST) Received: from sbct-3.watson.ibm.com (unknown [9.2.141.158]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id B92696A042; Tue, 10 Jan 2017 07:18:42 -0700 (MST) From: Stefan Berger <stefanb@linux.vnet.ibm.com> To: tpmdd-devel@lists.sourceforge.net Date: Tue, 10 Jan 2017 09:18:16 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1484057900-17871-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1484057900-17871-1-git-send-email-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17011014-0020-0000-0000-00000AB19052 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006408; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000199; SDB=6.00805683; UDB=6.00391989; IPR=6.00583019; BA=6.00005042; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013877; XFM=3.00000011; UTC=2017-01-10 14:18:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17011014-0021-0000-0000-000058BE1393 Message-Id: <1484057900-17871-6-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-10_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701100209 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.2 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1cQxGF-0000Ba-Np Cc: linux-security-module@vger.kernel.org Subject: [tpmdd-devel] [PATCH 06/10] tpm: tpm2_load_cmd: check size of response before accessing data X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance <tpmdd-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/tpmdd-devel>, <mailto:tpmdd-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=tpmdd-devel> List-Post: <mailto:tpmdd-devel@lists.sourceforge.net> List-Help: <mailto:tpmdd-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/tpmdd-devel>, <mailto:tpmdd-devel-request@lists.sourceforge.net?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: tpmdd-devel-bounces@lists.sourceforge.net |
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 57bb774..4bcda2b 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -618,6 +618,9 @@ static int tpm2_load_cmd(struct tpm_chip *chip, } rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, flags, "loading blob"); + if (!rc && be32_to_cpu(((struct tpm2_cmd *)&buf)->header.out.length) < + TPM_HEADER_SIZE + 4) + rc = -EFAULT; if (!rc) *blob_handle = be32_to_cpup( (__be32 *) &buf.data[TPM_HEADER_SIZE]);
Check the size of the response before accessing data in the response packet. This is to avoid accessing data beyond the end of the response. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> --- drivers/char/tpm/tpm2-cmd.c | 3 +++ 1 file changed, 3 insertions(+)