1. 05 Feb, 2017 3 commits
  2. 02 Feb, 2017 3 commits
    • Jason A. Donenfeld's avatar
      ext4: move halfmd4 into hash.c directly · 1c83a9aa
      Jason A. Donenfeld authored
      The "half md4" transform should not be used by any new code. And
      fortunately, it's only used now by ext4. Since ext4 supports several
      hashing methods, at some point it might be desirable to move to
      something like SipHash. As an intermediate step, remove half md4 from
      cryptohash.h and lib, and make it just a local function in ext4's
      hash.c. There's precedent for doing this; the other function ext can use
      for its hashes -- TEA -- is also implemented in the same place. Also, by
      being a local function, this might allow gcc to perform some additional
      optimizations.
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      1c83a9aa
    • Eric Biggers's avatar
      ext4: fix use-after-iput when fscrypt contexts are inconsistent · dd01b690
      Eric Biggers authored
      In the case where the child's encryption context was inconsistent with
      its parent directory, we were using inode->i_sb and inode->i_ino after
      the inode had already been iput().  Fix this by doing the iput() in the
      correct places.
      
      Note: only ext4 had this bug, not f2fs and ubifs.
      
      Fixes: d9cdc903 ("ext4 crypto: enforce context consistency")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      dd01b690
    • Sahitya Tummala's avatar
      jbd2: fix use after free in kjournald2() · dbfcef6b
      Sahitya Tummala authored
      Below is the synchronization issue between unmount and kjournald2
      contexts, which results into use after free issue in kjournald2().
      Fix this issue by using journal->j_state_lock to synchronize the
      wait_event() done in journal_kill_thread() and the wake_up() done
      in kjournald2().
      
      TASK 1:
      umount cmd:
         |--jbd2_journal_destroy() {
             |--journal_kill_thread() {
                  write_lock(&journal->j_state_lock);
      	    journal->j_flags |= JBD2_UNMOUNT;
      	    ...
      	    write_unlock(&journal->j_state_lock);
      	    wake_up(&journal->j_wait_commit);	   TASK 2 wakes up here:
      	    					   kjournald2() {
      						     ...
      						     checks JBD2_UNMOUNT flag and calls goto end-loop;
      						     ...
      						     end_loop:
      						       write_unlock(&journal->j_state_lock);
      						       journal->j_task = NULL; --> If this thread gets
      						       pre-empted here, then TASK 1 wait_event will
      						       exit even before this thread is completely
      						       done.
      	    wait_event(journal->j_wait_done_commit, journal->j_task == NULL);
      	    ...
      	    write_lock(&journal->j_state_lock);
      	    write_unlock(&journal->j_state_lock);
      	  }
             |--kfree(journal);
           }
      }
      						       wake_up(&journal->j_wait_done_commit); --> this step
      						       now results into use after free issue.
      						   }
      Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      dbfcef6b
  3. 27 Jan, 2017 2 commits
  4. 23 Jan, 2017 2 commits
  5. 12 Jan, 2017 2 commits
    • Theodore Ts'o's avatar
      ext4: avoid calling ext4_mark_inode_dirty() under unneeded semaphores · b907f2d5
      Theodore Ts'o authored
      There is no need to call ext4_mark_inode_dirty while holding xattr_sem
      or i_data_sem, so where it's easy to avoid it, move it out from the
      critical region.
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      b907f2d5
    • Theodore Ts'o's avatar
      ext4: fix deadlock between inline_data and ext4_expand_extra_isize_ea() · c755e251
      Theodore Ts'o authored
      The xattr_sem deadlock problems fixed in commit 2e81a4ee: "ext4:
      avoid deadlock when expanding inode size" didn't include the use of
      xattr_sem in fs/ext4/inline.c.  With the addition of project quota
      which added a new extra inode field, this exposed deadlocks in the
      inline_data code similar to the ones fixed by 2e81a4ee.
      
      The deadlock can be reproduced via:
      
         dmesg -n 7
         mke2fs -t ext4 -O inline_data -Fq -I 256 /dev/vdc 32768
         mount -t ext4 -o debug_want_extra_isize=24 /dev/vdc /vdc
         mkdir /vdc/a
         umount /vdc
         mount -t ext4 /dev/vdc /vdc
         echo foo > /vdc/a/foo
      
      and looks like this:
      
      [   11.158815] 
      [   11.160276] =============================================
      [   11.161960] [ INFO: possible recursive locking detected ]
      [   11.161960] 4.10.0-rc3-00015-g011b30a8a3cf #160 Tainted: G        W      
      [   11.161960] ---------------------------------------------
      [   11.161960] bash/2519 is trying to acquire lock:
      [   11.161960]  (&ei->xattr_sem){++++..}, at: [<c1225a4b>] ext4_expand_extra_isize_ea+0x3d/0x4cd
      [   11.161960] 
      [   11.161960] but task is already holding lock:
      [   11.161960]  (&ei->xattr_sem){++++..}, at: [<c1227941>] ext4_try_add_inline_entry+0x3a/0x152
      [   11.161960] 
      [   11.161960] other info that might help us debug this:
      [   11.161960]  Possible unsafe locking scenario:
      [   11.161960] 
      [   11.161960]        CPU0
      [   11.161960]        ----
      [   11.161960]   lock(&ei->xattr_sem);
      [   11.161960]   lock(&ei->xattr_sem);
      [   11.161960] 
      [   11.161960]  *** DEADLOCK ***
      [   11.161960] 
      [   11.161960]  May be due to missing lock nesting notation
      [   11.161960] 
      [   11.161960] 4 locks held by bash/2519:
      [   11.161960]  #0:  (sb_writers#3){.+.+.+}, at: [<c11a2414>] mnt_want_write+0x1e/0x3e
      [   11.161960]  #1:  (&type->i_mutex_dir_key){++++++}, at: [<c119508b>] path_openat+0x338/0x67a
      [   11.161960]  #2:  (jbd2_handle){++++..}, at: [<c123314a>] start_this_handle+0x582/0x622
      [   11.161960]  #3:  (&ei->xattr_sem){++++..}, at: [<c1227941>] ext4_try_add_inline_entry+0x3a/0x152
      [   11.161960] 
      [   11.161960] stack backtrace:
      [   11.161960] CPU: 0 PID: 2519 Comm: bash Tainted: G        W       4.10.0-rc3-00015-g011b30a8a3cf #160
      [   11.161960] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1 04/01/2014
      [   11.161960] Call Trace:
      [   11.161960]  dump_stack+0x72/0xa3
      [   11.161960]  __lock_acquire+0xb7c/0xcb9
      [   11.161960]  ? kvm_clock_read+0x1f/0x29
      [   11.161960]  ? __lock_is_held+0x36/0x66
      [   11.161960]  ? __lock_is_held+0x36/0x66
      [   11.161960]  lock_acquire+0x106/0x18a
      [   11.161960]  ? ext4_expand_extra_isize_ea+0x3d/0x4cd
      [   11.161960]  down_write+0x39/0x72
      [   11.161960]  ? ext4_expand_extra_isize_ea+0x3d/0x4cd
      [   11.161960]  ext4_expand_extra_isize_ea+0x3d/0x4cd
      [   11.161960]  ? _raw_read_unlock+0x22/0x2c
      [   11.161960]  ? jbd2_journal_extend+0x1e2/0x262
      [   11.161960]  ? __ext4_journal_get_write_access+0x3d/0x60
      [   11.161960]  ext4_mark_inode_dirty+0x17d/0x26d
      [   11.161960]  ? ext4_add_dirent_to_inline.isra.12+0xa5/0xb2
      [   11.161960]  ext4_add_dirent_to_inline.isra.12+0xa5/0xb2
      [   11.161960]  ext4_try_add_inline_entry+0x69/0x152
      [   11.161960]  ext4_add_entry+0xa3/0x848
      [   11.161960]  ? __brelse+0x14/0x2f
      [   11.161960]  ? _raw_spin_unlock_irqrestore+0x44/0x4f
      [   11.161960]  ext4_add_nondir+0x17/0x5b
      [   11.161960]  ext4_create+0xcf/0x133
      [   11.161960]  ? ext4_mknod+0x12f/0x12f
      [   11.161960]  lookup_open+0x39e/0x3fb
      [   11.161960]  ? __wake_up+0x1a/0x40
      [   11.161960]  ? lock_acquire+0x11e/0x18a
      [   11.161960]  path_openat+0x35c/0x67a
      [   11.161960]  ? sched_clock_cpu+0xd7/0xf2
      [   11.161960]  do_filp_open+0x36/0x7c
      [   11.161960]  ? _raw_spin_unlock+0x22/0x2c
      [   11.161960]  ? __alloc_fd+0x169/0x173
      [   11.161960]  do_sys_open+0x59/0xcc
      [   11.161960]  SyS_open+0x1d/0x1f
      [   11.161960]  do_int80_syscall_32+0x4f/0x61
      [   11.161960]  entry_INT80_32+0x2f/0x2f
      [   11.161960] EIP: 0xb76ad469
      [   11.161960] EFLAGS: 00000286 CPU: 0
      [   11.161960] EAX: ffffffda EBX: 08168ac8 ECX: 00008241 EDX: 000001b6
      [   11.161960] ESI: b75e46bc EDI: b7755000 EBP: bfbdb108 ESP: bfbdafc0
      [   11.161960]  DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b
      
      Cc: stable@vger.kernel.org # 3.10 (requires 2e81a4ee as a prereq)
      Reported-by: default avatarGeorge Spelvin <linux@sciencehorizons.net>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      c755e251
  6. 11 Jan, 2017 1 commit
  7. 09 Jan, 2017 3 commits
    • Roman Pen's avatar
      ext4: do not polute the extents cache while shifting extents · 03e916fa
      Roman Pen authored
      Inside ext4_ext_shift_extents() function ext4_find_extent() is called
      without EXT4_EX_NOCACHE flag, which should prevent cache population.
      
      This leads to oudated offsets in the extents tree and wrong blocks
      afterwards.
      
      Patch fixes the problem providing EXT4_EX_NOCACHE flag for each
      ext4_find_extents() call inside ext4_ext_shift_extents function.
      
      Fixes: 331573feSigned-off-by: default avatarRoman Pen <roman.penyaev@profitbricks.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: Namjae Jeon <namjae.jeon@samsung.com>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: stable@vger.kernel.org
      03e916fa
    • Roman Pen's avatar
      ext4: Include forgotten start block on fallocate insert range · 2a9b8cba
      Roman Pen authored
      While doing 'insert range' start block should be also shifted right.
      The bug can be easily reproduced by the following test:
      
          ptr = malloc(4096);
          assert(ptr);
      
          fd = open("./ext4.file", O_CREAT | O_TRUNC | O_RDWR, 0600);
          assert(fd >= 0);
      
          rc = fallocate(fd, 0, 0, 8192);
          assert(rc == 0);
          for (i = 0; i < 2048; i++)
                  *((unsigned short *)ptr + i) = 0xbeef;
          rc = pwrite(fd, ptr, 4096, 0);
          assert(rc == 4096);
          rc = pwrite(fd, ptr, 4096, 4096);
          assert(rc == 4096);
      
          for (block = 2; block < 1000; block++) {
                  rc = fallocate(fd, FALLOC_FL_INSERT_RANGE, 4096, 4096);
                  assert(rc == 0);
      
                  for (i = 0; i < 2048; i++)
                          *((unsigned short *)ptr + i) = block;
      
                  rc = pwrite(fd, ptr, 4096, 4096);
                  assert(rc == 4096);
          }
      
      Because start block is not included in the range the hole appears at
      the wrong offset (just after the desired offset) and the following
      pwrite() overwrites already existent block, keeping hole untouched.
      
      Simple way to verify wrong behaviour is to check zeroed blocks after
      the test:
      
         $ hexdump ./ext4.file | grep '0000 0000'
      
      The root cause of the bug is a wrong range (start, stop], where start
      should be inclusive, i.e. [start, stop].
      
      This patch fixes the problem by including start into the range.  But
      not to break left shift (range collapse) stop points to the beginning
      of the a block, not to the end.
      
      The other not obvious change is an iterator check on validness in a
      main loop.  Because iterator is unsigned the following corner case
      should be considered with care: insert a block at 0 offset, when stop
      variables overflows and never becomes less than start, which is 0.
      To handle this special case iterator is set to NULL to indicate that
      end of the loop is reached.
      
      Fixes: 331573feSigned-off-by: default avatarRoman Pen <roman.penyaev@profitbricks.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: Namjae Jeon <namjae.jeon@samsung.com>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: stable@vger.kernel.org
      2a9b8cba
    • Theodore Ts'o's avatar
      Merge branch 'fscrypt' into d · 56735be0
      Theodore Ts'o authored
      56735be0
  8. 08 Jan, 2017 9 commits
    • Linus Torvalds's avatar
      Linux 4.10-rc3 · a121103c
      Linus Torvalds authored
      a121103c
    • Linus Torvalds's avatar
      Merge tag 'usb-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 83280e90
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are a bunch of USB fixes for 4.10-rc3. Yeah, it's a lot, an
        artifact of the holiday break I think.
      
        Lots of gadget and the usual XHCI fixups for reported issues (one day
        that driver will calm down...) Also included are a bunch of usb-serial
        driver fixes, and for good measure, a number of much-reported MUSB
        driver issues have finally been resolved.
      
        All of these have been in linux-next with no reported issues"
      
      * tag 'usb-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (72 commits)
        USB: fix problems with duplicate endpoint addresses
        usb: ohci-at91: use descriptor-based gpio APIs correctly
        usb: storage: unusual_uas: Add JMicron JMS56x to unusual device
        usb: hub: Move hub_port_disable() to fix warning if PM is disabled
        usb: musb: blackfin: add bfin_fifo_offset in bfin_ops
        usb: musb: fix compilation warning on unused function
        usb: musb: Fix trying to free already-free IRQ 4
        usb: musb: dsps: implement clear_ep_rxintr() callback
        usb: musb: core: add clear_ep_rxintr() to musb_platform_ops
        USB: serial: ti_usb_3410_5052: fix NULL-deref at open
        USB: serial: spcp8x5: fix NULL-deref at open
        USB: serial: quatech2: fix sleep-while-atomic in close
        USB: serial: pl2303: fix NULL-deref at open
        USB: serial: oti6858: fix NULL-deref at open
        USB: serial: omninet: fix NULL-derefs at open and disconnect
        USB: serial: mos7840: fix misleading interrupt-URB comment
        USB: serial: mos7840: remove unused write URB
        USB: serial: mos7840: fix NULL-deref at open
        USB: serial: mos7720: remove obsolete port initialisation
        USB: serial: mos7720: fix parallel probe
        ...
      83280e90
    • Linus Torvalds's avatar
      Merge tag 'char-misc-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · cc250e26
      Linus Torvalds authored
      Pull char/misc fixes from Greg KH:
       "Here are a few small char/misc driver fixes for 4.10-rc3.
      
        Two MEI driver fixes, and three NVMEM patches for reported issues, and
        a new Hyper-V driver MAINTAINER update. Nothing major at all, all have
        been in linux-next with no reported issues"
      
      * tag 'char-misc-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        hyper-v: Add myself as additional MAINTAINER
        nvmem: fix nvmem_cell_read() return type doc
        nvmem: imx-ocotp: Fix wrong register size
        nvmem: qfprom: Allow single byte accesses for read/write
        mei: move write cb to completion on credentials failures
        mei: bus: fix mei_cldev_enable KDoc
      cc250e26
    • Linus Torvalds's avatar
      Merge tag 'staging-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging · 6ea17ed1
      Linus Torvalds authored
      Pull staging/IIO fixes from Greg KH:
       "Here are some staging and IIO driver fixes for 4.10-rc3.
      
        Most of these are minor IIO fixes of reported issues, along with one
        network driver fix to resolve an issue. And a MAINTAINERS update with
        a new mailing list. All of these, except the MAINTAINERS file update,
        have been in linux-next with no reported issues (the MAINTAINERS patch
        happened on Friday...)"
      
      * tag 'staging-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
        MAINTAINERS: add greybus subsystem mailing list
        staging: octeon: Call SET_NETDEV_DEV()
        iio: accel: st_accel: fix LIS3LV02 reading and scaling
        iio: common: st_sensors: fix channel data parsing
        iio: max44000: correct value in illuminance_integration_time_available
        iio: adc: TI_AM335X_ADC should depend on HAS_DMA
        iio: bmi160: Fix time needed to sleep after command execution
        iio: 104-quad-8: Fix active level mismatch for the preset enable option
        iio: 104-quad-8: Fix off-by-one errors when addressing IOR
        iio: 104-quad-8: Fix index control configuration
      6ea17ed1
    • Eric Biggers's avatar
      fscrypt: make fscrypt_operations.key_prefix a string · a5d431ef
      Eric Biggers authored
      There was an unnecessary amount of complexity around requesting the
      filesystem-specific key prefix.  It was unclear why; perhaps it was
      envisioned that different instances of the same filesystem type could
      use different key prefixes, or that key prefixes could be binary.
      However, neither of those things were implemented or really make sense
      at all.  So simplify the code by making key_prefix a const char *.
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Reviewed-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      a5d431ef
    • Eric Biggers's avatar
      fscrypt: remove unused 'mode' member of fscrypt_ctx · f099d616
      Eric Biggers authored
      Nothing reads or writes fscrypt_ctx.mode, and it doesn't belong there
      because a fscrypt_ctx is not tied to a specific encryption mode.
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      f099d616
    • Theodore Ts'o's avatar
      ext4: don't allow encrypted operations without keys · 173b8439
      Theodore Ts'o authored
      While we allow deletes without the key, the following should not be
      permitted:
      
      # cd /vdc/encrypted-dir-without-key
      # ls -l
      total 4
      -rw-r--r-- 1 root root   0 Dec 27 22:35 6,LKNRJsp209FbXoSvJWzB
      -rw-r--r-- 1 root root 286 Dec 27 22:35 uRJ5vJh9gE7vcomYMqTAyD
      # mv uRJ5vJh9gE7vcomYMqTAyD  6,LKNRJsp209FbXoSvJWzB
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      173b8439
    • Johannes Weiner's avatar
      mm: workingset: fix use-after-free in shadow node shrinker · ea07b862
      Johannes Weiner authored
      Several people report seeing warnings about inconsistent radix tree
      nodes followed by crashes in the workingset code, which all looked like
      use-after-free access from the shadow node shrinker.
      
      Dave Jones managed to reproduce the issue with a debug patch applied,
      which confirmed that the radix tree shrinking indeed frees shadow nodes
      while they are still linked to the shadow LRU:
      
        WARNING: CPU: 2 PID: 53 at lib/radix-tree.c:643 delete_node+0x1e4/0x200
        CPU: 2 PID: 53 Comm: kswapd0 Not tainted 4.10.0-rc2-think+ #3
        Call Trace:
           delete_node+0x1e4/0x200
           __radix_tree_delete_node+0xd/0x10
           shadow_lru_isolate+0xe6/0x220
           __list_lru_walk_one.isra.4+0x9b/0x190
           list_lru_walk_one+0x23/0x30
           scan_shadow_nodes+0x2e/0x40
           shrink_slab.part.44+0x23d/0x5d0
           shrink_node+0x22c/0x330
           kswapd+0x392/0x8f0
      
      This is the WARN_ON_ONCE(!list_empty(&node->private_list)) placed in the
      inlined radix_tree_shrink().
      
      The problem is with 14b46879 ("mm: workingset: move shadow entry
      tracking to radix tree exceptional tracking"), which passes an update
      callback into the radix tree to link and unlink shadow leaf nodes when
      tree entries change, but forgot to pass the callback when reclaiming a
      shadow node.
      
      While the reclaimed shadow node itself is unlinked by the shrinker, its
      deletion from the tree can cause the left-most leaf node in the tree to
      be shrunk.  If that happens to be a shadow node as well, we don't unlink
      it from the LRU as we should.
      
      Consider this tree, where the s are shadow entries:
      
             root->rnode
                  |
             [0       n]
              |       |
           [s    ] [sssss]
      
      Now the shadow node shrinker reclaims the rightmost leaf node through
      the shadow node LRU:
      
             root->rnode
                  |
             [0        ]
              |
          [s     ]
      
      Because the parent of the deleted node is the first level below the
      root and has only one child in the left-most slot, the intermediate
      level is shrunk and the node containing the single shadow is put in
      its place:
      
             root->rnode
                  |
             [s        ]
      
      The shrinker again sees a single left-most slot in a first level node
      and thus decides to store the shadow in root->rnode directly and free
      the node - which is a leaf node on the shadow node LRU.
      
        root->rnode
             |
             s
      
      Without the update callback, the freed node remains on the shadow LRU,
      where it causes later shrinker runs to crash.
      
      Pass the node updater callback into __radix_tree_delete_node() in case
      the deletion causes the left-most branch in the tree to collapse too.
      
      Also add warnings when linked nodes are freed right away, rather than
      wait for the use-after-free when the list is scanned much later.
      
      Fixes: 14b46879 ("mm: workingset: move shadow entry tracking to radix tree exceptional tracking")
      Reported-by: default avatarDave Chinner <david@fromorbit.com>
      Reported-by: default avatarHugh Dickins <hughd@google.com>
      Reported-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
      Reported-and-tested-by: default avatarDave Jones <davej@codemonkey.org.uk>
      Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Chris Leech <cleech@redhat.com>
      Cc: Lee Duncan <lduncan@suse.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Matthew Wilcox <mawilcox@linuxonhyperv.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ea07b862
    • Hugh Dickins's avatar
      mm: stop leaking PageTables · b0b9b3df
      Hugh Dickins authored
      4.10-rc loadtest (even on x86, and even without THPCache) fails with
      "fork: Cannot allocate memory" or some such; and /proc/meminfo shows
      PageTables growing.
      
      Commit 953c66c2 ("mm: THP page cache support for ppc64") that got
      merged in rc1 removed the freeing of an unused preallocated pagetable
      after do_fault_around() has called map_pages().
      
      This is usually a good optimization, so that the followup doesn't have
      to reallocate one; but it's not sufficient to shift the freeing into
      alloc_set_pte(), since there are failure cases (most commonly
      VM_FAULT_RETRY) which never reach finish_fault().
      
      Check and free it at the outer level in do_fault(), then we don't need
      to worry in alloc_set_pte(), and can restore that to how it was (I
      cannot find any reason to pte_free() under lock as it was doing).
      
      And fix a separate pagetable leak, or crash, introduced by the same
      change, that could only show up on some ppc64: why does do_set_pmd()'s
      failure case attempt to withdraw a pagetable when it never deposited
      one, at the same time overwriting (so leaking) the vmf->prealloc_pte?
      Residue of an earlier implementation, perhaps? Delete it.
      
      Fixes: 953c66c2 ("mm: THP page cache support for ppc64")
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Michael Neuling <mikey@neuling.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Balbir Singh <bsingharora@gmail.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b0b9b3df
  9. 07 Jan, 2017 2 commits
  10. 06 Jan, 2017 13 commits
    • Linus Torvalds's avatar
      Merge tag 'sound-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 308c470b
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "Nothing particular stands out, only a few small fixes for USB-audio,
        HD-audio and Firewire. The USB-audio fix is the respin of the previous
        race fix after a revert due to the regression"
      
      * tag 'sound-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        Revert "ALSA: firewire-lib: change structure member with proper type"
        ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion
        ALSA: usb-audio: Fix irq/process data synchronization
        ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL
        ALSA: hda - Fix up GPIO for ASUS ROG Ranger
        ALSA: firewire-lib: change structure member with proper type
        ALSA: firewire-tascam: Fix to handle error from initialization of stream data
        ALSA: fireworks: fix asymmetric API call at unit removal
      308c470b
    • Linus Torvalds's avatar
      Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · d72f0ded
      Linus Torvalds authored
      Pull clk fixes from Stephen Boyd:
       "One fix for a broken driver on Renesas RZ/A1 SoCs with bootloaders
        that don't turn all the clks on and another fix for stm32f4 SoCs where
        we have multiple drivers attaching to the same DT node"
      
      * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
        clk: stm32f4: Use CLK_OF_DECLARE_DRIVER initialization method
        clk: renesas: mstp: Support 8-bit registers for r7s72100
      d72f0ded
    • Linus Torvalds's avatar
      Merge tag 'hwmon-for-linus-v4.10-rc3' of... · baaf0315
      Linus Torvalds authored
      Merge tag 'hwmon-for-linus-v4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
      
      Pull hwmon fix from Guenter Roeck:
       "Fix temp1_max_alarm attribute in lm90 driver"
      
      * tag 'hwmon-for-linus-v4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
        hwmon: (lm90) fix temp1_max_alarm attribute
      baaf0315
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 08289086
      Linus Torvalds authored
      Pull KVM fixes from Radim Krčmář:
       "MIPS:
         - fix host kernel crashes when receiving a signal with 64-bit
           userspace
      
         - flush instruction cache on all vcpus after generating entry code
      
           (both for stable)
      
        x86:
         - fix NULL dereference in MMU caused by SMM transitions (for stable)
      
         - correct guest instruction pointer after emulating some VMX errors
      
         - minor cleanup"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: VMX: remove duplicated declaration
        KVM: MIPS: Flush KVM entry code from icache globally
        KVM: MIPS: Don't clobber CP0_Status.UX
        KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS
        KVM: nVMX: fix instruction skipping during emulated vm-entry
      08289086
    • Linus Torvalds's avatar
      Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux · b1ee5170
      Linus Torvalds authored
      Pull arm64 fixes from Catalin Marinas:
      
       - re-introduce the arm64 get_current() optimisation
      
       - KERN_CONT fallout fix in show_pte()
      
      * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
        arm64: restore get_current() optimisation
        arm64: mm: fix show_pte KERN_CONT fallout
      b1ee5170
    • Linus Torvalds's avatar
      Merge tag 'vfio-v4.10-rc3' of git://github.com/awilliam/linux-vfio · 5824f924
      Linus Torvalds authored
      Pull VFIO fixes from Alex Williamson:
       - Add mtty sample driver properly into build system (Alex Williamson)
       - Restore type1 mapping performance after mdev (Alex Williamson)
       - Fix mdev device race (Alex Williamson)
       - Cleanups to the mdev ABI used by vendor drivers (Alex Williamson)
       - Build fix for old compilers (Arnd Bergmann)
       - Fix sample driver error path (Dan Carpenter)
       - Handle pci_iomap() error (Arvind Yadav)
       - Fix mdev ioctl return type (Paul Gortmaker)
      
      * tag 'vfio-v4.10-rc3' of git://github.com/awilliam/linux-vfio:
        vfio-mdev: fix non-standard ioctl return val causing i386 build fail
        vfio-pci: Handle error from pci_iomap
        vfio-mdev: fix some error codes in the sample code
        vfio-pci: use 32-bit comparisons for register address for gcc-4.5
        vfio-mdev: Make mdev_device private and abstract interfaces
        vfio-mdev: Make mdev_parent private
        vfio-mdev: de-polute the namespace, rename parent_device & parent_ops
        vfio-mdev: Fix remove race
        vfio/type1: Restore mapping performance with mdev support
        vfio-mdev: Fix mtty sample driver building
      5824f924
    • Linus Torvalds's avatar
      Merge branch 'stable/for-linus-4.10' of... · 2fd8774c
      Linus Torvalds authored
      Merge branch 'stable/for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb
      
      Pull swiotlb fixes from Konrad Rzeszutek Wilk:
       "This has one fix to make i915 work when using Xen SWIOTLB, and a
        feature from Geert to aid in debugging of devices that can't do DMA
        outside the 32-bit address space.
      
        The feature from Geert is on top of v4.10 merge window commit
        (specifically you pulling my previous branch), as his changes were
        dependent on the Documentation/ movement patches.
      
        I figured it would just easier than me trying than to cherry-pick the
        Documentation patches to satisfy git.
      
        The patches have been soaking since 12/20, albeit I updated the last
        patch due to linux-next catching an compiler error and adding an
        Tested-and-Reported-by tag"
      
      * 'stable/for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb:
        swiotlb: Export swiotlb_max_segment to users
        swiotlb: Add swiotlb=noforce debug option
        swiotlb: Convert swiotlb_force from int to enum
        x86, swiotlb: Simplify pci_swiotlb_detect_override()
      2fd8774c
    • Linus Torvalds's avatar
      Merge tag 'iommu-fixes-v4.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu · 65cdc405
      Linus Torvalds authored
      Pull IOMMU fixes from Joerg Roedel:
       "Three fixes queued up:
      
         - fix an issue with command buffer overflow handling in the AMD IOMMU
           driver
      
         - add an additional context entry flush to the Intel VT-d driver to
           make sure any old context entry from kdump copying is flushed out
           of the cache
      
         - correct the encoding of the PASID table size in the Intel VT-d
           driver"
      
      * tag 'iommu-fixes-v4.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
        iommu/amd: Fix the left value check of cmd buffer
        iommu/vt-d: Fix pasid table size encoding
        iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped
      65cdc405
    • Linus Torvalds's avatar
      Merge tag 'acpi-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 7397e1e8
      Linus Torvalds authored
      Pull ACPI fixes from Rafael Wysocki:
       "These fix a device enumeration problem related to _ADR matching and an
        IOMMU initialization issue related to the DMAR table missing, remove
        an excessive function call from the core ACPI code, update an error
        message in the ACPI WDAT watchdog driver and add a way to work around
        problems with unhandled GPE notifications.
      
        Specifics:
      
         - Fix a device enumeration issue leading to incorrect associations
           between ACPI device objects and platform device objects
           representing physical devices if the given device object has both
           _ADR and _HID (Rafael Wysocki).
      
         - Avoid passing NULL to acpi_put_table() during IOMMU initialization
           which triggers a (rightful) warning from ACPICA (Rafael Wysocki).
      
         - Drop an excessive call to acpi_dma_deconfigure() from the core code
           that binds ACPI device objects to device objects representing
           physical devices (Lorenzo Pieralisi).
      
         - Update an error message in the ACPI WDAT watchdog driver to make it
           provide more useful information (Mika Westerberg).
      
         - Add a mechanism to work around issues with unhandled GPE
           notifications that occur during system initialization and cannot be
           prevented by means of sysfs (Lv Zheng)"
      
      * tag 'acpi-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        ACPI / DMAR: Avoid passing NULL to acpi_put_table()
        ACPI / scan: Prefer devices without _HID/_CID for _ADR matching
        ACPI / watchdog: Print out error number when device creation fails
        ACPI / sysfs: Provide quirk mechanism to prevent GPE flooding
        ACPI: Drop misplaced acpi_dma_deconfigure() call from acpi_bind_one()
      7397e1e8
    • Linus Torvalds's avatar
      Merge tag 'pm-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · b937a869
      Linus Torvalds authored
      Pull power management fixes from Rafael Wysocki:
       "These fix a few issues in the intel_pstate driver, a documetation
        issue, a false-positive compiler warning in the generic power domains
        framework and two problems in the devfreq subsystem. They also update
        the MAINTAINERS entry for devfreq and add a new "compatible" string to
        the generic cpufreq-dt driver.
      
        Specifics:
      
         - Fix a few intel_pstate driver issues: add missing locking it two
           places, avoid exposing a useless debugfs interface and keep the
           attribute values in sysfs in sync (Rafael Wysocki).
      
         - Drop confusing kernel-doc references related to power management
           and ACPI from the driver API manual (Rafael Wysocki).
      
         - Make a false-positive compiler warning in the generic power domains
           framework go away (Augusto Mecking Caringi).
      
         - Fix two initialization issues in the devfreq subsystem and update
           the MAINTAINERS entry for it (Chanwoo Choi).
      
         - Add a new "compatible" string for APM X-Gene 2 to the generic DT
           cpufreq driver (Hoan Tran)"
      
      * tag 'pm-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        cpufreq: dt: Add support for APM X-Gene 2
        PM / devfreq: exynos-bus: Fix the wrong return value
        PM / devfreq: Fix the bug of devfreq_add_device when governor is NULL
        MAINTAINERS: Add myself as reviewer for DEVFREQ subsystem support
        PM / docs: Drop confusing kernel-doc references from infrastructure.rst
        PM / domains: Fix 'may be used uninitialized' build warning
        cpufreq: intel_pstate: Always keep all limits settings in sync
        cpufreq: intel_pstate: Use locking in intel_cpufreq_verify_policy()
        cpufreq: intel_pstate: Use locking in intel_pstate_resume()
        cpufreq: intel_pstate: Do not expose PID parameters in passive mode
      b937a869
    • Konrad Rzeszutek Wilk's avatar
      swiotlb: Export swiotlb_max_segment to users · 7453c549
      Konrad Rzeszutek Wilk authored
      So they can figure out what is the optimal number of pages
      that can be contingously stitched together without fear of
      bounce buffer.
      
      We also expose an mechanism for sub-users of SWIOTLB API, such
      as Xen-SWIOTLB to set the max segment value. And lastly
      if swiotlb=force is set (which mandates we bounce buffer everything)
      we set max_segment so at least we can bounce buffer one 4K page
      instead of a giant 512KB one for which we may not have space.
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reported-and-Tested-by: default avatarJuergen Gross <jgross@suse.com>
      7453c549
    • Rafael J. Wysocki's avatar
      Merge branches 'acpi-scan', 'acpi-sysfs', 'acpi-wdat' and 'acpi-tables' · f1dabf0b
      Rafael J. Wysocki authored
      * acpi-scan:
        ACPI / scan: Prefer devices without _HID/_CID for _ADR matching
        ACPI: Drop misplaced acpi_dma_deconfigure() call from acpi_bind_one()
      
      * acpi-sysfs:
        ACPI / sysfs: Provide quirk mechanism to prevent GPE flooding
      
      * acpi-wdat:
        ACPI / watchdog: Print out error number when device creation fails
      
      * acpi-tables:
        ACPI / DMAR: Avoid passing NULL to acpi_put_table()
      f1dabf0b
    • Rafael J. Wysocki's avatar
      Merge branches 'pm-domains', 'pm-docs' and 'pm-devfreq' · 7e2b9d85
      Rafael J. Wysocki authored
      * pm-domains:
        PM / domains: Fix 'may be used uninitialized' build warning
      
      * pm-docs:
        PM / docs: Drop confusing kernel-doc references from infrastructure.rst
      
      * pm-devfreq:
        PM / devfreq: exynos-bus: Fix the wrong return value
        PM / devfreq: Fix the bug of devfreq_add_device when governor is NULL
        MAINTAINERS: Add myself as reviewer for DEVFREQ subsystem support
      7e2b9d85