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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46937C433F5 for ; Wed, 17 Nov 2021 16:49:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AA1961414 for ; Wed, 17 Nov 2021 16:49:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239287AbhKQQwZ (ORCPT ); Wed, 17 Nov 2021 11:52:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59614 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239260AbhKQQwS (ORCPT ); Wed, 17 Nov 2021 11:52:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637167759; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5r31ohO67CMQ07xbtqMClO0q3GCnOKbm6lne2ReCfu4=; b=EH6p7qSn6RzHpqvBzthqZEMfjxj6mJ9lrZkFH6JVP9g/FMC2fCFBmwit6U73/lo1/pb2sc zFA1AmOmC0zIGsux7s3n2h9xpc39b828t5maHiSyi7fdjUK2uWX+ALhaun7iPprNAoNeBY SLUGXN1kMwUxBYTFoe9Hd08hf7z0NDs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-FhPu6gN2MEi6jY6JEq2JfQ-1; Wed, 17 Nov 2021 11:49:17 -0500 X-MC-Unique: FhPu6gN2MEi6jY6JEq2JfQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD1FA87D541; Wed, 17 Nov 2021 16:49:16 +0000 (UTC) Received: from [10.39.192.245] (unknown [10.39.192.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7BF560C13; Wed, 17 Nov 2021 16:49:15 +0000 (UTC) Message-ID: <20eddd70-7abb-e1a8-a003-62ed08fc1cac@redhat.com> Date: Wed, 17 Nov 2021 17:49:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: There is a null-ptr-deref bug in kvm_dirty_ring_get in virt/kvm/dirty_ring.c Content-Language: en-US To: "Woodhouse, David" , "butterflyhuangxx@gmail.com" Cc: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <9eb83cdd-9314-0d1f-0d4b-0cf4432e1e84@redhat.com> <4b739ed0ce31e459eb8af9f5b0e2b1516d8e4517.camel@amazon.co.uk> From: Paolo Bonzini In-Reply-To: <4b739ed0ce31e459eb8af9f5b0e2b1516d8e4517.camel@amazon.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/17/21 10:46, Woodhouse, David wrote: >> 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... > I think I am coming to quite like that 'remaining option' as long as we > rephrase it as follows: > > KVM does not mark the shared_info page as dirty, and userspace is > expected to*assume* that it is dirty at all times. It's used for > delivering event channel interrupts and the overhead of marking it > dirty each time is just pointless. For the case of dirty-bitmap, one solution could be to only set a bool and actually mark the page dirty lazily, at the time of KVM_GET_DIRTY_LOG. For dirty-ring, I agree that it's easiest if userspace just "knows" the page is dirty. Paolo