1. 13 Nov, 2018 40 commits
    • Mauro Carvalho Chehab's avatar
      media: em28xx: fix input name for Terratec AV 350 · a4e311ed
      Mauro Carvalho Chehab authored
      commit 15644bfa upstream.
      
      Instead of using a register value, use an AMUX name, as otherwise
      VIDIOC_G_AUDIO would fail.
      
      Cc: stable@vger.kernel.org
      Fixes: 766ed64d ("V4L/DVB (11827): Add support for Terratec Grabster AV350")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4e311ed
    • Mauro Carvalho Chehab's avatar
      media: tvp5150: avoid going past array on v4l2_querymenu() · 3dfd975b
      Mauro Carvalho Chehab authored
      commit 5c4c4505 upstream.
      
      The parameters of v4l2_ctrl_new_std_menu_items() are tricky: instead of
      the number of possible values, it requires the number of the maximum
      value. In other words, the ARRAY_SIZE() value should be decremented,
      otherwise it will go past the array bounds, as warned by KASAN:
      
      [  279.839688] BUG: KASAN: global-out-of-bounds in v4l2_querymenu+0x10d/0x180 [videodev]
      [  279.839709] Read of size 8 at addr ffffffffc10a4cb0 by task v4l2-compliance/16676
      
      [  279.839736] CPU: 1 PID: 16676 Comm: v4l2-compliance Not tainted 4.18.0-rc2+ #120
      [  279.839741] Hardware name:  /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017
      [  279.839743] Call Trace:
      [  279.839758]  dump_stack+0x71/0xab
      [  279.839807]  ? v4l2_querymenu+0x10d/0x180 [videodev]
      [  279.839817]  print_address_description+0x1c9/0x270
      [  279.839863]  ? v4l2_querymenu+0x10d/0x180 [videodev]
      [  279.839871]  kasan_report+0x237/0x360
      [  279.839918]  v4l2_querymenu+0x10d/0x180 [videodev]
      [  279.839964]  __video_do_ioctl+0x2c8/0x590 [videodev]
      [  279.840011]  ? copy_overflow+0x20/0x20 [videodev]
      [  279.840020]  ? avc_ss_reset+0xa0/0xa0
      [  279.840028]  ? check_stack_object+0x21/0x60
      [  279.840036]  ? __check_object_size+0xe7/0x240
      [  279.840080]  video_usercopy+0xed/0x730 [videodev]
      [  279.840123]  ? copy_overflow+0x20/0x20 [videodev]
      [  279.840167]  ? v4l_enumstd+0x40/0x40 [videodev]
      [  279.840177]  ? __handle_mm_fault+0x9f9/0x1ba0
      [  279.840186]  ? __pmd_alloc+0x2c0/0x2c0
      [  279.840193]  ? __vfs_write+0xb6/0x350
      [  279.840200]  ? kernel_read+0xa0/0xa0
      [  279.840244]  ? video_usercopy+0x730/0x730 [videodev]
      [  279.840284]  v4l2_ioctl+0xa1/0xb0 [videodev]
      [  279.840295]  do_vfs_ioctl+0x117/0x8a0
      [  279.840303]  ? selinux_file_ioctl+0x211/0x2f0
      [  279.840313]  ? ioctl_preallocate+0x120/0x120
      [  279.840319]  ? selinux_capable+0x20/0x20
      [  279.840332]  ksys_ioctl+0x70/0x80
      [  279.840342]  __x64_sys_ioctl+0x3d/0x50
      [  279.840351]  do_syscall_64+0x6d/0x1c0
      [  279.840361]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [  279.840367] RIP: 0033:0x7fdfb46275d7
      [  279.840369] Code: b3 66 90 48 8b 05 b1 48 2d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 81 48 2d 00 f7 d8 64 89 01 48
      [  279.840474] RSP: 002b:00007ffee1179038 EFLAGS: 00000202 ORIG_RAX: 0000000000000010
      [  279.840483] RAX: ffffffffffffffda RBX: 00007ffee1179180 RCX: 00007fdfb46275d7
      [  279.840488] RDX: 00007ffee11790c0 RSI: 00000000c02c5625 RDI: 0000000000000003
      [  279.840493] RBP: 0000000000000002 R08: 0000000000000020 R09: 00000000009f0902
      [  279.840497] R10: 0000000000000000 R11: 0000000000000202 R12: 00007ffee117a5a0
      [  279.840501] R13: 00007ffee11790c0 R14: 0000000000000002 R15: 0000000000000000
      
      [  279.840515] The buggy address belongs to the variable:
      [  279.840535]  tvp5150_test_patterns+0x10/0xffffffffffffe360 [tvp5150]
      
      Fixes: c43875f6 ("[media] tvp5150: replace MEDIA_ENT_F_CONN_TEST by a control")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3dfd975b
    • Mauro Carvalho Chehab's avatar
      media: em28xx: use a default format if TRY_FMT fails · 1f1eb844
      Mauro Carvalho Chehab authored
      commit f823ce2a upstream.
      
      Follow the V4L2 spec, as warned by v4l2-compliance:
      
      	warn: v4l2-test-formats.cpp(732): TRY_FMT cannot handle an invalid pixelformat.
      	warn: v4l2-test-formats.cpp(733): This may or may not be a problem. For more information see:
      
      warn: v4l2-test-formats.cpp(734): http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
      
      Cc: stable@vger.kernel.org
      Fixes: bddcf633 ("V4L/DVB (9927): em28xx: use a more standard way to specify video formats")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f1eb844
    • Manjunath Patil's avatar
      xen-blkfront: fix kernel panic with negotiate_mq error path · 4e6d30de
      Manjunath Patil authored
      commit 6cc4a086 upstream.
      
      info->nr_rings isn't adjusted in case of ENOMEM error from
      negotiate_mq(). This leads to kernel panic in error path.
      
      Typical call stack involving panic -
       #8 page_fault at ffffffff8175936f
          [exception RIP: blkif_free_ring+33]
          RIP: ffffffffa0149491  RSP: ffff8804f7673c08  RFLAGS: 00010292
       ...
       #9 blkif_free at ffffffffa0149aaa [xen_blkfront]
       #10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront]
       #11 blkback_changed at ffffffffa014ea8b [xen_blkfront]
       #12 xenbus_otherend_changed at ffffffff81424670
       #13 backend_changed at ffffffff81426dc3
       #14 xenwatch_thread at ffffffff81422f29
       #15 kthread at ffffffff810abe6a
       #16 ret_from_fork at ffffffff81754078
      
      Cc: stable@vger.kernel.org
      Fixes: 7ed8ce1c ("xen-blkfront: move negotiate_mq to cover all cases of new VBDs")
      Signed-off-by: default avatarManjunath Patil <manjunath.b.patil@oracle.com>
      Acked-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e6d30de
    • Juergen Gross's avatar
      xen: fix xen_qlock_wait() · 034680fc
      Juergen Gross authored
      commit d3132b38 upstream.
      
      Commit a8565319 ("xen: make xen_qlock_wait() nestable")
      introduced a regression for Xen guests running fully virtualized
      (HVM or PVH mode). The Xen hypervisor wouldn't return from the poll
      hypercall with interrupts disabled in case of an interrupt (for PV
      guests it does).
      
      So instead of disabling interrupts in xen_qlock_wait() use a nesting
      counter to avoid calling xen_clear_irq_pending() in case
      xen_qlock_wait() is nested.
      
      Fixes: a8565319 ("xen: make xen_qlock_wait() nestable")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Tested-by: default avatarSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      034680fc
    • He Zhe's avatar
      kgdboc: Passing ekgdboc to command line causes panic · 8305d98c
      He Zhe authored
      commit 1bd54d85 upstream.
      
      kgdboc_option_setup does not check input argument before passing it
      to strlen. The argument would be a NULL pointer if "ekgdboc", without
      its value, is set in command line and thus cause the following panic.
      
      PANIC: early exception 0xe3 IP 10:ffffffff8fbbb620 error 0 cr2 0x0
      [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.18-rc8+ #1
      [    0.000000] RIP: 0010:strlen+0x0/0x20
      ...
      [    0.000000] Call Trace
      [    0.000000]  ? kgdboc_option_setup+0x9/0xa0
      [    0.000000]  ? kgdboc_early_init+0x6/0x1b
      [    0.000000]  ? do_early_param+0x4d/0x82
      [    0.000000]  ? parse_args+0x212/0x330
      [    0.000000]  ? rdinit_setup+0x26/0x26
      [    0.000000]  ? parse_early_options+0x20/0x23
      [    0.000000]  ? rdinit_setup+0x26/0x26
      [    0.000000]  ? parse_early_param+0x2d/0x39
      [    0.000000]  ? setup_arch+0x2f7/0xbf4
      [    0.000000]  ? start_kernel+0x5e/0x4c2
      [    0.000000]  ? load_ucode_bsp+0x113/0x12f
      [    0.000000]  ? secondary_startup_64+0xa5/0xb0
      
      This patch adds a check to prevent the panic.
      
      Cc: stable@vger.kernel.org
      Cc: jason.wessel@windriver.com
      Cc: gregkh@linuxfoundation.org
      Cc: jslaby@suse.com
      Signed-off-by: default avatarHe Zhe <zhe.he@windriver.com>
      Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8305d98c
    • Hans Verkuil's avatar
      media: v4l2-tpg: fix kernel oops when enabling HFLIP and OSD · fdff1cf0
      Hans Verkuil authored
      commit 250854ee upstream.
      
      When the OSD is on (i.e. vivid displays text on top of the test pattern), and
      you enable hflip, then the driver crashes.
      
      The cause turned out to be a division of a negative number by an unsigned value.
      You expect that -8 / 2U would be -4, but in reality it is 2147483644 :-(
      
      Fixes: 3e14e7a8 ("vivid-tpg: add hor/vert downsampling support to tpg_gen_text")
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Reported-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: <stable@vger.kernel.org>      # for v4.1 and up
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fdff1cf0
    • Maciej W. Rozycki's avatar
      TC: Set DMA masks for devices · e7f6b41a
      Maciej W. Rozycki authored
      commit 3f2aa244 upstream.
      
      Fix a TURBOchannel support regression with commit 205e1b7f
      ("dma-mapping: warn when there is no coherent_dma_mask") that caused
      coherent DMA allocations to produce a warning such as:
      
      defxx: v1.11 2014/07/01  Lawrence V. Stefani and others
      tc1: DEFTA at MMIO addr = 0x1e900000, IRQ = 20, Hardware addr = 08-00-2b-a3-a3-29
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 dfx_dev_register+0x670/0x678
      Modules linked in:
      CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.0-rc6 #2
      Stack : ffffffff8009ffc0 fffffffffffffec0 0000000000000000 ffffffff80647650
              0000000000000000 0000000000000000 ffffffff806f5f80 ffffffffffffffff
              0000000000000000 0000000000000000 0000000000000001 ffffffff8065d4e8
              98000000031b6300 ffffffff80563478 ffffffff805685b0 ffffffffffffffff
              0000000000000000 ffffffff805d6720 0000000000000204 ffffffff80388df8
              0000000000000000 0000000000000009 ffffffff8053efd0 ffffffff806657d0
              0000000000000000 ffffffff803177f8 0000000000000000 ffffffff806d0000
              9800000003078000 980000000307b9e0 000000001e900000 ffffffff80067940
              0000000000000000 ffffffff805d6720 0000000000000204 ffffffff80388df8
              ffffffff805176c0 ffffffff8004dc78 0000000000000000 ffffffff80067940
              ...
      Call Trace:
      [<ffffffff8004dc78>] show_stack+0xa0/0x130
      [<ffffffff80067940>] __warn+0x128/0x170
      ---[ end trace b1d1e094f67f3bb2 ]---
      
      This is because the TURBOchannel bus driver fails to set the coherent
      DMA mask for devices enumerated.
      
      Set the regular and coherent DMA masks for TURBOchannel devices then,
      observing that the bus protocol supports a 34-bit (16GiB) DMA address
      space, by interpreting the value presented in the address cycle across
      the 32 `ad' lines as a 32-bit word rather than byte address[1].  The
      architectural size of the TURBOchannel DMA address space exceeds the
      maximum amount of RAM any actual TURBOchannel system in existence may
      have, hence both masks are the same.
      
      This removes the warning shown above.
      
      References:
      
      [1] "TURBOchannel Hardware Specification", EK-369AA-OD-007B, Digital
          Equipment Corporation, January 1993, Section "DMA", pp. 1-15 -- 1-17
      Signed-off-by: default avatarMaciej W. Rozycki <macro@linux-mips.org>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20835/
      Fixes: 205e1b7f ("dma-mapping: warn when there is no coherent_dma_mask")
      Cc: stable@vger.kernel.org # 4.16+
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e7f6b41a
    • Will Deacon's avatar
      iommu/arm-smmu: Ensure that page-table updates are visible before TLBI · 34e0ab87
      Will Deacon authored
      commit 7d321bd3 upstream.
      
      The IO-pgtable code relies on the driver TLB invalidation callbacks to
      ensure that all page-table updates are visible to the IOMMU page-table
      walker.
      
      In the case that the page-table walker is cache-coherent, we cannot rely
      on an implicit DSB from the DMA-mapping code, so we must ensure that we
      execute a DSB in our tlb_add_flush() callback prior to triggering the
      invalidation.
      
      Cc: <stable@vger.kernel.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Fixes: 2df7a25c ("iommu/arm-smmu: Clean up DMA API usage")
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34e0ab87
    • Aaro Koskinen's avatar
      MIPS: OCTEON: fix out of bounds array access on CN68XX · d70d2e3c
      Aaro Koskinen authored
      commit c0fae7e2 upstream.
      
      The maximum number of interfaces is returned by
      cvmx_helper_get_number_of_interfaces(), and the value is used to access
      interface_port_count[]. When CN68XX support was added, we forgot
      to increase the array size. Fix that.
      
      Fixes: 2c8c3f02 ("MIPS: Octeon: Support additional interfaces on CN68XX")
      Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20949/
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: stable@vger.kernel.org # v4.3+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d70d2e3c
    • Christophe Leroy's avatar
      powerpc/msi: Fix compile error on mpc83xx · dfed53c8
      Christophe Leroy authored
      commit 0f99153d upstream.
      
      mpic_get_primary_version() is not defined when not using MPIC.
      The compile error log like:
      
      arch/powerpc/sysdev/built-in.o: In function `fsl_of_msi_probe':
      fsl_msi.c:(.text+0x150c): undefined reference to `fsl_mpic_primary_get_version'
      Signed-off-by: default avatarJia Hongtao <hongtao.jia@freescale.com>
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      Reported-by: default avatarRadu Rendec <radu.rendec@gmail.com>
      Fixes: 807d38b7 ("powerpc/mpic: Add get_version API both for internal and external use")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dfed53c8
    • Damien Le Moal's avatar
      dm zoned: fix various dmz_get_mblock() issues · 37531246
      Damien Le Moal authored
      commit 3d4e7383 upstream.
      
      dmz_fetch_mblock() called from dmz_get_mblock() has a race since the
      allocation of the new metadata block descriptor and its insertion in
      the cache rbtree with the READING state is not atomic. Two different
      contexts requesting the same block may end up each adding two different
      descriptors of the same block to the cache.
      
      Another problem for this function is that the BIO for processing the
      block read is allocated after the metadata block descriptor is inserted
      in the cache rbtree. If the BIO allocation fails, the metadata block
      descriptor is freed without first being removed from the rbtree.
      
      Fix the first problem by checking again if the requested block is not in
      the cache right before inserting the newly allocated descriptor,
      atomically under the mblk_lock spinlock. The second problem is fixed by
      simply allocating the BIO before inserting the new block in the cache.
      
      Finally, since dmz_fetch_mblock() also increments a block reference
      counter, rename the function to dmz_get_mblock_slow(). To be symmetric
      and clear, also rename dmz_lookup_mblock() to dmz_get_mblock_fast() and
      increment the block reference counter directly in that function rather
      than in dmz_get_mblock().
      
      Fixes: 3b1a94c8 ("dm zoned: drive-managed zoned block device target")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37531246
    • Damien Le Moal's avatar
      dm zoned: fix metadata block ref counting · 229cbc61
      Damien Le Moal authored
      commit 33c2865f upstream.
      
      Since the ref field of struct dmz_mblock is always used with the
      spinlock of struct dmz_metadata locked, there is no need to use an
      atomic_t type. Change the type of the ref field to an unsigne
      integer.
      
      Fixes: 3b1a94c8 ("dm zoned: drive-managed zoned block device target")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      229cbc61
    • Wenwen Wang's avatar
      dm ioctl: harden copy_params()'s copy_from_user() from malicious users · a0a46290
      Wenwen Wang authored
      commit 800a7340 upstream.
      
      In copy_params(), the struct 'dm_ioctl' is first copied from the user
      space buffer 'user' to 'param_kernel' and the field 'data_size' is
      checked against 'minimum_data_size' (size of 'struct dm_ioctl' payload
      up to its 'data' member).  If the check fails, an error code EINVAL will be
      returned.  Otherwise, param_kernel->data_size is used to do a second copy,
      which copies from the same user-space buffer to 'dmi'.  After the second
      copy, only 'dmi->data_size' is checked against 'param_kernel->data_size'.
      Given that the buffer 'user' resides in the user space, a malicious
      user-space process can race to change the content in the buffer between
      the two copies.  This way, the attacker can inject inconsistent data
      into 'dmi' (versus previously validated 'param_kernel').
      
      Fix redundant copying of 'minimum_data_size' from user-space buffer by
      using the first copy stored in 'param_kernel'.  Also remove the
      'data_size' check after the second copy because it is now unnecessary.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWenwen Wang <wang6495@umn.edu>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a0a46290
    • Amir Goldstein's avatar
      lockd: fix access beyond unterminated strings in prints · a45ce0e1
      Amir Goldstein authored
      commit 93f38b6f upstream.
      
      printk format used %*s instead of %.*s, so hostname_len does not limit
      the number of bytes accessed from hostname.
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a45ce0e1
    • Trond Myklebust's avatar
      nfsd: Fix an Oops in free_session() · eecd97e1
      Trond Myklebust authored
      commit bb6ad557 upstream.
      
      In call_xpt_users(), we delete the entry from the list, but we
      do not reinitialise it. This triggers the list poisoning when
      we later call unregister_xpt_user() in nfsd4_del_conns().
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eecd97e1
    • Benjamin Coddington's avatar
      nfs: Fix a missed page unlock after pg_doio() · eecbf2c2
      Benjamin Coddington authored
      commit fdbd1a2e upstream.
      
      We must check pg_error and call error_cleanup after any call to pg_doio.
      Currently, we are skipping the unlock of a page if we encounter an error in
      nfs_pageio_complete() before handing off the work to the RPC layer.
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eecbf2c2
    • Trond Myklebust's avatar
      NFSv4.1: Fix the r/wsize checking · 1796b389
      Trond Myklebust authored
      commit 943cff67 upstream.
      
      The intention of nfs4_session_set_rwsize() was to cap the r/wsize to the
      buffer sizes negotiated by the CREATE_SESSION. The initial code had a
      bug whereby we would not check the values negotiated by nfs_probe_fsinfo()
      (the assumption being that CREATE_SESSION will always negotiate buffer values
      that are sane w.r.t. the server's preferred r/wsizes) but would only check
      values set by the user in the 'mount' command.
      
      The code was changed in 4.11 to _always_ set the r/wsize, meaning that we
      now never use the server preferred r/wsizes. This is the regression that
      this patch fixes.
      Also rename the function to nfs4_session_limit_rwsize() in order to avoid
      future confusion.
      
      Fixes: 03385332 (NFSv4.1 respect server's max size in CREATE_SESSION")
      Cc: stable@vger.kernel.org # v4.11+
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1796b389
    • Lukas Wunner's avatar
      genirq: Fix race on spurious interrupt detection · e6b8a4d7
      Lukas Wunner authored
      commit 746a923b upstream.
      
      Commit 1e77d0a1 ("genirq: Sanitize spurious interrupt detection of
      threaded irqs") made detection of spurious interrupts work for threaded
      handlers by:
      
      a) incrementing a counter every time the thread returns IRQ_HANDLED, and
      b) checking whether that counter has increased every time the thread is
         woken.
      
      However for oneshot interrupts, the commit unmasks the interrupt before
      incrementing the counter.  If another interrupt occurs right after
      unmasking but before the counter is incremented, that interrupt is
      incorrectly considered spurious:
      
      time
       |  irq_thread()
       |    irq_thread_fn()
       |      action->thread_fn()
       |      irq_finalize_oneshot()
       |        unmask_threaded_irq()            /* interrupt is unmasked */
       |
       |                  /* interrupt fires, incorrectly deemed spurious */
       |
       |    atomic_inc(&desc->threads_handled); /* counter is incremented */
       v
      
      This is observed with a hi3110 CAN controller receiving data at high volume
      (from a separate machine sending with "cangen -g 0 -i -x"): The controller
      signals a huge number of interrupts (hundreds of millions per day) and
      every second there are about a dozen which are deemed spurious.
      
      In theory with high CPU load and the presence of higher priority tasks, the
      number of incorrectly detected spurious interrupts might increase beyond
      the 99,900 threshold and cause disablement of the interrupt.
      
      In practice it just increments the spurious interrupt count. But that can
      cause people to waste time investigating it over and over.
      
      Fix it by moving the accounting before the invocation of
      irq_finalize_oneshot().
      
      [ tglx: Folded change log update ]
      
      Fixes: 1e77d0a1 ("genirq: Sanitize spurious interrupt detection of threaded irqs")
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Mathias Duckeck <m.duckeck@kunbus.de>
      Cc: Akshay Bhat <akshay.bhat@timesys.com>
      Cc: Casey Fitzpatrick <casey.fitzpatrick@timesys.com>
      Cc: stable@vger.kernel.org # v3.16+
      Link: https://lkml.kernel.org/r/1dfd8bbd16163940648045495e3e9698e63b50ad.1539867047.git.lukas@wunner.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e6b8a4d7
    • He Zhe's avatar
      printk: Fix panic caused by passing log_buf_len to command line · cc4dcea8
      He Zhe authored
      commit 277fcdb2 upstream.
      
      log_buf_len_setup does not check input argument before passing it to
      simple_strtoull. The argument would be a NULL pointer if "log_buf_len",
      without its value, is set in command line and thus causes the following
      panic.
      
      PANIC: early exception 0xe3 IP 10:ffffffffaaeacd0d error 0 cr2 0x0
      [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1
      [    0.000000] RIP: 0010:_parse_integer_fixup_radix+0xd/0x70
      ...
      [    0.000000] Call Trace:
      [    0.000000]  simple_strtoull+0x29/0x70
      [    0.000000]  memparse+0x26/0x90
      [    0.000000]  log_buf_len_setup+0x17/0x22
      [    0.000000]  do_early_param+0x57/0x8e
      [    0.000000]  parse_args+0x208/0x320
      [    0.000000]  ? rdinit_setup+0x30/0x30
      [    0.000000]  parse_early_options+0x29/0x2d
      [    0.000000]  ? rdinit_setup+0x30/0x30
      [    0.000000]  parse_early_param+0x36/0x4d
      [    0.000000]  setup_arch+0x336/0x99e
      [    0.000000]  start_kernel+0x6f/0x4ee
      [    0.000000]  x86_64_start_reservations+0x24/0x26
      [    0.000000]  x86_64_start_kernel+0x6f/0x72
      [    0.000000]  secondary_startup_64+0xa4/0xb0
      
      This patch adds a check to prevent the panic.
      
      Link: http://lkml.kernel.org/r/1538239553-81805-1-git-send-email-zhe.he@windriver.com
      Cc: stable@vger.kernel.org
      Cc: rostedt@goodmis.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarHe Zhe <zhe.he@windriver.com>
      Reviewed-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cc4dcea8
    • Steve French's avatar
      smb3: on kerberos mount if server doesn't specify auth type use krb5 · e629461b
      Steve French authored
      commit 926674de upstream.
      
      Some servers (e.g. Azure) do not include a spnego blob in the SMB3
      negotiate protocol response, so on kerberos mounts ("sec=krb5")
      we can fail, as we expected the server to list its supported
      auth types (OIDs in the spnego blob in the negprot response).
      Change this so that on krb5 mounts we default to trying krb5 if the
      server doesn't list its supported protocol mechanisms.
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e629461b
    • Steve French's avatar
      smb3: do not attempt cifs operation in smb3 query info error path · 122f2bd8
      Steve French authored
      commit 1e77a8c2 upstream.
      
      If backupuid mount option is sent, we can incorrectly retry
      (on access denied on query info) with a cifs (FindFirst) operation
      on an smb3 mount which causes the server to force the session close.
      
      We set backup intent on open so no need for this fallback.
      
      See kernel bugzilla 201435
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      122f2bd8
    • Steve French's avatar
      smb3: allow stats which track session and share reconnects to be reset · 54341b9f
      Steve French authored
      commit 2c887635 upstream.
      
      Currently, "echo 0 > /proc/fs/cifs/Stats" resets all of the stats
      except the session and share reconnect counts.  Fix it to
      reset those as well.
      
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      54341b9f
    • Andreas Kemnade's avatar
      w1: omap-hdq: fix missing bus unregister at removal · 6838bb61
      Andreas Kemnade authored
      commit a0077346 upstream.
      
      The bus master was not removed after unloading the module
      or unbinding the driver. That lead to oopses like this
      
      [  127.842987] Unable to handle kernel paging request at virtual address bf01d04c
      [  127.850646] pgd = 70e3cd9a
      [  127.853698] [bf01d04c] *pgd=8f908811, *pte=00000000, *ppte=00000000
      [  127.860412] Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM
      [  127.866668] Modules linked in: bq27xxx_battery overlay [last unloaded: omap_hdq]
      [  127.874542] CPU: 0 PID: 1022 Comm: w1_bus_master1 Not tainted 4.19.0-rc4-00001-g2d51da718324 #12
      [  127.883819] Hardware name: Generic OMAP36xx (Flattened Device Tree)
      [  127.890441] PC is at 0xbf01d04c
      [  127.893798] LR is at w1_search_process_cb+0x4c/0xfc
      [  127.898956] pc : [<bf01d04c>]    lr : [<c05f9580>]    psr: a0070013
      [  127.905609] sp : cf885f48  ip : bf01d04c  fp : ddf1e11c
      [  127.911132] r10: cf8fe040  r9 : c05f8d00  r8 : cf8fe040
      [  127.916656] r7 : 000000f0  r6 : cf8fe02c  r5 : cf8fe000  r4 : cf8fe01c
      [  127.923553] r3 : c05f8d00  r2 : 000000f0  r1 : cf8fe000  r0 : dde1ef10
      [  127.930450] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
      [  127.938018] Control: 10c5387d  Table: 8f8f0019  DAC: 00000051
      [  127.944091] Process w1_bus_master1 (pid: 1022, stack limit = 0x9135699f)
      [  127.951171] Stack: (0xcf885f48 to 0xcf886000)
      [  127.955810] 5f40:                   cf8fe000 00000000 cf884000 cf8fe090 000003e8 c05f8d00
      [  127.964477] 5f60: dde5fc34 c05f9700 ddf1e100 ddf1e540 cf884000 cf8fe000 c05f9694 00000000
      [  127.973114] 5f80: dde5fc34 c01499a4 00000000 ddf1e540 c0149874 00000000 00000000 00000000
      [  127.981781] 5fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000
      [  127.990447] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      [  127.999114] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
      [  128.007781] [<c05f9580>] (w1_search_process_cb) from [<c05f9700>] (w1_process+0x6c/0x118)
      [  128.016479] [<c05f9700>] (w1_process) from [<c01499a4>] (kthread+0x130/0x148)
      [  128.024047] [<c01499a4>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
      [  128.031677] Exception stack(0xcf885fb0 to 0xcf885ff8)
      [  128.037017] 5fa0:                                     00000000 00000000 00000000 00000000
      [  128.045684] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      [  128.054351] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
      [  128.061340] Code: bad PC value
      [  128.064697] ---[ end trace af066e33c0e14119 ]---
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndreas Kemnade <andreas@kemnade.info>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6838bb61
    • Eugen Hristev's avatar
      iio: adc: at91: fix wrong channel number in triggered buffer mode · 28a1aaed
      Eugen Hristev authored
      commit aea835f2 upstream.
      
      When channels are registered, the hardware channel number is not the
      actual iio channel number.
      This is because the driver is probed with a certain number of accessible
      channels. Some pins are routed and some not, depending on the description of
      the board in the DT.
      Because of that, channels 0,1,2,3 can correspond to hardware channels
      2,3,4,5 for example.
      In the buffered triggered case, we need to do the translation accordingly.
      Fixed the channel number to stop reading the wrong channel.
      
      Fixes: 0e589d5f ("ARM: AT91: IIO: Add AT91 ADC driver.")
      Cc: Maxime Ripard <maxime.ripard@bootlin.com>
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@microchip.com>
      Acked-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28a1aaed
    • Eugen Hristev's avatar
      iio: adc: at91: fix acking DRDY irq on simple conversions · c4ecff9b
      Eugen Hristev authored
      commit bc1b4532 upstream.
      
      When doing simple conversions, the driver did not acknowledge the DRDY irq.
      If this irq status is not acked, it will be left pending, and as soon as a
      trigger is enabled, the irq handler will be called, it doesn't know why
      this status has occurred because no channel is pending, and then it will go
      int a irq loop and board will hang.
      To avoid this situation, read the LCDR after a raw conversion is done.
      
      Fixes: 0e589d5f ("ARM: AT91: IIO: Add AT91 ADC driver.")
      Cc: Maxime Ripard <maxime.ripard@bootlin.com>
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@microchip.com>
      Acked-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4ecff9b
    • Alexey Khoroshilov's avatar
      iio: adc: imx25-gcq: Fix leak of device_node in mx25_gcq_setup_cfgs() · 39b6d86b
      Alexey Khoroshilov authored
      commit d3fa21c7 upstream.
      
      Leaving for_each_child_of_node loop we should release child device node,
      if it is not stored for future use.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      
      JC: I'm not sending this as a quick fix as it's been wrong for years,
      but good to pick up for stable after the merge window.
      Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Fixes: 6df2e98c ("iio: adc: Add imx25-gcq ADC driver")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39b6d86b
    • Lars-Peter Clausen's avatar
      iio: ad5064: Fix regulator handling · 8b38d82b
      Lars-Peter Clausen authored
      commit 8911a43b upstream.
      
      The correct way to handle errors returned by regualtor_get() and friends is
      to propagate the error since that means that an regulator was specified,
      but something went wrong when requesting it.
      
      For handling optional regulators, e.g. when the device has an internal
      vref, regulator_get_optional() should be used to avoid getting the dummy
      regulator that the regulator core otherwise provides.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b38d82b
    • Arnd Bergmann's avatar
      kbuild: fix kernel/bounds.c 'W=1' warning · d6ea9f30
      Arnd Bergmann authored
      commit 6a32c246 upstream.
      
      Building any configuration with 'make W=1' produces a warning:
      
      kernel/bounds.c:16:6: warning: no previous prototype for 'foo' [-Wmissing-prototypes]
      
      When also passing -Werror, this prevents us from building any other files.
      Nobody ever calls the function, but we can't make it 'static' either
      since we want the compiler output.
      
      Calling it 'main' instead however avoids the warning, because gcc
      does not insist on having a declaration for main.
      
      Link: http://lkml.kernel.org/r/20181005083313.2088252-1-arnd@arndb.deSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reported-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d6ea9f30
    • Mark Rutland's avatar
      KVM: arm64: Fix caching of host MDCR_EL2 value · f1df7654
      Mark Rutland authored
      commit da5a3ce6 upstream.
      
      At boot time, KVM stashes the host MDCR_EL2 value, but only does this
      when the kernel is not running in hyp mode (i.e. is non-VHE). In these
      cases, the stashed value of MDCR_EL2.HPMN happens to be zero, which can
      lead to CONSTRAINED UNPREDICTABLE behaviour.
      
      Since we use this value to derive the MDCR_EL2 value when switching
      to/from a guest, after a guest have been run, the performance counters
      do not behave as expected. This has been observed to result in accesses
      via PMXEVTYPER_EL0 and PMXEVCNTR_EL0 not affecting the relevant
      counters, resulting in events not being counted. In these cases, only
      the fixed-purpose cycle counter appears to work as expected.
      
      Fix this by always stashing the host MDCR_EL2 value, regardless of VHE.
      
      Cc: Christopher Dall <christoffer.dall@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: stable@vger.kernel.org
      Fixes: 1e947bad ("arm64: KVM: Skip HYP setup when already running in HYP")
      Tested-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1df7654
    • Ralph Campbell's avatar
      mm/rmap: map_pte() was not handling private ZONE_DEVICE page properly · 9d3cc761
      Ralph Campbell authored
      commit aab8d052 upstream.
      
      Private ZONE_DEVICE pages use a special pte entry and thus are not
      present.  Properly handle this case in map_pte(), it is already handled in
      check_pte(), the map_pte() part was lost in some rebase most probably.
      
      Without this patch the slow migration path can not migrate back to any
      private ZONE_DEVICE memory to regular memory.  This was found after stress
      testing migration back to system memory.  This ultimatly can lead to the
      CPU constantly page fault looping on the special swap entry.
      
      Link: http://lkml.kernel.org/r/20181019160442.18723-3-jglisse@redhat.comSigned-off-by: default avatarRalph Campbell <rcampbell@nvidia.com>
      Signed-off-by: default avatarJérôme Glisse <jglisse@redhat.com>
      Reviewed-by: default avatarBalbir Singh <bsingharora@gmail.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9d3cc761
    • Mike Kravetz's avatar
      hugetlbfs: dirty pages as they are added to pagecache · d197121a
      Mike Kravetz authored
      commit 22146c3c upstream.
      
      Some test systems were experiencing negative huge page reserve counts and
      incorrect file block counts.  This was traced to /proc/sys/vm/drop_caches
      removing clean pages from hugetlbfs file pagecaches.  When non-hugetlbfs
      explicit code removes the pages, the appropriate accounting is not
      performed.
      
      This can be recreated as follows:
       fallocate -l 2M /dev/hugepages/foo
       echo 1 > /proc/sys/vm/drop_caches
       fallocate -l 2M /dev/hugepages/foo
       grep -i huge /proc/meminfo
         AnonHugePages:         0 kB
         ShmemHugePages:        0 kB
         HugePages_Total:    2048
         HugePages_Free:     2047
         HugePages_Rsvd:    18446744073709551615
         HugePages_Surp:        0
         Hugepagesize:       2048 kB
         Hugetlb:         4194304 kB
       ls -lsh /dev/hugepages/foo
         4.0M -rw-r--r--. 1 root root 2.0M Oct 17 20:05 /dev/hugepages/foo
      
      To address this issue, dirty pages as they are added to pagecache.  This
      can easily be reproduced with fallocate as shown above.  Read faulted
      pages will eventually end up being marked dirty.  But there is a window
      where they are clean and could be impacted by code such as drop_caches.
      So, just dirty them all as they are added to the pagecache.
      
      Link: http://lkml.kernel.org/r/b5be45b8-5afe-56cd-9482-28384699a049@oracle.com
      Fixes: 6bda666a ("hugepages: fold find_or_alloc_pages into huge_no_page()")
      Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Acked-by: default avatarMihcla Hocko <mhocko@suse.com>
      Reviewed-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d197121a
    • Eric Biggers's avatar
      ima: fix showing large 'violations' or 'runtime_measurements_count' · 4c6fda12
      Eric Biggers authored
      commit 1e4c8daf upstream.
      
      The 12 character temporary buffer is not necessarily long enough to hold
      a 'long' value.  Increase it.
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c6fda12
    • Vlastimil Babka's avatar
      mm: /proc/pid/smaps_rollup: fix NULL pointer deref in smaps_pte_range() · 0c5e357f
      Vlastimil Babka authored
      commit fa76da46 upstream.
      
      Leonardo reports an apparent regression in 4.19-rc7:
      
       BUG: unable to handle kernel NULL pointer dereference at 00000000000000f0
       PGD 0 P4D 0
       Oops: 0000 [#1] PREEMPT SMP PTI
       CPU: 3 PID: 6032 Comm: python Not tainted 4.19.0-041900rc7-lowlatency #201810071631
       Hardware name: LENOVO 80UG/Toronto 4A2, BIOS 0XCN45WW 08/09/2018
       RIP: 0010:smaps_pte_range+0x32d/0x540
       Code: 80 00 00 00 00 74 a9 48 89 de 41 f6 40 52 40 0f 85 04 02 00 00 49 2b 30 48 c1 ee 0c 49 03 b0 98 00 00 00 49 8b 80 a0 00 00 00 <48> 8b b8 f0 00 00 00 e8 b7 ef ec ff 48 85 c0 0f 84 71 ff ff ff a8
       RSP: 0018:ffffb0cbc484fb88 EFLAGS: 00010202
       RAX: 0000000000000000 RBX: 0000560ddb9e9000 RCX: 0000000000000000
       RDX: 0000000000000000 RSI: 0000000560ddb9e9 RDI: 0000000000000001
       RBP: ffffb0cbc484fbc0 R08: ffff94a5a227a578 R09: ffff94a5a227a578
       R10: 0000000000000000 R11: 0000560ddbbe7000 R12: ffffe903098ba728
       R13: ffffb0cbc484fc78 R14: ffffb0cbc484fcf8 R15: ffff94a5a2e9cf48
       FS:  00007f6dfb683740(0000) GS:ffff94a5aaf80000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00000000000000f0 CR3: 000000011c118001 CR4: 00000000003606e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
       Call Trace:
        __walk_page_range+0x3c2/0x6f0
        walk_page_vma+0x42/0x60
        smap_gather_stats+0x79/0xe0
        ? gather_pte_stats+0x320/0x320
        ? gather_hugetlb_stats+0x70/0x70
        show_smaps_rollup+0xcd/0x1c0
        seq_read+0x157/0x400
        __vfs_read+0x3a/0x180
        ? security_file_permission+0x93/0xc0
        ? security_file_permission+0x93/0xc0
        vfs_read+0x8f/0x140
        ksys_read+0x55/0xc0
        __x64_sys_read+0x1a/0x20
        do_syscall_64+0x5a/0x110
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Decoded code matched to local compilation+disassembly points to
      smaps_pte_entry():
      
              } else if (unlikely(IS_ENABLED(CONFIG_SHMEM) && mss->check_shmem_swap
                                                              && pte_none(*pte))) {
                      page = find_get_entry(vma->vm_file->f_mapping,
                                                      linear_page_index(vma, addr));
      
      Here, vma->vm_file is NULL.  mss->check_shmem_swap should be false in that
      case, however for smaps_rollup, smap_gather_stats() can set the flag true
      for one vma and leave it true for subsequent vma's where it should be
      false.
      
      To fix, reset the check_shmem_swap flag to false.  There's also related
      bug which sets mss->swap to shmem_swapped, which in the context of
      smaps_rollup overwrites any value accumulated from previous vma's.  Fix
      that as well.
      
      Note that the report suggests a regression between 4.17.19 and 4.19-rc7,
      which makes the 4.19 series ending with commit 258f669e ("mm:
      /proc/pid/smaps_rollup: convert to single value seq_file") suspicious.
      But the mss was reused for rollup since 493b0e9d ("mm: add
      /proc/pid/smaps_rollup") so let's play it safe with the stable backport.
      
      Link: http://lkml.kernel.org/r/555fbd1f-4ac9-0b58-dcd4-5dc4380ff7ca@suse.cz
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=201377
      Fixes: 493b0e9d ("mm: add /proc/pid/smaps_rollup")
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reported-by: default avatarLeonardo Soares Müller <leozinho29_eu@hotmail.com>
      Tested-by: default avatarLeonardo Soares Müller <leozinho29_eu@hotmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Daniel Colascione <dancol@google.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c5e357f
    • Horia Geantă's avatar
      crypto: tcrypt - fix ghash-generic speed test · 0c8496c5
      Horia Geantă authored
      commit 331351f8 upstream.
      
      ghash is a keyed hash algorithm, thus setkey needs to be called.
      Otherwise the following error occurs:
      $ modprobe tcrypt mode=318 sec=1
      testing speed of async ghash-generic (ghash-generic)
      tcrypt: test  0 (   16 byte blocks,   16 bytes per update,   1 updates):
      tcrypt: hashing failed ret=-126
      
      Cc: <stable@vger.kernel.org> # 4.6+
      Fixes: 0660511c ("crypto: tcrypt - Use ahash")
      Tested-by: default avatarFranck Lenormand <franck.lenormand@nxp.com>
      Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
      Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c8496c5
    • Ondrej Mosnacek's avatar
      crypto: lrw - Fix out-of bounds access on counter overflow · e86f4842
      Ondrej Mosnacek authored
      commit fbe1a850 upstream.
      
      When the LRW block counter overflows, the current implementation returns
      128 as the index to the precomputed multiplication table, which has 128
      entries. This patch fixes it to return the correct value (127).
      
      Fixes: 64470f1b ("[CRYPTO] lrw: Liskov Rivest Wagner, a tweakable narrow block cipher mode")
      Cc: <stable@vger.kernel.org> # 2.6.20+
      Reported-by: default avatarEric Biggers <ebiggers@kernel.org>
      Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e86f4842
    • Eric W. Biederman's avatar
      signal: Guard against negative signal numbers in copy_siginfo_from_user32 · 51f62e82
      Eric W. Biederman authored
      commit a3670058 upstream.
      
      While fixing an out of bounds array access in known_siginfo_layout
      reported by the kernel test robot it became apparent that the same bug
      exists in siginfo_layout and affects copy_siginfo_from_user32.
      
      The straight forward fix that makes guards against making this mistake
      in the future and should keep the code size small is to just take an
      unsigned signal number instead of a signed signal number, as I did to
      fix known_siginfo_layout.
      
      Cc: stable@vger.kernel.org
      Fixes: cc731525 ("signal: Remove kernel interal si_code magic")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51f62e82
    • Eric W. Biederman's avatar
      signal/GenWQE: Fix sending of SIGKILL · eb7f3c51
      Eric W. Biederman authored
      commit 0ab93e9c upstream.
      
      The genweq_add_file and genwqe_del_file by caching current without
      using reference counting embed the assumption that a file descriptor
      will never be passed from one process to another.  It even embeds the
      assumption that the the thread that opened the file will be in
      existence when the process terminates.   Neither of which are
      guaranteed to be true.
      
      Therefore replace caching the task_struct of the opener with
      pid of the openers thread group id.  All the knowledge of the
      opener is used for is as the target of SIGKILL and a SIGKILL
      will kill the entire process group.
      
      Rename genwqe_force_sig to genwqe_terminate, remove it's unncessary
      signal argument, update it's ownly caller, and use kill_pid
      instead of force_sig.
      
      The work force_sig does in changing signal handling state is not
      relevant to SIGKILL sent as SEND_SIG_PRIV.  The exact same processess
      will be killed just with less work, and less confusion.  The work done
      by force_sig is really only needed for handling syncrhonous
      exceptions.
      
      It will still be possible to cause genwqe_device_remove to wait
      8 seconds by passing a file descriptor to another process but
      the possible user after free is fixed.
      
      Fixes: eaf4722d ("GenWQE Character device and DDCB queue")
      Cc: stable@vger.kernel.org
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Frank Haverkamp <haver@linux.vnet.ibm.com>
      Cc: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
      Cc: Michael Jung <mijung@gmx.net>
      Cc: Michael Ruettger <michael@ibmra.de>
      Cc: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
      Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
      Cc: Eberhard S. Amann <esa@linux.vnet.ibm.com>
      Cc: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
      Cc: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eb7f3c51
    • Keith Busch's avatar
      PCI: vmd: White list for fast interrupt handlers · 635c8c9c
      Keith Busch authored
      commit a7f58b9e upstream.
      
      Devices with slow interrupt handlers are significantly harming
      performance when their interrupt vector is shared with a fast device.
      
      Create a class code white list for devices with known fast interrupt
      handlers and let all other devices share a single vector so that they
      don't interfere with performance.
      
      At the moment, only the NVM Express class code is on the list, but more
      may be added if VMD users desire to use other low-latency devices in
      these domains.
      Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
      [lorenzo.pieralisi@arm.com: changelog]
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarJon Derrick: <jonathan.derrick@intel.com>
      Cc: "Heitke, Kenneth" <kenneth.heitke@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      635c8c9c
    • Bin Meng's avatar
      PCI: Add Device IDs for Intel GPU "spurious interrupt" quirk · 2b216de5
      Bin Meng authored
      commit d0c9606b upstream.
      
      Add Device IDs to the Intel GPU "spurious interrupt" quirk table.
      
      For these devices, unplugging the VGA cable and plugging it in again causes
      spurious interrupts from the IGD.  Linux eventually disables the interrupt,
      but of course that disables any other devices sharing the interrupt.
      
      The theory is that this is a VGA BIOS defect: it should have disabled the
      IGD interrupt but failed to do so.
      
      See f67fd55f ("PCI: Add quirk for still enabled interrupts on Intel
      Sandy Bridge GPUs") and 7c82126a ("PCI: Add new ID for Intel GPU
      "spurious interrupt" quirk") for some history.
      
      [bhelgaas: See link below for discussion about how to fix this more
      generically instead of adding device IDs for every new Intel GPU.  I hope
      this is the last patch to add device IDs.]
      
      Link: https://lore.kernel.org/linux-pci/1537974841-29928-1-git-send-email-bmeng.cn@gmail.comSigned-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      [bhelgaas: changelog]
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org	# v3.4+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b216de5