1. Nov 20, 2019
    • Bob Peterson's avatar
      gfs2: clean up iopen glock mess in gfs2_create_inode · 2c47c1be
      Bob Peterson authored
      
      
      Before this patch, gfs2_create_inode had a use-after-free for the
      iopen glock in some error paths because it did this:
      
      	gfs2_glock_put(io_gl);
      fail_gunlock2:
      	if (io_gl)
      		clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
      
      In some cases, the io_gl was used for create and only had one
      reference, so the glock might be freed before the clear_bit().
      This patch tries to straighten it out by only jumping to the
      error paths where iopen is properly set, and moving the
      gfs2_glock_put after the clear_bit.
      
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      2c47c1be
  2. Nov 16, 2019
    • Bob Peterson's avatar
      gfs2: Close timing window with GLF_INVALIDATE_IN_PROGRESS · d99724c3
      Bob Peterson authored
      
      
      This patch closes a timing window in which two processes compete
      and overlap in the execution of do_xmote for the same glock:
      
                   Process A                              Process B
         ------------------------------------   -----------------------------
      1. Grabs gl_lockref and calls do_xmote
      2.                                        Grabs gl_lockref but is blocked
      3. Sets GLF_INVALIDATE_IN_PROGRESS
      4. Unlocks gl_lockref
      5.                                        Calls do_xmote
      6. Call glops->go_sync
      7. test_and_clear_bit GLF_DIRTY
      8. Call gfs2_log_flush                    Call glops->go_sync
      9. (slow IO, so it blocks a long time)    test_and_clear_bit GLF_DIRTY
                                                It's not dirty (step 7) returns
      10.                                       Tests GLF_INVALIDATE_IN_PROGRESS
      11.                                       Calls go_inval (rgrp_go_inval)
      12.                                       gfs2_rgrp_relse does brelse
      13.                                       truncate_inode_pages_range
      14.                                       Calls lm_lock UN
      
      In step 14 we've just told dlm to give the glock to another node
      when, in fact, process A has not finished the IO and synced all
      buffer_heads to disk and make sure their revokes are done.
      
      This patch fixes the problem by changing the GLF_INVALIDATE_IN_PROGRESS
      to use test_and_set_bit, and if the bit is already set, process B just
      ignores it and trusts that process A will do the do_xmote in the proper
      order.
      
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      d99724c3
    • Bob Peterson's avatar
      gfs2: Abort gfs2_freeze if io error is seen · 52b1cdcb
      Bob Peterson authored
      
      
      Before this patch, an io error, such as -EIO writing to the journal
      would cause function gfs2_freeze to go into an infinite loop,
      continuously retrying the freeze operation. But nothing ever clears
      the -EIO except unmount after withdraw, which is impossible if the
      freeze operation never ends (fails). Instead you get:
      
      [ 6499.767994] gfs2: fsid=dm-32.0: error freezing FS: -5
      [ 6499.773058] gfs2: fsid=dm-32.0: retrying...
      [ 6500.791957] gfs2: fsid=dm-32.0: error freezing FS: -5
      [ 6500.797015] gfs2: fsid=dm-32.0: retrying...
      
      This patch adds a check for -EIO in gfs2_freeze, and if seen, it
      dequeues the freeze glock, aborts the loop and returns the error.
      Also, there's no need to pass the freeze holder to function
      gfs2_lock_fs_check_clean since it's only called in one place and
      it's a well-known superblock pointer, so this simplifies that.
      
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      52b1cdcb
  3. Nov 15, 2019
  4. Nov 14, 2019
  5. Nov 12, 2019
    • Andreas Gruenbacher's avatar
      gfs2: Remove active journal side effect from gfs2_write_log_header · 19ebc050
      Andreas Gruenbacher authored
      Function gfs2_write_log_header can be used to write a log header into any of
      the journals of a filesystem.  When used on the node's own journal,
      gfs2_write_log_header advances the current position in the log
      (sdp->sd_log_flush_head) as a side effect, through function gfs2_log_bmap.
      
      This is confusing, and it also means that we can't use gfs2_log_bmap for other
      journals even if they have an extent map.  So clean this mess up by not
      advancing sdp->sd_log_flush_head in gfs2_write_log_header or gfs2_log_bmap
      anymore and making that a responsibility of the callers instead.
      
      This is related to commit 7c70b896
      
       ("gfs2: clean_journal improperly set
      sd_log_flush_head").
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      19ebc050
  6. Nov 08, 2019
    • Andreas Gruenbacher's avatar
      gfs2: Fix end-of-file handling in gfs2_page_mkwrite · 184b4e60
      Andreas Gruenbacher authored
      
      
      When the filesystem block size is smaller than the page size, the last
      page may contain blocks that lie entirely beyond the end of the file.
      Make sure to only allocate blocks that lie at least partially in the
      file.  Allocating blocks beyond that isn't useful, and what's more, they
      will not be zeroed out and may end up containing random data.
      
      With that change in place, make sure we'll still always unstuff stuffed
      inodes: iomap_writepage and iomap_writepages currently can't handle
      stuffed files.
      
      In addition, simplify and move the end-of-file check further to the top
      in gfs2_page_mkwrite to avoid weird side effects like unstuffing when
      we're not.
      
      Fixes xfstest generic/263.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      184b4e60
    • Andreas Gruenbacher's avatar
      gfs2: Multi-block allocations in gfs2_page_mkwrite · f53056c4
      Andreas Gruenbacher authored
      In gfs2_page_mkwrite's gfs2_allocate_page_backing helper, try to
      allocate as many blocks at once as we need.  Pass in the size of the
      requested allocation.
      
      Fixes: 35af80ae
      
       ("gfs2: don't use buffer_heads in gfs2_allocate_page_backing")
      Cc: stable@vger.kernel.org # v5.3+
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      f53056c4
    • Andreas Gruenbacher's avatar
      gfs2: Improve mmap write vs. punch_hole consistency · 39c3a948
      Andreas Gruenbacher authored
      
      
      When punching a hole in a file, use filemap_write_and_wait_range to
      write back any dirty pages in the range of the hole.  As a side effect,
      if the hole isn't page aligned, this marks unaligned pages at the
      beginning and the end of the hole read-only.  This is required when the
      block size is smaller than the page size: when those pages are written
      to again after the hole punching, we must make sure that page_mkwrite is
      called for those pages so that the page will be fully allocated and any
      blocks turned into holes from the hole punching will be reallocated.
      (If a page is writably mapped, page_mkwrite won't be called.)
      
      Fixes xfstest generic/567.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      39c3a948
  7. Oct 30, 2019
  8. Oct 28, 2019
  9. Oct 27, 2019
    • Linus Torvalds's avatar
      Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 153a971f
      Linus Torvalds authored
      Pull x86 fixes from Thomas Gleixner:
       "Two fixes for the VMWare guest support:
      
         - Unbreak VMWare platform detection which got wreckaged by converting
           an integer constant to a string constant.
      
         - Fix the clang build of the VMWAre hypercall by explicitely
           specifying the ouput register for INL instead of using the short
           form"
      
      * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/cpu/vmware: Fix platform detection VMWARE_PORT macro
        x86/cpu/vmware: Use the full form of INL in VMWARE_HYPERCALL, for clang/llvm
      153a971f
    • Linus Torvalds's avatar
      Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 2b776b54
      Linus Torvalds authored
      Pull timer fixes from Thomas Gleixner:
       "A small set of fixes for time(keeping):
      
         - Add a missing include to prevent compiler warnings.
      
         - Make the VDSO implementation of clock_getres() POSIX compliant
           again. A recent change dropped the NULL pointer guard which is
           required as NULL is a valid pointer value for this function.
      
         - Fix two function documentation typos"
      
      * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        posix-cpu-timers: Fix two trivial comments
        timers/sched_clock: Include local timekeeping.h for missing declarations
        lib/vdso: Make clock_getres() POSIX compliant again
      2b776b54
    • Linus Torvalds's avatar
      Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · a8a31fdc
      Linus Torvalds authored
      Pull perf fixes from Thomas Gleixner:
       "A set of perf fixes:
      
        kernel:
      
         - Unbreak the tracking of auxiliary buffer allocations which got
           imbalanced causing recource limit failures.
      
         - Fix the fallout of splitting of ToPA entries which missed to shift
           the base entry PA correctly.
      
         - Use the correct context to lookup the AUX event when unmapping the
           associated AUX buffer so the event can be stopped and the buffer
           reference dropped.
      
        tools:
      
         - Fix buildiid-cache mode setting in copyfile_mode_ns() when copying
           /proc/kcore
      
         - Fix freeing id arrays in the event list so the correct event is
           closed.
      
         - Sync sched.h anc kvm.h headers with the kernel sources.
      
         - Link jvmti against tools/lib/ctype.o to have weak strlcpy().
      
         - Fix multiple memory and file descriptor leaks, found by coverity in
           perf annotate.
      
         - Fix leaks in error handling paths in 'perf c2c', 'perf kmem', found
           by a static analysis tool"
      
      * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        perf/aux: Fix AUX output stopping
        perf/aux: Fix tracking of auxiliary trace buffer allocation
        perf/x86/intel/pt: Fix base for single entry topa
        perf kmem: Fix memory leak in compact_gfp_flags()
        tools headers UAPI: Sync sched.h with the kernel
        tools headers kvm: Sync kvm.h headers with the kernel sources
        tools headers kvm: Sync kvm headers with the kernel sources
        tools headers kvm: Sync kvm headers with the kernel sources
        perf c2c: Fix memory leak in build_cl_output()
        perf tools: Fix mode setting in copyfile_mode_ns()
        perf annotate: Fix multiple memory and file descriptor leaks
        perf tools: Fix resource leak of closedir() on the error paths
        perf evlist: Fix fix for freed id arrays
        perf jvmti: Link against tools/lib/ctype.h to have weak strlcpy()
      a8a31fdc
    • Linus Torvalds's avatar
      Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 1e1ac1cb
      Linus Torvalds authored
      Pull irq fixes from Thomas Gleixner:
       "Two fixes for interrupt controller drivers:
      
         - Skip IRQ_M_EXT entries in the device tree when initializing the
           RISCV PLIC controller to avoid a double init attempt.
      
         - Use the correct ITS list when issuing the VMOVP synchronization
           command so the operation works only on the ITS instances which are
           associated to a VM"
      
      * 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        irqchip/sifive-plic: Skip contexts except supervisor in plic_init()
        irqchip/gic-v3-its: Use the exact ITSList for VMOVP
      1e1ac1cb
    • Linus Torvalds's avatar
      Merge tag '5.4-rc5-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6 · c9a2e4a8
      Linus Torvalds authored
      Pull cifs fixes from Steve French:
       "Seven cifs/smb3 fixes, including three for stable"
      
      * tag '5.4-rc5-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6:
        cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs
        CIFS: Fix use after free of file info structures
        CIFS: Fix retry mid list corruption on reconnects
        cifs: Fix missed free operations
        CIFS: avoid using MID 0xFFFF
        cifs: clarify comment about timestamp granularity for old servers
        cifs: Handle -EINPROGRESS only when noblockcnt is set
      c9a2e4a8
    • Linus Torvalds's avatar
      Merge tag 'riscv/for-v5.4-rc5-b' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · 6995a6a5
      Linus Torvalds authored
      Pull RISC-V fixes from Paul Walmsley:
       "Several minor fixes and cleanups for v5.4-rc5:
      
         - Three build fixes for various SPARSEMEM-related kernel
           configurations
      
         - Two cleanup patches for the kernel bug and breakpoint trap handler
           code"
      
      * tag 'riscv/for-v5.4-rc5-b' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        riscv: cleanup do_trap_break
        riscv: cleanup <asm/bug.h>
        riscv: Fix undefined reference to vmemmap_populate_basepages
        riscv: Fix implicit declaration of 'page_to_section'
        riscv: fix fs/proc/kcore.c compilation with sparsemem enabled
      6995a6a5
    • Linus Torvalds's avatar
      Merge tag 'mips_fixes_5.4_3' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux · 5a1e843c
      Linus Torvalds authored
      Pull MIPS fixes from Paul Burton:
       "A few MIPS fixes:
      
         - Fix VDSO time-related function behavior for systems where we need
           to fall back to syscalls, but were instead returning bogus results.
      
         - A fix to TLB exception handlers for Cavium Octeon systems where
           they would inadvertently clobber the $1/$at register.
      
         - A build fix for bcm63xx configurations.
      
         - Switch to using my @kernel.org email address"
      
      * tag 'mips_fixes_5.4_3' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
        MIPS: tlbex: Fix build_restore_pagemask KScratch restore
        MIPS: bmips: mark exception vectors as char arrays
        mips: vdso: Fix __arch_get_hw_counter()
        MAINTAINERS: Use @kernel.org address for Paul Burton
      5a1e843c
    • Linus Torvalds's avatar
      Merge tag 'tty-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 29768954
      Linus Torvalds authored
      Pull tty/serial driver fix from Greg KH:
       "Here is a single tty/serial driver fix for 5.4-rc5 that resolves a
        reported issue.
      
        It has been in linux-next for a while with no problems"
      
      * tag 'tty-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        8250-men-mcb: fix error checking when get_num_ports returns -ENODEV
      29768954
    • Linus Torvalds's avatar
      Merge tag 'staging-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging · 228bd624
      Linus Torvalds authored
      Pull staging driver fix from Greg KH:
       "Here is a single staging driver fix, for the wlan-ng driver, that
        resolves a reported issue.
      
        It is been in linux-next for a while with no reported issues"
      
      * tag 'staging-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
        staging: wlan-ng: fix exit return when sme->key_idx >= NUM_WEPKEYS
      228bd624
    • Linus Torvalds's avatar
      Merge tag 'driver-core-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core · 13fa692e
      Linus Torvalds authored
      Pull driver core fix from Greg KH:
       "Here is a single sysfs fix for 5.4-rc5.
      
        It resolves an error if you actually try to use the __BIN_ATTR_WO()
        macro, seems I never tested it properly before :(
      
        This has been in linux-next for a while with no reported issues"
      
      * tag 'driver-core-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
        sysfs: Fixes __BIN_ATTR_WO() macro
      13fa692e
    • Linus Torvalds's avatar
      Merge tag 'char-misc-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · a03885d5
      Linus Torvalds authored
      Pull binder fix from Greg KH:
       "This is a single binder fix to resolve a reported issue by Jann. It's
        been in linux-next for a while with no reported issues"
      
      * tag 'char-misc-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        binder: Don't modify VMA bounds in ->mmap handler
      a03885d5
    • Linus Torvalds's avatar
      Merge tag 'usb-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 0ecdd78c
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are a number of small USB driver fixes for 5.4-rc5.
      
        More "fun" with some of the misc USB drivers as found by syzbot, and
        there are a number of other small bugfixes in here for reported
        issues.
      
        All have been in linux-next for a while with no reported issues"
      
      * tag 'usb-5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        usb: cdns3: Error out if USB_DR_MODE_UNKNOWN in cdns3_core_init_role()
        USB: ldusb: fix read info leaks
        USB: serial: ti_usb_3410_5052: clean up serial data access
        USB: serial: ti_usb_3410_5052: fix port-close races
        USB: usblp: fix use-after-free on disconnect
        usb: udc: lpc32xx: fix bad bit shift operation
        usb: cdns3: Fix dequeue implementation.
        USB: legousbtower: fix a signedness bug in tower_probe()
        USB: legousbtower: fix memleak on disconnect
        USB: ldusb: fix memleak on disconnect
      0ecdd78c
    • Linus Torvalds's avatar
      Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · 992cb107
      Linus Torvalds authored
      Pull i2c fixes from Wolfram Sang:
       "A few driver fixes for the I2C subsystem"
      
      * 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        i2c: stm32f7: remove warning when compiling with W=1
        i2c: stm32f7: fix a race in slave mode with arbitration loss irq
        i2c: stm32f7: fix first byte to send in slave mode
        i2c: mt65xx: fix NULL ptr dereference
        i2c: aspeed: fix master pending state handling
      992cb107
    • Linus Torvalds's avatar
      Merge tag 'for-linus-2019-10-26' of git://git.kernel.dk/linux-block · acf913b7
      Linus Torvalds authored
      Pull block and io_uring fixes from Jens Axboe:
       "A bit bigger than usual at this point in time, mostly due to some good
        bug hunting work by Pavel that resulted in three io_uring fixes from
        him and two from me. Anyway, this pull request contains:
      
         - Revert of the submit-and-wait optimization for io_uring, it can't
           always be done safely. It depends on commands always making
           progress on their own, which isn't necessarily the case outside of
           strict file IO. (me)
      
         - Series of two patches from me and three from Pavel, fixing issues
           with shared data and sequencing for io_uring.
      
         - Lastly, two timeout sequence fixes for io_uring (zhangyi)
      
         - Two nbd patches fixing races (Josef)
      
         - libahci regulator_get_optional() fix (Mark)"
      
      * tag 'for-linus-2019-10-26' of git://git.kernel.dk/linux-block:
        nbd: verify socket is supported during setup
        ata: libahci_platform: Fix regulator_get_optional() misuse
        nbd: handle racing with error'ed out commands
        nbd: protect cmd->status with cmd->lock
        io_uring: fix bad inflight accounting for SETUP_IOPOLL|SETUP_SQTHREAD
        io_uring: used cached copies of sq->dropped and cq->overflow
        io_uring: Fix race for sqes with userspace
        io_uring: Fix broken links with offloading
        io_uring: Fix corrupted user_data
        io_uring: correct timeout req sequence when inserting a new entry
        io_uring : correct timeout req sequence when waiting timeout
        io_uring: revert "io_uring: optimize submit_and_wait API"
      acf913b7
  10. Oct 26, 2019