Received: by 10.223.176.5 with SMTP id f5csp2887847wra; Thu, 1 Feb 2018 07:34:07 -0800 (PST) X-Google-Smtp-Source: AH8x224u5awG/U3VSPdlPQ3SnN4dvFh1kzM+8OJgoTNq0tasjQ1SJEahhrC8RoGhOBvQ7Y7/R6Vx X-Received: by 2002:a17:902:74c9:: with SMTP id f9-v6mr1731821plt.89.1517499247785; Thu, 01 Feb 2018 07:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517499247; cv=none; d=google.com; s=arc-20160816; b=Zln6sx7Fm6ZRxSC6vFR8PGDyi0baDt5dsvnPWrSloa3uezuBq5Ah127vkHQYGUUMzY DeA+kzdUxfXlvlK3eYwk53//VX8fWIBg1u87AZTlS0B4qywd/TEcCXrUKzqVzB4NVmRQ 8db/BmYyQkLotmtwc/PLSuYox2OmZLsLpi0r9dQ6aAPBWbmY5X1WwvTfO9d89gBrQSq/ j9OhqGtgjmimzRR6tAou+a9iUps4SgLK8P1bMZcRiv+tvjlGbDBGb2xIkVAJPv9v2AYT ZJTBq4HIhI854D9WYy1M2KXiPVd/aB6QUif8Ry390ZiM4v6+MM0PBEyN+eY5rCLb+Tm5 FyhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=lbd2UEFjgWYrf6NI9YXA79c2lBho0VZvBCH36er+KNk=; b=0kK6o8Afx2gfy6wRPxJwoMMRK59Ommcnzjy3imL0Iqj8GBE5qMtw6cxls8qufcD9As qOt00HV7GO7hZXlZbfxHnY6xD07cKrgpCzZ9JgXZG7hMLwY6O11eOUwbFlrMlUdX1xgu mMQiCxCymOWpBH1T2spAKKBBx7zgeC5t2NU48OecQGq3TMHl13uUmuo/L24mh3CkSeZk QAhA6K6R1Kxlyu1OLf9dLGXHwKJSxhG/zjwMJO5qPQGK9msCwTtKnZG3ZgngBpFWy7cb zBy++wK64K+QvKqs5hp8ZS5N1f6qMqfvjTeTPKLL0UvsUhEE9T1B2UaQu9+sJhLmzXd9 XSWQ== 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 8-v6si216642pla.105.2018.02.01.07.33.53; Thu, 01 Feb 2018 07:34:07 -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 S1752411AbeBAPda (ORCPT + 99 others); Thu, 1 Feb 2018 10:33:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37651 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751707AbeBAPd1 (ORCPT ); Thu, 1 Feb 2018 10:33:27 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82882E89B; Thu, 1 Feb 2018 15:33:27 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id E2300600C0; Thu, 1 Feb 2018 15:33:22 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 01 Feb 2018 16:33:10 +0100 Date: Thu, 1 Feb 2018 16:33:10 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Eric Biggers Cc: kvm@vger.kernel.org, Paolo Bonzini , linux-mm@kvack.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Eric Biggers Subject: Re: [PATCH] KVM/x86: remove WARN_ON() for when vm_munmap() fails Message-ID: <20180201153310.GD31080@flask> References: <001a1141c71c13f559055d1b28eb@google.com> <20180201013021.151884-1-ebiggers3@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180201013021.151884-1-ebiggers3@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 01 Feb 2018 15:33:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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 >