Skip to content
  1. Feb 15, 2020
    • Håkon Bugge's avatar
      RDMA/netlink: Do not always generate an ACK for some netlink operations · 81828ccf
      Håkon Bugge authored
      commit a242c369 upstream.
      
      In rdma_nl_rcv_skb(), the local variable err is assigned the return value
      of the supplied callback function, which could be one of
      ib_nl_handle_resolve_resp(), ib_nl_handle_set_timeout(), or
      ib_nl_handle_ip_res_resp(). These three functions all return skb->len on
      success.
      
      rdma_nl_rcv_skb() is merely a copy of netlink_rcv_skb(). The callback
      functions used by the latter have the convention: "Returns 0 on success or
      a negative error code".
      
      In particular, the statement (equal for both functions):
      
         if (nlh->nlmsg_flags & NLM_F_ACK || err)
      
      implies that rdma_nl_rcv_skb() always will ack a message, independent of
      the NLM_F_ACK being set in nlmsg_flags or not.
      
      The fix could be to change the above statement, but it is better to keep
      the two *_rcv_skb() functions equal in this respect and instead change the
      three callback functions in the rdma subsystem to the correct convention.
      
      Fixes: 2ca546b9 ("IB/sa: Route SA pathrecord query through netlink")
      Fixes: ae43f828
      
       ("IB/core: Add IP to GID netlink offload")
      Link: https://lore.kernel.org/r/20191216120436.3204814-1-haakon.bugge@oracle.com
      Suggested-by: default avatarMark Haywood <mark.haywood@oracle.com>
      Signed-off-by: default avatarHåkon Bugge <haakon.bugge@oracle.com>
      Tested-by: default avatarMark Haywood <mark.haywood@oracle.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81828ccf
    • Ranjani Sridharan's avatar
      ASoC: pcm: update FE/BE trigger order based on the command · 221f141c
      Ranjani Sridharan authored
      [ Upstream commit acbf2774
      
       ]
      
      Currently, the trigger orders SND_SOC_DPCM_TRIGGER_PRE/POST
      determine the order in which FE DAI and BE DAI are triggered.
      In the case of SND_SOC_DPCM_TRIGGER_PRE, the FE DAI is
      triggered before the BE DAI and in the case of
      SND_SOC_DPCM_TRIGGER_POST, the BE DAI is triggered before
      the FE DAI. And this order remains the same irrespective of the
      trigger command.
      
      In the case of the SOF driver, during playback, the FW
      expects the BE DAI to be triggered before the FE DAI during
      the START trigger. The BE DAI trigger handles the starting of
      Link DMA and so it must be started before the FE DAI is started
      to prevent xruns during pause/release. This can be addressed
      by setting the trigger order for the FE dai link to
      SND_SOC_DPCM_TRIGGER_POST. But during the STOP trigger,
      the FW expects the FE DAI to be triggered before the BE DAI.
      Retaining the same order during the START and STOP commands,
      results in FW error as the DAI component in the FW is still
      active.
      
      The issue can be fixed by mirroring the trigger order of
      FE and BE DAI's during the START and STOP trigger. So, with the
      trigger order set to SND_SOC_DPCM_TRIGGER_PRE, the FE DAI will be
      trigger first during SNDRV_PCM_TRIGGER_START/STOP/RESUME
      and the BE DAI will be triggered first during the
      STOP/SUSPEND/PAUSE commands. Conversely, with the trigger order
      set to SND_SOC_DPCM_TRIGGER_POST, the BE DAI will be triggered
      first during the SNDRV_PCM_TRIGGER_START/STOP/RESUME commands
      and the FE DAI will be triggered first during the
      SNDRV_PCM_TRIGGER_STOP/SUSPEND/PAUSE commands.
      
      Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
      Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20191104224812.3393-2-ranjani.sridharan@linux.intel.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      221f141c
    • David Howells's avatar
      rxrpc: Fix service call disconnection · 1b950f7a
      David Howells authored
      [ Upstream commit b39a934e ]
      
      The recent patch that substituted a flag on an rxrpc_call for the
      connection pointer being NULL as an indication that a call was disconnected
      puts the set_bit in the wrong place for service calls.  This is only a
      problem if a call is implicitly terminated by a new call coming in on the
      same connection channel instead of a terminating ACK packet.
      
      In such a case, rxrpc_input_implicit_end_call() calls
      __rxrpc_disconnect_call(), which is now (incorrectly) setting the
      disconnection bit, meaning that when rxrpc_release_call() is later called,
      it doesn't call rxrpc_disconnect_call() and so the call isn't removed from
      the peer's error distribution list and the list gets corrupted.
      
      KASAN finds the issue as an access after release on a call, but the
      position at which it occurs is confusing as it appears to be related to a
      different call (the call site is where the latter call is being removed
      from the error distribution list and either the next or pprev pointer
      points to a previously released call).
      
      Fix this by moving the setting of the flag from __rxrpc_disconnect_call()
      to rxrpc_disconnect_call() in the same place that the connection pointer
      was being cleared.
      
      Fixes: 5273a191
      
       ("rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1b950f7a
    • Song Liu's avatar
      perf/core: Fix mlock accounting in perf_mmap() · 026d9148
      Song Liu authored
      commit 00346155 upstream.
      
      Decreasing sysctl_perf_event_mlock between two consecutive perf_mmap()s of
      a perf ring buffer may lead to an integer underflow in locked memory
      accounting. This may lead to the undesired behaviors, such as failures in
      BPF map creation.
      
      Address this by adjusting the accounting logic to take into account the
      possibility that the amount of already locked memory may exceed the
      current limit.
      
      Fixes: c4b75479
      
       ("perf/core: Make the mlock accounting simple again")
      Suggested-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: <stable@vger.kernel.org>
      Acked-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
      Link: https://lkml.kernel.org/r/20200123181146.2238074-1-songliubraving@fb.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      026d9148
    • Konstantin Khlebnikov's avatar
      clocksource: Prevent double add_timer_on() for watchdog_timer · 75fc4654
      Konstantin Khlebnikov authored
      commit febac332 upstream.
      
      Kernel crashes inside QEMU/KVM are observed:
      
        kernel BUG at kernel/time/timer.c:1154!
        BUG_ON(timer_pending(timer) || !timer->function) in add_timer_on().
      
      At the same time another cpu got:
      
        general protection fault: 0000 [#1] SMP PTI of poinson pointer 0xdead000000000200 in:
      
        __hlist_del at include/linux/list.h:681
        (inlined by) detach_timer at kernel/time/timer.c:818
        (inlined by) expire_timers at kernel/time/timer.c:1355
        (inlined by) __run_timers at kernel/time/timer.c:1686
        (inlined by) run_timer_softirq at kernel/time/timer.c:1699
      
      Unfortunately kernel logs are badly scrambled, stacktraces are lost.
      
      Printing the timer->function before the BUG_ON() pointed to
      clocksource_watchdog().
      
      The execution of clocksource_watchdog() can race with a sequence of
      clocksource_stop_watchdog() .. clocksource_start_watchdog():
      
      expire_timers()
       detach_timer(timer, true);
        timer->entry.pprev = NULL;
       raw_spin_unlock_irq(&base->lock);
       call_timer_fn
        clocksource_watchdog()
      
      					clocksource_watchdog_kthread() or
      					clocksource_unbind()
      
      					spin_lock_irqsave(&watchdog_lock, flags);
      					clocksource_stop_watchdog();
      					 del_timer(&watchdog_timer);
      					 watchdog_running = 0;
      					spin_unlock_irqrestore(&watchdog_lock, flags);
      
      					spin_lock_irqsave(&watchdog_lock, flags);
      					clocksource_start_watchdog();
      					 add_timer_on(&watchdog_timer, ...);
      					 watchdog_running = 1;
      					spin_unlock_irqrestore(&watchdog_lock, flags);
      
        spin_lock(&watchdog_lock);
        add_timer_on(&watchdog_timer, ...);
         BUG_ON(timer_pending(timer) || !timer->function);
          timer_pending() -> true
          BUG()
      
      I.e. inside clocksource_watchdog() watchdog_timer could be already armed.
      
      Check timer_pending() before calling add_timer_on(). This is sufficient as
      all operations are synchronized by watchdog_lock.
      
      Fixes: 75c5158f
      
       ("timekeeping: Update clocksource with stop_machine")
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/158048693917.4378.13823603769948933793.stgit@buzz
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75fc4654
    • Ronnie Sahlberg's avatar
      cifs: fail i/o on soft mounts if sessionsetup errors out · f78ba732
      Ronnie Sahlberg authored
      commit b0dd940e
      
       upstream.
      
      RHBZ: 1579050
      
      If we have a soft mount we should fail commands for session-setup
      failures (such as the password having changed/ account being deleted/ ...)
      and return an error back to the application.
      
      Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f78ba732
    • Miaohe Lin's avatar
      KVM: nVMX: vmread should not set rflags to specify success in case of #PF · 0b414c54
      Miaohe Lin authored
      [ Upstream commit a4d956b9
      
       ]
      
      In case writing to vmread destination operand result in a #PF, vmread
      should not call nested_vmx_succeed() to set rflags to specify success.
      Similar to as done in VMPTRST (See handle_vmptrst()).
      
      Reviewed-by: default avatarLiran Alon <liran.alon@oracle.com>
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0b414c54
    • Sean Christopherson's avatar
      KVM: VMX: Add non-canonical check on writes to RTIT address MSRs · bd350d09
      Sean Christopherson authored
      [ Upstream commit fe6ed369
      
       ]
      
      Reject writes to RTIT address MSRs if the data being written is a
      non-canonical address as the MSRs are subject to canonical checks, e.g.
      KVM will trigger an unchecked #GP when loading the values to hardware
      during pt_guest_enter().
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd350d09
    • Sean Christopherson's avatar
      KVM: x86/mmu: Apply max PA check for MMIO sptes to 32-bit KVM · fce8d95c
      Sean Christopherson authored
      [ Upstream commit e30a7d62 ]
      
      Remove the bogus 64-bit only condition from the check that disables MMIO
      spte optimization when the system supports the max PA, i.e. doesn't have
      any reserved PA bits.  32-bit KVM always uses PAE paging for the shadow
      MMU, and per Intel's SDM:
      
        PAE paging translates 32-bit linear addresses to 52-bit physical
        addresses.
      
      The kernel's restrictions on max physical addresses are limits on how
      much memory the kernel can reasonably use, not what physical addresses
      are supported by hardware.
      
      Fixes: ce88decf
      
       ("KVM: MMU: mmio page fault support")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fce8d95c
    • Josef Bacik's avatar
      btrfs: flush write bio if we loop in extent_write_cache_pages · 8dc2210c
      Josef Bacik authored
      [ Upstream commit 42ffb0bf]
      
      There exists a deadlock with range_cyclic that has existed forever.  If
      we loop around with a bio already built we could deadlock with a writer
      who has the page locked that we're attempting to write but is waiting on
      a page in our bio to be written out.  The task traces are as follows
      
        PID: 1329874  TASK: ffff889ebcdf3800  CPU: 33  COMMAND: "kworker/u113:5"
         #0 [ffffc900297bb658] __schedule at ffffffff81a4c33f
         #1 [ffffc900297bb6e0] schedule at ffffffff81a4c6e3
         #2 [ffffc900297bb6f8] io_schedule at ffffffff81a4ca42
         #3 [ffffc900297bb708] __lock_page at ffffffff811f145b
         #4 [ffffc900297bb798] __process_pages_contig at ffffffff814bc502
         #5 [ffffc900297bb8c8] lock_delalloc_pages at ffffffff814bc684
         #6 [ffffc900297bb900] find_lock_delalloc_range at ffffffff814be9ff
         #7 [ffffc900297bb9a0] writepage_delalloc at ffffffff814bebd0
         #8 [ffffc900297bba18] __extent_writepage at ffffffff814bfbf2
         #9 [ffffc900297bba98] extent_write_cache_pages at ffffffff814bffbd
      
        PID: 2167901  TASK: ffff889dc6a59c00  CPU: 14  COMMAND:
        "aio-dio-invalid"
         #0 [ffffc9003b50bb18] __schedule at ffffffff81a4c33f
         #1 [ffffc9003b50bba0] schedule at ffffffff81a4c6e3
         #2 [ffffc9003b50bbb8] io_schedule at ffffffff81a4ca42
         #3 [ffffc9003b50bbc8] wait_on_page_bit at ffffffff811f24d6
         #4 [ffffc9003b50bc60] prepare_pages at ffffffff814b05a7
         #5 [ffffc9003b50bcd8] btrfs_buffered_write at ffffffff814b1359
         #6 [ffffc9003b50bdb0] btrfs_file_write_iter at ffffffff814b5933
         #7 [ffffc9003b50be38] new_sync_write at ffffffff8128f6a8
         #8 [ffffc9003b50bec8] vfs_write at ffffffff81292b9d
         #9 [ffffc9003b50bf00] ksys_pwrite64 at ffffffff81293032
      
      I used drgn to find the respective pages we were stuck on
      
      page_entry.page 0xffffea00fbfc7500 index 8148 bit 15 pid 2167901
      page_entry.page 0xffffea00f9bb7400 index 7680 bit 0 pid 1329874
      
      As you can see the kworker is waiting for bit 0 (PG_locked) on index
      7680, and aio-dio-invalid is waiting for bit 15 (PG_writeback) on index
      8148.  aio-dio-invalid has 7680, and the kworker epd looks like the
      following
      
        crash> struct extent_page_data ffffc900297bbbb0
        struct extent_page_data {
          bio = 0xffff889f747ed830,
          tree = 0xffff889eed6ba448,
          extent_locked = 0,
          sync_io = 0
        }
      
      Probably worth mentioning as well that it waits for writeback of the
      page to complete while holding a lock on it (at prepare_pages()).
      
      Using drgn I walked the bio pages looking for page
      0xffffea00fbfc7500 which is the one we're waiting for writeback on
      
        bio = Object(prog, 'struct bio', address=0xffff889f747ed830)
        for i in range(0, bio.bi_vcnt.value_()):
            bv = bio.bi_io_vec[i]
            if bv.bv_page.value_() == 0xffffea00fbfc7500:
      	  print("FOUND IT")
      
      which validated what I suspected.
      
      The fix for this is simple, flush the epd before we loop back around to
      the beginning of the file during writeout.
      
      Fixes: b293f02e
      
       ("Btrfs: Add writepages support")
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8dc2210c
    • Marios Pomonis's avatar
      KVM: x86: Protect pmu_intel.c from Spectre-v1/L1TF attacks · 66b85556
      Marios Pomonis authored
      [ Upstream commit 66061740 ]
      
      This fixes Spectre-v1/L1TF vulnerabilities in intel_find_fixed_event()
      and intel_rdpmc_ecx_to_pmc().
      kvm_rdpmc() (ancestor of intel_find_fixed_event()) and
      reprogram_fixed_counter() (ancestor of intel_rdpmc_ecx_to_pmc()) are
      exported symbols so KVM should treat them conservatively from a security
      perspective.
      
      Fixes: 25462f7f
      
       ("KVM: x86/vPMU: Define kvm_pmu_ops to support vPMU function dispatch")
      
      Signed-off-by: default avatarNick Finco <nifi@google.com>
      Signed-off-by: default avatarMarios Pomonis <pomonis@google.com>
      Reviewed-by: default avatarAndrew Honig <ahonig@google.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      66b85556
    • Claudiu Beznea's avatar
      drm: atmel-hlcdc: enable clock before configuring timing engine · 5d6e14f3
      Claudiu Beznea authored
      [ Upstream commit 2c1fb9d8 ]
      
      Changing pixel clock source without having this clock source enabled
      will block the timing engine and the next operations after (in this case
      setting ATMEL_HLCDC_CFG(5) settings in atmel_hlcdc_crtc_mode_set_nofb()
      will fail). It is recomended (although in datasheet this is not present)
      to actually enabled pixel clock source before doing any changes on timing
      enginge (only SAM9X60 datasheet specifies that the peripheral clock and
      pixel clock must be enabled before using LCD controller).
      
      Fixes: 1a396789
      
       ("drm: add Atmel HLCDC Display Controller support")
      Signed-off-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
      Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
      Cc: <stable@vger.kernel.org> # v4.0+
      Link: https://patchwork.freedesktop.org/patch/msgid/1576672109-22707-3-git-send-email-claudiu.beznea@microchip.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5d6e14f3
    • Filipe Manana's avatar
      Btrfs: fix race between adding and putting tree mod seq elements and nodes · 24e9e6bf
      Filipe Manana authored
      [ Upstream commit 7227ff4d ]
      
      There is a race between adding and removing elements to the tree mod log
      list and rbtree that can lead to use-after-free problems.
      
      Consider the following example that explains how/why the problems happens:
      
      1) Task A has mod log element with sequence number 200. It currently is
         the only element in the mod log list;
      
      2) Task A calls btrfs_put_tree_mod_seq() because it no longer needs to
         access the tree mod log. When it enters the function, it initializes
         'min_seq' to (u64)-1. Then it acquires the lock 'tree_mod_seq_lock'
         before checking if there are other elements in the mod seq list.
         Since the list it empty, 'min_seq' remains set to (u64)-1. Then it
         unlocks the lock 'tree_mod_seq_lock';
      
      3) Before task A acquires the lock 'tree_mod_log_lock', task B adds
         itself to the mod seq list through btrfs_get_tree_mod_seq() and gets a
         sequence number of 201;
      
      4) Some other task, name it task C, modifies a btree and because there
         elements in the mod seq list, it adds a tree mod elem to the tree
         mod log rbtree. That node added to the mod log rbtree is assigned
         a sequence number of 202;
      
      5) Task B, which is doing fiemap and resolving indirect back references,
         calls btrfs get_old_root(), with 'time_seq' == 201, which in turn
         calls tree_mod_log_search() - the search returns the mod log node
         from the rbtree with sequence number 202, created by task C;
      
      6) Task A now acquires the lock 'tree_mod_log_lock', starts iterating
         the mod log rbtree and finds the node with sequence number 202. Since
         202 is less than the previously computed 'min_seq', (u64)-1, it
         removes the node and frees it;
      
      7) Task B still has a pointer to the node with sequence number 202, and
         it dereferences the pointer itself and through the call to
         __tree_mod_log_rewind(), resulting in a use-after-free problem.
      
      This issue can be triggered sporadically with the test case generic/561
      from fstests, and it happens more frequently with a higher number of
      duperemove processes. When it happens to me, it either freezes the VM or
      it produces a trace like the following before crashing:
      
        [ 1245.321140] general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC PTI
        [ 1245.321200] CPU: 1 PID: 26997 Comm: pool Not tainted 5.5.0-rc6-btrfs-next-52 #1
        [ 1245.321235] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org 04/01/2014
        [ 1245.321287] RIP: 0010:rb_next+0x16/0x50
        [ 1245.321307] Code: ....
        [ 1245.321372] RSP: 0018:ffffa151c4d039b0 EFLAGS: 00010202
        [ 1245.321388] RAX: 6b6b6b6b6b6b6b6b RBX: ffff8ae221363c80 RCX: 6b6b6b6b6b6b6b6b
        [ 1245.321409] RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff8ae221363c80
        [ 1245.321439] RBP: ffff8ae20fcc4688 R08: 0000000000000002 R09: 0000000000000000
        [ 1245.321475] R10: ffff8ae20b120910 R11: 00000000243f8bb1 R12: 0000000000000038
        [ 1245.321506] R13: ffff8ae221363c80 R14: 000000000000075f R15: ffff8ae223f762b8
        [ 1245.321539] FS:  00007fdee1ec7700(0000) GS:ffff8ae236c80000(0000) knlGS:0000000000000000
        [ 1245.321591] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [ 1245.321614] CR2: 00007fded4030c48 CR3: 000000021da16003 CR4: 00000000003606e0
        [ 1245.321642] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        [ 1245.321668] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        [ 1245.321706] Call Trace:
        [ 1245.321798]  __tree_mod_log_rewind+0xbf/0x280 [btrfs]
        [ 1245.321841]  btrfs_search_old_slot+0x105/0xd00 [btrfs]
        [ 1245.321877]  resolve_indirect_refs+0x1eb/0xc60 [btrfs]
        [ 1245.321912]  find_parent_nodes+0x3dc/0x11b0 [btrfs]
        [ 1245.321947]  btrfs_check_shared+0x115/0x1c0 [btrfs]
        [ 1245.321980]  ? extent_fiemap+0x59d/0x6d0 [btrfs]
        [ 1245.322029]  extent_fiemap+0x59d/0x6d0 [btrfs]
        [ 1245.322066]  do_vfs_ioctl+0x45a/0x750
        [ 1245.322081]  ksys_ioctl+0x70/0x80
        [ 1245.322092]  ? trace_hardirqs_off_thunk+0x1a/0x1c
        [ 1245.322113]  __x64_sys_ioctl+0x16/0x20
        [ 1245.322126]  do_syscall_64+0x5c/0x280
        [ 1245.322139]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
        [ 1245.322155] RIP: 0033:0x7fdee3942dd7
        [ 1245.322177] Code: ....
        [ 1245.322258] RSP: 002b:00007fdee1ec6c88 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
        [ 1245.322294] RAX: ffffffffffffffda RBX: 00007fded40210d8 RCX: 00007fdee3942dd7
        [ 1245.322314] RDX: 00007fded40210d8 RSI: 00000000c020660b RDI: 0000000000000004
        [ 1245.322337] RBP: 0000562aa89e7510 R08: 0000000000000000 R09: 00007fdee1ec6d44
        [ 1245.322369] R10: 0000000000000073 R11: 0000000000000246 R12: 00007fdee1ec6d48
        [ 1245.322390] R13: 00007fdee1ec6d40 R14: 00007fded40210d0 R15: 00007fdee1ec6d50
        [ 1245.322423] Modules linked in: ....
        [ 1245.323443] ---[ end trace 01de1e9ec5dff3cd ]---
      
      Fix this by ensuring that btrfs_put_tree_mod_seq() computes the minimum
      sequence number and iterates the rbtree while holding the lock
      'tree_mod_log_lock' in write mode. Also get rid of the 'tree_mod_seq_lock'
      lock, since it is now redundant.
      
      Fixes: bd989ba3 ("Btrfs: add tree modification log functions")
      Fixes: 097b8a7c
      
       ("Btrfs: join tree mod log code with the code holding back delayed refs")
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      24e9e6bf
    • David Sterba's avatar
      btrfs: remove trivial locking wrappers of tree mod log · a71561b9
      David Sterba authored
      [ Upstream commit b1a09f1e
      
       ]
      
      The wrappers are trivial and do not bring any extra value on top of the
      plain locking primitives.
      
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a71561b9
    • Anand Jain's avatar
      btrfs: use bool argument in free_root_pointers() · fb8c8121
      Anand Jain authored
      [ Upstream commit 4273eaff
      
       ]
      
      We don't need int argument bool shall do in free_root_pointers().  And
      rename the argument as it confused two people.
      
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb8c8121
    • Filipe Manana's avatar
      Btrfs: fix assertion failure on fsync with NO_HOLES enabled · 131d3ff8
      Filipe Manana authored
      [ Upstream commit 0ccc3876 ]
      
      Back in commit a89ca6f2 ("Btrfs: fix fsync after truncate when
      no_holes feature is enabled") I added an assertion that is triggered when
      an inline extent is found to assert that the length of the (uncompressed)
      data the extent represents is the same as the i_size of the inode, since
      that is true most of the time I couldn't find or didn't remembered about
      any exception at that time. Later on the assertion was expanded twice to
      deal with a case of a compressed inline extent representing a range that
      matches the sector size followed by an expanding truncate, and another
      case where fallocate can update the i_size of the inode without adding
      or updating existing extents (if the fallocate range falls entirely within
      the first block of the file). These two expansion/fixes of the assertion
      were done by commit 7ed586d0 ("Btrfs: fix assertion on fsync of
      regular file when using no-holes feature") and commit 6399fb5a
      
      
      ("Btrfs: fix assertion failure during fsync in no-holes mode").
      These however missed the case where an falloc expands the i_size of an
      inode to exactly the sector size and inline extent exists, for example:
      
       $ mkfs.btrfs -f -O no-holes /dev/sdc
       $ mount /dev/sdc /mnt
      
       $ xfs_io -f -c "pwrite -S 0xab 0 1096" /mnt/foobar
       wrote 1096/1096 bytes at offset 0
       1 KiB, 1 ops; 0.0002 sec (4.448 MiB/sec and 4255.3191 ops/sec)
      
       $ xfs_io -c "falloc 1096 3000" /mnt/foobar
       $ xfs_io -c "fsync" /mnt/foobar
       Segmentation fault
      
       $ dmesg
       [701253.602385] assertion failed: len == i_size || (len == fs_info->sectorsize && btrfs_file_extent_compression(leaf, extent) != BTRFS_COMPRESS_NONE) || (len < i_size && i_size < fs_info->sectorsize), file: fs/btrfs/tree-log.c, line: 4727
       [701253.602962] ------------[ cut here ]------------
       [701253.603224] kernel BUG at fs/btrfs/ctree.h:3533!
       [701253.603503] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
       [701253.603774] CPU: 2 PID: 7192 Comm: xfs_io Tainted: G        W         5.0.0-rc8-btrfs-next-45 #1
       [701253.604054] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.2-0-gf9626ccb91-prebuilt.qemu-project.org 04/01/2014
       [701253.604650] RIP: 0010:assfail.constprop.23+0x18/0x1a [btrfs]
       (...)
       [701253.605591] RSP: 0018:ffffbb48c186bc48 EFLAGS: 00010286
       [701253.605914] RAX: 00000000000000de RBX: ffff921d0a7afc08 RCX: 0000000000000000
       [701253.606244] RDX: 0000000000000000 RSI: ffff921d36b16868 RDI: ffff921d36b16868
       [701253.606580] RBP: ffffbb48c186bcf0 R08: 0000000000000000 R09: 0000000000000000
       [701253.606913] R10: 0000000000000003 R11: 0000000000000000 R12: ffff921d05d2de18
       [701253.607247] R13: ffff921d03b54000 R14: 0000000000000448 R15: ffff921d059ecf80
       [701253.607769] FS:  00007f14da906700(0000) GS:ffff921d36b00000(0000) knlGS:0000000000000000
       [701253.608163] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       [701253.608516] CR2: 000056087ea9f278 CR3: 00000002268e8001 CR4: 00000000003606e0
       [701253.608880] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       [701253.609250] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
       [701253.609608] Call Trace:
       [701253.609994]  btrfs_log_inode+0xdfb/0xe40 [btrfs]
       [701253.610383]  btrfs_log_inode_parent+0x2be/0xa60 [btrfs]
       [701253.610770]  ? do_raw_spin_unlock+0x49/0xc0
       [701253.611150]  btrfs_log_dentry_safe+0x4a/0x70 [btrfs]
       [701253.611537]  btrfs_sync_file+0x3b2/0x440 [btrfs]
       [701253.612010]  ? do_sysinfo+0xb0/0xf0
       [701253.612552]  do_fsync+0x38/0x60
       [701253.612988]  __x64_sys_fsync+0x10/0x20
       [701253.613360]  do_syscall_64+0x60/0x1b0
       [701253.613733]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
       [701253.614103] RIP: 0033:0x7f14da4e66d0
       (...)
       [701253.615250] RSP: 002b:00007fffa670fdb8 EFLAGS: 00000246 ORIG_RAX: 000000000000004a
       [701253.615647] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f14da4e66d0
       [701253.616047] RDX: 000056087ea9c260 RSI: 000056087ea9c260 RDI: 0000000000000003
       [701253.616450] RBP: 0000000000000001 R08: 0000000000000020 R09: 0000000000000010
       [701253.616854] R10: 000000000000009b R11: 0000000000000246 R12: 000056087ea9c260
       [701253.617257] R13: 000056087ea9c240 R14: 0000000000000000 R15: 000056087ea9dd10
       (...)
       [701253.619941] ---[ end trace e088d74f132b6da5 ]---
      
      Updating the assertion again to allow for this particular case would result
      in a meaningless assertion, plus there is currently no risk of logging
      content that would result in any corruption after a log replay if the size
      of the data encoded in an inline extent is greater than the inode's i_size
      (which is not currently possibe either with or without compression),
      therefore just remove the assertion.
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      131d3ff8
    • Eric Biggers's avatar
      ext4: fix deadlock allocating crypto bounce page from mempool · e0f95d89
      Eric Biggers authored
      [ Upstream commit 547c556f ]
      
      ext4_writepages() on an encrypted file has to encrypt the data, but it
      can't modify the pagecache pages in-place, so it encrypts the data into
      bounce pages and writes those instead.  All bounce pages are allocated
      from a mempool using GFP_NOFS.
      
      This is not correct use of a mempool, and it can deadlock.  This is
      because GFP_NOFS includes __GFP_DIRECT_RECLAIM, which enables the "never
      fail" mode for mempool_alloc() where a failed allocation will fall back
      to waiting for one of the preallocated elements in the pool.
      
      But since this mode is used for all a bio's pages and not just the
      first, it can deadlock waiting for pages already in the bio to be freed.
      
      This deadlock can be reproduced by patching mempool_alloc() to pretend
      that pool->alloc() always fails (so that it always falls back to the
      preallocations), and then creating an encrypted file of size > 128 KiB.
      
      Fix it by only using GFP_NOFS for the first page in the bio.  For
      subsequent pages just use GFP_NOWAIT, and if any of those fail, just
      submit the bio and start a new one.
      
      This will need to be fixed in f2fs too, but that's less straightforward.
      
      Fixes: c9af28fd
      
       ("ext4 crypto: don't let data integrity writebacks fail with ENOMEM")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Link: https://lore.kernel.org/r/20191231181149.47619-1-ebiggers@kernel.org
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e0f95d89
    • Trond Myklebust's avatar
      NFS: Directory page cache pages need to be locked when read · 5c8f5770
      Trond Myklebust authored
      [ Upstream commit 114de382 ]
      
      When a NFS directory page cache page is removed from the page cache,
      its contents are freed through a call to nfs_readdir_clear_array().
      To prevent the removal of the page cache entry until after we've
      finished reading it, we must take the page lock.
      
      Fixes: 11de3b11
      
       ("NFS: Fix a memory leak in nfs_readdir")
      Cc: stable@vger.kernel.org # v2.6.37+
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5c8f5770
    • Thomas Meyer's avatar
      NFS: Fix bool initialization/comparison · 574940d9
      Thomas Meyer authored
      [ Upstream commit 6089dd0d
      
       ]
      
      Bool initializations should use true and false. Bool tests don't need
      comparisons.
      
      Signed-off-by: default avatarThomas Meyer <thomas@m3y3r.de>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      574940d9
    • Trond Myklebust's avatar
      NFS: Fix memory leaks and corruption in readdir · 67a56e97
      Trond Myklebust authored
      [ Upstream commit 4b310319 ]
      
      nfs_readdir_xdr_to_array() must not exit without having initialised
      the array, so that the page cache deletion routines can safely
      call nfs_readdir_clear_array().
      Furthermore, we should ensure that if we exit nfs_readdir_filler()
      with an error, we free up any page contents to prevent a leak
      if we try to fill the page again.
      
      Fixes: 11de3b11
      
       ("NFS: Fix a memory leak in nfs_readdir")
      Cc: stable@vger.kernel.org # v2.6.37+
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      67a56e97
    • Benjamin Coddington's avatar
      NFS: switch back to to ->iterate() · 9dc9bee7
      Benjamin Coddington authored
      [ Upstream commit b044f645
      
       ]
      
      NFS has some optimizations for readdir to choose between using READDIR or
      READDIRPLUS based on workload, and which NFS operation to use is determined
      by subsequent interactions with lookup, d_revalidate, and getattr.
      
      Concurrent use of nfs_readdir() via ->iterate_shared() can cause those
      optimizations to repeatedly invalidate the pagecache used to store
      directory entries during readdir(), which causes some very bad performance
      for directories with many entries (more than about 10000).
      
      There's a couple ways to fix this in NFS, but no fix would be as simple as
      going back to ->iterate() to serialize nfs_readdir(), and neither fix I
      tested performed as well as going back to ->iterate().
      
      The first required taking the directory's i_lock for each entry, with the
      result of terrible contention.
      
      The second way adds another flag to the nfs_inode, and so keeps the
      optimizations working for large directories.  The difference from using
      ->iterate() here is that much more memory is consumed for a given workload
      without any performance gain.
      
      The workings of nfs_readdir() are such that concurrent users are serialized
      within read_cache_page() waiting to retrieve pages of entries from the
      server.  By serializing this work in iterate_dir() instead, contention for
      cache pages is reduced.  Waiting processes can have an uncontended pass at
      the entirety of the directory's pagecache once previous processes have
      completed filling it.
      
      v2 - Keep the bits needed for parallel lookup
      
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9dc9bee7
    • Eric Dumazet's avatar
      bonding/alb: properly access headers in bond_alb_xmit() · aeba8c49
      Eric Dumazet authored
      [ Upstream commit 38f88c45 ]
      
      syzbot managed to send an IPX packet through bond_alb_xmit()
      and af_packet and triggered a use-after-free.
      
      First, bond_alb_xmit() was using ipx_hdr() helper to reach
      the IPX header, but ipx_hdr() was using the transport offset
      instead of the network offset. In the particular syzbot
      report transport offset was 0xFFFF
      
      This patch removes ipx_hdr() since it was only (mis)used from bonding.
      
      Then we need to make sure IPv4/IPv6/IPX headers are pulled
      in skb->head before dereferencing anything.
      
      BUG: KASAN: use-after-free in bond_alb_xmit+0x153a/0x1590 drivers/net/bonding/bond_alb.c:1452
      Read of size 2 at addr ffff8801ce56dfff by task syz-executor.2/18108
       (if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) ...)
      
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       [<ffffffff8441fc42>] __dump_stack lib/dump_stack.c:17 [inline]
       [<ffffffff8441fc42>] dump_stack+0x14d/0x20b lib/dump_stack.c:53
       [<ffffffff81a7dec4>] print_address_description+0x6f/0x20b mm/kasan/report.c:282
       [<ffffffff81a7e0ec>] kasan_report_error mm/kasan/report.c:380 [inline]
       [<ffffffff81a7e0ec>] kasan_report mm/kasan/report.c:438 [inline]
       [<ffffffff81a7e0ec>] kasan_report.cold+0x8c/0x2a0 mm/kasan/report.c:422
       [<ffffffff81a7dc4f>] __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:469
       [<ffffffff82c8c00a>] bond_alb_xmit+0x153a/0x1590 drivers/net/bonding/bond_alb.c:1452
       [<ffffffff82c60c74>] __bond_start_xmit drivers/net/bonding/bond_main.c:4199 [inline]
       [<ffffffff82c60c74>] bond_start_xmit+0x4f4/0x1570 drivers/net/bonding/bond_main.c:4224
       [<ffffffff83baa558>] __netdev_start_xmit include/linux/netdevice.h:4525 [inline]
       [<ffffffff83baa558>] netdev_start_xmit include/linux/netdevice.h:4539 [inline]
       [<ffffffff83baa558>] xmit_one net/core/dev.c:3611 [inline]
       [<ffffffff83baa558>] dev_hard_start_xmit+0x168/0x910 net/core/dev.c:3627
       [<ffffffff83bacf35>] __dev_queue_xmit+0x1f55/0x33b0 net/core/dev.c:4238
       [<ffffffff83bae3a8>] dev_queue_xmit+0x18/0x20 net/core/dev.c:4278
       [<ffffffff84339189>] packet_snd net/packet/af_packet.c:3226 [inline]
       [<ffffffff84339189>] packet_sendmsg+0x4919/0x70b0 net/packet/af_packet.c:3252
       [<ffffffff83b1ac0c>] sock_sendmsg_nosec net/socket.c:673 [inline]
       [<ffffffff83b1ac0c>] sock_sendmsg+0x12c/0x160 net/socket.c:684
       [<ffffffff83b1f5a2>] __sys_sendto+0x262/0x380 net/socket.c:1996
       [<ffffffff83b1f700>] SYSC_sendto net/socket.c:2008 [inline]
       [<ffffffff83b1f700>] SyS_sendto+0x40/0x60 net/socket.c:2004
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Jay Vosburgh <j.vosburgh@gmail.com>
      Cc: Veaceslav Falico <vfalico@gmail.com>
      Cc: Andy Gospodarek <andy@greyhouse.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aeba8c49
    • Florian Fainelli's avatar
      net: systemport: Avoid RBUF stuck in Wake-on-LAN mode · 34b4e7bd
      Florian Fainelli authored
      [ Upstream commit 263a425a ]
      
      After a number of suspend and resume cycles, it is possible for the RBUF
      to be stuck in Wake-on-LAN mode, despite the MPD enable bit being
      cleared which instructed the RBUF to exit that mode.
      
      Avoid creating that problematic condition by clearing the RX_EN and
      TX_EN bits in the UniMAC prior to disable the Magic Packet Detector
      logic which is guaranteed to make the RBUF exit Wake-on-LAN mode.
      
      Fixes: 83e82f4c
      
       ("net: systemport: add Wake-on-LAN support")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34b4e7bd
    • Andreas Kemnade's avatar
      mfd: rn5t618: Mark ADC control register volatile · e989b251
      Andreas Kemnade authored
      commit 2f3dc25c upstream.
      
      There is a bit which gets cleared after conversion.
      
      Fixes: 9bb9e29c
      
       ("mfd: Add Ricoh RN5T618 PMIC core driver")
      Signed-off-by: default avatarAndreas Kemnade <andreas@kemnade.info>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e989b251
    • Marco Felsch's avatar
      mfd: da9062: Fix watchdog compatible string · 4f7acf37
      Marco Felsch authored
      commit 1112ba02 upstream.
      
      The watchdog driver compatible is "dlg,da9062-watchdog" and not
      "dlg,da9062-wdt". Therefore the mfd-core can't populate the of_node and
      fwnode. As result the watchdog driver can't parse the devicetree.
      
      Fixes: 9b40b030
      
       ("mfd: da9062: Supply core driver")
      Signed-off-by: default avatarMarco Felsch <m.felsch@pengutronix.de>
      Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: default avatarAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f7acf37
    • Dan Carpenter's avatar
      ubi: Fix an error pointer dereference in error handling code · 03c25792
      Dan Carpenter authored
      commit 5d3805af upstream.
      
      If "seen_pebs = init_seen(ubi);" fails then "seen_pebs" is an error pointer
      and we try to kfree() it which results in an Oops.
      
      This patch re-arranges the error handling so now it only frees things
      which have been allocated successfully.
      
      Fixes: daef3dd1
      
       ("UBI: Fastmap: Add self check to detect absent PEBs")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03c25792
    • Sascha Hauer's avatar
      ubi: fastmap: Fix inverted logic in seen selfcheck · a17bdec5
      Sascha Hauer authored
      commit ef5aafb6 upstream.
      
      set_seen() sets the bit corresponding to the PEB number in the bitmap,
      so when self_check_seen() wants to find PEBs that haven't been seen we
      have to print the PEBs that have their bit cleared, not the ones which
      have it set.
      
      Fixes: 5d71afb0
      
       ("ubi: Use bitmaps in Fastmap self-check code")
      Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a17bdec5
    • Arnd Bergmann's avatar
      nfsd: fix jiffies/time_t mixup in LRU list · 669210a0
      Arnd Bergmann authored
      commit 9594497f upstream.
      
      The nfsd4_blocked_lock->nbl_time timestamp is recorded in jiffies,
      but then compared to a CLOCK_REALTIME timestamp later on, which makes
      no sense.
      
      For consistency with the other timestamps, change this to use a time_t.
      
      This is a change in behavior, which may cause regressions, but the
      current code is not sensible. On a system with CONFIG_HZ=1000,
      the 'time_after((unsigned long)nbl->nbl_time, (unsigned long)cutoff))'
      check is false for roughly the first 18 days of uptime and then true
      for the next 49 days.
      
      Fixes: 7919d0a2
      
       ("nfsd: add a LRU list for blocked locks")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      669210a0
    • Arnd Bergmann's avatar
      nfsd: fix delay timer on 32-bit architectures · 1df92bf3
      Arnd Bergmann authored
      commit 2561c92b upstream.
      
      The nfsd4_cb_layout_done() function takes a 'time_t' value,
      multiplied by NSEC_PER_SEC*2 to get a nanosecond value.
      
      This works fine on 64-bit architectures, but on 32-bit, any
      value over 1 second results in a signed integer overflow
      with unexpected results.
      
      Cast one input to a 64-bit type in order to produce the
      same result that we have on 64-bit architectures, regarless
      of the type of nfsd4_lease.
      
      Fixes: 6b9b2107
      
       ("nfsd: give up on CB_LAYOUTRECALLs after two lease periods")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1df92bf3
    • Prabhath Sajeepa's avatar
      IB/mlx5: Fix outstanding_pi index for GSI qps · ad0716a5
      Prabhath Sajeepa authored
      commit b5671afe upstream.
      
      Commit b0ffeb53 ("IB/mlx5: Fix iteration overrun in GSI qps") changed
      the way outstanding WRs are tracked for the GSI QP. But the fix did not
      cover the case when a call to ib_post_send() fails and updates index to
      track outstanding.
      
      Since the prior commmit outstanding_pi should not be bounded otherwise the
      loop generate_completions() will fail.
      
      Fixes: b0ffeb53
      
       ("IB/mlx5: Fix iteration overrun in GSI qps")
      Link: https://lore.kernel.org/r/1576195889-23527-1-git-send-email-psajeepa@purestorage.com
      Signed-off-by: default avatarPrabhath Sajeepa <psajeepa@purestorage.com>
      Acked-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad0716a5
    • Nathan Chancellor's avatar
      net: tulip: Adjust indentation in {dmfe, uli526x}_init_module · 3e4ab156
      Nathan Chancellor authored
      commit fe06bf3d upstream.
      
      Clang warns:
      
      ../drivers/net/ethernet/dec/tulip/uli526x.c:1812:3: warning: misleading
      indentation; statement is not part of the previous 'if'
      [-Wmisleading-indentation]
              switch (mode) {
              ^
      ../drivers/net/ethernet/dec/tulip/uli526x.c:1809:2: note: previous
      statement is here
              if (cr6set)
              ^
      1 warning generated.
      
      ../drivers/net/ethernet/dec/tulip/dmfe.c:2217:3: warning: misleading
      indentation; statement is not part of the previous 'if'
      [-Wmisleading-indentation]
              switch(mode) {
              ^
      ../drivers/net/ethernet/dec/tulip/dmfe.c:2214:2: note: previous
      statement is here
              if (cr6set)
              ^
      1 warning generated.
      
      This warning occurs because there is a space before the tab on these
      lines. Remove them so that the indentation is consistent with the Linux
      kernel coding style and clang no longer warns.
      
      While we are here, adjust the default block in dmfe_init_module to have
      a proper break between the label and assignment and add a space between
      the switch and opening parentheses to avoid a checkpatch warning.
      
      Fixes: e1c3e501
      
       ("[PATCH] initialisation cleanup for ULI526x-net-driver")
      Link: https://github.com/ClangBuiltLinux/linux/issues/795
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e4ab156
    • Nathan Chancellor's avatar
      net: smc911x: Adjust indentation in smc911x_phy_configure · 12b6b8f3
      Nathan Chancellor authored
      commit 5c61e223 upstream.
      
      Clang warns:
      
      ../drivers/net/ethernet/smsc/smc911x.c:939:3: warning: misleading
      indentation; statement is not part of the previous 'if'
      [-Wmisleading-indentation]
               if (!lp->ctl_rfduplx)
               ^
      ../drivers/net/ethernet/smsc/smc911x.c:936:2: note: previous statement
      is here
              if (lp->ctl_rspeed != 100)
              ^
      1 warning generated.
      
      This warning occurs because there is a space after the tab on this line.
      Remove it so that the indentation is consistent with the Linux kernel
      coding style and clang no longer warns.
      
      Fixes: 0a0c72c9
      
       ("[PATCH] RE: [PATCH 1/1] net driver: Add support for SMSC LAN911x line of ethernet chips")
      Link: https://github.com/ClangBuiltLinux/linux/issues/796
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12b6b8f3
    • Nathan Chancellor's avatar
      ppp: Adjust indentation into ppp_async_input · 2f152bf4
      Nathan Chancellor authored
      commit 08cbc75f upstream.
      
      Clang warns:
      
      ../drivers/net/ppp/ppp_async.c:877:6: warning: misleading indentation;
      statement is not part of the previous 'if' [-Wmisleading-indentation]
                                      ap->rpkt = skb;
                                      ^
      ../drivers/net/ppp/ppp_async.c:875:5: note: previous statement is here
                                      if (!skb)
                                      ^
      1 warning generated.
      
      This warning occurs because there is a space before the tab on this
      line. Clean up this entire block's indentation so that it is consistent
      with the Linux kernel coding style and clang no longer warns.
      
      Fixes: 6722e78c
      
       ("[PPP]: handle misaligned accesses")
      Link: https://github.com/ClangBuiltLinux/linux/issues/800
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f152bf4
    • Nathan Chancellor's avatar
      NFC: pn544: Adjust indentation in pn544_hci_check_presence · 05c3012a
      Nathan Chancellor authored
      commit 50808326 upstream.
      
      Clang warns
      
      ../drivers/nfc/pn544/pn544.c:696:4: warning: misleading indentation;
      statement is not part of the previous 'if' [-Wmisleading-indentation]
                       return nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE,
                       ^
      ../drivers/nfc/pn544/pn544.c:692:3: note: previous statement is here
                      if (target->nfcid1_len != 4 && target->nfcid1_len != 7 &&
                      ^
      1 warning generated.
      
      This warning occurs because there is a space after the tab on this line.
      Remove it so that the indentation is consistent with the Linux kernel
      coding style and clang no longer warns.
      
      Fixes: da052850
      
       ("NFC: Add pn544 presence check for different targets")
      Link: https://github.com/ClangBuiltLinux/linux/issues/814
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05c3012a
    • Nathan Chancellor's avatar
      powerpc/44x: Adjust indentation in ibm4xx_denali_fixup_memsize · 24a7c105
      Nathan Chancellor authored
      commit c3aae14e upstream.
      
      Clang warns:
      
      ../arch/powerpc/boot/4xx.c:231:3: warning: misleading indentation;
      statement is not part of the previous 'else' [-Wmisleading-indentation]
              val = SDRAM0_READ(DDR0_42);
              ^
      ../arch/powerpc/boot/4xx.c:227:2: note: previous statement is here
              else
              ^
      
      This is because there is a space at the beginning of this line; remove
      it so that the indentation is consistent according to the Linux kernel
      coding style and clang no longer warns.
      
      Fixes: d23f5099
      
       ("[POWERPC] 4xx: Adds decoding of 440SPE memory size to boot wrapper library")
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://github.com/ClangBuiltLinux/linux/issues/780
      Link: https://lore.kernel.org/r/20191209200338.12546-1-natechancellor@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24a7c105
    • Nathan Chancellor's avatar
      ext2: Adjust indentation in ext2_fill_super · 4d59b651
      Nathan Chancellor authored
      commit d9e98668 upstream.
      
      Clang warns:
      
      ../fs/ext2/super.c:1076:3: warning: misleading indentation; statement is
      not part of the previous 'if' [-Wmisleading-indentation]
              sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
              ^
      ../fs/ext2/super.c:1074:2: note: previous statement is here
              if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
              ^
      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.
      
      Fixes: 41f04d85
      
       ("[PATCH] ext2: fix mounts at 16T")
      Link: https://github.com/ClangBuiltLinux/linux/issues/827
      Link: https://lore.kernel.org/r/20191218031930.31393-1-natechancellor@gmail.com
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d59b651
    • Nathan Chancellor's avatar
      scsi: qla4xxx: Adjust indentation in qla4xxx_mem_free · b041f690
      Nathan Chancellor authored
      commit aa867973 upstream.
      
      Clang warns:
      
      ../drivers/scsi/qla4xxx/ql4_os.c:4148:3: warning: misleading
      indentation; statement is not part of the previous 'if'
      [-Wmisleading-indentation]
               if (ha->fw_dump)
               ^
      ../drivers/scsi/qla4xxx/ql4_os.c:4144:2: note: previous statement is
      here
              if (ha->queues)
              ^
      1 warning generated.
      
      This warning occurs because there is a space after the tab on this
      line.  Remove it so that the indentation is consistent with the Linux
      kernel coding style and clang no longer warns.
      
      Fixes: 068237c8
      
       ("[SCSI] qla4xxx: Capture minidump for ISP82XX on firmware failure")
      Link: https://github.com/ClangBuiltLinux/linux/issues/819
      Link: https://lore.kernel.org/r/20191218015252.20890-1-natechancellor@gmail.com
      Acked-by: default avatarManish Rangankar <mrangankar@marvell.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b041f690
    • Nathan Chancellor's avatar
      scsi: csiostor: Adjust indentation in csio_device_reset · 0d4aabaf
      Nathan Chancellor authored
      commit a808a04c upstream.
      
      Clang warns:
      
      ../drivers/scsi/csiostor/csio_scsi.c:1386:3: warning: misleading
      indentation; statement is not part of the previous 'if'
      [-Wmisleading-indentation]
               csio_lnodes_exit(hw, 1);
               ^
      ../drivers/scsi/csiostor/csio_scsi.c:1382:2: note: previous statement is
      here
              if (*buf != '1')
              ^
      1 warning generated.
      
      This warning occurs because there is a space after the tab on this
      line.  Remove it so that the indentation is consistent with the Linux
      kernel coding style and clang no longer warns.
      
      Fixes: a3667aae
      
       ("[SCSI] csiostor: Chelsio FCoE offload driver")
      Link: https://github.com/ClangBuiltLinux/linux/issues/818
      Link: https://lore.kernel.org/r/20191218014726.8455-1-natechancellor@gmail.com
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0d4aabaf
    • Bart Van Assche's avatar
      scsi: qla2xxx: Fix the endianness of the qla82xx_get_fw_size() return type · 6066737d
      Bart Van Assche authored
      commit 3f5f7335 upstream.
      
      Since qla82xx_get_fw_size() returns a number in CPU-endian format, change
      its return type from __le32 into u32. This patch does not change any
      functionality.
      
      Fixes: 9c2b2975
      
       ("[SCSI] qla2xxx: Support for loading Unified ROM Image (URI) format firmware file.")
      Cc: Himanshu Madhani <hmadhani@marvell.com>
      Cc: Quinn Tran <qutran@marvell.com>
      Cc: Martin Wilck <mwilck@suse.com>
      Cc: Daniel Wagner <dwagner@suse.de>
      Cc: Roman Bolshakov <r.bolshakov@yadro.com>
      Link: https://lore.kernel.org/r/20191219004905.39586-1-bvanassche@acm.org
      Reviewed-by: default avatarDaniel Wagner <dwagner@suse.de>
      Reviewed-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
      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>
      6066737d
    • Stephen Warren's avatar
      clk: tegra: Mark fuse clock as critical · 272fbad7
      Stephen Warren authored
      commit bf83b96f
      
       upstream.
      
      For a little over a year, U-Boot on Tegra124 has configured the flow
      controller to perform automatic RAM re-repair on off->on power
      transitions of the CPU rail[1]. This is mandatory for correct operation
      of Tegra124. However, RAM re-repair relies on certain clocks, which the
      kernel must enable and leave running. The fuse clock is one of those
      clocks. Mark this clock as critical so that LP1 power mode (system
      suspend) operates correctly.
      
      [1] 3cc7942a4ae5 ARM: tegra: implement RAM repair
      
      Reported-by: default avatarJonathan Hunter <jonathanh@nvidia.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      272fbad7