Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp696382lqb; Wed, 29 May 2024 08:03:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWf4E8BzDo8gLCEv9dt161fJM21Nf5pejI1wmlqMnUyeJSGCixMoi1Er71SqcrLKMDJkfDlZBgnd9AlAanxbATJoUFU4tFCBr8EiSnSQw== X-Google-Smtp-Source: AGHT+IGB+LPUND+7DITrrtjizhGDhyq19nfeXYWdopsLMjfOON1YqvqJOagR6q3xP6sEv0nL84b4 X-Received: by 2002:a17:906:2ad2:b0:a59:c9b1:cb68 with SMTP id a640c23a62f3a-a6264076042mr1167723066b.7.1716995012861; Wed, 29 May 2024 08:03:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716995012; cv=pass; d=google.com; s=arc-20160816; b=ZH0+mNTmUceR86EqZl68vLQPUpBFqLEEpv6wB4+vbqKRWRH5Fw9BpgdZDJsoNU7RfX oFOoy2QCV+sumT5+I8jbiUzwmKzuwkrcQnAjAJNQAGPGcXCnohpgwuCvEW4PK+fhnQ7a iyQRJPO28QPRHxV2gwciqGW666SFjhfptcLSwddmGyLpPZ8E9P9LTy7X7sgFeYVTVTqW 2762K47XYkt4SxYtVenasO3TccIvz74TMBvH+0qUJtZKsMb27g1D5mWNj0WCoA/s5J0j 6g7JY4FHCmoVz4FSp4L5nNseR3ibsjcuMTWM0LMQVcBQLAGawBtIOCfVerD9NNLSWAJ/ 4N0g== 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=xQGaTSeld7GdBoYxbatoY+W7RlfP8hhiufDU4PQZjGU=; fh=Drzx2JZ5+heBbbSBK3UjmVObwv3+kc1Ura/9H57iRIE=; b=t+4zhb3PEI8ToLIukkzj1LG0Ab4BnTowioiK0WqCODS91gIZyf6n0pD0NL6Za4Gjnl m7XqDEfXp/L4Shzfhn0oVNyUDjgD4pO5wjz1tE97V6FxSrbSMjxp8NzWNCwOpxwhyIym T0Z3nXDzGAJuBz7+o3rFsmSG1et3444GuO2w7znFIEWShi/ZT6hkQw/RwiNlCAeEgMkK VSbqid5uGVXbGdkZs/Q4OZ9wNbkiVv5HhB1LwOIb8KYQpgKSaKAUleEWfU8BCUTwRoVq Jvdk0A3MLrncTZrlXhKSbV33tjIrKwiRIuuoHv/UeelouL3sOA+DWsL/49+i0R+g7RiE /zkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nQxmWSDf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc3856dsi624132266b.331.2024.05.29.08.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 08:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nQxmWSDf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4500-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 am.mirrors.kernel.org (Postfix) with ESMTPS id DCD771F239BC for ; Wed, 29 May 2024 15:03:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EF6017BB15; Wed, 29 May 2024 15:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nQxmWSDf" X-Original-To: linux-crypto@vger.kernel.org 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 CF4FD15B11A; Wed, 29 May 2024 15:03:02 +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=1716994983; cv=none; b=Ct5kmO1lZVWAZXN7Dt0XbK8iM2yjyq77w6Co8v9NwJTyTkbZsskMbYKr9TFX+oKFxe8kcwc2F8j3pEdCGhzPtXoOF45VyZlqZNbN+OPoqLXi2g4YTS40wmoz+0o9gR8hS3bHu/xJXiizLHwM9uLAOsXqG09Vf14JoUGXnumwW1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716994983; c=relaxed/simple; bh=GgJTrTZisEXG4OMYBlgiTpElAAP3aUEM38oKEk6OIgE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EZzujF+3EvowF1bhfxdp/zv9r3F+2HP68bf5RGBtApS6bly+o3K8jbGWLTqdu3jagPVoPAyf4um8sR90menBSERcGNnQs2bKjH6mgTqX8QZADezu4Ym2W5nHuoeq/HBGfY8msJjm8knqwNPa3WqBUt3/k8yUJ2w881wv1j5ICuQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nQxmWSDf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC26FC113CC; Wed, 29 May 2024 15:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716994982; bh=GgJTrTZisEXG4OMYBlgiTpElAAP3aUEM38oKEk6OIgE=; h=From:To:Cc:Subject:Date:From; b=nQxmWSDfytkUQyRo+wZ9v6jYtaba9+r14sI5ypj2JwXsNfW6U7pSkaB1Gyw9BtUUt /qcY1pCFtUCL3AcCibBndTdfDP9o6i3s+vIwCGvUmD1vhPfC0fqMBHD/eOrnP3HfsH z742rZlRQ5oUdXUEuKW3XnS1az68qUetk+AXhIJtx9MmmdarIqP68pzlyBSKPPpAVr ltci8DAuAaMrGWOMfGjGT4O37ofsFkaZIpEh7TmBZzkXLOkMKHvZi70D8xNRz+r40H 6/bW4vOei5CUKMgmwTKoZ98Nl+YatiMAje3h53SU8Tli7g47n2LpxvZCjaMfO16+sl PtmwX6tzPHzbw== From: Jarkko Sakkinen To: Herbert Xu Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, Andreas.Fuchs@infineon.com, James Prestwood , David Woodhouse , Eric Biggers , James Bottomley , linux-crypto@vger.kernel.org, Stefan Berger , Jarkko Sakkinen , James Bottomley , 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: Change -EINVAL to -E2BIG Date: Wed, 29 May 2024 18:02:53 +0300 Message-ID: <20240529150253.27630-1-jarkko@kernel.org> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Report -E2BIG instead of -EINVAL when too large size for the key blob is requested. By filtering these errors from other invalid data, this will help distinguish the overflows. Link: https://lore.kernel.org/keyrings/D1M4GRF0RL2W.3QHTBXZWNW9RW@kernel.org/ Reviewed-by: Stefan Berger Signed-off-by: Jarkko Sakkinen --- I don't think this is a fix and neither needs to be backported but makes sense for upcoming versions. Sending as a separate patch from the TPM2 asymmetric keys series. security/keys/trusted-keys/trusted_tpm2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c index 8b7dd73d94c1..06c8fa7b21ae 100644 --- a/security/keys/trusted-keys/trusted_tpm2.c +++ b/security/keys/trusted-keys/trusted_tpm2.c @@ -122,7 +122,7 @@ static int tpm2_key_decode(struct trusted_key_payload *payload, return ret; if (ctx.priv_len + ctx.pub_len > MAX_BLOB_SIZE) - return -EINVAL; + return -E2BIG; blob = kmalloc(ctx.priv_len + ctx.pub_len + 4, GFP_KERNEL); if (!blob) -- 2.45.1