Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1297091pxb; Thu, 28 Oct 2021 00:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL+eTrVyXJmWrQog9OiDxEJPvO5oDIilXRBQRF+RtvC3wBB10Mt15k6SLyjWSxEtD3LKBG X-Received: by 2002:a17:90b:1d0d:: with SMTP id on13mr2841526pjb.118.1635407052113; Thu, 28 Oct 2021 00:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635407052; cv=none; d=google.com; s=arc-20160816; b=ygADiVqpDwxIXqbII2tMsLXHeVC/wuNekZKguBPDuROjDQ/qGB+0I7WzNp8tASOCL+ HEGUiJDkY3znEqgrLpD6D58AxW9q2lNzr6L3hhXMMZnQJJbwonqmujrsJZxA0f1zBJX+ qoek+vi+hede3wY6wXJGjOFDM9TQmbIxeumOxTN8+Cg5MQL8MxKdzq6/uS/Qhj79ZShX G/fwV4K6aazVbpwbyZwD3agFR0JI33wdwcfUgU+9rTKBOXlDkyPVFyVv3k/Y1tbFwenV MtkbDmUtZN8HjWODXBbZxAL2qiKUrSNGcGP9aJuKBiCd+pnAoSlWh/9w0CCI33O5RMDP FTXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jg8omDm1zuEDYPy2wE96j8MIp8X+Ixp0yvqeM2ZpT0g=; b=rMKmh/xcS/rgz7b7zvP5Qtba5jvylE0UZqEWqzPFcR/DxA/RbZ8F0+aMgfKPWvUVhl 2X7PLo2wT4sAP+zdi9bakhX/DLYf6/zdnLAbDYGDXIRP9gwME7I5P72ZgQli4ZDUONsv oIvVEFTtqUPKwqc+YAeDus2O957jEhD6Gi4/bvvDmrou8lawLpucSiYzWJ5pbsP/I8KC vBHPLfquaUk1+tiEjBbDr/JwSuQY77Ba3wBEngeznd24+qsFBr9j2mWlBHH5ZIg4ECBq c9OgnaMBPykRgb3gC4/tCwReLU+nx33YVvDXu2rGnYZe1SrXvERdkP5zw5Gt63hzNRNN YNrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KA1YcV+o; 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 y23si3122386pgk.277.2021.10.28.00.43.59; Thu, 28 Oct 2021 00:44:12 -0700 (PDT) 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=KA1YcV+o; 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 S229850AbhJ1Hot (ORCPT + 99 others); Thu, 28 Oct 2021 03:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbhJ1Hos (ORCPT ); Thu, 28 Oct 2021 03:44:48 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78031C061570; Thu, 28 Oct 2021 00:42:21 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id t127so12925740ybf.13; Thu, 28 Oct 2021 00:42:21 -0700 (PDT) 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:content-transfer-encoding; bh=jg8omDm1zuEDYPy2wE96j8MIp8X+Ixp0yvqeM2ZpT0g=; b=KA1YcV+oqiq8WH3aVGXJM18kP7H/wclsYSoUmbKqww/bQPKzs9CJtDAqYY8PekzznP aO3Ryl3VH9yQWVnq9OmuBOlynAhLo4NFRVS6EkioResNdxBJI/ITkqQDkCuE0aenNqYX SpyalUqhdLFPWFpjuDpH+L9UYYF2MnnEZziK72BnGVkfRBHywxt7YKztfPbi6y8IKiRN 1vwU/CRM+BfRGZrUAUY3Ap60xJKQOui9Oh0B195Pp6OFoK4EAorIqJBGhbNwvo6BtB5u pYdJ8ENi52vSCnhp02vWuUy8Ppyr6e9nzg76PMvkXErbgGBs7eJO7+bm8w6gEBYRkwxB 0oyw== 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:content-transfer-encoding; bh=jg8omDm1zuEDYPy2wE96j8MIp8X+Ixp0yvqeM2ZpT0g=; b=vfwh7TUByeruekWfivDPetMruh00jOw2FsMyE7vtL6O6KQ29CgqOaZLpG5vGapt/8f 3hAIAhuUuIiG+DQ0bYA/ppeejcA0vv4SPuemXwr9/9AUQtu2UJDdskFSRK2SOa9mAGIH 8/fvCITaTic082go+ky3oXOSP8EeBejqMa0pQUJDChnhcP+S0rtKpIkV/9dm5Q+4jWx1 tv9TzsPSVZOuNmlb+1BlxPFQIuTgnmUq1zzv7SXlr0QrADFbSCf6zxOqtjznet6/i31M Z4T8koT8YBLmPbWv29AWs2d0xYoZtOBPeGvMuAqHIuCtOu4c/d3F3WwEzGjFpO5PAyFW XOCQ== X-Gm-Message-State: AOAM531vEdG4pf7IMaRaw2VGiBkLkaLXvOywzAv3NBKZJ7wNzGM10GP8 PTCBd+wmY1aY+ZLPXtmP+NLPA/Li+a8fXtMAgwcb3jN0d9xY3BmW X-Received: by 2002:a5b:a92:: with SMTP id h18mr2872386ybq.439.1635406940758; Thu, 28 Oct 2021 00:42:20 -0700 (PDT) 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: Thu, 28 Oct 2021 15:42:10 +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" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I agree with you. But I don=E2=80=99t have a good idea how to fix it 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 =3D kvm_get_running_vcpu(); //-------> invoke > > kvm_get_running_vcpu() to get a vcpu. > > > > WARN_ON_ONCE(vcpu->kvm !=3D 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 > --=20 Active Defense Lab of Venustech