Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6067786pxb; Mon, 8 Nov 2021 02:38:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+GjXRTSA34ozDp5dR9IFr8kilhGaqpuKEYYBOPXPAgKYP9viLXEa3EK0dhRodnp2cneBy X-Received: by 2002:a17:907:3da3:: with SMTP id he35mr67057732ejc.464.1636367883621; Mon, 08 Nov 2021 02:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636367883; cv=none; d=google.com; s=arc-20160816; b=0URQy3tWxBxAxoprdX1dxVWjNdzcwPDn/1Yyc6eb7l098TVVOGix2eBMg9RLm9wGK5 rhJqgV2yBcXl6Cd0gBDL3nN46dq7ojwsN7FQdO6G8IfXXumEXrd/pzW11r8B0I8jYNNv qXqUcDsevPBAMgTWPnmbsxHFihAzK4LhyLrykhaI/t8pxRU/mLEbQah7beBw9E3DwA84 0lIttspc7TyE3cSvmTnZFreYgjoslv+WbftFQ7ekYlgHA0EhhojdqEIIrr8+suhaSMoJ k5SRMsm+32rsv10GswZ347IKXyAxZOn9WlgZWSsntBQxNfyiVWsZtsnVTgkctwzawuZB gXig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NTzUedNCNQEHveRyHIbZkdaiKokaUWSg5tuoQ1CJU2c=; b=lItPr1lOYhn7EeGefoFQjUWtwRb9/rTwEmXw1FiU2+QhgC4keNkb0wTL2HuCmh9Diw qdPKXSdoIBA17BoQF1IMNTormCtDQAn1vfymO6EHcNktsmwoktidWNlZhEhaN1Ds4pCS Hbzaa4/TuO61asdIQgdeHoAYglPTVdottObVvB3jNmFsw6a/JghDEJ1EjUw0GWIUZna0 idtwzWeiE4e10GfFJW1i2+O4hOq404IYyG4A4vfYmeUAU5bM5X6jdnwo3NS8w0IY/vFl go2lOYUYAqVlcKMPc+hiWMN7KUiB4zukdorp5I1mdg3rcAaYFxAvMZYaWdEfNNZhvO+x AnKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="VW8ISBH/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ho38si32177467ejc.745.2021.11.08.02.37.14; Mon, 08 Nov 2021 02:38:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="VW8ISBH/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235338AbhKHFOy (ORCPT + 99 others); Mon, 8 Nov 2021 00:14:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbhKHFOw (ORCPT ); Mon, 8 Nov 2021 00:14:52 -0500 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDE9C061570; Sun, 7 Nov 2021 21:12:08 -0800 (PST) Received: by mail-yb1-xb2a.google.com with SMTP id j75so40303880ybj.6; Sun, 07 Nov 2021 21:12:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NTzUedNCNQEHveRyHIbZkdaiKokaUWSg5tuoQ1CJU2c=; b=VW8ISBH/mMgF4Daj8nQbWD9UZyiOcQZmRXBWIJQFO861Fo0W6iRXv5uvYcsVNwBeYv PIMiR4m8m4YQEHNNcOcSnFuYiyt0gaFXoz8kjYZNCJUEnRJbFMPcp2QFg2bSPd5zAbGc tQMzrMUpDHi9V7f2jX+fDPe8y9Ot3c4WIGtqLyUcCJ7CwDi8rC4MQ894hraQf36Rd+jI yVsOEiEGeO7DNo7CWV07XhQmn79mNaTqEdSYB28SUKHyx2y6Au0y0zd9IRIo2/QvO4pJ IYFq/k/FZGzvq//mNcg4DwDlx0u+UkrHoTPmH0OZMdI/AZ/rhiz2hTye5tqWnUaRsqNq BgVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NTzUedNCNQEHveRyHIbZkdaiKokaUWSg5tuoQ1CJU2c=; b=wvEJW/8WtJrg0ORR23el4RjyoI/i8pCfehuTKG+V0KZynyN+LJDIibKPh7rmMJo9iI U9hUm3x2ModBQe49TO7WwSM9C8HAXIL4/m4qSyUOdKC9uN8E2vJx0HtmV+iLemvS/VwX E1L/DG3e34BC7Wdrwfx0rD3TX7MqOxGotN/Hw1u8G0G+Ko6GBhbKEbMyNnmdRv01divV a/flaieL3ARqPpiv4uJtp0S/ZXIHo+OAF36Cw9jbgQh3cAC35bUPAmWFp34nZKAhKo65 /C/Pha57Cilg8v5QD4oRtFDxOxPFWhiTB6dXia1RYOwKV3N1H6qH62ItEKIih692W6RZ AOTg== X-Gm-Message-State: AOAM532Q52PrZBKFSNdH1MH/41qO/pk6o+zP7SREV+Tap7oCPNs42gtw ETM56RxiiT6+CEPC5kfYvuNG+DP3okAA0Pzyb9dtT3HK2+0OYQ== X-Received: by 2002:a05:6902:10c4:: with SMTP id w4mr64523717ybu.439.1636348328184; Sun, 07 Nov 2021 21:12:08 -0800 (PST) MIME-Version: 1.0 References: <9eb83cdd-9314-0d1f-0d4b-0cf4432e1e84@redhat.com> In-Reply-To: <9eb83cdd-9314-0d1f-0d4b-0cf4432e1e84@redhat.com> From: butt3rflyh4ck Date: Mon, 8 Nov 2021 13:11:57 +0800 Message-ID: Subject: Re: There is a null-ptr-deref bug in kvm_dirty_ring_get in virt/kvm/dirty_ring.c To: Paolo Bonzini Cc: "Woodhouse, David" , kvm@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, No one pays attention to this issue? Regards, butt3rflyh4ck. On Fri, Oct 22, 2021 at 4:08 AM Paolo Bonzini wrote: > > On 18/10/21 19:14, butt3rflyh4ck wrote: > > { > > struct kvm_vcpu *vcpu = kvm_get_running_vcpu(); //-------> invoke > > kvm_get_running_vcpu() to get a vcpu. > > > > WARN_ON_ONCE(vcpu->kvm != kvm); [1] > > > > return &vcpu->dirty_ring; > > } > > ``` > > but we had not called KVM_CREATE_VCPU ioctl to create a kvm_vcpu so > > vcpu is NULL. > > It's not just because there was no call to KVM_CREATE_VCPU; in general > kvm->dirty_ring_size only works if all writes are associated to a > specific vCPU, which is not the case for the one of > kvm_xen_shared_info_init. > > David, what do you think? Making dirty-page ring buffer incompatible > with Xen is ugly and I'd rather avoid it; taking the mutex for vcpu 0 is > not an option because, as the reporter said, you might not have even > created a vCPU yet when you call KVM_XEN_HVM_SET_ATTR. The remaining > option would be just "do not mark the page as dirty if the ring buffer > is active". This is feasible because userspace itself has passed the > shared info gfn; but again, it's ugly... > > Paolo > -- Active Defense Lab of Venustech