1. 10 7月, 2019 34 次提交
    • J
      cpuset: restore sanity to cpuset_cpus_allowed_fallback() · b7747ecb
      Joel Savitz 提交于
      [ Upstream commit d477f8c202d1f0d4791ab1263ca7657bbe5cf79e ]
      
      In the case that a process is constrained by taskset(1) (i.e.
      sched_setaffinity(2)) to a subset of available cpus, and all of those are
      subsequently offlined, the scheduler will set tsk->cpus_allowed to
      the current value of task_cs(tsk)->effective_cpus.
      
      This is done via a call to do_set_cpus_allowed() in the context of
      cpuset_cpus_allowed_fallback() made by the scheduler when this case is
      detected. This is the only call made to cpuset_cpus_allowed_fallback()
      in the latest mainline kernel.
      
      However, this is not sane behavior.
      
      I will demonstrate this on a system running the latest upstream kernel
      with the following initial configuration:
      
      	# grep -i cpu /proc/$$/status
      	Cpus_allowed:	ffffffff,fffffff
      	Cpus_allowed_list:	0-63
      
      (Where cpus 32-63 are provided via smt.)
      
      If we limit our current shell process to cpu2 only and then offline it
      and reonline it:
      
      	# taskset -p 4 $$
      	pid 2272's current affinity mask: ffffffffffffffff
      	pid 2272's new affinity mask: 4
      
      	# echo off > /sys/devices/system/cpu/cpu2/online
      	# dmesg | tail -3
      	[ 2195.866089] process 2272 (bash) no longer affine to cpu2
      	[ 2195.872700] IRQ 114: no longer affine to CPU2
      	[ 2195.879128] smpboot: CPU 2 is now offline
      
      	# echo on > /sys/devices/system/cpu/cpu2/online
      	# dmesg | tail -1
      	[ 2617.043572] smpboot: Booting Node 0 Processor 2 APIC 0x4
      
      We see that our current process now has an affinity mask containing
      every cpu available on the system _except_ the one we originally
      constrained it to:
      
      	# grep -i cpu /proc/$$/status
      	Cpus_allowed:   ffffffff,fffffffb
      	Cpus_allowed_list:      0-1,3-63
      
      This is not sane behavior, as the scheduler can now not only place the
      process on previously forbidden cpus, it can't even schedule it on
      the cpu it was originally constrained to!
      
      Other cases result in even more exotic affinity masks. Take for instance
      a process with an affinity mask containing only cpus provided by smt at
      the moment that smt is toggled, in a configuration such as the following:
      
      	# taskset -p f000000000 $$
      	# grep -i cpu /proc/$$/status
      	Cpus_allowed:	000000f0,00000000
      	Cpus_allowed_list:	36-39
      
      A double toggle of smt results in the following behavior:
      
      	# echo off > /sys/devices/system/cpu/smt/control
      	# echo on > /sys/devices/system/cpu/smt/control
      	# grep -i cpus /proc/$$/status
      	Cpus_allowed:	ffffff00,ffffffff
      	Cpus_allowed_list:	0-31,40-63
      
      This is even less sane than the previous case, as the new affinity mask
      excludes all smt-provided cpus with ids less than those that were
      previously in the affinity mask, as well as those that were actually in
      the mask.
      
      With this patch applied, both of these cases end in the following state:
      
      	# grep -i cpu /proc/$$/status
      	Cpus_allowed:	ffffffff,ffffffff
      	Cpus_allowed_list:	0-63
      
      The original policy is discarded. Though not ideal, it is the simplest way
      to restore sanity to this fallback case without reinventing the cpuset
      wheel that rolls down the kernel just fine in cgroup v2. A user who wishes
      for the previous affinity mask to be restored in this fallback case can use
      that mechanism instead.
      
      This patch modifies scheduler behavior by instead resetting the mask to
      task_cs(tsk)->cpus_allowed by default, and cpu_possible mask in legacy
      mode. I tested the cases above on both modes.
      
      Note that the scheduler uses this fallback mechanism if and only if
      _every_ other valid avenue has been traveled, and it is the last resort
      before calling BUG().
      Suggested-by: NWaiman Long <longman@redhat.com>
      Suggested-by: NPhil Auld <pauld@redhat.com>
      Signed-off-by: NJoel Savitz <jsavitz@redhat.com>
      Acked-by: NPhil Auld <pauld@redhat.com>
      Acked-by: NWaiman Long <longman@redhat.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b7747ecb
    • L
      i2c: pca-platform: Fix GPIO lookup code · e33aeb9a
      Linus Walleij 提交于
      [ Upstream commit a0cac264a86fbf4d6cb201fbbb73c1d335e3248a ]
      
      The devm_gpiod_request_gpiod() call will add "-gpios" to
      any passed connection ID before looking it up.
      
      I do not think the reset GPIO on this platform is named
      "reset-gpios-gpios" but rather "reset-gpios" in the device
      tree, so fix this up so that we get a proper reset GPIO
      handle.
      
      Also drop the inclusion of the legacy GPIO header.
      
      Fixes: 0e8ce93b ("i2c: pca-platform: add devicetree awareness")
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: NChris Packham <chris.packham@alliedtelesis.co.nz>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e33aeb9a
    • V
      platform/mellanox: mlxreg-hotplug: Add devm_free_irq call to remove flow · 7cf431ed
      Vadim Pasternak 提交于
      [ Upstream commit 8c2eb7b6468ad4aa5600aed01aa0715f921a3f8b ]
      
      Add devm_free_irq() call to mlxreg-hotplug remove() for clean release
      of devices irq resource. Fix debugobjects warning triggered by rmmod
      It prevents of use-after-free memory, related to
      mlxreg_hotplug_work_handler.
      
      Issue has been reported as debugobjects warning triggered by
      'rmmod mlxtreg-hotplug' flow, while running kernel with
      CONFIG_DEBUG_OBJECTS* options.
      
      [ 2489.623551] ODEBUG: free active (active state 0) object type: work_struct hint: mlxreg_hotplug_work_handler+0x0/0x7f0 [mlxreg_hotplug]
      [ 2489.637097] WARNING: CPU: 5 PID: 3924 at lib/debugobjects.c:328 debug_print_object+0xfe/0x180
      [ 2489.637165] RIP: 0010:debug_print_object+0xfe/0x180
      ?
      [ 2489.637214] Call Trace:
      [ 2489.637225]  __debug_check_no_obj_freed+0x25e/0x320
      [ 2489.637231]  kfree+0x82/0x110
      [ 2489.637238]  release_nodes+0x33c/0x4e0
      [ 2489.637242]  ? devres_remove_group+0x1b0/0x1b0
      [ 2489.637247]  device_release_driver_internal+0x146/0x270
      [ 2489.637251]  driver_detach+0x73/0xe0
      [ 2489.637254]  bus_remove_driver+0xa1/0x170
      [ 2489.637261]  __x64_sys_delete_module+0x29e/0x320
      [ 2489.637265]  ? __ia32_sys_delete_module+0x320/0x320
      [ 2489.637268]  ? blkcg_exit_queue+0x20/0x20
      [ 2489.637273]  ? task_work_run+0x7d/0x100
      [ 2489.637278]  ? exit_to_usermode_loop+0x5b/0xf0
      [ 2489.637281]  do_syscall_64+0x73/0x160
      [ 2489.637287]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [ 2489.637290] RIP: 0033:0x7f95c3596fd7
      
      The difference in release flow with and with no devm_free_irq is listed
      below:
      
      bus: 'platform': remove driver mlxreg-hotplug
       mlxreg_hotplug_remove(start)
      					-> devm_free_irq (with new code)
       mlxreg_hotplug_remove (end)
       release_nodes (start)
        mlxreg-hotplug: DEVRES REL devm_hwmon_release (8 bytes)
        device: 'hwmon3': device_unregister
        PM: Removing info for No Bus:hwmon3
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (88 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (6 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes)
        mlxreg-hotplug: DEVRES REL devm_irq_release (16 bytes) (no new code)
        mlxreg-hotplug: DEVRES REL devm_kzalloc_release (1376 bytes)
         ------------[ cut here ]------------ (no new code):
         ODEBUG: free active (active state 0) object type: work_struct hint: mlxreg_hotplug_work_handler
      
       release_nodes(end)
      driver: 'mlxreg-hotplug': driver_release
      
      Fixes: 1f976f69 ("platform/x86: Move Mellanox platform hotplug driver to platform/mellanox")
      Signed-off-by: NVadim Pasternak <vadimp@mellanox.com>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7cf431ed
    • V
      platform/x86: mlx-platform: Fix parent device in i2c-mux-reg device registration · c241f3fb
      Vadim Pasternak 提交于
      [ Upstream commit 160da20b254dd4bfc5828f12c208fa831ad4be6c ]
      
      Fix the issue found while running kernel with the option
      CONFIG_DEBUG_TEST_DRIVER_REMOVE.
      Driver 'mlx-platform' registers 'i2c_mlxcpld' device and then registers
      few underlying 'i2c-mux-reg' devices:
      	priv->pdev_i2c = platform_device_register_simple("i2c_mlxcpld", nr,
      							 NULL, 0);
      	...
      	for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) {
      		priv->pdev_mux[i] = platform_device_register_resndata(
      						&mlxplat_dev->dev,
      						"i2c-mux-reg", i, NULL,
      						0, &mlxplat_mux_data[i],
      						sizeof(mlxplat_mux_data[i]));
      
      But actual parent of "i2c-mux-reg" device is priv->pdev_i2c->dev and
      not mlxplat_dev->dev.
      Patch fixes parent device parameter in a call to
      platform_device_register_resndata() for "i2c-mux-reg".
      
      It solves the race during initialization flow while 'i2c_mlxcpld.1' is
      removing after probe, while 'i2c-mux-reg.0' is still in probing flow:
      'i2c_mlxcpld.1'	flow:	probe -> remove -> probe.
      'i2c-mux-reg.0'	flow:		  probe -> ...
      
      [   12:621096] Registering platform device 'i2c_mlxcpld.1'. Parent at platform
      [   12:621117] device: 'i2c_mlxcpld.1': device_add
      [   12:621155] bus: 'platform': add device i2c_mlxcpld.1
      [   12:621384] Registering platform device 'i2c-mux-reg.0'. Parent at mlxplat
      [   12:621395] device: 'i2c-mux-reg.0': device_add
      [   12:621425] bus: 'platform': add device i2c-mux-reg.0
      [   12:621806] Registering platform device 'i2c-mux-reg.1'. Parent at mlxplat
      [   12:621828] device: 'i2c-mux-reg.1': device_add
      [   12:621892] bus: 'platform': add device i2c-mux-reg.1
      [   12:621906] bus: 'platform': add driver i2c_mlxcpld
      [   12:621996] bus: 'platform': driver_probe_device: matched device i2c_mlxcpld.1 with driver i2c_mlxcpld
      [   12:622003] bus: 'platform': really_probe: probing driver i2c_mlxcpld with device i2c_mlxcpld.1
      [   12:622100] i2c_mlxcpld i2c_mlxcpld.1: no default pinctrl state
      [   12:622293] device: 'i2c-1': device_add
      [   12:627280] bus: 'i2c': add device i2c-1
      [   12:627692] device: 'i2c-1': device_add
      [   12.629639] bus: 'platform': add driver i2c-mux-reg
      [   12.629718] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.0 with driver i2c-mux-reg
      [   12.629723] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.0
      [   12.629818] i2c-mux-reg i2c-mux-reg.0: no default pinctrl state
      [   12.629981] platform i2c-mux-reg.0: Driver i2c-mux-reg requests probe deferral
      [   12.629986] platform i2c-mux-reg.0: Added to deferred list
      [   12.629992] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.1 with driver i2c-mux-reg
      [   12.629997] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.1
      [   12.630091] i2c-mux-reg i2c-mux-reg.1: no default pinctrl state
      [   12.630247] platform i2c-mux-reg.1: Driver i2c-mux-reg requests probe deferral
      [   12.630252] platform i2c-mux-reg.1: Added to deferred list
      [   12.640892] devices_kset: Moving i2c-mux-reg.0 to end of list
      [   12.640900] platform i2c-mux-reg.0: Retrying from deferred list
      [   12.640911] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.0 with driver i2c-mux-reg
      [   12.640919] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.0
      [   12.640999] i2c-mux-reg i2c-mux-reg.0: no default pinctrl state
      [   12.641177] platform i2c-mux-reg.0: Driver i2c-mux-reg requests probe deferral
      [   12.641187] platform i2c-mux-reg.0: Added to deferred list
      [   12.641198] devices_kset: Moving i2c-mux-reg.1 to end of list
      [   12.641219] platform i2c-mux-reg.1: Retrying from deferred list
      [   12.641237] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.1 with driver i2c-mux-reg
      [   12.641247] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.1
      [   12.641331] i2c-mux-reg i2c-mux-reg.1: no default pinctrl state
      [   12.641465] platform i2c-mux-reg.1: Driver i2c-mux-reg requests probe deferral
      [   12.641469] platform i2c-mux-reg.1: Added to deferred list
      [   12.646427] device: 'i2c-1': device_add
      [   12.646647] bus: 'i2c': add device i2c-1
      [   12.647104] device: 'i2c-1': device_add
      [   12.669231] devices_kset: Moving i2c-mux-reg.0 to end of list
      [   12.669240] platform i2c-mux-reg.0: Retrying from deferred list
      [   12.669258] bus: 'platform': driver_probe_device: matched device i2c-mux-reg.0 with driver i2c-mux-reg
      [   12.669263] bus: 'platform': really_probe: probing driver i2c-mux-reg with device i2c-mux-reg.0
      [   12.669343] i2c-mux-reg i2c-mux-reg.0: no default pinctrl state
      [   12.669585] device: 'i2c-2': device_add
      [   12.669795] bus: 'i2c': add device i2c-2
      [   12.670201] device: 'i2c-2': device_add
      [   12.671427] i2c i2c-1: Added multiplexed i2c bus 2
      [   12.671514] device: 'i2c-3': device_add
      [   12.671724] bus: 'i2c': add device i2c-3
      [   12.672136] device: 'i2c-3': device_add
      [   12.673378] i2c i2c-1: Added multiplexed i2c bus 3
      [   12.673472] device: 'i2c-4': device_add
      [   12.673676] bus: 'i2c': add device i2c-4
      [   12.674060] device: 'i2c-4': device_add
      [   12.675861] i2c i2c-1: Added multiplexed i2c bus 4
      [   12.675941] device: 'i2c-5': device_add
      [   12.676150] bus: 'i2c': add device i2c-5
      [   12.676550] device: 'i2c-5': device_add
      [   12.678103] i2c i2c-1: Added multiplexed i2c bus 5
      [   12.678193] device: 'i2c-6': device_add
      [   12.678395] bus: 'i2c': add device i2c-6
      [   12.678774] device: 'i2c-6': device_add
      [   12.679969] i2c i2c-1: Added multiplexed i2c bus 6
      [   12.680065] device: 'i2c-7': device_add
      [   12.680275] bus: 'i2c': add device i2c-7
      [   12.680913] device: 'i2c-7': device_add
      [   12.682506] i2c i2c-1: Added multiplexed i2c bus 7
      [   12.682600] device: 'i2c-8': device_add
      [   12.682808] bus: 'i2c': add device i2c-8
      [   12.683189] device: 'i2c-8': device_add
      [   12.683907] device: 'i2c-1': device_unregister
      [   12.683945] device: 'i2c-1': device_unregister
      [   12.684387] device: 'i2c-1': device_create_release
      [   12.684536] bus: 'i2c': remove device i2c-1
      [   12.686019] i2c i2c-8: Failed to create compatibility class link
      [   12.686086] ------------[ cut here ]------------
      [   12.686087] can't create symlink to mux device
      [   12.686224] Workqueue: events deferred_probe_work_func
      [   12.686135] WARNING: CPU: 7 PID: 436 at drivers/i2c/i2c-mux.c:416 i2c_mux_add_adapter+0x729/0x7d0 [i2c_mux]
      [   12.686232] RIP: 0010:i2c_mux_add_adapter+0x729/0x7d0 [i2c_mux]
      [   0x190/0x190 [i2c_mux]
      [   12.686300]  ? i2c_mux_alloc+0xac/0x110 [i2c_mux]
      [   12.686306]  ? i2c_mux_reg_set+0x200/0x200 [i2c_mux_reg]
      [   12.686313]  i2c_mux_reg_probe+0x22c/0x731 [i2c_mux_reg]
      [   12.686322]  ? i2c_mux_reg_deselect+0x60/0x60 [i2c_mux_reg]
      [   12.686346]  platform_drv_probe+0xa8/0x110
      [   12.686351]  really_probe+0x185/0x720
      [   12.686358]  driver_probe_device+0xdf/0x1f0
      ...
      [   12.686522] i2c i2c-1: Added multiplexed i2c bus 8
      [   12.686621] device: 'i2c-9': device_add
      [   12.686626] kobject_add_internal failed for i2c-9 (error: -2 parent: i2c-1)
      [   12.694729] i2c-core: adapter 'i2c-1-mux (chan_id 8)': can't register device (-2)
      [   12.705726] i2c i2c-1: failed to add mux-adapter 8 as bus 9 (error=-2)
      [   12.714494] device: 'i2c-8': device_unregister
      [   12.714537] device: 'i2c-8': device_unregister
      
      Fixes: 6613d18e ("platform/x86: mlx-platform: Move module from arch/x86")
      Signed-off-by: NVadim Pasternak <vadimp@mellanox.com>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c241f3fb
    • M
      platform/x86: intel-vbtn: Report switch events when event wakes device · f8531127
      Mathew King 提交于
      [ Upstream commit cb1921b17adbe6509538098ac431033378cd7165 ]
      
      When a switch event, such as tablet mode/laptop mode or docked/undocked,
      wakes a device make sure that the value of the swich is reported.
      Without when a device is put in tablet mode from laptop mode when it is
      suspended or vice versa the device will wake up but mode will be
      incorrect.
      
      Tested by suspending a device in laptop mode and putting it in tablet
      mode, the device resumes and is in tablet mode. When suspending the
      device in tablet mode and putting it in laptop mode the device resumes
      and is in laptop mode.
      Signed-off-by: NMathew King <mathewk@chromium.org>
      Reviewed-by: NJett Rink <jettrink@chromium.org>
      Reviewed-by: NMario Limonciello <mario.limonciello@dell.com>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f8531127
    • H
      platform/x86: asus-wmi: Only Tell EC the OS will handle display hotkeys from asus_nb_wmi · 2ac96173
      Hans de Goede 提交于
      [ Upstream commit 401fee8195d401b2b94dee57383f627050724d5b ]
      
      Commit 78f3ac76d9e5 ("platform/x86: asus-wmi: Tell the EC the OS will
      handle the display off hotkey") causes the backlight to be permanently off
      on various EeePC laptop models using the eeepc-wmi driver (Asus EeePC
      1015BX, Asus EeePC 1025C).
      
      The asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 2, NULL) call added
      by that commit is made conditional in this commit and only enabled in
      the quirk_entry structs in the asus-nb-wmi driver fixing the broken
      display / backlight on various EeePC laptop models.
      
      Cc: João Paulo Rechi Vita <jprvita@endlessm.com>
      Fixes: 78f3ac76d9e5 ("platform/x86: asus-wmi: Tell the EC the OS will handle the display off hotkey")
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2ac96173
    • H
      drm: panel-orientation-quirks: Add quirk for GPD MicroPC · 027e043f
      Hans de Goede 提交于
      [ Upstream commit 652b8b086538c8a10de5aa5cbdaef79333b46358 ]
      
      GPD has done it again, make a nice device (good), use way too generic
      DMI strings (bad) and use a portrait screen rotated 90 degrees (ugly).
      
      Because of the too generic DMI strings this entry is also doing bios-date
      matching, so the gpd_micropc data struct may very well need to be updated
      with some extra bios-dates in the future.
      Acked-by: NMaxime Ripard <maxime.ripard@bootlin.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190524125759.14131-2-hdegoede@redhat.com
      (cherry picked from commit f2f2bb60d998abde10de7e483ef9e17639892450)
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      027e043f
    • H
      drm: panel-orientation-quirks: Add quirk for GPD pocket2 · 2446563d
      Hans de Goede 提交于
      [ Upstream commit 15abc7110a77555d3bf72aaef46d1557db0a4ac5 ]
      
      GPD has done it again, make a nice device (good), use way too generic
      DMI strings (bad) and use a portrait screen rotated 90 degrees (ugly).
      
      Because of the too generic DMI strings this entry is also doing bios-date
      matching, so the gpd_pocket2 data struct may very well need to be updated
      with some extra bios-dates in the future.
      
      Changes in v2:
      -Add one more known BIOS date to the list of BIOS dates
      
      Cc: Jurgen Kramer <gtmkramer@xs4all.nl>
      Reported-by: NJurgen Kramer <gtmkramer@xs4all.nl>
      Acked-by: NMaxime Ripard <maxime.ripard@bootlin.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190524125759.14131-1-hdegoede@redhat.com
      (cherry picked from commit 6dab9102dd7b144e5723915438e0d6c473018cd0)
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2446563d
    • D
      scsi: hpsa: correct ioaccel2 chaining · 8be5629b
      Don Brace 提交于
      [ Upstream commit 625d7d3518875c4d303c652a198feaa13d9f52d9 ]
      
      - set ioaccel2_sg_element member 'chain_indicator' to IOACCEL2_LAST_SG for
        the last s/g element.
      
      - set ioaccel2_sg_element member 'chain_indicator' to IOACCEL2_CHAIN when
        chaining.
      Reviewed-by: NBader Ali - Saleh <bader.alisaleh@microsemi.com>
      Reviewed-by: NScott Teel <scott.teel@microsemi.com>
      Reviewed-by: NMatt Perricone <matt.perricone@microsemi.com>
      Signed-off-by: NDon Brace <don.brace@microsemi.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8be5629b
    • A
      SoC: rt274: Fix internal jack assignment in set_jack callback · c1bef204
      Amadeusz Sławiński 提交于
      [ Upstream commit 04268bf2757a125616b6c2140e6250f43b7b737a ]
      
      When we call snd_soc_component_set_jack(component, NULL, NULL) we should
      set rt274->jack to passed jack, so when interrupt is triggered it calls
      snd_soc_jack_report(rt274->jack, ...) with proper value.
      
      This fixes problem in machine where in register, we call
      snd_soc_register(component, &headset, NULL), which just calls
      rt274_mic_detect via callback.
      Now when machine driver is removed "headset" will be gone, so we
      need to tell codec driver that it's gone with:
      snd_soc_register(component, NULL, NULL), but we also need to be able
      to handle NULL jack argument here gracefully.
      If we don't set it to NULL, next time the rt274_irq runs it will call
      snd_soc_jack_report with first argument being invalid pointer and there
      will be Oops.
      Signed-off-by: NAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c1bef204
    • A
      ALSA: hdac: fix memory release for SST and SOF drivers · 1023af0c
      Amadeusz Sławiński 提交于
      [ Upstream commit 6d647b736a6b1cbf2f8deab0e6a94c34a6ea9d60 ]
      
      During the integration of HDaudio support, we changed the way in which
      we get hdev in snd_hdac_ext_bus_device_init() to use one preallocated
      with devm_kzalloc(), however it still left kfree(hdev) in
      snd_hdac_ext_bus_device_exit(). It leads to oopses when trying to
      rmmod and modprobe. Fix it, by just removing kfree call.
      
      SOF also uses some of the snd_hdac_ functions for HDAudio support but
      allocated the memory with kzalloc. A matching fix is provided
      separately to align all users of the snd_hdac_ library.
      
      Fixes: 6298542f ("ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init")
      Reviewed-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
      Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      1023af0c
    • A
      usb: gadget: udc: lpc32xx: allocate descriptor with GFP_ATOMIC · 26a6acde
      Alexandre Belloni 提交于
      [ Upstream commit fbc318afadd6e7ae2252d6158cf7d0c5a2132f7d ]
      
      Gadget drivers may queue request in interrupt context. This would lead to
      a descriptor allocation in that context. In that case we would hit
      BUG_ON(in_interrupt()) in __get_vm_area_node.
      
      Also remove the unnecessary cast.
      Acked-by: NSylvain Lemieux <slemieux.tyco@gmail.com>
      Tested-by: NJames Grant <jamesg@zaltys.org>
      Signed-off-by: NAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      26a6acde
    • Y
      usb: gadget: fusb300_udc: Fix memory leak of fusb300->ep[i] · 9be058f5
      Young Xiao 提交于
      [ Upstream commit 62fd0e0a24abeebe2c19fce49dd5716d9b62042d ]
      
      There is no deallocation of fusb300->ep[i] elements, allocated at
      fusb300_probe.
      
      The patch adds deallocation of fusb300->ep array elements.
      Signed-off-by: NYoung Xiao <92siuyang@gmail.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9be058f5
    • K
      x86/CPU: Add more Icelake model numbers · 5284327f
      Kan Liang 提交于
      [ Upstream commit e35faeb64146f2015f2aec14b358ae508e4066db ]
      
      Add the CPUID model numbers of Icelake (ICL) desktop and server
      processors to the Intel family list.
      
       [ Qiuxu: Sort the macros by model number. ]
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
      Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@linux.intel.com>
      Cc: rui.zhang@intel.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190603134122.13853-1-kan.liang@linux.intel.comSigned-off-by: NSasha Levin <sashal@kernel.org>
      5284327f
    • M
      ASoC: sun4i-i2s: Add offset to RX channel select · 74929087
      Marcus Cooper 提交于
      [ Upstream commit f9927000cb35f250051f0f1878db12ee2626eea1 ]
      
      Whilst testing the capture functionality of the i2s on the newer
      SoCs it was noticed that the recording was somewhat distorted.
      This was due to the offset not being set correctly on the receiver
      side.
      Signed-off-by: NMarcus Cooper <codekipper@gmail.com>
      Acked-by: NMaxime Ripard <maxime.ripard@bootlin.com>
      Acked-by: NChen-Yu Tsai <wens@csie.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      74929087
    • M
      ASoC: sun4i-i2s: Fix sun8i tx channel offset mask · 32475634
      Marcus Cooper 提交于
      [ Upstream commit 7e46169a5f35762f335898a75d1b8a242f2ae0f5 ]
      
      Although not causing any noticeable issues, the mask for the
      channel offset is covering too many bits.
      Signed-off-by: NMarcus Cooper <codekipper@gmail.com>
      Acked-by: NMaxime Ripard <maxime.ripard@bootlin.com>
      Acked-by: NChen-Yu Tsai <wens@csie.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      32475634
    • Y
      ASoC: max98090: remove 24-bit format support if RJ is 0 · 7b748639
      Yu-Hsuan Hsu 提交于
      [ Upstream commit 5628c8979642a076f91ee86c3bae5ad251639af0 ]
      
      The supported formats are S16_LE and S24_LE now. However, by datasheet
      of max98090, S24_LE is only supported when it is in the right justified
      mode. We should remove 24-bit format if it is not in that mode to avoid
      triggering error.
      Signed-off-by: NYu-Hsuan Hsu <yuhsuan@chromium.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7b748639
    • H
      drm/mediatek: call mtk_dsi_stop() after mtk_drm_crtc_atomic_disable() · 3b60f98e
      Hsin-Yi Wang 提交于
      [ Upstream commit 2458d9d6d94be982b917e93c61a89b4426f32e31 ]
      
      mtk_dsi_stop() should be called after mtk_drm_crtc_atomic_disable(), which
      needs ovl irq for drm_crtc_wait_one_vblank(), since after mtk_dsi_stop() is
      called, ovl irq will be disabled. If drm_crtc_wait_one_vblank() is called
      after last irq, it will timeout with this message: "vblank wait timed out
      on crtc 0". This happens sometimes when turning off the screen.
      
      In drm_atomic_helper.c#disable_outputs(),
      the calling sequence when turning off the screen is:
      
      1. mtk_dsi_encoder_disable()
           --> mtk_output_dsi_disable()
             --> mtk_dsi_stop();  /* sometimes make vblank timeout in
                                     atomic_disable */
             --> mtk_dsi_poweroff();
      2. mtk_drm_crtc_atomic_disable()
           --> drm_crtc_wait_one_vblank();
           ...
             --> mtk_dsi_ddp_stop()
               --> mtk_dsi_poweroff();
      
      mtk_dsi_poweroff() has reference count design, change to make
      mtk_dsi_stop() called in mtk_dsi_poweroff() when refcount is 0.
      
      Fixes: 0707632b ("drm/mediatek: update DSI sub driver flow for sending commands to panel")
      Signed-off-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Signed-off-by: NCK Hu <ck.hu@mediatek.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3b60f98e
    • H
      drm/mediatek: clear num_pipes when unbind driver · 34e5e1c4
      Hsin-Yi Wang 提交于
      [ Upstream commit a4cd1d2b016d5d043ab2c4b9c4ec50a5805f5396 ]
      
      num_pipes is used for mutex created in mtk_drm_crtc_create(). If we
      don't clear num_pipes count, when rebinding driver, the count will
      be accumulated. From mtk_disp_mutex_get(), there can only be at most
      10 mutex id. Clear this number so it starts from 0 in every rebind.
      
      Fixes: 119f5173 ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.")
      Signed-off-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Signed-off-by: NCK Hu <ck.hu@mediatek.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      34e5e1c4
    • H
      drm/mediatek: call drm_atomic_helper_shutdown() when unbinding driver · a8a86e9a
      Hsin-Yi Wang 提交于
      [ Upstream commit cf49b24ffa62766f8f04cd1c4cf17b75d29b240a ]
      
      shutdown all CRTC when unbinding drm driver.
      
      Fixes: 119f5173 ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.")
      Signed-off-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Signed-off-by: NCK Hu <ck.hu@mediatek.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a8a86e9a
    • H
      drm/mediatek: unbind components in mtk_drm_unbind() · 79e095d2
      Hsin-Yi Wang 提交于
      [ Upstream commit f0fd848342802bc0f74620d387eead53e8905804 ]
      
      Unbinding components (i.e. mtk_dsi and mtk_disp_ovl/rdma/color) will
      trigger master(mtk_drm)'s .unbind(), and currently mtk_drm's unbind
      won't actually unbind components. During the next bind,
      mtk_drm_kms_init() is called, and the components are added back.
      
      .unbind() should call mtk_drm_kms_deinit() to unbind components.
      
      And since component_master_del() in .remove() will trigger .unbind(),
      which will also unregister device, it's fine to remove original functions
      called here.
      
      Fixes: 119f5173 ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.")
      Signed-off-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Signed-off-by: NCK Hu <ck.hu@mediatek.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      79e095d2
    • H
      drm/mediatek: fix unbind functions · 319f4699
      Hsin-Yi Wang 提交于
      [ Upstream commit 8fd7a37b191f93737f6280a9b5de65f98acc12c9 ]
      
      detatch panel in mtk_dsi_destroy_conn_enc(), since .bind will try to
      attach it again.
      
      Fixes: 2e54c14e ("drm/mediatek: Add DSI sub driver")
      Signed-off-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Signed-off-by: NCK Hu <ck.hu@mediatek.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      319f4699
    • Y
      spi: bitbang: Fix NULL pointer dereference in spi_unregister_master · dbd94f49
      YueHaibing 提交于
      [ Upstream commit 5caaf29af5ca82d5da8bc1d0ad07d9e664ccf1d8 ]
      
      If spi_register_master fails in spi_bitbang_start
      because device_add failure, We should return the
      error code other than 0, otherwise calling
      spi_bitbang_stop may trigger NULL pointer dereference
      like this:
      
      BUG: KASAN: null-ptr-deref in __list_del_entry_valid+0x45/0xd0
      Read of size 8 at addr 0000000000000000 by task syz-executor.0/3661
      
      CPU: 0 PID: 3661 Comm: syz-executor.0 Not tainted 5.1.0+ #28
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
      Call Trace:
       dump_stack+0xa9/0x10e
       ? __list_del_entry_valid+0x45/0xd0
       ? __list_del_entry_valid+0x45/0xd0
       __kasan_report+0x171/0x18d
       ? __list_del_entry_valid+0x45/0xd0
       kasan_report+0xe/0x20
       __list_del_entry_valid+0x45/0xd0
       spi_unregister_controller+0x99/0x1b0
       spi_lm70llp_attach+0x3ae/0x4b0 [spi_lm70llp]
       ? 0xffffffffc1128000
       ? klist_next+0x131/0x1e0
       ? driver_detach+0x40/0x40 [parport]
       port_check+0x3b/0x50 [parport]
       bus_for_each_dev+0x115/0x180
       ? subsys_dev_iter_exit+0x20/0x20
       __parport_register_driver+0x1f0/0x210 [parport]
       ? 0xffffffffc1150000
       do_one_initcall+0xb9/0x3b5
       ? perf_trace_initcall_level+0x270/0x270
       ? kasan_unpoison_shadow+0x30/0x40
       ? kasan_unpoison_shadow+0x30/0x40
       do_init_module+0xe0/0x330
       load_module+0x38eb/0x4270
       ? module_frob_arch_sections+0x20/0x20
       ? kernel_read_file+0x188/0x3f0
       ? find_held_lock+0x6d/0xd0
       ? fput_many+0x1a/0xe0
       ? __do_sys_finit_module+0x162/0x190
       __do_sys_finit_module+0x162/0x190
       ? __ia32_sys_init_module+0x40/0x40
       ? __mutex_unlock_slowpath+0xb4/0x3f0
       ? wait_for_completion+0x240/0x240
       ? vfs_write+0x160/0x2a0
       ? lockdep_hardirqs_off+0xb5/0x100
       ? mark_held_locks+0x1a/0x90
       ? do_syscall_64+0x14/0x2a0
       do_syscall_64+0x72/0x2a0
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Fixes: 702a4879 ("spi: bitbang: Let spi_bitbang_start() take a reference to master")
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: NAxel Lin <axel.lin@ingics.com>
      Reviewed-by: NMukesh Ojha <mojha@codeaurora.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      dbd94f49
    • V
      ASoC: ak4458: rstn_control - return a non-zero on error only · 3f8d3c95
      Viorel Suman 提交于
      [ Upstream commit 176a11834b65ec35e3b7a953f87fb9cc41309497 ]
      
      snd_soc_component_update_bits() may return 1 if operation
      was successful and the value of the register changed.
      Return a non-zero in ak4458_rstn_control for an error only.
      Signed-off-by: NShengjiu Wang <shengjiu.wang@nxp.com>
      Signed-off-by: NViorel Suman <viorel.suman@nxp.com>
      Reviewed-by: NDaniel Baluta <daniel.baluta@nxp.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3f8d3c95
    • L
      ASoC: soc-pcm: BE dai needs prepare when pause release after resume · 3c3dd68c
      Libin Yang 提交于
      [ Upstream commit 5087a8f17df868601cd7568299e91c28086d2b45 ]
      
      If playback/capture is paused and system enters S3, after system returns
      from suspend, BE dai needs to call prepare() callback when playback/capture
      is released from pause if RESUME_INFO flag is not set.
      
      Currently, the dpcm_be_dai_prepare() function will block calling prepare()
      if the pcm is in SND_SOC_DPCM_STATE_PAUSED state. This will cause the
      following test case fail if the pcm uses BE:
      
      playback -> pause -> S3 suspend -> S3 resume -> pause release
      
      The playback may exit abnormally when pause is released because the BE dai
      prepare() is not called.
      
      This patch allows dpcm_be_dai_prepare() to call dai prepare() callback in
      SND_SOC_DPCM_STATE_PAUSED state.
      Signed-off-by: NLibin Yang <libin.yang@intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3c3dd68c
    • V
      ASoC: ak4458: add return value for ak4458_probe · 4c31b4b4
      Viorel Suman 提交于
      [ Upstream commit a8dee20d792432740509237943700fbcfc230bad ]
      
      AK4458 is probed successfully even if AK4458 is not present - this
      is caused by probe function returning no error on i2c access failure.
      Return an error on probe if i2c access has failed.
      Signed-off-by: NShengjiu Wang <shengjiu.wang@nxp.com>
      Signed-off-by: NViorel Suman <viorel.suman@nxp.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      4c31b4b4
    • M
      ASoC : cs4265 : readable register too low · 0c19bcdb
      Matt Flax 提交于
      [ Upstream commit f3df05c805983427319eddc2411a2105ee1757cf ]
      
      The cs4265_readable_register function stopped short of the maximum
      register.
      
      An example bug is taken from :
      https://github.com/Audio-Injector/Ultra/issues/25
      
      Where alsactl store fails with :
      Cannot read control '2,0,0,C Data Buffer,0': Input/output error
      
      This patch fixes the bug by setting the cs4265 to have readable
      registers up to the maximum hardware register CS4265_MAX_REGISTER.
      Signed-off-by: NMatt Flax <flatmax@flatmax.org>
      Reviewed-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      0c19bcdb
    • F
      netfilter: nft_flow_offload: IPCB is only valid for ipv4 family · c549680e
      Florian Westphal 提交于
      commit 69aeb538587e087bfc81dd1f465eab3558ff3158 upstream.
      
      Guard this with a check vs. ipv4, IPCB isn't valid in ipv6 case.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c549680e
    • F
      netfilter: nft_flow_offload: don't offload when sequence numbers need adjustment · 041c181e
      Florian Westphal 提交于
      commit 91a9048f238063dde7feea752b9dd386f7e3808b upstream.
      
      We can't deal with tcp sequence number rewrite in flow_offload.
      While at it, simplify helper check, we only need to know if the extension
      is present, we don't need the helper data.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      041c181e
    • F
      netfilter: nft_flow_offload: set liberal tracking mode for tcp · 48f611ec
      Florian Westphal 提交于
      commit 8437a6209f76f85a2db1abb12a9bde2170801617 upstream.
      
      Without it, whenever a packet has to be pushed up the stack (e.g. because
      of mtu mismatch), then conntrack will flag packets as invalid, which in
      turn breaks NAT.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      48f611ec
    • F
      netfilter: nf_flow_table: ignore DF bit setting · 3b2734bc
      Florian Westphal 提交于
      commit e75b3e1c9bc5b997d09bdf8eb72ab3dd3c1a7072 upstream.
      
      Its irrelevant if the DF bit is set or not, we must pass packet to
      stack in either case.
      
      If the DF bit is set, we must pass it to stack so the appropriate
      ICMP error can be generated.
      
      If the DF is not set, we must pass it to stack for fragmentation.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b2734bc
    • G
      md/raid0: Do not bypass blocking queue entered for raid0 bios · 869eec89
      Guilherme G. Piccoli 提交于
      ```--------------------------------------------------------------
      This patch is not on mainline and is meant to 4.19 stable *only*.
      After the patch description there's a reasoning about that.
      ```
      
      --------------------------------------------------------------
      
      Commit cd4a4ae4 ("block: don't use blocking queue entered for
      recursive bio submits") introduced the flag BIO_QUEUE_ENTERED in order
      split bios bypass the blocking queue entering routine and use the live
      non-blocking version. It was a result of an extensive discussion in
      a linux-block thread[0], and the purpose of this change was to prevent
      a hung task waiting on a reference to drop.
      
      Happens that md raid0 split bios all the time, and more important,
      it changes their underlying device to the raid member. After the change
      introduced by this flag's usage, we experience various crashes if a raid0
      member is removed during a large write. This happens because the bio
      reaches the live queue entering function when the queue of the raid0
      member is dying.
      
      A simple reproducer of this behavior is presented below:
      a) Build kernel v4.19.56-stable with CONFIG_BLK_DEV_THROTTLING=y.
      
      b) Create a raid0 md array with 2 NVMe devices as members, and mount
      it with an ext4 filesystem.
      
      c) Run the following oneliner (supposing the raid0 is mounted in /mnt):
      (dd of=/mnt/tmp if=/dev/zero bs=1M count=999 &); sleep 0.3;
      echo 1 > /sys/block/nvme1n1/device/device/remove
      (whereas nvme1n1 is the 2nd array member)
      
      This will trigger the following warning/oops:
      
      ------------[ cut here ]------------
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000155
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP PTI
      RIP: 0010:blk_throtl_bio+0x45/0x970
      [...]
      Call Trace:
       generic_make_request_checks+0x1bf/0x690
       generic_make_request+0x64/0x3f0
       raid0_make_request+0x184/0x620 [raid0]
       ? raid0_make_request+0x184/0x620 [raid0]
       md_handle_request+0x126/0x1a0
       md_make_request+0x7b/0x180
       generic_make_request+0x19e/0x3f0
       submit_bio+0x73/0x140
      [...]
      
      This patch changes raid0 driver to fallback to the "old" blocking queue
      entering procedure, by clearing the BIO_QUEUE_ENTERED from raid0 bios.
      This prevents the crashes and restores the regular behavior of raid0
      arrays when a member is removed during a large write.
      
      [0] lore.kernel.org/linux-block/343bbbf6-64eb-879e-d19e-96aebb037d47@I-love.SAKURA.ne.jp
      
      ----------------------------
      Why this is not on mainline?
      ----------------------------
      
      The patch was originally submitted upstream in linux-raid and
      linux-block mailing-lists - it was initially accepted by Song Liu,
      but Christoph Hellwig[1] observed that there was a clean-up series
      ready to be accepted from Ming Lei[2] that fixed the same issue.
      
      The accepted patches from Ming's series in upstream are: commit
      47cdee29ef9d ("block: move blk_exit_queue into __blk_release_queue") and
      commit fe2008640ae3 ("block: don't protect generic_make_request_checks
      with blk_queue_enter"). Those patches basically do a clean-up in the
      block layer involving:
      
      1) Putting back blk_exit_queue() logic into __blk_release_queue(); that
      path was changed in the past and the logic from blk_exit_queue() was
      added to blk_cleanup_queue().
      
      2) Removing the guard/protection in generic_make_request_checks() with
      blk_queue_enter().
      
      The problem with Ming's series for -stable is that it relies in the
      legacy request IO path removal. So it's "backport-able" to v5.0+,
      but doing that for early versions (like 4.19) would incur in complex
      code changes. Hence, it was suggested by Christoph and Song Liu that
      this patch was submitted to stable only; otherwise merging it upstream
      would add code to fix a path removed in a subsequent commit.
      
      [1] lore.kernel.org/linux-block/20190521172258.GA32702@infradead.org
      [2] lore.kernel.org/linux-block/20190515030310.20393-1-ming.lei@redhat.com
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Fixes: cd4a4ae4 ("block: don't use blocking queue entered for recursive bio submits")
      Signed-off-by: NGuilherme G. Piccoli <gpiccoli@canonical.com>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      869eec89
    • G
      block: Fix a NULL pointer dereference in generic_make_request() · c9d8d3e9
      Guilherme G. Piccoli 提交于
      ```--------------------------------------------------------------
      This patch is not on mainline and is meant to 4.19 stable *only*.
      After the patch description there's a reasoning about that.
      ```
      
      --------------------------------------------------------------
      
      Commit 37f9579f ("blk-mq: Avoid that submitting a bio concurrently
      with device removal triggers a crash") introduced a NULL pointer
      dereference in generic_make_request(). The patch sets q to NULL and
      enter_succeeded to false; right after, there's an 'if (enter_succeeded)'
      which is not taken, and then the 'else' will dereference q in
      blk_queue_dying(q).
      
      This patch just moves the 'q = NULL' to a point in which it won't trigger
      the oops, although the semantics of this NULLification remains untouched.
      
      A simple test case/reproducer is as follows:
      a) Build kernel v4.19.56-stable with CONFIG_BLK_CGROUP=n.
      
      b) Create a raid0 md array with 2 NVMe devices as members, and mount
      it with an ext4 filesystem.
      
      c) Run the following oneliner (supposing the raid0 is mounted in /mnt):
      (dd of=/mnt/tmp if=/dev/zero bs=1M count=999 &); sleep 0.3;
      echo 1 > /sys/block/nvme1n1/device/device/remove
      (whereas nvme1n1 is the 2nd array member)
      
      This will trigger the following oops:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000078
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP PTI
      RIP: 0010:generic_make_request+0x32b/0x400
      Call Trace:
       submit_bio+0x73/0x140
       ext4_io_submit+0x4d/0x60
       ext4_writepages+0x626/0xe90
       do_writepages+0x4b/0xe0
      [...]
      
      This patch has no functional changes and preserves the md/raid0 behavior
      when a member is removed before kernel v4.17.
      
      ----------------------------
      Why this is not on mainline?
      ----------------------------
      
      The patch was originally submitted upstream in linux-raid and
      linux-block mailing-lists - it was initially accepted by Song Liu,
      but Christoph Hellwig[0] observed that there was a clean-up series
      ready to be accepted from Ming Lei[1] that fixed the same issue.
      
      The accepted patches from Ming's series in upstream are: commit
      47cdee29ef9d ("block: move blk_exit_queue into __blk_release_queue") and
      commit fe2008640ae3 ("block: don't protect generic_make_request_checks
      with blk_queue_enter"). Those patches basically do a clean-up in the
      block layer involving:
      
      1) Putting back blk_exit_queue() logic into __blk_release_queue(); that
      path was changed in the past and the logic from blk_exit_queue() was
      added to blk_cleanup_queue().
      
      2) Removing the guard/protection in generic_make_request_checks() with
      blk_queue_enter().
      
      The problem with Ming's series for -stable is that it relies in the
      legacy request IO path removal. So it's "backport-able" to v5.0+,
      but doing that for early versions (like 4.19) would incur in complex
      code changes. Hence, it was suggested by Christoph and Song Liu that
      this patch was submitted to stable only; otherwise merging it upstream
      would add code to fix a path removed in a subsequent commit.
      
      [0] lore.kernel.org/linux-block/20190521172258.GA32702@infradead.org
      [1] lore.kernel.org/linux-block/20190515030310.20393-1-ming.lei@redhat.com
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Jens Axboe <axboe@kernel.dk>
      Reviewed-by: NBart Van Assche <bvanassche@acm.org>
      Reviewed-by: NMing Lei <ming.lei@redhat.com>
      Tested-by: NEric Ren <renzhengeek@gmail.com>
      Fixes: 37f9579f ("blk-mq: Avoid that submitting a bio concurrently with device removal triggers a crash")
      Signed-off-by: NGuilherme G. Piccoli <gpiccoli@canonical.com>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9d8d3e9
    • M
      Bluetooth: Fix faulty expression for minimum encryption key size check · 5dd6139a
      Matias Karhumaa 提交于
      commit eca94432934fe5f141d084f2e36ee2c0e614cc04 upstream.
      
      Fix minimum encryption key size check so that HCI_MIN_ENC_KEY_SIZE is
      also allowed as stated in the comment.
      
      This bug caused connection problems with devices having maximum
      encryption key size of 7 octets (56-bit).
      
      Fixes: 693cd8ce3f88 ("Bluetooth: Fix regression with minimum encryption key size alignment")
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203997Signed-off-by: NMatias Karhumaa <matias.karhumaa@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5dd6139a
  2. 03 7月, 2019 6 次提交
    • G
      Linux 4.19.57 · 1a059243
      Greg Kroah-Hartman 提交于
      1a059243
    • J
      arm64: insn: Fix ldadd instruction encoding · 3919d91f
      Jean-Philippe Brucker 提交于
      commit c5e2edeb01ae9ffbdde95bdcdb6d3614ba1eb195 upstream.
      
      GCC 8.1.0 reports that the ldadd instruction encoding, recently added to
      insn.c, doesn't match the mask and couldn't possibly be identified:
      
       linux/arch/arm64/include/asm/insn.h: In function 'aarch64_insn_is_ldadd':
       linux/arch/arm64/include/asm/insn.h:280:257: warning: bitwise comparison always evaluates to false [-Wtautological-compare]
      
      Bits [31:30] normally encode the size of the instruction (1 to 8 bytes)
      and the current instruction value only encodes the 4- and 8-byte
      variants. At the moment only the BPF JIT needs this instruction, and
      doesn't require the 1- and 2-byte variants, but to be consistent with
      our other ldr and str instruction encodings, clear the size field in the
      insn value.
      
      Fixes: 34b8ab091f9ef57a ("bpf, arm64: use more scalable stadd over ldxr / stxr loop in xadd")
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Reported-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3919d91f
    • T
      usb: dwc3: Reset num_trbs after skipping · 9c423fd8
      Thinh Nguyen 提交于
      commit c7152763f02e05567da27462b2277a554e507c89 upstream.
      
      Currently req->num_trbs is not reset after the TRBs are skipped and
      processed from the cancelled list. The gadget driver may reuse the
      request with an invalid req->num_trbs, and DWC3 will incorrectly skip
      trbs. To fix this, simply reset req->num_trbs to 0 after skipping
      through all of them.
      
      Fixes: c3acd5901414 ("usb: dwc3: gadget: use num_trbs when skipping TRBs on ->dequeue()")
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Cc: Sasha Levin <sashal@kernel.org>
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c423fd8
    • X
      tipc: pass tunnel dev as NULL to udp_tunnel(6)_xmit_skb · 2bbb6b54
      Xin Long 提交于
      commit c3bcde026684c62d7a2b6f626dc7cf763833875c upstream.
      
      udp_tunnel(6)_xmit_skb() called by tipc_udp_xmit() expects a tunnel device
      to count packets on dev->tstats, a perpcu variable. However, TIPC is using
      udp tunnel with no tunnel device, and pass the lower dev, like veth device
      that only initializes dev->lstats(a perpcu variable) when creating it.
      
      Later iptunnel_xmit_stats() called by ip(6)tunnel_xmit() thinks the dev as
      a tunnel device, and uses dev->tstats instead of dev->lstats. tstats' each
      pointer points to a bigger struct than lstats, so when tstats->tx_bytes is
      increased, other percpu variable's members could be overwritten.
      
      syzbot has reported quite a few crashes due to fib_nh_common percpu member
      'nhc_pcpu_rth_output' overwritten, call traces are like:
      
        BUG: KASAN: slab-out-of-bounds in rt_cache_valid+0x158/0x190
        net/ipv4/route.c:1556
          rt_cache_valid+0x158/0x190 net/ipv4/route.c:1556
          __mkroute_output net/ipv4/route.c:2332 [inline]
          ip_route_output_key_hash_rcu+0x819/0x2d50 net/ipv4/route.c:2564
          ip_route_output_key_hash+0x1ef/0x360 net/ipv4/route.c:2393
          __ip_route_output_key include/net/route.h:125 [inline]
          ip_route_output_flow+0x28/0xc0 net/ipv4/route.c:2651
          ip_route_output_key include/net/route.h:135 [inline]
        ...
      
      or:
      
        kasan: GPF could be caused by NULL-ptr deref or user memory access
        RIP: 0010:dst_dev_put+0x24/0x290 net/core/dst.c:168
          <IRQ>
          rt_fibinfo_free_cpus net/ipv4/fib_semantics.c:200 [inline]
          free_fib_info_rcu+0x2e1/0x490 net/ipv4/fib_semantics.c:217
          __rcu_reclaim kernel/rcu/rcu.h:240 [inline]
          rcu_do_batch kernel/rcu/tree.c:2437 [inline]
          invoke_rcu_callbacks kernel/rcu/tree.c:2716 [inline]
          rcu_process_callbacks+0x100a/0x1ac0 kernel/rcu/tree.c:2697
        ...
      
      The issue exists since tunnel stats update is moved to iptunnel_xmit by
      Commit 039f5062 ("ip_tunnel: Move stats update to iptunnel_xmit()"),
      and here to fix it by passing a NULL tunnel dev to udp_tunnel(6)_xmit_skb
      so that the packets counting won't happen on dev->tstats.
      
      Reported-by: syzbot+9d4c12bfd45a58738d0a@syzkaller.appspotmail.com
      Reported-by: syzbot+a9e23ea2aa21044c2798@syzkaller.appspotmail.com
      Reported-by: syzbot+c4c4b2bb358bb936ad7e@syzkaller.appspotmail.com
      Reported-by: syzbot+0290d2290a607e035ba1@syzkaller.appspotmail.com
      Reported-by: syzbot+a43d8d4e7e8a7a9e149e@syzkaller.appspotmail.com
      Reported-by: syzbot+a47c5f4c6c00fc1ed16e@syzkaller.appspotmail.com
      Fixes: 039f5062 ("ip_tunnel: Move stats update to iptunnel_xmit()")
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2bbb6b54
    • J
      RDMA: Directly cast the sockaddr union to sockaddr · 89c49e7b
      Jason Gunthorpe 提交于
      commit 641114d2af312d39ca9bbc2369d18a5823da51c6 upstream.
      
      gcc 9 now does allocation size tracking and thinks that passing the member
      of a union and then accessing beyond that member's bounds is an overflow.
      
      Instead of using the union member, use the entire union with a cast to
      get to the sockaddr. gcc will now know that the memory extends the full
      size of the union.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89c49e7b
    • W
      futex: Update comments and docs about return values of arch futex code · a319c8ff
      Will Deacon 提交于
      commit 427503519739e779c0db8afe876c1b33f3ac60ae upstream.
      
      The architecture implementations of 'arch_futex_atomic_op_inuser()' and
      'futex_atomic_cmpxchg_inatomic()' are permitted to return only -EFAULT,
      -EAGAIN or -ENOSYS in the case of failure.
      
      Update the comments in the asm-generic/ implementation and also a stray
      reference in the robust futex documentation.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a319c8ff