1. 16 Aug, 2019 26 commits
    • Suzuki K Poulose's avatar
      usb: yurex: Fix use-after-free in yurex_delete · 33f2240a
      Suzuki K Poulose authored
      commit fc05481b upstream.
      
      syzbot reported the following crash [0]:
      
      BUG: KASAN: use-after-free in usb_free_coherent+0x79/0x80
      drivers/usb/core/usb.c:928
      Read of size 8 at addr ffff8881b18599c8 by task syz-executor.4/16007
      
      CPU: 0 PID: 16007 Comm: syz-executor.4 Not tainted 5.3.0-rc2+ #23
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      Call Trace:
        __dump_stack lib/dump_stack.c:77 [inline]
        dump_stack+0xca/0x13e lib/dump_stack.c:113
        print_address_description+0x6a/0x32c mm/kasan/report.c:351
        __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
        kasan_report+0xe/0x12 mm/kasan/common.c:612
        usb_free_coherent+0x79/0x80 drivers/usb/core/usb.c:928
        yurex_delete+0x138/0x330 drivers/usb/misc/yurex.c:100
        kref_put include/linux/kref.h:65 [inline]
        yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
        __fput+0x2d7/0x840 fs/file_table.c:280
        task_work_run+0x13f/0x1c0 kernel/task_work.c:113
        tracehook_notify_resume include/linux/tracehook.h:188 [inline]
        exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163
        prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
        syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
        do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x413511
      Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48
      83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48
      89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
      RSP: 002b:00007ffc424ea2e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
      RAX: 0000000000000000 RBX: 0000000000000007 RCX: 0000000000413511
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006
      RBP: 0000000000000001 R08: 0000000029a2fc22 R09: 0000000029a2fc26
      R10: 00007ffc424ea3c0 R11: 0000000000000293 R12: 000000000075c9a0
      R13: 000000000075c9a0 R14: 0000000000761938 R15: ffffffffffffffff
      
      Allocated by task 2776:
        save_stack+0x1b/0x80 mm/kasan/common.c:69
        set_track mm/kasan/common.c:77 [inline]
        __kasan_kmalloc mm/kasan/common.c:487 [inline]
        __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:460
        kmalloc include/linux/slab.h:552 [inline]
        kzalloc include/linux/slab.h:748 [inline]
        usb_alloc_dev+0x51/0xf95 drivers/usb/core/usb.c:583
        hub_port_connect drivers/usb/core/hub.c:5004 [inline]
        hub_port_connect_change drivers/usb/core/hub.c:5213 [inline]
        port_event drivers/usb/core/hub.c:5359 [inline]
        hub_event+0x15c0/0x3640 drivers/usb/core/hub.c:5441
        process_one_work+0x92b/0x1530 kernel/workqueue.c:2269
        worker_thread+0x96/0xe20 kernel/workqueue.c:2415
        kthread+0x318/0x420 kernel/kthread.c:255
        ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
      
      Freed by task 16007:
        save_stack+0x1b/0x80 mm/kasan/common.c:69
        set_track mm/kasan/common.c:77 [inline]
        __kasan_slab_free+0x130/0x180 mm/kasan/common.c:449
        slab_free_hook mm/slub.c:1423 [inline]
        slab_free_freelist_hook mm/slub.c:1470 [inline]
        slab_free mm/slub.c:3012 [inline]
        kfree+0xe4/0x2f0 mm/slub.c:3953
        device_release+0x71/0x200 drivers/base/core.c:1064
        kobject_cleanup lib/kobject.c:693 [inline]
        kobject_release lib/kobject.c:722 [inline]
        kref_put include/linux/kref.h:65 [inline]
        kobject_put+0x171/0x280 lib/kobject.c:739
        put_device+0x1b/0x30 drivers/base/core.c:2213
        usb_put_dev+0x1f/0x30 drivers/usb/core/usb.c:725
        yurex_delete+0x40/0x330 drivers/usb/misc/yurex.c:95
        kref_put include/linux/kref.h:65 [inline]
        yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
        __fput+0x2d7/0x840 fs/file_table.c:280
        task_work_run+0x13f/0x1c0 kernel/task_work.c:113
        tracehook_notify_resume include/linux/tracehook.h:188 [inline]
        exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163
        prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
        syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
        do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      The buggy address belongs to the object at ffff8881b1859980
        which belongs to the cache kmalloc-2k of size 2048
      The buggy address is located 72 bytes inside of
        2048-byte region [ffff8881b1859980, ffff8881b185a180)
      The buggy address belongs to the page:
      page:ffffea0006c61600 refcount:1 mapcount:0 mapping:ffff8881da00c000
      index:0x0 compound_mapcount: 0
      flags: 0x200000000010200(slab|head)
      raw: 0200000000010200 0000000000000000 0000000100000001 ffff8881da00c000
      raw: 0000000000000000 00000000000f000f 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
        ffff8881b1859880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
        ffff8881b1859900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      > ffff8881b1859980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                     ^
        ffff8881b1859a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        ffff8881b1859a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ==================================================================
      
      A quick look at the yurex_delete() shows that we drop the reference
      to the usb_device before releasing any buffers associated with the
      device. Delay the reference drop until we have finished the cleanup.
      
      [0] https://lore.kernel.org/lkml/0000000000003f86d8058f0bd671@google.com/
      
      Fixes: 6bc235a2 ("USB: add driver for Meywa-Denki & Kayac YUREX")
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
      Cc: Oliver Neukum <oneukum@suse.com>
      Cc: andreyknvl@google.com
      Cc: gregkh@linuxfoundation.org
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: syzkaller-bugs@googlegroups.com
      Cc: dtor@chromium.org
      Reported-by: syzbot+d1fedb1c1fdb07fca507@syzkaller.appspotmail.com
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190805111528.6758-1-suzuki.poulose@arm.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33f2240a
    • Yoshihiro Shimoda's avatar
      usb: host: xhci-rcar: Fix timeout in xhci_suspend() · 49888a4f
      Yoshihiro Shimoda authored
      commit 783bda5e upstream.
      
      When a USB device is connected to the host controller and
      the system enters suspend, the following error happens
      in xhci_suspend():
      
      	xhci-hcd ee000000.usb: WARN: xHC CMD_RUN timeout
      
      Since the firmware/internal CPU control the USBSTS.STS_HALT
      and the process speed is down when the roothub port enters U3,
      long delay for the handshake of STS_HALT is neeed in xhci_suspend().
      So, this patch adds to set the XHCI_SLOW_SUSPEND.
      
      Fixes: 435cc113 ("usb: host: xhci-plat: set resume_quirk() for R-Car controllers")
      Cc: <stable@vger.kernel.org> # v4.12+
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Link: https://lore.kernel.org/r/1564734815-17964-1-git-send-email-yoshihiro.shimoda.uh@renesas.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49888a4f
    • Andreas Gruenbacher's avatar
      gfs2: gfs2_walk_metadata fix · 21344f05
      Andreas Gruenbacher authored
      commit a27a0c9b upstream.
      
      It turns out that the current version of gfs2_metadata_walker suffers
      from multiple problems that can cause gfs2_hole_size to report an
      incorrect size.  This will confuse fiemap as well as lseek with the
      SEEK_DATA flag.
      
      Fix that by changing gfs2_hole_walker to compute the metapath to the
      first data block after the hole (if any), and compute the hole size
      based on that.
      
      Fixes xfstest generic/490.
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
      Cc: stable@vger.kernel.org # v4.18+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21344f05
    • Nick Desaulniers's avatar
      x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS · b674f791
      Nick Desaulniers authored
      commit b059f801 upstream.
      
      KBUILD_CFLAGS is very carefully built up in the top level Makefile,
      particularly when cross compiling or using different build tools.
      Resetting KBUILD_CFLAGS via := assignment is an antipattern.
      
      The comment above the reset mentions that -pg is problematic.  Other
      Makefiles use `CFLAGS_REMOVE_file.o = $(CC_FLAGS_FTRACE)` when
      CONFIG_FUNCTION_TRACER is set. Prefer that pattern to wiping out all of
      the important KBUILD_CFLAGS then manually having to re-add them. Seems
      also that __stack_chk_fail references are generated when using
      CONFIG_STACKPROTECTOR or CONFIG_STACKPROTECTOR_STRONG.
      
      Fixes: 8fc5b4d4 ("purgatory: core purgatory functionality")
      Reported-by: default avatarVaibhav Rustagi <vaibhavrustagi@google.com>
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarVaibhav Rustagi <vaibhavrustagi@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190807221539.94583-2-ndesaulniers@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b674f791
    • Thomas Richter's avatar
      perf record: Fix module size on s390 · 0a9e41e2
      Thomas Richter authored
      commit 12a6d294 upstream.
      
      On s390 the modules loaded in memory have the text segment located after
      the GOT and Relocation table. This can be seen with this output:
      
        [root@m35lp76 perf]# fgrep qeth /proc/modules
        qeth 151552 1 qeth_l2, Live 0x000003ff800b2000
        ...
        [root@m35lp76 perf]# cat /sys/module/qeth/sections/.text
        0x000003ff800b3990
        [root@m35lp76 perf]#
      
      There is an offset of 0x1990 bytes. The size of the qeth module is
      151552 bytes (0x25000 in hex).
      
      The location of the GOT/relocation table at the beginning of a module is
      unique to s390.
      
      commit 203d8a4a ("perf s390: Fix 'start' address of module's map")
      adjusts the start address of a module in the map structures, but does
      not adjust the size of the modules. This leads to overlapping of module
      maps as this example shows:
      
      [root@m35lp76 perf] # ./perf report -D
           0 0 0xfb0 [0xa0]: PERF_RECORD_MMAP -1/0: [0x3ff800b3990(0x25000)
                @ 0]:  x /lib/modules/.../qeth.ko.xz
           0 0 0x1050 [0xb0]: PERF_RECORD_MMAP -1/0: [0x3ff800d85a0(0x8000)
                @ 0]:  x /lib/modules/.../ip6_tables.ko.xz
      
      The module qeth.ko has an adjusted start address modified to b3990, but
      its size is unchanged and the module ends at 0x3ff800d8990.  This end
      address overlaps with the next modules start address of 0x3ff800d85a0.
      
      When the size of the leading GOT/Relocation table stored in the
      beginning of the text segment (0x1990 bytes) is subtracted from module
      qeth end address, there are no overlaps anymore:
      
         0x3ff800d8990 - 0x1990 = 0x0x3ff800d7000
      
      which is the same as
      
         0x3ff800b2000 + 0x25000 = 0x0x3ff800d7000.
      
      To fix this issue, also adjust the modules size in function
      arch__fix_module_text_start(). Add another function parameter named size
      and reduce the size of the module when the text segment start address is
      changed.
      
      Output after:
           0 0 0xfb0 [0xa0]: PERF_RECORD_MMAP -1/0: [0x3ff800b3990(0x23670)
                @ 0]:  x /lib/modules/.../qeth.ko.xz
           0 0 0x1050 [0xb0]: PERF_RECORD_MMAP -1/0: [0x3ff800d85a0(0x7a60)
                @ 0]:  x /lib/modules/.../ip6_tables.ko.xz
      Reported-by: default avatarStefan Liebler <stli@linux.ibm.com>
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: stable@vger.kernel.org
      Fixes: 203d8a4a ("perf s390: Fix 'start' address of module's map")
      Link: http://lkml.kernel.org/r/20190724122703.3996-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a9e41e2
    • Adrian Hunter's avatar
      perf db-export: Fix thread__exec_comm() · f1f66289
      Adrian Hunter authored
      commit 3de7ae0b upstream.
      
      Threads synthesized from /proc have comms with a start time of zero, and
      not marked as "exec". Currently, there can be 2 such comms. The first is
      created by processing a synthesized fork event and is set to the
      parent's comm string, and the second by processing a synthesized comm
      event set to the thread's current comm string.
      
      In the absence of an "exec" comm, thread__exec_comm() picks the last
      (oldest) comm, which, in the case above, is the parent's comm string.
      For a main thread, that is very probably wrong. Use the second-to-last
      in that case.
      
      This affects only db-export because it is the only user of
      thread__exec_comm().
      
      Example:
      
        $ sudo perf record -a -o pt-a-sleep-1 -e intel_pt//u -- sleep 1
        $ sudo chown ahunter pt-a-sleep-1
      
      Before:
      
        $ perf script -i pt-a-sleep-1 --itrace=bep -s tools/perf/scripts/python/export-to-sqlite.py pt-a-sleep-1.db branches calls
        $ sqlite3 -header -column pt-a-sleep-1.db 'select * from comm_threads_view'
        comm_id     command     thread_id   pid         tid
        ----------  ----------  ----------  ----------  ----------
        1           swapper     1           0           0
        2           rcu_sched   2           10          10
        3           kthreadd    3           78          78
        5           sudo        4           15180       15180
        5           sudo        5           15180       15182
        7           kworker/4:  6           10335       10335
        8           kthreadd    7           55          55
        10          systemd     8           865         865
        10          systemd     9           865         875
        13          perf        10          15181       15181
        15          sleep       10          15181       15181
        16          kworker/3:  11          14179       14179
        17          kthreadd    12          29376       29376
        19          systemd     13          746         746
        21          systemd     14          401         401
        23          systemd     15          879         879
        23          systemd     16          879         945
        25          kthreadd    17          556         556
        27          kworker/u1  18          14136       14136
        28          kworker/u1  19          15021       15021
        29          kthreadd    20          509         509
        31          systemd     21          836         836
        31          systemd     22          836         967
        33          systemd     23          1148        1148
        33          systemd     24          1148        1163
        35          kworker/2:  25          17988       17988
        36          kworker/0:  26          13478       13478
      
      After:
      
        $ perf script -i pt-a-sleep-1 --itrace=bep -s tools/perf/scripts/python/export-to-sqlite.py pt-a-sleep-1b.db branches calls
        $ sqlite3 -header -column pt-a-sleep-1b.db 'select * from comm_threads_view'
        comm_id     command     thread_id   pid         tid
        ----------  ----------  ----------  ----------  ----------
        1           swapper     1           0           0
        2           rcu_sched   2           10          10
        3           kswapd0     3           78          78
        4           perf        4           15180       15180
        4           perf        5           15180       15182
        6           kworker/4:  6           10335       10335
        7           kcompactd0  7           55          55
        8           accounts-d  8           865         865
        8           accounts-d  9           865         875
        10          perf        10          15181       15181
        12          sleep       10          15181       15181
        13          kworker/3:  11          14179       14179
        14          kworker/1:  12          29376       29376
        15          haveged     13          746         746
        16          systemd-jo  14          401         401
        17          NetworkMan  15          879         879
        17          NetworkMan  16          879         945
        19          irq/131-iw  17          556         556
        20          kworker/u1  18          14136       14136
        21          kworker/u1  19          15021       15021
        22          kworker/u1  20          509         509
        23          thermald    21          836         836
        23          thermald    22          836         967
        25          unity-sett  23          1148        1148
        25          unity-sett  24          1148        1163
        27          kworker/2:  25          17988       17988
        28          kworker/0:  26          13478       13478
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: 65de51f9 ("perf tools: Identify which comms are from exec")
      Link: http://lkml.kernel.org/r/20190808064823.14846-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1f66289
    • Thomas Richter's avatar
      perf annotate: Fix s390 gap between kernel end and module start · 532db2b9
      Thomas Richter authored
      commit b9c0a649 upstream.
      
      During execution of command 'perf top' the error message:
      
         Not enough memory for annotating '__irf_end' symbol!)
      
      is emitted from this call sequence:
        __cmd_top
          perf_top__mmap_read
            perf_top__mmap_read_idx
              perf_event__process_sample
                hist_entry_iter__add
                  hist_iter__top_callback
                    perf_top__record_precise_ip
                      hist_entry__inc_addr_samples
                        symbol__inc_addr_samples
                          symbol__get_annotation
                            symbol__alloc_hist
      
      In this function the size of symbol __irf_end is calculated. The size of
      a symbol is the difference between its start and end address.
      
      When the symbol was read the first time, its start and end was set to:
      
         symbol__new: __irf_end 0xe954d0-0xe954d0
      
      which is correct and maps with /proc/kallsyms:
      
         root@s8360046:~/linux-4.15.0/tools/perf# fgrep _irf_end /proc/kallsyms
         0000000000e954d0 t __irf_end
         root@s8360046:~/linux-4.15.0/tools/perf#
      
      In function symbol__alloc_hist() the end of symbol __irf_end is
      
        symbol__alloc_hist sym:__irf_end start:0xe954d0 end:0x3ff80045a8
      
      which is identical with the first module entry in /proc/kallsyms
      
      This results in a symbol size of __irf_req for histogram analyses of
      70334140059072 bytes and a malloc() for this requested size fails.
      
      The root cause of this is function
        __dso__load_kallsyms()
        +-> symbols__fixup_end()
      
      Function symbols__fixup_end() enlarges the last symbol in the kallsyms
      map:
      
         # fgrep __irf_end /proc/kallsyms
         0000000000e954d0 t __irf_end
         #
      
      to the start address of the first module:
         # cat /proc/kallsyms | sort  | egrep ' [tT] '
         ....
         0000000000e952d0 T __security_initcall_end
         0000000000e954d0 T __initramfs_size
         0000000000e954d0 t __irf_end
         000003ff800045a8 T fc_get_event_number       [scsi_transport_fc]
         000003ff800045d0 t store_fc_vport_disable    [scsi_transport_fc]
         000003ff800046a8 T scsi_is_fc_rport  [scsi_transport_fc]
         000003ff800046d0 t fc_target_setup   [scsi_transport_fc]
      
      On s390 the kernel is located around memory address 0x200, 0x10000 or
      0x100000, depending on linux version. Modules however start some- where
      around 0x3ff xxxx xxxx.
      
      This is different than x86 and produces a large gap for which histogram
      allocation fails.
      
      Fix this by detecting the kernel's last symbol and do no adjustment for
      it. Introduce a weak function and handle s390 specifics.
      Reported-by: default avatarKlaus Theurich <klaus.theurich@de.ibm.com>
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190724122703.3996-2-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      532db2b9
    • Joerg Roedel's avatar
      mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy() · 46b306f3
      Joerg Roedel authored
      commit 3f8fd02b upstream.
      
      On x86-32 with PTI enabled, parts of the kernel page-tables are not shared
      between processes. This can cause mappings in the vmalloc/ioremap area to
      persist in some page-tables after the region is unmapped and released.
      
      When the region is re-used the processes with the old mappings do not fault
      in the new mappings but still access the old ones.
      
      This causes undefined behavior, in reality often data corruption, kernel
      oopses and panics and even spontaneous reboots.
      
      Fix this problem by activly syncing unmaps in the vmalloc/ioremap area to
      all page-tables in the system before the regions can be re-used.
      
      References: https://bugzilla.suse.com/show_bug.cgi?id=1118689
      Fixes: 5d72b4fb ('x86, mm: support huge I/O mapping capability I/F')
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-4-joro@8bytes.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46b306f3
    • Joerg Roedel's avatar
      x86/mm: Sync also unmappings in vmalloc_sync_all() · 9935d7ed
      Joerg Roedel authored
      commit 8e998fc2 upstream.
      
      With huge-page ioremap areas the unmappings also need to be synced between
      all page-tables. Otherwise it can cause data corruption when a region is
      unmapped and later re-used.
      
      Make the vmalloc_sync_one() function ready to sync unmappings and make sure
      vmalloc_sync_all() iterates over all page-tables even when an unmapped PMD
      is found.
      
      Fixes: 5d72b4fb ('x86, mm: support huge I/O mapping capability I/F')
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-3-joro@8bytes.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9935d7ed
    • Joerg Roedel's avatar
      x86/mm: Check for pfn instead of page in vmalloc_sync_one() · dd524d48
      Joerg Roedel authored
      commit 51b75b5b upstream.
      
      Do not require a struct page for the mapped memory location because it
      might not exist. This can happen when an ioremapped region is mapped with
      2MB pages.
      
      Fixes: 5d72b4fb ('x86, mm: support huge I/O mapping capability I/F')
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-2-joro@8bytes.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd524d48
    • Dmitry Torokhov's avatar
      Input: synaptics - enable RMI mode for HP Spectre X360 · b8a2169b
      Dmitry Torokhov authored
      commit 25f8c834 upstream.
      
      The 2016 kabylake HP Spectre X360 (model number 13-w013dx) works much better
      with psmouse.synaptics_intertouch=1 kernel parameter, so let's enable RMI4
      mode automatically.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204115Reported-by: default avatarNate Graham <pointedstick@zoho.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8a2169b
    • Kai-Heng Feng's avatar
      Input: elantech - enable SMBus on new (2018+) systems · 3d180fe5
      Kai-Heng Feng authored
      commit 883a2a80 upstream.
      
      There are some new HP laptops with Elantech touchpad that don't support
      multitouch.
      
      Currently we use ETP_NEW_IC_SMBUS_HOST_NOTIFY() to check if SMBus is supported,
      but in addition to firmware version, the bus type also informs us whether the IC
      can support SMBus. To avoid breaking old ICs, we will only enable SMbus support
      based the bus type on systems manufactured after 2018.
      
      Lastly, let's consolidate all checks into elantech_use_host_notify() and use it
      to determine whether to use PS/2 or SMBus.
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d180fe5
    • Oliver Neukum's avatar
      Input: usbtouchscreen - initialize PM mutex before using it · ce7d4fe4
      Oliver Neukum authored
      commit b55d996f upstream.
      
      Mutexes shall be initialized before they are used.
      
      Fixes: 12e510db ("Input: usbtouchscreen - fix deadlock in autosuspend")
      Reported-by: syzbot+199ea16c7f26418b4365@syzkaller.appspotmail.com
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce7d4fe4
    • Mikulas Patocka's avatar
      loop: set PF_MEMALLOC_NOIO for the worker thread · c9a1c104
      Mikulas Patocka authored
      commit d0a255e7 upstream.
      
      A deadlock with this stacktrace was observed.
      
      The loop thread does a GFP_KERNEL allocation, it calls into dm-bufio
      shrinker and the shrinker depends on I/O completion in the dm-bufio
      subsystem.
      
      In order to fix the deadlock (and other similar ones), we set the flag
      PF_MEMALLOC_NOIO at loop thread entry.
      
      PID: 474    TASK: ffff8813e11f4600  CPU: 10  COMMAND: "kswapd0"
         #0 [ffff8813dedfb938] __schedule at ffffffff8173f405
         #1 [ffff8813dedfb990] schedule at ffffffff8173fa27
         #2 [ffff8813dedfb9b0] schedule_timeout at ffffffff81742fec
         #3 [ffff8813dedfba60] io_schedule_timeout at ffffffff8173f186
         #4 [ffff8813dedfbaa0] bit_wait_io at ffffffff8174034f
         #5 [ffff8813dedfbac0] __wait_on_bit at ffffffff8173fec8
         #6 [ffff8813dedfbb10] out_of_line_wait_on_bit at ffffffff8173ff81
         #7 [ffff8813dedfbb90] __make_buffer_clean at ffffffffa038736f [dm_bufio]
         #8 [ffff8813dedfbbb0] __try_evict_buffer at ffffffffa0387bb8 [dm_bufio]
         #9 [ffff8813dedfbbd0] dm_bufio_shrink_scan at ffffffffa0387cc3 [dm_bufio]
        #10 [ffff8813dedfbc40] shrink_slab at ffffffff811a87ce
        #11 [ffff8813dedfbd30] shrink_zone at ffffffff811ad778
        #12 [ffff8813dedfbdc0] kswapd at ffffffff811ae92f
        #13 [ffff8813dedfbec0] kthread at ffffffff810a8428
        #14 [ffff8813dedfbf50] ret_from_fork at ffffffff81745242
      
        PID: 14127  TASK: ffff881455749c00  CPU: 11  COMMAND: "loop1"
         #0 [ffff88272f5af228] __schedule at ffffffff8173f405
         #1 [ffff88272f5af280] schedule at ffffffff8173fa27
         #2 [ffff88272f5af2a0] schedule_preempt_disabled at ffffffff8173fd5e
         #3 [ffff88272f5af2b0] __mutex_lock_slowpath at ffffffff81741fb5
         #4 [ffff88272f5af330] mutex_lock at ffffffff81742133
         #5 [ffff88272f5af350] dm_bufio_shrink_count at ffffffffa03865f9 [dm_bufio]
         #6 [ffff88272f5af380] shrink_slab at ffffffff811a86bd
         #7 [ffff88272f5af470] shrink_zone at ffffffff811ad778
         #8 [ffff88272f5af500] do_try_to_free_pages at ffffffff811adb34
         #9 [ffff88272f5af590] try_to_free_pages at ffffffff811adef8
        #10 [ffff88272f5af610] __alloc_pages_nodemask at ffffffff811a09c3
        #11 [ffff88272f5af710] alloc_pages_current at ffffffff811e8b71
        #12 [ffff88272f5af760] new_slab at ffffffff811f4523
        #13 [ffff88272f5af7b0] __slab_alloc at ffffffff8173a1b5
        #14 [ffff88272f5af880] kmem_cache_alloc at ffffffff811f484b
        #15 [ffff88272f5af8d0] do_blockdev_direct_IO at ffffffff812535b3
        #16 [ffff88272f5afb00] __blockdev_direct_IO at ffffffff81255dc3
        #17 [ffff88272f5afb30] xfs_vm_direct_IO at ffffffffa01fe3fc [xfs]
        #18 [ffff88272f5afb90] generic_file_read_iter at ffffffff81198994
        #19 [ffff88272f5afc50] __dta_xfs_file_read_iter_2398 at ffffffffa020c970 [xfs]
        #20 [ffff88272f5afcc0] lo_rw_aio at ffffffffa0377042 [loop]
        #21 [ffff88272f5afd70] loop_queue_work at ffffffffa0377c3b [loop]
        #22 [ffff88272f5afe60] kthread_worker_fn at ffffffff810a8a0c
        #23 [ffff88272f5afec0] kthread at ffffffff810a8428
        #24 [ffff88272f5aff50] ret_from_fork at ffffffff81745242
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9a1c104
    • Kevin Hao's avatar
      mmc: cavium: Add the missing dma unmap when the dma has finished. · d79d76f2
      Kevin Hao authored
      commit b803974a upstream.
      
      This fixes the below calltrace when the CONFIG_DMA_API_DEBUG is enabled.
        DMA-API: thunderx_mmc 0000:01:01.4: cpu touching an active dma mapped cacheline [cln=0x000000002fdf9800]
        WARNING: CPU: 21 PID: 1 at kernel/dma/debug.c:596 debug_dma_assert_idle+0x1f8/0x270
        Modules linked in:
        CPU: 21 PID: 1 Comm: init Not tainted 5.3.0-rc1-next-20190725-yocto-standard+ #64
        Hardware name: Marvell OcteonTX CN96XX board (DT)
        pstate: 80400009 (Nzcv daif +PAN -UAO)
        pc : debug_dma_assert_idle+0x1f8/0x270
        lr : debug_dma_assert_idle+0x1f8/0x270
        sp : ffff0000113cfc10
        x29: ffff0000113cfc10 x28: 0000ffff8c880000
        x27: ffff800bc72a0000 x26: ffff000010ff8000
        x25: ffff000010ff8940 x24: ffff000010ff8968
        x23: 0000000000000000 x22: ffff000010e83700
        x21: ffff000010ea2000 x20: ffff000010e835c8
        x19: ffff800bc2c73300 x18: ffffffffffffffff
        x17: 0000000000000000 x16: 0000000000000000
        x15: ffff000010e835c8 x14: 6d20616d64206576
        x13: 69746361206e6120 x12: 676e696863756f74
        x11: 20757063203a342e x10: 31303a31303a3030
        x9 : 303020636d6d5f78 x8 : 3230303030303030
        x7 : 00000000000002fd x6 : ffff000010fd57d0
        x5 : 0000000000000000 x4 : ffff0000106c5210
        x3 : 00000000ffffffff x2 : 0000800bee9c0000
        x1 : 57d5843f4aa62800 x0 : 0000000000000000
        Call trace:
         debug_dma_assert_idle+0x1f8/0x270
         wp_page_copy+0xb0/0x688
         do_wp_page+0xa8/0x5b8
         __handle_mm_fault+0x600/0xd00
         handle_mm_fault+0x118/0x1e8
         do_page_fault+0x200/0x500
         do_mem_abort+0x50/0xb0
         el0_da+0x20/0x24
        ---[ end trace a005534bd23e109f ]---
        DMA-API: Mapped at:
         debug_dma_map_sg+0x94/0x350
         cvm_mmc_request+0x3c4/0x988
         __mmc_start_request+0x9c/0x1f8
         mmc_start_request+0x7c/0xb0
         mmc_blk_mq_issue_rq+0x5c4/0x7b8
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Fixes: ba3869ff ("mmc: cavium: Add core MMC driver for Cavium SOCs")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d79d76f2
    • Kevin Hao's avatar
      mmc: cavium: Set the correct dma max segment size for mmc_host · fd3f902d
      Kevin Hao authored
      commit fa25eba6 upstream.
      
      We have set the mmc_host.max_seg_size to 8M, but the dma max segment
      size of PCI device is set to 64K by default in function pci_device_add().
      The mmc_host.max_seg_size is used to set the max segment size of
      the blk queue. Then this mismatch will trigger a calltrace like below
      when a bigger than 64K segment request arrives at mmc dev. So we should
      consider the limitation of the cvm_mmc_host when setting the
      mmc_host.max_seg_size.
        DMA-API: thunderx_mmc 0000:01:01.4: mapping sg segment longer than device claims to support [len=131072] [max=65536]
        WARNING: CPU: 6 PID: 238 at kernel/dma/debug.c:1221 debug_dma_map_sg+0x2b8/0x350
        Modules linked in:
        CPU: 6 PID: 238 Comm: kworker/6:1H Not tainted 5.3.0-rc1-next-20190724-yocto-standard+ #62
        Hardware name: Marvell OcteonTX CN96XX board (DT)
        Workqueue: kblockd blk_mq_run_work_fn
        pstate: 80c00009 (Nzcv daif +PAN +UAO)
        pc : debug_dma_map_sg+0x2b8/0x350
        lr : debug_dma_map_sg+0x2b8/0x350
        sp : ffff00001770f9e0
        x29: ffff00001770f9e0 x28: ffffffff00000000
        x27: 00000000ffffffff x26: ffff800bc2c73180
        x25: ffff000010e83700 x24: 0000000000000002
        x23: 0000000000000001 x22: 0000000000000001
        x21: 0000000000000000 x20: ffff800bc48ba0b0
        x19: ffff800bc97e8c00 x18: ffffffffffffffff
        x17: 0000000000000000 x16: 0000000000000000
        x15: ffff000010e835c8 x14: 6874207265676e6f
        x13: 6c20746e656d6765 x12: 7320677320676e69
        x11: 7070616d203a342e x10: 31303a31303a3030
        x9 : 303020636d6d5f78 x8 : 35363d78616d5b20
        x7 : 00000000000002fd x6 : ffff000010fd57dc
        x5 : 0000000000000000 x4 : ffff0000106c61f0
        x3 : 00000000ffffffff x2 : 0000800bee060000
        x1 : 7010678df3041a00 x0 : 0000000000000000
        Call trace:
         debug_dma_map_sg+0x2b8/0x350
         cvm_mmc_request+0x3c4/0x988
         __mmc_start_request+0x9c/0x1f8
         mmc_start_request+0x7c/0xb0
         mmc_blk_mq_issue_rq+0x5c4/0x7b8
         mmc_mq_queue_rq+0x11c/0x278
         blk_mq_dispatch_rq_list+0xb0/0x568
         blk_mq_do_dispatch_sched+0x6c/0x108
         blk_mq_sched_dispatch_requests+0x110/0x1b8
         __blk_mq_run_hw_queue+0xb0/0x118
         blk_mq_run_work_fn+0x28/0x38
         process_one_work+0x210/0x490
         worker_thread+0x48/0x458
         kthread+0x130/0x138
         ret_from_fork+0x10/0x1c
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Fixes: ba3869ff ("mmc: cavium: Add core MMC driver for Cavium SOCs")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd3f902d
    • Wenwen Wang's avatar
      sound: fix a memory leak bug · 9575ba61
      Wenwen Wang authored
      commit c7cd7c74 upstream.
      
      In sound_insert_unit(), the controlling structure 's' is allocated through
      kmalloc(). Then it is added to the sound driver list by invoking
      __sound_insert_unit(). Later on, if __register_chrdev() fails, 's' is
      removed from the list through __sound_remove_unit(). If 'index' is not less
      than 0, -EBUSY is returned to indicate the error. However, 's' is not
      deallocated on this execution path, leading to a memory leak bug.
      
      To fix the above issue, free 's' before -EBUSY is returned.
      Signed-off-by: default avatarWenwen Wang <wenwen@cs.uga.edu>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9575ba61
    • Oliver Neukum's avatar
      usb: iowarrior: fix deadlock on disconnect · d397091d
      Oliver Neukum authored
      commit c468a8aa upstream.
      
      We have to drop the mutex before we close() upon disconnect()
      as close() needs the lock. This is safe to do by dropping the
      mutex as intfdata is already set to NULL, so open() will fail.
      
      Fixes: 03f36e88 ("USB: open disconnect race in iowarrior")
      Reported-by: syzbot+a64a382964bf6c71a9c0@syzkaller.appspotmail.com
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/20190808092728.23417-1-oneukum@suse.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d397091d
    • Gavin Li's avatar
      usb: usbfs: fix double-free of usb memory upon submiturb error · b43611cd
      Gavin Li authored
      commit c43f28df upstream.
      
      Upon an error within proc_do_submiturb(), dec_usb_memory_use_count()
      gets called once by the error handling tail and again by free_async().
      Remove the first call.
      Signed-off-by: default avatarGavin Li <git@thegavinli.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190804235044.22327-1-gavinli@thegavinli.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b43611cd
    • Gary R Hook's avatar
      crypto: ccp - Ignore tag length when decrypting GCM ciphertext · 6dbc3b74
      Gary R Hook authored
      commit e2664ecb upstream.
      
      AES GCM input buffers for decryption contain AAD+CTEXT+TAG. Only
      decrypt the ciphertext, and use the tag for comparison.
      
      Fixes: 36cf515b ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dbc3b74
    • Gary R Hook's avatar
      crypto: ccp - Add support for valid authsize values less than 16 · 30692ede
      Gary R Hook authored
      commit 9f00baf7 upstream.
      
      AES GCM encryption allows for authsize values of 4, 8, and 12-16 bytes.
      Validate the requested authsize, and retain it to save in the request
      context.
      
      Fixes: 36cf515b ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30692ede
    • Gary R Hook's avatar
      crypto: ccp - Fix oops by properly managing allocated structures · 1c4393df
      Gary R Hook authored
      commit 25e44338 upstream.
      
      A plaintext or ciphertext length of 0 is allowed in AES, in which case
      no encryption occurs. Ensure that we don't clean up data structures
      that were never allocated.
      
      Fixes: 36cf515b ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c4393df
    • Tetsuo Handa's avatar
      staging: android: ion: Bail out upon SIGKILL when allocating memory. · b9de2157
      Tetsuo Handa authored
      commit 8f9e86ee upstream.
      
      syzbot found that a thread can stall for minutes inside
      ion_system_heap_allocate() after that thread was killed by SIGKILL [1].
      Let's check for SIGKILL before doing memory allocation.
      
      [1] https://syzkaller.appspot.com/bug?id=a0e3436829698d5824231251fad9d8e998f94f5eSigned-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatarsyzbot <syzbot+8ab2d0f39fb79fe6ca40@syzkaller.appspotmail.com>
      Acked-by: default avatarLaura Abbott <labbott@redhat.com>
      Acked-by: default avatarSumit Semwal <sumit.semwal@linaro.org>
      Link: https://lore.kernel.org/r/d088f188-5f32-d8fc-b9a0-0b404f7501cc@I-love.SAKURA.ne.jpSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9de2157
    • Ivan Bornyakov's avatar
      staging: gasket: apex: fix copy-paste typo · 6b8f93b5
      Ivan Bornyakov authored
      commit 66665bb9 upstream.
      
      In sysfs_show() case-branches ATTR_KERNEL_HIB_PAGE_TABLE_SIZE and
      ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE do the same. It looks like
      copy-paste mistake.
      Signed-off-by: default avatarIvan Bornyakov <brnkv.i1@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190710204518.16814-1-brnkv.i1@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6b8f93b5
    • Joe Perches's avatar
      iio: adc: max9611: Fix misuse of GENMASK macro · fcab3783
      Joe Perches authored
      commit ae8cc91a upstream.
      
      Arguments are supposed to be ordered high then low.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Fixes: 69780a3b ("iio: adc: Add Maxim max9611 ADC driver")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fcab3783
    • Gwendal Grignou's avatar
      iio: cros_ec_accel_legacy: Fix incorrect channel setting · 805bd34a
      Gwendal Grignou authored
      commit 6cdff99c upstream.
      
      INFO_SCALE is set both for each channel and all channels.
      iio is using all channel setting, so the error was not user visible.
      Signed-off-by: default avatarGwendal Grignou <gwendal@chromium.org>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      805bd34a
  2. 09 Aug, 2019 14 commits