From patchwork Wed May 29 15:38:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 13679124 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 DB153746E; Wed, 29 May 2024 15:38:44 +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=1716997125; cv=none; b=iIVR79r0UK4fPK81y20WPo13izY7Zk6OKiuCYQNKMC41L+4xGCyhGQq8oVzgX7MxJGYmW4bMQbVon0C3JbfsqT7Rfo3as3aFbiJwX81CHsg3MOGq9Fcw5a6FoTKCOYIidIVXHOKeLWHOvjTQLF9oN6CQ+acYk88RleQEz5c2Rbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716997125; c=relaxed/simple; bh=95TvA9/h0nvrgtQHiKcs4/LTXnVVxXsNDauH0ofIR1c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oi4DOlJwmq2C883QTN/KDwQ2rOBGg+Eh29jHg66aL299PzuQL1okcvwE9YQGOrO9mnFA3bCywKVCYdzF1Py9D6prxqcxl3I51RG+P6ePkUAwWC3gxTCgRY8X1SZCwXjMcC72gFUPETa0M+3v4RRLicRYbDh/Y4It2EVC30H7H8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f6NRrSxR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f6NRrSxR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7923C113CC; Wed, 29 May 2024 15:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716997124; bh=95TvA9/h0nvrgtQHiKcs4/LTXnVVxXsNDauH0ofIR1c=; h=From:To:Cc:Subject:Date:From; b=f6NRrSxRkwEcniePe5IqWI+XjSKLpakhGIUebxS1vI3ZCzxw0EWmOsH5pxzs0X5QS 8CfnzAJuScqr+heWuEHBepANVqajFm9cmGkWf/4AV3295V0eZabJ/LbSHBZNOmUQaA kAI5zcO1DV8f6X8rX8QpR6DkYC8cnkhEPIXAAXEMqjZez3icILEoR1bLgrUtKQS6gO I4fgcUcM9AImA6vuynw8B5W+oKipY/qbOVkixC3TGRdnNBtn6ynmY+1ayl266I41rl Uc+mQEhNH39e7UmWLkWK1vLixt8zHgwcckmcUG08chakyKLT5QkN2+oAJE+v09BgCx 2PlT5hWYSkWSg== 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 , Greg Kroah-Hartman , Jarkko Sakkinen , Peter Huewe , Jason Gunthorpe , James Bottomley , Mimi Zohar , David Howells , Paul Moore , James Morris , "Serge E. Hallyn" , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH] tpm: Remove illict WARN's from tpm2-sessions.c Date: Wed, 29 May 2024 18:38:34 +0300 Message-ID: <20240529153835.14994-1-jarkko@kernel.org> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sprinkling all over the place is just plain wrong so drop all of them before the TPM bus encryption feature hits a release. Link: https://lore.kernel.org/lkml/20240414170850.148122-1-elder@linaro.org/ Fixes: 1085b8276bb4 ("tpm: Add the rest of the session HMAC API") Signed-off-by: Jarkko Sakkinen --- I have had to literally fight for so many other cosmetic things such as https://lore.kernel.org/linux-integrity/20240528095438.1857-1-jarkko@kernel.org/T/#u so that I must have missed this. If I contribute to any subsystem, I just plain do all that is asked, no questions asked. Only reason I left a review unaddressed is when I see some intersection with the architecture. And lastly, not introducing new WARN's should be dead obvious, unless per-WARN explicitly reasoned in the commit message near to the level that it could be proven at court. Unless this care, I will simply not review patch with something like this embedded. --- drivers/char/tpm/tpm2-sessions.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/char/tpm/tpm2-sessions.c b/drivers/char/tpm/tpm2-sessions.c index 907ac9956a78..371cf28a2b6a 100644 --- a/drivers/char/tpm/tpm2-sessions.c +++ b/drivers/char/tpm/tpm2-sessions.c @@ -394,7 +394,7 @@ void tpm_buf_append_hmac_session(struct tpm_chip *chip, struct tpm_buf *buf, /* we're not the first session */ len = get_unaligned_be32(&buf->data[auth->session]); if (4 + len + auth->session != tpm_buf_length(buf)) { - WARN(1, "session length mismatch, cannot append"); + pr_warn("tpm: session length mismatch, cannot append"); return; } @@ -644,8 +644,10 @@ void tpm_buf_append_name(struct tpm_chip *chip, struct tpm_buf *buf, dev_err(&chip->dev, "TPM: too many handles\n"); return; } - WARN(auth->session != tpm_buf_length(buf), - "name added in wrong place\n"); + if (auth->session != tpm_buf_length(buf)) { + pr_warn("tpm: name added in wrong place\n"); + return; + } tpm_buf_append_u32(buf, handle); auth->session += 4; @@ -706,8 +708,8 @@ int tpm_buf_check_hmac_response(struct tpm_chip *chip, struct tpm_buf *buf, int parm_len, len, i, handles; if (auth->session >= TPM_HEADER_SIZE) { - WARN(1, "tpm session not filled correctly\n"); - goto out; + pr_warn("tpm session not filled correctly\n"); + return; } if (rc != 0)