[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH RESEND] intel/pinctrl: check capability offset is between MMIO region


  • To: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 24 Mar 2021 14:55:15 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2WMi9DWalKfawkgbPzZMmmO0JisHja4ifJZM74rdk5U=; b=RJaJMndBXLvF4ZpqeXC6dxFhNTH+HwEpDuPYxEadaY2RbYWLONBzbIKJvBPULmIk/UlkrBma/4cglySSX/vbp6EcYS4SRyplaO2tMEeVCV64XRIaZ5kDbq95oIPrzDsstaMRklK6+eyQu13AHbzL1ey19XchN7Yut3YS0hYPD8E0B1mvVhfs04OsV58ITDyHD+coCCgivQsfVQb0l+fp9OiRmC6rHb6DSSwVn87TRpb851HQJfwIWhWqZKAPblRFiBxngSNiS+VSnm8Y0NV1m/tXgIYoS0nJmBBuCkPJslVRrRn8hAAdlkgXNtmGFFZn/CTJWTBoYp3e2nLFSnB1ZQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ypqeb9KUTd/IbZf6gu7Q12zB9QPODEzyUwTdQKEd5pXrC2R2U5NHQwyWO+0ojM7mFpFFZUNQZWQFu5aIYaw+5R/VCpMuxv98CYm85T+3JM2WmJ8y/2ukLFb0qkCZG6p4Bbvgyiaj/i4YUP6wulsRdClR/jSP7/eMm7x9AWzxD6nRMTQJDUyWz3oytB+/+KxaetBp6vW/spcEA8W80YGPHE/WQuWbK4qLlDDHAEHfoyTZgEckZC5cRQWMawlpHU8gK6f5A6vmDvinmtTpf4FpZaKwHh8b0Pl1nQ60vXSOwqxt7ouAVrt3FitHllndmH7AsR5bjdC7jJupRUtt/jcRTA==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <linux-kernel@xxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Mika Westerberg" <mika.westerberg@xxxxxxxxxxxxxxx>, Andy Shevchenko <andy@xxxxxxxxxx>, Linus Walleij <linus.walleij@xxxxxxxxxx>, <linux-gpio@xxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 24 Mar 2021 13:57:46 +0000
  • Ironport-hdrordr: A9a23:rwngPaiirm+xZZD/TJkEXV3fpnBQX0Rw3DAbvn1ZSRFFG/Gwv/ uF2NwGyB75jysQUnk8mdaGfJKNW2/Y6IQd2+csFJ+Ydk3DtHGzJI9vqbHjzTrpBjHk+odmup tIW5NVTOf9BV0St6rHySGlDtctx8SG+qi0heHYi0xgVx1udrsI1WdEIyywe3cGIjVuL5w/CZ aa+45rpyC4f24Wc8S8ARA+LpX+jvfMk4/rZgNDOgUu7xOAgSjtxLnxFRWZ2Rl2aUIy/Z4J92 /Znwvlopiyqv3T8G6n60b/zbRz3OHgxNxKGdCWhqEuSwnEpw60aO1aKti/lR8vpuXH0idPrP DtpFMaM913+zfteAiO0GTQ8i3B9Bpr1HP401+fhhLY0L/EbRY3EdBIi44cUjax0TtZgPhG3K hG332UuvNsZHuq9kmNhKmrJmRXv3G5rnY4nekYg2Y3a/pkVJZroZEC50QQKZ8cHUvBmfAaOd NzB8LR7us+SyLiU1nluABUsbuRd0V2NBKHTk8eg9eSwjhbkVtopnFotfA3rzMu8okwRIJD4P mBGqN0lKtWRstTVq5lAvwdKPHHRlDlcFbpCia/MF7nHKYINzbkrIP22qw84KWPdIYTxJU/tZ zdWDpjxCEPUnOrLffL8IxA8xjLTmn4dy/q0Nti659wvaC5bKb3MAWYIWpe0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uSu7+RMoTGZ3gxjz3YH/VcGhku/ybftl3Ll8fHSM6Q8Ei+P3ArnBWRWgAPCXo8Z SUE8JFW+Adr+lgmlPirS5f0/tk66iLWgyx8rVvaE2wXhxcgAV59D2Z5PnvuK5zY/wsvob5H/KO LYlDqe8FHGAjB9gHpnFNiN+TZULX7VmNVvMZXcbPpcc6L5AJeIODbXZgYoQEALoAMZpGR4o0KA 5bw=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Mar 24, 2021 at 02:58:07PM +0200, Andy Shevchenko wrote:
> On Wed, Mar 24, 2021 at 01:31:18PM +0100, Roger Pau Monne wrote:
> > When parsing the capability list make sure the offset is between the
> > MMIO region mapped in 'regs', or else the kernel hits a page fault.
> > 
> > This fault has been seen when running as a Xen PVH dom0, which doesn't
> > have the MMIO regions mapped into the domain physical memory map,
> > despite having the device reported in the ACPI DSDT table. This
> > results in reporting a capability offset of 0xffff (because the kernel
> > is accessing unpopulated memory), and such offset is outside of the
> > mapped region.
> > 
> > Adding the check is harmless, and prevents buggy or broken systems
> > from crashing the kernel if the MMIO region is not properly reported.
> 
> Thanks for the report.
> 
> Looking into the code I would like rather see the explicit comparison to 
> 0xffff
> or ~0 against entire register b/c it's (one of) standard way of devices to 
> tell
> that something is not supported.

That can be done also. I think what I've proposed is slightly more
robust, as it will prevent a kernel page fault if somehow the offset
to the next capability is below ~0, but past the end of the MMIO
region. Unlikely I know, but it's not worth a kernel panic.

What could be done is check whether reading REVID returns ~0 and exit
at that point, if ~0 will never be a valid value returned by that
register. I think that should be a separate patch however.

> Moreover, it seems you are bailing out and basically denying driver to load.
> This does look that capability is simply the first register that blows the 
> setup.
> I think you have to fix something into Xen to avoid loading these drivers or
> check with something like pci_device_is_present() approach.

Is there a backing PCI device BAR for those MMIO regions that the
pinctrl driver is trying to access? AFAICT those regions are only
reported in the ACPI DSDT table on the _CRS method of the object (at
least on my system).

Doing something like pci_device_is_present would require a register
that we know will never return ~0 unless the device is not present. As
said above, maybe we could use REVID to that end?

> > Fixes: 91d898e51e60 ('pinctrl: intel: Convert capability list to features')
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > ---
> > Cc: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
> > Cc: Andy Shevchenko <andy@xxxxxxxxxx>
> > Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
> > Cc: linux-gpio@xxxxxxxxxxxxxxx
> > ---
> > Resend because I've missed adding the maintainers, sorry for the spam.
> 
> I have a script to make it easier: 
> https://github.com/andy-shev/home-bin-tools/blob/master/ge2maintainer.sh

Thanks!



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.