From mboxrd@z Thu Jan 1 00:00:00 1970 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 D5D962FFF88 for ; Sun, 3 May 2026 11:46:51 +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=1777808811; cv=none; b=HiGIXr9TsF4KTSQ+Tr2scCIZjqNiJE51NCZquiDfQ770wJFLF0WhBlYfG7v/Oexw1zywLgpP+Am2uiNhKk4pu70jOecYM2BXBmsbE+UpGJOZHdyMzqi5wSR3XLw4JYHysnLR1EysvgOe3rHwjwzAZ+JLgnCRQ9RgfYQfj3j9e9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777808811; c=relaxed/simple; bh=Wus1zAxgigpgJovf6vjoRuTMgU+JmD36BGYCKF2lRzg=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=VhnoyQn1U4B28xy84WTByI+6gTVqZjqmXHzK9pxkP3lRgRppr8spqWriKvLqOfEAQKlPipwtOPIUOLCXEi6tsuqUi07zYU+N585FxyQdYfcsAPlHhzC9LM+pMQWwfGptQpQaEBb+5Oik+iBwSoHAAAvCy3pIWKlhzyDB2Mm6toY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bmvhtxRm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bmvhtxRm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CD4CC2BCB4; Sun, 3 May 2026 11:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777808811; bh=Wus1zAxgigpgJovf6vjoRuTMgU+JmD36BGYCKF2lRzg=; h=Subject:To:Cc:From:Date:From; b=bmvhtxRmuhGWmw9JKnVxHTEPGXl923yJ6gIznrie+sQyIV14lF4r8d+VuSFzDDmpa 9nkhRjIZGuDr/irI9TZi4q+KCZqxMaD+M4oL6pvAoBswn9K40e5kR0c5c9MIhdsLUX IxQyJlZ2L1LjU6ySPU14j4P7ENirfT70k6mfFcZg= Subject: FAILED: patch "[PATCH] tpm2-sessions: Fix missing tpm_buf_destroy() in" failed to apply to 6.12-stable tree To: gunnarku@amazon.com,jarkko@kernel.org,jbouron@amazon.com,pmenzel@molgen.mpg.de Cc: From: Date: Sun, 03 May 2026 13:46:43 +0200 Message-ID: <2026050343-flaring-bauble-02a2@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x f0f75a3d98b7959a8677b6363e23190f3018636b # git commit -s git send-email --to '' --in-reply-to '2026050343-flaring-bauble-02a2@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From f0f75a3d98b7959a8677b6363e23190f3018636b Mon Sep 17 00:00:00 2001 From: Gunnar Kudrjavets Date: Wed, 15 Apr 2026 03:00:03 +0300 Subject: [PATCH] tpm2-sessions: Fix missing tpm_buf_destroy() in tpm2_read_public() tpm2_read_public() calls tpm_buf_init() but fails to call tpm_buf_destroy() on two exit paths, leaking a page allocation: 1. When name_size() returns an error (unrecognized hash algorithm), the function returns directly without destroying the buffer. 2. On the success path, the buffer is never destroyed before returning. All other error paths in the function correctly call tpm_buf_destroy() before returning. Fix both by adding the missing tpm_buf_destroy() calls. Cc: stable@vger.kernel.org # v6.19+ Fixes: bda1cbf73c6e ("tpm2-sessions: Fix tpm2_read_public range checks") Signed-off-by: Gunnar Kudrjavets Reviewed-by: Justinien Bouron Reviewed-by: Paul Menzel Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen diff --git a/drivers/char/tpm/tpm2-sessions.c b/drivers/char/tpm/tpm2-sessions.c index 3b1cf1ca0420..c4da6fde748f 100644 --- a/drivers/char/tpm/tpm2-sessions.c +++ b/drivers/char/tpm/tpm2-sessions.c @@ -203,8 +203,10 @@ static int tpm2_read_public(struct tpm_chip *chip, u32 handle, void *name) rc = tpm_buf_read_u16(&buf, &offset); name_size_alg = name_size(&buf.data[offset]); - if (name_size_alg < 0) + if (name_size_alg < 0) { + tpm_buf_destroy(&buf); return name_size_alg; + } if (rc != name_size_alg) { tpm_buf_destroy(&buf); @@ -217,6 +219,7 @@ static int tpm2_read_public(struct tpm_chip *chip, u32 handle, void *name) } memcpy(name, &buf.data[offset], rc); + tpm_buf_destroy(&buf); return name_size_alg; } #endif /* CONFIG_TCG_TPM2_HMAC */