From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomas Bortoli Subject: Re: [PATCH] KVM: validate userspace input in kvm_clear_dirty_log_protect() Date: Tue, 8 Jan 2019 17:28:05 +0100 Message-ID: <8418f6c8-0fc8-e22c-c39a-bfcaee7471e2@gmail.com> References: <20190102172937.28741-1-tomasbortoli@gmail.com> <99de332c-d4e3-0628-8ad1-982032e67690@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: linux-kernel@vger.kernel.org, syzkaller@googlegroups.com To: Paolo Bonzini , rkrcmar@redhat.com, kvm@vger.kernel.org Return-path: In-Reply-To: <99de332c-d4e3-0628-8ad1-982032e67690@redhat.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Hi Paolo, On 1/7/19 11:42 PM, Paolo Bonzini wrote: > On 02/01/19 18:29, Tomas Bortoli wrote: >> n = kvm_dirty_bitmap_bytes(memslot); >> + >> + if (n << 3 < log->num_pages || log->first_page > log->num_pages) >> + return -EINVAL; >> + > > This should be > > if (log->first_page > memslot->npages || > log->num_pages > memslot->npages - log->first_page) > return -EINVAL; > > i.e. the comparison should check the last page in the range, not the > number of pages. In addition, using "n" is unnecessary since we do have > the memslot. I'll do the changes myself if you prefer, but an ack would > be nice. > > Yeah, I agree. Thanks for the reply and sure you can do the changes, np :) Tomas