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 E3C2AC433EF for ; Sat, 2 Apr 2022 22:41:29 +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=rKc5NVBHU3gsG1z6M1kcVp8lT6BHfuhOcq2FF191Bw4=; b=AzhndphvxtWAzH kF/oWZwlSwCa47eJcU2QrH//7gDngvI30/BM65TLYJuOtyKXoYPuEkZ4E0kG/j8qEQBJFmzc6JqFh fNMTZ6TbBnjxW7x2XrRmukolHVs8msVWdw/AXSnigj7yp8gbz4w0PdwArjeiJbk0KjTmOD4b/POko GeXEjb2HFjQsPNm1RXA76/DvlmQiT4rDFcqG2VDXrwe/3wtX0ZRMpoGg3m4OsbJDMsSBw8A3vCC6x muClW2Xa5xjigjuQcxe0NYEGNS52101MyUG495Fy5pEVbM0yrFzRch2OvwFmhsWT6DyCd7RFoiDfN d/QsBsKqiyTU9xqofjDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1namPP-00ADJ9-1t; Sat, 02 Apr 2022 22:39:51 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1namPK-00ADHw-BU for linux-arm-kernel@lists.infradead.org; Sat, 02 Apr 2022 22:39:47 +0000 Received: by mail-il1-x12e.google.com with SMTP id x9so4375931ilc.3 for ; Sat, 02 Apr 2022 15:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=qLNzO18ajat1m0fs1W8NtMq/BQbLXFrYLsmtTPYjHJ8=; b=fcII4z0VLNKpeNeV5LH4dIsf92I/nz7pTv6mXarO0z2A11z7ck/GMqJi+mc9XrUnxE 7ky3roY//u2Cwlvh1KM0wmujjr5BS+CZNvL3i0q0IUGBgQlGPDqkUlsdz9Qv1m66ZKzd HUOzOXtq18Kbx0+9BgZG3O3uS/BXrP9TCj3i5us0XTuANYrokrPw2idLLomuPfpJv8MV MqesIUQFeoKbaIKGe8DYFJGZ3X9qr7HNrbkmzuUn75LQH0PREvjnh8TLoylFd+uLK0Z/ ZxPIuqa4F4XSGj5MeJFtlf3eE0d0OJLE0rGeVLUdGNRN2V7z4fMMqSDJhJVSalF7jDPT j4Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qLNzO18ajat1m0fs1W8NtMq/BQbLXFrYLsmtTPYjHJ8=; b=mEmbjyT+IHgfEoM9I5hv5O19XltXguv0L1VvYmDl9fWTlCrQ5LGo9ihNnm/2QMt4u9 UGfe3VVUTch+G4xOPol8SClKJQiOnvSvSvLoxbzXhB7BKa5+d2ctk/TmYiGVBl07g/xp 5rx+9Ac634xDuXZQmvYYWzURFEaP7doc+g+k3Ho+r7OTwj2c+dBdR/tcix9TqCvc3eaG ASCZUkm7a9qq4IlBMknx3hFkB5PbQ8+qHVZHY9K92EnO3B3e+slfJvq7pqi248cb3lQo cPKgH3LjdtyFRWNMQXnIoNvCnTUWmcD3JpobD+VmwNFLiQpXiNK70YJll0GmmGpHesQO KTbw== X-Gm-Message-State: AOAM531cPzOUYWgH4Tnalu8jQ39+/05b/jeFSO3LhRh7m8Y2TkspFfXE eAaU5Uoh9Us++HQ6MP/0eNKvoA== X-Google-Smtp-Source: ABdhPJzkTWYehe59rde3kRAtZPzzbA6tHyxqruaUsn3Kn0DRZ6Wh/jC8BaavKN0yp+ne9/VWwnP0fw== X-Received: by 2002:a92:6a01:0:b0:2b6:87b7:180b with SMTP id f1-20020a926a01000000b002b687b7180bmr2725039ilc.82.1648939179643; Sat, 02 Apr 2022 15:39:39 -0700 (PDT) Received: from google.com (194.225.68.34.bc.googleusercontent.com. [34.68.225.194]) by smtp.gmail.com with ESMTPSA id r9-20020a6bd909000000b00649276ea9fesm3648152ioc.7.2022.04.02.15.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Apr 2022 15:39:37 -0700 (PDT) Date: Sat, 2 Apr 2022 22:39:34 +0000 From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Paolo Bonzini , Sean Christopherson , stable@kernel.org Subject: Re: [PATCH 1/4] KVM: arm64: vgic: Don't assume the VM debugfs directory exists Message-ID: References: <20220402174044.2263418-1-oupton@google.com> <20220402174044.2263418-2-oupton@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220402174044.2263418-2-oupton@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220402_153946_453022_6F6968FE X-CRM114-Status: GOOD ( 18.99 ) 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 Sat, Apr 02, 2022 at 05:40:41PM +0000, Oliver Upton wrote: > Unfortunately, there is no guarantee that KVM was able to instantiate a > debugfs directory for a particular VM. To that end, KVM shouldn't even > attempt to create new debugfs files in this case. If the specified > parent dentry is NULL, debugfs_create_file() will instantiate files at > the root of debugfs. > > Since it is possible to create the vgic-state file outside of a VM > directory, the file is not cleaned up when a VM is destroyed. > Nonetheless, the corresponding struct kvm is freed when the VM is > destroyed. > > Plug the use-after-free by plainly refusing to create vgic-state when > KVM fails to create a VM debugfs dir. > > Cc: stable@kernel.org > Fixes: 929f45e32499 ("kvm: no need to check return value of debugfs_create functions") > Signed-off-by: Oliver Upton Thinking about this a bit more... The game of whack-a-mole for other files that possibly have the same bug could probably be avoided if kvm->debugfs_dentry is initialized to PTR_ERR(-ENOENT) by default. That way there's no special error handling that needs to be done in KVM as any attempt to create a new file will bail. Going to test and send out a v2 most likely, just want to make sure no other use of debugfs in KVM will flip out from the change. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel