From: sashiko-bot@kernel.org
To: "Christian Borntraeger" <borntraeger@linux.ibm.com>
Cc: linux-s390@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
kvm@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v3 5/8] KVM: s390: Fix old_data leak in guest debug error path
Date: Wed, 05 Aug 2026 11:30:37 +0000 [thread overview]
Message-ID: <20260805113038.D21851F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805110455.7200-6-borntraeger@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing SRCU lock when accessing memslots during guest debug setup leads to Use-After-Free.
--
--- Patch [5]: [PATCH v3 5/8] KVM: s390: Fix old_data leak in guest debug error path ---
commit efad1ff98c2af0fcd50545a3067b444c29f0bc33
Author: Christian Borntraeger <borntraeger@linux.ibm.com>
KVM: s390: Fix old_data leak in guest debug error path
__import_wp_info() allocates a per-watchpoint old_data buffer to back up
the original guest memory contents. If a later watchpoint of the same
KVM_SET_GUEST_DEBUG request fails to import, kvm_s390_import_bp_data()
jumps to the error label, which frees the wp_info array but not the
old_data buffers of the entries that were imported successfully. Up to
MAX_BP_COUNT - 1 buffers of up to MAX_WP_SIZE bytes are leaked per failed
request, and the request can be repeated.
Create error handling for cleaning up all created old_data memory
areas.
> diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
> index 4c02dbebb2eb3..f7c94d54efbe2 100644
> --- a/arch/s390/kvm/guestdbg.c
> +++ b/arch/s390/kvm/guestdbg.c
> @@ -252,7 +252,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
> ret = __import_wp_info(vcpu, &bp_data[i],
> &wp_info[nr_wp]);
[Severity: High]
This isn't a bug introduced by this patch, but is it safe to call
__import_wp_info() here without holding the SRCU read lock?
__import_wp_info() in arch/s390/kvm/guestdbg.c attempts to read guest memory:
arch/s390/kvm/guestdbg.c:__import_wp_info() {
...
/* try to backup the original value */
ret = read_guest_abs(vcpu, wp_info->phys_addr, wp_info->old_data,
wp_info->len);
...
}
This ultimately accesses the KVM memslots array.
Because the KVM_SET_GUEST_DEBUG ioctl entry point doesn't acquire the SRCU read
lock before calling kvm_s390_import_bp_data():
arch/s390/kvm/kvm-s390.c:kvm_arch_vcpu_ioctl_set_guest_debug() {
...
if (dbg->control & KVM_GUESTDBG_USE_HW_BP)
rc = kvm_s390_import_bp_data(vcpu, dbg);
...
}
Could a concurrent memslot update (such as another thread calling
KVM_SET_USER_MEMORY_REGION on the VM) free the memslots array while it is being
accessed by this debug ioctl, leading to a Use-After-Free?
> if (ret)
> - goto error;
> + goto error_wp;
> nr_wp++;
> break;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805110455.7200-1-borntraeger@linux.ibm.com?part=5
next prev parent reply other threads:[~2026-08-05 11:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 11:04 [PATCH v3 0/8] KVM: s390: More fixes Christian Borntraeger
2026-08-05 11:04 ` [PATCH v3 1/8] KVM: s390: Remove user triggerable WARN_ON Christian Borntraeger
2026-08-05 11:15 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 2/8] KVM: s390: Zero initialize data structures for inject_pfault_token Christian Borntraeger
2026-08-05 11:31 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 3/8] KVM: s390: Zero initialize irq in reinject_machine_check Christian Borntraeger
2026-08-05 11:29 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 4/8] KVM: s390: Fix memory leak in guest debug handling Christian Borntraeger
2026-08-05 11:36 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 5/8] KVM: s390: Fix old_data leak in guest debug error path Christian Borntraeger
2026-08-05 11:30 ` sashiko-bot [this message]
2026-08-05 11:04 ` [PATCH v3 6/8] KVM: s390: Take srcu when importing watchpoint data Christian Borntraeger
2026-08-05 11:31 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 7/8] KVM: s390: Free guest debug data on vcpu destroy Christian Borntraeger
2026-08-05 11:26 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 8/8] KVM: s390: Fix length check __import_wp_info() Christian Borntraeger
2026-08-05 11:32 ` sashiko-bot
2026-08-05 11:55 ` [PATCH v3 0/8] KVM: s390: More fixes Claudio Imbrenda
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=20260805113038.D21851F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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