1. 04 Aug, 2019 40 commits
    • Kai-Heng Feng's avatar
      ALSA: line6: Fix wrong altsetting for LINE6_PODHD500_1 · ec565611
      Kai-Heng Feng authored
      commit 70256b42 upstream.
      
      Commit 7b9584fa ("staging: line6: Move altsetting to properties")
      set a wrong altsetting for LINE6_PODHD500_1 during refactoring.
      
      Set the correct altsetting number to fix the issue.
      
      BugLink: https://bugs.launchpad.net/bugs/1790595
      Fixes: 7b9584fa ("staging: line6: Move altsetting to properties")
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec565611
    • Kefeng Wang's avatar
      hpet: Fix division by zero in hpet_time_div() · 0cbed4f1
      Kefeng Wang authored
      commit 0c7d37f4 upstream.
      
      The base value in do_div() called by hpet_time_div() is truncated from
      unsigned long to uint32_t, resulting in a divide-by-zero exception.
      
      UBSAN: Undefined behaviour in ../drivers/char/hpet.c:572:2
      division by zero
      CPU: 1 PID: 23682 Comm: syz-executor.3 Not tainted 4.4.184.x86_64+ #4
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
       0000000000000000 b573382df1853d00 ffff8800a3287b98 ffffffff81ad7561
       ffff8800a3287c00 ffffffff838b35b0 ffffffff838b3860 ffff8800a3287c20
       0000000000000000 ffff8800a3287bb0 ffffffff81b8f25e ffffffff838b35a0
      Call Trace:
       [<ffffffff81ad7561>] __dump_stack lib/dump_stack.c:15 [inline]
       [<ffffffff81ad7561>] dump_stack+0xc1/0x120 lib/dump_stack.c:51
       [<ffffffff81b8f25e>] ubsan_epilogue+0x12/0x8d lib/ubsan.c:166
       [<ffffffff81b900cb>] __ubsan_handle_divrem_overflow+0x282/0x2c8 lib/ubsan.c:262
       [<ffffffff823560dd>] hpet_time_div drivers/char/hpet.c:572 [inline]
       [<ffffffff823560dd>] hpet_ioctl_common drivers/char/hpet.c:663 [inline]
       [<ffffffff823560dd>] hpet_ioctl_common.cold+0xa8/0xad drivers/char/hpet.c:577
       [<ffffffff81e63d56>] hpet_ioctl+0xc6/0x180 drivers/char/hpet.c:676
       [<ffffffff81711590>] vfs_ioctl fs/ioctl.c:43 [inline]
       [<ffffffff81711590>] file_ioctl fs/ioctl.c:470 [inline]
       [<ffffffff81711590>] do_vfs_ioctl+0x6e0/0xf70 fs/ioctl.c:605
       [<ffffffff81711eb4>] SYSC_ioctl fs/ioctl.c:622 [inline]
       [<ffffffff81711eb4>] SyS_ioctl+0x94/0xc0 fs/ioctl.c:613
       [<ffffffff82846003>] tracesys_phase2+0x90/0x95
      
      The main C reproducer autogenerated by syzkaller,
      
        syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
        memcpy((void*)0x20000100, "/dev/hpet\000", 10);
        syscall(__NR_openat, 0xffffffffffffff9c, 0x20000100, 0, 0);
        syscall(__NR_ioctl, r[0], 0x40086806, 0x40000000000000);
      
      Fix it by using div64_ul().
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarZhang HongJun <zhanghongjun2@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20190711132757.130092-1-wangkefeng.wang@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0cbed4f1
    • Zhenzhong Duan's avatar
      x86/speculation/mds: Apply more accurate check on hypervisor platform · 24db040f
      Zhenzhong Duan authored
      commit 517c3ba0 upstream.
      
      X86_HYPER_NATIVE isn't accurate for checking if running on native platform,
      e.g. CONFIG_HYPERVISOR_GUEST isn't set or "nopv" is enabled.
      
      Checking the CPU feature bit X86_FEATURE_HYPERVISOR to determine if it's
      running on native platform is more accurate.
      
      This still doesn't cover the platforms on which X86_FEATURE_HYPERVISOR is
      unsupported, e.g. VMware, but there is nothing which can be done about this
      scenario.
      
      Fixes: 8a4b06d3 ("x86/speculation/mds: Add sysfs reporting for MDS")
      Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@oracle.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1564022349-17338-1-git-send-email-zhenzhong.duan@oracle.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24db040f
    • Hans de Goede's avatar
      x86/sysfb_efi: Add quirks for some devices with swapped width and height · f7e02b15
      Hans de Goede authored
      commit d02f1aa3 upstream.
      
      Some Lenovo 2-in-1s with a detachable keyboard have a portrait screen but
      advertise a landscape resolution and pitch, resulting in a messed up
      display if the kernel tries to show anything on the efifb (because of the
      wrong pitch).
      
      Fix this by adding a new DMI match table for devices which need to have
      their width and height swapped.
      
      At first it was tried to use the existing table for overriding some of the
      efifb parameters, but some of the affected devices have variants with
      different LCD resolutions which will not work with hardcoded override
      values.
      
      Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1730783Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190721152418.11644-1-hdegoede@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7e02b15
    • Ryan Kennedy's avatar
      usb: pci-quirks: Correct AMD PLL quirk detection · 71960676
      Ryan Kennedy authored
      commit f3dccdaa upstream.
      
      The AMD PLL USB quirk is incorrectly enabled on newer Ryzen
      chipsets. The logic in usb_amd_find_chipset_info currently checks
      for unaffected chipsets rather than affected ones. This broke
      once a new chipset was added in e788787e. It makes more sense
      to reverse the logic so it won't need to be updated as new
      chipsets are added. Note that the core of the workaround in
      usb_amd_quirk_pll does correctly check the chipset.
      Signed-off-by: default avatarRyan Kennedy <ryan5544@gmail.com>
      Fixes: e788787e ("usb:xhci:Add quirk for Certain failing HP keyboard on reset after resume")
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20190704153529.9429-2-ryan5544@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71960676
    • Phong Tran's avatar
      usb: wusbcore: fix unbalanced get/put cluster_id · 53955976
      Phong Tran authored
      commit f90bf1ec upstream.
      
      syzboot reported that
      https://syzkaller.appspot.com/bug?extid=fd2bd7df88c606eea4ef
      
      There is not consitency parameter in cluste_id_get/put calling.
      In case of getting the id with result is failure, the wusbhc->cluster_id
      will not be updated and this can not be used for wusb_cluster_id_put().
      
      Tested report
      https://groups.google.com/d/msg/syzkaller-bugs/0znZopp3-9k/oxOrhLkLEgAJ
      
      Reproduce and gdb got the details:
      
      139		addr = wusb_cluster_id_get();
      (gdb) n
      140		if (addr == 0)
      (gdb) print addr
      $1 = 254 '\376'
      (gdb) n
      142		result = __hwahc_set_cluster_id(hwahc, addr);
      (gdb) print result
      $2 = -71
      (gdb) break wusb_cluster_id_put
      Breakpoint 3 at 0xffffffff836e3f20: file drivers/usb/wusbcore/wusbhc.c, line 384.
      (gdb) s
      Thread 2 hit Breakpoint 3, wusb_cluster_id_put (id=0 '\000') at drivers/usb/wusbcore/wusbhc.c:384
      384		id = 0xff - id;
      (gdb) n
      385		BUG_ON(id >= CLUSTER_IDS);
      (gdb) print id
      $3 = 255 '\377'
      
      Reported-by: syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com
      Signed-off-by: default avatarPhong Tran <tranmanphong@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190724020601.15257-1-tranmanphong@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53955976
    • Arnd Bergmann's avatar
      locking/lockdep: Hide unused 'class' variable · a0e02638
      Arnd Bergmann authored
      [ Upstream commit 68037aa7 ]
      
      The usage is now hidden in an #ifdef, so we need to move
      the variable itself in there as well to avoid this warning:
      
        kernel/locking/lockdep_proc.c:203:21: error: unused variable 'class' [-Werror,-Wunused-variable]
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qian Cai <cai@lca.pw>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yuyang Du <duyuyang@gmail.com>
      Cc: frederic@kernel.org
      Fixes: 68d41d8c ("locking/lockdep: Fix lock used or unused stats error")
      Link: https://lkml.kernel.org/r/20190715092809.736834-1-arnd@arndb.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a0e02638
    • Yuyang Du's avatar
      locking/lockdep: Fix lock used or unused stats error · ccaa280d
      Yuyang Du authored
      [ Upstream commit 68d41d8c ]
      
      The stats variable nr_unused_locks is incremented every time a new lock
      class is register and decremented when the lock is first used in
      __lock_acquire(). And after all, it is shown and checked in lockdep_stats.
      
      However, under configurations that either CONFIG_TRACE_IRQFLAGS or
      CONFIG_PROVE_LOCKING is not defined:
      
      The commit:
      
        09180651 ("locking/lockdep: Consolidate lock usage bit initialization")
      
      missed marking the LOCK_USED flag at IRQ usage initialization because
      as mark_usage() is not called. And the commit:
      
        886532ae ("locking/lockdep: Move mark_lock() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING")
      
      further made mark_lock() not defined such that the LOCK_USED cannot be
      marked at all when the lock is first acquired.
      
      As a result, we fix this by not showing and checking the stats under such
      configurations for lockdep_stats.
      Reported-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarYuyang Du <duyuyang@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: arnd@arndb.de
      Cc: frederic@kernel.org
      Link: https://lkml.kernel.org/r/20190709101522.9117-1-duyuyang@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ccaa280d
    • Jean-Philippe Brucker's avatar
      mm/mmu_notifier: use hlist_add_head_rcu() · 484354b2
      Jean-Philippe Brucker authored
      [ Upstream commit 543bdb2d ]
      
      Make mmu_notifier_register() safer by issuing a memory barrier before
      registering a new notifier.  This fixes a theoretical bug on weakly
      ordered CPUs.  For example, take this simplified use of notifiers by a
      driver:
      
      	my_struct->mn.ops = &my_ops; /* (1) */
      	mmu_notifier_register(&my_struct->mn, mm)
      		...
      		hlist_add_head(&mn->hlist, &mm->mmu_notifiers); /* (2) */
      		...
      
      Once mmu_notifier_register() releases the mm locks, another thread can
      invalidate a range:
      
      	mmu_notifier_invalidate_range()
      		...
      		hlist_for_each_entry_rcu(mn, &mm->mmu_notifiers, hlist) {
      			if (mn->ops->invalidate_range)
      
      The read side relies on the data dependency between mn and ops to ensure
      that the pointer is properly initialized.  But the write side doesn't have
      any dependency between (1) and (2), so they could be reordered and the
      readers could dereference an invalid mn->ops.  mmu_notifier_register()
      does take all the mm locks before adding to the hlist, but those have
      acquire semantics which isn't sufficient.
      
      By calling hlist_add_head_rcu() instead of hlist_add_head() we update the
      hlist using a store-release, ensuring that readers see prior
      initialization of my_struct.  This situation is better illustated by
      litmus test MP+onceassign+derefonce.
      
      Link: http://lkml.kernel.org/r/20190502133532.24981-1-jean-philippe.brucker@arm.com
      Fixes: cddb8a5c ("mmu-notifiers: core")
      Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Cc: Jérôme Glisse <jglisse@redhat.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      484354b2
    • Christoph Hellwig's avatar
      9p: pass the correct prototype to read_cache_page · 42297534
      Christoph Hellwig authored
      [ Upstream commit f053cbd4 ]
      
      Fix the callback 9p passes to read_cache_page to actually have the
      proper type expected.  Casting around function pointers can easily
      hide typing bugs, and defeats control flow protection.
      
      Link: http://lkml.kernel.org/r/20190520055731.24538-5-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      42297534
    • Dmitry Vyukov's avatar
      mm/kmemleak.c: fix check for softirq context · 478cf2d4
      Dmitry Vyukov authored
      [ Upstream commit 6ef90569 ]
      
      in_softirq() is a wrong predicate to check if we are in a softirq
      context.  It also returns true if we have BH disabled, so objects are
      falsely stamped with "softirq" comm.  The correct predicate is
      in_serving_softirq().
      
      If user does cat from /sys/kernel/debug/kmemleak previously they would
      see this, which is clearly wrong, this is system call context (see the
      comm):
      
      unreferenced object 0xffff88805bd661c0 (size 64):
        comm "softirq", pid 0, jiffies 4294942959 (age 12.400s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00  ................
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<0000000007dcb30c>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
          [<0000000007dcb30c>] slab_post_alloc_hook mm/slab.h:439 [inline]
          [<0000000007dcb30c>] slab_alloc mm/slab.c:3326 [inline]
          [<0000000007dcb30c>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
          [<00000000969722b7>] kmalloc include/linux/slab.h:547 [inline]
          [<00000000969722b7>] kzalloc include/linux/slab.h:742 [inline]
          [<00000000969722b7>] ip_mc_add1_src net/ipv4/igmp.c:1961 [inline]
          [<00000000969722b7>] ip_mc_add_src+0x36b/0x400 net/ipv4/igmp.c:2085
          [<00000000a4134b5f>] ip_mc_msfilter+0x22d/0x310 net/ipv4/igmp.c:2475
          [<00000000d20248ad>] do_ip_setsockopt.isra.0+0x19fe/0x1c00 net/ipv4/ip_sockglue.c:957
          [<000000003d367be7>] ip_setsockopt+0x3b/0xb0 net/ipv4/ip_sockglue.c:1246
          [<000000003c7c76af>] udp_setsockopt+0x4e/0x90 net/ipv4/udp.c:2616
          [<000000000c1aeb23>] sock_common_setsockopt+0x3e/0x50 net/core/sock.c:3130
          [<000000000157b92b>] __sys_setsockopt+0x9e/0x120 net/socket.c:2078
          [<00000000a9f3d058>] __do_sys_setsockopt net/socket.c:2089 [inline]
          [<00000000a9f3d058>] __se_sys_setsockopt net/socket.c:2086 [inline]
          [<00000000a9f3d058>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
          [<000000001b8da885>] do_syscall_64+0x7c/0x1a0 arch/x86/entry/common.c:301
          [<00000000ba770c62>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      now they will see this:
      
      unreferenced object 0xffff88805413c800 (size 64):
        comm "syz-executor.4", pid 8960, jiffies 4294994003 (age 14.350s)
        hex dump (first 32 bytes):
          00 7a 8a 57 80 88 ff ff e0 00 00 01 00 00 00 00  .z.W............
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000c5d3be64>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
          [<00000000c5d3be64>] slab_post_alloc_hook mm/slab.h:439 [inline]
          [<00000000c5d3be64>] slab_alloc mm/slab.c:3326 [inline]
          [<00000000c5d3be64>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
          [<0000000023865be2>] kmalloc include/linux/slab.h:547 [inline]
          [<0000000023865be2>] kzalloc include/linux/slab.h:742 [inline]
          [<0000000023865be2>] ip_mc_add1_src net/ipv4/igmp.c:1961 [inline]
          [<0000000023865be2>] ip_mc_add_src+0x36b/0x400 net/ipv4/igmp.c:2085
          [<000000003029a9d4>] ip_mc_msfilter+0x22d/0x310 net/ipv4/igmp.c:2475
          [<00000000ccd0a87c>] do_ip_setsockopt.isra.0+0x19fe/0x1c00 net/ipv4/ip_sockglue.c:957
          [<00000000a85a3785>] ip_setsockopt+0x3b/0xb0 net/ipv4/ip_sockglue.c:1246
          [<00000000ec13c18d>] udp_setsockopt+0x4e/0x90 net/ipv4/udp.c:2616
          [<0000000052d748e3>] sock_common_setsockopt+0x3e/0x50 net/core/sock.c:3130
          [<00000000512f1014>] __sys_setsockopt+0x9e/0x120 net/socket.c:2078
          [<00000000181758bc>] __do_sys_setsockopt net/socket.c:2089 [inline]
          [<00000000181758bc>] __se_sys_setsockopt net/socket.c:2086 [inline]
          [<00000000181758bc>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
          [<00000000d4b73623>] do_syscall_64+0x7c/0x1a0 arch/x86/entry/common.c:301
          [<00000000c1098bec>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Link: http://lkml.kernel.org/r/20190517171507.96046-1-dvyukov@gmail.comSigned-off-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      478cf2d4
    • Sam Ravnborg's avatar
      sh: prevent warnings when using iounmap · 8b593377
      Sam Ravnborg authored
      [ Upstream commit 733f0025 ]
      
      When building drm/exynos for sh, as part of an allmodconfig build, the
      following warning triggered:
      
        exynos7_drm_decon.c: In function `decon_remove':
        exynos7_drm_decon.c:769:24: warning: unused variable `ctx'
          struct decon_context *ctx = dev_get_drvdata(&pdev->dev);
      
      The ctx variable is only used as argument to iounmap().
      
      In sh - allmodconfig CONFIG_MMU is not defined
      so it ended up in:
      
      \#define __iounmap(addr)	do { } while (0)
      \#define iounmap		__iounmap
      
      Fix the warning by introducing a static inline function for iounmap.
      
      This is similar to several other architectures.
      
      Link: http://lkml.kernel.org/r/20190622114208.24427-1-sam@ravnborg.orgSigned-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Inki Dae <inki.dae@samsung.com>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b593377
    • Oliver O'Halloran's avatar
      powerpc/eeh: Handle hugepages in ioremap space · bce3e3e8
      Oliver O'Halloran authored
      [ Upstream commit 33439620 ]
      
      In commit 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap
      space") support for using hugepages in the vmalloc and ioremap areas was
      enabled for radix. Unfortunately this broke EEH MMIO error checking.
      
      Detection works by inserting a hook which checks the results of the
      ioreadXX() set of functions.  When a read returns a 0xFFs response we
      need to check for an error which we do by mapping the (virtual) MMIO
      address back to a physical address, then mapping physical address to a
      PCI device via an interval tree.
      
      When translating virt -> phys we currently assume the ioremap space is
      only populated by PAGE_SIZE mappings. If a hugepage mapping is found we
      emit a WARN_ON(), but otherwise handles the check as though a normal
      page was found. In pathalogical cases such as copying a buffer
      containing a lot of 0xFFs from BAR memory this can result in the system
      not booting because it's too busy printing WARN_ON()s.
      
      There's no real reason to assume huge pages can't be present and we're
      prefectly capable of handling them, so do that.
      
      Fixes: 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap space")
      Reported-by: default avatarSachin Sant <sachinp@linux.vnet.ibm.com>
      Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
      Tested-by: default avatarSachin Sant <sachinp@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190710150517.27114-1-oohall@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      bce3e3e8
    • morten petersen's avatar
      mailbox: handle failed named mailbox channel request · 450233af
      morten petersen authored
      [ Upstream commit 25777e57 ]
      
      Previously, if mbox_request_channel_byname was used with a name
      which did not exist in the "mbox-names" property of a mailbox
      client, the mailbox corresponding to the last entry in the
      "mbox-names" list would be incorrectly selected.
      With this patch, -EINVAL is returned if the named mailbox is
      not found.
      Signed-off-by: default avatarMorten Borup Petersen <morten_bp@live.dk>
      Signed-off-by: default avatarJassi Brar <jaswinder.singh@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      450233af
    • Ocean Chen's avatar
      f2fs: avoid out-of-range memory access · dd1fc2ce
      Ocean Chen authored
      [ Upstream commit 56f3ce67 ]
      
      blkoff_off might over 512 due to fs corrupt or security
      vulnerability. That should be checked before being using.
      
      Use ENTRIES_IN_SUM to protect invalid value in cur_data_blkoff.
      Signed-off-by: default avatarOcean Chen <oceanchen@google.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dd1fc2ce
    • Masahiro Yamada's avatar
      powerpc/boot: add {get, put}_unaligned_be32 to xz_config.h · 34dd8fb9
      Masahiro Yamada authored
      [ Upstream commit 9e005b76 ]
      
      The next commit will make the way of passing CONFIG options more robust.
      Unfortunately, it would uncover another hidden issue; without this
      commit, skiroot_defconfig would be broken like this:
      
      |   WRAP    arch/powerpc/boot/zImage.pseries
      | arch/powerpc/boot/wrapper.a(decompress.o): In function `bcj_powerpc.isra.10':
      | decompress.c:(.text+0x720): undefined reference to `get_unaligned_be32'
      | decompress.c:(.text+0x7a8): undefined reference to `put_unaligned_be32'
      | make[1]: *** [arch/powerpc/boot/Makefile;383: arch/powerpc/boot/zImage.pseries] Error 1
      | make: *** [arch/powerpc/Makefile;295: zImage] Error 2
      
      skiroot_defconfig is the only defconfig that enables CONFIG_KERNEL_XZ
      for ppc, which has never been correctly built before.
      
      I figured out the root cause in lib/decompress_unxz.c:
      
      | #ifdef CONFIG_PPC
      | #      define XZ_DEC_POWERPC
      | #endif
      
      CONFIG_PPC is undefined here in the ppc bootwrapper because autoconf.h
      is not included except by arch/powerpc/boot/serial.c
      
      XZ_DEC_POWERPC is not defined, therefore, bcj_powerpc() is not compiled
      for the bootwrapper.
      
      With the next commit passing CONFIG_PPC correctly, we would realize that
      {get,put}_unaligned_be32 was missing.
      
      Unlike the other decompressors, the ppc bootwrapper duplicates all the
      necessary helpers in arch/powerpc/boot/.
      
      The other architectures define __KERNEL__ and pull in helpers for
      building the decompressors.
      
      If ppc bootwrapper had defined __KERNEL__, lib/xz/xz_private.h would
      have included <asm/unaligned.h>:
      
      | #ifdef __KERNEL__
      | #       include <linux/xz.h>
      | #       include <linux/kernel.h>
      | #       include <asm/unaligned.h>
      
      However, doing so would cause tons of definition conflicts since the
      bootwrapper has duplicated everything.
      
      I just added copies of {get,put}_unaligned_be32, following the
      bootwrapper coding convention.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190705100144.28785-1-yamada.masahiro@socionext.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      34dd8fb9
    • Konstantin Taranov's avatar
      RDMA/rxe: Fill in wc byte_len with IB_WC_RECV_RDMA_WITH_IMM · 8baa8d68
      Konstantin Taranov authored
      [ Upstream commit bdce1290 ]
      
      Calculate the correct byte_len on the receiving side when a work
      completion is generated with IB_WC_RECV_RDMA_WITH_IMM opcode.
      
      According to the IBA byte_len must indicate the number of written bytes,
      whereas it was always equal to zero for the IB_WC_RECV_RDMA_WITH_IMM
      opcode, even though data was transferred.
      
      Fixes: 8700e3e7 ("Soft RoCE driver")
      Signed-off-by: default avatarKonstantin Taranov <konstantin.taranov@inf.ethz.ch>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8baa8d68
    • Numfor Mbiziwo-Tiapo's avatar
      perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning · ff859fa7
      Numfor Mbiziwo-Tiapo authored
      [ Upstream commit 4e4cf62b ]
      
      Running the 'perf test' command after building perf with a memory
      sanitizer causes a warning that says:
      
        WARNING: MemorySanitizer: use-of-uninitialized-value... in mmap-thread-lookup.c
      
      Initializing the go variable to 0 silences this harmless warning.
      
      Committer warning:
      
      This was harmless, just a simple test writing whatever was at that
      sizeof(int) memory area just to signal another thread blocked reading
      that file created with pipe(). Initialize it tho so that we don't get
      this warning.
      Signed-off-by: default avatarNumfor Mbiziwo-Tiapo <nums@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Drayton <mbd@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20190702173716.181223-1-nums@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff859fa7
    • Vasily Gorbik's avatar
      kallsyms: exclude kasan local symbols on s390 · c677e7ad
      Vasily Gorbik authored
      [ Upstream commit 33177f01 ]
      
      gcc asan instrumentation emits the following sequence to store frame pc
      when the kernel is built with CONFIG_RELOCATABLE:
      debug/vsprintf.s:
              .section        .data.rel.ro.local,"aw"
              .align  8
      .LC3:
              .quad   .LASANPC4826@GOTOFF
      .text
              .align  8
              .type   number, @function
      number:
      .LASANPC4826:
      
      and in case reloc is issued for LASANPC label it also gets into .symtab
      with the same address as actual function symbol:
      $ nm -n vmlinux | grep 0000000001397150
      0000000001397150 t .LASANPC4826
      0000000001397150 t number
      
      In the end kernel backtraces are almost unreadable:
      [  143.748476] Call Trace:
      [  143.748484] ([<000000002da3e62c>] .LASANPC2671+0x114/0x190)
      [  143.748492]  [<000000002eca1a58>] .LASANPC2612+0x110/0x160
      [  143.748502]  [<000000002de9d830>] print_address_description+0x80/0x3b0
      [  143.748511]  [<000000002de9dd64>] __kasan_report+0x15c/0x1c8
      [  143.748521]  [<000000002ecb56d4>] strrchr+0x34/0x60
      [  143.748534]  [<000003ff800a9a40>] kasan_strings+0xb0/0x148 [test_kasan]
      [  143.748547]  [<000003ff800a9bba>] kmalloc_tests_init+0xe2/0x528 [test_kasan]
      [  143.748555]  [<000000002da2117c>] .LASANPC4069+0x354/0x748
      [  143.748563]  [<000000002dbfbb16>] do_init_module+0x136/0x3b0
      [  143.748571]  [<000000002dbff3f4>] .LASANPC3191+0x2164/0x25d0
      [  143.748580]  [<000000002dbffc4c>] .LASANPC3196+0x184/0x1b8
      [  143.748587]  [<000000002ecdf2ec>] system_call+0xd8/0x2d8
      
      Since LASANPC labels are not even unique and get into .symtab only due
      to relocs filter them out in kallsyms.
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c677e7ad
    • Geert Uytterhoeven's avatar
      serial: sh-sci: Fix TX DMA buffer flushing and workqueue races · 7e55003b
      Geert Uytterhoeven authored
      [ Upstream commit 8493eab0 ]
      
      When uart_flush_buffer() is called, the .flush_buffer() callback zeroes
      the tx_dma_len field.  This may race with the work queue function
      handling transmit DMA requests:
      
        1. If the buffer is flushed before the first DMA API call,
           dmaengine_prep_slave_single() may be called with a zero length,
           causing the DMA request to never complete, leading to messages
           like:
      
              rcar-dmac e7300000.dma-controller: Channel Address Error happen
      
           and, with debug enabled:
      
      	sh-sci e6e88000.serial: sci_dma_tx_work_fn: ffff800639b55000: 0...0, cookie 126
      
           and DMA timeouts.
      
        2. If the buffer is flushed after the first DMA API call, but before
           the second, dma_sync_single_for_device() may be called with a zero
           length, causing the transmit data not to be flushed to RAM, and
           leading to stale data being output.
      
      Fix this by:
        1. Letting sci_dma_tx_work_fn() return immediately if the transmit
           buffer is empty,
        2. Extending the critical section to cover all DMA preparational work,
           so tx_dma_len stays consistent for all of it,
        3. Using local copies of circ_buf.head and circ_buf.tail, to make sure
           they match the actual operation above.
      Reported-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Suggested-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Tested-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Link: https://lore.kernel.org/r/20190624123540.20629-2-geert+renesas@glider.beSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7e55003b
    • Geert Uytterhoeven's avatar
      serial: sh-sci: Terminate TX DMA during buffer flushing · 56b68e63
      Geert Uytterhoeven authored
      [ Upstream commit 775b7ffd ]
      
      While the .flush_buffer() callback clears sci_port.tx_dma_len since
      commit 1cf4a7ef ("serial: sh-sci: Fix race condition causing
      garbage during shutdown"), it does not terminate a transmit DMA
      operation that may be in progress.
      
      Fix this by terminating any pending DMA operations, and resetting the
      corresponding cookie.
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Tested-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      
      Link: https://lore.kernel.org/r/20190624123540.20629-3-geert+renesas@glider.beSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      56b68e63
    • Liu, Changcheng's avatar
      RDMA/i40iw: Set queue pair state when being queried · c70bfc1b
      Liu, Changcheng authored
      [ Upstream commit 2e67e775 ]
      
      The API for ib_query_qp requires the driver to set qp_state and
      cur_qp_state on return, add the missing sets.
      
      Fixes: d3749841 ("i40iw: add files for iwarp interface")
      Signed-off-by: default avatarChangcheng Liu <changcheng.liu@aliyun.com>
      Acked-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
      Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c70bfc1b
    • Christian Lamparter's avatar
      powerpc/4xx/uic: clear pending interrupt after irq type/pol change · 5bab3a0a
      Christian Lamparter authored
      [ Upstream commit 3ab3a068 ]
      
      When testing out gpio-keys with a button, a spurious
      interrupt (and therefore a key press or release event)
      gets triggered as soon as the driver enables the irq
      line for the first time.
      
      This patch clears any potential bogus generated interrupt
      that was caused by the switching of the associated irq's
      type and polarity.
      Signed-off-by: default avatarChristian Lamparter <chunkeey@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5bab3a0a
    • Johannes Berg's avatar
      um: Silence lockdep complaint about mmap_sem · 20756b70
      Johannes Berg authored
      [ Upstream commit 80bf6cea ]
      
      When we get into activate_mm(), lockdep complains that we're doing
      something strange:
      
          WARNING: possible circular locking dependency detected
          5.1.0-10252-gb00152307319-dirty #121 Not tainted
          ------------------------------------------------------
          inside.sh/366 is trying to acquire lock:
          (____ptrval____) (&(&p->alloc_lock)->rlock){+.+.}, at: flush_old_exec+0x703/0x8d7
      
          but task is already holding lock:
          (____ptrval____) (&mm->mmap_sem){++++}, at: flush_old_exec+0x6c5/0x8d7
      
          which lock already depends on the new lock.
      
          the existing dependency chain (in reverse order) is:
      
          -> #1 (&mm->mmap_sem){++++}:
                 [...]
                 __lock_acquire+0x12ab/0x139f
                 lock_acquire+0x155/0x18e
                 down_write+0x3f/0x98
                 flush_old_exec+0x748/0x8d7
                 load_elf_binary+0x2ca/0xddb
                 [...]
      
          -> #0 (&(&p->alloc_lock)->rlock){+.+.}:
                 [...]
                 __lock_acquire+0x12ab/0x139f
                 lock_acquire+0x155/0x18e
                 _raw_spin_lock+0x30/0x83
                 flush_old_exec+0x703/0x8d7
                 load_elf_binary+0x2ca/0xddb
                 [...]
      
          other info that might help us debug this:
      
           Possible unsafe locking scenario:
      
                 CPU0                    CPU1
                 ----                    ----
            lock(&mm->mmap_sem);
                                         lock(&(&p->alloc_lock)->rlock);
                                         lock(&mm->mmap_sem);
            lock(&(&p->alloc_lock)->rlock);
      
           *** DEADLOCK ***
      
          2 locks held by inside.sh/366:
           #0: (____ptrval____) (&sig->cred_guard_mutex){+.+.}, at: __do_execve_file+0x12d/0x869
           #1: (____ptrval____) (&mm->mmap_sem){++++}, at: flush_old_exec+0x6c5/0x8d7
      
          stack backtrace:
          CPU: 0 PID: 366 Comm: inside.sh Not tainted 5.1.0-10252-gb00152307319-dirty #121
          Stack:
           [...]
          Call Trace:
           [<600420de>] show_stack+0x13b/0x155
           [<6048906b>] dump_stack+0x2a/0x2c
           [<6009ae64>] print_circular_bug+0x332/0x343
           [<6009c5c6>] check_prev_add+0x669/0xdad
           [<600a06b4>] __lock_acquire+0x12ab/0x139f
           [<6009f3d0>] lock_acquire+0x155/0x18e
           [<604a07e0>] _raw_spin_lock+0x30/0x83
           [<60151e6a>] flush_old_exec+0x703/0x8d7
           [<601a8eb8>] load_elf_binary+0x2ca/0xddb
           [...]
      
      I think it's because in exec_mmap() we have
      
      	down_read(&old_mm->mmap_sem);
      ...
              task_lock(tsk);
      ...
      	activate_mm(active_mm, mm);
      	(which does down_write(&mm->mmap_sem))
      
      I'm not really sure why lockdep throws in the whole knowledge
      about the task lock, but it seems that old_mm and mm shouldn't
      ever be the same (and it doesn't deadlock) so tell lockdep that
      they're different.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      20756b70
    • Axel Lin's avatar
      mfd: hi655x-pmic: Fix missing return value check for devm_regmap_init_mmio_clk · f9690b8e
      Axel Lin authored
      [ Upstream commit 7efd105c ]
      
      Since devm_regmap_init_mmio_clk can fail, add return value checking.
      Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
      Acked-by: default avatarChen Feng <puck.chen@hisilicon.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f9690b8e
    • Arnd Bergmann's avatar
      mfd: arizona: Fix undefined behavior · a3727b0a
      Arnd Bergmann authored
      [ Upstream commit 5da6cbcd ]
      
      When the driver is used with a subdevice that is disabled in the
      kernel configuration, clang gets a little confused about the
      control flow and fails to notice that n_subdevs is only
      uninitialized when subdevs is NULL, and we check for that,
      leading to a false-positive warning:
      
      drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here
            [-Werror,-Wuninitialized]
                                    subdevs, n_subdevs, NULL, 0, NULL);
                                             ^~~~~~~~~
      drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning
              int n_subdevs, ret, i;
                           ^
                            = 0
      
      Ideally, we would rearrange the code to avoid all those early
      initializations and have an explicit exit in each disabled case,
      but it's much easier to chicken out and add one more initialization
      here to shut up the warning.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a3727b0a
    • Robert Hancock's avatar
      mfd: core: Set fwnode for created devices · f1405059
      Robert Hancock authored
      [ Upstream commit c176c6d7 ]
      
      The logic for setting the of_node on devices created by mfd did not set
      the fwnode pointer to match, which caused fwnode-based APIs to
      malfunction on these devices since the fwnode pointer was null. Fix
      this.
      Signed-off-by: default avatarRobert Hancock <hancock@sedsystems.ca>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f1405059
    • Naveen N. Rao's avatar
      recordmcount: Fix spurious mcount entries on powerpc · 253278f2
      Naveen N. Rao authored
      [ Upstream commit 80e5302e ]
      
      An impending change to enable HAVE_C_RECORDMCOUNT on powerpc leads to
      warnings such as the following:
      
        # modprobe kprobe_example
        ftrace-powerpc: Not expected bl: opcode is 3c4c0001
        WARNING: CPU: 0 PID: 227 at kernel/trace/ftrace.c:2001 ftrace_bug+0x90/0x318
        Modules linked in:
        CPU: 0 PID: 227 Comm: modprobe Not tainted 5.2.0-rc6-00678-g1c329100b942 #2
        NIP:  c000000000264318 LR: c00000000025d694 CTR: c000000000f5cd30
        REGS: c000000001f2b7b0 TRAP: 0700   Not tainted  (5.2.0-rc6-00678-g1c329100b942)
        MSR:  900000010282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]>  CR: 28228222  XER: 00000000
        CFAR: c0000000002642fc IRQMASK: 0
        <snip>
        NIP [c000000000264318] ftrace_bug+0x90/0x318
        LR [c00000000025d694] ftrace_process_locs+0x4f4/0x5e0
        Call Trace:
        [c000000001f2ba40] [0000000000000004] 0x4 (unreliable)
        [c000000001f2bad0] [c00000000025d694] ftrace_process_locs+0x4f4/0x5e0
        [c000000001f2bb90] [c00000000020ff10] load_module+0x25b0/0x30c0
        [c000000001f2bd00] [c000000000210cb0] sys_finit_module+0xc0/0x130
        [c000000001f2be20] [c00000000000bda4] system_call+0x5c/0x70
        Instruction dump:
        419e0018 2f83ffff 419e00bc 2f83ffea 409e00cc 4800001c 0fe00000 3c62ff96
        39000001 39400000 386386d0 480000c4 <0fe00000> 3ce20003 39000001 3c62ff96
        ---[ end trace 4c438d5cebf78381 ]---
        ftrace failed to modify
        [<c0080000012a0008>] 0xc0080000012a0008
         actual:   01:00:4c:3c
        Initializing ftrace call sites
        ftrace record flags: 2000000
         (0)
         expected tramp: c00000000006af4c
      
      Looking at the relocation records in __mcount_loc shows a few spurious
      entries:
      
        RELOCATION RECORDS FOR [__mcount_loc]:
        OFFSET           TYPE              VALUE
        0000000000000000 R_PPC64_ADDR64    .text.unlikely+0x0000000000000008
        0000000000000008 R_PPC64_ADDR64    .text.unlikely+0x0000000000000014
        0000000000000010 R_PPC64_ADDR64    .text.unlikely+0x0000000000000060
        0000000000000018 R_PPC64_ADDR64    .text.unlikely+0x00000000000000b4
        0000000000000020 R_PPC64_ADDR64    .init.text+0x0000000000000008
        0000000000000028 R_PPC64_ADDR64    .init.text+0x0000000000000014
      
      The first entry in each section is incorrect. Looking at the
      relocation records, the spurious entries correspond to the
      R_PPC64_ENTRY records:
      
        RELOCATION RECORDS FOR [.text.unlikely]:
        OFFSET           TYPE              VALUE
        0000000000000000 R_PPC64_REL64     .TOC.-0x0000000000000008
        0000000000000008 R_PPC64_ENTRY     *ABS*
        0000000000000014 R_PPC64_REL24     _mcount
        <snip>
      
      The problem is that we are not validating the return value from
      get_mcountsym() in sift_rel_mcount(). With this entry, mcountsym is 0,
      but Elf_r_sym(relp) also ends up being 0. Fix this by ensuring
      mcountsym is valid before processing the entry.
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Tested-by: default avatarSatheesh Rajendran <sathnaga@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      253278f2
    • Bastien Nocera's avatar
      iio: iio-utils: Fix possible incorrect mask calculation · e2482f76
      Bastien Nocera authored
      [ Upstream commit 208a68c8 ]
      
      On some machines, iio-sensor-proxy was returning all 0's for IIO sensor
      values. It turns out that the bits_used for this sensor is 32, which makes
      the mask calculation:
      
      *mask = (1 << 32) - 1;
      
      If the compiler interprets the 1 literals as 32-bit ints, it generates
      undefined behavior depending on compiler version and optimization level.
      On my system, it optimizes out the shift, so the mask value becomes
      
      *mask = (1) - 1;
      
      With a mask value of 0, iio-sensor-proxy will always return 0 for every axis.
      
      Avoid incorrect 0 values caused by compiler optimization.
      
      See original fix by Brett Dutro <brett.dutro@gmail.com> in
      iio-sensor-proxy:
      https://github.com/hadess/iio-sensor-proxy/commit/9615ceac7c134d838660e209726cd86aa2064fd3Signed-off-by: default avatarBastien Nocera <hadess@hadess.net>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e2482f76
    • Bharat Kumar Gogada's avatar
      PCI: xilinx-nwl: Fix Multi MSI data programming · 5086e479
      Bharat Kumar Gogada authored
      [ Upstream commit 181fa434 ]
      
      According to the PCI Local Bus specification Revision 3.0,
      section 6.8.1.3 (Message Control for MSI), endpoints that
      are Multiple Message Capable as defined by bits [3:1] in
      the Message Control for MSI can request a number of vectors
      that is power of two aligned.
      
      As specified in section 6.8.1.6 "Message data for MSI", the Multiple
      Message Enable field (bits [6:4] of the Message Control register)
      defines the number of low order message data bits the function is
      permitted to modify to generate its system software allocated
      vectors.
      
      The MSI controller in the Xilinx NWL PCIe controller supports a number
      of MSI vectors specified through a bitmap and the hwirq number for an
      MSI, that is the value written in the MSI data TLP is determined by
      the bitmap allocation.
      
      For instance, in a situation where two endpoints sitting on
      the PCI bus request the following MSI configuration, with
      the current PCI Xilinx bitmap allocation code (that does not
      align MSI vector allocation on a power of two boundary):
      
      Endpoint #1: Requesting 1 MSI vector - allocated bitmap bits 0
      Endpoint #2: Requesting 2 MSI vectors - allocated bitmap bits [1,2]
      
      The bitmap value(s) corresponds to the hwirq number that is programmed
      into the Message Data for MSI field in the endpoint MSI capability
      and is detected by the root complex to fire the corresponding
      MSI irqs. The value written in Message Data for MSI field corresponds
      to the first bit allocated in the bitmap for Multi MSI vectors.
      
      The current Xilinx NWL MSI allocation code allows a bitmap allocation
      that is not a power of two boundaries, so endpoint #2, is allowed to
      toggle Message Data bit[0] to differentiate between its two vectors
      (meaning that the MSI data will be respectively 0x0 and 0x1 for the two
      vectors allocated to endpoint #2).
      
      This clearly aliases with the Endpoint #1 vector allocation, resulting
      in a broken Multi MSI implementation.
      
      Update the code to allocate MSI bitmap ranges with a power of two
      alignment, fixing the bug.
      
      Fixes: ab597d35 ("PCI: xilinx-nwl: Add support for Xilinx NWL PCIe Host Controller")
      Suggested-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarBharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>
      [lorenzo.pieralisi@arm.com: updated commit log]
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5086e479
    • Nathan Chancellor's avatar
      kbuild: Add -Werror=unknown-warning-option to CLANG_FLAGS · 7caebf6d
      Nathan Chancellor authored
      [ Upstream commit 589834b3 ]
      
      In commit ebcc5928 ("arm64: Silence gcc warnings about arch ABI
      drift"), the arm64 Makefile added -Wno-psabi to KBUILD_CFLAGS, which is
      a GCC only option so clang rightfully complains:
      
      warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
      
      https://clang.llvm.org/docs/DiagnosticsReference.html#wunknown-warning-option
      
      However, by default, this is merely a warning so the build happily goes
      on with a slew of these warnings in the process.
      
      Commit c3f0d0bc ("kbuild, LLVMLinux: Add -Werror to cc-option to
      support clang") worked around this behavior in cc-option by adding
      -Werror so that unknown flags cause an error. However, this all happens
      silently and when an unknown flag is added to the build unconditionally
      like -Wno-psabi, cc-option will always fail because there is always an
      unknown flag in the list of flags. This manifested as link time failures
      in the arm64 libstub because -fno-stack-protector didn't get added to
      KBUILD_CFLAGS.
      
      To avoid these weird cryptic failures in the future, make clang behave
      like gcc and immediately error when it encounters an unknown flag by
      adding -Werror=unknown-warning-option to CLANG_FLAGS. This can be added
      unconditionally for clang because it is supported by at least 3.0.0,
      according to godbolt [1] and 4.0.0, according to its documentation [2],
      which is far earlier than we typically support.
      
      [1]: https://godbolt.org/z/7F7rm3
      [2]: https://releases.llvm.org/4.0.0/tools/clang/docs/DiagnosticsReference.html#wunknown-warning-option
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/511
      Link: https://github.com/ClangBuiltLinux/linux/issues/517Suggested-by: default avatarPeter Smith <peter.smith@linaro.org>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7caebf6d
    • Marek Vasut's avatar
      PCI: sysfs: Ignore lockdep for remove attribute · 2abc45ec
      Marek Vasut authored
      [ Upstream commit dc6b698a ]
      
      With CONFIG_PROVE_LOCKING=y, using sysfs to remove a bridge with a device
      below it causes a lockdep warning, e.g.,
      
        # echo 1 > /sys/class/pci_bus/0000:00/device/0000:00:00.0/remove
        ============================================
        WARNING: possible recursive locking detected
        ...
        pci_bus 0000:01: busn_res: [bus 01] is released
      
      The remove recursively removes the subtree below the bridge.  Each call
      uses a different lock so there's no deadlock, but the locks were all
      created with the same lockdep key so the lockdep checker can't tell them
      apart.
      
      Mark the "remove" sysfs attribute with __ATTR_IGNORE_LOCKDEP() as it is
      safe to ignore the lockdep check between different "remove" kernfs
      instances.
      
      There's discussion about a similar issue in USB at [1], which resulted in
      356c05d5 ("sysfs: get rid of some lockdep false positives") and
      e9b526fe ("i2c: suppress lockdep warning on delete_device"), which do
      basically the same thing for USB "remove" and i2c "delete_device" files.
      
      [1] https://lore.kernel.org/r/Pine.LNX.4.44L0.1204251436140.1206-100000@iolanthe.rowland.org
      Link: https://lore.kernel.org/r/20190526225151.3865-1-marek.vasut@gmail.comSigned-off-by: default avatarMarek Vasut <marek.vasut+renesas@gmail.com>
      [bhelgaas: trim commit log, details at above links]
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Cc: Phil Edworthy <phil.edworthy@renesas.com>
      Cc: Simon Horman <horms+renesas@verge.net.au>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Wolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2abc45ec
    • Alexey Kardashevskiy's avatar
      powerpc/pci/of: Fix OF flags parsing for 64bit BARs · 514670ac
      Alexey Kardashevskiy authored
      [ Upstream commit df5be5be ]
      
      When the firmware does PCI BAR resource allocation, it passes the assigned
      addresses and flags (prefetch/64bit/...) via the "reg" property of
      a PCI device device tree node so the kernel does not need to do
      resource allocation.
      
      The flags are stored in resource::flags - the lower byte stores
      PCI_BASE_ADDRESS_SPACE/etc bits and the other bytes are IORESOURCE_IO/etc.
      Some flags from PCI_BASE_ADDRESS_xxx and IORESOURCE_xxx are duplicated,
      such as PCI_BASE_ADDRESS_MEM_PREFETCH/PCI_BASE_ADDRESS_MEM_TYPE_64/etc.
      When parsing the "reg" property, we copy the prefetch flag but we skip
      on PCI_BASE_ADDRESS_MEM_TYPE_64 which leaves the flags out of sync.
      
      The missing IORESOURCE_MEM_64 flag comes into play under 2 conditions:
      1. we remove PCI_PROBE_ONLY for pseries (by hacking pSeries_setup_arch()
      or by passing "/chosen/linux,pci-probe-only");
      2. we request resource alignment (by passing pci=resource_alignment=
      via the kernel cmd line to request PAGE_SIZE alignment or defining
      ppc_md.pcibios_default_alignment which returns anything but 0). Note that
      the alignment requests are ignored if PCI_PROBE_ONLY is enabled.
      
      With 1) and 2), the generic PCI code in the kernel unconditionally
      decides to:
      - reassign the BARs in pci_specified_resource_alignment() (works fine)
      - write new BARs to the device - this fails for 64bit BARs as the generic
      code looks at IORESOURCE_MEM_64 (not set) and writes only lower 32bits
      of the BAR and leaves the upper 32bit unmodified which breaks BAR mapping
      in the hypervisor.
      
      This fixes the issue by copying the flag. This is useful if we want to
      enforce certain BAR alignment per platform as handling subpage sized BARs
      is proven to cause problems with hotplug (SLOF already aligns BARs to 64k).
      Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: default avatarSam Bobroff <sbobroff@linux.ibm.com>
      Reviewed-by: default avatarOliver O'Halloran <oohall@gmail.com>
      Reviewed-by: default avatarShawn Anastasio <shawn@anastas.io>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      514670ac
    • Andrzej Pietrasiewicz's avatar
      usb: gadget: Zero ffs_io_data · d585589e
      Andrzej Pietrasiewicz authored
      [ Upstream commit 50859551 ]
      
      In some cases the "Allocate & copy" block in ffs_epfile_io() is not
      executed. Consequently, in such a case ffs_alloc_buffer() is never called
      and struct ffs_io_data is not initialized properly. This in turn leads to
      problems when ffs_free_buffer() is called at the end of ffs_epfile_io().
      
      This patch uses kzalloc() instead of kmalloc() in the aio case and memset()
      in non-aio case to properly initialize struct ffs_io_data.
      Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@collabora.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d585589e
    • Serge Semin's avatar
      tty: serial_core: Set port active bit in uart_port_activate · 47807595
      Serge Semin authored
      [ Upstream commit 13b18d35 ]
      
      A bug was introduced by commit b3b57646 ("tty: serial_core: convert
      uart_open to use tty_port_open"). It caused a constant warning printed
      into the system log regarding the tty and port counter mismatch:
      
      [   21.644197] ttyS ttySx: tty_port_close_start: tty->count = 1 port count = 2
      
      in case if session hangup was detected so the warning is printed starting
      from the second open-close iteration.
      
      Particularly the problem was discovered in situation when there is a
      serial tty device without hardware back-end being setup. It is considered
      by the tty-serial subsystems as a hardware problem with session hang up.
      In this case uart_startup() will return a positive value with TTY_IO_ERROR
      flag set in corresponding tty_struct instance. The same value will get
      passed to be returned from the activate() callback and then being returned
      from tty_port_open(). But since in this case tty_port_block_til_ready()
      isn't called the TTY_PORT_ACTIVE flag isn't set (while the method had been
      called before tty_port_open conversion was introduced and the rest of the
      subsystem code expected the bit being set in this case), which prevents the
      uart_hangup() method to perform any cleanups including the tty port
      counter setting to zero. So the next attempt to open/close the tty device
      will discover the counters mismatch.
      
      In order to fix the problem we need to manually set the TTY_PORT_ACTIVE
      flag in case if uart_startup() returned a positive value. In this case
      the hang up procedure will perform a full set of cleanup actions including
      the port ref-counter resetting.
      
      Fixes: b3b57646 "tty: serial_core: convert uart_open to use tty_port_open"
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      47807595
    • Douglas Anderson's avatar
      drm/rockchip: Properly adjust to a true clock in adjusted_mode · 1d133532
      Douglas Anderson authored
      [ Upstream commit 99b9683f ]
      
      When fixing up the clock in vop_crtc_mode_fixup() we're not doing it
      quite correctly.  Specifically if we've got the true clock 266666667 Hz,
      we'll perform this calculation:
         266666667 / 1000 => 266666
      
      Later when we try to set the clock we'll do clk_set_rate(266666 *
      1000).  The common clock framework won't actually pick the proper clock
      in this case since it always wants clocks <= the specified one.
      
      Let's solve this by using DIV_ROUND_UP.
      
      Fixes: b59b8de3 ("drm/rockchip: return a true clock rate to adjusted_mode")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
      Reviewed-by: default avatarYakir Yang <ykk@rock-chips.com>
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190614224730.98622-1-dianders@chromium.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      1d133532
    • Yoshihiro Shimoda's avatar
      phy: renesas: rcar-gen2: Fix memory leak at error paths · 67ac0ef9
      Yoshihiro Shimoda authored
      [ Upstream commit d4a36e82 ]
      
      This patch fixes memory leak at error paths of the probe function.
      In for_each_child_of_node, if the loop returns, the driver should
      call of_put_node() before returns.
      Reported-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
      Fixes: 1233f59f ("phy: Renesas R-Car Gen2 PHY driver")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      67ac0ef9
    • David Riley's avatar
      drm/virtio: Add memory barriers for capset cache. · 34db79ae
      David Riley authored
      [ Upstream commit 9ff3a5c8 ]
      
      After data is copied to the cache entry, atomic_set is used indicate
      that the data is the entry is valid without appropriate memory barriers.
      Similarly the read side was missing the corresponding memory barriers.
      Signed-off-by: default avatarDavid Riley <davidriley@chromium.org>
      Link: http://patchwork.freedesktop.org/patch/msgid/20190610211810.253227-5-davidriley@chromium.orgSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34db79ae
    • Rautkoski Kimmo EXT's avatar
      serial: 8250: Fix TX interrupt handling condition · bd36de4d
      Rautkoski Kimmo EXT authored
      [ Upstream commit db1b5bc0 ]
      
      Interrupt handler checked THRE bit (transmitter holding register
      empty) in LSR to detect if TX fifo is empty.
      In case when there is only receive interrupts the TX handling
      got called because THRE bit in LSR is set when there is no
      transmission (FIFO empty). TX handling caused TX stop, which in
      RS-485 half-duplex mode actually resets receiver FIFO. This is not
      desired during reception because of possible data loss.
      
      The fix is to check if THRI is set in IER in addition of the TX
      fifo status. THRI in IER is set when TX is started and cleared
      when TX is stopped.
      This ensures that TX handling is only called when there is really
      transmission on going and an interrupt for THRE and not when there
      are only RX interrupts.
      Signed-off-by: default avatarKimmo Rautkoski <ext-kimmo.rautkoski@vaisala.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd36de4d
    • Jorge Ramirez-Ortiz's avatar
      tty: serial: msm_serial: avoid system lockup condition · 20258b32
      Jorge Ramirez-Ortiz authored
      [ Upstream commit ba3684f9 ]
      
      The function msm_wait_for_xmitr can be taken with interrupts
      disabled. In order to avoid a potential system lockup - demonstrated
      under stress testing conditions on SoC QCS404/5 - make sure we wait
      for a bounded amount of time.
      
      Tested on SoC QCS404.
      Signed-off-by: default avatarJorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      20258b32