1. 13 Apr, 2018 40 commits
    • Will Deacon's avatar
      arm64: futex: Fix undefined behaviour with FUTEX_OP_OPARG_SHIFT usage · d259b771
      Will Deacon authored
      
      [ Upstream commit 5f16a046 ]
      
      FUTEX_OP_OPARG_SHIFT instructs the futex code to treat the 12-bit oparg
      field as a shift value, potentially leading to a left shift value that
      is negative or with an absolute value that is significantly larger then
      the size of the type. UBSAN chokes with:
      
      ================================================================================
      UBSAN: Undefined behaviour in ./arch/arm64/include/asm/futex.h:60:13
      shift exponent -1 is negative
      CPU: 1 PID: 1449 Comm: syz-executor0 Not tainted 4.11.0-rc4-00005-g977eb52-dirty #11
      Hardware name: linux,dummy-virt (DT)
      Call trace:
      [<ffff200008094778>] dump_backtrace+0x0/0x538 arch/arm64/kernel/traps.c:73
      [<ffff200008094cd0>] show_stack+0x20/0x30 arch/arm64/kernel/traps.c:228
      [<ffff200008c194a8>] __dump_stack lib/dump_stack.c:16 [inline]
      [<ffff200008c194a8>] dump_stack+0x120/0x188 lib/dump_stack.c:52
      [<ffff200008cc24b8>] ubsan_epilogue+0x18/0x98 lib/ubsan.c:164
      [<ffff200008cc3098>] __ubsan_handle_shift_out_of_bounds+0x250/0x294 lib/ubsan.c:421
      [<ffff20000832002c>] futex_atomic_op_inuser arch/arm64/include/asm/futex.h:60 [inline]
      [<ffff20000832002c>] futex_wake_op kernel/futex.c:1489 [inline]
      [<ffff20000832002c>] do_futex+0x137c/0x1740 kernel/futex.c:3231
      [<ffff200008320504>] SYSC_futex kernel/futex.c:3281 [inline]
      [<ffff200008320504>] SyS_futex+0x114/0x268 kernel/futex.c:3249
      [<ffff200008084770>] el0_svc_naked+0x24/0x28
      ================================================================================
      syz-executor1 uses obsolete (PF_INET,SOCK_PACKET)
      sock: process `syz-executor0' is using obsolete setsockopt SO_BSDCOMPAT
      
      This patch attempts to fix some of this by:
      
        * Making encoded_op an unsigned type, so we can shift it left even if
          the top bit is set.
      
        * Casting to signed prior to shifting right when extracting oparg
          and cmparg
      
        * Consider only the bottom 5 bits of oparg when using it as a left-shift
          value.
      
      Whilst I think this catches all of the issues, I'd much prefer to remove
      this stuff, as I think it's unused and the bugs are copy-pasted between
      a bunch of architectures.
      Reviewed-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d259b771
    • Arvind Yadav's avatar
      dmaengine: imx-sdma: Handle return value of clk_prepare_enable · 365d5376
      Arvind Yadav authored
      
      [ Upstream commit fb9caf37 ]
      
      clk_prepare_enable() can fail here and we must check its return value.
      Signed-off-by: default avatarArvind Yadav <arvind.yadav.cs@gmail.com>
      Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      365d5376
    • Ivan Mikhaylov's avatar
      powerpc/[booke|4xx]: Don't clobber TCR[WP] when setting TCR[DIE] · 6c9fe477
      Ivan Mikhaylov authored
      
      [ Upstream commit 6e2f03e2 ]
      
      Prevent a kernel panic caused by unintentionally clearing TCR watchdog
      bits. At this point in the kernel boot, the watchdog may have already
      been enabled by u-boot. The original code's attempt to write to the TCR
      register results in an inadvertent clearing of the watchdog
      configuration bits, causing the 476 to reset.
      Signed-off-by: default avatarIvan Mikhaylov <ivan@de.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c9fe477
    • Miklos Szeredi's avatar
      ovl: filter trusted xattr for non-admin · d88cbbe7
      Miklos Szeredi authored
      
      [ Upstream commit a082c6f6 ]
      
      Filesystems filter out extended attributes in the "trusted." domain for
      unprivlieged callers.
      
      Overlay calls underlying filesystem's method with elevated privs, so need
      to do the filtering in overlayfs too.
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d88cbbe7
    • Firo Yang's avatar
      hdlcdrv: Fix divide by zero in hdlcdrv_ioctl · b32436de
      Firo Yang authored
      
      [ Upstream commit fb3ce90b ]
      
      syszkaller fuzzer triggered a divide by zero, when set calibration
      through ioctl().
      
      To fix it, test 'bitrate' if it is negative or 0, just return -EINVAL.
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFiro Yang <firogm@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b32436de
    • Colin Ian King's avatar
      wl1251: check return from call to wl1251_acx_arp_ip_filter · 65bd5b00
      Colin Ian King authored
      
      [ Upstream commit ac1181c6 ]
      
      Currently the less than zero error check on ret is incorrect
      as it is checking a far earlier ret assignment rather than the
      return from the call to wl1251_acx_arp_ip_filter. Fix this by
      adding in the missing assginment.
      
      Detected by CoverityScan, CID#1164835 ("Logically dead code")
      
      Fixes: 204cc5c4 ("wl1251: implement hardware ARP filtering")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65bd5b00
    • Christophe JAILLET's avatar
      ASoC: Intel: sst: Fix the return value of 'sst_send_byte_stream_mrfld()' · abbdead1
      Christophe JAILLET authored
      
      [ Upstream commit eaadb1ca ]
      
      In some error handling paths, an error code is assiegned to 'ret'.
      However, the function always return 0.
      
      Fix it and return the error code if such an error paths is taken.
      
      Fixes: 3d9ff346 ("ASoC: Intel: sst: add stream operations")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      abbdead1
    • Linus Walleij's avatar
      gpio: label descriptors using the device name · a60a3a28
      Linus Walleij authored
      
      [ Upstream commit 24e78079 ]
      
      Some GPIO lines appear named "?" in the lsgpio dump due to their
      requesting drivers not passing a reasonable label.
      
      Most typically this happens if a device tree node just defines
      gpios = <...> and not foo-gpios = <...>, the former gets named
      "foo" and the latter gets named "?".
      
      However the struct device passed in is always valid so let's
      just label the GPIO with dev_name() on the device if no proper
      label was passed.
      
      Cc: Reported-by: Jason Kridner <jkridner@beagleboard.org>
      Reported-by: default avatarJason Kridner <jkridner@beagleboard.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a60a3a28
    • Pieter \"PoroCYon\" Sluys's avatar
      vfb: fix video mode and line_length being set when loaded · a10b8564
      Pieter \"PoroCYon\" Sluys authored
      
      [ Upstream commit 7b9faf5d ]
      
      Currently, when loading the vfb module, the newly created fbdev
      has a line_length of 0, and its video mode would be PSEUDOCOLOR
      regardless of color depth. (The former could be worked around by
      calling the FBIOPUT_VSCREENINFO ioctl with having the FBACTIVIATE_FORCE
      flag set.) This patch automatically sets the line_length correctly,
      and the video mode is derived from the bit depth now as well.
      
      Thanks to Geert Uytterhoeven for confirming the bug and helping me with
      the patch.
      
      Output of `fbset -i' before the patch:
      mode "1366x768-60"
          # D: 72.432 MHz, H: 47.403 kHz, V: 60.004 Hz
          geometry 1366 768 1366 768 32
          timings 13806 120 10 14 3 32 5
          rgba 8/0,8/8,8/16,8/24
      endmode
      
      Frame buffer device information:
          Name        : Virtual FB
          Address     : 0xffffaa1405d85000
          Size        : 4196352
          Type        : PACKED PIXELS
          Visual      : PSEUDOCOLOR
          XPanStep    : 1
          YPanStep    : 1
          YWrapStep   : 1
          LineLength  : 0                    <-- note this
          Accelerator : No
      
      After:
      mode "1366x768-60"
          # D: 72.432 MHz, H: 47.403 kHz, V: 60.004 Hz
          geometry 1366 768 1366 768 32
          timings 13806 120 10 14 3 32 5
          rgba 8/0,8/8,8/16,8/24
      endmode
      
      Frame buffer device information:
          Name        : Virtual FB
          Address     : 0xffffaa1405d85000
          Size        : 4196352
          Type        : PACKED PIXELS
          Visual      : TRUECOLOR
          XPanStep    : 1
          YPanStep    : 1
          YWrapStep   : 1
          LineLength  : 5464
          Accelerator : No
      Signed-off-by: default avatar"Pieter \"PoroCYon\" Sluys" <pcy@national.shitposting.agency>
      Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      [b.zolnierkie: minor fixups]
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a10b8564
    • Chaitra P B's avatar
      scsi: mpt3sas: Proper handling of set/clear of "ATA command pending" flag. · 9c4c4129
      Chaitra P B authored
      
      [ Upstream commit f49d4aed ]
      
      1. In IO path, setting of "ATA command pending" flag early before device
         removal, invalid device handle etc., checks causes any new commands
         to be always returned with SAM_STAT_BUSY and when the driver removes
         the drive the SML issues SYNC Cache command and that command is
         always returned with SAM_STAT_BUSY and thus making SYNC Cache command
         to requeued.
      
      2. If the driver gets an ATA PT command for a SATA drive then the driver
         set "ATA command pending" flag in device specific data structure not
         to allow any further commands until the ATA PT command is completed.
         However, after setting the flag if the driver decides to return the
         command back to upper layers without actually issuing to the firmware
         (i.e., returns from qcmd failure return paths) then the corresponding
         flag is not cleared and this prevents the driver from sending any new
         commands to the drive.
      
      This patch fixes above two issues by setting of "ATA command pending"
      flag after checking for whether device deleted, invalid device handle,
      device busy with task management. And by setting "ATA command pending"
      flag to false in all of the qcmd failure return paths after setting the
      flag.
      Signed-off-by: default avatarChaitra P B <chaitra.basappa@broadcom.com>
      Signed-off-by: default avatarSuganath Prabu S <suganath-prabu.subramani@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c4c4129
    • Rafael David Tinoco's avatar
      scsi: libiscsi: Allow sd_shutdown on bad transport · 6294172f
      Rafael David Tinoco authored
      
      [ Upstream commit d7549412 ]
      
      If, for any reason, userland shuts down iscsi transport interfaces
      before proper logouts - like when logging in to LUNs manually, without
      logging out on server shutdown, or when automated scripts can't
      umount/logout from logged LUNs - kernel will hang forever on its
      sd_sync_cache() logic, after issuing the SYNCHRONIZE_CACHE cmd to all
      still existent paths.
      
      PID: 1 TASK: ffff8801a69b8000 CPU: 1 COMMAND: "systemd-shutdow"
       #0 [ffff8801a69c3a30] __schedule at ffffffff8183e9ee
       #1 [ffff8801a69c3a80] schedule at ffffffff8183f0d5
       #2 [ffff8801a69c3a98] schedule_timeout at ffffffff81842199
       #3 [ffff8801a69c3b40] io_schedule_timeout at ffffffff8183e604
       #4 [ffff8801a69c3b70] wait_for_completion_io_timeout at ffffffff8183fc6c
       #5 [ffff8801a69c3bd0] blk_execute_rq at ffffffff813cfe10
       #6 [ffff8801a69c3c88] scsi_execute at ffffffff815c3fc7
       #7 [ffff8801a69c3cc8] scsi_execute_req_flags at ffffffff815c60fe
       #8 [ffff8801a69c3d30] sd_sync_cache at ffffffff815d37d7
       #9 [ffff8801a69c3da8] sd_shutdown at ffffffff815d3c3c
      
      This happens because iscsi_eh_cmd_timed_out(), the transport layer
      timeout helper, would tell the queue timeout function (scsi_times_out)
      to reset the request timer over and over, until the session state is
      back to logged in state. Unfortunately, during server shutdown, this
      might never happen again.
      
      Other option would be "not to handle" the issue in the transport
      layer. That would trigger the error handler logic, which would also need
      the session state to be logged in again.
      
      Best option, for such case, is to tell upper layers that the command was
      handled during the transport layer error handler helper, marking it as
      DID_NO_CONNECT, which will allow completion and inform about the
      problem.
      
      After the session was marked as ISCSI_STATE_FAILED, due to the first
      timeout during the server shutdown phase, all subsequent cmds will fail
      to be queued, allowing upper logic to fail faster.
      Signed-off-by: default avatarRafael David Tinoco <rafael.tinoco@canonical.com>
      Reviewed-by: default avatarLee Duncan <lduncan@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6294172f
    • Hans de Goede's avatar
      ASoC: Intel: cht_bsw_rt5645: Analog Mic support · a34ee459
      Hans de Goede authored
      
      [ Upstream commit b70b3099 ]
      
      Various Cherry Trail boards with a rt5645 codec have an analog mic
      connected to IN2P + IN2N. The mic on this boards also needs micbias to
      be enabled, on some boards micbias1 is used and on others micbias2, so
      we enable both.
      
      This commit adds a new "Int Analog Mic" DAPM widget for this, so that we
      do not end up enabling micbias on boards with a digital mic which uses
      the already present "Int Mic" widget. Some existing UCM files already
      refer to "Int Mic" for their "Internal Analog Microphones" SectionDevice,
      but these don't work anyways since they enable the RECMIX BST1 Switch
      instead of the BST2 switch.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a34ee459
    • Mauro Carvalho Chehab's avatar
      media: videobuf2-core: don't go out of the buffer range · 7fba5c7a
      Mauro Carvalho Chehab authored
      
      [ Upstream commit df93dc61 ]
      
      Currently, there's no check if an invalid buffer range
      is passed. However, while testing DVB memory mapped apps,
      I got this:
      
         videobuf2_core: VB: num_buffers -2143943680, buffer 33, index -2143943647
         unable to handle kernel paging request at ffff888b773c0890
         IP: __vb2_queue_alloc+0x134/0x4e0 [videobuf2_core]
         PGD 4142c7067 P4D 4142c7067 PUD 0
         Oops: 0002 [#1] SMP
         Modules linked in: xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables bluetooth rfkill ecdh_generic binfmt_misc rc_dvbsky sp2 ts2020 intel_rapl x86_pkg_temp_thermal dvb_usb_dvbsky intel_powerclamp dvb_usb_v2 coretemp m88ds3103 kvm_intel i2c_mux dvb_core snd_hda_codec_hdmi crct10dif_pclmul crc32_pclmul videobuf2_vmalloc videobuf2_memops snd_hda_intel ghash_clmulni_intel videobuf2_core snd_hda_codec rc_core mei_me intel_cstate snd_hwdep snd_hda_core videodev intel_uncore snd_pcm mei media tpm_tis tpm_tis_core intel_rapl_perf tpm snd_timer lpc_ich snd soundcore kvm irqbypass libcrc32c i915 i2c_algo_bit drm_kms_helper
         e1000e ptp drm crc32c_intel video pps_core
         CPU: 3 PID: 1776 Comm: dvbv5-zap Not tainted 4.14.0+ #78
         Hardware name:                  /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017
         task: ffff88877c73bc80 task.stack: ffffb7c402418000
         RIP: 0010:__vb2_queue_alloc+0x134/0x4e0 [videobuf2_core]
         RSP: 0018:ffffb7c40241bc60 EFLAGS: 00010246
         RAX: 0000000080360421 RBX: 0000000000000021 RCX: 000000000000000a
         RDX: ffffb7c40241bcf4 RSI: ffff888780362c60 RDI: ffff888796d8e130
         RBP: ffffb7c40241bcc8 R08: 0000000000000316 R09: 0000000000000004
         R10: ffff888780362c00 R11: 0000000000000001 R12: 000000000002f000
         R13: ffff8887758be700 R14: 0000000000021000 R15: 0000000000000001
         FS:  00007f2849024740(0000) GS:ffff888796d80000(0000) knlGS:0000000000000000
         CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
         CR2: ffff888b773c0890 CR3: 000000043beb2005 CR4: 00000000003606e0
         Call Trace:
          vb2_core_reqbufs+0x226/0x420 [videobuf2_core]
          dvb_vb2_reqbufs+0x2d/0xc0 [dvb_core]
          dvb_dvr_do_ioctl+0x98/0x1d0 [dvb_core]
          dvb_usercopy+0x53/0x1b0 [dvb_core]
          ? dvb_demux_ioctl+0x20/0x20 [dvb_core]
          ? tty_ldisc_deref+0x16/0x20
          ? tty_write+0x1f9/0x310
          ? process_echoes+0x70/0x70
          dvb_dvr_ioctl+0x15/0x20 [dvb_core]
          do_vfs_ioctl+0xa5/0x600
          SyS_ioctl+0x79/0x90
          entry_SYSCALL_64_fastpath+0x1a/0xa5
         RIP: 0033:0x7f28486f7ea7
         RSP: 002b:00007ffc13b2db18 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
         RAX: ffffffffffffffda RBX: 000055b10fc06130 RCX: 00007f28486f7ea7
         RDX: 00007ffc13b2db48 RSI: 00000000c0086f3c RDI: 0000000000000007
         RBP: 0000000000000203 R08: 000055b10df1e02c R09: 000000000000002e
         R10: 0036b42415108357 R11: 0000000000000246 R12: 0000000000000000
         R13: 00007f2849062f60 R14: 00000000000001f1 R15: 00007ffc13b2da54
         Code: 74 0a 60 8b 0a 48 83 c0 30 48 83 c2 04 89 48 d0 89 48 d4 48 39 f0 75 eb 41 8b 42 08 83 7d d4 01 41 c7 82 ec 01 00 00 ff ff ff ff <4d> 89 94 c5 88 00 00 00 74 14 83 c3 01 41 39 dc 0f 85 f1 fe ff
         RIP: __vb2_queue_alloc+0x134/0x4e0 [videobuf2_core] RSP: ffffb7c40241bc60
         CR2: ffff888b773c0890
      
      So, add a sanity check in order to prevent going past array.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.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 avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7fba5c7a
    • Maciej Purski's avatar
      hwmon: (ina2xx) Make calibration register value fixed · b11e68ac
      Maciej Purski authored
      
      [ Upstream commit 5d389b12 ]
      
      Calibration register is used for calculating current register in
      hardware according to datasheet:
      current = shunt_volt * calib_register / 2048 (ina 226)
      current = shunt_volt * calib_register / 4096 (ina 219)
      
      Fix calib_register value to 2048 for ina226 and 4096 for ina 219 in
      order to avoid truncation error and provide best precision allowed
      by shunt_voltage measurement. Make current scale value follow changes
      of shunt_resistor from sysfs as calib_register value is now fixed.
      
      Power_lsb value should also follow shunt_resistor changes as stated in
      datasheet:
      power_lsb = 25 * current_lsb (ina 226)
      power_lsb = 20 * current_lsb (ina 219)
      Signed-off-by: default avatarMaciej Purski <m.purski@samsung.com>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b11e68ac
    • Sowmini Varadhan's avatar
      rds; Reset rs->rs_bound_addr in rds_add_bound() failure path · f69275de
      Sowmini Varadhan authored
      
      [ Upstream commit 7ae0c649 ]
      
      If the rds_sock is not added to the bind_hash_table, we must
      reset rs_bound_addr so that rds_remove_bound will not trip on
      this rds_sock.
      
      rds_add_bound() does a rds_sock_put() in this failure path, so
      failing to reset rs_bound_addr will result in a socket refcount
      bug, and will trigger a WARN_ON with the stack shown below when
      the application subsequently tries to close the PF_RDS socket.
      
           WARNING: CPU: 20 PID: 19499 at net/rds/af_rds.c:496 \
      		rds_sock_destruct+0x15/0x30 [rds]
             :
           __sk_destruct+0x21/0x190
           rds_remove_bound.part.13+0xb6/0x140 [rds]
           rds_release+0x71/0x120 [rds]
           sock_release+0x1a/0x70
           sock_close+0xe/0x20
           __fput+0xd5/0x210
           task_work_run+0x82/0xa0
           do_exit+0x2ce/0xb30
           ? syscall_trace_enter+0x1cc/0x2b0
           do_group_exit+0x39/0xa0
           SyS_exit_group+0x10/0x10
           do_syscall_64+0x61/0x1a0
      Signed-off-by: default avatarSowmini Varadhan <sowmini.varadhan@oracle.com>
      Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f69275de
    • Hangbin Liu's avatar
      l2tp: fix missing print session offset info · 4dfd6274
      Hangbin Liu authored
      
      [ Upstream commit 820da535 ]
      
      Report offset parameter in L2TP_CMD_SESSION_GET command if
      it has been configured by userspace
      
      Fixes: 309795f4 ("l2tp: Add netlink control API for L2TP")
      Reported-by: default avatarJianlin Shi <jishi@redhat.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4dfd6274
    • Masami Hiramatsu's avatar
      perf probe: Add warning message if there is unexpected event name · f192874a
      Masami Hiramatsu authored
      
      [ Upstream commit 9f5c6d87 ]
      
      This improve the error message so that user can know event-name error
      before writing new events to kprobe-events interface.
      
      E.g.
         ======
         #./perf probe -x /lib64/libc-2.25.so malloc_get_state*
         Internal error: "malloc_get_state@GLIBC_2" is an invalid event name.
           Error: Failed to add events.
         ======
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Acked-by: default avatarRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Reviewed-by: default avatarThomas Richter <tmricht@linux.vnet.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: bhargavb <bhargavaramudu@gmail.com>
      Cc: linux-rt-users@vger.kernel.org
      Link: http://lkml.kernel.org/r/151275040665.24652.5188568529237584489.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f192874a
    • Yi Zeng's avatar
      thermal: power_allocator: fix one race condition issue for thermal_instances list · d8ccbd16
      Yi Zeng authored
      
      [ Upstream commit a5de11d6 ]
      
      When invoking allow_maximum_power and traverse tz->thermal_instances,
      we should grab thermal_zone_device->lock to avoid race condition. For
      example, during the system reboot, if the mali GPU device implements
      device shutdown callback and unregister GPU devfreq cooling device,
      the deleted list head may be accessed to cause panic, as the following
      log shows:
      
      [   33.551070] c3 25 (kworker/3:0) Unable to handle kernel paging request at virtual address dead000000000070
      [   33.566708] c3 25 (kworker/3:0) pgd = ffffffc0ed290000
      [   33.572071] c3 25 (kworker/3:0) [dead000000000070] *pgd=00000001ed292003, *pud=00000001ed292003, *pmd=0000000000000000
      [   33.581515] c3 25 (kworker/3:0) Internal error: Oops: 96000004 [#1] PREEMPT SMP
      [   33.599761] c3 25 (kworker/3:0) CPU: 3 PID: 25 Comm: kworker/3:0 Not tainted 4.4.35+ #912
      [   33.614137] c3 25 (kworker/3:0) Workqueue: events_freezable thermal_zone_device_check
      [   33.620245] c3 25 (kworker/3:0) task: ffffffc0f32e4200 ti: ffffffc0f32f0000 task.ti: ffffffc0f32f0000
      [   33.629466] c3 25 (kworker/3:0) PC is at power_allocator_throttle+0x7c8/0x8a4
      [   33.636609] c3 25 (kworker/3:0) LR is at power_allocator_throttle+0x808/0x8a4
      [   33.643742] c3 25 (kworker/3:0) pc : [<ffffff8008683dd0>] lr : [<ffffff8008683e10>] pstate: 20000145
      [   33.652874] c3 25 (kworker/3:0) sp : ffffffc0f32f3bb0
      [   34.468519] c3 25 (kworker/3:0) Process kworker/3:0 (pid: 25, stack limit = 0xffffffc0f32f0020)
      [   34.477220] c3 25 (kworker/3:0) Stack: (0xffffffc0f32f3bb0 to 0xffffffc0f32f4000)
      [   34.819822] c3 25 (kworker/3:0) Call trace:
      [   34.824021] c3 25 (kworker/3:0) Exception stack(0xffffffc0f32f39c0 to 0xffffffc0f32f3af0)
      [   34.924993] c3 25 (kworker/3:0) [<ffffff8008683dd0>] power_allocator_throttle+0x7c8/0x8a4
      [   34.933184] c3 25 (kworker/3:0) [<ffffff80086807f4>] handle_thermal_trip.part.25+0x70/0x224
      [   34.941545] c3 25 (kworker/3:0) [<ffffff8008680a68>] thermal_zone_device_update+0xc0/0x20c
      [   34.949818] c3 25 (kworker/3:0) [<ffffff8008680bd4>] thermal_zone_device_check+0x20/0x2c
      [   34.957924] c3 25 (kworker/3:0) [<ffffff80080b93a4>] process_one_work+0x168/0x458
      [   34.965414] c3 25 (kworker/3:0) [<ffffff80080ba068>] worker_thread+0x13c/0x4b4
      [   34.972650] c3 25 (kworker/3:0) [<ffffff80080c0a4c>] kthread+0xe8/0xfc
      [   34.979187] c3 25 (kworker/3:0) [<ffffff8008084e90>] ret_from_fork+0x10/0x40
      [   34.986244] c3 25 (kworker/3:0) Code: f9405e73 eb1302bf d102e273 54ffc460 (b9402a61)
      [   34.994339] c3 25 (kworker/3:0) ---[ end trace 32057901e3b7e1db ]---
      Signed-off-by: default avatarYi Zeng <yizeng@asrmicro.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8ccbd16
    • Rasmus Villemoes's avatar
      ARM: dts: ls1021a: add "fsl,ls1021a-esdhc" compatible string to esdhc node · 50eeba86
      Rasmus Villemoes authored
      
      [ Upstream commit d5c7b4d5 ]
      
      Commit a22950c8 (mmc: sdhci-of-esdhc: add quirk
      SDHCI_QUIRK_BROKEN_TIMEOUT_VAL for ls1021a) added logic to the driver to
      enable the broken timeout val quirk for ls1021a, but did not add the
      corresponding compatible string to the device tree, so it didn't really
      have any effect. Fix that.
      Signed-off-by: default avatarRasmus Villemoes <rasmus.villemoes@prevas.dk>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50eeba86
    • linzhang's avatar
      net: llc: add lock_sock in llc_ui_bind to avoid a race condition · 7b3e13e2
      linzhang authored
      
      [ Upstream commit 0908cf4d ]
      
      There is a race condition in llc_ui_bind if two or more processes/threads
      try to bind a same socket.
      
      If more processes/threads bind a same socket success that will lead to
      two problems, one is this action is not what we expected, another is
      will lead to kernel in unstable status or oops(in my simple test case,
      cause llc2.ko can't unload).
      
      The current code is test SOCK_ZAPPED bit to avoid a process to
      bind a same socket twice but that is can't avoid more processes/threads
      try to bind a same socket at the same time.
      
      So, add lock_sock in llc_ui_bind like others, such as llc_ui_connect.
      Signed-off-by: default avatarLin Zhang <xiaolou4617@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b3e13e2
    • Jan H. Schönherr's avatar
      KVM: nVMX: Fix handling of lmsw instruction · 2967094c
      Jan H. Schönherr authored
      
      [ Upstream commit e1d39b17 ]
      
      The decision whether or not to exit from L2 to L1 on an lmsw instruction is
      based on bogus values: instead of using the information encoded within the
      exit qualification, it uses the data also used for the mov-to-cr
      instruction, which boils down to using whatever is in %eax at that point.
      
      Use the correct values instead.
      
      Without this fix, an L1 may not get notified when a 32-bit Linux L2
      switches its secondary CPUs to protected mode; the L1 is only notified on
      the next modification of CR0. This short time window poses a problem, when
      there is some other reason to exit to L1 in between. Then, L2 will be
      resumed in real mode and chaos ensues.
      Signed-off-by: default avatarJan H. Schönherr <jschoenh@amazon.de>
      Reviewed-by: default avatarWanpeng Li <wanpeng.li@hotmail.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2967094c
    • Nithin Sujir's avatar
      bonding: Don't update slave->link until ready to commit · 9e1aa8a0
      Nithin Sujir authored
      
      [ Upstream commit 797a9364 ]
      
      In the loadbalance arp monitoring scheme, when a slave link change is
      detected, the slave->link is immediately updated and slave_state_changed
      is set. Later down the function, the rtnl_lock is acquired and the
      changes are committed, updating the bond link state.
      
      However, the acquisition of the rtnl_lock can fail. The next time the
      monitor runs, since slave->link is already updated, it determines that
      link is unchanged. This results in the bond link state permanently out
      of sync with the slave link.
      
      This patch modifies bond_loadbalance_arp_mon() to handle link changes
      identical to bond_ab_arp_{inspect/commit}(). The new link state is
      maintained in slave->new_link until we're ready to commit at which point
      it's copied into slave->link.
      
      NOTE: miimon_{inspect/commit}() has a more complex state machine
      requiring the use of the bond_{propose,commit}_link_state() functions
      which maintains the intermediate state in slave->link_new_state. The arp
      monitors don't require that.
      
      Testing: This bug is very easy to reproduce with the following steps.
      1. In a loop, toggle a slave link of a bond slave interface.
      2. In a separate loop, do ifconfig up/down of an unrelated interface to
      create contention for rtnl_lock.
      Within a few iterations, the bond link goes out of sync with the slave
      link.
      Signed-off-by: default avatarNithin Nayak Sujir <nsujir@tintri.com>
      Cc: Mahesh Bandewar <maheshb@google.com>
      Cc: Jay Vosburgh <jay.vosburgh@canonical.com>
      Acked-by: default avatarMahesh Bandewar <maheshb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e1aa8a0
    • KT Liao's avatar
      Input: elan_i2c - clear INT before resetting controller · 12e0201e
      KT Liao authored
      
      [ Upstream commit 4b3c7dbb ]
      
      Some old touchpad FWs need to have interrupt cleared before issuing reset
      command after updating firmware. We clear interrupt by attempting to read
      full report from the controller, and discarding any data read.
      Signed-off-by: default avatarKT Liao <kt.liao@emc.com.tw>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12e0201e
    • Roman Kapl's avatar
      net: move somaxconn init from sysctl code · 78aa52da
      Roman Kapl authored
      
      [ Upstream commit 7c3f1875 ]
      
      The default value for somaxconn is set in sysctl_core_net_init(), but this
      function is not called when kernel is configured without CONFIG_SYSCTL.
      
      This results in the kernel not being able to accept TCP connections,
      because the backlog has zero size. Usually, the user ends up with:
      "TCP: request_sock_TCP: Possible SYN flooding on port 7. Dropping request.  Check SNMP counters."
      If SYN cookies are not enabled the connection is rejected.
      
      Before ef547f2a (tcp: remove max_qlen_log), the effects were less
      severe, because the backlog was always at least eight slots long.
      Signed-off-by: default avatarRoman Kapl <roman.kapl@sysgo.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      78aa52da
    • Eric Dumazet's avatar
      tcp: better validation of received ack sequences · 87d96d1b
      Eric Dumazet authored
      
      [ Upstream commit d0e1a1b5 ]
      
      Paul Fiterau Brostean reported :
      
      <quote>
      Linux TCP stack we analyze exhibits behavior that seems odd to me.
      The scenario is as follows (all packets have empty payloads, no window
      scaling, rcv/snd window size should not be a factor):
      
             TEST HARNESS (CLIENT)                        LINUX SERVER
      
         1.  -                                          LISTEN (server listen,
      then accepts)
      
         2.  - --> <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
      
         3.  - <-- <SEQ=300><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
      
         4.  - --> <SEQ=101><ACK=301><CTL=ACK>      --> ESTABLISHED
      
         5.  - <-- <SEQ=301><ACK=101><CTL=FIN,ACK>  <-- FIN WAIT-1 (server
      opts to close the data connection calling "close" on the connection
      socket)
      
         6.  - --> <SEQ=101><ACK=99999><CTL=FIN,ACK> --> CLOSING (client sends
      FIN,ACK with not yet sent acknowledgement number)
      
         7.  - <-- <SEQ=302><ACK=102><CTL=ACK>      <-- CLOSING (ACK is 102
      instead of 101, why?)
      
      ... (silence from CLIENT)
      
         8.  - <-- <SEQ=301><ACK=102><CTL=FIN,ACK>  <-- CLOSING
      (retransmission, again ACK is 102)
      
      Now, note that packet 6 while having the expected sequence number,
      acknowledges something that wasn't sent by the server. So I would
      expect
      the packet to maybe prompt an ACK response from the server, and then be
      ignored. Yet it is not ignored and actually leads to an increase of the
      acknowledgement number in the server's retransmission of the FIN,ACK
      packet. The explanation I found is that the FIN  in packet 6 was
      processed, despite the acknowledgement number being unacceptable.
      Further experiments indeed show that the server processes this FIN,
      transitioning to CLOSING, then on receiving an ACK for the FIN it had
      send in packet 5, the server (or better said connection) transitions
      from CLOSING to TIME_WAIT (as signaled by netstat).
      
      </quote>
      
      Indeed, tcp_rcv_state_process() calls tcp_ack() but
      does not exploit the @acceptable status but for TCP_SYN_RECV
      state.
      
      What we want here is to send a challenge ACK, if not in TCP_SYN_RECV
      state. TCP_FIN_WAIT1 state is not the only state we should fix.
      
      Add a FLAG_NO_CHALLENGE_ACK so that tcp_rcv_state_process()
      can choose to send a challenge ACK and discard the packet instead
      of wrongly change socket state.
      
      With help from Neal Cardwell.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarPaul Fiterau Brostean <p.fiterau-brostean@science.ru.nl>
      Cc: Neal Cardwell <ncardwell@google.com>
      Cc: Yuchung Cheng <ycheng@google.com>
      Cc: Soheil Hassas Yeganeh <soheil@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87d96d1b
    • Eryu Guan's avatar
      ext4: fix off-by-one on max nr_pages in ext4_find_unwritten_pgoff() · d8857ead
      Eryu Guan authored
      
      [ Upstream commit 624327f8 ]
      
      ext4_find_unwritten_pgoff() is used to search for offset of hole or
      data in page range [index, end] (both inclusive), and the max number
      of pages to search should be at least one, if end == index.
      Otherwise the only page is missed and no hole or data is found,
      which is not correct.
      
      When block size is smaller than page size, this can be demonstrated
      by preallocating a file with size smaller than page size and writing
      data to the last block. E.g. run this xfs_io command on a 1k block
      size ext4 on x86_64 host.
      
        # xfs_io -fc "falloc 0 3k" -c "pwrite 2k 1k" \
        	    -c "seek -d 0" /mnt/ext4/testfile
        wrote 1024/1024 bytes at offset 2048
        1 KiB, 1 ops; 0.0000 sec (42.459 MiB/sec and 43478.2609 ops/sec)
        Whence  Result
        DATA    EOF
      
      Data at offset 2k was missed, and lseek(2) returned ENXIO.
      
      This is unconvered by generic/285 subtest 07 and 08 on ppc64 host,
      where pagesize is 64k. Because a recent change to generic/285
      reduced the preallocated file size to smaller than 64k.
      Signed-off-by: default avatarEryu Guan <eguan@redhat.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8857ead
    • Michael Schmitz's avatar
      fix race in drivers/char/random.c:get_reg() · e520c431
      Michael Schmitz authored
      
      [ Upstream commit 9dfa7bba ]
      
      get_reg() can be reentered on architectures with prioritized interrupts
      (m68k in this case), causing f->reg_index to be incremented after the
      range check. Out of bounds memory access past the pt_regs struct results.
      This will go mostly undetected unless access is beyond end of memory.
      
      Prevent the race by disabling interrupts in get_reg().
      
      Tested on m68k (Atari Falcon, and ARAnyM emulator).
      
      Kudos to Geert Uytterhoeven for helping to trace this race.
      Signed-off-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e520c431
    • Maurizio Lombardi's avatar
      scsi: bnx2fc: fix race condition in bnx2fc_get_host_stats() · 2a051639
      Maurizio Lombardi authored
      
      [ Upstream commit c2dd893a ]
      
      If multiple tasks attempt to read the stats, it may happen that the
      start_req_done completion is re-initialized while still being used by
      another task, causing a list corruption.
      
      This patch fixes the bug by adding a mutex to serialize the calls to
      bnx2fc_get_host_stats().
      
      WARNING: at lib/list_debug.c:48 list_del+0x6e/0xa0() (Not tainted)
      Hardware name: PowerEdge R820
      list_del corruption. prev->next should be ffff882035627d90, but was ffff884069541588
      
      Pid: 40267, comm: perl Not tainted 2.6.32-642.3.1.el6.x86_64 #1
      Call Trace:
       [<ffffffff8107c691>] ? warn_slowpath_common+0x91/0xe0
       [<ffffffff8107c796>] ? warn_slowpath_fmt+0x46/0x60
       [<ffffffff812ad16e>] ? list_del+0x6e/0xa0
       [<ffffffff81547eed>] ? wait_for_common+0x14d/0x180
       [<ffffffff8106c4a0>] ? default_wake_function+0x0/0x20
       [<ffffffff81547fd3>] ? wait_for_completion_timeout+0x13/0x20
       [<ffffffffa05410b1>] ? bnx2fc_get_host_stats+0xa1/0x280 [bnx2fc]
       [<ffffffffa04cf630>] ? fc_stat_show+0x90/0xc0 [scsi_transport_fc]
       [<ffffffffa04cf8b6>] ? show_fcstat_tx_frames+0x16/0x20 [scsi_transport_fc]
       [<ffffffff8137c647>] ? dev_attr_show+0x27/0x50
       [<ffffffff8113b9be>] ? __get_free_pages+0xe/0x50
       [<ffffffff812170e1>] ? sysfs_read_file+0x111/0x200
       [<ffffffff8119a305>] ? vfs_read+0xb5/0x1a0
       [<ffffffff8119b0b6>] ? fget_light_pos+0x16/0x50
       [<ffffffff8119a651>] ? sys_read+0x51/0xb0
       [<ffffffff810ee1fe>] ? __audit_syscall_exit+0x25e/0x290
       [<ffffffff8100b0d2>] ? system_call_fastpath+0x16/0x1b
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Acked-by: default avatarChad Dupuis <chad.dupuis@cavium.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a051639
    • Kuninori Morimoto's avatar
      ASoC: rsnd: SSI PIO adjust to 24bit mode · e019b423
      Kuninori Morimoto authored
      
      [ Upstream commit 7819a942 ]
      
      commit 90431eb4 ("ASoC: rsnd: don't use PDTA bit for 24bit on SSI")
      fixups 24bit mode data alignment, but PIO was not cared.
      This patch fixes PIO mode 24bit data alignment
      Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e019b423
    • Dan Carpenter's avatar
      pNFS/flexfiles: missing error code in ff_layout_alloc_lseg() · 9f3e50a5
      Dan Carpenter authored
      
      [ Upstream commit 662f9a10 ]
      
      If xdr_inline_decode() fails then we end up returning ERR_PTR(0).  The
      caller treats NULL returns as -ENOMEM so it doesn't really hurt runtime,
      but obviously we intended to set an error code here.
      
      Fixes: d67ae825 ("pnfs/flexfiles: Add the FlexFile Layout Driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f3e50a5
    • Liping Zhang's avatar
      netfilter: ctnetlink: fix incorrect nf_ct_put during hash resize · 2847cd27
      Liping Zhang authored
      
      [ Upstream commit fefa9267 ]
      
      If nf_conntrack_htable_size was adjusted by the user during the ct
      dump operation, we may invoke nf_ct_put twice for the same ct, i.e.
      the "last" ct. This will cause the ct will be freed but still linked
      in hash buckets.
      
      It's very easy to reproduce the problem by the following commands:
        # while : ; do
        echo $RANDOM > /proc/sys/net/netfilter/nf_conntrack_buckets
        done
        # while : ; do
        conntrack -L
        done
        # iperf -s 127.0.0.1 &
        # iperf -c 127.0.0.1 -P 60 -t 36000
      
      After a while, the system will hang like this:
        NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s! [bash:20184]
        NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [iperf:20382]
        ...
      
      So at last if we find cb->args[1] is equal to "last", this means hash
      resize happened, then we can set cb->args[1] to 0 to fix the above
      issue.
      
      Fixes: d205dc40 ("[NETFILTER]: ctnetlink: fix deadlock in table dumping")
      Signed-off-by: default avatarLiping Zhang <zlpnobody@gmail.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2847cd27
    • Dan Carpenter's avatar
      libceph: NULL deref on crush_decode() error path · 23ae585a
      Dan Carpenter authored
      
      [ Upstream commit 293dffaa ]
      
      If there is not enough space then ceph_decode_32_safe() does a goto bad.
      We need to return an error code in that situation.  The current code
      returns ERR_PTR(0) which is NULL.  The callers are not expecting that
      and it results in a NULL dereference.
      
      Fixes: f24e9980 ("ceph: OSD client")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23ae585a
    • Lin Zhang's avatar
      net: ieee802154: fix net_device reference release too early · f277940b
      Lin Zhang authored
      
      [ Upstream commit a611c58b ]
      
      This patch fixes the kernel oops when release net_device reference in
      advance. In function raw_sendmsg(i think the dgram_sendmsg has the same
      problem), there is a race condition between dev_put and dev_queue_xmit
      when the device is gong that maybe lead to dev_queue_ximt to see
      an illegal net_device pointer.
      
      My test kernel is 3.13.0-32 and because i am not have a real 802154
      device, so i change lowpan_newlink function to this:
      
              /* find and hold real wpan device */
              real_dev = dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
              if (!real_dev)
                      return -ENODEV;
      //      if (real_dev->type != ARPHRD_IEEE802154) {
      //              dev_put(real_dev);
      //              return -EINVAL;
      //      }
              lowpan_dev_info(dev)->real_dev = real_dev;
              lowpan_dev_info(dev)->fragment_tag = 0;
              mutex_init(&lowpan_dev_info(dev)->dev_list_mtx);
      
      Also, in order to simulate preempt, i change the raw_sendmsg function
      to this:
      
              skb->dev = dev;
              skb->sk  = sk;
              skb->protocol = htons(ETH_P_IEEE802154);
              dev_put(dev);
              //simulate preempt
              schedule_timeout_uninterruptible(30 * HZ);
              err = dev_queue_xmit(skb);
              if (err > 0)
                      err = net_xmit_errno(err);
      
      and this is my userspace test code named test_send_data:
      
      int main(int argc, char **argv)
      {
              char buf[127];
              int sockfd;
              sockfd = socket(AF_IEEE802154, SOCK_RAW, 0);
              if (sockfd < 0) {
                      printf("create sockfd error: %s\n", strerror(errno));
                      return -1;
              }
              send(sockfd, buf, sizeof(buf), 0);
              return 0;
      }
      
      This is my test case:
      
      root@zhanglin-x-computer:~/develop/802154# uname -a
      Linux zhanglin-x-computer 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15
      03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
      root@zhanglin-x-computer:~/develop/802154# ip link add link eth0 name
      lowpan0 type lowpan
      root@zhanglin-x-computer:~/develop/802154#
      //keep the lowpan0 device down
      root@zhanglin-x-computer:~/develop/802154# ./test_send_data &
      //wait a while
      root@zhanglin-x-computer:~/develop/802154# ip link del link dev lowpan0
      //the device is gone
      //oops
      [381.303307] general protection fault: 0000 [#1]SMP
      [381.303407] Modules linked in: af_802154 6lowpan bnep rfcomm
      bluetooth nls_iso8859_1 snd_hda_codec_hdmi snd_hda_codec_realtek
      rts5139(C) snd_hda_intel
      snd_had_codec snd_hwdep snd_pcm snd_page_alloc snd_seq_midi
      snd_seq_midi_event snd_rawmidi snd_req intel_rapl snd_seq_device
      coretemp i915 kvm_intel
      kvm snd_timer snd crct10dif_pclmul crc32_pclmul ghash_clmulni_intel
      cypted drm_kms_helper drm i2c_algo_bit soundcore video mac_hid
      parport_pc ppdev ip parport hid_generic
      usbhid hid ahci r8169 mii libahdi
      [381.304286] CPU:1 PID: 2524 Commm: 1 Tainted: G C 0 3.13.0-32-generic
      [381.304409] Hardware name: Haier Haier DT Computer/Haier DT Codputer,
      BIOS FIBT19H02_X64 06/09/2014
      [381.304546] tasks: ffff000096965fc0 ti: ffffB0013779c000 task.ti:
      ffffB8013779c000
      [381.304659] RIP: 0010:[<ffffffff01621fe1>] [<ffffffff81621fe1>]
      __dev_queue_ximt+0x61/0x500
      [381.304798] RSP: 0018:ffffB8013779dca0 EFLAGS: 00010202
      [381.304880] RAX: 272b031d57565351 RBX: 0000000000000000 RCX: ffff8800968f1a00
      [381.304987] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8800968f1a00
      [381.305095] RBP: ffff8e013773dce0 R08: 0000000000000266 R09: 0000000000000004
      [381.305202] R10: 0000000000000004 R11: 0000000000000005 R12: ffff88013902e000
      [381.305310] R13: 000000000000007f R14: 000000000000007f R15: ffff8800968f1a00
      [381.305418] FS:  00007fc57f50f740(0000) GS: ffff88013fc80000(0000)
      knlGS: 0000000000000000
      [381.305540] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [381.305627] CR2: 00007fad0841c000 CR3: 00000001368dd000 CR4: 00000000001007e0
      [361.905734] Stack:
      [381.305768]  00000000002052d0 000000003facb30a ffff88013779dcc0
      ffff880137764000
      [381.305898]  ffff88013779de70 000000000000007f 000000000000007f
      ffff88013902e000
      [381.306026]  ffff88013779dcf0 ffffffff81622490 ffff88013779dd39
      ffffffffa03af9f1
      [381.306155] Call Trace:
      [381.306202]  [<ffffffff81622490>] dev_queue_xmit+0x10/0x20
      [381.306294]  [<ffffffffa03af9f1>] raw_sendmsg+0x1b1/0x270 [af_802154]
      [381.306396]  [<ffffffffa03af054>] ieee802154_sock_sendmsg+0x14/0x20 [af_802154]
      [381.306512]  [<ffffffff816079eb>] sock_sendmsg+0x8b/0xc0
      [381.306600]  [<ffffffff811d52a5>] ? __d_alloc+0x25/0x180
      [381.306687]  [<ffffffff811a1f56>] ? kmem_cache_alloc_trace+0x1c6/0x1f0
      [381.306791]  [<ffffffff81607b91>] SYSC_sendto+0x121/0x1c0
      [381.306878]  [<ffffffff8109ddf4>] ? vtime_account_user+x54/0x60
      [381.306975]  [<ffffffff81020d45>] ? syscall_trace_enter+0x145/0x250
      [381.307073]  [<ffffffff816086ae>] SyS_sendto+0xe/0x10
      [381.307156]  [<ffffffff8172c87f>] tracesys+0xe1/0xe6
      [381.307233] Code: c6 a1 a4 ff 41 8b 57 78 49 8b 47 20 85 d2 48 8b 80
      78 07 00 00 75 21 49 8b 57 18 48 85 d2 74 18 48 85 c0 74 13 8b 92 ac
      01 00 00 <3b> 50 10 73 08 8b 44 90 14 41 89 47 78 41 f6 84 24 d5 00 00
      00
      [381.307801] RIP [<ffffffff81621fe1>] _dev_queue_xmit+0x61/0x500
      [381.307901]  RSP <ffff88013779dca0>
      [381.347512] Kernel panic - not syncing: Fatal exception in interrupt
      [381.347747] drm_kms_helper: panic occurred, switching back to text console
      
      In my opinion, there is always exist a chance that the device is gong
      before call dev_queue_xmit.
      
      I think the latest kernel is have the same problem and that
      dev_put should be behind of the dev_queue_xmit.
      Signed-off-by: default avatarLin Zhang <xiaolou4617@gmail.com>
      Acked-by: default avatarStefan Schmidt <stefan@osg.samsung.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f277940b
    • Jesper Dangaard Brouer's avatar
      mlx5: fix bug reading rss_hash_type from CQE · b23f1c33
      Jesper Dangaard Brouer authored
      
      [ Upstream commit 12e8b570 ]
      
      Masks for extracting part of the Completion Queue Entry (CQE)
      field rss_hash_type was swapped, namely CQE_RSS_HTYPE_IP and
      CQE_RSS_HTYPE_L4.
      
      The bug resulted in setting skb->l4_hash, even-though the
      rss_hash_type indicated that hash was NOT computed over the
      L4 (UDP or TCP) part of the packet.
      
      Added comments from the datasheet, to make it more clear what
      these masks are selecting.
      Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b23f1c33
    • Dan Carpenter's avatar
      block: fix an error code in add_partition() · ddec2acd
      Dan Carpenter authored
      
      [ Upstream commit 7bd897cf ]
      
      We don't set an error code on this path.  It means that we return NULL
      instead of an error pointer and the caller does a NULL dereference.
      
      Fixes: 6d1d8050 ("block, partition: add partition_meta_info to hd_struct")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ddec2acd
    • Stephen Smalley's avatar
      selinux: do not check open permission on sockets · 60c26da5
      Stephen Smalley authored
      
      [ Upstream commit ccb54478 ]
      
      open permission is currently only defined for files in the kernel
      (COMMON_FILE_PERMS rather than COMMON_FILE_SOCK_PERMS). Construction of
      an artificial test case that tries to open a socket via /proc/pid/fd will
      generate a recvfrom avc denial because recvfrom and open happen to map to
      the same permission bit in socket vs file classes.
      
      open of a socket via /proc/pid/fd is not supported by the kernel regardless
      and will ultimately return ENXIO. But we hit the permission check first and
      can thus produce these odd/misleading denials.  Omit the open check when
      operating on a socket.
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60c26da5
    • Tariq Toukan's avatar
      net/mlx5: Tolerate irq_set_affinity_hint() failures · 4f58c2e9
      Tariq Toukan authored
      
      [ Upstream commit b665d98e ]
      
      Add tolerance to failures of irq_set_affinity_hint().
      Its role is to give hints that optimizes performance,
      and should not block the driver load.
      
      In non-SMP systems, functionality is not available as
      there is a single core, and all these calls definitely
      fail.  Hence, do not call the function and avoid the
      warning prints.
      
      Fixes: db058a18 ("net/mlx5_core: Set irq affinity hints")
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Cc: kernel-team@fb.com
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f58c2e9
    • Vlastimil Babka's avatar
      sched/numa: Use down_read_trylock() for the mmap_sem · d5367b89
      Vlastimil Babka authored
      
      [ Upstream commit 8655d549 ]
      
      A customer has reported a soft-lockup when running an intensive
      memory stress test, where the trace on multiple CPU's looks like this:
      
       RIP: 0010:[<ffffffff810c53fe>]
        [<ffffffff810c53fe>] native_queued_spin_lock_slowpath+0x10e/0x190
      ...
       Call Trace:
        [<ffffffff81182d07>] queued_spin_lock_slowpath+0x7/0xa
        [<ffffffff811bc331>] change_protection_range+0x3b1/0x930
        [<ffffffff811d4be8>] change_prot_numa+0x18/0x30
        [<ffffffff810adefe>] task_numa_work+0x1fe/0x310
        [<ffffffff81098322>] task_work_run+0x72/0x90
      
      Further investigation showed that the lock contention here is pmd_lock().
      
      The task_numa_work() function makes sure that only one thread is let to perform
      the work in a single scan period (via cmpxchg), but if there's a thread with
      mmap_sem locked for writing for several periods, multiple threads in
      task_numa_work() can build up a convoy waiting for mmap_sem for read and then
      all get unblocked at once.
      
      This patch changes the down_read() to the trylock version, which prevents the
      build up. For a workload experiencing mmap_sem contention, it's probably better
      to postpone the NUMA balancing work anyway. This seems to have fixed the soft
      lockups involving pmd_lock(), which is in line with the convoy theory.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarRik van Riel <riel@redhat.com>
      Acked-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20170515131316.21909-1-vbabka@suse.czSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5367b89
    • Tin Huynh's avatar
      leds: pca955x: Correct I2C Functionality · a7147749
      Tin Huynh authored
      
      [ Upstream commit aace34c0 ]
      
      The driver checks an incorrect flag of functionality of adapter.
      When a driver requires i2c_smbus_read_byte_data and
      i2c_smbus_write_byte_data, it should check I2C_FUNC_SMBUS_BYTE_DATA
      instead I2C_FUNC_I2C.
      This patch fixes the problem.
      Signed-off-by: default avatarTin Huynh <tnhuynh@apm.com>
      Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7147749
    • Kees Cook's avatar
      ray_cs: Avoid reading past end of buffer · 26c8b9a5
      Kees Cook authored
      
      [ Upstream commit e48d661e ]
      
      Using memcpy() from a buffer that is shorter than the length copied means
      the destination buffer is being filled with arbitrary data from the kernel
      rodata segment. In this case, the source was made longer, since it did not
      match the destination structure size. Additionally removes a needless cast.
      
      This was found with the future CONFIG_FORTIFY_SOURCE feature.
      
      Cc: Daniel Micay <danielmicay@gmail.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26c8b9a5