1. 26 Apr, 2018 35 commits
  2. 24 Apr, 2018 5 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.14.36 · d6949f48
      Greg Kroah-Hartman authored
      d6949f48
    • Greg Thelen's avatar
      writeback: safer lock nesting · 7c9b87a7
      Greg Thelen authored
      commit 2e898e4c upstream.
      
      lock_page_memcg()/unlock_page_memcg() use spin_lock_irqsave/restore() if
      the page's memcg is undergoing move accounting, which occurs when a
      process leaves its memcg for a new one that has
      memory.move_charge_at_immigrate set.
      
      unlocked_inode_to_wb_begin,end() use spin_lock_irq/spin_unlock_irq() if
      the given inode is switching writeback domains.  Switches occur when
      enough writes are issued from a new domain.
      
      This existing pattern is thus suspicious:
          lock_page_memcg(page);
          unlocked_inode_to_wb_begin(inode, &locked);
          ...
          unlocked_inode_to_wb_end(inode, locked);
          unlock_page_memcg(page);
      
      If both inode switch and process memcg migration are both in-flight then
      unlocked_inode_to_wb_end() will unconditionally enable interrupts while
      still holding the lock_page_memcg() irq spinlock.  This suggests the
      possibility of deadlock if an interrupt occurs before unlock_page_memcg().
      
          truncate
          __cancel_dirty_page
          lock_page_memcg
          unlocked_inode_to_wb_begin
          unlocked_inode_to_wb_end
          <interrupts mistakenly enabled>
                                          <interrupt>
                                          end_page_writeback
                                          test_clear_page_writeback
                                          lock_page_memcg
                                          <deadlock>
          unlock_page_memcg
      
      Due to configuration limitations this deadlock is not currently possible
      because we don't mix cgroup writeback (a cgroupv2 feature) and
      memory.move_charge_at_immigrate (a cgroupv1 feature).
      
      If the kernel is hacked to always claim inode switching and memcg
      moving_account, then this script triggers lockup in less than a minute:
      
        cd /mnt/cgroup/memory
        mkdir a b
        echo 1 > a/memory.move_charge_at_immigrate
        echo 1 > b/memory.move_charge_at_immigrate
        (
          echo $BASHPID > a/cgroup.procs
          while true; do
            dd if=/dev/zero of=/mnt/big bs=1M count=256
          done
        ) &
        while true; do
          sync
        done &
        sleep 1h &
        SLEEP=$!
        while true; do
          echo $SLEEP > a/cgroup.procs
          echo $SLEEP > b/cgroup.procs
        done
      
      The deadlock does not seem possible, so it's debatable if there's any
      reason to modify the kernel.  I suggest we should to prevent future
      surprises.  And Wang Long said "this deadlock occurs three times in our
      environment", so there's more reason to apply this, even to stable.
      Stable 4.4 has minor conflicts applying this patch.  For a clean 4.4 patch
      see "[PATCH for-4.4] writeback: safer lock nesting"
      https://lkml.org/lkml/2018/4/11/146
      
      Wang Long said "this deadlock occurs three times in our environment"
      
      [gthelen@google.com: v4]
        Link: http://lkml.kernel.org/r/20180411084653.254724-1-gthelen@google.com
      [akpm@linux-foundation.org: comment tweaks, struct initialization simplification]
      Change-Id: Ibb773e8045852978f6207074491d262f1b3fb613
      Link: http://lkml.kernel.org/r/20180410005908.167976-1-gthelen@google.com
      Fixes: 682aa8e1 ("writeback: implement unlocked_inode_to_wb transaction and use it for stat updates")
      Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
      Reported-by: default avatarWang Long <wanglong19@meituan.com>
      Acked-by: default avatarWang Long <wanglong19@meituan.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: <stable@vger.kernel.org>	[v4.2+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [natechancellor: Adjust context due to lack of b93b0163]
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c9b87a7
    • Sean Young's avatar
      media: staging: lirc_zilog: incorrect reference counting · 071ff203
      Sean Young authored
      [not upstream as the driver is deleted in 4.16 - gregkh]
      
      Whenever poll is called, the reference count is increased but never
      decreased. This means that on rmmod, the lirc_thread is not stopped,
      and will trample over freed memory.
      
      Zilog/Hauppauge IR driver unloaded
      BUG: unable to handle kernel paging request at ffffffffc17ba640
      Oops: 0010 [#1] SMP
      CPU: 1 PID: 667 Comm: zilog-rx-i2c-1 Tainted: P         C OE   4.13.16-302.fc27.x86_64 #1
      Hardware name: Gigabyte Technology Co., Ltd. GA-MA790FXT-UD5P/GA-MA790FXT-UD5P, BIOS F6 08/06/2009
      task: ffff964eb452ca00 task.stack: ffffb254414dc000
      RIP: 0010:0xffffffffc17ba640
      RSP: 0018:ffffb254414dfe78 EFLAGS: 00010286
      RAX: 0000000000000000 RBX: ffff964ec1b35890 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000246 RDI: 0000000000000246
      RBP: ffffb254414dff00 R08: 000000000000036e R09: ffff964ecfc8dfd0
      R10: ffffb254414dfe78 R11: 00000000000f4240 R12: ffff964ec2bf28a0
      R13: ffff964ec1b358a8 R14: ffff964ec1b358d0 R15: ffff964ec1b35800
      FS:  0000000000000000(0000) GS:ffff964ecfc80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: ffffffffc17ba640 CR3: 000000023058c000 CR4: 00000000000006e0
      Call Trace:
       kthread+0x125/0x140
       ? kthread_park+0x60/0x60
       ? do_syscall_64+0x67/0x140
       ret_from_fork+0x25/0x30
      Code:  Bad RIP value.
      RIP: 0xffffffffc17ba640 RSP: ffffb254414dfe78
      CR2: ffffffffc17ba640
      
      Note that zilog-rx-i2c-1 should have exited by now, but hasn't due to
      the missing put in poll().
      
      This code has been replaced completely in kernel v4.16 by a new driver,
      see commit acaa34bf ("media: rc: implement zilog transmitter"), and
      commit f95367a7 ("media: staging: remove lirc_zilog driver").
      
      Cc: stable@vger.kernel.org # v4.15- (all up to and including v4.15)
      Reported-by: default avatarWarren Sturm <warren.sturm@gmail.com>
      Tested-by: default avatarWarren Sturm <warren.sturm@gmail.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      071ff203
    • Sean Young's avatar
      Revert "media: lirc_zilog: driver only sends LIRCCODE" · e7a08ffb
      Sean Young authored
      [not upstream as the driver is deleted in 4.16 - gregkh]
      
      The lirc config documented here
      https://www.blushingpenguin.com/mark/blog/?p=24 uses raw_codes for sending
      IR. Each key only has one pulse, which in fact is an index into the
      haup-ir-blaster.bin file. Changing the driver to LIRCCODE (although more
      accurate) breaks this configuration.
      
      This code has been replaced completely in kernel v4.16 by a new driver,
      see commit acaa34bf ("media: rc: implement zilog transmitter"), and
      commit f95367a7 ("media: staging: remove lirc_zilog driver").
      
      This reverts commit 89d8a2cc.
      
      Fixes: 615cd3fe ("[media] media: lirc_dev: make better use of file->private_data")
      
      Cc: stable@vger.kernel.org # v4.14-v4.15
      Reported-by: default avatarWarren Sturm <warren.sturm@gmail.com>
      Tested-by: default avatarWarren Sturm <warren.sturm@gmail.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e7a08ffb
    • Luca Coelho's avatar
      iwlwifi: add a bunch of new 9000 PCI IDs · 8caa4c5f
      Luca Coelho authored
      commit 9e5053ad upstream.
      
      A lot of new PCI IDs were added for the 9000 series.  Add them to the
      list of supported PCI IDs.
      
      Cc: stable@vger.kernel.org # 4.13+
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      8caa4c5f