Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp42623rdh; Tue, 13 Feb 2024 08:52:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVW1H7yfyhn/k58SQpEU6zSdWXrY2USZB0xtujH+ipMr6TE7rtfSVktcGcMyWp2RFt7l1mi7hGpbFHe5DxQ7Q74A7helyCMpkp8OMYx1w== X-Google-Smtp-Source: AGHT+IFItBl7tk4HD0bwpiVOww64FCvNUxBJGEx5/haLOjqP3GxqUJx0ziYL4PVkY14eppkmvhhb X-Received: by 2002:a05:6a00:1494:b0:6e0:d4c8:28e with SMTP id v20-20020a056a00149400b006e0d4c8028emr8736829pfu.29.1707843142258; Tue, 13 Feb 2024 08:52:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707843142; cv=pass; d=google.com; s=arc-20160816; b=qEpPibShwJ7agLHafccxHj9inqLOO3jmcq+j/Ke3Xw3lw4axZZx7egPktgYKJhhZQ+ Ye48TtA99bcFYw53MMYPvTwYVZmHPd/ukGIi/nGcRt/aCzSj/q7ECCKxGp/AJQg6Fcip ePs5rSRphi/tIeaTNRjiYui1XXAwN612NoPAMgTkR/0o2bbHntFpjxdrlt9oyyiBRAeD tnKq8uthC0sEfwiaHIwvEEaJgox+6q5PUUNg1+GP95nvUuoQgCN8mR3YYyssRmIqfwEZ NEhwaukBePii6zzOBz7VFAdENcxe6uynHzH9rSm0vVcm/Qc9VtoUPkekrAhTSAw7FlZO w68g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=E+a8il656wm0JNzy2XZ2whgFkgYGy3mjL1DXh5soG1M=; fh=FS2ugVtg2R6ol7uaMEoB+ps3HDaewgO+1GGzH8r1FIk=; b=gE6PhiwVTmbfjwQxVkHV/dlKqKdStFzcbaJ5euj2VN6K28nQx7X9SXHiYeimbn4Y4u MUc8w6oOuDIOYVWjI/iPDpJmkVhesQJKo7u3/hw0lqPdzHInRBoZ09VaQgLnhVdzEetC RB6rUq75fWCc6UE6aYSax1+4xgjtft9VQ3YSdJ92EMSLiHgHUi4sNiDOhbNvPGDj71a0 nhUk7Nk671nJ1oOU4DGNCmkB71O2FqbCTTOMBWZ9pZtJHVntosAfwkKp2UaJerpvylzr HNuGQ8MGgjylTdPBbzx/D+7xtlEhsqm53+8jyOGg+I8kAh8aLXw+xTK1HWe1qiipJnLs 9dTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nzMkqDRU; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63939-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCXKOGrfphU8xnw+sYnuz8XuOeBDcP91kG8qX7B+AyAseiJfsLz3wRwzdEnJVugwQZwi1C4cfsvZ2WT24PkYH1XeTrV6GfXEceg6O/mthA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p40-20020a056a000a2800b006e0dd1fc7aasi3776106pfh.187.2024.02.13.08.52.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 08:52:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63939-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nzMkqDRU; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63939-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E3FDF28DB9B for ; Tue, 13 Feb 2024 16:51:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42CC85788C; Tue, 13 Feb 2024 16:51:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nzMkqDRU" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5489025565 for ; Tue, 13 Feb 2024 16:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707843084; cv=none; b=iju5Vbr4YJqgD/eUVcQw62nmhkKm65J3LlkPGKHRHlgQ5Uzag6HaobPrr4K55lNYE6pZl1oh6nWQhPX8+xOteBp2B8dNKxMtYQtzEDedCd4Lp6EuKRKahXop1ayzjX7FNAVCMqCcXM9iBYF+SE4PUydDih2Cv0z++6zpf5s0DoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707843084; c=relaxed/simple; bh=kl7ymghwoEm5fD1aXGSjAnJFh0kINLOOXi5jM40r5aA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JXXhP1oM8hxCyoUD5cpuvjxKTU5VJeycHFKnQBY29hoHW1+dq+18zTzcmm3mPZpv32kW8s7A6GXlJgE89fUBc+ppzQYk0hg7MtxmsygJ0BQmlnR3OuSUjfUtkwUjpgVX1G1nQxJ9NtEMCVw0H0+GALygVhNX9VwE/FaWVfvJ/gg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nzMkqDRU; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT 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