Thread (12 messages) 12 messages, 2 authors, 2024-02-14

Re: [PATCH v5 3/4] KVM: arm64: Register ptdump with debugfs on guest creation

From: Oliver Upton <hidden>
Date: 2024-02-13 16:51:22
Also in: kvmarm, lkml

On Tue, Feb 13, 2024 at 04:42:27PM +0000, Sebastian Ene wrote:
On Tue, Feb 13, 2024 at 12:56:20AM +0000, Oliver Upton wrote:
quoted
On Wed, Feb 07, 2024 at 02:48:32PM +0000, Sebastian Ene wrote:
[...]
quoted
quoted
+static int kvm_ptdump_guest_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, kvm_ptdump_guest_show, inode->i_private);
+}
+
Shouldn't we take a reference on the KVM struct at open to avoid UAF?

	struct kvm *kvm = inode->i_private;

	if (!kvm_get_kvm_safe(kvm))
		return -ENOENT;

Then you can do a put on it at close().
Thanks, I though that the kvm_destroy_vm_debugfs will keep spinning if
there are opened paths to the debugfs entry, but I guess nothing prevents
that from happening and the kvm struct can be removed behind our back.
kvm_destroy_vm() will get called after the last put() on a kvm struct,
so all debugfs files should be closed too if we're consistent about
this.

-- 
Thanks,
Oliver

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help