Skip to content
Snippets Groups Projects
  1. Feb 28, 2020
    • Greg Kroah-Hartman's avatar
      Linux 4.4.215 · 1721173e
      Greg Kroah-Hartman authored
      v4.4.215
      1721173e
    • Thomas Gleixner's avatar
      xen: Enable interrupts when calling _cond_resched() · 5d9635bc
      Thomas Gleixner authored
      
      commit 8645e56a upstream.
      
      xen_maybe_preempt_hcall() is called from the exception entry point
      xen_do_hypervisor_callback with interrupts disabled.
      
      _cond_resched() evades the might_sleep() check in cond_resched() which
      would have caught that and schedule_debug() unfortunately lacks a check
      for irqs_disabled().
      
      Enable interrupts around the call and use cond_resched() to catch future
      issues.
      
      Fixes: fdfd811d ("x86/xen: allow privcmd hypercalls to be preempted")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/878skypjrh.fsf@nanos.tec.linutronix.de
      
      
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5d9635bc
    • Takashi Iwai's avatar
      ALSA: seq: Fix concurrent access to queue current tick/time · 2245b29f
      Takashi Iwai authored
      
      commit dc749779 upstream.
      
      snd_seq_check_queue() passes the current tick and time of the given
      queue as a pointer to snd_seq_prioq_cell_out(), but those might be
      updated concurrently by the seq timer update.
      
      Fix it by retrieving the current tick and time via the proper helper
      functions at first, and pass those values to snd_seq_prioq_cell_out()
      later in the loops.
      
      snd_seq_timer_get_cur_time() takes a new argument and adjusts with the
      current system time only when it's requested so; this update isn't
      needed for snd_seq_check_queue(), as it's called either from the
      interrupt handler or right after queuing.
      
      Also, snd_seq_timer_get_cur_tick() is changed to read the value in the
      spinlock for the concurrency, too.
      
      Reported-by: default avatar <syzbot+fd5e0eaa1a32999173b2@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/20200214111316.26939-3-tiwai@suse.de
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2245b29f
    • Takashi Iwai's avatar
      ALSA: seq: Avoid concurrent access to queue flags · 2bc3bde2
      Takashi Iwai authored
      
      commit bb51e669 upstream.
      
      The queue flags are represented in bit fields and the concurrent
      access may result in unexpected results.  Although the current code
      should be mostly OK as it's only reading a field while writing other
      fields as KCSAN reported, it's safer to cover both with a proper
      spinlock protection.
      
      This patch fixes the possible concurrent read by protecting with
      q->owner_lock.  Also the queue owner field is protected as well since
      it's the field to be protected by the lock itself.
      
      Reported-by: default avatar <syzbot+65c6c92d04304d0a8efc@syzkaller.appspotmail.com>
      Reported-by: default avatar <syzbot+e60ddfa48717579799dd@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/20200214111316.26939-2-tiwai@suse.de
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2bc3bde2
    • Takashi Iwai's avatar
      ALSA: rawmidi: Avoid bit fields for state flags · 68ff19b0
      Takashi Iwai authored
      
      commit dfa9a5ef upstream.
      
      The rawmidi state flags (opened, append, active_sensing) are stored in
      bit fields that can be potentially racy when concurrently accessed
      without any locks.  Although the current code should be fine, there is
      also no any real benefit by keeping the bitfields for this kind of
      short number of members.
      
      This patch changes those bit fields flags to the simple bool fields.
      There should be no size increase of the snd_rawmidi_substream by this
      change.
      
      Reported-by: default avatar <syzbot+576cc007eb9f2c968200@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/20200214111316.26939-4-tiwai@suse.de
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68ff19b0
    • Aditya Pakki's avatar
      ecryptfs: replace BUG_ON with error handling code · bbd3d0f4
      Aditya Pakki authored
      
      commit 2c2a7552 upstream.
      
      In crypt_scatterlist, if the crypt_stat argument is not set up
      correctly, the kernel crashes. Instead, by returning an error code
      upstream, the error is handled safely.
      
      The issue is detected via a static analysis tool written by us.
      
      Fixes: 237fead6 (ecryptfs: fs/Makefile and fs/Kconfig)
      Signed-off-by: default avatarAditya Pakki <pakki001@umn.edu>
      Signed-off-by: default avatarTyler Hicks <code@tyhicks.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbd3d0f4
    • Bart Van Assche's avatar
      scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session" · fb78ebdf
      Bart Van Assche authored
      commit 807b9515 upstream.
      
      Since commit e9d3009c introduced a regression and since the fix for
      that regression was not perfect, revert this commit.
      
      Link: https://marc.info/?l=target-devel&m=158157054906195
      
      
      Cc: Rahul Kundu <rahul.kundu@chelsio.com>
      Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
      Cc: Sagi Grimberg <sagi@grimberg.me>
      Reported-by: default avatarDakshaja Uppalapati <dakshaja@chelsio.com>
      Fixes: e9d3009c ("scsi: target: iscsi: Wait for all commands to finish before freeing a session")
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fb78ebdf
    • Bart Van Assche's avatar
      scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout" · 5a020781
      Bart Van Assche authored
      commit 76261ada upstream.
      
      Since commit 04060db4 introduces soft lockups when toggling network
      interfaces, revert it.
      
      Link: https://marc.info/?l=target-devel&m=158157054906196
      
      
      Cc: Rahul Kundu <rahul.kundu@chelsio.com>
      Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
      Cc: Sagi Grimberg <sagi@grimberg.me>
      Reported-by: default avatarDakshaja Uppalapati <dakshaja@chelsio.com>
      Fixes: 04060db4 ("scsi: RDMA/isert: Fix a recently introduced regression related to logout")
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a020781
    • Filipe Manana's avatar
      Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents · 6c0fc3d1
      Filipe Manana authored
      commit e75fd33b upstream.
      
      In btrfs_wait_ordered_range() once we find an ordered extent that has
      finished with an error we exit the loop and don't wait for any other
      ordered extents that might be still in progress.
      
      All the users of btrfs_wait_ordered_range() expect that there are no more
      ordered extents in progress after that function returns. So past fixes
      such like the ones from the two following commits:
      
        ff612ba7 ("btrfs: fix panic during relocation after ENOSPC before
                         writeback happens")
      
        28aeeac1 ("Btrfs: fix panic when starting bg cache writeout after
                         IO error")
      
      don't work when there are multiple ordered extents in the range.
      
      Fix that by making btrfs_wait_ordered_range() wait for all ordered extents
      even after it finds one that had an error.
      
      Link: https://github.com/kdave/btrfs-progs/issues/228#issuecomment-569777554
      
      
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c0fc3d1
    • Miaohe Lin's avatar
      KVM: apic: avoid calculating pending eoi from an uninitialized val · ec94e53c
      Miaohe Lin authored
      
      commit 23520b2d upstream.
      
      When pv_eoi_get_user() fails, 'val' may remain uninitialized and the return
      value of pv_eoi_get_pending() becomes random. Fix the issue by initializing
      the variable.
      
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec94e53c
    • Oliver Upton's avatar
      KVM: nVMX: Check IO instruction VM-exit conditions · 0e9a4cec
      Oliver Upton authored
      
      commit 35a57134 upstream.
      
      Consult the 'unconditional IO exiting' and 'use IO bitmaps' VM-execution
      controls when checking instruction interception. If the 'use IO bitmaps'
      VM-execution control is 1, check the instruction access against the IO
      bitmaps to determine if the instruction causes a VM-exit.
      
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e9a4cec
    • Oliver Upton's avatar
      KVM: nVMX: Refactor IO bitmap checks into helper function · bc1c6081
      Oliver Upton authored
      
      commit e71237d3 upstream.
      
      Checks against the IO bitmap are useful for both instruction emulation
      and VM-exit reflection. Refactor the IO bitmap checks into a helper
      function.
      
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc1c6081
    • Shijie Luo's avatar
      ext4: add cond_resched() to __ext4_find_entry() · 2083e63a
      Shijie Luo authored
      commit 9424ef56 upstream.
      
      We tested a soft lockup problem in linux 4.19 which could also
      be found in linux 5.x.
      
      When dir inode takes up a large number of blocks, and if the
      directory is growing when we are searching, it's possible the
      restart branch could be called many times, and the do while loop
      could hold cpu a long time.
      
      Here is the call trace in linux 4.19.
      
      [  473.756186] Call trace:
      [  473.756196]  dump_backtrace+0x0/0x198
      [  473.756199]  show_stack+0x24/0x30
      [  473.756205]  dump_stack+0xa4/0xcc
      [  473.756210]  watchdog_timer_fn+0x300/0x3e8
      [  473.756215]  __hrtimer_run_queues+0x114/0x358
      [  473.756217]  hrtimer_interrupt+0x104/0x2d8
      [  473.756222]  arch_timer_handler_virt+0x38/0x58
      [  473.756226]  handle_percpu_devid_irq+0x90/0x248
      [  473.756231]  generic_handle_irq+0x34/0x50
      [  473.756234]  __handle_domain_irq+0x68/0xc0
      [  473.756236]  gic_handle_irq+0x6c/0x150
      [  473.756238]  el1_irq+0xb8/0x140
      [  473.756286]  ext4_es_lookup_extent+0xdc/0x258 [ext4]
      [  473.756310]  ext4_map_blocks+0x64/0x5c0 [ext4]
      [  473.756333]  ext4_getblk+0x6c/0x1d0 [ext4]
      [  473.756356]  ext4_bread_batch+0x7c/0x1f8 [ext4]
      [  473.756379]  ext4_find_entry+0x124/0x3f8 [ext4]
      [  473.756402]  ext4_lookup+0x8c/0x258 [ext4]
      [  473.756407]  __lookup_hash+0x8c/0xe8
      [  473.756411]  filename_create+0xa0/0x170
      [  473.756413]  do_mkdirat+0x6c/0x140
      [  473.756415]  __arm64_sys_mkdirat+0x28/0x38
      [  473.756419]  el0_svc_common+0x78/0x130
      [  473.756421]  el0_svc_handler+0x38/0x78
      [  473.756423]  el0_svc+0x8/0xc
      [  485.755156] watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [tmp:5149]
      
      Add cond_resched() to avoid soft lockup and to provide a better
      system responding.
      
      Link: https://lore.kernel.org/r/20200215080206.13293-1-luoshijie1@huawei.com
      
      
      Signed-off-by: default avatarShijie Luo <luoshijie1@huawei.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2083e63a
    • Qian Cai's avatar
      ext4: fix a data race in EXT4_I(inode)->i_disksize · e4b14eb8
      Qian Cai authored
      
      commit 35df4299 upstream.
      
      EXT4_I(inode)->i_disksize could be accessed concurrently as noticed by
      KCSAN,
      
       BUG: KCSAN: data-race in ext4_write_end [ext4] / ext4_writepages [ext4]
      
       write to 0xffff91c6713b00f8 of 8 bytes by task 49268 on cpu 127:
        ext4_write_end+0x4e3/0x750 [ext4]
        ext4_update_i_disksize at fs/ext4/ext4.h:3032
        (inlined by) ext4_update_inode_size at fs/ext4/ext4.h:3046
        (inlined by) ext4_write_end at fs/ext4/inode.c:1287
        generic_perform_write+0x208/0x2a0
        ext4_buffered_write_iter+0x11f/0x210 [ext4]
        ext4_file_write_iter+0xce/0x9e0 [ext4]
        new_sync_write+0x29c/0x3b0
        __vfs_write+0x92/0xa0
        vfs_write+0x103/0x260
        ksys_write+0x9d/0x130
        __x64_sys_write+0x4c/0x60
        do_syscall_64+0x91/0xb47
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
       read to 0xffff91c6713b00f8 of 8 bytes by task 24872 on cpu 37:
        ext4_writepages+0x10ac/0x1d00 [ext4]
        mpage_map_and_submit_extent at fs/ext4/inode.c:2468
        (inlined by) ext4_writepages at fs/ext4/inode.c:2772
        do_writepages+0x5e/0x130
        __writeback_single_inode+0xeb/0xb20
        writeback_sb_inodes+0x429/0x900
        __writeback_inodes_wb+0xc4/0x150
        wb_writeback+0x4bd/0x870
        wb_workfn+0x6b4/0x960
        process_one_work+0x54c/0xbe0
        worker_thread+0x80/0x650
        kthread+0x1e0/0x200
        ret_from_fork+0x27/0x50
      
       Reported by Kernel Concurrency Sanitizer on:
       CPU: 37 PID: 24872 Comm: kworker/u261:2 Tainted: G        W  O L 5.5.0-next-20200204+ #5
       Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019
       Workqueue: writeback wb_workfn (flush-7:0)
      
      Since only the read is operating as lockless (outside of the
      "i_data_sem"), load tearing could introduce a logic bug. Fix it by
      adding READ_ONCE() for the read and WRITE_ONCE() for the write.
      
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Link: https://lore.kernel.org/r/1581085751-31793-1-git-send-email-cai@lca.pw
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4b14eb8
    • Jann Horn's avatar
      netfilter: xt_bpf: add overflow checks · 601adfdf
      Jann Horn authored
      
      [ Upstream commit 6ab40511 ]
      
      Check whether inputs from userspace are too long (explicit length field too
      big or string not null-terminated) to avoid out-of-bounds reads.
      
      As far as I can tell, this can at worst lead to very limited kernel heap
      memory disclosure or oopses.
      
      This bug can be triggered by an unprivileged user even if the xt_bpf module
      is not loaded: iptables is available in network namespaces, and the xt_bpf
      module can be autoloaded.
      
      Triggering the bug with a classic BPF filter with fake length 0x1000 causes
      the following KASAN report:
      
      ==================================================================
      BUG: KASAN: slab-out-of-bounds in bpf_prog_create+0x84/0xf0
      Read of size 32768 at addr ffff8801eff2c494 by task test/4627
      
      CPU: 0 PID: 4627 Comm: test Not tainted 4.15.0-rc1+ #1
      [...]
      Call Trace:
       dump_stack+0x5c/0x85
       print_address_description+0x6a/0x260
       kasan_report+0x254/0x370
       ? bpf_prog_create+0x84/0xf0
       memcpy+0x1f/0x50
       bpf_prog_create+0x84/0xf0
       bpf_mt_check+0x90/0xd6 [xt_bpf]
      [...]
      Allocated by task 4627:
       kasan_kmalloc+0xa0/0xd0
       __kmalloc_node+0x47/0x60
       xt_alloc_table_info+0x41/0x70 [x_tables]
      [...]
      The buggy address belongs to the object at ffff8801eff2c3c0
                      which belongs to the cache kmalloc-2048 of size 2048
      The buggy address is located 212 bytes inside of
                      2048-byte region [ffff8801eff2c3c0, ffff8801eff2cbc0)
      [...]
      ==================================================================
      
      Fixes: e6f30c73 ("netfilter: x_tables: add xt_bpf match")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarZubin Mithra <zsm@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      601adfdf
    • Paolo Bonzini's avatar
      KVM: nVMX: Don't emulate instructions in guest mode · 27021607
      Paolo Bonzini authored
      
      [ Upstream commit 07721fee ]
      
      vmx_check_intercept is not yet fully implemented. To avoid emulating
      instructions disallowed by the L1 hypervisor, refuse to emulate
      instructions by default.
      
      Cc: stable@vger.kernel.org
      [Made commit, added commit msg - Oliver]
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      27021607
    • Eric Dumazet's avatar
      vt: vt_ioctl: fix race in VT_RESIZEX · 803bc73a
      Eric Dumazet authored
      
      [ Upstream commit 6cd1ed50 ]
      
      We need to make sure vc_cons[i].d is not NULL after grabbing
      console_lock(), or risk a crash.
      
      general protection fault, probably for non-canonical address 0xdffffc0000000068: 0000 [#1] PREEMPT SMP KASAN
      KASAN: null-ptr-deref in range [0x0000000000000340-0x0000000000000347]
      CPU: 1 PID: 19462 Comm: syz-executor.5 Not tainted 5.5.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:vt_ioctl+0x1f96/0x26d0 drivers/tty/vt/vt_ioctl.c:883
      Code: 74 41 e8 bd a6 84 fd 48 89 d8 48 c1 e8 03 42 80 3c 28 00 0f 85 e4 04 00 00 48 8b 03 48 8d b8 40 03 00 00 48 89 fa 48 c1 ea 03 <42> 0f b6 14 2a 84 d2 74 09 80 fa 03 0f 8e b1 05 00 00 44 89 b8 40
      RSP: 0018:ffffc900086d7bb0 EFLAGS: 00010202
      RAX: 0000000000000000 RBX: ffffffff8c34ee88 RCX: ffffc9001415c000
      RDX: 0000000000000068 RSI: ffffffff83f0e6e3 RDI: 0000000000000340
      RBP: ffffc900086d7cd0 R08: ffff888054ce0100 R09: fffffbfff16a2f6d
      R10: ffff888054ce0998 R11: ffff888054ce0100 R12: 000000000000001d
      R13: dffffc0000000000 R14: 1ffff920010daf79 R15: 000000000000ff7f
      FS:  00007f7d13c12700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffd477e3c38 CR3: 0000000095d0a000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       tty_ioctl+0xa37/0x14f0 drivers/tty/tty_io.c:2660
       vfs_ioctl fs/ioctl.c:47 [inline]
       ksys_ioctl+0x123/0x180 fs/ioctl.c:763
       __do_sys_ioctl fs/ioctl.c:772 [inline]
       __se_sys_ioctl fs/ioctl.c:770 [inline]
       __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:770
       do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x45b399
      Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007f7d13c11c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 00007f7d13c126d4 RCX: 000000000045b399
      RDX: 0000000020000080 RSI: 000000000000560a RDI: 0000000000000003
      RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 0000000000000666 R14: 00000000004c7f04 R15: 000000000075bf2c
      Modules linked in:
      ---[ end trace 80970faf7a67eb77 ]---
      RIP: 0010:vt_ioctl+0x1f96/0x26d0 drivers/tty/vt/vt_ioctl.c:883
      Code: 74 41 e8 bd a6 84 fd 48 89 d8 48 c1 e8 03 42 80 3c 28 00 0f 85 e4 04 00 00 48 8b 03 48 8d b8 40 03 00 00 48 89 fa 48 c1 ea 03 <42> 0f b6 14 2a 84 d2 74 09 80 fa 03 0f 8e b1 05 00 00 44 89 b8 40
      RSP: 0018:ffffc900086d7bb0 EFLAGS: 00010202
      RAX: 0000000000000000 RBX: ffffffff8c34ee88 RCX: ffffc9001415c000
      RDX: 0000000000000068 RSI: ffffffff83f0e6e3 RDI: 0000000000000340
      RBP: ffffc900086d7cd0 R08: ffff888054ce0100 R09: fffffbfff16a2f6d
      R10: ffff888054ce0998 R11: ffff888054ce0100 R12: 000000000000001d
      R13: dffffc0000000000 R14: 1ffff920010daf79 R15: 000000000000ff7f
      FS:  00007f7d13c12700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffd477e3c38 CR3: 0000000095d0a000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Link: https://lore.kernel.org/r/20200210190721.200418-1-edumazet@google.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      803bc73a
    • Al Viro's avatar
      VT_RESIZEX: get rid of field-by-field copyin · b380e8c7
      Al Viro authored
      
      [ Upstream commit 1b3bce4d ]
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b380e8c7
    • Mathias Nyman's avatar
      xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms · efe7e885
      Mathias Nyman authored
      
      commit a3ae87dc upstream.
      
      Intel Comet Lake based platform require the XHCI_PME_STUCK_QUIRK
      quirk as well. Without this xHC can not enter D3 in runtime suspend.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20200210134553.9144-5-mathias.nyman@linux.intel.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      efe7e885
    • Ioanna Alifieraki's avatar
      Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()" · 7b14d607
      Ioanna Alifieraki authored
      commit edf28f40 upstream.
      
      This reverts commit a9795584.
      
      Commit a9795584 ("ipc,sem: remove uneeded sem_undo_list lock usage
      in exit_sem()") removes a lock that is needed.  This leads to a process
      looping infinitely in exit_sem() and can also lead to a crash.  There is
      a reproducer available in [1] and with the commit reverted the issue
      does not reproduce anymore.
      
      Using the reproducer found in [1] is fairly easy to reach a point where
      one of the child processes is looping infinitely in exit_sem between
      for(;;) and if (semid == -1) block, while it's trying to free its last
      sem_undo structure which has already been freed by freeary().
      
      Each sem_undo struct is on two lists: one per semaphore set (list_id)
      and one per process (list_proc).  The list_id list tracks undos by
      semaphore set, and the list_proc by process.
      
      Undo structures are removed either by freeary() or by exit_sem().  The
      freeary function is invoked when the user invokes a syscall to remove a
      semaphore set.  During this operation freeary() traverses the list_id
      associated with the semaphore set and removes the undo structures from
      both the list_id and list_proc lists.
      
      For this case, exit_sem() is called at process exit.  Each process
      contains a struct sem_undo_list (referred to as "ulp") which contains
      the head for the list_proc list.  When the process exits, exit_sem()
      traverses this list to remove each sem_undo struct.  As in freeary(),
      whenever a sem_undo struct is removed from list_proc, it is also removed
      from the list_id list.
      
      Removing elements from list_id is safe for both exit_sem() and freeary()
      due to sem_lock().  Removing elements from list_proc is not safe;
      freeary() locks &un->ulp->lock when it performs
      list_del_rcu(&un->list_proc) but exit_sem() does not (locking was
      removed by commit a9795584 ("ipc,sem: remove uneeded sem_undo_list
      lock usage in exit_sem()").
      
      This can result in the following situation while executing the
      reproducer [1] : Consider a child process in exit_sem() and the parent
      in freeary() (because of semctl(sid[i], NSEM, IPC_RMID)).
      
       - The list_proc for the child contains the last two undo structs A and
         B (the rest have been removed either by exit_sem() or freeary()).
      
       - The semid for A is 1 and semid for B is 2.
      
       - exit_sem() removes A and at the same time freeary() removes B.
      
       - Since A and B have different semid sem_lock() will acquire different
         locks for each process and both can proceed.
      
      The bug is that they remove A and B from the same list_proc at the same
      time because only freeary() acquires the ulp lock. When exit_sem()
      removes A it makes ulp->list_proc.next to point at B and at the same
      time freeary() removes B setting B->semid=-1.
      
      At the next iteration of for(;;) loop exit_sem() will try to remove B.
      
      The only way to break from for(;;) is for (&un->list_proc ==
      &ulp->list_proc) to be true which is not. Then exit_sem() will check if
      B->semid=-1 which is and will continue looping in for(;;) until the
      memory for B is reallocated and the value at B->semid is changed.
      
      At that point, exit_sem() will crash attempting to unlink B from the
      lists (this can be easily triggered by running the reproducer [1] a
      second time).
      
      To prove this scenario instrumentation was added to keep information
      about each sem_undo (un) struct that is removed per process and per
      semaphore set (sma).
      
                CPU0                                CPU1
        [caller holds sem_lock(sma for A)]      ...
        freeary()                               exit_sem()
        ...                                     ...
        ...                                     sem_lock(sma for B)
        spin_lock(A->ulp->lock)                 ...
        list_del_rcu(un_A->list_proc)           list_del_rcu(un_B->list_proc)
      
      Undo structures A and B have different semid and sem_lock() operations
      proceed.  However they belong to the same list_proc list and they are
      removed at the same time.  This results into ulp->list_proc.next
      pointing to the address of B which is already removed.
      
      After reverting commit a9795584 ("ipc,sem: remove uneeded
      sem_undo_list lock usage in exit_sem()") the issue was no longer
      reproducible.
      
      [1] https://bugzilla.redhat.com/show_bug.cgi?id=1694779
      
      Link: http://lkml.kernel.org/r/20191211191318.11860-1-ioanna-maria.alifieraki@canonical.com
      
      
      Fixes: a9795584 ("ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()")
      Signed-off-by: default avatarIoanna Alifieraki <ioanna-maria.alifieraki@canonical.com>
      Acked-by: default avatarManfred Spraul <manfred@colorfullife.com>
      Acked-by: default avatarHerton R. Krzesinski <herton@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: <malat@debian.org>
      Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Jay Vosburgh <jay.vosburgh@canonical.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b14d607
    • Fugang Duan's avatar
      tty: serial: imx: setup the correct sg entry for tx dma · 7e278b11
      Fugang Duan authored
      
      commit f7670783 upstream.
      
      There has oops as below happen on i.MX8MP EVK platform that has
      6G bytes DDR memory.
      
      when (xmit->tail < xmit->head) && (xmit->head == 0),
      it setups one sg entry with sg->length is zero:
      	sg_set_buf(sgl + 1, xmit->buf, xmit->head);
      
      if xmit->buf is allocated from >4G address space, and SDMA only
      support <4G address space, then dma_map_sg() will call swiotlb_map()
      to do bounce buffer copying and mapping.
      
      But swiotlb_map() don't allow sg entry's length is zero, otherwise
      report BUG_ON().
      
      So the patch is to correct the tx DMA scatter list.
      
      Oops:
      [  287.675715] kernel BUG at kernel/dma/swiotlb.c:497!
      [  287.680592] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      [  287.686075] Modules linked in:
      [  287.689133] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.3-00016-g3fdc4e0-dirty #10
      [  287.696872] Hardware name: FSL i.MX8MP EVK (DT)
      [  287.701402] pstate: 80000085 (Nzcv daIf -PAN -UAO)
      [  287.706199] pc : swiotlb_tbl_map_single+0x1fc/0x310
      [  287.711076] lr : swiotlb_map+0x60/0x148
      [  287.714909] sp : ffff800010003c00
      [  287.718221] x29: ffff800010003c00 x28: 0000000000000000
      [  287.723533] x27: 0000000000000040 x26: ffff800011ae0000
      [  287.728844] x25: ffff800011ae09f8 x24: 0000000000000000
      [  287.734155] x23: 00000001b7af9000 x22: 0000000000000000
      [  287.739465] x21: ffff000176409c10 x20: 00000000001f7ffe
      [  287.744776] x19: ffff000176409c10 x18: 000000000000002e
      [  287.750087] x17: 0000000000000000 x16: 0000000000000000
      [  287.755397] x15: 0000000000000000 x14: 0000000000000000
      [  287.760707] x13: ffff00017f334000 x12: 0000000000000001
      [  287.766018] x11: 00000000001fffff x10: 0000000000000000
      [  287.771328] x9 : 0000000000000003 x8 : 0000000000000000
      [  287.776638] x7 : 0000000000000000 x6 : 0000000000000000
      [  287.781949] x5 : 0000000000200000 x4 : 0000000000000000
      [  287.787259] x3 : 0000000000000001 x2 : 00000001b7af9000
      [  287.792570] x1 : 00000000fbfff000 x0 : 0000000000000000
      [  287.797881] Call trace:
      [  287.800328]  swiotlb_tbl_map_single+0x1fc/0x310
      [  287.804859]  swiotlb_map+0x60/0x148
      [  287.808347]  dma_direct_map_page+0xf0/0x130
      [  287.812530]  dma_direct_map_sg+0x78/0xe0
      [  287.816453]  imx_uart_dma_tx+0x134/0x2f8
      [  287.820374]  imx_uart_dma_tx_callback+0xd8/0x168
      [  287.824992]  vchan_complete+0x194/0x200
      [  287.828828]  tasklet_action_common.isra.0+0x154/0x1a0
      [  287.833879]  tasklet_action+0x24/0x30
      [  287.837540]  __do_softirq+0x120/0x23c
      [  287.841202]  irq_exit+0xb8/0xd8
      [  287.844343]  __handle_domain_irq+0x64/0xb8
      [  287.848438]  gic_handle_irq+0x5c/0x148
      [  287.852185]  el1_irq+0xb8/0x180
      [  287.855327]  cpuidle_enter_state+0x84/0x360
      [  287.859508]  cpuidle_enter+0x34/0x48
      [  287.863083]  call_cpuidle+0x18/0x38
      [  287.866571]  do_idle+0x1e0/0x280
      [  287.869798]  cpu_startup_entry+0x20/0x40
      [  287.873721]  rest_init+0xd4/0xe0
      [  287.876949]  arch_call_rest_init+0xc/0x14
      [  287.880958]  start_kernel+0x420/0x44c
      [  287.884622] Code: 9124c021 9417aff8 a94363f7 17ffffd5 (d4210000)
      [  287.890718] ---[ end trace 5bc44c4ab6b009ce ]---
      [  287.895334] Kernel panic - not syncing: Fatal exception in interrupt
      [  287.901686] SMP: stopping secondary CPUs
      [  288.905607] SMP: failed to stop secondary CPUs 0-1
      [  288.910395] Kernel Offset: disabled
      [  288.913882] CPU features: 0x0002,2000200c
      [  288.917888] Memory Limit: none
      [  288.920944] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
      
      Reported-by: default avatarEagle Zhou <eagle.zhou@nxp.com>
      Tested-by: default avatarEagle Zhou <eagle.zhou@nxp.com>
      Signed-off-by: default avatarFugang Duan <fugang.duan@nxp.com>
      Cc: stable <stable@vger.kernel.org>
      Fixes: 7942f857 ("serial: imx: TX DMA: clean up sg initialization")
      Reviewed-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Link: https://lore.kernel.org/r/1581401761-6378-1-git-send-email-fugang.duan@nxp.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e278b11
    • Thomas Gleixner's avatar
      x86/mce/amd: Fix kobject lifetime · 470fcc0c
      Thomas Gleixner authored
      
      commit 51dede9c upstream.
      
      Accessing the MCA thresholding controls in sysfs concurrently with CPU
      hotplug can lead to a couple of KASAN-reported issues:
      
        BUG: KASAN: use-after-free in sysfs_file_ops+0x155/0x180
        Read of size 8 at addr ffff888367578940 by task grep/4019
      
      and
      
        BUG: KASAN: use-after-free in show_error_count+0x15c/0x180
        Read of size 2 at addr ffff888368a05514 by task grep/4454
      
      for example. Both result from the fact that the threshold block
      creation/teardown code frees the descriptor memory itself instead of
      defining proper ->release function and leaving it to the driver core to
      take care of that, after all sysfs accesses have completed.
      
      Do that and get rid of the custom freeing code, fixing the above UAFs in
      the process.
      
        [ bp: write commit message. ]
      
      Fixes: 95268664 ("[PATCH] x86_64: mce_amd support for family 0x10 processors")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: <stable@vger.kernel.org>
      Link: https://lkml.kernel.org/r/20200214082801.13836-1-bp@alien8.de
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      470fcc0c
    • Larry Finger's avatar
      staging: rtl8188eu: Fix potential overuse of kernel memory · 2d2c1006
      Larry Finger authored
      
      commit 4ddf8ab8 upstream.
      
      In routine wpa_supplicant_ioctl(), the user-controlled p->length is
      checked to be at least the size of struct ieee_param size, but the code
      does not detect the case where p->length is greater than the size
      of the struct, thus a malicious user could be wasting kernel memory.
      Fixes commit a2c60d42 ("Add files for new driver - part 16").
      
      Reported by: Pietro Oliva <pietroliva@gmail.com>
      Cc: Pietro Oliva <pietroliva@gmail.com>
      Cc: Stable <stable@vger.kernel.org>
      Fixes commit a2c60d42 ("Add files for new driver - part 16").
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Link: https://lore.kernel.org/r/20200210180235.21691-4-Larry.Finger@lwfinger.net
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d2c1006
    • Larry Finger's avatar
      staging: rtl8188eu: Fix potential security hole · a3e4e606
      Larry Finger authored
      
      commit 499c405b upstream.
      
      In routine rtw_hostapd_ioctl(), the user-controlled p->length is assumed
      to be at least the size of struct ieee_param size, but this assumption is
      never checked. This could result in out-of-bounds read/write on kernel
      heap in case a p->length less than the size of struct ieee_param is
      specified by the user. If p->length is allowed to be greater than the size
      of the struct, then a malicious user could be wasting kernel memory.
      Fixes commit a2c60d42 ("Add files for new driver - part 16").
      
      Reported by: Pietro Oliva <pietroliva@gmail.com>
      Cc: Pietro Oliva <pietroliva@gmail.com>
      Cc: Stable <stable@vger.kernel.org>
      Fixes: a2c60d42 ("staging: r8188eu: Add files for new driver - part 16")
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Link: https://lore.kernel.org/r/20200210180235.21691-2-Larry.Finger@lwfinger.net
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3e4e606
    • Alan Stern's avatar
      USB: hub: Don't record a connect-change event during reset-resume · 87ce2c3f
      Alan Stern authored
      
      commit 8099f58f upstream.
      
      Paul Zimmerman reports that his USB Bluetooth adapter sometimes
      crashes following system resume, when it receives a
      Get-Device-Descriptor request while it is busy doing something else.
      
      Such a request was added by commit a4f55d8b ("usb: hub: Check
      device descriptor before resusciation").  It gets sent when the hub
      driver's work thread checks whether a connect-change event on an
      enabled port really indicates a new device has been connected, as
      opposed to an old device momentarily disconnecting and then
      reconnecting (which can happen with xHCI host controllers, since they
      automatically enable connected ports).
      
      The same kind of thing occurs when a port's power session is lost
      during system suspend.  When the system wakes up it sees a
      connect-change event on the port, and if the child device's
      persist_enabled flag was set then hub_activate() sets the device's
      reset_resume flag as well as the port's bit in hub->change_bits.  The
      reset-resume code then takes responsibility for checking that the same
      device is still attached to the port, and it does this as part of the
      device's resume pathway.  By the time the hub driver's work thread
      starts up again, the device has already been fully reinitialized and
      is busy doing its own thing.  There's no need for the work thread to
      do the same check a second time, and in fact this unnecessary check is
      what caused the problem that Paul observed.
      
      Note that performing the unnecessary check is not actually a bug.
      Devices are supposed to be able to send descriptors back to the host
      even when they are busy doing something else.  The underlying cause of
      Paul's problem lies in his Bluetooth adapter.  Nevertheless, we
      shouldn't perform the same check twice in a row -- and as a nice side
      benefit, removing the extra check allows the Bluetooth adapter to work
      more reliably.
      
      The work thread performs its check when it sees that the port's bit is
      set in hub->change_bits.  In this situation that bit is interpreted as
      though a connect-change event had occurred on the port _after_ the
      reset-resume, which is not what actually happened.
      
      One possible fix would be to make the reset-resume code clear the
      port's bit in hub->change_bits.  But it seems simpler to just avoid
      setting the bit during hub_activate() in the first place.  That's what
      this patch does.
      
      (Proving that the patch is correct when CONFIG_PM is disabled requires
      a little thought.  In that setting hub_activate() will be called only
      for initialization and resets, since there won't be any resumes or
      reset-resumes.  During initialization and hub resets the hub doesn't
      have any child devices, and so this code path never gets executed.)
      
      Reported-and-tested-by: default avatarPaul Zimmerman <pauldzim@gmail.com>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://marc.info/?t=157949360700001&r=1&w=2
      CC: David Heinzelmann <heinzelmann.david@gmail.com>
      CC: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2001311037460.1577-100000@iolanthe.rowland.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87ce2c3f
    • Richard Dodd's avatar
      USB: Fix novation SourceControl XL after suspend · 98c723d2
      Richard Dodd authored
      
      commit b692056d upstream.
      
      Currently, the SourceControl will stay in power-down mode after resuming
      from suspend. This patch resets the device after suspend to power it up.
      
      Signed-off-by: default avatarRichard Dodd <richard.o.dodd@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200212142220.36892-1-richard.o.dodd@gmail.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98c723d2
    • EJ Hsu's avatar
      usb: uas: fix a plug & unplug racing · f41dc515
      EJ Hsu authored
      
      commit 3e99862c upstream.
      
      When a uas disk is plugged into an external hub, uas_probe()
      will be called by the hub thread to do the probe. It will
      first create a SCSI host and then do the scan for this host.
      During the scan, it will probe the LUN using SCSI INQUERY command
      which will be packed in the URB and submitted to uas disk.
      
      There might be a chance that this external hub with uas disk
      attached is unplugged during the scan. In this case, uas driver
      will fail to submit the URB (due to the NOTATTACHED state of uas
      device) and try to put this SCSI command back to request queue
      waiting for next chance to run.
      
      In normal case, this cycle will terminate when hub thread gets
      disconnection event and calls into uas_disconnect() accordingly.
      But in this case, uas_disconnect() will not be called because
      hub thread of external hub gets stuck waiting for the completion
      of this SCSI command. A deadlock happened.
      
      In this fix, uas will call scsi_scan_host() asynchronously to
      avoid the blocking of hub thread.
      
      Signed-off-by: default avatarEJ Hsu <ejh@nvidia.com>
      Acked-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200130092506.102760-1-ejh@nvidia.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f41dc515
    • Malcolm Priestley's avatar
      staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi. · d8d7c3f6
      Malcolm Priestley authored
      
      commit 93134df5 upstream.
      
      bb_pre_ed_rssi is an u8 rx_dm always returns negative signed
      values add minus operator to always yield positive.
      
      fixes issue where rx sensitivity is always set to maximum because
      the unsigned numbers were always greater then 100.
      
      Fixes: 63b9907f ("staging: vt6656: mac80211 conversion: create rx function.")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
      Link: https://lore.kernel.org/r/aceac98c-6e69-3ce1-dfec-2bf27b980221@gmail.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8d7c3f6
    • Suren Baghdasaryan's avatar
      staging: android: ashmem: Disallow ashmem memory from being remapped · a349db84
      Suren Baghdasaryan authored
      
      commit 6d67b029 upstream.
      
      When ashmem file is mmapped, the resulting vma->vm_file points to the
      backing shmem file with the generic fops that do not check ashmem
      permissions like fops of ashmem do. If an mremap is done on the ashmem
      region, then the permission checks will be skipped. Fix that by disallowing
      mapping operation on the backing shmem file.
      
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Cc: stable <stable@vger.kernel.org> # 4.4,4.9,4.14,4.18,5.4
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Link: https://lore.kernel.org/r/20200127235616.48920-1-tkjos@google.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a349db84
    • Linus Torvalds's avatar
      floppy: check FDC index for errors before assigning it · 3dd989ef
      Linus Torvalds authored
      
      commit 2e90ca68 upstream.
      
      Jordy Zomer reported a KASAN out-of-bounds read in the floppy driver in
      wait_til_ready().
      
      Which on the face of it can't happen, since as Willy Tarreau points out,
      the function does no particular memory access.  Except through the FDCS
      macro, which just indexes a static allocation through teh current fdc,
      which is always checked against N_FDC.
      
      Except the checking happens after we've already assigned the value.
      
      The floppy driver is a disgrace (a lot of it going back to my original
      horrd "design"), and has no real maintainer.  Nobody has the hardware,
      and nobody really cares.  But it still gets used in virtual environment
      because it's one of those things that everybody supports.
      
      The whole thing should be re-written, or at least parts of it should be
      seriously cleaned up.  The 'current fdc' index, which is used by the
      FDCS macro, and which is often shadowed by a local 'fdc' variable, is a
      prime example of how not to write code.
      
      But because nobody has the hardware or the motivation, let's just fix up
      the immediate problem with a nasty band-aid: test the fdc index before
      actually assigning it to the static 'fdc' variable.
      
      Reported-by: default avatarJordy Zomer <jordy@simplyhacker.com>
      Cc: Willy Tarreau <w@1wt.eu>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3dd989ef
    • Firo Yang's avatar
      enic: prevent waking up stopped tx queues over watchdog reset · ed2a26ac
      Firo Yang authored
      
      [ Upstream commit 0f905225 ]
      
      Recent months, our customer reported several kernel crashes all
      preceding with following message:
      NETDEV WATCHDOG: eth2 (enic): transmit queue 0 timed out
      Error message of one of those crashes:
      BUG: unable to handle kernel paging request at ffffffffa007e090
      
      After analyzing severl vmcores, I found that most of crashes are
      caused by memory corruption. And all the corrupted memory areas
      are overwritten by data of network packets. Moreover, I also found
      that the tx queues were enabled over watchdog reset.
      
      After going through the source code, I found that in enic_stop(),
      the tx queues stopped by netif_tx_disable() could be woken up over
      a small time window between netif_tx_disable() and the
      napi_disable() by the following code path:
      napi_poll->
        enic_poll_msix_wq->
           vnic_cq_service->
              enic_wq_service->
                 netif_wake_subqueue(enic->netdev, q_number)->
                    test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state)
      In turn, upper netowrk stack could queue skb to ENIC NIC though
      enic_hard_start_xmit(). And this might introduce some race condition.
      
      Our customer comfirmed that this kind of kernel crash doesn't occur over
      90 days since they applied this patch.
      
      Signed-off-by: default avatarFiro Yang <firo.yang@suse.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed2a26ac
    • Jaihind Yadav's avatar
      selinux: ensure we cleanup the internal AVC counters on error in avc_update() · b89e36cf
      Jaihind Yadav authored
      
      [ Upstream commit 030b995a ]
      
      In AVC update we don't call avc_node_kill() when avc_xperms_populate()
      fails, resulting in the avc->avc_cache.active_nodes counter having a
      false value.  In last patch this changes was missed , so correcting it.
      
      Fixes: fa1aa143 ("selinux: extended permissions for ioctls")
      Signed-off-by: default avatarJaihind Yadav <jaihindyadav@codeaurora.org>
      Signed-off-by: default avatarRavi Kumar Siddojigari <rsiddoji@codeaurora.org>
      [PM: merge fuzz, minor description cleanup]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b89e36cf
    • Zhiqiang Liu's avatar
      brd: check and limit max_part par · 21d494d2
      Zhiqiang Liu authored
      
      [ Upstream commit c8ab4225 ]
      
      In brd_init func, rd_nr num of brd_device are firstly allocated
      and add in brd_devices, then brd_devices are traversed to add each
      brd_device by calling add_disk func. When allocating brd_device,
      the disk->first_minor is set to i * max_part, if rd_nr * max_part
      is larger than MINORMASK, two different brd_device may have the same
      devt, then only one of them can be successfully added.
      when rmmod brd.ko, it will cause oops when calling brd_exit.
      
      Follow those steps:
        # modprobe brd rd_nr=3 rd_size=102400 max_part=1048576
        # rmmod brd
      then, the oops will appear.
      
      Oops log:
      [  726.613722] Call trace:
      [  726.614175]  kernfs_find_ns+0x24/0x130
      [  726.614852]  kernfs_find_and_get_ns+0x44/0x68
      [  726.615749]  sysfs_remove_group+0x38/0xb0
      [  726.616520]  blk_trace_remove_sysfs+0x1c/0x28
      [  726.617320]  blk_unregister_queue+0x98/0x100
      [  726.618105]  del_gendisk+0x144/0x2b8
      [  726.618759]  brd_exit+0x68/0x560 [brd]
      [  726.619501]  __arm64_sys_delete_module+0x19c/0x2a0
      [  726.620384]  el0_svc_common+0x78/0x130
      [  726.621057]  el0_svc_handler+0x38/0x78
      [  726.621738]  el0_svc+0x8/0xc
      [  726.622259] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260)
      
      Here, we add brd_check_and_reset_par func to check and limit max_part par.
      
      --
      V5->V6:
       - remove useless code
      
      V4->V5:(suggested by Ming Lei)
       - make sure max_part is not larger than DISK_MAX_PARTS
      
      V3->V4:(suggested by Ming Lei)
       - remove useless change
       - add one limit of max_part
      
      V2->V3: (suggested by Ming Lei)
       - clear .minors when running out of consecutive minor space in brd_alloc
       - remove limit of rd_nr
      
      V1->V2:
       - add more checks in brd_check_par_valid as suggested by Ming Lei.
      
      Signed-off-by: default avatarZhiqiang Liu <liuzhiqiang26@huawei.com>
      Reviewed-by: default avatarBob Liu <bob.liu@oracle.com>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      21d494d2
    • Shubhrajyoti Datta's avatar
      microblaze: Prevent the overflow of the start · 1caa4d96
      Shubhrajyoti Datta authored
      
      [ Upstream commit 061d2c1d ]
      
      In case the start + cache size is more than the max int the
      start overflows.
      Prevent the same.
      
      Signed-off-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1caa4d96
    • Zenghui Yu's avatar
      irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL · 24eb51c5
      Zenghui Yu authored
      
      [ Upstream commit 10794522 ]
      
      It looks like an obvious mistake to use its_mapc_cmd descriptor when
      building the INVALL command block. It so far worked by luck because
      both its_mapc_cmd.col and its_invall_cmd.col sit at the same offset of
      the ITS command descriptor, but we should not rely on it.
      
      Fixes: cc2d3216 ("irqchip: GICv3: ITS command queue")
      Signed-off-by: default avatarZenghui Yu <yuzenghui@huawei.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20191202071021.1251-1-yuzenghui@huawei.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      24eb51c5
    • Coly Li's avatar
      bcache: explicity type cast in bset_bkey_last() · de2d6ae1
      Coly Li authored
      
      [ Upstream commit 7c02b005 ]
      
      In bset.h, macro bset_bkey_last() is defined as,
          bkey_idx((struct bkey *) (i)->d, (i)->keys)
      
      Parameter i can be variable type of data structure, the macro always
      works once the type of struct i has member 'd' and 'keys'.
      
      bset_bkey_last() is also used in macro csum_set() to calculate the
      checksum of a on-disk data structure. When csum_set() is used to
      calculate checksum of on-disk bcache super block, the parameter 'i'
      data type is struct cache_sb_disk. Inside struct cache_sb_disk (also in
      struct cache_sb) the member keys is __u16 type. But bkey_idx() expects
      unsigned int (a 32bit width), so there is problem when sending
      parameters via stack to call bkey_idx().
      
      Sparse tool from Intel 0day kbuild system reports this incompatible
      problem. bkey_idx() is part of user space API, so the simplest fix is
      to cast the (i)->keys to unsigned int type in macro bset_bkey_last().
      
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarColy Li <colyli@suse.de>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      de2d6ae1
    • Yunfeng Ye's avatar
      reiserfs: prevent NULL pointer dereference in reiserfs_insert_item() · e3494d2d
      Yunfeng Ye authored
      [ Upstream commit aacee544 ]
      
      The variable inode may be NULL in reiserfs_insert_item(), but there is
      no check before accessing the member of inode.
      
      Fix this by adding NULL pointer check before calling reiserfs_debug().
      
      Link: http://lkml.kernel.org/r/79c5135d-ff25-1cc9-4e99-9f572b88cc00@huawei.com
      
      
      Signed-off-by: default avatarYunfeng Ye <yeyunfeng@huawei.com>
      Cc: zhengbin <zhengbin13@huawei.com>
      Cc: Hu Shiyuan <hushiyuan@huawei.com>
      Cc: Feilong Lin <linfeilong@huawei.com>
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3494d2d
    • Nathan Chancellor's avatar
      lib/scatterlist.c: adjust indentation in __sg_alloc_table · 4a1b8231
      Nathan Chancellor authored
      [ Upstream commit 4e456fee ]
      
      Clang warns:
      
        ../lib/scatterlist.c:314:5: warning: misleading indentation; statement
        is not part of the previous 'if' [-Wmisleading-indentation]
                                return -ENOMEM;
                                ^
        ../lib/scatterlist.c:311:4: note: previous statement is here
                                if (prv)
                                ^
        1 warning generated.
      
      This warning occurs because there is a space before the tab on this
      line.  Remove it so that the indentation is consistent with the Linux
      kernel coding style and clang no longer warns.
      
      Link: http://lkml.kernel.org/r/20191218033606.11942-1-natechancellor@gmail.com
      Link: https://github.com/ClangBuiltLinux/linux/issues/830
      
      
      Fixes: edce6820 ("scatterlist: prevent invalid free when alloc fails")
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4a1b8231
    • wangyan's avatar
      ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans() · afa08652
      wangyan authored
      [ Upstream commit 9f16ca48 ]
      
      I found a NULL pointer dereference in ocfs2_update_inode_fsync_trans(),
      handle->h_transaction may be NULL in this situation:
      
      ocfs2_file_write_iter
        ->__generic_file_write_iter
            ->generic_perform_write
              ->ocfs2_write_begin
                ->ocfs2_write_begin_nolock
                  ->ocfs2_write_cluster_by_desc
                    ->ocfs2_write_cluster
                      ->ocfs2_mark_extent_written
                        ->ocfs2_change_extent_flag
                          ->ocfs2_split_extent
                            ->ocfs2_try_to_merge_extent
                              ->ocfs2_extend_rotate_transaction
                                ->ocfs2_extend_trans
                                  ->jbd2_journal_restart
                                    ->jbd2__journal_restart
                                      // handle->h_transaction is NULL here
                                      ->handle->h_transaction = NULL;
                                      ->start_this_handle
                                        /* journal aborted due to storage
                                           network disconnection, return error */
                                        ->return -EROFS;
                               /* line 3806 in ocfs2_try_to_merge_extent (),
                                  it will ignore ret error. */
                              ->ret = 0;
              ->...
              ->ocfs2_write_end
                ->ocfs2_write_end_nolock
                  ->ocfs2_update_inode_fsync_trans
                    // NULL pointer dereference
                    ->oi->i_sync_tid = handle->h_transaction->t_tid;
      
      The information of NULL pointer dereference as follows:
          JBD2: Detected IO errors while flushing file data on dm-11-45
          Aborting journal on device dm-11-45.
          JBD2: Error -5 detected when updating journal superblock for dm-11-45.
          (dd,22081,3):ocfs2_extend_trans:474 ERROR: status = -30
          (dd,22081,3):ocfs2_try_to_merge_extent:3877 ERROR: status = -30
          Unable to handle kernel NULL pointer dereference at
          virtual address 0000000000000008
          Mem abort info:
            ESR = 0x96000004
            Exception class = DABT (current EL), IL = 32 bits
            SET = 0, FnV = 0
            EA = 0, S1PTW = 0
          Data abort info:
            ISV = 0, ISS = 0x00000004
            CM = 0, WnR = 0
          user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000e74e1338
          [0000000000000008] pgd=0000000000000000
          Internal error: Oops: 96000004 [#1] SMP
          Process dd (pid: 22081, stack limit = 0x00000000584f35a9)
          CPU: 3 PID: 22081 Comm: dd Kdump: loaded
          Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 0.98 08/25/2019
          pstate: 60400009 (nZCv daif +PAN -UAO)
          pc : ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
          lr : ocfs2_write_end_nolock+0x2a0/0x550 [ocfs2]
          sp : ffff0000459fba70
          x29: ffff0000459fba70 x28: 0000000000000000
          x27: ffff807ccf7f1000 x26: 0000000000000001
          x25: ffff807bdff57970 x24: ffff807caf1d4000
          x23: ffff807cc79e9000 x22: 0000000000001000
          x21: 000000006c6cd000 x20: ffff0000091d9000
          x19: ffff807ccb239db0 x18: ffffffffffffffff
          x17: 000000000000000e x16: 0000000000000007
          x15: ffff807c5e15bd78 x14: 0000000000000000
          x13: 0000000000000000 x12: 0000000000000000
          x11: 0000000000000000 x10: 0000000000000001
          x9 : 0000000000000228 x8 : 000000000000000c
          x7 : 0000000000000fff x6 : ffff807a308ed6b0
          x5 : ffff7e01f10967c0 x4 : 0000000000000018
          x3 : d0bc661572445600 x2 : 0000000000000000
          x1 : 000000001b2e0200 x0 : 0000000000000000
          Call trace:
           ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
           ocfs2_write_end+0x4c/0x80 [ocfs2]
           generic_perform_write+0x108/0x1a8
           __generic_file_write_iter+0x158/0x1c8
           ocfs2_file_write_iter+0x668/0x950 [ocfs2]
           __vfs_write+0x11c/0x190
           vfs_write+0xac/0x1c0
           ksys_write+0x6c/0xd8
           __arm64_sys_write+0x24/0x30
           el0_svc_common+0x78/0x130
           el0_svc_handler+0x38/0x78
           el0_svc+0x8/0xc
      
      To prevent NULL pointer dereference in this situation, we use
      is_handle_aborted() before using handle->h_transaction->t_tid.
      
      Link: http://lkml.kernel.org/r/03e750ab-9ade-83aa-b000-b9e81e34e539@huawei.com
      
      
      Signed-off-by: default avatarYan Wang <wangyan122@huawei.com>
      Reviewed-by: default avatarJun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      afa08652
    • Daniel Vetter's avatar
      radeon: insert 10ms sleep in dce5_crtc_load_lut · a78220b4
      Daniel Vetter authored
      [ Upstream commit ec3d6508 ]
      
      Per at least one tester this is enough magic to recover the regression
      introduced for some people (but not all) in
      
      commit b8e2b019
      Author: Peter Rosin <peda@axentia.se>
      Date:   Tue Jul 4 12:36:57 2017 +0200
      
          drm/fb-helper: factor out pseudo-palette
      
      which for radeon had the side-effect of refactoring out a seemingly
      redudant writing of the color palette.
      
      10ms in a fairly slow modeset path feels like an acceptable form of
      duct-tape, so maybe worth a shot and see what sticks.
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Michel Dänzer <michel.daenzer@amd.com>
      References: https://bugzilla.kernel.org/show_bug.cgi?id=198123
      
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a78220b4
Loading