Received: by 10.223.164.221 with SMTP id h29csp944369wrb; Thu, 26 Oct 2017 09:38:48 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QgxTp6HvHM7sECs63Y39K/PdPJYhqCArkR8dELyDzNc43ZL6hXzxizd4tpVBfRn5CC88dj X-Received: by 10.98.215.66 with SMTP id v2mr5973428pfl.24.1509035928615; Thu, 26 Oct 2017 09:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509035928; cv=none; d=google.com; s=arc-20160816; b=h1AtgyS8IcwU3m9Zbs+2LCOfzPSYYsKYblV+sL7HXNe9HZF8pcODoJgWIitKLqfrnw NhzSl0G4PzJHLNUPmAb/FTFA5qwIVMRabU6pqGzM0Z95LLenfTftEETR6Lyz1oUI6H5c hTZkh7bMfms42SqI+aJWsmvkzBXarT3lPJbKey5Y43vb1kUYJ44y9paO4i1SIJisDf+D J3sO7kM2eHuIuqoSRbcmJJUSqAe0/AXrFW/uhqktVktIvGd99Qw0+Lq0Xf7E5mptKJY1 zf8KFjuMub5t2cVoQJbGrToFFtxXRJeDSGAiK1qqg/Yd+Dpci7Nd8Y6sfzt9yMW512E+ T1hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=G5/7g4wrmQj/xuU45YrfMkl5QTf+nFvxbxXnSaUbTsY=; b=hpewzpyebq7BIx8jO1CN3urnymXHg3pzZh8oVFcqdnb5jQy5mQHnwP2iKtKWW8JSfw 9m3siq83I0a0nyiK5YX+jpD3YNGAGAaM89v8/7DMQFqc9rDlIdeMjoBGZWzLwpnd6ctY 5/ORA37P7Bi6UREQrLoq6CrgmHKpYwKqwFAnwRvWs4M6PQ2D6orCg+nroMQdp7+IxcqH azU8ywvOjkGwhdK/Dd51PYDlDPpLgNrcxqyzIqMXYlU4jMycB1BklS8bhA6lEJ4wL/HK iBk3KDvF813TfyoDLYJ1x1PnP9ga/aAmP7U9o8w7PRPkuXOoYn8Shy8W+M12X/vlBNtH ZSjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HxIZqjR3; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21si3596333pgc.7.2017.10.26.09.38.34; Thu, 26 Oct 2017 09:38:48 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=HxIZqjR3; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932456AbdJZQgX (ORCPT + 99 others); Thu, 26 Oct 2017 12:36:23 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:50007 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932345AbdJZQf7 (ORCPT ); Thu, 26 Oct 2017 12:35:59 -0400 Received: by mail-wm0-f54.google.com with SMTP id b189so9037237wmd.4 for ; Thu, 26 Oct 2017 09:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=G5/7g4wrmQj/xuU45YrfMkl5QTf+nFvxbxXnSaUbTsY=; b=HxIZqjR3SETWdu+30mIOb0KXbIkDo/k5SvqtwRaZY1D8TryMQWkjFVhofDEscYKS4+ 31RMzVF8tUY9iZ+R0hmFpQyGa5gIyC4xkd/tz4amcD7NSm6l+A2B5413zjLs5UjjRhdF g7tITIo4o4YpUFjEN9d1kXlRY1nu83SUcD43A0vRT4p6H5mLcK8290+9vjwpUoXpg1RN Hq7JTvTq9GqJcesG8Y+R5giWfxwbGoLU1MSowt8g9ebbB8+aTs448jY1CRsd18HuQZ98 RD3tEwygBDNozx/Pge5GkV8Dy3QB0vdRnAXtzRfm8dqrl+BTCIcJNL1qiWX2ulbqhANn ZG9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=G5/7g4wrmQj/xuU45YrfMkl5QTf+nFvxbxXnSaUbTsY=; b=by2mxTKmnWJi5N4z0/BqHcL7KdnEN2ah3aWQ8Kb+xzbvoA6s5LCbqtdsdRf1nGYWjO 3YyjLiiU4HkWx9Ft+oLjg2QR2/66Ypg2xjkyhF0IoXNN5CiLEST9tcI34J0joCNZcoGY DgEi1scUc8nLl1jORB5OeUeV8hBMQKQLr4g9XrreAbHcvd81hwVlfMEzkUtZnLfcPK7o ABmq88qiJ1cbHAGqQ94eyNi6tyv+7YThTevhkgaG/vRxXTG4W+bo7uHJVLx1ojqqYD0t XUXRGWezya//M5LTOOG19snh7tT0tdqsbGY8Ylw/rf2uW3+ry6/D49JfV5ZkZr/e0AzD nOuQ== X-Gm-Message-State: AMCzsaVEfmVM8nb59zOY8aVBhZBjSQiJF4mTEp280ZjvFTaIFWxDH+9E 7LdYgM9BoyPEu3a0fQzW33MaF5Vh+rx0l+YhBgE92A== X-Received: by 10.28.29.205 with SMTP id d196mr1888902wmd.106.1509035757018; Thu, 26 Oct 2017 09:35:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.176.4 with HTTP; Thu, 26 Oct 2017 09:35:55 -0700 (PDT) In-Reply-To: <8721eeac-a644-e815-55e9-5f01956dd22a@eikelenboom.it> References: <20171024024439.u3ywfgvi67fe4mbg@wfg-t540p.sh.intel.com> <440615a7-6cc0-a607-ce7c-22a34b69e8fe@eikelenboom.it> <1d203c07-0595-a33a-620b-c51eea9721d1@eikelenboom.it> <8721eeac-a644-e815-55e9-5f01956dd22a@eikelenboom.it> From: Craig Bergstrom Date: Thu, 26 Oct 2017 10:35:55 -0600 Message-ID: Subject: Re: ce56a86e2a ("x86/mm: Limit mmap() of /dev/mem to valid physical addresses"): kernel BUG at arch/x86/mm/physaddr.c:79! To: Sander Eikelenboom Cc: Boris Ostrovsky , Fengguang Wu , wfg@linux.intel.com, Ingo Molnar , linux-kernel@vger.kernel.org, LKP Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yes, not much time left for 4.14, it might be reasonable to pull the change out since it's causing problems. The 0day testing robot failure is relatively simple (definitely aided by the reproduction instructions), but I'm still pulling apart the qemu failure. Another alternative that I considered when coding this up would be to explicitly reject mmaps of pages that are greater than the bus width of the system. It would let through a lot more mmaps of /dev/mem that don't point to valid addresses, but prevents the page table corruption and seems less likely to cause problems (diff shown below). I haven't tested this on anything but a single 64-bit system. Standby while I figure out what's going on with the qemu failures. diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index 320c6237e1d1..7d78ae4d0731 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c @@ -182,7 +182,11 @@ int valid_phys_addr_range(phys_addr_t addr, size_t count) int valid_mmap_phys_addr_range(unsigned long pfn, size_t count) { - phys_addr_t addr = (phys_addr_t)pfn << PAGE_SHIFT; + phys_addr_t addr = pfn << PAGE_SHIFT; - return valid_phys_addr_range(addr, count); + if ((addr + count) & + ~(1ul << (unsigned long)boot_cpu_data.x86_phys_bits)) + return 0; + + return 1; } On Thu, Oct 26, 2017 at 2:58 AM, Sander Eikelenboom wrote: > On 26/10/17 10:12, Sander Eikelenboom wrote: >> On 26/10/17 10:05, Sander Eikelenboom wrote: >>> On 26/10/17 00:02, Craig Bergstrom wrote: >>>> Thanks for the notification, my apologies for the breakage. I'll take a >>>> close look and see if I can figure out what went wrong. >>>> >>>> Sander, any chance you can send /proc/iomem and the inputs to the mmap call >>>> that fail on your affected system? >>> >>> Hi Craig, >>> >>> The output from /proc/iomem is simple to get and attached. >>> The mmap call is probably issued by qemu and will require more digging. >> >> Ahh grepping qemu gave a pointer, it's probably the code in: >> >> http://xenbits.xen.org/gitweb/?p=qemu-xen.git;a=blob;f=hw/xen/xen_pt_msi.c;h=ff9a79f5d27ad7d74a1b22297be560feb455063c;hb=5cd7ce5dde3f228b3b669ed9ca432f588947bd40 >> >> around line 571, that would also explain why it's only this device that >> has the problem, since it's the only one trying to use MSI(-X) >> interrupts. Will see it i can add some logging to that function. > > Attached is the qemu debug output with an extra line outputting all stuff > used to calculate the arguments used by the mmap-call. > -- > Sander > > >> -- >> Sander >> >> >>> >>> I don't know if there is that much time left for 4.14, since we are at >>> RC6 already. >>> >>> -- >>> Sander >>> >>> >>>> >>>> >>>> On Wed, Oct 25, 2017 at 2:50 PM, Boris Ostrovsky >>>> wrote: >>>> >>>>> On 10/23/2017 10:44 PM, Fengguang Wu wrote: >>>>>> Greetings, >>>>>> >>>>>> 0day kernel testing robot got the below dmesg and the first bad commit is >>>>>> >>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git >>>>> master >>>>>> >>>>>> commit ce56a86e2ade45d052b3228cdfebe913a1ae7381 >>>>>> Author: Craig Bergstrom >>>>>> AuthorDate: Thu Oct 19 13:28:56 2017 -0600 >>>>>> Commit: Ingo Molnar >>>>>> CommitDate: Fri Oct 20 09:48:00 2017 +0200 >>>>>> >>>>>> x86/mm: Limit mmap() of /dev/mem to valid physical addresses >>>>> >>>>> Also note >>>>> https://lists.xenproject.org/archives/html/xen-devel/2017-10/msg02935.html >>>>> >>>>> -boris >>>>> >>>> >>> >> > From 1582309946658569019@xxx Thu Oct 26 08:59:16 +0000 2017 X-GM-THRID: 1582105239086831553 X-Gmail-Labels: Inbox,Category Forums