4.14.185-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 80/190 spi: pxa2xx: Apply CS clk quirk to BXT
In reply to Greg Kroah-HartmanFrom: Evan Green <[email protected]>
[ Upstream commit 6eefaee4f2d366a389da0eb95e524ba82bf358c4 ]
With a couple allies at Intel, and much badgering, I got confirmation from Intel that at least BXT suffers from the same SPI chip-select issue as Cannonlake (and beyond). The issue being that after going through runtime suspend/resume, toggling the chip-select line without also sending data does nothing.
Add the quirk to BXT to briefly toggle dynamic clock gating off and on, forcing the fabric to wake up enough to notice the CS register change.
--- drivers/spi/spi-pxa2xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-pxa2xx.c +1 -0
@@ -156,6 +156,7 @@ static const struct lpss_config lpss_platforms[] = { .tx_threshold_hi = 48, .cs_sel_shift = 8, .cs_sel_mask = 3 << 8, + .cs_clk_stays_gated = true, }, {/* LPSS_CNL_SSP */ .offset = 0x200,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 89/190 clocksource: dw_apb_timer_of: Fix missing clockevent timers
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 6d2e16a3181bafb77b535095c39ad1c8b9558c8c ]
Commit 100214889973 ("clocksource: dw_apb_timer_of: use clocksource_of_init") replaced a publicly available driver initialization method with one called by the timer_probe() method available after CLKSRC_OF. In current implementation it traverses all the timers available in the system and calls their initialization methods if corresponding devices were either in dtb or in acpi. But if before the commit any number of available timers would be installed as clockevent and clocksource devices, after that there would be at most two. The rest are just ignored since default case branch doesn't do anything. I don't see a reason of such behaviour, neither the commit message explains it. Moreover this might be wrong if on some platforms these timers might be used for different purpose, as virtually CPU-local clockevent timers and as an independent broadcast timer. So in order to keep the compatibility with the platforms where the order of the timers detection has some meaning, lets add the secondly discovered timer to be of clocksource/sched_clock type, while the very first and the others would provide the clockevents service.
--- drivers/clocksource/dw_apb_timer_of.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/clocksource/dw_apb_timer_of.c +2 -4
@@ -146,10 +146,6 @@ static int num_called;static int __init dw_apb_timer_init (struct device_node *timer) {switch (num_called) { -case 0 : -pr_debug ("%s: found clockevent timer\n" , __func__); -add_clockevent (timer); -break ;case 1 :pr_debug ("%s: found clocksource timer\n" , __func__);add_clocksource (timer);
@@ -160,6 +156,8 @@ static int __init dw_apb_timer_init(struct device_node *timer)#endif break ;default : +pr_debug ("%s: found clockevent timer\n" , __func__); +add_clockevent (timer);break ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 62/190 ath9k: Fix use-after-free Read in ath9k_wmi_ctrl_rx
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit abeaa85054ff8cfe8b99aafc5c70ea067e5d0908 upstream.
Free wmi later after cmd urb has been killed, as urb cb will access wmi.
the case reported by syzbot:
https://lore.kernel.org/linux-usb/[email protected]
BUG: KASAN: use-after-free in ath9k_wmi_ctrl_rx+0x416/0x500 drivers/net/wireless/ath/ath9k/wmi.c:215 Read of size 1 at addr ffff8881cef1417c by task swapper/1/0 Call Trace: <IRQ> ath9k_wmi_ctrl_rx+0x416/0x500 drivers/net/wireless/ath/ath9k/wmi.c:215 ath9k_htc_rx_msg+0x2da/0xaf0 drivers/net/wireless/ath/ath9k/htc_hst.c:459 ath9k_hif_usb_reg_in_cb+0x1ba/0x630 drivers/net/wireless/ath/ath9k/hif_usb.c:718 __usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++-- drivers/net/wireless/ath/ath9k/hif_usb.h | 1 + drivers/net/wireless/ath/ath9k/htc_drv_init.c | 10 +++++++--- drivers/net/wireless/ath/ath9k/wmi.c | 5 ++++- drivers/net/wireless/ath/ath9k/wmi.h | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +3 -2
@@ -971,7 +971,7 @@ err:return -ENOMEM ; } -static void ath9k_hif_usb_dealloc_urbs (struct hif_device_usb *hif_dev) +void ath9k_hif_usb_dealloc_urbs (struct hif_device_usb *hif_dev) {usb_kill_anchored_urbs (&hif_dev->regout_submitted);ath9k_hif_usb_dealloc_reg_in_urbs (hif_dev);
@@ -1339,8 +1339,9 @@ static void ath9k_hif_usb_disconnect(strif (hif_dev->flags &HIF_USB_READY ) {ath9k_htc_hw_deinit (hif_dev->htc_handle, unplugged); -ath9k_htc_hw_free (hif_dev->htc_handle);ath9k_hif_usb_dev_deinit (hif_dev); +ath9k_destoy_wmi (hif_dev->htc_handle->drv_priv); +ath9k_htc_hw_free (hif_dev->htc_handle); }usb_set_intfdata (interface,NULL );
drivers/net/wireless/ath/ath9k/hif_usb.h +1 -0
@@ -133,5 +133,6 @@ struct hif_device_usb {int ath9k_hif_usb_init (void );void ath9k_hif_usb_exit (void ); +void ath9k_hif_usb_dealloc_urbs (struct hif_device_usb *hif_dev);#endif /* HTC_USB_H */
drivers/net/wireless/ath/ath9k/htc_drv_init.c +7 -3
@@ -933,8 +933,9 @@ err_init:int ath9k_htc_probe_device (struct htc_target *htc_handle,struct device *dev,u16 devid,char *product,u32 drv_info) { -struct ieee80211_hw *hw; +struct hif_device_usb *hif_dev;struct ath9k_htc_priv *priv; +struct ieee80211_hw *hw;int ret; hw =ieee80211_alloc_hw (sizeof (struct ath9k_htc_priv ), &ath9k_htc_ops);
@@ -969,7 +970,10 @@ int ath9k_htc_probe_device(struct htc_tareturn 0 ; err_init: -ath9k_deinit_wmi (priv); +ath9k_stop_wmi (priv); + hif_dev = (struct hif_device_usb *)htc_handle->hif_dev; +ath9k_hif_usb_dealloc_urbs (hif_dev); +ath9k_destoy_wmi (priv); err_free:ieee80211_free_hw (hw);return ret;
@@ -984,7 +988,7 @@ void ath9k_htc_disconnect_device(struct htc_handle->drv_priv->ah->ah_flags |=AH_UNPLUGGED ;ath9k_deinit_device (htc_handle->drv_priv); -ath9k_deinit_wmi (htc_handle->drv_priv); +ath9k_stop_wmi (htc_handle->drv_priv);ieee80211_free_hw (htc_handle->drv_priv->hw); } }
drivers/net/wireless/ath/ath9k/wmi.c +4 -1
@@ -112,14 +112,17 @@ struct wmi *ath9k_init_wmi(struct ath9k_return wmi; } -void ath9k_deinit_wmi (struct ath9k_htc_priv *priv) +void ath9k_stop_wmi (struct ath9k_htc_priv *priv) {struct wmi *wmi = priv->wmi;mutex_lock (&wmi->op_mutex); wmi->stopped = true;mutex_unlock (&wmi->op_mutex); +} +void ath9k_destoy_wmi (struct ath9k_htc_priv *priv) +{kfree (priv->wmi); }
drivers/net/wireless/ath/ath9k/wmi.h +2 -1
@@ -179,7 +179,6 @@ struct wmi { };struct wmi *ath9k_init_wmi (struct ath9k_htc_priv *priv); -void ath9k_deinit_wmi (struct ath9k_htc_priv *priv);int ath9k_wmi_connect (struct htc_target *htc,struct wmi *wmi,enum htc_endpoint_id *wmi_ctrl_epid); int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
@@ -189,6 +188,8 @@ int ath9k_wmi_cmd(struct wmi *wmi, enumvoid ath9k_wmi_event_tasklet (unsigned long data);void ath9k_fatal_work (struct work_struct *work);void ath9k_wmi_event_drain (struct ath9k_htc_priv *priv); +void ath9k_stop_wmi (struct ath9k_htc_priv *priv); +void ath9k_destoy_wmi (struct ath9k_htc_priv *priv);#define WMI_CMD (_wmi_cmd) \ do { \
Greg Kroah-Hartman
maintainerPATCH 84/190 MIPS: Loongson: Build ATI Radeon GPU driver as module
In reply to Greg Kroah-HartmanFrom: Tiezhu Yang <[email protected]>
[ Upstream commit a44de7497f91834df0b8b6d459e259788ba66794 ]
When ATI Radeon GPU driver has been compiled directly into the kernel instead of as a module, we should make sure the firmware for the model (check available ones in /lib/firmware/radeon) is built-in to the kernel as well, otherwise there exists the following fatal error during GPU init, change CONFIG_DRM_RADEON=y to CONFIG_DRM_RADEON=m to fix it.
[ 1.900997] [drm] Loading RS780 Microcode [ 1.905077] radeon 0000:01:05.0: Direct firmware load for radeon/RS780_pfp.bin failed with error -2 [ 1.914140] r600_cp: Failed to load firmware "radeon/RS780_pfp.bin" [ 1.920405] [drm:r600_init] *ERROR* Failed to load firmware! [ 1.926069] radeon 0000:01:05.0: Fatal error during GPU init [ 1.931729] [drm] radeon: finishing device.
--- arch/mips/configs/loongson3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/configs/loongson3_defconfig +1 -1
@@ -250,7 +250,7 @@ CONFIG_MEDIA_CAMERA_SUPPORT=y CONFIG_MEDIA_USB_SUPPORT=y CONFIG_USB_VIDEO_CLASS=m CONFIG_DRM=y -CONFIG_DRM_RADEON=y +CONFIG_DRM_RADEON=m CONFIG_FB_RADEON=y CONFIG_LCD_CLASS_DEVICE=y CONFIG_LCD_PLATFORM=m
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 83/190 ixgbe: Fix XDP redirect on archs with PAGE_SIZE above 4K
In reply to Greg Kroah-HartmanFrom: Jesper Dangaard Brouer <[email protected]>
[ Upstream commit 88eb0ee17b2ece64fcf6689a4557a5c2e7a89c4b ]
The ixgbe driver have another memory model when compiled on archs with PAGE_SIZE above 4096 bytes. In this mode it doesn't split the page in two halves, but instead increment rx_buffer->page_offset by truesize of packet (which include headroom and tailroom for skb_shared_info).
This is done correctly in ixgbe_build_skb(), but in ixgbe_rx_buffer_flip which is currently only called on XDP_TX and XDP_REDIRECT, it forgets to add the tailroom for skb_shared_info. This breaks XDP_REDIRECT, for veth and cpumap. Fix by adding size of skb_shared_info tailroom.
Maintainers notice: This fix have been queued to Jeff.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -1
@@ -2274,7 +2274,8 @@ static void ixgbe_rx_buffer_flip(struct ixgbe_ring *rx_ring, rx_buffer->page_offset ^= truesize;#else unsigned int truesize =ring_uses_build_skb (rx_ring) ? -SKB_DATA_ALIGN (IXGBE_SKB_PAD + size) : +SKB_DATA_ALIGN (IXGBE_SKB_PAD + size) + +SKB_DATA_ALIGN (sizeof (struct skb_shared_info )) :SKB_DATA_ALIGN (size); rx_buffer->page_offset += truesize;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 82/190 spi: dw: Zero DMA Tx and Rx configurations on stack
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 3cb97e223d277f84171cc4ccecab31e08b2ee7b5 ]
Some DMA controller drivers do not tolerate non-zero values in the DMA configuration structures. Zero them to avoid issues with such DMA controller drivers. Even despite above this is a good practice per se.
--- drivers/spi/spi-dw-mid.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-dw-mid.c +2 -0
@@ -155,6 +155,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws,if (!xfer->tx_buf)return NULL ; +memset (&txconf,0 ,sizeof (txconf)); txconf.direction =DMA_MEM_TO_DEV ; txconf.dst_addr = dws->dma_addr; txconf.dst_maxburst =16 ;
@@ -201,6 +202,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,if (!xfer->rx_buf)return NULL ; +memset (&rxconf,0 ,sizeof (rxconf)); rxconf.direction =DMA_DEV_TO_MEM ; rxconf.src_addr = dws->dma_addr; rxconf.src_maxburst =16 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 61/190 KVM: arm64: Make vcpu_cp1x() work on Big Endian hosts
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 3204be4109ad681523e3461ce64454c79278450a upstream.
AArch32 CP1x registers are overlayed on their AArch64 counterparts in the vcpu struct. This leads to an interesting problem as they are stored in their CPU-local format, and thus a CP1x register doesn't "hit" the lower 32bit portion of the AArch64 register on a BE host.
To workaround this unfortunate situation, introduce a bias trick in the vcpu_cp1x() accessors which picks the correct half of the 64bit register.
--- arch/arm64/include/asm/kvm_host.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/include/asm/kvm_host.h +4 -2
@@ -292,8 +292,10 @@ struct kvm_vcpu_arch {* CP14 and CP15 live in the same array, as they are backed by the * same system registers. */ -#define vcpu_cp14 (v,r) ((v)->arch.ctxt.copro[(r)]) -#define vcpu_cp15 (v,r) ((v)->arch.ctxt.copro[(r)]) +#define CPx_BIAS IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) + +#define vcpu_cp14 (v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS]) +#define vcpu_cp15 (v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])#ifdef CONFIG_CPU_BIG_ENDIAN #define vcpu_cp15_64_high (v,r) vcpu_cp15((v),(r))
Greg Kroah-Hartman
maintainerPATCH 34/190 crypto: cavium/nitrox - Fix nitrox_get_first_device() when ndevlist is fully iterated
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit 320bdbd816156f9ca07e5fed7bfb449f2908dda7 upstream.
When a list is completely iterated with 'list_for_each_entry(x, ...)', x is not NULL at the end.
While at it, remove a useless initialization of the ndev variable. It is overridden by 'list_for_each_entry'.
--- drivers/crypto/cavium/nitrox/nitrox_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/cavium/nitrox/nitrox_main.c +2 -2
@@ -183,7 +183,7 @@ static void nitrox_remove_from_devlist(sstruct nitrox_device *nitrox_get_first_device (void ) { -struct nitrox_device *ndev =NULL ; +struct nitrox_device *ndev;mutex_lock (&devlist_lock);list_for_each_entry (ndev, &ndevlist, list) {
@@ -191,7 +191,7 @@ struct nitrox_device *nitrox_get_first_dbreak ; }mutex_unlock (&devlist_lock); -if (!ndev) +if (&ndev->list == &ndevlist)return NULL ;refcount_inc (&ndev->refcnt);
Greg Kroah-Hartman
maintainerPATCH 35/190 ALSA: pcm: disallow linking stream to itself
In reply to Greg Kroah-HartmanFrom: Michał Mirosław <[email protected]>
commit 951e2736f4b11b58dc44d41964fa17c3527d882a upstream.
Prevent SNDRV_PCM_IOCTL_LINK linking stream to itself - the code can't handle it. Fixed commit is not where bug was introduced, but changes the context significantly.
--- sound/core/pcm_native.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/core/pcm_native.c +5 -0
@@ -1950,6 +1950,11 @@ static int snd_pcm_link(struct snd_pcm_s } pcm_file = f.file->private_data; substream1 = pcm_file->substream; +if (substream == substream1) { + res = -EINVAL ; + goto _badf; + } + group =kmalloc (sizeof (*group),GFP_KERNEL );if (!group) { res = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 71/190 mmc: sdhci-msm: Clear tuning done flag while hs400 tuning
In reply to Greg Kroah-HartmanFrom: Veerabhadrarao Badiganti <[email protected]>
commit 9253d71011c349d5f5cc0cebdf68b4a80811b92d upstream.
Clear tuning_done flag while executing tuning to ensure vendor specific HS400 settings are applied properly when the controller is re-initialized in HS400 mode.
Without this, re-initialization of the qcom SDHC in HS400 mode fails while resuming the driver from runtime-suspend or system-suspend.
--- drivers/mmc/host/sdhci-msm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mmc/host/sdhci-msm.c +6 -0
@@ -861,6 +861,12 @@ static int sdhci_msm_execute_tuning(stru msm_host->use_cdr = true;/* +* Clear tuning_done flag before tuning to ensure proper +* HS400 settings. +*/ + msm_host->tuning_done =0 ; + +/* * For HS400 tuning in HS200 timing requires: * - select MCLK/2 in VENDOR_SPEC * - program MCLK to 400MHz (or nearest supported) in GCC
Greg Kroah-Hartman
maintainerPATCH 70/190 agp/intel: Reinforce the barrier after GTT updates
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit f30d3ced9fafa03e4855508929b5b6334907f45e upstream.
After changing the timing between GTT updates and execution on the GPU, we started seeing sporadic failures on Ironlake. These were narrowed down to being an insufficiently strong enough barrier/delay after updating the GTT and scheduling execution on the GPU. By forcing the uncached read, and adding the missing barrier for the singular insert_page (relocation paths), the sporadic failures go away.
--- drivers/char/agp/intel-gtt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/agp/intel-gtt.c +3 -1
@@ -846,6 +846,7 @@ void intel_gtt_insert_page(dma_addr_t ad unsigned int flags) { intel_private.driver->write_entry (addr, pg, flags); +readl (intel_private.gtt + pg);if (intel_private.driver->chipset_flush) intel_private.driver->chipset_flush (); }
@@ -871,7 +872,7 @@ void intel_gtt_insert_sg_entries(struct j++; } } -wmb (); +readl (intel_private.gtt + j -1 );if (intel_private.driver->chipset_flush) intel_private.driver->chipset_flush (); }
@@ -1105,6 +1106,7 @@ static void i9xx_cleanup(void)static void i9xx_chipset_flush (void ) { +wmb ();if (intel_private.i9xx_flush_page)writel (1 , intel_private.i9xx_flush_page); }
Greg Kroah-Hartman
maintainerPATCH 69/190 perf: Add cond_resched() to task_function_call()
In reply to Greg Kroah-HartmanFrom: Barret Rhoden <[email protected]>
commit 2ed6edd33a214bca02bd2b45e3fc3038a059436b upstream.
Under rare circumstances, task_function_call() can repeatedly fail and cause a soft lockup.
There is a slight race where the process is no longer running on the cpu we targeted by the time remote_function() runs. The code will simply try again. If we are very unlucky, this will continue to fail, until a watchdog fires. This can happen in a heavily loaded, multi-core virtual machine.
--- kernel/events/core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
kernel/events/core.c +14 -9
@@ -94,11 +94,11 @@ static void remote_function(void *data)* @info: the function call argument * * Calls the function @func when the task is currently running. This might -* be on the current CPU, which just calls the function directly +* be on the current CPU, which just calls the function directly. This will +* retry due to any failures in smp_call_function_single(), such as if the +* task_cpu() goes offline concurrently. * -* returns: @func return value, or -* -ESRCH - when the process isn't running -* -EAGAIN - when the process moved away +* returns @func return value or -ESRCH when the process isn't running */ static int task_function_call (struct task_struct *p,remote_function_f func,void *info)
@@ -111,11 +111,16 @@ task_function_call(struct task_struct *p };int ret; -do { - ret =smp_call_function_single (task_cpu (p), remote_function, &data,1 ); -if (!ret) - ret = data.ret; - }while (ret == -EAGAIN ); +for (;;) { + ret =smp_call_function_single (task_cpu (p), remote_function, + &data,1 ); + ret = !ret ? data.ret : -EAGAIN ; + +if (ret != -EAGAIN ) +break ; + +cond_resched (); + }return ret; }
Greg Kroah-Hartman
maintainerPATCH 32/190 spi: bcm2835aux: Fix controller unregister order
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
commit b9dd3f6d417258ad0beeb292a1bc74200149f15d upstream.
The BCM2835aux SPI driver uses devm_spi_register_master() on bind. As a consequence, on unbind, __device_release_driver() first invokes bcm2835aux_spi_remove() before unregistering the SPI controller via devres_release_all().
This order is incorrect: bcm2835aux_spi_remove() turns off the SPI controller, including its interrupts and clock. The SPI controller is thus no longer usable.
When the SPI controller is subsequently unregistered, it unbinds all its slave devices. If their drivers need to access the SPI bus, e.g. to quiesce their interrupts, unbinding will fail.
As a rule, devm_spi_register_master() must not be used if the ->remove() hook performs teardown steps which shall be performed after unbinding of slaves.
Fix by using the non-devm variant spi_register_master(). Note that the struct spi_master as well as the driver-private data are not freed until after bcm2835aux_spi_remove() has finished, so accessing them is safe.
--- drivers/spi/spi-bcm2835aux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm2835aux.c +3 -1
@@ -485,7 +485,7 @@ static int bcm2835aux_spi_probe(struct p goto out_clk_disable; } - err =devm_spi_register_master (&pdev->dev, master); + err =spi_register_master (master);if (err) {dev_err (&pdev->dev,"could not register SPI master: %d\n" , err); goto out_clk_disable;
@@ -505,6 +505,8 @@ static int bcm2835aux_spi_remove(structstruct spi_master *master =platform_get_drvdata (pdev);struct bcm2835aux_spi *bs =spi_master_get_devdata (master); +spi_unregister_master (master); +bcm2835aux_spi_reset_hw (bs);/* disable the HW block by releasing the clock */
Greg Kroah-Hartman
maintainerPATCH 30/190 cgroup, blkcg: Prepare some symbols for module and !CONFIG_CGROUP usages
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 9b0eb69b75bccada2d341d7e7ca342f0cb1c9a6a upstream.
btrfs is going to use css_put() and wbc helpers to improve cgroup writeback support. Add dummy css_get() definition and export wbc helpers to prepare for module and !CONFIG_CGROUP builds.
[only backport the export of __inode_attach_wb for stable kernels - gregkh]
--- fs/fs-writeback.c | 1 + 1 file changed, 1 insertion(+)
fs/fs-writeback.c +1 -0
@@ -269,6 +269,7 @@ void __inode_attach_wb(struct inode *inoif (unlikely (cmpxchg (&inode->i_wb,NULL , wb)))wb_put (wb); } +EXPORT_SYMBOL_GPL (__inode_attach_wb);/** * locked_inode_to_wb_and_lock_list - determine a locked inode's wb and lock it
Greg Kroah-Hartman
maintainerPATCH 29/190 ACPI: PM: Avoid using power resources if there are none for D0
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 956ad9d98b73f59e442cc119c98ba1e04e94fe6d upstream.
As recently reported, some platforms provide a list of power resources for device power state D3hot, through the _PR3 object, but they do not provide a list of power resources for device power state D0.
Among other things, this causes acpi_device_get_power() to return D3hot as the current state of the device in question if all of the D3hot power resources are "on", because it sees the power_resources flag set and calls acpi_power_get_inferred_state() which finds that D3hot is the shallowest power state with all of the associated power resources turned "on", so that's what it returns. Moreover, that value takes precedence over the acpi_dev_pm_explicit_get() return value, because it means a deeper power state. The device may very well be in D0 physically at that point, however.
Moreover, the presence of _PR3 without _PR0 for a given device means that only one D3-level power state can be supported by it. Namely, because there are no power resources to turn "off" when transitioning the device from D0 into D3cold (which should be supported since _PR3 is present), the evaluation of _PS3 should be sufficient to put it straight into D3cold, but this means that the effect of turning "on" the _PR3 power resources is unclear, so it is better to avoid doing that altogether. Consequently, there is no practical way do distinguish D3cold from D3hot for the device in question and the power states of it can be labeled so that D3hot is the deepest supported one (and Linux assumes that putting a device into D3hot via ACPI may cause power to be removed from it anyway, for legacy reasons).
To work around the problem described above modify the ACPI enumeration of devices so that power resources are only used for device power management if the list of D0 power resources is not empty and make it mart D3cold as supported only if that is the case and the D3hot list of power resources is not empty too.
--- drivers/acpi/device_pm.c | 2 +- drivers/acpi/scan.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-)
drivers/acpi/device_pm.c +1 -1
@@ -172,7 +172,7 @@ int acpi_device_set_power(struct acpi_de* possibly drop references to the power resources in use. */ state =ACPI_STATE_D3_HOT ; -/* If _PR3 is not available, use D3hot as the target state. */ +/* If D3cold is not supported, use D3hot as the target state. */ if (!device->power.states[ACPI_STATE_D3_COLD ].flags.valid) target_state = state; }else if (!device->power.states[state].flags.valid) {
drivers/acpi/scan.c +19 -9
@@ -920,12 +920,9 @@ static void acpi_bus_init_power_state(stif (buffer.length && package && package->type ==ACPI_TYPE_PACKAGE - && package->package.count) { -int err =acpi_extract_power_resources (package,0 , - &ps->resources); -if (!err) - device->power.flags.power_resources =1 ; - } + && package->package.count) +acpi_extract_power_resources (package,0 , &ps->resources); +ACPI_FREE (buffer.pointer); }
@@ -972,14 +969,27 @@ static void acpi_bus_get_power_flags(stracpi_bus_init_power_state (device, i);INIT_LIST_HEAD (&device->power.states[ACPI_STATE_D3_COLD ].resources); -if (!list_empty (&device->power.states[ACPI_STATE_D3_HOT ].resources)) - device->power.states[ACPI_STATE_D3_COLD ].flags.valid =1 ; -/* Set defaults for D0 and D3hot states (always valid) */ +/* Set the defaults for D0 and D3hot (always supported). */ device->power.states[ACPI_STATE_D0 ].flags.valid =1 ; device->power.states[ACPI_STATE_D0 ].power =100 ; device->power.states[ACPI_STATE_D3_HOT ].flags.valid =1 ; +/* +* Use power resources only if the D0 list of them is populated, because +* some platforms may provide _PR3 only to indicate D3cold support and +* in those cases the power resources list returned by it may be bogus. +*/ +if (!list_empty (&device->power.states[ACPI_STATE_D0 ].resources)) { + device->power.flags.power_resources =1 ; +/* +* D3cold is supported if the D3hot list of power resources is +* not empty. +*/ +if (!list_empty (&device->power.states[ACPI_STATE_D3_HOT ].resources)) + device->power.states[ACPI_STATE_D3_COLD ].flags.valid =1 ; + } +if (acpi_bus_init_power (device)) device->flags.power_manageable =0 ; }
Greg Kroah-Hartman
maintainerPATCH 58/190 KVM: nVMX: Consult only the "basic" exit reason when routing nested exit
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 2ebac8bb3c2d35f5135466490fc8eeaf3f3e2d37 upstream.
Consult only the basic exit reason, i.e. bits 15:0 of vmcs.EXIT_REASON, when determining whether a nested VM-Exit should be reflected into L1 or handled by KVM in L0.
For better or worse, the switch statement in nested_vmx_exit_reflected() currently defaults to "true", i.e. reflects any nested VM-Exit without dedicated logic. Because the case statements only contain the basic exit reason, any VM-Exit with modifier bits set will be reflected to L1, even if KVM intended to handle it in L0.
Practically speaking, this only affects EXIT_REASON_MCE_DURING_VMENTRY, i.e. a #MC that occurs on nested VM-Enter would be incorrectly routed to L1, as "failed VM-Entry" is the only modifier that KVM can currently encounter. The SMM modifiers will never be generated as KVM doesn't support/employ a SMI Transfer Monitor. Ditto for "exit from enclave", as KVM doesn't yet support virtualizing SGX, i.e. it's impossible to enter an enclave in a KVM guest (L1 or L2).
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx.c +1 -1
@@ -8711,7 +8711,7 @@ static bool nested_vmx_exit_reflected(stvmcs_read32 (VM_EXIT_INTR_ERROR_CODE ), KVM_ISA_VMX); -switch (exit_reason) { +switch ((u16 )exit_reason) {case EXIT_REASON_EXCEPTION_NMI :if (is_nmi (intr_info))return false;
Greg Kroah-Hartman
maintainerPATCH 54/190 proc: Use new_inode not new_inode_pseudo
In reply to Greg Kroah-HartmanFrom: Eric W. Biederman <[email protected]>
commit ef1548adada51a2f32ed7faef50aa465e1b4c5da upstream.
Recently syzbot reported that unmounting proc when there is an ongoing inotify watch on the root directory of proc could result in a use after free when the watch is removed after the unmount of proc when the watcher exits.
Commit 69879c01a0c3 ("proc: Remove the now unnecessary internal mount of proc") made it easier to unmount proc and allowed syzbot to see the problem, but looking at the code it has been around for a long time.
Looking at the code the fsnotify watch should have been removed by fsnotify_sb_delete in generic_shutdown_super. Unfortunately the inode was allocated with new_inode_pseudo instead of new_inode so the inode was not on the sb->s_inodes list. Which prevented fsnotify_unmount_inodes from finding the inode and removing the watch as well as made it so the "VFS: Busy inodes after unmount" warning could not find the inodes to warn about them.
Make all of the inodes in proc visible to generic_shutdown_super, and fsnotify_sb_delete by using new_inode instead of new_inode_pseudo. The only functional difference is that new_inode places the inodes on the sb->s_inodes list.
I wrote a small test program and I can verify that without changes it can trigger this issue, and by replacing new_inode_pseudo with new_inode the issues goes away.
--- fs/proc/inode.c | 2 +- fs/proc/self.c | 2 +- fs/proc/thread_self.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
fs/proc/inode.c +1 -1
@@ -432,7 +432,7 @@ const struct inode_operations proc_link_struct inode *proc_get_inode (struct super_block *sb,struct proc_dir_entry *de) { -struct inode *inode =new_inode_pseudo (sb); +struct inode *inode =new_inode (sb);if (inode) { inode->i_ino = de->low_ino;
fs/proc/self.c +1 -1
@@ -41,7 +41,7 @@ int proc_setup_self(struct super_block *inode_lock (root_inode); self =d_alloc_name (s->s_root,"self" );if (self) { -struct inode *inode =new_inode_pseudo (s); +struct inode *inode =new_inode (s);if (inode) { inode->i_ino = self_inum; inode->i_mtime = inode->i_atime = inode->i_ctime =current_time (inode);
fs/proc/thread_self.c +1 -1
@@ -42,7 +42,7 @@ int proc_setup_thread_self(struct super_inode_lock (root_inode); thread_self =d_alloc_name (s->s_root,"thread-self" );if (thread_self) { -struct inode *inode =new_inode_pseudo (s); +struct inode *inode =new_inode (s);if (inode) { inode->i_ino = thread_self_inum; inode->i_mtime = inode->i_atime = inode->i_ctime =current_time (inode);
Greg Kroah-Hartman
maintainerPATCH 53/190 ovl: initialize error in ovl_copy_xattr
In reply to Greg Kroah-HartmanFrom: Yuxuan Shui <[email protected]>
commit 520da69d265a91c6536c63851cbb8a53946974f0 upstream.
In ovl_copy_xattr, if all the xattrs to be copied are overlayfs private xattrs, the copy loop will terminate without assigning anything to the error variable, thus returning an uninitialized value.
If ovl_copy_xattr is called from ovl_clear_empty, this uninitialized error value is put into a pointer by ERR_PTR(), causing potential invalid memory accesses down the line.
This commit initialize error with 0. This is the correct value because when there's no xattr to copy, because all xattrs are private, ovl_copy_xattr should succeed.
This bug is discovered with the help of INIT_STACK_ALL and clang.
--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/copy_up.c +1 -1
@@ -59,7 +59,7 @@ int ovl_copy_xattr(struct dentry *old, s {ssize_t list_size, size, value_size =0 ;char *buf, *name, *value =NULL ; -int uninitialized_var (error ); +int error =0 ;size_t slen; if (!(old->d_inode->i_opflags & IOP_XATTR) ||
Greg Kroah-Hartman
maintainerPATCH 28/190 ACPI: GED: add support for _Exx / _Lxx handler methods
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit ea6f3af4c5e63f6981c0b0ab8ebec438e2d5ef40 upstream.
Per the ACPI spec, interrupts in the range [0, 255] may be handled in AML using individual methods whose naming is based on the format _Exx or _Lxx, where xx is the hex representation of the interrupt index.
Add support for this missing feature to our ACPI GED driver.
--- drivers/acpi/evged.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/evged.c +19 -3
@@ -82,6 +82,8 @@ static acpi_status acpi_ged_request_intestruct resource r;struct acpi_resource_irq *p = &ares->data.irq;struct acpi_resource_extended_irq *pext = &ares->data.extended_irq; +char ev_name[5 ]; +u8 trigger;if (ares->type ==ACPI_RESOURCE_TYPE_END_TAG )return AE_OK ;
@@ -90,14 +92,28 @@ static acpi_status acpi_ged_request_intedev_err (dev,"unable to parse IRQ resource\n" );return AE_ERROR ; } -if (ares->type ==ACPI_RESOURCE_TYPE_IRQ ) +if (ares->type ==ACPI_RESOURCE_TYPE_IRQ ) { gsi = p->interrupts[0 ]; -else + trigger = p->triggering; + }else { gsi = pext->interrupts[0 ]; + trigger = p->triggering; + } irq = r.start; -if (ACPI_FAILURE (acpi_get_handle (handle,"_EVT" , &evt_handle))) { +switch (gsi) { + case 0 ... 255: +sprintf (ev_name,"_%c%02hhX" , + trigger ==ACPI_EDGE_SENSITIVE ?'E' :'L' , gsi); + +if (ACPI_SUCCESS (acpi_get_handle (handle, ev_name, &evt_handle))) +break ; +/* fall through */ +default : +if (ACPI_SUCCESS (acpi_get_handle (handle,"_EVT" , &evt_handle))) +break ; +dev_err (dev,"cannot locate _EVT method\n" );return AE_ERROR ; }
Greg Kroah-Hartman
maintainerPATCH 45/190 spi: No need to assign dummy value in spi_unregister_controller()
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit ebc37af5e0a134355ea2b62ed4141458bdbd5389 ]
The device_for_each_child() doesn't require the returned value to be checked. Thus, drop the dummy variable completely and have no warning anymore:
drivers/spi/spi.c: In function ‘spi_unregister_controller’:drivers/spi/spi.c:2480:6: warning: variable ‘dummy’ set but not used [-Wunused-but-set-variable]
int dummy;
^~~~~--- drivers/spi/spi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi.c +1 -2
@@ -2264,7 +2264,6 @@ void spi_unregister_controller(struct spi_controller *ctlr) {struct spi_controller *found;int id = ctlr->bus_num; -int dummy;/* First make sure that this controller was ever added */ mutex_lock (&board_lock);
@@ -2278,7 +2277,7 @@ void spi_unregister_controller(struct spi_controller *ctlr)list_del (&ctlr->list);mutex_unlock (&board_lock); - dummy =device_for_each_child (&ctlr->dev,NULL , __unregister); +device_for_each_child (&ctlr->dev,NULL , __unregister);device_unregister (&ctlr->dev);/* free bus id */ mutex_lock (&board_lock);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 38/190 KVM: x86: only do L1TF workaround on affected processors
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
[ Upstream commit d43e2675e96fc6ae1a633b6a69d296394448cc32 ]
KVM stores the gfn in MMIO SPTEs as a caching optimization. These are split in two parts, as in "[high 11111 low]", to thwart any attempt to use these bits in an L1TF attack. This works as long as there are 5 free bits between MAXPHYADDR and bit 50 (inclusive), leaving bit 51 free so that the MMIO access triggers a reserved-bit-set page fault.
The bit positions however were computed wrongly for AMD processors that have encryption support. In this case, x86_phys_bits is reduced (for example from 48 to 43, to account for the C bit at position 47 and four bits used internally to store the SEV ASID and other stuff) while x86_cache_bits in would remain set to 48, and _all_ bits between the reduced MAXPHYADDR and bit 51 are set. Then low_phys_bits would also cover some of the bits that are set in the shadow_mmio_value, terribly confusing the gfn caching mechanism.
To fix this, avoid splitting gfns as long as the processor does not have the L1TF bug (which includes all AMD processors). When there is no splitting, low_phys_bits can be set to the reduced MAXPHYADDR removing the overlap. This fixes "npt=0" operation on EPYC processors.
Thanks to Maxim Levitsky for bisecting this bug.
--- arch/x86/kvm/mmu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
arch/x86/kvm/mmu.c +10 -9
@@ -275,6 +275,8 @@ static bool is_executable_pte(u64 spte);void kvm_mmu_set_mmio_spte_mask (u64 mmio_mask,u64 mmio_value) {BUG_ON ((mmio_mask & mmio_value) != mmio_value); +WARN_ON (mmio_value & (shadow_nonpresent_or_rsvd_mask << shadow_nonpresent_or_rsvd_mask_len)); +WARN_ON (mmio_value & shadow_nonpresent_or_rsvd_lower_gfn_mask); shadow_mmio_value = mmio_value |SPTE_SPECIAL_MASK ; shadow_mmio_mask = mmio_mask |SPTE_SPECIAL_MASK ; }
@@ -467,16 +469,15 @@ static void kvm_mmu_reset_all_pte_masks(void)* the most significant bits of legal physical address space. */ shadow_nonpresent_or_rsvd_mask =0 ; - low_phys_bits = boot_cpu_data.x86_cache_bits; -if (boot_cpu_data.x86_cache_bits < -52 - shadow_nonpresent_or_rsvd_mask_len) { + low_phys_bits = boot_cpu_data.x86_phys_bits; +if (boot_cpu_has_bug (X86_BUG_L1TF ) && + !WARN_ON_ONCE (boot_cpu_data.x86_cache_bits >= +52 - shadow_nonpresent_or_rsvd_mask_len)) { + low_phys_bits = boot_cpu_data.x86_cache_bits + - shadow_nonpresent_or_rsvd_mask_len; shadow_nonpresent_or_rsvd_mask = -rsvd_bits (boot_cpu_data.x86_cache_bits - - shadow_nonpresent_or_rsvd_mask_len, - boot_cpu_data.x86_cache_bits -1 ); - low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; - }else -WARN_ON_ONCE (boot_cpu_has_bug (X86_BUG_L1TF )); +rsvd_bits (low_phys_bits, boot_cpu_data.x86_cache_bits -1 ); + } shadow_nonpresent_or_rsvd_lower_gfn_mask =GENMASK_ULL (low_phys_bits -1 ,PAGE_SHIFT );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 43/190 spi: dw: fix possible race condition
In reply to Greg Kroah-Hartman[ Upstream commit 66b19d762378785d1568b5650935205edfeb0503 ]
It is possible to get an interrupt as soon as it is requested. dw_spi_irq does spi_controller_get_devdata(master) and expects it to be different than NULL. However, spi_controller_set_devdata() is called after request_irq(), resulting in the following crash:
CPU 0 Unable to handle kernel paging request at virtual address 00000030, epc == 8058e09c, ra == 8018ff90 [...]
Call Trace: [<8058e09c>] dw_spi_irq+0x8/0x64 [<8018ff90>] __handle_irq_event_percpu+0x70/0x1d4 [<80190128>] handle_irq_event_percpu+0x34/0x8c [<801901c4>] handle_irq_event+0x44/0x80 [<801951a8>] handle_level_irq+0xdc/0x194 [<8018f580>] generic_handle_irq+0x38/0x50 [<804c6924>] ocelot_irq_handler+0x104/0x1c0
--- drivers/spi/spi-dw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-dw.c +2 -1
@@ -499,6 +499,8 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) dws->dma_addr = (dma_addr_t)(dws->paddr +DW_SPI_DR );spin_lock_init (&dws->buf_lock); +spi_master_set_devdata (master, dws); + ret =request_irq (dws->irq, dw_spi_irq,IRQF_SHARED ,dev_name (dev), master);if (ret <0 ) {
@@ -532,7 +534,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) } } -spi_master_set_devdata (master, dws); ret =devm_spi_register_master (dev, master);if (ret) {dev_err (&master->dev,"problem registering spi master\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 41/190 x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS.
In reply to Greg Kroah-HartmanFrom: Anthony Steinhauser <[email protected]>
[ Upstream commit 21998a351512eba4ed5969006f0c55882d995ada ]
When STIBP is unavailable or enhanced IBRS is available, Linux force-disables the IBPB mitigation of Spectre-BTB even when simultaneous multithreading is disabled. While attempts to enable IBPB using prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIRECT_BRANCH, ...) fail with EPERM, the seccomp syscall (or its prctl(PR_SET_SECCOMP, ...) equivalent) which are used e.g. by Chromium or OpenSSH succeed with no errors but the application remains silently vulnerable to cross-process Spectre v2 attacks (classical BTB poisoning). At the same time the SYSFS reporting (/sys/devices/system/cpu/vulnerabilities/spectre_v2) displays that IBPB is conditionally enabled when in fact it is unconditionally disabled.
STIBP is useful only when SMT is enabled. When SMT is disabled and STIBP is unavailable, it makes no sense to force-disable also IBPB, because IBPB protects against cross-process Spectre-BTB attacks regardless of the SMT state. At the same time since missing STIBP was only observed on AMD CPUs, AMD does not recommend using STIBP, but recommends using IBPB, so disabling IBPB because of missing STIBP goes directly against AMD's advice:
https://developer.amd.com/wp-content/resources/Architecture_Guidelines_Update_Indirect_Branch_Control.pdf
Similarly, enhanced IBRS is designed to protect cross-core BTB poisoning and BTB-poisoning attacks from user space against kernel (and BTB-poisoning attacks from guest against hypervisor), it is not designed to prevent cross-process (or cross-VM) BTB poisoning between processes (or VMs) running on the same core. Therefore, even with enhanced IBRS it is necessary to flush the BTB during context-switches, so there is no reason to force disable IBPB when enhanced IBRS is available.
Enable the prctl control of IBPB even when STIBP is unavailable or enhanced IBRS is available.
--- arch/x86/kernel/cpu/bugs.c | 87 ++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 37 deletions(-)
arch/x86/kernel/cpu/bugs.c +50 -37
@@ -581,7 +581,9 @@ early_param("nospectre_v1", nospectre_v1_cmdline);static enum spectre_v2_mitigation spectre_v2_enabled__ro_after_init =SPECTRE_V2_NONE ; -static enum spectre_v2_user_mitigation spectre_v2_user__ro_after_init = +static enum spectre_v2_user_mitigation spectre_v2_user_stibp__ro_after_init = +SPECTRE_V2_USER_NONE ; +static enum spectre_v2_user_mitigation spectre_v2_user_ibpb__ro_after_init =SPECTRE_V2_USER_NONE ;#ifdef CONFIG_RETPOLINE
@@ -727,15 +729,6 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd)break ; } -/* -* At this point, an STIBP mode other than "off" has been set. -* If STIBP support is not being forced, check if STIBP always-on -* is preferred. -*/ -if (mode !=SPECTRE_V2_USER_STRICT && -boot_cpu_has (X86_FEATURE_AMD_STIBP_ALWAYS_ON )) - mode =SPECTRE_V2_USER_STRICT_PREFERRED ; -/* Initialize Indirect Branch Prediction Barrier */ if (boot_cpu_has (X86_FEATURE_IBPB )) {setup_force_cpu_cap (X86_FEATURE_USE_IBPB );
@@ -758,23 +751,36 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd)pr_info ("mitigation: Enabling %s Indirect Branch Prediction Barrier\n" ,static_key_enabled (&switch_mm_always_ibpb) ?"always-on" :"conditional" ); + + spectre_v2_user_ibpb = mode; } -/* If enhanced IBRS is enabled no STIBP required */ -if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED ) +/* +* If enhanced IBRS is enabled or SMT impossible, STIBP is not +* required. +*/ +if (!smt_possible || spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )return ;/* -* If SMT is not possible or STIBP is not available clear the STIBP -* mode. +* At this point, an STIBP mode other than "off" has been set. +* If STIBP support is not being forced, check if STIBP always-on +* is preferred. +*/ +if (mode !=SPECTRE_V2_USER_STRICT && +boot_cpu_has (X86_FEATURE_AMD_STIBP_ALWAYS_ON )) + mode =SPECTRE_V2_USER_STRICT_PREFERRED ; + +/* +* If STIBP is not available, clear the STIBP mode. */ -if (!smt_possible || !boot_cpu_has (X86_FEATURE_STIBP )) +if (!boot_cpu_has (X86_FEATURE_STIBP )) mode =SPECTRE_V2_USER_NONE ; + + spectre_v2_user_stibp = mode; + set_mode: - spectre_v2_user = mode; -/* Only print the STIBP mode when SMT possible */ -if (smt_possible) -pr_info ("%s\n" , spectre_v2_user_strings[mode]); +pr_info ("%s\n" , spectre_v2_user_strings[mode]); }static const char *const spectre_v2_strings[] = {
@@ -1005,7 +1011,7 @@ void arch_smt_update(void) {mutex_lock (&spec_ctrl_mutex); -switch (spectre_v2_user) { +switch (spectre_v2_user_stibp) {case SPECTRE_V2_USER_NONE :break ;case SPECTRE_V2_USER_STRICT :
@@ -1238,14 +1244,16 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl) {switch (ctrl) {case PR_SPEC_ENABLE : -if (spectre_v2_user ==SPECTRE_V2_USER_NONE ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_NONE && + spectre_v2_user_stibp ==SPECTRE_V2_USER_NONE )return 0 ;/* * Indirect branch speculation is always disabled in strict * mode. */ -if (spectre_v2_user ==SPECTRE_V2_USER_STRICT || - spectre_v2_user ==SPECTRE_V2_USER_STRICT_PREFERRED ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED )return -EPERM ;task_clear_spec_ib_disable (task);task_update_spec_tif (task);
@@ -1256,10 +1264,12 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)* Indirect branch speculation is always allowed when * mitigation is force disabled. */ -if (spectre_v2_user ==SPECTRE_V2_USER_NONE ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_NONE && + spectre_v2_user_stibp ==SPECTRE_V2_USER_NONE )return -EPERM ; -if (spectre_v2_user ==SPECTRE_V2_USER_STRICT || - spectre_v2_user ==SPECTRE_V2_USER_STRICT_PREFERRED ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED )return 0 ;task_set_spec_ib_disable (task);if (ctrl ==PR_SPEC_FORCE_DISABLE )
@@ -1290,7 +1300,8 @@ void arch_seccomp_spec_mitigate(struct task_struct *task) {if (ssb_mode ==SPEC_STORE_BYPASS_SECCOMP )ssb_prctl_set (task,PR_SPEC_FORCE_DISABLE ); -if (spectre_v2_user ==SPECTRE_V2_USER_SECCOMP ) +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_SECCOMP || + spectre_v2_user_stibp ==SPECTRE_V2_USER_SECCOMP )ib_prctl_set (task,PR_SPEC_FORCE_DISABLE ); }#endif
@@ -1319,22 +1330,24 @@ static int ib_prctl_get(struct task_struct *task)if (!boot_cpu_has_bug (X86_BUG_SPECTRE_V2 ))return PR_SPEC_NOT_AFFECTED ; -switch (spectre_v2_user) { -case SPECTRE_V2_USER_NONE : +if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_NONE && + spectre_v2_user_stibp ==SPECTRE_V2_USER_NONE )return PR_SPEC_ENABLE ; -case SPECTRE_V2_USER_PRCTL : -case SPECTRE_V2_USER_SECCOMP : +else if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED ) +return PR_SPEC_DISABLE ; +else if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_PRCTL || + spectre_v2_user_ibpb ==SPECTRE_V2_USER_SECCOMP || + spectre_v2_user_stibp ==SPECTRE_V2_USER_PRCTL || + spectre_v2_user_stibp ==SPECTRE_V2_USER_SECCOMP ) {if (task_spec_ib_force_disable (task))return PR_SPEC_PRCTL |PR_SPEC_FORCE_DISABLE ;if (task_spec_ib_disable (task))return PR_SPEC_PRCTL |PR_SPEC_DISABLE ;return PR_SPEC_PRCTL |PR_SPEC_ENABLE ; -case SPECTRE_V2_USER_STRICT : -case SPECTRE_V2_USER_STRICT_PREFERRED : -return PR_SPEC_DISABLE ; -default : + }else return PR_SPEC_NOT_AFFECTED ; - } }int arch_prctl_spec_ctrl_get (struct task_struct *task,unsigned long which)
@@ -1573,7 +1586,7 @@ static char *stibp_state(void)if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )return "" ; -switch (spectre_v2_user) { +switch (spectre_v2_user_stibp) {case SPECTRE_V2_USER_NONE :return ", STIBP: disabled" ;case SPECTRE_V2_USER_STRICT :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 42/190 x86/speculation: PR_SPEC_FORCE_DISABLE enforcement for indirect branches.
In reply to Greg Kroah-HartmanFrom: Anthony Steinhauser <[email protected]>
[ Upstream commit 4d8df8cbb9156b0a0ab3f802b80cb5db57acc0bf ]
Currently, it is possible to enable indirect branch speculation even after it was force-disabled using the PR_SPEC_FORCE_DISABLE option. Moreover, the PR_GET_SPECULATION_CTRL command gives afterwards an incorrect result (force-disabled when it is in fact enabled). This also is inconsistent vs. STIBP and the documention which cleary states that PR_SPEC_FORCE_DISABLE cannot be undone.
Fix this by actually enforcing force-disabled indirect branch speculation. PR_SPEC_ENABLE called after PR_SPEC_FORCE_DISABLE now fails with -EPERM as described in the documentation.
--- arch/x86/kernel/cpu/bugs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +5 -2
@@ -1249,11 +1249,14 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)return 0 ;/* * Indirect branch speculation is always disabled in strict -* mode. +* mode. It can neither be enabled if it was force-disabled +* by a previous prctl call. +*/ if (spectre_v2_user_ibpb ==SPECTRE_V2_USER_STRICT || spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT || - spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED ) + spectre_v2_user_stibp ==SPECTRE_V2_USER_STRICT_PREFERRED || +task_spec_ib_force_disable (task))return -EPERM ;task_clear_spec_ib_disable (task);task_update_spec_tif (task);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 36/190 kvm: x86: Fix L1TF mitigation for shadow MMU
In reply to Greg Kroah-HartmanFrom: Kai Huang <[email protected]>
[ Upstream commit 61455bf26236e7f3d72705382a6437fdfd1bd0af ]
Currently KVM sets 5 most significant bits of physical address bits reported by CPUID (boot_cpu_data.x86_phys_bits) for nonpresent or reserved bits SPTE to mitigate L1TF attack from guest when using shadow MMU. However for some particular Intel CPUs the physical address bits of internal cache is greater than physical address bits reported by CPUID.
Use the kernel's existing boot_cpu_data.x86_cache_bits to determine the five most significant bits. Doing so improves KVM's L1TF mitigation in the unlikely scenario that system RAM overlaps the high order bits of the "real" physical address space as reported by CPUID. This aligns with the kernel's warnings regarding L1TF mitigation, e.g. in the above scenario the kernel won't warn the user about lack of L1TF mitigation if x86_cache_bits is greater than x86_phys_bits.
Also initialize shadow_nonpresent_or_rsvd_mask explicitly to make it consistent with other 'shadow_{xxx}_mask', and opportunistically add a WARN once if KVM's L1TF mitigation cannot be applied on a system that is marked as being susceptible to L1TF.
--- arch/x86/kvm/mmu.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
arch/x86/kvm/mmu.c +13 -5
@@ -460,16 +460,24 @@ static void kvm_mmu_reset_all_pte_masks(void)* If the CPU has 46 or less physical address bits, then set an * appropriate mask to guard against L1TF attacks. Otherwise, it is * assumed that the CPU is not vulnerable to L1TF. +* +* Some Intel CPUs address the L1 cache using more PA bits than are +* reported by CPUID. Use the PA width of the L1 cache when possible +* to achieve more effective mitigation, e.g. if system RAM overlaps +* the most significant bits of legal physical address space. */ - low_phys_bits = boot_cpu_data.x86_phys_bits; -if (boot_cpu_data.x86_phys_bits < + shadow_nonpresent_or_rsvd_mask =0 ; + low_phys_bits = boot_cpu_data.x86_cache_bits; +if (boot_cpu_data.x86_cache_bits <52 - shadow_nonpresent_or_rsvd_mask_len) { shadow_nonpresent_or_rsvd_mask = -rsvd_bits (boot_cpu_data.x86_phys_bits - +rsvd_bits (boot_cpu_data.x86_cache_bits - shadow_nonpresent_or_rsvd_mask_len, - boot_cpu_data.x86_phys_bits -1 ); + boot_cpu_data.x86_cache_bits -1 ); low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; - } + }else +WARN_ON_ONCE (boot_cpu_has_bug (X86_BUG_L1TF )); + shadow_nonpresent_or_rsvd_lower_gfn_mask =GENMASK_ULL (low_phys_bits -1 ,PAGE_SHIFT ); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 39/190 x86/speculation: Change misspelled STIPB to STIBP
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
[ Upstream commit aa77bfb354c495fc4361199e63fc5765b9e1e783 ]
STIBP stands for Single Thread Indirect Branch Predictors. The acronym, however, can be easily mis-spelled as STIPB. It is perhaps due to the presence of another related term - IBPB (Indirect Branch Predictor Barrier).
Fix the mis-spelling in the code.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- arch/x86/kernel/process.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -61,7 +61,7 @@ static u64 __ro_after_init x86_spec_ctrl_mask = SPEC_CTRL_IBRS;u64 __ro_after_init x86_amd_ls_cfg_base;u64 __ro_after_init x86_amd_ls_cfg_ssbd_mask; -/* Control conditional STIPB in switch_to() */ +/* Control conditional STIBP in switch_to() */ DEFINE_STATIC_KEY_FALSE (switch_to_cond_stibp);/* Control conditional IBPB in switch_mm() */ DEFINE_STATIC_KEY_FALSE (switch_mm_cond_ibpb);
@@ -750,12 +750,12 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) "always-on" : "conditional"); } -/* If enhanced IBRS is enabled no STIPB required */ +/* If enhanced IBRS is enabled no STIBP required */ if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )return ;/* -* If SMT is not possible or STIBP is not available clear the STIPB +* If SMT is not possible or STIBP is not available clear the STIBP * mode. */ if (!smt_possible || !boot_cpu_has (X86_FEATURE_STIBP ))
arch/x86/kernel/process.h +1 -1
@@ -19,7 +19,7 @@ static inline void switch_to_extra(struct task_struct *prev,if (IS_ENABLED (CONFIG_SMP )) {/* * Avoid __switch_to_xtra() invocation when conditional -* STIPB is disabled and the only different bit is +* STIBP is disabled and the only different bit is * TIF_SPEC_IB. For CONFIG_SMP=n TIF_SPEC_IB is not * in the TIF_WORK_CTXSW masks. */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 27/190 ACPI: CPPC: Fix reference count leak in acpi_cppc_processor_probe()
In reply to Greg Kroah-HartmanFrom: Qiushi Wu <[email protected]>
commit 4d8be4bc94f74bb7d096e1c2e44457b530d5a170 upstream.
kobject_init_and_add() takes reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Previous commit "b8eb718348b8" fixed a similar problem.
--- drivers/acpi/cppc_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/cppc_acpi.c +1 -0
@@ -800,6 +800,7 @@ int acpi_cppc_processor_probe(struct acp "acpi_cppc");if (ret) {per_cpu (cpc_desc_ptr, pr->id) =NULL ; +kobject_put (&cpc_ptr->kobj); goto out_free; }
Greg Kroah-Hartman
maintainerPATCH 7/190 lib: Reduce user_access_begin() boundaries in strncpy_from_user() and strnlen_user()
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit ab10ae1c3bef56c29bac61e1201c752221b87b41 upstream.
The range passed to user_access_begin() by strncpy_from_user() and strnlen_user() starts at 'src' and goes up to the limit of userspace although reads will be limited by the 'count' param.
On 32 bits powerpc (book3s/32) access has to be granted for each 256Mbytes segment and the cost increases with the number of segments to unlock.
Limit the range with 'count' param.
--- lib/strncpy_from_user.c | 14 +++++++------- lib/strnlen_user.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-)
lib/strncpy_from_user.c +7 -7
@@ -29,13 +29,6 @@ static inline long do_strncpy_from_user(const struct word_at_a_time constants =WORD_AT_A_TIME_CONSTANTS ;unsigned long res =0 ; -/* -* Truncate 'max' to the user-specified limit, so that -* we only have one limit we need to check in the loop -*/ -if (max > count) - max = count; -if (IS_UNALIGNED (src, dst)) goto byte_at_a_time;
@@ -113,6 +106,13 @@ long strncpy_from_user(char *dst, constunsigned long max = max_addr - src_addr;long retval; +/* +* Truncate 'max' to the user-specified limit, so that +* we only have one limit we need to check in the loop +*/ +if (max > count) + max = count; +kasan_check_write (dst, count);check_object_size (dst, count, false);if (user_access_begin (VERIFY_READ , src, max)) {
lib/strnlen_user.c +7 -7
@@ -32,13 +32,6 @@ static inline long do_strnlen_user(constunsigned long c;/* -* Truncate 'max' to the user-specified limit, so that -* we only have one limit we need to check in the loop -*/ -if (max > count) - max = count; - -/* * Do everything aligned. But that means that we * need to also expand the maximum.. */
@@ -114,6 +107,13 @@ long strnlen_user(const char __user *strunsigned long max = max_addr - src_addr;long retval; +/* +* Truncate 'max' to the user-specified limit, so that +* we only have one limit we need to check in the loop +*/ +if (max > count) + max = count; +if (user_access_begin (VERIFY_READ , str, max)) { retval =do_strnlen_user (str, count, max);user_access_end ();
Greg Kroah-Hartman
maintainerPATCH 8/190 serial: imx: Fix handling of TC irq in combination with DMA
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
commit 1866541492641c02874bf51f9d8712b5510f2c64 upstream.
When using RS485 half duplex the Transmitter Complete irq is needed to determine the moment when the transmitter can be disabled. When using DMA this irq must only be enabled when DMA has completed to transfer all data. Otherwise the CPU might busily trigger this irq which is not properly handled and so the also pending irq for the DMA transfer cannot trigger.
--- drivers/tty/serial/imx.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/tty/serial/imx.c +18 -4
@@ -538,6 +538,11 @@ static void dma_tx_callback(void *data)if (!uart_circ_empty (xmit) && !uart_tx_stopped (&sport->port))imx_dma_tx (sport); +else if (sport->port.rs485.flags &SER_RS485_ENABLED ) { + temp =readl (sport->port.membase +UCR4 ); + temp |=UCR4_TCEN ; +writel (temp, sport->port.membase +UCR4 ); + }spin_unlock_irqrestore (&sport->port.lock, flags); }
@@ -555,6 +560,10 @@ static void imx_dma_tx(struct imx_port *if (sport->dma_is_txing)return ; + temp =readl (sport->port.membase +UCR4 ); + temp &= ~UCR4_TCEN ; +writel (temp, sport->port.membase +UCR4 ); + sport->tx_bytes =uart_circ_chars_pending (xmit);if (xmit->tail < xmit->head || xmit->head ==0 ) {
@@ -617,10 +626,15 @@ static void imx_start_tx(struct uart_porif (!(port->rs485.flags &SER_RS485_RX_DURING_TX ))imx_stop_rx (port); -/* enable transmitter and shifter empty irq */ - temp =readl (port->membase +UCR4 ); - temp |=UCR4_TCEN ; -writel (temp, port->membase +UCR4 ); +/* +* Enable transmitter and shifter empty irq only if DMA is off. +* In the DMA case this is done in the tx-callback. +*/ +if (!sport->dma_is_enabled) { + temp =readl (port->membase +UCR4 ); + temp |=UCR4_TCEN ; +writel (temp, port->membase +UCR4 ); + } }if (!sport->dma_is_enabled) {
Greg Kroah-Hartman
maintainerPATCH 22/190 efi/efivars: Add missing kobject_put() in sysfs entry creation error path
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit d8bd8c6e2cfab8b78b537715255be8d7557791c0 upstream.
The documentation provided by kobject_init_and_add() clearly spells out the need to call kobject_put() on the kobject if an error is returned. Add this missing call to the error path.
--- drivers/firmware/efi/efivars.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/firmware/efi/efivars.c +3 -1
@@ -586,8 +586,10 @@ efivar_create_sysfs_entry(struct efivar_ ret =kobject_init_and_add (&new_var->kobj, &efivar_ktype,NULL ,"%s" , short_name);kfree (short_name); -if (ret) +if (ret) { +kobject_put (&new_var->kobj);return ret; + }kobject_uevent (&new_var->kobj,KOBJ_ADD );if (efivar_entry_add (new_var, &efivar_sysfs_list)) {
Greg Kroah-Hartman
maintainerPATCH 5/190 arch/openrisc: Fix issues with access_ok()
In reply to Greg Kroah-HartmanFrom: Stafford Horne <[email protected]>
commit 9cb2feb4d21d97386eb25c7b67e2793efcc1e70a upstream.
The commit 594cc251fdd0 ("make 'user_access_begin()' do 'access_ok()'") exposed incorrect implementations of access_ok() macro in several architectures. This change fixes 2 issues found in OpenRISC.
OpenRISC was not properly using parenthesis for arguments and also using arguments twice. This patch fixes those 2 issues.
I test booted this patch with v5.0-rc1 on qemu and it's working fine.
--- arch/openrisc/include/asm/uaccess.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/openrisc/include/asm/uaccess.h +6 -2
@@ -58,8 +58,12 @@/* Ensure that addr is below task's addr_limit */ #define __addr_ok (addr) ((unsigned long) addr < get_fs()) -#define access_ok (type, addr, size) \ - __range_ok((unsigned long)addr, (unsigned long)size) +#define access_ok (type, addr, size) \ +({ \ + unsigned long __ao_addr = (unsigned long)(addr); \ + unsigned long __ao_size = (unsigned long)(size); \ + __range_ok(__ao_addr, __ao_size); \ +})/* * These are the main single-value transfer routines. They automatically
Greg Kroah-Hartman
maintainerPATCH 3/190 make user_access_begin() do access_ok()
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 594cc251fdd0d231d342d88b2fdff4bc42fb0690 upstream.
Originally, the rule used to be that you'd have to do access_ok() separately, and then user_access_begin() before actually doing the direct (optimized) user access.
But experience has shown that people then decide not to do access_ok() at all, and instead rely on it being implied by other operations or similar. Which makes it very hard to verify that the access has actually been range-checked.
If you use the unsafe direct user accesses, hardware features (either SMAP - Supervisor Mode Access Protection - on x86, or PAN - Privileged Access Never - on ARM) do force you to use user_access_begin(). But nothing really forces the range check.
By putting the range check into user_access_begin(), we actually force people to do the right thing (tm), and the range check vill be visible near the actual accesses. We have way too long a history of people trying to avoid them.
--- arch/x86/include/asm/uaccess.h | 12 +++++++++++- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 17 +++++++++++++++-- include/linux/uaccess.h | 2 +- kernel/compat.c | 6 ++---- kernel/exit.c | 6 ++---- lib/strncpy_from_user.c | 9 +++++---- lib/strnlen_user.c | 9 +++++---- 7 files changed, 41 insertions(+), 20 deletions(-)
arch/x86/include/asm/uaccess.h +11 -1
@@ -711,7 +711,17 @@ extern struct movsl_mask {* checking before using them, but you have to surround them with the * user_access_begin/end() pair. */ -#define user_access_begin () __uaccess_begin() +static __must_check inline bool user_access_begin (int type, +const void __user *ptr, +size_t len) +{ +if (unlikely (!access_ok (type, ptr, len))) +return 0 ; +__uaccess_begin (); +return 1 ; +} + +#define user_access_begin (a, b, c) user_access_begin(a, b, c)#define user_access_end () __uaccess_end()#define unsafe_put_user (x, ptr, err_label) \
drivers/gpu/drm/i915/i915_gem_execbuffer.c +15 -2
@@ -1566,7 +1566,9 @@ static int eb_copy_relocations(const str* happened we would make the mistake of assuming that the * relocations were valid. */ -user_access_begin (); +if (!user_access_begin (VERIFY_WRITE , urelocs, size)) + goto end_user; +for (copied =0 ; copied < nreloc; copied++) unsafe_put_user(-1, &urelocs[copied].presumed_offset,
@@ -2601,6 +2603,7 @@ i915_gem_execbuffer2(struct drm_device *struct drm_i915_gem_execbuffer2 *args = data;struct drm_i915_gem_exec_object2 *exec2_list;struct drm_syncobj **fences =NULL ; +const size_t count = args->buffer_count;int err;if (args->buffer_count <1 || args->buffer_count >SIZE_MAX / sz -1 ) {
@@ -2649,7 +2652,17 @@ i915_gem_execbuffer2(struct drm_device *unsigned int i;/* Copy the new buffer offsets back to the user's exec list. */ -user_access_begin (); +/* +* Note: count * sizeof(*user_exec_list) does not overflow, +* because we checked 'count' in check_buffer_count(). +* +* And this range already got effectively checked earlier +* when we did the "copy_from_user()" above. +*/ +if (!user_access_begin (VERIFY_WRITE , user_exec_list, + count *sizeof (*user_exec_list))) + goto end_user; +for (i =0 ; i < args->buffer_count; i++) {if (!(exec2_list[i].offset &UPDATE ))continue ;
include/linux/uaccess.h +1 -1
@@ -267,7 +267,7 @@ extern long strncpy_from_unsafe(char *ds probe_kernel_read(&retval, addr, sizeof(retval))#ifndef user_access_begin -#define user_access_begin () do { } while (0) +#define user_access_begin (type, ptr, len) access_ok(type, ptr, len)#define user_access_end () do { } while (0)#define unsafe_get_user (x, ptr, err) do { if (unlikely(__get_user(x, ptr))) goto err; } while (0)#define unsafe_put_user (x, ptr, err) do { if (unlikely(__put_user(x, ptr))) goto err; } while (0)
kernel/compat.c +2 -4
@@ -437,10 +437,9 @@ long compat_get_bitmap(unsigned long *ma bitmap_size =ALIGN (bitmap_size,BITS_PER_COMPAT_LONG ); nr_compat_longs =BITS_TO_COMPAT_LONGS (bitmap_size); -if (!access_ok (VERIFY_READ , umask, bitmap_size /8 )) +if (!user_access_begin (VERIFY_READ , umask, bitmap_size /8 ))return -EFAULT ; -user_access_begin ();while (nr_compat_longs >1 ) {compat_ulong_t l1, l2;unsafe_get_user (l1, umask++, Efault);
@@ -467,10 +466,9 @@ long compat_put_bitmap(compat_ulong_t __ bitmap_size =ALIGN (bitmap_size,BITS_PER_COMPAT_LONG ); nr_compat_longs =BITS_TO_COMPAT_LONGS (bitmap_size); -if (!access_ok (VERIFY_WRITE , umask, bitmap_size /8 )) +if (!user_access_begin (VERIFY_WRITE , umask, bitmap_size /8 ))return -EFAULT ; -user_access_begin ();while (nr_compat_longs >1 ) {unsigned long m = *mask++;unsafe_put_user ((compat_ulong_t )m, umask++, Efault);
kernel/exit.c +2 -4
@@ -1597,10 +1597,9 @@ SYSCALL_DEFINE5(waitid, int, which, pid_if (!infop)return err; -if (!access_ok (VERIFY_WRITE , infop,sizeof (*infop))) +if (!user_access_begin (VERIFY_WRITE , infop,sizeof (*infop)))return -EFAULT ; -user_access_begin ();unsafe_put_user (signo, &infop->si_signo, Efault);unsafe_put_user (0 , &infop->si_errno, Efault);unsafe_put_user (info.cause, &infop->si_code, Efault);
@@ -1725,10 +1724,9 @@ COMPAT_SYSCALL_DEFINE5(waitid,if (!infop)return err; -if (!access_ok (VERIFY_WRITE , infop,sizeof (*infop))) +if (!user_access_begin (VERIFY_WRITE , infop,sizeof (*infop)))return -EFAULT ; -user_access_begin ();unsafe_put_user (signo, &infop->si_signo, Efault);unsafe_put_user (0 , &infop->si_errno, Efault);unsafe_put_user (info.cause, &infop->si_code, Efault);
lib/strncpy_from_user.c +5 -4
@@ -115,10 +115,11 @@ long strncpy_from_user(char *dst, constkasan_check_write (dst, count);check_object_size (dst, count, false); -user_access_begin (); - retval =do_strncpy_from_user (dst, src, count, max); -user_access_end (); -return retval; +if (user_access_begin (VERIFY_READ , src, max)) { + retval =do_strncpy_from_user (dst, src, count, max); +user_access_end (); +return retval; + } }return -EFAULT ; }
lib/strnlen_user.c +5 -4
@@ -114,10 +114,11 @@ long strnlen_user(const char __user *strunsigned long max = max_addr - src_addr;long retval; -user_access_begin (); - retval =do_strnlen_user (str, count, max); -user_access_end (); -return retval; +if (user_access_begin (VERIFY_READ , str, max)) { + retval =do_strnlen_user (str, count, max); +user_access_end (); +return retval; + } }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 19/190 x86/PCI: Mark Intel C620 MROMs as having non-compliant BARs
In reply to Greg Kroah-HartmanFrom: Xiaochun Lee <[email protected]>
commit 1574051e52cb4b5b7f7509cfd729b76ca1117808 upstream.
The Intel C620 Platform Controller Hub has MROM functions that have non-PCI registers (undocumented in the public spec) where BAR 0 is supposed to be, which results in messages like this:
pci 0000:00:11.0: [Firmware Bug]: reg 0x30: invalid BAR (can't size)
Mark these MROM functions as having non-compliant BARs so we don't try to probe any of them. There are no other BARs on these devices.
See the Intel C620 Series Chipset Platform Controller Hub Datasheet, May 2019, Document Number 336067-007US, sec 2.1, 35.5, 35.6.
--- arch/x86/pci/fixup.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/pci/fixup.c +4 -0
@@ -572,6 +572,10 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INDECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6f60 , pci_invalid_bar);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6fa0 , pci_invalid_bar);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6fc0 , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa1ec , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa1ed , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa26c , pci_invalid_bar); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0xa26d , pci_invalid_bar);/* * Device [1022:7808]
Greg Kroah-Hartman
maintainerPATCH 16/190 perf probe: Accept the instance number of kretprobe event
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit c6aab66a728b6518772c74bd9dff66e1a1c652fd ]
Since the commit 6a13a0d7b4d1 ("ftrace/kprobe: Show the maxactive number on kprobe_events") introduced to show the instance number of kretprobe events, the length of the 1st format of the kprobe event will not 1, but it can be longer. This caused a parser error in perf-probe.
Skip the length check the 1st format of the kprobe event to accept this instance number.
Without this fix:
# perf probe -a vfs_read%return
Added new event:
probe:vfs_read__return (on vfs_read%return)You can now use it in all perf tools, such as:
perf record -e probe:vfs_read__return -aR sleep 1
# perf probe -l
Semantic error :Failed to parse event name: r16:probe/vfs_read__return
Error: Failed to show event list.And with this fixes:
# perf probe -a vfs_read%return
...
# perf probe -l
probe:vfs_read__return (on vfs_read%return)Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207587
--- tools/perf/util/probe-event.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/probe-event.c +1 -2
@@ -1762,8 +1762,7 @@ int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev) fmt1_str =strtok_r (argv0_str,":" , &fmt); fmt2_str =strtok_r (NULL ,"/" , &fmt); fmt3_str =strtok_r (NULL ," \t" , &fmt); -if (fmt1_str ==NULL ||strlen (fmt1_str) !=1 || fmt2_str ==NULL - || fmt3_str ==NULL ) { +if (fmt1_str ==NULL || fmt2_str ==NULL || fmt3_str ==NULL ) {semantic_error ("Failed to parse event name: %s\n" , argv[0 ]); ret = -EINVAL ; goto out;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 15/190 ath9k_htc: Silence undersized packet warnings
In reply to Greg Kroah-HartmanFrom: Masashi Honma <[email protected]>
[ Upstream commit 450edd2805982d14ed79733a82927d2857b27cac ]
Some devices like TP-Link TL-WN722N produces this kind of messages frequently.
kernel: ath: phy0: Short RX data len, dropping (dlen: 4)
This warning is useful for developers to recognize that the device (Wi-Fi dongle or USB hub etc) is noisy but not for general users. So this patch make this warning to debug message.
Ref: https://bugzilla.kernel.org/show_bug.cgi?id=207539
--- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +3 -3
@@ -999,9 +999,9 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,* which are not PHY_ERROR (short radar pulses have a length of 3) */ if (unlikely (!rs_datalen || (rs_datalen <10 && !is_phyerr))) { -ath_warn (common, -"Short RX data len, dropping (dlen: %d)\n" , - rs_datalen); +ath_dbg (common,ANY , +"Short RX data len, dropping (dlen: %d)\n" , + rs_datalen); goto rx_next; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 14/190 powerpc/xive: Clear the page tables for the ESB IO mapping
In reply to Greg Kroah-HartmanFrom: Cédric Le Goater <[email protected]>
[ Upstream commit a101950fcb78b0ba20cd487be6627dea58d55c2b ]
Commit 1ca3dec2b2df ("powerpc/xive: Prevent page fault issues in the machine crash handler") fixed an issue in the FW assisted dump of machines using hash MMU and the XIVE interrupt mode under the POWER hypervisor. It forced the mapping of the ESB page of interrupts being mapped in the Linux IRQ number space to make sure the 'crash kexec' sequence worked during such an event. But it didn't handle the un-mapping.
This mapping is now blocking the removal of a passthrough IO adapter under the POWER hypervisor because it expects the guest OS to have cleared all page table entries related to the adapter. If some are still present, the RTAS call which isolates the PCI slot returns error 9001 "valid outstanding translations".
Remove these mapping in the IRQ data cleanup routine.
Under KVM, this cleanup is not required because the ESB pages for the adapter interrupts are un-mapped from the guest by the hypervisor in the KVM XIVE native device. This is now redundant but it's harmless.
--- arch/powerpc/sysdev/xive/common.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/sysdev/xive/common.c +5 -0
@@ -23,6 +23,7 @@#include <linux/slab.h> #include <linux/spinlock.h> #include <linux/msi.h> +#include <linux/vmalloc.h> #include <asm/prom.h> #include <asm/io.h>
@@ -932,12 +933,16 @@ EXPORT_SYMBOL_GPL(is_xive_irq);void xive_cleanup_irq_data (struct xive_irq_data *xd) {if (xd->eoi_mmio) { +unmap_kernel_range ((unsigned long )xd->eoi_mmio, +1u << xd->esb_shift);iounmap (xd->eoi_mmio);if (xd->eoi_mmio == xd->trig_mmio) xd->trig_mmio =NULL ; xd->eoi_mmio =NULL ; }if (xd->trig_mmio) { +unmap_kernel_range ((unsigned long )xd->trig_mmio, +1u << xd->esb_shift);iounmap (xd->trig_mmio); xd->trig_mmio =NULL ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 11/190 sched/fair: Dont NUMA balance for kthreads
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit 18f855e574d9799a0e7489f8ae6fd8447d0dd74a ]
Stefano reported a crash with using SQPOLL with io_uring:
BUG: kernel NULL pointer dereference, address: 00000000000003b0 CPU: 2 PID: 1307 Comm: io_uring-sq Not tainted 5.7.0-rc7 #11 RIP: 0010:task_numa_work+0x4f/0x2c0 Call Trace: task_work_run+0x68/0xa0 io_sq_thread+0x252/0x3d0 kthread+0xf9/0x130 ret_from_fork+0x35/0x40
which is task_numa_work() oopsing on current->mm being NULL.
The task work is queued by task_tick_numa(), which checks if current->mm is NULL at the time of the call. But this state isn't necessarily persistent, if the kthread is using use_mm() to temporarily adopt the mm of a task.
Change the task_tick_numa() check to exclude kernel threads in general, as it doesn't make sense to attempt ot balance for kthreads anyway.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -2643,7 +2643,7 @@ void task_tick_numa(struct rq *rq, struct task_struct *curr)/* * We don't care about NUMA placement if we don't have memory. */ -if (!curr->mm || (curr->flags &PF_EXITING ) || work->next != work) +if ((curr->flags & (PF_EXITING |PF_KTHREAD )) || work->next != work)return ;/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 10/190 ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook
In reply to Greg Kroah-HartmanFrom: Fredrik Strupe <[email protected]>
[ Upstream commit 3866f217aaa81bf7165c7f27362eee5d7919c496 ]
call_undef_hook() in traps.c applies the same instr_mask for both 16-bit and 32-bit thumb instructions. If instr_mask then is only 16 bits wide (0xffff as opposed to 0xffffffff), the first half-word of 32-bit thumb instructions will be masked out. This makes the function match 32-bit thumb instructions where the second half-word is equal to instr_val, regardless of the first half-word.
The result in this case is that all undefined 32-bit thumb instructions with the second half-word equal to 0xde01 (udf #1) work as breakpoints and will raise a SIGTRAP instead of a SIGILL, instead of just the one intended 16-bit instruction. An example of such an instruction is 0xeaa0de01, which is unallocated according to Arm ARM and should raise a SIGILL, but instead raises a SIGTRAP.
This patch fixes the issue by setting all the bits in instr_mask, which will still match the intended 16-bit thumb instruction (where the upper half is always 0), but not any 32-bit thumb instructions.
--- arch/arm/kernel/ptrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/kernel/ptrace.c +2 -2
@@ -228,8 +228,8 @@ static struct undef_hook arm_break_hook = { };static struct undef_hook thumb_break_hook = { - .instr_mask =0xffff , - .instr_val =0xde01 , + .instr_mask =0xffffffff , + .instr_val =0x0000de01 , .cpsr_mask =PSR_T_BIT , .cpsr_val =PSR_T_BIT , .fn = break_trap,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 1/190 ipv6: fix IPV6_ADDRFORM operation logic
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit 79a1f0ccdbb4ad700590f61b00525b390cb53905 ]
Socket option IPV6_ADDRFORM supports UDP/UDPLITE and TCP at present. Previously the checking logic looks like:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; else if (sk->sk_protocol != IPPROTO_TCP) break;
After commit b6f6118901d1 ("ipv6: restrict IPV6_ADDRFORM operation"), TCP was blocked as the logic changed to:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; else if (sk->sk_protocol == IPPROTO_TCP) do_some_check; break; else break;
Then after commit 82c9ae440857 ("ipv6: fix restrict IPV6_ADDRFORM operation") UDP/UDPLITE were blocked as the logic changed to:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; if (sk->sk_protocol == IPPROTO_TCP) do_some_check;
if (sk->sk_protocol != IPPROTO_TCP)
break;
Fix it by using Eric's code and simply remove the break in TCP check, which looks like:
if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
do_some_check; else if (sk->sk_protocol == IPPROTO_TCP) do_some_check; else break;
--- net/ipv6/ipv6_sockglue.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/ipv6/ipv6_sockglue.c +7 -6
@@ -185,14 +185,15 @@ static int do_ipv6_setsockopt(struct soc retv = -EBUSY ;break ; } - } -if (sk->sk_protocol ==IPPROTO_TCP && - sk->sk_prot != &tcpv6_prot) { - retv = -EBUSY ; + }else if (sk->sk_protocol ==IPPROTO_TCP ) { +if (sk->sk_prot != &tcpv6_prot) { + retv = -EBUSY ; +break ; + } + }else {break ; } -if (sk->sk_protocol !=IPPROTO_TCP ) -break ; +if (sk->sk_state !=TCP_ESTABLISHED ) { retv = -ENOTCONN ;break ;
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.185 release. There are 190 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 21 Jun 2020 14:15:50 +0000. Anything received after that time might be too late.
Build results:
total: 171 pass: 171 fail: 0 Qemu test results: total: 408 pass: 408 fail: 0
Guenter
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.185 release. There are 190 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 21 Jun 2020 14:15:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.185-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 4.14.185-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.14.y
git commit: e26bcff6a5af4b6e19e350a39e88637307e07eb8
git describe: v4.14.184-191-ge26bcff6a5af
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.14-oe/build/v4.14.184-191-ge26bcff6a5af
No regressions (compared to build v4.14.184)
No fixes (compared to build v4.14.184)
Ran 34182 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- i386
- juno-r2 - arm64
- juno-r2-compat
- juno-r2-kasan
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15 - arm
- x86_64
- x86-kasan
Test Suites
-----------
* build
* kselftest
* kselftest/drivers
* kselftest/filesystems
* kselftest/net
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-native/drivers
* kselftest-vsyscall-mode-native/filesystems
* kselftest-vsyscall-mode-native/net
* kselftest-vsyscall-mode-none
* kselftest-vsyscall-mode-none/drivers
* kselftest-vsyscall-mode-none/filesystems
* kselftest-vsyscall-mode-none/net
* kvm-unit-tests
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fs-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-open-posix-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* network-basic-tests
* perf
* v4l2-compliance
Greetings!
Daniel Díaz
[email protected]
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Jon Hunter
maintainerQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.185 release. There are 190 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 21 Jun 2020 14:15:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.185-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v4.14:
8 builds: 8 pass, 0 fail
16 boots: 16 pass, 0 fail
30 tests: 30 pass, 0 failLinux version: 4.14.185-rc1-ge26bcff6a5af
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 4.14 038/190] KVM: x86: only do L1TF workaround on affected processors
In reply to Greg Kroah-HartmanQuoted 11 lines · Greg Kroah-Hartman
From: Paolo Bonzini <[email protected]>
[ Upstream commit
d43e2675e96fc6ae1a633b6a69d296394448cc32]KVM stores the gfn in MMIO SPTEs as a caching optimization. These are split
in two parts, as in "[high 11111 low]", to thwart any attempt to use these bits
in an L1TF attack. This works as long as there are 5 free bits between MAXPHYADDR and bit 50 (inclusive), leaving bit 51 free so that the MMIO access triggers a reserved-bit-set page fault.
Hi, I'm now seeing this warning in VM bootup with 4.14.y
Not seen with 4.19.129 and 5.4.47 that also included this commit.
Any ideas what's missing in 4.14 ?
[ 2.294049] ------------[ cut here ]------------ [ 2.294621] WARNING: CPU: 43 PID: 856 at arch/x86/kvm/mmu.c:279 kvm_mmu_set_mmio_spte_mask+0x4e/0x60 [kvm] [ 2.295583] Modules linked in: kvm_intel(+) kvm irqbypass bfq sch_fq_codel pcbc aesni_intel aes_x86_64 crypto_simd cryptd glue_helper ata_piix dm_mirror dm_region_hash dm_log dm_mod dax autofs4 [ 2.297269] CPU: 43 PID: 856 Comm: systemd-udevd Not tainted 4.14.185 #1 [ 2.297920] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-2.fc32 04/01/2014 [ 2.298782] task: ffff9b2350b19dc0 task.stack: ffffa86344604000 [ 2.299390] RIP: 0010:kvm_mmu_set_mmio_spte_mask+0x4e/0x60 [kvm] [ 2.299987] RSP: 0018:ffffa86344607c78 EFLAGS: 00010206 [ 2.300522] RAX: 0000000000000000 RBX: ffffffffc0457000 RCX: 0000000000000000 [ 2.301239] RDX: ffffffff00000001 RSI: 0008000000000001 RDI: 0008000000000001 [ 2.301935] RBP: ffffffffc03bd951 R08: ffff9b235f4e33a0 R09: ffff9b2355f57258 [ 2.302646] R10: 0000000000000164 R11: 00000000ffffffff R12: 0000000000000000 [ 2.303356] R13: ffffffffc0458780 R14: ffffa86344607ea0 R15: 0000000000000001 [ 2.304069] FS: 00007f3e95dedc40(0000) GS:ffff9b235f4c0000(0000) knlGS:0000000000000000 [ 2.304852] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2.305425] CR2: 000055bd35ff10d0 CR3: 000000081026a004 CR4: 00000000001606e0 [ 2.306137] Call Trace: [ 2.306414] kvm_arch_init+0x90/0x130 [kvm] [ 2.306852] kvm_init+0x1c/0x2b0 [kvm] [ 2.307258] ? __slab_free+0x13a/0x2e0 [ 2.307649] ? hardware_setup+0x4ab/0x4ab [kvm_intel] [ 2.308178] vmx_init+0x21/0x6af [kvm_intel] [ 2.308604] ? hardware_setup+0x4ab/0x4ab [kvm_intel] [ 2.309132] do_one_initcall+0x3e/0xf4 [ 2.309512] ? kmem_cache_alloc_trace+0xef/0x190 [ 2.309985] do_init_module+0x5c/0x1f0 [ 2.310386] load_module+0x1f31/0x2620 [ 2.310769] ? SYSC_finit_module+0x95/0xb0 [ 2.311202] SYSC_finit_module+0x95/0xb0 [ 2.311600] do_syscall_64+0x74/0x190 [ 2.311980] entry_SYSCALL_64_after_hwframe+0x41/0xa6 [ 2.312496] RIP: 0033:0x7f3e966b71bd [ 2.312860] RSP: 002b:00007ffe0db584c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 2.313606] RAX: ffffffffffffffda RBX: 000055bd36027b10 RCX: 00007f3e966b71bd [ 2.314314] RDX: 0000000000000000 RSI: 00007f3e962fe84d RDI: 000000000000000f [ 2.315017] RBP: 0000000000020000 R08: 0000000000000000 R09: 0000000000000007 [ 2.315719] R10: 000000000000000f R11: 0000000000000246 R12: 00007f3e962fe84d [ 2.316420] R13: 0000000000000000 R14: 000055bd3602f400 R15: 000055bd36027b10 [ 2.317130] Code: 29 25 06 00 75 25 48 b8 00 00 00 00 00 00 00 40 48 09 c6 48 09 c7 48 89 35 38 25 06 00 48 89 3d 39 25 06 00 c3 0f 0b 0f 0b eb d2 <0f> 0b eb d7 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 0f 1f 44 [ 2.318933] ---[ end trace d933315308434918 ]---
$ head /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
Quoted 66 lines
The bit positions however were computed wrongly for AMD processors that have
encryption support. In this case,x86_phys_bitsis reduced (for example from 48 to 43, to account for the C bit at position 47 and four bits used internally to store the SEV ASID and other stuff) whilex86_cache_bitsin would remain set to 48, and _all_ bits between the reduced MAXPHYADDR and bit 51 are set. Thenlow_phys_bitswould also cover some of the bits that are set in theshadow_mmio_value, terribly confusing the gfn caching mechanism.To fix this, avoid splitting gfns as long as the processor does not have the L1TF bug (which includes all AMD processors). When there is no splitting,
low_phys_bitscan be set to the reduced MAXPHYADDR removing the overlap. This fixes "npt=0" operation on EPYC processors.Thanks to Maxim Levitsky for bisecting this bug.
Fixes 52918ed5fcf0 ("KVM: SVM: Override default MMIO mask if memoryencryption is enabled")
Signed-off-by Paolo Bonzini <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- arch/x86/kvm/mmu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)arch/x86/kvm/mmu.c +2
-0@@ -275,6 +275,8 @@ static bool is_executable_pte(u64 spte);void kvm_mmu_set_mmio_spte_mask (u64 mmio_mask,u64 mmio_value) {BUG_ON ((mmio_mask & mmio_value) != mmio_value); +WARN_ON (mmio_value & (shadow_nonpresent_or_rsvd_mask << shadow_nonpresent_or_rsvd_mask_len)); +WARN_ON (mmio_value & shadow_nonpresent_or_rsvd_lower_gfn_mask); shadow_mmio_value = mmio_value |SPTE_SPECIAL_MASK ; shadow_mmio_mask = mmio_mask |SPTE_SPECIAL_MASK ;}
arch/x86/kvm/mmu.c +8
-9@@ -467,16 +469,15 @@ static void kvm_mmu_reset_all_pte_masks(void)* the most significant bits of legal physical address space. */ shadow_nonpresent_or_rsvd_mask =0 ; - low_phys_bits = boot_cpu_data.x86_cache_bits; -if (boot_cpu_data.x86_cache_bits < -52 - shadow_nonpresent_or_rsvd_mask_len) { + low_phys_bits = boot_cpu_data.x86_phys_bits; +if (boot_cpu_has_bug (X86_BUG_L1TF ) && + !WARN_ON_ONCE (boot_cpu_data.x86_cache_bits >= +52 - shadow_nonpresent_or_rsvd_mask_len)) { + low_phys_bits = boot_cpu_data.x86_cache_bits + - shadow_nonpresent_or_rsvd_mask_len; shadow_nonpresent_or_rsvd_mask = -rsvd_bits (boot_cpu_data.x86_cache_bits - - shadow_nonpresent_or_rsvd_mask_len, - boot_cpu_data.x86_cache_bits -1 ); - low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; - }else -WARN_ON_ONCE (boot_cpu_has_bug (X86_BUG_L1TF )); +rsvd_bits (low_phys_bits, boot_cpu_data.x86_cache_bits -1 ); + } shadow_nonpresent_or_rsvd_lower_gfn_mask =
GENMASK_ULL(low_phys_bits - 1, PAGE_SHIFT);
Sasha Levin
maintainerRe: [PATCH 4.14 038/190] KVM: x86: only do L1TF workaround on affected processors
Quoted 13 lines · Tommi T. (Nokia - FI/Espoo)
Quoted 11 lines · Greg Kroah-Hartman
From: Paolo Bonzini <[email protected]>
[ Upstream commit
d43e2675e96fc6ae1a633b6a69d296394448cc32]KVM stores the gfn in MMIO SPTEs as a caching optimization. These are split
in two parts, as in "[high 11111 low]", to thwart any attempt to use these bits
in an L1TF attack. This works as long as there are 5 free bits between MAXPHYADDR and bit 50 (inclusive), leaving bit 51 free so that the MMIO access triggers a reserved-bit-set page fault.
Quoted 1 line
Hi, I'm now seeing this warning in VM bootup with 4.14.y
Thanks for the report!
Quoted 3 lines
Not seen with 4.19.129 and 5.4.47 that also included this commit.
Any ideas what's missing in 4.14 ?
I think that this was because we're missing 6129ed877d40 ("KVM: x86/mmu:
Set mmio_value to '0' if reserved #PF can't be generated"). I've queued it up (along with a few other related commits) and a new -rc cycle should be underway for those.
Signature · 2 lines
Thanks, Sasha
Re: [PATCH 4.14 038/190] KVM: x86: only do L1TF workaround on affected processors
Quoted 7 lines · Sasha Levin
Quoted 5 lines · Tommi T. (Nokia - FI/Espoo)
Quoted 4 lines · Greg Kroah-Hartman
From: Paolo Bonzini <[email protected]>
[ Upstream commit
d43e2675e96fc6ae1a633b6a69d296394448cc32]
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
KVM stores the gfn in MMIO SPTEs as a caching optimization.
Any ideas what's missing in 4.14 ?
I think that this was because we're missing
6129ed877d40("KVM: x86/mmu:
Setmmio_valueto '0' if reserved #PF can't be generated"). I've queued it up (along with a few other related commits) and a new -rc cycle should be underway for those.
Sorry, I still see it with 4.14.186:
[ 2.355140] ------------[ cut here ]------------ [ 2.355872] WARNING: CPU: 0 PID: 849 at arch/x86/kvm/mmu.c:284 kvm_mmu_set_mmio_spte_mask+0x4e/0x60 [kvm] [ 2.357723] Modules linked in: kvm_intel(+) kvm irqbypass bfq sch_fq_codel pcbc aesni_intel aes_x86_64 crypto_simd cryptd glue_helper ata_piix dm_mirror dm_region_hash dm_log dm_mod dax autofs4 [ 2.359639] CPU: 0 PID: 849 Comm: systemd-udevd Not tainted 4.14.186 #2 [ 2.360309] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-2.fc32 04/01/2014 [ 2.361177] task: ffff8a3d19429dc0 task.stack: ffffb2558460c000 [ 2.361775] RIP: 0010:kvm_mmu_set_mmio_spte_mask+0x4e/0x60 [kvm] [ 2.362390] RSP: 0018:ffffb2558460fc58 EFLAGS: 00010206 [ 2.362901] RAX: 0000000000000000 RBX: ffffffffc0179000 RCX: 00000000ffffff45 [ 2.363617] RDX: 0000000000000028 RSI: 0008000000000001 RDI: 0008000000000001 [ 2.364329] RBP: ffffffffc00c5951 R08: 00000000ffffffff R09: 00003fffffffffff [ 2.365021] R10: ffffb255841592b8 R11: 00000000fffffffe R12: 0000000000005bc0 [ 2.365717] R13: ffffffffc017a780 R14: ffffb2558460fea0 R15: 0000000000000001 [ 2.366437] FS: 00007fc6fcab6c40(0000) GS:ffff8a3d1ea00000(0000) knlGS:0000000000000000 [ 2.367270] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2.367824] CR2: 0000564de775f840 CR3: 0000000818efc001 CR4: 00000000001606f0 [ 2.368535] Call Trace: [ 2.368809] kvm_mmu_module_init+0x15f/0x240 [kvm] [ 2.369323] kvm_arch_init+0x5e/0x100 [kvm] [ 2.369750] kvm_init+0x1c/0x2b0 [kvm] [ 2.370155] ? free_pcppages_bulk+0x22d/0x4b0 [ 2.370591] ? hardware_setup+0x4ab/0x4ab [kvm_intel] [ 2.371113] vmx_init+0x21/0x6af [kvm_intel] [ 2.371596] ? hardware_setup+0x4ab/0x4ab [kvm_intel] [ 2.372118] do_one_initcall+0x3e/0xf4 [ 2.372501] ? kmem_cache_alloc_trace+0xef/0x190 [ 2.372964] do_init_module+0x5c/0x1f0 [ 2.373383] load_module+0x1f31/0x2620 [ 2.373765] ? SYSC_finit_module+0x95/0xb0 [ 2.374205] SYSC_finit_module+0x95/0xb0 [ 2.374601] do_syscall_64+0x74/0x190 [ 2.374974] entry_SYSCALL_64_after_hwframe+0x41/0xa6 [ 2.375500] RIP: 0033:0x7fc6fd3801bd [ 2.375853] RSP: 002b:00007ffd768187f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 2.376593] RAX: ffffffffffffffda RBX: 0000564539d9ab50 RCX: 00007fc6fd3801bd [ 2.377305] RDX: 0000000000000000 RSI: 00007fc6fcfc784d RDI: 000000000000000e [ 2.377981] RBP: 0000000000020000 R08: 0000000000000000 R09: 0000000000000007 [ 2.378693] R10: 000000000000000e R11: 0000000000000246 R12: 00007fc6fcfc784d [ 2.379401] R13: 0000000000000000 R14: 0000564539d7a530 R15: 0000564539d9ab50 [ 2.380104] Code: 59 25 06 00 75 25 48 b8 00 00 00 00 00 00 00 40 48 09 c6 48 09 c7 48 89 35 68 25 06 00 48 89 3d 69 25 06 00 c3 0f 0b 0f 0b eb d2 <0f> 0b eb d7 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 0f 1f 44 [ 2.381905] ---[ end trace 5f757335c2eac657 ]---