From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D706C48260 for ; Tue, 13 Feb 2024 16:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V9/kwt6SJKjWLVmDzVVxgVbNYccR46I473M1Quzjmg8=; b=RSrR6Xuu0gJAZb Cxkvo5D3vYshAytO/ZgrOGXBdbFJRogsS2mm9k5dYQMTF26YTLQC1+W40EObOf2igC3u6KrqU3Lsv BZt8Z/W4QrvktbcH2+nHie2dUIvXc4Nhu/z3fppoVuE8knhbV/QkCSsdzgEmz8653fUIFgfm7w1gR lI/pKkM1iLOySoUjboFckxyaDZPdPFAnFuUuw2uf5kwFaBHQu06//pEFt4gHU99xi1XvKmBUdMSL+ 7CTMvH2oapqB0bEHa1yoAodEH86ALkAEnzef8d7QyFFcumrZG5LEtby/8iBjMel6CH8rRkNQVnsvA yr1+gamVs3RvCS2c1hUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZw0H-0000000A2lP-0wwy; Tue, 13 Feb 2024 16:51:29 +0000 Received: from out-188.mta0.migadu.com ([91.218.175.188]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZw0F-0000000A2kw-0zrN for linux-arm-kernel@lists.infradead.org; Tue, 13 Feb 2024 16:51:28 +0000 Date: Tue, 13 Feb 2024 16:51:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707843080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E+a8il656wm0JNzy2XZ2whgFkgYGy3mjL1DXh5soG1M=; b=nzMkqDRU7++7XpYRT6myB0KFUTXU8HbtM7x7fHvME6+8jN1MOBq0WYcuhXR+N3AN/q3TMQ cPMI15KvdQT7jxXBwqTPjA9SGQ6QZxcPeWRIQmd5G3IC8nEE//IW38C5yea3gtmEGxhKj5 kthep06gyAyeELiwUsqhVRffxI7r6bw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sebastian Ene Cc: catalin.marinas@arm.com, gshan@redhat.com, james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org, rananta@google.com, ricarkol@google.com, ryan.roberts@arm.com, shahuang@redhat.com, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vdonnefort@google.com Subject: Re: [PATCH v5 3/4] KVM: arm64: Register ptdump with debugfs on guest creation Message-ID: References: <20240207144832.1017815-2-sebastianene@google.com> <20240207144832.1017815-5-sebastianene@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240213_085127_512434_5CE1228C X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: > > On Wed, Feb 07, 2024 at 02:48:32PM +0000, Sebastian Ene wrote: [...] > > > +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