Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1088328lqb; Sat, 25 May 2024 05:36:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWYwhYqyIrDUUDX/s+FmpIcwbd7AeX9XDClMQf2tqfZ8a/JL25/ls02g90stwRH9jq4WzB247BSFylUWED4r7NRTTuPOA8jlmBCShIXg== X-Google-Smtp-Source: AGHT+IEHw9eyZ15GwYsYmTxVU/lQUkN8CPXM0EiCk8V3mdGCM+OpJOyFDzM7GvGBRXzAAmNMnHg1 X-Received: by 2002:a05:620a:240a:b0:793:ff1:abfa with SMTP id af79cd13be357-794aa7c4e68mr919917185a.7.1716640618256; Sat, 25 May 2024 05:36:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716640618; cv=pass; d=google.com; s=arc-20160816; b=t4ybWU6xx0crh9Y0A+vJYuAICoS71n02i44AK19Xt2CJ1cmFYha/f0RFhpEdnbGvKT ZYxf7dApP9mlhj6MeRZpJjPlTGgszGoUasWnz9oiunXNcckgKfciw5l2+Phtj9wWQT2k 73rPiKtL+3ZTiQlYtfEt5plf+O5akexVPB313B7xKJibt5bsgUC9AdDqadHh5OB9OguF 9ZkxUuI4Sq/dcRpcvPIlq626O9UpWWtCMMyPHrmWu9g6DsGFCb6EJbZPBIZcVQGHeS+p /Zei/UAYAkb1UqKz7RAlcp/4PsZf1uH84/0sX6w39dFSiLzKVdrekrSs9p7nnGJSS7wc yZkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=TbD37W7ADNCyxIK9n+n/kY6CIppqRTbyCe+QjbsiI4w=; fh=hVg4LrrhFSDzbriqHJpcMiUtLePPU0VRrh7QdWe4jXM=; b=RSSyYlASV1WFwtxolzf2Q7yE3QC8xX1rqMUMPmmgEEx/nRjFBUPlFt3fC5W9msTqg4 /6Mf8cWBDOzeMnx+MmtJkbOTdbh6kD7Tp88Iojtu/4npHpbpRGSf6/DJs5kRkskpsYlg rPXujQ3xdyH3wrvfpfb5Fxi/Wf0LYSsZu/b04+5coSdGIR2mjgmhs3Xs5PmMhuhAX0l2 aiOQ3Gc4haBaFaWDVRkzvKS6ED/PhHhshUZrSO4xpOwXtAqNXM0+vE8RE0U3DWHhrTN7 aqz15O2JaGnxh6Z50sFIINoMibiljKOD0CDo1u5LSjQsP7uoaJ4E0dIY3M+lRMp4EMu0 q3bA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ubWj447c; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abcac28fsi361029985a.40.2024.05.25.05.36.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 05:36:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ubWj447c; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id ED4B91C20B7F for ; Sat, 25 May 2024 12:36:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C67947F6B; Sat, 25 May 2024 12:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ubWj447c" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 836AFDF62; Sat, 25 May 2024 12:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716640606; cv=none; b=d37LBzim/SfW1RCHSb2+IdEWlhPvK9W5QLRRghE+UW812n72ch17Cany4NdNmYHZDSeUowFhx2J+/Jg6M61Gk4Zcq61DzljbL7XZxxOrXY24vCSNS4ioR7Cbht5K1VZ2BOROmz/46qmAqyAEY/OqaPjwe32rtOVX1BZuI/TAl+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716640606; c=relaxed/simple; bh=iYJiwZkq202sbFOQmZ/InspF352DafABToYi4GRr+ps=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=S87TlXO1XQ3xCG/hsTEV+JKWy5iOONh6wARkAexl33yRIJV5K9gOYmoRbG9G68xqYBhRPxP8sWjYsIus7sc2QxeNn/jCFQSSzOlJzWBQkg6N6B8iPb011E3P28My1EdqJUgjLkX1dDRAGj4WKSfLZvsUgw6SFElKW4Fvy9tSM6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ubWj447c; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1CC4C2BD11; Sat, 25 May 2024 12:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716640605; bh=iYJiwZkq202sbFOQmZ/InspF352DafABToYi4GRr+ps=; h=From:To:Cc:Subject:Date:From; b=ubWj447cpnppasdvMyvq08tvBeJD4k495DIDLj5VpV7XZXppojROdM94TAKzujuvb bIhwbPJ2BQHa9TSWAFMNaEW0xOimICXZ6i0aWHc62jNFw+T3l9b4IWTsnwREX3H81J aKLyPMBhXF6VZQSoTr+5xkl8ia+6YaWMmCiF/6WXIDjPX2J7ByQG+FNxmdTCI3dQCe NU38ASVM37vlftlIWZr1BAgsNNJKy0v1VVr4F6Ei4/s1P5XQeCugJBX5ndJGNFfzW/ S2tryxDtyKrrlL8pmyBbPireptWqei0qzSC79MnxmTOcN/vYcJzsWa5c41osn2gq8d SfT+ONdUOof9w== From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: keyrings@vger.kernel.org, James.Bottomley@HansenPartnership.com, Jarkko Sakkinen , stable@vger.kernel.org, Mimi Zohar , David Howells , Paul Moore , James Morris , "Serge E. Hallyn" , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KEYS: trusted_tpm2: Only check options->keyhandle for ASN.1 Date: Sat, 25 May 2024 15:36:33 +0300 Message-ID: <20240525123634.3396-1-jarkko@kernel.org> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit tpm2_load_cmd incorrectly checks options->keyhandle also for the legacy format, as also implied by the inline comment. Check options->keyhandle when ASN.1 is loaded. Cc: James Bottomey Cc: stable@vger.kernel.org # v5.13+ Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs") Signed-off-by: Jarkko Sakkinen --- security/keys/trusted-keys/trusted_tpm2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c index 8b7dd73d94c1..4f8207bf52a7 100644 --- a/security/keys/trusted-keys/trusted_tpm2.c +++ b/security/keys/trusted-keys/trusted_tpm2.c @@ -400,12 +400,11 @@ static int tpm2_load_cmd(struct tpm_chip *chip, /* old form */ blob = payload->blob; payload->old_format = 1; + } else { + if (!options->keyhandle) + return -EINVAL; } - /* new format carries keyhandle but old format doesn't */ - if (!options->keyhandle) - return -EINVAL; - /* must be big enough for at least the two be16 size counts */ if (payload->blob_len < 4) return -EINVAL; -- 2.45.1