1. 20 Feb, 2019 17 commits
  2. 15 Feb, 2019 23 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.14.101 · d6bf9dce
      Greg Kroah-Hartman authored
      d6bf9dce
    • Linus Torvalds's avatar
      Revert "exec: load_script: don't blindly truncate shebang string" · 56f88d75
      Linus Torvalds authored
      commit cb5b020a upstream.
      
      This reverts commit 8099b047.
      
      It turns out that people do actually depend on the shebang string being
      truncated, and on the fact that an interpreter (like perl) will often
      just re-interpret it entirely to get the full argument list.
      Reported-by: default avatarSamuel Dionne-Riel <samuel@dionne-riel.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      56f88d75
    • Greg Kroah-Hartman's avatar
      Linux 4.14.100 · 557ac4e2
      Greg Kroah-Hartman authored
      557ac4e2
    • Xiubo Li's avatar
      Revert "uio: use request_threaded_irq instead" · f142573d
      Xiubo Li authored
      commit 3d27c4de upstream.
      
      Since mutex lock in irq hanler is useless currently, here will
      remove it together with it.
      
      This reverts commit 9421e45f.
      
      Reported-by: james.r.harris@intel.com
      CC: Ahsan Atta <ahsan.atta@intel.com>
      Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f142573d
    • Xiubo Li's avatar
      uio: fix possible circular locking dependency · 5d07d245
      Xiubo Li authored
      commit b34e9a15 upstream.
      
      The call trace:
      XXX/1910 is trying to acquire lock:
       (&mm->mmap_sem){++++++}, at: [<ffffffff97008c87>] might_fault+0x57/0xb0
      
      but task is already holding lock:
       (&idev->info_lock){+.+...}, at: [<ffffffffc0638a06>] uio_write+0x46/0x130 [uio]
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #1 (&idev->info_lock){+.+...}:
             [<ffffffff96f31fc9>] lock_acquire+0x99/0x1e0
             [<ffffffff975edad3>] mutex_lock_nested+0x93/0x410
             [<ffffffffc063873d>] uio_mmap+0x2d/0x170 [uio]
             [<ffffffff97016b58>] mmap_region+0x428/0x650
             [<ffffffff97017138>] do_mmap+0x3b8/0x4e0
             [<ffffffff96ffaba3>] vm_mmap_pgoff+0xd3/0x120
             [<ffffffff97015261>] SyS_mmap_pgoff+0x1f1/0x270
             [<ffffffff96e387c2>] SyS_mmap+0x22/0x30
             [<ffffffff975ff315>] system_call_fastpath+0x1c/0x21
      
      -> #0 (&mm->mmap_sem){++++++}:
             [<ffffffff96f30e9c>] __lock_acquire+0xdac/0x15f0
             [<ffffffff96f31fc9>] lock_acquire+0x99/0x1e0
             [<ffffffff97008cb4>] might_fault+0x84/0xb0
             [<ffffffffc0638a74>] uio_write+0xb4/0x130 [uio]
             [<ffffffff9706ffa3>] vfs_write+0xc3/0x1f0
             [<ffffffff97070e2a>] SyS_write+0x8a/0x100
             [<ffffffff975ff315>] system_call_fastpath+0x1c/0x21
      
      other info that might help us debug this:
       Possible unsafe locking scenario:
             CPU0                    CPU1
             ----                    ----
        lock(&idev->info_lock);
                                     lock(&mm->mmap_sem);
                                     lock(&idev->info_lock);
        lock(&mm->mmap_sem);
      
       *** DEADLOCK ***
      1 lock held by XXX/1910:
       #0:  (&idev->info_lock){+.+...}, at: [<ffffffffc0638a06>] uio_write+0x46/0x130 [uio]
      
      stack backtrace:
      CPU: 0 PID: 1910 Comm: XXX Kdump: loaded Not tainted #1
      Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
      Call Trace:
       [<ffffffff975e9211>] dump_stack+0x19/0x1b
       [<ffffffff975e260a>] print_circular_bug+0x1f9/0x207
       [<ffffffff96f2f6a7>] check_prevs_add+0x957/0x960
       [<ffffffff96f30e9c>] __lock_acquire+0xdac/0x15f0
       [<ffffffff96f2fb19>] ? mark_held_locks+0xb9/0x140
       [<ffffffff96f31fc9>] lock_acquire+0x99/0x1e0
       [<ffffffff97008c87>] ? might_fault+0x57/0xb0
       [<ffffffff97008cb4>] might_fault+0x84/0xb0
       [<ffffffff97008c87>] ? might_fault+0x57/0xb0
       [<ffffffffc0638a74>] uio_write+0xb4/0x130 [uio]
       [<ffffffff9706ffa3>] vfs_write+0xc3/0x1f0
       [<ffffffff9709349c>] ? fget_light+0xfc/0x510
       [<ffffffff97070e2a>] SyS_write+0x8a/0x100
       [<ffffffff975ff315>] system_call_fastpath+0x1c/0x21
      Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5d07d245
    • Hailong Liu's avatar
      uio: fix wrong return value from uio_mmap() · 28c618ab
      Hailong Liu authored
      commit e7de2590 upstream.
      
      uio_mmap has multiple fail paths to set return value to nonzero then
      goto out. However, it always returns *0* from the *out* at end, and
      this will mislead callers who check the return value of this function.
      
      Fixes: 57c5f4df ("uio: fix crash after the device is unregistered")
      CC: Xiubo Li <xiubli@redhat.com>
      Signed-off-by: default avatarHailong Liu <liu.hailong6@zte.com.cn>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJiang Biao <jiang.biao2@zte.com.cn>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28c618ab
    • Xiubo Li's avatar
      uio: fix crash after the device is unregistered · 13af019c
      Xiubo Li authored
      commit 57c5f4df upstream.
      
      For the target_core_user use case, after the device is unregistered
      it maybe still opened in user space, then the kernel will crash, like:
      
      [  251.163692] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
      [  251.163820] IP: [<ffffffffc0736213>] show_name+0x23/0x40 [uio]
      [  251.163965] PGD 8000000062694067 PUD 62696067 PMD 0
      [  251.164097] Oops: 0000 [#1] SMP
      ...
      [  251.165605]  e1000 mptscsih mptbase drm_panel_orientation_quirks dm_mirror dm_region_hash dm_log dm_mod
      [  251.166014] CPU: 0 PID: 13380 Comm: tcmu-runner Kdump: loaded Not tainted 3.10.0-916.el7.test.x86_64 #1
      [  251.166381] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
      [  251.166747] task: ffff971eb91db0c0 ti: ffff971e9e384000 task.ti: ffff971e9e384000
      [  251.167137] RIP: 0010:[<ffffffffc0736213>]  [<ffffffffc0736213>] show_name+0x23/0x40 [uio]
      [  251.167563] RSP: 0018:ffff971e9e387dc8  EFLAGS: 00010282
      [  251.167978] RAX: 0000000000000000 RBX: ffff971e9e3f8000 RCX: ffff971eb8368d98
      [  251.168408] RDX: ffff971e9e3f8000 RSI: ffffffffc0738084 RDI: ffff971e9e3f8000
      [  251.168856] RBP: ffff971e9e387dd0 R08: ffff971eb8bc0018 R09: 0000000000000000
      [  251.169296] R10: 0000000000001000 R11: ffffffffa09d444d R12: ffffffffa1076e80
      [  251.169750] R13: ffff971e9e387f18 R14: 0000000000000001 R15: ffff971e9cfb1c80
      [  251.170213] FS:  00007ff37d175880(0000) GS:ffff971ebb600000(0000) knlGS:0000000000000000
      [  251.170693] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  251.171248] CR2: 0000000000000008 CR3: 00000000001f6000 CR4: 00000000003607f0
      [  251.172071] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  251.172640] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  251.173236] Call Trace:
      [  251.173789]  [<ffffffffa0c9b2d3>] dev_attr_show+0x23/0x60
      [  251.174356]  [<ffffffffa0f561b2>] ? mutex_lock+0x12/0x2f
      [  251.174892]  [<ffffffffa0ac6d9f>] sysfs_kf_seq_show+0xcf/0x1f0
      [  251.175433]  [<ffffffffa0ac54e6>] kernfs_seq_show+0x26/0x30
      [  251.175981]  [<ffffffffa0a63be0>] seq_read+0x110/0x3f0
      [  251.176609]  [<ffffffffa0ac5d45>] kernfs_fop_read+0xf5/0x160
      [  251.177158]  [<ffffffffa0a3d3af>] vfs_read+0x9f/0x170
      [  251.177707]  [<ffffffffa0a3e27f>] SyS_read+0x7f/0xf0
      [  251.178268]  [<ffffffffa0f648af>] system_call_fastpath+0x1c/0x21
      [  251.178823] Code: 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 53 48 89 d3 e8 7e 96 56 e0 48 8b 80 d8 02 00 00 48 89 df 48 c7 c6 84 80 73 c0 <48> 8b 50 08 31 c0 e8 e2 67 44 e0 5b 48 98 5d c3 0f 1f 00 66 2e
      [  251.180115] RIP  [<ffffffffc0736213>] show_name+0x23/0x40 [uio]
      [  251.180820]  RSP <ffff971e9e387dc8>
      [  251.181473] CR2: 0000000000000008
      
      CC: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
      CC: Mike Christie <mchristi@redhat.com>
      Reviewed-by: default avatarHamish Martin <hamish.martin@alliedtelesis.co.nz>
      Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      13af019c
    • Xiubo Li's avatar
      uio: change to use the mutex lock instead of the spin lock · 3f400c2c
      Xiubo Li authored
      commit 543af586 upstream.
      
      We are hitting a regression with the following commit:
      
      commit a93e7b33
      Author: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
      Date:   Mon May 14 13:32:23 2018 +1200
      
          uio: Prevent device destruction while fds are open
      
      The problem is the addition of spin_lock_irqsave in uio_write. This
      leads to hitting  uio_write -> copy_from_user -> _copy_from_user ->
      might_fault and the logs filling up with sleeping warnings.
      
      I also noticed some uio drivers allocate memory, sleep, grab mutexes
      from callouts like open() and release and uio is now doing
      spin_lock_irqsave while calling them.
      Reported-by: default avatarMike Christie <mchristi@redhat.com>
      CC: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
      Reviewed-by: default avatarHamish Martin <hamish.martin@alliedtelesis.co.nz>
      Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f400c2c
    • Xiubo Li's avatar
      uio: use request_threaded_irq instead · 8a68c55d
      Xiubo Li authored
      commit 9421e45f upstream.
      
      Prepraing for changing to use mutex lock.
      Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a68c55d
    • Hamish Martin's avatar
      uio: Prevent device destruction while fds are open · 085d735c
      Hamish Martin authored
      commit a93e7b33 upstream.
      
      Prevent destruction of a uio_device while user space apps hold open
      file descriptors to that device. Further, access to the 'info' member
      of the struct uio_device is protected by spinlock. This is to ensure
      stale pointers to data not under control of the UIO subsystem are not
      dereferenced.
      Signed-off-by: default avatarHamish Martin <hamish.martin@alliedtelesis.co.nz>
      Reviewed-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [4.14 change __poll_t to unsigned int]
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      085d735c
    • Hamish Martin's avatar
      uio: Reduce return paths from uio_write() · cd4fe633
      Hamish Martin authored
      commit 81daa406 upstream.
      
      Drive all return paths for uio_write() through a single block at the
      end of the function.
      Signed-off-by: default avatarHamish Martin <hamish.martin@alliedtelesis.co.nz>
      Reviewed-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cd4fe633
    • Jiri Olsa's avatar
      perf tests attr: Make hw events optional · 943f5f2a
      Jiri Olsa authored
      commit 692f5a22 upstream.
      
      Otherwise we fail on virtual machines with no support for specific HW
      events.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20171009130712.14747-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: "Rantala, Tommi T. (Nokia - FI/Espoo)" <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      943f5f2a
    • Jiri Olsa's avatar
      perf tests attr: Fix group stat tests · 3fbfbd39
      Jiri Olsa authored
      commit f6a9820d upstream.
      
      We started to use group read whenever it's possible:
      
        82bf311e perf stat: Use group read for event groups
      
      That breaks some of attr tests, this change adds the new possible
      read_format value.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      LPU-Reference: 20170928160633.GA26973@krava
      Link: http://lkml.kernel.org/n/tip-1ko2zc4nph93d8lfwjyk9ivz@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: "Rantala, Tommi T. (Nokia - FI/Espoo)" <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3fbfbd39
    • Jiri Olsa's avatar
      perf tests attr: Fix task term values · ffc2faad
      Jiri Olsa authored
      commit 10836d9f upstream.
      
      The perf_event_attr::task is 1 by default for first (tracking) event in
      the session. Setting task=1 as default and adding task=0 for cases that
      need it.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20170703145030.12903-16-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: "Rantala, Tommi T. (Nokia - FI/Espoo)" <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffc2faad
    • Sven Eckelmann's avatar
      batman-adv: Force mac header to start of data on xmit · 0ee47efd
      Sven Eckelmann authored
      commit 9114daa8 upstream.
      
      The caller of ndo_start_xmit may not already have called
      skb_reset_mac_header. The returned value of skb_mac_header/eth_hdr
      therefore can be in the wrong position and even outside the current skbuff.
      This for example happens when the user binds to the device using a
      PF_PACKET-SOCK_RAW with enabled qdisc-bypass:
      
        int opt = 4;
        setsockopt(sock, SOL_PACKET, PACKET_QDISC_BYPASS, &opt, sizeof(opt));
      
      Since eth_hdr is used all over the codebase, the batadv_interface_tx
      function must always take care of resetting it.
      
      Fixes: c6c8fea2 ("net: Add batman-adv meshing protocol")
      Reported-by: syzbot+9d7405c7faa390e60b4e@syzkaller.appspotmail.com
      Reported-by: syzbot+7d20bc3f1ddddc0f9079@syzkaller.appspotmail.com
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0ee47efd
    • Sven Eckelmann's avatar
      batman-adv: Avoid WARN on net_device without parent in netns · d6621386
      Sven Eckelmann authored
      commit 955d3411 upstream.
      
      It is not allowed to use WARN* helpers on potential incorrect input from
      the user or transient problems because systems configured as panic_on_warn
      will reboot due to such a problem.
      
      A NULL return value of __dev_get_by_index can be caused by various problems
      which can either be related to the system configuration or problems
      (incorrectly returned network namespaces) in other (virtual) net_device
      drivers. batman-adv should not cause a (harmful) WARN in this situation and
      instead only report it via a simple message.
      
      Fixes: b7eddd0b ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
      Reported-by: syzbot+c764de0fcfadca9a8595@syzkaller.appspotmail.com
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d6621386
    • Florian Westphal's avatar
      xfrm: refine validation of template and selector families · bc09fc5d
      Florian Westphal authored
      commit 35e61038 upstream.
      
      The check assumes that in transport mode, the first templates family
      must match the address family of the policy selector.
      
      Syzkaller managed to build a template using MODE_ROUTEOPTIMIZATION,
      with ipv4-in-ipv6 chain, leading to following splat:
      
      BUG: KASAN: stack-out-of-bounds in xfrm_state_find+0x1db/0x1854
      Read of size 4 at addr ffff888063e57aa0 by task a.out/2050
       xfrm_state_find+0x1db/0x1854
       xfrm_tmpl_resolve+0x100/0x1d0
       xfrm_resolve_and_create_bundle+0x108/0x1000 [..]
      
      Problem is that addresses point into flowi4 struct, but xfrm_state_find
      treats them as being ipv6 because it uses templ->encap_family is used
      (AF_INET6 in case of reproducer) rather than family (AF_INET).
      
      This patch inverts the logic: Enforce 'template family must match
      selector' EXCEPT for tunnel and BEET mode.
      
      In BEET and Tunnel mode, xfrm_tmpl_resolve_one will have remote/local
      address pointers changed to point at the addresses found in the template,
      rather than the flowi ones, so no oob read will occur.
      
      Reported-by: 3ntr0py1337@gmail.com
      Reported-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc09fc5d
    • Ilya Dryomov's avatar
      libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive() · 264c83c2
      Ilya Dryomov authored
      commit 4aac9228 upstream.
      
      con_fault() can transition the connection into STANDBY right after
      ceph_con_keepalive() clears STANDBY in clear_standby():
      
          libceph user thread               ceph-msgr worker
      
      ceph_con_keepalive()
        mutex_lock(&con->mutex)
        clear_standby(con)
        mutex_unlock(&con->mutex)
                                      mutex_lock(&con->mutex)
                                      con_fault()
                                        ...
                                        if KEEPALIVE_PENDING isn't set
                                          set state to STANDBY
                                        ...
                                      mutex_unlock(&con->mutex)
        set KEEPALIVE_PENDING
        set WRITE_PENDING
      
      This triggers warnings in clear_standby() when either ceph_con_send()
      or ceph_con_keepalive() get to clearing STANDBY next time.
      
      I don't see a reason to condition queue_con() call on the previous
      value of KEEPALIVE_PENDING, so move the setting of KEEPALIVE_PENDING
      into the critical section -- unlike WRITE_PENDING, KEEPALIVE_PENDING
      could have been a non-atomic flag.
      
      Reported-by: syzbot+acdeb633f6211ccdf886@syzkaller.appspotmail.com
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Tested-by: default avatarMyungho Jung <mhjungk@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      264c83c2
    • Theodore Ts'o's avatar
      Revert "ext4: use ext4_write_inode() when fsyncing w/o a journal" · 850d4760
      Theodore Ts'o authored
      commit 8fdd60f2 upstream.
      
      This reverts commit ad211f3e.
      
      As Jan Kara pointed out, this change was unsafe since it means we lose
      the call to sync_mapping_buffers() in the nojournal case.  The
      original point of the commit was avoid taking the inode mutex (since
      it causes a lockdep warning in generic/113); but we need the mutex in
      order to call sync_mapping_buffers().
      
      The real fix to this problem was discussed here:
      
      https://lore.kernel.org/lkml/20181025150540.259281-4-bvanassche@acm.org
      
      The proposed patch was to fix a syzbot complaint, but the problem can
      also demonstrated via "kvm-xfstests -c nojournal generic/113".
      Multiple solutions were discused in the e-mail thread, but none have
      landed in the kernel as of this writing.  Anyway, commit
      ad211f3e is absolutely the wrong way to suppress the lockdep, so
      revert it.
      
      Fixes: ad211f3e ("ext4: use ext4_write_inode() when fsyncing w/o a journal")
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Reported: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      850d4760
    • Vladis Dronov's avatar
      HID: debug: fix the ring buffer implementation · e0f784bf
      Vladis Dronov authored
      commit 13054abb upstream.
      
      Ring buffer implementation in hid_debug_event() and hid_debug_events_read()
      is strange allowing lost or corrupted data. After commit 717adfda
      ("HID: debug: check length before copy_to_user()") it is possible to enter
      an infinite loop in hid_debug_events_read() by providing 0 as count, this
      locks up a system. Fix this by rewriting the ring buffer implementation
      with kfifo and simplify the code.
      
      This fixes CVE-2019-3819.
      
      v2: fix an execution logic and add a comment
      v3: use __set_current_state() instead of set_current_state()
      
      Backport to v4.14: 2 tree-wide patches 6396bb22 ("treewide: kzalloc() ->
      kcalloc()") and a9a08845 ("vfs: do bulk POLL* -> EPOLL* replacement")
      are missing in v4.14 so cherry-pick relevant pieces.
      
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=1669187
      Cc: stable@vger.kernel.org # v4.18+
      Fixes: cd667ce2 ("HID: use debugfs for events/reports dumping")
      Fixes: 717adfda ("HID: debug: check length before copy_to_user()")
      Signed-off-by: default avatarVladis Dronov <vdronov@redhat.com>
      Reviewed-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e0f784bf
    • Thomas Hellstrom's avatar
      drm/vmwgfx: Return error code from vmw_execbuf_copy_fence_user · 7fa5536f
      Thomas Hellstrom authored
      commit 728354c0 upstream.
      
      The function was unconditionally returning 0, and a caller would have to
      rely on the returned fence pointer being NULL to detect errors. However,
      the function vmw_execbuf_copy_fence_user() would expect a non-zero error
      code in that case and would BUG otherwise.
      
      So make sure we return a proper non-zero error code if the fence pointer
      returned is NULL.
      
      Cc: <stable@vger.kernel.org>
      Fixes: ae2a1040: ("vmwgfx: Implement fence objects")
      Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Reviewed-by: default avatarDeepak Rawat <drawat@vmware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7fa5536f
    • Thomas Hellstrom's avatar
      drm/vmwgfx: Fix setting of dma masks · d69e310c
      Thomas Hellstrom authored
      commit 4cbfa1e6 upstream.
      
      Previously we set only the dma mask and not the coherent mask. Fix that.
      Also, for clarity, make sure both are initially set to 64 bits.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 0d00c488: ("drm/vmwgfx: Fix the driver for large dma addresses")
      Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Reviewed-by: default avatarDeepak Rawat <drawat@vmware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d69e310c
    • Tina Zhang's avatar
      drm/modes: Prevent division by zero htotal · 90c7dfa3
      Tina Zhang authored
      commit a2fcd5c8 upstream.
      
      This patch prevents division by zero htotal.
      
      In a follow-up mail Tina writes:
      
      > > How did you manage to get here with htotal == 0? This needs backtraces (or if
      > > this is just about static checkers, a mention of that).
      > > -Daniel
      >
      > In GVT-g, we are trying to enable a virtual display w/o setting timings for a pipe
      > (a.k.a htotal=0), then we met the following kernel panic:
      >
      > [   32.832048] divide error: 0000 [#1] SMP PTI
      > [   32.833614] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc4-sriov+ #33
      > [   32.834438] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.10.1-0-g8891697-dirty-20180511_165818-tinazhang-linux-1 04/01/2014
      > [   32.835901] RIP: 0010:drm_mode_hsync+0x1e/0x40
      > [   32.836004] Code: 31 c0 c3 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 8b 87 d8 00 00 00 85 c0 75 22 8b 4f 68 85 c9 78 1b 69 47 58 e8 03 00 00 99 <f7> f9 b9 d3 4d 62 10 05 f4 01 00 00 f7 e1 89 d0 c1 e8 06 f3 c3 66
      > [   32.836004] RSP: 0000:ffffc900000ebb90 EFLAGS: 00010206
      > [   32.836004] RAX: 0000000000000000 RBX: ffff88001c67c8a0 RCX: 0000000000000000
      > [   32.836004] RDX: 0000000000000000 RSI: ffff88001c67c000 RDI: ffff88001c67c8a0
      > [   32.836004] RBP: ffff88001c7d03a0 R08: ffff88001c67c8a0 R09: ffff88001c7d0330
      > [   32.836004] R10: ffffffff822c3a98 R11: 0000000000000001 R12: ffff88001c67c000
      > [   32.836004] R13: ffff88001c7d0370 R14: ffffffff8207eb78 R15: ffff88001c67c800
      > [   32.836004] FS:  0000000000000000(0000) GS:ffff88001da00000(0000) knlGS:0000000000000000
      > [   32.836004] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      > [   32.836004] CR2: 0000000000000000 CR3: 000000000220a000 CR4: 00000000000006f0
      > [   32.836004] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      > [   32.836004] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      > [   32.836004] Call Trace:
      > [   32.836004]  intel_mode_from_pipe_config+0x72/0x90
      > [   32.836004]  intel_modeset_setup_hw_state+0x569/0xf90
      > [   32.836004]  intel_modeset_init+0x905/0x1db0
      > [   32.836004]  i915_driver_load+0xb8c/0x1120
      > [   32.836004]  i915_pci_probe+0x4d/0xb0
      > [   32.836004]  local_pci_probe+0x44/0xa0
      > [   32.836004]  ? pci_assign_irq+0x27/0x130
      > [   32.836004]  pci_device_probe+0x102/0x1c0
      > [   32.836004]  driver_probe_device+0x2b8/0x480
      > [   32.836004]  __driver_attach+0x109/0x110
      > [   32.836004]  ? driver_probe_device+0x480/0x480
      > [   32.836004]  bus_for_each_dev+0x67/0xc0
      > [   32.836004]  ? klist_add_tail+0x3b/0x70
      > [   32.836004]  bus_add_driver+0x1e8/0x260
      > [   32.836004]  driver_register+0x5b/0xe0
      > [   32.836004]  ? mipi_dsi_bus_init+0x11/0x11
      > [   32.836004]  do_one_initcall+0x4d/0x1eb
      > [   32.836004]  kernel_init_freeable+0x197/0x237
      > [   32.836004]  ? rest_init+0xd0/0xd0
      > [   32.836004]  kernel_init+0xa/0x110
      > [   32.836004]  ret_from_fork+0x35/0x40
      > [   32.836004] Modules linked in:
      > [   32.859183] ---[ end trace 525608b0ed0e8665 ]---
      > [   32.859722] RIP: 0010:drm_mode_hsync+0x1e/0x40
      > [   32.860287] Code: 31 c0 c3 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 8b 87 d8 00 00 00 85 c0 75 22 8b 4f 68 85 c9 78 1b 69 47 58 e8 03 00 00 99 <f7> f9 b9 d3 4d 62 10 05 f4 01 00 00 f7 e1 89 d0 c1 e8 06 f3 c3 66
      > [   32.862680] RSP: 0000:ffffc900000ebb90 EFLAGS: 00010206
      > [   32.863309] RAX: 0000000000000000 RBX: ffff88001c67c8a0 RCX: 0000000000000000
      > [   32.864182] RDX: 0000000000000000 RSI: ffff88001c67c000 RDI: ffff88001c67c8a0
      > [   32.865206] RBP: ffff88001c7d03a0 R08: ffff88001c67c8a0 R09: ffff88001c7d0330
      > [   32.866359] R10: ffffffff822c3a98 R11: 0000000000000001 R12: ffff88001c67c000
      > [   32.867213] R13: ffff88001c7d0370 R14: ffffffff8207eb78 R15: ffff88001c67c800
      > [   32.868075] FS:  0000000000000000(0000) GS:ffff88001da00000(0000) knlGS:0000000000000000
      > [   32.868983] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      > [   32.869659] CR2: 0000000000000000 CR3: 000000000220a000 CR4: 00000000000006f0
      > [   32.870599] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      > [   32.871598] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      > [   32.872549] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
      >
      > Since drm_mode_hsync() has the logic to check mode->htotal, I just extend it to cover the case htotal==0.
      Signed-off-by: default avatarTina Zhang <tina.zhang@intel.com>
      Cc: Adam Jackson <ajax@redhat.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      [danvet: Add additional explanations + cc: stable.]
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/1548228539-3061-1-git-send-email-tina.zhang@intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      90c7dfa3