1. 16 8月, 2019 33 次提交
    • F
      netfilter: nfnetlink: avoid deadlock due to synchronous request_module · bb312b4a
      Florian Westphal 提交于
      [ Upstream commit 1b0890cd60829bd51455dc5ad689ed58c4408227 ]
      
      Thomas and Juliana report a deadlock when running:
      
      (rmmod nf_conntrack_netlink/xfrm_user)
      
        conntrack -e NEW -E &
        modprobe -v xfrm_user
      
      They provided following analysis:
      
      conntrack -e NEW -E
          netlink_bind()
              netlink_lock_table() -> increases "nl_table_users"
                  nfnetlink_bind()
                  # does not unlock the table as it's locked by netlink_bind()
                      __request_module()
                          call_usermodehelper_exec()
      
      This triggers "modprobe nf_conntrack_netlink" from kernel, netlink_bind()
      won't return until modprobe process is done.
      
      "modprobe xfrm_user":
          xfrm_user_init()
              register_pernet_subsys()
                  -> grab pernet_ops_rwsem
                      ..
                      netlink_table_grab()
                          calls schedule() as "nl_table_users" is non-zero
      
      so modprobe is blocked because netlink_bind() increased
      nl_table_users while also holding pernet_ops_rwsem.
      
      "modprobe nf_conntrack_netlink" runs and inits nf_conntrack_netlink:
          ctnetlink_init()
              register_pernet_subsys()
                  -> blocks on "pernet_ops_rwsem" thanks to xfrm_user module
      
      both modprobe processes wait on one another -- neither can make
      progress.
      
      Switch netlink_bind() to "nowait" modprobe -- this releases the netlink
      table lock, which then allows both modprobe instances to complete.
      Reported-by: NThomas Jarosch <thomas.jarosch@intra2net.com>
      Reported-by: NJuliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      bb312b4a
    • S
      can: peak_usb: fix potential double kfree_skb() · f61c4d3a
      Stephane Grosjean 提交于
      commit fee6a8923ae0d318a7f7950c6c6c28a96cea099b upstream.
      
      When closing the CAN device while tx skbs are inflight, echo skb could
      be released twice. By calling close_candev() before unlinking all
      pending tx urbs, then the internal echo_skb[] array is fully and
      correctly cleared before the USB write callback and, therefore,
      can_get_echo_skb() are called, for each aborted URB.
      
      Fixes: bb478555 ("can: usb: PEAK-System Technik USB adapters driver core")
      Signed-off-by: NStephane Grosjean <s.grosjean@peak-system.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f61c4d3a
    • N
      can: rcar_canfd: fix possible IRQ storm on high load · 0e9038a2
      Nikita Yushchenko 提交于
      commit d4b890aec4bea7334ca2ca56fd3b12fb48a00cd1 upstream.
      
      We have observed rcar_canfd driver entering IRQ storm under high load,
      with following scenario:
      - rcar_canfd_global_interrupt() in entered due to Rx available,
      - napi_schedule_prep() is called, and sets NAPIF_STATE_SCHED in state
      - Rx fifo interrupts are masked,
      - rcar_canfd_global_interrupt() is entered again, this time due to
        error interrupt (e.g. due to overflow),
      - since scheduled napi poller has not yet executed, condition for calling
        napi_schedule_prep() from rcar_canfd_global_interrupt() remains true,
        thus napi_schedule_prep() gets called and sets NAPIF_STATE_MISSED flag
        in state,
      - later, napi poller function rcar_canfd_rx_poll() gets executed, and
        calls napi_complete_done(),
      - due to NAPIF_STATE_MISSED flag in state, this call does not clear
        NAPIF_STATE_SCHED flag from state,
      - on return from napi_complete_done(), rcar_canfd_rx_poll() unmasks Rx
        interrutps,
      - Rx interrupt happens, rcar_canfd_global_interrupt() gets called
        and calls napi_schedule_prep(),
      - since NAPIF_STATE_SCHED is set in state at this time, this call
        returns false,
      - due to that false return, rcar_canfd_global_interrupt() returns
        without masking Rx interrupt
      - and this results into IRQ storm: unmasked Rx interrupt happens again
        and again is misprocessed in the same way.
      
      This patch fixes that scenario by unmasking Rx interrupts only when
      napi_complete_done() returns true, which means it has cleared
      NAPIF_STATE_SCHED in state.
      
      Fixes: dd3bd23e ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
      Signed-off-by: NNikita Yushchenko <nikita.yoush@cogentembedded.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e9038a2
    • G
      usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests · 9479a058
      Guenter Roeck 提交于
      commit 88d02c9ba2e83fc22d37ccb1f11c62ea6fc9ae50 upstream.
      
      TCPM may receive PD messages associated with unknown or unsupported
      alternate modes. If that happens, calls to typec_match_altmode()
      will return NULL. The tcpm code does not currently take this into
      account. This results in crashes.
      
      Unable to handle kernel NULL pointer dereference at virtual address 000001f0
      pgd = 41dad9a1
      [000001f0] *pgd=00000000
      Internal error: Oops: 5 [#1] THUMB2
      Modules linked in: tcpci tcpm
      CPU: 0 PID: 2338 Comm: kworker/u2:0 Not tainted 5.1.18-sama5-armv7-r2 #6
      Hardware name: Atmel SAMA5
      Workqueue: 2-0050 tcpm_pd_rx_handler [tcpm]
      PC is at typec_altmode_attention+0x0/0x14
      LR is at tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm]
      ...
      [<c03fbee8>] (typec_altmode_attention) from [<bf8030fb>]
      				(tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm])
      [<bf8030fb>] (tcpm_pd_rx_handler [tcpm]) from [<c012082b>]
      				(process_one_work+0x123/0x2a8)
      [<c012082b>] (process_one_work) from [<c0120a6d>]
      				(worker_thread+0xbd/0x3b0)
      [<c0120a6d>] (worker_thread) from [<c012431f>] (kthread+0xcf/0xf4)
      [<c012431f>] (kthread) from [<c01010f9>] (ret_from_fork+0x11/0x38)
      
      Ignore PD messages if the associated alternate mode is not supported.
      
      Fixes: e9576fe8 ("usb: typec: tcpm: Support for Alternate Modes")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: NDouglas Gilbert <dgilbert@interlog.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Acked-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Tested-by: NDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/1564761822-13984-1-git-send-email-linux@roeck-us.netSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9479a058
    • G
      usb: typec: tcpm: Add NULL check before dereferencing config · 3f524b63
      Guenter Roeck 提交于
      commit 1957de95d425d1c06560069dc7277a73a8b28683 upstream.
      
      When instantiating tcpm on an NXP OM 13588 board with NXP PTN5110,
      the following crash is seen when writing into the 'preferred_role'
      sysfs attribute.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000028
      pgd = f69149ad
      [00000028] *pgd=00000000
      Internal error: Oops: 5 [#1] THUMB2
      Modules linked in: tcpci tcpm
      CPU: 0 PID: 1882 Comm: bash Not tainted 5.1.18-sama5-armv7-r2 #4
      Hardware name: Atmel SAMA5
      PC is at tcpm_try_role+0x3a/0x4c [tcpm]
      LR is at tcpm_try_role+0x15/0x4c [tcpm]
      pc : [<bf8000e2>]    lr : [<bf8000bd>]    psr: 60030033
      sp : dc1a1e88  ip : c03fb47d  fp : 00000000
      r10: dc216190  r9 : dc1a1f78  r8 : 00000001
      r7 : df4ae044  r6 : dd032e90  r5 : dd1ce340  r4 : df4ae054
      r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : df4ae044
      Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment none
      Control: 50c53c7d  Table: 3efec059  DAC: 00000051
      Process bash (pid: 1882, stack limit = 0x6a6d4aa5)
      Stack: (0xdc1a1e88 to 0xdc1a2000)
      1e80:                   dd05d808 dd1ce340 00000001 00000007 dd1ce340 c03fb4a7
      1ea0: 00000007 00000007 dc216180 00000000 00000000 c01e1e03 00000000 00000000
      1ec0: c0907008 dee98b40 c01e1d5d c06106c4 00000000 00000000 00000007 c0194e8b
      1ee0: 0000000a 00000400 00000000 c01a97db dc22bf00 ffffe000 df4b6a00 df745900
      1f00: 00000001 00000001 000000dd c01a9c2f 7aeab3be c0907008 00000000 dc22bf00
      1f20: c0907008 00000000 00000000 00000000 00000000 7aeab3be 00000007 dee98b40
      1f40: 005dc318 dc1a1f78 00000000 00000000 00000007 c01969f7 0000000a c01a20cb
      1f60: dee98b40 c0907008 dee98b40 005dc318 00000000 c0196b9b 00000000 00000000
      1f80: dee98b40 7aeab3be 00000074 005dc318 b6f3bdb0 00000004 c0101224 dc1a0000
      1fa0: 00000004 c0101001 00000074 005dc318 00000001 005dc318 00000007 00000000
      1fc0: 00000074 005dc318 b6f3bdb0 00000004 00000007 00000007 00000000 00000000
      1fe0: 00000004 be800880 b6ed35b3 b6e5c746 60030030 00000001 00000000 00000000
      [<bf8000e2>] (tcpm_try_role [tcpm]) from [<c03fb4a7>] (preferred_role_store+0x2b/0x5c)
      [<c03fb4a7>] (preferred_role_store) from [<c01e1e03>] (kernfs_fop_write+0xa7/0x150)
      [<c01e1e03>] (kernfs_fop_write) from [<c0194e8b>] (__vfs_write+0x1f/0x104)
      [<c0194e8b>] (__vfs_write) from [<c01969f7>] (vfs_write+0x6b/0x104)
      [<c01969f7>] (vfs_write) from [<c0196b9b>] (ksys_write+0x43/0x94)
      [<c0196b9b>] (ksys_write) from [<c0101001>] (ret_fast_syscall+0x1/0x62)
      
      Since commit 96232cbc ("usb: typec: tcpm: support get typec and pd
      config from device properties"), the 'config' pointer in struct tcpc_dev
      is optional when registering a Type-C port. Since it is optional, we have
      to check if it is NULL before dereferencing it.
      Reported-by: NDouglas Gilbert <dgilbert@interlog.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Fixes: 96232cbc ("usb: typec: tcpm: support get typec and pd config from device properties")
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: NJun Li <jun.li@nxp.com>
      Reviewed-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/1563979112-22483-1-git-send-email-linux@roeck-us.netSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f524b63
    • L
      usb: typec: tcpm: remove tcpm dir if no children · bbc2e820
      Li Jun 提交于
      commit 12ca7297b8855c0af1848503d37196159b24e6b9 upstream.
      
      If config tcpm as module, module unload will not remove tcpm dir,
      then the next module load will have problem: the rootdir is NULL
      but tcpm dir is still there, so tcpm_debugfs_init() will create
      tcpm dir again with failure, fix it by remove the tcpm dir if no
      children.
      
      Cc: stable@vger.kernel.org # v4.15+
      Fixes: 4b4e02c8 ("typec: tcpm: Move out of staging")
      Signed-off-by: NLi Jun <jun.li@nxp.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-2-jun.li@nxp.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbc2e820
    • L
      usb: typec: tcpm: free log buf memory when remove debug file · 2ec5c9b7
      Li Jun 提交于
      commit fd5da3e2cc61b4a7c877172fdc9348c82cf6ccfc upstream.
      
      The logbuffer memory should be freed when remove debug file.
      
      Cc: stable@vger.kernel.org # v4.15+
      Fixes: 4b4e02c8 ("typec: tcpm: Move out of staging")
      Signed-off-by: NLi Jun <jun.li@nxp.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-1-jun.li@nxp.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ec5c9b7
    • S
      usb: yurex: Fix use-after-free in yurex_delete · 33f2240a
      Suzuki K Poulose 提交于
      commit fc05481b2fcabaaeccf63e32ac1baab54e5b6963 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: NSuzuki 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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33f2240a
    • Y
      usb: host: xhci-rcar: Fix timeout in xhci_suspend() · 49888a4f
      Yoshihiro Shimoda 提交于
      commit 783bda5e41acc71f98336e1a402c180f9748e5dc 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: NYoshihiro 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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49888a4f
    • A
      gfs2: gfs2_walk_metadata fix · 21344f05
      Andreas Gruenbacher 提交于
      commit a27a0c9b6a208722016c8ec5ad31ec96082b91ec 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: NAndreas Gruenbacher <agruenba@redhat.com>
      Reviewed-by: NBob Peterson <rpeterso@redhat.com>
      Cc: stable@vger.kernel.org # v4.18+
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21344f05
    • N
      x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS · b674f791
      Nick Desaulniers 提交于
      commit b059f801a937d164e03b33c1848bb3dca67c0b04 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: NVaibhav Rustagi <vaibhavrustagi@google.com>
      Suggested-by: NPeter Zijlstra <peterz@infradead.org>
      Suggested-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Tested-by: NVaibhav Rustagi <vaibhavrustagi@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190807221539.94583-2-ndesaulniers@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b674f791
    • T
      perf record: Fix module size on s390 · 0a9e41e2
      Thomas Richter 提交于
      commit 12a6d2940b5f02b4b9f71ce098e3bb02bc24a9ea 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: NStefan Liebler <stli@linux.ibm.com>
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NHeiko 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a9e41e2
    • A
      perf db-export: Fix thread__exec_comm() · f1f66289
      Adrian Hunter 提交于
      commit 3de7ae0b2a1d86dbb23d0cb135150534fdb2e836 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: NAdrian 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1f66289
    • T
      perf annotate: Fix s390 gap between kernel end and module start · 532db2b9
      Thomas Richter 提交于
      commit b9c0a64901d5bdec6eafd38d1dc8fa0e2974fccb 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: NKlaus Theurich <klaus.theurich@de.ibm.com>
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NHeiko 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      532db2b9
    • J
      mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy() · 46b306f3
      Joerg Roedel 提交于
      commit 3f8fd02b1bf1d7ba964485a56f2f4b53ae88c167 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: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-4-joro@8bytes.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46b306f3
    • J
      x86/mm: Sync also unmappings in vmalloc_sync_all() · 9935d7ed
      Joerg Roedel 提交于
      commit 8e998fc24de47c55b47a887f6c95ab91acd4a720 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: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-3-joro@8bytes.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9935d7ed
    • J
      x86/mm: Check for pfn instead of page in vmalloc_sync_one() · dd524d48
      Joerg Roedel 提交于
      commit 51b75b5b563a2637f9d8dc5bd02a31b2ff9e5ea0 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: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-2-joro@8bytes.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd524d48
    • D
      Input: synaptics - enable RMI mode for HP Spectre X360 · b8a2169b
      Dmitry Torokhov 提交于
      commit 25f8c834e2a6871920cc1ca113f02fb301d007c3 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: NNate Graham <pointedstick@zoho.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8a2169b
    • K
      Input: elantech - enable SMBus on new (2018+) systems · 3d180fe5
      Kai-Heng Feng 提交于
      commit 883a2a80f79ca5c0c105605fafabd1f3df99b34c 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: NKai-Heng Feng <kai.heng.feng@canonical.com>
      Acked-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d180fe5
    • O
      Input: usbtouchscreen - initialize PM mutex before using it · ce7d4fe4
      Oliver Neukum 提交于
      commit b55d996f057bf2e7ba9422a80b5e17e99860cb0b 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: NOliver Neukum <oneukum@suse.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce7d4fe4
    • M
      loop: set PF_MEMALLOC_NOIO for the worker thread · c9a1c104
      Mikulas Patocka 提交于
      commit d0a255e795ab976481565f6ac178314b34fbf891 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: NMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9a1c104
    • K
      mmc: cavium: Add the missing dma unmap when the dma has finished. · d79d76f2
      Kevin Hao 提交于
      commit b803974a86039913d5280add083d730b2b9ed8ec 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: NKevin Hao <haokexin@gmail.com>
      Fixes: ba3869ff ("mmc: cavium: Add core MMC driver for Cavium SOCs")
      Cc: stable@vger.kernel.org
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d79d76f2
    • K
      mmc: cavium: Set the correct dma max segment size for mmc_host · fd3f902d
      Kevin Hao 提交于
      commit fa25eba6993b3750f417baabba169afaba076178 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: NKevin Hao <haokexin@gmail.com>
      Fixes: ba3869ff ("mmc: cavium: Add core MMC driver for Cavium SOCs")
      Cc: stable@vger.kernel.org
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd3f902d
    • W
      sound: fix a memory leak bug · 9575ba61
      Wenwen Wang 提交于
      commit c7cd7c748a3250ca33509f9235efab9c803aca09 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: NWenwen Wang <wenwen@cs.uga.edu>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9575ba61
    • O
      usb: iowarrior: fix deadlock on disconnect · d397091d
      Oliver Neukum 提交于
      commit c468a8aa790e0dfe0a7f8a39db282d39c2c00b46 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: NOliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/20190808092728.23417-1-oneukum@suse.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d397091d
    • G
      usb: usbfs: fix double-free of usb memory upon submiturb error · b43611cd
      Gavin Li 提交于
      commit c43f28dfdc4654e738aa6d3fd08a105b2bee758d 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: NGavin Li <git@thegavinli.com>
      Acked-by: NAlan 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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b43611cd
    • G
      crypto: ccp - Ignore tag length when decrypting GCM ciphertext · 6dbc3b74
      Gary R Hook 提交于
      commit e2664ecbb2f26225ac6646876f2899558ffb2604 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: NGary R Hook <gary.hook@amd.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dbc3b74
    • G
      crypto: ccp - Add support for valid authsize values less than 16 · 30692ede
      Gary R Hook 提交于
      commit 9f00baf74e4b6f79a3a3dfab44fb7bb2e797b551 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: NGary R Hook <gary.hook@amd.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30692ede
    • G
      crypto: ccp - Fix oops by properly managing allocated structures · 1c4393df
      Gary R Hook 提交于
      commit 25e44338321af545ab34243a6081c3f0fc6107d0 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: NGary R Hook <gary.hook@amd.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c4393df
    • T
      staging: android: ion: Bail out upon SIGKILL when allocating memory. · b9de2157
      Tetsuo Handa 提交于
      commit 8f9e86ee795971eabbf372e6d804d6b8578287a7 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: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: stable <stable@vger.kernel.org>
      Reported-by: Nsyzbot <syzbot+8ab2d0f39fb79fe6ca40@syzkaller.appspotmail.com>
      Acked-by: NLaura Abbott <labbott@redhat.com>
      Acked-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://lore.kernel.org/r/d088f188-5f32-d8fc-b9a0-0b404f7501cc@I-love.SAKURA.ne.jpSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9de2157
    • I
      staging: gasket: apex: fix copy-paste typo · 6b8f93b5
      Ivan Bornyakov 提交于
      commit 66665bb9979246729562a09fcdbb101c83127989 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: NIvan 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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6b8f93b5
    • J
      iio: adc: max9611: Fix misuse of GENMASK macro · fcab3783
      Joe Perches 提交于
      commit ae8cc91a7d85e018c0c267f580820b2bb558cd48 upstream.
      
      Arguments are supposed to be ordered high then low.
      Signed-off-by: NJoe Perches <joe@perches.com>
      Fixes: 69780a3b ("iio: adc: Add Maxim max9611 ADC driver")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fcab3783
    • G
      iio: cros_ec_accel_legacy: Fix incorrect channel setting · 805bd34a
      Gwendal Grignou 提交于
      commit 6cdff99c9f7d7d28b87cf05dd464f7c7736332ae 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: NGwendal Grignou <gwendal@chromium.org>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      805bd34a
  2. 09 8月, 2019 7 次提交
    • G
      Linux 4.19.66 · 893af1c7
      Greg Kroah-Hartman 提交于
      893af1c7
    • L
      spi: bcm2835: Fix 3-wire mode if DMA is enabled · 48fcdaba
      Lukas Wunner 提交于
      commit 8d8bef50365847134b51c1ec46786bc2873e4e47 upstream.
      
      Commit 6935224d ("spi: bcm2835: enable support of 3-wire mode")
      added 3-wire support to the BCM2835 SPI driver by setting the REN bit
      (Read Enable) in the CS register when receiving data.  The REN bit puts
      the transmitter in high-impedance state.  The driver recognizes that
      data is to be received by checking whether the rx_buf of a transfer is
      non-NULL.
      
      Commit 3ecd37ed ("spi: bcm2835: enable dma modes for transfers
      meeting certain conditions") subsequently broke 3-wire support because
      it set the SPI_MASTER_MUST_RX flag which causes spi_map_msg() to replace
      rx_buf with a dummy buffer if it is NULL.  As a result, rx_buf is
      *always* non-NULL if DMA is enabled.
      
      Reinstate 3-wire support by not only checking whether rx_buf is non-NULL,
      but also checking that it is not the dummy buffer.
      
      Fixes: 3ecd37ed ("spi: bcm2835: enable dma modes for transfers meeting certain conditions")
      Reported-by: NNuno Sá <nuno.sa@analog.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Cc: stable@vger.kernel.org # v4.2+
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Acked-by: NStefan Wahren <wahrenst@gmx.net>
      Link: https://lore.kernel.org/r/328318841455e505370ef8ecad97b646c033dc8a.1562148527.git.lukas@wunner.deSigned-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      48fcdaba
    • T
      cgroup: Fix css_task_iter_advance_css_set() cset skip condition · ebda41dd
      Tejun Heo 提交于
      commit c596687a008b579c503afb7a64fcacc7270fae9e upstream.
      
      While adding handling for dying task group leaders c03cd7738a83
      ("cgroup: Include dying leaders with live threads in PROCS
      iterations") added an inverted cset skip condition to
      css_task_iter_advance_css_set().  It should skip cset if it's
      completely empty but was incorrectly testing for the inverse condition
      for the dying_tasks list.  Fix it.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Fixes: c03cd7738a83 ("cgroup: Include dying leaders with live threads in PROCS iterations")
      Reported-by: syzbot+d4bba5ccd4f9a2a68681@syzkaller.appspotmail.com
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebda41dd
    • T
      cgroup: css_task_iter_skip()'d iterators must be advanced before accessed · 0a9abd27
      Tejun Heo 提交于
      commit cee0c33c546a93957a52ae9ab6bebadbee765ec5 upstream.
      
      b636fd38dc40 ("cgroup: Implement css_task_iter_skip()") introduced
      css_task_iter_skip() which is used to fix task iterations skipping
      dying threadgroup leaders with live threads.  Skipping is implemented
      as a subportion of full advancing but css_task_iter_next() forgot to
      fully advance a skipped iterator before determining the next task to
      visit causing it to return invalid task pointers.
      
      Fix it by making css_task_iter_next() fully advance the iterator if it
      has been skipped since the previous iteration.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: syzbot
      Link: http://lkml.kernel.org/r/00000000000097025d058a7fd785@google.com
      Fixes: b636fd38dc40 ("cgroup: Implement css_task_iter_skip()")
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a9abd27
    • T
      cgroup: Include dying leaders with live threads in PROCS iterations · 4340d175
      Tejun Heo 提交于
      commit c03cd7738a83b13739f00546166969342c8ff014 upstream.
      
      CSS_TASK_ITER_PROCS currently iterates live group leaders; however,
      this means that a process with dying leader and live threads will be
      skipped.  IOW, cgroup.procs might be empty while cgroup.threads isn't,
      which is confusing to say the least.
      
      Fix it by making cset track dying tasks and include dying leaders with
      live threads in PROCS iteration.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-and-tested-by: NTopi Miettinen <toiwoton@gmail.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4340d175
    • T
      cgroup: Implement css_task_iter_skip() · 370b9e63
      Tejun Heo 提交于
      commit b636fd38dc40113f853337a7d2a6885ad23b8811 upstream.
      
      When a task is moved out of a cset, task iterators pointing to the
      task are advanced using the normal css_task_iter_advance() call.  This
      is fine but we'll be tracking dying tasks on csets and thus moving
      tasks from cset->tasks to (to be added) cset->dying_tasks.  When we
      remove a task from cset->tasks, if we advance the iterators, they may
      move over to the next cset before we had the chance to add the task
      back on the dying list, which can allow the task to escape iteration.
      
      This patch separates out skipping from advancing.  Skipping only moves
      the affected iterators to the next pointer rather than fully advancing
      it and the following advancing will recognize that the cursor has
      already been moved forward and do the rest of advancing.  This ensures
      that when a task moves from one list to another in its cset, as long
      as it moves in the right direction, it's always visible to iteration.
      
      This doesn't cause any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      370b9e63
    • T
      cgroup: Call cgroup_release() before __exit_signal() · 7528e95b
      Tejun Heo 提交于
      commit 6b115bf58e6f013ca75e7115aabcbd56c20ff31d upstream.
      
      cgroup_release() calls cgroup_subsys->release() which is used by the
      pids controller to uncharge its pid.  We want to use it to manage
      iteration of dying tasks which requires putting it before
      __unhash_process().  Move cgroup_release() above __exit_signal().
      While this makes it uncharge before the pid is freed, pid is RCU freed
      anyway and the window is very narrow.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7528e95b