Received: by 10.223.176.5 with SMTP id f5csp3001649wra; Thu, 1 Feb 2018 09:13:18 -0800 (PST) X-Google-Smtp-Source: AH8x224joO0di529wHM5pIalWy+oys2v8dOIC5+E6curczC2gTyqy0i34UWuJVPjC1c7DUUJFnKP X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr32564913plb.278.1517505198197; Thu, 01 Feb 2018 09:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517505198; cv=none; d=google.com; s=arc-20160816; b=q4HX+GwP/QQwaN1n9qLinYfEA+GR62HeorT9dxwOD4RdZU+dwhyyO2ah9kIZik9rmd PzxzPvvurm8DzZfxllzIJzR6zopYPqSq5CEV327cMuNuKHoGkseO9v1JGCWaoHNubaxF cq5PIKt7X0lYPFt9Nv/KRvcwtmr2h55hwW6AskiKk/63nHgCMOKKumUEJjK62piesynJ saoxYoYV7DtA6WKqEAza4t2rXd6lvQFIZceLAWCOEeJtgLCJO/th8IS3cscvOa77AuKp tvOf8/0h+Cm0kVSWfz1peHn2McBoFRvN5paWN18QfefVhLFV8TzuzAUhXqetedCrX9KA +Q7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=a8oDlAMOukf3mDxXJeCA4/sVsHBa1U/v506vmSfssCg=; b=cap4mBZqIL9uG50CrRQzpIW3M0cv4SzacFLkJxV25KP4hCuECiE/kX616rPmSVGr3W +DEs9SPuDhN7OcDSBW1wRwDS6zn3N1LnqHGvoZ/xduy/naArcPN4ZDON3kG4mmbJFjIy i0LuJkM9wYJXzJGZfCSPNSkaSHFT8iZNdIGHW3ow6qyiaDPI/w5s+w0laVkgEIM5y/63 z/QlwxuazI4ZERWE++Hbc7ctXLFeVUcKU3ARAuMCZlFWZt3+tDniMSiBFlkaEUdSHWFt vmxbuB1+9V7pQCq5Q4mpkrlHYgHtgIZspXDgCoNR9M1uXjuf3TAU/RzD/PLM87KyevZV mGpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7si28616pfl.198.2018.02.01.09.13.03; Thu, 01 Feb 2018 09:13:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753098AbeBARMM (ORCPT + 99 others); Thu, 1 Feb 2018 12:12:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48473 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753083AbeBARMK (ORCPT ); Thu, 1 Feb 2018 12:12:10 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7153B3ADA3; Thu, 1 Feb 2018 17:12:09 +0000 (UTC) Received: from [10.36.116.105] (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAF465E1B5; Thu, 1 Feb 2018 17:12:03 +0000 (UTC) Subject: Re: [PATCH] KVM/x86: remove WARN_ON() for when vm_munmap() fails To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Eric Biggers Cc: kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Eric Biggers References: <001a1141c71c13f559055d1b28eb@google.com> <20180201013021.151884-1-ebiggers3@gmail.com> <20180201153310.GD31080@flask> From: Paolo Bonzini Message-ID: <584ef475-21cc-9ef5-8ac9-d6b00e93134e@redhat.com> Date: Thu, 1 Feb 2018 12:12:00 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180201153310.GD31080@flask> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 01 Feb 2018 17:12:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/02/2018 10:33, Radim Krčmář wrote: > 2018-01-31 17:30-0800, Eric Biggers: >> From: Eric Biggers >> >> On x86, special KVM memslots such as the TSS region have anonymous >> memory mappings created on behalf of userspace, and these mappings are >> removed when the VM is destroyed. >> >> It is however possible for removing these mappings via vm_munmap() to >> fail. This can most easily happen if the thread receives SIGKILL while >> it's waiting to acquire ->mmap_sem. This triggers the 'WARN_ON(r < 0)' >> in __x86_set_memory_region(). syzkaller was able to hit this, using >> 'exit()' to send the SIGKILL. Note that while the vm_munmap() failure >> results in the mapping not being removed immediately, it is not leaked >> forever but rather will be freed when the process exits. >> >> It's not really possible to handle this failure properly, so almost > > We could check "r < 0 && r != -EINTR" to get rid of the easily > triggerable warning. Considering that vm_munmap uses down_write_killable, that would be preferrable I think. Paolo >> every other caller of vm_munmap() doesn't check the return value. It's >> a limitation of having the kernel manage these mappings rather than >> userspace. >> >> So just remove the WARN_ON() so that users can't spam the kernel log >> with this warning. >> >> Fixes: f0d648bdf0a5 ("KVM: x86: map/unmap private slots in __x86_set_memory_region") >> Reported-by: syzbot >> Signed-off-by: Eric Biggers >> --- > > Removing it altogether doesn't sound that bad, though ... > Queued, thanks. > >> arch/x86/kvm/x86.c | 6 ++---- >> 1 file changed, 2 insertions(+), 4 deletions(-) >> >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index c53298dfbf50..53b57f18baec 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -8272,10 +8272,8 @@ int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size) >> return r; >> } >> >> - if (!size) { >> - r = vm_munmap(old.userspace_addr, old.npages * PAGE_SIZE); >> - WARN_ON(r < 0); >> - } >> + if (!size) >> + vm_munmap(old.userspace_addr, old.npages * PAGE_SIZE); >> >> return 0; >> } >> -- >> 2.16.0.rc1.238.g530d649a79-goog >>