Skip to content
  1. Aug 01, 2019
  2. Jul 31, 2019
    • popcornmix's avatar
    • Greg Kroah-Hartman's avatar
      Linux 4.19.63 · 9a9de33a
      Greg Kroah-Hartman authored
      9a9de33a
    • Linus Torvalds's avatar
      access: avoid the RCU grace period for the temporary subjective credentials · 408af823
      Linus Torvalds authored
      commit d7852fbd
      
       upstream.
      
      It turns out that 'access()' (and 'faccessat()') can cause a lot of RCU
      work because it installs a temporary credential that gets allocated and
      freed for each system call.
      
      The allocation and freeing overhead is mostly benign, but because
      credentials can be accessed under the RCU read lock, the freeing
      involves a RCU grace period.
      
      Which is not a huge deal normally, but if you have a lot of access()
      calls, this causes a fair amount of seconday damage: instead of having a
      nice alloc/free patterns that hits in hot per-CPU slab caches, you have
      all those delayed free's, and on big machines with hundreds of cores,
      the RCU overhead can end up being enormous.
      
      But it turns out that all of this is entirely unnecessary.  Exactly
      because access() only installs the credential as the thread-local
      subjective credential, the temporary cred pointer doesn't actually need
      to be RCU free'd at all.  Once we're done using it, we can just free it
      synchronously and avoid all the RCU overhead.
      
      So add a 'non_rcu' flag to 'struct cred', which can be set by users that
      know they only use it in non-RCU context (there are other potential
      users for this).  We can make it a union with the rcu freeing list head
      that we need for the RCU case, so this doesn't need any extra storage.
      
      Note that this also makes 'get_current_cred()' clear the new non_rcu
      flag, in case we have filesystems that take a long-term reference to the
      cred and then expect the RCU delayed freeing afterwards.  It's not
      entirely clear that this is required, but it makes for clear semantics:
      the subjective cred remains non-RCU as long as you only access it
      synchronously using the thread-local accessors, but you _can_ use it as
      a generic cred if you want to.
      
      It is possible that we should just remove the whole RCU markings for
      ->cred entirely.  Only ->real_cred is really supposed to be accessed
      through RCU, and the long-term cred copies that nfs uses might want to
      explicitly re-enable RCU freeing if required, rather than have
      get_current_cred() do it implicitly.
      
      But this is a "minimal semantic changes" change for the immediate
      problem.
      
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Jan Glauber <jglauber@marvell.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Jayachandran Chandrasekharan Nair <jnair@marvell.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      408af823
    • Dan Williams's avatar
      libnvdimm/bus: Stop holding nvdimm_bus_list_mutex over __nd_ioctl() · 1a547d24
      Dan Williams authored
      commit b70d31d0 upstream.
      
      In preparation for fixing a deadlock between wait_for_bus_probe_idle()
      and the nvdimm_bus_list_mutex arrange for __nd_ioctl() without
      nvdimm_bus_list_mutex held. This also unifies the 'dimm' and 'bus' level
      ioctls into a common nd_ioctl() preamble implementation.
      
      Marked for -stable as it is a pre-requisite for a follow-on fix.
      
      Cc: <stable@vger.kernel.org>
      Fixes: bf9bccc1
      
       ("libnvdimm: pmem label sets and namespace instantiation")
      Cc: Vishal Verma <vishal.l.verma@intel.com>
      Tested-by: default avatarJane Chu <jane.chu@oracle.com>
      Link: https://lore.kernel.org/r/156341209518.292348.7183897251740665198.stgit@dwillia2-desk3.amr.corp.intel.com
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1a547d24
    • Michael Neuling's avatar
      powerpc/tm: Fix oops on sigreturn on systems without TM · b993a66d
      Michael Neuling authored
      commit f16d80b7 upstream.
      
      On systems like P9 powernv where we have no TM (or P8 booted with
      ppc_tm=off), userspace can construct a signal context which still has
      the MSR TS bits set. The kernel tries to restore this context which
      results in the following crash:
      
        Unexpected TM Bad Thing exception at c0000000000022fc (msr 0x8000000102a03031) tm_scratch=800000020280f033
        Oops: Unrecoverable exception, sig: 6 [#1]
        LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in:
        CPU: 0 PID: 1636 Comm: sigfuz Not tainted 5.2.0-11043-g0a8ad0ffa4 #69
        NIP:  c0000000000022fc LR: 00007fffb2d67e48 CTR: 0000000000000000
        REGS: c00000003fffbd70 TRAP: 0700   Not tainted  (5.2.0-11045-g7142b497d8)
        MSR:  8000000102a03031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[E]>  CR: 42004242  XER: 00000000
        CFAR: c0000000000022e0 IRQMASK: 0
        GPR00: 0000000000000072 00007fffb2b6e560 00007fffb2d87f00 0000000000000669
        GPR04: 00007fffb2b6e728 0000000000000000 0000000000000000 00007fffb2b6f2a8
        GPR08: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
        GPR12: 0000000000000000 00007fffb2b76900 0000000000000000 0000000000000000
        GPR16: 00007fffb2370000 00007fffb2d84390 00007fffea3a15ac 000001000a250420
        GPR20: 00007fffb2b6f260 0000000010001770 0000000000000000 0000000000000000
        GPR24: 00007fffb2d843a0 00007fffea3a14a0 0000000000010000 0000000000800000
        GPR28: 00007fffea3a14d8 00000000003d0f00 0000000000000000 00007fffb2b6e728
        NIP [c0000000000022fc] rfi_flush_fallback+0x7c/0x80
        LR [00007fffb2d67e48] 0x7fffb2d67e48
        Call Trace:
        Instruction dump:
        e96a0220 e96a02a8 e96a0330 e96a03b8 394a0400 4200ffdc 7d2903a6 e92d0c00
        e94d0c08 e96d0c10 e82d0c18 7db242a6 <4c000024> 7db243a6 7db142a6 f82d0c18
      
      The problem is the signal code assumes TM is enabled when
      CONFIG_PPC_TRANSACTIONAL_MEM is enabled. This may not be the case as
      with P9 powernv or if `ppc_tm=off` is used on P8.
      
      This means any local user can crash the system.
      
      Fix the problem by returning a bad stack frame to the user if they try
      to set the MSR TS bits with sigreturn() on systems where TM is not
      supported.
      
      Found with sigfuz kernel selftest on P9.
      
      This fixes CVE-2019-13648.
      
      Fixes: 2b0a576d
      
       ("powerpc: Add new transactional memory state to the signal context")
      Cc: stable@vger.kernel.org # v3.9
      Reported-by: default avatarPraveen Pandey <Praveen.Pandey@in.ibm.com>
      Signed-off-by: default avatarMichael Neuling <mikey@neuling.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190719050502.405-1-mikey@neuling.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b993a66d
    • Gautham R. Shenoy's avatar
      powerpc/xive: Fix loop exit-condition in xive_find_target_in_mask() · b9310c56
      Gautham R. Shenoy authored
      commit 4d202c8c upstream.
      
      xive_find_target_in_mask() has the following for(;;) loop which has a
      bug when @first == cpumask_first(@mask) and condition 1 fails to hold
      for every CPU in @mask. In this case we loop forever in the for-loop.
      
        first = cpu;
        for (;;) {
        	  if (cpu_online(cpu) && xive_try_pick_target(cpu)) // condition 1
      		  return cpu;
      	  cpu = cpumask_next(cpu, mask);
      	  if (cpu == first) // condition 2
      		  break;
      
      	  if (cpu >= nr_cpu_ids) // condition 3
      		  cpu = cpumask_first(mask);
        }
      
      This is because, when @first == cpumask_first(@mask), we never hit the
      condition 2 (cpu == first) since prior to this check, we would have
      executed "cpu = cpumask_next(cpu, mask)" which will set the value of
      @cpu to a value greater than @first or to nr_cpus_ids. When this is
      coupled with the fact that condition 1 is not met, we will never exit
      this loop.
      
      This was discovered by the hard-lockup detector while running LTP test
      concurrently with SMT switch tests.
      
       watchdog: CPU 12 detected hard LOCKUP on other CPUs 68
       watchdog: CPU 12 TB:85587019220796, last SMP heartbeat TB:85578827223399 (15999ms ago)
       watchdog: CPU 68 Hard LOCKUP
       watchdog: CPU 68 TB:85587019361273, last heartbeat TB:85576815065016 (19930ms ago)
       CPU: 68 PID: 45050 Comm: hxediag Kdump: loaded Not tainted 4.18.0-100.el8.ppc64le #1
       NIP:  c0000000006f5578 LR: c000000000cba9ec CTR: 0000000000000000
       REGS: c000201fff3c7d80 TRAP: 0100   Not tainted  (4.18.0-100.el8.ppc64le)
       MSR:  9000000002883033 <SF,HV,VEC,VSX,FP,ME,IR,DR,RI,LE>  CR: 24028424  XER: 00000000
       CFAR: c0000000006f558c IRQMASK: 1
       GPR00: c0000000000afc58 c000201c01c43400 c0000000015ce500 c000201cae26ec18
       GPR04: 0000000000000800 0000000000000540 0000000000000800 00000000000000f8
       GPR08: 0000000000000020 00000000000000a8 0000000080000000 c00800001a1beed8
       GPR12: c0000000000b1410 c000201fff7f4c00 0000000000000000 0000000000000000
       GPR16: 0000000000000000 0000000000000000 0000000000000540 0000000000000001
       GPR20: 0000000000000048 0000000010110000 c00800001a1e3780 c000201cae26ed18
       GPR24: 0000000000000000 c000201cae26ed8c 0000000000000001 c000000001116bc0
       GPR28: c000000001601ee8 c000000001602494 c000201cae26ec18 000000000000001f
       NIP [c0000000006f5578] find_next_bit+0x38/0x90
       LR [c000000000cba9ec] cpumask_next+0x2c/0x50
       Call Trace:
       [c000201c01c43400] [c000201cae26ec18] 0xc000201cae26ec18 (unreliable)
       [c000201c01c43420] [c0000000000afc58] xive_find_target_in_mask+0x1b8/0x240
       [c000201c01c43470] [c0000000000b0228] xive_pick_irq_target.isra.3+0x168/0x1f0
       [c000201c01c435c0] [c0000000000b1470] xive_irq_startup+0x60/0x260
       [c000201c01c43640] [c0000000001d8328] __irq_startup+0x58/0xf0
       [c000201c01c43670] [c0000000001d844c] irq_startup+0x8c/0x1a0
       [c000201c01c436b0] [c0000000001d57b0] __setup_irq+0x9f0/0xa90
       [c000201c01c43760] [c0000000001d5aa0] request_threaded_irq+0x140/0x220
       [c000201c01c437d0] [c00800001a17b3d4] bnx2x_nic_load+0x188c/0x3040 [bnx2x]
       [c000201c01c43950] [c00800001a187c44] bnx2x_self_test+0x1fc/0x1f70 [bnx2x]
       [c000201c01c43a90] [c000000000adc748] dev_ethtool+0x11d8/0x2cb0
       [c000201c01c43b60] [c000000000b0b61c] dev_ioctl+0x5ac/0xa50
       [c000201c01c43bf0] [c000000000a8d4ec] sock_do_ioctl+0xbc/0x1b0
       [c000201c01c43c60] [c000000000a8dfb8] sock_ioctl+0x258/0x4f0
       [c000201c01c43d20] [c0000000004c9704] do_vfs_ioctl+0xd4/0xa70
       [c000201c01c43de0] [c0000000004ca274] sys_ioctl+0xc4/0x160
       [c000201c01c43e30] [c00000000000b388] system_call+0x5c/0x70
       Instruction dump:
       78aad182 54a806be 3920ffff 78a50664 794a1f24 7d294036 7d43502a 7d295039
       4182001c 48000034 78a9d182 79291f24 <7d23482a> 2fa90000 409e0020 38a50040
      
      To fix this, move the check for condition 2 after the check for
      condition 3, so that we are able to break out of the loop soon after
      iterating through all the CPUs in the @mask in the problem case. Use
      do..while() to achieve this.
      
      Fixes: 243e2511
      
       ("powerpc/xive: Native exploitation of the XIVE interrupt controller")
      Cc: stable@vger.kernel.org # v4.12+
      Reported-by: default avatarIndira P. Joga <indira.priya@in.ibm.com>
      Signed-off-by: default avatarGautham R. Shenoy <ego@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1563359724-13931-1-git-send-email-ego@linux.vnet.ibm.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9310c56
    • Hui Wang's avatar
      ALSA: hda - Add a conexant codec entry to let mute led work · c2194442
      Hui Wang authored
      commit 3f880949
      
       upstream.
      
      This conexant codec isn't in the supported codec list yet, the hda
      generic driver can drive this codec well, but on a Lenovo machine
      with mute/mic-mute leds, we need to apply CXT_FIXUP_THINKPAD_ACPI
      to make the leds work. After adding this codec to the list, the
      driver patch_conexant.c will apply THINKPAD_ACPI to this machine.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2194442
    • Kai-Heng Feng's avatar
      ALSA: line6: Fix wrong altsetting for LINE6_PODHD500_1 · 491483ed
      Kai-Heng Feng authored
      commit 70256b42 upstream.
      
      Commit 7b9584fa ("staging: line6: Move altsetting to properties")
      set a wrong altsetting for LINE6_PODHD500_1 during refactoring.
      
      Set the correct altsetting number to fix the issue.
      
      BugLink: https://bugs.launchpad.net/bugs/1790595
      Fixes: 7b9584fa
      
       ("staging: line6: Move altsetting to properties")
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      491483ed
    • Ding Xiang's avatar
      ALSA: ac97: Fix double free of ac97_codec_device · 60274409
      Ding Xiang authored
      commit 607975b3 upstream.
      
      put_device will call ac97_codec_release to free
      ac97_codec_device and other resources, so remove the kfree
      and other redundant code.
      
      Fixes: 74426fbf
      
       ("ALSA: ac97: add an ac97 bus")
      Signed-off-by: default avatarDing Xiang <dingxiang@cmss.chinamobile.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60274409
    • Kefeng Wang's avatar
      hpet: Fix division by zero in hpet_time_div() · 9845fb5a
      Kefeng Wang authored
      commit 0c7d37f4
      
       upstream.
      
      The base value in do_div() called by hpet_time_div() is truncated from
      unsigned long to uint32_t, resulting in a divide-by-zero exception.
      
      UBSAN: Undefined behaviour in ../drivers/char/hpet.c:572:2
      division by zero
      CPU: 1 PID: 23682 Comm: syz-executor.3 Not tainted 4.4.184.x86_64+ #4
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
       0000000000000000 b573382df1853d00 ffff8800a3287b98 ffffffff81ad7561
       ffff8800a3287c00 ffffffff838b35b0 ffffffff838b3860 ffff8800a3287c20
       0000000000000000 ffff8800a3287bb0 ffffffff81b8f25e ffffffff838b35a0
      Call Trace:
       [<ffffffff81ad7561>] __dump_stack lib/dump_stack.c:15 [inline]
       [<ffffffff81ad7561>] dump_stack+0xc1/0x120 lib/dump_stack.c:51
       [<ffffffff81b8f25e>] ubsan_epilogue+0x12/0x8d lib/ubsan.c:166
       [<ffffffff81b900cb>] __ubsan_handle_divrem_overflow+0x282/0x2c8 lib/ubsan.c:262
       [<ffffffff823560dd>] hpet_time_div drivers/char/hpet.c:572 [inline]
       [<ffffffff823560dd>] hpet_ioctl_common drivers/char/hpet.c:663 [inline]
       [<ffffffff823560dd>] hpet_ioctl_common.cold+0xa8/0xad drivers/char/hpet.c:577
       [<ffffffff81e63d56>] hpet_ioctl+0xc6/0x180 drivers/char/hpet.c:676
       [<ffffffff81711590>] vfs_ioctl fs/ioctl.c:43 [inline]
       [<ffffffff81711590>] file_ioctl fs/ioctl.c:470 [inline]
       [<ffffffff81711590>] do_vfs_ioctl+0x6e0/0xf70 fs/ioctl.c:605
       [<ffffffff81711eb4>] SYSC_ioctl fs/ioctl.c:622 [inline]
       [<ffffffff81711eb4>] SyS_ioctl+0x94/0xc0 fs/ioctl.c:613
       [<ffffffff82846003>] tracesys_phase2+0x90/0x95
      
      The main C reproducer autogenerated by syzkaller,
      
        syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
        memcpy((void*)0x20000100, "/dev/hpet\000", 10);
        syscall(__NR_openat, 0xffffffffffffff9c, 0x20000100, 0, 0);
        syscall(__NR_ioctl, r[0], 0x40086806, 0x40000000000000);
      
      Fix it by using div64_ul().
      
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarZhang HongJun <zhanghongjun2@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20190711132757.130092-1-wangkefeng.wang@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9845fb5a
    • Alexander Usyskin's avatar
      mei: me: add mule creek canyon (EHL) device ids · e4c91583
      Alexander Usyskin authored
      commit 1be8624a
      
       upstream.
      
      Add Mule Creek Canyon (PCH) MEI device ids for Elkhart Lake (EHL) Platform.
      
      Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
      Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190712095814.20746-1-tomas.winkler@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4c91583
    • YueHaibing's avatar
      fpga-manager: altera-ps-spi: Fix build error · 3d0a6926
      YueHaibing authored
      commit 3d139703
      
       upstream.
      
      If BITREVERSE is m and FPGA_MGR_ALTERA_PS_SPI is y,
      build fails:
      
      drivers/fpga/altera-ps-spi.o: In function `altera_ps_write':
      altera-ps-spi.c:(.text+0x4ec): undefined reference to `byte_rev_table'
      
      Select BITREVERSE to fix this.
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Fixes: fcfe18f8
      
       ("fpga-manager: altera-ps-spi: use bitrev8x4")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarMoritz Fischer <mdf@kernel.org>
      Link: https://lore.kernel.org/r/20190708071356.50928-1-yuehaibing@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d0a6926
    • Hridya Valsaraju's avatar
      binder: prevent transactions to context manager from its own process. · e907b131
      Hridya Valsaraju authored
      commit 49ed9694
      
       upstream.
      
      Currently, a transaction to context manager from its own process
      is prevented by checking if its binder_proc struct is the same as
      that of the sender. However, this would not catch cases where the
      process opens the binder device again and uses the new fd to send
      a transaction to the context manager.
      
      Reported-by: default avatar <syzbot+8b3c354d33c4ac78bfad@syzkaller.appspotmail.com>
      Signed-off-by: default avatarHridya Valsaraju <hridya@google.com>
      Acked-by: default avatarTodd Kjos <tkjos@google.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190715191804.112933-1-hridya@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e907b131
    • Zhenzhong Duan's avatar
      x86/speculation/mds: Apply more accurate check on hypervisor platform · 7d20e3ba
      Zhenzhong Duan authored
      commit 517c3ba0 upstream.
      
      X86_HYPER_NATIVE isn't accurate for checking if running on native platform,
      e.g. CONFIG_HYPERVISOR_GUEST isn't set or "nopv" is enabled.
      
      Checking the CPU feature bit X86_FEATURE_HYPERVISOR to determine if it's
      running on native platform is more accurate.
      
      This still doesn't cover the platforms on which X86_FEATURE_HYPERVISOR is
      unsupported, e.g. VMware, but there is nothing which can be done about this
      scenario.
      
      Fixes: 8a4b06d3
      
       ("x86/speculation/mds: Add sysfs reporting for MDS")
      Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@oracle.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1564022349-17338-1-git-send-email-zhenzhong.duan@oracle.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d20e3ba
    • Hans de Goede's avatar
      x86/sysfb_efi: Add quirks for some devices with swapped width and height · 5e87e8b4
      Hans de Goede authored
      commit d02f1aa3
      
       upstream.
      
      Some Lenovo 2-in-1s with a detachable keyboard have a portrait screen but
      advertise a landscape resolution and pitch, resulting in a messed up
      display if the kernel tries to show anything on the efifb (because of the
      wrong pitch).
      
      Fix this by adding a new DMI match table for devices which need to have
      their width and height swapped.
      
      At first it was tried to use the existing table for overriding some of the
      efifb parameters, but some of the affected devices have variants with
      different LCD resolutions which will not work with hardcoded override
      values.
      
      Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1730783
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190721152418.11644-1-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e87e8b4
    • Qu Wenruo's avatar
      btrfs: inode: Don't compress if NODATASUM or NODATACOW set · e3dc9ea5
      Qu Wenruo authored
      commit 42c16da6
      
       upstream.
      
      As btrfs(5) specified:
      
      	Note
      	If nodatacow or nodatasum are enabled, compression is disabled.
      
      If NODATASUM or NODATACOW set, we should not compress the extent.
      
      Normally NODATACOW is detected properly in run_delalloc_range() so
      compression won't happen for NODATACOW.
      
      However for NODATASUM we don't have any check, and it can cause
      compressed extent without csum pretty easily, just by:
        mkfs.btrfs -f $dev
        mount $dev $mnt -o nodatasum
        touch $mnt/foobar
        mount -o remount,datasum,compress $mnt
        xfs_io -f -c "pwrite 0 128K" $mnt/foobar
      
      And in fact, we have a bug report about corrupted compressed extent
      without proper data checksum so even RAID1 can't recover the corruption.
      (https://bugzilla.kernel.org/show_bug.cgi?id=199707)
      
      Running compression without proper checksum could cause more damage when
      corruption happens, as compressed data could make the whole extent
      unreadable, so there is no need to allow compression for
      NODATACSUM.
      
      The fix will refactor the inode compression check into two parts:
      
      - inode_can_compress()
        As the hard requirement, checked at btrfs_run_delalloc_range(), so no
        compression will happen for NODATASUM inode at all.
      
      - inode_need_compress()
        As the soft requirement, checked at btrfs_run_delalloc_range() and
        compress_file_range().
      
      Reported-by: default avatarJames Harvey <jamespharvey20@gmail.com>
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3dc9ea5
    • Ryan Kennedy's avatar
      usb: pci-quirks: Correct AMD PLL quirk detection · 1f37bec8
      Ryan Kennedy authored
      commit f3dccdaa upstream.
      
      The AMD PLL USB quirk is incorrectly enabled on newer Ryzen
      chipsets. The logic in usb_amd_find_chipset_info currently checks
      for unaffected chipsets rather than affected ones. This broke
      once a new chipset was added in e788787e
      
      . It makes more sense
      to reverse the logic so it won't need to be updated as new
      chipsets are added. Note that the core of the workaround in
      usb_amd_quirk_pll does correctly check the chipset.
      
      Signed-off-by: default avatarRyan Kennedy <ryan5544@gmail.com>
      Fixes: e788787e
      
       ("usb:xhci:Add quirk for Certain failing HP keyboard on reset after resume")
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20190704153529.9429-2-ryan5544@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f37bec8
    • Phong Tran's avatar
      usb: wusbcore: fix unbalanced get/put cluster_id · 41d3dbb9
      Phong Tran authored
      commit f90bf1ec
      
       upstream.
      
      syzboot reported that
      https://syzkaller.appspot.com/bug?extid=fd2bd7df88c606eea4ef
      
      There is not consitency parameter in cluste_id_get/put calling.
      In case of getting the id with result is failure, the wusbhc->cluster_id
      will not be updated and this can not be used for wusb_cluster_id_put().
      
      Tested report
      https://groups.google.com/d/msg/syzkaller-bugs/0znZopp3-9k/oxOrhLkLEgAJ
      
      Reproduce and gdb got the details:
      
      139		addr = wusb_cluster_id_get();
      (gdb) n
      140		if (addr == 0)
      (gdb) print addr
      $1 = 254 '\376'
      (gdb) n
      142		result = __hwahc_set_cluster_id(hwahc, addr);
      (gdb) print result
      $2 = -71
      (gdb) break wusb_cluster_id_put
      Breakpoint 3 at 0xffffffff836e3f20: file drivers/usb/wusbcore/wusbhc.c, line 384.
      (gdb) s
      Thread 2 hit Breakpoint 3, wusb_cluster_id_put (id=0 '\000') at drivers/usb/wusbcore/wusbhc.c:384
      384		id = 0xff - id;
      (gdb) n
      385		BUG_ON(id >= CLUSTER_IDS);
      (gdb) print id
      $3 = 255 '\377'
      
      Reported-by: default avatar <syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPhong Tran <tranmanphong@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190724020601.15257-1-tranmanphong@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      41d3dbb9
    • Arnd Bergmann's avatar
      locking/lockdep: Hide unused 'class' variable · 148959cc
      Arnd Bergmann authored
      [ Upstream commit 68037aa7
      
       ]
      
      The usage is now hidden in an #ifdef, so we need to move
      the variable itself in there as well to avoid this warning:
      
        kernel/locking/lockdep_proc.c:203:21: error: unused variable 'class' [-Werror,-Wunused-variable]
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qian Cai <cai@lca.pw>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yuyang Du <duyuyang@gmail.com>
      Cc: frederic@kernel.org
      Fixes: 68d41d8c
      
       ("locking/lockdep: Fix lock used or unused stats error")
      Link: https://lkml.kernel.org/r/20190715092809.736834-1-arnd@arndb.de
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      148959cc
    • Konstantin Khlebnikov's avatar
      mm: use down_read_killable for locking mmap_sem in access_remote_vm · b0768724
      Konstantin Khlebnikov authored
      [ Upstream commit 1e426fe2
      
       ]
      
      This function is used by ptrace and proc files like /proc/pid/cmdline and
      /proc/pid/environ.
      
      Access_remote_vm never returns error codes, all errors are ignored and
      only size of successfully read data is returned.  So, if current task was
      killed we'll simply return 0 (bytes read).
      
      Mmap_sem could be locked for a long time or forever if something goes
      wrong.  Using a killable lock permits cleanup of stuck tasks and
      simplifies investigation.
      
      Link: http://lkml.kernel.org/r/156007494202.3335.16782303099589302087.stgit@buzz
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Reviewed-by: default avatarMichal Koutný <mkoutny@suse.com>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Cyrill Gorcunov <gorcunov@gmail.com>
      Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Roman Gushchin <guro@fb.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0768724
    • Yuyang Du's avatar
      locking/lockdep: Fix lock used or unused stats error · 4acb04ef
      Yuyang Du authored
      [ Upstream commit 68d41d8c ]
      
      The stats variable nr_unused_locks is incremented every time a new lock
      class is register and decremented when the lock is first used in
      __lock_acquire(). And after all, it is shown and checked in lockdep_stats.
      
      However, under configurations that either CONFIG_TRACE_IRQFLAGS or
      CONFIG_PROVE_LOCKING is not defined:
      
      The commit:
      
        09180651 ("locking/lockdep: Consolidate lock usage bit initialization")
      
      missed marking the LOCK_USED flag at IRQ usage initialization because
      as mark_usage() is not called. And the commit:
      
        886532ae
      
       ("locking/lockdep: Move mark_lock() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING")
      
      further made mark_lock() not defined such that the LOCK_USED cannot be
      marked at all when the lock is first acquired.
      
      As a result, we fix this by not showing and checking the stats under such
      configurations for lockdep_stats.
      
      Reported-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarYuyang Du <duyuyang@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: arnd@arndb.de
      Cc: frederic@kernel.org
      Link: https://lkml.kernel.org/r/20190709101522.9117-1-duyuyang@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4acb04ef
    • Konstantin Khlebnikov's avatar
      proc: use down_read_killable mmap_sem for /proc/pid/maps · af0883f9
      Konstantin Khlebnikov authored
      [ Upstream commit 8a713e7d
      
       ]
      
      Do not remain stuck forever if something goes wrong.  Using a killable
      lock permits cleanup of stuck tasks and simplifies investigation.
      
      This function is also used for /proc/pid/smaps.
      
      Link: http://lkml.kernel.org/r/156007493160.3335.14447544314127417266.stgit@buzz
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Reviewed-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Koutný <mkoutny@suse.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      af0883f9
    • Arnd Bergmann's avatar
      cxgb4: reduce kernel stack usage in cudbg_collect_mem_region() · 0d72bb85
      Arnd Bergmann authored
      [ Upstream commit 752c2ea2 ]
      
      The cudbg_collect_mem_region() and cudbg_read_fw_mem() both use several
      hundred kilobytes of kernel stack space. One gets inlined into the other,
      which causes the stack usage to be combined beyond the warning limit
      when building with clang:
      
      drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c:1057:12: error: stack frame size of 1244 bytes in function 'cudbg_collect_mem_region' [-Werror,-Wframe-larger-than=]
      
      Restructuring cudbg_collect_mem_region() lets clang do the same
      optimization that gcc does and reuse the stack slots as it can
      see that the large variables are never used together.
      
      A better fix might be to avoid using cudbg_meminfo on the stack
      altogether, but that requires a larger rewrite.
      
      Fixes: a1c69520
      
       ("cxgb4: collect MC memory dump")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d72bb85
    • Konstantin Khlebnikov's avatar
      proc: use down_read_killable mmap_sem for /proc/pid/map_files · 6ecdcbcd
      Konstantin Khlebnikov authored
      [ Upstream commit cd9e2bb8
      
       ]
      
      Do not remain stuck forever if something goes wrong.  Using a killable
      lock permits cleanup of stuck tasks and simplifies investigation.
      
      It seems ->d_revalidate() could return any error (except ECHILD) to abort
      validation and pass error as result of lookup sequence.
      
      [akpm@linux-foundation.org: fix proc_map_files_lookup() return value, per Andrei]
      Link: http://lkml.kernel.org/r/156007493995.3335.9595044802115356911.stgit@buzz
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Reviewed-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Koutný <mkoutny@suse.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ecdcbcd
    • Konstantin Khlebnikov's avatar
      proc: use down_read_killable mmap_sem for /proc/pid/clear_refs · 3d617da8
      Konstantin Khlebnikov authored
      [ Upstream commit c4603801
      
       ]
      
      Do not remain stuck forever if something goes wrong.  Using a killable
      lock permits cleanup of stuck tasks and simplifies investigation.
      
      Replace the only unkillable mmap_sem lock in clear_refs_write().
      
      Link: http://lkml.kernel.org/r/156007493826.3335.5424884725467456239.stgit@buzz
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Reviewed-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Koutný <mkoutny@suse.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d617da8
    • Konstantin Khlebnikov's avatar
      proc: use down_read_killable mmap_sem for /proc/pid/pagemap · 42beb7b3
      Konstantin Khlebnikov authored
      [ Upstream commit ad80b932
      
       ]
      
      Do not remain stuck forever if something goes wrong.  Using a killable
      lock permits cleanup of stuck tasks and simplifies investigation.
      
      Link: http://lkml.kernel.org/r/156007493638.3335.4872164955523928492.stgit@buzz
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Reviewed-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Koutný <mkoutny@suse.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      42beb7b3
    • Konstantin Khlebnikov's avatar
      proc: use down_read_killable mmap_sem for /proc/pid/smaps_rollup · 1b3042d0
      Konstantin Khlebnikov authored
      [ Upstream commit a26a9781
      
       ]
      
      Do not remain stuck forever if something goes wrong.  Using a killable
      lock permits cleanup of stuck tasks and simplifies investigation.
      
      Link: http://lkml.kernel.org/r/156007493429.3335.14666825072272692455.stgit@buzz
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Reviewed-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Koutný <mkoutny@suse.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1b3042d0
    • Jean-Philippe Brucker's avatar
      mm/mmu_notifier: use hlist_add_head_rcu() · a8c568fc
      Jean-Philippe Brucker authored
      [ Upstream commit 543bdb2d ]
      
      Make mmu_notifier_register() safer by issuing a memory barrier before
      registering a new notifier.  This fixes a theoretical bug on weakly
      ordered CPUs.  For example, take this simplified use of notifiers by a
      driver:
      
      	my_struct->mn.ops = &my_ops; /* (1) */
      	mmu_notifier_register(&my_struct->mn, mm)
      		...
      		hlist_add_head(&mn->hlist, &mm->mmu_notifiers); /* (2) */
      		...
      
      Once mmu_notifier_register() releases the mm locks, another thread can
      invalidate a range:
      
      	mmu_notifier_invalidate_range()
      		...
      		hlist_for_each_entry_rcu(mn, &mm->mmu_notifiers, hlist) {
      			if (mn->ops->invalidate_range)
      
      The read side relies on the data dependency between mn and ops to ensure
      that the pointer is properly initialized.  But the write side doesn't have
      any dependency between (1) and (2), so they could be reordered and the
      readers could dereference an invalid mn->ops.  mmu_notifier_register()
      does take all the mm locks before adding to the hlist, but those have
      acquire semantics which isn't sufficient.
      
      By calling hlist_add_head_rcu() instead of hlist_add_head() we update the
      hlist using a store-release, ensuring that readers see prior
      initialization of my_struct.  This situation is better illustated by
      litmus test MP+onceassign+derefonce.
      
      Link: http://lkml.kernel.org/r/20190502133532.24981-1-jean-philippe.brucker@arm.com
      Fixes: cddb8a5c
      
       ("mmu-notifiers: core")
      Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Cc: Jérôme Glisse <jglisse@redhat.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a8c568fc
    • Shakeel Butt's avatar
      memcg, fsnotify: no oom-kill for remote memcg charging · 3062448e
      Shakeel Butt authored
      [ Upstream commit ec165450 ]
      
      Commit d46eb14b ("fs: fsnotify: account fsnotify metadata to
      kmemcg") added remote memcg charging for fanotify and inotify event
      objects.  The aim was to charge the memory to the listener who is
      interested in the events but without triggering the OOM killer.
      Otherwise there would be security concerns for the listener.
      
      At the time, oom-kill trigger was not in the charging path.  A parallel
      work added the oom-kill back to charging path i.e.  commit 29ef680a
      
      
      ("memcg, oom: move out_of_memory back to the charge path").  So to not
      trigger oom-killer in the remote memcg, explicitly add
      __GFP_RETRY_MAYFAIL to the fanotigy and inotify event allocations.
      
      Link: http://lkml.kernel.org/r/20190514212259.156585-2-shakeelb@google.com
      Signed-off-by: default avatarShakeel Butt <shakeelb@google.com>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Acked-by: default avatarJan Kara <jack@suse.cz>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3062448e
    • Andy Lutomirski's avatar
      mm/gup.c: remove some BUG_ONs from get_gate_page() · 041b127d
      Andy Lutomirski authored
      [ Upstream commit b5d1c39f
      
       ]
      
      If we end up without a PGD or PUD entry backing the gate area, don't BUG
      -- just fail gracefully.
      
      It's not entirely implausible that this could happen some day on x86.  It
      doesn't right now even with an execute-only emulated vsyscall page because
      the fixmap shares the PUD, but the core mm code shouldn't rely on that
      particular detail to avoid OOPSing.
      
      Link: http://lkml.kernel.org/r/a1d9f4efb75b9d464e59fd6af00104b21c58f6f7.1561610798.git.luto@kernel.org
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Florian Weimer <fweimer@redhat.com>
      Cc: Jann Horn <jannh@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      041b127d
    • Guenter Roeck's avatar
      mm/gup.c: mark undo_dev_pagemap as __maybe_unused · fa099d6d
      Guenter Roeck authored
      [ Upstream commit 790c7369
      
       ]
      
      Several mips builds generate the following build warning.
      
        mm/gup.c:1788:13: warning: 'undo_dev_pagemap' defined but not used
      
      The function is declared unconditionally but only called from behind
      various ifdefs. Mark it __maybe_unused.
      
      Link: http://lkml.kernel.org/r/1562072523-22311-1-git-send-email-linux@roeck-us.net
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fa099d6d
    • Christoph Hellwig's avatar
      9p: pass the correct prototype to read_cache_page · 8be4a30e
      Christoph Hellwig authored
      [ Upstream commit f053cbd4
      
       ]
      
      Fix the callback 9p passes to read_cache_page to actually have the
      proper type expected.  Casting around function pointers can easily
      hide typing bugs, and defeats control flow protection.
      
      Link: http://lkml.kernel.org/r/20190520055731.24538-5-hch@lst.de
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8be4a30e
    • Dmitry Vyukov's avatar
      mm/kmemleak.c: fix check for softirq context · 071f2135
      Dmitry Vyukov authored
      [ Upstream commit 6ef90569
      
       ]
      
      in_softirq() is a wrong predicate to check if we are in a softirq
      context.  It also returns true if we have BH disabled, so objects are
      falsely stamped with "softirq" comm.  The correct predicate is
      in_serving_softirq().
      
      If user does cat from /sys/kernel/debug/kmemleak previously they would
      see this, which is clearly wrong, this is system call context (see the
      comm):
      
      unreferenced object 0xffff88805bd661c0 (size 64):
        comm "softirq", pid 0, jiffies 4294942959 (age 12.400s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00  ................
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<0000000007dcb30c>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
          [<0000000007dcb30c>] slab_post_alloc_hook mm/slab.h:439 [inline]
          [<0000000007dcb30c>] slab_alloc mm/slab.c:3326 [inline]
          [<0000000007dcb30c>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
          [<00000000969722b7>] kmalloc include/linux/slab.h:547 [inline]
          [<00000000969722b7>] kzalloc include/linux/slab.h:742 [inline]
          [<00000000969722b7>] ip_mc_add1_src net/ipv4/igmp.c:1961 [inline]
          [<00000000969722b7>] ip_mc_add_src+0x36b/0x400 net/ipv4/igmp.c:2085
          [<00000000a4134b5f>] ip_mc_msfilter+0x22d/0x310 net/ipv4/igmp.c:2475
          [<00000000d20248ad>] do_ip_setsockopt.isra.0+0x19fe/0x1c00 net/ipv4/ip_sockglue.c:957
          [<000000003d367be7>] ip_setsockopt+0x3b/0xb0 net/ipv4/ip_sockglue.c:1246
          [<000000003c7c76af>] udp_setsockopt+0x4e/0x90 net/ipv4/udp.c:2616
          [<000000000c1aeb23>] sock_common_setsockopt+0x3e/0x50 net/core/sock.c:3130
          [<000000000157b92b>] __sys_setsockopt+0x9e/0x120 net/socket.c:2078
          [<00000000a9f3d058>] __do_sys_setsockopt net/socket.c:2089 [inline]
          [<00000000a9f3d058>] __se_sys_setsockopt net/socket.c:2086 [inline]
          [<00000000a9f3d058>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
          [<000000001b8da885>] do_syscall_64+0x7c/0x1a0 arch/x86/entry/common.c:301
          [<00000000ba770c62>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      now they will see this:
      
      unreferenced object 0xffff88805413c800 (size 64):
        comm "syz-executor.4", pid 8960, jiffies 4294994003 (age 14.350s)
        hex dump (first 32 bytes):
          00 7a 8a 57 80 88 ff ff e0 00 00 01 00 00 00 00  .z.W............
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000c5d3be64>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
          [<00000000c5d3be64>] slab_post_alloc_hook mm/slab.h:439 [inline]
          [<00000000c5d3be64>] slab_alloc mm/slab.c:3326 [inline]
          [<00000000c5d3be64>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
          [<0000000023865be2>] kmalloc include/linux/slab.h:547 [inline]
          [<0000000023865be2>] kzalloc include/linux/slab.h:742 [inline]
          [<0000000023865be2>] ip_mc_add1_src net/ipv4/igmp.c:1961 [inline]
          [<0000000023865be2>] ip_mc_add_src+0x36b/0x400 net/ipv4/igmp.c:2085
          [<000000003029a9d4>] ip_mc_msfilter+0x22d/0x310 net/ipv4/igmp.c:2475
          [<00000000ccd0a87c>] do_ip_setsockopt.isra.0+0x19fe/0x1c00 net/ipv4/ip_sockglue.c:957
          [<00000000a85a3785>] ip_setsockopt+0x3b/0xb0 net/ipv4/ip_sockglue.c:1246
          [<00000000ec13c18d>] udp_setsockopt+0x4e/0x90 net/ipv4/udp.c:2616
          [<0000000052d748e3>] sock_common_setsockopt+0x3e/0x50 net/core/sock.c:3130
          [<00000000512f1014>] __sys_setsockopt+0x9e/0x120 net/socket.c:2078
          [<00000000181758bc>] __do_sys_setsockopt net/socket.c:2089 [inline]
          [<00000000181758bc>] __se_sys_setsockopt net/socket.c:2086 [inline]
          [<00000000181758bc>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
          [<00000000d4b73623>] do_syscall_64+0x7c/0x1a0 arch/x86/entry/common.c:301
          [<00000000c1098bec>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Link: http://lkml.kernel.org/r/20190517171507.96046-1-dvyukov@gmail.com
      Signed-off-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Acked-by: default avatarCatalin 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>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      071f2135
    • Sam Ravnborg's avatar
      sh: prevent warnings when using iounmap · 7bd5902a
      Sam Ravnborg authored
      [ Upstream commit 733f0025
      
       ]
      
      When building drm/exynos for sh, as part of an allmodconfig build, the
      following warning triggered:
      
        exynos7_drm_decon.c: In function `decon_remove':
        exynos7_drm_decon.c:769:24: warning: unused variable `ctx'
          struct decon_context *ctx = dev_get_drvdata(&pdev->dev);
      
      The ctx variable is only used as argument to iounmap().
      
      In sh - allmodconfig CONFIG_MMU is not defined
      so it ended up in:
      
      \#define __iounmap(addr)	do { } while (0)
      \#define iounmap		__iounmap
      
      Fix the warning by introducing a static inline function for iounmap.
      
      This is similar to several other architectures.
      
      Link: http://lkml.kernel.org/r/20190622114208.24427-1-sam@ravnborg.org
      Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Inki Dae <inki.dae@samsung.com>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7bd5902a