4.14.276-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 161/284 PM: core: keep irq flags in device_pm_check_callbacks()
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 524bb1da785a7ae43dd413cd392b5071c6c367f8 ]
The function device_pm_check_callbacks() can be called under the spin lock (in the reported case it happens from genpd_add_device() -> dev_pm_domain_set(), when the genpd uses spinlocks rather than mutexes.
However this function uncoditionally uses spin_lock_irq() / spin_unlock_irq(), thus not preserving the CPU flags. Use the irqsave/irqrestore instead.
The backtrace for the reference:
[ 2.752010] ------------[ cut here ]------------ [ 2.756769] raw_local_irq_restore() called with IRQs enabled [ 2.762596] WARNING: CPU: 4 PID: 1 at kernel/locking/irqflag-debug.c:10 warn_bogus_irq_restore+0x34/0x50 [ 2.772338] Modules linked in: [ 2.775487] CPU: 4 PID: 1 Comm: swapper/0 Tainted: G S 5.17.0-rc6-00384-ge330d0d82eff-dirty #684 [ 2.781384] Freeing initrd memory: 46024K [ 2.785839] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.785841] pc : warn_bogus_irq_restore+0x34/0x50 [ 2.785844] lr : warn_bogus_irq_restore+0x34/0x50 [ 2.785846] sp : ffff80000805b7d0 [ 2.785847] x29: ffff80000805b7d0 x28: 0000000000000000 x27: 0000000000000002 [ 2.785850] x26: ffffd40e80930b18 x25: ffff7ee2329192b8 x24: ffff7edfc9f60800 [ 2.785853] x23: ffffd40e80930b18 x22: ffffd40e80930d30 x21: ffff7edfc0dffa00 [ 2.785856] x20: ffff7edfc09e3768 x19: 0000000000000000 x18: ffffffffffffffff [ 2.845775] x17: 6572206f74206465 x16: 6c696166203a3030 x15: ffff80008805b4f7 [ 2.853108] x14: 0000000000000000 x13: ffffd40e809550b0 x12: 00000000000003d8 [ 2.860441] x11: 0000000000000148 x10: ffffd40e809550b0 x9 : ffffd40e809550b0 [ 2.867774] x8 : 00000000ffffefff x7 : ffffd40e809ad0b0 x6 : ffffd40e809ad0b0 [ 2.875107] x5 : 000000000000bff4 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.882440] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff7edfc03a8000 [ 2.889774] Call trace: [ 2.892290] warn_bogus_irq_restore+0x34/0x50 [ 2.896770] _raw_spin_unlock_irqrestore+0x94/0xa0 [ 2.901690] genpd_unlock_spin+0x20/0x30 [ 2.905724] genpd_add_device+0x100/0x2d0 [ 2.909850] __genpd_dev_pm_attach+0xa8/0x23c [ 2.914329] genpd_dev_pm_attach_by_id+0xc4/0x190 [ 2.919167] genpd_dev_pm_attach_by_name+0x3c/0xd0 [ 2.924086] dev_pm_domain_attach_by_name+0x24/0x30 [ 2.929102] psci_dt_attach_cpu+0x24/0x90 [ 2.933230] psci_cpuidle_probe+0x2d4/0x46c [ 2.937534] platform_probe+0x68/0xe0 [ 2.941304] really_probe.part.0+0x9c/0x2fc [ 2.945605] __driver_probe_device+0x98/0x144 [ 2.950085] driver_probe_device+0x44/0x15c [ 2.954385] __device_attach_driver+0xb8/0x120 [ 2.958950] bus_for_each_drv+0x78/0xd0 [ 2.962896] __device_attach+0xd8/0x180 [ 2.966843] device_initial_probe+0x14/0x20 [ 2.971144] bus_probe_device+0x9c/0xa4 [ 2.975092] device_add+0x380/0x88c [ 2.978679] platform_device_add+0x114/0x234 [ 2.983067] platform_device_register_full+0x100/0x190 [ 2.988344] psci_idle_init+0x6c/0xb0 [ 2.992113] do_one_initcall+0x74/0x3a0 [ 2.996060] kernel_init_freeable+0x2fc/0x384 [ 3.000543] kernel_init+0x28/0x130 [ 3.004132] ret_from_fork+0x10/0x20 [ 3.007817] irq event stamp: 319826 [ 3.011404] hardirqs last enabled at (319825): [<ffffd40e7eda0268>] __up_console_sem+0x78/0x84 [ 3.020332] hardirqs last disabled at (319826): [<ffffd40e7fd6d9d8>] el1_dbg+0x24/0x8c [ 3.028458] softirqs last enabled at (318312): [<ffffd40e7ec90410>] _stext+0x410/0x588 [ 3.036678] softirqs last disabled at (318299): [<ffffd40e7ed1bf68>] __irq_exit_rcu+0x158/0x174 [ 3.045607] ---[ end trace 0000000000000000 ]---
--- drivers/base/power/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/base/power/main.c +4 -2
@@ -1901,7 +1901,9 @@ static bool pm_ops_is_empty(const struct dev_pm_ops *ops)void device_pm_check_callbacks (struct device *dev) { -spin_lock_irq (&dev->power.lock); +unsigned long flags; + +spin_lock_irqsave (&dev->power.lock, flags); dev->power.no_pm_callbacks = (!dev->bus || (pm_ops_is_empty (dev->bus->pm) && !dev->bus->suspend && !dev->bus->resume)) &&
@@ -1911,5 +1913,5 @@ void device_pm_check_callbacks(struct device *dev) (!dev->pm_domain ||pm_ops_is_empty (&dev->pm_domain->ops)) && (!dev->driver || (pm_ops_is_empty (dev->driver->pm) && !dev->driver->suspend && !dev->driver->resume)); -spin_unlock_irq (&dev->power.lock); +spin_unlock_irqrestore (&dev->power.lock, flags); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 162/284 spi: tegra20: Use of_device_get_match_data()
In reply to Greg Kroah-HartmanFrom: Minghao Chi <[email protected]>
[ Upstream commit c9839acfcbe20ce43d363c2a9d0772472d9921c0 ]
Use of_device_get_match_data() to simplify the code.
--- drivers/spi/spi-tegra20-slink.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/spi/spi-tegra20-slink.c +1 -7
@@ -1016,14 +1016,8 @@ static int tegra_slink_probe(struct platform_device *pdev)struct resource *r;int ret, spi_irq;const struct tegra_slink_chip_data *cdata =NULL ; -const struct of_device_id *match; - match =of_match_device (tegra_slink_of_match, &pdev->dev); -if (!match) { -dev_err (&pdev->dev,"Error: No device match found\n" ); -return -ENODEV ; - } - cdata = match->data; + cdata =of_device_get_match_data (&pdev->dev); master =spi_alloc_master (&pdev->dev,sizeof (*tspi));if (!master) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 163/284 ext4: dont BUG if someone dirty pages without asking ext4 first
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
[ Upstream commit cc5095747edfb054ca2068d01af20be3fcc3634f ]
[un]pin_user_pages_remote is dirtying pages without properly warning the file system in advance. A related race was noted by Jan Kara in 2018[1]; however, more recently instead of it being a very hard-to-hit race, it could be reliably triggered by process_vm_writev(2) which was discovered by Syzbot[2].
This is technically a bug in mm/gup.c, but arguably ext4 is fragile in that if some other kernel subsystem dirty pages without properly notifying the file system using page_mkwrite(), ext4 will BUG, while other file systems will not BUG (although data will still be lost).
So instead of crashing with a BUG, issue a warning (since there may be potential data loss) and just mark the page as clean to avoid unprivileged denial of service attacks until the problem can be properly fixed. More discussion and background can be found in the thread starting at [2].
[1] https://lore.kernel.org/linux-mm/[email protected]
[2] https://lore.kernel.org/r/[email protected]
--- fs/ext4/inode.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
fs/ext4/inode.c +25 -0
@@ -2147,6 +2147,15 @@ static int ext4_writepage(struct page *page,else len =PAGE_SIZE ; +/* Should never happen but for bugs in other kernel subsystems */ +if (!page_has_buffers (page)) { +ext4_warning_inode (inode, +"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +return 0 ; + } + page_bufs =page_buffers (page);/* * We cannot do block allocation or other extent handling in this
@@ -2706,6 +2715,22 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)wait_on_page_writeback (page);BUG_ON (PageWriteback (page)); +/* +* Should never happen but for buggy code in +* other subsystems that call +* set_page_dirty() without properly warning +* the file system first. See [1] for more +* information. +* +* [1] https://lore.kernel.org/linux-mm/[email protected] +*/ +if (!page_has_buffers (page)) { +ext4_warning_inode (mpd->inode,"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +continue ; + } +if (mpd->map.m_len ==0 ) mpd->first_page = page->index; mpd->next_page = page->index +1 ;
Signature · 1 line
2.34.1
syzbot
syzbotRe: [PATCH 4.14 163/284] ext4: dont BUG if someone dirty pages without asking ext4 first
I see the command but can't find the corresponding bug. The email is sent to [email protected] address but the HASH does not correspond to any known bug. Please double check the…
Quoted 81 lines
From: Theodore Ts'o <[email protected]>
[ Upstream commit
cc5095747edfb054ca2068d01af20be3fcc3634f][un]pin_user_pages_remote is dirtying pages without properly warning the file system in advance. A related race was noted by Jan Kara in 2018[1]; however, more recently instead of it being a very hard-to-hit race, it could be reliably triggered by
process_vm_writev(2)which was discovered by Syzbot[2].This is technically a bug in
mm/gup.c, but arguably ext4 is fragile in that if some other kernel subsystem dirty pages without properly notifying the file system usingpage_mkwrite(), ext4 will BUG, while other file systems will not BUG (although data will still be lost).So instead of crashing with a BUG, issue a warning (since there may be potential data loss) and just mark the page as clean to avoid unprivileged denial of service attacks until the problem can be properly fixed. More discussion and background can be found in the thread starting at [2].
[1] https://lore.kernel.org/linux-mm/[email protected]
[2] https://lore.kernel.org/r/[email protected]Reported-by Lee Jones <[email protected]>Signed-off-by Theodore Ts'o <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/ext4/inode.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)fs/ext4/inode.c +25
-0@@ -2147,6 +2147,15 @@ static int ext4_writepage(struct page *page,else len =PAGE_SIZE ; +/* Should never happen but for bugs in other kernel subsystems */ +if (!page_has_buffers (page)) { +ext4_warning_inode (inode, +"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +return 0 ; + } + page_bufs =page_buffers (page);/* * We cannot do block allocation or other extent handling in this @@ -2706,6 +2715,22 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)wait_on_page_writeback (page);BUG_ON (PageWriteback (page)); +/* +* Should never happen but for buggy code in +* other subsystems that call +* set_page_dirty() without properly warning +* the file system first. See [1] for more +* information. +* +* [1] https://lore.kernel.org/linux-mm/[email protected] +*/ +if (!page_has_buffers (page)) { +ext4_warning_inode (mpd->inode,"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +continue ; + } +if (mpd->map.m_len ==0 ) mpd->first_page = page->index; mpd->next_page = page->index +1 ;Signature · 1 line
2.34.1
I see the command but can't find the corresponding bug. The email is sent to [email protected] address but the HASH does not correspond to any known bug. Please double check the address.
Greg Kroah-Hartman
maintainerPATCH 164/284 ntfs: add sanity check on allocation size
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 714fbf2647b1a33d914edd695d4da92029c7e7c0 ]
ntfs_read_inode_mount invokes ntfs_malloc_nofs with zero allocation size. It triggers one BUG in the __ntfs_malloc function.
Fix this by adding sanity check on ni->attr_list_size.
--- fs/ntfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ntfs/inode.c +4 -0
@@ -1915,6 +1915,10 @@ int ntfs_read_inode_mount(struct inode *vi) }/* Now allocate memory for the attribute list. */ ni->attr_list_size = (u32 )ntfs_attr_size (a); +if (!ni->attr_list_size) { +ntfs_error (sb,"Attr_list_size is zero" ); + goto put_err_out; + } ni->attr_list =ntfs_malloc_nofs (ni->attr_list_size);if (!ni->attr_list) { ntfs_error(sb, "Not enough memory to allocate buffer "
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 165/284 video: fbdev: nvidiafb: Use strscpy() to prevent buffer overflow
In reply to Greg Kroah-HartmanFrom: Tim Gardner <[email protected]>
[ Upstream commit 37a1a2e6eeeb101285cd34e12e48a881524701aa ]
Coverity complains of a possible buffer overflow. However, given the 'static' scope of nvidia_setup_i2c_bus() it looks like that can't happen after examiniing the call sites.
CID 19036 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
1. fixed_size_dest: You might overrun the 48-character fixed-size string chan->adapter.name by copying name without checking the length.
2. parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
89 strcpy(chan->adapter.name, name);
Fix this warning by using strscpy() which will silence the warning and prevent any future buffer overflows should the names used to identify the channel become much longer.
--- drivers/video/fbdev/nvidia/nv_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/nvidia/nv_i2c.c +1 -1
@@ -86,7 +86,7 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name, {int rc; -strcpy (chan->adapter.name, name); +strscpy (chan->adapter.name, name,sizeof (chan->adapter.name)); chan->adapter.owner =THIS_MODULE ; chan->adapter.class = i2c_class; chan->adapter.algo_data = &chan->algo;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 166/284 video: fbdev: w100fb: Reset global state
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit 8738ddcac644964ae128ccd3d80d48773c8d528e ]
w100fb_probe() did not reset the global state to its initial state. This can result in invocation of iounmap() even when there was not the appropriate successful call of ioremap(). For instance, this may be the case if first probe fails after two successful ioremap() while second probe fails when first ioremap() fails. The similar issue is with w100fb_remove(). The patch fixes both bugs.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/video/fbdev/w100fb.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/video/fbdev/w100fb.c +12 -3
@@ -772,12 +772,18 @@ int w100fb_probe(struct platform_device *pdev)fb_dealloc_cmap (&info->cmap);kfree (info->pseudo_palette); } -if (remapped_fbuf !=NULL ) +if (remapped_fbuf !=NULL ) {iounmap (remapped_fbuf); -if (remapped_regs !=NULL ) + remapped_fbuf =NULL ; + } +if (remapped_regs !=NULL ) {iounmap (remapped_regs); -if (remapped_base !=NULL ) + remapped_regs =NULL ; + } +if (remapped_base !=NULL ) {iounmap (remapped_base); + remapped_base =NULL ; + }if (info)framebuffer_release (info);return err;
@@ -802,8 +808,11 @@ static int w100fb_remove(struct platform_device *pdev)fb_dealloc_cmap (&info->cmap);iounmap (remapped_base); + remapped_base =NULL ;iounmap (remapped_regs); + remapped_regs =NULL ;iounmap (remapped_fbuf); + remapped_fbuf =NULL ;framebuffer_release (info);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 167/284 video: fbdev: cirrusfb: check pixclock to avoid divide by zero
In reply to Greg Kroah-HartmanFrom: George Kennedy <[email protected]>
[ Upstream commit 5c6f402bdcf9e7239c6bc7087eda71ac99b31379 ]
Do a sanity check on pixclock value to avoid divide by zero.
If the pixclock value is zero, the cirrusfb driver will round up pixclock to get the derived frequency as close to maxclock as possible.
Syzkaller reported a divide error in cirrusfb_check_pixclock.
divide error: 0000 [#1] SMP KASAN PTI
CPU: 0 PID: 14938 Comm: cirrusfb_test Not tainted 5.15.0-rc6 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2 RIP: 0010:cirrusfb_check_var+0x6f1/0x1260 Call Trace: fb_set_var+0x398/0xf90 do_fb_ioctl+0x4b8/0x6f0 fb_ioctl+0xeb/0x130 __x64_sys_ioctl+0x19d/0x220 do_syscall_64+0x3a/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- drivers/video/fbdev/cirrusfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/video/fbdev/cirrusfb.c +8 -8
@@ -470,7 +470,7 @@ static int cirrusfb_check_mclk(struct fb_info *info, long freq)return 0 ; } -static int cirrusfb_check_pixclock (const struct fb_var_screeninfo *var, +static int cirrusfb_check_pixclock (struct fb_var_screeninfo *var,struct fb_info *info) {long freq;
@@ -479,9 +479,7 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,unsigned maxclockidx = var->bits_per_pixel >>3 ;/* convert from ps to kHz */ - freq =PICOS2KHZ (var->pixclock); - -dev_dbg (info->device,"desired pixclock: %ld kHz\n" , freq); + freq =PICOS2KHZ (var->pixclock ? :1 ); maxclock = cirrusfb_board_info[cinfo->btype].maxclock[maxclockidx]; cinfo->multiplexing =0 ;
@@ -489,11 +487,13 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,/* If the frequency is greater than we can support, we might be able * to use multiplexing for the video mode */ if (freq > maxclock) { -dev_err (info->device, -"Frequency greater than maxclock (%ld kHz)\n" , - maxclock); -return -EINVAL ; + var->pixclock =KHZ2PICOS (maxclock); + +while ((freq =PICOS2KHZ (var->pixclock)) > maxclock) + var->pixclock++; } +dev_dbg (info->device,"desired pixclock: %ld kHz\n" , freq); +/* * Additional constraint: 8bpp uses DAC clock doubling to allow maximum * pixel clock
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 168/284 video: fbdev: omapfb: acx565akm: replace snprintf with sysfs_emit
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit 24565bc4115961db7ee64fcc7ad2a7437c0d0a49 ]
coccinelle report:./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c:
479:9-17: WARNING: use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
--- .../video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c +1 -1
@@ -487,7 +487,7 @@ static ssize_t show_cabc_available_modes(struct device *dev,int i;if (!ddata->has_cabc) -return snprintf (buf,PAGE_SIZE ,"%s\n" , cabc_modes[0 ]); +return sysfs_emit (buf,"%s\n" , cabc_modes[0 ]);for (i =0 , len =0 ; len <PAGE_SIZE && i <ARRAY_SIZE (cabc_modes); i++)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 169/284 ARM: dts: qcom: fix gic_irq_domain_translate warnings for msm8960
In reply to Greg Kroah-HartmanFrom: David Heidelberg <[email protected]>
[ Upstream commit 6f7e221e7a5cfc3299616543fce42b36e631497b ]
IRQ types blindly copied from very similar APQ8064.
Fixes warnings as:
WARNING: CPU: 0 PID: 1 at drivers/irqchip/irq-gic.c:1080 gic_irq_domain_translate+0x118/0x120
...
--- arch/arm/boot/dts/qcom-msm8960.dtsi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/arm/boot/dts/qcom-msm8960.dtsi +5 -3
@@ -140,7 +140,9 @@ reg = <0x108000 0x1000>; qcom,ipc = <&l2cc 0x8 2>; - interrupts = <0 19 0>, <0 21 0>, <0 22 0>; + interrupts = <GIC_SPI 19 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 21 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 22 IRQ_TYPE_EDGE_RISING>; interrupt-names = "ack", "err", "wakeup"; regulators {
@@ -186,7 +188,7 @@ compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm"; reg = <0x16440000 0x1000>, <0x16400000 0x1000>; - interrupts = <0 154 0x0>; + interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>; clocks = <&gcc GSBI5_UART_CLK>, <&gcc GSBI5_H_CLK>; clock-names = "core", "iface"; status = "disabled";
@@ -312,7 +314,7 @@ #address-cells = <1>; #size-cells = <0>; reg = <0x16080000 0x1000>; - interrupts = <0 147 0>; + interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>; spi-max-frequency = <24000000>; cs-gpios = <&msmgpio 8 0>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 170/284 ARM: dts: bcm2837: Add the missing L1/L2 cache information
In reply to Greg Kroah-HartmanFrom: Richard Schleich <[email protected]>
[ Upstream commit bdf8762da268d2a34abf517c36528413906e9cd5 ]
This patch fixes the kernel warning "cacheinfo: Unable to detect cache hierarchy for CPU 0" for the bcm2837 on newer kernel versions.
--- arch/arm/boot/dts/bcm2837.dtsi | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
arch/arm/boot/dts/bcm2837.dtsi +49 -0
@@ -32,12 +32,26 @@ #size-cells = <0>; enable-method = "brcm,bcm2836-smp"; // for ARM 32-bit + /* Source for d/i-cache-line-size and d/i-cache-sets + * https://developer.arm.com/documentation/ddi0500/e/level-1-memory-system + * /about-the-l1-memory-system?lang=en + * + * Source for d/i-cache-size + * https://magpi.raspberrypi.com/articles/raspberry-pi-3-specs-benchmarks + */ cpu0: cpu@0 { device_type = "cpu"; compatible = "arm,cortex-a53"; reg = <0>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000d8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; }; cpu1: cpu@1 {
@@ -46,6 +60,13 @@ reg = <1>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; }; cpu2: cpu@2 {
@@ -54,6 +75,13 @@ reg = <2>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; }; cpu3: cpu@3 {
@@ -62,6 +90,27 @@ reg = <3>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000f0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; + }; + + /* Source for cache-line-size + cache-sets + * https://developer.arm.com/documentation/ddi0500 + * /e/level-2-memory-system/about-the-l2-memory-system?lang=en + * Source for cache-size + * https://datasheets.raspberrypi.com/cm/cm1-and-cm3-datasheet.pdf + */ + l2: l2-cache0 { + compatible = "cache"; + cache-size = <0x80000>; + cache-line-size = <64>; + cache-sets = <512>; // 512KiB(size)/64(line-size)=8192ways/16-way set + cache-level = <2>; }; }; };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 171/284 video: fbdev: omapfb: panel-dsi-cm: Use sysfs_emit() instead of snprintf()
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit f63658a59c3d439c8ad7b290f8ec270980e0f384 ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c +4 -4
@@ -413,7 +413,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,if (r)return r; -return snprintf (buf,PAGE_SIZE ,"%d\n" , errors); +return sysfs_emit (buf,"%d\n" , errors); } static ssize_t dsicm_hw_revision_show(struct device *dev,
@@ -444,7 +444,7 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,if (r)return r; -return snprintf (buf,PAGE_SIZE ,"%02x.%02x.%02x\n" , id1, id2, id3); +return sysfs_emit (buf,"%02x.%02x.%02x\n" , id1, id2, id3); } static ssize_t dsicm_store_ulps(struct device *dev,
@@ -494,7 +494,7 @@ static ssize_t dsicm_show_ulps(struct device *dev, t = ddata->ulps_enabled;mutex_unlock (&ddata->lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , t); +return sysfs_emit (buf,"%u\n" , t); } static ssize_t dsicm_store_ulps_timeout(struct device *dev,
@@ -541,7 +541,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev, t = ddata->ulps_timeout;mutex_unlock (&ddata->lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , t); +return sysfs_emit (buf,"%u\n" , t); } static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 172/284 video: fbdev: omapfb: panel-tpo-td043mtea1: Use sysfs_emit() instead of snprintf()
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit c07a039cbb96748f54c02995bae8131cc9a73b0a ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- .../video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c +2 -2
@@ -173,7 +173,7 @@ static ssize_t tpo_td043_vmirror_show(struct device *dev, {struct panel_drv_data *ddata =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ddata->vmirror); +return sysfs_emit (buf,"%d\n" , ddata->vmirror); } static ssize_t tpo_td043_vmirror_store(struct device *dev,
@@ -203,7 +203,7 @@ static ssize_t tpo_td043_mode_show(struct device *dev, {struct panel_drv_data *ddata =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ddata->mode); +return sysfs_emit (buf,"%d\n" , ddata->mode); } static ssize_t tpo_td043_mode_store(struct device *dev,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 173/284 ASoC: soc-core: skip zero num_dai component in searching dai name
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit f7d344a2bd5ec81fbd1ce76928fd059e57ec9bea ]
In the case like dmaengine which's not a dai but as a component, the num_dai is zero, dmaengine component has the same component_of_node as cpu dai, when cpu dai component is not ready, but dmaengine component is ready, try to get cpu dai name, the snd_soc_get_dai_name() return -EINVAL, not -EPROBE_DEFER, that cause below error:
asoc-simple-card <card name>: parse error -22
asoc-simple-card: probe of <card name> failed with error -22
The sound card failed to probe.
So this patch fixes the issue above by skipping the zero num_dai component in searching dai name.
--- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-core.c +1 -1
@@ -4243,7 +4243,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args,if (!component_of_node && pos->dev->parent) component_of_node = pos->dev->parent->of_node; -if (component_of_node != args->np) +if (component_of_node != args->np || !pos->num_dai)continue ;if (pos->driver->of_xlate_dai_name) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 174/284 media: cx88-mpeg: clear interrupt status register before streaming video
In reply to Greg Kroah-HartmanFrom: Daniel González Cabanelas <[email protected]>
[ Upstream commit 56cb61f70e547e1b0cdfe6ff5a1f1ce6242e6d96 ]
Some cx88 video cards may have transport stream status interrupts set to 1 from cold start, causing errors like this:
cx88xx: cx88_print_irqbits: core:irq mpeg [0x100000] ts_err?*
cx8802: cx8802_mpeg_irq: mpeg:general errors: 0x00100000
According to CX2388x datasheet, the interrupt status register should be cleared before enabling IRQs to stream video.
Fix it by clearing the Transport Stream Interrupt Status register.
--- drivers/media/pci/cx88/cx88-mpeg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/pci/cx88/cx88-mpeg.c +3 -0
@@ -171,6 +171,9 @@ int cx8802_start_dma(struct cx8802_dev *dev,cx_write (MO_TS_GPCNTRL ,GP_COUNT_CONTROL_RESET ); q->count =0 ; +/* clear interrupt status register */ +cx_write (MO_TS_INTSTAT ,0x1f1111 ); +/* enable irqs */ dprintk (1 ,"setting the interrupt mask\n" );cx_set (MO_PCI_INTMSK , core->pci_irqmask |PCI_INT_TSINT );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 175/284 ARM: tegra: tamonten: Fix I2C3 pad setting
In reply to Greg Kroah-HartmanFrom: Richard Leitner <[email protected]>
[ Upstream commit 0092c25b541a5422d7e71892a13c55ee91abc34b ]
This patch fixes the tristate configuration for i2c3 function assigned to the dtf pins on the Tamonten Tegra20 SoM.
--- arch/arm/boot/dts/tegra20-tamonten.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/tegra20-tamonten.dtsi +3 -3
@@ -183,8 +183,8 @@ }; conf_ata { nvidia,pins = "ata", "atb", "atc", "atd", "ate", - "cdev1", "cdev2", "dap1", "dtb", "gma", - "gmb", "gmc", "gmd", "gme", "gpu7", + "cdev1", "cdev2", "dap1", "dtb", "dtf", + "gma", "gmb", "gmc", "gmd", "gme", "gpu7", "gpv", "i2cp", "irrx", "irtx", "pta", "rm", "slxa", "slxk", "spia", "spib", "uac";
@@ -203,7 +203,7 @@ }; conf_crtp { nvidia,pins = "crtp", "dap2", "dap3", "dap4", - "dtc", "dte", "dtf", "gpu", "sdio1", + "dtc", "dte", "gpu", "sdio1", "slxc", "slxd", "spdi", "spdo", "spig", "uda"; nvidia,pull = <TEGRA_PIN_PULL_NONE>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 176/284 ARM: mmp: Fix failure to remove sram device
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 4036b29a146b2749af3bb213b003eb69f3e5ecc4 ]
Make sure in .probe() to set driver data before the function is left to make it possible in .remove() to undo the actions done.
This fixes a potential memory leak and stops returning an error code in .remove() that is ignored by the driver core anyhow.
--- arch/arm/mach-mmp/sram.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
arch/arm/mach-mmp/sram.c +12 -10
@@ -75,6 +75,8 @@ static int sram_probe(struct platform_device *pdev)if (!info)return -ENOMEM ; +platform_set_drvdata (pdev, info); + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (res ==NULL ) {dev_err (&pdev->dev,"no memory resource defined\n" );
@@ -110,8 +112,6 @@ static int sram_probe(struct platform_device *pdev)list_add (&info->node, &sram_bank_list);mutex_unlock (&sram_lock); -platform_set_drvdata (pdev, info); -dev_info (&pdev->dev,"initialized\n" );return 0 ;
@@ -130,17 +130,19 @@ static int sram_remove(struct platform_device *pdev)struct sram_bank_info *info; info =platform_get_drvdata (pdev); -if (info ==NULL ) -return -ENODEV ; -mutex_lock (&sram_lock); -list_del (&info->node); -mutex_unlock (&sram_lock); +if (info->sram_size) { +mutex_lock (&sram_lock); +list_del (&info->node); +mutex_unlock (&sram_lock); + +gen_pool_destroy (info->gpool); +iounmap (info->sram_virt); +kfree (info->pool_name); + } -gen_pool_destroy (info->gpool); -iounmap (info->sram_virt); -kfree (info->pool_name);kfree (info); +return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 177/284 video: fbdev: sm712fb: Fix crash in smtcfb_write()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 4f01d09b2bbfbcb47b3eb305560a7f4857a32260 ]
When the sm712fb driver writes three bytes to the framebuffer, the driver will crash:
BUG: unable to handle page fault for address: ffffc90001ffffff
RIP: 0010:smtcfb_write+0x454/0x5b0
Call Trace:
vfs_write+0x291/0xd60
? do_sys_openat2+0x27d/0x350
? __fget_light+0x54/0x340
ksys_write+0xce/0x190
do_syscall_64+0x43/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xaeFix it by removing the open-coded endianness fixup-code.
--- drivers/video/fbdev/sm712fb.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/video/fbdev/sm712fb.c +4 -17
@@ -1119,7 +1119,7 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf, count = total_size - p; } - buffer =kmalloc ((count >PAGE_SIZE ) ?PAGE_SIZE : count,GFP_KERNEL ); + buffer =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -1137,24 +1137,11 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,break ; } -for (i = c >>2 ; i--;) { -fb_writel (big_swap (*src), dst++); +for (i = (c +3 ) >>2 ; i--;) { +fb_writel (big_swap (*src), dst); + dst++; src++; } -if (c &3 ) { -u8 *src8 = (u8 *)src; -u8 __iomem *dst8 = (u8 __iomem *)dst; - -for (i = c &3 ; i--;) { -if (i &1 ) { -fb_writeb (*src8++, ++dst8); - }else { -fb_writeb (*src8++, --dst8); - dst8 +=2 ; - } - } - dst = (u32 __iomem *)dst8; - } *ppos += c; buf += c;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 178/284 media: hdpvr: initialize dev->worker at hdpvr_register_videodev
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 07922937e9a580825f9965c46fd15e23ba5754b6 ]
hdpvr_register_videodev is responsible to initialize a worker in hdpvr_device. However, the worker is only initialized at hdpvr_start_streaming other than hdpvr_register_videodev. When hdpvr_probe does not initialize its worker, the hdpvr_disconnect will encounter one WARN in flush_work.The stack trace is as follows:
hdpvr_disconnect+0xb8/0xf2 drivers/media/usb/hdpvr/hdpvr-core.c:425 usb_unbind_interface+0xbf/0x3a0 drivers/usb/core/driver.c:458 __device_release_driver drivers/base/dd.c:1206 [inline] device_release_driver_internal+0x22a/0x230 drivers/base/dd.c:1237 bus_remove_device+0x108/0x160 drivers/base/bus.c:529 device_del+0x1fe/0x510 drivers/base/core.c:3592 usb_disable_device+0xd1/0x1d0 drivers/usb/core/message.c:1419 usb_disconnect+0x109/0x330 drivers/usb/core/hub.c:2228
Fix this by moving the initialization of dev->worker to the starting of hdpvr_register_videodev
--- drivers/media/usb/hdpvr/hdpvr-video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/hdpvr/hdpvr-video.c +3 -1
@@ -312,7 +312,6 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev) dev->status =STATUS_STREAMING ; -INIT_WORK (&dev->worker, hdpvr_transmit_buffers);schedule_work (&dev->worker); v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
@@ -1175,6 +1174,9 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,bool ac3 = dev->flags &HDPVR_FLAG_AC3_CAP ;int res; +// initialize dev->worker +INIT_WORK (&dev->worker, hdpvr_transmit_buffers); + dev->cur_std =V4L2_STD_525_60 ; dev->width =720 ; dev->height =480 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 179/284 mmc: host: Return an error when ->enable_sdio_irq() ops is missing
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
[ Upstream commit d6c9219ca1139b74541b2a98cee47a3426d754a9 ]
Even if the current WARN() notifies the user that something is severely wrong, we can still end up in a PANIC() when trying to invoke the missing ->enable_sdio_irq() ops. Therefore, let's also return an error code and prevent the host from being added.
While at it, move the code into a separate function to prepare for subsequent changes and for further host caps validations.
--- drivers/mmc/core/host.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/core/host.c +13 -2
@@ -401,6 +401,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)EXPORT_SYMBOL (mmc_alloc_host); +static int mmc_validate_host_caps (struct mmc_host *host) +{ +if (host->caps &MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) { +dev_warn (host->parent,"missing ->enable_sdio_irq() ops\n" ); +return -EINVAL ; + } + +return 0 ; +} +/** * mmc_add_host - initialise host hardware * @host: mmc host
@@ -413,8 +423,9 @@ int mmc_add_host(struct mmc_host *host) {int err; -WARN_ON ((host->caps &MMC_CAP_SDIO_IRQ ) && - !host->ops->enable_sdio_irq); + err =mmc_validate_host_caps (host); +if (err) +return err; err =device_add (&host->class_dev);if (err)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 180/284 powerpc/lib/sstep: Fix sthcx instruction
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit a633cb1edddaa643fadc70abc88f89a408fa834a upstream.
Looks like there been a copy paste mistake when added the instruction 'stbcx' twice and one was probably meant to be 'sthcx'. Changing to 'sthcx' from 'stbcx'.
--- arch/powerpc/lib/sstep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/sstep.c +1 -1
@@ -2776,7 +2776,7 @@ int emulate_loadstore(struct pt_regs *re__put_user_asmx (op->val, ea, err,"stbcx." , cr);break ;case 2 : -__put_user_asmx (op->val, ea, err,"stbcx." , cr); +__put_user_asmx (op->val, ea, err,"sthcx." , cr);break ;#endif case 4 :
Greg Kroah-Hartman
maintainerPATCH 181/284 powerpc/lib/sstep: Fix build errors with newer binutils
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit 8219d31effa7be5dbc7ff915d7970672e028c701 upstream.
Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian 2.37.90.20220207) the following build error shows up:
{standard input}: Assembler messages:
{standard input}:10576: Error: unrecognized opcode: stbcx.' {standard input}:10680: Error: unrecognized opcode: lharx' {standard input}:10694: Error: unrecognized opcode: `lbarx'
Rework to add assembler directives [1] around the instruction. The problem with this might be that we can trick a power6 into single-stepping through an stbcx. for instance, and it will execute that in kernel mode.
[1] https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo
--- arch/powerpc/lib/sstep.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/powerpc/lib/sstep.c +6 -0
@@ -908,7 +908,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);#define __put_user_asmx (x, addr, err, op, cr) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine power8\n" \ "1: " op " %2,0,%3\n" \ + ".machine pop\n" \ " mfcr %1\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \
@@ -921,7 +924,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);#define __get_user_asmx (x, addr, err, op) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine power8\n" \ "1: "op" %1,0,%2\n" \ + ".machine pop\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: li %0,%3\n" \
Greg Kroah-Hartman
maintainerPATCH 182/284 scsi: qla2xxx: Fix warning for missing error code
In reply to Greg Kroah-HartmanFrom: Nilesh Javali <[email protected]>
commit 14cb838d245ae0d523b2f7804af5a02c22e79f5a upstream.
Fix smatch-reported warning message:
drivers/scsi/qla2xxx/qla_target.c:3324 qlt_xmit_response() warn: missing error code 'res'
--- drivers/scsi/qla2xxx/qla_target.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_target.c +1 -0
@@ -3095,6 +3095,7 @@ int qlt_xmit_response(struct qla_tgt_cmd"RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n" , vha->flags.online,qla2x00_reset_active (vha), cmd->reset_count, qpair->chip_reset); + res =0 ; goto out_unmap_unlock; }
Greg Kroah-Hartman
maintainerPATCH 183/284 scsi: qla2xxx: Suppress a kernel complaint in qla_create_qpair()
In reply to Greg Kroah-HartmanFrom: Saurav Kashyap <[email protected]>
commit a60447e7d451df42c7bde43af53b34f10f34f469 upstream.
[ 12.323788] BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/1020 [ 12.332297] caller is qla2xxx_create_qpair+0x32a/0x5d0 [qla2xxx] [ 12.338417] CPU: 7 PID: 1020 Comm: systemd-udevd Tainted: G I --------- --- 5.14.0-29.el9.x86_64 #1 [ 12.348827] Hardware name: Dell Inc. PowerEdge R610/0F0XJ6, BIOS 6.6.0 05/22/2018 [ 12.356356] Call Trace: [ 12.358821] dump_stack_lvl+0x34/0x44 [ 12.362514] check_preemption_disabled+0xd9/0xe0 [ 12.367164] qla2xxx_create_qpair+0x32a/0x5d0 [qla2xxx] [ 12.372481] qla2x00_probe_one+0xa3a/0x1b80 [qla2xxx] [ 12.377617] ? _raw_spin_lock_irqsave+0x19/0x40 [ 12.384284] local_pci_probe+0x42/0x80 [ 12.390162] ? pci_match_device+0xd7/0x110 [ 12.396366] pci_device_probe+0xfd/0x1b0 [ 12.402372] really_probe+0x1e7/0x3e0 [ 12.408114] __driver_probe_device+0xfe/0x180 [ 12.414544] driver_probe_device+0x1e/0x90 [ 12.420685] __driver_attach+0xc0/0x1c0 [ 12.426536] ? __device_attach_driver+0xe0/0xe0 [ 12.433061] ? __device_attach_driver+0xe0/0xe0 [ 12.439538] bus_for_each_dev+0x78/0xc0 [ 12.445294] bus_add_driver+0x12b/0x1e0 [ 12.451021] driver_register+0x8f/0xe0 [ 12.456631] ? 0xffffffffc07bc000 [ 12.461773] qla2x00_module_init+0x1be/0x229 [qla2xxx] [ 12.468776] do_one_initcall+0x44/0x200 [ 12.474401] ? load_module+0xad3/0xba0 [ 12.479908] ? kmem_cache_alloc_trace+0x45/0x410 [ 12.486268] do_init_module+0x5c/0x280 [ 12.491730] __do_sys_init_module+0x12e/0x1b0 [ 12.497785] do_syscall_64+0x3b/0x90 [ 12.503029] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 12.509764] RIP: 0033:0x7f554f73ab2e
--- drivers/scsi/qla2xxx/qla_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_init.c +1 -1
@@ -8037,7 +8037,7 @@ struct qla_qpair *qla2xxx_create_qpair(s qpair->rsp->req = qpair->req; qpair->rsp->qpair = qpair;/* init qpair to this cpu. Will adjust at run time. */ -qla_cpu_update (qpair,smp_processor_id ()); +qla_cpu_update (qpair,raw_smp_processor_id ());if (IS_T10_PI_CAPABLE (ha) && ql2xenabledif) {if (ha->fw_attributes &BIT_4 )
Greg Kroah-Hartman
maintainerPATCH 184/284 KVM: Prevent module exit until all VMs are freed
In reply to Greg Kroah-HartmanFrom: David Matlack <[email protected]>
commit 5f6de5cbebee925a612856fce6f9182bb3eee0db upstream.
Tie the lifetime the KVM module to the lifetime of each VM via kvm.users_count. This way anything that grabs a reference to the VM via kvm_get_kvm() cannot accidentally outlive the KVM module.
Prior to this commit, the lifetime of the KVM module was tied to the lifetime of /dev/kvm file descriptors, VM file descriptors, and vCPU file descriptors by their respective file_operations "owner" field. This approach is insufficient because references grabbed via kvm_get_kvm() do not prevent closing any of the aforementioned file descriptors.
This fixes a long standing theoretical bug in KVM that at least affects async page faults. kvm_setup_async_pf() grabs a reference via kvm_get_kvm(), and drops it in an asynchronous work callback. Nothing prevents the VM file descriptor from being closed and the KVM module from being unloaded before this callback runs.
Message-Id: <[email protected]>
--- virt/kvm/kvm_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
virt/kvm/kvm_main.c +13 -0
@@ -112,6 +112,8 @@ EXPORT_SYMBOL_GPL(kvm_debugfs_dir);static int kvm_debugfs_num_entries;static const struct file_operations *stat_fops_per_vm[]; +static struct file_operations kvm_chardev_ops; +static long kvm_vcpu_ioctl (struct file *file,unsigned int ioctl,unsigned long arg);#ifdef CONFIG_KVM_COMPAT
@@ -716,6 +718,16 @@ static struct kvm *kvm_create_vm(unsignepreempt_notifier_inc (); +/* +* When the fd passed to this ioctl() is opened it pins the module, +* but try_module_get() also prevents getting a reference if the module +* is in MODULE_STATE_GOING (e.g. if someone ran "rmmod --wait"). +*/ +if (!try_module_get (kvm_chardev_ops.owner)) { + r = -ENODEV ; + goto out_err; + } +return kvm; out_err:
@@ -792,6 +804,7 @@ static void kvm_destroy_vm(struct kvm *kpreempt_notifier_dec ();hardware_disable_all ();mmdrop (mm); +module_put (kvm_chardev_ops.owner); }void kvm_get_kvm (struct kvm *kvm)
Greg Kroah-Hartman
maintainerPATCH 185/284 ubifs: rename_whiteout: Fix double free for whiteout_ui->data
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 40a8f0d5e7b3999f096570edab71c345da812e3e upstream.
'whiteout_ui->data' will be freed twice if space budget fail for rename whiteout operation as following process:
rename_whiteout
dev = kmalloc
whiteout_ui->data = dev
kfree(whiteout_ui->data) // Free first time
iput(whiteout)
ubifs_free_inode
kfree(ui->data) // Double free!KASAN reports:
==================================================================
BUG: KASAN: double-free or invalid-free in ubifs_free_inode+0x4f/0x70 Call Trace: kfree+0x117/0x490 ubifs_free_inode+0x4f/0x70 [ubifs] i_callback+0x30/0x60 rcu_do_batch+0x366/0xac0 __do_softirq+0x133/0x57f Allocated by task 1506: kmem_cache_alloc_trace+0x3c2/0x7a0 do_rename+0x9b7/0x1150 [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 Freed by task 1506: kfree+0x117/0x490 do_rename.cold+0x53/0x8a [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 The buggy address belongs to the object at ffff88810238bed8 which
belongs to the cache kmalloc-8 of size 8
==================================================================
Let ubifs_free_inode() free 'whiteout_ui->data'. BTW, delete unused assignment 'whiteout_ui->data_len = 0', process 'ubifs_evict_inode() -> ubifs_jnl_delete_inode() -> ubifs_jnl_write_inode()' doesn't need it (because 'inc_nlink(whiteout)' won't be excuted by 'goto out_release',
and the nlink of whiteout inode is 0).
--- fs/ubifs/dir.c | 2 -- 1 file changed, 2 deletions(-)
fs/ubifs/dir.c +0 -2
@@ -1496,8 +1496,6 @@ static int do_rename(struct inode *old_d err =ubifs_budget_space (c, &wht_req);if (err) { -kfree (whiteout_ui->data); - whiteout_ui->data_len =0 ;iput (whiteout); goto out_release; }
Greg Kroah-Hartman
maintainerPATCH 186/284 ubifs: Add missing iput if do_tmpfile() failed in rename whiteout
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 716b4573026bcbfa7b58ed19fe15554bac66b082 upstream.
whiteout inode should be put when do_tmpfile() failed if inode has been initialized. Otherwise we will get following warning during umount:
UBIFS error (ubi0:0 pid 1494): ubifs_assert_failed [ubifs]: UBIFS assert failed: c->bi.dd_growth == 0, in fs/ubifs/super.c:1930
VFS: Busy inodes after unmount of ubifs. Self-destruct in 5 seconds.
--- fs/ubifs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/dir.c +2 -0
@@ -468,6 +468,8 @@ out_inode:make_bad_inode (inode);if (!instantiated)iput (inode); +else if (whiteout) +iput (*whiteout); out_budg:ubifs_release_budget (c, &req);if (!instantiated)
Greg Kroah-Hartman
maintainerPATCH 187/284 ubifs: setflags: Make dirtied_ino_d 8 bytes aligned
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 1b83ec057db16b4d0697dc21ef7a9743b6041f72 upstream.
Make 'ui->data_len' aligned with 8 bytes before it is assigned to dirtied_ino_d. Since 8871d84c8f8b0c6b("ubifs: convert to fileattr") applied, 'setflags()' only affects regular files and directories, only xattr inode, symlink inode and special inode(pipe/char_dev/block_dev) have none- zero 'ui->data_len' field, so assertion '!(req->dirtied_ino_d & 7)' cannot fail in ubifs_budget_space(). To avoid assertion fails in future evolution(eg. setflags can operate special inodes), it's better to make dirtied_ino_d 8 bytes aligned, after all aligned size is still zero for regular files.
--- fs/ubifs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/ioctl.c +1 -1
@@ -110,7 +110,7 @@ static int setflags(struct inode *inode,struct ubifs_inode *ui =ubifs_inode (inode);struct ubifs_info *c = inode->i_sb->s_fs_info;struct ubifs_budget_req req = { .dirtied_ino =1 , - .dirtied_ino_d = ui->data_len }; + .dirtied_ino_d =ALIGN (ui->data_len,8 ) }; err =ubifs_budget_space (c, &req);if (err)
Greg Kroah-Hartman
maintainerPATCH 188/284 ubifs: rename_whiteout: correct old_dir size computing
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit 705757274599e2e064dd3054aabc74e8af31a095 upstream.
When renaming the whiteout file, the old whiteout file is not deleted. Therefore, we add the old dentry size to the old dir like XFS. Otherwise, an error may be reported due to fscki->calc_sz != fscki->size in check_indes.
--- fs/ubifs/dir.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ubifs/dir.c +3 -0
@@ -1452,6 +1452,9 @@ static int do_rename(struct inode *old_dif (unlink)drop_nlink (old_dir); } + +/* Add the old_dentry size to the old_dir size. */ + old_sz -=CALC_DENT_SIZE (fname_len (&old_nm)); } old_dir->i_size -= old_sz;
Greg Kroah-Hartman
maintainerPATCH 189/284 can: mcba_usb: mcba_usb_start_xmit(): fix double dev_kfree_skb in error path
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
commit 04c9b00ba83594a29813d6b1fb8fdc93a3915174 upstream.
There is no need to call dev_kfree_skb() when usb_submit_urb() fails because can_put_echo_skb() deletes original skb and can_free_echo_skb() deletes the cloned skb.
--- drivers/net/can/usb/mcba_usb.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/can/usb/mcba_usb.c +0 -1
@@ -379,7 +379,6 @@ static netdev_tx_t mcba_usb_start_xmit(s xmit_failed:can_free_echo_skb (priv->netdev, ctx->ndx);mcba_usb_free_ctx (ctx); -dev_kfree_skb (skb); stats->tx_dropped++;return NETDEV_TX_OK ;
Greg Kroah-Hartman
maintainerPATCH 190/284 can: mcba_usb: properly check endpoint type
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
commit 136bed0bfd3bc9c95c88aafff2d22ecb3a919f23 upstream.
Syzbot reported warning in usb_submit_urb() which is caused by wrong endpoint type. We should check that in endpoint is actually present to prevent this warning.
Found pipes are now saved to struct mcba_priv and code uses them directly instead of making pipes in place.
Fail log:
| usb 5-1: BOGUS urb xfer, pipe 3 != type 1 | WARNING: CPU: 1 PID: 49 at drivers/usb/core/urb.c:502 usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | Modules linked in: | CPU: 1 PID: 49 Comm: kworker/1:2 Not tainted 5.17.0-rc6-syzkaller-00184-g38f80f42147f #0 | Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 | Workqueue: usb_hub_wq hub_event | RIP: 0010:usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | ... | Call Trace: | <TASK> | mcba_usb_start drivers/net/can/usb/mcba_usb.c:662 [inline] | mcba_usb_probe+0x8a3/0xc50 drivers/net/can/usb/mcba_usb.c:858 | usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396 | call_driver_probe drivers/base/dd.c:517 [inline]
--- drivers/net/can/usb/mcba_usb.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/net/can/usb/mcba_usb.c +16 -10
@@ -44,10 +44,6 @@#define MCBA_USB_RX_BUFF_SIZE 64#define MCBA_USB_TX_BUFF_SIZE (sizeof(struct mcba_usb_msg)) -/* MCBA endpoint numbers */ -#define MCBA_USB_EP_IN 1 -#define MCBA_USB_EP_OUT 1 -/* Microchip command id */ #define MBCA_CMD_RECEIVE_MESSAGE 0xE3#define MBCA_CMD_I_AM_ALIVE_FROM_CAN 0xF5
@@ -95,6 +91,8 @@ struct mcba_priv {atomic_t free_ctx_cnt;void *rxbuf[MCBA_MAX_RX_URBS ];dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS ]; +int rx_pipe; +int tx_pipe; };/* CAN frame */
@@ -283,10 +281,8 @@ static netdev_tx_t mcba_usb_xmit(structmemcpy (buf, usb_msg,MCBA_USB_TX_BUFF_SIZE ); -usb_fill_bulk_urb (urb, priv->udev, -usb_sndbulkpipe (priv->udev,MCBA_USB_EP_OUT ), buf, -MCBA_USB_TX_BUFF_SIZE , mcba_usb_write_bulk_callback, - ctx); +usb_fill_bulk_urb (urb, priv->udev, priv->tx_pipe, buf,MCBA_USB_TX_BUFF_SIZE , + mcba_usb_write_bulk_callback, ctx); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;usb_anchor_urb (urb, &priv->tx_submitted);
@@ -621,7 +617,7 @@ static void mcba_usb_read_bulk_callback( resubmit_urb:usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_OUT ), + priv->rx_pipe, urb->transfer_buffer,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv);
@@ -666,7 +662,7 @@ static int mcba_usb_start(struct mcba_pr urb->transfer_dma = buf_dma;usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_IN ), + priv->rx_pipe, buf,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;
@@ -820,6 +816,13 @@ static int mcba_usb_probe(struct usb_intstruct mcba_priv *priv;int err = -ENOMEM ;struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_endpoint_descriptor *in, *out; + + err =usb_find_common_endpoints (intf->cur_altsetting, &in, &out,NULL ,NULL ); +if (err) { +dev_err (&intf->dev,"Can't find endpoints\n" ); +return err; + } netdev =alloc_candev (sizeof (struct mcba_priv ),MCBA_MAX_TX_URBS );if (!netdev) {
@@ -865,6 +868,9 @@ static int mcba_usb_probe(struct usb_int goto cleanup_free_candev; } + priv->rx_pipe =usb_rcvbulkpipe (priv->udev, in->bEndpointAddress); + priv->tx_pipe =usb_sndbulkpipe (priv->udev, out->bEndpointAddress); +devm_can_led_init (netdev);/* Start USB dev only if we have successfully registered CAN device */
Greg Kroah-Hartman
maintainerPATCH 191/284 gfs2: Make sure FITRIM minlen is rounded up to fs block size
In reply to Greg Kroah-HartmanFrom: Andrew Price <[email protected]>
commit 27ca8273fda398638ca994a207323a85b6d81190 upstream.
Per fstrim(8) we must round up the minlen argument to the fs block size. The current calculation doesn't take into account devices that have a discard granularity and requested minlen less than 1 fs block, so the value can get shifted away to zero in the translation to fs blocks.
The zero minlen passed to gfs2_rgrp_send_discards() then allows sb_issue_discard() to be called with nr_sects == 0 which returns -EINVAL and results in gfs2_rgrp_send_discards() returning -EIO.
Make sure minlen is never < 1 fs block by taking the max of the requested minlen and the fs block size before comparing to the device's discard granularity and shifting to fs blocks.
--- fs/gfs2/rgrp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/rgrp.c +2 -1
@@ -1380,7 +1380,8 @@ int gfs2_fitrim(struct file *filp, void start = r.start >> bs_shift; end = start + (r.len >> bs_shift); - minlen =max_t (u64, r.minlen, + minlen =max_t (u64, r.minlen, sdp->sd_sb.sb_bsize); + minlen =max_t (u64, minlen, q->limits.discard_granularity) >> bs_shift;if (end <= start || minlen > sdp->sd_max_rg_data)
Greg Kroah-Hartman
maintainerPATCH 192/284 pinctrl: pinconf-generic: Print arguments for bias-pull-*
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
commit 188e5834b930acd03ad3cf7c5e7aa24db9665a29 upstream.
The bias-pull-* properties, or PIN_CONFIG_BIAS_PULL_* pin config parameters, accept optional arguments in ohms denoting the strength of the pin bias.
Print these values out in debugfs as well.
--- drivers/pinctrl/pinconf-generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/pinconf-generic.c +3 -3
@@ -31,10 +31,10 @@ static const struct pin_config_item confPCONFDUMP (PIN_CONFIG_BIAS_BUS_HOLD ,"input bias bus hold" ,NULL , false),PCONFDUMP (PIN_CONFIG_BIAS_DISABLE ,"input bias disabled" ,NULL , false),PCONFDUMP (PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,"input bias high impedance" ,NULL , false), -PCONFDUMP (PIN_CONFIG_BIAS_PULL_DOWN ,"input bias pull down" ,NULL , false), +PCONFDUMP (PIN_CONFIG_BIAS_PULL_DOWN ,"input bias pull down" ,"ohms" , true),PCONFDUMP (PIN_CONFIG_BIAS_PULL_PIN_DEFAULT , -"input bias pull to pin specific state" ,NULL , false), -PCONFDUMP (PIN_CONFIG_BIAS_PULL_UP ,"input bias pull up" ,NULL , false), +"input bias pull to pin specific state" ,"ohms" , true), +PCONFDUMP (PIN_CONFIG_BIAS_PULL_UP ,"input bias pull up" ,"ohms" , true),PCONFDUMP (PIN_CONFIG_DRIVE_OPEN_DRAIN ,"output drive open drain" ,NULL , false),PCONFDUMP (PIN_CONFIG_DRIVE_OPEN_SOURCE ,"output drive open source" ,NULL , false), PCONFDUMP(PIN_CONFIG_DRIVE_PUSH_PULL, "output drive push pull", NULL, false),
Greg Kroah-Hartman
maintainerPATCH 193/284 ubi: Fix race condition between ctrl_cdev_ioctl and ubi_cdev_ioctl
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit 3cbf0e392f173ba0ce425968c8374a6aa3e90f2e upstream.
Hulk Robot reported a KASAN report about use-after-free:
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0x13d/0x160 Read of size 8 at addr ffff888035e37d98 by task ubiattach/1385 [...] Call Trace: klist_dec_and_del+0xa7/0x4a0 klist_put+0xc7/0x1a0 device_del+0x4d4/0xed0 cdev_device_del+0x1a/0x80 ubi_attach_mtd_dev+0x2951/0x34b0 [ubi] ctrl_cdev_ioctl+0x286/0x2f0 [ubi] Allocated by task 1414: device_add+0x60a/0x18b0 cdev_device_add+0x103/0x170 ubi_create_volume+0x1118/0x1a10 [ubi] ubi_cdev_ioctl+0xb7f/0x1ba0 [ubi] Freed by task 1385: cdev_device_del+0x1a/0x80 ubi_remove_volume+0x438/0x6c0 [ubi] ubi_cdev_ioctl+0xbf4/0x1ba0 [ubi] [...] ==================================================================
The lock held by ctrl_cdev_ioctl is ubi_devices_mutex, but the lock held by ubi_cdev_ioctl is ubi->device_mutex. Therefore, the two locks can be concurrent.
ctrl_cdev_ioctl contains two operations: ubi_attach and ubi_detach. ubi_detach is bug-free because it uses reference counting to prevent concurrency. However, uif_init and uif_close in ubi_attach may race with ubi_cdev_ioctl.
uif_init will race with ubi_cdev_ioctl as in the following stack.
cpu1 cpu2 cpu3
_______________________|________________________|______________________ ctrl_cdev_ioctl
ubi_attach_mtd_dev
uif_init
ubi_cdev_ioctl
ubi_create_volume
cdev_device_add
ubi_add_volume
// sysfs exist
kill_volumes
ubi_cdev_ioctl
ubi_remove_volume
cdev_device_del
// first free
ubi_free_volume
cdev_del
// double free cdev_device_del
And uif_close will race with ubi_cdev_ioctl as in the following stack.
cpu1 cpu2 cpu3
_______________________|________________________|______________________ ctrl_cdev_ioctl
ubi_attach_mtd_dev
uif_init
ubi_cdev_ioctl
ubi_create_volume
cdev_device_add
ubi_debugfs_init_dev
//error goto out_uif;
uif_close
kill_volumes
ubi_cdev_ioctl
ubi_remove_volume
cdev_device_del
// first free
ubi_free_volume
// double freeThe cause of this problem is that commit 714fb87e8bc0 make device "available" before it becomes accessible via sysfs. Therefore, we roll back the modification. We will fix the race condition between ubi device creation and udev by removing ubi_get_device in vol_attribute_show and dev_attribute_show.This avoids accessing uninitialized ubi_devices[ubi_num].
ubi_get_device is used to prevent devices from being deleted during sysfs execution. However, now kernfs ensures that devices will not be deleted before all reference counting are released. The key process is shown in the following stack.
device_del
device_remove_attrs
device_remove_groups
sysfs_remove_groups
sysfs_remove_group
remove_files
kernfs_remove_by_name
kernfs_remove_by_name_ns
__kernfs_remove
kernfs_drain
--- drivers/mtd/ubi/build.c | 9 +-------- drivers/mtd/ubi/vmt.c | 8 +------- 2 files changed, 2 insertions(+), 15 deletions(-)
drivers/mtd/ubi/build.c +1 -8
@@ -363,9 +363,6 @@ static ssize_t dev_attribute_show(struct* we still can use 'ubi->ubi_num'. */ ubi = container_of(dev, struct ubi_device, dev); - ubi =ubi_get_device (ubi->ubi_num); -if (!ubi) -return -ENODEV ;if (attr == &dev_eraseblock_size) ret =sprintf (buf,"%d\n" , ubi->leb_size);
@@ -394,7 +391,6 @@ static ssize_t dev_attribute_show(structelse ret = -EINVAL ; -ubi_put_device (ubi);return ret; }
@@ -960,9 +956,6 @@ int ubi_attach_mtd_dev(struct mtd_info * goto out_detach; } -/* Make device "available" before it becomes accessible via sysfs */ - ubi_devices[ubi_num] = ubi; - err =uif_init (ubi);if (err) goto out_detach;
@@ -1007,6 +1000,7 @@ int ubi_attach_mtd_dev(struct mtd_info *wake_up_process (ubi->bgt_thread);spin_unlock (&ubi->wl_lock); + ubi_devices[ubi_num] = ubi;ubi_notify_all (ubi,UBI_VOLUME_ADDED ,NULL );return ubi_num;
@@ -1015,7 +1009,6 @@ out_debugfs: out_uif:uif_close (ubi); out_detach: - ubi_devices[ubi_num] =NULL ;ubi_wl_close (ubi);ubi_free_internal_volumes (ubi);vfree (ubi->vtbl);
drivers/mtd/ubi/vmt.c +1 -7
@@ -69,16 +69,11 @@ static ssize_t vol_attribute_show(struct {int ret; struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev); -struct ubi_device *ubi; - - ubi =ubi_get_device (vol->ubi->ubi_num); -if (!ubi) -return -ENODEV ; +struct ubi_device *ubi = vol->ubi;spin_lock (&ubi->volumes_lock);if (!ubi->volumes[vol->vol_id]) {spin_unlock (&ubi->volumes_lock); -ubi_put_device (ubi);return -ENODEV ; }/* Take a reference to prevent volume removal */
@@ -116,7 +111,6 @@ static ssize_t vol_attribute_show(struct vol->ref_count -=1 ;ubi_assert (vol->ref_count >=0 );spin_unlock (&ubi->volumes_lock); -ubi_put_device (ubi);return ret; }
Greg Kroah-Hartman
maintainerPATCH 194/284 ACPI: CPPC: Avoid out of bounds access when parsing _CPC data
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 40d8abf364bcab23bc715a9221a3c8623956257b upstream.
If the NumEntries field in the _CPC return package is less than 2, do not attempt to access the "Revision" element of that package, because it may not be present then.
--- drivers/acpi/cppc_acpi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/acpi/cppc_acpi.c +5 -0
@@ -678,6 +678,11 @@ int acpi_cppc_processor_probe(struct acp cpc_obj = &out_obj->package.elements[0 ];if (cpc_obj->type ==ACPI_TYPE_INTEGER ) { num_ent = cpc_obj->integer.value; +if (num_ent <=1 ) { +pr_debug ("Unexpected _CPC NumEntries value (%d) for CPU:%d\n" , + num_ent, pr->id); + goto out_free; + } }else {pr_debug ("Unexpected entry type(%d) for NumEntries\n" , cpc_obj->type);
Greg Kroah-Hartman
maintainerPATCH 195/284 mm/mmap: return 1 from stack_guard_gap __setup() handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit e6d094936988910ce6e8197570f2753898830081 upstream.
__setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; it just pollutes init's environment). This prevents:
Unknown kernel command line parameters \ "BOOT_IMAGE=/boot/bzImage-517rc5 stack_guard_gap=100", will be \ passed to user space.
Run /sbin/init as init process
with arguments:
/sbin/init
with environment:
HOME=/
TERM=linux
BOOT_IMAGE=/boot/bzImage-517rc5
stack_guard_gap=100Return 1 to indicate that the boot option has been handled.
Note that there is no warning message if someone enters:
stack_guard_gap=anything_invalid
and 'val' and stack_guard_gap are both set to 0 due to the use of simple_strtoul(). This could be improved by using kstrtoxxx() and checking for an error.
It appears that having stack_guard_gap == 0 is valid (if unexpected) since using "stack_guard_gap=0" on the kernel command line does that.
--- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mmap.c +1 -1
@@ -2426,7 +2426,7 @@ static int __init cmdline_parse_stack_guif (!*endptr) stack_guard_gap = val <<PAGE_SHIFT ; -return 0 ; +return 1 ; }__setup ("stack_guard_gap=" , cmdline_parse_stack_guard_gap);
Greg Kroah-Hartman
maintainerPATCH 196/284 mm/memcontrol: return 1 from cgroup.memory __setup() handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 460a79e18842caca6fa0c415de4a3ac1e671ac50 upstream.
__setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; it just pollutes init's environment).
The only reason that this particular __setup handler does not pollute init's environment is that the setup string contains a '.', as in "cgroup.memory". This causes init/main.c::unknown_boottoption() to consider it to be an "Unused module parameter" and ignore it. (This is for parsing of loadable module parameters any time after kernel init.) Otherwise the string "cgroup.memory=whatever" would be added to init's environment strings.
Instead of relying on this '.' quirk, just return 1 to indicate that the boot option has been handled.
Note that there is no warning message if someone enters:
cgroup.memory=anything_invalid
--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
@@ -5978,7 +5978,7 @@ static int __init cgroup_memory(char *s)if (!strcmp (token,"nokmem" )) cgroup_memory_nokmem = true; } -return 0 ; +return 1 ; }__setup ("cgroup.memory=" , cgroup_memory);
Greg Kroah-Hartman
maintainerPATCH 197/284 ubi: fastmap: Return error code if memory allocation fails in add_aeb()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit c3c07fc25f37c157fde041b3a0c3dfcb1590cbce upstream.
Abort fastmap scanning and return error code if memory allocation fails in add_aeb(). Otherwise ubi will get wrong peb statistics information after scanning.
--- drivers/mtd/ubi/fastmap.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/mtd/ubi/fastmap.c +19 -9
@@ -478,7 +478,9 @@ static int scan_pool(struct ubi_device *if (err ==UBI_IO_FF_BITFLIPS ) scrub =1 ; -add_aeb (ai, free, pnum, ec, scrub); + ret =add_aeb (ai, free, pnum, ec, scrub); +if (ret) + goto out;continue ; }else if (err ==0 || err ==UBI_IO_BITFLIPS ) {dbg_bld ("Found non empty PEB:%i in pool" , pnum);
@@ -648,8 +650,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &ai->free,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),0 ); + ret =add_aeb (ai, &ai->free,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),0 ); +if (ret) + goto fail; }/* read EC values from used list */
@@ -659,8 +663,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &used,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),0 ); + ret =add_aeb (ai, &used,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),0 ); +if (ret) + goto fail; }/* read EC values from scrub list */
@@ -670,8 +676,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &used,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),1 ); + ret =add_aeb (ai, &used,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),1 ); +if (ret) + goto fail; }/* read EC values from erase list */
@@ -681,8 +689,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &ai->erase,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),1 ); + ret =add_aeb (ai, &ai->erase,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),1 ); +if (ret) + goto fail; } ai->mean_ec =div_u64 (ai->ec_sum, ai->ec_count);
Greg Kroah-Hartman
maintainerPATCH 198/284 ASoC: topology: Allow TLV control to be either read or write
In reply to Greg Kroah-HartmanFrom: Amadeusz Sławiński <[email protected]>
commit feb00b736af64875560f371fe7f58b0b7f239046 upstream.
There is no reason to force readwrite access on TLV controls. It can be either read, write or both. This is further evidenced in code where it performs following checks:
if ((k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) && !sbe->get)
return -EINVAL;
if ((k->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) && !sbe->put)
return -EINVAL;--- sound/soc/soc-topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/soc-topology.c +2 -1
@@ -599,7 +599,8 @@ static int soc_tplg_kcontrol_bind_io(strif (hdr->ops.info ==SND_SOC_TPLG_CTL_BYTES && k->iface &SNDRV_CTL_ELEM_IFACE_MIXER - && k->access &SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE + && (k->access &SNDRV_CTL_ELEM_ACCESS_TLV_READ + || k->access &SNDRV_CTL_ELEM_ACCESS_TLV_WRITE ) && k->access &SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK ) {struct soc_bytes_ext *sbe;struct snd_soc_tplg_bytes_control *be;
Greg Kroah-Hartman
maintainerPATCH 199/284 ARM: dts: spear1340: Update serial node properties
In reply to Greg Kroah-HartmanFrom: Kuldeep Singh <[email protected]>
commit 583d6b0062640def86f3265aa1042ecb6672516e upstream.
Reorder dma and dma-names property for serial node to make it compliant with bindings.
--- arch/arm/boot/dts/spear1340.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/spear1340.dtsi +3 -3
@@ -142,9 +142,9 @@ reg = <0xb4100000 0x1000>; interrupts = <0 105 0x4>; status = "disabled"; - dmas = <&dwdma0 12 0 1>, - <&dwdma0 13 1 0>; - dma-names = "tx", "rx"; + dmas = <&dwdma0 13 0 1>, + <&dwdma0 12 1 0>; + dma-names = "rx", "tx"; }; thermal@e07008c4 {
Greg Kroah-Hartman
maintainerPATCH 200/284 ARM: dts: spear13xx: Update SPI dma properties
In reply to Greg Kroah-HartmanFrom: Kuldeep Singh <[email protected]>
commit 31d3687d6017c7ce6061695361598d9cda70807a upstream.
Reorder dmas and dma-names property for spi controller node to make it compliant with bindings.
--- arch/arm/boot/dts/spear13xx.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/spear13xx.dtsi +3 -3
@@ -290,9 +290,9 @@ #size-cells = <0>; interrupts = <0 31 0x4>; status = "disabled"; - dmas = <&dwdma0 4 0 0>, - <&dwdma0 5 0 0>; - dma-names = "tx", "rx"; + dmas = <&dwdma0 5 0 0>, + <&dwdma0 4 0 0>; + dma-names = "rx", "tx"; }; rtc@e0580000 {
Greg Kroah-Hartman
maintainerPATCH 201/284 openvswitch: Fixed nd target mask field in the flow dump.
In reply to Greg Kroah-HartmanFrom: Martin Varghese <[email protected]>
commit f19c44452b58a84d95e209b847f5495d91c9983a upstream.
IPv6 nd target mask was not getting populated in flow dump.
In the function __ovs_nla_put_key the icmp code mask field was checked instead of icmp code key field to classify the flow as neighbour discovery.
ufid:bdfbe3e5-60c2-43b0-a5ff-dfcac1c37328, recirc_id(0),dp_hash(0/0), skb_priority(0/0),in_port(ovs-nm1),skb_mark(0/0),ct_state(0/0), ct_zone(0/0),ct_mark(0/0),ct_label(0/0), eth(src=00:00:00:00:00:00/00:00:00:00:00:00, dst=00:00:00:00:00:00/00:00:00:00:00:00),eth_type(0x86dd), ipv6(src=::/::,dst=::/::,label=0/0,proto=58,tclass=0/0,hlimit=0/0,frag=no), icmpv6(type=135,code=0),
nd(target=2001::2/::,
sll=00:00:00:00:00:00/00:00:00:00:00:00, tll=00:00:00:00:00:00/00:00:00:00:00:00),
packets:10, bytes:860, used:0.504s, dp:ovs, actions:ovs-nm2
--- net/openvswitch/flow_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/openvswitch/flow_netlink.c +2 -2
@@ -1827,8 +1827,8 @@ static int __ovs_nla_put_key(const struc icmpv6_key->icmpv6_type =ntohs (output->tp.src); icmpv6_key->icmpv6_code =ntohs (output->tp.dst); -if (icmpv6_key->icmpv6_type ==NDISC_NEIGHBOUR_SOLICITATION || - icmpv6_key->icmpv6_type ==NDISC_NEIGHBOUR_ADVERTISEMENT ) { +if (swkey->tp.src ==htons (NDISC_NEIGHBOUR_SOLICITATION ) || + swkey->tp.src ==htons (NDISC_NEIGHBOUR_ADVERTISEMENT )) {struct ovs_key_nd *nd_key; nla =nla_reserve (skb,OVS_KEY_ATTR_ND ,sizeof (*nd_key));
Greg Kroah-Hartman
maintainerPATCH 202/284 KVM: x86: Forbid VMM to set SYNIC/STIMER MSRs when SynIC wasnt activated
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit b1e34d325397a33d97d845e312d7cf2a8b646b44 upstream.
Setting non-zero values to SYNIC/STIMER MSRs activates certain features, this should not happen when KVM_CAP_HYPERV_SYNIC{,2} was not activated.
Note, it would've been better to forbid writing anything to SYNIC/STIMER MSRs, including zeroes, however, at least QEMU tries clearing HV_X64_MSR_STIMER0_CONFIG without SynIC. HV_X64_MSR_EOM MSR is somewhat 'special' as writing zero there triggers an action, this also should not happen when SynIC wasn't activated.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/x86/kvm/hyperv.c +15 -0
@@ -260,6 +260,9 @@ static int synic_set_msr(struct kvm_vcpucase HV_X64_MSR_EOM : {int i; +if (!synic->active) +break ; +for (i =0 ; i <ARRAY_SIZE (synic->sint); i++)kvm_hv_notify_acked_sint (vcpu, i);break ;
@@ -520,6 +523,12 @@ static int stimer_start(struct kvm_vcpu_static int stimer_set_config (struct kvm_vcpu_hv_stimer *stimer,u64 config,bool host) { +struct kvm_vcpu *vcpu =stimer_to_vcpu (stimer); +struct kvm_vcpu_hv_synic *synic =vcpu_to_synic (vcpu); + +if (!synic->active && (!host || config)) +return 1 ; +trace_kvm_hv_stimer_set_config (stimer_to_vcpu (stimer)->vcpu_id, stimer->index, config, host);
@@ -534,6 +543,12 @@ static int stimer_set_config(struct kvm_static int stimer_set_count (struct kvm_vcpu_hv_stimer *stimer,u64 count,bool host) { +struct kvm_vcpu *vcpu =stimer_to_vcpu (stimer); +struct kvm_vcpu_hv_synic *synic =vcpu_to_synic (vcpu); + +if (!synic->active && (!host || count)) +return 1 ; +trace_kvm_hv_stimer_set_count (stimer_to_vcpu (stimer)->vcpu_id, stimer->index, count, host);
Greg Kroah-Hartman
maintainerPATCH 203/284 ubifs: Rectify space amount budget for mkdir/tmpfile operations
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
[ Upstream commit a6dab6607d4681d227905d5198710b575dbdb519 ]
UBIFS should make sure the flash has enough space to store dirty (Data that is newer than disk) data (in memory), space budget is exactly designed to do that. If space budget calculates less data than we need, 'make_reservation()' will do more work(return -ENOSPC if no free space lelf, sometimes we can see "cannot reserve xxx bytes in jhead xxx, error -28" in ubifs error messages) with ubifs inodes locked, which may effect other syscalls.
A simple way to decide how much space do we need when make a budget:
See how much space is needed by 'make_reservation()' in ubifs_jnl_xxx() function according to corresponding operation.
It's better to report ENOSPC in ubifs_budget_space(), as early as we can.
--- fs/ubifs/dir.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ubifs/dir.c +8 -4
@@ -390,15 +390,18 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry, {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 };struct ubifs_inode *ui, *dir_ui =ubifs_inode (dir);int err, instantiated =0 ;struct fscrypt_name nm;/* -* Budget request settings: new dirty inode, new direntry, -* budget for dirtied inode will be released via writeback. +* Budget request settings: new inode, new direntry, changing the +* parent directory inode. +* Allocate budget separately for new dirtied inode, the budget will +* be released via writeback. */ dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
@@ -990,7 +993,8 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)struct ubifs_inode *dir_ui =ubifs_inode (dir);struct ubifs_info *c = dir->i_sb->s_fs_info;int err, sz_change; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct fscrypt_name nm;/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 204/284 rtc: wm8350: Handle error for wm8350_register_irq
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 43f0269b6b89c1eec4ef83c48035608f4dcdd886 ]
As the potential failure of the wm8350_register_irq(), it should be better to check it and return error if fails. Also, it need not free 'wm_rtc->rtc' since it will be freed automatically.
--- drivers/rtc/rtc-wm8350.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/rtc/rtc-wm8350.c +9 -2
@@ -441,14 +441,21 @@ static int wm8350_rtc_probe(struct platform_device *pdev)return ret; } -wm8350_register_irq (wm8350,WM8350_IRQ_RTC_SEC , + ret =wm8350_register_irq (wm8350,WM8350_IRQ_RTC_SEC , wm8350_rtc_update_handler,0 ,"RTC Seconds" , wm8350); +if (ret) +return ret; +wm8350_mask_irq (wm8350,WM8350_IRQ_RTC_SEC ); -wm8350_register_irq (wm8350,WM8350_IRQ_RTC_ALM , + ret =wm8350_register_irq (wm8350,WM8350_IRQ_RTC_ALM , wm8350_rtc_alarm_handler,0 ,"RTC Alarm" , wm8350); +if (ret) { +wm8350_free_irq (wm8350,WM8350_IRQ_RTC_SEC , wm8350); +return ret; + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 205/284 ARM: 9187/1: JIVE: fix return value of __setup handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 8b2360c7157b462c4870d447d1e65d30ef31f9aa ]
__setup() handlers should return 1 to obsolete_checksetup() in init/main.c to indicate that the boot option has been handled. A return of 0 causes the boot option/value to be listed as an Unknown kernel parameter and added to init's (limited) argument or environment strings. Also, error return codes don't mean anything to obsolete_checksetup() -- only non-zero (usually 1) or zero. So return 1 from jive_mtdset().
--- arch/arm/mach-s3c24xx/mach-jive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-s3c24xx/mach-jive.c +3 -3
@@ -241,11 +241,11 @@ static int __init jive_mtdset(char *options)unsigned long set;if (options ==NULL || options[0 ] =='\0' ) -return 0 ; +return 1 ;if (kstrtoul (options,10 , &set)) {printk (KERN_ERR "failed to parse mtdset=%s\n" , options); -return 0 ; +return 1 ; }switch (set) {
@@ -260,7 +260,7 @@ static int __init jive_mtdset(char *options) "using default.", set); } -return 0 ; +return 1 ; }/* parse the mtdset= option given to the kernel command line */
Signature · 9 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 206/284 KVM: x86/svm: Clear reserved bits written to PerfEvtSeln MSRs
In reply to Greg Kroah-HartmanFrom: Jim Mattson <[email protected]>
[ Upstream commit 9b026073db2f1ad0e4d8b61c83316c8497981037 ]
AMD EPYC CPUs never raise a #GP for a WRMSR to a PerfEvtSeln MSR. Some reserved bits are cleared, and some are not. Specifically, on Zen3/Milan, bits 19 and 42 are not cleared.
When emulating such a WRMSR, KVM should not synthesize a #GP, regardless of which bits are set. However, undocumented bits should not be passed through to the hardware MSR. So, rather than checking for reserved bits and synthesizing a #GP, just clear the reserved bits.
This may seem pedantic, but since KVM currently does not support the "Host/Guest Only" bits (41:40), it is necessary to clear these bits rather than synthesizing #GP, because some popular guests (e.g Linux) will set the "Host Only" bit even on CPUs that don't support EFER.SVME, and they don't expect a #GP.
For example,
root@Ubuntu1804:~# perf stat -e r26 -a sleep 1
Performance counter stats for 'system wide':
0 r26
1.001070977 seconds time elapsedFeb 23 03:59:58 Ubuntu1804 kernel: [ 405.379957] unchecked MSR access error: WRMSR to 0xc0010200 (tried to write 0x0000020000130026) at rIP: 0xffffffff9b276a28 (native_write_msr+0x8/0x30) Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379958] Call Trace: Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379963] amd_pmu_disable_event+0x27/0x90
Message-Id: <[email protected]>
--- arch/x86/kvm/pmu_amd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/x86/kvm/pmu_amd.c +3 -5
@@ -139,12 +139,10 @@ static int amd_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)/* MSR_K7_EVNTSELn */ pmc =get_gp_pmc (pmu, msr,MSR_K7_EVNTSEL0 );if (pmc) { -if (data == pmc->eventsel) -return 0 ; -if (!(data & pmu->reserved_bits)) { + data &= ~pmu->reserved_bits; +if (data != pmc->eventsel)reprogram_gp_counter (pmc, data); -return 0 ; - } +return 0 ; }return 1 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 207/284 ath5k: fix OOB in ath5k_eeprom_read_pcal_info_5111
In reply to Greg Kroah-HartmanFrom: Zekun Shen <[email protected]>
[ Upstream commit 564d4eceb97eaf381dd6ef6470b06377bb50c95a ]
The bug was found during fuzzing. Stacktrace locates it in ath5k_eeprom_convert_pcal_info_5111.
When none of the curve is selected in the loop, idx can go up to AR5K_EEPROM_N_PD_CURVES. The line makes pd out of bound. pd = &chinfo[pier].pd_curves[idx];
There are many OOB writes using pd later in the code. So I added a sanity check for idx. Checks for other loops involving AR5K_EEPROM_N_PD_CURVES are not needed as the loop index is not used outside the loops.
The patch is NOT tested with real device.
The following is the fuzzing report
BUG: KASAN: slab-out-of-bounds in ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] Write of size 1 at addr ffff8880174a4d60 by task modprobe/214 CPU: 0 PID: 214 Comm: modprobe Not tainted 5.6.0 #1 Call Trace: dump_stack+0x76/0xa0 print_address_description.constprop.0+0x16/0x200 ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] __kasan_report.cold+0x37/0x7c ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] kasan_report+0xe/0x20 ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] ? apic_timer_interrupt+0xa/0x20 ? ath5k_eeprom_init_11a_pcal_freq+0xbc0/0xbc0 [ath5k] ? ath5k_pci_eeprom_read+0x228/0x3c0 [ath5k] ath5k_eeprom_init+0x2513/0x6290 [ath5k] ? ath5k_eeprom_init_11a_pcal_freq+0xbc0/0xbc0 [ath5k] ? usleep_range+0xb8/0x100 ? apic_timer_interrupt+0xa/0x20 ? ath5k_eeprom_read_pcal_info_2413+0x2f20/0x2f20 [ath5k] ath5k_hw_init+0xb60/0x1970 [ath5k] ath5k_init_ah+0x6fe/0x2530 [ath5k] ? kasprintf+0xa6/0xe0 ? ath5k_stop+0x140/0x140 [ath5k] ? _dev_notice+0xf6/0xf6 ? apic_timer_interrupt+0xa/0x20 ath5k_pci_probe.cold+0x29a/0x3d6 [ath5k] ? ath5k_pci_eeprom_read+0x3c0/0x3c0 [ath5k] ? mutex_lock+0x89/0xd0 ? ath5k_pci_eeprom_read+0x3c0/0x3c0 [ath5k] local_pci_probe+0xd3/0x160 pci_device_probe+0x23f/0x3e0 ? pci_device_remove+0x280/0x280 ? pci_device_remove+0x280/0x280 really_probe+0x209/0x5d0
--- drivers/net/wireless/ath/ath5k/eeprom.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath5k/eeprom.c +3 -0
@@ -746,6 +746,9 @@ ath5k_eeprom_convert_pcal_info_5111(struct ath5k_hw *ah, int mode, } } +if (idx ==AR5K_EEPROM_N_PD_CURVES ) + goto err_out; + ee->ee_pd_gains[mode] =1 ; pd = &chinfo[pier].pd_curves[idx];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 208/284 ptp: replace snprintf with sysfs_emit
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit e2cf07654efb0fd7bbcb475c6f74be7b5755a8fd ]
coccinelle report:
./drivers/ptp/ptp_sysfs.c:17:8-16:
WARNING: use scnprintf or sprintf
./drivers/ptp/ptp_sysfs.c:390:8-16:
WARNING: use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
--- drivers/ptp/ptp_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ptp/ptp_sysfs.c +2 -2
@@ -26,7 +26,7 @@ static ssize_t clock_name_show(struct device *dev, struct device_attribute *attr, char *page) { struct ptp_clock *ptp = dev_get_drvdata(dev); -return snprintf (page,PAGE_SIZE -1 ,"%s\n" , ptp->info->name); +return sysfs_emit (page,"%s\n" , ptp->info->name); }static DEVICE_ATTR_RO (clock_name);
@@ -240,7 +240,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct device_attribute *attr,mutex_unlock (&ptp->pincfg_mux); -return snprintf (page,PAGE_SIZE ,"%u %u\n" , func, chan); +return sysfs_emit (page,"%u %u\n" , func, chan); } static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 209/284 powerpc: dts: t104xrdb: fix phy type for FMAN 4/5
In reply to Greg Kroah-HartmanFrom: Maxim Kiselev <[email protected]>
[ Upstream commit 17846485dff91acce1ad47b508b633dffc32e838 ]
T1040RDB has two RTL8211E-VB phys which requires setting of internal delays for correct work.
Changing the phy-connection-type property to rgmii-id will fix this issue.
--- arch/powerpc/boot/dts/fsl/t104xrdb.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/boot/dts/fsl/t104xrdb.dtsi +2 -2
@@ -139,12 +139,12 @@ fman@400000 { ethernet@e6000 { phy-handle = <&phy_rgmii_0>; - phy-connection-type = "rgmii"; + phy-connection-type = "rgmii-id"; }; ethernet@e8000 { phy-handle = <&phy_rgmii_1>; - phy-connection-type = "rgmii"; + phy-connection-type = "rgmii-id"; }; mdio0: mdio@fc000 {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 210/284 scsi: mvsas: Replace snprintf() with sysfs_emit()
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit 0ad3867b0f13e45cfee5a1298bfd40eef096116c ]
coccinelle report:
./drivers/scsi/mvsas/mv_init.c:699:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/mvsas/mv_init.c:747:8-16:
WARNING: use scnprintf or sprintf
Use sysfs_emit() instead of scnprintf() or sprintf().
--- drivers/scsi/mvsas/mv_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mvsas/mv_init.c +2 -2
@@ -729,7 +729,7 @@ static ssize_t mvs_show_driver_version(struct device *cdev, struct device_attribute *attr, char *buffer) { - return snprintf(buffer, PAGE_SIZE, "%s\n", DRV_VERSION); + return sysfs_emit(buffer, "%s\n", DRV_VERSION); } static DEVICE_ATTR(driver_version,
@@ -781,7 +781,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,static ssize_t mvs_show_interrupt_coalescing (struct device *cdev,struct device_attribute *attr,char *buffer) { -return snprintf (buffer,PAGE_SIZE ,"%d\n" , interrupt_coalescing); +return sysfs_emit (buffer,"%d\n" , interrupt_coalescing); } static DEVICE_ATTR(interrupt_coalescing,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 211/284 scsi: bfa: Replace snprintf() with sysfs_emit()
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit 2245ea91fd3a04cafbe2f54911432a8657528c3b ]
coccinelle report:
./drivers/scsi/bfa/bfad_attr.c:908:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:860:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:888:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:853:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:808:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:728:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:822:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:927:9-17:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:900:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:874:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:714:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:839:8-16:
WARNING: use scnprintf or sprintf
Use sysfs_emit() instead of scnprintf() or sprintf().
--- drivers/scsi/bfa/bfad_attr.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/scsi/bfa/bfad_attr.c +13 -13
@@ -722,7 +722,7 @@ bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN ];bfa_get_adapter_serial_num (&bfad->bfa, serial_num); -return snprintf (buf,PAGE_SIZE ,"%s\n" , serial_num); +return sysfs_emit (buf,"%s\n" , serial_num); } static ssize_t
@@ -736,7 +736,7 @@ bfad_im_model_show(struct device *dev, struct device_attribute *attr,char model[BFA_ADAPTER_MODEL_NAME_LEN ];bfa_get_adapter_model (&bfad->bfa, model); -return snprintf (buf,PAGE_SIZE ,"%s\n" , model); +return sysfs_emit (buf,"%s\n" , model); } static ssize_t
@@ -816,7 +816,7 @@ bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,snprintf (model_descr,BFA_ADAPTER_MODEL_DESCR_LEN ,"Invalid Model" ); -return snprintf (buf,PAGE_SIZE ,"%s\n" , model_descr); +return sysfs_emit (buf,"%s\n" , model_descr); } static ssize_t
@@ -830,7 +830,7 @@ bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,u64 nwwn; nwwn =bfa_fcs_lport_get_nwwn (port->fcs_port); -return snprintf (buf,PAGE_SIZE ,"0x%llx\n" ,cpu_to_be64 (nwwn)); +return sysfs_emit (buf,"0x%llx\n" ,cpu_to_be64 (nwwn)); } static ssize_t
@@ -847,7 +847,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,bfa_fcs_lport_get_attr (&bfad->bfa_fcs.fabric.bport, &port_attr);strlcpy (symname, port_attr.port_cfg.sym_name.symname,BFA_SYMNAME_MAXLEN ); -return snprintf (buf,PAGE_SIZE ,"%s\n" , symname); +return sysfs_emit (buf,"%s\n" , symname); } static ssize_t
@@ -861,14 +861,14 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,char hw_ver[BFA_VERSION_LEN ];bfa_get_pci_chip_rev (&bfad->bfa, hw_ver); -return snprintf (buf,PAGE_SIZE ,"%s\n" , hw_ver); +return sysfs_emit (buf,"%s\n" , hw_ver); }static ssize_t bfad_im_drv_version_show (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%s\n" ,BFAD_DRIVER_VERSION ); +return sysfs_emit (buf,"%s\n" ,BFAD_DRIVER_VERSION ); } static ssize_t
@@ -882,7 +882,7 @@ bfad_im_optionrom_version_show(struct device *dev,char optrom_ver[BFA_VERSION_LEN ];bfa_get_adapter_optrom_ver (&bfad->bfa, optrom_ver); -return snprintf (buf,PAGE_SIZE ,"%s\n" , optrom_ver); +return sysfs_emit (buf,"%s\n" , optrom_ver); } static ssize_t
@@ -896,7 +896,7 @@ bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,char fw_ver[BFA_VERSION_LEN ];bfa_get_adapter_fw_ver (&bfad->bfa, fw_ver); -return snprintf (buf,PAGE_SIZE ,"%s\n" , fw_ver); +return sysfs_emit (buf,"%s\n" , fw_ver); } static ssize_t
@@ -908,7 +908,7 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr, (struct bfad_im_port_s *) shost->hostdata[0 ];struct bfad_s *bfad = im_port->bfad; -return snprintf (buf,PAGE_SIZE ,"%d\n" , +return sysfs_emit (buf,"%d\n" ,bfa_get_nports (&bfad->bfa)); }
@@ -916,7 +916,7 @@ static ssize_t bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_NAME); + return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME); } static ssize_t
@@ -935,14 +935,14 @@ bfad_im_num_of_discovered_ports_show(struct device *dev, rports =kzalloc (sizeof (struct bfa_rport_qualifier_s ) * nrports,GFP_ATOMIC );if (rports ==NULL ) -return snprintf (buf,PAGE_SIZE ,"Failed\n" ); +return sysfs_emit (buf,"Failed\n" );spin_lock_irqsave (&bfad->bfad_lock, flags);bfa_fcs_lport_get_rport_quals (port->fcs_port, rports, &nrports);spin_unlock_irqrestore (&bfad->bfad_lock, flags);kfree (rports); -return snprintf (buf,PAGE_SIZE ,"%d\n" , nrports); +return sysfs_emit (buf,"%d\n" , nrports); } static DEVICE_ATTR(serial_number, S_IRUGO,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 212/284 power: supply: axp20x_battery: properly report current when discharging
In reply to Greg Kroah-HartmanFrom: Evgeny Boger <[email protected]>
[ Upstream commit d4f408cdcd26921c1268cb8dcbe8ffb6faf837f3 ]
As stated in [1], negative current values are used for discharging batteries.
AXP PMICs internally have two different ADC channels for shunt current
measurement: one used during charging and one during discharging. The values reported by these ADCs are unsigned.
While the driver properly selects ADC channel to get the data from, it doesn't apply negative sign when reporting discharging current.
[1] Documentation/ABI/testing/sysfs-class-power
--- drivers/power/supply/axp20x_battery.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/power/supply/axp20x_battery.c +6 -7
@@ -160,7 +160,6 @@ static int axp20x_battery_get_prop(struct power_supply *psy, union power_supply_propval *val) {struct axp20x_batt_ps *axp20x_batt =power_supply_get_drvdata (psy); -struct iio_channel *chan;int ret =0 , reg, val1;switch (psp) {
@@ -240,12 +239,12 @@ static int axp20x_battery_get_prop(struct power_supply *psy,if (ret)return ret; -if (reg &AXP20X_PWR_STATUS_BAT_CHARGING ) - chan = axp20x_batt->batt_chrg_i; -else - chan = axp20x_batt->batt_dischrg_i; - - ret =iio_read_channel_processed (chan, &val->intval); +if (reg &AXP20X_PWR_STATUS_BAT_CHARGING ) { + ret =iio_read_channel_processed (axp20x_batt->batt_chrg_i, &val->intval); + }else { + ret =iio_read_channel_processed (axp20x_batt->batt_dischrg_i, &val1); + val->intval = -val1; + }if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 213/284 powerpc: Set crashkernel offset to mid of RMA region
In reply to Greg Kroah-HartmanFrom: Sourabh Jain <[email protected]>
[ Upstream commit 7c5ed82b800d8615cdda00729e7b62e5899f0b13 ]
On large config LPARs (having 192 and more cores), Linux fails to boot due to insufficient memory in the first memblock. It is due to the memory reservation for the crash kernel which starts at 128MB offset of the first memblock. This memory reservation for the crash kernel doesn't leave enough space in the first memblock to accommodate other essential system resources.
The crash kernel start address was set to 128MB offset by default to ensure that the crash kernel get some memory below the RMA region which is used to be of size 256MB. But given that the RMA region size can be 512MB or more, setting the crash kernel offset to mid of RMA size will leave enough space for the kernel to allocate memory for other system resources.
Since the above crash kernel offset change is only applicable to the LPAR platform, the LPAR feature detection is pushed before the crash kernel reservation. The rest of LPAR specific initialization will still be done during pseries_probe_fw_features as usual.
This patch is dependent on changes to paca allocation for boot CPU. It expect boot CPU to discover 1T segment support which is introduced by the patch posted here:
https://lists.ozlabs.org/pipermail/linuxppc-dev/2022-January/239175.html
--- arch/powerpc/kernel/machine_kexec.c | 15 +++++++++++---- arch/powerpc/kernel/rtas.c | 6 ++++++ 2 files changed, 17 insertions(+), 4 deletions(-)
arch/powerpc/kernel/machine_kexec.c +11 -4
@@ -145,11 +145,18 @@ void __init reserve_crashkernel(void)if (!crashk_res.start) {#ifdef CONFIG_PPC64 /* -* On 64bit we split the RMO in half but cap it at half of -* a small SLB (128MB) since the crash kernel needs to place -* itself and some stacks to be in the first segment. +* On the LPAR platform place the crash kernel to mid of +* RMA size (512MB or more) to ensure the crash kernel +* gets enough space to place itself and some stack to be +* in the first segment. At the same time normal kernel +* also get enough space to allocate memory for essential +* system resource in the first segment. Keep the crash +* kernel starts at 128MB offset on other platforms. */ - crashk_res.start =min (0x8000000ULL , (ppc64_rma_size /2 )); +if (firmware_has_feature (FW_FEATURE_LPAR )) + crashk_res.start = ppc64_rma_size /2 ; +else + crashk_res.start =min (0x8000000ULL , (ppc64_rma_size /2 ));#else crashk_res.start =KDUMP_KERNELBASE ;#endif
arch/powerpc/kernel/rtas.c +6 -0
@@ -1356,6 +1356,12 @@ int __init early_init_dt_scan_rtas(unsigned long node, entryp =of_get_flat_dt_prop (node,"linux,rtas-entry" ,NULL ); sizep =of_get_flat_dt_prop (node,"rtas-size" ,NULL ); +#ifdef CONFIG_PPC64 +/* need this feature to decide the crashkernel offset */ +if (of_get_flat_dt_prop (node,"ibm,hypertas-functions" ,NULL )) + powerpc_firmware_features |=FW_FEATURE_LPAR ; +#endif +if (basep && entryp && sizep) { rtas.base = *basep; rtas.entry = *entryp;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 214/284 PCI: aardvark: Fix support for MSI interrupts
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit b0b0b8b897f8e12b2368e868bd7cdc5742d5c5a9 ]
Aardvark hardware supports Multi-MSI and MSI_FLAG_MULTI_PCI_MSI is already set for the MSI chip. But when allocating MSI interrupt numbers for Multi-MSI, the numbers need to be properly aligned, otherwise endpoint devices send MSI interrupt with incorrect numbers.
Fix this issue by using function bitmap_find_free_region() instead of bitmap_find_next_zero_area().
To ensure that aligned MSI interrupt numbers are used by endpoint devices, we cannot use Linux virtual irq numbers (as they are random and not properly aligned). Instead we need to use the aligned hwirq numbers.
This change fixes receiving MSI interrupts on Armada 3720 boards and allows using NVMe disks which use Multi-MSI feature with 3 interrupts.
Without this NVMe disks freeze booting as linux nvme-core.c is waiting 60s for an interrupt.
--- drivers/pci/host/pci-aardvark.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/pci/host/pci-aardvark.c +6 -10
@@ -834,7 +834,7 @@ static void advk_msi_irq_compose_msi_msg(struct irq_data *data, msg->address_lo =lower_32_bits (msi_msg); msg->address_hi =upper_32_bits (msi_msg); - msg->data = data->irq; + msg->data = data->hwirq; } static int advk_msi_set_affinity(struct irq_data *irq_data,
@@ -851,15 +851,11 @@ static int advk_msi_irq_domain_alloc(struct irq_domain *domain,int hwirq, i;mutex_lock (&pcie->msi_used_lock); - hwirq =bitmap_find_next_zero_area (pcie->msi_used,MSI_IRQ_NUM , -0 , nr_irqs,0 ); -if (hwirq >=MSI_IRQ_NUM ) { -mutex_unlock (&pcie->msi_used_lock); -return -ENOSPC ; - } - -bitmap_set (pcie->msi_used, hwirq, nr_irqs); + hwirq =bitmap_find_free_region (pcie->msi_used,MSI_IRQ_NUM , +order_base_2 (nr_irqs));mutex_unlock (&pcie->msi_used_lock); +if (hwirq <0 ) +return -ENOSPC ;for (i =0 ; i < nr_irqs; i++) irq_domain_set_info(domain, virq + i, hwirq + i,
@@ -877,7 +873,7 @@ static void advk_msi_irq_domain_free(struct irq_domain *domain,struct advk_pcie *pcie = domain->host_data;mutex_lock (&pcie->msi_used_lock); -bitmap_clear (pcie->msi_used, d->hwirq, nr_irqs); +bitmap_release_region (pcie->msi_used, d->hwirq,order_base_2 (nr_irqs));mutex_unlock (&pcie->msi_used_lock); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 215/284 iommu/arm-smmu-v3: fix event handling soft lockup
In reply to Greg Kroah-HartmanFrom: Zhou Guanghui <[email protected]>
[ Upstream commit 30de2b541af98179780054836b48825fcfba4408 ]
During event processing, events are read from the event queue one by one until the queue is empty.If the master device continuously requests address access at the same time and the SMMU generates events, the cyclic processing of the event takes a long time and softlockup warnings may be reported.
arm-smmu-v3 arm-smmu-v3.34.auto: event 0x0a received:
arm-smmu-v3 arm-smmu-v3.34.auto: 0x00007f220000280a
arm-smmu-v3 arm-smmu-v3.34.auto: 0x000010000000007e
arm-smmu-v3 arm-smmu-v3.34.auto: 0x00000000034e8670
watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [irq/268-arm-smm:247] Call trace: _dev_info+0x7c/0xa0 arm_smmu_evtq_thread+0x1c0/0x230 irq_thread_fn+0x30/0x80 irq_thread+0x128/0x210 kthread+0x134/0x138 ret_from_fork+0x10/0x1c Kernel panic - not syncing: softlockup: hung tasks
Fix this by calling cond_resched() after the event information is printed.
--- drivers/iommu/arm-smmu-v3.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/arm-smmu-v3.c +1 -0
@@ -1210,6 +1210,7 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)dev_info (smmu->dev,"\t0x%016llx\n" , (unsigned long long )evt[i]); +cond_resched (); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 216/284 dm ioctl: prevent potential spectre v1 gadget
In reply to Greg Kroah-HartmanFrom: Jordy Zomer <[email protected]>
[ Upstream commit cd9c88da171a62c4b0f1c70e50c75845969fbc18 ]
It appears like cmd could be a Spectre v1 gadget as it's supplied by a user and used as an array index. Prevent the contents of kernel memory from being leaked to userspace via speculative execution by using array_index_nospec.
--- drivers/md/dm-ioctl.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/dm-ioctl.c +2 -0
@@ -17,6 +17,7 @@#include <linux/dm-ioctl.h> #include <linux/hdreg.h> #include <linux/compat.h> +#include <linux/nospec.h> #include <linux/uaccess.h>
@@ -1669,6 +1670,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)if (unlikely (cmd >=ARRAY_SIZE (_ioctls)))return NULL ; + cmd =array_index_nospec (cmd,ARRAY_SIZE (_ioctls)); *ioctl_flags = _ioctls[cmd].flags;return _ioctls[cmd].fn; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 217/284 scsi: pm8001: Fix pm8001_mpi_task_abort_resp()
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit 7e6b7e740addcea450041b5be8e42f0a4ceece0f ]
The call to pm8001_ccb_task_free() at the end of pm8001_mpi_task_abort_resp() already frees the ccb tag. So when the device NCQ_ABORT_ALL_FLAG is set, the tag should not be freed again. Also change the hardcoded 0xBFFFFFFF value to ~NCQ_ABORT_ALL_FLAG as it ought to be.
--- drivers/scsi/pm8001/pm8001_hwi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/pm8001/pm8001_hwi.c +3 -4
@@ -3768,12 +3768,11 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)mb ();if (pm8001_dev->id &NCQ_ABORT_ALL_FLAG ) { -pm8001_tag_free (pm8001_ha, tag);sas_free_task (t); -/* clear the flag */ - pm8001_dev->id &=0xBFFFFFFF ; - }else + pm8001_dev->id &= ~NCQ_ABORT_ALL_FLAG ; + }else { t->task_done (t); + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 218/284 scsi: aha152x: Fix aha152x_setup() __setup handler return value
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit cc8294ec4738d25e2bb2d71f7d82a9bf7f4a157b ]
__setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; doing so just pollutes init's environment with strings that are not init arguments/parameters).
Return 1 from aha152x_setup() to indicate that the boot option has been handled.
--- drivers/scsi/aha152x.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/aha152x.c +2 -4
@@ -3374,13 +3374,11 @@ static int __init aha152x_setup(char *str) setup[setup_count].synchronous = ints[0 ] >=6 ? ints[6 ] :1 ; setup[setup_count].delay = ints[0 ] >=7 ? ints[7 ] :DELAY_DEFAULT ; setup[setup_count].ext_trans = ints[0 ] >=8 ? ints[8 ] :0 ; -if (ints[0 ] >8 ) {/*}*/ +if (ints[0 ] >8 )printk (KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>" "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n" ); - }else { +else setup_count++; -return 0 ; - }return 1 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 219/284 net/smc: correct settings of RMB window update limit
In reply to Greg Kroah-HartmanFrom: Dust Li <[email protected]>
[ Upstream commit 6bf536eb5c8ca011d1ff57b5c5f7c57ceac06a37 ]
rmbe_update_limit is used to limit announcing receive window updating too frequently. RFC7609 request a minimal increase in the window size of 10% of the receive buffer space. But current implementation used:
min_t(int, rmbe_size / 10, SOCK_MIN_SNDBUF / 2)
and SOCK_MIN_SNDBUF / 2 == 2304 Bytes, which is almost always less then 10% of the receive buffer space.
This causes the receiver always sending CDC message to update its consumer cursor when it consumes more then 2K of data. And as a result, we may encounter something like "TCP silly window syndrome" when sending 2.5~8K message.
This patch fixes this using max(rmbe_size / 10, SOCK_MIN_SNDBUF / 2).
With this patch and SMC autocorking enabled, qperf 2K/4K/8K tcp_bw test shows 45%/75%/40% increase in throughput respectively.
--- net/smc/smc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_core.c +1 -1
@@ -499,7 +499,7 @@ struct smc_buf_desc *smc_buf_get_slot(struct smc_link_group *lgr,*/ static inline int smc_rmb_wnd_update_limit (int rmbe_size) { -return min_t (int, rmbe_size /10 ,SOCK_MIN_SNDBUF /2 ); +return max_t (int, rmbe_size /10 ,SOCK_MIN_SNDBUF /2 ); } static struct smc_buf_desc *smc_new_buf_create(struct smc_link_group *lgr,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 220/284 macvtap: advertise link netns via netlink
In reply to Greg Kroah-HartmanFrom: Sven Eckelmann <[email protected]>
[ Upstream commit a02192151b7dbf855084c38dca380d77c7658353 ]
Assign rtnl_link_ops->get_link_net() callback so that IFLA_LINK_NETNSID is added to rtnetlink messages. This fixes iproute2 which otherwise resolved the link interface to an interface in the wrong namespace.
Test commands:
ip netns add nst
ip link add dummy0 type dummy
ip link add link macvtap0 link dummy0 type macvtap ip link set macvtap0 netns nst
ip -netns nst link show macvtap0
Before:
10: macvtap0@gre0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 500
link/ether 5e:8f:ae:1d:60:50 brd ff:ff:ff:ff:ff:ff
After:
10: macvtap0@if2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 500
link/ether 5e:8f:ae:1d:60:50 brd ff:ff:ff:ff:ff:ff link-netnsid 0
--- drivers/net/macvtap.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/macvtap.c +6 -0
@@ -132,11 +132,17 @@ static void macvtap_setup(struct net_device *dev) dev->tx_queue_len =TUN_READQ_SIZE ; } +static struct net *macvtap_link_net (const struct net_device *dev) +{ +return dev_net (macvlan_dev_real_dev (dev)); +} +static struct rtnl_link_ops macvtap_link_ops__read_mostly = { .kind ="macvtap" , .setup = macvtap_setup, .newlink = macvtap_newlink, .dellink = macvtap_dellink, + .get_link_net = macvtap_link_net, .priv_size =sizeof (struct macvtap_dev ), };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 221/284 bnxt_en: Eliminate unintended link toggle during FW reset
In reply to Greg Kroah-HartmanFrom: Michael Chan <[email protected]>
[ Upstream commit 7c492a2530c1f05441da541307c2534230dfd59b ]
If the flow control settings have been changed, a subsequent FW reset may cause the ethernet link to toggle unnecessarily. This link toggle will increase the down time by a few seconds.
The problem is caused by bnxt_update_phy_setting() detecting a false mismatch in the flow control settings between the stored software settings and the current FW settings after the FW reset. This mismatch is caused by the AUTONEG bit added to link_info->req_flow_ctrl in an inconsistent way in bnxt_set_pauseparam() in autoneg mode. The AUTONEG bit should not be added to link_info->req_flow_ctrl.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -3
@@ -1272,9 +1272,7 @@ static int bnxt_set_pauseparam(struct net_device *dev, } link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; -if (bp->hwrm_spec_code >=0x10201 ) - link_info->req_flow_ctrl = -PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE ; + link_info->req_flow_ctrl =0 ; }else {/* when transition from auto pause to force pause, * force a link change
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 222/284 MIPS: fix fortify panic when copying asm exception handlers
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
[ Upstream commit d17b66417308996e7e64b270a3c7f3c1fbd4cfc8 ]
With KCFLAGS="-O3", I was able to trigger a fortify-source memcpy() overflow panic on set_vi_srs_handler(). Although O3 level is not supported in the mainline, under some conditions that may've happened with any optimization settings, it's just a matter of inlining luck. The panic itself is correct, more precisely, 50/50 false-positive and not at the same time.
Quoted 1 line
From the one side, no real overflow happens. Exception handler
defined in asm just gets copied to some reserved places in the memory.
But the reason behind is that C code refers to that exception handler declares it as char, i.e. something of 1 byte length. It's obvious that the asm function itself is way more than 1 byte, so fortify logics thought we are going to past the symbol declared. The standard way to refer to asm symbols from C code which is not supposed to be called from C is to declare them as extern const u8[]. This is fully correct from any point of view, as any code itself is just a bunch of bytes (including 0 as it is for syms like _stext/_etext/etc.), and the exact size is not known at the moment of compilation.
Adjust the type of the except_vec_vi_*() and related variables. Make set_handler() take const as a second argument to avoid cast-away warnings and give a little more room for optimization.
--- arch/mips/include/asm/setup.h | 2 +- arch/mips/kernel/traps.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-)
arch/mips/include/asm/setup.h +1 -1
@@ -14,7 +14,7 @@ static inline void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift, unsigned int timeout) {}#endif -extern void set_handler (unsigned long offset,void *addr,unsigned long len); +void set_handler (unsigned long offset,const void *addr,unsigned long len);extern void set_uncached_handler (unsigned long offset,void *addr,unsigned long len);typedef void (*vi_handler_t )(void );
arch/mips/kernel/traps.c +11 -11
@@ -2017,19 +2017,19 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)* If no shadow set is selected then use the default handler * that does normal register saving and standard interrupt exit */ -extern char except_vec_vi, except_vec_vi_lui; -extern char except_vec_vi_ori, except_vec_vi_end; -extern char rollback_except_vec_vi; -char *vec_start =using_rollback_handler () ? - &rollback_except_vec_vi : &except_vec_vi; +extern const u8 except_vec_vi[], except_vec_vi_lui[]; +extern const u8 except_vec_vi_ori[], except_vec_vi_end[]; +extern const u8 rollback_except_vec_vi[]; +const u8 *vec_start =using_rollback_handler () ? + rollback_except_vec_vi : except_vec_vi;#if defined(CONFIG_CPU_MICROMIPS ) || defined(CONFIG_CPU_BIG_ENDIAN ) -const int lui_offset = &except_vec_vi_lui - vec_start +2 ; -const int ori_offset = &except_vec_vi_ori - vec_start +2 ; +const int lui_offset = except_vec_vi_lui - vec_start +2 ; +const int ori_offset = except_vec_vi_ori - vec_start +2 ;#else -const int lui_offset = &except_vec_vi_lui - vec_start; -const int ori_offset = &except_vec_vi_ori - vec_start; +const int lui_offset = except_vec_vi_lui - vec_start; +const int ori_offset = except_vec_vi_ori - vec_start;#endif -const int handler_len = &except_vec_vi_end - vec_start; +const int handler_len = except_vec_vi_end - vec_start;if (handler_len >VECTORSPACING ) {/*
@@ -2249,7 +2249,7 @@ void per_cpu_trap_init(bool is_boot_cpu) }/* Install CPU exception handler */ -void set_handler (unsigned long offset,void *addr,unsigned long size) +void set_handler (unsigned long offset,const void *addr,unsigned long size) {#ifdef CONFIG_CPU_MICROMIPS memcpy ((void *)(ebase + offset), ((unsigned char *)addr -1 ), size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 223/284 scsi: libfc: Fix use after free in fc_exch_abts_resp()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit 271add11994ba1a334859069367e04d2be2ebdd4 ]
fc_exch_release(ep) will decrease the ep's reference count. When the reference count reaches zero, it is freed. But ep is still used in the following code, which will lead to a use after free.
Return after the fc_exch_release() call to avoid use after free.
--- drivers/scsi/libfc/fc_exch.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/libfc/fc_exch.c +1 -0
@@ -1709,6 +1709,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)if (cancel_delayed_work_sync (&ep->timeout_work)) {FC_EXCH_DBG (ep,"Exchange timer canceled due to ABTS response\n" );fc_exch_release (ep);/* release from pending timer hold */ +return ; }spin_lock_bh (&ep->ex_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 224/284 usb: dwc3: omap: fix "unbalanced disables for smps10_out1" on omap5evm
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
[ Upstream commit ac01df343e5a6c6bcead2ed421af1fde30f73e7e ]
Usually, the vbus_regulator (smps10 on omap5evm) boots up disabled.
Hence calling regulator_disable() indirectly through dwc3_omap_set_mailbox() during probe leads to:
[ 10.332764] WARNING: CPU: 0 PID: 1628 at drivers/regulator/core.c:2853 _regulator_disable+0x40/0x164 [ 10.351919] unbalanced disables for smps10_out1 [ 10.361298] Modules linked in: dwc3_omap(+) clk_twl6040 at24 gpio_twl6040 palmas_gpadc palmas_pwrbutton industrialio snd_soc_omap_mcbsp(+) snd_soc_ti_sdma display_connector ti_tpd12s015 drm leds_gpio drm_panel_orientation_quirks ip_tables x_tables ipv6 autofs4 [ 10.387818] CPU: 0 PID: 1628 Comm: systemd-udevd Not tainted 5.17.0-rc1-letux-lpae+ #8139 [ 10.405129] Hardware name: Generic OMAP5 (Flattened Device Tree) [ 10.411455] unwind_backtrace from show_stack+0x10/0x14 [ 10.416970] show_stack from dump_stack_lvl+0x40/0x4c [ 10.422313] dump_stack_lvl from __warn+0xb8/0x170 [ 10.427377] __warn from warn_slowpath_fmt+0x70/0x9c [ 10.432595] warn_slowpath_fmt from _regulator_disable+0x40/0x164 [ 10.439037] _regulator_disable from regulator_disable+0x30/0x64 [ 10.445382] regulator_disable from dwc3_omap_set_mailbox+0x8c/0xf0 [dwc3_omap] [ 10.453116] dwc3_omap_set_mailbox [dwc3_omap] from dwc3_omap_probe+0x2b8/0x394 [dwc3_omap] [ 10.467021] dwc3_omap_probe [dwc3_omap] from platform_probe+0x58/0xa8 [ 10.481762] platform_probe from really_probe+0x168/0x2fc [ 10.481782] really_probe from __driver_probe_device+0xc4/0xd8 [ 10.481782] __driver_probe_device from driver_probe_device+0x24/0xa4 [ 10.503762] driver_probe_device from __driver_attach+0xc4/0xd8 [ 10.510018] __driver_attach from bus_for_each_dev+0x64/0xa0 [ 10.516001] bus_for_each_dev from bus_add_driver+0x148/0x1a4 [ 10.524880] bus_add_driver from driver_register+0xb4/0xf8 [ 10.530678] driver_register from do_one_initcall+0x90/0x1c4 [ 10.536661] do_one_initcall from do_init_module+0x4c/0x200 [ 10.536683] do_init_module from load_module+0x13dc/0x1910 [ 10.551159] load_module from sys_finit_module+0xc8/0xd8 [ 10.561319] sys_finit_module from __sys_trace_return+0x0/0x18 [ 10.561336] Exception stack(0xc344bfa8 to 0xc344bff0) [ 10.561341] bfa0: b6fb5778 b6fab8d8 00000007 b6ecfbb8 00000000 b6ed0398 [ 10.561341] bfc0: b6fb5778 b6fab8d8 855c0500 0000017b 00020000 b6f9a3cc 00000000 b6fb5778 [ 10.595500] bfe0: bede18f8 bede18e8 b6ec9aeb b6dda1c2 [ 10.601345] ---[ end trace 0000000000000000 ]---
Fix this unnecessary warning by checking if the regulator is enabled.
--- drivers/usb/dwc3/dwc3-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-omap.c +1 -1
@@ -245,7 +245,7 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,break ;case OMAP_DWC3_ID_FLOAT : -if (omap->vbus_reg) +if (omap->vbus_reg &®ulator_is_enabled (omap->vbus_reg))regulator_disable (omap->vbus_reg); val =dwc3_omap_read_utmi_ctrl (omap); val |=USBOTGSS_UTMI_OTG_CTRL_IDDIG ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 225/284 xtensa: fix DTC warning unit_address_format
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
[ Upstream commit e85d29ba4b24f68e7a78cb85c55e754362eeb2de ]
DTC issues the following warnings when building xtfpga device trees:
/soc/flash@00000000/partition@0x0: unit name should not have leading "0x" /soc/flash@00000000/partition@0x6000000: unit name should not have leading "0x" /soc/flash@00000000/partition@0x6800000: unit name should not have leading "0x" /soc/flash@00000000/partition@0x7fe0000: unit name should not have leading "0x"
Drop leading 0x from flash partition unit names.
--- arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-)
arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi +4 -4
@@ -8,19 +8,19 @@ reg = <0x00000000 0x08000000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "data"; reg = <0x00000000 0x06000000>; }; - partition@0x6000000 { + partition@6000000 { label = "boot loader area"; reg = <0x06000000 0x00800000>; }; - partition@0x6800000 { + partition@6800000 { label = "kernel image"; reg = <0x06800000 0x017e0000>; }; - partition@0x7fe0000 { + partition@7fe0000 { label = "boot environment"; reg = <0x07fe0000 0x00020000>; };
arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi +4 -4
@@ -8,19 +8,19 @@ reg = <0x08000000 0x01000000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "boot loader area"; reg = <0x00000000 0x00400000>; }; - partition@0x400000 { + partition@400000 { label = "kernel image"; reg = <0x00400000 0x00600000>; }; - partition@0xa00000 { + partition@a00000 { label = "data"; reg = <0x00a00000 0x005e0000>; }; - partition@0xfe0000 { + partition@fe0000 { label = "boot environment"; reg = <0x00fe0000 0x00020000>; };
arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi +2 -2
@@ -8,11 +8,11 @@ reg = <0x08000000 0x00400000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "boot loader area"; reg = <0x00000000 0x003f0000>; }; - partition@0x3f0000 { + partition@3f0000 { label = "boot environment"; reg = <0x003f0000 0x00010000>; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 226/284 Bluetooth: Fix use after free in hci_send_acl
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f63d24baff787e13b723d86fe036f84bdbc35045 ]
This fixes the following trace caused by receiving HCI_EV_DISCONN_PHY_LINK_COMPLETE which does call hci_conn_del without first checking if conn->type is in fact AMP_LINK and in case it is do properly cleanup upper layers with hci_disconn_cfm:
==================================================================
BUG: KASAN: use-after-free in hci_send_acl+0xaba/0xc50
Read of size 8 at addr ffff88800e404818 by task bluetoothd/142
CPU: 0 PID: 142 Comm: bluetoothd Not tainted
5.17.0-rc5-00006-gda4022eeac1a #7
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x45/0x59
print_address_description.constprop.0+0x1f/0x150
kasan_report.cold+0x7f/0x11b
hci_send_acl+0xaba/0xc50
l2cap_do_send+0x23f/0x3d0
l2cap_chan_send+0xc06/0x2cc0
l2cap_sock_sendmsg+0x201/0x2b0
sock_sendmsg+0xdc/0x110
sock_write_iter+0x20f/0x370
do_iter_readv_writev+0x343/0x690
do_iter_write+0x132/0x640
vfs_writev+0x198/0x570
do_writev+0x202/0x280
do_syscall_64+0x38/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xae
RSP: 002b:00007ffce8a099b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3
0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 14 00 00 00 0f 05
<48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10
RDX: 0000000000000001 RSI: 00007ffce8a099e0 RDI: 0000000000000015
RAX: ffffffffffffffda RBX: 00007ffce8a099e0 RCX: 00007f788fc3cf77
R10: 00007ffce8af7080 R11: 0000000000000246 R12: 000055e4ccf75580
RBP: 0000000000000015 R08: 0000000000000002 R09: 0000000000000001
</TASK>
R13: 000055e4ccf754a0 R14: 000055e4ccf75cd0 R15: 000055e4ccf4a6b0
Allocated by task 45:
kasan_save_stack+0x1e/0x40
__kasan_kmalloc+0x81/0xa0
hci_chan_create+0x9a/0x2f0
l2cap_conn_add.part.0+0x1a/0xdc0
l2cap_connect_cfm+0x236/0x1000
le_conn_complete_evt+0x15a7/0x1db0
hci_le_conn_complete_evt+0x226/0x2c0
hci_le_meta_evt+0x247/0x450
hci_event_packet+0x61b/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
Freed by task 45:
kasan_save_stack+0x1e/0x40
kasan_set_track+0x21/0x30
kasan_set_free_info+0x20/0x30
__kasan_slab_free+0xfb/0x130
kfree+0xac/0x350
hci_conn_cleanup+0x101/0x6a0
hci_conn_del+0x27e/0x6c0
hci_disconn_phylink_complete_evt+0xe0/0x120
hci_event_packet+0x812/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
The buggy address belongs to the object at ffff88800c0f0500
The buggy address is located 24 bytes inside of
which belongs to the cache kmalloc-128 of size 128
The buggy address belongs to the page:
128-byte region [ffff88800c0f0500, ffff88800c0f0580)
flags: 0x100000000000200(slab|node=0|zone=1)
page:00000000fe45cd86 refcount:1 mapcount:0
mapping:0000000000000000 index:0x0 pfn:0xc0f0
raw: 0000000000000000 0000000080100010 00000001ffffffff
0000000000000000
raw: 0100000000000200 ffffea00003a2c80 dead000000000004
ffff8880078418c0
page dumped because: kasan: bad access detected
ffff88800c0f0400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
Memory state around the buggy address:
>ffff88800c0f0500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800c0f0480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800c0f0580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
==================================================================
ffff88800c0f0600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_event.c +2 -1
@@ -4470,8 +4470,9 @@ static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev,hci_dev_lock (hdev); hcon =hci_conn_hash_lookup_handle (hdev, ev->phy_handle); -if (hcon) { +if (hcon && hcon->type ==AMP_LINK ) { hcon->state =BT_CLOSED ; +hci_disconn_cfm (hcon, ev->reason);hci_conn_del (hcon); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 227/284 init/main.c: return 1 from handled __setup() functions
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit f9a40b0890658330c83c95511f9d6b396610defc ]
initcall_blacklist() should return 1 to indicate that it handled its cmdline arguments.
set_debug_rodata() should return 1 to indicate that it handled its cmdline arguments. Print a warning if the option string is invalid.
This prevents these strings from being added to the 'init' program's environment as they are not init arguments/parameters.
--- init/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
init/main.c +4 -2
@@ -749,7 +749,7 @@ static int __init initcall_blacklist(char *str) } }while (str_entry); -return 0 ; +return 1 ; } static bool __init_or_module initcall_blacklisted(initcall_t fn)
@@ -965,7 +965,9 @@ static noinline void __init kernel_init_freeable(void);bool rodata_enabled__ro_after_init = true;static int __init set_debug_rodata (char *str) { -return strtobool (str, &rodata_enabled); +if (strtobool (str, &rodata_enabled)) +pr_warn ("Invalid option string for rodata: '%s'\n" , str); +return 1 ; }__setup ("rodata=" , set_debug_rodata);#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 228/284 w1: w1_therm: fixes w1_seq for ds28ea00 sensors
In reply to Greg Kroah-HartmanFrom: Lucas Denefle <[email protected]>
[ Upstream commit 41a92a89eee819298f805c40187ad8b02bb53426 ]
w1_seq was failing due to several devices responding to the CHAIN_DONE at the same time. Now properly selects the current device in the chain with MATCH_ROM. Also acknowledgment was read twice.
--- drivers/w1/slaves/w1_therm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/w1/slaves/w1_therm.c +6 -2
@@ -690,16 +690,20 @@ static ssize_t w1_seq_show(struct device *device,if (sl->reg_num.id == reg_num->id) seq = i; +if (w1_reset_bus (sl->master)) + goto error; + +/* Put the device into chain DONE state */ +w1_write_8 (sl->master,W1_MATCH_ROM ); +w1_write_block (sl->master, (u8 *)&rn,8 );w1_write_8 (sl->master,W1_42_CHAIN );w1_write_8 (sl->master,W1_42_CHAIN_DONE );w1_write_8 (sl->master,W1_42_CHAIN_DONE_INV ); -w1_read_block (sl->master, &ack,sizeof (ack));/* check for acknowledgment */ ack =w1_read_8 (sl->master);if (ack !=W1_42_SUCCESS_CONFIRM_BYTE ) goto error; - }/* Exit from CHAIN state */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 229/284 SUNRPC/call_alloc: async tasks mustnt block waiting for memory
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit c487216bec83b0c5a8803e5c61433d33ad7b104d ]
When memory is short, new worker threads cannot be created and we depend on the minimum one rpciod thread to be able to handle everything. So it must not block waiting for memory.
mempools are particularly a problem as memory can only be released back to the mempool by an async rpc task running. If all available workqueue threads are waiting on the mempool, no thread is available to return anything.
rpc_malloc() can block, and this might cause deadlocks.
So check RPC_IS_ASYNC(), rather than RPC_IS_SWAPPER() to determine if blocking is acceptable.
--- net/sunrpc/sched.c | 4 +++- net/sunrpc/xprtrdma/transport.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
net/sunrpc/sched.c +3 -1
@@ -883,8 +883,10 @@ int rpc_malloc(struct rpc_task *task)struct rpc_buffer *buf;gfp_t gfp =GFP_NOIO | __GFP_NOWARN; +if (RPC_IS_ASYNC (task)) + gfp =GFP_NOWAIT | __GFP_NOWARN;if (RPC_IS_SWAPPER (task)) - gfp = __GFP_MEMALLOC |GFP_NOWAIT | __GFP_NOWARN; + gfp |= __GFP_MEMALLOC; size +=sizeof (struct rpc_buffer );if (size <=RPC_BUFFER_MAXSIZE )
net/sunrpc/xprtrdma/transport.c +3 -1
@@ -645,8 +645,10 @@ xprt_rdma_allocate(struct rpc_task *task)return -ENOMEM ; flags =RPCRDMA_DEF_GFP ; +if (RPC_IS_ASYNC (task)) + flags =GFP_NOWAIT | __GFP_NOWARN;if (RPC_IS_SWAPPER (task)) - flags = __GFP_MEMALLOC |GFP_NOWAIT | __GFP_NOWARN; + flags |= __GFP_MEMALLOC;if (!rpcrdma_get_rdmabuf (r_xprt, req, flags)) goto out_fail;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 230/284 NFS: swap IO handling is slightly different for O_DIRECT IO
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit 64158668ac8b31626a8ce48db4cad08496eb8340 ]
1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding
possible deadlocks with "fs_reclaim". These deadlocks could, I believe, eventuate if a buffered read on the swapfile was attempted.
We don't need coherence with the page cache for a swap file, and buffered writes are forbidden anyway. There is no other need for i_rwsem during direct IO. So never take it for swap_rw()
2/ generic_write_checks() explicitly forbids writes to swap, and
performs checks that are not needed for swap. So bypass it for swap_rw().
--- fs/nfs/direct.c | 42 ++++++++++++++++++++++++++++-------------- fs/nfs/file.c | 4 ++-- include/linux/nfs_fs.h | 8 ++++---- 3 files changed, 34 insertions(+), 20 deletions(-)
fs/nfs/direct.c +28 -14
@@ -288,8 +288,8 @@ ssize_t nfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)VM_BUG_ON (iov_iter_count (iter) !=PAGE_SIZE );if (iov_iter_rw (iter) ==READ ) -return nfs_file_direct_read (iocb, iter); -return nfs_file_direct_write (iocb, iter); +return nfs_file_direct_read (iocb, iter, true); +return nfs_file_direct_write (iocb, iter, true); }static void nfs_direct_release_pages (struct page **pages,unsigned int npages)
@@ -553,6 +553,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,* nfs_file_direct_read - file direct read operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers into which to read data +* @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct reads instead of calling * generic_file_aio_read() in order to avoid gfar's check to see if
@@ -568,7 +569,8 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,* client must read the updated atime from the server back into its * cache. */ -ssize_t nfs_file_direct_read (struct kiocb *iocb,struct iov_iter *iter) +ssize_t nfs_file_direct_read (struct kiocb *iocb,struct iov_iter *iter, +bool swap) {struct file *file = iocb->ki_filp;struct address_space *mapping = file->f_mapping;
@@ -610,12 +612,14 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter)if (iter_is_iovec (iter)) dreq->flags =NFS_ODIRECT_SHOULD_DIRTY ; -nfs_start_io_direct (inode); +if (!swap) +nfs_start_io_direct (inode);NFS_I (inode)->read_io += count; requested =nfs_direct_read_schedule_iovec (dreq, iter, iocb->ki_pos); -nfs_end_io_direct (inode); +if (!swap) +nfs_end_io_direct (inode);if (requested >0 ) { result =nfs_direct_wait (dreq);
@@ -971,6 +975,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,* nfs_file_direct_write - file direct write operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers from which to write data +* @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct writes instead of calling * generic_file_aio_write() in order to avoid taking the inode
@@ -987,7 +992,8 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,* Note that O_APPEND is not supported for NFS direct writes, as there * is no atomic O_APPEND write facility in the NFS protocol. */ -ssize_t nfs_file_direct_write (struct kiocb *iocb,struct iov_iter *iter) +ssize_t nfs_file_direct_write (struct kiocb *iocb,struct iov_iter *iter, +bool swap) {ssize_t result = -EINVAL , requested;size_t count;
@@ -1001,7 +1007,11 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)dfprintk (FILE ,"NFS: direct write(%pD2, %zd@%Ld)\n" , file,iov_iter_count (iter), (long long ) iocb->ki_pos); - result =generic_write_checks (iocb, iter); +if (swap) +/* bypass generic checks */ + result =iov_iter_count (iter); +else + result =generic_write_checks (iocb, iter);if (result <=0 )return result; count = result;
@@ -1031,16 +1041,20 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)if (!is_sync_kiocb (iocb)) dreq->iocb = iocb; -nfs_start_io_direct (inode); +if (swap) { + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + }else { +nfs_start_io_direct (inode); - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); -if (mapping->nrpages) { -invalidate_inode_pages2_range (mapping, - pos >>PAGE_SHIFT , end); - } +if (mapping->nrpages) { +invalidate_inode_pages2_range (mapping, + pos >>PAGE_SHIFT , end); + } -nfs_end_io_direct (inode); +nfs_end_io_direct (inode); + }if (requested >0 ) { result =nfs_direct_wait (dreq);
fs/nfs/file.c +2 -2
@@ -157,7 +157,7 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to)ssize_t result;if (iocb->ki_flags &IOCB_DIRECT ) -return nfs_file_direct_read (iocb, to); +return nfs_file_direct_read (iocb, to, false); dprintk("NFS: read(%pD2, %zu@%lu)\n", iocb->ki_filp,
@@ -606,7 +606,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)return result;if (iocb->ki_flags &IOCB_DIRECT ) -return nfs_file_direct_write (iocb, from); +return nfs_file_direct_write (iocb, from, false);dprintk ("NFS: write(%pD2, %zu@%Ld)\n" , file,iov_iter_count (from), (long long ) iocb->ki_pos);
include/linux/nfs_fs.h +4 -4
@@ -442,10 +442,10 @@ static inline struct rpc_cred *nfs_file_cred(struct file *file)* linux/fs/nfs/direct.c */ extern ssize_t nfs_direct_IO (struct kiocb *,struct iov_iter *); -extern ssize_t nfs_file_direct_read (struct kiocb *iocb, -struct iov_iter *iter); -extern ssize_t nfs_file_direct_write (struct kiocb *iocb, -struct iov_iter *iter); +ssize_t nfs_file_direct_read (struct kiocb *iocb, +struct iov_iter *iter,bool swap); +ssize_t nfs_file_direct_write (struct kiocb *iocb, +struct iov_iter *iter,bool swap);/* * linux/fs/nfs/dir.c
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 231/284 NFS: swap-out must always use STABLE writes.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit c265de257f558a05c1859ee9e3fed04883b9ec0e ]
The commit handling code is not safe against memory-pressure deadlocks when writing to swap. In particular, nfs_commitdata_alloc() blocks indefinitely waiting for memory, and this can consume all available workqueue threads.
swap-out most likely uses STABLE writes anyway as COND_STABLE indicates that a stable write should be used if the write fits in a single request, and it normally does. However if we ever swap with a small wsize, or gather unusually large numbers of pages for a single write, this might change.
For safety, make it explicit in the code that direct writes used for swap must always use FLUSH_STABLE.
--- fs/nfs/direct.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/nfs/direct.c +6 -4
@@ -888,7 +888,7 @@ static const struct nfs_pgio_completion_ops nfs_direct_write_completion_ops = {*/ static ssize_t nfs_direct_write_schedule_iovec (struct nfs_direct_req *dreq,struct iov_iter *iter, -loff_t pos) +loff_t pos,int ioflags) {struct nfs_pageio_descriptor desc;struct inode *inode = dreq->inode;
@@ -896,7 +896,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,size_t requested_bytes =0 ;size_t wsize =max_t (size_t,NFS_SERVER (inode)->wsize,PAGE_SIZE ); -nfs_pageio_init_write (&desc, inode,FLUSH_COND_STABLE , false, +nfs_pageio_init_write (&desc, inode, ioflags, false, &nfs_direct_write_completion_ops); desc.pg_dreq = dreq;get_dreq (dreq);
@@ -1042,11 +1042,13 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter, dreq->iocb = iocb;if (swap) { - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos, +FLUSH_STABLE ); }else {nfs_start_io_direct (inode); - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos, +FLUSH_COND_STABLE );if (mapping->nrpages) { invalidate_inode_pages2_range(mapping,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 232/284 serial: samsung_tty: do not unlock port->lock for uart_write_wakeup()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
[ Upstream commit 988c7c00691008ea1daaa1235680a0da49dab4e8 ]
The commit c15c3747ee32 (serial: samsung: fix potential soft lockup during uart write) added an unlock of port->lock before uart_write_wakeup() and a lock after it. It was always problematic to write data from tty_ldisc_ops::write_wakeup and it was even documented that way. We fixed the line disciplines to conform to this recently. So if there is still a missed one, we should fix them instead of this workaround.
On the top of that, s3c24xx_serial_tx_dma_complete() in this driver still holds the port->lock while calling uart_write_wakeup().
So revert the wrap added by the commit above.
--- drivers/tty/serial/samsung.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/samsung.c +1 -4
@@ -764,11 +764,8 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id) goto out; } -if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS ) { -spin_unlock (&port->lock); +if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )uart_write_wakeup (port); -spin_lock (&port->lock); - }if (uart_circ_empty (xmit))s3c24xx_serial_stop_tx (port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 233/284 virtio_console: eliminate anonymous module_init & module_exit
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit fefb8a2a941338d871e2d83fbd65fbfa068857bd ]
Eliminate anonymous module_init() and module_exit(), which can lead to confusion or ambiguity when reading System.map, crashes/oops/bugs, or an initcall_debug log.
Give each of these init and exit functions unique driver-specific names to eliminate the anonymous names.
Example 1: (System.map)
ffffffff832fc78c t init
ffffffff832fc79e t init
ffffffff832fc8f8 t init
Example 2: (initcall_debug log)
calling init+0x0/0x12 @ 1
initcall init+0x0/0x12 returned 0 after 15 usecs
calling init+0x0/0x60 @ 1
initcall init+0x0/0x60 returned 0 after 2 usecs
calling init+0x0/0x9a @ 1
initcall init+0x0/0x9a returned 0 after 74 usecs
--- drivers/char/virtio_console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/virtio_console.c +4 -4
@@ -2281,7 +2281,7 @@ static struct virtio_driver virtio_rproc_serial = { .remove = virtcons_remove, }; -static int __init init (void ) +static int __init virtio_console_init (void ) {int err;
@@ -2318,7 +2318,7 @@ static int __init init(void)return err; } -static void __exit fini(void) +static void __exit virtio_console_fini(void) {reclaim_dma_bufs ();
@@ -2328,8 +2328,8 @@ static void __exit fini(void)class_destroy (pdrvdata.class);debugfs_remove_recursive (pdrvdata.debugfs_dir); } -module_init (init); -module_exit (fini); +module_init (virtio_console_init); +module_exit (virtio_console_fini);MODULE_DESCRIPTION ("Virtio console driver" );MODULE_LICENSE ("GPL" );
Signature · 8 lines
2.35.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Greg Kroah-Hartman
maintainerPATCH 234/284 jfs: prevent NULL deref in diFree
In reply to Greg Kroah-HartmanFrom: Haimin Zhang <[email protected]>
[ Upstream commit a53046291020ec41e09181396c1e829287b48d47 ]
Add validation check for JFS_IP(ipimap)->i_imap to prevent a NULL deref in diFree since diFree uses it without do any validations. When function jfs_mount calls diMount to initialize fileset inode allocation map, it can fail and JFS_IP(ipimap)->i_imap won't be initialized. Then it calls diFreeSpecial to close fileset inode allocation map inode and it will flow into jfs_evict_inode. Function jfs_evict_inode just validates JFS_SBI(inode->i_sb)->ipimap, then calls diFree. diFree use JFS_IP(ipimap)->i_imap directly, then it will cause a NULL deref.
--- fs/jfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/jfs/inode.c +2 -1
@@ -156,12 +156,13 @@ void jfs_evict_inode(struct inode *inode)dquot_initialize (inode);if (JFS_IP (inode)->fileset ==FILESYSTEM_I ) { +struct inode *ipimap =JFS_SBI (inode->i_sb)->ipimap;truncate_inode_pages_final (&inode->i_data);if (test_cflag (COMMIT_Freewmap, inode))jfs_free_zero_link (inode); -if (JFS_SBI (inode->i_sb)->ipimap) +if (ipimap &&JFS_IP (ipimap)->i_imap)diFree (inode);/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 235/284 parisc: Fix CPU affinity for Lasi, WAX and Dino chips
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 939fc856676c266c3bc347c1c1661872a3725c0f ]
Add the missing logic to allow Lasi, WAX and Dino to set the CPU affinity. This fixes IRQ migration to other CPUs when a CPU is shutdown which currently holds the IRQs for one of those chips.
--- drivers/parisc/dino.c | 41 +++++++++++++++++++++++++++++++++-------- drivers/parisc/gsc.c | 31 +++++++++++++++++++++++++++++++ drivers/parisc/gsc.h | 1 + drivers/parisc/lasi.c | 7 +++---- drivers/parisc/wax.c | 7 +++---- 5 files changed, 71 insertions(+), 16 deletions(-)
drivers/parisc/dino.c +33 -8
@@ -144,9 +144,8 @@ struct dino_device {struct pci_hba_data hba;/* 'C' inheritance - must be first */ spinlock_t dinosaur_pen; -unsigned long txn_addr;/* EIR addr to generate interrupt */ -u32 txn_data;/* EIR data assign to each dino */ u32 imr;/* IRQ's which are enabled */ +struct gsc_irq gsc_irq;int global_irq[DINO_LOCAL_IRQS ];/* map IMR bit to global irq */ #ifdef DINO_DEBUG unsigned int dino_irr0;/* save most recent IRQ line stat */
@@ -343,14 +342,43 @@ static void dino_unmask_irq(struct irq_data *d)if (tmp &DINO_MASK_IRQ (local_irq)) {DBG (KERN_WARNING "%s(): IRQ asserted! (ILR 0x%x)\n" , __func__, tmp); -gsc_writel (dino_dev->txn_data, dino_dev->txn_addr); +gsc_writel (dino_dev->gsc_irq.txn_data, dino_dev->gsc_irq.txn_addr); } } +#ifdef CONFIG_SMP +static int dino_set_affinity_irq (struct irq_data *d,const struct cpumask *dest, +bool force) +{ +struct dino_device *dino_dev =irq_data_get_irq_chip_data (d); +struct cpumask tmask; +int cpu_irq; +u32 eim; + +if (!cpumask_and (&tmask, dest, cpu_online_mask)) +return -EINVAL ; + + cpu_irq =cpu_check_affinity (d, &tmask); +if (cpu_irq <0 ) +return cpu_irq; + + dino_dev->gsc_irq.txn_addr =txn_affinity_addr (d->irq, cpu_irq); + eim = ((u32 ) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data; +__raw_writel (eim, dino_dev->hba.base_addr+DINO_IAR0 ); + +irq_data_update_effective_affinity (d, &tmask); + +return IRQ_SET_MASK_OK ; +} +#endif +static struct irq_chip dino_interrupt_type = { .name ="GSC-PCI" , .irq_unmask = dino_unmask_irq, .irq_mask = dino_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity = dino_set_affinity_irq, +#endif };
@@ -811,7 +839,6 @@ static int __init dino_common_init(struct parisc_device *dev, {int status;u32 eim; -struct gsc_irq gsc_irq;struct resource *res;pcibios_register_hba (&dino_dev->hba);
@@ -826,10 +853,8 @@ static int __init dino_common_init(struct parisc_device *dev,** still only has 11 IRQ input lines - just map some of them ** to a different processor. */ - dev->irq =gsc_alloc_irq (&gsc_irq); - dino_dev->txn_addr = gsc_irq.txn_addr; - dino_dev->txn_data = gsc_irq.txn_data; - eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + dev->irq =gsc_alloc_irq (&dino_dev->gsc_irq); + eim = ((u32 ) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data;/* ** Dino needs a PA "IRQ" to get a processor's attention.
drivers/parisc/gsc.c +31 -0
@@ -139,10 +139,41 @@ static void gsc_asic_unmask_irq(struct irq_data *d)*/ } +#ifdef CONFIG_SMP +static int gsc_set_affinity_irq (struct irq_data *d,const struct cpumask *dest, +bool force) +{ +struct gsc_asic *gsc_dev =irq_data_get_irq_chip_data (d); +struct cpumask tmask; +int cpu_irq; + +if (!cpumask_and (&tmask, dest, cpu_online_mask)) +return -EINVAL ; + + cpu_irq =cpu_check_affinity (d, &tmask); +if (cpu_irq <0 ) +return cpu_irq; + + gsc_dev->gsc_irq.txn_addr =txn_affinity_addr (d->irq, cpu_irq); + gsc_dev->eim = ((u32 ) gsc_dev->gsc_irq.txn_addr) | gsc_dev->gsc_irq.txn_data; + +/* switch IRQ's for devices below LASI/WAX to other CPU */ +gsc_writel (gsc_dev->eim, gsc_dev->hpa +OFFSET_IAR ); + +irq_data_update_effective_affinity (d, &tmask); + +return IRQ_SET_MASK_OK ; +} +#endif + +static struct irq_chip gsc_asic_interrupt_type = { .name ="GSC-ASIC" , .irq_unmask = gsc_asic_unmask_irq, .irq_mask = gsc_asic_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity = gsc_set_affinity_irq, +#endif };int gsc_assign_irq (struct irq_chip *type,void *data)
drivers/parisc/gsc.h +1 -0
@@ -32,6 +32,7 @@ struct gsc_asic {int version;int type;int eim; +struct gsc_irq gsc_irq;int global_irq[32 ]; };
drivers/parisc/lasi.c +3 -4
@@ -167,7 +167,6 @@ static int __init lasi_init_chip(struct parisc_device *dev) {extern void (*chassis_power_off)(void );struct gsc_asic *lasi; -struct gsc_irq gsc_irq;int ret; lasi =kzalloc (sizeof (*lasi),GFP_KERNEL );
@@ -189,7 +188,7 @@ static int __init lasi_init_chip(struct parisc_device *dev)lasi_init_irq (lasi);/* the IRQ lasi should use */ - dev->irq =gsc_alloc_irq (&gsc_irq); + dev->irq =gsc_alloc_irq (&lasi->gsc_irq);if (dev->irq <0 ) {printk (KERN_ERR "%s(): cannot get GSC irq\n" , __func__);
@@ -197,9 +196,9 @@ static int __init lasi_init_chip(struct parisc_device *dev)return -EBUSY ; } - lasi->eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + lasi->eim = ((u32 ) lasi->gsc_irq.txn_addr) | lasi->gsc_irq.txn_data; - ret =request_irq (gsc_irq.irq, gsc_asic_intr,0 ,"lasi" , lasi); + ret =request_irq (lasi->gsc_irq.irq, gsc_asic_intr,0 ,"lasi" , lasi);if (ret <0 ) {kfree (lasi);return ret;
drivers/parisc/wax.c +3 -4
@@ -72,7 +72,6 @@ static int __init wax_init_chip(struct parisc_device *dev) {struct gsc_asic *wax;struct parisc_device *parent; -struct gsc_irq gsc_irq;int ret; wax =kzalloc (sizeof (*wax),GFP_KERNEL );
@@ -89,7 +88,7 @@ static int __init wax_init_chip(struct parisc_device *dev)wax_init_irq (wax);/* the IRQ wax should use */ - dev->irq =gsc_claim_irq (&gsc_irq,WAX_GSC_IRQ ); + dev->irq =gsc_claim_irq (&wax->gsc_irq,WAX_GSC_IRQ );if (dev->irq <0 ) {printk (KERN_ERR "%s(): cannot get GSC irq\n" , __func__);
@@ -97,9 +96,9 @@ static int __init wax_init_chip(struct parisc_device *dev)return -EBUSY ; } - wax->eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + wax->eim = ((u32 ) wax->gsc_irq.txn_addr) | wax->gsc_irq.txn_data; - ret =request_irq (gsc_irq.irq, gsc_asic_intr,0 ,"wax" , wax); + ret =request_irq (wax->gsc_irq.irq, gsc_asic_intr,0 ,"wax" , wax);if (ret <0 ) {kfree (wax);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 236/284 ipv6: add missing tx timestamping on IPPROTO_RAW
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit fbfb2321e950918b430e7225546296b2dcadf725 ]
Raw sockets support tx timestamping, but one case is missing.
IPPROTO_RAW takes a separate packet construction path. raw_send_hdrinc has an explicit call to sock_tx_timestamp, but rawv6_send_hdrinc does not. Add it.
--- net/ipv6/raw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv6/raw.c +5 -2
@@ -622,7 +622,7 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,static int rawv6_send_hdrinc (struct sock *sk,struct msghdr *msg,int length,struct flowi6 *fl6,struct dst_entry **dstp, -unsigned int flags) +unsigned int flags,const struct sockcm_cookie *sockc) {struct ipv6_pinfo *np =inet6_sk (sk);struct net *net =sock_net (sk);
@@ -659,6 +659,8 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length, skb->ip_summed =CHECKSUM_NONE ; +sock_tx_timestamp (sk, sockc->tsflags, &skb_shinfo (skb)->tx_flags); +if (flags &MSG_CONFIRM )skb_set_dst_pending_confirm (skb,1 );
@@ -945,7 +947,8 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) back_from_confirm:if (hdrincl) - err =rawv6_send_hdrinc (sk, msg, len, &fl6, &dst, msg->msg_flags); + err =rawv6_send_hdrinc (sk, msg, len, &fl6, &dst, + msg->msg_flags, &sockc);else { ipc6.opt = opt;lock_sock (sk);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 237/284 net: add missing SOF_TIMESTAMPING_OPT_ID support
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit 8f932f762e7928d250e21006b00ff9b7718b0a64 ]
SOF_TIMESTAMPING_OPT_ID is supported on TCP, UDP and RAW sockets. But it was missing on RAW with IPPROTO_IP, PF_PACKET and CAN.
Add skb_setup_tx_timestamp that configures both tx_flags and tskey for these paths that do not need corking or use bytestream keys.
--- include/net/sock.h | 25 +++++++++++++++++++++---- net/can/raw.c | 2 +- net/ipv4/raw.c | 2 +- net/ipv6/raw.c | 2 +- net/packet/af_packet.c | 6 +++--- 5 files changed, 27 insertions(+), 10 deletions(-)
include/net/sock.h +21 -4
@@ -2311,22 +2311,39 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,void __sock_tx_timestamp (__u16 tsflags,__u8 *tx_flags);/** -* sock_tx_timestamp - checks whether the outgoing packet is to be time stamped +* _sock_tx_timestamp - checks whether the outgoing packet is to be time stamped * @sk: socket sending this packet * @tsflags: timestamping flags to use * @tx_flags: completed with instructions for time stamping +* @tskey: filled in with next sk_tskey (not for TCP, which uses seqno) * * Note: callers should take care of initial ``*tx_flags`` value (usually 0) */ -static inline void sock_tx_timestamp (const struct sock *sk,__u16 tsflags, -__u8 *tx_flags) +static inline void _sock_tx_timestamp (struct sock *sk,__u16 tsflags, +__u8 *tx_flags,__u32 *tskey) { -if (unlikely (tsflags)) +if (unlikely (tsflags)) {__sock_tx_timestamp (tsflags, tx_flags); +if (tsflags &SOF_TIMESTAMPING_OPT_ID && tskey && + tsflags &SOF_TIMESTAMPING_TX_RECORD_MASK ) + *tskey = sk->sk_tskey++; + }if (unlikely (sock_flag (sk,SOCK_WIFI_STATUS ))) *tx_flags |=SKBTX_WIFI_STATUS ; } +static inline void sock_tx_timestamp (struct sock *sk,__u16 tsflags, +__u8 *tx_flags) +{ +_sock_tx_timestamp (sk, tsflags, tx_flags,NULL ); +} + +static inline void skb_setup_tx_timestamp (struct sk_buff *skb,__u16 tsflags) +{ +_sock_tx_timestamp (skb->sk, tsflags, &skb_shinfo (skb)->tx_flags, + &skb_shinfo (skb)->tskey); +} +/** * sk_eat_skb - Release a skb if it is no longer needed * @sk: socket to eat this skb from
net/can/raw.c +1 -1
@@ -814,7 +814,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)if (err <0 ) goto free_skb; -sock_tx_timestamp (sk, sk->sk_tsflags, &skb_shinfo (skb)->tx_flags); +skb_setup_tx_timestamp (skb, sk->sk_tsflags); skb->dev = dev; skb->sk = sk;
net/ipv4/raw.c +1 -1
@@ -390,7 +390,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4, skb->ip_summed =CHECKSUM_NONE ; -sock_tx_timestamp (sk, sockc->tsflags, &skb_shinfo (skb)->tx_flags); +skb_setup_tx_timestamp (skb, sockc->tsflags);if (flags &MSG_CONFIRM )skb_set_dst_pending_confirm (skb,1 );
net/ipv6/raw.c +1 -1
@@ -659,7 +659,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length, skb->ip_summed =CHECKSUM_NONE ; -sock_tx_timestamp (sk, sockc->tsflags, &skb_shinfo (skb)->tx_flags); +skb_setup_tx_timestamp (skb, sockc->tsflags);if (flags &MSG_CONFIRM )skb_set_dst_pending_confirm (skb,1 );
net/packet/af_packet.c +3 -3
@@ -2017,7 +2017,7 @@ static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg, skb->priority = sk->sk_priority; skb->mark = sk->sk_mark; -sock_tx_timestamp (sk, sockc.tsflags, &skb_shinfo (skb)->tx_flags); +skb_setup_tx_timestamp (skb, sockc.tsflags);if (unlikely (extra_len ==4 )) skb->no_fcs =1 ;
@@ -2539,7 +2539,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb, skb->dev = dev; skb->priority = po->sk.sk_priority; skb->mark = po->sk.sk_mark; -sock_tx_timestamp (&po->sk, sockc->tsflags, &skb_shinfo (skb)->tx_flags); +skb_setup_tx_timestamp (skb, sockc->tsflags);skb_zcopy_set_nouarg (skb, ph.raw);skb_reserve (skb, hlen);
@@ -3002,7 +3002,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) goto out_free; } -sock_tx_timestamp (sk, sockc.tsflags, &skb_shinfo (skb)->tx_flags); +skb_setup_tx_timestamp (skb, sockc.tsflags);if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) && !packet_extra_vlan_len_allowed (dev, skb)) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 238/284 mm: fix race between MADV_FREE reclaim and blkdev direct IO read
In reply to Greg Kroah-HartmanFrom: Mauricio Faria de Oliveira <[email protected]>
commit 6c8e2a256915a223f6289f651d6b926cd7135c9e upstream.
Problem:
=======
Userspace might read the zero-page instead of actual data from a direct IO read on a block device if the buffers have been called madvise(MADV_FREE) on earlier (this is discussed below) due to a race between page reclaim on MADV_FREE and blkdev direct IO read.
- Race condition:
==============
During page reclaim, the MADV_FREE page check in try_to_unmap_one() checks if the page is not dirty, then discards its rmap PTE(s) (vs. remap back if the page is dirty).
However, after try_to_unmap_one() returns to shrink_page_list(), it might keep the page _anyway_ if page_ref_freeze() fails (it expects exactly _one_ page reference, from the isolation for page reclaim).
Well, blkdev_direct_IO() gets references for all pages, and on READ operations it only sets them dirty _later_.
So, if MADV_FREE'd pages (i.e., not dirty) are used as buffers for direct IO read from block devices, and page reclaim happens during __blkdev_direct_IO[_simple]() exactly AFTER bio_iov_iter_get_pages() returns, but BEFORE the pages are set dirty, the situation happens.
The direct IO read eventually completes. Now, when userspace reads the buffers, the PTE is no longer there and the page fault handler do_anonymous_page() services that with the zero-page, NOT the data!
A synthetic reproducer is provided.
- Page faults:
===========
If page reclaim happens BEFORE bio_iov_iter_get_pages() the issue doesn't happen, because that faults-in all pages as writeable, so do_anonymous_page() sets up a new page/rmap/PTE, and that is used by direct IO. The userspace reads don't fault as the PTE is there (thus zero-page is not used/setup).
But if page reclaim happens AFTER it / BEFORE setting pages dirty, the PTE is no longer there; the subsequent page faults can't help:
The data-read from the block device probably won't generate faults due to DMA (no MMU) but even in the case it wouldn't use DMA, that happens on different virtual addresses (not user-mapped addresses) because struct bio_vec stores struct page to figure addresses out (which are different from user-mapped addresses) for the read.
Thus userspace reads (to user-mapped addresses) still fault, then do_anonymous_page() gets another struct page that would address/ map to other memory than the struct page used by struct bio_vec for the read. (The original struct page is not available, since it wasn't freed, as page_ref_freeze() failed due to more page refs. And even if it were available, its data cannot be trusted anymore.)
Solution:
========
One solution is to check for the expected page reference count in try_to_unmap_one().
There should be one reference from the isolation (that is also checked in shrink_page_list() with page_ref_freeze()) plus one or more references from page mapping(s) (put in discard: label). Further references mean that rmap/PTE cannot be unmapped/nuked.
(Note: there might be more than one reference from mapping due to fork()/clone() without CLONE_VM, which use the same struct page for references, until the copy-on-write page gets copied.)
So, additional page references (e.g., from direct IO read) now prevent the rmap/PTE from being unmapped/dropped; similarly to the page is not freed per shrink_page_list()/page_ref_freeze()).
- Races and Barriers:
==================
The new check in try_to_unmap_one() should be safe in races with bio_iov_iter_get_pages() in get_user_pages() fast and slow paths, as it's done under the PTE lock.
The fast path doesn't take the lock, but it checks if the PTE has changed and if so, it drops the reference and leaves the page for the slow path (which does take that lock).
The fast path requires synchronization w/ full memory barrier: it writes the page reference count first then it reads the PTE later, while try_to_unmap() writes PTE first then it reads page refcount.
And a second barrier is needed, as the page dirty flag should not be read before the page reference count (as in __remove_mapping()). (This can be a load memory barrier only; no writes are involved.)
Call stack/comments:
- try_to_unmap_one()
- page_vma_mapped_walk()
- map_pte() # see pte_offset_map_lock():
pte_offset_map()
spin_lock()
- ptep_get_and_clear() # write PTE
- smp_mb() # (new barrier) GUP fast path
- page_ref_count() # (new check) read refcount
- page_vma_mapped_walk_done() # see pte_unmap_unlock():
pte_unmap()
spin_unlock()- bio_iov_iter_get_pages()
- __bio_iov_iter_get_pages()
- iov_iter_get_pages()
- get_user_pages_fast()
- internal_get_user_pages_fast()
# fast path
- lockless_pages_from_mm()
- gup_{pgd,p4d,pud,pmd,pte}_range()
ptep = pte_offset_map() # not _lock()
pte = ptep_get_lockless(ptep)
page = pte_page(pte)
try_grab_compound_head(page) # inc refcount
# (RMW/barrier # on success)
if (pte_val(pte) != pte_val(*ptep)) # read PTE
put_compound_head(page) # dec refcount
# go slow path
# slow path
- __gup_longterm_unlocked()
- get_user_pages_unlocked()
- __get_user_pages_locked()
- __get_user_pages()
- follow_{page,p4d,pud,pmd}_mask()
- follow_page_pte()
ptep = pte_offset_map_lock() pte = *ptep
page = vm_normal_page(pte)
try_grab_page(page) # inc refcount
pte_unmap_unlock()
- Huge Pages:
==========
Regarding transparent hugepages, that logic shouldn't change, as MADV_FREE (aka lazyfree) pages are PageAnon() && !PageSwapBacked() (madvise_free_pte_range() -> mark_page_lazyfree() -> lru_lazyfree_fn()) thus should reach shrink_page_list() -> split_huge_page_to_list() before try_to_unmap[_one](), so it deals with normal pages only.
(And in case unlikely/TTU_SPLIT_HUGE_PMD/split_huge_pmd_address() happens, which should not or be rare, the page refcount should be greater than
mapcount: the head page is referenced by tail pages. That also prevents checking the head page then incorrectly call page_remove_rmap(subpage) for a tail page, that isn't even in the shrink_page_list()'s page_list (an effect of split huge pmd/pmvw), as it might happen today in this unlikely scenario.)
MADV_FREE'd buffers:
===================
So, back to the "if MADV_FREE pages are used as buffers" note. The case is arguable, and subject to multiple interpretations.
The madvise(2) manual page on the MADV_FREE advice value says:
1) 'After a successful MADV_FREE ... data will be lost when the kernel frees the pages.'
2) 'the free operation will be canceled if the caller writes into the page' / 'subsequent writes ... will succeed and then [the] kernel cannot free those dirtied pages'
3) 'If there is no subsequent write, the kernel can free the pages at any time.'
Thoughts, questions, considerations... respectively:
1) Since the kernel didn't actually free the page (page_ref_freeze() failed), should the data not have been lost? (on userspace read.)
2) Should writes performed by the direct IO read be able to cancel the free operation?
- Should the direct IO read be considered as 'the caller' too, as it's been requested by 'the caller'?
- Should the bio technique to dirty pages on return to userspace (bio_check_pages_dirty() is called/used by __blkdev_direct_IO()) be considered in another/special way here?
3) Should an upcoming write from a previously requested direct IO read be considered as a subsequent write, so the kernel should not free the pages? (as it's known at the time of page reclaim.)
And lastly:
Technically, the last point would seem a reasonable consideration and balance, as the madvise(2) manual page apparently (and fairly) seem to assume that 'writes' are memory access from the userspace process (not explicitly considering writes from the kernel or its corner cases; again, fairly).. plus the kernel fix implementation for the corner case of the largely 'non-atomic write' encompassed by a direct IO read operation, is relatively simple; and it helps.
Reproducer:
==========
@ test.c (simplified, but works)
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
int main() {
int fd, i;
char *buf;
fd = open(DEV, O_RDONLY | O_DIRECT);
buf = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
buf[i] = 1; // init to non-zero
madvise(buf, BUF_SIZE, MADV_FREE);
read(fd, buf, BUF_SIZE);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
printf("%p: 0x%x\n", &buf[i], buf[i]);
return 0;
}@ block/fops.c (formerly fs/block_dev.c)
+#include <linux/swap.h>
...
... __blkdev_direct_IO[_simple](...)
{
...
+ if (!strcmp(current->comm, "good"))
+ shrink_all_memory(ULONG_MAX);
+
ret = bio_iov_iter_get_pages(...);
+
+ if (!strcmp(current->comm, "bad"))
+ shrink_all_memory(ULONG_MAX);
...
}@ shell
# NUM_PAGES=4
# PAGE_SIZE=$(getconf PAGE_SIZE)
# yes | dd of=test.img bs=${PAGE_SIZE} count=${NUM_PAGES}
# DEV=$(losetup -f --show test.img)
# gcc -DDEV=\"$DEV\" \
-DBUF_SIZE=$((PAGE_SIZE * NUM_PAGES)) \
-DPAGE_SIZE=${PAGE_SIZE} \
test.c -o test
# od -tx1 $DEV
0000000 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a
*
0040000
# mv test good
# ./good
0x7f7c10418000: 0x79
0x7f7c10419000: 0x79
0x7f7c1041a000: 0x79
0x7f7c1041b000: 0x79
# mv good bad
# ./bad
0x7fa1b8050000: 0x0
0x7fa1b8051000: 0x0
0x7fa1b8052000: 0x0
0x7fa1b8053000: 0x0Note: the issue is consistent on v5.17-rc3, but it's intermittent with the support of MADV_FREE on v4.5 (60%-70% error; needs swap). [wrap do_direct_IO() in do_blockdev_direct_IO() @ fs/direct-io.c].
- v5.17-rc3:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x0 # free | grep Swap
Swap: 0 0 0- v4.5:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
2702 0x0
1298 0x79 # swapoff -av
swapoff /swap # for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79Ceph/TCMalloc:
=============
For documentation purposes, the use case driving the analysis/fix is Ceph on Ubuntu 18.04, as the TCMalloc library there still uses MADV_FREE to release unused memory to the system from the mmap'ed page heap (might be committed back/used again; it's not munmap'ed.) - PageHeap::DecommitSpan() -> TCMalloc_SystemRelease() -> madvise() - PageHeap::CommitSpan() -> TCMalloc_SystemCommit() -> do nothing.
Note: TCMalloc switched back to MADV_DONTNEED a few commits after the release in Ubuntu 18.04 (google-perftools/gperftools 2.5), so the issue just 'disappeared' on Ceph on later Ubuntu releases but is still present in the kernel, and can be hit by other use cases.
The observed issue seems to be the old Ceph bug #22464 [1], where checksum mismatches are observed (and instrumentation with buffer dumps shows zero-pages read from mmap'ed/MADV_FREE'd page ranges).
The issue in Ceph was reasonably deemed a kernel bug (comment #50) and mostly worked around with a retry mechanism, but other parts of Ceph could still hit that (rocksdb). Anyway, it's less likely to be hit again as TCMalloc switched out of MADV_FREE by default.
(Some kernel versions/reports from the Ceph bug, and relation with the MADV_FREE introduction/changes; TCMalloc versions not checked.)
- 4.4 good
- 4.5 (madv_free: introduction)
- 4.9 bad
- 4.10 good? maybe a swapless system
- 4.12 (madv_free: no longer free instantly on swapless systems)
- 4.13 bad
[1] https://tracker.ceph.com/issues/22464
Thanks:
======
Several people contributed to analysis/discussions/tests/reproducers in the first stages when drilling down on ceph/tcmalloc/linux kernel:
- Dan Hill
- Dan Streetman
- Dongdong Tao
- Gavin Guo
- Gerald Yang
- Heitor Alves de Siqueira
- Ioanna Alifieraki
- Jay Vosburgh
- Matthew Ruffell
- Ponnuvel Palaniyappan
Reviews, suggestions, corrections, comments:
- Minchan Kim
- Yu Zhao
- Huang, Ying
- John Hubbard
- Christoph Hellwig
[mfo: backport: replace folio/test_flag with page/flag equivalents;
mmu_notifier_invalidate_range() is called in the 'discard:' label; real Fixes: 854e9ed09ded ("mm: support madvise(MADV_FREE)") in v4.]
--- mm/rmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
mm/rmap.c +24 -1
@@ -1564,7 +1564,30 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,/* MADV_FREE page check */ if (!PageSwapBacked (page)) { -if (!PageDirty (page)) { +int ref_count, map_count; + +/* +* Synchronize with gup_pte_range(): +* - clear PTE; barrier; read refcount +* - inc refcount; barrier; read PTE +*/ +smp_mb (); + + ref_count =page_ref_count (page); + map_count =page_mapcount (page); + +/* +* Order reads for page refcount and dirty flag +* (see comments in __remove_mapping()). +*/ +smp_rmb (); + +/* +* The only page refs must be one from isolation +* plus the rmap(s) (dropped by discard:). +*/ +if (ref_count ==1 + map_count && + !PageDirty (page)) {dec_mm_counter (mm,MM_ANONPAGES ); goto discard; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 239/284 drm/amdgpu: fix off by one in amdgpu_gfx_kiq_acquire()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1647b54ed55d4d48c7199d439f8834626576cbe9 ]
This post-op should be a pre-op so that we do not pass -1 as the bit number to test_bit(). The current code will loop downwards from 63 to -1. After changing to a pre-op, it loops from 63 to 0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
@@ -157,7 +157,7 @@ static int amdgpu_gfx_kiq_acquire(struct amdgpu_device *adev,* adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_queue_per_pipe; -while (queue_bit-- >= 0) { +while (--queue_bit >= 0) { if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap)) continue;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 240/284 scsi: zorro7xx: Fix a resource leak in zorro7xx_remove_one()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 16ed828b872d12ccba8f07bcc446ae89ba662f9c ]
The error handling path of the probe releases a resource that is not freed in the remove function. In some cases, a ioremap() must be undone.
Add the missing iounmap() call in the remove function.
--- drivers/scsi/zorro7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/zorro7xx.c +2 -0
@@ -158,6 +158,8 @@ static void zorro7xx_remove_one(struct zorro_dev *z)scsi_remove_host (host);NCR_700_release (host); +if (host->base >0x01000000 ) +iounmap (hostdata->base);kfree (hostdata);free_irq (host->irq, host);zorro_release_device (z);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 241/284 net: stmmac: Fix unset max_speed difference between DT and non-DT platforms
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit c21cabb0fd0b54b8b54235fc1ecfe1195a23bcb2 ]
In commit 9cbadf094d9d ("net: stmmac: support max-speed device tree property"), when DT platforms don't set "max-speed", max_speed is set to -1; for non-DT platforms, it stays the default 0.
Prior to commit eeef2f6b9f6e ("net: stmmac: Start adding phylink support"), the check for a valid max_speed setting was to check if it was greater than zero. This commit got it right, but subsequent patches just checked for non-zero, which is incorrect for DT platforms.
In commit 92c3807b9ac3 ("net: stmmac: convert to phylink_get_linkmodes()") the conversion switched completely to checking for non-zero value as a valid value, which caused 1000base-T to stop getting advertised by default.
Instead of trying to fix all the checks, simply leave max_speed alone if DT property parsing fails.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -2
@@ -388,8 +388,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->interface =of_get_phy_mode (np);/* Get max speed of operation from device tree */ -if (of_property_read_u32 (np,"max-speed" , &plat->max_speed)) - plat->max_speed =-1 ; +of_property_read_u32 (np,"max-speed" , &plat->max_speed); plat->bus_id =of_alias_get_id (np,"ethernet" );if (plat->bus_id <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 242/284 drm/imx: Fix memory leak in imx_pd_connector_get_modes
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit bce81feb03a20fca7bbdd1c4af16b4e9d5c0e1d3 ]
Avoid leaking the display mode variable if of_get_drm_display_mode fails.
Addresses-Coverity-ID: 1443943 ("Resource leak")
--- drivers/gpu/drm/imx/parallel-display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/parallel-display.c +3 -1
@@ -77,8 +77,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector) ret =of_get_drm_display_mode (np, &imxpd->mode, &imxpd->bus_flags,OF_USE_NATIVE_MODE ); -if (ret) +if (ret) { +drm_mode_destroy (connector->dev, mode);return ret; + }drm_mode_copy (mode, &imxpd->mode); mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 243/284 drbd: Fix five use after free bugs in get_initial_state
In reply to Greg Kroah-HartmanFrom: Lv Yunlong <[email protected]>
[ Upstream commit aadb22ba2f656581b2f733deb3a467c48cc618f6 ]
In get_initial_state, it calls notify_initial_state_done(skb,..) if cb->args[5]==1. If genlmsg_put() failed in notify_initial_state_done(), the skb will be freed by nlmsg_free(skb).
Then get_initial_state will goto out and the freed skb will be used by return value skb->len, which is a uaf bug.
What's worse, the same problem goes even further: skb can also be freed in the notify_*_state_change -> notify_*_state calls below. Thus 4 additional uaf bugs happened.
My patch lets the problem callee functions: notify_initial_state_done and notify_*_state_change return an error code if errors happen. So that the error codes could be propagated and the uaf bugs can be avoid.
v2 reports a compilation warning. This v3 fixed this warning and built successfully in my local environment with no additional warnings.
v2: https://lore.kernel.org/patchwork/patch/1435218/
--- drivers/block/drbd/drbd_int.h | 8 ++--- drivers/block/drbd/drbd_nl.c | 41 ++++++++++++++++---------- drivers/block/drbd/drbd_state.c | 18 +++++------ drivers/block/drbd/drbd_state_change.h | 8 ++--- 4 files changed, 42 insertions(+), 33 deletions(-)
drivers/block/drbd/drbd_int.h +4 -4
@@ -1690,22 +1690,22 @@ struct sib_info { };void drbd_bcast_event (struct drbd_device *device,const struct sib_info *sib); -extern void notify_resource_state (struct sk_buff *, +extern int notify_resource_state (struct sk_buff *,unsigned int ,struct drbd_resource *,struct resource_info *,enum drbd_notification_type ); -extern void notify_device_state (struct sk_buff *, +extern int notify_device_state (struct sk_buff *,unsigned int ,struct drbd_device *,struct device_info *,enum drbd_notification_type ); -extern void notify_connection_state (struct sk_buff *, +extern int notify_connection_state (struct sk_buff *,unsigned int ,struct drbd_connection *,struct connection_info *,enum drbd_notification_type ); -extern void notify_peer_device_state(struct sk_buff *, +extern int notify_peer_device_state(struct sk_buff *, unsigned int, struct drbd_peer_device *, struct peer_device_info *,
drivers/block/drbd/drbd_nl.c +25 -16
156 lines not on this page · raw message
drivers/block/drbd/drbd_state.c +9 -9
@@ -1549,7 +1549,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,return rv; } -void notify_resource_state_change (struct sk_buff *skb, +int notify_resource_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_resource_state_change *resource_state_change,enum drbd_notification_type type)
@@ -1562,10 +1562,10 @@ void notify_resource_state_change(struct sk_buff *skb, .res_susp_fen = resource_state_change->susp_fen[NEW], }; -notify_resource_state (skb, seq, resource, &resource_info, type); +return notify_resource_state (skb, seq, resource, &resource_info, type); } -void notify_connection_state_change (struct sk_buff *skb, +int notify_connection_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_connection_state_change *connection_state_change,enum drbd_notification_type type)
@@ -1576,10 +1576,10 @@ void notify_connection_state_change(struct sk_buff *skb, .conn_role = connection_state_change->peer_role[NEW], }; -notify_connection_state (skb, seq, connection, &connection_info, type); +return notify_connection_state (skb, seq, connection, &connection_info, type); } -void notify_device_state_change (struct sk_buff *skb, +int notify_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_device_state_change *device_state_change,enum drbd_notification_type type)
@@ -1589,10 +1589,10 @@ void notify_device_state_change(struct sk_buff *skb, .dev_disk_state = device_state_change->disk_state[NEW], }; -notify_device_state (skb, seq, device, &device_info, type); +return notify_device_state (skb, seq, device, &device_info, type); } -void notify_peer_device_state_change (struct sk_buff *skb, +int notify_peer_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_peer_device_state_change *p,enum drbd_notification_type type)
@@ -1606,7 +1606,7 @@ void notify_peer_device_state_change(struct sk_buff *skb, .peer_resync_susp_dependency = p->resync_susp_dependency[NEW], }; -notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); +return notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); }static void broadcast_state_change (struct drbd_state_change *state_change)
@@ -1614,7 +1614,7 @@ static void broadcast_state_change(struct drbd_state_change *state_change)struct drbd_resource_state_change *resource_state_change = &state_change->resource[0 ];bool resource_state_has_changed;unsigned int n_device, n_connection, n_peer_device, n_peer_devices; -void (*last_func)(struct sk_buff *,unsigned int ,void *, +int (*last_func)(struct sk_buff *,unsigned int ,void *,enum drbd_notification_type ) =NULL ;void *uninitialized_var (last_arg );
drivers/block/drbd/drbd_state_change.h +4 -4
@@ -44,19 +44,19 @@ extern struct drbd_state_change *remember_old_state(struct drbd_resource *, gfp_extern void copy_old_to_new_state_change (struct drbd_state_change *);extern void forget_state_change (struct drbd_state_change *); -extern void notify_resource_state_change (struct sk_buff *, +extern int notify_resource_state_change (struct sk_buff *,unsigned int ,struct drbd_resource_state_change *,enum drbd_notification_type type); -extern void notify_connection_state_change (struct sk_buff *, +extern int notify_connection_state_change (struct sk_buff *,unsigned int ,struct drbd_connection_state_change *,enum drbd_notification_type type); -extern void notify_device_state_change (struct sk_buff *, +extern int notify_device_state_change (struct sk_buff *,unsigned int ,struct drbd_device_state_change *,enum drbd_notification_type type); -extern void notify_peer_device_state_change (struct sk_buff *, +extern int notify_peer_device_state_change (struct sk_buff *,unsigned int ,struct drbd_peer_device_state_change *,enum drbd_notification_type type);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 244/284 Revert "mmc: sdhci-xenon: fix annoying 1.8V regulator warning"
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 7e2646ed47542123168d43916b84b954532e5386 upstream.
This reverts commit bb32e1987bc55ce1db400faf47d85891da3c9b9f.
Commit 1a3ed0dc3594 ("mmc: sdhci-xenon: fix 1.8v regulator stabilization") contains proper fix for the issue described in commit bb32e1987bc5 ("mmc:
sdhci-xenon: fix annoying 1.8V regulator warning").
--- drivers/mmc/host/sdhci-xenon.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/mmc/host/sdhci-xenon.c +0 -10
@@ -243,16 +243,6 @@ static void xenon_voltage_switch(struct {/* Wait for 5ms after set 1.8V signal enable bit */ usleep_range (5000 ,5500 ); - -/* -* For some reason the controller's Host Control2 register reports -* the bit representing 1.8V signaling as 0 when read after it was -* written as 1. Subsequent read reports 1. -* -* Since this may cause some issues, do an empty read of the Host -* Control2 register here to circumvent this. -*/ -sdhci_readw (host,SDHCI_HOST_CONTROL2 ); }static const struct sdhci_ops sdhci_xenon_ops = {
Greg Kroah-Hartman
maintainerPATCH 245/284 mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 01e67e04c28170c47700c2c226d732bbfedb1ad0 upstream.
If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range.
This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue.
--- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+)
mm/mremap.c +3 -0
@@ -203,6 +203,9 @@ unsigned long move_page_tables(struct vmunsigned long mmun_start;/* For mmu_notifiers */ unsigned long mmun_end;/* For mmu_notifiers */ +if (!len) +return 0 ; + old_end = old_addr + len;flush_cache_range (vma, old_addr, old_end);
Greg Kroah-Hartman
maintainerPATCH 246/284 mm/mempolicy: fix mpol_new leak in shared_policy_replace
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
commit 4ad099559b00ac01c3726e5c95dc3108ef47d03e upstream.
If mpol_new is allocated but not used in restart loop, mpol_new will be freed via mpol_put before returning to the caller. But refcnt is not initialized yet, so mpol_put could not do the right things and might leak the unused mpol_new. This would happen if mempolicy was updated on the shared shmem file while the sp->lock has been dropped during the memory allocation.
This issue could be triggered easily with the below code snippet if there are many processes doing the below work at the same time:
shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT);
shm = shmat(shmid, 0, 0);
loop many times {
mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0);
mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask,
maxnode, 0);
}--- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+)
mm/mempolicy.c +1 -0
@@ -2479,6 +2479,7 @@ alloc_new: mpol_new =kmem_cache_alloc (policy_cache,GFP_KERNEL );if (!mpol_new) goto err_out; +atomic_set (&mpol_new->refcnt,1 ); goto restart; }
Greg Kroah-Hartman
maintainerPATCH 247/284 x86/pm: Save the MSR validity status at context setup
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 73924ec4d560257004d5b5116b22a3647661e364 upstream.
The mechanism to save/restore MSRs during S3 suspend/resume checks for the MSR validity during suspend, and only restores the MSR if its a valid MSR. This is not optimal, as an invalid MSR will unnecessarily throw an exception for every suspend cycle. The more invalid MSRs, higher the impact will be.
Check and save the MSR validity at setup. This ensures that only valid MSRs that are guaranteed to not throw an exception will be attempted during suspend.
--- arch/x86/power/cpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/power/cpu.c +5 -2
@@ -41,7 +41,8 @@ static void msr_save_context(struct savestruct saved_msr *end = msr + ctxt->saved_msrs.num;while (msr < end) { - msr->valid = !rdmsrl_safe (msr->info.msr_no, &msr->info.reg.q); +if (msr->valid) +rdmsrl (msr->info.msr_no, msr->info.reg.q); msr++; } }
@@ -426,8 +427,10 @@ static int msr_build_context(const u32 * }for (i = saved_msrs->num, j =0 ; i < total_num; i++, j++) { +u64 dummy; + msr_array[i].info.msr_no = msr_id[j]; - msr_array[i].valid = false; + msr_array[i].valid = !rdmsrl_safe (msr_id[j], &dummy); msr_array[i].info.reg.q =0 ; } saved_msrs->num = total_num;
Greg Kroah-Hartman
maintainerPATCH 248/284 x86/speculation: Restore speculation related MSRs during S3 resume
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit e2a1256b17b16f9b9adf1b6fea56819e7b68e463 upstream.
After resuming from suspend-to-RAM, the MSRs that control CPU's speculative execution behavior are not being restored on the boot CPU.
These MSRs are used to mitigate speculative execution vulnerabilities. Not restoring them correctly may leave the CPU vulnerable. Secondary CPU's MSRs are correctly being restored at S3 resume by identify_secondary_cpu().
During S3 resume, restore these MSRs for boot CPU when restoring its processor state.
--- arch/x86/power/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/power/cpu.c +14 -0
@@ -517,10 +517,24 @@ static int pm_cpu_check(const struct x86return ret; } +static void pm_save_spec_msr (void ) +{ +u32 spec_msr_id[] = { +MSR_IA32_SPEC_CTRL , +MSR_IA32_TSX_CTRL , +MSR_TSX_FORCE_ABORT , +MSR_IA32_MCU_OPT_CTRL , +MSR_AMD64_LS_CFG , + }; + +msr_build_context (spec_msr_id,ARRAY_SIZE (spec_msr_id)); +} +static int pm_check_save_msr (void ) {dmi_check_system (msr_save_dmi_table);pm_cpu_check (msr_save_cpu_table); +pm_save_spec_msr ();return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 249/284 btrfs: fix qgroup reserve overflow the qgroup limit
In reply to Greg Kroah-HartmanFrom: Ethan Lien <[email protected]>
commit b642b52d0b50f4d398cb4293f64992d0eed2e2ce upstream.
We use extent_changeset->bytes_changed in qgroup_reserve_data() to record how many bytes we set for EXTENT_QGROUP_RESERVED state. Currently the bytes_changed is set as "unsigned int", and it will overflow if we try to fallocate a range larger than 4GiB. The result is we reserve less bytes and eventually break the qgroup limit.
Unlike regular buffered/direct write, which we use one changeset for each ordered extent, which can never be larger than 256M. For fallocate, we use one changeset for the whole range, thus it no longer respects the 256M per extent limit, and caused the problem.
The following example test script reproduces the problem:
$ cat qgroup-overflow.sh #!/bin/bash
DEV=/dev/sdj
MNT=/mnt/sdj
mkfs.btrfs -f $DEV
mount $DEV $MNT
# Set qgroup limit to 2GiB.
btrfs quota enable $MNT
btrfs qgroup limit 2G $MNT
# Try to fallocate a 3GiB file. This should fail. echo
echo "Try to fallocate a 3GiB file..." fallocate -l 3G $MNT/3G.file
# Try to fallocate a 5GiB file.
echo
echo "Try to fallocate a 5GiB file..."
fallocate -l 5G $MNT/5G.file
# See we break the qgroup limit.
echo
sync
btrfs qgroup show -r $MNT
umount $MNT
When running the test:
$ ./qgroup-overflow.sh (...)
Try to fallocate a 3GiB file...
fallocate: fallocate failed: Disk quota exceeded
Try to fallocate a 5GiB file...
qgroupid rfer excl max_rfer
-------- ---- ---- --------
0/5 5.00GiB 5.00GiB 2.00GiB
Since we have no control of how bytes_changed is used, it's better to set it to u64.
--- fs/btrfs/extent_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent_io.h +1 -1
@@ -210,7 +210,7 @@ struct extent_buffer {*/ struct extent_changeset {/* How many bytes are set/cleared in this operation */ -unsigned int bytes_changed; +u64 bytes_changed;/* Changed ranges */ struct ulist range_changed;
Greg Kroah-Hartman
maintainerPATCH 250/284 arm64: patch_text: Fixup last cpu should be master
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
commit 31a099dbd91e69fcab55eef4be15ed7a8c984918 upstream.
These patch_text implementations are using stop_machine_cpuslocked infrastructure with atomic cpu_count. The original idea: When the master CPU patch_text, the others should wait for it. But current implementation is using the first CPU as master, which couldn't guarantee the remaining CPUs are waiting. This patch changes the last CPU as the master to solve the potential risk.
--- arch/arm64/kernel/insn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/insn.c +2 -2
@@ -233,8 +233,8 @@ static int __kprobes aarch64_insn_patch_int i, ret =0 ;struct aarch64_insn_patch *pp = arg; -/* The first CPU becomes master */ -if (atomic_inc_return (&pp->cpu_count) ==1 ) { +/* The last CPU becomes master */ +if (atomic_inc_return (&pp->cpu_count) ==num_online_cpus ()) {for (i =0 ; ret ==0 && i < pp->insn_cnt; i++) ret =aarch64_insn_patch_text_nosync (pp->text_addrs[i], pp->new_insns[i]);
Greg Kroah-Hartman
maintainerPATCH 251/284 perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
commit 2012a9e279013933885983cbe0a5fe828052563b upstream.
The bug is here:
return cluster;
The list iterator value 'cluster' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found.
To fix the bug, return 'cluster' when found, otherwise return NULL.
--- drivers/perf/qcom_l2_pmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/perf/qcom_l2_pmu.c +3 -3
@@ -744,7 +744,7 @@ static struct cluster_pmu *l2_cache_asso {u64 mpidr;int cpu_cluster_id; -struct cluster_pmu *cluster =NULL ; +struct cluster_pmu *cluster;/* * This assumes that the cluster_id is in MPIDR[aff1] for
@@ -766,10 +766,10 @@ static struct cluster_pmu *l2_cache_asso cluster->cluster_id);cpumask_set_cpu (cpu, &cluster->cluster_cpus); *per_cpu_ptr (l2cache_pmu->pmu_cluster, cpu) = cluster; -break ; +return cluster; } -return cluster; +return NULL ; }static int l2cache_pmu_online_cpu (unsigned int cpu,struct hlist_node *node)
Greg Kroah-Hartman
maintainerPATCH 252/284 tools build: Use $(shell ) instead of `` to get embedded libperls ccopts
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit 541f695cbcb6932c22638b06e0cbe1d56177e2e9 upstream.
Just like its done for ldopts and for both in tools/perf/Makefile.config.
Using `` to initialize PERL_EMBED_CCOPTS somehow precludes using:
$(filter-out SOMETHING_TO_FILTER,$(PERL_EMBED_CCOPTS))
And we need to do it to allow for building with versions of clang where some gcc options selected by distros are not available.
--- tools/build/feature/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/feature/Makefile +1 -1
@@ -184,7 +184,7 @@ strip-libs = $(filter-out -l%,$(1)) PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) -PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` +PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) $(OUTPUT)test-libperl.bin:
Greg Kroah-Hartman
maintainerPATCH 253/284 dmaengine: Revert "dmaengine: shdma: Fix runtime PM imbalance on error"
In reply to Greg Kroah-HartmanFrom: Vinod Koul <[email protected]>
commit d143f939a95696d38ff800ada14402fa50ebbd6c upstream.
This reverts commit 455896c53d5b ("dmaengine: shdma: Fix runtime PM imbalance on error") as the patch wrongly reduced the count on error and did not bail out. So drop the count by reverting the patch .
--- drivers/dma/sh/shdma-base.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sh/shdma-base.c +1 -3
@@ -118,10 +118,8 @@ static dma_cookie_t shdma_tx_submit(stru ret =pm_runtime_get (schan->dev);spin_unlock_irq (&schan->chan_lock); -if (ret <0 ) { +if (ret <0 )dev_err (schan->dev,"%s(): GET = %d\n" , __func__, ret); -pm_runtime_put (schan->dev); - }pm_runtime_barrier (schan->dev);
Greg Kroah-Hartman
maintainerPATCH 254/284 mm: dont skip swap entry even if zap_details specified
In reply to Greg Kroah-HartmanFrom: Peter Xu <[email protected]>
commit 5abfd71d936a8aefd9f9ccd299dea7a164a5d455 upstream.
Patch series "mm: Rework zap ptes on swap entries", v5.
Patch 1 should fix a long standing bug for zap_pte_range() on zap_details usage. The risk is we could have some swap entries skipped while we should have zapped them.
Migration entries are not the major concern because file backed memory always zap in the pattern that "first time without page lock, then re-zap with page lock" hence the 2nd zap will always make sure all migration entries are already recovered.
However there can be issues with real swap entries got skipped errornoously. There's a reproducer provided in commit message of patch 1 for that.
Patch 2-4 are cleanups that are based on patch 1. After the whole patchset applied, we should have a very clean view of zap_pte_range().
Only patch 1 needs to be backported to stable if necessary.
This patch (of 4):
The "details" pointer shouldn't be the token to decide whether we should skip swap entries.
For example, when the callers specified details->zap_mapping==NULL, it means the user wants to zap all the pages (including COWed pages), then we need to look into swap entries because there can be private COWed pages that was swapped out.
Skipping some swap entries when details is non-NULL may lead to wrongly leaving some of the swap entries while we should have zapped them.
A reproducer of the problem:
===8<===
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
int page_size;
int shmem_fd;
char *buffer;
void main(void)
{
int ret;
char val;
page_size = getpagesize();
shmem_fd = memfd_create("test", 0);
assert(shmem_fd >= 0);
ret = ftruncate(shmem_fd, page_size * 2);
assert(ret == 0);
buffer = mmap(NULL, page_size * 2, PROT_READ | PROT_WRITE,
MAP_PRIVATE, shmem_fd, 0);
assert(buffer != MAP_FAILED);
/* Write private page, swap it out */
buffer[page_size] = 1;
madvise(buffer, page_size * 2, MADV_PAGEOUT);
/* This should drop private buffer[page_size] already */
ret = ftruncate(shmem_fd, page_size);
assert(ret == 0);
/* Recover the size */
ret = ftruncate(shmem_fd, page_size * 2);
assert(ret == 0);
/* Re-read the data, it should be all zero */
val = buffer[page_size];
if (val == 0)
printf("Good\n");
else
printf("BUG\n");
}===8<===
We don't need to touch up the pmd path, because pmd never had a issue with swap entries. For example, shmem pmd migration will always be split into pte level, and same to swapping on anonymous.
Add another helper should_zap_cows() so that we can also check whether we should zap private mappings when there's no page pointer specified.
This patch drops that trick, so we handle swap ptes coherently. Meanwhile we should do the same check upon migration entry, hwpoison entry and genuine swap entries too.
To be explicit, we should still remember to keep the private entries if even_cows==false, and always zap them when even_cows==true.
The issue seems to exist starting from the initial commit of git.
--- mm/memory.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
mm/memory.c +19 -6
@@ -1306,6 +1306,17 @@ int copy_page_range(struct mm_struct *dsreturn ret; } +/* Whether we should zap all COWed (private) pages too */ +static inline bool should_zap_cows (struct zap_details *details) +{ +/* By default, zap all pages */ +if (!details) +return true; + +/* Or, we zap COWed pages only if the caller wants to */ +return !details->check_mapping; +} + static unsigned long zap_pte_range(struct mmu_gather *tlb, struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, unsigned long end,
@@ -1394,17 +1405,19 @@ again:continue ; } -/* If details->check_mapping, we leave swap entries. */ -if (unlikely (details)) -continue ; - entry =pte_to_swp_entry (ptent); -if (!non_swap_entry (entry)) +if (!non_swap_entry (entry)) { +/* Genuine swap entry, hence a private anon page */ +if (!should_zap_cows (details)) +continue ; rss[MM_SWAPENTS ]--; -else if (is_migration_entry (entry)) { + }else if (is_migration_entry (entry)) {struct page *page; page =migration_entry_to_page (entry); +if (details && details->check_mapping && + details->check_mapping !=page_rmapping (page)) +continue ; rss[mm_counter (page)]--; }if (unlikely (!free_swap_and_cache (entry)))
Greg Kroah-Hartman
maintainerPATCH 255/284 arm64: module: remove (NOLOAD) from linker script
In reply to Greg Kroah-HartmanFrom: Fangrui Song <[email protected]>
commit 4013e26670c590944abdab56c4fa797527b74325 upstream.
On ELF, (NOLOAD) sets the section type to SHT_NOBITS[1]. It is conceptually inappropriate for .plt and .text.* sections which are always SHT_PROGBITS.
In GNU ld, if PLT entries are needed, .plt will be SHT_PROGBITS anyway and (NOLOAD) will be essentially ignored. In ld.lld, since
https://reviews.llvm.org/D118840 ("[ELF] Support (TYPE=<value>) to customize the output section type"), ld.lld will report a section type mismatch error. Just remove (NOLOAD) to fix the error.
[1] https://lld.llvm.org/ELF/linker_script.html As of today, "The section should be marked as not loadable" on
https://sourceware.org/binutils/docs/ld/Output-Section-Type.html is outdated for ELF.
--- arch/arm64/kernel/module.lds | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/kernel/module.lds +3 -3
@@ -1,5 +1,5 @@ SECTIONS { - .plt 0 (NOLOAD) : { BYTE(0) } - .init.plt 0 (NOLOAD) : { BYTE(0) } - .text.ftrace_trampoline 0 (NOLOAD) : { BYTE(0) } + .plt 0 : { BYTE(0) } + .init.plt 0 : { BYTE(0) } + .text.ftrace_trampoline 0 : { BYTE(0) } }
Greg Kroah-Hartman
maintainerPATCH 256/284 mm/sparsemem: fix mem_section will never be NULL gcc 12 warning
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
commit a431dbbc540532b7465eae4fc8b56a85a9fc7d17 upstream.
The gcc 12 compiler reports a "'mem_section' will never be NULL" warning on the following code:
static inline struct mem_section *__nr_to_section(unsigned long nr)
{
#ifdef CONFIG_SPARSEMEM_EXTREME
if (!mem_section)
return NULL;
#endif
if (!mem_section[SECTION_NR_TO_ROOT(nr)])
return NULL;
:It happens with CONFIG_SPARSEMEM_EXTREME off. The mem_section definition is
#ifdef CONFIG_SPARSEMEM_EXTREME
extern struct mem_section **mem_section;
#else
extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
#endifIn the !CONFIG_SPARSEMEM_EXTREME case, mem_section is a static 2-dimensional array and so the check "!mem_section[SECTION_NR_TO_ROOT(nr)]" doesn't make sense.
Fix this warning by moving the "!mem_section[SECTION_NR_TO_ROOT(nr)]" check up inside the CONFIG_SPARSEMEM_EXTREME block and adding an explicit NR_SECTION_ROOTS check to make sure that there is no out-of-bound array access.
--- include/linux/mmzone.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/linux/mmzone.h +7 -4
@@ -1160,13 +1160,16 @@ extern struct mem_section mem_section[NRstatic inline struct mem_section *__nr_to_section (unsigned long nr) { +unsigned long root =SECTION_NR_TO_ROOT (nr); + +if (unlikely (root >=NR_SECTION_ROOTS )) +return NULL ; +#ifdef CONFIG_SPARSEMEM_EXTREME -if (!mem_section) +if (!mem_section || !mem_section[root])return NULL ;#endif -if (!mem_section[SECTION_NR_TO_ROOT (nr)]) -return NULL ; -return &mem_section[SECTION_NR_TO_ROOT (nr)][nr &SECTION_ROOT_MASK ]; +return &mem_section[root][nr &SECTION_ROOT_MASK ]; }extern int __section_nr (struct mem_section * ms);extern unsigned long usemap_size (void );
Greg Kroah-Hartman
maintainerPATCH 257/284 cgroup: Use open-time credentials for process migraton perm checks
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 1756d7994ad85c2479af6ae5a9750b92324685af upstream.
cgroup process migration permission checks are performed at write time as whether a given operation is allowed or not is dependent on the content of the write - the PID. This currently uses current's credentials which is a potential security weakness as it may allow scenarios where a less privileged process tricks a more privileged one into writing into a fd that it created.
This patch makes both cgroup2 and cgroup1 process migration interfaces to use the credentials saved at the time of open (file->f_cred) instead of current's.
[OP: backport to v4.14: apply original __cgroup_procs_write() changes to cgroup_threads_write() and cgroup_procs_write()]
--- kernel/cgroup/cgroup-v1.c | 7 ++++--- kernel/cgroup/cgroup.c | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-)
kernel/cgroup/cgroup-v1.c +4 -3
@@ -535,10 +535,11 @@ static ssize_t __cgroup1_procs_write(str goto out_unlock;/* -* Even if we're attaching all tasks in the thread group, we only -* need to check permissions on one of them. +* Even if we're attaching all tasks in the thread group, we only need +* to check permissions on one of them. Check permissions using the +* credentials from file open to protect against inherited fd attacks. */ - cred =current_cred (); + cred = of->file->f_cred; tcred =get_task_cred (task); if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && !uid_eq(cred->euid, tcred->uid) &&
kernel/cgroup/cgroup.c +16 -1
@@ -4381,6 +4381,7 @@ static ssize_t cgroup_procs_write(struct {struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task; +const struct cred *saved_cred;ssize_t ret; dst_cgrp =cgroup_kn_lock_live (of->kn, false);
@@ -4397,8 +4398,15 @@ static ssize_t cgroup_procs_write(struct src_cgrp =task_cgroup_from_root (task, &cgrp_dfl_root);spin_unlock_irq (&css_set_lock); +/* +* Process and thread migrations follow same delegation rule. Check +* permissions using the credentials from file open to protect against +* inherited fd attacks. +*/ + saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb); +revert_creds (saved_cred);if (ret) goto out_finish;
@@ -4422,6 +4430,7 @@ static ssize_t cgroup_threads_write(stru {struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task; +const struct cred *saved_cred;ssize_t ret; buf =strstrip (buf);
@@ -4440,9 +4449,15 @@ static ssize_t cgroup_threads_write(stru src_cgrp =task_cgroup_from_root (task, &cgrp_dfl_root);spin_unlock_irq (&css_set_lock); -/* thread migrations follow the cgroup.procs delegation rule */ +/* +* Process and thread migrations follow same delegation rule. Check +* permissions using the credentials from file open to protect against +* inherited fd attacks. +*/ + saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb); +revert_creds (saved_cred);if (ret) goto out_finish;
Greg Kroah-Hartman
maintainerPATCH 258/284 cgroup: Allocate cgroup_file_ctx for kernfs_open_file->priv
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 0d2b5955b36250a9428c832664f2079cbf723bec upstream.
of->priv is currently used by each interface file implementation to store private information. This patch collects the current two private data usages into struct cgroup_file_ctx which is allocated and freed by the common path. This allows generic private data which applies to multiple files, which will be used to in the following patch.
Note that cgroup_procs iterator is now embedded as procs.iter in the new cgroup_file_ctx so that it doesn't need to be allocated and freed separately.
v2: union dropped from cgroup_file_ctx and the procs iterator is embedded in
cgroup_file_ctx as suggested by Linus.
v3: Michal pointed out that cgroup1's procs pidlist uses of->priv too.
Converted. Didn't change to embedded allocation as cgroup1 pidlists get stored for caching.
--- kernel/cgroup/cgroup-internal.h | 17 ++++++++++++++++ kernel/cgroup/cgroup-v1.c | 26 +++++++++++++----------- kernel/cgroup/cgroup.c | 42 ++++++++++++++++++++++++---------------- 3 files changed, 57 insertions(+), 28 deletions(-)
kernel/cgroup/cgroup-internal.h +17 -0
@@ -8,6 +8,23 @@#include <linux/list.h> #include <linux/refcount.h> +struct cgroup_pidlist ; + +struct cgroup_file_ctx { +struct { +void *trigger; + } psi; + +struct { +bool started; +struct css_task_iter iter; + } procs; + +struct { +struct cgroup_pidlist *pidlist; + } procs1; +}; +/* * A cgroup can be associated with multiple css_sets as different tasks may * belong to different cgroups on different hierarchies. In the other
kernel/cgroup/cgroup-v1.c +14 -12
@@ -426,6 +426,7 @@ static void *cgroup_pidlist_start(struct* next pid to display, if any */ struct kernfs_open_file *of = s->private; +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *cgrp =seq_css (s)->cgroup;struct cgroup_pidlist *l;enum cgroup_filetype type =seq_cft (s)->private;
@@ -435,25 +436,24 @@ static void *cgroup_pidlist_start(structmutex_lock (&cgrp->pidlist_mutex);/* -* !NULL @of->priv indicates that this isn't the first start() -* after open. If the matching pidlist is around, we can use that. -* Look for it. Note that @of->priv can't be used directly. It -* could already have been destroyed. +* !NULL @ctx->procs1.pidlist indicates that this isn't the first +* start() after open. If the matching pidlist is around, we can use +* that. Look for it. Note that @ctx->procs1.pidlist can't be used +* directly. It could already have been destroyed. */ -if (of->priv) - of->priv =cgroup_pidlist_find (cgrp, type); +if (ctx->procs1.pidlist) + ctx->procs1.pidlist =cgroup_pidlist_find (cgrp, type);/* * Either this is the first start() after open or the matching * pidlist has been destroyed inbetween. Create a new one. */ -if (!of->priv) { - ret =pidlist_array_load (cgrp, type, - (struct cgroup_pidlist **)&of->priv); +if (!ctx->procs1.pidlist) { + ret =pidlist_array_load (cgrp, type, &ctx->procs1.pidlist);if (ret)return ERR_PTR (ret); } - l = of->priv; + l = ctx->procs1.pidlist;if (pid) {int end = l->length;
@@ -481,7 +481,8 @@ static void *cgroup_pidlist_start(structstatic void cgroup_pidlist_stop (struct seq_file *s,void *v) {struct kernfs_open_file *of = s->private; -struct cgroup_pidlist *l = of->priv; +struct cgroup_file_ctx *ctx = of->priv; +struct cgroup_pidlist *l = ctx->procs1.pidlist;if (l) mod_delayed_work(cgroup_pidlist_destroy_wq, &l->destroy_dwork,
@@ -492,7 +493,8 @@ static void cgroup_pidlist_stop(struct sstatic void *cgroup_pidlist_next (struct seq_file *s,void *v,loff_t *pos) {struct kernfs_open_file *of = s->private; -struct cgroup_pidlist *l = of->priv; +struct cgroup_file_ctx *ctx = of->priv; +struct cgroup_pidlist *l = ctx->procs1.pidlist;pid_t *p = v;pid_t *end = l->list + l->length;/*
kernel/cgroup/cgroup.c +26 -16
86 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 259/284 cgroup: Use open-time cgroup namespace for process migration perm checks
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit e57457641613fef0d147ede8bd6a3047df588b95 upstream.
cgroup process migration permission checks are performed at write time as whether a given operation is allowed or not is dependent on the content of the write - the PID. This currently uses current's cgroup namespace which is a potential security weakness as it may allow scenarios where a less privileged process tricks a more privileged one into writing into a fd that it created.
This patch makes cgroup remember the cgroup namespace at the time of open and uses it for migration permission checks instad of current's. Note that this only applies to cgroup2 as cgroup1 doesn't have namespace support.
This also fixes a use-after-free bug on cgroupns reported in
https://lore.kernel.org/r/[email protected]
Note that backporting this fix also requires the preceding patch.
[OP: backport to v4.14: drop changes to cgroup_attach_permissions() and cgroup_css_set_fork(), adjust cgroup_procs_write_permission() calls]
--- kernel/cgroup/cgroup-internal.h | 2 ++ kernel/cgroup/cgroup.c | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-)
kernel/cgroup/cgroup-internal.h +2 -0
@@ -11,6 +11,8 @@struct cgroup_pidlist ;struct cgroup_file_ctx { +struct cgroup_namespace *ns; +struct {void *trigger; } psi;
kernel/cgroup/cgroup.c +17 -7
@@ -3370,14 +3370,19 @@ static int cgroup_file_open(struct kernf ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ; + + ctx->ns = current->nsproxy->cgroup_ns; +get_cgroup_ns (ctx->ns); of->priv = ctx;if (!cft->open)return 0 ; ret = cft->open (of); -if (ret) +if (ret) { +put_cgroup_ns (ctx->ns);kfree (ctx); + }return ret; }
@@ -3388,13 +3393,14 @@ static void cgroup_file_release(struct kif (cft->release) cft->release (of); +put_cgroup_ns (ctx->ns);kfree (ctx); }static ssize_t cgroup_file_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off) { -struct cgroup_namespace *ns = current->nsproxy->cgroup_ns; +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *cgrp = of->kn->parent->priv;struct cftype *cft = of->kn->priv;struct cgroup_subsys_state *css;
@@ -3408,7 +3414,7 @@ static ssize_t cgroup_file_write(struct*/ if ((cgrp->root->flags &CGRP_ROOT_NS_DELEGATE ) && !(cft->flags &CFTYPE_NS_DELEGATABLE ) && - ns != &init_cgroup_ns && ns->root_cset->dfl_cgrp == cgrp) + ctx->ns != &init_cgroup_ns && ctx->ns->root_cset->dfl_cgrp == cgrp)return -EPERM ;if (cft->write)
@@ -4351,9 +4357,9 @@ static int cgroup_procs_show(struct seq_static int cgroup_procs_write_permission (struct cgroup *src_cgrp,struct cgroup *dst_cgrp, -struct super_block *sb) +struct super_block *sb, +struct cgroup_namespace *ns) { -struct cgroup_namespace *ns = current->nsproxy->cgroup_ns;struct cgroup *com_cgrp = src_cgrp;struct inode *inode;int ret;
@@ -4389,6 +4395,7 @@ static int cgroup_procs_write_permissionstatic ssize_t cgroup_procs_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off) { +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task;const struct cred *saved_cred;
@@ -4415,7 +4422,8 @@ static ssize_t cgroup_procs_write(struct*/ saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, - of->file->f_path.dentry->d_sb); + of->file->f_path.dentry->d_sb, + ctx->ns);revert_creds (saved_cred);if (ret) goto out_finish;
@@ -4438,6 +4446,7 @@ static void *cgroup_threads_start(structstatic ssize_t cgroup_threads_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off) { +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task;const struct cred *saved_cred;
@@ -4466,7 +4475,8 @@ static ssize_t cgroup_threads_write(stru*/ saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, - of->file->f_path.dentry->d_sb); + of->file->f_path.dentry->d_sb, + ctx->ns);revert_creds (saved_cred);if (ret) goto out_finish;
Greg Kroah-Hartman
maintainerPATCH 260/284 xfrm: policy: match with both mark and mask on user interfaces
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
commit 4f47e8ab6ab796b5380f74866fa5287aca4dcc58 upstream.
In commit ed17b8d377ea ("xfrm: fix a warning in xfrm_policy_insert_list"), it would take 'priority' to make a policy unique, and allow duplicated policies with different 'priority' to be added, which is not expected by userland, as Tobias reported in strongswan.
To fix this duplicated policies issue, and also fix the issue in commit ed17b8d377ea ("xfrm: fix a warning in xfrm_policy_insert_list"), when doing add/del/get/update on user interfaces, this patch is to change to look up a policy with both mark and mask by doing:
mark.v == pol->mark.v && mark.m == pol->mark.m
and leave the check:
(mark & pol->mark.m) == pol->mark.v
for tx/rx path only.
As the userland expects an exact mark and mask match to manage policies.
v1->v2:
- make xfrm_policy_mark_match inline and fix the changelog as Tobias suggested.
--- include/net/xfrm.h | 9 ++++++--- net/key/af_key.c | 4 ++-- net/xfrm/xfrm_policy.c | 24 ++++++++++-------------- net/xfrm/xfrm_user.c | 14 ++++++++------ 4 files changed, 26 insertions(+), 25 deletions(-)
include/net/xfrm.h +6 -3
@@ -1674,13 +1674,16 @@ int xfrm_policy_walk(struct net *net, st void *);void xfrm_policy_walk_done (struct xfrm_policy_walk *walk,struct net *net);int xfrm_policy_insert (int dir,struct xfrm_policy *policy,int excl); -struct xfrm_policy *xfrm_policy_bysel_ctx (struct net *net,u32 mark, +struct xfrm_policy *xfrm_policy_bysel_ctx (struct net *net, +const struct xfrm_mark *mark,u8 type,int dir,struct xfrm_selector *sel,struct xfrm_sec_ctx *ctx,int delete,int *err); -struct xfrm_policy *xfrm_policy_byid (struct net *net,u32 mark,u8 ,int dir, -u32 id,int delete,int *err); +struct xfrm_policy *xfrm_policy_byid (struct net *net, +const struct xfrm_mark *mark, +u8 type,int dir,u32 id,int delete, +int *err);int xfrm_policy_flush (struct net *net,u8 type,bool task_valid);void xfrm_policy_hash_rebuild (struct net *net);u32 xfrm_get_acqseq (void );
net/key/af_key.c +2 -2
@@ -2411,7 +2411,7 @@ static int pfkey_spddelete(struct sock *return err; } - xp =xfrm_policy_bysel_ctx (net,DUMMY_MARK ,XFRM_POLICY_TYPE_MAIN , + xp =xfrm_policy_bysel_ctx (net, &dummy_mark,XFRM_POLICY_TYPE_MAIN , pol->sadb_x_policy_dir -1 , &sel, pol_ctx,1 , &err);security_xfrm_policy_free (pol_ctx);
@@ -2662,7 +2662,7 @@ static int pfkey_spdget(struct sock *sk,return -EINVAL ; delete = (hdr->sadb_msg_type ==SADB_X_SPDDELETE2 ); - xp =xfrm_policy_byid (net,DUMMY_MARK ,XFRM_POLICY_TYPE_MAIN , + xp =xfrm_policy_byid (net, &dummy_mark,XFRM_POLICY_TYPE_MAIN , dir, pol->sadb_x_policy_id, delete, &err);if (xp ==NULL )return -ENOENT ;
net/xfrm/xfrm_policy.c +10 -14
@@ -719,14 +719,10 @@ static void xfrm_policy_requeue(struct xspin_unlock_bh (&pq->hold_queue.lock); } -static bool xfrm_policy_mark_match (struct xfrm_policy *policy, -struct xfrm_policy *pol) +static inline bool xfrm_policy_mark_match (const struct xfrm_mark *mark, +struct xfrm_policy *pol) { -if (policy->mark.v == pol->mark.v && - policy->priority == pol->priority) -return true; - -return false; +return mark->v == pol->mark.v && mark->m == pol->mark.m; }int xfrm_policy_insert (int dir,struct xfrm_policy *policy,int excl)
@@ -744,7 +740,7 @@ int xfrm_policy_insert(int dir, struct xhlist_for_each_entry (pol, chain, bydst) {if (pol->type == policy->type && !selector_cmp (&pol->selector, &policy->selector) && -xfrm_policy_mark_match (policy, pol) && +xfrm_policy_mark_match (&policy->mark, pol) &&xfrm_sec_ctx_match (pol->security, policy->security) && !WARN_ON (delpol)) {if (excl) {
@@ -794,8 +790,8 @@ int xfrm_policy_insert(int dir, struct x }EXPORT_SYMBOL (xfrm_policy_insert); -struct xfrm_policy *xfrm_policy_bysel_ctx (struct net *net,u32 mark,u8 type, -int dir,struct xfrm_selector *sel, +struct xfrm_policy *xfrm_policy_bysel_ctx (struct net *net,const struct xfrm_mark *mark, +u8 type,int dir,struct xfrm_selector *sel,struct xfrm_sec_ctx *ctx,int delete,int *err) {
@@ -808,7 +804,7 @@ struct xfrm_policy *xfrm_policy_bysel_ct ret =NULL ;hlist_for_each_entry (pol, chain, bydst) {if (pol->type == type && - (mark & pol->mark.m) == pol->mark.v && +xfrm_policy_mark_match (mark, pol) && !selector_cmp (sel, &pol->selector) &&xfrm_sec_ctx_match (ctx, pol->security)) {xfrm_pol_hold (pol);
@@ -833,8 +829,8 @@ struct xfrm_policy *xfrm_policy_bysel_ct }EXPORT_SYMBOL (xfrm_policy_bysel_ctx); -struct xfrm_policy *xfrm_policy_byid (struct net *net,u32 mark,u8 type, -int dir,u32 id,int delete,int *err) +struct xfrm_policy *xfrm_policy_byid (struct net *net,const struct xfrm_mark *mark, +u8 type,int dir,u32 id,int delete,int *err) {struct xfrm_policy *pol, *ret;struct hlist_head *chain;
@@ -849,7 +845,7 @@ struct xfrm_policy *xfrm_policy_byid(str ret =NULL ;hlist_for_each_entry (pol, chain, byidx) {if (pol->type == type && pol->index == id && - (mark & pol->mark.m) == pol->mark.v) { +xfrm_policy_mark_match (mark, pol)) {xfrm_pol_hold (pol);if (delete) { *err = security_xfrm_policy_delete(
net/xfrm/xfrm_user.c +8 -6
@@ -1814,7 +1814,6 @@ static int xfrm_get_policy(struct sk_bufstruct km_event c;int delete;struct xfrm_mark m; -u32 mark =xfrm_mark_get (attrs, &m); p =nlmsg_data (nlh); delete = nlh->nlmsg_type ==XFRM_MSG_DELPOLICY ;
@@ -1827,8 +1826,10 @@ static int xfrm_get_policy(struct sk_bufif (err)return err; +xfrm_mark_get (attrs, &m); +if (p->index) - xp =xfrm_policy_byid (net, mark, type, p->dir, p->index, delete, &err); + xp =xfrm_policy_byid (net, &m, type, p->dir, p->index, delete, &err);else {struct nlattr *rt = attrs[XFRMA_SEC_CTX ];struct xfrm_sec_ctx *ctx;
@@ -1845,7 +1846,7 @@ static int xfrm_get_policy(struct sk_bufif (err)return err; } - xp =xfrm_policy_bysel_ctx (net, mark, type, p->dir, &p->sel, + xp =xfrm_policy_bysel_ctx (net, &m, type, p->dir, &p->sel, ctx, delete, &err);security_xfrm_policy_free (ctx); }
@@ -2108,7 +2109,6 @@ static int xfrm_add_pol_expire(struct sku8 type =XFRM_POLICY_TYPE_MAIN ;int err = -ENOENT ;struct xfrm_mark m; -u32 mark =xfrm_mark_get (attrs, &m); err =copy_from_user_policy_type (&type, attrs);if (err)
@@ -2118,8 +2118,10 @@ static int xfrm_add_pol_expire(struct skif (err)return err; +xfrm_mark_get (attrs, &m); +if (p->index) - xp =xfrm_policy_byid (net, mark, type, p->dir, p->index,0 , &err); + xp =xfrm_policy_byid (net, &m, type, p->dir, p->index,0 , &err);else {struct nlattr *rt = attrs[XFRMA_SEC_CTX ];struct xfrm_sec_ctx *ctx;
@@ -2136,7 +2138,7 @@ static int xfrm_add_pol_expire(struct skif (err)return err; } - xp =xfrm_policy_bysel_ctx (net, mark, type, p->dir, + xp =xfrm_policy_bysel_ctx (net, &m, type, p->dir, &p->sel, ctx,0 , &err);security_xfrm_policy_free (ctx); }
Greg Kroah-Hartman
maintainerPATCH 261/284 memory: atmel-ebi: Fix missing of_node_put in atmel_ebi_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 6f296a9665ba5ac68937bf11f96214eb9de81baa ]
The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.
--- drivers/memory/atmel-ebi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/memory/atmel-ebi.c +17 -6
@@ -524,20 +524,27 @@ static int atmel_ebi_probe(struct platform_device *pdev) smc_np =of_parse_phandle (dev->of_node,"atmel,smc" ,0 ); ebi->smc.regmap =syscon_node_to_regmap (smc_np); -if (IS_ERR (ebi->smc.regmap)) -return PTR_ERR (ebi->smc.regmap); +if (IS_ERR (ebi->smc.regmap)) { + ret =PTR_ERR (ebi->smc.regmap); + goto put_node; + } ebi->smc.layout =atmel_hsmc_get_reg_layout (smc_np); -if (IS_ERR (ebi->smc.layout)) -return PTR_ERR (ebi->smc.layout); +if (IS_ERR (ebi->smc.layout)) { + ret =PTR_ERR (ebi->smc.layout); + goto put_node; + } ebi->smc.clk =of_clk_get (smc_np,0 );if (IS_ERR (ebi->smc.clk)) { -if (PTR_ERR (ebi->smc.clk) != -ENOENT ) -return PTR_ERR (ebi->smc.clk); +if (PTR_ERR (ebi->smc.clk) != -ENOENT ) { + ret =PTR_ERR (ebi->smc.clk); + goto put_node; + } ebi->smc.clk =NULL ; } +of_node_put (smc_np); ret =clk_prepare_enable (ebi->smc.clk);if (ret)return ret;
@@ -587,6 +594,10 @@ static int atmel_ebi_probe(struct platform_device *pdev) }return of_platform_populate (np,NULL ,NULL , dev); + +put_node: +of_node_put (smc_np); +return ret; }static __maybe_unused int atmel_ebi_resume (struct device *dev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 262/284 veth: Ensure eth header is in skbs linear part
In reply to Greg Kroah-HartmanFrom: Guillaume Nault <[email protected]>
[ Upstream commit 726e2c5929de841fdcef4e2bf995680688ae1b87 ]
After feeding a decapsulated packet to a veth device with act_mirred, skb_headlen() may be 0. But veth_xmit() calls __dev_forward_skb(), which expects at least ETH_HLEN byte of linear data (as __dev_forward_skb2() calls eth_type_trans(), which pulls ETH_HLEN bytes unconditionally).
Use pskb_may_pull() to ensure veth_xmit() respects this constraint.
kernel BUG at include/linux/skbuff.h:2328!
RIP: 0010:eth_type_trans+0xcf/0x140 Call Trace: <IRQ> __dev_forward_skb2+0xe3/0x160 veth_xmit+0x6e/0x250 [veth] dev_hard_start_xmit+0xc7/0x200 __dev_queue_xmit+0x47f/0x520 ? skb_ensure_writable+0x85/0xa0 ? skb_mpls_pop+0x98/0x1c0 tcf_mirred_act+0x442/0x47e [act_mirred] tcf_action_exec+0x86/0x140 fl_classify+0x1d8/0x1e0 [cls_flower] ? dma_pte_clear_level+0x129/0x1a0 ? dma_pte_clear_level+0x129/0x1a0 ? prb_fill_curr_block+0x2f/0xc0 ? skb_copy_bits+0x11a/0x220 __tcf_classify+0x58/0x110 tcf_classify_ingress+0x6b/0x140 __netif_receive_skb_core.constprop.0+0x47d/0xfd0 ? __iommu_dma_unmap_swiotlb+0x44/0x90 __netif_receive_skb_one_core+0x3d/0xa0 netif_receive_skb+0x116/0x170 be_process_rx+0x22f/0x330 [be2net] be_poll+0x13c/0x370 [be2net] __napi_poll+0x2a/0x170 net_rx_action+0x22f/0x2f0 __do_softirq+0xca/0x2a8 __irq_exit_rcu+0xc1/0xe0 common_interrupt+0x83/0xa0
--- drivers/net/veth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/veth.c +1 -1
@@ -106,7 +106,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)rcu_read_lock (); rcv =rcu_dereference (priv->peer); -if (unlikely (!rcv)) { +if (unlikely (!rcv) || !pskb_may_pull (skb,ETH_HLEN )) {kfree_skb (skb); goto drop; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 263/284 gpiolib: acpi: use correct format characters
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
[ Upstream commit 213d266ebfb1621aab79cfe63388facc520a1381 ]
When compiling with -Wformat, clang emits the following warning:
gpiolib-acpi.c:393:4: warning: format specifies type 'unsigned char' but the argument has type 'int' [-Wformat]
pin);
^~~So warning that '%hhX' is paired with an 'int' is all just completely mindless and wrong. Sadly, I can see a different bogus warning reason why people would want to use '%02hhX'.
Again, the *sane* thing from a human perspective is to use '%02X. But if the compiler doesn't do any range analysis at all, it could decide that "Oh, that print format could need up to 8 bytes of space in the result". Using '%02hhX' would cut that down to two.
And since we use
char ev_name[5];
and currently use "_%c%02hhX" as the format string, even a compiler that doesn't notice that "pin <= 255" test that guards this all will go "OK, that's at most 4 bytes and the final NUL termination, so it's fine".
While a compiler - like gcc - that only sees that the original source of the 'pin' value is a 'unsigned short' array, and then doesn't take the "pin <= 255" into account, will warn like this:
gpiolib-acpi.c: In function 'acpi_gpiochip_request_interrupt':
gpiolib-acpi.c:206:24: warning: '%02X' directive writing between 2 and 4 bytes into a region of size 3 [-Wformat-overflow=]
sprintf(ev_name, "_%c%02X",
^~~~gpiolib-acpi.c:206:20: note: directive argument in the range [0, 65535]
because gcc isn't being very good at that argument range analysis either.
In other words, the original use of 'hhx' was bogus to begin with, and due to *another* compiler warning being bad, and we had that bad code being written back in 2016 to work around _that_ compiler warning (commit e40a3ae1f794: "gpio: acpi: work around false-positive -Wstring-overflow warning").
Sadly, two different bad compiler warnings together does not make for one good one.
It just makes for even more pain.
End result: I think the simplest and cleanest option is simply the proposed change which undoes that '%hhX' change for gcc, and replaces it with just using a slightly bigger stack allocation. It's not like a 5-byte allocation is in any way likely to have saved any actual stack, since all the other variables in that function are 'int' or bigger.
False-positive compiler warnings really do make people write worse code, and that's a problem. But on a scale of bad code, I feel that extending the buffer trivially is better than adding a pointless cast that literally makes no sense.
At least in this case the end result isn't unreadable or buggy. We've had several cases of bad compiler warnings that caused changes that were actually horrendously wrong.
--- drivers/gpio/gpiolib-acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +2 -2
@@ -335,8 +335,8 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares, pin = agpio->pin_table[0 ];if (pin <=255 ) { -char ev_name[5 ]; -sprintf (ev_name,"_%c%02hhX" , +char ev_name[8 ]; +sprintf (ev_name,"_%c%02X" , agpio->triggering ==ACPI_EDGE_SENSITIVE ?'E' :'L' , pin);if (ACPI_SUCCESS (acpi_get_handle (handle, ev_name, &evt_handle)))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 264/284 mlxsw: i2c: Fix initialization error flow
In reply to Greg Kroah-HartmanFrom: Vadim Pasternak <[email protected]>
[ Upstream commit d452088cdfd5a4ad9d96d847d2273fe958d6339b ]
Add mutex_destroy() call in driver initialization error flow.
--- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlxsw/i2c.c +1 -0
@@ -548,6 +548,7 @@ static int mlxsw_i2c_probe(struct i2c_client *client,return 0 ; errout: +mutex_destroy (&mlxsw_i2c->cmd.lock);i2c_set_clientdata (client,NULL );return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 265/284 net: ethernet: stmmac: fix altr_tse_pcs function when using a fixed-link
In reply to Greg Kroah-HartmanFrom: Dinh Nguyen <[email protected]>
[ Upstream commit a6aaa00324240967272b451bfa772547bd576ee6 ]
When using a fixed-link, the altr_tse_pcs driver crashes due to null-pointer dereference as no phy_device is provided to tse_pcs_fix_mac_speed function. Fix this by adding a check for phy_dev before calling the tse_pcs_fix_mac_speed() function.
Also clean up the tse_pcs_fix_mac_speed function a bit. There is no need to check for splitter_base and sgmii_adapter_base because the driver will fail if these 2 variables are not derived from the device tree.
--- drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c | 8 -------- drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h | 4 ++++ drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 13 +++++-------- 3 files changed, 9 insertions(+), 16 deletions(-)
drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c +0 -8
@@ -68,10 +68,6 @@#define TSE_PCS_USE_SGMII_ENA BIT(0)#define TSE_PCS_IF_USE_SGMII 0x03 -#define SGMII_ADAPTER_CTRL_REG 0x00 -#define SGMII_ADAPTER_DISABLE 0x0001 -#define SGMII_ADAPTER_ENABLE 0x0000 -#define AUTONEGO_LINK_TIMER 20static int tse_pcs_reset (void __iomem *base,struct tse_pcs *pcs)
@@ -215,12 +211,8 @@ void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev, unsigned int speed) {void __iomem *tse_pcs_base = pcs->tse_pcs_base; -void __iomem *sgmii_adapter_base = pcs->sgmii_adapter_base;u32 val; -writew (SGMII_ADAPTER_ENABLE , - sgmii_adapter_base +SGMII_ADAPTER_CTRL_REG ); - pcs->autoneg = phy_dev->autoneg;if (phy_dev->autoneg ==AUTONEG_ENABLE ) {
drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h +4 -0
@@ -21,6 +21,10 @@#include <linux/phy.h> #include <linux/timer.h> +#define SGMII_ADAPTER_CTRL_REG 0x00 +#define SGMII_ADAPTER_ENABLE 0x0000 +#define SGMII_ADAPTER_DISABLE 0x0001 +struct tse_pcs {struct device *dev;void __iomem *tse_pcs_base;
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +5 -8
@@ -29,9 +29,6 @@#include "altr_tse_pcs.h" -#define SGMII_ADAPTER_CTRL_REG 0x00 -#define SGMII_ADAPTER_DISABLE 0x0001 -#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII 0x0#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII 0x1#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII 0x2
@@ -65,16 +62,14 @@ static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed) {struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv;void __iomem *splitter_base = dwmac->splitter_base; -void __iomem *tse_pcs_base = dwmac->pcs.tse_pcs_base;void __iomem *sgmii_adapter_base = dwmac->pcs.sgmii_adapter_base;struct device *dev = dwmac->dev;struct net_device *ndev =dev_get_drvdata (dev);struct phy_device *phy_dev = ndev->phydev;u32 val; -if ((tse_pcs_base) && (sgmii_adapter_base)) -writew (SGMII_ADAPTER_DISABLE , - sgmii_adapter_base +SGMII_ADAPTER_CTRL_REG ); +writew (SGMII_ADAPTER_DISABLE , + sgmii_adapter_base +SGMII_ADAPTER_CTRL_REG );if (splitter_base) { val =readl (splitter_base +EMAC_SPLITTER_CTRL_REG );
@@ -96,7 +91,9 @@ static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed)writel (val, splitter_base +EMAC_SPLITTER_CTRL_REG ); } -if (tse_pcs_base && sgmii_adapter_base) +writew (SGMII_ADAPTER_ENABLE , + sgmii_adapter_base +SGMII_ADAPTER_CTRL_REG ); +if (phy_dev)tse_pcs_fix_mac_speed (&dwmac->pcs, phy_dev, speed); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 266/284 nfc: nci: add flush_workqueue to prevent uaf
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
[ Upstream commit ef27324e2cb7bb24542d6cb2571740eefe6b00dc ]
Our detector found a concurrent use-after-free bug when detaching an NCI device. The main reason for this bug is the unexpected scheduling between the used delayed mechanism (timer and workqueue).
The race can be demonstrated below:
Thread-1 Thread-2
| nci_dev_up()
| nci_open_device()
| __nci_request(nci_reset_req)
| nci_send_cmd
| queue_work(cmd_work)
nci_unregister_device() |
nci_close_device() | ...
del_timer_sync(cmd_timer)[1] |
... | Worker
nci_free_device() | nci_cmd_work()
kfree(ndev)[3] | mod_timer(cmd_timer)[2]In short, the cleanup routine thought that the cmd_timer has already been detached by [1] but the mod_timer can re-attach the timer [2], even it is already released [3], resulting in UAF.
This UAF is easy to trigger, crash trace by POC is like below
[ 66.703713] ================================================================== [ 66.703974] BUG: KASAN: use-after-free in enqueue_timer+0x448/0x490 [ 66.703974] Write of size 8 at addr ffff888009fb7058 by task kworker/u4:1/33 [ 66.703974] [ 66.703974] CPU: 1 PID: 33 Comm: kworker/u4:1 Not tainted 5.18.0-rc2 #5 [ 66.703974] Workqueue: nfc2_nci_cmd_wq nci_cmd_work [ 66.703974] Call Trace: [ 66.703974] <TASK> [ 66.703974] dump_stack_lvl+0x57/0x7d [ 66.703974] print_report.cold+0x5e/0x5db [ 66.703974] ? enqueue_timer+0x448/0x490 [ 66.703974] kasan_report+0xbe/0x1c0 [ 66.703974] ? enqueue_timer+0x448/0x490 [ 66.703974] enqueue_timer+0x448/0x490 [ 66.703974] __mod_timer+0x5e6/0xb80 [ 66.703974] ? mark_held_locks+0x9e/0xe0 [ 66.703974] ? try_to_del_timer_sync+0xf0/0xf0 [ 66.703974] ? lockdep_hardirqs_on_prepare+0x17b/0x410 [ 66.703974] ? queue_work_on+0x61/0x80 [ 66.703974] ? lockdep_hardirqs_on+0xbf/0x130 [ 66.703974] process_one_work+0x8bb/0x1510 [ 66.703974] ? lockdep_hardirqs_on_prepare+0x410/0x410 [ 66.703974] ? pwq_dec_nr_in_flight+0x230/0x230 [ 66.703974] ? rwlock_bug.part.0+0x90/0x90 [ 66.703974] ? _raw_spin_lock_irq+0x41/0x50 [ 66.703974] worker_thread+0x575/0x1190 [ 66.703974] ? process_one_work+0x1510/0x1510 [ 66.703974] kthread+0x2a0/0x340 [ 66.703974] ? kthread_complete_and_exit+0x20/0x20 [ 66.703974] ret_from_fork+0x22/0x30 [ 66.703974] </TASK> [ 66.703974] [ 66.703974] Allocated by task 267: [ 66.703974] kasan_save_stack+0x1e/0x40 [ 66.703974] __kasan_kmalloc+0x81/0xa0 [ 66.703974] nci_allocate_device+0xd3/0x390 [ 66.703974] nfcmrvl_nci_register_dev+0x183/0x2c0 [ 66.703974] nfcmrvl_nci_uart_open+0xf2/0x1dd [ 66.703974] nci_uart_tty_ioctl+0x2c3/0x4a0 [ 66.703974] tty_ioctl+0x764/0x1310 [ 66.703974] __x64_sys_ioctl+0x122/0x190 [ 66.703974] do_syscall_64+0x3b/0x90 [ 66.703974] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 66.703974] [ 66.703974] Freed by task 406: [ 66.703974] kasan_save_stack+0x1e/0x40 [ 66.703974] kasan_set_track+0x21/0x30 [ 66.703974] kasan_set_free_info+0x20/0x30 [ 66.703974] __kasan_slab_free+0x108/0x170 [ 66.703974] kfree+0xb0/0x330 [ 66.703974] nfcmrvl_nci_unregister_dev+0x90/0xd0 [ 66.703974] nci_uart_tty_close+0xdf/0x180 [ 66.703974] tty_ldisc_kill+0x73/0x110 [ 66.703974] tty_ldisc_hangup+0x281/0x5b0 [ 66.703974] __tty_hangup.part.0+0x431/0x890 [ 66.703974] tty_release+0x3a8/0xc80 [ 66.703974] __fput+0x1f0/0x8c0 [ 66.703974] task_work_run+0xc9/0x170 [ 66.703974] exit_to_user_mode_prepare+0x194/0x1a0 [ 66.703974] syscall_exit_to_user_mode+0x19/0x50 [ 66.703974] do_syscall_64+0x48/0x90 [ 66.703974] entry_SYSCALL_64_after_hwframe+0x44/0xae
To fix the UAF, this patch adds flush_workqueue() to ensure the nci_cmd_work is finished before the following del_timer_sync. This combination will promise the timer is actually detached.
--- net/nfc/nci/core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/nfc/nci/core.c +4 -0
@@ -560,6 +560,10 @@ static int nci_close_device(struct nci_dev *ndev)mutex_lock (&ndev->req_lock);if (!test_and_clear_bit (NCI_UP , &ndev->flags)) { +/* Need to flush the cmd wq in case +* there is a queued/running cmd_work +*/ +flush_workqueue (ndev->cmd_wq);del_timer_sync (&ndev->cmd_timer);del_timer_sync (&ndev->data_timer);mutex_unlock (&ndev->req_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 267/284 cifs: potential buffer overflow in handling symlinks
In reply to Greg Kroah-HartmanFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 64c4a37ac04eeb43c42d272f6e6c8c12bfcf4304 ]
Smatch printed a warning:
arch/x86/crypto/poly1305_glue.c:198 poly1305_update_arch() error: __memcpy() 'dctx->buf' too small (16 vs u32max)
It's caused because Smatch marks 'link_len' as untrusted since it comes from sscanf(). Add a check to ensure that 'link_len' is not larger than the size of the 'link_str' buffer.
--- fs/cifs/link.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/link.c +3 -0
@@ -97,6 +97,9 @@ parse_mf_symlink(const u8 *buf, unsigned int buf_len, unsigned int *_link_len,if (rc !=1 )return -EINVAL ; +if (link_len >CIFS_MF_SYMLINK_LINK_MAXLEN ) +return -EINVAL ; + rc =symlink_hash (link_len, link_str, md5_hash);if (rc) {cifs_dbg (FYI ,"%s: MD5 hash failure: %d\n" , __func__, rc);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 268/284 drm/amd: Add USBC connector ID
In reply to Greg Kroah-HartmanFrom: Aurabindo Pillai <[email protected]>
[ Upstream commit c5c948aa894a831f96fccd025e47186b1ee41615 ]
[Why&How] Add a dedicated AMDGPU specific ID for use with newer ASICs that support USB-C output
--- drivers/gpu/drm/amd/amdgpu/ObjectID.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/ObjectID.h +1 -0
@@ -119,6 +119,7 @@#define CONNECTOR_OBJECT_ID_eDP 0x14#define CONNECTOR_OBJECT_ID_MXM 0x15#define CONNECTOR_OBJECT_ID_LVDS_eDP 0x16 +#define CONNECTOR_OBJECT_ID_USBC 0x17/* deleted */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 269/284 drm/amdkfd: Check for potential null return of kmalloc_array()
In reply to Greg Kroah-HartmanFrom: QintaoShen <[email protected]>
[ Upstream commit ebbb7bb9e80305820dc2328a371c1b35679f2667 ]
As the kmalloc_array() may return null, the 'event_waiters[i].wait' would lead to null-pointer dereference. Therefore, it is better to check the return value of kmalloc_array() to avoid this confusion.
--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +2 -0
@@ -607,6 +607,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events) event_waiters =kmalloc_array (num_events,sizeof (struct kfd_event_waiter ),GFP_KERNEL ); +if (!event_waiters) +return NULL ;for (i =0 ; (event_waiters) && (i < num_events) ; i++) {INIT_LIST_HEAD (&event_waiters[i].waiters);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 270/284 Drivers: hv: vmbus: Prevent load re-ordering when reading ring buffer
In reply to Greg Kroah-HartmanFrom: Michael Kelley <[email protected]>
[ Upstream commit b6cae15b5710c8097aad26a2e5e752c323ee5348 ]
When reading a packet from a host-to-guest ring buffer, there is no memory barrier between reading the write index (to see if there is a packet to read) and reading the contents of the packet. The Hyper-V host uses store-release when updating the write index to ensure that writes of the packet data are completed first. On the guest side, the processor can reorder and read the packet data before the write index, and sometimes get stale packet data. Getting such stale packet data has been observed in a reproducible case in a VM on ARM64.
Fix this by using virt_load_acquire() to read the write index, ensuring that reads of the packet data cannot be reordered before it. Preventing such reordering is logically correct, and with this change, getting stale data can no longer be reproduced.
--- drivers/hv/ring_buffer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/hv/ring_buffer.c +10 -1
@@ -340,7 +340,16 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,static u32 hv_pkt_iter_avail (const struct hv_ring_buffer_info *rbi) {u32 priv_read_loc = rbi->priv_read_index; -u32 write_loc =READ_ONCE (rbi->ring_buffer->write_index); +u32 write_loc; + +/* +* The Hyper-V host writes the packet data, then uses +* store_release() to update the write_index. Use load_acquire() +* here to prevent loads of the packet data from being re-ordered +* before the read of the write_index and potentially getting +* stale data. +*/ + write_loc =virt_load_acquire (&rbi->ring_buffer->write_index);if (write_loc >= priv_read_loc)return write_loc - priv_read_loc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 271/284 scsi: target: tcmu: Fix possible page UAF
In reply to Greg Kroah-HartmanFrom: Xiaoguang Wang <[email protected]>
[ Upstream commit a6968f7a367f128d120447360734344d5a3d5336 ]
tcmu_try_get_data_page() looks up pages under cmdr_lock, but it does not take refcount properly and just returns page pointer. When tcmu_try_get_data_page() returns, the returned page may have been freed by tcmu_blocks_release().
We need to get_page() under cmdr_lock to avoid concurrent tcmu_blocks_release().
--- drivers/target/target_core_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/target/target_core_user.c +2 -1
@@ -1165,6 +1165,7 @@ static struct page *tcmu_try_get_block_page(struct tcmu_dev *udev, uint32_t dbi)mutex_lock (&udev->cmdr_lock); page =tcmu_get_block_page (udev, dbi);if (likely (page)) { +get_page (page);mutex_unlock (&udev->cmdr_lock);return page; }
@@ -1233,6 +1234,7 @@ static int tcmu_vma_fault(struct vm_fault *vmf)/* For the vmalloc()ed cmd area pages */ addr = (void *)(unsigned long )info->mem[mi].addr + offset; page =vmalloc_to_page (addr); +get_page (page); }else {uint32_t dbi;
@@ -1243,7 +1245,6 @@ static int tcmu_vma_fault(struct vm_fault *vmf)return VM_FAULT_NOPAGE ; } -get_page (page); vmf->page = page;return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 272/284 scsi: ibmvscsis: Increase INITIAL_SRP_LIMIT to 1024
In reply to Greg Kroah-HartmanFrom: Tyrel Datwyler <[email protected]>
[ Upstream commit 0bade8e53279157c7cc9dd95d573b7e82223d78a ]
The adapter request_limit is hardcoded to be INITIAL_SRP_LIMIT which is currently an arbitrary value of 800. Increase this value to 1024 which better matches the characteristics of the typical IBMi Initiator that supports 32 LUNs and a queue depth of 32.
This change also has the secondary benefit of being a power of two as required by the kfifo API. Since, Commit ab9bb6318b09 ("Partially revert "kfifo: fix kfifo_alloc() and kfifo_init()"") the size of IU pool for each target has been rounded down to 512 when attempting to kfifo_init() those pools with the current request_limit size of 800.
--- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +1 -1
@@ -44,7 +44,7 @@#define IBMVSCSIS_VERSION "v0.2" -#define INITIAL_SRP_LIMIT 800 +#define INITIAL_SRP_LIMIT 1024#define DEFAULT_MAX_SECTORS 256#define MAX_TXU 1024 * 1024
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 273/284 net: micrel: fix KS8851_MLL Kconfig
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit c3efcedd272aa6dd5929e20cf902a52ddaa1197a ]
KS8851_MLL selects MICREL_PHY, which depends on PTP_1588_CLOCK_OPTIONAL, so make KS8851_MLL also depend on PTP_1588_CLOCK_OPTIONAL since 'select' does not follow any dependency chains.
Fixes kconfig warning and build errors:
WARNING: unmet direct dependencies detected for MICREL_PHY
Depends on [m]: NETDEVICES [=y] && PHYLIB [=y] && PTP_1588_CLOCK_OPTIONAL [=m] Selected by [y]:
- KS8851_MLL [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_MICREL [=y] && HAS_IOMEM [=y]
ld: drivers/net/phy/micrel.o: in function `lan8814_ts_info':
micrel.c:(.text+0xb35): undefined reference to `ptp_clock_index'
ld: drivers/net/phy/micrel.o: in function `lan8814_probe':
micrel.c:(.text+0x2586): undefined reference to `ptp_clock_register'
--- drivers/net/ethernet/micrel/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/micrel/Kconfig +1 -0
@@ -45,6 +45,7 @@ config KS8851 config KS8851_MLL tristate "Micrel KS8851 MLL" depends on HAS_IOMEM + depends on PTP_1588_CLOCK_OPTIONAL select MII ---help--- This platform driver is for Micrel KS8851 Address/data bus
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 274/284 ata: libata-core: Disable READ LOG DMA EXT for Samsung 840 EVOs
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
[ Upstream commit 5399752299396a3c9df6617f4b3c907d7aa4ded8 ]
Samsung' 840 EVO with the latest firmware (EXT0DB6Q) locks up with the a message: "READ LOG DMA EXT failed, trying PIO" during boot.
Initially this was discovered because it caused a crash with the sata_dwc_460ex controller on a WD MyBook Live DUO.
The reporter "Tice Rex" which has the unique opportunity that he has two Samsung 840 EVO SSD! One with the older firmware "EXT0BB0Q" which booted fine and didn't expose "READ LOG DMA EXT". But the newer/latest firmware "EXT0DB6Q" caused the headaches.
--- drivers/ata/libata-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/ata/libata-core.c +3 -0
@@ -4588,6 +4588,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { ATA_HORKAGE_ZERO_AFTER_TRIM, }, {"Crucial_CT*MX100*" ,"MU01" ,ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, + { "Samsung SSD 840 EVO*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | +ATA_HORKAGE_NO_DMA_LOG | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, { "Samsung SSD 840*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 275/284 gpu: ipu-v3: Fix dev_dbg frequency output
In reply to Greg Kroah-HartmanFrom: Leo Ruan <[email protected]>
[ Upstream commit 070a88fd4a03f921b73a2059e97d55faaa447dab ]
This commit corrects the printing of the IPU clock error percentage if it is between -0.1% to -0.9%. For example, if the pixel clock requested is 27.2 MHz but only 27.0 MHz can be achieved the deviation is -0.8%. But the fixed point math had a flaw and calculated error of 0.2%.
Before:
Clocks: IPU 270000000Hz DI 24716667Hz Needed 27200000Hz IPU clock can give 27000000 with divider 10, error 0.2% Want 27200000Hz IPU 270000000Hz DI 24716667Hz using IPU, 27000000Hz
After:
Clocks: IPU 270000000Hz DI 24716667Hz Needed 27200000Hz IPU clock can give 27000000 with divider 10, error -0.8% Want 27200000Hz IPU 270000000Hz DI 24716667Hz using IPU, 27000000Hz
--- drivers/gpu/ipu-v3/ipu-di.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/ipu-v3/ipu-di.c +3 -2
@@ -460,8 +460,9 @@ static void ipu_di_config_clock(struct ipu_di *di, error = rate / (sig->mode.pixelclock /1000 ); -dev_dbg (di->ipu->dev," IPU clock can give %lu with divider %u, error %d.%u%%\n" , - rate, div, (signed )(error -1000 ) /10 , error %10 ); +dev_dbg (di->ipu->dev," IPU clock can give %lu with divider %u, error %c%d.%d%%\n" , + rate, div, error <1000 ?'-' :'+' , +abs (error -1000 ) /10 ,abs (error -1000 ) %10 );/* Allow a 1% error */ if (error <1010 && error >=990 ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 276/284 scsi: mvsas: Add PCI ID of RocketRaid 2640
In reply to Greg Kroah-HartmanFrom: Alexey Galakhov <[email protected]>
[ Upstream commit 5f2bce1e222028dc1c15f130109a17aa654ae6e8 ]
The HighPoint RocketRaid 2640 is a low-cost SAS controller based on Marvell chip. The chip in question was already supported by the kernel, just the PCI ID of this particular board was missing.
--- drivers/scsi/mvsas/mv_init.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/mvsas/mv_init.c +1 -0
@@ -678,6 +678,7 @@ static struct pci_device_id mvs_pci_table[] = { { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1300), chip_1300 }, { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1320), chip_1320 }, { PCI_VDEVICE(ADAPTEC2, 0x0450), chip_6440 }, + { PCI_VDEVICE(TTI, 0x2640), chip_6440 }, { PCI_VDEVICE(TTI, 0x2710), chip_9480 }, { PCI_VDEVICE(TTI, 0x2720), chip_9480 }, { PCI_VDEVICE(TTI, 0x2721), chip_9480 },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 277/284 drivers: net: slip: fix NPD bug in sl_tx_timeout()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit ec4eb8a86ade4d22633e1da2a7d85a846b7d1798 ]
When a slip driver is detaching, the slip_close() will act to cleanup necessary resources and sl->tty is set to NULL in slip_close(). Meanwhile, the packet we transmit is blocked, sl_tx_timeout() will be called. Although slip_close() and sl_tx_timeout() use sl->lock to synchronize, we don`t judge whether sl->tty equals to NULL in sl_tx_timeout() and the null pointer dereference bug will happen.
(Thread 1) | (Thread 2)
| slip_close()
| spin_lock_bh(&sl->lock)
| ...
... | sl->tty = NULL //(1)
sl_tx_timeout() | spin_unlock_bh(&sl->lock)
spin_lock(&sl->lock); |
... | ...
tty_chars_in_buffer(sl->tty)|
if (tty->ops->..) //(2) |
... | synchronize_rcu()We set NULL to sl->tty in position (1) and dereference sl->tty in position (2).
This patch adds check in sl_tx_timeout(). If sl->tty equals to NULL, sl_tx_timeout() will goto out.
--- drivers/net/slip/slip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/slip/slip.c +1 -1
@@ -471,7 +471,7 @@ static void sl_tx_timeout(struct net_device *dev)spin_lock (&sl->lock);if (netif_queue_stopped (dev)) { -if (!netif_running (dev)) +if (!netif_running (dev) || !sl->tty) goto out;/* May be we must check transmitter timeout here ?
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 278/284 mm, page_alloc: fix build_zonerefs_node()
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit e553f62f10d93551eb883eca227ac54d1a4fad84 upstream.
Since commit 6aa303defb74 ("mm, vmscan: only allocate and reclaim from zones with pages managed by the buddy allocator") only zones with free memory are included in a built zonelist. This is problematic when e.g. all memory of a zone has been ballooned out when zonelists are being rebuilt.
The decision whether to rebuild the zonelists when onlining new memory is done based on populated_zone() returning 0 for the zone the memory will be added to. The new zone is added to the zonelists only, if it has free memory pages (managed_zone() returns a non-zero value) after the memory has been onlined. This implies, that onlining memory will always free the added pages to the allocator immediately, but this is not true in all cases: when e.g. running as a Xen guest the onlined new memory will be added only to the ballooned memory list, it will be freed only when the guest is being ballooned up afterwards.
Another problem with using managed_zone() for the decision whether a zone is being added to the zonelists is, that a zone with all memory used will in fact be removed from all zonelists in case the zonelists happen to be rebuilt.
Use populated_zone() when building a zonelist as it has been done before that commit.
There was a report that QubesOS (based on Xen) is hitting this problem. Xen has switched to use the zone device functionality in kernel 5.9 and QubesOS wants to use memory hotplugging for guests in order to be able to start a guest with minimal memory and expand it as needed. This was the report leading to the patch.
--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
@@ -4879,7 +4879,7 @@ static int build_zonerefs_node(pg_data_t do { zone_type--; zone = pgdat->node_zones + zone_type; - if (managed_zone(zone)) { + if (populated_zone(zone)) { zoneref_set_zone(zone, &zonerefs[nr_zones++]); check_highest_zone(zone_type); }
Greg Kroah-Hartman
maintainerPATCH 279/284 mm: kmemleak: take a full lowmem check in kmemleak_*_phys()
In reply to Greg Kroah-HartmanFrom: Patrick Wang <[email protected]>
commit 23c2d497de21f25898fbea70aeb292ab8acc8c94 upstream.
The kmemleak_*_phys() apis do not check the address for lowmem's min boundary, while the caller may pass an address below lowmem, which will trigger an oops:
# echo scan > /sys/kernel/debug/kmemleak
Unable to handle kernel paging request at virtual address ff5fffffffe00000
Oops [#1]
Modules linked in:
CPU: 2 PID: 134 Comm: bash Not tainted 5.18.0-rc1-next-20220407 #33
Hardware name: riscv-virtio,qemu (DT)
epc : scan_block+0x74/0x15c
ra : scan_block+0x72/0x15c
epc : ffffffff801e5806 ra : ffffffff801e5804 sp : ff200000104abc30
gp : ffffffff815cd4e8 tp : ff60000004cfa340 t0 : 0000000000000200
t1 : 00aaaaaac23954cc t2 : 00000000000003ff s0 : ff200000104abc90
s1 : ffffffff81b0ff28 a0 : 0000000000000000 a1 : ff5fffffffe01000
a2 : ffffffff81b0ff28 a3 : 0000000000000002 a4 : 0000000000000001
a5 : 0000000000000000 a6 : ff200000104abd7c a7 : 0000000000000005
s2 : ff5fffffffe00ff9 s3 : ffffffff815cd998 s4 : ffffffff815d0e90
s5 : ffffffff81b0ff28 s6 : 0000000000000020 s7 : ffffffff815d0eb0
s8 : ffffffffffffffff s9 : ff5fffffffe00000 s10: ff5fffffffe01000
s11: 0000000000000022 t3 : 00ffffffaa17db4c t4 : 000000000000000f
t5 : 0000000000000001 t6 : 0000000000000000
status: 0000000000000100 badaddr: ff5fffffffe00000 cause: 000000000000000d
scan_gray_list+0x12e/0x1a6
kmemleak_scan+0x2aa/0x57e
kmemleak_write+0x32a/0x40c
full_proxy_write+0x56/0x82
vfs_write+0xa6/0x2a6
ksys_write+0x6c/0xe2
sys_write+0x22/0x2a
ret_from_syscall+0x0/0x2The callers may not quite know the actual address they pass(e.g. from devicetree). So the kmemleak_*_phys() apis should guarantee the address they finally use is in lowmem range, so check the address for lowmem's min boundary.
--- mm/kmemleak.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/kmemleak.c +4 -4
@@ -1192,7 +1192,7 @@ EXPORT_SYMBOL(kmemleak_no_scan);void __ref kmemleak_alloc_phys (phys_addr_t phys,size_t size,int min_count,gfp_t gfp) { -if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn) +if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn)kmemleak_alloc (__va (phys), size, min_count, gfp); }EXPORT_SYMBOL (kmemleak_alloc_phys);
@@ -1203,7 +1203,7 @@ EXPORT_SYMBOL(kmemleak_alloc_phys);*/ void __ref kmemleak_free_part_phys (phys_addr_t phys,size_t size) { -if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn) +if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn)kmemleak_free_part (__va (phys), size); }EXPORT_SYMBOL (kmemleak_free_part_phys);
@@ -1214,7 +1214,7 @@ EXPORT_SYMBOL(kmemleak_free_part_phys);*/ void __ref kmemleak_not_leak_phys (phys_addr_t phys) { -if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn) +if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn)kmemleak_not_leak (__va (phys)); }EXPORT_SYMBOL (kmemleak_not_leak_phys);
@@ -1225,7 +1225,7 @@ EXPORT_SYMBOL(kmemleak_not_leak_phys);*/ void __ref kmemleak_ignore_phys (phys_addr_t phys) { -if (!IS_ENABLED (CONFIG_HIGHMEM ) ||PHYS_PFN (phys) < max_low_pfn) +if (PHYS_PFN (phys) >= min_low_pfn &&PHYS_PFN (phys) < max_low_pfn)kmemleak_ignore (__va (phys)); }EXPORT_SYMBOL (kmemleak_ignore_phys);
Greg Kroah-Hartman
maintainerPATCH 280/284 gcc-plugins: latent_entropy: use /dev/urandom
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit c40160f2998c897231f8454bf797558d30a20375 upstream.
While the latent entropy plugin mostly doesn't derive entropy from get_random_const() for measuring the call graph, when __latent_entropy is applied to a constant, then it's initialized statically to output from get_random_const(). In that case, this data is derived from a 64-bit seed, which means a buffer of 512 bits doesn't really have that amount of compile-time entropy.
This patch fixes that shortcoming by just buffering chunks of /dev/urandom output and doling it out as requested.
At the same time, it's important that we don't break the use of -frandom-seed, for people who want the runtime benefits of the latent entropy plugin, while still having compile-time determinism. In that case, we detect whether gcc's set_random_seed() has been called by making a call to get_random_seed(noinit=true) in the plugin init function, which is called after set_random_seed() is called but before anything that calls get_random_seed(noinit=false), and seeing if it's zero or not. If it's not zero, we're in deterministic mode, and so we just generate numbers with a basic xorshift prng.
Note that we don't detect if -frandom-seed is being used using the documented local_tick variable, because it's assigned via:
local_tick = (unsigned) tv.tv_sec * 1000 + tv.tv_usec / 1000;
which may well overflow and become -1 on its own, and so isn't
reliable: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105171
[kees: The 256 byte rnd_buf size was chosen based on average (250),
median (64), and std deviation (575) bytes of used entropy for a defconfig x86_64 build]
--- scripts/gcc-plugins/latent_entropy_plugin.c | 44 +++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-)
scripts/gcc-plugins/latent_entropy_plugin.c +27 -17
@@ -86,25 +86,31 @@ static struct plugin_info latent_entropy .help = "disable\tturn off latent entropy instrumentation\n", }; -static unsigned HOST_WIDE_INT seed; -/* -* get_random_seed() (this is a GCC function) generates the seed. -* This is a simple random generator without any cryptographic security because -* the entropy doesn't come from here. -*/ +static unsigned HOST_WIDE_INT deterministic_seed; +static unsigned HOST_WIDE_INT rnd_buf[32 ]; +static size_t rnd_idx =ARRAY_SIZE (rnd_buf); +static int urandom_fd =-1 ; +static unsigned HOST_WIDE_INT get_random_const (void ) { -unsigned int i; -unsigned HOST_WIDE_INT ret =0 ; - -for (i =0 ; i <8 *sizeof (ret); i++) { - ret = (ret <<1 ) | (seed &1 ); - seed >>=1 ; -if (ret &1 ) - seed ^=0xD800000000000000ULL ; +if (deterministic_seed) { +unsigned HOST_WIDE_INT w = deterministic_seed; + w ^= w <<13 ; + w ^= w >>7 ; + w ^= w <<17 ; + deterministic_seed = w; +return deterministic_seed; } -return ret; +if (urandom_fd <0 ) { + urandom_fd =open ("/dev/urandom" ,O_RDONLY ); +gcc_assert (urandom_fd >=0 ); + } +if (rnd_idx >=ARRAY_SIZE (rnd_buf)) { +gcc_assert (read (urandom_fd, rnd_buf,sizeof (rnd_buf)) ==sizeof (rnd_buf)); + rnd_idx =0 ; + } +return rnd_buf[rnd_idx++]; }static tree tree_get_random_const (tree type)
@@ -549,8 +555,6 @@ static void latent_entropy_start_unit(votree type, id;int quals; - seed =get_random_seed (false); -if (in_lto_p)return ;
@@ -585,6 +589,12 @@ __visible int plugin_init(struct plugin_const struct plugin_argument *const argv = plugin_info->argv;int i; +/* +* Call get_random_seed() with noinit=true, so that this returns +* 0 in the case where no seed has been passed via -frandom-seed. +*/ + deterministic_seed =get_random_seed (true); +static const struct ggc_root_tab gt_ggc_r_gt_latent_entropy[] = { { .base = &latent_entropy_decl,
Greg Kroah-Hartman
maintainerPATCH 281/284 ALSA: pcm: Test for "silence" field in struct "pcm_format_data"
In reply to Greg Kroah-HartmanFrom: Fabio M. De Francesco <[email protected]>
commit 2f7a26abb8241a0208c68d22815aa247c5ddacab upstream.
Syzbot reports "KASAN: null-ptr-deref Write in
snd_pcm_format_set_silence".[1]
It is due to missing validation of the "silence" field of struct "pcm_format_data" in "pcm_formats" array.
Add a test for valid "pat" and, if it is not so, return -EINVAL.
[1] https://lore.kernel.org/lkml/[email protected]/
--- sound/core/pcm_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/pcm_misc.c +1 -1
@@ -406,7 +406,7 @@ int snd_pcm_format_set_silence(snd_pcm_freturn 0 ; width = pcm_formats[(INT )format].phys;/* physical width */ pat = pcm_formats[(INT )format].silence; -if (! width) +if (!width || !pat)return -EINVAL ;/* signed or 1 byte data */ if (pcm_formats[(INT )format].signd ==1 || width <=8 ) {
Greg Kroah-Hartman
maintainerPATCH 282/284 ARM: davinci: da850-evm: Avoid NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 83a1cde5c74bfb44b49cb2a940d044bb2380f4ea upstream.
With newer versions of GCC, there is a panic in da850_evm_config_emac() when booting multi_v5_defconfig in QEMU under the palmetto-bmc machine:
Unable to handle kernel NULL pointer dereference at virtual address 00000020 pgd = (ptrval) [00000020] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 5.15.0 #1 Hardware name: Generic DT based system PC is at da850_evm_config_emac+0x1c/0x120 LR is at do_one_initcall+0x50/0x1e0
The emac_pdata pointer in soc_info is NULL because davinci_soc_info only gets populated on davinci machines but da850_evm_config_emac() is called on all machines via device_initcall().
Move the rmii_en assignment below the machine check so that it is only dereferenced when running on a supported SoC.
--- arch/arm/mach-davinci/board-da850-evm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-davinci/board-da850-evm.c +3 -1
@@ -1035,11 +1035,13 @@ static int __init da850_evm_config_emac(int ret;u32 val;struct davinci_soc_info *soc_info = &davinci_soc_info; -u8 rmii_en = soc_info->emac_pdata->rmii_en; +u8 rmii_en;if (!machine_is_davinci_da850_evm ())return 0 ; + rmii_en = soc_info->emac_pdata->rmii_en; + cfg_chip3_base =DA8XX_SYSCFG0_VIRT (DA8XX_CFGCHIP3_REG ); val =__raw_readl (cfg_chip3_base);
Greg Kroah-Hartman
maintainerPATCH 283/284 smp: Fix offline cpu check in flush_smp_call_function_queue()
In reply to Greg Kroah-HartmanFrom: Nadav Amit <[email protected]>
commit 9e949a3886356fe9112c6f6f34a6e23d1d35407f upstream.
The check in flush_smp_call_function_queue() for callbacks that are sent to offline CPUs currently checks whether the queue is empty.
However, flush_smp_call_function_queue() has just deleted all the callbacks from the queue and moved all the entries into a local list. This checks would only be positive if some callbacks were added in the short time after llist_del_all() was called. This does not seem to be the intention of this check.
Change the check to look at the local list to which the entries were moved instead of the queue from which all the callbacks were just removed.
--- kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smp.c +1 -1
@@ -221,7 +221,7 @@ static void flush_smp_call_function_queu/* There shouldn't be any pending callbacks on an offline CPU. */ if (unlikely (warn_cpu_offline && !cpu_online (smp_processor_id ()) && - !warned && !llist_empty (head))) { + !warned && entry !=NULL )) { warned = true;WARN (1 ,"IPI on offline CPU %d\n" ,smp_processor_id ());
Greg Kroah-Hartman
maintainerPATCH 284/284 i2c: pasemi: Wait for write xfers to finish
In reply to Greg Kroah-HartmanFrom: Martin Povišer <[email protected]>
commit bd8963e602c77adc76dbbbfc3417c3cf14fed76b upstream.
Wait for completion of write transfers before returning from the driver. At first sight it may seem advantageous to leave write transfers queued for the controller to carry out on its own time, but there's a couple of issues with it:
* Driver doesn't check for FIFO space.
* The queued writes can complete while the driver is in its I2C read transfer path which means it will get confused by the raising of XEN (the 'transaction ended' signal). This can cause a spurious ENODATA error due to premature reading of the MRXFIFO register.
Adding the wait fixes some unreliability issues with the driver. There's some efficiency cost to it (especially with pasemi_smb_waitready doing its polling), but that will be alleviated once the driver receives interrupt support.
--- drivers/i2c/busses/i2c-pasemi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/i2c/busses/i2c-pasemi.c +6 -0
@@ -145,6 +145,12 @@ static int pasemi_i2c_xfer_msg(struct i2TXFIFO_WR (smbus, msg->buf[msg->len-1 ] | (stop ?MTXFIFO_STOP :0 )); + +if (stop) { + err =pasemi_smb_waitready (smbus); +if (err) + goto reset_out; + } }return 0 ;
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.276 release. There are 284 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 Wed, 20 Apr 2022 12:11:14 +0000. Anything received after that time might be too late.
Build results:
total: 168 pass: 168 fail: 0 Qemu test results: total: 424 pass: 424 fail: 0
Guenter
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.276 release. There are 284 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 Wed, 20 Apr 2022 12:11:14 +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.276-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.
## Build
* kernel: 4.14.276-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-4.14.y
* git commit: e419aef383a11eecb0ea07a61430afa74c724e9b
* git describe: v4.14.275-285-ge419aef383a1
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.275-285-ge419aef383a1
## Test Regressions (compared to v4.14.275-264-g7bdda4a2902a) No test regressions found.
## Metric Regressions (compared to v4.14.275-264-g7bdda4a2902a) No metric regressions found.
## Test Fixes (compared to v4.14.275-264-g7bdda4a2902a) No test fixes found.
## Metric Fixes (compared to v4.14.275-264-g7bdda4a2902a) No metric fixes found.
## Test result summary
total: 80663, pass: 64544, fail: 876, skip: 12943, xfail: 2300
## Build Summary
* arm: 280 total, 270 passed, 10 failed
* arm64: 35 total, 35 passed, 0 failed
* i386: 18 total, 18 passed, 0 failed
* mips: 22 total, 22 passed, 0 failed
* powerpc: 60 total, 16 passed, 44 failed
* sparc: 12 total, 12 passed, 0 failed
* x86_64: 34 total, 34 passed, 0 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-firmware
* kselftest-fpu
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-net
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-vm
* kselftest-x86
* kselftest-zram
* 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-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-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
* ltp-tracing-tests
* network-basic-tests
* packetdrill
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.276 release. There are 284 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 Wed, 20 Apr 2022 12:11:14 +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.276-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 passing for Tegra ...
Test results for stable-v4.14:
8 builds: 8 pass, 0 fail
16 boots: 16 pass, 0 fail
32 tests: 32 pass, 0 failLinux version: 4.14.276-rc1-ge419aef383a1
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Jon