From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>, sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org, Vasily Gorbik <gor@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [GIT PULL 4/6] KVM/vfio: Use file-based reference counting for KVM
Date: Fri, 9 Oct 2026 18:46:36 +0200 [thread overview]
Message-ID: <f73f015a-1d2e-4a61-82b6-0c47a2ae66ca@linux.ibm.com> (raw)
In-Reply-To: <4944d4a4-cb8d-4c46-aa84-c0050991cffb@redhat.com>
Am 09.10.26 um 18:06 schrieb Paolo Bonzini:
> On 10/9/26 16:56, sashiko-bot@kernel.org wrote:
>>> -static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm)
>>> +static void vfio_device_file_set_kvm(struct file *file, struct file *kvm)
>>> {
>>> struct vfio_device_file *df = file->private_data;
>>> + struct file *old;
>>> +
>>> + if (kvm)
>>> + get_file(kvm);
>>
>> [Severity: Critical]
>> Does taking a strong reference to the KVM file here create a circular
>> reference cycle?
>>
>> When userspace adds a VFIO device to a KVM VM, kvm_vfio_file_add() takes a
>> reference to the VFIO file. If vfio_device_file_set_kvm() then takes a
>> reference to the KVM file, both files hold references to each other.
>>
>> Because both file descriptors hold each other's references, their f_count
>> will never reach 0 when userspace closes the FDs, permanently leaking the
>> KVM VM and the VFIO structures.
>
> False positive, the reference to VFIO is in the KVM-VFIO device file and not in the KVM file descriptor itself. Using variable names, there is one reference from kvf to vfio and one from vfio to kvm.
>
> (Right? :))
>
Yes, already addressed here.
https://lore.kernel.org/kvm/b49ec974-6937-4057-869b-a6e2d5958c6d@linux.ibm.com/
next prev parent reply other threads:[~2026-10-09 16:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 14:27 [GIT PULL 0/6] KVM/vfio: Use file-based reference counting for KVM Christian Borntraeger
2026-10-09 14:27 ` [GIT PULL 1/6] KVM: Introduce file_to_kvm_<arch>() infrastructure Christian Borntraeger
2026-10-09 14:37 ` sashiko-bot
2026-10-09 14:27 ` [GIT PULL 2/6] KVM: Add file back-pointer to struct kvm Christian Borntraeger
2026-10-09 14:40 ` sashiko-bot
2026-10-09 14:27 ` [GIT PULL 3/6] KVM: x86: Use file_to_kvm_x86() in SEV Christian Borntraeger
2026-10-09 14:36 ` sashiko-bot
2026-10-09 14:53 ` Christian Borntraeger
2026-10-09 14:27 ` [GIT PULL 4/6] KVM/vfio: Use file-based reference counting for KVM Christian Borntraeger
2026-10-09 14:56 ` sashiko-bot
2026-10-09 16:06 ` Paolo Bonzini
2026-10-09 16:46 ` Christian Borntraeger [this message]
2026-10-09 14:27 ` [GIT PULL 5/6] KVM: Restrict kvm_get_kvm/kvm_put_kvm export to internal KVM modules Christian Borntraeger
2026-10-09 14:27 ` [GIT PULL 6/6] KVM: Remove unused file_is_kvm Christian Borntraeger
2026-10-09 16:30 ` [GIT PULL 0/6] KVM/vfio: Use file-based reference counting for KVM Paolo Bonzini
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=f73f015a-1d2e-4a61-82b6-0c47a2ae66ca@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=agordeev@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=pbonzini@redhat.com \
--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