From: Heiko Carstens <hca@linux.ibm.com>
To: Jarkko Sakkinen <jarkko@kernel.org>,
Anastasia Eskova <anastasia.eskova@ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>,
Peter Oberparleiter <oberpar@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
keyrings@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 14/15] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce()
Date: Mon, 16 Nov 2026 15:35:33 +0100 [thread overview]
Message-ID: <20261116143534.158375-15-hca@linux.ibm.com> (raw)
In-Reply-To: <20261116143534.158375-1-hca@linux.ibm.com>
pr_dbf_vce() dumps the last 128 bytes of the certificate data of a
Verification Certificate Entry (VCE) into a debug area.
However the address calculation is wrong: vce_length is the length of
the whole entry including the header, while cert_data_buf starts
behind the header. Therefore the dump starts at the end of the entry
and starts reading behind it.
Dump the last 128 bytes of the entry like intended. Limit dumps to the
data length.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/kernel/cert_store.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 996ca3025629..12fc0ee87f3b 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -181,6 +181,7 @@ static void pr_dbf_vce(const struct vce *e)
{
unsigned char vc_name[VC_NAME_LEN_BYTES + 1];
char log_string[VC_NAME_LEN_BYTES + 40];
+ u32 data_len = 0;
pr_dbf_msg("VCE Header:");
pr_dbf_msg("vce_hdr.vce_length: %d", e->vce_hdr.vce_length);
@@ -206,11 +207,13 @@ static void pr_dbf_vce(const struct vce *e)
debug_text_event(cert_store_hexdump, 3, log_string);
/* Certificate data. */
+ if (e->vce_hdr.vce_length > sizeof(e->vce_hdr))
+ data_len = e->vce_hdr.vce_length - sizeof(e->vce_hdr);
debug_text_event(cert_store_hexdump, 3, "VCE: Certificate data start");
- debug_event(cert_store_hexdump, 3, (u8 *)e->cert_data_buf, 128);
+ debug_event(cert_store_hexdump, 3, (u8 *)e->cert_data_buf, min(data_len, 128U));
debug_text_event(cert_store_hexdump, 3, "VCE: Certificate data end");
- debug_event(cert_store_hexdump, 3,
- (u8 *)e->cert_data_buf + e->vce_hdr.vce_length - 128, 128);
+ if (data_len > 128)
+ debug_event(cert_store_hexdump, 3, (u8 *)e + e->vce_hdr.vce_length - 128, 128);
}
static void pr_dbf_vcssb(const struct vcssb *s)
--
2.56.1
prev parent reply other threads:[~2026-11-16 14:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261116143534.158375-1-hca@linux.ibm.com>
2026-11-16 14:35 ` [PATCH 03/15] s390/cert_store: Fix potential use-after-free in invalidate_keyring_keys() Heiko Carstens
2026-11-16 14:35 ` [PATCH 04/15] s390/cert_store: Check key_lookup() return code " Heiko Carstens
2026-11-16 14:35 ` [PATCH 05/15] s390/cert_store: Unlink before invalidate " Heiko Carstens
2026-11-16 14:35 ` [PATCH 06/15] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring() Heiko Carstens
2026-11-16 14:35 ` [PATCH 07/15] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring() Heiko Carstens
2026-11-16 14:35 ` [PATCH 08/15] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring() Heiko Carstens
2026-11-16 14:35 ` [PATCH 10/15] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring() Heiko Carstens
2026-11-16 14:35 ` [PATCH 11/15] s390/cert_store: Do not search the process keyrings for the cert_store keyring Heiko Carstens
2026-11-16 14:35 ` [PATCH 13/15] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb() Heiko Carstens
2026-11-16 14:35 ` Heiko Carstens [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116143534.158375-15-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=anastasia.eskova@ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=jarkko@kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=oberpar@linux.ibm.com \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox