1. 25 May, 2019 40 commits
    • Al Viro's avatar
      ufs: fix braino in ufs_get_inode_gid() for solaris UFS flavour · a06fdd99
      Al Viro authored
      [ Upstream commit 4e903604 ]
      
      To choose whether to pick the GID from the old (16bit) or new (32bit)
      field, we should check if the old gid field is set to 0xffff.  Mainline
      checks the old *UID* field instead - cut'n'paste from the corresponding
      code in ufs_get_inode_uid().
      
      Fixes: 252e211eSigned-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a06fdd99
    • Gary Hook's avatar
      x86/mm/mem_encrypt: Disable all instrumentation for early SME setup · f037116f
      Gary Hook authored
      [ Upstream commit b51ce374 ]
      
      Enablement of AMD's Secure Memory Encryption feature is determined very
      early after start_kernel() is entered. Part of this procedure involves
      scanning the command line for the parameter 'mem_encrypt'.
      
      To determine intended state, the function sme_enable() uses library
      functions cmdline_find_option() and strncmp(). Their use occurs early
      enough such that it cannot be assumed that any instrumentation subsystem
      is initialized.
      
      For example, making calls to a KASAN-instrumented function before KASAN
      is set up will result in the use of uninitialized memory and a boot
      failure.
      
      When AMD's SME support is enabled, conditionally disable instrumentation
      of these dependent functions in lib/string.c and arch/x86/lib/cmdline.c.
      
       [ bp: Get rid of intermediary nostackp var and cleanup whitespace. ]
      
      Fixes: aca20d54 ("x86/mm: Add support to make use of Secure Memory Encryption")
      Reported-by: default avatarLi RongQing <lirongqing@baidu.com>
      Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Boris Brezillon <bbrezillon@kernel.org>
      Cc: Coly Li <colyli@suse.de>
      Cc: "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Kent Overstreet <kent.overstreet@gmail.com>
      Cc: "luto@kernel.org" <luto@kernel.org>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: "mingo@redhat.com" <mingo@redhat.com>
      Cc: "peterz@infradead.org" <peterz@infradead.org>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/155657657552.7116.18363762932464011367.stgit@sosrh3.amd.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      f037116f
    • Tobin C. Harding's avatar
      sched/cpufreq: Fix kobject memleak · 290da8e7
      Tobin C. Harding authored
      [ Upstream commit 9a4f26cc ]
      
      Currently the error return path from kobject_init_and_add() is not
      followed by a call to kobject_put() - which means we are leaking
      the kobject.
      
      Fix it by adding a call to kobject_put() in the error path of
      kobject_init_and_add().
      Signed-off-by: default avatarTobin C. Harding <tobin@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tobin C. Harding <tobin@kernel.org>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      290da8e7
    • Luca Coelho's avatar
      iwlwifi: mvm: check for length correctness in iwl_mvm_create_skb() · 2da19da7
      Luca Coelho authored
      [ Upstream commit de1887c0 ]
      
      We don't check for the validity of the lengths in the packet received
      from the firmware.  If the MPDU length received in the rx descriptor
      is too short to contain the header length and the crypt length
      together, we may end up trying to copy a negative number of bytes
      (headlen - hdrlen < 0) which will underflow and cause us to try to
      copy a huge amount of data.  This causes oopses such as this one:
      
      BUG: unable to handle kernel paging request at ffff896be2970000
      PGD 5e201067 P4D 5e201067 PUD 5e205067 PMD 16110d063 PTE 8000000162970161
      Oops: 0003 [#1] PREEMPT SMP NOPTI
      CPU: 2 PID: 1824 Comm: irq/134-iwlwifi Not tainted 4.19.33-04308-geea41cf4930f #1
      Hardware name: [...]
      RIP: 0010:memcpy_erms+0x6/0x10
      Code: 90 90 90 90 eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3
       0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 fe
      RSP: 0018:ffffa4630196fc60 EFLAGS: 00010287
      RAX: ffff896be2924618 RBX: ffff896bc8ecc600 RCX: 00000000fffb4610
      RDX: 00000000fffffff8 RSI: ffff896a835e2a38 RDI: ffff896be2970000
      RBP: ffffa4630196fd30 R08: ffff896bc8ecc600 R09: ffff896a83597000
      R10: ffff896bd6998400 R11: 000000000200407f R12: ffff896a83597050
      R13: 00000000fffffff8 R14: 0000000000000010 R15: ffff896a83597038
      FS:  0000000000000000(0000) GS:ffff896be8280000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: ffff896be2970000 CR3: 000000005dc12002 CR4: 00000000003606e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       iwl_mvm_rx_mpdu_mq+0xb51/0x121b [iwlmvm]
       iwl_pcie_rx_handle+0x58c/0xa89 [iwlwifi]
       iwl_pcie_irq_rx_msix_handler+0xd9/0x12a [iwlwifi]
       irq_thread_fn+0x24/0x49
       irq_thread+0xb0/0x122
       kthread+0x138/0x140
       ret_from_fork+0x1f/0x40
      
      Fix that by checking the lengths for correctness and trigger a warning
      to show that we have received wrong data.
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2da19da7
    • Bjørn Mork's avatar
      qmi_wwan: new Wistron, ZTE and D-Link devices · 7341daa0
      Bjørn Mork authored
      [ Upstream commit 88ef66a2 ]
      
      Adding device entries found in vendor modified versions of this
      driver.  Function maps for some of the devices follow:
      
      WNC D16Q1, D16Q5, D18Q1 LTE CAT3 module (1435:0918)
      
      MI_00 Qualcomm HS-USB Diagnostics
      MI_01 Android Debug interface
      MI_02 Qualcomm HS-USB Modem
      MI_03 Qualcomm Wireless HS-USB Ethernet Adapter
      MI_04 Qualcomm Wireless HS-USB Ethernet Adapter
      MI_05 Qualcomm Wireless HS-USB Ethernet Adapter
      MI_06 USB Mass Storage Device
      
       T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 0
       D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
       P:  Vendor=1435 ProdID=0918 Rev= 2.32
       S:  Manufacturer=Android
       S:  Product=Android
       S:  SerialNumber=0123456789ABCDEF
       C:* #Ifs= 7 Cfg#= 1 Atr=80 MxPwr=500mA
       I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
       E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)
       E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
       E:  Ad=84(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
       E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
       E:  Ad=86(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
       E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
       E:  Ad=88(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
       E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       I:* If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
       E:  Ad=8a(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
       E:  Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
       E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      
      WNC D18 LTE CAT3 module (1435:d182)
      
      MI_00 Qualcomm HS-USB Diagnostics
      MI_01 Androd Debug interface
      MI_02 Qualcomm HS-USB Modem
      MI_03 Qualcomm HS-USB NMEA
      MI_04 Qualcomm Wireless HS-USB Ethernet Adapter
      MI_05 Qualcomm Wireless HS-USB Ethernet Adapter
      MI_06 USB Mass Storage Device
      
      ZM8510/ZM8620/ME3960 (19d2:0396)
      
      MI_00 ZTE Mobile Broadband Diagnostics Port
      MI_01 ZTE Mobile Broadband AT Port
      MI_02 ZTE Mobile Broadband Modem
      MI_03 ZTE Mobile Broadband NDIS Port (qmi_wwan)
      MI_04 ZTE Mobile Broadband ADB Port
      
      ME3620_X (19d2:1432)
      
      MI_00 ZTE Diagnostics Device
      MI_01 ZTE UI AT Interface
      MI_02 ZTE Modem Device
      MI_03 ZTE Mobile Broadband Network Adapter
      MI_04 ZTE Composite ADB Interface
      Reported-by: default avatarLars Melin <larsm17@gmail.com>
      Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7341daa0
    • Peter Zijlstra's avatar
      bpf: Fix preempt_enable_no_resched() abuse · c1528193
      Peter Zijlstra authored
      [ Upstream commit 0edd6b64 ]
      
      Unless the very next line is schedule(), or implies it, one must not use
      preempt_enable_no_resched(). It can cause a preemption to go missing and
      thereby cause arbitrary delays, breaking the PREEMPT=y invariant.
      
      Cc: Roman Gushchin <guro@fb.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c1528193
    • Andrey Smirnov's avatar
      power: supply: sysfs: prevent endless uevent loop with CONFIG_POWER_SUPPLY_DEBUG · aea54f61
      Andrey Smirnov authored
      [ Upstream commit 349ced99 ]
      
      Fix a similar endless event loop as was done in commit
      8dcf3217 ("i2c: prevent endless uevent loop with
      CONFIG_I2C_DEBUG_CORE"):
      
        The culprit is the dev_dbg printk in the i2c uevent handler. If
        this is activated (for instance by CONFIG_I2C_DEBUG_CORE) it results
        in an endless loop with systemd-journald.
      
        This happens if user-space scans the system log and reads the uevent
        file to get information about a newly created device, which seems
        fair use to me. Unfortunately reading the "uevent" file uses the
        same function that runs for creating the uevent for a new device,
        generating the next syslog entry
      
      Both CONFIG_I2C_DEBUG_CORE and CONFIG_POWER_SUPPLY_DEBUG were reported
      in https://bugs.freedesktop.org/show_bug.cgi?id=76886 but only former
      seems to have been fixed. Drop debug prints as it was done in I2C
      subsystem to resolve the issue.
      Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
      Cc: Chris Healy <cphealy@gmail.com>
      Cc: linux-pm@vger.kernel.org
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aea54f61
    • Andrew Jones's avatar
      KVM: arm/arm64: Ensure vcpu target is unset on reset failure · a1251522
      Andrew Jones authored
      [ Upstream commit 811328fc ]
      
      A failed KVM_ARM_VCPU_INIT should not set the vcpu target,
      as the vcpu target is used by kvm_vcpu_initialized() to
      determine if other vcpu ioctls may proceed. We need to set
      the target before calling kvm_reset_vcpu(), but if that call
      fails, we should then unset it and clear the feature bitmap
      while we're at it.
      Signed-off-by: default avatarAndrew Jones <drjones@redhat.com>
      [maz: Simplified patch, completed commit message]
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a1251522
    • Kangjie Lu's avatar
      net: ieee802154: fix missing checks for regmap_update_bits · 36ae546a
      Kangjie Lu authored
      [ Upstream commit 22e8860c ]
      
      regmap_update_bits could fail and deserves a check.
      
      The patch adds the checks and if it fails, returns its error
      code upstream.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Reviewed-by: default avatarMukesh Ojha <mojha@codeaurora.org>
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      36ae546a
    • Bhagavathi Perumal S's avatar
      mac80211: Fix kernel panic due to use of txq after free · 9c045d8c
      Bhagavathi Perumal S authored
      [ Upstream commit f1267cf3 ]
      
      The txq of vif is added to active_txqs list for ATF TXQ scheduling
      in the function ieee80211_queue_skb(), but it was not properly removed
      before freeing the txq object. It was causing use after free of the txq
      objects from the active_txqs list, result was kernel panic
      due to invalid memory access.
      
      Fix kernel invalid memory access by properly removing txq object
      from active_txqs list before free the object.
      Signed-off-by: default avatarBhagavathi Perumal S <bperumal@codeaurora.org>
      Acked-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9c045d8c
    • Vitaly Kuznetsov's avatar
      x86: kvm: hyper-v: deal with buggy TLB flush requests from WS2012 · a0a49d87
      Vitaly Kuznetsov authored
      [ Upstream commit da66761c ]
      
      It was reported that with some special Multi Processor Group configuration,
      e.g:
       bcdedit.exe /set groupsize 1
       bcdedit.exe /set maxgroup on
       bcdedit.exe /set groupaware on
      for a 16-vCPU guest WS2012 shows BSOD on boot when PV TLB flush mechanism
      is in use.
      
      Tracing kvm_hv_flush_tlb immediately reveals the issue:
      
       kvm_hv_flush_tlb: processor_mask 0x0 address_space 0x0 flags 0x2
      
      The only flag set in this request is HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES,
      however, processor_mask is 0x0 and no HV_FLUSH_ALL_PROCESSORS is specified.
      We don't flush anything and apparently it's not what Windows expects.
      
      TLFS doesn't say anything about such requests and newer Windows versions
      seem to be unaffected. This all feels like a WS2012 bug, which is, however,
      easy to workaround in KVM: let's flush everything when we see an empty
      flush request, over-flushing doesn't hurt.
      Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a0a49d87
    • Logan Gunthorpe's avatar
      PCI: Fix issue with "pci=disable_acs_redir" parameter being ignored · a4696468
      Logan Gunthorpe authored
      [ Upstream commit d5bc73f3 ]
      
      In most cases, kmalloc() will not be available early in boot when
      pci_setup() is called.  Thus, the kstrdup() call that was added to fix the
      __initdata bug with the disable_acs_redir parameter usually returns NULL,
      so the parameter is discarded and has no effect.
      
      To fix this, store the string that's in initdata until an initcall function
      can allocate the memory appropriately.  This way we don't need any
      additional static memory.
      
      Fixes: d2fd6e81 ("PCI: Fix __initdata issue with "pci=disable_acs_redir" parameter")
      Signed-off-by: default avatarLogan Gunthorpe <logang@deltatee.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a4696468
    • Al Viro's avatar
      apparmorfs: fix use-after-free on symlink traversal · b21ca276
      Al Viro authored
      [ Upstream commit f51dcd0f ]
      
      symlink body shouldn't be freed without an RCU delay.  Switch apparmorfs
      to ->destroy_inode() and use of call_rcu(); free both the inode and symlink
      body in the callback.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b21ca276
    • Al Viro's avatar
      securityfs: fix use-after-free on symlink traversal · 9a0467e1
      Al Viro authored
      [ Upstream commit 46c87441 ]
      
      symlink body shouldn't be freed without an RCU delay.  Switch securityfs
      to ->destroy_inode() and use of call_rcu(); free both the inode and symlink
      body in the callback.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9a0467e1
    • Tony Lindgren's avatar
      power: supply: cpcap-battery: Fix division by zero · 900bf351
      Tony Lindgren authored
      [ Upstream commit dbe7208c ]
      
      If called fast enough so samples do not increment, we can get
      division by zero in kernel:
      
      __div0
      cpcap_battery_cc_raw_div
      cpcap_battery_get_property
      power_supply_get_property.part.1
      power_supply_get_property
      power_supply_show_property
      power_supply_uevent
      
      Fixes: 874b2adb ("power: supply: cpcap-battery: Add a battery driver")
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Acked-by: default avatarPavel Machek <pavel@ucw.cz>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      900bf351
    • Jernej Skrabec's avatar
      clk: sunxi-ng: nkmp: Avoid GENMASK(-1, 0) · b7771cb0
      Jernej Skrabec authored
      [ Upstream commit 2abc330c ]
      
      Sometimes one of the nkmp factors is unused. This means that one of the
      factors shift and width values are set to 0. Current nkmp clock code
      generates a mask for each factor with GENMASK(width + shift - 1, shift).
      For unused factor this translates to GENMASK(-1, 0). This code is
      further expanded by C preprocessor to final version:
      (((~0UL) - (1UL << (0)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (-1))))
      or a bit simplified:
      (~0UL & (~0UL >> BITS_PER_LONG))
      
      It turns out that result of the second part (~0UL >> BITS_PER_LONG) is
      actually undefined by C standard, which clearly specifies:
      
      "If the value of the right operand is negative or is greater than or
      equal to the width of the promoted left operand, the behavior is
      undefined."
      
      Additionally, compiling kernel with aarch64-linux-gnu-gcc 8.3.0 gave
      different results whether literals or variables with same values as
      literals were used. GENMASK with literals -1 and 0 gives zero and with
      variables gives 0xFFFFFFFFFFFFFFF (~0UL). Because nkmp driver uses
      GENMASK with variables as parameter, expression calculates mask as ~0UL
      instead of 0. This has further consequences that LSB in register is
      always set to 1 (1 is neutral value for a factor and shift is 0).
      
      For example, H6 pll-de clock is set to 600 MHz by sun4i-drm driver, but
      due to this bug ends up being 300 MHz. Additionally, 300 MHz seems to be
      too low because following warning can be found in dmesg:
      
      [    1.752763] WARNING: CPU: 2 PID: 41 at drivers/clk/sunxi-ng/ccu_common.c:41 ccu_helper_wait_for_lock.part.0+0x6c/0x90
      [    1.763378] Modules linked in:
      [    1.766441] CPU: 2 PID: 41 Comm: kworker/2:1 Not tainted 5.1.0-rc2-next-20190401 #138
      [    1.774269] Hardware name: Pine H64 (DT)
      [    1.778200] Workqueue: events deferred_probe_work_func
      [    1.783341] pstate: 40000005 (nZcv daif -PAN -UAO)
      [    1.788135] pc : ccu_helper_wait_for_lock.part.0+0x6c/0x90
      [    1.793623] lr : ccu_helper_wait_for_lock.part.0+0x48/0x90
      [    1.799107] sp : ffff000010f93840
      [    1.802422] x29: ffff000010f93840 x28: 0000000000000000
      [    1.807735] x27: ffff800073ce9d80 x26: ffff000010afd1b8
      [    1.813049] x25: ffffffffffffffff x24: 00000000ffffffff
      [    1.818362] x23: 0000000000000001 x22: ffff000010abd5c8
      [    1.823675] x21: 0000000010000000 x20: 00000000685f367e
      [    1.828987] x19: 0000000000001801 x18: 0000000000000001
      [    1.834300] x17: 0000000000000001 x16: 0000000000000000
      [    1.839613] x15: 0000000000000000 x14: ffff000010789858
      [    1.844926] x13: 0000000000000000 x12: 0000000000000001
      [    1.850239] x11: 0000000000000000 x10: 0000000000000970
      [    1.855551] x9 : ffff000010f936c0 x8 : ffff800074cec0d0
      [    1.860864] x7 : 0000800067117000 x6 : 0000000115c30b41
      [    1.866177] x5 : 00ffffffffffffff x4 : 002c959300bfe500
      [    1.871490] x3 : 0000000000000018 x2 : 0000000029aaaaab
      [    1.876802] x1 : 00000000000002e6 x0 : 00000000686072bc
      [    1.882114] Call trace:
      [    1.884565]  ccu_helper_wait_for_lock.part.0+0x6c/0x90
      [    1.889705]  ccu_helper_wait_for_lock+0x10/0x20
      [    1.894236]  ccu_nkmp_set_rate+0x244/0x2a8
      [    1.898334]  clk_change_rate+0x144/0x290
      [    1.902258]  clk_core_set_rate_nolock+0x180/0x1b8
      [    1.906963]  clk_set_rate+0x34/0xa0
      [    1.910455]  sun8i_mixer_bind+0x484/0x558
      [    1.914466]  component_bind_all+0x10c/0x230
      [    1.918651]  sun4i_drv_bind+0xc4/0x1a0
      [    1.922401]  try_to_bring_up_master+0x164/0x1c0
      [    1.926932]  __component_add+0xa0/0x168
      [    1.930769]  component_add+0x10/0x18
      [    1.934346]  sun8i_dw_hdmi_probe+0x18/0x20
      [    1.938443]  platform_drv_probe+0x50/0xa0
      [    1.942455]  really_probe+0xcc/0x280
      [    1.946032]  driver_probe_device+0x54/0xe8
      [    1.950130]  __device_attach_driver+0x80/0xb8
      [    1.954488]  bus_for_each_drv+0x78/0xc8
      [    1.958326]  __device_attach+0xd4/0x130
      [    1.962163]  device_initial_probe+0x10/0x18
      [    1.966348]  bus_probe_device+0x90/0x98
      [    1.970185]  deferred_probe_work_func+0x6c/0xa0
      [    1.974720]  process_one_work+0x1e0/0x320
      [    1.978732]  worker_thread+0x228/0x428
      [    1.982484]  kthread+0x120/0x128
      [    1.985714]  ret_from_fork+0x10/0x18
      [    1.989290] ---[ end trace 9babd42e1ca4b84f ]---
      
      This commit solves the issue by first checking value of the factor
      width. If it is equal to 0 (unused factor), mask is set to 0, otherwise
      GENMASK() macro is used as before.
      
      Fixes: d897ef56 ("clk: sunxi-ng: Mask nkmp factors when setting register")
      Signed-off-by: default avatarJernej Skrabec <jernej.skrabec@siol.net>
      Signed-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b7771cb0
    • Steffen Klassert's avatar
      xfrm4: Fix uninitialized memory read in _decode_session4 · a654a73d
      Steffen Klassert authored
      [ Upstream commit 8742dc86 ]
      
      We currently don't reload pointers pointing into skb header
      after doing pskb_may_pull() in _decode_session4(). So in case
      pskb_may_pull() changed the pointers, we read from random
      memory. Fix this by putting all the needed infos on the
      stack, so that we don't need to access the header pointers
      after doing pskb_may_pull().
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a654a73d
    • Martin Willi's avatar
      xfrm: Honor original L3 slave device in xfrmi policy lookup · 6faa6206
      Martin Willi authored
      [ Upstream commit 025c65e1 ]
      
      If an xfrmi is associated to a vrf layer 3 master device,
      xfrm_policy_check() fails after traffic decapsulation. The input
      interface is replaced by the layer 3 master device, and hence
      xfrmi_decode_session() can't match the xfrmi anymore to satisfy
      policy checking.
      
      Extend ingress xfrmi lookup to honor the original layer 3 slave
      device, allowing xfrm interfaces to operate within a vrf domain.
      
      Fixes: f203b76d ("xfrm: Add virtual xfrm interfaces")
      Signed-off-by: default avatarMartin Willi <martin@strongswan.org>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6faa6206
    • Sabrina Dubroca's avatar
      esp4: add length check for UDP encapsulation · 3716c262
      Sabrina Dubroca authored
      [ Upstream commit 8dfb4eba ]
      
      esp_output_udp_encap can produce a length that doesn't fit in the 16
      bits of a UDP header's length field. In that case, we'll send a
      fragmented packet whose length is larger than IP_MAX_MTU (resulting in
      "Oversized IP packet" warnings on receive) and with a bogus UDP
      length.
      
      To prevent this, add a length check to esp_output_udp_encap and return
       -EMSGSIZE on failure.
      
      This seems to be older than git history.
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3716c262
    • Cong Wang's avatar
      xfrm: clean up xfrm protocol checks · d410ef75
      Cong Wang authored
      [ Upstream commit dbb2483b ]
      
      In commit 6a53b759 ("xfrm: check id proto in validate_tmpl()")
      I introduced a check for xfrm protocol, but according to Herbert
      IPSEC_PROTO_ANY should only be used as a wildcard for lookup, so
      it should be removed from validate_tmpl().
      
      And, IPSEC_PROTO_ANY is expected to only match 3 IPSec-specific
      protocols, this is why xfrm_state_flush() could still miss
      IPPROTO_ROUTING, which leads that those entries are left in
      net->xfrm.state_all before exit net. Fix this by replacing
      IPSEC_PROTO_ANY with zero.
      
      This patch also extracts the check from validate_tmpl() to
      xfrm_id_proto_valid() and uses it in parse_ipsecrequest().
      With this, no other protocols should be added into xfrm.
      
      Fixes: 6a53b759 ("xfrm: check id proto in validate_tmpl()")
      Reported-by: syzbot+0bf0519d6e0de15914fe@syzkaller.appspotmail.com
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d410ef75
    • Jeremy Sowden's avatar
      vti4: ipip tunnel deregistration fixes. · 159269cc
      Jeremy Sowden authored
      [ Upstream commit 5483844c ]
      
      If tunnel registration failed during module initialization, the module
      would fail to deregister the IPPROTO_COMP protocol and would attempt to
      deregister the tunnel.
      
      The tunnel was not deregistered during module-exit.
      
      Fixes: dd9ee344 ("vti4: Fix a ipip packet processing bug in 'IPCOMP' virtual tunnel")
      Signed-off-by: default avatarJeremy Sowden <jeremy@azazel.net>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      159269cc
    • Su Yanjun's avatar
      xfrm6_tunnel: Fix potential panic when unloading xfrm6_tunnel module · 64f214ce
      Su Yanjun authored
      [ Upstream commit 6ee02a54 ]
      
      When unloading xfrm6_tunnel module, xfrm6_tunnel_fini directly
      frees the xfrm6_tunnel_spi_kmem. Maybe someone has gotten the
      xfrm6_tunnel_spi, so need to wait it.
      
      Fixes: 91cc3bb0("xfrm6_tunnel: RCU conversion")
      Signed-off-by: default avatarSu Yanjun <suyj.fnst@cn.fujitsu.com>
      Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      64f214ce
    • YueHaibing's avatar
      xfrm: policy: Fix out-of-bound array accesses in __xfrm_policy_unlink · c9516503
      YueHaibing authored
      [ Upstream commit b805d78d ]
      
      UBSAN report this:
      
      UBSAN: Undefined behaviour in net/xfrm/xfrm_policy.c:1289:24
      index 6 is out of range for type 'unsigned int [6]'
      CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.4.162-514.55.6.9.x86_64+ #13
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
       0000000000000000 1466cf39b41b23c9 ffff8801f6b07a58 ffffffff81cb35f4
       0000000041b58ab3 ffffffff83230f9c ffffffff81cb34e0 ffff8801f6b07a80
       ffff8801f6b07a20 1466cf39b41b23c9 ffffffff851706e0 ffff8801f6b07ae8
      Call Trace:
       <IRQ>  [<ffffffff81cb35f4>] __dump_stack lib/dump_stack.c:15 [inline]
       <IRQ>  [<ffffffff81cb35f4>] dump_stack+0x114/0x1a0 lib/dump_stack.c:51
       [<ffffffff81d94225>] ubsan_epilogue+0x12/0x8f lib/ubsan.c:164
       [<ffffffff81d954db>] __ubsan_handle_out_of_bounds+0x16e/0x1b2 lib/ubsan.c:382
       [<ffffffff82a25acd>] __xfrm_policy_unlink+0x3dd/0x5b0 net/xfrm/xfrm_policy.c:1289
       [<ffffffff82a2e572>] xfrm_policy_delete+0x52/0xb0 net/xfrm/xfrm_policy.c:1309
       [<ffffffff82a3319b>] xfrm_policy_timer+0x30b/0x590 net/xfrm/xfrm_policy.c:243
       [<ffffffff813d3927>] call_timer_fn+0x237/0x990 kernel/time/timer.c:1144
       [<ffffffff813d8e7e>] __run_timers kernel/time/timer.c:1218 [inline]
       [<ffffffff813d8e7e>] run_timer_softirq+0x6ce/0xb80 kernel/time/timer.c:1401
       [<ffffffff8120d6f9>] __do_softirq+0x299/0xe10 kernel/softirq.c:273
       [<ffffffff8120e676>] invoke_softirq kernel/softirq.c:350 [inline]
       [<ffffffff8120e676>] irq_exit+0x216/0x2c0 kernel/softirq.c:391
       [<ffffffff82c5edab>] exiting_irq arch/x86/include/asm/apic.h:652 [inline]
       [<ffffffff82c5edab>] smp_apic_timer_interrupt+0x8b/0xc0 arch/x86/kernel/apic/apic.c:926
       [<ffffffff82c5c985>] apic_timer_interrupt+0xa5/0xb0 arch/x86/entry/entry_64.S:735
       <EOI>  [<ffffffff81188096>] ? native_safe_halt+0x6/0x10 arch/x86/include/asm/irqflags.h:52
       [<ffffffff810834d7>] arch_safe_halt arch/x86/include/asm/paravirt.h:111 [inline]
       [<ffffffff810834d7>] default_idle+0x27/0x430 arch/x86/kernel/process.c:446
       [<ffffffff81085f05>] arch_cpu_idle+0x15/0x20 arch/x86/kernel/process.c:437
       [<ffffffff8132abc3>] default_idle_call+0x53/0x90 kernel/sched/idle.c:92
       [<ffffffff8132b32d>] cpuidle_idle_call kernel/sched/idle.c:156 [inline]
       [<ffffffff8132b32d>] cpu_idle_loop kernel/sched/idle.c:251 [inline]
       [<ffffffff8132b32d>] cpu_startup_entry+0x60d/0x9a0 kernel/sched/idle.c:299
       [<ffffffff8113e119>] start_secondary+0x3c9/0x560 arch/x86/kernel/smpboot.c:245
      
      The issue is triggered as this:
      
      xfrm_add_policy
          -->verify_newpolicy_info  //check the index provided by user with XFRM_POLICY_MAX
      			      //In my case, the index is 0x6E6BB6, so it pass the check.
          -->xfrm_policy_construct  //copy the user's policy and set xfrm_policy_timer
          -->xfrm_policy_insert
      	--> __xfrm_policy_link //use the orgin dir, in my case is 2
      	--> xfrm_gen_index   //generate policy index, there is 0x6E6BB6
      
      then xfrm_policy_timer be fired
      
      xfrm_policy_timer
         --> xfrm_policy_id2dir  //get dir from (policy index & 7), in my case is 6
         --> xfrm_policy_delete
            --> __xfrm_policy_unlink //access policy_count[dir], trigger out of range access
      
      Add xfrm_policy_id2dir check in verify_newpolicy_info, make sure the computed dir is
      valid, to fix the issue.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Fixes: e682adf0 ("xfrm: Try to honor policy index if it's supplied by user")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c9516503
    • Kirill Smelkov's avatar
      fuse: Add FOPEN_STREAM to use stream_open() · fea68500
      Kirill Smelkov authored
      commit bbd84f33 upstream.
      
      Starting from commit 9c225f26 ("vfs: atomic f_pos accesses as per
      POSIX") files opened even via nonseekable_open gate read and write via lock
      and do not allow them to be run simultaneously. This can create read vs
      write deadlock if a filesystem is trying to implement a socket-like file
      which is intended to be simultaneously used for both read and write from
      filesystem client.  See commit 10dce8af ("fs: stream_open - opener for
      stream-like files so that read and write can run simultaneously without
      deadlock") for details and e.g. commit 581d21a2 ("xenbus: fix deadlock
      on writes to /proc/xen/xenbus") for a similar deadlock example on
      /proc/xen/xenbus.
      
      To avoid such deadlock it was tempting to adjust fuse_finish_open to use
      stream_open instead of nonseekable_open on just FOPEN_NONSEEKABLE flags,
      but grepping through Debian codesearch shows users of FOPEN_NONSEEKABLE,
      and in particular GVFS which actually uses offset in its read and write
      handlers
      
      	https://codesearch.debian.net/search?q=-%3Enonseekable+%3D
      	https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1080
      	https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1247-1346
      	https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1399-1481
      
      so if we would do such a change it will break a real user.
      
      Add another flag (FOPEN_STREAM) for filesystem servers to indicate that the
      opened handler is having stream-like semantics; does not use file position
      and thus the kernel is free to issue simultaneous read and write request on
      opened file handle.
      
      This patch together with stream_open() should be added to stable kernels
      starting from v3.14+. This will allow to patch OSSPD and other FUSE
      filesystems that provide stream-like files to return FOPEN_STREAM |
      FOPEN_NONSEEKABLE in open handler and this way avoid the deadlock on all
      kernel versions. This should work because fuse_finish_open ignores unknown
      open flags returned from a filesystem and so passing FOPEN_STREAM to a
      kernel that is not aware of this flag cannot hurt. In turn the kernel that
      is not aware of FOPEN_STREAM will be < v3.14 where just FOPEN_NONSEEKABLE
      is sufficient to implement streams without read vs write deadlock.
      
      Cc: stable@vger.kernel.org # v3.14+
      Signed-off-by: Kirill Smelkov's avatarKirill Smelkov <kirr@nexedi.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fea68500
    • Martin Wilck's avatar
      dm mpath: always free attached_handler_name in parse_path() · f9eccf6c
      Martin Wilck authored
      commit 940bc471 upstream.
      
      Commit b592211c ("dm mpath: fix attached_handler_name leak and
      dangling hw_handler_name pointer") fixed a memory leak for the case
      where setup_scsi_dh() returns failure. But setup_scsi_dh may return
      success and not "use" attached_handler_name if the
      retain_attached_hwhandler flag is not set on the map. As setup_scsi_sh
      properly "steals" the pointer by nullifying it, freeing it
      unconditionally in parse_path() is safe.
      
      Fixes: b592211c ("dm mpath: fix attached_handler_name leak and dangling hw_handler_name pointer")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarYufen Yu <yuyufen@huawei.com>
      Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9eccf6c
    • Mikulas Patocka's avatar
      dm integrity: correctly calculate the size of metadata area · 9407680a
      Mikulas Patocka authored
      commit 30bba430 upstream.
      
      When we use separate devices for data and metadata, dm-integrity would
      incorrectly calculate the size of the metadata device as if it had
      512-byte block size - and it would refuse activation with larger block
      size and smaller metadata device.
      
      Fix this so that it takes actual block size into account, which fixes
      the following reported issue:
      https://gitlab.com/cryptsetup/cryptsetup/issues/450
      
      Fixes: 356d9d52 ("dm integrity: allow separate metadata device")
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9407680a
    • Mikulas Patocka's avatar
      dm delay: fix a crash when invalid device is specified · 3b92ff72
      Mikulas Patocka authored
      commit 81bc6d15 upstream.
      
      When the target line contains an invalid device, delay_ctr() will call
      delay_dtr() with NULL workqueue.  Attempting to destroy the NULL
      workqueue causes a crash.
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b92ff72
    • Damien Le Moal's avatar
      dm zoned: Fix zone report handling · 90cc7112
      Damien Le Moal authored
      commit 7aedf75f upstream.
      
      The function blkdev_report_zones() returns success even if no zone
      information is reported (empty report). Empty zone reports can only
      happen if the report start sector passed exceeds the device capacity.
      The conditions for this to happen are either a bug in the caller code,
      or, a change in the device that forced the low level driver to change
      the device capacity to a value that is lower than the report start
      sector. This situation includes a failed disk revalidation resulting in
      the disk capacity being changed to 0.
      
      If this change happens while dm-zoned is in its initialization phase
      executing dmz_init_zones(), this function may enter an infinite loop
      and hang the system. To avoid this, add a check to disallow empty zone
      reports and bail out early. Also fix the function dmz_update_zone() to
      make sure that the report for the requested zone was correctly obtained.
      
      Fixes: 3b1a94c8 ("dm zoned: drive-managed zoned block device target")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: default avatarShaun Tancheff <shaun@tancheff.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      90cc7112
    • Nikos Tsironis's avatar
      dm cache metadata: Fix loading discard bitset · ff0699a5
      Nikos Tsironis authored
      commit e28adc3b upstream.
      
      Add missing dm_bitset_cursor_next() to properly advance the bitset
      cursor.
      
      Otherwise, the discarded state of all blocks is set according to the
      discarded state of the first block.
      
      Fixes: ae4a46a1 ("dm cache metadata: use bitset cursor api to load discard bitset")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarNikos Tsironis <ntsironis@arrikto.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ff0699a5
    • Stefan Mätje's avatar
      PCI: Work around Pericom PCIe-to-PCI bridge Retrain Link erratum · d5c35230
      Stefan Mätje authored
      commit 4ec73791 upstream.
      
      Due to an erratum in some Pericom PCIe-to-PCI bridges in reverse mode
      (conventional PCI on primary side, PCIe on downstream side), the Retrain
      Link bit needs to be cleared manually to allow the link training to
      complete successfully.
      
      If it is not cleared manually, the link training is continuously restarted
      and no devices below the PCI-to-PCIe bridge can be accessed.  That means
      drivers for devices below the bridge will be loaded but won't work and may
      even crash because the driver is only reading 0xffff.
      
      See the Pericom Errata Sheet PI7C9X111SLB_errata_rev1.2_102711.pdf for
      details.  Devices known as affected so far are: PI7C9X110, PI7C9X111SL,
      PI7C9X130.
      
      Add a new flag, clear_retrain_link, in struct pci_dev.  Quirks for affected
      devices set this bit.
      
      Note that pcie_retrain_link() lives in aspm.c because that's currently the
      only place we use it, but this erratum is not specific to ASPM, and we may
      retrain links for other reasons in the future.
      Signed-off-by: default avatarStefan Mätje <stefan.maetje@esd.eu>
      [bhelgaas: apply regardless of CONFIG_PCIEASPM]
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5c35230
    • Stefan Mätje's avatar
      PCI: Factor out pcie_retrain_link() function · b51a0333
      Stefan Mätje authored
      commit 86fa6a34 upstream.
      
      Factor out pcie_retrain_link() to use for Pericom Retrain Link quirk.  No
      functional change intended.
      Signed-off-by: default avatarStefan Mätje <stefan.maetje@esd.eu>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b51a0333
    • Kazufumi Ikeda's avatar
      PCI: rcar: Add the initialization of PCIe link in resume_noirq() · 7bc992e2
      Kazufumi Ikeda authored
      commit be20bbcb upstream.
      
      Reestablish the PCIe link very early in the resume process in case it
      went down to prevent PCI accesses from hanging the bus. Such accesses
      can happen early in the PCI resume process, as early as the
      SUSPEND_RESUME_NOIRQ step, thus the link must be reestablished in the
      driver resume_noirq() callback.
      
      Fixes: e015f88c ("PCI: rcar: Add support for R-Car H3 to pcie-rcar")
      Signed-off-by: default avatarKazufumi Ikeda <kaz-ikeda@xc.jp.nec.com>
      Signed-off-by: default avatarGaku Inami <gaku.inami.xw@bp.renesas.com>
      Signed-off-by: default avatarMarek Vasut <marek.vasut+renesas@gmail.com>
      [lorenzo.pieralisi@arm.com: reformatted commit log]
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Reviewed-by: default avatarSimon Horman <horms+renesas@verge.net.au>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Cc: stable@vger.kernel.org
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Cc: Phil Edworthy <phil.edworthy@renesas.com>
      Cc: Simon Horman <horms+renesas@verge.net.au>
      Cc: Wolfram Sang <wsa@the-dreams.de>
      Cc: linux-renesas-soc@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7bc992e2
    • Jisheng Zhang's avatar
      PCI/AER: Change pci_aer_init() stub to return void · 2e757498
      Jisheng Zhang authored
      commit 31f996ef upstream.
      
      Commit 60ed982a ("PCI/AER: Move internal declarations to
      drivers/pci/pci.h") changed pci_aer_init() to return "void", but didn't
      change the stub for when CONFIG_PCIEAER isn't enabled.  Change the stub to
      match.
      
      Fixes: 60ed982a ("PCI/AER: Move internal declarations to drivers/pci/pci.h")
      Signed-off-by: default avatarJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org	# v4.19+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e757498
    • Jean-Philippe Brucker's avatar
      PCI: Init PCIe feature bits for managed host bridge alloc · 8c30e149
      Jean-Philippe Brucker authored
      commit 6302bf3e upstream.
      
      Two functions allocate a host bridge: devm_pci_alloc_host_bridge() and
      pci_alloc_host_bridge().  At the moment, only the unmanaged one initializes
      the PCIe feature bits, which prevents from using features such as hotplug
      or AER on some systems, when booting with device tree.  Make the
      initialization code common.
      
      Fixes: 02bfeb48 ("PCI/portdrv: Simplify PCIe feature permission checking")
      Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org	# v4.17+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c30e149
    • James Prestwood's avatar
      PCI: Mark Atheros AR9462 to avoid bus reset · 29d03140
      James Prestwood authored
      commit 6afb7e26 upstream.
      
      When using PCI passthrough with this device, the host machine locks up
      completely when starting the VM, requiring a hard reboot.  Add a quirk to
      avoid bus resets on this device.
      
      Fixes: c3e59ee4 ("PCI: Mark Atheros AR93xx to avoid bus reset")
      Link: https://lore.kernel.org/linux-pci/20190107213248.3034-1-james.prestwood@linux.intel.comSigned-off-by: default avatarJames Prestwood <james.prestwood@linux.intel.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org	# v3.14+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      29d03140
    • Nikolai Kostrigin's avatar
      PCI: Mark AMD Stoney Radeon R7 GPU ATS as broken · f4be6b7e
      Nikolai Kostrigin authored
      commit d28ca864 upstream.
      
      ATS is broken on the Radeon R7 GPU (at least for Stoney Ridge based laptop)
      and causes IOMMU stalls and system failure.  Disable ATS on these devices
      to make them usable again with IOMMU enabled.
      
      Thanks to Joerg Roedel <jroedel@suse.de> for help.
      
      [bhelgaas: In the email thread mentioned below, Alex suspects the real
      problem is in sbios or iommu, so it may affect only certain systems, and it
      may affect other devices in those systems as well.  However, per Joerg we
      lack the ability to debug further, so this quirk is the best we can do for
      now.]
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=194521
      Link: https://lore.kernel.org/lkml/20190408103725.30426-1-nickel@altlinux.org
      Fixes: 9b44b0b0 ("PCI: Mark AMD Stoney GPU ATS as broken")
      Signed-off-by: default avatarNikolai Kostrigin <nickel@altlinux.org>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarJoerg Roedel <jroedel@suse.de>
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4be6b7e
    • Yifeng Li's avatar
      fbdev: sm712fb: fix crashes and garbled display during DPMS modesetting · 2cf1dce1
      Yifeng Li authored
      commit f627caf5 upstream.
      
      On a Thinkpad s30 (Pentium III / i440MX, Lynx3DM), blanking the display
      or starting the X server will crash and freeze the system, or garble the
      display.
      
      Experiments showed this problem can mostly be solved by adjusting the
      order of register writes. Also, sm712fb failed to consider the difference
      of clock frequency when unblanking the display, and programs the clock for
      SM712 to SM720.
      
      Fix them by adjusting the order of register writes, and adding an
      additional check for SM720 for programming the clock frequency.
      Signed-off-by: default avatarYifeng Li <tomli@tomli.me>
      Tested-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Cc: Teddy Wang <teddy.wang@siliconmotion.com>
      Cc: <stable@vger.kernel.org>  # v4.4+
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2cf1dce1
    • Yifeng Li's avatar
      fbdev: sm712fb: use 1024x768 by default on non-MIPS, fix garbled display · 27968d82
      Yifeng Li authored
      commit 4ed7d2cc upstream.
      
      Loongson MIPS netbooks use 1024x600 LCD panels, which is the original
      target platform of this driver, but nearly all old x86 laptops have
      1024x768. Lighting 768 panels using 600's timings would partially
      garble the display. Since it's not possible to distinguish them reliably,
      we change the default to 768, but keep 600 as-is on MIPS.
      
      Further, earlier laptops, such as IBM Thinkpad 240X, has a 800x600 LCD
      panel, this driver would probably garbled those display. As we don't
      have one for testing, the original behavior of the driver is kept as-is,
      but the problem has been documented is the comments.
      Signed-off-by: default avatarYifeng Li <tomli@tomli.me>
      Tested-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Cc: Teddy Wang <teddy.wang@siliconmotion.com>
      Cc: <stable@vger.kernel.org>  # v4.4+
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      27968d82
    • Yifeng Li's avatar
      fbdev: sm712fb: fix support for 1024x768-16 mode · f1c97f63
      Yifeng Li authored
      commit 6053d3a4 upstream.
      
      In order to support the 1024x600 panel on Yeeloong Loongson MIPS
      laptop, the original 1024x768-16 table was modified to 1024x600-16,
      without leaving the original. It causes problem on x86 laptop as
      the 1024x768-16 support was still claimed but not working.
      
      Fix it by introducing the 1024x768-16 mode.
      Signed-off-by: default avatarYifeng Li <tomli@tomli.me>
      Tested-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Cc: Teddy Wang <teddy.wang@siliconmotion.com>
      Cc: <stable@vger.kernel.org>  # v4.4+
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1c97f63
    • Yifeng Li's avatar
      fbdev: sm712fb: fix crashes during framebuffer writes by correctly mapping VRAM · b415308a
      Yifeng Li authored
      commit 9e0e5999 upstream.
      
      On a Thinkpad s30 (Pentium III / i440MX, Lynx3DM), running fbtest or X
      will crash the machine instantly, because the VRAM/framebuffer is not
      mapped correctly.
      
      On SM712, the framebuffer starts at the beginning of address space, but
      SM720's framebuffer starts at the 1 MiB offset from the beginning. However,
      sm712fb fails to take this into account, as a result, writing to the
      framebuffer will destroy all the registers and kill the system immediately.
      Another problem is the driver assumes 8 MiB of VRAM for SM720, but some
      SM720 system, such as this IBM Thinkpad, only has 4 MiB of VRAM.
      
      Fix this problem by removing the hardcoded VRAM size, adding a function to
      query the amount of VRAM from register MCR76 on SM720, and adding proper
      framebuffer offset.
      
      Please note that the memory map may have additional problems on Big-Endian
      system, which is not available for testing by myself. But I highly suspect
      that the original code is also broken on Big-Endian machines for SM720, so
      at least we are not making the problem worse. More, the driver also assumed
      SM710/SM712 has 4 MiB of VRAM, but it has a 2 MiB version as well, and used
      in earlier laptops, such as IBM Thinkpad 240X, the driver would probably
      crash on them. I've never seen one of those machines and cannot fix it, but
      I have documented these problems in the comments.
      Signed-off-by: default avatarYifeng Li <tomli@tomli.me>
      Tested-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Cc: Teddy Wang <teddy.wang@siliconmotion.com>
      Cc: <stable@vger.kernel.org>  # v4.4+
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b415308a