1. 19 Mar, 2018 16 commits
  2. 03 Mar, 2018 24 commits
    • Ben Hutchings's avatar
      Linux 3.16.55 · 3e50cd97
      Ben Hutchings authored
      3e50cd97
    • James Hogan's avatar
      MIPS: CPS: Fix MIPS_ISA_LEVEL_RAW fallout · 96455112
      James Hogan authored
      commit 8dbc1864 upstream.
      
      Commit 17278a91
      
       ("MIPS: CPS: Fix r1 .set mt assembler warning")
      added .set MIPS_ISA_LEVEL_RAW to silence warnings about .set mt on r1,
      however this can result in a MOVE being encoded as a 64-bit DADDU
      instruction on certain version of binutils (e.g. 2.22), and reserved
      instruction exceptions at runtime on 32-bit hardware.
      
      Reduce the sizes of the push/pop sections to include only instructions
      that are part of the MT ASE or which won't convert to 64-bit
      instructions after .set mips64r2/mips64r6.
      Reported-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
      Fixes: 17278a91
      
       ("MIPS: CPS: Fix r1 .set mt assembler warning")
      Signed-off-by: default avatarJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: linux-mips@linux-mips.org
      Tested-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
      Patchwork: https://patchwork.linux-mips.org/patch/18578/
      
      
      [bwh: Backported to 3.16: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      96455112
    • Yang Shunyong's avatar
      dmaengine: dmatest: fix container_of member in dmatest_callback · b11db6ef
      Yang Shunyong authored
      commit 66b3bd23 upstream.
      
      The type of arg passed to dmatest_callback is struct dmatest_done.
      It refers to test_done in struct dmatest_thread, not done_wait.
      
      Fixes: 6f6a23a2
      
       ("dmaengine: dmatest: move callback wait ...")
      Signed-off-by: default avatarYang Shunyong <shunyong.yang@hxt-semitech.com>
      Acked-by: default avatarAdam Wallis <awallis@codeaurora.org>
      Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      b11db6ef
    • Håkon Bugge's avatar
      rds: Fix NULL pointer dereference in __rds_rdma_map · 39961200
      Håkon Bugge authored
      commit f3069c6d
      
       upstream.
      
      This is a fix for syzkaller719569, where memory registration was
      attempted without any underlying transport being loaded.
      
      Analysis of the case reveals that it is the setsockopt() RDS_GET_MR
      (2) and RDS_GET_MR_FOR_DEST (7) that are vulnerable.
      
      Here is an example stack trace when the bug is hit:
      
      BUG: unable to handle kernel NULL pointer dereference at 00000000000000c0
      IP: __rds_rdma_map+0x36/0x440 [rds]
      PGD 2f93d03067 P4D 2f93d03067 PUD 2f93d02067 PMD 0
      Oops: 0000 [#1] SMP
      Modules linked in: bridge stp llc tun rpcsec_gss_krb5 nfsv4
      dns_resolver nfs fscache rds binfmt_misc sb_edac intel_powerclamp
      coretemp kvm_intel kvm irqbypass crct10dif_pclmul c rc32_pclmul
      ghash_clmulni_intel pcbc aesni_intel crypto_simd glue_helper cryptd
      iTCO_wdt mei_me sg iTCO_vendor_support ipmi_si mei ipmi_devintf nfsd
      shpchp pcspkr i2c_i801 ioatd ma ipmi_msghandler wmi lpc_ich mfd_core
      auth_rpcgss nfs_acl lockd grace sunrpc ip_tables ext4 mbcache jbd2
      mgag200 i2c_algo_bit drm_kms_helper ixgbe syscopyarea ahci sysfillrect
      sysimgblt libahci mdio fb_sys_fops ttm ptp libata sd_mod mlx4_core drm
      crc32c_intel pps_core megaraid_sas i2c_core dca dm_mirror
      dm_region_hash dm_log dm_mod
      CPU: 48 PID: 45787 Comm: repro_set2 Not tainted 4.14.2-3.el7uek.x86_64 #2
      Hardware name: Oracle Corporation ORACLE SERVER X5-2L/ASM,MOBO TRAY,2U, BIOS 31110000 03/03/2017
      task: ffff882f9190db00 task.stack: ffffc9002b994000
      RIP: 0010:__rds_rdma_map+0x36/0x440 [rds]
      RSP: 0018:ffffc9002b997df0 EFLAGS: 00010202
      RAX: 0000000000000000 RBX: ffff882fa2182580 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: ffffc9002b997e40 RDI: ffff882fa2182580
      RBP: ffffc9002b997e30 R08: 0000000000000000 R09: 0000000000000002
      R10: ffff885fb29e3838 R11: 0000000000000000 R12: ffff882fa2182580
      R13: ffff882fa2182580 R14: 0000000000000002 R15: 0000000020000ffc
      FS:  00007fbffa20b700(0000) GS:ffff882fbfb80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000000000c0 CR3: 0000002f98a66006 CR4: 00000000001606e0
      Call Trace:
       rds_get_mr+0x56/0x80 [rds]
       rds_setsockopt+0x172/0x340 [rds]
       ? __fget_light+0x25/0x60
       ? __fdget+0x13/0x20
       SyS_setsockopt+0x80/0xe0
       do_syscall_64+0x67/0x1b0
       entry_SYSCALL64_slow_path+0x25/0x25
      RIP: 0033:0x7fbff9b117f9
      RSP: 002b:00007fbffa20aed8 EFLAGS: 00000293 ORIG_RAX: 0000000000000036
      RAX: ffffffffffffffda RBX: 00000000000c84a4 RCX: 00007fbff9b117f9
      RDX: 0000000000000002 RSI: 0000400000000114 RDI: 000000000000109b
      RBP: 00007fbffa20af10 R08: 0000000000000020 R09: 00007fbff9dd7860
      R10: 0000000020000ffc R11: 0000000000000293 R12: 0000000000000000
      R13: 00007fbffa20b9c0 R14: 00007fbffa20b700 R15: 0000000000000021
      
      Code: 41 56 41 55 49 89 fd 41 54 53 48 83 ec 18 8b 87 f0 02 00 00 48
      89 55 d0 48 89 4d c8 85 c0 0f 84 2d 03 00 00 48 8b 87 00 03 00 00 <48>
      83 b8 c0 00 00 00 00 0f 84 25 03 00 0 0 48 8b 06 48 8b 56 08
      
      The fix is to check the existence of an underlying transport in
      __rds_rdma_map().
      Signed-off-by: default avatarHåkon Bugge <haakon.bugge@oracle.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      39961200
    • Greg Kroah-Hartman's avatar
      ACPI: sbshc: remove raw pointer from printk() message · 0c257563
      Greg Kroah-Hartman authored
      commit 43cdd1b7
      
       upstream.
      
      There's no need to be printing a raw kernel pointer to the kernel log at
      every boot.  So just remove it, and change the whole message to use the
      correct dev_info() call at the same time.
      Reported-by: default avatarWang Qize <wang_qize@venustech.com.cn>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      0c257563
    • Daniel Mentz's avatar
      media: v4l2-compat-ioctl32.c: refactor compat ioctl32 logic · a0b6b578
      Daniel Mentz authored
      commit a1dfb4c4 upstream.
      
      The 32-bit compat v4l2 ioctl handling is implemented based on its 64-bit
      equivalent. It converts 32-bit data structures into its 64-bit
      equivalents and needs to provide the data to the 64-bit ioctl in user
      space memory which is commonly allocated using
      compat_alloc_user_space().
      
      However, due to how that function is implemented, it can only be called
      a single time for every syscall invocation.
      
      Supposedly to avoid this limitation, the existing code uses a mix of
      memory from the kernel stack and memory allocated through
      compat_alloc_user_space().
      
      Under normal circumstances, this would not work, because the 64-bit
      ioctl expects all pointers to point to user space memory. As a
      workaround, set_fs(KERNEL_DS) is called to temporarily disable this
      extra safety check and allow kernel pointers. However, this might
      introduce a security vulnerability: The result of the 32-bit to 64-bit
      conversion is writeable by user space because the output buffer has been
      allocated via compat_alloc_user_space(). A malicious user space process
      could then manipulate pointers inside this output buffer, and due to the
      previous set_fs(KERNEL_DS) call, functions like get_user() or put_user()
      no longer prevent kernel memory access.
      
      The new approach is to pre-calculate the total amount of user space
      memory that is needed, allocate it using compat_alloc_user_space() and
      then divide up the allocated memory to accommodate all data structures
      that need to be converted.
      
      An alternative approach would have been to retain the union type karg
      that they allocated on the kernel stack in do_video_ioctl(), copy all
      data from user space into karg and then back to user space. However, we
      decided against this approach because it does not align with other
      compat syscall implementations. Instead, we tried to replicate the
      get_user/put_user pairs as found in other places in the kernel:
      
          if (get_user(clipcount, &up->clipcount) ||
              put_user(clipcount, &kp->clipcount)) return -EFAULT;
      
      Notes from hans.verkuil@cisco.com:
      
      This patch was taken from:
          https://github.com/LineageOS/android_kernel_samsung_apq8084/commit/97b733953c06e4f0398ade18850f0817778255f7
      
      Clearly nobody could be bothered to upstream this patch or at minimum
      tell us :-( We only heard about this a week ago.
      
      This patch was rebased and cleaned up. Compared to the original I
      also swapped the order of the convert_in_user arguments so that they
      matched copy_in_user. It was hard to review otherwise. I also replaced
      the ALLOC_USER_SPACE/ALLOC_AND_GET by a normal function.
      
      Fixes: 6b5a9492
      
       ("v4l: introduce string control support.")
      Signed-off-by: default avatarDaniel Mentz <danielmentz@google.com>
      Co-developed-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      [bwh: Rebased on top of some earlier fixes]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a0b6b578
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: don't copy back the result for certain errors · 8c04a4f0
      Hans Verkuil authored
      commit d83a8243
      
       upstream.
      
      Some ioctls need to copy back the result even if the ioctl returned
      an error. However, don't do this for the error code -ENOTTY.
      It makes no sense in that cases.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      8c04a4f0
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: drop pr_info for unknown buffer type · 3b764d65
      Hans Verkuil authored
      commit 169f24ca
      
       upstream.
      
      There is nothing wrong with using an unknown buffer type. So
      stop spamming the kernel log whenever this happens. The kernel
      will just return -EINVAL to signal this.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3b764d65
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: copy clip list in put_v4l2_window32 · e05a2d30
      Hans Verkuil authored
      commit a751be5b
      
       upstream.
      
      put_v4l2_window32() didn't copy back the clip list to userspace.
      Drivers can update the clip rectangles, so this should be done.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e05a2d30
    • Daniel Mentz's avatar
      media: v4l2-compat-ioctl32: Copy v4l2_window->global_alpha · 79bd1439
      Daniel Mentz authored
      commit 025a26fa upstream.
      
      Commit b2787845
      
       ("V4L/DVB (5289): Add support for video output
      overlays.") added the field global_alpha to struct v4l2_window but did
      not update the compat layer accordingly. This change adds global_alpha
      to struct v4l2_window32 and copies the value for global_alpha back and
      forth.
      Signed-off-by: default avatarDaniel Mentz <danielmentz@google.com>
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      79bd1439
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: fix ctrl_is_pointer · 606ae3b1
      Hans Verkuil authored
      commit b8c601e8
      
       upstream.
      
      ctrl_is_pointer just hardcoded two known string controls, but that
      caused problems when using e.g. custom controls that use a pointer
      for the payload.
      
      Reimplement this function: it now finds the v4l2_ctrl (if the driver
      uses the control framework) or it calls vidioc_query_ext_ctrl (if the
      driver implements that directly).
      
      In both cases it can now check if the control is a pointer control
      or not.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      [bwh: Rebased on top of some earlier fixes]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      606ae3b1
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: copy m.userptr in put_v4l2_plane32 · e8b35041
      Hans Verkuil authored
      commit 8ed5a59d
      
       upstream.
      
      The struct v4l2_plane32 should set m.userptr as well. The same
      happens in v4l2_buffer32 and v4l2-compliance tests for this.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e8b35041
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: avoid sizeof(type) · e601a9a8
      Hans Verkuil authored
      commit 333b1e9f
      
       upstream.
      
      Instead of doing sizeof(struct foo) use sizeof(*up). There even were
      cases where 4 * sizeof(__u32) was used instead of sizeof(kp->reserved),
      which is very dangerous when the size of the reserved array changes.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      [bwh: Rebased on top of some earlier fixes]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e601a9a8
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: move 'helper' functions to __get/put_v4l2_format32 · f64f7bd5
      Hans Verkuil authored
      commit 486c5215
      
       upstream.
      
      These helper functions do not really help. Move the code to the
      __get/put_v4l2_format32 functions.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      [bwh: Rebased on top of some earlier fixes]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f64f7bd5
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: fix the indentation · 846e2145
      Hans Verkuil authored
      commit b7b957d4
      
       upstream.
      
      The indentation of this source is all over the place. Fix this.
      This patch only changes whitespace.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      [bwh: Rebased on top of some earlier fixes]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      846e2145
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: add missing VIDIOC_PREPARE_BUF · 182f3143
      Hans Verkuil authored
      commit 3ee6d040
      
       upstream.
      
      The result of the VIDIOC_PREPARE_BUF ioctl was never copied back
      to userspace since it was missing in the switch.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      182f3143
    • Ricardo Ribalda's avatar
      vb2: V4L2_BUF_FLAG_DONE is set after DQBUF · a1cdbb82
      Ricardo Ribalda authored
      commit 3171cc2b
      
       upstream.
      
      According to the doc, V4L2_BUF_FLAG_DONE is cleared after DQBUF:
      
      V4L2_BUF_FLAG_DONE 0x00000004  ... After calling the VIDIOC_QBUF or
      VIDIOC_DQBUF it is always cleared ...
      
      Unfortunately, it seems that videobuf2 keeps it set after DQBUF. This
      can be tested with vivid and dev_debug:
      
      [257604.338082] video1: VIDIOC_DQBUF: 71:33:25.00260479 index=3,
      type=vid-cap, flags=0x00002004, field=none, sequence=163,
      memory=userptr, bytesused=460800, offset/userptr=0x344b000,
      length=460800
      
      This patch forces FLAG_DONE to 0 after calling DQBUF.
      Reported-by: default avatarDimitrios Katsaros <patcherwork@gmail.com>
      Signed-off-by: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a1cdbb82
    • Hans Verkuil's avatar
      media: v4l2-ioctl.c: don't copy back the result for -ENOTTY · 5e574764
      Hans Verkuil authored
      commit 181a4a2d
      
       upstream.
      
      If the ioctl returned -ENOTTY, then don't bother copying
      back the result as there is no point.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5e574764
    • Hans Verkuil's avatar
      adv7604: use correct drive strength defines · 98dc7e90
      Hans Verkuil authored
      The prefix is ADV7604_, not ADV76XX.
      
      Fixes: f31b62e1
      
       ("adv7604: add hdmi driver strength adjustment")
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      98dc7e90
    • Hans Verkuil's avatar
      media: v4l2-compat-ioctl32.c: add capabilities field to, v4l2_input32 · f9b33d1f
      Hans Verkuil authored
      commit 037e0865
      
       upstream.
      
      The v4l2_input32 struct wasn't updated when this field was added.
      It didn't cause a failure in the compat code, but it is better to
      keep it in sync with v4l2_input to avoid confusion.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f9b33d1f
    • Tiffany Lin's avatar
      media: v4l2-compat-ioctl32: fix missing reserved field copy in put_v4l2_create32 · bd4e8dc0
      Tiffany Lin authored
      commit baf43c6e
      
       upstream.
      
      In v4l2-compliance utility, test VIDIOC_CREATE_BUFS will check whether reserved
      filed of v4l2_create_buffers filled with zero
      Reserved field is filled with zero in v4l_create_bufs.
      This patch copy reserved field of v4l2_create_buffer from kernel space to user
      space
      Signed-off-by: default avatarTiffany Lin <tiffany.lin@mediatek.com>
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      bd4e8dc0
    • Guennadi Liakhovetski's avatar
      V4L2: fix VIDIOC_CREATE_BUFS 32-bit compatibility mode data copy-back · 99d5e1c4
      Guennadi Liakhovetski authored
      commit 6ed9b285
      
       upstream.
      
      Similar to an earlier patch, fixing reading user-space data for the
      VIDIOC_CREATE_BUFS ioctl() in 32-bit compatibility mode, this patch fixes
      writing back of the possibly modified struct to the user. However, unlike
      the former bug, this one is much less harmful, because it only results in
      the kernel failing to write the .type field back to the user, but in fact
      this is likely unneeded, because the kernel will hardly want to change
      that field. Therefore this bug is more of a theoretical nature.
      Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
      Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      99d5e1c4
    • Hans Verkuil's avatar
      v4l2-compat-ioctl32: fix sparse warnings · 64a2bd74
      Hans Verkuil authored
      commit 8ae632b1
      
       upstream.
      
      A lot of these warnings are caused by the fact that we don't generally use
      __user in videodev2.h. Normally the video_usercopy function will copy anything
      pointed to by pointers into kernel space, so having __user in the struct will only
      cause lots of warnings in the drivers. But the flip side of that is that you
      need to add __force casts here.
      
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:337:26: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:337:30: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:338:31: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:338:49: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:343:21: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:346:21: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:349:35: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:349:46: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:352:35: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:352:54: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:363:26: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:363:32: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:364:31: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:364:51: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:371:35: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:371:56: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:376:35: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:376:48: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:430:30: warning: incorrect type in assignment (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:433:48: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:433:56: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:501:24: warning: incorrect type in assignment (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:507:48: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:507:56: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:565:18: warning: incorrect type in assignment (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:670:22: warning: incorrect type in assignment (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:680:29: warning: incorrect type in assignment (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:692:55: warning: incorrect type in initializer (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:773:18: warning: incorrect type in assignment (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:786:30: warning: incorrect type in argument 1 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:786:44: warning: incorrect type in argument 2 (different address spaces)
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:674:37: warning: dereference of noderef expression
      drivers/media/v4l2-core/v4l2-compat-ioctl32.c:718:37: warning: dereference of noderef expression
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
      [bwh: Backported to 3.16: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      64a2bd74
    • Ming Lei's avatar
      blk-mq: fix race between timeout and freeing request · 7acba7c0
      Ming Lei authored
      commit 0048b483
      
       upstream.
      
      Inside timeout handler, blk_mq_tag_to_rq() is called
      to retrieve the request from one tag. This way is obviously
      wrong because the request can be freed any time and some
      fiedds of the request can't be trusted, then kernel oops
      might be triggered[1].
      
      Currently wrt. blk_mq_tag_to_rq(), the only special case is
      that the flush request can share same tag with the request
      cloned from, and the two requests can't be active at the same
      time, so this patch fixes the above issue by updating tags->rqs[tag]
      with the active request(either flush rq or the request cloned
      from) of the tag.
      
      Also blk_mq_tag_to_rq() gets much simplified with this patch.
      
      Given blk_mq_tag_to_rq() is mainly for drivers and the caller must
      make sure the request can't be freed, so in bt_for_each() this
      helper is replaced with tags->rqs[tag].
      
      [1] kernel oops log
      [  439.696220] BUG: unable to handle kernel NULL pointer dereference at 0000000000000158^M
      [  439.697162] IP: [<ffffffff812d89ba>] blk_mq_tag_to_rq+0x21/0x6e^M
      [  439.700653] PGD 7ef765067 PUD 7ef764067 PMD 0 ^M
      [  439.700653] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC ^M
      [  439.700653] Dumping ftrace buffer:^M
      [  439.700653]    (ftrace buffer empty)^M
      [  439.700653] Modules linked in: nbd ipv6 kvm_intel kvm serio_raw^M
      [  439.700653] CPU: 6 PID: 2779 Comm: stress-ng-sigfd Not tainted 4.2.0-rc5-next-20150805+ #265^M
      [  439.730500] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011^M
      [  439.730500] task: ffff880605308000 ti: ffff88060530c000 task.ti: ffff88060530c000^M
      [  439.730500] RIP: 0010:[<ffffffff812d89ba>]  [<ffffffff812d89ba>] blk_mq_tag_to_rq+0x21/0x6e^M
      [  439.730500] RSP: 0018:ffff880819203da0  EFLAGS: 00010283^M
      [  439.730500] RAX: ffff880811b0e000 RBX: ffff8800bb465f00 RCX: 0000000000000002^M
      [  439.730500] RDX: 0000000000000000 RSI: 0000000000000202 RDI: 0000000000000000^M
      [  439.730500] RBP: ffff880819203db0 R08: 0000000000000002 R09: 0000000000000000^M
      [  439.730500] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000202^M
      [  439.730500] R13: ffff880814104800 R14: 0000000000000002 R15: ffff880811a2ea00^M
      [  439.730500] FS:  00007f165b3f5740(0000) GS:ffff880819200000(0000) knlGS:0000000000000000^M
      [  439.730500] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b^M
      [  439.730500] CR2: 0000000000000158 CR3: 00000007ef766000 CR4: 00000000000006e0^M
      [  439.730500] Stack:^M
      [  439.730500]  0000000000000008 ffff8808114eed90 ffff880819203e00 ffffffff812dc104^M
      [  439.755663]  ffff880819203e40 ffffffff812d9f5e 0000020000000000 ffff8808114eed80^M
      [  439.755663] Call Trace:^M
      [  439.755663]  <IRQ> ^M
      [  439.755663]  [<ffffffff812dc104>] bt_for_each+0x6e/0xc8^M
      [  439.755663]  [<ffffffff812d9f5e>] ? blk_mq_rq_timed_out+0x6a/0x6a^M
      [  439.755663]  [<ffffffff812d9f5e>] ? blk_mq_rq_timed_out+0x6a/0x6a^M
      [  439.755663]  [<ffffffff812dc1b3>] blk_mq_tag_busy_iter+0x55/0x5e^M
      [  439.755663]  [<ffffffff812d88b4>] ? blk_mq_bio_to_request+0x38/0x38^M
      [  439.755663]  [<ffffffff812d8911>] blk_mq_rq_timer+0x5d/0xd4^M
      [  439.755663]  [<ffffffff810a3e10>] call_timer_fn+0xf7/0x284^M
      [  439.755663]  [<ffffffff810a3d1e>] ? call_timer_fn+0x5/0x284^M
      [  439.755663]  [<ffffffff812d88b4>] ? blk_mq_bio_to_request+0x38/0x38^M
      [  439.755663]  [<ffffffff810a46d6>] run_timer_softirq+0x1ce/0x1f8^M
      [  439.755663]  [<ffffffff8104c367>] __do_softirq+0x181/0x3a4^M
      [  439.755663]  [<ffffffff8104c76e>] irq_exit+0x40/0x94^M
      [  439.755663]  [<ffffffff81031482>] smp_apic_timer_interrupt+0x33/0x3e^M
      [  439.755663]  [<ffffffff815559a4>] apic_timer_interrupt+0x84/0x90^M
      [  439.755663]  <EOI> ^M
      [  439.755663]  [<ffffffff81554350>] ? _raw_spin_unlock_irq+0x32/0x4a^M
      [  439.755663]  [<ffffffff8106a98b>] finish_task_switch+0xe0/0x163^M
      [  439.755663]  [<ffffffff8106a94d>] ? finish_task_switch+0xa2/0x163^M
      [  439.755663]  [<ffffffff81550066>] __schedule+0x469/0x6cd^M
      [  439.755663]  [<ffffffff8155039b>] schedule+0x82/0x9a^M
      [  439.789267]  [<ffffffff8119b28b>] signalfd_read+0x186/0x49a^M
      [  439.790911]  [<ffffffff8106d86a>] ? wake_up_q+0x47/0x47^M
      [  439.790911]  [<ffffffff811618c2>] __vfs_read+0x28/0x9f^M
      [  439.790911]  [<ffffffff8117a289>] ? __fget_light+0x4d/0x74^M
      [  439.790911]  [<ffffffff811620a7>] vfs_read+0x7a/0xc6^M
      [  439.790911]  [<ffffffff8116292b>] SyS_read+0x49/0x7f^M
      [  439.790911]  [<ffffffff81554c17>] entry_SYSCALL_64_fastpath+0x12/0x6f^M
      [  439.790911] Code: 48 89 e5 e8 a9 b8 e7 ff 5d c3 0f 1f 44 00 00 55 89
      f2 48 89 e5 41 54 41 89 f4 53 48 8b 47 60 48 8b 1c d0 48 8b 7b 30 48 8b
      53 38 <48> 8b 87 58 01 00 00 48 85 c0 75 09 48 8b 97 88 0c 00 00 eb 10
      ^M
      [  439.790911] RIP  [<ffffffff812d89ba>] blk_mq_tag_to_rq+0x21/0x6e^M
      [  439.790911]  RSP <ffff880819203da0>^M
      [  439.790911] CR2: 0000000000000158^M
      [  439.790911] ---[ end trace d40af58949325661 ]---^M
      Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      [bwh: Backported to 3.16:
       - Flush state is in struct request_queue, not struct blk_flush_queue
       - Flush request cloning is done in blk_mq_clone_flush_request() rather
         than blk_kick_flush()
       - Drop changes in bt{,_tags}_for_each()
       - Adjust filename, context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      7acba7c0