Skip to content
  1. Oct 09, 2014
    • Eric W. Biederman's avatar
      vfs: Don't allow overwriting mounts in the current mount namespace · 7af1364f
      Eric W. Biederman authored
      
      
      In preparation for allowing mountpoints to be renamed and unlinked
      in remote filesystems and in other mount namespaces test if on a dentry
      there is a mount in the local mount namespace before allowing it to
      be renamed or unlinked.
      
      The primary motivation here are old versions of fusermount unmount
      which is not safe if the a path can be renamed or unlinked while it is
      verifying the mount is safe to unmount.  More recent versions are simpler
      and safer by simply using UMOUNT_NOFOLLOW when unmounting a mount
      in a directory owned by an arbitrary user.
      
      Miklos Szeredi <miklos@szeredi.hu> reports this is approach is good
      enough to remove concerns about new kernels mixed with old versions
      of fusermount.
      
      A secondary motivation for restrictions here is that it removing empty
      directories that have non-empty mount points on them appears to
      violate the rule that rmdir can not remove empty directories.  As
      Linus Torvalds pointed out this is useful for programs (like git) that
      test if a directory is empty with rmdir.
      
      Therefore this patch arranges to enforce the existing mount point
      semantics for local mount namespace.
      
      v2: Rewrote the test to be a drop in replacement for d_mountpoint
      v3: Use bool instead of int as the return type of is_local_mountpoint
      
      Reviewed-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7af1364f
    • Eric W. Biederman's avatar
      vfs: More precise tests in d_invalidate · bafc9b75
      Eric W. Biederman authored
      
      
      The current comments in d_invalidate about what and why it is doing
      what it is doing are wildly off-base.  Which is not surprising as
      the comments date back to last minute bug fix of the 2.2 kernel.
      
      The big fat lie of a comment said: If it's a directory, we can't drop
      it for fear of somebody re-populating it with children (even though
      dropping it would make it unreachable from that root, we still might
      repopulate it if it was a working directory or similar).
      
      [AV] What we really need to avoid is multiple dentry aliases of the
      same directory inode; on all filesystems that have ->d_revalidate()
      we either declare all positive dentries always valid (and thus never
      fed to d_invalidate()) or use d_materialise_unique() and/or d_splice_alias(),
      which take care of alias prevention.
      
      The current rules are:
      - To prevent mount point leaks dentries that are mount points or that
        have childrent that are mount points may not be be unhashed.
      - All dentries may be unhashed.
      - Directories may be rehashed with d_materialise_unique
      
      check_submounts_and_drop implements this already for well maintained
      remote filesystems so implement the current rules in d_invalidate
      by just calling check_submounts_and_drop.
      
      The one difference between d_invalidate and check_submounts_and_drop
      is that d_invalidate must respect it when a d_revalidate method has
      earlier called d_drop so preserve the d_unhashed check in
      d_invalidate.
      
      Reviewed-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      bafc9b75
    • Eric W. Biederman's avatar
      vfs: Document the effect of d_revalidate on d_find_alias · 3ccb354d
      Eric W. Biederman authored
      
      
      d_drop or check_submounts_and_drop called from d_revalidate can result
      in renamed directories with child dentries being unhashed.  These
      renamed and drop directory dentries can be rehashed after
      d_materialise_unique uses d_find_alias to find them.
      
      Reviewed-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3ccb354d
    • Al Viro's avatar
      delayed mntput · 9ea459e1
      Al Viro authored
      
      
      On final mntput() we want fs shutdown to happen before return to
      userland; however, the only case where we want it happen right
      there (i.e. where task_work_add won't do) is MNT_INTERNAL victim.
      Those have to be fully synchronous - failure halfway through module
      init might count on having vfsmount killed right there.  Fortunately,
      final mntput on MNT_INTERNAL vfsmounts happens on shallow stack.
      So we handle those synchronously and do an analog of delayed fput
      logics for everything else.
      
      As the result, we are guaranteed that fs shutdown will always happen
      on shallow stack.
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      9ea459e1
    • Ian Kent's avatar
      autofs - remove obsolete d_invalidate() from expire · b3ca406f
      Ian Kent authored
      
      
      Biederman's umount-on-rmdir series changes d_invalidate() to sumarily remove
      mounts under the passed in dentry regardless of whether they are busy
      or not. So calling this in fs/autofs4/expire.c:autofs4_tree_busy() is
      definitely the wrong thing to do becuase it will silently umount entries
      instead of just cleaning stale dentrys.
      
      But this call shouldn't be needed and testing shows that automounting
      continues to function without it.
      
      As Al Viro correctly surmises the original intent of the call was to
      perform what shrink_dcache_parent() does.
      
      If at some time in the future I see stale dentries accumulating
      following failed mounts I'll revisit the issue and possibly add a
      shrink_dcache_parent() call if needed.
      
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      b3ca406f
    • Al Viro's avatar
      Allow sharing external names after __d_move() · 8d85b484
      Al Viro authored
      
      
      * external dentry names get a small structure prepended to them
      (struct external_name).
      * it contains an atomic refcount, matching the number of struct dentry
      instances that have ->d_name.name pointing to that external name.  The
      first thing free_dentry() does is decrementing refcount of external name,
      so the instances that are between the call of free_dentry() and
      RCU-delayed actual freeing do not contribute.
      * __d_move(x, y, false) makes the name of x equal to the name of y,
      external or not.  If y has an external name, extra reference is grabbed
      and put into x->d_name.name.  If x used to have an external name, the
      reference to the old name is dropped and, should it reach zero, freeing
      is scheduled via kfree_rcu().
      * free_dentry() in dentry with external name decrements the refcount of
      that name and, should it reach zero, does RCU-delayed call that will
      free both the dentry and external name.  Otherwise it does what it
      used to do, except that __d_free() doesn't even look at ->d_name.name;
      it simply frees the dentry.
      
      All non-RCU accesses to dentry external name are safe wrt freeing since they
      all should happen before free_dentry() is called.  RCU accesses might run
      into a dentry seen by free_dentry() or into an old name that got already
      dropped by __d_move(); however, in both cases dentry must have been
      alive and refer to that name at some point after we'd done rcu_read_lock(),
      which means that any freeing must be still pending.
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      8d85b484
  2. Sep 30, 2014
    • Al Viro's avatar
      missing data dependency barrier in prepend_name() · 6d13f694
      Al Viro authored
      
      
      AFAICS, prepend_name() is broken on SMP alpha.  Disclaimer: I don't have
      SMP alpha boxen to reproduce it on.  However, it really looks like the race
      is real.
      
      CPU1: d_path() on /mnt/ramfs/<255-character>/foo
      CPU2: mv /mnt/ramfs/<255-character> /mnt/ramfs/<63-character>
      
      CPU2 does d_alloc(), which allocates an external name, stores the name there
      including terminating NUL, does smp_wmb() and stores its address in
      dentry->d_name.name.  It proceeds to d_add(dentry, NULL) and d_move()
      old dentry over to that.  ->d_name.name value ends up in that dentry.
      
      In the meanwhile, CPU1 gets to prepend_name() for that dentry.  It fetches
      ->d_name.name and ->d_name.len; the former ends up pointing to new name
      (64-byte kmalloc'ed array), the latter - 255 (length of the old name).
      Nothing to force the ordering there, and normally that would be OK, since we'd
      run into the terminating NUL and stop.  Except that it's alpha, and we'd need
      a data dependency barrier to guarantee that we see that store of NUL
      __d_alloc() has done.  In a similar situation dentry_cmp() would survive; it
      does explicit smp_read_barrier_depends() after fetching ->d_name.name.
      prepend_name() doesn't and it risks walking past the end of kmalloc'ed object
      and possibly oops due to taking a page fault in kernel mode.
      
      Cc: stable@vger.kernel.org # 3.12+
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      6d13f694
  3. Sep 28, 2014
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 1e3827bf
      Linus Torvalds authored
      Pull vfs fixes from Al Viro:
       "Assorted fixes + unifying __d_move() and __d_materialise_dentry() +
        minimal regression fix for d_path() of victims of overwriting rename()
        ported on top of that"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        vfs: Don't exchange "short" filenames unconditionally.
        fold swapping ->d_name.hash into switch_names()
        fold unlocking the children into dentry_unlock_parents_for_move()
        kill __d_materialise_dentry()
        __d_materialise_dentry(): flip the order of arguments
        __d_move(): fold manipulations with ->d_child/->d_subdirs
        don't open-code d_rehash() in d_materialise_unique()
        pull rehashing and unlocking the target dentry into __d_materialise_dentry()
        ufs: deal with nfsd/iget races
        fuse: honour max_read and max_write in direct_io mode
        shmem: fix nlink for rename overwrite directory
      1e3827bf
    • Linus Torvalds's avatar
      Merge branch 'for-3.17-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup · 6111da34
      Linus Torvalds authored
      Pull cgroup fixes from Tejun Heo:
       "This is quite late but these need to be backported anyway.
      
        This is the fix for a long-standing cpuset bug which existed from
        2009.  cpuset makes use of PF_SPREAD_{PAGE|SLAB} flags to modify the
        task's memory allocation behavior according to the settings of the
        cpuset it belongs to; unfortunately, when those flags have to be
        changed, cpuset did so directly even whlie the target task is running,
        which is obviously racy as task->flags may be modified by the task
        itself at any time.  This obscure bug manifested as corrupt
        PF_USED_MATH flag leading to a weird crash.
      
        The bug is fixed by moving the flag to task->atomic_flags.  The first
        two are prepatory ones to help defining atomic_flags accessors and the
        third one is the actual fix"
      
      * 'for-3.17-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
        cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should be atomic flags
        sched: add macros to define bitops for task atomic flags
        sched: fix confusing PFA_NO_NEW_PRIVS constant
      6111da34
    • Linus Torvalds's avatar
      Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc · 83692898
      Linus Torvalds authored
      Pull ARM SoC fixes from Olof Johansson:
       "Here's our last set of fixes for 3.17.  Most of these are for TI
        platforms, fixing some noisy Kconfig issues, runtime clock and power
        issues on several platforms and NAND timings on DRA7.
      
        There are also a couple of bug fixes for i.MX, one for QCOM and a
       small fix to avoid section mismatch noise on PXA.
      
        Diffstat looks large, partially due to some tables being updated and
        thus touching many lines.  The qcom gsbi change also restructures
        clock management a bit and thus touches a bunch of lines.
      
        All in all, a bit more changes than we'd like at this point, but
        nothing stands out as risky either so it seems like the right thing to
        send it up now instead of holding it to the merge window"
      
      * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc:
        drivers/soc: qcom: do not disable the iface clock in probe
        ARM: imx: fix .is_enabled() of shared gate clock
        ARM: OMAP3: Fix I/O chain clock line assertion timed out error
        ARM: keystone: dts: fix bindings for pcie and usb clock nodes
        bus: omap_l3_noc: Fix connID for OMAP4
        ARM: DT: imx53: fix lvds channel 1 port
        ARM: dts: cm-t54: fix serial console power supply.
        ARM: dts: dra7-evm: Fix NAND GPMC timings
        ARM: pxa: fix section mismatch warning for pxa_timer_nodt_init
        ARM: OMAP: Fix Kconfig warning for omap1
      83692898
    • Linus Torvalds's avatar
      Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus · 74807afd
      Linus Torvalds authored
      Pull MIPS fixes from Ralf Baechle:
       "The final round of fixes.  One corner case in the math emulator and
        another one in the mcount function for ftrace"
      
      * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus:
        MIPS: mcount: Adjust stack pointer for static trace in MIPS32
        MIPS: Fix MFC1 & MFHC1 emulation for 64-bit MIPS systems
      74807afd
    • Linus Torvalds's avatar
      Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · cd40fab6
      Linus Torvalds authored
      Pull x86 fixes from Ingo Molnar:
       "This has:
      
         - EFI revert to fix a boot regression
         - early_ioremap() fix for boot failure
         - KASLR fix for possible boot failures
         - EFI fix for corrupted string printing
         - remove a misleading EFI bootup 'failed!' error message
      
        Unfortunately it's all rather close to the merge window"
      
      * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/efi: Truncate 64-bit values when calling 32-bit OutputString()
        x86/efi: Delete misleading efi_printk() error message
        Revert "efi/x86: efistub: Move shared dependencies to <asm/efi.h>"
        x86/kaslr: Avoid the setup_data area when picking location
        x86 early_ioremap: Increase FIX_BTMAPS_SLOTS to 8
      cd40fab6
    • Mikhail Efremov's avatar
      vfs: Don't exchange "short" filenames unconditionally. · d2fa4a84
      Mikhail Efremov authored
      Only exchange source and destination filenames
      if flags contain RENAME_EXCHANGE.
      In case if executable file was running and replaced by
      other file /proc/PID/exe should still show correct file name,
      not the old name of the file by which it was replaced.
      
      The scenario when this bug manifests itself was like this:
      * ALT Linux uses rpm and start-stop-daemon;
      * during a package upgrade rpm creates a temporary file
        for an executable to rename it upon successful unpacking;
      * start-stop-daemon is run subsequently and it obtains
        the (nonexistant) temporary filename via /proc/PID/exe
        thus failing to identify the running process.
      
      Note that "long" filenames (> DNAiME_INLINE_LEN) are still
      exchanged without RENAME_EXCHANGE and this behaviour exists
      long enough (should be fixed too apparently).
      So this patch is just an interim workaround that restores
      behavior for "short" names as it was before changes
      introduced by commit da1ce067
      
       ("vfs: add cross-rename").
      
      See https://lkml.org/lkml/2014/9/7/6 for details.
      
      AV: the comments about being more careful with ->d_name.hash
      than with ->d_name.name are from back in 2.3.40s; they
      became obsolete by 2.3.60s, when we started to unhash the
      target instead of swapping hash chain positions followed
      by d_delete() as we used to do when dcache was first
      introduced.
      
      Acked-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: stable@vger.kernel.org
      Fixes: da1ce067
      
       "vfs: add cross-rename"
      Signed-off-by: default avatarMikhail Efremov <sem@altlinux.org>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d2fa4a84
    • Linus Torvalds's avatar
      fold swapping ->d_name.hash into switch_names() · a28ddb87
      Linus Torvalds authored
      
      
      and do it along with ->d_name.len there
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      a28ddb87
  4. Sep 27, 2014
  5. Sep 26, 2014
    • Linus Torvalds's avatar
      Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · d2865c7d
      Linus Torvalds authored
      Pull scheduler fixes from Ingo Molnar:
       "A CONFIG_STACK_GROWSUP=y fix, and a hotplug llc CPU mask fix"
      
      * 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        sched: Fix unreleased llc_shared_mask bit during CPU hotplug
        sched: Fix end_of_stack() and location of stack canary for architectures using CONFIG_STACK_GROWSUP
      d2865c7d
    • Linus Torvalds's avatar
      Merge branch 'akpm' (fixes from Andrew Morton) · 8207649c
      Linus Torvalds authored
      Merge fixes from Andrew Morton:
       "9 fixes"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        mm: softdirty: keep bit when zapping file pte
        fs/cachefiles: add missing \n to kerror conversions
        genalloc: fix device node resource counter
        drivers/rtc/rtc-efi.c: add missing module alias
        mm, slab: initialize object alignment on cache creation
        mm: softdirty: addresses before VMAs in PTE holes aren't softdirty
        ocfs2/dlm: do not get resource spinlock if lockres is new
        nilfs2: fix data loss with mmap()
        ocfs2: free vol_label in ocfs2_delete_osb()
      8207649c
    • Peter Feiner's avatar
      mm: softdirty: keep bit when zapping file pte · dbab31aa
      Peter Feiner authored
      This fixes the same bug as b43790ee ("mm: softdirty: don't forget to
      save file map softdiry bit on unmap") and 9aed8614
      
       ("mm/memory.c:
      don't forget to set softdirty on file mapped fault") where the return
      value of pte_*mksoft_dirty was being ignored.
      
      To be sure that no other pte/pmd "mk" function return values were being
      ignored, I annotated the functions in arch/x86/include/asm/pgtable.h
      with __must_check and rebuilt.
      
      The userspace effect of this bug is that the softdirty mark might be
      lost if a file mapped pte get zapped.
      
      Signed-off-by: default avatarPeter Feiner <pfeiner@google.com>
      Acked-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Cc: Pavel Emelyanov <xemul@parallels.com>
      Cc: Jamie Liu <jamieliu@google.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: <stable@vger.kernel.org>	[3.12+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dbab31aa
    • Fabian Frederick's avatar
      fs/cachefiles: add missing \n to kerror conversions · 6ff66ac7
      Fabian Frederick authored
      Commit 0227d6ab
      
       ("fs/cachefiles: replace kerror by pr_err") didn't
      include newline featuring in original kerror definition
      
      Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
      Reported-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarDavid Howells <dhowells@redhat.com>
      Cc: <stable@vger.kernel.org>	[3.16.x]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6ff66ac7
    • Vladimir Zapolskiy's avatar
      genalloc: fix device node resource counter · 6f3aabd1
      Vladimir Zapolskiy authored
      
      
      Decrement the np_pool device_node refcount, which was incremented on
      the preceding of_parse_phandle() call.
      
      Signed-off-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Olof Johansson <olof@lixom.net>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6f3aabd1
    • Pali Rohár's avatar
      drivers/rtc/rtc-efi.c: add missing module alias · 451ff6d4
      Pali Rohár authored
      
      
      Without proper alias kernel module is not loaded for rtc-efi driver.
      
      Signed-off-by: default avatarPali Rohár <pali.rohar@gmail.com>
      Cc: dann frazier <dannf@dannf.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      451ff6d4
    • David Rientjes's avatar
      mm, slab: initialize object alignment on cache creation · d4a5fca5
      David Rientjes authored
      Since commit 45906855
      
       ("mm/sl[aou]b: Common alignment code"), the
      "ralign" automatic variable in __kmem_cache_create() may be used as
      uninitialized.
      
      The proper alignment defaults to BYTES_PER_WORD and can be overridden by
      SLAB_RED_ZONE or the alignment specified by the caller.
      
      This fixes https://bugzilla.kernel.org/show_bug.cgi?id=85031
      
      Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
      Reported-by: default avatarAndrei Elovikov <a.elovikov@gmail.com>
      Acked-by: default avatarChristoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.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>
      d4a5fca5
    • Peter Feiner's avatar
      mm: softdirty: addresses before VMAs in PTE holes aren't softdirty · 87e6d49a
      Peter Feiner authored
      In PTE holes that contain VM_SOFTDIRTY VMAs, unmapped addresses before
      VM_SOFTDIRTY VMAs are reported as softdirty by /proc/pid/pagemap.  This
      bug was introduced in commit 68b5a652
      
       ("mm: softdirty: respect
      VM_SOFTDIRTY in PTE holes").  That commit made /proc/pid/pagemap look at
      VM_SOFTDIRTY in PTE holes but neglected to observe the start of VMAs
      returned by find_vma.
      
      Tested:
        Wrote a selftest that creates a PMD-sized VMA then unmaps the first
        page and asserts that the page is not softdirty. I'm going to send the
        pagemap selftest in a later commit.
      
      Signed-off-by: default avatarPeter Feiner <pfeiner@google.com>
      Cc: Cyrill Gorcunov <gorcunov@openvz.org>
      Cc: Pavel Emelyanov <xemul@parallels.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
      Cc: Jamie Liu <jamieliu@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      87e6d49a
    • Joseph Qi's avatar
      ocfs2/dlm: do not get resource spinlock if lockres is new · 5760a97c
      Joseph Qi authored
      There is a deadlock case which reported by Guozhonghua:
        https://oss.oracle.com/pipermail/ocfs2-devel/2014-September/010079.html
      
      This case is caused by &res->spinlock and &dlm->master_lock
      misordering in different threads.
      
      It was introduced by commit 8d400b81 ("ocfs2/dlm: Clean up refmap
      helpers").  Since lockres is new, it doesn't not require the
      &res->spinlock.  So remove it.
      
      Fixes: 8d400b81
      
       ("ocfs2/dlm: Clean up refmap helpers")
      Signed-off-by: default avatarJoseph Qi <joseph.qi@huawei.com>
      Reviewed-by: default avatarjoyce.xue <xuejiufei@huawei.com>
      Reported-by: default avatarGuozhonghua <guozhonghua@h3c.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Mark Fasheh <mfasheh@suse.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>
      5760a97c
    • Andreas Rohner's avatar
      nilfs2: fix data loss with mmap() · 56d7acc7
      Andreas Rohner authored
      This bug leads to reproducible silent data loss, despite the use of
      msync(), sync() and a clean unmount of the file system.  It is easily
      reproducible with the following script:
      
        ----------------[BEGIN SCRIPT]--------------------
        mkfs.nilfs2 -f /dev/sdb
        mount /dev/sdb /mnt
      
        dd if=/dev/zero bs=1M count=30 of=/mnt/testfile
      
        umount /mnt
        mount /dev/sdb /mnt
        CHECKSUM_BEFORE="$(md5sum /mnt/testfile)"
      
        /root/mmaptest/mmaptest /mnt/testfile 30 10 5
      
        sync
        CHECKSUM_AFTER="$(md5sum /mnt/testfile)"
        umount /mnt
        mount /dev/sdb /mnt
        CHECKSUM_AFTER_REMOUNT="$(md5sum /mnt/testfile)"
        umount /mnt
      
        echo "BEFORE MMAP:\t$CHECKSUM_BEFORE"
        echo "AFTER MMAP:\t$CHECKSUM_AFTER"
        echo "AFTER REMOUNT:\t$CHECKSUM_AFTER_REMOUNT"
        ----------------[END SCRIPT]--------------------
      
      The mmaptest tool looks something like this (very simplified, with
      error checking removed):
      
        ----------------[BEGIN mmaptest]--------------------
        data = mmap(NULL, file_size - file_offset, PROT_READ | PROT_WRITE,
                    MAP_SHARED, fd, file_offset);
      
        for (i = 0; i < write_count; ++i) {
              memcpy(data + i * 4096, buf, sizeof(buf));
              msync(data, file_size - file_offset, MS_SYNC))
        }
        ----------------[END mmaptest]--------------------
      
      The output of the script looks something like this:
      
        BEFORE MMAP:    281ed1d5ae50e8419f9b978aab16de83  /mnt/testfile
        AFTER MMAP:     6604a1c31f10780331a6850371b3a313  /mnt/testfile
        AFTER REMOUNT:  281ed1d5ae50e8419f9b978aab16de83  /mnt/testfile
      
      So it is clear, that the changes done using mmap() do not survive a
      remount.  This can be reproduced a 100% of the time.  The problem was
      introduced in commit 136e8770
      
       ("nilfs2: fix issue of
      nilfs_set_page_dirty() for page at EOF boundary").
      
      If the page was read with mpage_readpage() or mpage_readpages() for
      example, then it has no buffers attached to it.  In that case
      page_has_buffers(page) in nilfs_set_page_dirty() will be false.
      Therefore nilfs_set_file_dirty() is never called and the pages are never
      collected and never written to disk.
      
      This patch fixes the problem by also calling nilfs_set_file_dirty() if the
      page has no buffers attached to it.
      
      [akpm@linux-foundation.org: s/PAGE_SHIFT/PAGE_CACHE_SHIFT/]
      Signed-off-by: default avatarAndreas Rohner <andreas.rohner@gmx.net>
      Tested-by: default avatarAndreas Rohner <andreas.rohner@gmx.net>
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
      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>
      56d7acc7
    • Joseph Qi's avatar
      ocfs2: free vol_label in ocfs2_delete_osb() · f13a568e
      Joseph Qi authored
      
      
      osb->vol_label is malloced in ocfs2_initialize_super but not freed if
      error occurs or during umount, thus causing a memory leak.
      
      Signed-off-by: default avatarJoseph Qi <joseph.qi@huawei.com>
      Reviewed-by: default avatarjoyce.xue <xuejiufei@huawei.com>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f13a568e
    • Markos Chandras's avatar
      MIPS: mcount: Adjust stack pointer for static trace in MIPS32 · 8a574cfa
      Markos Chandras authored
      Every mcount() call in the MIPS 32-bit kernel is done as follows:
      
      [...]
      move at, ra
      jal _mcount
      addiu sp, sp, -8
      [...]
      
      but upon returning from the mcount() function, the stack pointer
      is not adjusted properly. This is explained in details in 58b69401
      (MIPS: Function tracer: Fix broken function tracing).
      
      Commit ad8c3969
      
       ("MIPS: Unbreak function tracer for 64-bit kernel.)
      fixed the stack manipulation for 64-bit but it didn't fix it completely
      for MIPS32.
      
      Signed-off-by: default avatarMarkos Chandras <markos.chandras@imgtec.com>
      Cc: <stable@vger.kernel.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/7792/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      8a574cfa
    • Paul Burton's avatar
      MIPS: Fix MFC1 & MFHC1 emulation for 64-bit MIPS systems · c8c0da6b
      Paul Burton authored
      Commit bbd426f5
      
       "MIPS: Simplify FP context access" modified the
      SIFROMREG & SIFROMHREG macros such that they return unsigned rather
      than signed 32b integers. I had believed that to be fine, but
      inadvertently missed the MFC1 & MFHC1 cases which write to a struct
      pt_regs regs element. On MIPS32 this is fine, but on 64 bit those
      saved regs' fields are 64 bit wide. Using unsigned values caused the
      32 bit value from the FP register to be zero rather than sign extended
      as the architecture specifies, causing incorrect emulation of the
      MFC1 & MFHc1 instructions. Fix by reintroducing the casts to signed
      integers, and therefore the sign extension.
      
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Cc: stable@vger.kernel.org # v3.15+
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/7848/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      c8c0da6b
    • Linus Torvalds's avatar
      Merge tag 'pm+acpi-3.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · f4cb707e
      Linus Torvalds authored
      Pull ACPI and power management fixes from Rafael Wysocki:
       "These are regression fixes (ACPI hotplug, cpufreq, hibernation, ACPI
        LPSS driver), fixes for stuff that never worked correctly (ACPI GPIO
        support in some cases and a wrong sign of an error code in the ACPI
        core in one place), and one blacklist item for ACPI backlight
        handling.
      
        Specifics:
      
         - Revert of a recent hibernation core commit that introduced a NULL
           pointer dereference during resume for at least one user (Rafael J
           Wysocki).
      
         - Fix for the ACPI LPSS (Low-Power Subsystem) driver to disable
           asynchronous PM callback execution for LPSS devices during system
           suspend/resume (introduced in 3.16) which turns out to break
           ordering expectations on some systems.  From Fu Zhonghui.
      
         - cpufreq core fix related to the handling of sysfs nodes during
           system suspend/resume that has been broken for intel_pstate since
           3.15 from Lan Tianyu.
      
         - Restore the generation of "online" uevents for ACPI container
           devices that was removed in 3.14, but some user space utilities
           turn out to need them (Rafael J Wysocki).
      
         - The cpufreq core fails to release a lock in an error code path
           after changes made in 3.14.  Fix from Prarit Bhargava.
      
         - ACPICA and ACPI/GPIO fixes to make the handling of ACPI GPIO
           operation regions (which means AML using GPIOs) work correctly in
           all cases from Bob Moore and Srinivas Pandruvada.
      
         - Fix for a wrong sign of the ACPI core's create_modalias() return
           value in case of an error from Mika Westerberg.
      
         - ACPI backlight blacklist entry for ThinkPad X201s from Aaron Lu"
      
      * tag 'pm+acpi-3.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        Revert "PM / Hibernate: Iterate over set bits instead of PFNs in swsusp_free()"
        gpio / ACPI: Use pin index and bit length
        ACPICA: Update to GPIO region handler interface.
        ACPI / platform / LPSS: disable async suspend/resume of LPSS devices
        cpufreq: release policy->rwsem on error
        cpufreq: fix cpufreq suspend/resume for intel_pstate
        ACPI / scan: Correct error return value of create_modalias()
        ACPI / video: disable native backlight for ThinkPad X201s
        ACPI / hotplug: Generate online uevents for ACPI containers
      f4cb707e
    • Linus Torvalds's avatar
      Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · 12df9f37
      Linus Torvalds authored
      Pull i2c fixes from Wolfram Sang:
       "This is probably not the kind of pull request you want to see that
        late in the cycle.  Yet, the ACPI refactorization was problematic
        again and caused another two issues which need fixing.  My holidays
        with limited internet (plus travelling) and the developer's illness
        didn't help either :(
      
        The details:
      
         - ACPI code was refactored out into a seperate file and as a
           side-effect, the i2c-core module got renamed.  Jean Delvare
           rightfully complained about the rename being problematic for
           distributions.  So, Mika and I thought the least problematic way to
           deal with it is to move all the code back into the main i2c core
           source file.  This is mainly a huge code move with some #ifdeffery
           applied.  No functional code changes.  Our personal tests and the
           testbots did not find problems.  (I was thinking about reverting,
           too, yet that would also have ~800 lines changed)
      
         - The new ACPI code also had a NULL pointer exception, thanks to
           Peter for finding and fixing it.
      
         - Mikko fixed a locking problem by decoupling clock_prepare and
           clock_enable.
      
         - Addy learnt that the datasheet was wrong and reimplemented the
           frequency setup according to the new algorithm.
      
        - Fan fixed an off-by-one error when copying data
      
        - Janusz fixed a copy'n'paste bug which gave a wrong error message
      
        - Sergei made sure that "don't touch" bits are not accessed"
      
      * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        i2c: acpi: Fix NULL Pointer dereference
        i2c: move acpi code back into the core
        i2c: rk3x: fix divisor calculation for SCL frequency
        i2c: mxs: fix error message in pio transfer
        i2c: ismt: use correct length when copy buffer
        i2c: rcar: fix RCAR_IRQ_ACK_{RECV|SEND}
        i2c: tegra: Move clk_prepare/clk_set_rate to probe
      12df9f37
    • Randy Dunlap's avatar
      MAINTAINERS: new Documentation maintainer · d671e424
      Randy Dunlap authored
      
      
      Transfer Documentation maintainership to Jiri Kosina.
      Thanks, Jiri.
      
      I'll still be reviewing and working on documentation.
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Acked-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d671e424