Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3916370rwb; Tue, 16 Aug 2022 10:54:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5J6wurOQz0Yj8Vv1UlPBpus57+rW0qL7eD4Hx1Rt0hB4FNaPubU6TdlpMnhzaVnBZJwrt/ X-Received: by 2002:a17:902:ea03:b0:16f:2506:bfd5 with SMTP id s3-20020a170902ea0300b0016f2506bfd5mr22890529plg.21.1660672468850; Tue, 16 Aug 2022 10:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660672468; cv=none; d=google.com; s=arc-20160816; b=thH9bswYtPPokEKhcjtd8q5gNzxZ2H0X0L0SxpJg/P0W1KJMEkjRYFH2ADwmV/ivWl SP8M9Hpzgt1E8wFavJiTrvawlaUnQ6zlr8meCeQ8pFUpyVFKPptf/QCdGBMdcErJGkBK 2T9K/0bzVKZiUPdj1tPbQ4uLdKuNvSyKfb8bg1rgDqXjucoFFfOrrMJzmCfUpp94wVsc qfG6BSlZRy2epZbLFefCQ+aajEk6VDRTfFG0uy2/xemL2ffyL4MxCKLGoLsQ579lBEr9 V/mo0l8EVT8aAxAGb+2/Y1mcILyC9oe/mAbPFPuauf+GpZM3RPfYSqNsXeu8fF304MKq O/mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=Q7GzCHpVG7Wwapi8snUOsa+0evy9/qQD8vVEsMqe4rc=; b=fUPF0U0EalipWvB/REhvgzZHWoplATqZD79wlZOsPzRN0MPQ8SYz2NGBLlIHNUpj5l 1N6TvdKteftV+i8/R9kP9Ph0JbCM51cxgiUCFI8Ri4oQMOWnihrw6KJBmNG1dH63Alna d62v0Ug8H4701735PlKU++qw6xjj8gJ7l4S2oxu90Gm/5pRO/lZBnZ4NuvoAOxeJkMa8 rOOOUdeMYYb4rr74KbOkT9WfgYx0GtByB0iSO4Kajhx9uU1H+6RudJlIONq1LFrpjXgF fhC+qVxmvk1lJWlisVEZ2ABEdxj9LAZ3gx+ERszFyqNdxYzcienlkliIfEgNPqV+B2md cRdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="PCK/uec1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t187-20020a6378c4000000b0041ccc0ff2b8si14069204pgc.95.2022.08.16.10.54.17; Tue, 16 Aug 2022 10:54:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="PCK/uec1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236078AbiHPRwq (ORCPT + 99 others); Tue, 16 Aug 2022 13:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbiHPRwp (ORCPT ); Tue, 16 Aug 2022 13:52:45 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BCC082763; Tue, 16 Aug 2022 10:52:44 -0700 (PDT) Date: Tue, 16 Aug 2022 17:52:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1660672361; 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=Q7GzCHpVG7Wwapi8snUOsa+0evy9/qQD8vVEsMqe4rc=; b=PCK/uec1VTNPAPm9bkC4rVejRIVlzNGvrmwPsjkHtuej17Djedxh17ZNZfyvdfXVqZ3Otr /IfX3csoFElUvB7JtzWtftO5cEG6/MG0mGGo0f64UnRsv33tMdU5PIivlQ9EoCgswN1GBg paBKly6TCYhea1yh+DWZ3+z60qQ779U= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+744e173caec2e1627ee0@syzkaller.appspotmail.com, David Matlack Subject: Re: [PATCH 1/3] KVM: Properly unwind VM creation if creating debugfs fails Message-ID: References: <20220816053937.2477106-1-seanjc@google.com> <20220816053937.2477106-2-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220816053937.2477106-2-seanjc@google.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 16, 2022 at 05:39:35AM +0000, Sean Christopherson wrote: > Properly unwind VM creation if kvm_create_vm_debugfs() fails. A recent > change to invoke kvm_create_vm_debug() in kvm_create_vm() was led astray typo: kvm_create_vm_debugfs() > by buggy try_get_module() handling adding by commit 5f6de5cbebee ("KVM: > Prevent module exit until all VMs are freed"). The debugfs error path > effectively inherits the bad error path of try_module_get(), e.g. KVM > leaves the to-be-free VM on vm_list even though KVM appears to do the > right thing by calling module_put() and falling through. > > Opportunistically hoist kvm_create_vm_debugfs() above the call to > kvm_arch_post_init_vm() so that the "post-init" arch hook is actually > invoked after the VM is initialized (ignoring kvm_coalesced_mmio_init() > for the moment). x86 is the only non-nop implementation of the post-init > hook, and it doesn't allocate/initialize any objects that are reachable > via debugfs code (spawns a kthread worker for the NX huge page mitigation). > > Leave the buggy try_get_module() alone for now, it will be fixed in a > separate commit. > > Fixes: b74ed7a68ec1 ("KVM: Actually create debugfs in kvm_create_vm()") > Reported-by: syzbot+744e173caec2e1627ee0@syzkaller.appspotmail.com > Cc: Oliver Upton > Signed-off-by: Sean Christopherson Fun times! Thanks for the fix Sean. Reviewed-by: Oliver Upton -- Best, Oliver