5.15.190-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 116/644 selftests: Fix errno checking in syscall_user_dispatch test
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Vyukov <[email protected]>
[ Upstream commit b89732c8c8357487185f260a723a060b3476144e ]
Successful syscalls don't change errno, so checking errno is wrong to ensure that a syscall has failed. For example for the following sequence:
prctl(PR_SET_SYSCALL_USER_DISPATCH, op, 0x0, 0xff, 0); EXPECT_EQ(EINVAL, errno); prctl(PR_SET_SYSCALL_USER_DISPATCH, op, 0x0, 0x0, &sel); EXPECT_EQ(EINVAL, errno);
only the first syscall may fail and set errno, but the second may succeed and keep errno intact, and the check will falsely pass.
Or if errno happened to be EINVAL before, even the first check may falsely pass.
Also use EXPECT/ASSERT consistently. Currently there is an inconsistent mix without obvious reasons for usage of one or another.
--- .../syscall_user_dispatch/sud_test.c | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-)
tools/testing/selftests/syscall_user_dispatch/sud_test.c +25 -25
@@ -79,6 +79,21 @@ TEST_SIGNAL(dispatch_trigger_sigsys, SIGSYS) } } +static void prctl_valid (struct __test_metadata *_metadata, +unsigned long op,unsigned long off, +unsigned long size,void *sel) +{ +EXPECT_EQ (0 ,prctl (PR_SET_SYSCALL_USER_DISPATCH , op, off, size, sel)); +} + +static void prctl_invalid (struct __test_metadata *_metadata, +unsigned long op,unsigned long off, +unsigned long size,void *sel,int err) +{ +EXPECT_EQ (-1 ,prctl (PR_SET_SYSCALL_USER_DISPATCH , op, off, size, sel)); +EXPECT_EQ (err, errno); +} +TEST (bad_prctl_param) {char sel =SYSCALL_DISPATCH_FILTER_ALLOW ;
@@ -86,57 +101,42 @@ TEST(bad_prctl_param)/* Invalid op */ op =-1 ; -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,0 ,0 , &sel); -ASSERT_EQ (EINVAL , errno); +prctl_invalid (_metadata, op,0 ,0 , &sel,EINVAL );/* PR_SYS_DISPATCH_OFF */ op =PR_SYS_DISPATCH_OFF ;/* offset != 0 */ -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,0x1 ,0x0 ,0 ); -EXPECT_EQ (EINVAL , errno); +prctl_invalid (_metadata, op,0x1 ,0x0 ,0 ,EINVAL );/* len != 0 */ -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,0x0 ,0xff ,0 ); -EXPECT_EQ (EINVAL , errno); +prctl_invalid (_metadata, op,0x0 ,0xff ,0 ,EINVAL );/* sel != NULL */ -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,0x0 ,0x0 , &sel); -EXPECT_EQ (EINVAL , errno); +prctl_invalid (_metadata, op,0x0 ,0x0 , &sel,EINVAL );/* Valid parameter */ - errno =0 ; -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,0x0 ,0x0 ,0x0 ); -EXPECT_EQ (0 , errno); +prctl_valid (_metadata, op,0x0 ,0x0 ,0x0 );/* PR_SYS_DISPATCH_ON */ op =PR_SYS_DISPATCH_ON ;/* Dispatcher region is bad (offset > 0 && len == 0) */ -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,0x1 ,0x0 , &sel); -EXPECT_EQ (EINVAL , errno); -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,-1L ,0x0 , &sel); -EXPECT_EQ (EINVAL , errno); +prctl_invalid (_metadata, op,0x1 ,0x0 , &sel,EINVAL ); +prctl_invalid (_metadata, op,-1L ,0x0 , &sel,EINVAL );/* Invalid selector */ -prctl (PR_SET_SYSCALL_USER_DISPATCH , op,0x0 ,0x1 , (void *)-1 ); -ASSERT_EQ (EFAULT , errno); +prctl_invalid (_metadata, op,0x0 ,0x1 , (void *)-1 ,EFAULT );/* * Dispatcher range overflows unsigned long */ -prctl (PR_SET_SYSCALL_USER_DISPATCH ,PR_SYS_DISPATCH_ON ,1 ,-1L , &sel); - ASSERT_EQ(EINVAL, errno) { -TH_LOG ("Should reject bad syscall range" ); - } +prctl_invalid (_metadata,PR_SYS_DISPATCH_ON ,1 ,-1L , &sel,EINVAL );/* * Allowed range overflows usigned long */ -prctl (PR_SET_SYSCALL_USER_DISPATCH ,PR_SYS_DISPATCH_ON ,-1L ,0x1 , &sel); - ASSERT_EQ(EINVAL, errno) { -TH_LOG ("Should reject bad syscall range" ); - } +prctl_invalid (_metadata,PR_SYS_DISPATCH_ON ,-1L ,0x1 , &sel,EINVAL ); }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 117/644 ARM: dts: vfxxx: Correctly use two tuples for timer address
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f3440dcf8b994197c968fbafe047ce27eed226e8 ]
Address and size-cells are 1 and the ftm timer node takes two address spaces in "reg" property, so this should be in two <> tuples. Change has no functional impact, but original code is confusing/less readable.
--- arch/arm/boot/dts/vfxxx.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/vfxxx.dtsi +1 -1
@@ -617,7 +617,7 @@ usbmisc1: usb@400b4800 { ftm: ftm@400b8000 { compatible = "fsl,ftm-timer"; - reg = <0x400b8000 0x1000 0x400b9000 0x1000>; + reg = <0x400b8000 0x1000>, <0x400b9000 0x1000>; interrupts = <44 IRQ_TYPE_LEVEL_HIGH>; clock-names = "ftm-evt", "ftm-src", "ftm-evt-counter-en", "ftm-src-counter-en";
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 118/644 usb: misc: apple-mfi-fastcharge: Make power supply names unique
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charalampos Mitrodimas <[email protected]>
[ Upstream commit 43007b89fb2de746443fbbb84aedd1089afdf582 ]
When multiple Apple devices are connected concurrently, the apple-mfi-fastcharge driver fails to probe the subsequent devices with the following error:
sysfs: cannot create duplicate filename '/class/power_supply/apple_mfi_fastcharge' apple-mfi-fastcharge 5-2.4.3.3: probe of 5-2.4.3.3 failed with error -17
This happens because the driver uses a fixed power supply name ("apple_mfi_fastcharge") for all devices, causing a sysfs name conflict when a second device is connected.
Fix this by generating unique names using the USB bus and device number (e.g., "apple_mfi_fastcharge_5-12"). This ensures each connected device gets a unique power supply entry in sysfs.
The change requires storing a copy of the power_supply_desc structure in the per-device mfi_device struct, since the name pointer needs to remain valid for the lifetime of the power supply registration.
--- drivers/usb/misc/apple-mfi-fastcharge.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/usb/misc/apple-mfi-fastcharge.c +21 -3
@@ -44,6 +44,7 @@ MODULE_DEVICE_TABLE(usb, mfi_fc_id_table);struct mfi_device {struct usb_device *udev;struct power_supply *battery; +struct power_supply_desc battery_desc;int charge_type; };
@@ -178,6 +179,7 @@ static int mfi_fc_probe(struct usb_device *udev) {struct power_supply_config battery_cfg = {};struct mfi_device *mfi =NULL ; +char *battery_name;int err;if (!mfi_fc_match (udev))
@@ -187,23 +189,38 @@ static int mfi_fc_probe(struct usb_device *udev)if (!mfi)return -ENOMEM ; + battery_name =kasprintf (GFP_KERNEL ,"apple_mfi_fastcharge_%d-%d" , + udev->bus->busnum, udev->devnum); +if (!battery_name) { + err = -ENOMEM ; + goto err_free_mfi; + } + + mfi->battery_desc = apple_mfi_fc_desc; + mfi->battery_desc.name = battery_name; + battery_cfg.drv_data = mfi; mfi->charge_type =POWER_SUPPLY_CHARGE_TYPE_TRICKLE ; mfi->battery =power_supply_register (&udev->dev, - &apple_mfi_fc_desc, + &mfi->battery_desc, &battery_cfg);if (IS_ERR (mfi->battery)) {dev_err (&udev->dev,"Can't register battery\n" ); err =PTR_ERR (mfi->battery); -kfree (mfi); -return err; + goto err_free_name; } mfi->udev =usb_get_dev (udev);dev_set_drvdata (&udev->dev, mfi);return 0 ; + +err_free_name: +kfree (battery_name); +err_free_mfi: +kfree (mfi); +return err; }static void mfi_fc_disconnect (struct usb_device *udev)
@@ -213,6 +230,7 @@ static void mfi_fc_disconnect(struct usb_device *udev) mfi =dev_get_drvdata (&udev->dev);if (mfi->battery)power_supply_unregister (mfi->battery); +kfree (mfi->battery_desc.name);dev_set_drvdata (&udev->dev,NULL );usb_put_dev (mfi->udev);kfree (mfi);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 119/644 staging: fbtft: fix potential memory leak in fbtft_framebuffer_alloc()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit eb2cb7dab60f9be0b435ac4a674255429a36d72c ]
In the error paths after fb_info structure is successfully allocated, the memory allocated in fb_deferred_io_init() for info->pagerefs is not freed. Fix that by adding the cleanup function on the error path.
--- drivers/staging/fbtft/fbtft-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/fbtft/fbtft-core.c +1 -0
@@ -747,6 +747,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,return info; release_framebuf: +fb_deferred_io_cleanup (info);framebuffer_release (info); alloc_fail:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 120/644 vmci: Prevent the dispatching of uninitialized payloads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Xu <[email protected]>
[ Upstream commit bfb4cf9fb97e4063f0aa62e9e398025fb6625031 ]
The reproducer executes the host's unlocked_ioctl call in two different tasks. When init_context fails, the struct vmci_event_ctx is not fully initialized when executing vmci_datagram_dispatch() to send events to all vm contexts. This affects the datagram taken from the datagram queue of its context by another task, because the datagram payload is not initialized according to the size payload_size, which causes the kernel data to leak to the user space.
Before dispatching the datagram, and before setting the payload content, explicitly set the payload content to 0 to avoid data leakage caused by incomplete payload initialization.
--- drivers/misc/vmw_vmci/vmci_context.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/vmw_vmci/vmci_context.c +2 -0
@@ -251,6 +251,8 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID ); ev.msg.hdr.payload_size =sizeof (ev) -sizeof (ev.msg.hdr); +memset ((char *)&ev.msg.hdr +sizeof (ev.msg.hdr),0 , + ev.msg.hdr.payload_size); ev.msg.event_data.event =VMCI_EVENT_CTX_REMOVED ; ev.payload.context_id = context_id;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 121/644 pps: fix poll support
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis OSTERLAND-HEIM <[email protected]>
[ Upstream commit 12c409aa1ec2592280a2ddcc66ff8f3c7f7bb171 ]
Because pps_cdev_poll() returns unconditionally EPOLLIN,
a user space program that calls select/poll get always an immediate data ready-to-read response. As a result the intended use to wait until next data becomes ready does not work.
User space snippet:
struct pollfd pollfd = {
.fd = open("/dev/pps0", O_RDONLY),
.events = POLLIN|POLLERR,
.revents = 0 };
while(1) {
poll(&pollfd, 1, 2000/*ms*/); // returns immediate, but should wait
if(revents & EPOLLIN) { // always true
struct pps_fdata fdata;
memset(&fdata, 0, sizeof(memdata));
ioctl(PPS_FETCH, &fdata); // currently fetches data at max speed
}
}Lets remember the last fetch event counter and compare this value in pps_cdev_poll() with most recent event counter
and return 0 if they are equal.
--- drivers/pps/pps.c | 11 +++++++++-- include/linux/pps_kernel.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/pps/pps.c +9 -2
@@ -41,6 +41,9 @@ static __poll_t pps_cdev_poll(struct file *file, poll_table *wait)poll_wait (file, &pps->queue, wait); +if (pps->last_fetched_ev == pps->last_ev) +return 0 ; +return EPOLLIN |EPOLLRDNORM ; }
@@ -186,9 +189,11 @@ static long pps_cdev_ioctl(struct file *file,if (err)return err; -/* Return the fetched timestamp */ +/* Return the fetched timestamp and save last fetched event */ spin_lock_irq (&pps->lock); + pps->last_fetched_ev = pps->last_ev; + fdata.info.assert_sequence = pps->assert_sequence; fdata.info.clear_sequence = pps->clear_sequence; fdata.info.assert_tu = pps->assert_tu;
@@ -272,9 +277,11 @@ static long pps_cdev_compat_ioctl(struct file *file,if (err)return err; -/* Return the fetched timestamp */ +/* Return the fetched timestamp and save last fetched event */ spin_lock_irq (&pps->lock); + pps->last_fetched_ev = pps->last_ev; + compat.info.assert_sequence = pps->assert_sequence; compat.info.clear_sequence = pps->clear_sequence; compat.info.current_mode = pps->current_mode;
include/linux/pps_kernel.h +1 -0
@@ -52,6 +52,7 @@ struct pps_device {int current_mode;/* PPS mode at event time */ unsigned int last_ev;/* last PPS event id */ +unsigned int last_fetched_ev;/* last fetched PPS event id */ wait_queue_head_t queue;/* PPS event queue */ unsigned int id;/* PPS source unique ID */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 122/644 Revert "vmci: Prevent the dispatching of uninitialized payloads"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 8f5d9bed6122b8d96508436e5ad2498bb797eb6b ]
This reverts commit bfb4cf9fb97e4063f0aa62e9e398025fb6625031.
While the code "looks" correct, the compiler has no way to know that doing "fun" pointer math like this really isn't a write off the end of the structure as there is no hint anywhere that the structure has data at the end of it.
This causes the following build warning:
In function 'fortify_memset_chk',
inlined from 'ctx_fire_notification.isra' at drivers/misc/vmw_vmci/vmci_context.c:254:3:include/linux/fortify-string.h:480:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
480 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~So revert it for now and it can come back in the future in a "sane" way that either correctly makes the structure know that there is trailing data, OR just the payload structure is properly referenced and zeroed out.
--- drivers/misc/vmw_vmci/vmci_context.c | 2 -- 1 file changed, 2 deletions(-)
drivers/misc/vmw_vmci/vmci_context.c +0 -2
@@ -251,8 +251,6 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID ); ev.msg.hdr.payload_size =sizeof (ev) -sizeof (ev.msg.hdr); -memset ((char *)&ev.msg.hdr +sizeof (ev.msg.hdr),0 , - ev.msg.hdr.payload_size); ev.msg.event_data.event =VMCI_EVENT_CTX_REMOVED ; ev.payload.context_id = context_id;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 123/644 usb: early: xhci-dbc: Fix early_ioremap leak
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas De Marchi <[email protected]>
[ Upstream commit 2b7eec2ec3015f52fc74cf45d0408925e984ecd1 ]
Using the kernel param earlyprintk=xdbc,keep without proper hardware setup leads to this:
[ ] xhci_dbc:early_xdbc_parse_parameter: dbgp_num: 0 ... [ ] xhci_dbc:early_xdbc_setup_hardware: failed to setup the connection to host ... [ ] calling kmemleak_late_init+0x0/0xa0 @ 1 [ ] kmemleak: Kernel memory leak detector initialized (mem pool available: 14919) [ ] kmemleak: Automatic memory scanning thread started [ ] initcall kmemleak_late_init+0x0/0xa0 returned 0 after 417 usecs [ ] calling check_early_ioremap_leak+0x0/0x70 @ 1 [ ] ------------[ cut here ]------------ [ ] Debug warning: early ioremap leak of 1 areas detected. please boot with early_ioremap_debug and report the dmesg. [ ] WARNING: CPU: 11 PID: 1 at mm/early_ioremap.c:90 check_early_ioremap_leak+0x4e/0x70
When early_xdbc_setup_hardware() fails, make sure to call early_iounmap() since xdbc_init() won't handle it.
--- drivers/usb/early/xhci-dbc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/early/xhci-dbc.c +4 -0
@@ -679,6 +679,10 @@ int __init early_xdbc_setup_hardware(void) xdbc.table_base =NULL ; xdbc.out_buf =NULL ; + +early_iounmap (xdbc.xhci_base, xdbc.xhci_length); + xdbc.xhci_base =NULL ; + xdbc.xhci_length =0 ; }return ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 124/644 arm: dts: ti: omap: Fixup pinheader typo
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Albin Törnqvist <[email protected]>
[ Upstream commit a3a4be32b69c99fc20a66e0de83b91f8c882bf4c ]
This commit fixes a typo introduced in commitee368a10d0df ("ARM: dts: am335x-boneblack.dts: unique gpio-line-names"). gpio0_7 is located on the P9 header on the BBB.
This was verified with a BeagleBone Black by toggling the pin and checking with a multimeter that it corresponds to pin 42 on the P9 header.
--- arch/arm/boot/dts/am335x-boneblack.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/am335x-boneblack.dts +1 -1
@@ -34,7 +34,7 @@ &gpio0 { "P9_18 [spi0_d1]", "P9_17 [spi0_cs0]", "[mmc0_cd]", - "P8_42A [ecappwm0]", + "P9_42A [ecappwm0]", "P8_35 [lcd d12]", "P8_33 [lcd d13]", "P8_31 [lcd d14]",
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 125/644 ARM: dts: imx6ul-kontron-bl-common: Fix RTS polarity for RS485 interface
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Annette Kobou <[email protected]>
[ Upstream commit 47ef5256124fb939d8157b13ca048c902435cf23 ]
The polarity of the DE signal of the transceiver is active-high for sending. Therefore rs485-rts-active-low is wrong and needs to be removed to make RS485 transmissions work.
--- arch/arm/boot/dts/imx6ul-kontron-n6x1x-s.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/imx6ul-kontron-n6x1x-s.dtsi +0 -1
@@ -170,7 +170,6 @@ &uart2 { pinctrl-0 = <&pinctrl_uart2>; linux,rs485-enabled-at-boot-time; rs485-rx-during-tx; - rs485-rts-active-low; uart-has-rtscts; status = "okay"; };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 126/644 arm64: dts: imx8mm-beacon: Fix HS400 USDHC clock speed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Ford <[email protected]>
[ Upstream commit f83f69097a302ed2a2775975ddcf12e6a5ac6ec3 ]
The reference manual for the i.MX8MM states the clock rate in MMC mode is 1/2 of the input clock, therefore to properly run at HS400 rates, the input clock must be 400MHz to operate at 200MHz. Currently the clock is set to 200MHz which is half the rate it should be, so the throughput is half of what it should be for HS400 operation.
--- arch/arm64/boot/dts/freescale/imx8mm-beacon-som.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm-beacon-som.dtsi +2 -0
@@ -285,6 +285,8 @@ &usdhc3 { pinctrl-0 = <&pinctrl_usdhc3>; pinctrl-1 = <&pinctrl_usdhc3_100mhz>; pinctrl-2 = <&pinctrl_usdhc3_200mhz>; + assigned-clocks = <&clk IMX8MM_CLK_USDHC3>; + assigned-clock-rates = <400000000>; bus-width = <8>; non-removable; status = "okay";
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 127/644 arm64: dts: imx8mn-beacon: Fix HS400 USDHC clock speed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Ford <[email protected]>
[ Upstream commit e16ad6c79906bba5e2ac499492b6a5b29ab19d6c ]
The reference manual for the i.MX8MN states the clock rate in MMC mode is 1/2 of the input clock, therefore to properly run at HS400 rates, the input clock must be 400MHz to operate at 200MHz. Currently the clock is set to 200MHz which is half the rate it should be, so the throughput is half of what it should be for HS400 operation.
--- arch/arm64/boot/dts/freescale/imx8mn-beacon-som.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/freescale/imx8mn-beacon-som.dtsi +2 -0
@@ -296,6 +296,8 @@ &usdhc3 { pinctrl-0 = <&pinctrl_usdhc3>; pinctrl-1 = <&pinctrl_usdhc3_100mhz>; pinctrl-2 = <&pinctrl_usdhc3_200mhz>; + assigned-clocks = <&clk IMX8MN_CLK_USDHC3>; + assigned-clock-rates = <400000000>; bus-width = <8>; non-removable; status = "okay";
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 128/644 PM / devfreq: Check governor before using governor->name
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lifeng Zheng <[email protected]>
[ Upstream commit bab7834c03820eb11269bc48f07c3800192460d2 ]
Commit 96ffcdf239de ("PM / devfreq: Remove redundant governor_name from struct devfreq") removes governor_name and uses governor->name to replace it. But devfreq->governor may be NULL and directly using devfreq->governor->name may cause null pointer exception. Move the check of governor to before using governor->name.
--- drivers/devfreq/devfreq.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/devfreq/devfreq.c +3 -7
@@ -1347,15 +1347,11 @@ int devfreq_remove_governor(struct devfreq_governor *governor)int ret;struct device *dev = devfreq->dev.parent; +if (!devfreq->governor) +continue ; +if (!strncmp (devfreq->governor->name, governor->name,DEVFREQ_NAME_LEN )) { -/* we should have a devfreq governor! */ -if (!devfreq->governor) { -dev_warn (dev,"%s: Governor %s NOT present\n" , - __func__, governor->name); -continue ; -/* Fall through */ - } ret = devfreq->governor->event_handler (devfreq,DEVFREQ_GOV_STOP ,NULL );if (ret) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 129/644 cpufreq: intel_pstate: Always use HWP_DESIRED_PERF in passive mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 1cefe495cacba5fb0417da3a75a1a76e3546d176 ]
In the passive mode, intel_cpufreq_update_pstate() sets HWP_MIN_PERF in accordance with the target frequency to ensure delivering adequate performance, but it sets HWP_DESIRED_PERF to 0, so the processor has no indication that the desired performance level is actually equal to the floor one. This may cause it to choose a performance point way above the desired level.
Moreover, this is inconsistent with intel_cpufreq_adjust_perf() which actually sets HWP_DESIRED_PERF in accordance with the target performance value.
Address this by adjusting intel_cpufreq_update_pstate() to pass target_pstate as both the minimum and the desired performance levels to intel_cpufreq_hwp_update().
--- drivers/cpufreq/intel_pstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/intel_pstate.c +2 -2
@@ -2703,8 +2703,8 @@ static int intel_cpufreq_update_pstate(struct cpufreq_policy *policy,int max_pstate = policy->strict_target ? target_pstate : cpu->max_perf_ratio; -intel_cpufreq_hwp_update (cpu, target_pstate, max_pstate,0 , - fast_switch); +intel_cpufreq_hwp_update (cpu, target_pstate, max_pstate, + target_pstate, fast_switch); }else if (target_pstate != old_pstate) {intel_cpufreq_perf_ctl_update (cpu, target_pstate, fast_switch); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 130/644 cpufreq: Initialize cpufreq-based frequency-invariance later
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lifeng Zheng <[email protected]>
[ Upstream commit 2a6c727387062a2ea79eb6cf5004820cb1b0afe2 ]
The cpufreq-based invariance is enabled in cpufreq_register_driver(), but never disabled after registration fails. Move the invariance initialization to where all other initializations have been successfully done to solve this problem.
--- drivers/cpufreq/cpufreq.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/cpufreq/cpufreq.c +9 -9
@@ -2841,15 +2841,6 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); -/* -* Mark support for the scheduler's frequency invariance engine for -* drivers that implement target(), target_index() or fast_switch(). -*/ -if (!cpufreq_driver->setpolicy) { -static_branch_enable_cpuslocked (&cpufreq_freq_invariance); -pr_debug ("supports frequency invariance" ); - } -if (driver_data->setpolicy) driver_data->flags |=CPUFREQ_CONST_LOOPS ;
@@ -2880,6 +2871,15 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) hp_online = ret; ret =0 ; +/* +* Mark support for the scheduler's frequency invariance engine for +* drivers that implement target(), target_index() or fast_switch(). +*/ +if (!cpufreq_driver->setpolicy) { +static_branch_enable_cpuslocked (&cpufreq_freq_invariance); +pr_debug ("supports frequency invariance" ); + } +pr_debug ("driver %s up and running\n" , driver_data->name); goto out;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 131/644 cpufreq: Init policy->rwsem before it may be possibly used
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lifeng Zheng <[email protected]>
[ Upstream commit d1378d1d7edb3a4c4935a44fe834ae135be03564 ]
In cpufreq_policy_put_kobj(), policy->rwsem is used. But in cpufreq_policy_alloc(), if freq_qos_add_notifier() returns an error, error path via err_kobj_remove or err_min_qos_notifier will be reached and cpufreq_policy_put_kobj() will be called before policy->rwsem is initialized. Thus, the calling of init_rwsem() should be moved to where before these two error paths can be reached.
--- drivers/cpufreq/cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +2 -1
@@ -1228,6 +1228,8 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) goto err_free_real_cpus; } +init_rwsem (&policy->rwsem); +freq_constraints_init (&policy->constraints); policy->nb_min.notifier_call = cpufreq_notifier_min;
@@ -1250,7 +1252,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) }INIT_LIST_HEAD (&policy->policy_list); -init_rwsem (&policy->rwsem);spin_lock_init (&policy->transition_lock);init_waitqueue_head (&policy->transition_wait);INIT_WORK (&policy->update, handle_update);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 132/644 samples: mei: Fix building on musl libc
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brahmajit Das <[email protected]>
[ Upstream commit 239df3e4b4752524e7c0fb3417c218d8063654b4 ]
The header bits/wordsize.h is glibc specific and on building on musl with allyesconfig results in
samples/mei/mei-amt-version.c:77:10: fatal error: bits/wordsize.h: No such file or directory
77 | #include <bits/wordsize.h>
| ^~~~~~~~~~~~~~~~~
mei-amt-version.c build file without bits/wordsize.h on musl and glibc.
However on musl we get the follwing error without sys/time.h
samples/mei/mei-amt-version.c: In function 'mei_recv_msg':samples/mei/mei-amt-version.c:159:24: error: storage size of 'tv' isn't known
159 | struct timeval tv;
| ^~samples/mei/mei-amt-version.c:160:9: error: unknown type name 'fd_set'
160 | fd_set set;
| ^~~~~~
samples/mei/mei-amt-version.c:168:9: error: implicit declaration of function 'FD_ZERO' [-Wimplicit-function-declaration]
168 | FD_ZERO(&set);
| ^~~~~~~
samples/mei/mei-amt-version.c:169:9: error: implicit declaration of function 'FD_SET'; did you mean 'L_SET'? [-Wimplicit-function-declaration]
169 | FD_SET(me->fd, &set);
| ^~~~~~
| L_SET
samples/mei/mei-amt-version.c:170:14: error: implicit declaration of function 'select' [-Wimplicit-function-declaration]
170 | rc = select(me->fd + 1, &set, NULL, NULL, &tv);
| ^~~~~~
samples/mei/mei-amt-version.c:171:23: error: implicit declaration of function 'FD_ISSET' [-Wimplicit-function-declaration]
171 | if (rc > 0 && FD_ISSET(me->fd, &set)) {
| ^~~~~~~~samples/mei/mei-amt-version.c:159:24: warning: unused variable 'tv' [-Wunused-variable]
159 | struct timeval tv;
| ^~
Hence the the file has been included.
--- samples/mei/mei-amt-version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/mei/mei-amt-version.c +1 -1
@@ -69,11 +69,11 @@#include <string.h> #include <fcntl.h> #include <sys/ioctl.h> +#include <sys/time.h> #include <unistd.h> #include <errno.h> #include <stdint.h> #include <stdbool.h> -#include <bits/wordsize.h> #include <linux/mei.h> /*****************************************************************************
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 133/644 staging: nvec: Fix incorrect null termination of battery manufacturer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit a8934352ba01081c51d2df428e9d540aae0e88b5 ]
The battery manufacturer string was incorrectly null terminated using bat_model instead of bat_manu. This could result in an unintended write to the wrong field and potentially incorrect behavior.
fixe the issue by correctly null terminating the bat_manu string.
--- drivers/staging/nvec/nvec_power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec_power.c +1 -1
@@ -194,7 +194,7 @@ static int nvec_power_bat_notifier(struct notifier_block *nb,break ;case MANUFACTURER :memcpy (power->bat_manu, &res->plc, res->length -2 ); - power->bat_model[res->length -2 ] ='\0' ; + power->bat_manu[res->length -2 ] ='\0' ;break ;case MODEL :memcpy (power->bat_model, &res->plc, res->length -2 );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 134/644 selftests/tracing: Fix false failure of subsystem event test
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit 213879061a9c60200ba971330dbefec6df3b4a30 ]
The subsystem event test enables all "sched" events and makes sure there's at least 3 different events in the output. It used to cat the entire trace file to | wc -l, but on slow machines, that could last a very long time. To solve that, it was changed to just read the first 100 lines of the trace file. This can cause false failures as some events repeat so often, that the 100 lines that are examined could possibly be of only one event.
Instead, create an awk script that looks for 3 different events and will exit out after it finds them. This will find the 3 events the test looks for (eventually if it works), and still exit out after the test is satisfied and not cause slower machines to run forever.
--- .../ftrace/test.d/event/subsystem-enable.tc | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +26 -2
@@ -14,11 +14,35 @@ fail() { #msg exit_fail } +# As reading trace can last forever, simply look for 3 different +# events then exit out of reading the file. If there's not 3 different +# events, then the test has failed. +check_unique() { + cat trace | grep -v '^#' | awk ' + BEGIN { cnt = 0; } + { + for (i = 0; i < cnt; i++) { + if (event[i] == $5) { + break; + } + } + if (i == cnt) { + event[cnt++] = $5; + if (cnt > 2) { + exit; + } + } + } + END { + printf "%d", cnt; + }' +} + echo 'sched:*' > set_event yield -count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` +count=`check_unique` if [ $count -lt 3 ]; then fail "at least fork, exec and exit events should be recorded" fi
@@ -29,7 +53,7 @@ echo 1 > events/sched/enable yield -count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` +count=`check_unique` if [ $count -lt 3 ]; then fail "at least fork, exec and exit events should be recorded" fi
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 135/644 drm/rockchip: cleanup fb when drm_gem_fb_afbc_init failed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Yan <[email protected]>
[ Upstream commit 099593a28138b48feea5be8ce700e5bc4565e31d ]
In the function drm_gem_fb_init_with_funcs, the framebuffer (fb) and its corresponding object ID have already been registered.
So we need to cleanup the drm framebuffer if the subsequent execution of drm_gem_fb_afbc_init fails.
Directly call drm_framebuffer_put to ensure that all fb related resources are cleanup.
--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +1 -8
@@ -81,16 +81,9 @@ rockchip_fb_create(struct drm_device *dev, struct drm_file *file, }if (drm_is_afbc (mode_cmd->modifier[0 ])) { -int ret, i; - ret =drm_gem_fb_afbc_init (dev, mode_cmd, afbc_fb);if (ret) { -struct drm_gem_object **obj = afbc_fb->base.obj; - -for (i =0 ; i < info->num_planes; ++i) -drm_gem_object_put (obj[i]); - -kfree (afbc_fb); +drm_framebuffer_put (&afbc_fb->base);return ERR_PTR (ret); } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 136/644 bpf, sockmap: Fix psock incorrectly pointing to sk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 76be5fae32febb1fdb848ba09f78c4b2c76cb337 ]
We observed an issue from the latest selftest: sockmap_redir where sk_psock(psock->sk) != psock in the backlog. The root cause is the special behavior in sockmap_redir - it frequently performs map_update() and map_delete() on the same socket. During map_update(), we create a new psock and during map_delete(), we eventually free the psock via rcu_work in sk_psock_drop(). However, pending workqueues might still exist and not be processed yet. If users immediately perform another map_update(), a new psock will be allocated for the same sk, resulting in two psocks pointing to the same sk.
When the pending workqueue is later triggered, it uses the old psock to access sk for I/O operations, which is incorrect.
Timing Diagram:
cpu0 cpu1
map_update(sk):
sk->psock = psock1
psock1->sk = skmap_delete(sk):
rcu_work_free(psock1)
map_update(sk):
sk->psock = psock2
psock2->sk = sk
workqueue:
wakeup with psock1, but the sk of psock1 doesn't belong to psock1rcu_handler:
clean psock1
free(psock1)
Previously, we used reference counting to address the concurrency issue between backlog and sock_map_close(). This logic remains necessary as it prevents the sk from being freed while processing the backlog. But this patch prevents pending backlogs from using a psock after it has been stopped.
Note: We cannot call cancel_delayed_work_sync() in map_delete() since this might be invoked in BPF context by BPF helper, and the function may sleep.
--- net/core/skmsg.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/skmsg.c +7 -0
@@ -648,6 +648,13 @@ static void sk_psock_backlog(struct work_struct *work)bool ingress;int ret; +/* If sk is quickly removed from the map and then added back, the old +* psock should not be scheduled, because there are now two psocks +* pointing to the same sk. +*/ +if (!sk_psock_test_state (psock,SK_PSOCK_TX_ENABLED )) +return ; +/* Increment the psock refcnt to synchronize with close(fd) path in * sock_map_close(), ensuring we wait for backlog thread completion * before sk_socket freed. If refcnt increment fails, it indicates
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 137/644 bpf, ktls: Fix data corruption when using bpf_msg_pop_data() in ktls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 178f6a5c8cb3b6be1602de0964cd440243f493c9 ]
When sending plaintext data, we initially calculated the corresponding ciphertext length. However, if we later reduced the plaintext data length via socket policy, we failed to recalculate the ciphertext length.
This results in transmitting buffers containing uninitialized data during ciphertext transmission.
This causes uninitialized bytes to be appended after a complete "Application Data" packet, leading to errors on the receiving end when parsing TLS record.
--- net/tls/tls_sw.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/tls/tls_sw.c +13 -0
@@ -857,6 +857,19 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk, delta = msg->sg.size; psock->eval =sk_psock_msg_verdict (sk, psock, msg); delta -= msg->sg.size; + +if ((s32 )delta >0 ) { +/* It indicates that we executed bpf_msg_pop_data(), +* causing the plaintext data size to decrease. +* Therefore the encrypted data size also needs to +* correspondingly decrease. We only need to subtract +* delta to calculate the new ciphertext length since +* ktls does not support block encryption. +*/ +struct sk_msg *enc = &ctx->open_rec->msg_encrypted; + +sk_msg_trim (sk, enc, enc->sg.size - delta); + } }if (msg->cork_bytes && msg->cork_bytes > msg->sg.size && !enospc && !full_record) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 138/644 bpftool: Fix memory leak in dump_xx_nlmsg on realloc failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit 99fe8af069a9fa5b09140518b1364e35713a642e ]
In function dump_xx_nlmsg(), when realloc() fails to allocate memory, the original pointer to the buffer is overwritten with NULL. This causes a memory leak because the previously allocated buffer becomes unreachable without being freed.
--- tools/bpf/bpftool/net.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
tools/bpf/bpftool/net.c +9 -6
@@ -353,17 +353,18 @@ static int dump_link_nlmsg(void *cookie, void *msg, struct nlattr **tb) {struct bpf_netdev_t *netinfo = cookie;struct ifinfomsg *ifinfo = msg; +struct ip_devname_ifindex *tmp;if (netinfo->filter_idx >0 && netinfo->filter_idx != ifinfo->ifi_index)return 0 ;if (netinfo->used_len == netinfo->array_len) { - netinfo->devices =realloc (netinfo->devices, - (netinfo->array_len +16 ) * -sizeof (struct ip_devname_ifindex )); -if (!netinfo->devices) + tmp =realloc (netinfo->devices, + (netinfo->array_len +16 ) *sizeof (struct ip_devname_ifindex )); +if (!tmp)return -ENOMEM ; + netinfo->devices = tmp; netinfo->array_len +=16 ; } netinfo->devices[netinfo->used_len].ifindex = ifinfo->ifi_index;
@@ -382,6 +383,7 @@ static int dump_class_qdisc_nlmsg(void *cookie, void *msg, struct nlattr **tb) {struct bpf_tcinfo_t *tcinfo = cookie;struct tcmsg *info = msg; +struct tc_kind_handle *tmp;if (tcinfo->is_qdisc) {/* skip clsact qdisc */
@@ -393,11 +395,12 @@ static int dump_class_qdisc_nlmsg(void *cookie, void *msg, struct nlattr **tb) }if (tcinfo->used_len == tcinfo->array_len) { - tcinfo->handle_array =realloc (tcinfo->handle_array, + tmp =realloc (tcinfo->handle_array, (tcinfo->array_len +16 ) *sizeof (struct tc_kind_handle )); -if (!tcinfo->handle_array) +if (!tmp)return -ENOMEM ; + tcinfo->handle_array = tmp; tcinfo->array_len +=16 ; } tcinfo->handle_array[tcinfo->used_len].handle = info->tcm_handle;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 139/644 caif: reduce stack size, again
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit b630c781bcf6ff87657146661816d0d30a902139 ]
I tried to fix the stack usage in this function a couple of years ago, but there is still a problem with the latest gcc versions in some configurations:
net/caif/cfctrl.c:553:1: error: the frame size of 1296 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
Reduce this once again, with a separate cfctrl_link_setup() function that holds the bulk of all the local variables. It also turns out that the param[] array that takes up a large portion of the stack is write-only and can be left out here.
--- net/caif/cfctrl.c | 294 +++++++++++++++++++++++----------------------- 1 file changed, 144 insertions(+), 150 deletions(-)
net/caif/cfctrl.c +144 -150
@@ -351,17 +351,154 @@ int cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer)return found; } +static int cfctrl_link_setup (struct cfctrl *cfctrl,struct cfpkt *pkt,u8 cmdrsp) +{ +u8 len; +u8 linkid =0 ; +enum cfctrl_srv serv; +enum cfctrl_srv servtype; +u8 endpoint; +u8 physlinkid; +u8 prio; +u8 tmp; +u8 *cp; +int i; +struct cfctrl_link_param linkparam; +struct cfctrl_request_info rsp, *req; + +memset (&linkparam,0 ,sizeof (linkparam)); + + tmp =cfpkt_extr_head_u8 (pkt); + + serv = tmp &CFCTRL_SRV_MASK ; + linkparam.linktype = serv; + + servtype = tmp >>4 ; + linkparam.chtype = servtype; + + tmp =cfpkt_extr_head_u8 (pkt); + physlinkid = tmp &0x07 ; + prio = tmp >>3 ; + + linkparam.priority = prio; + linkparam.phyid = physlinkid; + endpoint =cfpkt_extr_head_u8 (pkt); + linkparam.endpoint = endpoint &0x03 ; + +switch (serv) { +case CFCTRL_SRV_VEI : +case CFCTRL_SRV_DBG : +if (CFCTRL_ERR_BIT & cmdrsp) +break ; +/* Link ID */ + linkid =cfpkt_extr_head_u8 (pkt); +break ; +case CFCTRL_SRV_VIDEO : + tmp =cfpkt_extr_head_u8 (pkt); + linkparam.u.video.connid = tmp; +if (CFCTRL_ERR_BIT & cmdrsp) +break ; +/* Link ID */ + linkid =cfpkt_extr_head_u8 (pkt); +break ; + +case CFCTRL_SRV_DATAGRAM : + linkparam.u.datagram.connid =cfpkt_extr_head_u32 (pkt); +if (CFCTRL_ERR_BIT & cmdrsp) +break ; +/* Link ID */ + linkid =cfpkt_extr_head_u8 (pkt); +break ; +case CFCTRL_SRV_RFM : +/* Construct a frame, convert +* DatagramConnectionID +* to network format long and copy it out... +*/ + linkparam.u.rfm.connid =cfpkt_extr_head_u32 (pkt); + cp = (u8 *) linkparam.u.rfm.volume; +for (tmp =cfpkt_extr_head_u8 (pkt); +cfpkt_more (pkt) && tmp !='\0' ; + tmp =cfpkt_extr_head_u8 (pkt)) + *cp++ = tmp; + *cp ='\0' ; + +if (CFCTRL_ERR_BIT & cmdrsp) +break ; +/* Link ID */ + linkid =cfpkt_extr_head_u8 (pkt); + +break ; +case CFCTRL_SRV_UTIL : +/* Construct a frame, convert +* DatagramConnectionID +* to network format long and copy it out... +*/ +/* Fifosize KB */ + linkparam.u.utility.fifosize_kb =cfpkt_extr_head_u16 (pkt); +/* Fifosize bufs */ + linkparam.u.utility.fifosize_bufs =cfpkt_extr_head_u16 (pkt); +/* name */ + cp = (u8 *) linkparam.u.utility.name; +caif_assert (sizeof (linkparam.u.utility.name) + >=UTILITY_NAME_LENGTH ); +for (i =0 ; i <UTILITY_NAME_LENGTH &&cfpkt_more (pkt); i++) { + tmp =cfpkt_extr_head_u8 (pkt); + *cp++ = tmp; + } +/* Length */ + len =cfpkt_extr_head_u8 (pkt); + linkparam.u.utility.paramlen = len; +/* Param Data */ + cp = linkparam.u.utility.params; +while (cfpkt_more (pkt) && len--) { + tmp =cfpkt_extr_head_u8 (pkt); + *cp++ = tmp; + } +if (CFCTRL_ERR_BIT & cmdrsp) +break ; +/* Link ID */ + linkid =cfpkt_extr_head_u8 (pkt); +/* Length */ + len =cfpkt_extr_head_u8 (pkt); +/* Param Data */ +cfpkt_extr_head (pkt,NULL , len); +break ; +default : +pr_warn ("Request setup, invalid type (%d)\n" , serv); +return -1 ; + } + + rsp.cmd =CFCTRL_CMD_LINK_SETUP ; + rsp.param = linkparam; +spin_lock_bh (&cfctrl->info_list_lock); + req =cfctrl_remove_req (cfctrl, &rsp); + +if (CFCTRL_ERR_BIT == (CFCTRL_ERR_BIT & cmdrsp) || +cfpkt_erroneous (pkt)) { +pr_err ("Invalid O/E bit or parse error " +"on CAIF control channel\n" ); + cfctrl->res.reject_rsp (cfctrl->serv.layer.up,0 , + req ? req->client_layer :NULL ); + }else { + cfctrl->res.linksetup_rsp (cfctrl->serv.layer.up, linkid, + serv, physlinkid, + req ? req->client_layer :NULL ); + } + +kfree (req); + +spin_unlock_bh (&cfctrl->info_list_lock); + +return 0 ; +} +static int cfctrl_recv (struct cflayer *layer,struct cfpkt *pkt) {u8 cmdrsp;u8 cmd; -int ret =-1 ; -u8 len; -u8 param[255 ]; +int ret =0 ;u8 linkid =0 ;struct cfctrl *cfctrl =container_obj (layer); -struct cfctrl_request_info rsp, *req; - cmdrsp =cfpkt_extr_head_u8 (pkt); cmd = cmdrsp &CFCTRL_CMD_MASK ;
@@ -374,150 +511,7 @@ static int cfctrl_recv(struct cflayer *layer, struct cfpkt *pkt)switch (cmd) {case CFCTRL_CMD_LINK_SETUP : - { -enum cfctrl_srv serv; -enum cfctrl_srv servtype; -u8 endpoint; -u8 physlinkid; -u8 prio; -u8 tmp; -u8 *cp; -int i; -struct cfctrl_link_param linkparam; -memset (&linkparam,0 ,sizeof (linkparam)); - - tmp =cfpkt_extr_head_u8 (pkt); - - serv = tmp &CFCTRL_SRV_MASK ; - linkparam.linktype = serv; - - servtype = tmp >>4 ; - linkparam.chtype = servtype; - - tmp =cfpkt_extr_head_u8 (pkt); - physlinkid = tmp &0x07 ; - prio = tmp >>3 ; - - linkparam.priority = prio; - linkparam.phyid = physlinkid; - endpoint =cfpkt_extr_head_u8 (pkt); - linkparam.endpoint = endpoint &0x03 ; - -switch (serv) { -case CFCTRL_SRV_VEI : -case CFCTRL_SRV_DBG : -if (CFCTRL_ERR_BIT & cmdrsp) -break ; -/* Link ID */ - linkid =cfpkt_extr_head_u8 (pkt); -break ; -case CFCTRL_SRV_VIDEO : - tmp =cfpkt_extr_head_u8 (pkt); - linkparam.u.video.connid = tmp; -if (CFCTRL_ERR_BIT & cmdrsp) -break ; -/* Link ID */ - linkid =cfpkt_extr_head_u8 (pkt); -break ; - -case CFCTRL_SRV_DATAGRAM : - linkparam.u.datagram.connid = -cfpkt_extr_head_u32 (pkt); -if (CFCTRL_ERR_BIT & cmdrsp) -break ; -/* Link ID */ - linkid =cfpkt_extr_head_u8 (pkt); -break ; -case CFCTRL_SRV_RFM : -/* Construct a frame, convert -* DatagramConnectionID -* to network format long and copy it out... -*/ - linkparam.u.rfm.connid = -cfpkt_extr_head_u32 (pkt); - cp = (u8 *) linkparam.u.rfm.volume; -for (tmp =cfpkt_extr_head_u8 (pkt); -cfpkt_more (pkt) && tmp !='\0' ; - tmp =cfpkt_extr_head_u8 (pkt)) - *cp++ = tmp; - *cp ='\0' ; - -if (CFCTRL_ERR_BIT & cmdrsp) -break ; -/* Link ID */ - linkid =cfpkt_extr_head_u8 (pkt); - -break ; -case CFCTRL_SRV_UTIL : -/* Construct a frame, convert -* DatagramConnectionID -* to network format long and copy it out... -*/ -/* Fifosize KB */ - linkparam.u.utility.fifosize_kb = -cfpkt_extr_head_u16 (pkt); -/* Fifosize bufs */ - linkparam.u.utility.fifosize_bufs = -cfpkt_extr_head_u16 (pkt); -/* name */ - cp = (u8 *) linkparam.u.utility.name; -caif_assert (sizeof (linkparam.u.utility.name) - >=UTILITY_NAME_LENGTH ); -for (i =0 ; - i <UTILITY_NAME_LENGTH - &&cfpkt_more (pkt); i++) { - tmp =cfpkt_extr_head_u8 (pkt); - *cp++ = tmp; - } -/* Length */ - len =cfpkt_extr_head_u8 (pkt); - linkparam.u.utility.paramlen = len; -/* Param Data */ - cp = linkparam.u.utility.params; -while (cfpkt_more (pkt) && len--) { - tmp =cfpkt_extr_head_u8 (pkt); - *cp++ = tmp; - } -if (CFCTRL_ERR_BIT & cmdrsp) -break ; -/* Link ID */ - linkid =cfpkt_extr_head_u8 (pkt); -/* Length */ - len =cfpkt_extr_head_u8 (pkt); -/* Param Data */ -cfpkt_extr_head (pkt, ¶m, len); -break ; -default : -pr_warn ("Request setup, invalid type (%d)\n" , - serv); - goto error; - } - - rsp.cmd = cmd; - rsp.param = linkparam; -spin_lock_bh (&cfctrl->info_list_lock); - req =cfctrl_remove_req (cfctrl, &rsp); - -if (CFCTRL_ERR_BIT == (CFCTRL_ERR_BIT & cmdrsp) || -cfpkt_erroneous (pkt)) { -pr_err ("Invalid O/E bit or parse error " -"on CAIF control channel\n" ); - cfctrl->res.reject_rsp (cfctrl->serv.layer.up, -0 , - req ? req->client_layer - :NULL ); - }else { - cfctrl->res.linksetup_rsp (cfctrl->serv. - layer.up, linkid, - serv, physlinkid, - req ? req-> - client_layer :NULL ); - } - -kfree (req); - -spin_unlock_bh (&cfctrl->info_list_lock); - } + ret =cfctrl_link_setup (cfctrl, pkt, cmdrsp);break ;case CFCTRL_CMD_LINK_DESTROY : linkid =cfpkt_extr_head_u8 (pkt);
@@ -544,9 +538,9 @@ static int cfctrl_recv(struct cflayer *layer, struct cfpkt *pkt)break ;default :pr_err ("Unrecognized Control Frame\n" ); + ret =-1 ; goto error; } - ret =0 ; error:cfpkt_destroy (pkt);return ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 140/644 wifi: rtl818x: Kill URBs before clearing tx status queue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniil Dulov <[email protected]>
[ Upstream commit 16d8fd74dbfca0ea58645cd2fca13be10cae3cdd ]
In rtl8187_stop() move the call of usb_kill_anchored_urbs() before clearing b_tx_status.queue. This change prevents callbacks from using already freed skb due to anchor was not killed before freeing such skb.
BUG: kernel NULL pointer dereference, address: 0000000000000080 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: Oops: 0000 [#1] SMP NOPTI CPU: 7 UID: 0 PID: 0 Comm: swapper/7 Not tainted 6.15.0 #8 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 RIP: 0010:ieee80211_tx_status_irqsafe+0x21/0xc0 [mac80211] Call Trace: <IRQ> rtl8187_tx_cb+0x116/0x150 [rtl8187] __usb_hcd_giveback_urb+0x9d/0x120 usb_giveback_urb_bh+0xbb/0x140 process_one_work+0x19b/0x3c0 bh_worker+0x1a7/0x210 tasklet_action+0x10/0x30 handle_softirqs+0xf0/0x340 __irq_exit_rcu+0xcd/0xf0 common_interrupt+0x85/0xa0 </IRQ>
Tested on RTL8187BvE device.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c +2 -1
@@ -1041,10 +1041,11 @@ static void rtl8187_stop(struct ieee80211_hw *dev)rtl818x_iowrite8 (priv, &priv->map->CONFIG4, reg |RTL818X_CONFIG4_VCOOFF );rtl818x_iowrite8 (priv, &priv->map->EEPROM_CMD,RTL818X_EEPROM_CMD_NORMAL ); +usb_kill_anchored_urbs (&priv->anchored); +while ((skb =skb_dequeue (&priv->b_tx_status.queue)))dev_kfree_skb_any (skb); -usb_kill_anchored_urbs (&priv->anchored);mutex_unlock (&priv->conf_mutex);if (!priv->is_rtl8187b)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 141/644 wifi: iwlwifi: Fix memory leak in iwl_mvm_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiu Jianfeng <[email protected]>
[ Upstream commit ed2e916c890944633d6826dce267579334f63ea5 ]
When iwl_opmode_register() fails, it does not unregster rate control, which will cause a memory leak issue, this patch fixes it.
--- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +3 -1
@@ -61,8 +61,10 @@ static int __init iwl_mvm_init(void) } ret =iwl_opmode_register ("iwlmvm" , &iwl_mvm_ops); -if (ret) +if (ret) {pr_err ("Unable to register MVM op_mode: %d\n" , ret); +iwl_mvm_rate_control_unregister (); + }return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 142/644 iwlwifi: Add missing check for alloc_ordered_workqueue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 90a0d9f339960448a3acc1437a46730f975efd6a ]
Add check for the return value of alloc_ordered_workqueue since it may return NULL pointer.
--- drivers/net/wireless/intel/iwlwifi/dvm/main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/dvm/main.c +9 -2
@@ -1053,9 +1053,11 @@ static void iwl_bg_restart(struct work_struct *data)* *****************************************************************************/ -static void iwl_setup_deferred_work (struct iwl_priv *priv) +static int iwl_setup_deferred_work (struct iwl_priv *priv) { priv->workqueue =alloc_ordered_workqueue (DRV_NAME ,0 ); +if (!priv->workqueue) +return -ENOMEM ;INIT_WORK (&priv->restart, iwl_bg_restart);INIT_WORK (&priv->beacon_update, iwl_bg_beacon_update);
@@ -1072,6 +1074,8 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)timer_setup (&priv->statistics_periodic, iwl_bg_statistics_periodic,0 );timer_setup (&priv->ucode_trace, iwl_bg_ucode_trace,0 ); + +return 0 ; }void iwl_cancel_deferred_work (struct iwl_priv *priv)
@@ -1461,7 +1465,9 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,/******************** * 6. Setup services ********************/ -iwl_setup_deferred_work (priv); +if (iwl_setup_deferred_work (priv)) + goto out_uninit_drv; +iwl_setup_rx_handlers (priv);iwl_power_initialize (priv);
@@ -1499,6 +1505,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,iwl_cancel_deferred_work (priv);destroy_workqueue (priv->workqueue); priv->workqueue =NULL ; +out_uninit_drv:iwl_uninit_drv (priv); out_free_eeprom_blob:kfree (priv->eeprom_blob);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 143/644 wifi: ath11k: clear initialized flag for deinit-ed srng lists
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Senozhatsky <[email protected]>
[ Upstream commit a5b46aa7cf5f05c213316a018e49a8e086efd98e ]
In a number of cases we see kernel panics on resume due to ath11k kernel page fault, which happens under the following circumstances:
1) First ath11k_hal_dump_srng_stats() call
Last interrupt received for each group:
ath11k_pci 0000:01:00.0: group_id 0 22511ms before
ath11k_pci 0000:01:00.0: group_id 1 14440788ms before
[..]
ath11k_pci 0000:01:00.0: failed to receive control response completion, polling.. ath11k_pci 0000:01:00.0: Service connect timeout
ath11k_pci 0000:01:00.0: failed to connect to HTT: -110
ath11k_pci 0000:01:00.0: failed to start core: -110
ath11k_pci 0000:01:00.0: firmware crashed: MHI_CB_EE_RDDM
ath11k_pci 0000:01:00.0: already resetting count 2
ath11k_pci 0000:01:00.0: failed to wait wlan mode request (mode 4): -110 ath11k_pci 0000:01:00.0: qmi failed to send wlan mode off: -110 ath11k_pci 0000:01:00.0: failed to reconfigure driver on crash recovery [..]
2) At this point reconfiguration fails (we have 2 resets) and ath11k_core_reconfigure_on_crash() calls ath11k_hal_srng_deinit() which destroys srng lists. However, it does not reset per-list ->initialized flag.
3) Second ath11k_hal_dump_srng_stats() call sees stale ->initialized flag and attempts to dump srng stats:
Last interrupt received for each group:
ath11k_pci 0000:01:00.0: group_id 0 66785ms before ath11k_pci 0000:01:00.0: group_id 1 14485062ms before ath11k_pci 0000:01:00.0: group_id 2 14485062ms before ath11k_pci 0000:01:00.0: group_id 3 14485062ms before ath11k_pci 0000:01:00.0: group_id 4 14780845ms before ath11k_pci 0000:01:00.0: group_id 5 14780845ms before ath11k_pci 0000:01:00.0: group_id 6 14485062ms before ath11k_pci 0000:01:00.0: group_id 7 66814ms before ath11k_pci 0000:01:00.0: group_id 8 68997ms before ath11k_pci 0000:01:00.0: group_id 9 67588ms before ath11k_pci 0000:01:00.0: group_id 10 69511ms before
BUG: unable to handle page fault for address: ffffa007404eb010 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 100000067 P4D 100000067 PUD 10022d067 PMD 100b01067 PTE 0 Oops: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:ath11k_hal_dump_srng_stats+0x2b4/0x3b0 [ath11k] Call Trace: <TASK> ? __die_body+0xae/0xb0 ? page_fault_oops+0x381/0x3e0 ? exc_page_fault+0x69/0xa0 ? asm_exc_page_fault+0x22/0x30 ? ath11k_hal_dump_srng_stats+0x2b4/0x3b0 [ath11k (HASH:6cea 4)] ath11k_qmi_driver_event_work+0xbd/0x1050 [ath11k (HASH:6cea 4)] worker_thread+0x389/0x930 kthread+0x149/0x170
Clear per-list ->initialized flag in ath11k_hal_srng_deinit().
--- drivers/net/wireless/ath/ath11k/hal.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath11k/hal.c +4 -0
@@ -1286,6 +1286,10 @@ EXPORT_SYMBOL(ath11k_hal_srng_init);void ath11k_hal_srng_deinit (struct ath11k_base *ab) {struct ath11k_hal *hal = &ab->hal; +int i; + +for (i =0 ; i <HAL_SRNG_RING_ID_MAX ; i++) + ab->hal.srng_list[i].initialized =0 ;ath11k_hal_unregister_srng_key (ab);ath11k_hal_free_cont_rdp (ab);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 144/644 tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: xin.guo <[email protected]>
[ Upstream commit a041f70e573e185d5d5fdbba53f0db2fbe7257ad ]
If the new coming segment covers more than one skbs in the ofo queue, and which seq is equal to rcv_nxt, then the sequence range that is duplicated will be sent as DUP SACK, the detail as below, in step6, the {501,2001} range is clearly including too much DUP SACK range, in violation of RFC 2883 rules.
1. client > server: Flags [.], seq 501:1001, ack 1325288529, win 20000, length 500
2. server > client: Flags [.], ack 1, [nop,nop,sack 1 {501:1001}], length 0
3. client > server: Flags [.], seq 1501:2001, ack 1325288529, win 20000, length 500
4. server > client: Flags [.], ack 1, [nop,nop,sack 2 {1501:2001} {501:1001}], length 0
5. client > server: Flags [.], seq 1:2001, ack 1325288529, win 20000, length 2000
6. server > client: Flags [.], ack 2001, [nop,nop,sack 1 {501:2001}], length 0
After this fix, the final ACK is as below:
6. server > client: Flags [.], ack 2001, options [nop,nop,sack 1 {501:1001}], length 0
[edumazet] added a new packetdrill test in the following patch.
--- net/ipv4/tcp_input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp_input.c +2 -1
@@ -4826,8 +4826,9 @@ static void tcp_ofo_queue(struct sock *sk)if (before (TCP_SKB_CB (skb)->seq, dsack_high)) {__u32 dsack = dsack_high; +if (before (TCP_SKB_CB (skb)->end_seq, dsack_high)) - dsack_high =TCP_SKB_CB (skb)->end_seq; + dsack =TCP_SKB_CB (skb)->end_seq;tcp_dsack_extend (sk,TCP_SKB_CB (skb)->seq, dsack); } p =rb_next (p);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 145/644 net/mlx5: Check device memory pointer before usage
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stav Aviram <[email protected]>
[ Upstream commit 70f238c902b8c0461ae6fbb8d1a0bbddc4350eea ]
Add a NULL check before accessing device memory to prevent a crash if dev->dm allocation in mlx5_init_once() fails.
--- drivers/infiniband/hw/mlx5/dm.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/main.c | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/infiniband/hw/mlx5/dm.c +1 -1
@@ -282,7 +282,7 @@ static struct ib_dm *handle_alloc_dm_memic(struct ib_ucontext *ctx,int err;u64 address; -if (!MLX5_CAP_DEV_MEM (dm_db->dev, memic)) +if (!dm_db || !MLX5_CAP_DEV_MEM (dm_db->dev, memic))return ERR_PTR (-EOPNOTSUPP ); dm =kzalloc (sizeof (*dm),GFP_KERNEL );
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c +2 -2
@@ -25,7 +25,7 @@ struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev) dm =kzalloc (sizeof (*dm),GFP_KERNEL );if (!dm) -return ERR_PTR (-ENOMEM ); +return NULL ;spin_lock_init (&dm->lock);
@@ -61,7 +61,7 @@ struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev) err_steering:kfree (dm); -return ERR_PTR (-ENOMEM ); +return NULL ; }void mlx5_dm_cleanup (struct mlx5_core_dev *dev)
drivers/net/ethernet/mellanox/mlx5/core/main.c +0 -3
@@ -901,9 +901,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev) } dev->dm =mlx5_dm_create (dev); -if (IS_ERR (dev->dm)) -mlx5_core_warn (dev,"Failed to init device memory %ld\n" ,PTR_ERR (dev->dm)); - dev->tracer =mlx5_fw_tracer_create (dev); dev->hv_vhca =mlx5_hv_vhca_create (dev); dev->rsc_dump =mlx5_rsc_dump_create (dev);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 146/644 m68k: Dont unregister boot console needlessly
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
[ Upstream commit 83f672a7f69ec38b1bbb27221e342937f68c11c7 ]
When MACH_IS_MVME147, the boot console calls mvme147_scc_write() to generate console output. That will continue to work even after debug_cons_nputs() becomes unavailable so there's no need to unregister the boot console.
Take the opportunity to remove a repeated MACH_IS_* test. Use the actual .write method (instead of a wrapper) and test that pointer instead. This means adding an unused parameter to debug_cons_nputs() for consistency with the struct console API.
early_printk.c is only built when CONFIG_EARLY_PRINTK=y. As of late, head.S is only built when CONFIG_MMU_MOTOROLA=y. So let the former symbol depend on the latter, to obviate some ifdef conditionals.
--- arch/m68k/Kconfig.debug | 2 +- arch/m68k/kernel/early_printk.c | 42 +++++++++++---------------------- arch/m68k/kernel/head.S | 8 +++---- 3 files changed, 19 insertions(+), 33 deletions(-)
arch/m68k/Kconfig.debug +1 -1
@@ -10,7 +10,7 @@ config BOOTPARAM_STRING config EARLY_PRINTK bool "Early printk" - depends on !(SUN3 || M68000 || COLDFIRE) + depends on MMU_MOTOROLA help Write kernel log output directly to a serial port. Where implemented, output goes to the framebuffer as well.
arch/m68k/kernel/early_printk.c +14 -28
65 lines not on this page · raw message
arch/m68k/kernel/head.S +4 -4
@@ -3242,8 +3242,8 @@ func_return putn * turns around and calls the internal routines. This routine * is used by the boot console. * - * The calling parameters are: - * void debug_cons_nputs(const char *str, unsigned length) + * The function signature is - + * void debug_cons_nputs(struct console *c, const char *s, unsigned int n) * * This routine does NOT understand variable arguments only * simple strings!
@@ -3252,8 +3252,8 @@ ENTRY(debug_cons_nputs) moveml %d0/%d1/%a0,%sp@- movew %sr,%sp@- ori #0x0700,%sr - movel %sp@(18),%a0 /* fetch parameter */ - movel %sp@(22),%d1 /* fetch parameter */ + movel %sp@(22),%a0 /* char *s */ + movel %sp@(26),%d1 /* unsigned int n */ jra 2f 1: #ifdef CONSOLE_DEBUG
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 147/644 drm/amd/pm/powerplay/hwmgr/smu_helper: fix order of mask and value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit a54e4639c4ef37a0241bac7d2a77f2e6ffb57099 ]
There is a small typo in phm_wait_on_indirect_register().
Swap mask and value arguments provided to phm_wait_on_register() so that they satisfy the function signature and actual usage scheme.
Found by Linux Verification Center (linuxtesting.org) with Svace static analysis tool.
In practice this doesn't fix any issues because the only place this function is used uses the same value for the value and mask.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c +1 -1
@@ -149,7 +149,7 @@ int phm_wait_on_indirect_register(struct pp_hwmgr *hwmgr, }cgs_write_register (hwmgr->device, indirect_port, index); -return phm_wait_on_register (hwmgr, indirect_port +1 , mask, value); +return phm_wait_on_register (hwmgr, indirect_port +1 , value, mask); } int phm_wait_for_register_unequal(struct pp_hwmgr *hwmgr,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 148/644 netfilter: nf_tables: adjust lockdep assertions handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit 8df1b40de76979bb8e975201d07b71103d5de820 ]
It's needed to check the return value of lockdep_commit_lock_is_held(), otherwise there's no point in this assertion as it doesn't print any debug information on itself.
Found by Linux Verification Center (linuxtesting.org) with Svace static analysis tool.
--- net/netfilter/nf_tables_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +2 -2
@@ -3443,7 +3443,7 @@ void nf_tables_rule_destroy(const struct nft_ctx *ctx, struct nft_rule *rule)/* can only be used if rule is no longer visible to dumps */ static void nf_tables_rule_release (const struct nft_ctx *ctx,struct nft_rule *rule) { -lockdep_commit_lock_is_held (ctx->net); +WARN_ON_ONCE (!lockdep_commit_lock_is_held (ctx->net));nft_rule_expr_deactivate (ctx, rule,NFT_TRANS_RELEASE );nf_tables_rule_destroy (ctx, rule);
@@ -5180,7 +5180,7 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,struct nft_set_binding *binding, enum nft_trans_phase phase) { - lockdep_commit_lock_is_held(ctx->net); + WARN_ON_ONCE(!lockdep_commit_lock_is_held(ctx->net));switch (phase) {case NFT_TRANS_PREPARE_ERROR :
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 149/644 arch: powerpc: defconfig: Drop obsolete CONFIG_NET_CLS_TCINDEX
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Korsnes <[email protected]>
[ Upstream commit 75cd37c5f28b85979fd5a65174013010f6b78f27 ]
This option was removed from the Kconfig in commit 8c710f75256b ("net/sched: Retire tcindex classifier") but it was not removed from the defconfigs.
--- arch/powerpc/configs/ppc6xx_defconfig | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/configs/ppc6xx_defconfig +0 -1
@@ -263,7 +263,6 @@ CONFIG_NET_SCH_DSMARK=m CONFIG_NET_SCH_NETEM=m CONFIG_NET_SCH_INGRESS=m CONFIG_NET_CLS_BASIC=m -CONFIG_NET_CLS_TCINDEX=m CONFIG_NET_CLS_ROUTE4=m CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_U32=m
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 150/644 um: rtc: Avoid shadowing err in uml_rtc_start()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiwei Bie <[email protected]>
[ Upstream commit 4c916e3b224a02019b3cc3983a15f32bfd9a22df ]
Remove the declaration of 'err' inside the 'if (timetravel)' block, as it would otherwise be unavailable outside that block, potentially leading to uml_rtc_start() returning an uninitialized value.
--- arch/um/drivers/rtc_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/rtc_user.c +1 -1
@@ -28,7 +28,7 @@ int uml_rtc_start(bool timetravel)int err;if (timetravel) { -int err =os_pipe (uml_rtc_irq_fds,1 ,1 ); + err =os_pipe (uml_rtc_irq_fds,1 ,1 );if (err) goto fail; }else {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 151/644 net/sched: Restrict conditions for adding duplicating netems to qdisc tree
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Liu <[email protected]>
[ Upstream commit ec8e0e3d7adef940cdf9475e2352c0680189d14e ]
netem_enqueue's duplication prevention logic breaks when a netem resides in a qdisc tree with other netems - this can lead to a soft lockup and OOM loop in netem_dequeue, as seen in [1]. Ensure that a duplicating netem cannot exist in a tree with other netems.
Previous approaches suggested in discussions in chronological order:
1) Track duplication status or ttl in the sk_buff struct. Considered too specific a use case to extend such a struct, though this would be a resilient fix and address other previous and potential future DOS bugs like the one described in loopy fun [2].
2) Restrict netem_enqueue recursion depth like in act_mirred with a per cpu variable. However, netem_dequeue can call enqueue on its child, and the depth restriction could be bypassed if the child is a netem.
3) Use the same approach as in 2, but add metadata in netem_skb_cb to handle the netem_dequeue case and track a packet's involvement in duplication. This is an overly complex approach, and Jamal notes that the skb cb can be overwritten to circumvent this safeguard.
4) Prevent the addition of a netem to a qdisc tree if its ancestral path contains a netem. However, filters and actions can cause a packet to change paths when re-enqueued to the root from netem duplication, leading us to the current solution: prevent a duplicating netem from inhabiting the same tree as other netems.
[1] https://lore.kernel.org/netdev/8DuRWwfqjoRDLDmBMlIfbrsZg9Gx50DHJc1ilxsEBNe2D6NMoigR_eIRIG0LOjMc3r10nUUZtArXx4oZBIdUfZQrwjcQhdinnMis_0G7VEk=@willsroot.io/
[2] https://lwn.net/Articles/719297/
--- net/sched/sch_netem.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
net/sched/sch_netem.c +40 -0
@@ -962,6 +962,41 @@ static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla,return 0 ; } +static const struct Qdisc_class_ops netem_class_ops; + +static int check_netem_in_tree (struct Qdisc *sch,bool duplicates, +struct netlink_ext_ack *extack) +{ +struct Qdisc *root, *q; +unsigned int i; + + root =qdisc_root_sleeping (sch); + +if (sch != root && root->ops->cl_ops == &netem_class_ops) { +if (duplicates || + ((struct netem_sched_data *)qdisc_priv (root))->duplicate) + goto err; + } + +if (!qdisc_dev (root)) +return 0 ; + +hash_for_each (qdisc_dev (root)->qdisc_hash, i, q, hash) { +if (sch != q && q->ops->cl_ops == &netem_class_ops) { +if (duplicates || + ((struct netem_sched_data *)qdisc_priv (q))->duplicate) + goto err; + } + } + +return 0 ; + +err: +NL_SET_ERR_MSG (extack, +"netem: cannot mix duplicating netems with other netems in tree" ); +return -EINVAL ; +} +/* Parse netlink message to set options */ static int netem_change (struct Qdisc *sch,struct nlattr *opt,struct netlink_ext_ack *extack)
@@ -1023,6 +1058,11 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, q->gap = qopt->gap; q->counter =0 ; q->loss = qopt->loss; + + ret =check_netem_in_tree (sch, qopt->duplicate, extack); +if (ret) + goto unlock; + q->duplicate = qopt->duplicate;/* for compatibility with earlier versions.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 152/644 net_sched: act_ctinfo: use atomic64_t for three counters
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit d300335b4e18672913dd792ff9f49e6cccf41d26 ]
Commit 21c167aa0ba9 ("net/sched: act_ctinfo: use percpu stats") missed that stats_dscp_set, stats_dscp_error and stats_cpmark_set might be written (and read) locklessly.
Use atomic64_t for these three fields, I doubt act_ctinfo is used heavily on big SMP hosts anyway.
--- include/net/tc_act/tc_ctinfo.h | 6 +++--- net/sched/act_ctinfo.c | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-)
include/net/tc_act/tc_ctinfo.h +3 -3
@@ -18,9 +18,9 @@ struct tcf_ctinfo_params {struct tcf_ctinfo {struct tc_action common;struct tcf_ctinfo_params __rcu *params; -u64 stats_dscp_set; -u64 stats_dscp_error; -u64 stats_cpmark_set; +atomic64_t stats_dscp_set; +atomic64_t stats_dscp_error; +atomic64_t stats_cpmark_set; };enum {
net/sched/act_ctinfo.c +11 -8
@@ -44,9 +44,9 @@ static void tcf_ctinfo_dscp_set(struct nf_conn *ct, struct tcf_ctinfo *ca,ipv4_change_dsfield (ip_hdr (skb),INET_ECN_MASK , newdscp); - ca->stats_dscp_set++; +atomic64_inc (&ca->stats_dscp_set); }else { - ca->stats_dscp_error++; +atomic64_inc (&ca->stats_dscp_error); } }break ;
@@ -57,9 +57,9 @@ static void tcf_ctinfo_dscp_set(struct nf_conn *ct, struct tcf_ctinfo *ca,ipv6_change_dsfield (ipv6_hdr (skb),INET_ECN_MASK , newdscp); - ca->stats_dscp_set++; +atomic64_inc (&ca->stats_dscp_set); }else { - ca->stats_dscp_error++; +atomic64_inc (&ca->stats_dscp_error); } }break ;
@@ -72,7 +72,7 @@ static void tcf_ctinfo_cpmark_set(struct nf_conn *ct, struct tcf_ctinfo *ca,struct tcf_ctinfo_params *cp, struct sk_buff *skb) { - ca->stats_cpmark_set++; + atomic64_inc(&ca->stats_cpmark_set); skb->mark =READ_ONCE (ct->mark) & cp->cpmarkmask; }
@@ -322,15 +322,18 @@ static int tcf_ctinfo_dump(struct sk_buff *skb, struct tc_action *a, }if (nla_put_u64_64bit (skb,TCA_CTINFO_STATS_DSCP_SET , - ci->stats_dscp_set,TCA_CTINFO_PAD )) +atomic64_read (&ci->stats_dscp_set), +TCA_CTINFO_PAD )) goto nla_put_failure;if (nla_put_u64_64bit (skb,TCA_CTINFO_STATS_DSCP_ERROR , - ci->stats_dscp_error,TCA_CTINFO_PAD )) +atomic64_read (&ci->stats_dscp_error), +TCA_CTINFO_PAD )) goto nla_put_failure;if (nla_put_u64_64bit (skb,TCA_CTINFO_STATS_CPMARK_SET , - ci->stats_cpmark_set,TCA_CTINFO_PAD )) +atomic64_read (&ci->stats_cpmark_set), +TCA_CTINFO_PAD )) goto nla_put_failure;spin_unlock_bh (&ci->tcf_lock);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 153/644 xen/gntdev: remove struct gntdev_copy_batch from stack
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit 70045cf6593cbf0740956ea9b7b4269142c6ee38 ]
When compiling the kernel with LLVM, the following warning was issued:
drivers/xen/gntdev.c:991: warning: stack frame size (1160) exceeds limit (1024) in function 'gntdev_ioctl'
The main reason is struct gntdev_copy_batch which is located on the stack and has a size of nearly 1kb.
For performance reasons it shouldn't by just dynamically allocated instead, so allocate a new instance when needed and instead of freeing it put it into a list of free structs anchored in struct gntdev_priv.
Message-ID: <[email protected]>
--- drivers/xen/gntdev-common.h | 4 +++ drivers/xen/gntdev.c | 71 ++++++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 21 deletions(-)
drivers/xen/gntdev-common.h +4 -0
@@ -26,6 +26,10 @@ struct gntdev_priv {/* lock protects maps and freeable_maps. */ struct mutex lock; +/* Free instances of struct gntdev_copy_batch. */ +struct gntdev_copy_batch *batch; +struct mutex batch_lock; +#ifdef CONFIG_XEN_GRANT_DMA_ALLOC /* Device for which DMA memory is allocated. */ struct device *dma_dev;
drivers/xen/gntdev.c +50 -21
127 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 154/644 wifi: rtl8xxxu: Fix RX skb size for aggregation disabled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kaistra <[email protected]>
[ Upstream commit d76a1abcf57734d2bcd4a7ec051617edd4513d7f ]
Commit 1e5b3b3fe9e0 ("rtl8xxxu: Adjust RX skb size to include space for phystats") increased the skb size when aggregation is enabled but decreased it for the aggregation disabled case.
As a result, if a frame near the maximum size is received, rtl8xxxu_rx_complete() is called with status -EOVERFLOW and then the driver starts to malfunction and no further communication is possible.
Restore the skb size in the aggregation disabled case.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +1 -1
@@ -5795,7 +5795,7 @@ static int rtl8xxxu_submit_rx_urb(struct rtl8xxxu_priv *priv, skb_size = fops->rx_agg_buf_size; skb_size += (rx_desc_sz +sizeof (struct rtl8723au_phy_stats )); }else { - skb_size =IEEE80211_MAX_FRAME_LEN ; + skb_size =IEEE80211_MAX_FRAME_LEN + rx_desc_sz; } skb =__netdev_alloc_skb (NULL , skb_size,GFP_KERNEL );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 155/644 mwl8k: Add missing check after DMA map
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 50459501b9a212dbe7a673727589ee105a8a9954 ]
The DMA map functions can fail and should be tested for errors. If the mapping fails, unmap and return an error.
--- drivers/net/wireless/marvell/mwl8k.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/marvell/mwl8k.c +4 -0
@@ -1222,6 +1222,10 @@ static int rxq_refill(struct ieee80211_hw *hw, int index, int limit) addr =dma_map_single (&priv->pdev->dev, skb->data,MWL8K_RX_MAXSZ ,DMA_FROM_DEVICE ); +if (dma_mapping_error (&priv->pdev->dev, addr)) { +kfree_skb (skb); +break ; + } rxq->rxd_count++; rx = rxq->tail++;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 156/644 wifi: mac80211: Dont call fq_flow_idx() for management frames
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Wetzel <[email protected]>
[ Upstream commit cb3bb3d88dfcd177a1050c0a009a3ee147b2e5b9 ]
skb_get_hash() can only be used when the skb is linked to a netdev device.
--- net/mac80211/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/tx.c +2 -1
@@ -1417,7 +1417,7 @@ static void ieee80211_txq_enqueue(struct ieee80211_local *local, {struct fq *fq = &local->fq;struct fq_tin *tin = &txqi->tin; -u32 flow_idx =fq_flow_idx (fq, skb); +u32 flow_idx;ieee80211_set_skb_enqueue_time (skb);
@@ -1433,6 +1433,7 @@ static void ieee80211_txq_enqueue(struct ieee80211_local *local,IEEE80211_TX_INTCFL_NEED_TXPROCESSING ;__skb_queue_tail (&txqi->frags, skb); }else { + flow_idx =fq_flow_idx (fq, skb);fq_tin_enqueue (fq, tin, flow_idx, skb, fq_skb_free_func); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 157/644 wifi: mac80211: Check 802.11 encaps offloading in ieee80211_tx_h_select_key()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Remi Pommarel <[email protected]>
[ Upstream commit 4037c468d1b3c508d69e6df0ef47fdee3d440e39 ]
With 802.11 encapsulation offloading, ieee80211_tx_h_select_key() is called on 802.3 frames. In that case do not try to use skb data as valid 802.11 headers.
--- net/mac80211/tx.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/mac80211/tx.c +6 -0
@@ -608,6 +608,12 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)else tx->key =NULL ; +if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) { +if (tx->key && tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) + info->control.hw_key = &tx->key->conf; +return TX_CONTINUE ; + } +if (tx->key) {bool skip_hw = false;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 158/644 Reapply "wifi: mac80211: Update skbs control block key in ieee80211_tx_dequeue()"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Remi Pommarel <[email protected]>
[ Upstream commit 754fe848b3b297fc85ec24cd959bad22b6df8cb8 ]
This reverts commit 0937cb5f345c ("Revert "wifi: mac80211: Update skb's control block key in ieee80211_tx_dequeue()"").
This commit broke TX with 802.11 encapsulation HW offloading, now that this is fixed, reapply it.
--- net/mac80211/tx.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/tx.c +1 -0
@@ -3711,6 +3711,7 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,* The key can be removed while the packet was queued, so need to call * this here to get the current key. */ + info->control.hw_key =NULL ; r =ieee80211_tx_h_select_key (&tx);if (r !=TX_CONTINUE ) {ieee80211_free_txskb (&local->hw, skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 159/644 wifi: brcmfmac: fix P2P discovery failure in P2P peer due to missing P2P IE
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gokul Sivakumar <[email protected]>
[ Upstream commit 579bf8037b70b644a674c126a32bbb2212cf5c21 ]
After commit bd99a3013bdc ("brcmfmac: move configuration of probe request IEs"), the probe request MGMT IE addition operation brcmf_vif_set_mgmt_ie() got moved from the brcmf_p2p_scan_prep() to the brcmf_cfg80211_scan().
Because of this, as part of the scan request handler for the P2P Discovery, vif struct used for adding the Probe Request P2P IE in firmware got changed from the P2PAPI_BSSCFG_DEVICE vif to P2PAPI_BSSCFG_PRIMARY vif incorrectly. So the firmware stopped adding P2P IE to the outgoing P2P Discovery probe requests frames and the other P2P peers were unable to discover this device causing a regression on the P2P feature.
To fix this, while setting the P2P IE in firmware, properly use the vif of the P2P discovery wdev on which the driver received the P2P scan request. This is done by not changing the vif pointer, until brcmf_vif_set_mgmt_ie() is completed.
--- .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +4 -4
@@ -1199,10 +1199,6 @@ brcmf_cfg80211_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)return -EAGAIN ; } -/* If scan req comes for p2p0, send it over primary I/F */ -if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE ].vif) - vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY ].vif; -brcmf_dbg (SCAN ,"START ESCAN\n" ); cfg->scan_request = request;
@@ -1218,6 +1214,10 @@ brcmf_cfg80211_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)if (err) goto scan_out; +/* If scan req comes for p2p0, send it over primary I/F */ +if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE ].vif) + vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY ].vif; + err =brcmf_do_escan (vif->ifp, request);if (err) goto scan_out;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 160/644 can: kvaser_pciefd: Store device channel index
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
[ Upstream commit d54b16b40ddadb7d0a77fff48af7b319a0cd6aae ]
Store device channel index in netdev.dev_port.
--- drivers/net/can/kvaser_pciefd.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/kvaser_pciefd.c +1 -0
@@ -955,6 +955,7 @@ static int kvaser_pciefd_setup_can_ctrls(struct kvaser_pciefd *pcie) can->err_rep_cnt =0 ; can->bec.txerr =0 ; can->bec.rxerr =0 ; + can->can.dev->dev_port = i;init_completion (&can->start_comp);init_completion (&can->flush_comp);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 161/644 can: kvaser_usb: Assign netdev.dev_port based on device channel index
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
[ Upstream commit c151b06a087a61c7a1790b75ee2f1d6edb6a8a45 ]
Assign netdev.dev_port based on the device channel index, to indicate the port number of the network device.
While this driver already uses netdev.dev_id for that purpose, dev_port is more appropriate. However, retain dev_id to avoid potential regressions.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +1 -0
@@ -838,6 +838,7 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel)SET_NETDEV_DEV (netdev, &dev->intf->dev); netdev->dev_id = channel; + netdev->dev_port = channel; dev->nets[channel] = priv;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 162/644 netfilter: xt_nfacct: dont assume acct name is null-terminated
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit bf58e667af7d96c8eb9411f926a0a0955f41ce21 ]
BUG: KASAN: slab-out-of-bounds in .. lib/vsprintf.c:721 Read of size 1 at addr ffff88801eac95c8 by task syz-executor183/5851 [..] string+0x231/0x2b0 lib/vsprintf.c:721 vsnprintf+0x739/0xf00 lib/vsprintf.c:2874 [..] nfacct_mt_checkentry+0xd2/0xe0 net/netfilter/xt_nfacct.c:41 xt_check_match+0x3d1/0xab0 net/netfilter/x_tables.c:523
nfnl_acct_find_get() handles non-null input, but the error printk relied on its presence.
--- net/netfilter/xt_nfacct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/xt_nfacct.c +2 -2
@@ -38,8 +38,8 @@ nfacct_mt_checkentry(const struct xt_mtchk_param *par) nfacct =nfnl_acct_find_get (par->net, info->name);if (nfacct ==NULL ) { -pr_info_ratelimited ("accounting object `%s' does not exists\n" , - info->name); +pr_info_ratelimited ("accounting object `%.*s' does not exist\n" , +NFACCT_NAME_MAX , info->name);return -ENOENT ; } info->nfacct = nfacct;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 163/644 selftests: rtnetlink.sh: remove esp4_offload after test
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiumei Mu <[email protected]>
[ Upstream commit 5b32321fdaf3fd1a92ec726af18765e225b0ee2b ]
The esp4_offload module, loaded during IPsec offload tests, should be reset to its default settings after testing.
Otherwise, leaving it enabled could unintentionally affect subsequence test cases by keeping offload active.
Without this fix:
$ lsmod | grep offload; ./rtnetlink.sh -t kci_test_ipsec_offload ; lsmod | grep offload; PASS: ipsec_offload esp4_offload 12288 0 esp4 32768 1 esp4_offload
With this fix:
$ lsmod | grep offload; ./rtnetlink.sh -t kci_test_ipsec_offload ; lsmod | grep offload; PASS: ipsec_offload
--- tools/testing/selftests/net/rtnetlink.sh | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/net/rtnetlink.sh +6 -0
@@ -746,6 +746,11 @@ kci_test_ipsec_offload() sysfsf=$sysfsd/ipsec sysfsnet=/sys/bus/netdevsim/devices/netdevsim0/net/ probed=false + esp4_offload_probed_default=false + + if lsmod | grep -q esp4_offload; then + esp4_offload_probed_default=true + fi # setup netdevsim since dummydev doesn't have offload support if [ ! -w /sys/bus/netdevsim/new_device ] ; then
@@ -835,6 +840,7 @@ EOF fi # clean up any leftovers + ! "$esp4_offload_probed_default" && lsmod | grep -q esp4_offload && rmmod esp4_offload echo 0 > /sys/bus/netdevsim/del_device $probed && rmmod netdevsim
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 164/644 vrf: Drop existing dst reference in vrf_ip6_input_dst
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit f388f807eca1de9e6e70f9ffb1a573c3811c4215 ]
Commit ff3fbcdd4724 ("selftests: tc: Add generic erspan_opts matching support for tc-flower") started triggering the following kmemleak warning:
unreferenced object 0xffff888015fb0e00 (size 512):
comm "softirq", pid 0, jiffies 4294679065 hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 40 d2 85 9e ff ff ff ff ........@.......
41 69 59 9d ff ff ff ff 00 00 00 00 00 00 00 00 AiY.............
backtrace (crc 30b71e8b):
__kmalloc_noprof+0x359/0x460
metadata_dst_alloc+0x28/0x490
erspan_rcv+0x4f1/0x1160 [ip_gre]
gre_rcv+0x217/0x240 [ip_gre]
gre_rcv+0x1b8/0x400 [gre]
ip_protocol_deliver_rcu+0x31d/0x3a0
ip_local_deliver_finish+0x37d/0x620
ip_local_deliver+0x174/0x460
ip_rcv+0x52b/0x6b0
__netif_receive_skb_one_core+0x149/0x1a0
process_backlog+0x3c8/0x1390
__napi_poll.constprop.0+0xa1/0x390
net_rx_action+0x59b/0xe00
handle_softirqs+0x22b/0x630
do_softirq+0xb1/0xf0
__local_bh_enable_ip+0x115/0x150vrf_ip6_input_dst unconditionally sets skb dst entry, add a call to skb_dst_drop to drop any existing entry.
--- drivers/net/vrf.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/vrf.c +2 -0
@@ -1364,6 +1364,8 @@ static void vrf_ip6_input_dst(struct sk_buff *skb, struct net_device *vrf_dev,struct net *net =dev_net (vrf_dev);struct rt6_info *rt6; +skb_dst_drop (skb); + rt6 =vrf_ip6_route_lookup (net, vrf_dev, &fl6, ifindex, skb,RT6_LOOKUP_F_HAS_SADDR |RT6_LOOKUP_F_IFACE );if (unlikely (!rt6))
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 165/644 PCI: rockchip-host: Fix "Unexpected Completion" log message
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Zhang <[email protected]>
[ Upstream commit fcc5f586c4edbcc10de23fb9b8c0972a84e945cd ]
Fix the debug message for the PCIE_CORE_INT_UCR interrupt to clearly indicate "Unexpected Completion" instead of a duplicate "malformed TLP" message.
--- drivers/pci/controller/pcie-rockchip-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-rockchip-host.c +1 -1
@@ -441,7 +441,7 @@ static irqreturn_t rockchip_pcie_subsys_irq_handler(int irq, void *arg)dev_dbg (dev,"malformed TLP received from the link\n" );if (sub_reg &PCIE_CORE_INT_UCR ) -dev_dbg (dev,"malformed TLP received from the link\n" ); +dev_dbg (dev,"Unexpected Completion received from the link\n" );if (sub_reg &PCIE_CORE_INT_FCE )dev_dbg (dev,"an error was observed in the flow control advertisements from the other side\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 166/644 crypto: marvell/cesa - Fix engine load inaccuracy
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 442134ab30e75b7229c4bfc1ac5641d245cffe27 ]
If an error occurs during queueing the engine load will never be decremented. Fix this by moving the engine load adjustment into the cleanup function.
--- drivers/crypto/marvell/cesa/cipher.c | 4 +++- drivers/crypto/marvell/cesa/hash.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/crypto/marvell/cesa/cipher.c +3 -1
@@ -75,9 +75,12 @@ mv_cesa_skcipher_dma_cleanup(struct skcipher_request *req)static inline void mv_cesa_skcipher_cleanup (struct skcipher_request *req) {struct mv_cesa_skcipher_req *creq =skcipher_request_ctx (req); +struct mv_cesa_engine *engine = creq->base.engine;if (mv_cesa_req_get_type (&creq->base) ==CESA_DMA_REQ )mv_cesa_skcipher_dma_cleanup (req); + +atomic_sub (req->cryptlen, &engine->load); }static void mv_cesa_skcipher_std_step (struct skcipher_request *req)
@@ -212,7 +215,6 @@ mv_cesa_skcipher_complete(struct crypto_async_request *req)struct mv_cesa_engine *engine = creq->base.engine;unsigned int ivsize; -atomic_sub (skreq->cryptlen, &engine->load); ivsize =crypto_skcipher_ivsize (crypto_skcipher_reqtfm (skreq));if (mv_cesa_req_get_type (&creq->base) ==CESA_DMA_REQ ) {
drivers/crypto/marvell/cesa/hash.c +3 -2
@@ -110,9 +110,12 @@ static inline void mv_cesa_ahash_dma_cleanup(struct ahash_request *req)static inline void mv_cesa_ahash_cleanup (struct ahash_request *req) {struct mv_cesa_ahash_req *creq =ahash_request_ctx (req); +struct mv_cesa_engine *engine = creq->base.engine;if (mv_cesa_req_get_type (&creq->base) ==CESA_DMA_REQ )mv_cesa_ahash_dma_cleanup (req); + +atomic_sub (req->nbytes, &engine->load); }static void mv_cesa_ahash_last_cleanup (struct ahash_request *req)
@@ -395,8 +398,6 @@ static void mv_cesa_ahash_complete(struct crypto_async_request *req) } } } - -atomic_sub (ahashreq->nbytes, &engine->load); } static void mv_cesa_ahash_prepare(struct crypto_async_request *req,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 167/644 mtd: fix possible integer overflow in erase_xfer()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Stepchenko <[email protected]>
[ Upstream commit 9358bdb9f9f54d94ceafc650deffefd737d19fdd ]
The expression '1 << EraseUnitSize' is evaluated in int, which causes a negative result when shifting by 31 - the upper bound of the valid range [10, 31], enforced by scan_header(). This leads to incorrect extension when storing the result in 'erase->len' (uint64_t), producing a large unexpected value.
Found by Linux Verification Center (linuxtesting.org) with Svace.
--- drivers/mtd/ftl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ftl.c +1 -1
@@ -344,7 +344,7 @@ static int erase_xfer(partition_t *part,return -ENOMEM ; erase->addr = xfer->Offset; - erase->len =1 << part->header.EraseUnitSize; + erase->len =1ULL << part->header.EraseUnitSize; ret =mtd_erase (part->mbd.mtd, erase);if (!ret) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 168/644 clk: davinci: Add NULL check in davinci_lpsc_clk_register()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 13de464f445d42738fe18c9a28bab056ba3a290a ]
devm_kasprintf() returns NULL when memory allocation fails. Currently, davinci_lpsc_clk_register() does not check for this case, which results in a NULL pointer dereference.
Add NULL check after devm_kasprintf() to prevent this issue and ensuring no resources are left allocated.
--- drivers/clk/davinci/psc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/davinci/psc.c +5 -0
@@ -278,6 +278,11 @@ davinci_lpsc_clk_register(struct device *dev, const char *name, lpsc->pm_domain.name =devm_kasprintf (dev,GFP_KERNEL ,"%s: %s" ,best_dev_name (dev), name); +if (!lpsc->pm_domain.name) { +clk_hw_unregister (&lpsc->hw); +kfree (lpsc); +return ERR_PTR (-ENOMEM ); + } lpsc->pm_domain.attach_dev = davinci_psc_genpd_attach_dev; lpsc->pm_domain.detach_dev = davinci_psc_genpd_detach_dev; lpsc->pm_domain.flags =GENPD_FLAG_PM_CLK ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 169/644 media: v4l2-ctrls: Fix H264 SEPARATE_COLOUR_PLANE check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Cowgill <[email protected]>
[ Upstream commit 803b9eabc649c778986449eb0596e5ffeb7a8aed ]
The separate_colour_plane_flag element is only present in the SPS if chroma_format_idc == 3, so the corresponding flag should be disabled whenever that is not the case and not just on profiles where chroma_format_idc is not present.
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls-core.c +4 -4
@@ -431,12 +431,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, p_h264_sps->flags &= ~V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS ; - -if (p_h264_sps->chroma_format_idc <3 ) - p_h264_sps->flags &= - ~V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE ; } +if (p_h264_sps->chroma_format_idc <3 ) + p_h264_sps->flags &= + ~V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE ; +if (p_h264_sps->flags &V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY ) p_h264_sps->flags &= ~V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 170/644 clk: xilinx: vcu: unregister pll_post only if registered correctly
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rohit Visavalia <[email protected]>
[ Upstream commit 3b0abc443ac22f7d4f61ddbbbbc5dbb06c87139d ]
If registration of pll_post is failed, it will be set to NULL or ERR, unregistering same will fail with following call trace:
Unable to handle kernel NULL pointer dereference at virtual address 008 pc : clk_hw_unregister+0xc/0x20 lr : clk_hw_unregister_fixed_factor+0x18/0x30 sp : ffff800011923850 ... Call trace: clk_hw_unregister+0xc/0x20 clk_hw_unregister_fixed_factor+0x18/0x30 xvcu_unregister_clock_provider+0xcc/0xf4 [xlnx_vcu] xvcu_probe+0x2bc/0x53c [xlnx_vcu]
--- drivers/clk/xilinx/xlnx_vcu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/xilinx/xlnx_vcu.c +2 -2
@@ -587,8 +587,8 @@ static void xvcu_unregister_clock_provider(struct xvcu_device *xvcu)xvcu_clk_hw_unregister_leaf (hws[CLK_XVCU_ENC_MCU ]);if (!IS_ERR_OR_NULL (hws[CLK_XVCU_ENC_CORE ]))xvcu_clk_hw_unregister_leaf (hws[CLK_XVCU_ENC_CORE ]); - -clk_hw_unregister_fixed_factor (xvcu->pll_post); +if (!IS_ERR_OR_NULL (xvcu->pll_post)) +clk_hw_unregister_fixed_factor (xvcu->pll_post); }/**
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 171/644 power: supply: cpcap-charger: Fix null check for power_supply_get_by_name
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit d9fa3aae08f99493e67fb79413c0e95d30fca5e9 ]
In the cpcap_usb_detect() function, the power_supply_get_by_name() function may return NULL instead of an error pointer. To prevent potential null pointer dereferences, Added a null check.
--- drivers/power/supply/cpcap-charger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/power/supply/cpcap-charger.c +2 -3
@@ -689,9 +689,8 @@ static void cpcap_usb_detect(struct work_struct *work)struct power_supply *battery; battery =power_supply_get_by_name ("battery" ); -if (IS_ERR_OR_NULL (battery)) { -dev_err (ddata->dev,"battery power_supply not available %li\n" , -PTR_ERR (battery)); +if (!battery) { +dev_err (ddata->dev,"battery power_supply not available\n" );return ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 172/644 power: supply: max14577: Handle NULL pdata when CONFIG_OF is not set
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit 2937f5d2e24eefef8cb126244caec7fe3307f724 ]
When the kernel is not configured CONFIG_OF, the max14577_charger_dt_init function returns NULL. Fix the max14577_charger_probe functionby returning -ENODATA instead of potentially passing a NULL pointer to PTR_ERR.
This fixes the below smatch warning:max14577_charger_probe() warn: passing zero to 'PTR_ERR'
--- drivers/power/supply/max14577_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/max14577_charger.c +2 -2
@@ -501,7 +501,7 @@ static struct max14577_charger_platform_data *max14577_charger_dt_init(static struct max14577_charger_platform_data *max14577_charger_dt_init (struct platform_device *pdev) { -return NULL ; +return ERR_PTR (-ENODATA ); }#endif /* CONFIG_OF */
@@ -572,7 +572,7 @@ static int max14577_charger_probe(struct platform_device *pdev) chg->max14577 = max14577; chg->pdata =max14577_charger_dt_init (pdev); -if (IS_ERR_OR_NULL (chg->pdata)) +if (IS_ERR (chg->pdata))return PTR_ERR (chg->pdata); ret =max14577_charger_reg_init (chg);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 173/644 PCI: endpoint: pci-epf-vntb: Return -ENOENT if pci_epc_get_next_free_bar() fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
[ Upstream commit 7ea488cce73263231662e426639dd3e836537068 ]
According the function documentation of epf_ntb_init_epc_bar(), the function should return an error code on error. However, it returns -1 when no BAR is available i.e., when pci_epc_get_next_free_bar() fails.
Return -ENOENT instead.
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
@@ -686,7 +686,7 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) barno =pci_epc_get_next_free_bar (epc_features, barno);if (barno <0 ) {dev_err (dev,"Fail to get NTB function BAR\n" ); -return barno; +return -ENOENT ; } ntb->epf_ntb_bar[bar] = barno; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 174/644 pinctrl: sunxi: Fix memory leak on krealloc failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit e3507c56cbb208d4f160942748c527ef6a528ba1 ]
In sunxi_pctrl_dt_node_to_map(), when krealloc() fails to resize the pinctrl_map array, the function returns -ENOMEM directly without freeing the previously allocated *map buffer. This results in a memory leak of the original kmalloc_array allocation.
--- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +8 -3
@@ -335,6 +335,7 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,const char *function, *pin_prop;const char *group;int ret, npins, nmaps, configlen =0 , i =0 ; +struct pinctrl_map *new_map; *map =NULL ; *num_maps =0 ;
@@ -409,9 +410,13 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,* We know have the number of maps we need, we can resize our * map array */ - *map =krealloc (*map, i *sizeof (struct pinctrl_map ),GFP_KERNEL ); -if (!*map) -return -ENOMEM ; + new_map =krealloc (*map, i *sizeof (struct pinctrl_map ),GFP_KERNEL ); +if (!new_map) { + ret = -ENOMEM ; + goto err_free_map; + } + + *map = new_map;return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 175/644 clk: clk-axi-clkgen: fix fpfd_max frequency for zynq
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sá <[email protected]>
[ Upstream commit ce8a9096699500e2c5bca09dde27b16edda5f636 ]
The fpfd_max frequency should be set to 450 MHz instead of 300 MHz. Well, it actually depends on the platform speed grade but we are being conservative for ultrascale so let's be consistent. In a following change we will set these limits at runtime.
--- drivers/clk/clk-axi-clkgen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-axi-clkgen.c +1 -1
@@ -118,7 +118,7 @@ static const struct axi_clkgen_limits axi_clkgen_zynqmp_default_limits = {static const struct axi_clkgen_limits axi_clkgen_zynq_default_limits = { .fpfd_min =10000 , - .fpfd_max =300000 , + .fpfd_max =450000 , .fvco_min =600000 , .fvco_max =1200000 , };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 176/644 perf sched: Fix memory leaks for evsel->priv in timehist
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 117e5c33b1c44037af016d77ce6c0b086d55535f ]
It uses evsel->priv to save per-cpu timing information. It should be freed when the evsel is released.
Add the priv destructor for evsel same as thread to handle that.
--- tools/perf/builtin-sched.c | 12 ++++++++++++ tools/perf/util/evsel.c | 11 +++++++++++ tools/perf/util/evsel.h | 2 ++ 3 files changed, 25 insertions(+)
tools/perf/builtin-sched.c +12 -0
@@ -1902,6 +1902,16 @@ static u64 evsel__get_time(struct evsel *evsel, u32 cpu)return r->last_time[cpu]; } +static void timehist__evsel_priv_destructor (void *priv) +{ +struct evsel_runtime *r = priv; + +if (r) { +free (r->last_time); +free (r); + } +} +static int comm_width =30 ;static char *timehist_get_commstr (struct thread *thread)
@@ -3039,6 +3049,8 @@ static int perf_sched__timehist(struct perf_sched *sched)setup_pager (); +evsel__set_priv_destructor (timehist__evsel_priv_destructor); +/* prefer sched_waking if it is captured */ if (evlist__find_tracepoint_by_name (session->evlist,"sched:sched_waking" )) handlers[1 ].handler = timehist_sched_wakeup_ignore;
tools/perf/util/evsel.c +11 -0
@@ -1416,6 +1416,15 @@ static void evsel__free_config_terms(struct evsel *evsel)free_config_terms (&evsel->config_terms); } +static void (*evsel__priv_destructor)(void *priv); + +void evsel__set_priv_destructor (void (*destructor)(void *priv)) +{ +assert (evsel__priv_destructor ==NULL ); + + evsel__priv_destructor = destructor; +} +void evsel__exit (struct evsel *evsel) {assert (list_empty (&evsel->core.node));
@@ -1436,6 +1445,8 @@ void evsel__exit(struct evsel *evsel)hashmap__free (evsel->per_pkg_mask); evsel->per_pkg_mask =NULL ;zfree (&evsel->metric_events); +if (evsel__priv_destructor) +evsel__priv_destructor (evsel->priv); perf_evsel__object.fini (evsel); }
tools/perf/util/evsel.h +2 -0
@@ -231,6 +231,8 @@ void evsel__init(struct evsel *evsel, struct perf_event_attr *attr, int idx);void evsel__exit (struct evsel *evsel);void evsel__delete (struct evsel *evsel); +void evsel__set_priv_destructor (void (*destructor)(void *priv)); +struct callchain_param ; void evsel__config(struct evsel *evsel, struct record_opts *opts,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 177/644 crypto: inside-secure - Fix `dma_unmap_sg()` nents value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit cb7fa6b6fc71e0c801e271aa498e2f19e6df2931 ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/crypto/inside-secure/safexcel_hash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/crypto/inside-secure/safexcel_hash.c +6 -2
@@ -249,7 +249,9 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv,safexcel_complete (priv, ring);if (sreq->nents) { -dma_unmap_sg (priv->dev, areq->src, sreq->nents,DMA_TO_DEVICE ); +dma_unmap_sg (priv->dev, areq->src, +sg_nents_for_len (areq->src, areq->nbytes), +DMA_TO_DEVICE ); sreq->nents =0 ; }
@@ -497,7 +499,9 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, DMA_FROM_DEVICE); unmap_sg:if (req->nents) { -dma_unmap_sg (priv->dev, areq->src, req->nents,DMA_TO_DEVICE ); +dma_unmap_sg (priv->dev, areq->src, +sg_nents_for_len (areq->src, areq->nbytes), +DMA_TO_DEVICE ); req->nents =0 ; } cdesc_rollback:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 178/644 crypto: ccp - Fix crash when rebind ccp device for ccp.ko
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mengbiao Xiong <[email protected]>
[ Upstream commit 181698af38d3f93381229ad89c09b5bd0496661a ]
When CONFIG_CRYPTO_DEV_CCP_DEBUGFS is enabled, rebinding the ccp device causes the following crash:
$ echo '0000:0a:00.2' > /sys/bus/pci/drivers/ccp/unbind $ echo '0000:0a:00.2' > /sys/bus/pci/drivers/ccp/bind
[ 204.976930] BUG: kernel NULL pointer dereference, address: 0000000000000098 [ 204.978026] #PF: supervisor write access in kernel mode [ 204.979126] #PF: error_code(0x0002) - not-present page [ 204.980226] PGD 0 P4D 0 [ 204.981317] Oops: Oops: 0002 [#1] SMP NOPTI ... [ 204.997852] Call Trace: [ 204.999074] <TASK> [ 205.000297] start_creating+0x9f/0x1c0 [ 205.001533] debugfs_create_dir+0x1f/0x170 [ 205.002769] ? srso_return_thunk+0x5/0x5f [ 205.004000] ccp5_debugfs_setup+0x87/0x170 [ccp] [ 205.005241] ccp5_init+0x8b2/0x960 [ccp] [ 205.006469] ccp_dev_init+0xd4/0x150 [ccp] [ 205.007709] sp_init+0x5f/0x80 [ccp] [ 205.008942] sp_pci_probe+0x283/0x2e0 [ccp] [ 205.010165] ? srso_return_thunk+0x5/0x5f [ 205.011376] local_pci_probe+0x4f/0xb0 [ 205.012584] pci_device_probe+0xdb/0x230 [ 205.013810] really_probe+0xed/0x380 [ 205.015024] __driver_probe_device+0x7e/0x160 [ 205.016240] device_driver_attach+0x2f/0x60 [ 205.017457] bind_store+0x7c/0xb0 [ 205.018663] drv_attr_store+0x28/0x40 [ 205.019868] sysfs_kf_write+0x5f/0x70 [ 205.021065] kernfs_fop_write_iter+0x145/0x1d0 [ 205.022267] vfs_write+0x308/0x440 [ 205.023453] ksys_write+0x6d/0xe0 [ 205.024616] __x64_sys_write+0x1e/0x30 [ 205.025778] x64_sys_call+0x16ba/0x2150 [ 205.026942] do_syscall_64+0x56/0x1e0 [ 205.028108] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 205.029276] RIP: 0033:0x7fbc36f10104 [ 205.030420] Code: 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 8d 05 e1 08 2e 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 f3 c3 66 90 41 54 55 49 89 d4 53 48 89 f5
This patch sets ccp_debugfs_dir to NULL after destroying it in ccp5_debugfs_destroy, allowing the directory dentry to be recreated when rebinding the ccp device.
Tested on AMD Ryzen 7 1700X.
--- drivers/crypto/ccp/ccp-debugfs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/ccp/ccp-debugfs.c +3 -0
@@ -319,5 +319,8 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)void ccp5_debugfs_destroy (void ) { +mutex_lock (&ccp_debugfs_lock);debugfs_remove_recursive (ccp_debugfs_dir); + ccp_debugfs_dir =NULL ; +mutex_unlock (&ccp_debugfs_lock); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 179/644 RDMA/hns: Fix -Wframe-larger-than issue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 79d56805c5068f2bc81518043e043c3dedd1c82a ]
Fix -Wframe-larger-than issue by allocating memory for qpc struct with kzalloc() instead of using stack memory.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +10 -5
@@ -5008,11 +5008,10 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp, {struct hns_roce_dev *hr_dev =to_hr_dev (ibqp->device);struct hns_roce_qp *hr_qp =to_hr_qp (ibqp); -struct hns_roce_v2_qp_context ctx[2 ]; -struct hns_roce_v2_qp_context *context = ctx; -struct hns_roce_v2_qp_context *qpc_mask = ctx +1 ; +struct hns_roce_v2_qp_context *context; +struct hns_roce_v2_qp_context *qpc_mask;struct ib_device *ibdev = &hr_dev->ib_dev; -int ret; +int ret = -ENOMEM ;if (attr_mask & ~IB_QP_ATTR_STANDARD_BITS )return -EOPNOTSUPP ;
@@ -5023,7 +5022,11 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,* we should set all bits of the relevant fields in context mask to * 0 at the same time, else set them to 0x1. */ -memset (context,0 , hr_dev->caps.qpc_sz); + context =kvzalloc (sizeof (*context),GFP_KERNEL ); + qpc_mask =kvzalloc (sizeof (*qpc_mask),GFP_KERNEL ); +if (!context || !qpc_mask) + goto out; +memset (qpc_mask,0xff , hr_dev->caps.qpc_sz); ret = hns_roce_v2_set_abs_fields(ibqp, attr, attr_mask, cur_state,
@@ -5065,6 +5068,8 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,clear_qp (hr_qp); out: +kvfree (qpc_mask); +kvfree (context);return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 180/644 kernel: trace: preemptirq_delay_test: use offstack cpu mask
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit adc353c0bfb243ebfd29b6222fa3bf149169a6de ]
A CPU mask on the stack is broken for large values of CONFIG_NR_CPUS:
kernel/trace/preemptirq_delay_test.c: In function ‘preemptirq_delay_run’:kernel/trace/preemptirq_delay_test.c:143:1: error: the frame size of 8512 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
Fall back to dynamic allocation here.
--- kernel/trace/preemptirq_delay_test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/trace/preemptirq_delay_test.c +9 -4
@@ -119,12 +119,15 @@ static int preemptirq_delay_run(void *data) {int i;int s =MIN (burst_size,NR_TEST_FUNCS ); -struct cpumask cpu_mask; +cpumask_var_t cpu_mask; + +if (!alloc_cpumask_var (&cpu_mask,GFP_KERNEL )) +return -ENOMEM ;if (cpu_affinity >-1 ) { -cpumask_clear (&cpu_mask); -cpumask_set_cpu (cpu_affinity, &cpu_mask); -if (set_cpus_allowed_ptr (current, &cpu_mask)) +cpumask_clear (cpu_mask); +cpumask_set_cpu (cpu_affinity, cpu_mask); +if (set_cpus_allowed_ptr (current, cpu_mask))pr_err ("cpu_affinity:%d, failed\n" , cpu_affinity); }
@@ -141,6 +144,8 @@ static int preemptirq_delay_run(void *data)__set_current_state (TASK_RUNNING ); +free_cpumask_var (cpu_mask); +return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 181/644 perf tests bp_account: Fix leaked file descriptor
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 4a6cdecaa1497f1fbbd1d5307a225b6ca5a62a90 ]
Since the commit e9846f5ead26 ("perf test: In forked mode add check that fds aren't leaked"), the test "Breakpoint accounting" reports the error:
# perf test -vvv "Breakpoint accounting" 20: Breakpoint accounting: --- start --- test child forked, pid 373 failed opening event 0 failed opening event 0 watchpoints count 4, breakpoints count 6, has_ioctl 1, share 0 wp 0 created wp 1 created wp 2 created wp 3 created wp 0 modified to bp wp max created ---- end(0) ---- Leak of file descriptor 7 that opened: 'anon_inode:[perf_event]'
A watchpoint's file descriptor was not properly released. This patch fixes the leak.
--- tools/perf/tests/bp_account.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/bp_account.c +1 -0
@@ -89,6 +89,7 @@ static int bp_accounting(int wp_cnt, int share) fd_wp =wp_event ((void *)&the_var, &attr_new);TEST_ASSERT_VAL ("failed to create max wp\n" , fd_wp !=-1 );pr_debug ("wp max created\n" ); +close (fd_wp); }for (i =0 ; i < wp_cnt; i++)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 182/644 clk: sunxi-ng: v3s: Fix de clock definition
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Kocialkowski <[email protected]>
[ Upstream commit e8ab346f9907a1a3aa2f0e5decf849925c06ae2e ]
The de clock is marked with CLK_SET_RATE_PARENT, which is really not necessary (as confirmed from experimentation) and significantly restricts flexibility for other clocks using the same parent.
In addition the source selection (parent) field is marked as using 2 bits, when it the documentation reports that it uses 3.
Fix both issues in the de clock definition.
--- drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +1 -2
@@ -345,8 +345,7 @@ static SUNXI_CCU_GATE(dram_ohci_clk, "dram-ohci", "dram",static const char *const de_parents[] = {"pll-video" ,"pll-periph0" }; static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, -0x104 ,0 ,4 ,24 ,2 ,BIT (31 ), - CLK_SET_RATE_PARENT); + 0x104, 0, 4, 24, 3, BIT(31), 0);static const char *const tcon_parents[] = {"pll-video" }; static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 183/644 scsi: ibmvscsi_tgt: Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 023a293b9cd0bb86a9b50cd7688a3d9d266826db ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/scsi/ibmvscsi_tgt/libsrp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/ibmvscsi_tgt/libsrp.c +4 -2
@@ -184,7 +184,8 @@ static int srp_direct_data(struct ibmvscsis_cmd *cmd, struct srp_direct_buf *md, err =rdma_io (cmd, sg, nsg, md,1 , dir, len);if (dma_map) -dma_unmap_sg (iue->target->dev, sg, nsg,DMA_BIDIRECTIONAL ); +dma_unmap_sg (iue->target->dev, sg, cmd->se_cmd.t_data_nents, +DMA_BIDIRECTIONAL );return err; }
@@ -256,7 +257,8 @@ static int srp_indirect_data(struct ibmvscsis_cmd *cmd, struct srp_cmd *srp_cmd, err =rdma_io (cmd, sg, nsg, md, nmd, dir, len);if (dma_map) -dma_unmap_sg (iue->target->dev, sg, nsg,DMA_BIDIRECTIONAL ); +dma_unmap_sg (iue->target->dev, sg, cmd->se_cmd.t_data_nents, +DMA_BIDIRECTIONAL ); free_mem:if (token && dma_map) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 184/644 scsi: mvsas: Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 0141618727bc929fe868153d21797f10ce5bef3f ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/scsi/mvsas/mv_sas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mvsas/mv_sas.c +2 -2
@@ -829,7 +829,7 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmfdev_printk (KERN_ERR , mvi->dev,"mvsas prep failed[%d]!\n" , rc);if (!sas_protocol_ata (task->task_proto))if (n_elem) -dma_unmap_sg (mvi->dev, task->scatter, n_elem, +dma_unmap_sg (mvi->dev, task->scatter, task->num_scatter, task->data_dir); prep_out:return rc;
@@ -880,7 +880,7 @@ static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,if (!sas_protocol_ata (task->task_proto))if (slot->n_elem)dma_unmap_sg (mvi->dev, task->scatter, - slot->n_elem, task->data_dir); + task->num_scatter, task->data_dir);switch (task->task_proto) {case SAS_PROTOCOL_SMP :
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 185/644 scsi: isci: Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 063bec4444d54e5f35d11949c5c90eaa1ff84c11 ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/scsi/isci/request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/isci/request.c +1 -1
@@ -2906,7 +2906,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost, task->total_xfer_len, task->data_dir); else /* unmap the sgl dma addresses */ dma_unmap_sg(&ihost->pdev->dev, task->scatter, - request->num_sg_entries, task->data_dir); + task->num_scatter, task->data_dir);break ;case SAS_PROTOCOL_SMP : {struct scatterlist *sg = &task->smp_task.smp_req;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 186/644 watchdog: ziirave_wdt: check record length in ziirave_firm_verify()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 8b61d8ca751bc15875b50e0ff6ac3ba0cf95a529 ]
The "rec->len" value comes from the firmware. We generally do trust firmware, but it's always better to double check. If the length value is too large it would lead to memory corruption when we set "data[i] = ret;"
--- drivers/watchdog/ziirave_wdt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/watchdog/ziirave_wdt.c +3 -0
@@ -302,6 +302,9 @@ static int ziirave_firm_verify(struct watchdog_device *wdd,const u16 len =be16_to_cpu (rec->len);const u32 addr =be32_to_cpu (rec->addr); +if (len >sizeof (data)) +return -EINVAL ; +if (ziirave_firm_addr_readonly (addr))continue ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 187/644 hwrng: mtk - handle devm_pm_runtime_enable errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit 522a242a18adc5c63a24836715dbeec4dc3faee1 ]
Although unlikely, devm_pm_runtime_enable() call might fail, so handle the return value.
--- drivers/char/hw_random/mtk-rng.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/mtk-rng.c +3 -1
@@ -142,7 +142,9 @@ static int mtk_rng_probe(struct platform_device *pdev)dev_set_drvdata (&pdev->dev, priv);pm_runtime_set_autosuspend_delay (&pdev->dev,RNG_AUTOSUSPEND_TIMEOUT );pm_runtime_use_autosuspend (&pdev->dev); -devm_pm_runtime_enable (&pdev->dev); + ret =devm_pm_runtime_enable (&pdev->dev); +if (ret) +return ret;dev_info (&pdev->dev,"registered RNG driver\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 188/644 crypto: keembay - Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 01951a7dc5ac1a37e5fb7d86ea7eb2dfbf96e8b6 ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/crypto/keembay/keembay-ocs-hcu-core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/crypto/keembay/keembay-ocs-hcu-core.c +7 -1
@@ -68,6 +68,7 @@ struct ocs_hcu_ctx {* @sg_data_total: Total data in the SG list at any time. * @sg_data_offset: Offset into the data of the current individual SG node. * @sg_dma_nents: Number of sg entries mapped in dma_list. +* @nents: Number of entries in the scatterlist. */ struct ocs_hcu_rctx {struct ocs_hcu_dev *hcu_dev;
@@ -91,6 +92,7 @@ struct ocs_hcu_rctx {unsigned int sg_data_total;unsigned int sg_data_offset;unsigned int sg_dma_nents; +unsigned int nents; };/**
@@ -199,7 +201,7 @@ static void kmb_ocs_hcu_dma_cleanup(struct ahash_request *req,/* Unmap req->src (if mapped). */ if (rctx->sg_dma_nents) { -dma_unmap_sg (dev, req->src, rctx->sg_dma_nents,DMA_TO_DEVICE ); +dma_unmap_sg (dev, req->src, rctx->nents,DMA_TO_DEVICE ); rctx->sg_dma_nents =0 ; }
@@ -260,6 +262,10 @@ static int kmb_ocs_dma_prepare(struct ahash_request *req) rc = -ENOMEM ; goto cleanup; } + +/* Save the value of nents to pass to dma_unmap_sg. */ + rctx->nents = nents; +/* * The value returned by dma_map_sg() can be < nents; so update * nents accordingly.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 189/644 crypto: img-hash - Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 34b283636181ce02c52633551f594fec9876bec7 ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/crypto/img-hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/img-hash.c +1 -1
@@ -436,7 +436,7 @@ static int img_hash_write_via_dma_stop(struct img_hash_dev *hdev)struct img_hash_request_ctx *ctx =ahash_request_ctx (hdev->req);if (ctx->flags &DRIVER_FLAGS_SG ) -dma_unmap_sg (hdev->dev, ctx->sg, ctx->dma_ct,DMA_TO_DEVICE ); +dma_unmap_sg (hdev->dev, ctx->sg,1 ,DMA_TO_DEVICE );return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 190/644 soundwire: stream: restore params when prepare ports fail
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bard Liao <[email protected]>
[ Upstream commit dba7d9dbfdc4389361ff3a910e767d3cfca22587 ]
The bus->params should be restored if the stream is failed to prepare. The issue exists since beginning. The Fixes tag just indicates the first commit that the commit can be applied to.
--- drivers/soundwire/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soundwire/stream.c +1 -1
@@ -1575,7 +1575,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,if (ret <0 ) {dev_err (bus->dev,"Prepare port(s) failed ret = %d\n" , ret); -return ret; + goto restore_params; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 191/644 PCI: endpoint: pci-epf-vntb: Fix the incorrect usage of __iomem attribute
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 61ae7f8694fb4b57a8c02a1a8d2b601806afc999 ]
__iomem attribute is supposed to be used only with variables holding the MMIO pointer. But here, 'mw_addr' variable is just holding a 'void *' returned by pci_epf_alloc_space(). So annotating it with __iomem is clearly wrong. Hence, drop the attribute.
This also fixes the below sparse warning:
drivers/pci/endpoint/functions/pci-epf-vntb.c:524:17: warning: incorrect type in assignment (different address spaces)
drivers/pci/endpoint/functions/pci-epf-vntb.c:524:17: expected void [noderef] __iomem *mw_addr
drivers/pci/endpoint/functions/pci-epf-vntb.c:524:17: got void *
drivers/pci/endpoint/functions/pci-epf-vntb.c:530:21: warning: incorrect type in assignment (different address spaces)
drivers/pci/endpoint/functions/pci-epf-vntb.c:530:21: expected unsigned int [usertype] *epf_db
drivers/pci/endpoint/functions/pci-epf-vntb.c:530:21: got void [noderef] __iomem *mw_addr
drivers/pci/endpoint/functions/pci-epf-vntb.c:542:38: warning: incorrect type in argument 2 (different address spaces)
drivers/pci/endpoint/functions/pci-epf-vntb.c:542:38: expected void *addr
drivers/pci/endpoint/functions/pci-epf-vntb.c:542:38: got void [noderef] __iomem *mw_addr
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
@@ -520,7 +520,7 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb)struct device *dev = &ntb->epf->dev;int ret;struct pci_epf_bar *epf_bar; -void __iomem *mw_addr; +void *mw_addr;enum pci_barno barno;size_t size =4 * ntb->db_count;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 192/644 fs/orangefs: Allow 2 more characters in do_c_string()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 2138e89cb066b40386b1d9ddd61253347d356474 ]
The do_k_string() and do_c_string() functions do essentially the same thing which is they add a string and a comma onto the end of an existing string. At the end, the caller will overwrite the last comma with a newline. Later, in orangefs_kernel_debug_init(), we add a newline to the string.
The change to do_k_string() is just cosmetic. I moved the "- 1" to the other side of the comparison and made it "+ 1". This has no effect on runtime, I just wanted the functions to match each other and the rest of the file.
However in do_c_string(), I removed the "- 2" which allows us to print two extra characters. I noticed this issue while reviewing the code and I doubt affects anything in real life. My guess is that this was double counting the comma and the newline. The "+ 1" accounts for the newline, and the caller will delete the final comma which ensures there is enough space for the newline.
Removing the "- 2" lets us print 2 more characters, but mainly it makes the code more consistent and understandable for reviewers.
--- fs/orangefs/orangefs-debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/orangefs/orangefs-debugfs.c +3 -3
@@ -728,8 +728,8 @@ static void do_k_string(void *k_mask, int index)if (*mask & s_kmod_keyword_mask_map[index].mask_val) {if ((strlen (kernel_debug_string) + -strlen (s_kmod_keyword_mask_map[index].keyword)) - <ORANGEFS_MAX_DEBUG_STRING_LEN -1 ) { +strlen (s_kmod_keyword_mask_map[index].keyword) +1 ) + <ORANGEFS_MAX_DEBUG_STRING_LEN ) {strcat (kernel_debug_string, s_kmod_keyword_mask_map[index].keyword);strcat (kernel_debug_string,"," );
@@ -756,7 +756,7 @@ static void do_c_string(void *c_mask, int index) (mask->mask2 & cdm_array[index].mask2)) {if ((strlen (client_debug_string) +strlen (cdm_array[index].keyword) +1 ) - <ORANGEFS_MAX_DEBUG_STRING_LEN -2 ) { + <ORANGEFS_MAX_DEBUG_STRING_LEN ) {strcat (client_debug_string, cdm_array[index].keyword);strcat (client_debug_string,"," );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 193/644 dmaengine: mv_xor: Fix missing check after DMA map and missing unmap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 60095aca6b471b7b7a79c80b7395f7e4e414b479 ]
The DMA map functions can fail and should be tested for errors.
In case of error, unmap the already mapped regions.
--- drivers/dma/mv_xor.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/dma/mv_xor.c +19 -2
@@ -1061,8 +1061,16 @@ mv_xor_channel_add(struct mv_xor_device *xordev,*/ mv_chan->dummy_src_addr =dma_map_single (dma_dev->dev, mv_chan->dummy_src,MV_XOR_MIN_BYTE_COUNT ,DMA_FROM_DEVICE ); +if (dma_mapping_error (dma_dev->dev, mv_chan->dummy_src_addr)) +return ERR_PTR (-ENOMEM ); + mv_chan->dummy_dst_addr =dma_map_single (dma_dev->dev, mv_chan->dummy_dst,MV_XOR_MIN_BYTE_COUNT ,DMA_TO_DEVICE ); +if (dma_mapping_error (dma_dev->dev, mv_chan->dummy_dst_addr)) { + ret = -ENOMEM ; + goto err_unmap_src; + } +/* allocate coherent memory for hardware descriptors * note: writecombine gives slightly better performance, but
@@ -1071,8 +1079,10 @@ mv_xor_channel_add(struct mv_xor_device *xordev, mv_chan->dma_desc_pool_virt =dma_alloc_wc (&pdev->dev,MV_XOR_POOL_SIZE , &mv_chan->dma_desc_pool,GFP_KERNEL ); -if (!mv_chan->dma_desc_pool_virt) -return ERR_PTR (-ENOMEM ); +if (!mv_chan->dma_desc_pool_virt) { + ret = -ENOMEM ; + goto err_unmap_dst; + }/* discover transaction capabilites from the platform data */ dma_dev->cap_mask = cap_mask;
@@ -1155,6 +1165,13 @@ mv_xor_channel_add(struct mv_xor_device *xordev, err_free_dma:dma_free_coherent (&pdev->dev,MV_XOR_POOL_SIZE , mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool); +err_unmap_dst: +dma_unmap_single (dma_dev->dev, mv_chan->dummy_dst_addr, +MV_XOR_MIN_BYTE_COUNT ,DMA_TO_DEVICE ); +err_unmap_src: +dma_unmap_single (dma_dev->dev, mv_chan->dummy_src_addr, +MV_XOR_MIN_BYTE_COUNT ,DMA_FROM_DEVICE ); +return ERR_PTR (ret); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 194/644 dmaengine: nbpfaxi: Add missing check after DMA map
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit c6ee78fc8f3e653bec427cfd06fec7877ee782bd ]
The DMA map functions can fail and should be tested for errors. If the mapping fails, unmap and return an error.
--- drivers/dma/nbpfaxi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/dma/nbpfaxi.c +13 -0
@@ -712,6 +712,9 @@ static int nbpf_desc_page_alloc(struct nbpf_channel *chan)list_add_tail (&ldesc->node, &lhead); ldesc->hwdesc_dma_addr =dma_map_single (dchan->device->dev, hwdesc,sizeof (*hwdesc),DMA_TO_DEVICE ); +if (dma_mapping_error (dchan->device->dev, + ldesc->hwdesc_dma_addr)) + goto unmap_error;dev_dbg (dev,"%s(): mapped 0x%p to %pad\n" , __func__, hwdesc, &ldesc->hwdesc_dma_addr);
@@ -738,6 +741,16 @@ static int nbpf_desc_page_alloc(struct nbpf_channel *chan)spin_unlock_irq (&chan->lock);return ARRAY_SIZE (dpage->desc); + +unmap_error: +while (i--) { + ldesc--; hwdesc--; + +dma_unmap_single (dchan->device->dev, ldesc->hwdesc_dma_addr, +sizeof (hwdesc),DMA_TO_DEVICE ); + } + +return -ENOMEM ; }static void nbpf_desc_put (struct nbpf_desc *desc)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 195/644 sh: Do not use hyphen in exported variable name
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
[ Upstream commit c32969d0362a790fbc6117e0b6a737a7e510b843 ]
arch/sh/Makefile defines and exports ld-bfd to be used by arch/sh/boot/compressed/Makefile and arch/sh/boot/romimage/Makefile. However some shells, including dash, will not pass through environment variables whose name includes a hyphen. Usually GNU make does not use a shell to recurse, but if e.g. $(srctree) contains '~' it will use a shell here.
Other instances of this problem were previously fixed by commits 2bfbe7881ee0 "kbuild: Do not use hyphen in exported variable name" and 82977af93a0d "sh: rename suffix-y to suffix_y".
Rename the variable to ld_bfd.
References: https://buildd.debian.org/status/fetch.php?pkg=linux&arch=sh4&ver=4.13%7Erc5-1%7Eexp1&stamp=1502943967&raw=0
--- arch/sh/Makefile | 10 +++++----- arch/sh/boot/compressed/Makefile | 4 ++-- arch/sh/boot/romimage/Makefile | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
arch/sh/Makefile +5 -5
@@ -103,16 +103,16 @@ UTS_MACHINE := sh LDFLAGS_vmlinux += -e _stext ifdef CONFIG_CPU_LITTLE_ENDIAN -ld-bfd := elf32-sh-linux -LDFLAGS_vmlinux += --defsym jiffies=jiffies_64 --oformat $(ld-bfd) +ld_bfd := elf32-sh-linux +LDFLAGS_vmlinux += --defsym jiffies=jiffies_64 --oformat $(ld_bfd) KBUILD_LDFLAGS += -EL else -ld-bfd := elf32-shbig-linux -LDFLAGS_vmlinux += --defsym jiffies=jiffies_64+4 --oformat $(ld-bfd) +ld_bfd := elf32-shbig-linux +LDFLAGS_vmlinux += --defsym jiffies=jiffies_64+4 --oformat $(ld_bfd) KBUILD_LDFLAGS += -EB endif -export ld-bfd +export ld_bfd head-y := arch/sh/kernel/head_32.o
arch/sh/boot/compressed/Makefile +2 -2
@@ -30,7 +30,7 @@ endif ccflags-remove-$(CONFIG_MCOUNT) += -pg -LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ +LDFLAGS_vmlinux := --oformat $(ld_bfd) -Ttext $(IMAGE_OFFSET) -e startup \ -T $(obj)/../../kernel/vmlinux.lds #
@@ -68,7 +68,7 @@ $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE OBJCOPYFLAGS += -R .empty_zero_page -LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T +LDFLAGS_piggy.o := -r --format binary --oformat $(ld_bfd) -T $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE $(call if_changed,ld)
arch/sh/boot/romimage/Makefile +2 -2
@@ -13,7 +13,7 @@ mmcif-obj-$(CONFIG_CPU_SUBTYPE_SH7724) := $(obj)/mmcif-sh7724.o load-$(CONFIG_ROMIMAGE_MMCIF) := $(mmcif-load-y) obj-$(CONFIG_ROMIMAGE_MMCIF) := $(mmcif-obj-y) -LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(load-y) -e romstart \ +LDFLAGS_vmlinux := --oformat $(ld_bfd) -Ttext $(load-y) -e romstart \ -T $(obj)/../../kernel/vmlinux.lds $(obj)/vmlinux: $(obj)/head.o $(obj-y) $(obj)/piggy.o FORCE
@@ -24,7 +24,7 @@ OBJCOPYFLAGS += -j .empty_zero_page $(obj)/zeropage.bin: vmlinux FORCE $(call if_changed,objcopy) -LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T +LDFLAGS_piggy.o := -r --format binary --oformat $(ld_bfd) -T $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/zeropage.bin arch/sh/boot/zImage FORCE $(call if_changed,ld)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 196/644 crypto: qat - fix seq_file position update in adf_ring_next()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Giovanni Cabiddu <[email protected]>
[ Upstream commit 6908c5f4f066a0412c3d9a6f543a09fa7d87824b ]
The adf_ring_next() function in the QAT debug transport interface fails to correctly update the position index when reaching the end of the ring elements. This triggers the following kernel warning when reading ring files, such as /sys/kernel/debug/qat_c6xx_<D:B:D:F>/transport/bank_00/ring_00:
[27725.022965] seq_file: buggy .next function adf_ring_next [intel_qat] did not update position index
Ensure that the *pos index is incremented before returning NULL when after the last element in the ring is found, satisfying the seq_file API requirements and preventing the warning.
--- drivers/crypto/qat/qat_common/adf_transport_debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_transport_debug.c +3 -1
@@ -31,8 +31,10 @@ static void *adf_ring_next(struct seq_file *sfile, void *v, loff_t *pos)struct adf_etr_ring_data *ring = sfile->private;if (*pos >= (ADF_SIZE_TO_RING_SIZE_IN_BYTES (ring->ring_size) / -ADF_MSG_SIZE_TO_BYTES (ring->msg_size))) +ADF_MSG_SIZE_TO_BYTES (ring->msg_size))) { + (*pos)++;return NULL ; + }return ring->base_addr + (ADF_MSG_SIZE_TO_BYTES (ring->msg_size) * (*pos)++);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 197/644 fbdev: imxfb: Check fb_add_videomode to prevent null-ptr-deref
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
[ Upstream commit da11e6a30e0bb8e911288bdc443b3dc8f6a7cac7 ]
fb_add_videomode() can fail with -ENOMEM when its internal kmalloc() cannot allocate a struct fb_modelist. If that happens, the modelist stays empty but the driver continues to register. Add a check for its return value to prevent poteintial null-ptr-deref, which is similar to the commit 17186f1f90d3 ("fbdev:
Fix do_register_framebuffer to prevent null-ptr-deref in fb_videomode_to_var").
--- drivers/video/fbdev/imxfb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/video/fbdev/imxfb.c +7 -2
@@ -1007,8 +1007,13 @@ static int imxfb_probe(struct platform_device *pdev)INIT_LIST_HEAD (&info->modelist); -for (i =0 ; i < fbi->num_modes; i++) -fb_add_videomode (&fbi->mode[i].mode, &info->modelist); +for (i =0 ; i < fbi->num_modes; i++) { + ret =fb_add_videomode (&fbi->mode[i].mode, &info->modelist); +if (ret) { +dev_err (&pdev->dev,"Failed to add videomode\n" ); + goto failed_cmap; + } + }/* * This makes sure that our colour bitfield
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 198/644 jfs: fix metapage reference count leak in dbAllocCtl
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Yu <[email protected]>
[ Upstream commit 856db37592021e9155384094e331e2d4589f28b1 ]
In dbAllocCtl(), read_metapage() increases the reference count of the metapage. However, when dp->tree.budmin < 0, the function returns -EIO without calling release_metapage() to decrease the reference count, leading to a memory leak.
Add release_metapage(mp) before the error return to properly manage the metapage reference count and prevent the leak.
--- fs/jfs/jfs_dmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +3 -1
@@ -1877,8 +1877,10 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)return -EIO ; dp = (struct dmap *) mp->data; -if (dp->tree.budmin <0 ) +if (dp->tree.budmin <0 ) { +release_metapage (mp);return -EIO ; + }/* try to allocate the blocks. */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 199/644 mtd: rawnand: atmel: Fix dma_mapping_error() address
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit e1e6b933c56b1e9fda93caa0b8bae39f3f421e5c ]
It seems like what was intended is to test if the dma_map of the previous line failed but the wrong dma address was passed.
Rule: add
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
@@ -373,7 +373,7 @@ static int atmel_nand_dma_transfer(struct atmel_nand_controller *nc,dma_cookie_t cookie; buf_dma =dma_map_single (nc->dev, buf, len, dir); -if (dma_mapping_error (nc->dev, dev_dma)) { +if (dma_mapping_error (nc->dev, buf_dma)) {dev_err (nc->dev,"Failed to prepare a buffer for DMA access\n" ); goto err;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 200/644 mtd: rawnand: rockchip: Add missing check after DMA map
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 3b36f86dc47261828f96f826077131a35dd825fd ]
The DMA map functions can fail and should be tested for errors.
--- drivers/mtd/nand/raw/rockchip-nand-controller.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/mtd/nand/raw/rockchip-nand-controller.c +15 -0
@@ -657,9 +657,16 @@ static int rk_nfc_write_page_hwecc(struct nand_chip *chip, const u8 *buf, dma_data =dma_map_single (nfc->dev, (void *)nfc->page_buf, mtd->writesize,DMA_TO_DEVICE ); +if (dma_mapping_error (nfc->dev, dma_data)) +return -ENOMEM ; + dma_oob =dma_map_single (nfc->dev, nfc->oob_buf, ecc->steps * oob_step,DMA_TO_DEVICE ); +if (dma_mapping_error (nfc->dev, dma_oob)) { +dma_unmap_single (nfc->dev, dma_data, mtd->writesize,DMA_TO_DEVICE ); +return -ENOMEM ; + }reinit_completion (&nfc->done);writel (INT_DMA , nfc->regs + nfc->cfg->int_en_off);
@@ -773,9 +780,17 @@ static int rk_nfc_read_page_hwecc(struct nand_chip *chip, u8 *buf, int oob_on, dma_data =dma_map_single (nfc->dev, nfc->page_buf, mtd->writesize,DMA_FROM_DEVICE ); +if (dma_mapping_error (nfc->dev, dma_data)) +return -ENOMEM ; + dma_oob =dma_map_single (nfc->dev, nfc->oob_buf, ecc->steps * oob_step,DMA_FROM_DEVICE ); +if (dma_mapping_error (nfc->dev, dma_oob)) { +dma_unmap_single (nfc->dev, dma_data, mtd->writesize, +DMA_FROM_DEVICE ); +return -ENOMEM ; + }/* * The first blocks (4, 8 or 16 depending on the device)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 201/644 mtd: rawnand: atmel: set pmecc data setup time
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balamanikandan Gunasundar <[email protected]>
[ Upstream commit f552a7c7e0a14215cb8a6fd89e60fa3932a74786 ]
Setup the pmecc data setup time as 3 clock cycles for 133MHz as recommended by the datasheet.
--- drivers/mtd/nand/raw/atmel/pmecc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mtd/nand/raw/atmel/pmecc.c +6 -0
@@ -143,6 +143,7 @@ struct atmel_pmecc_caps {int nstrengths;int el_offset;bool correct_erased_chunks; +bool clk_ctrl; };struct atmel_pmecc {
@@ -846,6 +847,10 @@ static struct atmel_pmecc *atmel_pmecc_create(struct platform_device *pdev,if (IS_ERR (pmecc->regs.errloc))return ERR_CAST (pmecc->regs.errloc); +/* pmecc data setup time */ +if (caps->clk_ctrl) +writel (PMECC_CLK_133MHZ , pmecc->regs.base +ATMEL_PMECC_CLK ); +/* Disable all interrupts before registering the PMECC handler. */ writel (0xffffffff , pmecc->regs.base +ATMEL_PMECC_IDR );atmel_pmecc_reset (pmecc);
@@ -899,6 +904,7 @@ static struct atmel_pmecc_caps at91sam9g45_caps = { .strengths = atmel_pmecc_strengths, .nstrengths = 5, .el_offset = 0x8c, + .clk_ctrl = true, };static struct atmel_pmecc_caps sama5d4_caps = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 202/644 vhost-scsi: Fix log flooding with target does not exist errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Christie <[email protected]>
[ Upstream commit 69cd720a8a5e9ef0f05ce5dd8c9ea6e018245c82 ]
As part of the normal initiator side scanning the guest's scsi layer will loop over all possible targets and send an inquiry. Since the max number of targets for virtio-scsi is 256, this can result in 255 error messages about targets not existing if you only have a single target. When there's more than 1 vhost-scsi device each with a single target, then you get N * 255 log messages.
It looks like the log message was added by accident in:
commit 3f8ca2e115e5 ("vhost/scsi: Extract common handling code from control queue handler")
when we added common helpers. Then in:
commit 09d7583294aa ("vhost/scsi: Use common handling code in request queue handler")
we converted the scsi command processing path to use the new helpers so we started to see the extra log messages during scanning.
The patches were just making some code common but added the vq_err call and I'm guessing the patch author forgot to enable the vq_err call (vq_err is implemented by pr_debug which defaults to off). So this patch removes the call since it's expected to hit this path during device discovery.
Message-Id: <[email protected]>
--- drivers/vhost/scsi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/vhost/scsi.c +1 -3
@@ -907,10 +907,8 @@ vhost_scsi_get_req(struct vhost_virtqueue *vq, struct vhost_scsi_ctx *vc,/* validated at handler entry */ vs_tpg =vhost_vq_get_backend (vq); tpg =READ_ONCE (vs_tpg[*vc->target]); -if (unlikely (!tpg)) { -vq_err (vq,"Target 0x%x does not exist\n" , *vc->target); +if (unlikely (!tpg)) goto out; - } }if (tpgp)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 203/644 bpf: Check flow_dissector ctx accesses are aligned
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Chaignon <[email protected]>
[ Upstream commit ead3d7b2b6afa5ee7958620c4329982a7d9c2b78 ]
flow_dissector_is_valid_access doesn't check that the context access is aligned. As a consequence, an unaligned access within one of the exposed field is considered valid and later rejected by flow_dissector_convert_ctx_access when we try to convert it.
The later rejection is problematic because it's reported as a verifier bug with a kernel warning and doesn't point to the right instruction in verifier logs.
--- net/core/filter.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/filter.c +3 -0
@@ -8764,6 +8764,9 @@ static bool flow_dissector_is_valid_access(int off, int size,if (off <0 || off >=sizeof (struct __sk_buff ))return false; +if (off % size !=0 ) +return false; +if (type ==BPF_WRITE )return false;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 204/644 apparmor: ensure WB_HISTORY_SIZE value is a power of 2
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Lee <[email protected]>
[ Upstream commit 6c055e62560b958354625604293652753d82bcae ]
WB_HISTORY_SIZE was defined to be a value not a power of 2, despite a comment in the declaration of struct match_workbuf stating it is and a modular arithmetic usage in the inc_wb_pos macro assuming that it is. Bump WB_HISTORY_SIZE's value up to 32 and add a BUILD_BUG_ON_NOT_POWER_OF_2 line to ensure that any future changes to the value of WB_HISTORY_SIZE respect this requirement.
--- security/apparmor/include/match.h | 3 ++- security/apparmor/match.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
security/apparmor/include/match.h +2 -1
@@ -141,7 +141,8 @@ unsigned int aa_dfa_matchn_until(struct aa_dfa *dfa, unsigned int start,void aa_dfa_free_kref (struct kref *kref); -#define WB_HISTORY_SIZE 24 +/* This needs to be a power of 2 */ +#define WB_HISTORY_SIZE 32struct match_workbuf {unsigned int count;unsigned int pos;
security/apparmor/match.c +1 -0
@@ -672,6 +672,7 @@ unsigned int aa_dfa_matchn_until(struct aa_dfa *dfa, unsigned int start,#define inc_wb_pos (wb) \ do { \ + BUILD_BUG_ON_NOT_POWER_OF_2(WB_HISTORY_SIZE); \ wb->pos = (wb->pos + 1) & (WB_HISTORY_SIZE - 1); \ wb->len = (wb->len + 1) & (WB_HISTORY_SIZE - 1); \ } while (0)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 205/644 module: Restore the moduleparam prefix length check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Pavlu <[email protected]>
[ Upstream commit bdc877ba6b7ff1b6d2ebeff11e63da4a50a54854 ]
The moduleparam code allows modules to provide their own definition of MODULE_PARAM_PREFIX, instead of using the default KBUILD_MODNAME ".".
Commit 730b69d22525 ("module: check kernel param length at compile time, not runtime") added a check to ensure the prefix doesn't exceed MODULE_NAME_LEN, as this is what param_sysfs_builtin() expects.
Later, commit 58f86cc89c33 ("VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.") removed this check, but there is no indication this was intentional.
Since the check is still useful for param_sysfs_builtin() to function properly, reintroduce it in __module_param_call(), but in a modernized form using static_assert().
While here, clean up the __module_param_call() comments. In particular, remove the comment "Default value instead of permissions?", which comes from commit 9774a1f54f17 ("[PATCH] Compile-time check re world-writeable module params"). This comment was related to the test variable __param_perm_check_##name, which was removed in the previously mentioned commit 58f86cc89c33.
--- include/linux/moduleparam.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/moduleparam.h +2 -3
@@ -282,10 +282,9 @@ struct kparam_array#define __moduleparam_const const#endif -/* This is the fundamental function for registering boot/module -parameters. */ +/* This is the fundamental function for registering boot/module parameters. */ #define __module_param_call (prefix, name, ops, arg, perm, level, flags) \ -/* Default value instead of permissions? */ \ + static_assert(sizeof(""prefix) - 1 <= MAX_PARAM_PREFIX_LEN); \ static const char __param_str_##name[] = prefix #name; \ static struct kernel_param __moduleparam_const __param_##name \ __used __section("__param") \
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 206/644 ucount: fix atomic_long_inc_below() argument type
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uros Bizjak <[email protected]>
[ Upstream commit f8cd9193b62e92ad25def5370ca8ea2bc7585381 ]
The type of u argument of atomic_long_inc_below() should be long to avoid unwanted truncation to int.
The patch fixes the wrong argument type of an internal function to prevent unwanted argument truncation. It fixes an internal locking primitive; it should not have any direct effect on userspace.
Mark said
: AFAICT there's no problem in practice because atomic_long_inc_below() : is only used by inc_ucount(), and it looks like the value is : constrained between 0 and INT_MAX.
:
: In inc_ucount() the limit value is taken from
: user_namespace::ucount_max[], and AFAICT that's only written by : sysctls, to the table setup by setup_userns_sysctls(), where : UCOUNT_ENTRY() limits the value between 0 and INT_MAX.
:
: This is certainly a cleanup, but there might be no functional issue in : practice as above.
--- kernel/ucount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/ucount.c +1 -1
@@ -210,7 +210,7 @@ void put_ucounts(struct ucounts *ucounts) } } -static inline bool atomic_long_inc_below (atomic_long_t *v,int u) +static inline bool atomic_long_inc_below (atomic_long_t *v,long u) {long c, old; c =atomic_long_read (v);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 207/644 rtc: ds1307: fix incorrect maximum clock rate handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
[ Upstream commit cf6eb547a24af7ad7bbd2abe9c5327f956bbeae8 ]
When ds3231_clk_sqw_round_rate() is called with a requested rate higher than the highest supported rate, it currently returns 0, which disables the clock. According to the clk API, round_rate() should instead return the highest supported rate. Update the function to return the maximum supported rate in this case.
--- drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1307.c +1 -1
@@ -1461,7 +1461,7 @@ static long ds3231_clk_sqw_round_rate(struct clk_hw *hw, unsigned long rate,return ds3231_clk_sqw_rates[i]; } -return 0 ; +return ds3231_clk_sqw_rates[ARRAY_SIZE (ds3231_clk_sqw_rates) -1 ]; } static int ds3231_clk_sqw_set_rate(struct clk_hw *hw, unsigned long rate,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 208/644 rtc: hym8563: fix incorrect maximum clock rate handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
[ Upstream commit d0a518eb0a692a2ab8357e844970660c5ea37720 ]
When hym8563_clkout_round_rate() is called with a requested rate higher than the highest supported rate, it currently returns 0, which disables the clock. According to the clk API, round_rate() should instead return the highest supported rate. Update the function to return the maximum supported rate in this case.
--- drivers/rtc/rtc-hym8563.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-hym8563.c +1 -1
@@ -312,7 +312,7 @@ static long hym8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,if (clkout_rates[i] <= rate)return clkout_rates[i]; -return 0 ; +return clkout_rates[0 ]; } static int hym8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 209/644 rtc: pcf85063: fix incorrect maximum clock rate handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
[ Upstream commit 186ae1869880e58bb3f142d222abdb35ecb4df0f ]
When pcf85063_clkout_round_rate() is called with a requested rate higher than the highest supported rate, it currently returns 0, which disables the clock. According to the clk API, round_rate() should instead return the highest supported rate. Update the function to return the maximum supported rate in this case.
--- drivers/rtc/rtc-pcf85063.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf85063.c +1 -1
@@ -407,7 +407,7 @@ static long pcf85063_clkout_round_rate(struct clk_hw *hw, unsigned long rate,if (clkout_rates[i] <= rate)return clkout_rates[i]; -return 0 ; +return clkout_rates[0 ]; } static int pcf85063_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 210/644 rtc: pcf8563: fix incorrect maximum clock rate handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
[ Upstream commit 906726a5efeefe0ef0103ccff5312a09080c04ae ]
When pcf8563_clkout_round_rate() is called with a requested rate higher than the highest supported rate, it currently returns 0, which disables the clock. According to the clk API, round_rate() should instead return the highest supported rate. Update the function to return the maximum supported rate in this case.
--- drivers/rtc/rtc-pcf8563.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf8563.c +1 -1
@@ -399,7 +399,7 @@ static long pcf8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,if (clkout_rates[i] <= rate)return clkout_rates[i]; -return 0 ; +return clkout_rates[0 ]; } static int pcf8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 211/644 rtc: rv3028: fix incorrect maximum clock rate handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
[ Upstream commit b574acb3cf7591d2513a9f29f8c2021ad55fb881 ]
When rv3028_clkout_round_rate() is called with a requested rate higher than the highest supported rate, it currently returns 0, which disables the clock. According to the clk API, round_rate() should instead return the highest supported rate. Update the function to return the maximum supported rate in this case.
--- drivers/rtc/rtc-rv3028.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-rv3028.c +1 -1
@@ -669,7 +669,7 @@ static long rv3028_clkout_round_rate(struct clk_hw *hw, unsigned long rate,if (clkout_rates[i] <= rate)return clkout_rates[i]; -return 0 ; +return clkout_rates[0 ]; } static int rv3028_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 212/644 f2fs: fix KMSAN uninit-value in extent_info usage
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abinash Singh <[email protected]>
[ Upstream commit 154467f4ad033473e5c903a03e7b9bca7df9a0fa ]
KMSAN reported a use of uninitialized value in __is_extent_mergeable()
and __is_back_mergeable() via the read extent tree path.
The root cause is that get_read_extent_info() only initializes three fields (fofs, blk, len) of struct extent_info, leaving the remaining fields uninitialized. This leads to undefined behavior when those fields are accessed later, especially during extent merging.
Fix it by zero-initializing the extent_info struct before population.
--- fs/f2fs/extent_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/extent_cache.c +1 -1
@@ -365,7 +365,7 @@ static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage)struct f2fs_extent *i_ext = ipage ? &F2FS_INODE (ipage)->i_ext :NULL ;struct extent_tree *et;struct extent_node *en; -struct extent_info ei; +struct extent_info ei = {0 };if (!f2fs_may_extent_tree (inode)) {/* drop largest extent */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 213/644 f2fs: doc: fix wrong quota mount option description
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 81b6ecca2f15922e8d653dc037df5871e754be6e ]
We should use "{usr,grp,prj}jquota=" to disable journaled quota, rather than using off{usr,grp,prj}jquota.
--- Documentation/filesystems/f2fs.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/filesystems/f2fs.rst +3 -3
@@ -211,9 +211,9 @@ usrjquota=<file> Appoint specified file and type during mount, so that quota grpjquota=<file> information can be properly updated during recovery flow, prjjquota=<file> <quota file>: must be in root directory; jqfmt=<quota type> <quota type>: [vfsold,vfsv0,vfsv1]. -offusrjquota Turn off user journalled quota. -offgrpjquota Turn off group journalled quota. -offprjjquota Turn off project journalled quota. +usrjquota= Turn off user journalled quota. +grpjquota= Turn off group journalled quota. +prjjquota= Turn off project journalled quota. quota Enable plain user disk quota accounting. noquota Disable all plain disk quota option. whint_mode=%s Control which write hints are passed down to block
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 214/644 f2fs: fix to avoid UAF in f2fs_sync_inode_meta()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 7c30d79930132466f5be7d0b57add14d1a016bda ]
syzbot reported an UAF issue as below: [1] [2]
[1] https://syzkaller.appspot.com/text?tag=CrashReport&x=16594c60580000
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0xa6/0x130 lib/list_debug.c:62 Read of size 8 at addr ffff888100567dc8 by task kworker/u4:0/8 CPU: 1 PID: 8 Comm: kworker/u4:0 Tainted: G W 6.1.129-syzkaller-00017-g642656a36791 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Workqueue: writeback wb_workfn (flush-7:0) Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0x158/0x4e0 mm/kasan/report.c:427 kasan_report+0x13c/0x170 mm/kasan/report.c:531 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:351 __list_del_entry_valid+0xa6/0x130 lib/list_debug.c:62 __list_del_entry include/linux/list.h:134 [inline] list_del_init include/linux/list.h:206 [inline] f2fs_inode_synced+0x100/0x2e0 fs/f2fs/super.c:1553 f2fs_update_inode+0x72/0x1c40 fs/f2fs/inode.c:588 f2fs_update_inode_page+0x135/0x170 fs/f2fs/inode.c:706 f2fs_write_inode+0x416/0x790 fs/f2fs/inode.c:734 write_inode fs/fs-writeback.c:1460 [inline] __writeback_single_inode+0x4cf/0xb80 fs/fs-writeback.c:1677 writeback_sb_inodes+0xb32/0x1910 fs/fs-writeback.c:1903 __writeback_inodes_wb+0x118/0x3f0 fs/fs-writeback.c:1974 wb_writeback+0x3da/0xa00 fs/fs-writeback.c:2081 wb_check_background_flush fs/fs-writeback.c:2151 [inline] wb_do_writeback fs/fs-writeback.c:2239 [inline] wb_workfn+0xbba/0x1030 fs/fs-writeback.c:2266 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446 kthread+0x26d/0x300 kernel/kthread.c:386 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 </TASK> Allocated by task 298: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:333 kasan_slab_alloc include/linux/kasan.h:202 [inline] slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768 slab_alloc_node mm/slub.c:3421 [inline] slab_alloc mm/slub.c:3431 [inline] __kmem_cache_alloc_lru mm/slub.c:3438 [inline] kmem_cache_alloc_lru+0x102/0x270 mm/slub.c:3454 alloc_inode_sb include/linux/fs.h:3255 [inline] f2fs_alloc_inode+0x2d/0x350 fs/f2fs/super.c:1437 alloc_inode fs/inode.c:261 [inline] iget_locked+0x18c/0x7e0 fs/inode.c:1373 f2fs_iget+0x55/0x4ca0 fs/f2fs/inode.c:486 f2fs_lookup+0x3c1/0xb50 fs/f2fs/namei.c:484 __lookup_slow+0x2b9/0x3e0 fs/namei.c:1689 lookup_slow+0x5a/0x80 fs/namei.c:1706 walk_component+0x2e7/0x410 fs/namei.c:1997 lookup_last fs/namei.c:2454 [inline] path_lookupat+0x16d/0x450 fs/namei.c:2478 filename_lookup+0x251/0x600 fs/namei.c:2507 vfs_statx+0x107/0x4b0 fs/stat.c:229 vfs_fstatat fs/stat.c:267 [inline] vfs_lstat include/linux/fs.h:3434 [inline] __do_sys_newlstat fs/stat.c:423 [inline] __se_sys_newlstat+0xda/0x7c0 fs/stat.c:417 __x64_sys_newlstat+0x5b/0x70 fs/stat.c:417 x64_sys_call+0x52/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:7 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3b/0x80 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Freed by task 0: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249 kasan_slab_free include/linux/kasan.h:178 [inline] slab_free_hook mm/slub.c:1745 [inline] slab_free_freelist_hook mm/slub.c:1771 [inline] slab_free mm/slub.c:3686 [inline] kmem_cache_free+0x291/0x560 mm/slub.c:3711 f2fs_free_inode+0x24/0x30 fs/f2fs/super.c:1584 i_callback+0x4b/0x70 fs/inode.c:250 rcu_do_batch+0x552/0xbe0 kernel/rcu/tree.c:2297 rcu_core+0x502/0xf40 kernel/rcu/tree.c:2557 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2574 handle_softirqs+0x1db/0x650 kernel/softirq.c:624 __do_softirq kernel/softirq.c:662 [inline] invoke_softirq kernel/softirq.c:479 [inline] __irq_exit_rcu+0x52/0xf0 kernel/softirq.c:711 irq_exit_rcu+0x9/0x10 kernel/softirq.c:723 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline] sysvec_apic_timer_interrupt+0xa9/0xc0 arch/x86/kernel/apic/apic.c:1118 asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:691 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496 __call_rcu_common kernel/rcu/tree.c:2807 [inline] call_rcu+0xdc/0x10f0 kernel/rcu/tree.c:2926 destroy_inode fs/inode.c:316 [inline] evict+0x87d/0x930 fs/inode.c:720 iput_final fs/inode.c:1834 [inline] iput+0x616/0x690 fs/inode.c:1860 do_unlinkat+0x4e1/0x920 fs/namei.c:4396 __do_sys_unlink fs/namei.c:4437 [inline] __se_sys_unlink fs/namei.c:4435 [inline] __x64_sys_unlink+0x49/0x50 fs/namei.c:4435 x64_sys_call+0x289/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:88 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3b/0x80 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 The buggy address belongs to the object at ffff888100567a10 which belongs to the cache f2fs_inode_cache of size 1360
The buggy address is located 952 bytes inside of
1360-byte region [ffff888100567a10, ffff888100567f60)
The buggy address belongs to the physical page: page:ffffea0004015800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x100560 head:ffffea0004015800 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x4000000000010200(slab|head|zone=1) raw: 4000000000010200 0000000000000000 dead000000000122 ffff8881002c4d80 raw: 0000000000000000 0000000080160016 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Reclaimable, gfp_mask 0xd2050(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 298, tgid 298 (syz-executor330), ts 26489303743, free_ts 0 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0x213/0x220 mm/page_alloc.c:2637 prep_new_page+0x1b/0x110 mm/page_alloc.c:2644 get_page_from_freelist+0x3a98/0x3b10 mm/page_alloc.c:4539 __alloc_pages+0x234/0x610 mm/page_alloc.c:5837 alloc_slab_page+0x6c/0xf0 include/linux/gfp.h:-1 allocate_slab mm/slub.c:1962 [inline] new_slab+0x90/0x3e0 mm/slub.c:2015 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203 __slab_alloc+0x5d/0xa0 mm/slub.c:3302 slab_alloc_node mm/slub.c:3387 [inline] slab_alloc mm/slub.c:3431 [inline] __kmem_cache_alloc_lru mm/slub.c:3438 [inline] kmem_cache_alloc_lru+0x149/0x270 mm/slub.c:3454 alloc_inode_sb include/linux/fs.h:3255 [inline] f2fs_alloc_inode+0x2d/0x350 fs/f2fs/super.c:1437 alloc_inode fs/inode.c:261 [inline] iget_locked+0x18c/0x7e0 fs/inode.c:1373 f2fs_iget+0x55/0x4ca0 fs/f2fs/inode.c:486 f2fs_fill_super+0x5360/0x6dc0 fs/f2fs/super.c:4488 mount_bdev+0x282/0x3b0 fs/super.c:1445 f2fs_mount+0x34/0x40 fs/f2fs/super.c:4743 legacy_get_tree+0xf1/0x190 fs/fs_context.c:632
page_owner free stack trace missing
Memory state around the buggy address:
ffff888100567c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888100567d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888100567d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888100567e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888100567e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================[2] https://syzkaller.appspot.com/text?tag=CrashLog&x=13654c60580000
[ 24.675720][ T28] audit: type=1400 audit(1745327318.732:72): avc: denied { write } for pid=298 comm="syz-executor399" name="/" dev="loop0" ino=3 scontext=root:sysadm_r:sysadm_t tcontext=system_u:object_r:unlabeled_t tclass=dir permissive=1
[ 24.705426][ T296] ------------[ cut here ]------------
[ 24.706608][ T28] audit: type=1400 audit(1745327318.732:73): avc: denied { remove_name } for pid=298 comm="syz-executor399" name="file0" dev="loop0" ino=4 scontext=root:sysadm_r:sysadm_t tcontext=system_u:object_r:unlabeled_t tclass=dir permissive=1
[ 24.711550][ T296] WARNING: CPU: 0 PID: 296 at fs/f2fs/inode.c:847 f2fs_evict_inode+0x1262/0x1540
[ 24.734141][ T28] audit: type=1400 audit(1745327318.732:74): avc: denied { rename } for pid=298 comm="syz-executor399" name="file0" dev="loop0" ino=4 scontext=root:sysadm_r:sysadm_t tcontext=system_u:object_r:unlabeled_t tclass=dir permissive=1
[ 24.742969][ T296] Modules linked in:
[ 24.765201][ T28] audit: type=1400 audit(1745327318.732:75): avc: denied { add_name } for pid=298 comm="syz-executor399" name="bus" scontext=root:sysadm_r:sysadm_t tcontext=system_u:object_r:unlabeled_t tclass=dir permissive=1
[ 24.768847][ T296] CPU: 0 PID: 296 Comm: syz-executor399 Not tainted 6.1.129-syzkaller-00017-g642656a36791 #0
[ 24.799506][ T296] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
[ 24.809401][ T296] RIP: 0010:f2fs_evict_inode+0x1262/0x1540
[ 24.815018][ T296] Code: 34 70 4a ff eb 0d e8 2d 70 4a ff 4d 89 e5 4c 8b 64 24 18 48 8b 5c 24 28 4c 89 e7 e8 78 38 03 00 e9 84 fc ff ff e8 0e 70 4a ff <0f> 0b 4c 89 f7 be 08 00 00 00 e8 7f 21 92 ff f0 41 80 0e 04 e9 61
[ 24.834584][ T296] RSP: 0018:ffffc90000db7a40 EFLAGS: 00010293
[ 24.840465][ T296] RAX: ffffffff822aca42 RBX: 0000000000000002 RCX: ffff888110948000
[ 24.848291][ T296] RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000000
[ 24.856064][ T296] RBP: ffffc90000db7bb0 R08: ffffffff822ac6a8 R09: ffffed10200b005d
[ 24.864073][ T296] R10: 0000000000000000 R11: dffffc0000000001 R12: ffff888100580000
[ 24.871812][ T296] R13: dffffc0000000000 R14: ffff88810fef4078 R15: 1ffff920001b6f5cThe root cause is w/ a fuzzed image, f2fs may missed to clear FI_DIRTY_INODE flag for target inode, after f2fs_evict_inode(), the inode is still linked in sbi->inode_list[DIRTY_META] global list, once it triggers checkpoint, f2fs_sync_inode_meta() may access the released inode.
In f2fs_evict_inode(), let's always call f2fs_inode_synced() to clear FI_DIRTY_INODE flag and drop inode from global dirty list to avoid this UAF issue.
--- fs/f2fs/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/f2fs/inode.c +6 -2
@@ -842,8 +842,12 @@ void f2fs_evict_inode(struct inode *inode)if (likely (!f2fs_cp_error (sbi) && !is_sbi_flag_set (sbi,SBI_CP_DISABLED )))f2fs_bug_on (sbi,is_inode_flag_set (inode,FI_DIRTY_INODE )); -else -f2fs_inode_synced (inode); + +/* +* anyway, it needs to remove the inode from sbi->inode_list[DIRTY_META] +* list to avoid UAF in f2fs_sync_inode_meta() during checkpoint. +*/ +f2fs_inode_synced (inode);/* for the case f2fs_new_inode() was failed, .i_ino is zero, skip it */ if (inode->i_ino)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 215/644 f2fs: fix to avoid panic in f2fs_evict_inode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit a509a55f8eecc8970b3980c6f06886bbff0e2f68 ]
As syzbot [1] reported as below:
R10: 0000000000000100 R11: 0000000000000206 R12: 00007ffe17473450
R13: 00007f28b1c10854 R14: 000000000000dae5 R15: 00007ffe17474520
</TASK> ---[ end trace 0000000000000000 ]--- ================================================================== BUG: KASAN: use-after-free in __list_del_entry_valid+0xa6/0x130 lib/list_debug.c:62 Read of size 8 at addr ffff88812d962278 by task syz-executor/564 CPU: 1 PID: 564 Comm: syz-executor Tainted: G W 6.1.129-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call Trace: <TASK> __dump_stack+0x21/0x24 lib/dump_stack.c:88 dump_stack_lvl+0xee/0x158 lib/dump_stack.c:106 print_address_description+0x71/0x210 mm/kasan/report.c:316 print_report+0x4a/0x60 mm/kasan/report.c:427 kasan_report+0x122/0x150 mm/kasan/report.c:531 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:351 __list_del_entry_valid+0xa6/0x130 lib/list_debug.c:62 __list_del_entry include/linux/list.h:134 [inline] list_del_init include/linux/list.h:206 [inline] f2fs_inode_synced+0xf7/0x2e0 fs/f2fs/super.c:1531 f2fs_update_inode+0x74/0x1c40 fs/f2fs/inode.c:585 f2fs_update_inode_page+0x137/0x170 fs/f2fs/inode.c:703 f2fs_write_inode+0x4ec/0x770 fs/f2fs/inode.c:731 write_inode fs/fs-writeback.c:1460 [inline] __writeback_single_inode+0x4a0/0xab0 fs/fs-writeback.c:1677 writeback_single_inode+0x221/0x8b0 fs/fs-writeback.c:1733 sync_inode_metadata+0xb6/0x110 fs/fs-writeback.c:2789 f2fs_sync_inode_meta+0x16d/0x2a0 fs/f2fs/checkpoint.c:1159 block_operations fs/f2fs/checkpoint.c:1269 [inline] f2fs_write_checkpoint+0xca3/0x2100 fs/f2fs/checkpoint.c:1658 kill_f2fs_super+0x231/0x390 fs/f2fs/super.c:4668 deactivate_locked_super+0x98/0x100 fs/super.c:332 deactivate_super+0xaf/0xe0 fs/super.c:363 cleanup_mnt+0x45f/0x4e0 fs/namespace.c:1186 __cleanup_mnt+0x19/0x20 fs/namespace.c:1193 task_work_run+0x1c6/0x230 kernel/task_work.c:203 exit_task_work include/linux/task_work.h:39 [inline] do_exit+0x9fb/0x2410 kernel/exit.c:871 do_group_exit+0x210/0x2d0 kernel/exit.c:1021 __do_sys_exit_group kernel/exit.c:1032 [inline] __se_sys_exit_group kernel/exit.c:1030 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1030 x64_sys_call+0x7b4/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 RIP: 0033:0x7f28b1b8e169 Code: Unable to access opcode bytes at 0x7f28b1b8e13f. RSP: 002b:00007ffe174710a8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 00007f28b1c10879 RCX: 00007f28b1b8e169 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001 RBP: 0000000000000002 R08: 00007ffe1746ee47 R09: 00007ffe17472360 R10: 0000000000000009 R11: 0000000000000246 R12: 00007ffe17472360 R13: 00007f28b1c10854 R14: 000000000000dae5 R15: 00007ffe17474520 </TASK> Allocated by task 569: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_alloc_info+0x25/0x30 mm/kasan/generic.c:505 __kasan_slab_alloc+0x72/0x80 mm/kasan/common.c:328 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook+0x4f/0x2c0 mm/slab.h:737 slab_alloc_node mm/slub.c:3398 [inline] slab_alloc mm/slub.c:3406 [inline] __kmem_cache_alloc_lru mm/slub.c:3413 [inline] kmem_cache_alloc_lru+0x104/0x220 mm/slub.c:3429 alloc_inode_sb include/linux/fs.h:3245 [inline] f2fs_alloc_inode+0x2d/0x340 fs/f2fs/super.c:1419 alloc_inode fs/inode.c:261 [inline] iget_locked+0x186/0x880 fs/inode.c:1373 f2fs_iget+0x55/0x4c60 fs/f2fs/inode.c:483 f2fs_lookup+0x366/0xab0 fs/f2fs/namei.c:487 __lookup_slow+0x2a3/0x3d0 fs/namei.c:1690 lookup_slow+0x57/0x70 fs/namei.c:1707 walk_component+0x2e6/0x410 fs/namei.c:1998 lookup_last fs/namei.c:2455 [inline] path_lookupat+0x180/0x490 fs/namei.c:2479 filename_lookup+0x1f0/0x500 fs/namei.c:2508 vfs_statx+0x10b/0x660 fs/stat.c:229 vfs_fstatat fs/stat.c:267 [inline] vfs_lstat include/linux/fs.h:3424 [inline] __do_sys_newlstat fs/stat.c:423 [inline] __se_sys_newlstat+0xd5/0x350 fs/stat.c:417 __x64_sys_newlstat+0x5b/0x70 fs/stat.c:417 x64_sys_call+0x393/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:7 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Freed by task 13: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x31/0x50 mm/kasan/generic.c:516 ____kasan_slab_free+0x132/0x180 mm/kasan/common.c:236 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:244 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1724 [inline] slab_free_freelist_hook+0xc2/0x190 mm/slub.c:1750 slab_free mm/slub.c:3661 [inline] kmem_cache_free+0x12d/0x2a0 mm/slub.c:3683 f2fs_free_inode+0x24/0x30 fs/f2fs/super.c:1562 i_callback+0x4c/0x70 fs/inode.c:250 rcu_do_batch+0x503/0xb80 kernel/rcu/tree.c:2297 rcu_core+0x5a2/0xe70 kernel/rcu/tree.c:2557 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2574 handle_softirqs+0x178/0x500 kernel/softirq.c:578 run_ksoftirqd+0x28/0x30 kernel/softirq.c:945 smpboot_thread_fn+0x45a/0x8c0 kernel/smpboot.c:164 kthread+0x270/0x310 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Last potentially related work creation: kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb6/0xc0 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496 call_rcu+0xd4/0xf70 kernel/rcu/tree.c:2845 destroy_inode fs/inode.c:316 [inline] evict+0x7da/0x870 fs/inode.c:720 iput_final fs/inode.c:1834 [inline] iput+0x62b/0x830 fs/inode.c:1860 do_unlinkat+0x356/0x540 fs/namei.c:4397 __do_sys_unlink fs/namei.c:4438 [inline] __se_sys_unlink fs/namei.c:4436 [inline] __x64_sys_unlink+0x49/0x50 fs/namei.c:4436 x64_sys_call+0x958/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:88 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 The buggy address belongs to the object at ffff88812d961f20 which belongs to the cache f2fs_inode_cache of size 1200
The buggy address is located 856 bytes inside of
1200-byte region [ffff88812d961f20, ffff88812d9623d0)
The buggy address belongs to the physical page: page:ffffea0004b65800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12d960 head:ffffea0004b65800 order:2 compound_mapcount:0 compound_pincount:0 flags: 0x4000000000010200(slab|head|zone=1) raw: 4000000000010200 0000000000000000 dead000000000122 ffff88810a94c500 raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Reclaimable, gfp_mask 0x1d2050(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 569, tgid 568 (syz.2.16), ts 55943246141, free_ts 0 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1d0/0x1f0 mm/page_alloc.c:2532 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x2e63/0x2ef0 mm/page_alloc.c:4328 __alloc_pages+0x235/0x4b0 mm/page_alloc.c:5605 alloc_slab_page include/linux/gfp.h:-1 [inline] allocate_slab mm/slub.c:1939 [inline] new_slab+0xec/0x4b0 mm/slub.c:1992 ___slab_alloc+0x6f6/0xb50 mm/slub.c:3180 __slab_alloc+0x5e/0xa0 mm/slub.c:3279 slab_alloc_node mm/slub.c:3364 [inline] slab_alloc mm/slub.c:3406 [inline] __kmem_cache_alloc_lru mm/slub.c:3413 [inline] kmem_cache_alloc_lru+0x13f/0x220 mm/slub.c:3429 alloc_inode_sb include/linux/fs.h:3245 [inline] f2fs_alloc_inode+0x2d/0x340 fs/f2fs/super.c:1419 alloc_inode fs/inode.c:261 [inline] iget_locked+0x186/0x880 fs/inode.c:1373 f2fs_iget+0x55/0x4c60 fs/f2fs/inode.c:483 f2fs_fill_super+0x3ad7/0x6bb0 fs/f2fs/super.c:4293 mount_bdev+0x2ae/0x3e0 fs/super.c:1443 f2fs_mount+0x34/0x40 fs/f2fs/super.c:4642 legacy_get_tree+0xea/0x190 fs/fs_context.c:632 vfs_get_tree+0x89/0x260 fs/super.c:1573 do_new_mount+0x25a/0xa20 fs/namespace.c:3056
page_owner free stack trace missing
Memory state around the buggy address:
ffff88812d962100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88812d962180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88812d962200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88812d962280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88812d962300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================[1] https://syzkaller.appspot.com/x/report.txt?x=13448368580000
This bug can be reproduced w/ the reproducer [2], once we enable CONFIG_F2FS_CHECK_FS config, the reproducer will trigger panic as below, so the direct reason of this bug is the same as the one below patch [3] fixed.
kernel BUG at fs/f2fs/inode.c:857!
RIP: 0010:f2fs_evict_inode+0x1204/0x1a20 Call Trace: <TASK> evict+0x32a/0x7a0 do_unlinkat+0x37b/0x5b0 __x64_sys_unlink+0xad/0x100 do_syscall_64+0x5a/0xb0 entry_SYSCALL_64_after_hwframe+0x6e/0xd8 RIP: 0010:f2fs_evict_inode+0x1204/0x1a20
[2] https://syzkaller.appspot.com/x/repro.c?x=17495ccc580000
[3] https://lore.kernel.org/linux-f2fs-devel/[email protected]
Tracepoints before panic:
f2fs_unlink_enter: dev = (7,0), dir ino = 3, i_size = 4096, i_blocks = 8, name = file1f2fs_unlink_exit: dev = (7,0), ino = 7, ret = 0f2fs_evict_inode: dev = (7,0), ino = 7, pino = 3, i_mode = 0x81ed, i_size = 10, i_nlink = 0, i_blocks = 0, i_advise = 0x0f2fs_truncate_node: dev = (7,0), ino = 7, nid = 8, block_address = 0x3c05
f2fs_unlink_enter: dev = (7,0), dir ino = 3, i_size = 4096, i_blocks = 8, name = file3f2fs_unlink_exit: dev = (7,0), ino = 8, ret = 0f2fs_evict_inode: dev = (7,0), ino = 8, pino = 3, i_mode = 0x81ed, i_size = 9000, i_nlink = 0, i_blocks = 24, i_advise = 0x4f2fs_truncate: dev = (7,0), ino = 8, pino = 3, i_mode = 0x81ed, i_size = 0, i_nlink = 0, i_blocks = 24, i_advise = 0x4 f2fs_truncate_blocks_enter: dev = (7,0), ino = 8, i_size = 0, i_blocks = 24, start file offset = 0f2fs_truncate_blocks_exit: dev = (7,0), ino = 8, ret = -2
The root cause is: in the fuzzed image, dnode #8 belongs to inode #7, after inode #7 eviction, dnode #8 was dropped.
However there is dirent that has ino #8, so, once we unlink file3, in f2fs_evict_inode(), both f2fs_truncate() and f2fs_update_inode_page() will fail due to we can not load node #8, result in we missed to call f2fs_inode_synced() to clear inode dirty status.
Let's fix this by calling f2fs_inode_synced() in error path of f2fs_evict_inode().
PS: As I verified, the reproducer [2] can trigger this bug in v6.1.129, but it failed in v6.16-rc4, this is because the testcase will stop due to other corruption has been detected by f2fs:
F2FS-fs (loop0): inconsistent node block, node_type:2, nid:8, node_footer[nid:8,ino:8,ofs:0,cpver:5013063228981249506,blkaddr:15366] F2FS-fs (loop0): f2fs_lookup: inode (ino=9) has zero i_nlink
--- fs/f2fs/inode.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/f2fs/inode.c +13 -0
@@ -826,6 +826,19 @@ void f2fs_evict_inode(struct inode *inode)f2fs_update_inode_page (inode);if (dquot_initialize_needed (inode))set_sbi_flag (sbi,SBI_QUOTA_NEED_REPAIR ); + +/* +* If both f2fs_truncate() and f2fs_update_inode_page() failed +* due to fuzzed corrupted inode, call f2fs_inode_synced() to +* avoid triggering later f2fs_bug_on(). +*/ +if (is_inode_flag_set (inode,FI_DIRTY_INODE )) { +f2fs_warn (sbi, +"f2fs_evict_inode: inode is dirty, ino:%lu" , + inode->i_ino); +f2fs_inode_synced (inode); +set_sbi_flag (sbi,SBI_NEED_FSCK ); + } }if (!is_sbi_flag_set (sbi,SBI_IS_FREEZING ))sb_end_intwrite (inode->i_sb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 216/644 f2fs: fix to avoid out-of-boundary access in devs.path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 5661998536af52848cc4d52a377e90368196edea ]
- touch /mnt/f2fs/012345678901234567890123456789012345678901234567890123
- truncate -s $((1024*1024*1024)) \
/mnt/f2fs/012345678901234567890123456789012345678901234567890123
- touch /mnt/f2fs/file
- truncate -s $((1024*1024*1024)) /mnt/f2fs/file
- mkfs.f2fs /mnt/f2fs/012345678901234567890123456789012345678901234567890123 \
-c /mnt/f2fs/file
- mount /mnt/f2fs/012345678901234567890123456789012345678901234567890123 \
/mnt/f2fs/loop
[16937.192225] F2FS-fs (loop0): Mount Device [ 0]: /mnt/f2fs/012345678901234567890123456789012345678901234567890123\xff\x01, 511, 0 - 3ffff [16937.192268] F2FS-fs (loop0): Failed to find devices
If device path length equals to MAX_PATH_LEN, sbi->devs.path[] may not end up w/ null character due to path array is fully filled, So accidently, fields locate after path[] may be treated as part of device path, result in parsing wrong device path.
struct f2fs_dev_info {
...
char path[MAX_PATH_LEN];
...
};
Let's add one byte space for sbi->devs.path[] to store null character of device path string.
--- fs/f2fs/f2fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/f2fs.h +1 -1
@@ -1209,7 +1209,7 @@ struct f2fs_bio_info {#define RDEV (i) (raw_super->devs[i])struct f2fs_dev_info {struct block_device *bdev; -char path[MAX_PATH_LEN ]; +char path[MAX_PATH_LEN +1 ];unsigned int total_segments;block_t start_blk;block_t end_blk;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 217/644 scsi: mpt3sas: Fix a fw_event memory leak
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomas Henzl <[email protected]>
[ Upstream commit 3e90b38781e3bdd651edaf789585687611638862 ]
In _mpt3sas_fw_work() the fw_event reference is removed, it should also be freed in all cases.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -2
@@ -10806,8 +10806,7 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)break ;case MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST :_scsih_pcie_topology_change_event (ioc, fw_event); - ioc->current_event =NULL ; -return ; +break ; } out:fw_event_work_put (fw_event);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 218/644 scsi: ufs: core: Use link recovery when h8 exit fails during runtime resume
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seunghui Lee <[email protected]>
[ Upstream commit 35dabf4503b94a697bababe94678a8bc989c3223 ]
If the h8 exit fails during runtime resume process, the runtime thread enters runtime suspend immediately and the error handler operates at the same time. It becomes stuck and cannot be recovered through the error handler. To fix this, use link recovery instead of the error handler.
--- drivers/scsi/ufs/ufshcd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +9 -1
@@ -4013,7 +4013,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) hba->uic_async_done =NULL ;if (reenable_intr)ufshcd_enable_intr (hba,UIC_COMMAND_COMPL ); -if (ret) { +if (ret && !hba->pm_op_in_progress) {ufshcd_set_link_broken (hba);ufshcd_schedule_eh_work (hba); }
@@ -4021,6 +4021,14 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)spin_unlock_irqrestore (hba->host->host_lock, flags);mutex_unlock (&hba->uic_cmd_mutex); +/* +* If the h8 exit fails during the runtime resume process, it becomes +* stuck and cannot be recovered through the error handler. To fix +* this, use link recovery instead of the error handler. +*/ +if (ret && hba->pm_op_in_progress) + ret =ufshcd_link_recovery (hba); +return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 219/644 kconfig: qconf: fix ConfigList::updateListAllforAll()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 721bfe583c52ba1ea74b3736a31a9dcfe6dd6d95 ]
ConfigList::updateListForAll() and ConfigList::updateListAllforAll() are identical.
Commit f9b918fae678 ("kconfig: qconf: move ConfigView::updateList(All) to ConfigList class") was a misconversion.
--- scripts/kconfig/qconf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/qconf.cc +1 -1
@@ -478,7 +478,7 @@ void ConfigList::updateListAllForAll() while (it.hasNext()) { ConfigList *list = it.next(); - list->updateList(); + list->updateListAll(); } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 220/644 PCI: pnv_php: Clean up allocated IRQs on unplug
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timothy Pearson <[email protected]>
[ Upstream commit 4668619092554e1b95c9a5ac2941ca47ba6d548a ]
When the root of a nested PCIe bridge configuration is unplugged, the pnv_php driver leaked the allocated IRQ resources for the child bridges' hotplug event notifications, resulting in a panic.
Fix this by walking all child buses and deallocating all its IRQ resources before calling pci_hp_remove_devices().
Also modify the lifetime of the workqueue at struct pnv_php_slot::wq so that it is only destroyed in pnv_php_free_slot(), instead of pnv_php_disable_irq(). This is required since pnv_php_disable_irq() will now be called by workers triggered by hot unplug interrupts, so the workqueue needs to stay allocated.
The abridged kernel panic that occurs without this patch is as follows:
WARNING: CPU: 0 PID: 687 at kernel/irq/msi.c:292 msi_device_data_release+0x6c/0x9c CPU: 0 UID: 0 PID: 687 Comm: bash Not tainted 6.14.0-rc5+ #2 Call Trace: msi_device_data_release+0x34/0x9c (unreliable) release_nodes+0x64/0x13c devres_release_all+0xc0/0x140 device_del+0x2d4/0x46c pci_destroy_dev+0x5c/0x194 pci_hp_remove_devices+0x90/0x128 pci_hp_remove_devices+0x44/0x128 pnv_php_disable_slot+0x54/0xd4 power_write_file+0xf8/0x18c pci_slot_attr_store+0x40/0x5c sysfs_kf_write+0x64/0x78 kernfs_fop_write_iter+0x1b0/0x290 vfs_write+0x3bc/0x50c ksys_write+0x84/0x140 system_call_exception+0x124/0x230 system_call_vectored_common+0x15c/0x2ec
--- drivers/pci/hotplug/pnv_php.c | 96 ++++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 19 deletions(-)
drivers/pci/hotplug/pnv_php.c +77 -19
@@ -3,6 +3,7 @@* PCI Hotplug Driver for PowerPC PowerNV platform. * * Copyright Gavin Shan, IBM Corporation 2016. +* Copyright (C) 2025 Raptor Engineering, LLC */ #include <linux/libfdt.h>
@@ -34,8 +35,10 @@ static void pnv_php_register(struct device_node *dn);static void pnv_php_unregister_one (struct device_node *dn);static void pnv_php_unregister (struct device_node *dn); +static void pnv_php_enable_irq (struct pnv_php_slot *php_slot); +static void pnv_php_disable_irq (struct pnv_php_slot *php_slot, -bool disable_device) +bool disable_device,bool disable_msi) {struct pci_dev *pdev = php_slot->pdev;u16 ctrl;
@@ -51,19 +54,15 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot, php_slot->irq =0 ; } -if (php_slot->wq) { -destroy_workqueue (php_slot->wq); - php_slot->wq =NULL ; - } - -if (disable_device) { +if (disable_device || disable_msi) {if (pdev->msix_enabled)pci_disable_msix (pdev);else if (pdev->msi_enabled)pci_disable_msi (pdev); + } +if (disable_device)pci_disable_device (pdev); - } }static void pnv_php_free_slot (struct kref *kref)
@@ -72,7 +71,8 @@ static void pnv_php_free_slot(struct kref *kref) struct pnv_php_slot, kref);WARN_ON (!list_empty (&php_slot->children)); -pnv_php_disable_irq (php_slot, false); +pnv_php_disable_irq (php_slot, false, false); +destroy_workqueue (php_slot->wq);kfree (php_slot->name);kfree (php_slot); }
@@ -559,8 +559,58 @@ static int pnv_php_reset_slot(struct hotplug_slot *slot, bool probe)static int pnv_php_enable_slot (struct hotplug_slot *slot) {struct pnv_php_slot *php_slot =to_pnv_php_slot (slot); +u32 prop32; +int ret; + + ret =pnv_php_enable (php_slot, true); +if (ret) +return ret; + +/* (Re-)enable interrupt if the slot supports surprise hotplug */ + ret =of_property_read_u32 (php_slot->dn,"ibm,slot-surprise-pluggable" , + &prop32); +if (!ret && prop32) +pnv_php_enable_irq (php_slot); -return pnv_php_enable (php_slot, true); +return 0 ; +} + +/* +* Disable any hotplug interrupts for all slots on the provided bus, as well as +* all downstream slots in preparation for a hot unplug. +*/ +static int pnv_php_disable_all_irqs (struct pci_bus *bus) +{ +struct pci_bus *child_bus; +struct pci_slot *slot; + +/* First go down child buses */ +list_for_each_entry (child_bus, &bus->children, node) +pnv_php_disable_all_irqs (child_bus); + +/* Disable IRQs for all pnv_php slots on this bus */ +list_for_each_entry (slot, &bus->slots, list) { +struct pnv_php_slot *php_slot =to_pnv_php_slot (slot->hotplug); + +pnv_php_disable_irq (php_slot, false, true); + } + +return 0 ; +} + +/* +* Disable any hotplug interrupts for all downstream slots on the provided +* bus in preparation for a hot unplug. +*/ +static int pnv_php_disable_all_downstream_irqs (struct pci_bus *bus) +{ +struct pci_bus *child_bus; + +/* Go down child buses, recursively deactivating their IRQs */ +list_for_each_entry (child_bus, &bus->children, node) +pnv_php_disable_all_irqs (child_bus); + +return 0 ; }static int pnv_php_disable_slot (struct hotplug_slot *slot)
@@ -577,6 +627,13 @@ static int pnv_php_disable_slot(struct hotplug_slot *slot) php_slot->state != PNV_PHP_STATE_REGISTERED)return 0 ; +/* +* Free all IRQ resources from all child slots before remove. +* Note that we do not disable the root slot IRQ here as that +* would also deactivate the slot hot (re)plug interrupt! +*/ +pnv_php_disable_all_downstream_irqs (php_slot->bus); +/* Remove all devices behind the slot */ pci_lock_rescan_remove ();pci_hp_remove_devices (php_slot->bus);
@@ -645,6 +702,15 @@ static struct pnv_php_slot *pnv_php_alloc_slot(struct device_node *dn)return NULL ; } +/* Allocate workqueue for this slot's interrupt handling */ + php_slot->wq =alloc_workqueue ("pciehp-%s" ,0 ,0 , php_slot->name); +if (!php_slot->wq) { +SLOT_WARN (php_slot,"Cannot alloc workqueue\n" ); +kfree (php_slot->name); +kfree (php_slot); +return NULL ; + } +if (dn->child &&PCI_DN (dn->child)) php_slot->slot_no =PCI_SLOT (PCI_DN (dn->child)->devfn);else
@@ -841,14 +907,6 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)u16 sts, ctrl;int ret; -/* Allocate workqueue */ - php_slot->wq =alloc_workqueue ("pciehp-%s" ,0 ,0 , php_slot->name); -if (!php_slot->wq) { -SLOT_WARN (php_slot,"Cannot alloc workqueue\n" ); -pnv_php_disable_irq (php_slot, true); -return ; - } -/* Check PDC (Presence Detection Change) is broken or not */ ret =of_property_read_u32 (php_slot->dn,"ibm,slot-broken-pdc" , &broken_pdc);
@@ -867,7 +925,7 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq) ret =request_irq (irq, pnv_php_interrupt,IRQF_SHARED , php_slot->name, php_slot);if (ret) { -pnv_php_disable_irq (php_slot, true); +pnv_php_disable_irq (php_slot, true, true);SLOT_WARN (php_slot,"Error %d enabling IRQ %d\n" , ret, irq);return ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 221/644 PCI: pnv_php: Work around switches with broken presence detection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timothy Pearson <[email protected]>
[ Upstream commit 80f9fc2362797538ebd4fd70a1dfa838cc2c2cdb ]
The Microsemi Switchtec PM8533 PFX 48xG3 [11f8:8533] PCIe switch system was observed to incorrectly assert the Presence Detect Set bit in its capabilities when tested on a Raptor Computing Systems Blackbird system, resulting in the hot insert path never attempting a rescan of the bus and any downstream devices not being re-detected.
Work around this by additionally checking whether the PCIe data link is active or not when performing presence detection on downstream switches' ports, similar to the pciehp_hpc.c driver.
--- drivers/pci/hotplug/pnv_php.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/pci/hotplug/pnv_php.c +27 -0
@@ -389,6 +389,20 @@ static int pnv_php_get_power_state(struct hotplug_slot *slot, u8 *state)return 0 ; } +static int pcie_check_link_active (struct pci_dev *pdev) +{ +u16 lnk_status; +int ret; + + ret =pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnk_status); +if (ret ==PCIBIOS_DEVICE_NOT_FOUND ||PCI_POSSIBLE_ERROR (lnk_status)) +return -ENODEV ; + + ret = !!(lnk_status &PCI_EXP_LNKSTA_DLLLA ); + +return ret; +} +static int pnv_php_get_adapter_state (struct hotplug_slot *slot,u8 *state) {struct pnv_php_slot *php_slot =to_pnv_php_slot (slot);
@@ -401,6 +415,19 @@ static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state)*/ ret =pnv_pci_get_presence_state (php_slot->id, &presence);if (ret >=0 ) { +if (pci_pcie_type (php_slot->pdev) ==PCI_EXP_TYPE_DOWNSTREAM && + presence ==OPAL_PCI_SLOT_EMPTY ) { +/* +* Similar to pciehp_hpc, check whether the Link Active +* bit is set to account for broken downstream bridges +* that don't properly assert Presence Detect State, as +* was observed on the Microsemi Switchtec PM8533 PFX +* [11f8:8533]. +*/ +if (pcie_check_link_active (php_slot->pdev) >0 ) + presence =OPAL_PCI_SLOT_PRESENT ; + } + *state = presence; ret =0 ; }else {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 222/644 powerpc/eeh: Export eeh_unfreeze_pe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timothy Pearson <[email protected]>
[ Upstream commit e82b34eed04b0ddcff4548b62633467235672fd3 ]
The PowerNV hotplug driver needs to be able to clear any frozen PE(s) on the PHB after suprise removal of a downstream device.
Export the eeh_unfreeze_pe() symbol to allow implementation of this functionality in the php_nv module.
--- arch/powerpc/kernel/eeh.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kernel/eeh.c +1 -0
@@ -1119,6 +1119,7 @@ int eeh_unfreeze_pe(struct eeh_pe *pe)return ret; } +EXPORT_SYMBOL_GPL (eeh_unfreeze_pe);static struct pci_device_id eeh_reset_ids[] = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 223/644 powerpc/eeh: Rely on dev->link_active_reporting
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
[ Upstream commit 1541a21305ceb10fcf3f7cbb23f3e1a00bbf1789 ]
Use dev->link_active_reporting to determine whether Data Link Layer Link Active Reporting is available rather than re-retrieving the capability.
--- arch/powerpc/kernel/eeh_pe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/kernel/eeh_pe.c +2 -3
@@ -670,9 +670,8 @@ static void eeh_bridge_check_link(struct eeh_dev *edev) eeh_ops->write_config (edev, cap +PCI_EXP_LNKCTL ,2 , val);/* Check link */ - eeh_ops->read_config (edev, cap +PCI_EXP_LNKCAP ,4 , &val); -if (!(val &PCI_EXP_LNKCAP_DLLLARC )) { -eeh_edev_dbg (edev,"No link reporting capability (0x%08x) \n" , val); +if (!edev->pdev->link_active_reporting) { +eeh_edev_dbg (edev,"No link reporting capability\n" );msleep (1000 );return ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 224/644 powerpc/eeh: Make EEH driver device hotplug safe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timothy Pearson <[email protected]>
[ Upstream commit 1010b4c012b0d78dfb9d3132b49aa2ef024a07a7 ]
Multiple race conditions existed between the PCIe hotplug driver and the EEH driver, leading to a variety of kernel oopses of the same general nature:
<pcie device unplug>
<eeh driver trigger>
<hotplug removal trigger>
<pcie tree reconfiguration>
<eeh recovery next step>
<oops in EEH driver bus iteration loop>
A second class of oops is also seen when the underlying bus disappears during device recovery.
Refactor the EEH module to be PCI rescan and remove safe. Also clean up a few minor formatting / readability issues.
--- arch/powerpc/kernel/eeh_driver.c | 48 +++++++++++++++++++++----------- arch/powerpc/kernel/eeh_pe.c | 10 ++++--- 2 files changed, 38 insertions(+), 20 deletions(-)
arch/powerpc/kernel/eeh_driver.c +32 -16
@@ -258,13 +258,12 @@ static void eeh_pe_report_edev(struct eeh_dev *edev, eeh_report_fn fn,struct pci_driver *driver;enum pci_ers_result new_result; -pci_lock_rescan_remove (); pdev = edev->pdev;if (pdev)get_device (&pdev->dev); -pci_unlock_rescan_remove ();if (!pdev) {eeh_edev_info (edev,"no device" ); + *result =PCI_ERS_RESULT_DISCONNECT ;return ; }device_lock (&pdev->dev);
@@ -305,8 +304,9 @@ static void eeh_pe_report(const char *name, struct eeh_pe *root,struct eeh_dev *edev, *tmp;pr_info ("EEH: Beginning: '%s'\n" , name); - eeh_for_each_pe(root, pe) eeh_pe_for_each_dev(pe, edev, tmp) -eeh_pe_report_edev (edev, fn, result); +eeh_for_each_pe (root, pe) +eeh_pe_for_each_dev (pe, edev, tmp) +eeh_pe_report_edev (edev, fn, result);if (result)pr_info ("EEH: Finished:'%s' with aggregate recovery state:'%s'\n" , name,pci_ers_result_name (*result));
@@ -384,6 +384,8 @@ static void eeh_dev_restore_state(struct eeh_dev *edev, void *userdata)if (!edev)return ; +pci_lock_rescan_remove (); +/* * The content in the config space isn't saved because * the blocked config space on some adapters. We have
@@ -394,14 +396,19 @@ static void eeh_dev_restore_state(struct eeh_dev *edev, void *userdata)if (list_is_last (&edev->entry, &edev->pe->edevs))eeh_pe_restore_bars (edev->pe); +pci_unlock_rescan_remove ();return ; } pdev =eeh_dev_to_pci_dev (edev); -if (!pdev) +if (!pdev) { +pci_unlock_rescan_remove ();return ; + }pci_restore_state (pdev); + +pci_unlock_rescan_remove (); }/**
@@ -648,9 +655,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,if (any_passed || driver_eeh_aware || (pe->type &EEH_PE_VF )) {eeh_pe_dev_traverse (pe, eeh_rmv_device, rmv_data); }else { -pci_lock_rescan_remove ();pci_hp_remove_devices (bus); -pci_unlock_rescan_remove (); }/*
@@ -666,8 +671,6 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,if (rc)return rc; -pci_lock_rescan_remove (); -/* Restore PE */ eeh_ops->configure_bridge (pe);eeh_pe_restore_bars (pe);
@@ -675,7 +678,6 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,/* Clear frozen state */ rc =eeh_clear_pe_frozen_state (pe, false);if (rc) { -pci_unlock_rescan_remove ();return rc; }
@@ -710,7 +712,6 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus, pe->tstamp = tstamp; pe->freeze_count = cnt; -pci_unlock_rescan_remove ();return 0 ; }
@@ -844,10 +845,13 @@ void eeh_handle_normal_event(struct eeh_pe *pe) {LIST_HEAD_INIT(rmv_data.removed_vf_list), 0};int devices =0 ; +pci_lock_rescan_remove (); + bus =eeh_pe_bus_get (pe);if (!bus) {pr_err ("%s: Cannot find PCI bus for PHB#%x-PE#%x\n" , __func__, pe->phb->global_number, pe->addr); +pci_unlock_rescan_remove ();return ; }
@@ -1089,10 +1093,15 @@ void eeh_handle_normal_event(struct eeh_pe *pe)eeh_pe_state_clear (pe,EEH_PE_PRI_BUS , true);eeh_pe_dev_mode_mark (pe,EEH_DEV_REMOVED ); -pci_lock_rescan_remove (); -pci_hp_remove_devices (bus); -pci_unlock_rescan_remove (); + bus =eeh_pe_bus_get (pe); +if (bus) +pci_hp_remove_devices (bus); +else +pr_err ("%s: PCI bus for PHB#%x-PE#%x disappeared\n" , + __func__, pe->phb->global_number, pe->addr); +/* The passed PE should no longer be used */ +pci_unlock_rescan_remove ();return ; }
@@ -1109,6 +1118,8 @@ void eeh_handle_normal_event(struct eeh_pe *pe)eeh_clear_slot_attention (edev->pdev);eeh_pe_state_clear (pe,EEH_PE_RECOVERING , true); + +pci_unlock_rescan_remove (); }/**
@@ -1127,6 +1138,7 @@ void eeh_handle_special_event(void)unsigned long flags;int rc; +pci_lock_rescan_remove (); do { rc = eeh_ops->next_error(&pe);
@@ -1166,10 +1178,12 @@ void eeh_handle_special_event(void)break ;case EEH_NEXT_ERR_NONE : +pci_unlock_rescan_remove ();return ;default :pr_warn ("%s: Invalid value %d from next_error()\n" , __func__, rc); +pci_unlock_rescan_remove ();return ; }
@@ -1181,7 +1195,9 @@ void eeh_handle_special_event(void)if (rc ==EEH_NEXT_ERR_FROZEN_PE || rc ==EEH_NEXT_ERR_FENCED_PHB ) {eeh_pe_state_mark (pe,EEH_PE_RECOVERING ); +pci_unlock_rescan_remove ();eeh_handle_normal_event (pe); +pci_lock_rescan_remove (); }else {eeh_for_each_pe (pe, tmp_pe)eeh_pe_for_each_dev (tmp_pe, edev, tmp_edev)
@@ -1194,7 +1210,6 @@ void eeh_handle_special_event(void) eeh_report_failure, NULL);eeh_set_channel_state (pe, pci_channel_io_perm_failure); -pci_lock_rescan_remove ();list_for_each_entry (hose, &hose_list, list_node) { phb_pe =eeh_phb_pe_get (hose); if (!phb_pe ||
@@ -1213,7 +1228,6 @@ void eeh_handle_special_event(void) }pci_hp_remove_devices (bus); } -pci_unlock_rescan_remove (); }/*
@@ -1223,4 +1237,6 @@ void eeh_handle_special_event(void)if (rc ==EEH_NEXT_ERR_DEAD_IOC )break ; }while (rc !=EEH_NEXT_ERR_NONE ); + +pci_unlock_rescan_remove (); }
arch/powerpc/kernel/eeh_pe.c +6 -4
@@ -670,10 +670,12 @@ static void eeh_bridge_check_link(struct eeh_dev *edev) eeh_ops->write_config (edev, cap +PCI_EXP_LNKCTL ,2 , val);/* Check link */ -if (!edev->pdev->link_active_reporting) { -eeh_edev_dbg (edev,"No link reporting capability\n" ); -msleep (1000 ); -return ; +if (edev->pdev) { +if (!edev->pdev->link_active_reporting) { +eeh_edev_dbg (edev,"No link reporting capability\n" ); +msleep (1000 ); +return ; + } }/* Wait the link is up until timeout (5s) */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 225/644 PCI: pnv_php: Fix surprise plug detection and recovery
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timothy Pearson <[email protected]>
[ Upstream commit a2a2a6fc2469524caa713036297c542746d148dc ]
The existing PowerNV hotplug code did not handle surprise plug events correctly, leading to a complete failure of the hotplug system after device removal and a required reboot to detect new devices.
This comes down to two issues:
1) When a device is surprise removed, often the bridge upstream port will cause a PE freeze on the PHB. If this freeze is not cleared, the MSI interrupts from the bridge hotplug notification logic will not be received by the kernel, stalling all plug events on all slots associated with the PE.
2) When a device is removed from a slot, regardless of surprise or programmatic removal, the associated PHB/PE ls left frozen. If this freeze is not cleared via a fundamental reset, skiboot is unable to clear the freeze and cannot retrain / rescan the slot. This also requires a reboot to clear the freeze and redetect the device in the slot.
Issue the appropriate unfreeze and rescan commands on hotplug events, and don't oops on hotplug if pci_bus_to_OF_node() returns NULL.
--- arch/powerpc/kernel/pci-hotplug.c | 3 + drivers/pci/hotplug/pnv_php.c | 110 +++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 3 deletions(-)
arch/powerpc/kernel/pci-hotplug.c +3 -0
@@ -110,6 +110,9 @@ void pci_hp_add_devices(struct pci_bus *bus)struct pci_controller *phb;struct device_node *dn =pci_bus_to_OF_node (bus); +if (!dn) +return ; + phb =pci_bus_to_host (bus); mode =PCI_PROBE_NORMAL ;
drivers/pci/hotplug/pnv_php.c +107 -3
147 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 226/644 pNFS/flexfiles: dont attempt pnfs on fatal DS errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tigran Mkrtchyan <[email protected]>
[ Upstream commit f06bedfa62d57f7b67d44aacd6badad2e13a803f ]
When an applications get killed (SIGTERM/SIGINT) while pNFS client performs a connection to DS, client ends in an infinite loop of connect-disconnect. This
source of the issue, it that flexfilelayoutdev#nfs4_ff_layout_prepare_ds gets an error on nfs4_pnfs_ds_connect with status ERESTARTSYS, which is set by rpc_signal_task, but the error is treated as transient, thus retried.
The issue is reproducible with Ctrl+C the following script(there should be ~1000 files in a directory, client should must not have any connections to DSes):
``` echo 3 > /proc/sys/vm/drop_caches for i in * do head -1 $i done ```
The change aims to propagate the nfs4_ff_layout_prepare_ds error state to the caller that can decide whatever this is a retryable error or not.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 26 ++++++++++++++--------- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 6 +++--- 2 files changed, 19 insertions(+), 13 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +16 -10
@@ -739,14 +739,14 @@ ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg, {struct nfs4_ff_layout_segment *fls =FF_LAYOUT_LSEG (lseg);struct nfs4_ff_layout_mirror *mirror; -struct nfs4_pnfs_ds *ds; +struct nfs4_pnfs_ds *ds =ERR_PTR (-EAGAIN );u32 idx;/* mirrors are initially sorted by efficiency */ for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) { mirror =FF_LAYOUT_COMP (lseg, idx); ds =nfs4_ff_layout_prepare_ds (lseg, mirror, false); -if (!ds) +if (IS_ERR (ds))continue ; if (check_device &&
@@ -754,10 +754,10 @@ ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg,continue ; *best_idx = idx; -return ds; +break ; } -return NULL ; +return ds; } static struct nfs4_pnfs_ds *
@@ -933,7 +933,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,for (i =0 ; i < pgio->pg_mirror_count; i++) { mirror =FF_LAYOUT_COMP (pgio->pg_lseg, i); ds =nfs4_ff_layout_prepare_ds (pgio->pg_lseg, mirror, true); -if (!ds) { +if (IS_ERR (ds)) {if (!ff_layout_no_fallback_to_mds (pgio->pg_lseg)) goto out_mds;pnfs_generic_pg_cleanup (pgio);
@@ -1826,6 +1826,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)u32 idx = hdr->pgio_mirror_idx;int vers;struct nfs_fh *fh; +bool ds_fatal_error = false; dprintk("--> %s ino %lu pgbase %u req %zu@%llu\n", __func__, hdr->inode->i_ino,
@@ -1833,8 +1834,10 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr) mirror =FF_LAYOUT_COMP (lseg, idx); ds =nfs4_ff_layout_prepare_ds (lseg, mirror, false); -if (!ds) +if (IS_ERR (ds)) { + ds_fatal_error =nfs_error_is_fatal (PTR_ERR (ds)); goto out_failed; + } ds_clnt =nfs4_ff_find_or_create_ds_client (mirror, ds->ds_clp, hdr->inode);
@@ -1875,7 +1878,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)return PNFS_ATTEMPTED ; out_failed: -if (ff_layout_avoid_mds_available_ds (lseg)) +if (ff_layout_avoid_mds_available_ds (lseg) && !ds_fatal_error)return PNFS_TRY_AGAIN ; trace_pnfs_mds_fallback_read_pagelist(hdr->inode, hdr->args.offset, hdr->args.count,
@@ -1896,11 +1899,14 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)int vers;struct nfs_fh *fh;u32 idx = hdr->pgio_mirror_idx; +bool ds_fatal_error = false; mirror =FF_LAYOUT_COMP (lseg, idx); ds =nfs4_ff_layout_prepare_ds (lseg, mirror, true); -if (!ds) +if (IS_ERR (ds)) { + ds_fatal_error =nfs_error_is_fatal (PTR_ERR (ds)); goto out_failed; + } ds_clnt =nfs4_ff_find_or_create_ds_client (mirror, ds->ds_clp, hdr->inode);
@@ -1943,7 +1949,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)return PNFS_ATTEMPTED ; out_failed: -if (ff_layout_avoid_mds_available_ds (lseg)) +if (ff_layout_avoid_mds_available_ds (lseg) && !ds_fatal_error)return PNFS_TRY_AGAIN ; trace_pnfs_mds_fallback_write_pagelist(hdr->inode, hdr->args.offset, hdr->args.count,
@@ -1985,7 +1991,7 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how) idx =calc_ds_index_from_commit (lseg, data->ds_commit_index); mirror =FF_LAYOUT_COMP (lseg, idx); ds =nfs4_ff_layout_prepare_ds (lseg, mirror, true); -if (!ds) +if (IS_ERR (ds)) goto out_err; ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp,
fs/nfs/flexfilelayout/flexfilelayoutdev.c +3 -3
@@ -368,11 +368,11 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, struct nfs4_ff_layout_mirror *mirror, bool fail_return) { -struct nfs4_pnfs_ds *ds =NULL ; +struct nfs4_pnfs_ds *ds;struct inode *ino = lseg->pls_layout->plh_inode;struct nfs_server *s =NFS_SERVER (ino);unsigned int max_payload; -int status; +int status = -EAGAIN ;if (!ff_layout_init_mirror_ds (lseg->pls_layout, mirror)) goto noconnect;
@@ -410,7 +410,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,ff_layout_send_layouterror (lseg);if (fail_return || !ff_layout_has_available_ds (lseg))pnfs_error_mark_layout_for_return (ino, lseg); - ds =NULL ; + ds =ERR_PTR (status); out:return ds; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 227/644 NFS: Fix filehandle bounds checking in nfs_fh_to_dentry()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
[ Upstream commit ef93a685e01a281b5e2a25ce4e3428cf9371a205 ]
The function needs to check the minimal filehandle length before it can access the embedded filehandle.
--- fs/nfs/export.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/nfs/export.c +9 -2
@@ -67,14 +67,21 @@ nfs_fh_to_dentry(struct super_block *sb, struct fid *fid,struct nfs4_label *label =NULL ;struct nfs_fattr *fattr =NULL ;struct nfs_fh *server_fh =nfs_exp_embedfh (fid->raw); -size_t fh_size = offsetof(struct nfs_fh , data) + server_fh->size; +size_t fh_size = offsetof(struct nfs_fh , data);const struct nfs_rpc_ops *rpc_ops;struct dentry *dentry;struct inode *inode; -int len =EMBED_FH_OFF +XDR_QUADLEN (fh_size); +int len =EMBED_FH_OFF ;u32 *p = fid->raw;int ret; +/* Initial check of bounds */ +if (fh_len < len +XDR_QUADLEN (fh_size) || + fh_len >XDR_QUADLEN (NFS_MAXFHSIZE )) +return NULL ; +/* Calculate embedded filehandle size */ + fh_size += server_fh->size; + len +=XDR_QUADLEN (fh_size);/* NULL translates to ESTALE */ if (fh_len < len || fh_type != len)return NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 228/644 NFSv4.2: another fix for listxattr
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olga Kornievskaia <[email protected]>
[ Upstream commit 9acb237deff7667b0f6b10fe6b1b70c4429ea049 ]
Currently, when the server supports NFS4.1 security labels then security.selinux label in included twice. Instead, only add it when the server doesn't possess security label support.
--- fs/nfs/nfs4proc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +6 -4
@@ -10528,7 +10528,7 @@ const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = {static ssize_t nfs4_listxattr (struct dentry *dentry,char *list,size_t size) { -ssize_t error, error2, error3, error4; +ssize_t error, error2, error3, error4 =0 ;size_t left = size; error =generic_listxattr (dentry, list, left);
@@ -10556,9 +10556,11 @@ static ssize_t nfs4_listxattr(struct dentry *dentry, char *list, size_t size) left -= error3; } - error4 =security_inode_listsecurity (d_inode (dentry), list, left); -if (error4 <0 ) -return error4; +if (!nfs_server_capable (d_inode (dentry),NFS_CAP_SECURITY_LABEL )) { + error4 =security_inode_listsecurity (d_inode (dentry), list, left); +if (error4 <0 ) +return error4; + } error += error2 + error3 + error4;if (size && error > size)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 229/644 XArray: Add calls to might_alloc()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 1dd685c414a7b9fdb3d23aca3aedae84f0b998ae ]
Catch bogus GFP flags deterministically, instead of occasionally when we actually have to allocate memory.
Stable-dep-of: 99765233ab42 ("NFS: Fixup allocation flags for nfsiod's __GFP_NORETRY")
--- include/linux/xarray.h | 15 +++++++++++++++ tools/include/linux/sched/mm.h | 2 ++ 2 files changed, 17 insertions(+)
include/linux/xarray.h +15 -0
@@ -15,6 +15,7 @@#include <linux/kconfig.h> #include <linux/kernel.h> #include <linux/rcupdate.h> +#include <linux/sched/mm.h> #include <linux/spinlock.h> #include <linux/types.h>
@@ -585,6 +586,7 @@ static inline void *xa_store_bh(struct xarray *xa, unsigned long index, {void *curr; +might_alloc (gfp);xa_lock_bh (xa); curr =__xa_store (xa, index, entry, gfp);xa_unlock_bh (xa);
@@ -611,6 +613,7 @@ static inline void *xa_store_irq(struct xarray *xa, unsigned long index, {void *curr; +might_alloc (gfp);xa_lock_irq (xa); curr =__xa_store (xa, index, entry, gfp);xa_unlock_irq (xa);
@@ -686,6 +689,7 @@ static inline void *xa_cmpxchg(struct xarray *xa, unsigned long index, {void *curr; +might_alloc (gfp);xa_lock (xa); curr =__xa_cmpxchg (xa, index, old, entry, gfp);xa_unlock (xa);
@@ -713,6 +717,7 @@ static inline void *xa_cmpxchg_bh(struct xarray *xa, unsigned long index, {void *curr; +might_alloc (gfp);xa_lock_bh (xa); curr =__xa_cmpxchg (xa, index, old, entry, gfp);xa_unlock_bh (xa);
@@ -740,6 +745,7 @@ static inline void *xa_cmpxchg_irq(struct xarray *xa, unsigned long index, {void *curr; +might_alloc (gfp);xa_lock_irq (xa); curr =__xa_cmpxchg (xa, index, old, entry, gfp);xa_unlock_irq (xa);
@@ -769,6 +775,7 @@ static inline int __must_check xa_insert(struct xarray *xa, {int err; +might_alloc (gfp);xa_lock (xa); err =__xa_insert (xa, index, entry, gfp);xa_unlock (xa);
@@ -798,6 +805,7 @@ static inline int __must_check xa_insert_bh(struct xarray *xa, {int err; +might_alloc (gfp);xa_lock_bh (xa); err =__xa_insert (xa, index, entry, gfp);xa_unlock_bh (xa);
@@ -827,6 +835,7 @@ static inline int __must_check xa_insert_irq(struct xarray *xa, {int err; +might_alloc (gfp);xa_lock_irq (xa); err =__xa_insert (xa, index, entry, gfp);xa_unlock_irq (xa);
@@ -856,6 +865,7 @@ static inline __must_check int xa_alloc(struct xarray *xa, u32 *id, {int err; +might_alloc (gfp);xa_lock (xa); err =__xa_alloc (xa, id, entry, limit, gfp);xa_unlock (xa);
@@ -885,6 +895,7 @@ static inline int __must_check xa_alloc_bh(struct xarray *xa, u32 *id, {int err; +might_alloc (gfp);xa_lock_bh (xa); err =__xa_alloc (xa, id, entry, limit, gfp);xa_unlock_bh (xa);
@@ -914,6 +925,7 @@ static inline int __must_check xa_alloc_irq(struct xarray *xa, u32 *id, {int err; +might_alloc (gfp);xa_lock_irq (xa); err =__xa_alloc (xa, id, entry, limit, gfp);xa_unlock_irq (xa);
@@ -947,6 +959,7 @@ static inline int xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, {int err; +might_alloc (gfp);xa_lock (xa); err =__xa_alloc_cyclic (xa, id, entry, limit, next, gfp);xa_unlock (xa);
@@ -980,6 +993,7 @@ static inline int xa_alloc_cyclic_bh(struct xarray *xa, u32 *id, void *entry, {int err; +might_alloc (gfp);xa_lock_bh (xa); err =__xa_alloc_cyclic (xa, id, entry, limit, next, gfp);xa_unlock_bh (xa);
@@ -1013,6 +1027,7 @@ static inline int xa_alloc_cyclic_irq(struct xarray *xa, u32 *id, void *entry, {int err; +might_alloc (gfp);xa_lock_irq (xa); err =__xa_alloc_cyclic (xa, id, entry, limit, next, gfp);xa_unlock_irq (xa);
tools/include/linux/sched/mm.h +2 -0
@@ -1,4 +1,6 @@#ifndef _TOOLS_PERF_LINUX_SCHED_MM_H#define _TOOLS_PERF_LINUX_SCHED_MM_H +#define might_alloc (gfp) do { } while (0) +#endif /* _TOOLS_PERF_LINUX_SCHED_MM_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 230/644 NFS: Fixup allocation flags for nfsiods __GFP_NORETRY
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
[ Upstream commit 99765233ab42bf7a4950377ad7894dce8a5c0e60 ]
If the NFS client is doing writeback from a workqueue context, avoid using __GFP_NORETRY for allocations if the task has set PF_MEMALLOC_NOIO or PF_MEMALLOC_NOFS. The combination of these flags makes memory allocation failures much more likely.
We've seen those allocation failures show up when the loopback driver is doing writeback from a workqueue to a file on NFS, where memory allocation failure results in errors or corruption within the loopback device's filesystem.
--- fs/nfs/internal.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/nfs/internal.h +6 -3
@@ -581,9 +581,12 @@ nfs_write_match_verf(const struct nfs_writeverf *verf,static inline gfp_t nfs_io_gfp_mask (void ) { -if (current->flags &PF_WQ_WORKER ) -return GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; -return GFP_KERNEL ; +gfp_t ret =current_gfp_context (GFP_KERNEL ); + +/* For workers __GFP_NORETRY only with __GFP_IO or __GFP_FS */ +if ((current->flags &PF_WQ_WORKER ) && ret ==GFP_KERNEL ) + ret |= __GFP_NORETRY | __GFP_NOWARN; +return ret; }/* unlink.c */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 231/644 netpoll: prevent hanging NAPI when netcons gets enabled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 2da4def0f487f24bbb0cece3bb2bcdcb918a0b72 ]
Paolo spotted hangs in NIPA running driver tests against virtio. The tests hang in virtnet_close() -> virtnet_napi_tx_disable().
The problem is only reproducible if running multiple of our tests in sequence (I used TEST_PROGS="xdp.py ping.py netcons_basic.sh \netpoll_basic.py stats.py"). Initial suspicion was that this is a simple case of double-disable of NAPI, but instrumenting the code reveals:
Deadlocked on NAPI ffff888007cd82c0 (virtnet_poll_tx):
state: 0x37, disabled: false, owner: 0, listed: false, weight: 64
The NAPI was not in fact disabled, owner is 0 (rather than -1), so the NAPI "thinks" it's scheduled for CPU 0 but it's not listed (!list_empty(&n->poll_list) => false). It seems odd that normal NAPI processing would wedge itself like this.
Better suspicion is that netpoll gets enabled while NAPI is polling, and also grabs the NAPI instance. This confuses napi_complete_done():
[netpoll] [normal NAPI]
napi_poll()
have = netpoll_poll_lock()
rcu_access_pointer(dev->npinfo)
return NULL # no netpoll
__napi_poll()
->poll(->weight)
poll_napi()
cmpxchg(->poll_owner, -1, cpu)
poll_one_napi()
set_bit(NAPI_STATE_NPSVC, ->state)
napi_complete_done()
if (NAPIF_STATE_NPSVC)
return false
# exit without clearing SCHEDThis feels very unlikely, but perhaps virtio has some interactions with the hypervisor in the NAPI ->poll that makes the race window larger?
Best I could to to prove the theory was to add and trigger this warning in napi_poll (just before netpoll_poll_unlock()):
WARN_ONCE(!have && rcu_access_pointer(n->dev->npinfo) &&
napi_is_scheduled(n) && list_empty(&n->poll_list),
"NAPI race with netpoll %px", n);If this warning hits the next virtio_close() will hang.
This patch survived 30 test iterations without a hang (without it the longest clean run was around 10). Credit for triggering this goes to Breno's recent netconsole tests.
--- net/core/netpoll.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/netpoll.c +7 -0
@@ -800,6 +800,13 @@ int netpoll_setup(struct netpoll *np) goto put;rtnl_unlock (); + +/* Make sure all NAPI polls which started before dev->npinfo +* was visible have exited before we start calling NAPI poll. +* NAPI skips locking if dev->npinfo is NULL. +*/ +synchronize_rcu (); +return 0 ; put:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 232/644 phy: mscc: Fix parsing of unicast frames
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horatiu Vultur <[email protected]>
[ Upstream commit 6fb5ff63b35b7e849cc8510957f25753f87f63d2 ]
According to the 1588 standard, it is possible to use both unicast and multicast frames to send the PTP information. It was noticed that if the frames were unicast they were not processed by the analyzer meaning that they were not timestamped. Therefore fix this to match also these unicast frames.
--- drivers/net/phy/mscc/mscc_ptp.c | 1 + drivers/net/phy/mscc/mscc_ptp.h | 1 + 2 files changed, 2 insertions(+)
drivers/net/phy/mscc/mscc_ptp.c +1 -0
@@ -897,6 +897,7 @@ static int vsc85xx_eth1_conf(struct phy_device *phydev, enum ts_blk blk, get_unaligned_be32(ptp_multicast)); }else { val |=ANA_ETH1_FLOW_ADDR_MATCH2_ANY_MULTICAST ; + val |=ANA_ETH1_FLOW_ADDR_MATCH2_ANY_UNICAST ;vsc85xx_ts_write_csr (phydev, blk,MSCC_ANA_ETH1_FLOW_ADDR_MATCH2 (0 ), val); vsc85xx_ts_write_csr(phydev, blk,
drivers/net/phy/mscc/mscc_ptp.h +1 -0
@@ -98,6 +98,7 @@#define MSCC_ANA_ETH1_FLOW_ADDR_MATCH2 (x) (MSCC_ANA_ETH1_FLOW_ENA(x) + 3)#define ANA_ETH1_FLOW_ADDR_MATCH2_MASK_MASK GENMASK(22, 20)#define ANA_ETH1_FLOW_ADDR_MATCH2_ANY_MULTICAST 0x400000 +#define ANA_ETH1_FLOW_ADDR_MATCH2_ANY_UNICAST 0x200000#define ANA_ETH1_FLOW_ADDR_MATCH2_FULL_ADDR 0x100000#define ANA_ETH1_FLOW_ADDR_MATCH2_SRC_DEST_MASK GENMASK(17, 16)#define ANA_ETH1_FLOW_ADDR_MATCH2_SRC_DEST 0x020000
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 233/644 pptp: ensure minimal skb length in pptp_xmit()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit de9c4861fb42f0cd72da844c3c34f692d5895b7b ]
Commit aabc6596ffb3 ("net: ppp: Add bound checking for skb data on ppp_sync_txmung") fixed ppp_sync_txmunge()
We need a similar fix in pptp_xmit(), otherwise we might read uninit data as reported by syzbot.
BUG: KMSAN: uninit-value in pptp_xmit+0xc34/0x2720 drivers/net/ppp/pptp.c:193 pptp_xmit+0xc34/0x2720 drivers/net/ppp/pptp.c:193 ppp_channel_bridge_input drivers/net/ppp/ppp_generic.c:2290 [inline] ppp_input+0x1d6/0xe60 drivers/net/ppp/ppp_generic.c:2314 pppoe_rcv_core+0x1e8/0x760 drivers/net/ppp/pppoe.c:379 sk_backlog_rcv+0x142/0x420 include/net/sock.h:1148 __release_sock+0x1d3/0x330 net/core/sock.c:3213 release_sock+0x6b/0x270 net/core/sock.c:3767 pppoe_sendmsg+0x15d/0xcb0 drivers/net/ppp/pppoe.c:904 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg+0x330/0x3d0 net/socket.c:727 ____sys_sendmsg+0x893/0xd80 net/socket.c:2566 ___sys_sendmsg+0x271/0x3b0 net/socket.c:2620 __sys_sendmmsg+0x2d9/0x7c0 net/socket.c:2709
--- drivers/net/ppp/pptp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/ppp/pptp.c +9 -6
@@ -159,9 +159,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)int len;unsigned char *data;__u32 seq_recv; - - -struct rtable *rt; +struct rtable *rt =NULL ;struct net_device *tdev;struct iphdr *iph;int max_headroom;
@@ -179,16 +177,20 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)if (skb_headroom (skb) < max_headroom ||skb_cloned (skb) ||skb_shared (skb)) {struct sk_buff *new_skb =skb_realloc_headroom (skb, max_headroom); -if (!new_skb) { -ip_rt_put (rt); + +if (!new_skb) goto tx_error; - } +if (skb->sk)skb_set_owner_w (new_skb, skb->sk);consume_skb (skb); skb = new_skb; } +/* Ensure we can safely access protocol field and LCP code */ +if (!pskb_may_pull (skb,3 )) + goto tx_error; + data = skb->data; islcp = ((data[0 ] <<8 ) + data[1 ]) ==PPP_LCP &&1 <= data[2 ] && data[2 ] <=7 ;
@@ -262,6 +264,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)return 1 ; tx_error: +ip_rt_put (rt);kfree_skb (skb);return 1 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 234/644 net/mlx5: Correctly set gso_segs when LRO is used
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Paasch <[email protected]>
[ Upstream commit 77bf1c55b2acc7fa3734b14f4561e3d75aea1a90 ]
When gso_segs is left at 0, a number of assumptions will end up being incorrect throughout the stack.
For example, in the GRO-path, we set NAPI_GRO_CB()->count to gso_segs. So, if a non-LRO'ed packet followed by an LRO'ed packet is being processed in GRO, the first one will have NAPI_GRO_CB()->count set to 1 and the next one to 0 (in dev_gro_receive()).
Since commit 531d0d32de3e
("net/mlx5: Correctly set gso_size when LRO is used")
these packets will get merged (as their gso_size now matches). So, we end up in gro_complete() with NAPI_GRO_CB()->count == 1 and thus don't call inet_gro_complete(). Meaning, checksum-validation in tcp_checksum_complete() will fail with a "hw csum failure".
Even before the above mentioned commit, incorrect gso_segs means that other things like TCP's accounting of incoming packets (tp->segs_in, data_segs_in, rcv_ooopack) will be incorrect. Which means that if one does bytes_received/data_segs_in, the result will be bigger than the MTU.
Fix this by initializing gso_segs correctly when LRO is used.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -0
@@ -1061,6 +1061,7 @@ static inline void mlx5e_build_rx_skb(stunsigned int hdrlen =mlx5e_lro_update_hdr (skb, cqe, cqe_bcnt);skb_shinfo (skb)->gso_size =DIV_ROUND_UP (cqe_bcnt - hdrlen, lro_num_seg); +skb_shinfo (skb)->gso_segs = lro_num_seg;/* Subtract one since we already counted this as one * "regular" packet in mlx5e_complete_rx_cqe() */
Greg Kroah-Hartman
maintainerPATCH 235/644 ipv6: reject malicious packets in ipv6_gso_segment()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit d45cf1e7d7180256e17c9ce88e32e8061a7887fe ]
syzbot was able to craft a packet with very long IPv6 extension headers leading to an overflow of skb->transport_header.
This 16bit field has a limited range.
Add skb_reset_transport_header_careful() helper and use it from ipv6_gso_segment()
WARNING: CPU: 0 PID: 5871 at ./include/linux/skbuff.h:3032 skb_reset_transport_header include/linux/skbuff.h:3032 [inline] WARNING: CPU: 0 PID: 5871 at ./include/linux/skbuff.h:3032 ipv6_gso_segment+0x15e2/0x21e0 net/ipv6/ip6_offload.c:151 Modules linked in: CPU: 0 UID: 0 PID: 5871 Comm: syz-executor211 Not tainted 6.16.0-rc6-syzkaller-g7abc678e3084 #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 RIP: 0010:skb_reset_transport_header include/linux/skbuff.h:3032 [inline] RIP: 0010:ipv6_gso_segment+0x15e2/0x21e0 net/ipv6/ip6_offload.c:151 Call Trace: <TASK> skb_mac_gso_segment+0x31c/0x640 net/core/gso.c:53 nsh_gso_segment+0x54a/0xe10 net/nsh/nsh.c:110 skb_mac_gso_segment+0x31c/0x640 net/core/gso.c:53 __skb_gso_segment+0x342/0x510 net/core/gso.c:124 skb_gso_segment include/net/gso.h:83 [inline] validate_xmit_skb+0x857/0x11b0 net/core/dev.c:3950 validate_xmit_skb_list+0x84/0x120 net/core/dev.c:4000 sch_direct_xmit+0xd3/0x4b0 net/sched/sch_generic.c:329 __dev_xmit_skb net/core/dev.c:4102 [inline] __dev_queue_xmit+0x17b6/0x3a70 net/core/dev.c:4679
--- include/linux/skbuff.h | 23 +++++++++++++++++++++++ net/ipv6/ip6_offload.c | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-)
include/linux/skbuff.h +23 -0
@@ -2646,6 +2646,29 @@ static inline void skb_reset_transport_header(struct sk_buff *skb) skb->transport_header = skb->data - skb->head; } +/** +* skb_reset_transport_header_careful - conditionally reset transport header +* @skb: buffer to alter +* +* Hardened version of skb_reset_transport_header(). +* +* Returns: true if the operation was a success. +*/ +static inline bool __must_check +skb_reset_transport_header_careful (struct sk_buff *skb) +{ +long offset = skb->data - skb->head; + + if (unlikely(offset != (typeof(skb->transport_header))offset)) +return false; + + if (unlikely(offset == (typeof(skb->transport_header))~0U)) +return false; + + skb->transport_header = offset; +return true; +} +static inline void skb_set_transport_header (struct sk_buff *skb,const int offset) {
net/ipv6/ip6_offload.c +3 -1
@@ -112,7 +112,9 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, ops =rcu_dereference (inet6_offloads[proto]);if (likely (ops && ops->callbacks.gso_segment)) { -skb_reset_transport_header (skb); +if (!skb_reset_transport_header_careful (skb)) + goto out; + segs = ops->callbacks.gso_segment (skb, features);if (!segs) skb->network_header =skb_mac_header (skb) + nhoff - skb->head;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 236/644 net: drop UFO packets in udp_rcv_segment()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Liang <[email protected]>
[ Upstream commit d46e51f1c78b9ab9323610feb14238d06d46d519 ]
When sending a packet with virtio_net_hdr to tun device, if the gso_type in virtio_net_hdr is SKB_GSO_UDP and the gso_size is less than udphdr size, below crash may happen.
------------[ cut here ]------------ kernel BUG at net/core/skbuff.c:4572! Oops: invalid opcode: 0000 [#1] SMP NOPTI CPU: 0 UID: 0 PID: 62 Comm: mytest Not tainted 6.16.0-rc7 #203 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 RIP: 0010:skb_pull_rcsum+0x8e/0xa0 Code: 00 00 5b c3 cc cc cc cc 8b 93 88 00 00 00 f7 da e8 37 44 38 00 f7 d8 89 83 88 00 00 00 48 8b 83 c8 00 00 00 5b c3 cc cc cc cc <0f> 0b 0f 0b 66 66 2e 0f 1f 84 00 000 RSP: 0018:ffffc900001fba38 EFLAGS: 00000297 RAX: 0000000000000004 RBX: ffff8880040c1000 RCX: ffffc900001fb948 RDX: ffff888003e6d700 RSI: 0000000000000008 RDI: ffff88800411a062 RBP: ffff8880040c1000 R08: 0000000000000000 R09: 0000000000000001 R10: ffff888003606c00 R11: 0000000000000001 R12: 0000000000000000 R13: ffff888004060900 R14: ffff888004050000 R15: ffff888004060900 FS: 000000002406d3c0(0000) GS:ffff888084a19000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000040 CR3: 0000000004007000 CR4: 00000000000006f0 Call Trace: <TASK> udp_queue_rcv_one_skb+0x176/0x4b0 net/ipv4/udp.c:2445 udp_queue_rcv_skb+0x155/0x1f0 net/ipv4/udp.c:2475 udp_unicast_rcv_skb+0x71/0x90 net/ipv4/udp.c:2626 __udp4_lib_rcv+0x433/0xb00 net/ipv4/udp.c:2690 ip_protocol_deliver_rcu+0xa6/0x160 net/ipv4/ip_input.c:205 ip_local_deliver_finish+0x72/0x90 net/ipv4/ip_input.c:233 ip_sublist_rcv_finish+0x5f/0x70 net/ipv4/ip_input.c:579 ip_sublist_rcv+0x122/0x1b0 net/ipv4/ip_input.c:636 ip_list_rcv+0xf7/0x130 net/ipv4/ip_input.c:670 __netif_receive_skb_list_core+0x21d/0x240 net/core/dev.c:6067 netif_receive_skb_list_internal+0x186/0x2b0 net/core/dev.c:6210 napi_complete_done+0x78/0x180 net/core/dev.c:6580 tun_get_user+0xa63/0x1120 drivers/net/tun.c:1909 tun_chr_write_iter+0x65/0xb0 drivers/net/tun.c:1984 vfs_write+0x300/0x420 fs/read_write.c:593 ksys_write+0x60/0xd0 fs/read_write.c:686 do_syscall_64+0x50/0x1c0 arch/x86/entry/syscall_64.c:63 </TASK>
To trigger gso segment in udp_queue_rcv_skb(), we should also set option UDP_ENCAP_ESPINUDP to enable udp_sk(sk)->encap_rcv. When the encap_rcv hook return 1 in udp_queue_rcv_one_skb(), udp_csum_pull_header() will try to pull udphdr, but the skb size has been segmented to gso size, which leads to this crash.
Previous commit cf329aa42b66 ("udp: cope with UDP GRO packet misdirection") introduces segmentation in UDP receive path only for GRO, which was never intended to be used for UFO, so drop UFO packets in udp_rcv_segment().
--- include/net/udp.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
include/net/udp.h +18 -6
@@ -483,6 +483,16 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk, {netdev_features_t features =NETIF_F_SG ;struct sk_buff *segs; +int drop_count; + +/* +* Segmentation in UDP receive path is only for UDP GRO, drop udp +* fragmentation offload (UFO) packets. +*/ +if (skb_shinfo (skb)->gso_type &SKB_GSO_UDP ) { + drop_count =1 ; + goto drop; + }/* Avoid csum recalculation by skb_segment unless userspace explicitly * asks for the final checksum values
@@ -506,16 +516,18 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,*/ segs =__skb_gso_segment (skb, features, false);if (IS_ERR_OR_NULL (segs)) { -int segs_nr =skb_shinfo (skb)->gso_segs; - -atomic_add (segs_nr, &sk->sk_drops); -SNMP_ADD_STATS (__UDPX_MIB (sk, ipv4),UDP_MIB_INERRORS , segs_nr); -kfree_skb (skb); -return NULL ; + drop_count =skb_shinfo (skb)->gso_segs; + goto drop; }consume_skb (skb);return segs; + +drop: +atomic_add (drop_count, &sk->sk_drops); +SNMP_ADD_STATS (__UDPX_MIB (sk, ipv4),UDP_MIB_INERRORS , drop_count); +kfree_skb (skb); +return NULL ; }static inline void udp_post_segment_fix_csum (struct sk_buff *skb)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 237/644 benet: fix BUG when creating VFs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Schmidt <[email protected]>
[ Upstream commit 5a40f8af2ba1b9bdf46e2db10e8c9710538fbc63 ]
benet crashes as soon as SRIOV VFs are created:
kernel BUG at mm/vmalloc.c:3457!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 4 UID: 0 PID: 7408 Comm: test.sh Kdump: loaded Not tainted 6.16.0+ #1 PREEMPT(voluntary) [...] RIP: 0010:vunmap+0x5f/0x70 [...] Call Trace: <TASK> __iommu_dma_free+0xe8/0x1c0 be_cmd_set_mac_list+0x3fe/0x640 [be2net] be_cmd_set_mac+0xaf/0x110 [be2net] be_vf_eth_addr_config+0x19f/0x330 [be2net] be_vf_setup+0x4f7/0x990 [be2net] be_pci_sriov_configure+0x3a1/0x470 [be2net] sriov_numvfs_store+0x20b/0x380 kernfs_fop_write_iter+0x354/0x530 vfs_write+0x9b9/0xf60 ksys_write+0xf3/0x1d0 do_syscall_64+0x8c/0x3d0
be_cmd_set_mac_list() calls dma_free_coherent() under a spin_lock_bh. Fix it by freeing only after the lock has been released.
--- drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/emulex/benet/be_cmds.c +1 -1
@@ -3851,8 +3851,8 @@ int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, status =be_mcc_notify_wait (adapter); err: -dma_free_coherent (&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);spin_unlock_bh (&adapter->mcc_lock); +dma_free_coherent (&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);return status; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 238/644 ALSA: hda/ca0132: Fix missing error handling in ca0132_alt_select_out()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9f320dfb0ffc555aa2eac8331dee0c2c16f67633 ]
There are a couple of cases where the error is ignored or the error code isn't propagated in ca0132_alt_select_out(). Fix those.
--- sound/pci/hda/patch_ca0132.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/pci/hda/patch_ca0132.c +4 -1
@@ -4794,7 +4794,8 @@ static int ca0132_alt_select_out(struct hda_codec *codec)if (err <0 ) goto exit; -if (ca0132_alt_select_out_quirk_set (codec) <0 ) + err =ca0132_alt_select_out_quirk_set (codec); +if (err <0 ) goto exit;switch (spec->cur_out_type) {
@@ -4884,6 +4885,8 @@ static int ca0132_alt_select_out(struct hda_codec *codec) spec->bass_redirection_val); else err =ca0132_alt_surround_set_bass_redirection (codec,0 ); +if (err <0 ) + goto exit;/* Unmute DSP now that we're done with output selection. */ err = dspio_set_uint_param(codec, 0x96,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 239/644 smb: server: remove separate empty_recvmsg_queue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit 01027a62b508c48c762096f347de925eedcbd008 ]
There's no need to maintain two lists, we can just have a single list of receive buffers, which are free to use.
--- fs/ksmbd/transport_rdma.c | 60 ++++++--------------------------------- 1 file changed, 8 insertions(+), 52 deletions(-)
fs/ksmbd/transport_rdma.c +8 -52
@@ -128,9 +128,6 @@ struct smb_direct_transport {spinlock_t recvmsg_queue_lock;struct list_head recvmsg_queue; -spinlock_t empty_recvmsg_queue_lock; -struct list_head empty_recvmsg_queue; -int send_credit_target;atomic_t send_credits;spinlock_t lock_new_recv_credits;
@@ -274,32 +271,6 @@ static void put_recvmsg(struct smb_direct_transport *t,spin_unlock (&t->recvmsg_queue_lock); } -static struct -smb_direct_recvmsg *get_empty_recvmsg (struct smb_direct_transport *t) -{ -struct smb_direct_recvmsg *recvmsg =NULL ; - -spin_lock (&t->empty_recvmsg_queue_lock); -if (!list_empty (&t->empty_recvmsg_queue)) { - recvmsg =list_first_entry (&t->empty_recvmsg_queue, - struct smb_direct_recvmsg, list); -list_del (&recvmsg->list); - } -spin_unlock (&t->empty_recvmsg_queue_lock); -return recvmsg; -} - -static void put_empty_recvmsg (struct smb_direct_transport *t, -struct smb_direct_recvmsg *recvmsg) -{ -ib_dma_unmap_single (t->cm_id->device, recvmsg->sge.addr, - recvmsg->sge.length,DMA_FROM_DEVICE ); - -spin_lock (&t->empty_recvmsg_queue_lock); -list_add_tail (&recvmsg->list, &t->empty_recvmsg_queue); -spin_unlock (&t->empty_recvmsg_queue_lock); -} -static void enqueue_reassembly (struct smb_direct_transport *t,struct smb_direct_recvmsg *recvmsg,int data_length)
@@ -384,9 +355,6 @@ static struct smb_direct_transport *alloc_transport(struct rdma_cm_id *cm_id)spin_lock_init (&t->recvmsg_queue_lock);INIT_LIST_HEAD (&t->recvmsg_queue); -spin_lock_init (&t->empty_recvmsg_queue_lock); -INIT_LIST_HEAD (&t->empty_recvmsg_queue); -init_waitqueue_head (&t->wait_send_pending);atomic_set (&t->send_pending,0 );
@@ -548,7 +516,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) wc->opcode);smb_direct_disconnect_rdma_connection (t); } -put_empty_recvmsg (t, recvmsg); +put_recvmsg (t, recvmsg);return ; }
@@ -562,7 +530,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)switch (recvmsg->type) {case SMB_DIRECT_MSG_NEGOTIATE_REQ :if (wc->byte_len <sizeof (struct smb_direct_negotiate_req )) { -put_empty_recvmsg (t, recvmsg); +put_recvmsg (t, recvmsg);return ; } t->negotiation_requested = true;
@@ -579,7 +547,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)if (wc->byte_len < offsetof(struct smb_direct_data_transfer , padding)) { -put_empty_recvmsg (t, recvmsg); +put_recvmsg (t, recvmsg);return ; }
@@ -587,7 +555,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)if (data_length) {if (wc->byte_len <sizeof (struct smb_direct_data_transfer ) + (u64 )data_length) { -put_empty_recvmsg (t, recvmsg); +put_recvmsg (t, recvmsg);return ; }
@@ -607,7 +575,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) avail_recvmsg_count = t->count_avail_recvmsg;spin_unlock (&t->receive_credit_lock); }else { -put_empty_recvmsg (t, recvmsg); +put_recvmsg (t, recvmsg);spin_lock (&t->receive_credit_lock); receive_credits = --(t->recv_credits);
@@ -805,7 +773,6 @@ static void smb_direct_post_recv_credits(struct work_struct *work)struct smb_direct_recvmsg *recvmsg;int receive_credits, credits =0 ;int ret; -int use_free =1 ;spin_lock (&t->receive_credit_lock); receive_credits = t->recv_credits;
@@ -813,18 +780,9 @@ static void smb_direct_post_recv_credits(struct work_struct *work)if (receive_credits < t->recv_credit_target) {while (true) { -if (use_free) - recvmsg =get_free_recvmsg (t); -else - recvmsg =get_empty_recvmsg (t); -if (!recvmsg) { -if (use_free) { - use_free =0 ; -continue ; - }else { -break ; - } - } + recvmsg =get_free_recvmsg (t); +if (!recvmsg) +break ; recvmsg->type =SMB_DIRECT_MSG_DATA_TRANSFER ; recvmsg->first_segment = false;
@@ -1800,8 +1758,6 @@ static void smb_direct_destroy_pools(struct smb_direct_transport *t)while ((recvmsg =get_free_recvmsg (t)))mempool_free (recvmsg, t->recvmsg_mempool); -while ((recvmsg =get_empty_recvmsg (t))) -mempool_free (recvmsg, t->recvmsg_mempool);mempool_destroy (t->recvmsg_mempool); t->recvmsg_mempool =NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 240/644 smb: server: make sure we call ib_dma_unmap_single() only if we called ib_dma_map_single already
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit afb4108c92898350e66b9a009692230bcdd2ac73 ]
In case of failures either ib_dma_map_single() might not be called yet or ib_dma_unmap_single() was already called.
We should make sure put_recvmsg() only calls ib_dma_unmap_single() if needed.
--- fs/ksmbd/transport_rdma.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ksmbd/transport_rdma.c +9 -2
@@ -263,8 +263,13 @@ smb_direct_recvmsg *get_free_recvmsg(struct smb_direct_transport *t)static void put_recvmsg (struct smb_direct_transport *t,struct smb_direct_recvmsg *recvmsg) { -ib_dma_unmap_single (t->cm_id->device, recvmsg->sge.addr, - recvmsg->sge.length,DMA_FROM_DEVICE ); +if (likely (recvmsg->sge.length !=0 )) { +ib_dma_unmap_single (t->cm_id->device, + recvmsg->sge.addr, + recvmsg->sge.length, +DMA_FROM_DEVICE ); + recvmsg->sge.length =0 ; + }spin_lock (&t->recvmsg_queue_lock);list_add (&recvmsg->list, &t->recvmsg_queue);
@@ -632,6 +637,7 @@ static int smb_direct_post_recv(struct smb_direct_transport *t,ib_dma_unmap_single (t->cm_id->device, recvmsg->sge.addr, recvmsg->sge.length,DMA_FROM_DEVICE ); + recvmsg->sge.length =0 ;smb_direct_disconnect_rdma_connection (t);return ret; }
@@ -1813,6 +1819,7 @@ static int smb_direct_create_pools(struct smb_direct_transport *t)if (!recvmsg) goto err; recvmsg->transport = t; + recvmsg->sge.length =0 ;list_add (&recvmsg->list, &t->recvmsg_queue); } t->count_avail_recvmsg = t->recv_credit_max;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 241/644 smb: server: let recv_done() consistently call put_recvmsg/smb_direct_disconnect_rdma_connection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit cfe76fdbb9729c650f3505d9cfb2f70ddda2dbdc ]
We should call put_recvmsg() before smb_direct_disconnect_rdma_connection() in order to call it before waking up the callers.
In all error cases we should call smb_direct_disconnect_rdma_connection() in order to avoid stale connections.
--- fs/ksmbd/transport_rdma.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
fs/ksmbd/transport_rdma.c +13 -5
@@ -515,13 +515,13 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) t = recvmsg->transport;if (wc->status !=IB_WC_SUCCESS || wc->opcode !=IB_WC_RECV ) { +put_recvmsg (t, recvmsg);if (wc->status !=IB_WC_WR_FLUSH_ERR ) {pr_err ("Recv error. status='%s (%d)' opcode=%d\n" ,ib_wc_status_msg (wc->status), wc->status, wc->opcode);smb_direct_disconnect_rdma_connection (t); } -put_recvmsg (t, recvmsg);return ; }
@@ -536,6 +536,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)case SMB_DIRECT_MSG_NEGOTIATE_REQ :if (wc->byte_len <sizeof (struct smb_direct_negotiate_req )) {put_recvmsg (t, recvmsg); +smb_direct_disconnect_rdma_connection (t);return ; } t->negotiation_requested = true;
@@ -543,7 +544,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) t->status =SMB_DIRECT_CS_CONNECTED ;enqueue_reassembly (t, recvmsg,0 );wake_up_interruptible (&t->wait_status); -break ; +return ;case SMB_DIRECT_MSG_DATA_TRANSFER : {struct smb_direct_data_transfer *data_transfer = (struct smb_direct_data_transfer *)recvmsg->packet;
@@ -553,6 +554,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)if (wc->byte_len < offsetof(struct smb_direct_data_transfer , padding)) {put_recvmsg (t, recvmsg); +smb_direct_disconnect_rdma_connection (t);return ; }
@@ -561,6 +563,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)if (wc->byte_len <sizeof (struct smb_direct_data_transfer ) + (u64 )data_length) {put_recvmsg (t, recvmsg); +smb_direct_disconnect_rdma_connection (t);return ; }
@@ -603,11 +606,16 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)if (is_receive_credit_post_required (receive_credits, avail_recvmsg_count))mod_delayed_work (smb_direct_wq, &t->post_recv_credits_work,0 ); -break ; +return ; } -default : -break ; } + +/* +* This is an internal error! +*/ +WARN_ON_ONCE (recvmsg->type !=SMB_DIRECT_MSG_DATA_TRANSFER ); +put_recvmsg (t, recvmsg); +smb_direct_disconnect_rdma_connection (t); } static int smb_direct_post_recv(struct smb_direct_transport *t,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 242/644 smb: server: let recv_done() avoid touching data_transfer after cleanup/move
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit a6c015b7ac2d8c5233337e5793f50d04fac17669 ]
Calling enqueue_reassembly() and wake_up_interruptible(&t->wait_reassembly_queue) or put_receive_buffer() means the recvmsg/data_transfer pointer might get re-used by another thread, which means these should be
the last operations before calling return.
--- fs/ksmbd/transport_rdma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/ksmbd/transport_rdma.c +7 -5
@@ -575,16 +575,11 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)else t->full_packet_received = true; -enqueue_reassembly (t, recvmsg, (int )data_length); -wake_up_interruptible (&t->wait_reassembly_queue); -spin_lock (&t->receive_credit_lock); receive_credits = --(t->recv_credits); avail_recvmsg_count = t->count_avail_recvmsg;spin_unlock (&t->receive_credit_lock); }else { -put_recvmsg (t, recvmsg); -spin_lock (&t->receive_credit_lock); receive_credits = --(t->recv_credits); avail_recvmsg_count = ++(t->count_avail_recvmsg);
@@ -606,6 +601,13 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)if (is_receive_credit_post_required (receive_credits, avail_recvmsg_count))mod_delayed_work (smb_direct_wq, &t->post_recv_credits_work,0 ); + +if (data_length) { +enqueue_reassembly (t, recvmsg, (int )data_length); +wake_up_interruptible (&t->wait_reassembly_queue); + }else +put_recvmsg (t, recvmsg); +return ; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 243/644 smb: client: let recv_done() cleanup before notifying the callers.
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit bdd7afc6dca5e0ebbb75583484aa6ea9e03fbb13 ]
We should call put_receive_buffer() before waking up the callers.
For the internal error case of response->type being unexpected, we now also call smbd_disconnect_rdma_connection() instead of not waking up the callers at all.
Note that the SMBD_TRANSFER_DATA case still has problems, which will be addressed in the next commit in order to make it easier to review this one.
--- fs/cifs/smbdirect.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
fs/cifs/smbdirect.c +8 -6
@@ -455,7 +455,6 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)if (wc->status !=IB_WC_SUCCESS || wc->opcode !=IB_WC_RECV ) {log_rdma_recv (INFO ,"wc->status=%d opcode=%d\n" , wc->status, wc->opcode); -smbd_disconnect_rdma_connection (info); goto error; }
@@ -472,8 +471,9 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) info->full_packet_received = true; info->negotiate_done =process_negotiation_response (response, wc->byte_len); +put_receive_buffer (info, response);complete (&info->negotiate_completion); -break ; +return ;/* SMBD data transfer packet */ case SMBD_TRANSFER_DATA :
@@ -530,14 +530,16 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) }return ; - -default : -log_rdma_recv (ERR , -"unexpected response type=%d\n" , response->type); } +/* +* This is an internal error! +*/ +log_rdma_recv (ERR ,"unexpected response type=%d\n" , response->type); +WARN_ON_ONCE (response->type !=SMBD_TRANSFER_DATA ); error:put_receive_buffer (info, response); +smbd_disconnect_rdma_connection (info); } static struct rdma_cm_id *smbd_create_id(
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 244/644 pptp: fix pptp_xmit() error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit ae633388cae349886f1a3cfb27aa092854b24c1b ]
I accidentally added a bug in pptp_xmit() that syzbot caught for us.
Only call ip_rt_put() if a route has been allocated.
BUG: unable to handle page fault for address: ffffffffffffffdb PGD df3b067 P4D df3b067 PUD df3d067 PMD 0 Oops: Oops: 0002 [#1] SMP KASAN PTI CPU: 1 UID: 0 PID: 6346 Comm: syz.0.336 Not tainted 6.16.0-next-20250804-syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 RIP: 0010:arch_atomic_add_return arch/x86/include/asm/atomic.h:85 [inline] RIP: 0010:raw_atomic_sub_return_release include/linux/atomic/atomic-arch-fallback.h:846 [inline] RIP: 0010:atomic_sub_return_release include/linux/atomic/atomic-instrumented.h:327 [inline] RIP: 0010:__rcuref_put include/linux/rcuref.h:109 [inline] RIP: 0010:rcuref_put+0x172/0x210 include/linux/rcuref.h:173 Call Trace: <TASK> dst_release+0x24/0x1b0 net/core/dst.c:167 ip_rt_put include/net/route.h:285 [inline] pptp_xmit+0x14b/0x1a90 drivers/net/ppp/pptp.c:267 __ppp_channel_push+0xf2/0x1c0 drivers/net/ppp/ppp_generic.c:2166 ppp_channel_push+0x123/0x660 drivers/net/ppp/ppp_generic.c:2198 ppp_write+0x2b0/0x400 drivers/net/ppp/ppp_generic.c:544 vfs_write+0x27b/0xb30 fs/read_write.c:684 ksys_write+0x145/0x250 fs/read_write.c:738 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- drivers/net/ppp/pptp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ppp/pptp.c +4 -3
@@ -159,17 +159,17 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)int len;unsigned char *data;__u32 seq_recv; -struct rtable *rt =NULL ; +struct rtable *rt;struct net_device *tdev;struct iphdr *iph;int max_headroom;if (sk_pppox (po)->sk_state &PPPOX_DEAD ) - goto tx_error; + goto tx_drop; rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) - goto tx_error; + goto tx_drop; tdev = rt->dst.dev;
@@ -265,6 +265,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) tx_error:ip_rt_put (rt); +tx_drop:kfree_skb (skb);return 1 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 245/644 perf/core: Dont leak AUX buffer refcount on allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 5468c0fbccbb9d156522c50832244a8b722374fb upstream.
Failure of the AUX buffer allocation leaks the reference count.
Set the reference count to 1 only when the allocation succeeds.
--- kernel/events/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/events/core.c +4 -3
@@ -6477,9 +6477,7 @@ static int perf_mmap(struct file *file, goto unlock; } -atomic_set (&rb->aux_mmap_count,1 ); user_extra = nr_pages; - goto accounting; }
@@ -6581,8 +6579,10 @@ accounting: }else { ret =rb_alloc_aux (rb, event, vma->vm_pgoff, nr_pages, event->attr.aux_watermark, flags); -if (!ret) +if (!ret) { +atomic_set (&rb->aux_mmap_count,1 ); rb->aux_mmap_locked = extra; + } } unlock:
@@ -6592,6 +6592,7 @@ unlock:atomic_inc (&event->mmap_count); }else if (rb) { +/* AUX allocation failed */ atomic_dec (&rb->mmap_count); } aux_unlock:
Greg Kroah-Hartman
maintainerPATCH 246/644 perf/core: Exit early on perf_mmap() fail
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 07091aade394f690e7b655578140ef84d0e8d7b0 upstream.
When perf_mmap() fails to allocate a buffer, it still invokes the event_mapped() callback of the related event. On X86 this might increase the perf_rdpmc_allowed reference counter. But nothing undoes this as perf_mmap_close() is never called in this case, which causes another reference count leak.
Return early on failure to prevent that.
--- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/events/core.c +3 -0
@@ -6600,6 +6600,9 @@ aux_unlock:mutex_unlock (aux_mutex);mutex_unlock (&event->mmap_mutex); +if (ret) +return ret; +/* * Since pinned accounting is per vm we cannot allow fork() to copy our * vma.
Greg Kroah-Hartman
maintainerPATCH 247/644 perf/core: Prevent VMA split of buffer mappings
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit b024d7b56c77191cde544f838debb7f8451cd0d6 upstream.
The perf mmap code is careful about mmap()'ing the user page with the ringbuffer and additionally the auxiliary buffer, when the event supports it. Once the first mapping is established, subsequent mapping have to use the same offset and the same size in both cases. The reference counting for the ringbuffer and the auxiliary buffer depends on this being correct.
Though perf does not prevent that a related mapping is split via mmap(2), munmap(2) or mremap(2). A split of a VMA results in perf_mmap_open() calls, which take reference counts, but then the subsequent perf_mmap_close() calls are not longer fulfilling the offset and size checks. This leads to reference count leaks.
As perf already has the requirement for subsequent mappings to match the initial mapping, the obvious consequence is that VMA splits, caused by resizing of a mapping or partial unmapping, have to be prevented.
Implement the vm_operations_struct::may_split() callback and return unconditionally -EINVAL.
That ensures that the mapping offsets and sizes cannot be changed after the fact. Remapping to a different fixed address with the same size is still possible as it takes the references for the new mapping and drops those of the old mapping.
--- kernel/events/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/events/core.c +10 -0
@@ -6381,11 +6381,21 @@ out_put:ring_buffer_put (rb);/* could be last */ } +static int perf_mmap_may_split (struct vm_area_struct *vma,unsigned long addr) +{ +/* +* Forbid splitting perf mappings to prevent refcount leaks due to +* the resulting non-matching offsets and sizes. See open()/close(). +*/ +return -EINVAL ; +} +static const struct vm_operations_struct perf_mmap_vmops = { .open = perf_mmap_open, .close = perf_mmap_close,/* non mergeable */ .fault = perf_mmap_fault, .page_mkwrite = perf_mmap_fault, + .may_split = perf_mmap_may_split, };static int perf_mmap (struct file *file,struct vm_area_struct *vma)
Greg Kroah-Hartman
maintainerPATCH 248/644 selftests/perf_events: Add a mmap() correctness test
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Stoakes <[email protected]>
commit 084d2ac4030c5919e85bba1f4af26e33491469cb upstream.
Exercise various mmap(), munmap() and mremap() invocations, which might cause a perf buffer mapping to be split or truncated.
To avoid hard coding the perf event and having dependencies on architectures and configuration options, scan through event types in sysfs and try to open them. On success, try to mmap() and if that succeeds try to mmap() the AUX buffer.
In case that no AUX buffer supporting event is found, only test the base buffer mapping. If no mappable event is found or permissions are not sufficient, skip the tests.
Reserve a PROT_NONE region for both rb and aux tests to allow testing the case where mremap unmaps beyond the end of a mapped VMA to prevent it from unmapping unrelated mappings.
--- tools/testing/selftests/perf_events/.gitignore | 1 tools/testing/selftests/perf_events/Makefile | 2 tools/testing/selftests/perf_events/mmap.c | 236 +++++++++++++++++++++++++ 3 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/perf_events/mmap.c
tools/testing/selftests/perf_events/.gitignore +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only sigtrap_threads remove_on_exec +mmap
tools/testing/selftests/perf_events/Makefile +1 -1
@@ -2,5 +2,5 @@ CFLAGS += -Wl,-no-as-needed -Wall -I../../../../usr/include LDFLAGS += -lpthread -TEST_GEN_PROGS := sigtrap_threads remove_on_exec +TEST_GEN_PROGS := sigtrap_threads remove_on_exec mmap include ../lib.mk
tools/testing/selftests/perf_events/mmap.c new file +236 -0
236 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 249/644 net/packet: fix a race in packet_set_ring() and packet_notifier()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quang Le <[email protected]>
commit 01d3c8417b9c1b884a8a981a3b886da556512f36 upstream.
When packet_set_ring() releases po->bind_lock, another thread can run packet_notifier() and process an NETDEV_UP event.
This race and the fix are both similar to that of commit 15fe076edea7 ("net/packet: fix a race in packet_bind() and packet_notifier()").
There too the packet_notifier NETDEV_UP event managed to run while a po->bind_lock critical section had to be temporarily released. And the fix was similarly to temporarily set po->num to zero to keep the socket unhooked until the lock is retaken.
The po->bind_lock in packet_set_ring and packet_notifier precede the introduction of git history.
--- net/packet/af_packet.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/packet/af_packet.c +6 -6
@@ -4506,10 +4506,10 @@ static int packet_set_ring(struct sock *spin_lock (&po->bind_lock); was_running = po->running; num = po->num; -if (was_running) { -WRITE_ONCE (po->num,0 ); +WRITE_ONCE (po->num,0 ); +if (was_running)__unregister_prot_hook (sk, false); - } +spin_unlock (&po->bind_lock);synchronize_net ();
@@ -4541,10 +4541,10 @@ static int packet_set_ring(struct sock *mutex_unlock (&po->pg_vec_lock);spin_lock (&po->bind_lock); -if (was_running) { -WRITE_ONCE (po->num, num); +WRITE_ONCE (po->num, num); +if (was_running)register_prot_hook (sk); - } +spin_unlock (&po->bind_lock);if (pg_vec && (po->tp_version >TPACKET_V2 )) {/* Because we don't support block-based V3 on tx-ring */
Greg Kroah-Hartman
maintainerPATCH 250/644 vsock: Do not allow binding to VMADDR_PORT_ANY
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Budimir Markovic <[email protected]>
commit aba0c94f61ec05315fa7815d21aefa4c87f6a9f4 upstream.
It is possible for a vsock to autobind to VMADDR_PORT_ANY. This can cause a use-after-free when a connection is made to the bound socket. The socket returned by accept() also has port VMADDR_PORT_ANY but is not on the list of unbound sockets. Binding it will result in an extra refcount decrement similar to the one fixed in fcdd2242c023 (vsock: Keep the binding until socket destruction).
Modify the check in __vsock_bind_connectible() to also prevent binding to VMADDR_PORT_ANY.
--- net/vmw_vsock/af_vsock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/vmw_vsock/af_vsock.c +2 -1
@@ -683,7 +683,8 @@ static int __vsock_bind_connectible(struunsigned int i;for (i =0 ; i <MAX_PORT_RETRIES ; i++) { -if (port <=LAST_RESERVED_PORT ) +if (port ==VMADDR_PORT_ANY || + port <=LAST_RESERVED_PORT ) port =LAST_RESERVED_PORT +1 ; new_addr.svm_port = port++;
Greg Kroah-Hartman
maintainerPATCH 251/644 USB: serial: option: add Foxconn T99W709
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slark Xiao <[email protected]>
commit ad1244e1ce18f8c1a5ebad8074bfcf10eacb0311 upstream.
T99W709 is designed based on MTK T300(5G redcap) chip. There are 7 serial ports to be enumerated: AP_LOG, GNSS, AP_META, AT, MD_META, NPT, DBG. RSVD(5) for ADB port.
test evidence as below:
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0489 ProdID=e15f Rev=00.01 S: Manufacturer=MediaTek Inc. S: Product=USB DATA CARD S: SerialNumber=355511220000399 C: #Ifs=10 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim I: If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim I: If#=0x2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs I: If#=0x6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x7 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x8 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x9 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -2346,6 +2346,8 @@ static const struct usb_device_id option .driver_info = RSVD(3) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe145, 0xff), /* Foxconn T99W651 RNDIS */ .driver_info = RSVD(5) | RSVD(6) }, + { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe15f, 0xff), /* Foxconn T99W709 */ + .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe167, 0xff), /* Foxconn T99W640 MBIM */ .driver_info = RSVD(3) }, { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 (IOT version) */
Greg Kroah-Hartman
maintainerPATCH 252/644 net: usbnet: Avoid potential RCU stall on LINK_CHANGE event
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ernberg <[email protected]>
commit 0d9cfc9b8cb17dbc29a98792d36ec39a1cf1395f upstream.
The Gemalto Cinterion PLS83-W modem (cdc_ether) is emitting confusing link up and down events when the WWAN interface is activated on the modem-side.
Interrupt URBs will in consecutive polls grab:
* Link Connected
* Link Disconnected
* Link Connected
Where the last Connected is then a stable link state.
When the system is under load this may cause the unlink_urbs() work in __handle_link_change() to not complete before the next usbnet_link_change() call turns the carrier on again, allowing rx_submit() to queue new SKBs.
In that event the URB queue is filled faster than it can drain, ending up in a RCU stall:
rcu: INFO: rcu_sched detected expedited stalls on CPUs/tasks: { 0-.... } 33108 jiffies s: 201 root: 0x1/.
rcu: blocking rcu_node structures (internal RCU debug):
Sending NMI from CPU 1 to CPUs 0:
NMI backtrace for cpu 0
Call trace:
arch_local_irq_enable+0x4/0x8
local_bh_enable+0x18/0x20
__netdev_alloc_skb+0x18c/0x1cc
rx_submit+0x68/0x1f8 [usbnet]
rx_alloc_submit+0x4c/0x74 [usbnet]
usbnet_bh+0x1d8/0x218 [usbnet]
usbnet_bh_tasklet+0x10/0x18 [usbnet]
tasklet_action_common+0xa8/0x110
tasklet_action+0x2c/0x34
handle_softirqs+0x2cc/0x3a0
__do_softirq+0x10/0x18
____do_softirq+0xc/0x14
call_on_irq_stack+0x24/0x34
do_softirq_own_stack+0x18/0x20
__irq_exit_rcu+0xa8/0xb8
irq_exit_rcu+0xc/0x30
el1_interrupt+0x34/0x48
el1h_64_irq_handler+0x14/0x1c
el1h_64_irq+0x68/0x6c
_raw_spin_unlock_irqrestore+0x38/0x48
xhci_urb_dequeue+0x1ac/0x45c [xhci_hcd]
unlink1+0xd4/0xdc [usbcore]
usb_hcd_unlink_urb+0x70/0xb0 [usbcore]
usb_unlink_urb+0x24/0x44 [usbcore]
unlink_urbs.constprop.0.isra.0+0x64/0xa8 [usbnet]
__handle_link_change+0x34/0x70 [usbnet]
usbnet_deferred_kevent+0x1c0/0x320 [usbnet]
process_scheduled_works+0x2d0/0x48c
worker_thread+0x150/0x1dc
kthread+0xd8/0xe8
ret_from_fork+0x10/0x20Get around the problem by delaying the carrier on to the scheduled work.
This needs a new flag to keep track of the necessary action.
The carrier ok check cannot be removed as it remains required for the LINK_RESET event flow.
--- drivers/net/usb/usbnet.c | 11 ++++++++--- include/linux/usb/usbnet.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/usb/usbnet.c +8 -3
@@ -1127,6 +1127,9 @@ static void __handle_link_change(struct* tx queue is stopped by netcore after link becomes off */ }else { +if (test_and_clear_bit (EVENT_LINK_CARRIER_ON , &dev->flags)) +netif_carrier_on (dev->net); +/* submitting URBs for reading packets */ tasklet_schedule (&dev->bh); }
@@ -2013,10 +2016,12 @@ EXPORT_SYMBOL(usbnet_manage_power);void usbnet_link_change (struct usbnet *dev,bool link,bool need_reset) {/* update link after link is reseted */ -if (link && !need_reset) -netif_carrier_on (dev->net); -else +if (link && !need_reset) { +set_bit (EVENT_LINK_CARRIER_ON , &dev->flags); + }else { +clear_bit (EVENT_LINK_CARRIER_ON , &dev->flags);netif_carrier_off (dev->net); + }if (need_reset && link)usbnet_defer_kevent (dev,EVENT_LINK_RESET );
include/linux/usb/usbnet.h +1 -0
@@ -84,6 +84,7 @@ struct usbnet {# define EVENT_LINK_CHANGE 11# define EVENT_SET_RX_MODE 12# define EVENT_NO_IP_ALIGN 13 +# define EVENT_LINK_CARRIER_ON 14/* This one is special, as it indicates that the device is going away * there are cyclic dependencies between tasklet, timer and bh * that must be broken
Greg Kroah-Hartman
maintainerPATCH 253/644 net: usbnet: Fix the wrong netif_carrier_on() call
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ammar Faizi <[email protected]>
commit 8466d393700f9ccef68134d3349f4e0a087679b9 upstream.
The commit referenced in the Fixes tag causes usbnet to malfunction (identified via git bisect). Post-commit, my external RJ45 LAN cable fails to connect. Linus also reported the same issue after pulling that commit.
The code has a logic error: netif_carrier_on() is only called when the link is already on. Fix this by moving the netif_carrier_on() call outside the if-statement entirely. This ensures it is always called when EVENT_LINK_CARRIER_ON is set and properly clears it regardless of the link state.
--- drivers/net/usb/usbnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/usbnet.c +3 -3
@@ -1118,6 +1118,9 @@ static void __handle_link_change(structif (!test_bit (EVENT_DEV_OPEN , &dev->flags))return ; +if (test_and_clear_bit (EVENT_LINK_CARRIER_ON , &dev->flags)) +netif_carrier_on (dev->net); +if (!netif_carrier_ok (dev->net)) {/* kill URBs for reading packets to save bus bandwidth */ unlink_urbs (dev, &dev->rxq);
@@ -1127,9 +1130,6 @@ static void __handle_link_change(struct* tx queue is stopped by netcore after link becomes off */ }else { -if (test_and_clear_bit (EVENT_LINK_CARRIER_ON , &dev->flags)) -netif_carrier_on (dev->net); -/* submitting URBs for reading packets */ tasklet_schedule (&dev->bh); }
Greg Kroah-Hartman
maintainerPATCH 254/644 ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 8cbe564974248ee980562be02f2b1912769562c7 upstream.
In __hdmi_lpe_audio_probe(), strscpy() is incorrectly called with the length of the source string (excluding the NUL terminator) rather than the size of the destination buffer. This results in one character less being copied from 'card->shortname' to 'pcm->name'.
Use the destination buffer size instead to ensure the card name is copied correctly.
--- sound/x86/intel_hdmi_audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +1 -1
@@ -1769,7 +1769,7 @@ static int __hdmi_lpe_audio_probe(struct/* setup private data which can be retrieved when required */ pcm->private_data = ctx; pcm->info_flags =0 ; -strscpy (pcm->name, card->shortname,strlen (card->shortname)); +strscpy (pcm->name, card->shortname,sizeof (pcm->name));/* setup the ops for playback */ snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_PLAYBACK , &had_pcm_ops);
Greg Kroah-Hartman
maintainerPATCH 255/644 MIPS: mm: tlb-r4k: Uniquify TLB entries on init
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit 35ad7e181541aa5757f9f316768d3e64403ec843 upstream.
Hardware or bootloader will initialize TLB entries to any value, which may collide with kernel's UNIQUE_ENTRYHI value. On MIPS microAptiv/M5150 family of cores this will trigger machine check exception and cause boot failure. On M5150 simulation this could happen 7 times out of 1000 boots.
Replace local_flush_tlb_all() with r4k_tlb_uniquify() which probes each TLB ENTRIHI unique value for collisions before it's written, and in case of collision try a different ASID.
--- arch/mips/mm/tlb-r4k.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-)
arch/mips/mm/tlb-r4k.c +55 -1
@@ -498,6 +498,60 @@ static int __init set_ntlb(char *str)__setup ("ntlb=" , set_ntlb); +/* Initialise all TLB entries with unique values */ +static void r4k_tlb_uniquify (void ) +{ +int entry =num_wired_entries (); + +htw_stop (); +write_c0_entrylo0 (0 ); +write_c0_entrylo1 (0 ); + +while (entry < current_cpu_data.tlbsize) { +unsigned long asid_mask =cpu_asid_mask (¤t_cpu_data); +unsigned long asid =0 ; +int idx; + +/* Skip wired MMID to make ginvt_mmid work */ +if (cpu_has_mmid) + asid =MMID_KERNEL_WIRED +1 ; + +/* Check for match before using UNIQUE_ENTRYHI */ +do { +if (cpu_has_mmid) { +write_c0_memorymapid (asid); +write_c0_entryhi (UNIQUE_ENTRYHI (entry)); + }else { +write_c0_entryhi (UNIQUE_ENTRYHI (entry) | asid); + } +mtc0_tlbw_hazard (); +tlb_probe (); +tlb_probe_hazard (); + idx =read_c0_index (); +/* No match or match is on current entry */ +if (idx <0 || idx == entry) +break ; +/* +* If we hit a match, we need to try again with +* a different ASID. +*/ + asid++; + }while (asid < asid_mask); + +if (idx >=0 && idx != entry) +panic ("Unable to uniquify TLB entry %d" , idx); + +write_c0_index (entry); +mtc0_tlbw_hazard (); +tlb_write_indexed (); + entry++; + } + +tlbw_use_hazard (); +htw_start (); +flush_micro_tlb (); +} +/* * Configure TLB (for init or after a CPU has been powered off). */
@@ -537,7 +591,7 @@ static void r4k_tlb_configure(void) temp_tlb_entry = current_cpu_data.tlbsize -1 ;/* From this point on the ARC firmware is dead. */ -local_flush_tlb_all (); +r4k_tlb_uniquify ();/* Did I tell you that ARC SUCKS? */ }
Greg Kroah-Hartman
maintainerPATCH 256/644 mm/hmm: move pmd_to_hmm_pfn_flags() to the respective #ifdeffery
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 188cb385bbf04d486df3e52f28c47b3961f5f0c0 upstream.
When pmd_to_hmm_pfn_flags() is unused, it prevents kernel builds with clang, make W=1 and CONFIG_TRANSPARENT_HUGEPAGE=n:
mm/hmm.c:186:29: warning: unused function 'pmd_to_hmm_pfn_flags' [-Wunused-function]
Fix this by moving the function to the respective existing ifdeffery for its the only user.
See also:
6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build")
--- mm/hmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hmm.c +1 -1
@@ -173,6 +173,7 @@ static inline unsigned long hmm_pfn_flagreturn order <<HMM_PFN_ORDER_SHIFT ; } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE static inline unsigned long pmd_to_hmm_pfn_flags (struct hmm_range *range,pmd_t pmd) {
@@ -183,7 +184,6 @@ static inline unsigned long pmd_to_hmm_phmm_pfn_flags_order (PMD_SHIFT -PAGE_SHIFT ); } -#ifdef CONFIG_TRANSPARENT_HUGEPAGE static int hmm_vma_handle_pmd (struct mm_walk *walk,unsigned long addr,unsigned long end,unsigned long hmm_pfns[],pmd_t pmd)
Greg Kroah-Hartman
maintainerPATCH 257/644 usb: gadget : fix use-after-free in composite_dev_cleanup()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Xue <[email protected]>
commit 151c0aa896c47a4459e07fee7d4843f44c1bb18e upstream.
1. In func configfs_composite_bind() -> composite_os_desc_req_prepare():
if kmalloc fails, the pointer cdev->os_desc_req will be freed but not set to NULL. Then it will return a failure to the upper-level function.
2. in func configfs_composite_bind() -> composite_dev_cleanup():
it will checks whether cdev->os_desc_req is NULL. If it is not NULL, it will attempt to use it.This will lead to a use-after-free issue.
BUG: KASAN: use-after-free in composite_dev_cleanup+0xf4/0x2c0 Read of size 8 at addr 0000004827837a00 by task init/1 CPU: 10 PID: 1 Comm: init Tainted: G O 5.10.97-oh #1 kasan_report+0x188/0x1cc __asan_load8+0xb4/0xbc composite_dev_cleanup+0xf4/0x2c0 configfs_composite_bind+0x210/0x7ac udc_bind_to_driver+0xb4/0x1ec usb_gadget_probe_driver+0xec/0x21c gadget_dev_desc_UDC_store+0x264/0x27c
--- drivers/usb/gadget/composite.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/gadget/composite.c +5 -0
@@ -2351,6 +2351,11 @@ int composite_os_desc_req_prepare(structif (!cdev->os_desc_req->buf) { ret = -ENOMEM ;usb_ep_free_request (ep0, cdev->os_desc_req); +/* +* Set os_desc_req to NULL so that composite_dev_cleanup() +* will not try to free it again. +*/ + cdev->os_desc_req =NULL ; goto end; } cdev->os_desc_req->context = cdev;
Greg Kroah-Hartman
maintainerPATCH 258/644 io_uring: dont use int for ABI
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit cf73d9970ea4f8cace5d8f02d2565a2723003112 upstream.
__kernel_rwf_t is defined as int, the actual size of which is implementation defined. It won't go well if some compiler / archs ever defines it as i64, so replace it with __u32, hoping that there is no one using i16 for it.
--- include/uapi/linux/io_uring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/io_uring.h +1 -1
@@ -29,7 +29,7 @@ struct io_uring_sqe { };__u32 len;/* buffer size or number of iovecs */ union { -__kernel_rwf_t rw_flags; +__u32 rw_flags;__u32 fsync_flags;__u16 poll_events;/* compatibility */ __u32 poll32_events;/* word-reversed for BE */
Greg Kroah-Hartman
maintainerPATCH 259/644 ALSA: usb-audio: Validate UAC3 power domain descriptors, too
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit d832ccbc301fbd9e5a1d691bdcf461cdb514595f upstream.
UAC3 power domain descriptors need to be verified with its variable bLength for avoiding the unexpected OOB accesses by malicious firmware, too.
--- sound/usb/validate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/usb/validate.c +12 -0
@@ -221,6 +221,17 @@ static bool validate_uac3_feature_unit(creturn d->bLength >=sizeof (*d) +4 +2 ; } +static bool validate_uac3_power_domain_unit (const void *p, +const struct usb_desc_validator *v) +{ +const struct uac3_power_domain_descriptor *d = p; + +if (d->bLength <sizeof (*d)) +return false; +/* baEntities[] + wPDomainDescrStr */ +return d->bLength >=sizeof (*d) + d->bNrEntities +2 ; +} +static bool validate_midi_out_jack (const void *p,const struct usb_desc_validator *v) {
@@ -285,6 +296,7 @@ static const struct usb_desc_validator a struct uac3_clock_multiplier_descriptor), /* UAC_VERSION_3, UAC3_SAMPLE_RATE_CONVERTER: not implemented yet */ /* UAC_VERSION_3, UAC3_CONNECTORS: not implemented yet */ + FUNC(UAC_VERSION_3, UAC3_POWER_DOMAIN, validate_uac3_power_domain_unit), { }/* terminator */ };
Greg Kroah-Hartman
maintainerPATCH 260/644 ALSA: usb-audio: Validate UAC3 cluster segment descriptors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit ecfd41166b72b67d3bdeb88d224ff445f6163869 upstream.
UAC3 class segment descriptors need to be verified whether their sizes match with the declared lengths and whether they fit with the allocated buffer sizes, too. Otherwise malicious firmware may lead to the unexpected OOB accesses.
--- sound/usb/stream.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
sound/usb/stream.c +22 -3
@@ -341,20 +341,28 @@ snd_pcm_chmap_elem *convert_chmap_v3(str len =le16_to_cpu (cluster->wLength); c =0 ; - p +=sizeof (struct uac3_cluster_header_descriptor ); + p +=sizeof (*cluster); + len -=sizeof (*cluster); -while (((p - (void *)cluster) < len) && (c < channels)) { +while (len >0 && (c < channels)) {struct uac3_cluster_segment_descriptor *cs_desc = p;u16 cs_len;u8 cs_type; +if (len <sizeof (*p)) +break ; cs_len =le16_to_cpu (cs_desc->wLength); +if (len < cs_len) +break ; cs_type = cs_desc->bSegmentType;if (cs_type ==UAC3_CHANNEL_INFORMATION ) {struct uac3_cluster_information_segment_descriptor *is = p;unsigned char map; +if (cs_len <sizeof (*is)) +break ; +/* * TODO: this conversion is not complete, update it * after adding UAC3 values to asound.h
@@ -456,6 +464,7 @@ snd_pcm_chmap_elem *convert_chmap_v3(str chmap->map[c++] = map; } p += cs_len; + len -= cs_len; }if (channels < c)
@@ -876,7 +885,7 @@ snd_usb_get_audioformat_uac3(struct snd_u64 badd_formats =0 ;unsigned int num_channels;struct audioformat *fp; -u16 cluster_id, wLength; +u16 cluster_id, wLength, cluster_wLength;int clock =0 ;int err;
@@ -1003,6 +1012,16 @@ snd_usb_get_audioformat_uac3(struct snd_ iface_no, altno);kfree (cluster);return ERR_PTR (-EIO ); + } + + cluster_wLength =le16_to_cpu (cluster->wLength); +if (cluster_wLength <sizeof (*cluster) || + cluster_wLength > wLength) { +dev_err (&dev->dev, +"%u:%d : invalid Cluster Descriptor size\n" , + iface_no, altno); +kfree (cluster); +return ERR_PTR (-EIO ); } num_channels = cluster->bNrChannels;
Greg Kroah-Hartman
maintainerPATCH 261/644 gpio: virtio: Fix config space reading.
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Mommer <[email protected]>
commit 4740e1e2f320061c2f0dbadc0dd3dfb58df986d5 upstream.
Quote from the virtio specification chapter 4.2.2.2:
"For the device-specific configuration space, the driver MUST use 8 bit wide accesses for 8 bit wide fields, 16 bit wide and aligned accesses for 16 bit wide fields and 32 bit wide and aligned accesses for 32 and 64 bit wide fields."
--- drivers/gpio/gpio-virtio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpio/gpio-virtio.c +5 -4
@@ -275,7 +275,6 @@ static const char **virtio_gpio_get_namestatic int virtio_gpio_probe (struct virtio_device *vdev) { -struct virtio_gpio_config config;struct device *dev = &vdev->dev;struct virtio_gpio *vgpio;u32 gpio_names_size;
@@ -287,9 +286,11 @@ static int virtio_gpio_probe(struct virtreturn -ENOMEM ;/* Read configuration */ -virtio_cread_bytes (vdev,0 , &config,sizeof (config)); - gpio_names_size =le32_to_cpu (config.gpio_names_size); - ngpio =le16_to_cpu (config.ngpio); + gpio_names_size = +virtio_cread32 (vdev, offsetof(struct virtio_gpio_config , + gpio_names_size)); + ngpio =virtio_cread16 (vdev, offsetof(struct virtio_gpio_config , + ngpio));if (!ngpio) {dev_err (dev,"Number of GPIOs can't be zero\n" );return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 262/644 netlink: avoid infinite retry looping in netlink_unicast()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit 759dfc7d04bab1b0b86113f1164dc1fec192b859 upstream.
netlink_attachskb() checks for the socket's read memory allocation constraints. Firstly, it has:
rmem < READ_ONCE(sk->sk_rcvbuf)
to check if the just increased rmem value fits into the socket's receive buffer. If not, it proceeds and tries to wait for the memory under:
rmem + skb->truesize > READ_ONCE(sk->sk_rcvbuf)
The checks don't cover the case when skb->truesize + sk->sk_rmem_alloc is equal to sk->sk_rcvbuf. Thus the function neither successfully accepts these conditions, nor manages to reschedule the task - and is called in retry loop for indefinite time which is caught as:
rcu: INFO: rcu_sched self-detected stall on CPU rcu: 0-....: (25999 ticks this GP) idle=ef2/1/0x4000000000000000 softirq=262269/262269 fqs=6212 (t=26000 jiffies g=230833 q=259957) NMI backtrace for cpu 0 CPU: 0 PID: 22 Comm: kauditd Not tainted 5.10.240 #68 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-4.fc42 04/01/2014 Call Trace: <IRQ> dump_stack lib/dump_stack.c:120 nmi_cpu_backtrace.cold lib/nmi_backtrace.c:105 nmi_trigger_cpumask_backtrace lib/nmi_backtrace.c:62 rcu_dump_cpu_stacks kernel/rcu/tree_stall.h:335 rcu_sched_clock_irq.cold kernel/rcu/tree.c:2590 update_process_times kernel/time/timer.c:1953 tick_sched_handle kernel/time/tick-sched.c:227 tick_sched_timer kernel/time/tick-sched.c:1399 __hrtimer_run_queues kernel/time/hrtimer.c:1652 hrtimer_interrupt kernel/time/hrtimer.c:1717 __sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1113 asm_call_irq_on_stack arch/x86/entry/entry_64.S:808 </IRQ> netlink_attachskb net/netlink/af_netlink.c:1234 netlink_unicast net/netlink/af_netlink.c:1349 kauditd_send_queue kernel/audit.c:776 kauditd_thread kernel/audit.c:897 kthread kernel/kthread.c:328 ret_from_fork arch/x86/entry/entry_64.S:304
Restore the original behavior of the check which commit in Fixes accidentally missed when restructuring the code.
Found by Linux Verification Center (linuxtesting.org).
--- net/netlink/af_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlink/af_netlink.c +1 -1
@@ -1217,7 +1217,7 @@ int netlink_attachskb(struct sock *sk, s nlk =nlk_sk (sk); rmem =atomic_add_return (skb->truesize, &sk->sk_rmem_alloc); -if ((rmem == skb->truesize || rmem <READ_ONCE (sk->sk_rcvbuf)) && +if ((rmem == skb->truesize || rmem <=READ_ONCE (sk->sk_rcvbuf)) && !test_bit (NETLINK_S_CONGESTED , &nlk->state)) {netlink_skb_set_owner_r (skb, sk);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 263/644 net: gianfar: fix device leak when querying time stamp info
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit da717540acd34e5056e3fa35791d50f6b3303f55 upstream.
Make sure to drop the reference to the ptp device taken by of_find_device_by_node() when querying the time stamping capabilities.
Note that holding a reference to the ptp device does not prevent its driver data from going away.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +3 -1
@@ -1461,8 +1461,10 @@ static int gfar_get_ts_info(struct net_dif (ptp_node) { ptp_dev =of_find_device_by_node (ptp_node);of_node_put (ptp_node); -if (ptp_dev) +if (ptp_dev) { ptp =platform_get_drvdata (ptp_dev); +put_device (&ptp_dev->dev); + } }if (ptp)
Greg Kroah-Hartman
maintainerPATCH 264/644 net: dpaa: fix device leak when querying time stamp info
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3fa840230f534385b34a4f39c8dd313fbe723f05 upstream.
Make sure to drop the reference to the ptp device taken by of_find_device_by_node() when querying the time stamping capabilities.
Note that holding a reference to the ptp device does not prevent its driver data from going away.
--- drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c +3 -1
@@ -499,8 +499,10 @@ static int dpaa_get_ts_info(struct net_dof_node_put (ptp_node); } -if (ptp_dev) +if (ptp_dev) { ptp =platform_get_drvdata (ptp_dev); +put_device (&ptp_dev->dev); + }if (ptp) info->phc_index = ptp->phc_index;
Greg Kroah-Hartman
maintainerPATCH 265/644 net: usb: asix_devices: add phy_mask for ax88772 mdio bus
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit 4faff70959d51078f9ee8372f8cff0d7045e4114 upstream.
Without setting phy_mask for ax88772 mdio bus, current driver may create at most 32 mdio phy devices with phy address range from 0x00 ~ 0x1f. DLink DUB-E100 H/W Ver B1 is such a device. However, only one main phy device will bind to net phy driver. This is creating issue during system suspend/resume since phy_polling_mode() in phy_state_machine() will directly deference member of phydev->drv for non-main phy devices. Then NULL pointer dereference issue will occur. Due to only external phy or internal phy is necessary, add phy_mask for ax88772 mdio bus to workarnoud the issue.
--- drivers/net/usb/asix_devices.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/asix_devices.c +1 -0
@@ -669,6 +669,7 @@ static int ax88772_init_mdio(struct usbn priv->mdio->read = &asix_mdio_bus_read; priv->mdio->write = &asix_mdio_bus_write; priv->mdio->name ="Asix MDIO Bus" ; + priv->mdio->phy_mask = ~(BIT (priv->phy_addr) |BIT (AX_EMBD_PHY_ADDR ));/* mii bus name is usb-<usb bus number>-<usb device number> */ snprintf (priv->mdio->id,MII_BUS_ID_SIZE ,"usb-%03d:%03d" , dev->udev->bus->busnum, dev->udev->devnum);
Greg Kroah-Hartman
maintainerPATCH 266/644 nfsd: handle get_client_locked() failure in nfsd4_setclientid_confirm()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit 908e4ead7f757504d8b345452730636e298cbf68 upstream.
Lei Lu recently reported that nfsd4_setclientid_confirm() did not check the return value from get_client_locked(). a SETCLIENTID_CONFIRM could race with a confirmed client expiring and fail to get a reference. That could later lead to a UAF.
Fix this by getting a reference early in the case where there is an extant confirmed client. If that fails then treat it as if there were no confirmed client found at all.
In the case where the unconfirmed client is expiring, just fail and return the result from get_client_locked().
--- fs/nfsd/nfs4state.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
fs/nfsd/nfs4state.c +15 -5
@@ -4285,10 +4285,16 @@ nfsd4_setclientid_confirm(struct svc_rqs } status = nfs_ok;if (conf) { - old = unconf; -unhash_client_locked (old); -nfsd4_change_callback (conf, &unconf->cl_cb_conn); - }else { +if (get_client_locked (conf) == nfs_ok) { + old = unconf; +unhash_client_locked (old); +nfsd4_change_callback (conf, &unconf->cl_cb_conn); + }else { + conf =NULL ; + } + } + +if (!conf) { old =find_confirmed_client_by_name (&unconf->cl_name, nn);if (old) { status = nfserr_clid_inuse;
@@ -4305,10 +4311,14 @@ nfsd4_setclientid_confirm(struct svc_rqs }trace_nfsd_clid_replaced (&old->cl_clientid); } + status =get_client_locked (unconf); +if (status != nfs_ok) { + old =NULL ; + goto out; + }move_to_confirmed (unconf); conf = unconf; } -get_client_locked (conf);spin_unlock (&nn->client_lock);if (conf == unconf)fsnotify_dentry (conf->cl_nfsd_info_dentry,FS_MODIFY );
Greg Kroah-Hartman
maintainerPATCH 267/644 NFSD: detect mismatch of file handle and delegation stateid in OPEN op
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dai Ngo <[email protected]>
commit 9c65001c57164033ad08b654c8b5ae35512ddf4a upstream.
When the client sends an OPEN with claim type CLAIM_DELEG_CUR_FH or CLAIM_DELEGATION_CUR, the delegation stateid and the file handle must belong to the same file, otherwise return NFS4ERR_INVAL.
Note that RFC8881, section 8.2.4, mandates the server to return NFS4ERR_BAD_STATEID if the selected table entry does not match the current filehandle. However returning NFS4ERR_BAD_STATEID in the OPEN causes the client to retry the operation and therefor get the client into a loop. To avoid this situation we return NFS4ERR_INVAL instead.
--- fs/nfsd/nfs4state.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/nfsd/nfs4state.c +14 -0
@@ -5736,6 +5736,20 @@ nfsd4_process_open2(struct svc_rqst *rqs status =nfs4_check_deleg (cl, open, &dp);if (status) goto out; +if (dp &&nfsd4_is_deleg_cur (open) && + (dp->dl_stid.sc_file != fp)) { +/* +* RFC8881 section 8.2.4 mandates the server to return +* NFS4ERR_BAD_STATEID if the selected table entry does +* not match the current filehandle. However returning +* NFS4ERR_BAD_STATEID in the OPEN can cause the client +* to repeatedly retry the operation with the same +* stateid, since the stateid itself is valid. To avoid +* this situation NFSD returns NFS4ERR_INVAL instead. +*/ + status = nfserr_inval; + goto out; + } stp =nfsd4_find_and_lock_existing_open (fp, open); }else { open->op_file =NULL ;
Greg Kroah-Hartman
maintainerPATCH 268/644 sunvdc: Balance device refcount in vdc_port_mpgroup_check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 63ce53724637e2e7ba51fe3a4f78351715049905 upstream.
Using device_find_child() to locate a probed virtual-device-port node causes a device refcount imbalance, as device_find_child() internally calls get_device() to increment the device’s reference count before returning its pointer. vdc_port_mpgroup_check() directly returns true upon finding a matching device without releasing the reference via put_device(). We should call put_device() to decrement refcount.
As comment of device_find_child() says, 'NOTE: you will need to drop the reference with put_device() after use'.
Found by code review.
--- drivers/block/sunvdc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/sunvdc.c +3 -1
@@ -948,8 +948,10 @@ static bool vdc_port_mpgroup_check(struc dev =device_find_child (vdev->dev.parent, &port_data, vdc_device_probed); -if (dev) +if (dev) { +put_device (dev);return true; + }return false; }
Greg Kroah-Hartman
maintainerPATCH 269/644 fs: Prevent file descriptor table allocations exceeding INT_MAX
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <[email protected]>
commit 04a2c4b4511d186b0fce685da21085a5d4acd370 upstream.
When sysctl_nr_open is set to a very high value (for example, 1073741816 as set by systemd), processes attempting to use file descriptors near the limit can trigger massive memory allocation attempts that exceed INT_MAX, resulting in a WARNING in mm/slub.c:
WARNING: CPU: 0 PID: 44 at mm/slub.c:5027 __kvmalloc_node_noprof+0x21a/0x288
This happens because kvmalloc_array() and kvmalloc() check if the requested size exceeds INT_MAX and emit a warning when the allocation is not flagged with __GFP_NOWARN.
Specifically, when nr_open is set to 1073741816 (0x3ffffff8) and a process calls dup2(oldfd, 1073741880), the kernel attempts to allocate:
- File descriptor array: 1073741880 * 8 bytes = 8,589,935,040 bytes
- Multiple bitmaps: ~400MB
- Total allocation size: > 8GB (exceeding INT_MAX = 2,147,483,647)
Reproducer:
1. Set /proc/sys/fs/nr_open to 1073741816:
# echo 1073741816 > /proc/sys/fs/nr_open
2. Run a program that uses a high file descriptor:
#include <unistd.h>
#include <sys/resource.h>
int main() {
struct rlimit rlim = {1073741824, 1073741824};
setrlimit(RLIMIT_NOFILE, &rlim);
dup2(2, 1073741880); // Triggers the warning
return 0;
}3. Observe WARNING in dmesg at mm/slub.c:5027
systemd commit a8b627a introduced automatic bumping of fs.nr_open to the maximum possible value. The rationale was that systems with memory control groups (memcg) no longer need separate file descriptor limits since memory is properly accounted. However, this change overlooked that:
1. The kernel's allocation functions still enforce INT_MAX as a maximum size regardless of memcg accounting
2. Programs and tests that legitimately test file descriptor limits can inadvertently trigger massive allocations
3. The resulting allocations (>8GB) are impractical and will always fail
systemd's algorithm starts with INT_MAX and keeps halving the value until the kernel accepts it. On most systems, this results in nr_open being set to 1073741816 (0x3ffffff8), which is just under 1GB of file descriptors.
While processes rarely use file descriptors near this limit in normal operation, certain selftests (like tools/testing/selftests/core/unshare_test.c) and programs that test file descriptor limits can trigger this issue.
Fix this by adding a check in alloc_fdtable() to ensure the requested allocation size does not exceed INT_MAX. This causes the operation to fail with -EMFILE instead of triggering a kernel warning and avoids the impractical >8GB memory allocation request.
--- fs/file.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/file.c +15 -0
@@ -126,6 +126,21 @@ static struct fdtable * alloc_fdtable(unif (unlikely (nr > sysctl_nr_open)) nr = ((sysctl_nr_open -1 ) | (BITS_PER_LONG -1 )) +1 ; +/* +* Check if the allocation size would exceed INT_MAX. kvmalloc_array() +* and kvmalloc() will warn if the allocation size is greater than +* INT_MAX, as filp_cachep objects are not __GFP_NOWARN. +* +* This can happen when sysctl_nr_open is set to a very high value and +* a process tries to use a file descriptor near that limit. For example, +* if sysctl_nr_open is set to 1073741816 (0x3ffffff8) - which is what +* systemd typically sets it to - then trying to use a file descriptor +* close to that value will require allocating a file descriptor table +* that exceeds 8GB in size. +*/ +if (unlikely (nr >INT_MAX /sizeof (struct file *))) +return ERR_PTR (-EMFILE ); + fdt =kmalloc (sizeof (struct fdtable ),GFP_KERNEL_ACCOUNT );if (!fdt) goto out;
Greg Kroah-Hartman
maintainerPATCH 270/644 eventpoll: Fix semi-unbounded recursion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit f2e467a48287c868818085aa35389a224d226732 upstream.
Ensure that epoll instances can never form a graph deeper than EP_MAX_NESTS+1 links.
Currently, ep_loop_check_proc() ensures that the graph is loop-free and does some recursion depth checks, but those recursion depth checks don't limit the depth of the resulting tree for two reasons:
- They don't look upwards in the tree.
- If there are multiple downwards paths of different lengths, only one of the paths is actually considered for the depth check since commit 28d82dc1c4ed ("epoll: limit paths").
Essentially, the current recursion depth check in ep_loop_check_proc() just serves to prevent it from recursing too deeply while checking for loops.
A more thorough check is done in reverse_path_check() after the new graph edge has already been created; this checks, among other things, that no paths going upwards from any non-epoll file with a length of more than 5 edges exist. However, this check does not apply to non-epoll files.
As a result, it is possible to recurse to a depth of at least roughly 500, tested on v6.15. (I am unsure if deeper recursion is possible; and this may have changed with commit 8c44dac8add7 ("eventpoll: Fix priority inversion problem").)
To fix it:
1. In ep_loop_check_proc(), note the subtree depth of each visited node, and use subtree depths for the total depth calculation even when a subtree has already been visited.
2. Add ep_get_upwards_depth_proc() for similarly determining the maximum depth of an upwards walk.
3. In ep_loop_check(), use these values to limit the total path length between epoll nodes to EP_MAX_NESTS edges.
--- fs/eventpoll.c | 60 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 14 deletions(-)
fs/eventpoll.c +46 -14
@@ -216,6 +216,7 @@ struct eventpoll {/* used to optimize loop detection check */ u64 gen;struct hlist_head refs; +u8 loop_check_depth;#ifdef CONFIG_NET_RX_BUSY_POLL /* used to track busy poll napi_id */
@@ -1944,23 +1945,24 @@ static int ep_poll(struct eventpoll *ep, }/** -* ep_loop_check_proc - verify that adding an epoll file inside another -* epoll structure does not violate the constraints, in -* terms of closed loops, or too deep chains (which can -* result in excessive stack usage). +* ep_loop_check_proc - verify that adding an epoll file @ep inside another +* epoll file does not create closed loops, and +* determine the depth of the subtree starting at @ep * * @ep: the &struct eventpoll to be currently checked. * @depth: Current depth of the path being checked. * -* Return: %zero if adding the epoll @file inside current epoll -* structure @ep does not violate the constraints, or %-1 otherwise. +* Return: depth of the subtree, or INT_MAX if we found a loop or went too deep. */ static int ep_loop_check_proc (struct eventpoll *ep,int depth) { -int error =0 ; +int result =0 ;struct rb_node *rbp;struct epitem *epi; +if (ep->gen == loop_check_gen) +return ep->loop_check_depth; +mutex_lock_nested (&ep->mtx, depth +1 ); ep->gen = loop_check_gen;for (rbp =rb_first_cached (&ep->rbr); rbp; rbp =rb_next (rbp)) {
@@ -1968,13 +1970,11 @@ static int ep_loop_check_proc(struct eveif (unlikely (is_file_epoll (epi->ffd.file))) {struct eventpoll *ep_tovisit; ep_tovisit = epi->ffd.file->private_data; -if (ep_tovisit->gen == loop_check_gen) -continue ;if (ep_tovisit == inserting_into || depth >EP_MAX_NESTS ) - error =-1 ; + result =INT_MAX ;else - error =ep_loop_check_proc (ep_tovisit, depth +1 ); -if (error !=0 ) + result =max (result,ep_loop_check_proc (ep_tovisit, depth +1 ) +1 ); +if (result >EP_MAX_NESTS )break ; }else {/*
@@ -1988,9 +1988,27 @@ static int ep_loop_check_proc(struct evelist_file (epi->ffd.file); } } + ep->loop_check_depth = result;mutex_unlock (&ep->mtx); -return error; +return result; +} + +/** +* ep_get_upwards_depth_proc - determine depth of @ep when traversed upwards +*/ +static int ep_get_upwards_depth_proc (struct eventpoll *ep,int depth) +{ +int result =0 ; +struct epitem *epi; + +if (ep->gen == loop_check_gen) +return ep->loop_check_depth; +hlist_for_each_entry_rcu (epi, &ep->refs, fllink) + result =max (result,ep_get_upwards_depth_proc (epi->ep, depth +1 ) +1 ); + ep->gen = loop_check_gen; + ep->loop_check_depth = result; +return result; }/**
@@ -2006,8 +2024,22 @@ static int ep_loop_check_proc(struct eve*/ static int ep_loop_check (struct eventpoll *ep,struct eventpoll *to) { +int depth, upwards_depth; + inserting_into = ep; -return ep_loop_check_proc (to,0 ); +/* +* Check how deep down we can get from @to, and whether it is possible +* to loop up to @ep. +*/ + depth =ep_loop_check_proc (to,0 ); +if (depth >EP_MAX_NESTS ) +return -1 ; +/* Check how far up we can go from @ep. */ +rcu_read_lock (); + upwards_depth =ep_get_upwards_depth_proc (ep,0 ); +rcu_read_unlock (); + +return (depth+1 +upwards_depth >EP_MAX_NESTS ) ?-1 :0 ; }static void clear_tfile_check_list (void )
Greg Kroah-Hartman
maintainerPATCH 271/644 Documentation: ACPI: Fix parent device references
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit e65cb011349e653ded541dddd6469c2ca813edcf upstream.
The _CRS resources in many cases want to have ResourceSource field to be a type of ACPI String. This means that to compile properly we need to enclosure the name path into double quotes. This will in practice defer the interpretation to a run-time stage, However, this may be interpreted differently on different OSes and ACPI interpreter implementations. In particular ACPICA might not correctly recognize the leading '^' (caret) character and will not resolve the relative name path properly. On top of that, this piece may be used in SSDTs which are loaded after the DSDT and on itself may also not resolve relative name paths outside of their own scopes. With this all said, fix documentation to use fully-qualified name paths always to avoid any misinterpretations, which is proven to work.
--- Documentation/firmware-guide/acpi/i2c-muxes.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/firmware-guide/acpi/i2c-muxes.rst +4 -4
@@ -14,7 +14,7 @@ Consider this topology:: | | | 0x70 |--CH01--> i2c client B (0x50) +------+ +------+ -which corresponds to the following ASL:: +which corresponds to the following ASL (in the scope of \_SB):: Device (SMB1) {
@@ -24,7 +24,7 @@ which corresponds to the following ASL:: Name (_HID, ...) Name (_CRS, ResourceTemplate () { I2cSerialBus (0x70, ControllerInitiated, I2C_SPEED, - AddressingMode7Bit, "^SMB1", 0x00, + AddressingMode7Bit, "\\_SB.SMB1", 0x00, ResourceConsumer,,) }
@@ -37,7 +37,7 @@ which corresponds to the following ASL:: Name (_HID, ...) Name (_CRS, ResourceTemplate () { I2cSerialBus (0x50, ControllerInitiated, I2C_SPEED, - AddressingMode7Bit, "^CH00", 0x00, + AddressingMode7Bit, "\\_SB.SMB1.CH00", 0x00, ResourceConsumer,,) } }
@@ -52,7 +52,7 @@ which corresponds to the following ASL:: Name (_HID, ...) Name (_CRS, ResourceTemplate () { I2cSerialBus (0x50, ControllerInitiated, I2C_SPEED, - AddressingMode7Bit, "^CH01", 0x00, + AddressingMode7Bit, "\\_SB.SMB1.CH01", 0x00, ResourceConsumer,,) } }
Greg Kroah-Hartman
maintainerPATCH 272/644 ACPI: processor: perflib: Fix initial _PPC limit application
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayi Li <[email protected]>
commit d33bd88ac0ebb49e7f7c8f29a8c7ee9eae85d765 upstream.
If the BIOS sets a _PPC frequency limit upfront, it will fail to take effect due to a call ordering issue. Namely, freq_qos_update_request() is called before freq_qos_add_request() for the given request causing the constraint update to be ignored. The call sequence in question is as follows:
cpufreq_policy_online()
acpi_cpufreq_cpu_init()
acpi_processor_register_performance()
acpi_processor_get_performance_info()
acpi_processor_get_platform_limit()
freq_qos_update_request(&perflib_req) <- inactive QoS request
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
CPUFREQ_CREATE_POLICY)
acpi_processor_notifier()
acpi_processor_ppc_init()
freq_qos_add_request(&perflib_req) <- QoS request activation
Address this by adding an acpi_processor_get_platform_limit() call to acpi_processor_ppc_init(), after the perflib_req activation via freq_qos_add_request(), which causes the initial _PPC limit to be picked up as appropriate. However, also ensure that the _PPC limit will not be picked up in the cases when the cpufreq driver does not call acpi_processor_register_performance() by adding a pr->performance check to the related_cpus loop in acpi_processor_ppc_init().
--- drivers/acpi/processor_perflib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/acpi/processor_perflib.c +9 -1
@@ -173,11 +173,14 @@ void acpi_processor_ppc_init(struct cpuf {unsigned int cpu; +if (ignore_ppc ==1 ) +return ; +for_each_cpu (cpu, policy->related_cpus) {struct acpi_processor *pr =per_cpu (processors, cpu);int ret; -if (!pr) +if (!pr || !pr->performance)continue ;/*
@@ -193,6 +196,11 @@ void acpi_processor_ppc_init(struct cpufif (ret <0 )pr_err ("Failed to add freq constraint for CPU%d (%d)\n" , cpu, ret); + + ret =acpi_processor_get_platform_limit (pr); +if (ret) +pr_err ("Failed to update freq constraint for CPU%d (%d)\n" , + cpu, ret); } }
Greg Kroah-Hartman
maintainerPATCH 273/644 ACPI: processor: perflib: Move problematic pr->performance check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit d405ec23df13e6df599f5bd965a55d13420366b8 upstream.
Commit d33bd88ac0eb ("ACPI: processor: perflib: Fix initial _PPC limit application") added a pr->performance check that prevents the frequency QoS request from being added when the given processor has no performance object. Unfortunately, this causes a WARN() in freq_qos_remove_request() to trigger on an attempt to take the given CPU offline later because the frequency QoS object has not been added for it due to the missing performance object.
Address this by moving the pr->performance check before calling acpi_processor_get_platform_limit() so it only prevents a limit from being set for the CPU if the performance object is not present. This way, the frequency QoS request is added as it was before the above commit and it is present all the time along with the CPU's cpufreq policy regardless of whether or not the CPU is online.
--- drivers/acpi/processor_perflib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/acpi/processor_perflib.c +4 -1
@@ -180,7 +180,7 @@ void acpi_processor_ppc_init(struct cpufstruct acpi_processor *pr =per_cpu (processors, cpu);int ret; -if (!pr || !pr->performance) +if (!pr)continue ;/*
@@ -197,6 +197,9 @@ void acpi_processor_ppc_init(struct cpufpr_err ("Failed to add freq constraint for CPU%d (%d)\n" , cpu, ret); +if (!pr->performance) +continue ; + ret =acpi_processor_get_platform_limit (pr);if (ret) pr_err("Failed to update freq constraint for CPU%d (%d)\n",