Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2216011rdb; Mon, 9 Oct 2023 17:38:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRtFs9GHeE3NwN1fFT2DNSb5gYVYX74om0E5iB9YcyZHHJetRmxe3OYNGCJwf1lcyvl6AX X-Received: by 2002:a17:90b:1c83:b0:274:616e:3fc4 with SMTP id oo3-20020a17090b1c8300b00274616e3fc4mr13374328pjb.34.1696898289550; Mon, 09 Oct 2023 17:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696898289; cv=none; d=google.com; s=arc-20160816; b=ywaRY7srHd2ZOb2FCupDsgAxa5aZ3JYmDT2sruLjKqJtl4zX/weAwKaS30NfmAR7rV c7JaV0wB3xzYZMqsKBtDy1X38l5ezFHMGQVVjc96seopEOSIBMfboyFEzPMM6ro6Ykgg fHE4FXr+zO/QtPjmSVABAJPImeL7vEqVcqzBAO79YdRe0DkqPKIlmyylqa8DFmaJ30Fn IAYkSt4UlNUoDWlme9QkVtSboM1PKGCZN/bg6Z3qdcnI3+GLXD8o/wVFKbBFoWTLPQv4 Gvgr38VH9kq2o6OwL3jlRDC3KO4CCYPCkuYYXFQV3qixA52YbRUWTXPDcqumd/2UGQ7Q B/8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Yd8LtAUhil6gDxO7/Lkm05KcSXZOGIjG2k/iyrJTHVg=; fh=7A2vjXu/ewATeTgBdu7iBmgBP0mnBjez2UGBNdh/IPI=; b=CxpOt/PcvQ1UYQa0M+eMdN+1npvySjZIy0W5KEC4zSEWQ0uoydYFPqXU/Ed4haSW8m 1suFqNoOqFCcIxFX4BMzGGiqH+81kjYmWSDNwWG1jTntZ4i+CUQGswcj+j+cI0oF8RrG YC8Qaa2kCRDG/Ov0NpQRBdsRESJJyxzajNlo1KbJIc0VDHPCTFtJvS0cRcapDZ7vjmYz 6RJAQmwnY+MV+VBkmvA/wpKe0TRMunM+k7mUlU6c/rrctItsoKfIgS/eVkSt9kRPHQ6c apBH3nAYOXL1f+5IrK3rKXFxxl6f1yYEJufXJ4i5uKCMKHW/m8W6kBHbT+1lOPjYmmLr 2gxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=DE60vF+H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id qe17-20020a17090b4f9100b00258996c09e4si14071483pjb.22.2023.10.09.17.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 17:38:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=DE60vF+H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2C65880FFD8A; Mon, 9 Oct 2023 17:38:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379141AbjJJAhv (ORCPT + 99 others); Mon, 9 Oct 2023 20:37:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379189AbjJJAht (ORCPT ); Mon, 9 Oct 2023 20:37:49 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3743AA4; Mon, 9 Oct 2023 17:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Yd8LtAUhil6gDxO7/Lkm05KcSXZOGIjG2k/iyrJTHVg=; b=DE60vF+HLqkpf9A7JBwAois7JV 6ywwIeJ2n/D6CTnROrUZZ4Yhik8I7foIPFdHAJ+Uwwy2nJ7CUhEkhGqX7E6VJTqn3Zn/IQeE3xG01 dz9iPU0GGfFmrpuki3FsRu4fcuw7aZhKMQ6XP3eF/jsRTwxL6NKk0MJzCnIi74CeJKbyxU44sUBSq CAYPICH6lhhsJL4Fz12dkDMDSWC7DGDEY5OBOccItP0ePmIZ/ghlIVuTMkhCOTI5wjNCWysvKU5g7 n5ggTjUbITV01IWY4vljXOAPYnlHnbXQdJlYHdkn/4R3dor/Wgk75dVuSgUdcjIiJGVT/j0lDhR7o oltm2B4g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1qq0ks-00HM47-21; Tue, 10 Oct 2023 00:37:46 +0000 Date: Tue, 10 Oct 2023 01:37:46 +0100 From: Al Viro To: Sean Christopherson Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH gmem FIXUP] kvm: guestmem: do not use a file system Message-ID: <20231010003746.GN800259@ZenIV> References: <20230928180651.1525674-1-pbonzini@redhat.com> <169595365500.1386813.6579237770749312873.b4-ty@google.com> <20231009022248.GD800259@ZenIV> <20231009200608.GJ800259@ZenIV> <20231009204037.GK800259@ZenIV> <20231010000910.GM800259@ZenIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 17:38:07 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 09, 2023 at 05:27:04PM -0700, Sean Christopherson wrote: > If the last reference is effectively held by guest_memfd, it would be: > > kvm_gmem_release(), a.k.a. file_operations.release() > | > -> kvm_put_kvm() > | > -> kvm_destroy_vm() > | > -> module_put(kvm_chardev_ops.owner); ... and now your thread gets preempted and loses CPU; before you get it back, some joker calls delete_module(), and page of code containing kvm_gmem_release() is unmapped. Even though an address within that page is stored as return address in a frame on your thread's stack. That thread gets the timeslice again and proceeds to return into unmapped page. Oops...