5.15.224-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 275/571 wifi: wlcore: Fix runtime PM leak in wlcore_remove()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit a8b8881d0c1aff544fae190469d86db7b07f43a9 ]
pm_runtime_get_sync() keeps the runtime PM usage counter elevated even when it returns an error, so the reference taken at the beginning of wlcore_remove() has to be dropped on every exit path. When the device was not initialized the function returned early without doing so, leaking the reference.
Release it with pm_runtime_put_noidle() as done on the other early error paths of this driver.
--- drivers/net/wireless/ti/wlcore/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wlcore/main.c +3 -1
@@ -6817,8 +6817,10 @@ void wlcore_remove(struct platform_device *pdev)if (pdev_data->family && pdev_data->family->nvs_name)wait_for_completion (&wl->nvs_loading_complete); -if (!wl->initialized) +if (!wl->initialized) { +pm_runtime_put_noidle (wl->dev);return ; + }if (wl->wakeirq >=0 ) {dev_pm_clear_wake_irq (wl->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 276/571 RDMA/hns: Fix WQ_MEM_RECLAIM warning
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengchang Tang <[email protected]>
commit c0a26bbd3f99b7b03f072e3409aff4e6ec8af6f6 upstream.
When sunrpc is used, if a reset triggered, our wq may lead the following trace:
workqueue: WQ_MEM_RECLAIM xprtiod:xprt_rdma_connect_worker [rpcrdma] is flushing !WQ_MEM_RECLAIM hns_roce_irq_workq:flush_work_handle [hns_roce_hw_v2]
WARNING: CPU: 0 PID: 8250 at kernel/workqueue.c:2644 check_flush_dependency+0xe0/0x144 Call trace: check_flush_dependency+0xe0/0x144 start_flush_work.constprop.0+0x1d0/0x2f0 __flush_work.isra.0+0x40/0xb0 flush_work+0x14/0x30 hns_roce_v2_destroy_qp+0xac/0x1e0 [hns_roce_hw_v2] ib_destroy_qp_user+0x9c/0x2b4 rdma_destroy_qp+0x34/0xb0 rpcrdma_ep_destroy+0x28/0xcc [rpcrdma] rpcrdma_ep_put+0x74/0xb4 [rpcrdma] rpcrdma_xprt_disconnect+0x1d8/0x260 [rpcrdma] xprt_rdma_connect_worker+0xc0/0x120 [rpcrdma] process_one_work+0x1cc/0x4d0 worker_thread+0x154/0x414 kthread+0x104/0x144 ret_from_fork+0x10/0x18
Since QP destruction frees memory, this wq should have the WQ_MEM_RECLAIM.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +2 -1
@@ -6209,7 +6209,8 @@ static int hns_roce_v2_init_eq_table(str } } - hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" ,0 ); + hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" , +WQ_MEM_RECLAIM );if (!hr_dev->irq_workq) {dev_err (dev,"failed to create irq workqueue.\n" ); ret = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 277/571 vxlan: Fix potential null-ptr-deref in vxlan_gro_prepare_receive().
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
commit 30a45c0bffdd62350261e2f2689fdba426a33578 upstream.
udp_tunnel_sock_release() could set sk->sk_user_data to NULL while vxlan_gro_prepare_receive() is running.
Let's check if rcu_dereference_sk_user_data() is NULL after skb_gro_remcsum_init().
[ Artem Novikov: Apply the check to the older vxlan_gro_receive()
implementation. Initialize the remcsum state first and use the existing out path for cleanup when sk_user_data has been cleared. ]
--- drivers/net/vxlan/vxlan_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/vxlan/vxlan_core.c +5 -1
@@ -791,12 +791,16 @@ static struct sk_buff *vxlan_gro_receivestruct vxlanhdr *vh, *vh2;unsigned int hlen, off_vx;int flush =1 ; -struct vxlan_sock *vs =rcu_dereference_sk_user_data (sk); +struct vxlan_sock *vs;__be32 flags;struct gro_remcsum grc;skb_gro_remcsum_init (&grc); + vs =rcu_dereference_sk_user_data (sk); +if (!vs) + goto out; + off_vx =skb_gro_offset (skb); hlen = off_vx +sizeof (*vh); vh =skb_gro_header_fast (skb, off_vx);
Greg Kroah-Hartman
maintainerPATCH 278/571 wifi: wcn36xx: fix heap overflow from oversized firmware HAL response
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
commit 88a240d86d3d64521f9194abe185ac71cc74d0bd upstream.
The firmware response dispatcher copies all synchronous HAL responses into the 4096-byte hal_buf without validating the response length. A response exceeding WCN36XX_HAL_BUF_SIZE causes a heap buffer overflow with firmware-controlled content.
Add a bounds check on the response length.
--- drivers/net/wireless/ath/wcn36xx/smd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/wcn36xx/smd.c +4 -0
@@ -3174,6 +3174,10 @@ int wcn36xx_smd_rsp_process(struct rpmsgcase WCN36XX_HAL_GTK_OFFLOAD_GETINFO_RSP :case WCN36XX_HAL_HOST_RESUME_RSP :case WCN36XX_HAL_UPDATE_CHANNEL_LIST_RSP : +if (len >WCN36XX_HAL_BUF_SIZE ) { +wcn36xx_warn ("HAL response too large: %d\n" , len); +break ; + }memcpy (wcn->hal_buf, buf, len); wcn->hal_rsp_len = len;complete (&wcn->hal_rsp_compl);
Greg Kroah-Hartman
maintainerPATCH 279/571 net: usb: qmi_wwan: add Quectel EG120K-EA
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gilberto Conde <[email protected]>
commit 0f2fd31f63c65c409bd336af3a42d478a9207c1f upstream.
Add support for the Quectel EG120K-EA LTE Cat.12 module (USB ID 2c7c:030b). Its QMI interface (interface 4) uses class/subclass/protocol ff/ff/ff like the other recent Quectel modules, so match it the same way.
The product ID is shared with the EM060K, which the option driver already knows and uses to claim the serial interfaces. Without a qmi_wwan entry the data interface is left unbound.
Tested on a GL.iNet GL-X2000, where the module is soldered down and enumerates at SuperSpeed: cdc-wdm0 and wwan0 appear and ModemManager brings up a data session.
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=5000 MxCh= 0 D: Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1 P: Vendor=2c7c ProdID=030b Rev= 5.04 S: Manufacturer=Quectel S: Product=EG120K-EA S: SerialNumber=45546267 C:* #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=896mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=40 Driver=option E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=86(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=8e(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=0f(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#=12 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=70 Driver=(none)
E: Ad=89(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
--- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/qmi_wwan.c +1 -0
@@ -1090,6 +1090,7 @@ static const struct usb_device_id produc {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0122)}, /* Quectel RG650V */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x030b)}, /* Quectel EM060K/EG120K-EA */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0620)}, /* Quectel EM160R-GL */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */
Greg Kroah-Hartman
maintainerPATCH 280/571 serial: imx: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit c066f87314b7fbbf4d72d38957436a98e7b7e503 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 8b0b29fdcb47 ("serial: imx: serialize imx_uart_ports[] lifetime")
--- drivers/tty/serial/imx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/imx.c +3 -3
@@ -2484,11 +2484,11 @@ err_clk:return ret; } -static int imx_uart_remove (struct platform_device *pdev) +static void imx_uart_remove (struct platform_device *pdev) {struct imx_port *sport =platform_get_drvdata (pdev); -return uart_remove_one_port (&imx_uart_uart_driver, &sport->port); +uart_remove_one_port (&imx_uart_uart_driver, &sport->port); }static void imx_uart_restore_context (struct imx_port *sport)
@@ -2655,7 +2655,7 @@ static const struct dev_pm_ops imx_uart_static struct platform_driver imx_uart_platform_driver = { .probe = imx_uart_probe, - .remove = imx_uart_remove, + .remove_new = imx_uart_remove, .driver = { .name ="imx-uart" ,
Greg Kroah-Hartman
maintainerPATCH 281/571 serial: imx: serialize imx_uart_ports[] lifetime
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8b0b29fdcb47907ae0296b8fe829e918e05e300f ]
imx_uart_probe() publishes its devm-allocated port in imx_uart_ports[] before uart_add_one_port() because console setup uses the table. The entry is not cleared when adding the port fails or after removal, leaving a dangling pointer.
A sibling probe can register the shared console through that stale entry. This was reproduced under KASAN on QEMU mcimx6ul-evk by unbinding a sibling UART, unbinding the console UART and rebinding the sibling.
Keep the entry valid through uart_remove_one_port(), then clear it. Protect port addition and removal together with their table updates so sibling operations cannot interleave. Reject an occupied slot rather than clobbering an active port during a duplicate-line probe.
--- drivers/tty/serial/imx.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/tty/serial/imx.c +16 -3
@@ -21,6 +21,7 @@#include <linux/clk.h> #include <linux/delay.h> #include <linux/ktime.h> +#include <linux/mutex.h> #include <linux/pinctrl/consumer.h> #include <linux/rational.h> #include <linux/slab.h>
@@ -2005,6 +2006,9 @@ static const struct uart_ops imx_uart_postatic struct imx_port *imx_uart_ports[UART_NR ]; +/* Held across uart_add/remove_one_port(); console callbacks must not take it. */ +static DEFINE_MUTEX (imx_uart_ports_lock); +#if IS_ENABLED (CONFIG_SERIAL_IMX_CONSOLE )static void imx_uart_console_putchar (struct uart_port *port,int ch) {
@@ -2472,11 +2476,18 @@ static int imx_uart_probe(struct platfor } } - imx_uart_ports[sport->port.line] = sport; -platform_set_drvdata (pdev, sport); - ret =uart_add_one_port (&imx_uart_uart_driver, &sport->port); +mutex_lock (&imx_uart_ports_lock); +if (imx_uart_ports[sport->port.line]) { + ret = -EBUSY ; + }else { + imx_uart_ports[sport->port.line] = sport; + ret =uart_add_one_port (&imx_uart_uart_driver, &sport->port); +if (ret) + imx_uart_ports[sport->port.line] =NULL ; + } +mutex_unlock (&imx_uart_ports_lock); err_clk:clk_disable_unprepare (sport->clk_ipg);
@@ -2488,7 +2499,9 @@ static void imx_uart_remove(struct platf {struct imx_port *sport =platform_get_drvdata (pdev); +guard (mutex)(&imx_uart_ports_lock);uart_remove_one_port (&imx_uart_uart_driver, &sport->port); + imx_uart_ports[sport->port.line] =NULL ; }static void imx_uart_restore_context (struct imx_port *sport)
Greg Kroah-Hartman
maintainerPATCH 282/571 usb: gadget: at91_udc: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit cbd1b152519a581bfe14fb6b14ea6e57cca426c1 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
In the error path emit an error message replacing the (less useful) message by the core. Apart from the improved error message there is no change in behaviour.
Stable-dep-of: c27d13ce4bab ("usb: gadget: at91_udc: drain polled-VBUS timer/work before udc is freed")
--- drivers/usb/gadget/udc/at91_udc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/at91_udc.c +7 -6
@@ -1942,7 +1942,7 @@ err_unprepare_fclk:return retval; } -static int at91udc_remove (struct platform_device *pdev) +static void at91udc_remove (struct platform_device *pdev) {struct at91_udc *udc =platform_get_drvdata (pdev);unsigned long flags;
@@ -1950,8 +1950,11 @@ static int at91udc_remove(struct platforDBG ("remove\n" );usb_del_gadget_udc (&udc->gadget); -if (udc->driver) -return -EBUSY ; +if (udc->driver) { +dev_err (&pdev->dev, +"Driver still in use but removing anyhow\n" ); +return ; + }spin_lock_irqsave (&udc->lock, flags);pullup (udc,0 );
@@ -1961,8 +1964,6 @@ static int at91udc_remove(struct platforremove_debug_file (udc);clk_unprepare (udc->fclk);clk_unprepare (udc->iclk); - -return 0 ; }#ifdef CONFIG_PM
@@ -2018,7 +2019,7 @@ static int at91udc_resume(struct platfor#endif static struct platform_driver at91_udc_driver = { - .remove = at91udc_remove, + .remove_new = at91udc_remove, .shutdown = at91udc_shutdown, .suspend = at91udc_suspend, .resume = at91udc_resume,
Greg Kroah-Hartman
maintainerPATCH 283/571 usb: gadget: at91_udc: drain polled-VBUS timer/work before udc is freed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit c27d13ce4bab80fbdf6523928071b6c24b37606c ]
In polled-VBUS mode (board.vbus_pin && board.vbus_polled), probe arms a self-restarting cycle: at91_vbus_timer() schedules vbus_timer_work, and at91_vbus_timer_work() calls at91_vbus_update() and re-arms the timer via mod_timer(). Both recover the same udc through container_of and dereference it on every iteration.
Neither teardown path cancels this cycle. udc is devm-allocated, so it is freed after at91udc_remove() returns, and is likewise freed when probe fails and devres runs. A timer callback or work item that is pending or running at either point dereferences the freed udc.
Add at91_udc_shutdown_vbus_timer() and call it from at91udc_remove() and from the usb_add_gadget_udc() failure path in probe; the remaining probe error paths fail before the timer is armed. timer_shutdown_sync() waits for a running callback and clears timer->function, which makes the work handler's mod_timer() a permanent no-op; cancel_work_sync() then drains any pending or running work whose re-arm attempt now does nothing. The timer must be shut down first, since cancelling the work alone would let the timer re-queue it. The guard mirrors probe: in IRQ mode the timer and work_struct are never initialized.
This does not require a fault; a normal driver unbind can interleave with an already queued work item.
This issue was found by an in-house static analysis tool.
--- drivers/usb/gadget/udc/at91_udc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/at91_udc.c +19 -1
@@ -1803,6 +1803,19 @@ static void at91udc_of_init(struct at91_ udc->caps = match->data; } +/* +* The work handler re-arms this timer, so shut the timer down before +* draining the work; otherwise it restarts the polling cycle. +*/ +static void at91_udc_shutdown_vbus_timer (struct at91_udc *udc) +{ +if (!(udc->board.vbus_pin && udc->board.vbus_polled)) +return ; + +timer_shutdown_sync (&udc->vbus_timer); +cancel_work_sync (&udc->vbus_timer_work); +} +static int at91udc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -1924,7 +1937,7 @@ static int at91udc_probe(struct platform } retval =usb_add_gadget_udc (dev, &udc->gadget);if (retval) - goto err_unprepare_iclk; + goto err_shutdown_vbus;dev_set_drvdata (dev, udc);device_init_wakeup (dev,1 );create_debug_file (udc);
@@ -1932,6 +1945,8 @@ static int at91udc_probe(struct platformINFO ("%s version %s\n" , driver_name,DRIVER_VERSION );return 0 ; +err_shutdown_vbus: +at91_udc_shutdown_vbus_timer (udc); err_unprepare_iclk:clk_unprepare (udc->iclk); err_unprepare_fclk:
@@ -1950,6 +1965,9 @@ static void at91udc_remove(struct platfoDBG ("remove\n" );usb_del_gadget_udc (&udc->gadget); + +at91_udc_shutdown_vbus_timer (udc); +if (udc->driver) {dev_err (&pdev->dev,"Driver still in use but removing anyhow\n" );
Greg Kroah-Hartman
maintainerPATCH 284/571 usb: typec: tcpm: fix debug accessory mode detection for sink ports
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
[ Upstream commit f6ec9bb4acc7182b25a793ad094a764e1cb819a7 ]
The port in debug accessory mode can be either a source or sink. The previous tcpm_port_is_debug() function only checked for source port.
Commit 8db73e6a42b6 ("usb: typec: tcpm: allow sink (ufp) to toggle into accessory mode debug") changed the detection logic to support both roles, but left some logic in _tcpm_cc_change() unchanged, This causes the state machine to transition to an incorrect state when operating as a sink in debug accessory mode. Log as below:
[ 978.637541] CC1: 0 -> 5, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected] [ 978.637567] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS] [ 978.637596] pending state change SRC_ATTACH_WAIT -> DEBUG_ACC_ATTACHED @ 180 ms [rev1 NONE_AMS] [ 978.647098] CC1: 5 -> 0, CC2: 5 -> 5 [state SRC_ATTACH_WAIT, polarity 0, connected] [ 978.647115] state change SRC_ATTACH_WAIT -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
It should go to SNK_ATTACH_WAIT instead of SRC_ATTACH_WAIT state.
To fix this, add tcpm_port_is_debug_source() and tcpm_port_is_debug_sink() helper to explicitly identify the power mode in debug accessory mode. Update the state transition logic in _tcpm_cc_change() to ensure the state machine transitions comply with Type-C specification. Also update the logic in run_state_machine() to keep consistency.
[Backport to 6.12: This tree lacks 8db73e6a42b6 and the associated sink debug-accessory state-machine support. Retain only the source-debug macro extraction and source-side call-site updates. Keep tcpm_port_is_debug() source-only and omit the sink-debug macro and all sink/audio attachment transitions introduced by the upstream dependency. This preserves existing detection and state transitions while providing tcpm_port_is_debug_source() for cd3b9cea675b ("usb: typec: tcpm: constrain TCPM_SOURCING_VBUS event handling"). No functions are added.]
Stable-dep-of: cd3b9cea675b ("usb: typec: tcpm: constrain TCPM_SOURCING_VBUS event handling")
--- drivers/usb/typec/tcpm/tcpm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +7 -4
@@ -514,9 +514,12 @@ static const char * const pd_rev[] = { (tcpm_cc_is_source((port)->cc2) && \ !tcpm_cc_is_source((port)->cc1))) -#define tcpm_port_is_debug (port) \ +#define tcpm_port_is_debug_source (port) \ (tcpm_cc_is_source((port)->cc1) && tcpm_cc_is_source((port)->cc2)) +#define tcpm_port_is_debug (port) \ + tcpm_port_is_debug_source(port) +#define tcpm_port_is_audio (port) \ (tcpm_cc_is_audio((port)->cc1) && tcpm_cc_is_audio((port)->cc2))
@@ -3951,7 +3954,7 @@ static void run_state_machine(struct tcptcpm_set_state (port,SNK_UNATTACHED ,PD_T_DRP_SNK );break ;case SRC_ATTACH_WAIT : -if (tcpm_port_is_debug (port)) +if (tcpm_port_is_debug_source (port))tcpm_set_state (port,DEBUG_ACC_ATTACHED ,PD_T_CC_DEBOUNCE );else if (tcpm_port_is_audio (port))
@@ -4954,7 +4957,7 @@ static void _tcpm_cc_change(struct tcpm_switch (port->state) {case TOGGLING : -if (tcpm_port_is_debug (port) ||tcpm_port_is_audio (port) || +if (tcpm_port_is_debug_source (port) ||tcpm_port_is_audio (port) ||tcpm_port_is_source (port))tcpm_set_state (port,SRC_ATTACH_WAIT ,0 );else if (tcpm_port_is_sink (port))
@@ -4962,7 +4965,7 @@ static void _tcpm_cc_change(struct tcpm_break ;case SRC_UNATTACHED :case ACC_UNATTACHED : -if (tcpm_port_is_debug (port) ||tcpm_port_is_audio (port) || +if (tcpm_port_is_debug_source (port) ||tcpm_port_is_audio (port) ||tcpm_port_is_source (port))tcpm_set_state (port,SRC_ATTACH_WAIT ,0 );break ;
Greg Kroah-Hartman
maintainerPATCH 285/571 usb: typec: tcpm: constrain TCPM_SOURCING_VBUS event handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Sunil Dhamne <[email protected]>
[ Upstream commit cd3b9cea675bbfebc223f007dc2f4e79524fa54c ]
When a sink detach occurs while waiting for TX send status, the old TCPM_SOURCING_VBUS event along with TCPM_VBUS_EVENT and TCPM_CC_EVENT can be queued in port->pd_events. Because TCPM_SOURCING_VBUS is evaluated after TCPM_VBUS_EVENT and TCPM_CC_EVENT in tcpm_pd_event_handler(), a stale TCPM_SOURCING_VBUS event can override the detach handling and incorrectly set port->vbus_source and port->vbus_present to true.
Add a state guard to check that the port is either operating as a Source (tcpm_port_is_source(port)) or in a Fast Role Swap (FRS) state up to FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED before processing TCPM_SOURCING_VBUS. Otherwise, discard and log the event.
Log snippet for error condition before fix:
[72792.204955] state change SRC_ATTACHED -> SRC_STARTUP [rev3 NONE_AMS] [72792.204960] sourcing vbus [72792.204962] VBUS on [72792.204970] AMS POWER_NEGOTIATION start [72792.204974] cc:=4 [72792.205319] state change SRC_STARTUP -> AMS_START [rev3 POWER_NEGOTIATION] [72792.205325] state change AMS_START -> SRC_SEND_CAPABILITIES [rev3 POWER_NEGOTIATION] [72792.205332] PD TX, header: 0x11a1 [72792.216911] PD TX complete, status: 2 [72792.216957] pending state change SRC_SEND_CAPABILITIES -> SRC_SEND_CAPABILITIES @ 150 ms [rev3 POWER_NEGOTIATION] [72792.218005] VBUS off [72792.218013] pending state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED @ 650 ms [rev3 POWER_NEGOTIATION] [72792.218020] VBUS VSAFE0V [72792.218024] state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED [rev3 POWER_NEGOTIATION] [72792.218458] CC1: 2 -> 0, CC2: 0 -> 0 [state SNK_UNATTACHED, polarity 0, disconnected] [72792.218467] VBUS on --> VBUS left on [72792.218980] disable vbus discharge ret:0 [72792.235193] Start toggling
After fix:
[ 1195.291691] state change SRC_ATTACHED -> SRC_STARTUP [rev3 NONE_AMS] [ 1195.291698] sourcing vbus [ 1195.291700] VBUS on [ 1195.291707] AMS POWER_NEGOTIATION start [ 1195.291710] cc:=4 [ 1195.291758] state change SRC_STARTUP -> AMS_START [rev3 POWER_NEGOTIATION] [ 1195.291794] state change AMS_START -> SRC_SEND_CAPABILITIES [rev3 POWER_NEGOTIATION] [ 1195.291798] PD TX, header: 0x11a1 [ 1195.297056] PD TX complete, status: 2 [ 1195.297092] pending state change SRC_SEND_CAPABILITIES -> SRC_SEND_CAPABILITIES @ 150 ms [rev3 POWER_NEGOTIATION] [ 1195.297177] VBUS off [ 1195.297184] pending state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED @ 650 ms [rev3 POWER_NEGOTIATION] [ 1195.297227] CC1: 2 -> 0, CC2: 0 -> 0 [state SRC_SEND_CAPABILITIES, polarity 0, disconnected] [ 1195.307469] cc:=2 [ 1195.307544] pending state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED @ 650 ms [rev3 POWER_NEGOTIATION] [ 1195.307555] Discarding sourcing vbus! Invalid state SRC_SEND_CAPABILITIES [ 1195.957636] state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED [delayed 650 ms] [ 1195.957732] disable vbus discharge ret:0 [ 1195.970196] Start toggling [ 1195.970468] VBUS off [ 1196.051637] VBUS off [ 1196.051642] VBUS VSAFE0V
--- drivers/usb/typec/tcpm/tcpm.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +22 -6
@@ -5468,16 +5468,32 @@ static void tcpm_pd_event_handler(struct } }if (events &TCPM_SOURCING_VBUS ) { -tcpm_log (port,"sourcing vbus" );/* * In fast role swap case TCPC autonomously sources vbus. Set vbus_source -* true as TCPM wouldn't have called tcpm_set_vbus. +* true conditionally as TCPM wouldn't have called tcpm_set_vbus. +* If TCPM calls tcpm_set_vbus to source vbus, vbus_source would already +* be true. * -* When vbus is sourced on the command on TCPM i.e. TCPM called -* tcpm_set_vbus to source vbus, vbus_source would already be true. +* When TCPM_FRS_EVENT and TCPM_SOURCING_VBUS arrive simultaneously, +* handling TCPM_FRS_EVENT above transitions the state to AMS_START +* with upcoming_state FR_SWAP_SEND. */ - port->vbus_source = true; -_tcpm_pd_vbus_on (port); + +if (tcpm_port_is_source (port) || +tcpm_port_is_debug_source (port) || + (port->state ==AMS_START && port->upcoming_state ==FR_SWAP_SEND ) || + port->state ==FR_SWAP_SEND || + port->state ==FR_SWAP_SEND_TIMEOUT || + port->state ==FR_SWAP_SNK_SRC_TRANSITION_TO_OFF || + port->state ==FR_SWAP_SNK_SRC_NEW_SINK_READY || + port->state ==FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED ) { +tcpm_log (port,"sourcing vbus" ); + port->vbus_source = true; +_tcpm_pd_vbus_on (port); + }else { +tcpm_log (port,"Discarding sourcing vbus! Invalid state %s" , + tcpm_states[port->state]); + } }spin_lock (&port->pd_event_lock);
Greg Kroah-Hartman
maintainerPATCH 286/571 xen/netfront: drop RX packets with a short Ethernet header
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 089e58805c452e52179482b1025a8e309a57f801 upstream.
handle_incoming_queue() pulls pull_to bytes into the head before calling eth_type_trans(). pull_to is the length of the first RX slot, capped at RX_COPY_THRESHOLD, and that length comes from the backend. Nothing checks it against ETH_HLEN.
If the first slot is shorter than ETH_HLEN and more slots follow, the head ends up shorter than an Ethernet header while skb->len is longer, and eth_type_trans() BUG()s in __skb_pull(). If the whole packet is shorter than ETH_HLEN, eth_type_trans() reads the header past the end of the data instead.
Pull at least ETH_HLEN, and drop the packet if that fails, which also drops packets too short to hold an Ethernet header. This also checks the return value of the pull, which was ignored.
--- drivers/net/xen-netfront.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/xen-netfront.c +10 -2
@@ -1228,8 +1228,16 @@ static int handle_incoming_queue(structwhile ((skb =__skb_dequeue (rxq)) !=NULL ) {int pull_to =NETFRONT_SKB_CB (skb)->pull_to; -if (pull_to >skb_headlen (skb)) -__pskb_pull_tail (skb, pull_to -skb_headlen (skb)); +/* pull_to comes from the first slot's length, which the +* backend controls. Make sure the head holds at least an +* Ethernet header for eth_type_trans(). +*/ +if (!pskb_may_pull (skb,max (pull_to,ETH_HLEN ))) { +kfree_skb (skb); + packets_dropped++; + queue->info->netdev->stats.rx_errors++; +continue ; + }/* Ethernet work: Delayed to here as it peeks the header. */ skb->protocol =eth_type_trans (skb, queue->info->netdev);
Greg Kroah-Hartman
maintainerPATCH 287/571 smb: client: clear setuid/setgid bit on write with cifsacl/modefromsid/posix extensions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangshan Yi <[email protected]>
[ Upstream commit b8e5dc4f95e5484159b343903f302eb6d783f2e6 ]
When a file has the setuid or setgid bit set and is written to, the VFS strips those bits and issues a setattr with ATTR_KILL_SUID/ATTR_KILL_SGID together with an ATTR_MODE carrying the already-cleared mode.
Both cifs_setattr_unix() and cifs_setattr_nounix() unconditionally dropped ATTR_MODE in that case:
/* skip mode change if it's just for clearing setuid/setgid */ if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) attrs->ia_valid &= ~ATTR_MODE;
This is fine for the default mount, where the mode is only emulated via the DOS read-only attribute and cannot represent the setuid/setgid bits anyway. However, with the "cifsacl" or "modefromsid" mount options the mode is stored on the server through an ACL (id_mode_to_cifs_acl()), with the SMB3.1.1 POSIX extensions the mode is sent to the server directly, and with the SMB1 Unix extensions (cifs_setattr_unix) the mode is sent via CIFSSMBUnixSetPathInfo(). In all those cases dropping ATTR_MODE means the cleared mode is never pushed to the server, so the setuid/setgid bit survives the write.
This is a security issue: on local filesystems the setuid bit is stripped when a file is written, but over these cifs.ko mounts the bit persists on the server, potentially allowing an unexpected privilege escalation on subsequent execution.
Fix this in two places:
1. cifs_setattr_nounix(): only take the "skip mode change" shortcut when the mode is emulated via the DOS read-only attribute (i.e. neither cifsacl/modefromsid nor the SMB3.1.1 POSIX extensions are in effect), so that the cleared mode is propagated to the server in the ACL / POSIX cases.
2. cifs_setattr_unix(): this function is only called when Unix extensions are in effect, so the mode is always stored on the server. Remove the shortcut entirely so that the cleared mode is always pushed.
[ Backport note for 5.15: code lives in fs/cifs/inode.c; no sbflags
local exists here, so test cifs_sb->mnt_cifs_flags directly (same flag bits). Drop the upstream posix_extensions clause: 5.15 lacks d413eabff18d ("fs/smb/client: implement chmod() for SMB3 POSIX Extensions"), so cifs_setattr_nounix() has no POSIX ATTR_MODE branch; match its CIFS_ACL/MODE_FROM_SID check. ]
--- fs/cifs/inode.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
fs/cifs/inode.c +23 -5
@@ -2714,9 +2714,13 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) goto out; } -/* skip mode change if it's just for clearing setuid/setgid */ -if (attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) - attrs->ia_valid &= ~ATTR_MODE ; +/* +* This function is only called when Unix extensions are in effect, +* so the mode is always sent to and stored on the server. Do not +* skip the mode change when clearing setuid/setgid bits: dropping +* ATTR_MODE here would leave those bits set on the server after a +* write, which is a security issue. +*/ args =kmalloc (sizeof (*args),GFP_KERNEL );if (args ==NULL ) {
@@ -2899,8 +2903,22 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID )) attrs->ia_valid &= ~(ATTR_UID |ATTR_GID ); -/* skip mode change if it's just for clearing setuid/setgid */ -if (attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) +/* +* Skip the mode change if it is only being done to clear the +* setuid/setgid bits *and* the mode is emulated via the DOS +* read-only attribute (the default, non-ACL case), which cannot +* represent the setuid/setgid bits anyway. +* +* When the mode is instead stored on the server - i.e. with the +* cifsacl or modefromsid mount options (via an ACL) - the cleared +* mode must be pushed to the server. Dropping ATTR_MODE here +* would leave the setuid/setgid bit set on the server after a +* write, which is a security issue (the bits are not stripped as +* they are on local filesystems). +*/ +if ((attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) && + !(cifs_sb->mnt_cifs_flags & + (CIFS_MOUNT_CIFS_ACL |CIFS_MOUNT_MODE_FROM_SID ))) attrs->ia_valid &= ~ATTR_MODE ;if (attrs->ia_valid &ATTR_MODE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 288/571 drm/amd/pm/si: Check AMD_IS_MOBILITY flag for PPSMC_SYSTEMFLAG_GPIO_DC
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit cd883d0a3937df82a5ea03709ba8ba623b868419 ]
Unfortunately, some desktop boards eg. the FirePro D500 have the HARDWAREDC platform flag set and also have a battery power state configured in their VBIOS. This makes no sense for a desktop GPU and results in incorrect behaviour: the clocks are stuck at lowest.
We observed that the kernel driver can work around the issue in two possible ways:
1. Set PPSMC_SWSTATE_FLAG_DC on all power states
2. Clear PPSMC_SYSTEMFLAG_GPIO_DC
We think that the PPSMC_SYSTEMFLAG_GPIO_DC flag makes the SMC assume it's running on battery even though this is a desktop machine with no battery, and that's why it doesn't do DPM on power states without PPSMC_SYSTEMFLAG_GPIO_DC.
Issue was uncovered by "Fix updating clock limits from power states" because previously the limits for the battery state were not tracked separately. However, battery power state has lower frequencies and voltages, so the kernel doesn't set the DC flag on the current power state anymore. That causes the SMC to be stuck on the lowest clocks.
Let's clear PPSMC_SYSTEMFLAG_GPIO_DC on desktop GPUs. We can use the AMD_IS_MOBILITY flag to determine that.
--- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +2 -1
@@ -5164,7 +5164,8 @@ static int si_init_smc_table(struct amdgpu_device *adev)break ; } -if (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_HARDWAREDC ) +if ((adev->flags &AMD_IS_MOBILITY ) && + (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_HARDWAREDC )) table->systemFlags |=PPSMC_SYSTEMFLAG_GPIO_DC ;if (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_REGULATOR_HOT ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 289/571 soc: qcom: geni-se: Correct QUP Core ICC vote constants
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viken Dadhaniya <[email protected]>
[ Upstream commit 1cd9b1be5a9c56fd69e3f555b200a1844f9b873e ]
The GENI_TO_CORE ("qup-core") ICC vote selects the QUP Core 2X clock rate. The CORE_2X_*_MHZ constants are expressed in Bps, but their values are several orders of magnitude too small. For example, the 50 MHz threshold is represented by 2500 rather than 25000000 Bps.
As a result, clients using these constants can severely under-vote the QUP Core clock.
Correct the constants to their intended Bps thresholds so that the ICC provider selects the corresponding QUP Core 2X clock rate. Drop the unused definitions.
--- include/linux/qcom-geni-se.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
include/linux/qcom-geni-se.h +5 -10
@@ -265,17 +265,12 @@ struct geni_se {#define QUP_SE_VERSION_2_5 0x20050000/* -* Define bandwidth thresholds that cause the underlying Core 2X interconnect -* clock to run at the named frequency. These baseline values are recommended -* by the hardware team, and are not dynamically scaled with GENI bandwidth -* beyond basic on/off. +* QUP Core 2X clock votes used by GENI clients through the "qup-core" ICC +* path. Values are in Bps and must be converted with Bps_to_icc() before +* setting avg_bw. */ -#define CORE_2X_19_2_MHZ 960 -#define CORE_2X_50_MHZ 2500 -#define CORE_2X_100_MHZ 5000 -#define CORE_2X_150_MHZ 7500 -#define CORE_2X_200_MHZ 10000 -#define CORE_2X_236_MHZ 16383 +#define CORE_2X_19_2_MHZ 9600000 +#define CORE_2X_50_MHZ 25000000#define GENI_DEFAULT_BW Bps_to_icc(1000)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 290/571 usb: dwc3: gadget: fix IRQ storm on invalid event buffer count
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiazi Liu <[email protected]>
[ Upstream commit 1ff77cbefe5a653ea12874c213ea4bd0d72c1067 ]
When dwc3_check_event_buf() reads a GEVNTCOUNT value exceeding the event buffer length, commit 63ccd26cd1f6 ("usb: dwc3: gadget: check that event count does not exceed event buffer length") returns IRQ_NONE without writing back GEVNTCOUNT. Since the DWC3 interrupt is level-triggered, the uncleared IRQ source keeps the line asserted, causing a tight IRQ storm that accumulates 99,900 unhandled interrupts and triggers spurious.c:184 BUG -> kernel panic.
The resulting call stack:
__report_bad_irq+0xac/0xc8 note_interrupt+0x340/0x468 handle_irq_event+0xac/0xc0 handle_fasteoi_irq+0x120/0x228 gic_handle_irq+0x68/0x108 ... kernel BUG at kernel/irq/spurious.c:184
To reproduce, write a bogus value exceeding the event buffer length directly to the GEVNTCOUNT register:
devmem <DWC3_BASE + 0xc40c> 4 0x1004
Write the bogus count back to GEVNTCOUNT to clear the IRQ source, consistent with the stale event clearing pattern in dwc3_event_buffers_setup(), and schedule error recovery to reinitialize the controller.
--- drivers/usb/dwc3/core.h | 19 +++++++ drivers/usb/dwc3/ep0.c | 9 ++++ drivers/usb/dwc3/gadget.c | 104 +++++++++++++++++++++++++++++++++++++- 3 files changed, 130 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.h +19 -0
@@ -42,6 +42,7 @@#define DWC3_ENDPOINTS_NUM 32#define DWC3_XHCI_RESOURCES_NUM 2#define DWC3_ISOC_MAX_RETRIES 5 +#define DWC3_ERR_RECOVERY_MAX 3#define DWC3_SCRATCHBUF_SIZE 4096/* each buffer is assumed to be 4KiB */ #define DWC3_EVENT_BUFFERS_SIZE 4096
@@ -796,6 +797,12 @@ enum dwc3_link_state { DWC3_LINK_STATE_MASK = 0x0f, }; +enum dwc3_err_state { +DWC3_ERR_NONE =0 , +DWC3_ERR_RECOVERY , +DWC3_ERR_UNRECOVERABLE , +}; +/* TRB Length, PCM and Status */ #define DWC3_TRB_SIZE_MASK (0x00ffffff)#define DWC3_TRB_SIZE_LENGTH (n) ((n) & DWC3_TRB_SIZE_MASK)
@@ -947,6 +954,7 @@ struct dwc3_scratchpad_array {/** * struct dwc3 - representation of our controller * @drd_work: workqueue used for role swapping +* @err_recovery_work: workqueue used for controller error recovery * @ep0_trb: trb which is used for the ctrl_req * @bounce: address of bounce buffer * @scratchbuf: address of scratch buffer
@@ -958,6 +966,7 @@ struct dwc3_scratchpad_array {* @ep0_in_setup: one control transfer is completed and enter setup phase * @lock: for synchronizing * @mutex: for mode switching +* @connect_mutex: for the pull-up and err_recovery_work * @dev: pointer to our struct device * @sysdev: pointer to the DMA-capable device * @xhci: pointer to our xHCI child
@@ -1014,6 +1023,9 @@ struct dwc3_scratchpad_array {* @ep0_next_event: hold the next expected event * @ep0state: state of endpoint zero * @link_state: link state +* @err_state: current error recovery state. +* @err_recovery_count: number of consecutive error recovery attempts until +* confirmed healthy and reset to 0 on reset event. * @speed: device speed (super, high, full, low) * @hwparams: copy of hwparams registers * @regset: debugfs pointer to regdump file
@@ -1099,6 +1111,7 @@ struct dwc3_scratchpad_array {*/ struct dwc3 {struct work_struct drd_work; +struct work_struct err_recovery_work;struct dwc3_trb *ep0_trb;void *bounce;void *scratchbuf;
@@ -1115,6 +1128,9 @@ struct dwc3 {/* mode switching lock */ struct mutex mutex; +/* serializes pull-up run/stop vs error recovery */ +struct mutex connect_mutex; +struct device *dev;struct device *sysdev;
@@ -1229,6 +1245,9 @@ struct dwc3 {enum dwc3_ep0_next ep0_next_event;enum dwc3_ep0_state ep0state;enum dwc3_link_state link_state; +enum dwc3_err_state err_state; + +u32 err_recovery_count;u16 u2sel;u16 u2pel;
drivers/usb/dwc3/ep0.c +9 -0
@@ -198,6 +198,11 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,int ret;spin_lock_irqsave (&dwc->lock, flags); +if (dwc->err_state !=DWC3_ERR_NONE ) { + ret = -ESHUTDOWN ; + goto out; + } +if (!dep->endpoint.desc || !dwc->pullups_connected) {dev_err (dwc->dev,"%s: can't queue to disabled endpoint\n" , dep->name);
@@ -265,6 +270,10 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)int ret;spin_lock_irqsave (&dwc->lock, flags); +if (dwc->err_state !=DWC3_ERR_NONE ) { +spin_unlock_irqrestore (&dwc->lock, flags); +return -ESHUTDOWN ; + } ret =__dwc3_gadget_ep0_set_halt (ep, value);spin_unlock_irqrestore (&dwc->lock, flags);
drivers/usb/dwc3/gadget.c +102 -2
181 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 291/571 tty: fix saved termios reset race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 8df07fe93573e9e548d6645273e9bcb6eb74059e ]
Resetting saved termios state on device registration is needed where a minor number can be reused for an entirely different device and where the old settings may prevent the port from even being opened (e.g. when CLOCAL is not set).
Not all TTY drivers guarantee that the minor number is no longer in use when registering devices however, something which can lead to a use-after-free when closing a TTY (and saving its termios) races with re-registration.
Add a new TTY_DRIVER_RESET_SAVED_TERMIOS flag to request that any saved termios state is reset on registration and only set it for drivers that make sure that the minor number is no longer in use.
--- drivers/staging/greybus/uart.c | 3 ++- drivers/tty/tty_io.c | 18 ++++++++++-------- drivers/usb/class/cdc-acm.c | 2 +- drivers/usb/serial/usb-serial.c | 3 ++- include/linux/tty_driver.h | 5 +++++ 5 files changed, 20 insertions(+), 11 deletions(-)
drivers/staging/greybus/uart.c +2 -1
@@ -960,7 +960,8 @@ static int gb_tty_init(void) gb_tty_driver->minor_start =0 ; gb_tty_driver->type =TTY_DRIVER_TYPE_SERIAL ; gb_tty_driver->subtype =SERIAL_TYPE_NORMAL ; - gb_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV ; + gb_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV | +TTY_DRIVER_RESET_SAVED_TERMIOS ; gb_tty_driver->init_termios = tty_std_termios; gb_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD |HUPCL |CLOCAL ;
drivers/tty/tty_io.c +10 -8
@@ -3294,14 +3294,16 @@ struct device *tty_register_device_attr(struct tty_driver *driver, goto err_put;if (!(driver->flags &TTY_DRIVER_DYNAMIC_ALLOC )) { -/* -* Free any saved termios data so that the termios state is -* reset when reusing a minor number. -*/ - tp = driver->termios[index]; -if (tp) { - driver->termios[index] =NULL ; -kfree (tp); +if (driver->flags &TTY_DRIVER_RESET_SAVED_TERMIOS ) { +/* +* Free any saved termios data so that the termios +* state is reset when reusing a minor number. +*/ + tp = driver->termios[index]; +if (tp) { + driver->termios[index] =NULL ; +kfree (tp); + } } retval =tty_cdev_add (driver, devt, index,1 );
drivers/usb/class/cdc-acm.c +1 -1
@@ -2084,7 +2084,7 @@ static int __init acm_init(void) {int retval; acm_tty_driver =tty_alloc_driver (ACM_TTY_MINORS ,TTY_DRIVER_REAL_RAW | -TTY_DRIVER_DYNAMIC_DEV ); +TTY_DRIVER_DYNAMIC_DEV |TTY_DRIVER_RESET_SAVED_TERMIOS );if (IS_ERR (acm_tty_driver))return PTR_ERR (acm_tty_driver); acm_tty_driver->driver_name = "acm",
drivers/usb/serial/usb-serial.c +2 -1
@@ -1325,7 +1325,8 @@ static int __init usb_serial_init(void)int result; usb_serial_tty_driver =tty_alloc_driver (USB_SERIAL_TTY_MINORS , -TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV ); +TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV | +TTY_DRIVER_RESET_SAVED_TERMIOS );if (IS_ERR (usb_serial_tty_driver))return PTR_ERR (usb_serial_tty_driver);
include/linux/tty_driver.h +5 -0
@@ -395,6 +395,10 @@ static inline void tty_set_operations(struct tty_driver *driver,* other words create /dev/ttyprintk and not /dev/ttyprintk0. * Applicable only when a driver for a single tty device is * being allocated. +* +* TTY_DRIVER_RESET_SAVED_TERMIOS -- reset any saved termios settings on +* device registration when reusing a minor number. Must only be set by +* drivers that guarantee that the minor number is no longer in use. */ #define TTY_DRIVER_INSTALLED 0x0001#define TTY_DRIVER_RESET_TERMIOS 0x0002
@@ -404,6 +408,7 @@ static inline void tty_set_operations(struct tty_driver *driver,#define TTY_DRIVER_HARDWARE_BREAK 0x0020#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 +#define TTY_DRIVER_RESET_SAVED_TERMIOS 0x0200/* tty driver types */ #define TTY_DRIVER_TYPE_SYSTEM 0x0001
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 292/571 perf: Require kernel access for text poke events
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchuan Liang <[email protected]>
[ Upstream commit 357e8a77a501d96c9517f01f4a211eed5e9c9184 ]
Perf events with exclude_kernel=1 can be opened without kernel perf access. However, exclude_kernel does not suppress text-poke sideband records. Every PERF_RECORD_TEXT_POKE is marked PERF_RECORD_MISC_KERNEL and contains a raw kernel instruction address.
An unprivileged task can therefore open and mmap a task-local software event with text_poke=1. Both opening a count-only tracepoint event and configuring UDP GRO for ESP-in-UDP cause updates to inline static calls; the observer receives the relocated addresses of the modified instructions. For a known kernel image, any such address reveals the runtime kernel text base despite KASLR.
Call perf_allow_kernel() whenever attr.text_poke is set, regardless of exclude_kernel. Events that neither monitor kernel execution nor request text-poke records retain their existing permissions.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -12427,7 +12427,7 @@ SYSCALL_DEFINE5(perf_event_open,if (err)return err; -if (!attr.exclude_kernel) { +if (!attr.exclude_kernel || attr.text_poke) { err =perf_allow_kernel (&attr);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 293/571 ALSA: seq: Serialize compat port-info ioctls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 95b2e0361c88753afa030c10698be0a1a5b67650 ]
The native sequencer ioctl path serializes handler calls with client->ioctl_mutex, but the translated port-info compat path invokes the same handlers through snd_seq_kernel_client_ctl() without taking that mutex.
This lets concurrent compat CREATE_PORT requests pass the port-count check before any request reaches the serialized insertion. The computed integer port index can then exceed the address field range and wrap to an existing index. Subsequent subscriber teardown can resolve the duplicate address to the wrong port and access a freed subscriber.
Take ioctl_mutex while dispatching converted port-info requests, matching the native ioctl path. All translated port-info commands share this helper, so their accesses to the client port state are serialized as well.
--- sound/core/seq/seq_compat.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/seq/seq_compat.c +2 -0
@@ -44,7 +44,9 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned goto error; data->kernel =NULL ; +mutex_lock (&client->ioctl_mutex); err =snd_seq_kernel_client_ctl (client->number, cmd, data); +mutex_unlock (&client->ioctl_mutex);if (err <0 ) goto error;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 294/571 arm64: errata: Factor out broken AMU const counter cap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beata Michalska <[email protected]>
[ Upstream commit 573371caf7aea8582212da81dcead2c3f48fac4b ]
Move the workaround from the erratum 2457168-specific cpucap to a generic broken AMU constant-counter one. This keeps the existing Cortex-A510 handling unchanged while allowing other errata with similar AMU constant counter issue to share the capability bit and call sites.
--- arch/arm64/Kconfig | 8 ++++++++ arch/arm64/kernel/cpu_errata.c | 20 ++++++++++++++------ arch/arm64/kernel/cpufeature.c | 2 +- arch/arm64/kernel/topology.c | 2 +- arch/arm64/tools/cpucaps | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-)
arch/arm64/Kconfig +8 -0
@@ -716,9 +716,17 @@ config ARM64_ERRATUM_2441009 If unsure, say Y. +config ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT + bool + # Targeting errata affecting AMEVCNTR01, the AMU constant counter. + # On affected CPUs the counter may not increment at the expected rate, + # making it unreliable. As a result, AMU users should treat it as + # unavailable rather than relying on misleading counter values. + config ARM64_ERRATUM_2457168 bool "Cortex-A510: 2457168: workaround for AMEVCNTR01 incrementing incorrectly" depends on ARM64_AMU_EXTN + select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT default y help This option adds the workaround for ARM Cortex-A510 erratum 2457168.
arch/arm64/kernel/cpu_errata.c +14 -6
@@ -259,6 +259,16 @@ static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = { };#endif +#ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT +static const struct midr_range workaround_amu_constcnt_list[] = { +#ifdef CONFIG_ARM64_ERRATUM_2457168 +/* Cortex-A510 r0p0-r1p1 */ +MIDR_RANGE (MIDR_CORTEX_A510 ,0 ,0 ,1 ,1 ), +#endif + {} +}; +#endif /* CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT */ +#ifdef CONFIG_CAVIUM_ERRATUM_27456 const struct midr_range cavium_erratum_27456_cpus[] = { /* Cavium ThunderX, T88 pass 1.x - 2.1 */
@@ -660,14 +670,12 @@ const struct arm64_cpu_capabilities arm64_errata[] = { ERRATA_MIDR_ALL_VERSIONS(MIDR_NVIDIA_CARMEL), },#endif - -#ifdef CONFIG_ARM64_ERRATUM_2457168 +#ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT { - .desc = "ARM erratum 2457168", - .capability = ARM64_WORKAROUND_2457168, + .desc = "Broken AMU AMEVCNTR01 (const counter)", + .capability = ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT, .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, - /* Cortex-A510 r0p0-r1p1 */ - CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) + CAP_MIDR_RANGE_LIST(workaround_amu_constcnt_list) }, #endif #ifdef CONFIG_ARM64_ERRATUM_1742098
arch/arm64/kernel/cpufeature.c +1 -1
@@ -1785,7 +1785,7 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)cpumask_set_cpu (smp_processor_id (), &amu_cpus);/* 0 reference values signal broken/disabled counters */ -if (!this_cpu_has_cap (ARM64_WORKAROUND_2457168 )) +if (!this_cpu_has_cap (ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT ))update_freq_counters_refs (); } }
arch/arm64/kernel/topology.c +1 -1
@@ -285,7 +285,7 @@ static void cpu_read_constcnt(void *val)* the counter is disabled. A return value of 0 at counter read is * properly handled as an error case by the users of the counter. */ - *(u64 *)val =this_cpu_has_cap (ARM64_WORKAROUND_2457168 ) ? + *(u64 *)val =this_cpu_has_cap (ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT ) ?0UL :read_constcnt (); }
arch/arm64/tools/cpucaps +1 -1
@@ -55,7 +55,6 @@ WORKAROUND_1463225 WORKAROUND_1508412 WORKAROUND_1542419 WORKAROUND_1742098 -WORKAROUND_2457168 WORKAROUND_TRBE_OVERWRITE_FILL_MODE WORKAROUND_TSB_FLUSH_FAILURE WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
@@ -71,3 +70,4 @@ WORKAROUND_QCOM_FALKOR_E1003 WORKAROUND_REPEAT_TLBI WORKAROUND_SPECULATIVE_AT WORKAROUND_SPECULATIVE_SSBS +WORKAROUND_BROKEN_AMU_CONSTCNT
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 295/571 arm64: errata: Add Cortex-A725 erratum 3821522 workaround
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beata Michalska <[email protected]>
[ Upstream commit 45f7304679875eb000d67e194090ee7abd05c89c ]
Cortex-A725 erratum 3821522 affects the CNT_CYCLES event, which can incur a significant increment error when a CPU enters and subsequently exits WFE or WFI, and may no longer track the system counter frequency.
The AMEVCNTR01_EL0 counter is used as the AMU constant counter for frequency invariance and CPPC FFH feedback counters. Wire the affected Cortex-A725 range into the shared broken AMU constant-counter capability so the affected counter is treated as unavailable by returning zero in the AMU counter paths. This prevents the broken counter from being used as a reference source.
The erratum can also affect PMUv3 users of the CNT_CYCLES event, but this workaround intentionally does not change PMU event handling. Hiding or rejecting the PMU event from the erratum code would change the perf-visible PMU event interface, including raw event selection, and would need a separate PMU-specific approach rather than being folded into the AMU reference-counter workaround.
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 22 ++++++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 4 ++++ arch/arm64/kernel/topology.c | 9 +++++---- 4 files changed, 33 insertions(+), 4 deletions(-)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -138,6 +138,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A725 | #3456106 | ARM64_ERRATUM_3194386 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A725 | #3821522 | ARM64_ERRATUM_3821522 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-X1 | #3324344 | ARM64_ERRATUM_3194386 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-X1 | #4193791 | ARM64_ERRATUM_4118414 |
arch/arm64/Kconfig +22 -0
@@ -741,6 +741,28 @@ config ARM64_ERRATUM_2457168 If unsure, say Y. +config ARM64_ERRATUM_3821522 + bool "Cortex-A725: 3821522: workaround for possible CNT_CYCLES increment error due to WFE/WFI" + depends on ARM64_AMU_EXTN + select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT + default y + help + This option adds the workaround for ARM Cortex-A725 erratum 3821522. + + On affected A725 cores, the CNT_CYCLES event may incur a significant + increment error when entering and subsequently exiting WFx. + As a result, the CNT_CYCLES may diverge from the system counter + frequency at which it is expected to increment. + This renders the AMU counter AMEVCNTR01, that implements CNT_CYCLES, + being unreliable and unsuitable for use. + + Since there is no hardware workaround, reads of the affected CNT_CYCLES + counter return 0 in the relevant paths. This causes users of the counter + to treat it as unavailable and is functionally equivalent to firmware + disabling the affected counter. + + If unsure, say Y. + config ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE bool
arch/arm64/kernel/cpu_errata.c +4 -0
@@ -264,6 +264,10 @@ static const struct midr_range workaround_amu_constcnt_list[] = {#ifdef CONFIG_ARM64_ERRATUM_2457168 /* Cortex-A510 r0p0-r1p1 */ MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1), +#endif +#ifdef CONFIG_ARM64_ERRATUM_3821522 +/* Cortex-A725 r0p0 - r0p2 */ + MIDR_RANGE(MIDR_CORTEX_A725, 0, 0, 0, 2),#endif {} };
arch/arm64/kernel/topology.c +5 -4
@@ -280,10 +280,11 @@ static void cpu_read_corecnt(void *val)static void cpu_read_constcnt (void *val) {/* -* Return 0 if the current CPU is affected by erratum 2457168. A value -* of 0 is also returned if the current CPU does not support AMUs or if -* the counter is disabled. A return value of 0 at counter read is -* properly handled as an error case by the users of the counter. +* Return 0 if the current CPU is affected by a HW erratum. +* A value of 0 is also returned if the current CPU does not +* support AMUs or if the counter is disabled. A return +* value of 0 at counter read is properly handled as an error +* case by the users of the counter. */ *(u64 *)val =this_cpu_has_cap (ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT ) ?0UL :read_constcnt ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 296/571 iio: buffer: serialize buffer teardown with mode claims
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinseob Kim <[email protected]>
commit 84bb0fc46ccf6a545b8fdf57cda83770186ed8dd upstream.
Buffer-mode claims hold mlock to guarantee that the device remains in buffer mode until the claim is released. Normal buffer updates take info_exist_lock followed by mlock in iio_update_buffers().
However, iio_device_unregister() disables and deactivates all buffers without taking mlock. This can invalidate buffer state, including active_scan_mask, while a buffer-mode claim is held.
Take mlock in iio_disable_all_buffers() so that unregister honors the mode-claim lifetime guarantee. The info_exist_lock -> mlock ordering matches iio_update_buffers().
[ Backport by Jinseob Kim to 5.15.y: mlock is still in struct iio_dev,
so use indio_dev->mlock instead of iio_dev_opaque->mlock. ]
--- drivers/iio/industrialio-buffer.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/industrialio-buffer.c +2 -0
@@ -1187,6 +1187,8 @@ EXPORT_SYMBOL_GPL(iio_update_buffers);void iio_disable_all_buffers (struct iio_dev *indio_dev) { +guard (mutex)(&indio_dev->mlock); +iio_disable_buffers (indio_dev);iio_buffer_deactivate_all (indio_dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 297/571 KVM: arm64: Dont use the VMA to size stage-2 block mappings for VM_PFNMAP
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mostafa Saleh <[email protected]>
[ Upstream commit 71cc2c67fb8f8d5aa8154eb482e9846d2214f11b ]
get_vma_page_shift() derives the stage-2 block size for VM_PFNMAP VMAs from the VMA layout alone, which does not necessarily match what stage-1 maps for that VMA.
Upstream commit 71cc2c67fb8f ("KVM: arm64: Use stage-1 leaf size for VM_PFNMAP") drops that calculation and lets transparent_hugepage_adjust() derive the mapping size from the stage-1 leaf instead. The second part is not applicable here: in this kernel transparent_hugepage_adjust() takes a reference on the backing struct page, which is not safe for MMIO, and stage-1 has no huge PFNMAP before v6.12 anyway. Only drop the VMA-based calculation, so VM_PFNMAP VMAs are mapped at PAGE_SIZE.
--- arch/arm64/kvm/mmu.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-)
arch/arm64/kvm/mmu.c +2 -23
@@ -904,32 +904,11 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,return PAGE_SIZE ; } -static int get_vma_page_shift (struct vm_area_struct *vma,unsigned long hva) +static int get_vma_page_shift (struct vm_area_struct *vma) { -unsigned long pa; -if (is_vm_hugetlb_page (vma) && !(vma->vm_flags &VM_PFNMAP ))return huge_page_shift (hstate_vma (vma)); -if (!(vma->vm_flags &VM_PFNMAP )) -return PAGE_SHIFT ; - -VM_BUG_ON (is_vm_hugetlb_page (vma)); - - pa = (vma->vm_pgoff <<PAGE_SHIFT ) + (hva - vma->vm_start); - -#ifndef __PAGETABLE_PMD_FOLDED -if ((hva & (PUD_SIZE -1 )) == (pa & (PUD_SIZE -1 )) && -ALIGN_DOWN (hva,PUD_SIZE ) >= vma->vm_start && -ALIGN (hva,PUD_SIZE ) <= vma->vm_end) -return PUD_SHIFT ; -#endif - -if ((hva & (PMD_SIZE -1 )) == (pa & (PMD_SIZE -1 )) && -ALIGN_DOWN (hva,PMD_SIZE ) >= vma->vm_start && -ALIGN (hva,PMD_SIZE ) <= vma->vm_end) -return PMD_SHIFT ; -return PAGE_SHIFT ; }
@@ -1038,7 +1017,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, force_pte = true; vma_shift =PAGE_SHIFT ; }else { - vma_shift =get_vma_page_shift (vma, hva); + vma_shift =get_vma_page_shift (vma); } shared = (vma->vm_flags &VM_SHARED );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 298/571 fsverity: add dependency on 64K or smaller pages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit a300000233a9ff842e2fb450fb9a79f7827a586d upstream.
Currently, all filesystems that support fsverity (ext4, f2fs, and btrfs) cache the Merkle tree in the pagecache at a 64K aligned offset after the end of the file data. This offset needs to be a multiple of the page size, which is guaranteed only when the page size is 64K or smaller.
64K was chosen to be the "largest reasonable page size". But it isn't the largest *possible* page size: the hexagon and powerpc ports of Linux support 256K pages, though that configuration is rarely used.
For now, just disable support for FS_VERITY in these odd configurations to ensure it isn't used in cases where it would have incorrect behavior.
--- fs/verity/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
fs/verity/Kconfig +3 -0
@@ -2,6 +2,9 @@ config FS_VERITY bool "FS Verity (read-only file-based authenticity protection)" + # Filesystems cache the Merkle tree at a 64K aligned offset in the + # pagecache. That approach assumes the page size is at most 64K. + depends on !PAGE_SIZE_256KB && !PPC_256K_PAGES select CRYPTO # SHA-256 is implied as it's intended to be the default hash algorithm. # To avoid bloat, other wanted algorithms must be selected explicitly.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/571 drm/amd/display: check dc_state_create_copy() for NULL in dm_suspend
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangshan Yi <[email protected]>
[ Upstream commit 015e72cde567d2450e282c2790773463156b2d0a ]
dc_state_create_copy() can return NULL on allocation failure. dm_suspend() only conditionally skips dm_gpureset_toggle_interrupts() and continues execution, returning success. dm_resume() then dereferences the NULL cached_dc_state in link_enc_cfg_copy() and the following dc_state->stream_count loop, crashing during GPU reset recovery.
Return -ENOMEM immediately if the copy fails, so the caller aborts suspend instead of leaving a NULL cached state for resume.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -2
@@ -2440,9 +2440,14 @@ static int dm_suspend(void *handle)#endif dm->cached_dc_state =dc_copy_state (dm->dc->current_state); +if (!dm->cached_dc_state) { +drm_err (adev_to_drm (adev), +"Failed to allocate cached DC state during suspend\n" ); +mutex_unlock (&dm->dc_lock); +return -ENOMEM ; + } -if (dm->cached_dc_state) -dm_gpureset_toggle_interrupts (adev, dm->cached_dc_state, false); +dm_gpureset_toggle_interrupts (adev, dm->cached_dc_state, false);amdgpu_dm_commit_zero_streams (dm->dc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 300/571 drm/amd/pm/si: Fix updating clock limits on AC/DC
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 08c9100f65299c64439e22e6057d750ae0e6c660 ]
Assume that the AC limits are the maximum of all power states, and the DC limits are the maximum of battery power states. This shouldn't make any difference in practice, but is cleaner and more robust against bogus information in the VBIOS.
--- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +18 -18
@@ -7133,6 +7133,19 @@ static void si_parse_pplib_non_clock_info(struct amdgpu_device *adev, adev->pm.dpm.uvd_ps = rps; } +static void si_update_limits (struct amdgpu_clock_and_voltage_limits *limits, +struct rv7xx_pl *pl) +{ +if (pl->sclk > limits->sclk) + limits->sclk = pl->sclk; +if (pl->mclk > limits->mclk) + limits->mclk = pl->mclk; +if (pl->vddc > limits->vddc) + limits->vddc = pl->vddc; +if (pl->vddci > limits->vddci) + limits->vddci = pl->vddci; +} +static void si_parse_pplib_clock_info (struct amdgpu_device *adev,struct amdgpu_ps *rps,int index,union pplib_clock_info *clock_info)
@@ -7141,7 +7154,6 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev,struct evergreen_power_info *eg_pi =evergreen_get_pi (adev);struct si_power_info *si_pi =si_get_pi (adev);struct si_ps *ps =si_get_ps (rps); -struct amdgpu_clock_and_voltage_limits *limits;u16 leakage_voltage;struct rv7xx_pl *pl = &ps->performance_levels[index];int ret;
@@ -7206,26 +7218,14 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev,* VBIOS can contain conflicting values between: * - the maximum allowed clocks and voltages on AC or DC * - the clocks and voltages in power states on AC or DC +* +* Assume that the AC limits are the maximum of all power states, +* and the DC limits are the maximum of battery power states. */ +si_update_limits (&adev->pm.dpm.dyn_state.max_clock_voltage_on_ac, pl);if ((rps->class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) == -ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE ) - limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; -else if ((rps->class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) ==ATOM_PPLIB_CLASSIFICATION_UI_BATTERY ) - limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; -else - limits =NULL ; - -if (limits) { -if (pl->sclk > limits->sclk) - limits->sclk = pl->sclk; -if (pl->mclk > limits->mclk) - limits->mclk = pl->mclk; -if (pl->vddc > limits->vddc) - limits->vddc = pl->vddc; -if (pl->vddci > limits->vddci) - limits->vddci = pl->vddci; - } +si_update_limits (&adev->pm.dpm.dyn_state.max_clock_voltage_on_dc, pl); }union pplib_power_state {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 301/571 drm/amdgpu: reset VI ASIC on MacBookPro15,1
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Eikmeyer <[email protected]>
[ Upstream commit a5be7ad8f5f0e067613e9197638f216f46252946 ]
After S3, reloading amdgpu on MacBookPro15,1 systems with a Radeon Pro 555X or 560X fails while loading the SMU firmware. The existing SMC register check does not request a reset because the registers do not reliably reflect the stale SMU state on these machines.
Frederick Morlock found that forcing a VI ASIC reset allows the driver to initialize again. This patch limits his workaround to the exact PCI device, Apple subsystem device and revision combinations used by these two GPUs, leaving other VI hardware unchanged.
Stable-dep-of: a22e5e4f2ebb ("drm/amdgpu: reset VI ASIC on MacBookPro14,3")
--- drivers/gpu/drm/amd/amdgpu/vi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/vi.c +20 -0
@@ -1432,10 +1432,30 @@ static uint64_t vi_get_pcie_replay_count(struct amdgpu_device *adev)return (nak_r + nak_g); } +struct vi_reset_quirk { +u16 device; +u16 subsystem_vendor; +u16 subsystem_device; +u8 revision; +}; + +static const struct vi_reset_quirk vi_reset_quirks[] = { + {0x67ef ,PCI_VENDOR_ID_APPLE ,0x0190 ,0xe3 },/* Radeon Pro 555X */ + {0x67ef ,PCI_VENDOR_ID_APPLE ,0x018f ,0xc2 },/* Radeon Pro 560X */ +}; +static bool vi_need_reset_on_init (struct amdgpu_device *adev) { +unsigned int i;u32 clock_cntl, pc; +for (i =0 ; i <ARRAY_SIZE (vi_reset_quirks); i++) +if (adev->pdev->device == vi_reset_quirks[i].device && + adev->pdev->subsystem_vendor == vi_reset_quirks[i].subsystem_vendor && + adev->pdev->subsystem_device == vi_reset_quirks[i].subsystem_device && + adev->pdev->revision == vi_reset_quirks[i].revision) +return true; +if (adev->flags &AMD_IS_APU )return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 302/571 drm/amdgpu: reset VI ASIC on MacBookPro14,3
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francisco Beltrán Millalén <[email protected]>
[ Upstream commit a22e5e4f2ebbdbb962cc3233094d189c4dfaa051 ]
On a MacBookPro14,3 with a Radeon Pro 555 (Polaris11), the framebuffer is at MC address 0 when amdgpu loads after a cold boot, as the firmware leaves it (MC_VM_FB_LOCATION = 0x007f0000), while the VBIOS ASIC_Init table places it at 0xF4_0000_0000 (0xf47ff400). amdgpu reads the location once, at init, so after a re-POST (S3 resume or GPU reset) the framebuffer has moved and the driver keeps programming the old
one: the SMU is handed a table that was never written and the GPU does not come back, which leaves the internal panel black.
Resetting the ASIC on load makes ASIC_Init run before the driver reads the location, so the driver uses the VBIOS placement from the start and every later re-POST puts the framebuffer back where it already is.
Add the Radeon Pro 555 used in this machine to the existing VI reset quirk table.
Tested on a MacBookPro14,3 on 6.18.49 with the quirk table backported (the kernel also carries unrelated local PCI and ACPI patches for this machine). The framebuffer is at 0x000000F400000000 after both cold and warm boot, and the GPU survived 9 S3 cycles (lid close and rtcwake, one of them with the lid closed for about 7.5 minutes and a USB-C disk attached), each followed by a few minutes of 3D load; no ring timeouts or VM faults were reported. The reset adds about 0.23 s to amdgpu init.
--- drivers/gpu/drm/amd/amdgpu/vi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/vi.c +1 -0
@@ -1442,6 +1442,7 @@ struct vi_reset_quirk {static const struct vi_reset_quirk vi_reset_quirks[] = { {0x67ef ,PCI_VENDOR_ID_APPLE ,0x0190 ,0xe3 },/* Radeon Pro 555X */ {0x67ef ,PCI_VENDOR_ID_APPLE ,0x018f ,0xc2 },/* Radeon Pro 560X */ + {0x67ef ,PCI_VENDOR_ID_APPLE ,0x017a ,0xc7 },/* Radeon Pro 555 */ };static bool vi_need_reset_on_init (struct amdgpu_device *adev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 303/571 drm/amdgpu: fix for coding style issues
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijendar Mukunda <[email protected]>
[ Upstream commit 604d3a3f0dca0ef0ab0322f5e7af8c70c5ddb6d4 ]
Fixed below checkpatch warnings and errors
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:131: CHECK: Comparison to NULL could be written "apd" drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:150: CHECK: Comparison to NULL could be written "apd" drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:196: CHECK: Prefer kernel type 'u64' over 'uint64_t' drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:224: CHECK: Please don't use multiple blank lines drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:226: CHECK: Comparison to NULL could be written "!adev->acp.acp_genpd" drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:233: CHECK: Please don't use multiple blank lines drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:239: CHECK: Alignment should match open parenthesis drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:241: CHECK: Comparison to NULL could be written "!adev->acp.acp_cell" drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:247: CHECK: Comparison to NULL could be written "!adev->acp.acp_res" drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:253: CHECK: Comparison to NULL could be written "!i2s_pdata" drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:350: CHECK: Alignment should match open parenthesis drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:550: ERROR: that open brace { should be on the previous line
Stable-dep-of: f0013046151b ("drm/amdgpu: fix ACP MFD device leak on init failure")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 35 +++++++++---------------- 1 file changed, 12 insertions(+), 23 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +12 -23
@@ -128,16 +128,14 @@ static int acp_poweroff(struct generic_pm_domain *genpd)struct amdgpu_device *adev; apd = container_of(genpd, struct acp_pm_domain, gpd); -if (apd !=NULL ) { - adev = apd->adev; + adev = apd->adev;/* call smu to POWER GATE ACP block * smu will * 1. turn off the acp clock * 2. power off the acp tiles * 3. check and enter ulv state */ -amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , true); - } +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , true);return 0 ; }
@@ -147,16 +145,14 @@ static int acp_poweron(struct generic_pm_domain *genpd)struct amdgpu_device *adev; apd = container_of(genpd, struct acp_pm_domain, gpd); -if (apd !=NULL ) { - adev = apd->adev; + adev = apd->adev;/* call smu to UNGATE ACP block * smu will * 1. exit ulv * 2. turn on acp clock * 3. power on acp tiles */ -amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , false); - } +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , false);return 0 ; }
@@ -193,7 +189,7 @@ static int acp_genpd_remove_device(struct device *dev, void *data)static int acp_hw_init (void *handle) {int r; -uint64_t acp_base; +u64 acp_base;u32 val =0 ;u32 count =0 ;struct i2s_platform_data *i2s_pdata =NULL ;
@@ -220,37 +216,32 @@ static int acp_hw_init(void *handle)return -EINVAL ; acp_base = adev->rmmio_base; - - adev->acp.acp_genpd =kzalloc (sizeof (struct acp_pm_domain ),GFP_KERNEL ); -if (adev->acp.acp_genpd ==NULL ) +if (!adev->acp.acp_genpd)return -ENOMEM ; adev->acp.acp_genpd->gpd.name ="ACP_AUDIO" ; adev->acp.acp_genpd->gpd.power_off = acp_poweroff; adev->acp.acp_genpd->gpd.power_on = acp_poweron; - - adev->acp.acp_genpd->adev = adev;pm_genpd_init (&adev->acp.acp_genpd->gpd,NULL , false); - adev->acp.acp_cell =kcalloc (ACP_DEVS ,sizeof (struct mfd_cell ), -GFP_KERNEL ); + adev->acp.acp_cell =kcalloc (ACP_DEVS ,sizeof (struct mfd_cell ),GFP_KERNEL ); -if (adev->acp.acp_cell ==NULL ) { +if (!adev->acp.acp_cell) { r = -ENOMEM ; goto failure; } adev->acp.acp_res =kcalloc (5 ,sizeof (struct resource ),GFP_KERNEL ); -if (adev->acp.acp_res ==NULL ) { +if (!adev->acp.acp_res) { r = -ENOMEM ; goto failure; } i2s_pdata =kcalloc (3 ,sizeof (struct i2s_platform_data ),GFP_KERNEL ); -if (i2s_pdata ==NULL ) { +if (!i2s_pdata) { r = -ENOMEM ; goto failure; }
@@ -346,8 +337,7 @@ static int acp_hw_init(void *handle) adev->acp.acp_cell[3 ].platform_data = &i2s_pdata[2 ]; adev->acp.acp_cell[3 ].pdata_size =sizeof (struct i2s_platform_data ); - r =mfd_add_hotplug_devices (adev->acp.parent, adev->acp.acp_cell, -ACP_DEVS ); + r =mfd_add_hotplug_devices (adev->acp.parent, adev->acp.acp_cell,ACP_DEVS );if (r) goto failure;
@@ -548,8 +538,7 @@ static const struct amd_ip_funcs acp_ip_funcs = { .set_powergating_state = acp_set_powergating_state, }; -const struct amdgpu_ip_block_version acp_ip_block = -{ +const struct amdgpu_ip_block_version acp_ip_block = { .type =AMD_IP_BLOCK_TYPE_ACP , .major =2 , .minor =2 ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 304/571 drm/amdgpu: fix ACP MFD device leak on init failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit f0013046151b7467e62c471c1c83d63ea255799c ]
acp_hw_init() registers ACP child devices with mfd_add_devices() before attaching them to the ACP power domain and initializing the hardware.
If attaching a child to the power domain fails, or if the ACP reset or clock enable operation times out, the failure path frees only the source cell, resource, and platform-data allocations. The child platform devices already registered by mfd_add_devices() remain registered and are never released.
Remove the children from the power domain and unregister the MFD devices on failures that occur after mfd_add_devices() succeeds. Keep mfd_add_devices() failures on the existing cleanup path since the MFD core already rolls back partially registered children itself.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +8 -3
@@ -344,7 +344,7 @@ static int acp_hw_init(void *handle) r =device_for_each_child (adev->acp.parent, &adev->acp.acp_genpd->gpd, acp_genpd_add_device);if (r) - goto failure; + goto failure_remove_mfd;/* Assert Soft reset of ACP */ val =cgs_read_register (adev->acp.cgs_device, mmACP_SOFT_RESET);
@@ -361,7 +361,7 @@ static int acp_hw_init(void *handle)if (--count ==0 ) {dev_err (&adev->pdev->dev,"Failed to reset ACP\n" ); r = -ETIMEDOUT ; - goto failure; + goto failure_remove_mfd; }udelay (100 ); }
@@ -379,7 +379,7 @@ static int acp_hw_init(void *handle)if (--count ==0 ) {dev_err (&adev->pdev->dev,"Failed to reset ACP\n" ); r = -ETIMEDOUT ; - goto failure; + goto failure_remove_mfd; }udelay (100 ); }
@@ -389,6 +389,11 @@ static int acp_hw_init(void *handle)cgs_write_register (adev->acp.cgs_device, mmACP_SOFT_RESET, val);return 0 ; +failure_remove_mfd: +device_for_each_child (adev->acp.parent,NULL , + acp_genpd_remove_device); +mfd_remove_devices (adev->acp.parent); + failure:kfree (i2s_pdata);kfree (adev->acp.acp_res);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 305/571 drm/amdgpu/gfx6: fix firmware leak on teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willian Oliveira <[email protected]>
[ Upstream commit cc172e177795c5f87bc2d71768d077e1c10633e8 ]
The firmware requested in gfx_v6_0_init_microcode() is not released when the GFX block is torn down, leaking the firmware resources.
Add gfx_v6_0_free_microcode() and call it from gfx_v6_0_sw_fini() to release the PFP, ME, CE and RLC firmware.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +9 -0
@@ -3222,6 +3222,15 @@ static int gfx_v6_0_sw_fini(void *handle)amdgpu_gfx_rlc_fini (adev); +release_firmware (adev->gfx.pfp_fw); + adev->gfx.pfp_fw =NULL ; +release_firmware (adev->gfx.me_fw); + adev->gfx.me_fw =NULL ; +release_firmware (adev->gfx.ce_fw); + adev->gfx.ce_fw =NULL ; +release_firmware (adev->gfx.rlc_fw); + adev->gfx.rlc_fw =NULL ; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 306/571 usb: octeon-hcd: fix the FIFO-flush timeout computation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit 4c7a1b9f1f1979f2b3b69428ada12680695159c2 ]
cvmx_wait_tx_rx() computes its 100us deadline from (u64)octeon_get_clock_rate - the address of the function, not its return value; the parentheses have been missing since the CVMX_WAIT_FOR_FIELD32 macro became a function. The cast makes it compile silently, and the resulting deadline is effectively infinite.
On a healthy controller the flush bit clears on the first read and nothing is noticed. On a controller whose PHY did not come up (for example when the reference-clock configuration is wrong for the board), txfflsh/rxfflsh never clear and probe spins forever in __delay() - observed as a hard hang with a soft-lockup splat on a CN5020 board, where the board watchdog then resets the system with no console output.
Call the function, restoring the 100us timeout the code always intended.
--- drivers/staging/octeon-usb/octeon-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/octeon-usb/octeon-hcd.c +1 -1
@@ -578,7 +578,7 @@ static int cvmx_wait_tx_rx(struct octeon_hcd *usb, int fflsh_type)int result;u64 address =CVMX_USBCX_GRSTCTL (usb->index);u64 done =cvmx_get_cycle () +100 * - (u64 )octeon_get_clock_rate /1000000 ; + (u64 )octeon_get_clock_rate () /1000000 ;union cvmx_usbcx_grstctl c;while (1 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 307/571 usb: ohci-spear: Remove unnecessary NULL check before clk_disable_unprepare()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit a891b9aebcc7406fe2f439d184bac3948fb08645 ]
clk_disable_unprepare() already checks NULL by using IS_ERR_OR_NULL. Remove unneeded NULL check for clk here.
Stable-dep-of: b1b0f8bdbbc8 ("usb: ohci-spear: disable controller wakeup on removal")
--- drivers/usb/host/ohci-spear.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/ohci-spear.c +1 -2
@@ -105,8 +105,7 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev)struct spear_ohci *sohci_p =to_spear_ohci (hcd);usb_remove_hcd (hcd); -if (sohci_p->clk) -clk_disable_unprepare (sohci_p->clk); +clk_disable_unprepare (sohci_p->clk);usb_put_hcd (hcd);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 308/571 usb: ohci-spear: disable controller wakeup on removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit b1b0f8bdbbc891a4ee7f3b1a878c633e02b7bbeb ]
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind.
Disable controller wakeup after removing the HCD.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/host/ohci-spear.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/ohci-spear.c +1 -0
@@ -105,6 +105,7 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev)struct spear_ohci *sohci_p =to_spear_ohci (hcd);usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller);clk_disable_unprepare (sohci_p->clk);usb_put_hcd (hcd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 309/571 USB: dwc2: shut down wakeup timer before freeing HCD state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit fd772af9512cdecb83de34a461801533828e77fd ]
dwc2_wakeup_detected() accesses the DWC2 host state and can rearm the wakeup timer. dwc2_hcd_free() currently deletes the timer only after freeing host-owned state, and timer_delete() does not synchronize a callback or prevent it from being queued again.
Stop and shut down the timer in dwc2_hcd_release(), before the HCD resources are freed. This covers both the HCD initialization error path and normal HCD removal.
--- drivers/usb/dwc2/hcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/dwc2/hcd.c +1 -2
@@ -5115,14 +5115,13 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) }cancel_work_sync (&hsotg->phy_reset_work); - -del_timer (&hsotg->wkp_timer); }static void dwc2_hcd_release (struct dwc2_hsotg *hsotg) {/* Turn off all host-specific interrupts */ dwc2_disable_host_interrupts (hsotg); +timer_shutdown_sync (&hsotg->wkp_timer);dwc2_hcd_free (hsotg); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 310/571 usb: typec: ucsi: acpi: Assume UCSI 1.2 on Acer Nitro ANV15-41
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pannarat Wiriyaarritham <[email protected]>
[ Upstream commit 8c51ea651d043c786c37668c51624bd6b338a0ef ]
The Acer Nitro ANV15-41 exposes a functional UCSI ACPI PPM but reports a UCSI VERSION value of zero.
ucsi_register() rejects a zero version with -ENODEV, leaving the system without registered USB Type-C connectors.
The PPM works correctly when using the UCSI 1.2 layout. With UCSI 1.2 assumed, both Type-C connectors register correctly and USB Power Delivery negotiation works.
Add a DMI-specific UCSI operation for the Acer Nitro ANV15-41 that substitutes UCSI 1.2 only when firmware reports a zero version. Preserve any valid non-zero firmware version.
Tested on an Acer Nitro ANV15-41 with BIOS V1.51.
--- drivers/usb/typec/ucsi/ucsi_acpi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/usb/typec/ucsi/ucsi_acpi.c +18 -0
@@ -9,6 +9,7 @@#include <linux/platform_device.h> #include <linux/module.h> #include <linux/acpi.h> +#include <linux/dmi.h> #include "ucsi.h"
@@ -25,6 +26,16 @@ struct ucsi_acpi {guid_t guid; }; +static const struct dmi_system_id ucsi_acpi_quirks[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Nitro ANV15-41" ), + }, + }, + { } +}; +static int ucsi_acpi_dsm (struct ucsi_acpi *ua,int func) {union acpi_object *obj;
@@ -45,6 +56,7 @@ static int ucsi_acpi_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_len) {struct ucsi_acpi *ua =ucsi_get_drvdata (ucsi); +u16 *version = val;int ret; ret =ucsi_acpi_dsm (ua,UCSI_DSM_FUNC_READ );
@@ -53,6 +65,12 @@ static int ucsi_acpi_read(struct ucsi *ucsi, unsigned int offset,memcpy (val, (const void __force *)(ua->base + offset), val_len); +if (offset ==UCSI_VERSION && val_len ==sizeof (*version) && !*version && +dmi_check_system (ucsi_acpi_quirks)) { +dev_warn (ua->dev,"UCSI version is zero, assuming 1.2\n" ); + *version =0x0120 ; + } +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 311/571 tty: tty_port: restore TTY_IO_ERROR on activation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 56964f6a31238fb41d5830bb42520c5b10ff7d8f ]
Make sure to restore the TTY_IO_ERROR flag if activation fails to prevent I/O attempts on a port that is gone or powered down.
This specifically avoids issues like kernel panic due to unclocked accesses or NULL-pointer dereferences when accessing powered down or deregistered ports when a TTY ioctl races with hangup and open.
Note that the flag is set again in tty_port_close() but not restoring it on activation failure leaves a window where drivers fail to handle the ioctl-hangup race.
--- drivers/tty/tty_port.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/tty_port.c +1 -0
@@ -694,6 +694,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,int retval = port->ops->activate (port, tty);if (retval) { +set_bit (TTY_IO_ERROR , &tty->flags);mutex_unlock (&port->mutex);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 312/571 tty: reformat kernel-doc in tty_io.c
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby <[email protected]>
[ Upstream commit 796a75a98762f14006d2f941163b589f7ebcdf87 ]
Kernel-doc is a bit strict about some formatting. So fix these:
1) When there is a tab in comments, it thinks the line is a continuation one. So the description of the functions end up as descriptions of the last parameter described. Remove the tabs.
2) Remove newlines before parameters description and after the comments. This was not wrong per se, only inconsistent with the rest of the file.
3) Add periods to the end of sentences where appropriate.
4) Add "()" to function names and "%" to constants, so that they are properly highlighted.
By the above, this patch also unifies these docs with the other kernel-doc's in this file.
Stable-dep-of: 845a2737e0f5 ("tty: abort break signalling on hangup")
--- drivers/tty/tty_io.c | 871 +++++++++++++++++++++---------------------- 1 file changed, 419 insertions(+), 452 deletions(-)
drivers/tty/tty_io.c +419 -452
@@ -158,14 +158,13 @@ static int tty_fasync(int fd, struct file *filp, int on);static void release_tty (struct tty_struct *tty,int idx);/** -* free_tty_struct - free a disused tty -* @tty: tty struct to free +* free_tty_struct - free a disused tty +* @tty: tty struct to free * -* Free the write buffers, tty queue and tty memory itself. +* Free the write buffers, tty queue and tty memory itself. * -* Locking: none. Must be called after tty is definitely unused +* Locking: none. Must be called after tty is definitely unused */ -static void free_tty_struct (struct tty_struct *tty) {tty_ldisc_deinit (tty);
@@ -206,8 +205,9 @@ void tty_add_file(struct tty_struct *tty, struct file *file)spin_unlock (&tty->files_lock); } -/* +/** * tty_free_file - free file->private_data +* @file: to free private_data of * * This shall be used only for fail path handling when tty_add_file was not * called yet.
@@ -233,15 +233,14 @@ static void tty_del_file(struct file *file) }/** -* tty_name - return tty naming -* @tty: tty structure +* tty_name - return tty naming +* @tty: tty structure * -* Convert a tty structure into a name. The name reflects the kernel -* naming policy and if udev is in use may not reflect user space +* Convert a tty structure into a name. The name reflects the kernel naming +* policy and if udev is in use may not reflect user space * -* Locking: none +* Locking: none */ -const char *tty_name (const struct tty_struct *tty) {if (!tty)/* Hmm. NULL pointer. That's fun. */
@@ -303,16 +302,15 @@ static int check_tty_count(struct tty_struct *tty, const char *routine) }/** -* get_tty_driver - find device of a tty -* @device: device identifier -* @index: returns the index of the tty +* get_tty_driver - find device of a tty +* @device: device identifier +* @index: returns the index of the tty * -* This routine returns a tty driver structure, given a device number -* and also passes back the index number. +* This routine returns a tty driver structure, given a device number and also +* passes back the index number. * -* Locking: caller must hold tty_mutex +* Locking: caller must hold tty_mutex */ -static struct tty_driver *get_tty_driver (dev_t device,int *index) {struct tty_driver *p;
@@ -329,17 +327,17 @@ static struct tty_driver *get_tty_driver(dev_t device, int *index) }/** -* tty_dev_name_to_number - return dev_t for device name -* @name: user space name of device under /dev -* @number: pointer to dev_t that this function will populate +* tty_dev_name_to_number - return dev_t for device name +* @name: user space name of device under /dev +* @number: pointer to dev_t that this function will populate * -* This function converts device names like ttyS0 or ttyUSB1 into dev_t -* like (4, 64) or (188, 1). If no corresponding driver is registered then -* the function returns -ENODEV. +* This function converts device names like ttyS0 or ttyUSB1 into dev_t like +* (4, 64) or (188, 1). If no corresponding driver is registered then the +* function returns -%ENODEV. * -* Locking: this acquires tty_mutex to protect the tty_drivers list from -* being modified while we are traversing it, and makes sure to -* release it before exiting. +* Locking: this acquires tty_mutex to protect the tty_drivers list from +* being modified while we are traversing it, and makes sure to +* release it before exiting. */ int tty_dev_name_to_number (const char *name,dev_t *number) {
@@ -381,13 +379,12 @@ EXPORT_SYMBOL_GPL(tty_dev_name_to_number);#ifdef CONFIG_CONSOLE_POLL /** -* tty_find_polling_driver - find device of a polled tty -* @name: name string to match -* @line: pointer to resulting tty line nr +* tty_find_polling_driver - find device of a polled tty +* @name: name string to match +* @line: pointer to resulting tty line nr * -* This routine returns a tty driver structure, given a name -* and the condition that the tty driver is capable of polled -* operation. +* This routine returns a tty driver structure, given a name and the condition +* that the tty driver is capable of polled operation. */ struct tty_driver *tty_find_polling_driver (char *name,int *line) {
@@ -515,14 +512,13 @@ static DEFINE_SPINLOCK(redirect_lock);static struct file *redirect;/** -* tty_wakeup - request more data -* @tty: terminal +* tty_wakeup - request more data +* @tty: terminal * -* Internal and external helper for wakeups of tty. This function -* informs the line discipline if present that the driver is ready -* to receive more output data. +* Internal and external helper for wakeups of tty. This function informs the +* line discipline if present that the driver is ready to receive more output +* data. */ -void tty_wakeup (struct tty_struct *tty) {struct tty_ldisc *ld;
@@ -540,11 +536,11 @@ void tty_wakeup(struct tty_struct *tty)EXPORT_SYMBOL_GPL (tty_wakeup);/** -* tty_release_redirect - Release a redirect on a pty if present -* @tty: tty device +* tty_release_redirect - Release a redirect on a pty if present +* @tty: tty device * -* This is available to the pty code so if the master closes, if the -* slave is a redirect it can release the redirect. +* This is available to the pty code so if the master closes, if the slave is a +* redirect it can release the redirect. */ static struct file *tty_release_redirect (struct tty_struct *tty) {
@@ -561,27 +557,29 @@ static struct file *tty_release_redirect(struct tty_struct *tty) }/** -* __tty_hangup - actual handler for hangup events -* @tty: tty device -* @exit_session: if non-zero, signal all foreground group processes -* -* This can be called by a "kworker" kernel thread. That is process -* synchronous but doesn't hold any locks, so we need to make sure we -* have the appropriate locks for what we're doing. -* -* The hangup event clears any pending redirections onto the hung up -* device. It ensures future writes will error and it does the needed -* line discipline hangup and signal delivery. The tty object itself -* remains intact. -* -* Locking: -* BTM -* redirect lock for undoing redirection -* file list lock for manipulating list of ttys -* tty_ldiscs_lock from called functions -* termios_rwsem resetting termios data -* tasklist_lock to walk task list for hangup event -* ->siglock to protect ->signal/->sighand +* __tty_hangup - actual handler for hangup events +* @tty: tty device +* @exit_session: if non-zero, signal all foreground group processes +* +* This can be called by a "kworker" kernel thread. That is process synchronous +* but doesn't hold any locks, so we need to make sure we have the appropriate +* locks for what we're doing. +* +* The hangup event clears any pending redirections onto the hung up device. It +* ensures future writes will error and it does the needed line discipline +* hangup and signal delivery. The tty object itself remains intact. +* +* Locking: +* * BTM +* +* * redirect lock for undoing redirection +* * file list lock for manipulating list of ttys +* * tty_ldiscs_lock from called functions +* * termios_rwsem resetting termios data +* * tasklist_lock to walk task list for hangup event +* +* * ->siglock to protect ->signal/->sighand +* */ static void __tty_hangup (struct tty_struct *tty,int exit_session) {
@@ -682,13 +680,12 @@ static void do_tty_hangup(struct work_struct *work) }/** -* tty_hangup - trigger a hangup event -* @tty: tty to hangup +* tty_hangup - trigger a hangup event +* @tty: tty to hangup * -* A carrier loss (virtual or otherwise) has occurred on this like -* schedule a hangup sequence to run after this event. +* A carrier loss (virtual or otherwise) has occurred on @tty. Schedule a +* hangup sequence to run after this event. */ -void tty_hangup (struct tty_struct *tty) {tty_debug_hangup (tty,"hangup\n" );
@@ -697,14 +694,13 @@ void tty_hangup(struct tty_struct *tty)EXPORT_SYMBOL (tty_hangup);/** -* tty_vhangup - process vhangup -* @tty: tty to hangup +* tty_vhangup - process vhangup +* @tty: tty to hangup * -* The user has asked via system call for the terminal to be hung up. -* We do this synchronously so that when the syscall returns the process -* is complete. That guarantee is necessary for security reasons. +* The user has asked via system call for the terminal to be hung up. We do +* this synchronously so that when the syscall returns the process is complete. +* That guarantee is necessary for security reasons. */ -void tty_vhangup (struct tty_struct *tty) {tty_debug_hangup (tty,"vhangup\n" );
@@ -714,11 +710,10 @@ EXPORT_SYMBOL(tty_vhangup);/** -* tty_vhangup_self - process vhangup for own ctty +* tty_vhangup_self - process vhangup for own ctty * -* Perform a vhangup on the current controlling tty +* Perform a vhangup on the current controlling tty */ -void tty_vhangup_self (void ) {struct tty_struct *tty;
@@ -731,16 +726,15 @@ void tty_vhangup_self(void) }/** -* tty_vhangup_session - hangup session leader exit -* @tty: tty to hangup +* tty_vhangup_session - hangup session leader exit +* @tty: tty to hangup * -* The session leader is exiting and hanging up its controlling terminal. -* Every process in the foreground process group is signalled SIGHUP. +* The session leader is exiting and hanging up its controlling terminal. +* Every process in the foreground process group is signalled %SIGHUP. * -* We do this synchronously so that when the syscall returns the process -* is complete. That guarantee is necessary for security reasons. +* We do this synchronously so that when the syscall returns the process is +* complete. That guarantee is necessary for security reasons. */ -void tty_vhangup_session (struct tty_struct *tty) {tty_debug_hangup (tty,"session hangup\n" );
@@ -748,13 +742,11 @@ void tty_vhangup_session(struct tty_struct *tty) }/** -* tty_hung_up_p - was tty hung up -* @filp: file pointer of tty +* tty_hung_up_p - was tty hung up +* @filp: file pointer of tty * -* Return true if the tty has been subject to a vhangup or a carrier -* loss +* Return: true if the tty has been subject to a vhangup or a carrier loss */ -int tty_hung_up_p (struct file *filp) {return (filp && filp->f_op == &hung_up_tty_fops);
@@ -771,20 +763,18 @@ void __stop_tty(struct tty_struct *tty) }/** -* stop_tty - propagate flow control -* @tty: tty to stop +* stop_tty - propagate flow control +* @tty: tty to stop * -* Perform flow control to the driver. May be called -* on an already stopped device and will not re-call the driver -* method. +* Perform flow control to the driver. May be called on an already stopped +* device and will not re-call the &tty_driver->stop() method. * -* This functionality is used by both the line disciplines for -* halting incoming flow and by the driver. It may therefore be -* called from any context, may be under the tty atomic_write_lock -* but not always. +* This functionality is used by both the line disciplines for halting incoming +* flow and by the driver. It may therefore be called from any context, may be +* under the tty %atomic_write_lock but not always. * -* Locking: -* flow.lock +* Locking: +* flow.lock */ void stop_tty (struct tty_struct *tty) {
@@ -807,15 +797,15 @@ void __start_tty(struct tty_struct *tty) }/** -* start_tty - propagate flow control -* @tty: tty to start +* start_tty - propagate flow control +* @tty: tty to start * -* Start a tty that has been stopped if at all possible. If this -* tty was previous stopped and is now being started, the driver -* start method is invoked and the line discipline woken. +* Start a tty that has been stopped if at all possible. If @tty was previously +* stopped and is now being started, the &tty_driver->start() method is invoked +* and the line discipline woken. * -* Locking: -* flow.lock +* Locking: +* flow.lock */ void start_tty (struct tty_struct *tty) {
@@ -908,18 +898,17 @@ static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty,/** -* tty_read - read method for tty device files -* @iocb: kernel I/O control block -* @to: destination for the data read +* tty_read - read method for tty device files +* @iocb: kernel I/O control block +* @to: destination for the data read * -* Perform the read system call function on this terminal device. Checks -* for hung up devices before calling the line discipline method. +* Perform the read system call function on this terminal device. Checks +* for hung up devices before calling the line discipline method. * -* Locking: -* Locks the line discipline internally while needed. Multiple -* read calls may be outstanding in parallel. +* Locking: +* Locks the line discipline internally while needed. Multiple read calls +* may be outstanding in parallel. */ -static ssize_t tty_read (struct kiocb *iocb,struct iov_iter *to) {int i;
@@ -1069,13 +1058,12 @@ static inline ssize_t do_tty_write(* @tty: the destination tty_struct * @msg: the message to write * -* This is used for messages that need to be redirected to a specific tty. -* We don't put it into the syslog queue right now maybe in the future if -* really needed. +* This is used for messages that need to be redirected to a specific tty. We +* don't put it into the syslog queue right now maybe in the future if really +* needed. * * We must still hold the BTM and test the CLOSING flag for the moment. */ -void tty_write_message (struct tty_struct *tty,char *msg) {if (tty) {
@@ -1113,18 +1101,18 @@ static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_ }/** -* tty_write - write method for tty device file -* @iocb: kernel I/O control block -* @from: iov_iter with data to write +* tty_write - write method for tty device file +* @iocb: kernel I/O control block +* @from: iov_iter with data to write * -* Write data to a tty device via the line discipline. +* Write data to a tty device via the line discipline. * -* Locking: -* Locks the line discipline as required -* Writes to the tty driver are serialized by the atomic_write_lock -* and are then processed in chunks to the device. The line -* discipline write method will not be invoked in parallel for -* each device. +* Locking: +* Locks the line discipline as required +* Writes to the tty driver are serialized by the atomic_write_lock +* and are then processed in chunks to the device. The line +* discipline write method will not be invoked in parallel for +* each device. */ static ssize_t tty_write (struct kiocb *iocb,struct iov_iter *from) {
@@ -1154,14 +1142,15 @@ ssize_t redirected_tty_write(struct kiocb *iocb, struct iov_iter *iter)return tty_write (iocb, iter); } -/* -* tty_send_xchar - send priority character +/** +* tty_send_xchar - send priority character +* @tty: the tty to send to +* @ch: xchar to send * -* Send a high priority character to the tty even if stopped +* Send a high priority character to the tty even if stopped. * -* Locking: none for xchar method, write ordering for write method. +* Locking: none for xchar method, write ordering for write method. */ -int tty_send_xchar (struct tty_struct *tty,char ch) {bool was_stopped = tty->flow.stopped;
@@ -1188,15 +1177,15 @@ int tty_send_xchar(struct tty_struct *tty, char ch) }/** -* pty_line_name - generate name for a pty -* @driver: the tty driver in use -* @index: the minor number -* @p: output buffer of at least 6 bytes +* pty_line_name - generate name for a pty +* @driver: the tty driver in use +* @index: the minor number +* @p: output buffer of at least 6 bytes * -* Generate a name from a driver reference and write it to the output -* buffer. +* Generate a name from a @driver reference and write it to the output buffer +* @p. * -* Locking: None +* Locking: None */ static void pty_line_name (struct tty_driver *driver,int index,char *p) {
@@ -1209,15 +1198,15 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p) }/** -* tty_line_name - generate name for a tty -* @driver: the tty driver in use -* @index: the minor number -* @p: output buffer of at least 7 bytes +* tty_line_name - generate name for a tty +* @driver: the tty driver in use +* @index: the minor number +* @p: output buffer of at least 7 bytes * -* Generate a name from a driver reference and write it to the output -* buffer. +* Generate a name from a @driver reference and write it to the output buffer +* @p. * -* Locking: None +* Locking: None */ static ssize_t tty_line_name (struct tty_driver *driver,int index,char *p) {
@@ -1229,15 +1218,15 @@ static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p) }/** -* tty_driver_lookup_tty() - find an existing tty, if any -* @driver: the driver for the tty -* @file: file object -* @idx: the minor number +* tty_driver_lookup_tty() - find an existing tty, if any +* @driver: the driver for the tty +* @file: file object +* @idx: the minor number * -* Return the tty, if found. If not found, return NULL or ERR_PTR() if the -* driver lookup() method returns an error. +* Return: the tty, if found. If not found, return %NULL or ERR_PTR() if the +* driver lookup() method returns an error. * -* Locking: tty_mutex must be held. If the tty is found, bump the tty kref. +* Locking: tty_mutex must be held. If the tty is found, bump the tty kref. */ static struct tty_struct *tty_driver_lookup_tty (struct tty_driver *driver,struct file *file,int idx)
@@ -1260,13 +1249,12 @@ static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver, }/** -* tty_init_termios - helper for termios setup -* @tty: the tty to set up +* tty_init_termios - helper for termios setup +* @tty: the tty to set up * -* Initialise the termios structure for this tty. This runs under -* the tty_mutex currently so we can be relaxed about ordering. +* Initialise the termios structure for this tty. This runs under the +* %tty_mutex currently so we can be relaxed about ordering. */ -void tty_init_termios (struct tty_struct *tty) {struct ktermios *tp;
@@ -1300,16 +1288,15 @@ int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)EXPORT_SYMBOL_GPL (tty_standard_install);/** -* tty_driver_install_tty() - install a tty entry in the driver -* @driver: the driver for the tty -* @tty: the tty +* tty_driver_install_tty() - install a tty entry in the driver +* @driver: the driver for the tty +* @tty: the tty * -* Install a tty object into the driver tables. The tty->index field -* will be set by the time this is called. This method is responsible -* for ensuring any need additional structures are allocated and -* configured. +* Install a tty object into the driver tables. The @tty->index field will be +* set by the time this is called. This method is responsible for ensuring any +* need additional structures are allocated and configured. * -* Locking: tty_mutex for now +* Locking: tty_mutex for now */ static int tty_driver_install_tty (struct tty_driver *driver,struct tty_struct *tty)
@@ -1319,14 +1306,14 @@ static int tty_driver_install_tty(struct tty_driver *driver, }/** -* tty_driver_remove_tty() - remove a tty from the driver tables -* @driver: the driver for the tty -* @tty: tty to remove +* tty_driver_remove_tty() - remove a tty from the driver tables +* @driver: the driver for the tty +* @tty: tty to remove * -* Remvoe a tty object from the driver tables. The tty->index field -* will be set by the time this is called. +* Remove a tty object from the driver tables. The tty->index field will be set +* by the time this is called. * -* Locking: tty_mutex for now +* Locking: tty_mutex for now */ static void tty_driver_remove_tty (struct tty_driver *driver,struct tty_struct *tty) {
@@ -1337,13 +1324,13 @@ static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct * }/** -* tty_reopen() - fast re-open of an open tty -* @tty: the tty to open +* tty_reopen() - fast re-open of an open tty +* @tty: the tty to open * -* Return 0 on success, -errno on error. -* Re-opens on master ptys are not allowed and return -EIO. +* Re-opens on master ptys are not allowed and return -%EIO. * -* Locking: Caller must hold tty_lock +* Locking: Caller must hold tty_lock +* Return: 0 on success, -errno on error. */ static int tty_reopen (struct tty_struct *tty) {
@@ -1381,30 +1368,28 @@ static int tty_reopen(struct tty_struct *tty) }/** -* tty_init_dev - initialise a tty device -* @driver: tty driver we are opening a device on -* @idx: device index +* tty_init_dev - initialise a tty device +* @driver: tty driver we are opening a device on +* @idx: device index * -* Prepare a tty device. This may not be a "new" clean device but -* could also be an active device. The pty drivers require special -* handling because of this. +* Prepare a tty device. This may not be a "new" clean device but could also be +* an active device. The pty drivers require special handling because of this. * -* Locking: -* The function is called under the tty_mutex, which -* protects us from the tty struct or driver itself going away. +* Locking: +* The function is called under the tty_mutex, which protects us from the +* tty struct or driver itself going away. * -* On exit the tty device has the line discipline attached and -* a reference count of 1. If a pair was created for pty/tty use -* and the other was a pty master then it too has a reference count of 1. +* On exit the tty device has the line discipline attached and a reference +* count of 1. If a pair was created for pty/tty use and the other was a pty +* master then it too has a reference count of 1. * -* WSH 06/09/97: Rewritten to remove races and properly clean up after a -* failed open. The new code protects the open with a mutex, so it's -* really quite straightforward. The mutex locking can probably be -* relaxed for the (most common) case of reopening a tty. +* WSH 06/09/97: Rewritten to remove races and properly clean up after a failed +* open. The new code protects the open with a mutex, so it's really quite +* straightforward. The mutex locking can probably be relaxed for the (most +* common) case of reopening a tty. * -* Return: returned tty structure +* Return: new tty structure */ -struct tty_struct *tty_init_dev (struct tty_driver *driver,int idx) {struct tty_struct *tty;
@@ -1505,10 +1490,10 @@ void tty_save_termios(struct tty_struct *tty)EXPORT_SYMBOL_GPL (tty_save_termios);/** -* tty_flush_works - flush all works of a tty/pty pair -* @tty: tty device to flush works for (or either end of a pty pair) +* tty_flush_works - flush all works of a tty/pty pair +* @tty: tty device to flush works for (or either end of a pty pair) * -* Sync flush all works belonging to @tty (and the 'other' tty). +* Sync flush all works belonging to @tty (and the 'other' tty). */ static void tty_flush_works (struct tty_struct *tty) {
@@ -1521,19 +1506,19 @@ static void tty_flush_works(struct tty_struct *tty) }/** -* release_one_tty - release tty structure memory -* @work: work of tty we are obliterating +* release_one_tty - release tty structure memory +* @work: work of tty we are obliterating * -* Releases memory associated with a tty structure, and clears out the -* driver table slots. This function is called when a device is no longer -* in use. It also gets called when setup of a device fails. +* Releases memory associated with a tty structure, and clears out the +* driver table slots. This function is called when a device is no longer +* in use. It also gets called when setup of a device fails. * -* Locking: -* takes the file list lock internally when working on the list -* of ttys that the driver keeps. +* Locking: +* takes the file list lock internally when working on the list of ttys +* that the driver keeps. * -* This method gets called from a work queue so that the driver private -* cleanup ops can sleep (needed for USB at least) +* This method gets called from a work queue so that the driver private +* cleanup ops can sleep (needed for USB at least) */ static void release_one_tty (struct work_struct *work) {
@@ -1570,13 +1555,12 @@ static void queue_release_one_tty(struct kref *kref) }/** -* tty_kref_put - release a tty kref -* @tty: tty device +* tty_kref_put - release a tty kref +* @tty: tty device * -* Release a reference to a tty device and if need be let the kref -* layer destruct the object for us +* Release a reference to the @tty device and if need be let the kref layer +* destruct the object for us. */ -void tty_kref_put (struct tty_struct *tty) {if (tty)
@@ -1585,18 +1569,17 @@ void tty_kref_put(struct tty_struct *tty)EXPORT_SYMBOL (tty_kref_put);/** -* release_tty - release tty structure memory -* @tty: tty device release -* @idx: index of the tty device release -* -* Release both @tty and a possible linked partner (think pty pair), -* and decrement the refcount of the backing module. +* release_tty - release tty structure memory +* @tty: tty device release +* @idx: index of the tty device release * -* Locking: -* tty_mutex -* takes the file list lock internally when working on the list -* of ttys that the driver keeps. +* Release both @tty and a possible linked partner (think pty pair), +* and decrement the refcount of the backing module. * +* Locking: +* tty_mutex +* takes the file list lock internally when working on the list of ttys +* that the driver keeps. */ static void release_tty (struct tty_struct *tty,int idx) {
@@ -1621,12 +1604,12 @@ static void release_tty(struct tty_struct *tty, int idx) }/** -* tty_release_checks - check a tty before real release -* @tty: tty to check -* @idx: index of the tty +* tty_release_checks - check a tty before real release +* @tty: tty to check +* @idx: index of the tty * -* Performs some paranoid checking before true release of the @tty. -* This is a no-op unless TTY_PARANOIA_CHECK is defined. +* Performs some paranoid checking before true release of the @tty. This is a +* no-op unless %TTY_PARANOIA_CHECK is defined. */ static int tty_release_checks (struct tty_struct *tty,int idx) {
@@ -1663,12 +1646,12 @@ static int tty_release_checks(struct tty_struct *tty, int idx) }/** -* tty_kclose - closes tty opened by tty_kopen -* @tty: tty device +* tty_kclose - closes tty opened by tty_kopen +* @tty: tty device * -* Performs the final steps to release and free a tty device. It is the -* same as tty_release_struct except that it also resets TTY_PORT_KOPENED -* flag on tty->port. +* Performs the final steps to release and free a tty device. It is the same as +* tty_release_struct() except that it also resets %TTY_PORT_KOPENED flag on +* @tty->port. */ void tty_kclose (struct tty_struct *tty) {
@@ -1693,12 +1676,12 @@ void tty_kclose(struct tty_struct *tty)EXPORT_SYMBOL_GPL (tty_kclose);/** -* tty_release_struct - release a tty struct -* @tty: tty device -* @idx: index of the tty +* tty_release_struct - release a tty struct +* @tty: tty device +* @idx: index of the tty * -* Performs the final steps to release and free a tty device. It is -* roughly the reverse of tty_init_dev. +* Performs the final steps to release and free a tty device. It is roughly the +* reverse of tty_init_dev(). */ void tty_release_struct (struct tty_struct *tty,int idx) {
@@ -1722,24 +1705,23 @@ void tty_release_struct(struct tty_struct *tty, int idx)EXPORT_SYMBOL_GPL (tty_release_struct);/** -* tty_release - vfs callback for close -* @inode: inode of tty -* @filp: file pointer for handle to tty +* tty_release - vfs callback for close +* @inode: inode of tty +* @filp: file pointer for handle to tty * -* Called the last time each file handle is closed that references -* this tty. There may however be several such references. +* Called the last time each file handle is closed that references this tty. +* There may however be several such references. * -* Locking: -* Takes bkl. See tty_release_dev +* Locking: +* Takes BKL. See tty_release_dev(). * -* Even releasing the tty structures is a tricky business.. We have -* to be very careful that the structures are all released at the -* same time, as interrupts might otherwise get the wrong pointers. +* Even releasing the tty structures is a tricky business. We have to be very +* careful that the structures are all released at the same time, as interrupts +* might otherwise get the wrong pointers. * * WSH 09/09/97: rewritten to avoid some nasty race conditions that could * lead to double frees or releasing memory still in use. */ -int tty_release (struct inode *inode,struct file *filp) {struct tty_struct *tty =file_tty (filp);
@@ -1882,15 +1864,15 @@ int tty_release(struct inode *inode, struct file *filp) }/** -* tty_open_current_tty - get locked tty of current task -* @device: device number -* @filp: file pointer to tty -* @return: locked tty of the current task iff @device is /dev/tty +* tty_open_current_tty - get locked tty of current task +* @device: device number +* @filp: file pointer to tty +* @return: locked tty of the current task iff @device is /dev/tty * -* Performs a re-open of the current task's controlling tty. +* Performs a re-open of the current task's controlling tty. * -* We cannot return driver and index like for the other nodes because -* devpts will not work then. It expects inodes to be from devpts FS. +* We cannot return driver and index like for the other nodes because devpts +* will not work then. It expects inodes to be from devpts FS. */ static struct tty_struct *tty_open_current_tty (dev_t device,struct file *filp) {
@@ -1918,16 +1900,17 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp) }/** -* tty_lookup_driver - lookup a tty driver for a given device file -* @device: device number -* @filp: file pointer to tty -* @index: index for the device in the @return driver -* @return: driver for this inode (with increased refcount) +* tty_lookup_driver - lookup a tty driver for a given device file +* @device: device number +* @filp: file pointer to tty +* @index: index for the device in the @return driver * -* If @return is not erroneous, the caller is responsible to decrement the -* refcount by tty_driver_kref_put. +* If returned value is not erroneous, the caller is responsible to decrement +* the refcount by tty_driver_kref_put(). * -* Locking: tty_mutex protects get_tty_driver +* Locking: %tty_mutex protects get_tty_driver() +* +* Return: driver for this inode (with increased refcount) */ static struct tty_driver *tty_lookup_driver (dev_t device,struct file *filp,int *index)
@@ -2003,19 +1986,18 @@ static struct tty_struct *tty_kopen(dev_t device, int shared) }/** -* tty_kopen_exclusive - open a tty device for kernel -* @device: dev_t of device to open +* tty_kopen_exclusive - open a tty device for kernel +* @device: dev_t of device to open * -* Opens tty exclusively for kernel. Performs the driver lookup, -* makes sure it's not already opened and performs the first-time -* tty initialization. +* Opens tty exclusively for kernel. Performs the driver lookup, makes sure +* it's not already opened and performs the first-time tty initialization. * -* Returns the locked initialized &tty_struct +* Claims the global %tty_mutex to serialize: +* * concurrent first-time tty initialization +* * concurrent tty driver removal w/ lookup +* * concurrent tty removal from driver table * -* Claims the global tty_mutex to serialize: -* - concurrent first-time tty initialization -* - concurrent tty driver removal w/ lookup -* - concurrent tty removal from driver table +* Return: the locked initialized &tty_struct */ struct tty_struct *tty_kopen_exclusive (dev_t device) {
@@ -2024,13 +2006,13 @@ struct tty_struct *tty_kopen_exclusive(dev_t device)EXPORT_SYMBOL_GPL (tty_kopen_exclusive);/** -* tty_kopen_shared - open a tty device for shared in-kernel use -* @device: dev_t of device to open +* tty_kopen_shared - open a tty device for shared in-kernel use +* @device: dev_t of device to open * -* Opens an already existing tty for in-kernel use. Compared to -* tty_kopen_exclusive() above it doesn't ensure to be the only user. +* Opens an already existing tty for in-kernel use. Compared to +* tty_kopen_exclusive() above it doesn't ensure to be the only user. * -* Locking is identical to tty_kopen() above. +* Locking: identical to tty_kopen() above. */ struct tty_struct *tty_kopen_shared (dev_t device) {
@@ -2039,19 +2021,20 @@ struct tty_struct *tty_kopen_shared(dev_t device)EXPORT_SYMBOL_GPL (tty_kopen_shared);/** -* tty_open_by_driver - open a tty device -* @device: dev_t of device to open -* @filp: file pointer to tty +* tty_open_by_driver - open a tty device +* @device: dev_t of device to open +* @filp: file pointer to tty +* +* Performs the driver lookup, checks for a reopen, or otherwise performs the +* first-time tty initialization. * -* Performs the driver lookup, checks for a reopen, or otherwise -* performs the first-time tty initialization. * -* Returns the locked initialized or re-opened &tty_struct +* Claims the global tty_mutex to serialize: +* * concurrent first-time tty initialization +* * concurrent tty driver removal w/ lookup +* * concurrent tty removal from driver table * -* Claims the global tty_mutex to serialize: -* - concurrent first-time tty initialization -* - concurrent tty driver removal w/ lookup -* - concurrent tty removal from driver table +* Return: the locked initialized or re-opened &tty_struct */ static struct tty_struct *tty_open_by_driver (dev_t device,struct file *filp)
@@ -2106,29 +2089,28 @@ static struct tty_struct *tty_open_by_driver(dev_t device, }/** -* tty_open - open a tty device -* @inode: inode of device file -* @filp: file pointer to tty +* tty_open - open a tty device +* @inode: inode of device file +* @filp: file pointer to tty * -* tty_open and tty_release keep up the tty count that contains the -* number of opens done on a tty. We cannot use the inode-count, as -* different inodes might point to the same tty. +* tty_open() and tty_release() keep up the tty count that contains the number +* of opens done on a tty. We cannot use the inode-count, as different inodes +* might point to the same tty. * -* Open-counting is needed for pty masters, as well as for keeping -* track of serial lines: DTR is dropped when the last close happens. -* (This is not done solely through tty->count, now. - Ted 1/27/92) +* Open-counting is needed for pty masters, as well as for keeping track of +* serial lines: DTR is dropped when the last close happens. +* (This is not done solely through tty->count, now. - Ted 1/27/92) * -* The termios state of a pty is reset on first open so that -* settings don't persist across reuse. +* The termios state of a pty is reset on the first open so that settings don't +* persist across reuse. * -* Locking: tty_mutex protects tty, tty_lookup_driver and tty_init_dev. -* tty->count should protect the rest. -* ->siglock protects ->signal/->sighand +* Locking: +* * %tty_mutex protects tty, tty_lookup_driver() and tty_init_dev(). +* * @tty->count should protect the rest. +* * ->siglock protects ->signal/->sighand * -* Note: the tty_unlock/lock cases without a ref are only safe due to -* tty_mutex +* Note: the tty_unlock/lock cases without a ref are only safe due to %tty_mutex */ -static int tty_open (struct inode *inode,struct file *filp) {struct tty_struct *tty;
@@ -2200,19 +2182,17 @@ static int tty_open(struct inode *inode, struct file *filp) } -/** -* tty_poll - check tty status -* @filp: file being polled -* @wait: poll wait structures to update +* tty_poll - check tty status +* @filp: file being polled +* @wait: poll wait structures to update * -* Call the line discipline polling method to obtain the poll -* status of the device. +* Call the line discipline polling method to obtain the poll status of the +* device. * -* Locking: locks called line discipline but ldisc poll method -* may be re-entered freely by other callers. +* Locking: locks called line discipline but ldisc poll method may be +* re-entered freely by other callers. */ -static __poll_t tty_poll (struct file *filp,poll_table *wait) {struct tty_struct *tty =file_tty (filp);
@@ -2280,20 +2260,18 @@ static int tty_fasync(int fd, struct file *filp, int on) }/** -* tiocsti - fake input character -* @tty: tty to fake input into -* @p: pointer to character +* tiocsti - fake input character +* @tty: tty to fake input into +* @p: pointer to character * -* Fake input to a tty device. Does the necessary locking and -* input management. +* Fake input to a tty device. Does the necessary locking and input management. * -* FIXME: does not honour flow control ?? +* FIXME: does not honour flow control ?? * -* Locking: -* Called functions take tty_ldiscs_lock -* current->signal->tty check is safe without locks +* Locking: +* * Called functions take tty_ldiscs_lock +* * current->signal->tty check is safe without locks */ -static int tiocsti (struct tty_struct *tty,char __user *p) {char ch, mbz =0 ;
@@ -2316,16 +2294,15 @@ static int tiocsti(struct tty_struct *tty, char __user *p) }/** -* tiocgwinsz - implement window query ioctl -* @tty: tty -* @arg: user buffer for result +* tiocgwinsz - implement window query ioctl +* @tty: tty +* @arg: user buffer for result * -* Copies the kernel idea of the window size into the user buffer. +* Copies the kernel idea of the window size into the user buffer. * -* Locking: tty->winsize_mutex is taken to ensure the winsize data -* is consistent. +* Locking: @tty->winsize_mutex is taken to ensure the winsize data is +* consistent. */ -static int tiocgwinsz (struct tty_struct *tty,struct winsize __user *arg) {int err;
@@ -2338,14 +2315,13 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) }/** -* tty_do_resize - resize event -* @tty: tty being resized -* @ws: new dimensions +* tty_do_resize - resize event +* @tty: tty being resized +* @ws: new dimensions * -* Update the termios variables and send the necessary signals to -* peform a terminal resize correctly +* Update the termios variables and send the necessary signals to peform a +* terminal resize correctly. */ -int tty_do_resize (struct tty_struct *tty,struct winsize *ws) {struct pid *pgrp;
@@ -2369,20 +2345,19 @@ int tty_do_resize(struct tty_struct *tty, struct winsize *ws)EXPORT_SYMBOL (tty_do_resize);/** -* tiocswinsz - implement window size set ioctl -* @tty: tty side of tty -* @arg: user buffer for result +* tiocswinsz - implement window size set ioctl +* @tty: tty side of tty +* @arg: user buffer for result * -* Copies the user idea of the window size to the kernel. Traditionally -* this is just advisory information but for the Linux console it -* actually has driver level meaning and triggers a VC resize. +* Copies the user idea of the window size to the kernel. Traditionally this is +* just advisory information but for the Linux console it actually has driver +* level meaning and triggers a VC resize. * -* Locking: -* Driver dependent. The default do_resize method takes the -* tty termios mutex and ctrl.lock. The console takes its own lock -* then calls into the default method. +* Locking: +* Driver dependent. The default do_resize method takes the tty termios +* mutex and ctrl.lock. The console takes its own lock then calls into the +* default method. */ -static int tiocswinsz (struct tty_struct *tty,struct winsize __user *arg) {struct winsize tmp_ws;
@@ -2397,14 +2372,13 @@ static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg) }/** -* tioccons - allow admin to move logical console -* @file: the file to become console +* tioccons - allow admin to move logical console +* @file: the file to become console * -* Allow the administrator to move the redirected console device +* Allow the administrator to move the redirected console device. * -* Locking: uses redirect_lock to guard the redirect information +* Locking: uses redirect_lock to guard the redirect information */ -static int tioccons (struct file *file) {if (!capable (CAP_SYS_ADMIN ))
@@ -2437,15 +2411,14 @@ static int tioccons(struct file *file) }/** -* tiocsetd - set line discipline -* @tty: tty device -* @p: pointer to user data +* tiocsetd - set line discipline +* @tty: tty device +* @p: pointer to user data * -* Set the line discipline according to user request. +* Set the line discipline according to user request. * -* Locking: see tty_set_ldisc, this function is just a helper +* Locking: see tty_set_ldisc(), this function is just a helper */ -static int tiocsetd (struct tty_struct *tty,int __user *p) {int disc;
@@ -2460,16 +2433,15 @@ static int tiocsetd(struct tty_struct *tty, int __user *p) }/** -* tiocgetd - get line discipline -* @tty: tty device -* @p: pointer to user data +* tiocgetd - get line discipline +* @tty: tty device +* @p: pointer to user data * -* Retrieves the line discipline id directly from the ldisc. +* Retrieves the line discipline id directly from the ldisc. * -* Locking: waits for ldisc reference (in case the line discipline -* is changing or the tty is being hungup) +* Locking: waits for ldisc reference (in case the line discipline is changing +* or the @tty is being hungup) */ -static int tiocgetd (struct tty_struct *tty,int __user *p) {struct tty_ldisc *ld;
@@ -2484,18 +2456,16 @@ static int tiocgetd(struct tty_struct *tty, int __user *p) }/** -* send_break - performed time break -* @tty: device to break on -* @duration: timeout in mS +* send_break - performed time break +* @tty: device to break on +* @duration: timeout in mS * -* Perform a timed break on hardware that lacks its own driver level -* timed break functionality. -* -* Locking: -* atomic_write_lock serializes +* Perform a timed break on hardware that lacks its own driver level timed +* break functionality. * +* Locking: +* @tty->atomic_write_lock serializes */ -static int send_break (struct tty_struct *tty,unsigned int duration) {int retval;
@@ -2527,16 +2497,15 @@ static int send_break(struct tty_struct *tty, unsigned int duration) }/** -* tty_tiocmget - get modem status -* @tty: tty device -* @p: pointer to result +* tty_tiocmget - get modem status +* @tty: tty device +* @p: pointer to result * -* Obtain the modem status bits from the tty driver if the feature -* is supported. Return -ENOTTY if it is not available. +* Obtain the modem status bits from the tty driver if the feature is +* supported. Return -%ENOTTY if it is not available. * -* Locking: none (up to the driver) +* Locking: none (up to the driver) */ -static int tty_tiocmget (struct tty_struct *tty,int __user *p) {int retval = -ENOTTY ;
@@ -2551,17 +2520,16 @@ static int tty_tiocmget(struct tty_struct *tty, int __user *p) }/** -* tty_tiocmset - set modem status -* @tty: tty device -* @cmd: command - clear bits, set bits or set all -* @p: pointer to desired bits +* tty_tiocmset - set modem status +* @tty: tty device +* @cmd: command - clear bits, set bits or set all +* @p: pointer to desired bits * -* Set the modem status bits from the tty driver if the feature -* is supported. Return -ENOTTY if it is not available. +* Set the modem status bits from the tty driver if the feature +* is supported. Return -%ENOTTY if it is not available. * -* Locking: none (up to the driver) +* Locking: none (up to the driver) */ -static int tty_tiocmset (struct tty_struct *tty,unsigned int cmd,unsigned __user *p) {
@@ -2593,13 +2561,13 @@ static int tty_tiocmset(struct tty_struct *tty, unsigned int cmd, }/** -* tty_get_icount - get tty statistics -* @tty: tty device -* @icount: output parameter +* tty_get_icount - get tty statistics +* @tty: tty device +* @icount: output parameter * -* Gets a copy of the tty's icount statistics. +* Gets a copy of the @tty's icount statistics. * -* Locking: none (up to the driver) +* Locking: none (up to the driver) */ int tty_get_icount (struct tty_struct *tty,struct serial_icounter_struct *icount)
@@ -3112,14 +3080,15 @@ static struct device *tty_get_device(struct tty_struct *tty) } -/* -* alloc_tty_struct +/** +* alloc_tty_struct - allocate a new tty +* @driver: driver which will handle the returned tty +* @idx: minor of the tty * -* This subroutine allocates and initializes a tty structure. +* This subroutine allocates and initializes a tty structure. * -* Locking: none - tty in question is not exposed at this point +* Locking: none - @tty in question is not exposed at this point */ -struct tty_struct *alloc_tty_struct (struct tty_driver *driver,int idx) {struct tty_struct *tty;
@@ -3161,17 +3130,18 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx) }/** -* tty_put_char - write one character to a tty -* @tty: tty -* @ch: character +* tty_put_char - write one character to a tty +* @tty: tty +* @ch: character to write +* +* Write one byte to the @tty using the provided @tty->ops->put_char() method +* if present. * -* Write one byte to the tty using the provided put_char method -* if present. Returns the number of characters successfully output. +* Note: the specific put_char operation in the driver layer may go +* away soon. Don't call it directly, use this method * -* Note: the specific put_char operation in the driver layer may go -* away soon. Don't call it directly, use this method +* Return: the number of characters successfully output. */ -int tty_put_char (struct tty_struct *tty,unsigned char ch) {if (tty->ops->put_char)
@@ -3202,24 +3172,23 @@ static int tty_cdev_add(struct tty_driver *driver, dev_t dev, }/** -* tty_register_device - register a tty device -* @driver: the tty driver that describes the tty device -* @index: the index in the tty driver for this tty device -* @device: a struct device that is associated with this tty device. -* This field is optional, if there is no known struct device -* for this tty device it can be set to NULL safely. +* tty_register_device - register a tty device +* @driver: the tty driver that describes the tty device +* @index: the index in the tty driver for this tty device +* @device: a struct device that is associated with this tty device. +* This field is optional, if there is no known struct device +* for this tty device it can be set to NULL safely. * -* Returns a pointer to the struct device for this tty device -* (or ERR_PTR(-EFOO) on error). +* This call is required to be made to register an individual tty device +* if the tty driver's flags have the %TTY_DRIVER_DYNAMIC_DEV bit set. If +* that bit is not set, this function should not be called by a tty +* driver. * -* This call is required to be made to register an individual tty device -* if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If -* that bit is not set, this function should not be called by a tty -* driver. +* Locking: ?? * -* Locking: ?? +* Return: A pointer to the struct device for this tty device (or +* ERR_PTR(-EFOO) on error). */ -struct device *tty_register_device (struct tty_driver *driver,unsigned index,struct device *device) {
@@ -3234,24 +3203,23 @@ static void tty_device_create_release(struct device *dev) }/** -* tty_register_device_attr - register a tty device -* @driver: the tty driver that describes the tty device -* @index: the index in the tty driver for this tty device -* @device: a struct device that is associated with this tty device. -* This field is optional, if there is no known struct device -* for this tty device it can be set to NULL safely. -* @drvdata: Driver data to be set to device. -* @attr_grp: Attribute group to be set on device. +* tty_register_device_attr - register a tty device +* @driver: the tty driver that describes the tty device +* @index: the index in the tty driver for this tty device +* @device: a struct device that is associated with this tty device. +* This field is optional, if there is no known struct device +* for this tty device it can be set to %NULL safely. +* @drvdata: Driver data to be set to device. +* @attr_grp: Attribute group to be set on device. * -* Returns a pointer to the struct device for this tty device -* (or ERR_PTR(-EFOO) on error). +* This call is required to be made to register an individual tty device if the +* tty driver's flags have the %TTY_DRIVER_DYNAMIC_DEV bit set. If that bit is +* not set, this function should not be called by a tty driver. * -* This call is required to be made to register an individual tty device -* if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If -* that bit is not set, this function should not be called by a tty -* driver. +* Locking: ?? * -* Locking: ?? +* Return: A pointer to the struct device for this tty device (or +* ERR_PTR(-EFOO) on error). */ struct device *tty_register_device_attr(struct tty_driver *driver, unsigned index, struct device *device,
@@ -3326,16 +3294,15 @@ struct device *tty_register_device_attr(struct tty_driver *driver,EXPORT_SYMBOL_GPL (tty_register_device_attr);/** -* tty_unregister_device - unregister a tty device -* @driver: the tty driver that describes the tty device -* @index: the index in the tty driver for this tty device +* tty_unregister_device - unregister a tty device +* @driver: the tty driver that describes the tty device +* @index: the index in the tty driver for this tty device * -* If a tty device is registered with a call to tty_register_device() then -* this function must be called when the tty device is gone. +* If a tty device is registered with a call to tty_register_device() then +* this function must be called when the tty device is gone. * -* Locking: ?? +* Locking: ?? */ -void tty_unregister_device (struct tty_driver *driver,unsigned index) { device_destroy(tty_class,
@@ -3351,10 +3318,10 @@ EXPORT_SYMBOL(tty_unregister_device);* __tty_alloc_driver -- allocate tty driver * @lines: count of lines this driver can handle at most * @owner: module which is responsible for this driver -* @flags: some of TTY_DRIVER_* flags, will be set in driver->flags +* @flags: some of %TTY_DRIVER_ flags, will be set in driver->flags * * This should not be called directly, some of the provided macros should be -* used instead. Use IS_ERR and friends on @retval. +* used instead. Use IS_ERR() and friends on @retval. */ struct tty_driver *__tty_alloc_driver (unsigned int lines,struct module *owner,unsigned long flags)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 313/571 tty: abort break signalling on hangup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 845a2737e0f5ffe5ca8d38de556012b0c9472cdd ]
The break ioctls can race with hangup and end up calling into a tty driver for a device that is already gone or powered down.
Drivers must handle this race, but TCSBRK and TCSBRKP should still be aborted to avoid calling back into the driver after a user-controlled timeout (possibly even after the tty has been reopened).
Note that drivers should disable any break state on shutdown so just return on hangup (calling break_ctl() again is racy and will most likely fail for drivers handling the race).
--- drivers/tty/tty_io.c | 36 +++++++++++++++++++++++++++--------- include/linux/tty.h | 1 + 2 files changed, 28 insertions(+), 9 deletions(-)
drivers/tty/tty_io.c +27 -9
@@ -636,6 +636,8 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)tty_ldisc_hangup (tty, cons_filp !=NULL ); +wake_up_interruptible (&tty->break_wait); +spin_lock_irq (&tty->ctrl.lock);clear_bit (TTY_THROTTLED , &tty->flags);clear_bit (TTY_DO_WRITE_WAKEUP , &tty->flags);
@@ -2459,6 +2461,7 @@ static int tiocgetd(struct tty_struct *tty, int __user *p)* send_break - performed time break * @tty: device to break on * @duration: timeout in mS +* @file: file object * * Perform a timed break on hardware that lacks its own driver level timed * break functionality.
@@ -2466,8 +2469,9 @@ static int tiocgetd(struct tty_struct *tty, int __user *p)* Locking: * @tty->atomic_write_lock serializes */ -static int send_break (struct tty_struct *tty,unsigned int duration) +static int send_break (struct file *file,struct tty_struct *tty,unsigned int duration) { +long timeout;int retval;if (tty->ops->break_ctl ==NULL )
@@ -2481,13 +2485,26 @@ static int send_break(struct tty_struct *tty, unsigned int duration)return -EINTR ; retval = tty->ops->break_ctl (tty,-1 ); -if (!retval) { -msleep_interruptible (duration); - retval = tty->ops->break_ctl (tty,0 ); - }else if (retval == -EOPNOTSUPP ) { -/* some drivers can tell only dynamically */ - retval =0 ; +if (retval) { +if (retval == -EOPNOTSUPP ) { +/* some drivers can tell only dynamically */ + retval =0 ; + } + goto out_unlock; + } + + timeout =msecs_to_jiffies (duration); + timeout =wait_event_interruptible_timeout (tty->break_wait, +tty_hung_up_p (file), + timeout); +/* return early on hangup only */ +if (timeout >0 ) { + retval = -EIO ; + goto out_unlock; } + + retval = tty->ops->break_ctl (tty,0 ); +out_unlock:tty_write_unlock (tty);if (signal_pending (current))
@@ -2740,10 +2757,10 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)* This is used by the tcdrain() termios function. */ if (!arg) -return send_break (tty,250 ); +return send_break (file, tty,250 );return 0 ;case TCSBRKP :/* support for POSIX tcsendbreak() */ -return send_break (tty, arg ? arg*100 :250 ); +return send_break (file, tty, arg ? arg *100 :250 );case TIOCMGET :return tty_tiocmget (tty, p);
@@ -3112,6 +3129,7 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)init_ldsem (&tty->ldisc_sem);init_waitqueue_head (&tty->write_wait);init_waitqueue_head (&tty->read_wait); +init_waitqueue_head (&tty->break_wait);INIT_WORK (&tty->hangup_work, do_tty_hangup);mutex_init (&tty->atomic_write_lock);spin_lock_init (&tty->ctrl.lock);
include/linux/tty.h +1 -0
@@ -188,6 +188,7 @@ struct tty_struct {struct fasync_struct *fasync;wait_queue_head_t write_wait;wait_queue_head_t read_wait; +wait_queue_head_t break_wait;struct work_struct hangup_work;void *disc_data;void *driver_data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 314/571 tty: serial: max3100: shut down timer before freeing port
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit db0949bbd06db0a75b4b1076f1e25194be7d956a ]
max3100_shutdown() stops the polling timer but returns early during system suspend. If the SPI device is unbound before resume, the serial core does not call max3100_shutdown() again, so max3100_remove() frees the port while the timer remains armed. max3100_timeout() may then access the freed port and re-arm the timer.
Add final timer teardown to max3100_remove() and use timer_shutdown_sync() to prevent a racing callback from re-arming it. Also free the IRQ and destroy the workqueue there before freeing the port. Keep timer_delete_sync() in max3100_shutdown() so that a subsequent open() can re-arm the timer.
The workqueue is created before request_irq() and destroyed on both request_irq() failure and normal shutdown. Its presence at remove thus identifies the IRQ left registered when suspend bypasses shutdown.
Free the IRQ before destroying the workqueue, in both max3100_shutdown() and max3100_remove(), and cancel the pending work in between. free_irq() waits for a running interrupt handler to finish and no new handler can start afterwards, so a racing handler cannot queue work on a workqueue that is being destroyed; the force_end_work check in max3100_dowork() only narrows that window, as a handler delayed between the check and queue_work() could still run after the teardown has cleared the workqueue pointer. Cancelling the work also keeps destroy_workqueue() from waiting on a queued work item in case remove() ever runs while the freezable workqueue is still frozen, e.g. device removal during the resume window, before workqueues are thawed.
This issue was found by an in-house static analysis tool.
--- drivers/tty/serial/max3100.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/tty/serial/max3100.c +11 -3
@@ -568,12 +568,11 @@ static void max3100_shutdown(struct uart_port *port)del_timer_sync (&s->timer);if (s->workqueue) { -flush_workqueue (s->workqueue); +free_irq (s->irq, s); +cancel_work_sync (&s->work);destroy_workqueue (s->workqueue); s->workqueue =NULL ; } -if (s->irq) -free_irq (s->irq, s);/* set shutdown mode to save power */ if (s->max3100_hw_suspend)
@@ -832,6 +831,15 @@ static int max3100_remove(struct spi_device *spi)if (max3100s[i] == s) {dev_dbg (&spi->dev,"%s: removing port %d\n" , __func__, i);uart_remove_one_port (&max3100_uart_driver, &max3100s[i]->port); + + s->force_end_work =1 ; +timer_shutdown_sync (&s->timer); +if (s->workqueue) { +free_irq (s->irq, s); +cancel_work_sync (&s->work); +destroy_workqueue (s->workqueue); + s->workqueue =NULL ; + }kfree (max3100s[i]); max3100s[i] =NULL ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 315/571 Input: s6sy761 - fix resume ordering and restore sensing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit a215720959c5450b3699e243904b39c3f8f68888 ]
System suspend powers the controller off and resume powers it back on, but the resume path enables the interrupt before s6sy761_power_on() checks the boot. The firmware raises its boot-complete event on the interrupt line, the threaded handler consumes it, s6sy761_power_on() then reads an empty event and resume fails with -ENODEV, skipping the touch function setup:
s6sy761 2-0048: PM: dpm_run_callback(): s6sy761_resume [s6sy761] returns -19
Power the chip on first and only then unmask the interrupt. Once resume completes the boot handshake the chip comes back with sensing off, as at probe where input_open() turns it on, so the touchscreen stays dead after resume. Send SENSE_ON again when the input device is open.
Tested on a Pixel 3 XL over several s2idle cycles: resume succeeds and the touch function and sense status match the pre-suspend state.
--- drivers/input/touchscreen/s6sy761.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/input/touchscreen/s6sy761.c +13 -1
@@ -510,10 +510,22 @@ static int __maybe_unused s6sy761_suspend(struct device *dev)static int __maybe_unused s6sy761_resume (struct device *dev) {struct s6sy761_data *sdata =dev_get_drvdata (dev); +int err; + + err =s6sy761_power_on (sdata); +if (err) +return err;enable_irq (sdata->client->irq); -return s6sy761_power_on (sdata); +mutex_lock (&sdata->input->mutex); + +if (input_device_enabled (sdata->input)) + err =i2c_smbus_write_byte (sdata->client,S6SY761_SENSE_ON ); + +mutex_unlock (&sdata->input->mutex); + +return err; }static const struct dev_pm_ops s6sy761_pm_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 316/571 tty: vt: fix memory leak in vc_allocate()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingyu Wang <[email protected]>
[ Upstream commit 5b114bfc1dfd88f9d50822d532f7f1fce0f7388a ]
If the screen buffer allocation fails in vc_allocate(), the error handling path jumps to err_free. However, this path fails to release the unicode screen map attached to vc->uni_pagedict_loc.
During the early stages of vc_allocate(), the unicode screen map is either newly allocated via con_set_default_unimap() or shares the default unicode map from a previously initialized console (which increments its refcount). If the subsequent kzalloc() for the screen buffer fails, the err_free path frees the vc structure but leaves the attached uni_pagedict with an elevated refcount. This results in an unreferenced object memory leak, as the reference to the dictionary is lost and its refcount can never reach zero.
This issue was discovered by DevGen (an automated virtual device modeling fuzzer based on Syzkaller). During fuzzing with kernel fault injection (failslab) enabled, the fuzzer forcefully failed the kzalloc() for the screen buffer, exposing this error-handling path leak.
Fix this by checking *vc->uni_pagedict_loc and calling con_free_unimap(vc) in the err_free path before kfree(vc). This safely decrements the refcount and releases the dictionary memory if this was the last reference. The explicit check is added to maintain consistency with other callers.
--- drivers/tty/vt/vt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/vt/vt.c +2 -0
@@ -1160,6 +1160,8 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */return 0 ; err_free:visual_deinit (vc); +if (*vc->vc_uni_pagedir_loc) +con_free_unimap (vc);kfree (vc); vc_cons[currcons].d =NULL ;return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 317/571 serial: fix TIOCMIWAIT race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 40adffec8c0090533dfaa863ced7901b60bbf1dc ]
The task state must be updated before checking the wakeup condition to avoid missing a racing modem status update.
--- drivers/tty/serial/serial_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/serial_core.c +2 -2
@@ -1213,12 +1213,12 @@ static int uart_wait_modem_status(struct uart_state *state, unsigned long arg)add_wait_queue (&port->delta_msr_wait, &wait);for (;;) { +set_current_state (TASK_INTERRUPTIBLE ); +spin_lock_irq (&uport->lock);memcpy (&cnow, &uport->icount,sizeof (struct uart_icount ));spin_unlock_irq (&uport->lock); -set_current_state (TASK_INTERRUPTIBLE ); - if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 318/571 drm/amd/display: Mark DCE 6.4 as not APU
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 3a52d587d1fc8e8bf94ba1b07374f7ec91aaffb4 ]
DCE 6.4 is found in Oland chips, which were advertised as low-end gaming GPUs in 2013~2015 and then have been sold as low-end workstation GPUs until 2017~2019.
These are not APUs.
--- drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c +0 -1
@@ -1354,7 +1354,6 @@ static bool dce64_construct( dc->caps.max_downscale_ratio =200 ; dc->caps.i2c_speed_in_khz =40 ; dc->caps.max_cursor_size =64 ; - dc->caps.is_apu = true;/************************************************* * Create resources *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 319/571 wifi: mac80211: shut down RX BA session timer on teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit e588e83e5c7a0f6d7a77dbbb58927c8c8cfd598e ]
Tearing down an RX BA session can leave the session timer queued on a freed tid_rx. Later timer-wheel processing and the timer callback itself then run against freed memory.
An RX BAR handler can dereference tid_rx under RCU before teardown unpublishes it and stay in its read-side critical section while teardown deletes the session timer. The stale handler can then rearm the timer after timer_delete_sync() returns and before the RCU callback frees tid_rx.
Use timer_shutdown_sync() so rearm attempts become ineffective once teardown starts. Keep reorder_timer unchanged: teardown marks the session removed under reorder_lock and its release path checks that state before rearming. session_timer has no equivalent guard because ieee80211_rx_h_ctrl() rearms it before taking reorder_lock.
--- net/mac80211/agg-rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/agg-rx.c +1 -1
@@ -103,7 +103,7 @@ void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,if (!tid_rx)return ; -del_timer_sync (&tid_rx->session_timer); +timer_shutdown_sync (&tid_rx->session_timer);/* make sure ieee80211_sta_reorder_release() doesn't re-arm the timer */ spin_lock_bh (&tid_rx->reorder_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 320/571 wifi: mac80211: keep fallback association elements alive
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit a10a2f80476d166fd81c361ec0319493671b694e ]
Associating to a non-transmitted MBSSID profile reads freed memory while determining the operating channel and applying HT capabilities.
When an association response omits WMM, HT, or VHT information, ieee80211_assoc_config_link() parses the cached BSS IEs and copies the missing element pointers out of that fallback parse. For a non-transmitted MBSSID profile those pointers refer to merged-profile storage owned by the parse object, and the fallback block frees that object at its end. The copied pointers are used afterwards to determine the operating channel, configure bandwidth, and apply HT capabilities.
Keep the fallback parse result alive until association setup finishes.
--- net/mac80211/mlme.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/mac80211/mlme.c +2 -3
@@ -3310,6 +3310,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,u16 capab_info, aid;struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;const struct cfg80211_bss_ies *bss_ies =NULL ; +struct ieee802_11_elems *bss_elems =NULL ;struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data;bool is_6ghz = cbss->channel->band ==NL80211_BAND_6GHZ ;bool is_s1g = cbss->channel->band ==NL80211_BAND_S1GHZ ;
@@ -3376,7 +3377,6 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) && (!elems->vht_cap_elem || !elems->vht_operation)))) {const struct cfg80211_bss_ies *ies; -struct ieee802_11_elems *bss_elems;rcu_read_lock (); ies =rcu_dereference (cbss->ies);
@@ -3432,8 +3432,6 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,sdata_info (sdata,"AP bug: VHT operation missing from AssocResp\n" ); } - -kfree (bss_elems); }/*
@@ -3685,6 +3683,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, ret = true; out:kfree (elems); +kfree (bss_elems);kfree (bss_ies);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/571 thunderbolt: Fix KASAN reported use-after-free when request is canceled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
[ Upstream commit a02188ddc24b7872f0c5e0c5873f827318717803 ]
Alan reported that when doing stress testing sometimes KASAN notices use-after-free during control channel operation (stripped down keeping the relevant parts):
BUG: KASAN: slab-use-after-free in tb_cfg_request_sync+0x240/0x250 [thunderbolt] Read of size 24 at addr ffff88811067f290 by task kworker/u40:2/1760 <TASK> tb_cfg_request_sync+0x240/0x250 [thunderbolt] tb_cfg_read_raw+0x367/0x510 [thunderbolt] tb_cfg_read+0xec/0x240 [thunderbolt] tb_port_get_link_generation+0x258/0x420 [thunderbolt] tb_usb3_consumed_bandwidth+0x1c1/0x2c0 [thunderbolt] tb_tunnel_consumed_bandwidth+0xfd/0x910 [thunderbolt] tb_available_bandwidth+0x5f2/0xeb0 [thunderbolt] tb_recalc_estimated_bandwidth+0x2a0/0x1bc0 [thunderbolt] tb_handle_dp_bandwidth_request+0x1897/0x5e20 [thunderbolt] process_one_work+0x675/0x1230 worker_thread+0x5e6/0xf70 kthread+0x365/0x470 ret_from_fork+0x54d/0x710 ret_from_fork_asm+0x1a/0x30 </TASK> Allocated by task 1760: __kmalloc_cache_noprof+0x1ee/0x550 tb_cfg_read_raw+0x1d3/0x510 [thunderbolt] tb_cfg_read+0xec/0x240 [thunderbolt] tb_port_get_link_generation+0x258/0x420 [thunderbolt] tb_usb3_consumed_bandwidth+0x1c1/0x2c0 [thunderbolt] tb_tunnel_consumed_bandwidth+0xfd/0x910 [thunderbolt] tb_available_bandwidth+0x5f2/0xeb0 [thunderbolt] tb_recalc_estimated_bandwidth+0x2a0/0x1bc0 [thunderbolt] tb_handle_dp_bandwidth_request+0x1897/0x5e20 [thunderbolt] process_one_work+0x675/0x1230 worker_thread+0x5e6/0xf70 kthread+0x365/0x470 ret_from_fork+0x54d/0x710 ret_from_fork_asm+0x1a/0x30 Freed by task 926: kfree+0x18f/0x4a0 tb_cfg_request_put+0xb7/0xe0 [thunderbolt] tb_cfg_request_work+0x82/0x120 [thunderbolt] process_one_work+0x675/0x1230 worker_thread+0x5e6/0xf70 kthread+0x365/0x470 ret_from_fork+0x54d/0x710 ret_from_fork_asm+0x1a/0x30 Second to last potentially related work creation: __queue_work+0x575/0xd00 queue_work_on+0x77/0x80 tb_cfg_request_cancel+0xc7/0x260 [thunderbolt] tb_cfg_request_sync+0x1f6/0x250 [thunderbolt] tb_cfg_read_raw+0x367/0x510 [thunderbolt] tb_cfg_read+0xec/0x240 [thunderbolt] tb_port_get_link_generation+0x258/0x420 [thunderbolt] tb_usb3_consumed_bandwidth+0x1c1/0x2c0 [thunderbolt] tb_tunnel_consumed_bandwidth+0xfd/0x910 [thunderbolt] tb_available_bandwidth+0x5f2/0xeb0 [thunderbolt] tb_recalc_estimated_bandwidth+0x2a0/0x1bc0 [thunderbolt] tb_handle_dp_bandwidth_request+0x1897/0x5e20 [thunderbolt] process_one_work+0x675/0x1230 worker_thread+0x5e6/0xf70 kthread+0x365/0x470 ret_from_fork+0x54d/0x710 ret_from_fork_asm+0x1a/0x30
The last stack trace is helpful because it shows that we are cancelling a request and looking at tb_cfg_request_cancel() what might happen is that tb_cfg_request_work() completes right before tb_cfg_request_cancel() starts and because of this it will call schedule_work() queueing the same work to run again. However, it is already removed from the request_queue and reference count is dropped so when tb_cfg_request_work() triggers again it will access memory that is already released.
Fix this so that we first make sure a cancelled request is not handed away from tb_cfg_request_find() or scheduled to run. Then instead of relying on the worker to clean up the request we will do it in tb_cfg_request_cancel() after the work is canceled from running. Make tb_cfg_request_dequeue() release the request only if it was actually removed from the queue.
--- drivers/thunderbolt/ctl.c | 47 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-)
drivers/thunderbolt/ctl.c +23 -24
@@ -65,7 +65,6 @@ struct tb_ctl { #define tb_ctl_dbg(ctl, format, arg...) \ dev_dbg(&(ctl)->nhi->pdev->dev, format, ## arg) -static DECLARE_WAIT_QUEUE_HEAD (tb_cfg_request_cancel_queue);/* Serializes access to request kref_get/put */ static DEFINE_MUTEX (tb_cfg_request_lock);
@@ -123,11 +122,14 @@ void tb_cfg_request_put(struct tb_cfg_request *req)static int tb_cfg_request_enqueue (struct tb_ctl *ctl,struct tb_cfg_request *req) { +tb_cfg_request_get (req); +WARN_ON (test_bit (TB_CFG_REQUEST_ACTIVE , &req->flags));WARN_ON (req->ctl);mutex_lock (&ctl->request_queue_lock);if (!ctl->running) { +tb_cfg_request_put (req);mutex_unlock (&ctl->request_queue_lock);return -ENOTCONN ; }
@@ -138,28 +140,24 @@ static int tb_cfg_request_enqueue(struct tb_ctl *ctl,return 0 ; } +static bool tb_cfg_request_is_active (struct tb_cfg_request *req) +{ +return test_bit (TB_CFG_REQUEST_ACTIVE , &req->flags); +} +static void tb_cfg_request_dequeue (struct tb_cfg_request *req) {struct tb_ctl *ctl = req->ctl;mutex_lock (&ctl->request_queue_lock); -if (!test_bit (TB_CFG_REQUEST_ACTIVE , &req->flags)) { -mutex_unlock (&ctl->request_queue_lock); -return ; +if (tb_cfg_request_is_active (req)) { +list_del (&req->list); +clear_bit (TB_CFG_REQUEST_ACTIVE , &req->flags); +tb_cfg_request_put (req); } - -list_del (&req->list); -clear_bit (TB_CFG_REQUEST_ACTIVE , &req->flags); -if (test_bit (TB_CFG_REQUEST_CANCELED , &req->flags)) -wake_up (&tb_cfg_request_cancel_queue);mutex_unlock (&ctl->request_queue_lock); } -static bool tb_cfg_request_is_active (struct tb_cfg_request *req) -{ -return test_bit (TB_CFG_REQUEST_ACTIVE , &req->flags); -} -static struct tb_cfg_request *tb_cfg_request_find (struct tb_ctl *ctl,struct ctl_pkg *pkg) {
@@ -169,7 +167,8 @@ tb_cfg_request_find(struct tb_ctl *ctl, struct ctl_pkg *pkg)mutex_lock (&pkg->ctl->request_queue_lock);list_for_each_entry (req, &pkg->ctl->request_queue, list) {tb_cfg_request_get (req); -if (req->match (req, pkg)) { +if (!test_bit (TB_CFG_REQUEST_CANCELED , &req->flags) && + req->match (req, pkg)) { found = true;break ; }
@@ -496,8 +495,11 @@ static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,*/ req =tb_cfg_request_find (pkg->ctl, pkg);if (req) { -if (req->copy (req, pkg)) +mutex_lock (&pkg->ctl->request_queue_lock); +if (!test_bit (TB_CFG_REQUEST_CANCELED , &req->flags) && + req->copy (req, pkg))schedule_work (&req->work); +mutex_unlock (&pkg->ctl->request_queue_lock);tb_cfg_request_put (req); }
@@ -513,7 +515,6 @@ static void tb_cfg_request_work(struct work_struct *work) req->callback (req->callback_data);tb_cfg_request_dequeue (req); -tb_cfg_request_put (req); }/**
@@ -537,10 +538,9 @@ int tb_cfg_request(struct tb_ctl *ctl, struct tb_cfg_request *req,INIT_WORK (&req->work, tb_cfg_request_work);INIT_LIST_HEAD (&req->list); -tb_cfg_request_get (req); ret =tb_cfg_request_enqueue (ctl, req);if (ret) - goto err_put; +return ret; ret =tb_ctl_tx (ctl, req->request, req->request_size, req->request_type);
@@ -554,9 +554,6 @@ int tb_cfg_request(struct tb_ctl *ctl, struct tb_cfg_request *req, err_dequeue:tb_cfg_request_dequeue (req); -err_put: -tb_cfg_request_put (req); -return ret; }
@@ -570,9 +567,11 @@ int tb_cfg_request(struct tb_ctl *ctl, struct tb_cfg_request *req,*/ void tb_cfg_request_cancel (struct tb_cfg_request *req,int err) { +mutex_lock (&req->ctl->request_queue_lock);set_bit (TB_CFG_REQUEST_CANCELED , &req->flags); -schedule_work (&req->work); -wait_event (tb_cfg_request_cancel_queue, !tb_cfg_request_is_active (req)); +mutex_unlock (&req->ctl->request_queue_lock); +cancel_work_sync (&req->work); +tb_cfg_request_dequeue (req); req->result.err = err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/571 USB: serial: fix ioctl hangup race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit ae0e61d95677efa778379853e495d748e6efbf95 ]
The tty ioctls can race with hangup and end up calling into a tty driver for a device that is already gone or powered down.
Serialise the callbacks using the tty port mutex and add the missing checks to make sure the port has not been hung up before accessing port driver data or hardware.
This specifically avoids dereferencing a NULL-pointer if a device is disconnected during lengthy break signalling.
Note that TIOCGICOUNT and TIOCMIWAIT do not access port driver data or hardware and are therefore not affected by the race.
--- drivers/usb/serial/generic.c | 10 +++- drivers/usb/serial/usb-serial.c | 92 ++++++++++++++++++++++++++------- 2 files changed, 82 insertions(+), 20 deletions(-)
drivers/usb/serial/generic.c +9 -1
@@ -268,6 +268,7 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_chars_in_buffer);void usb_serial_generic_wait_until_sent (struct tty_struct *tty,long timeout) {struct usb_serial_port *port = tty->driver_data; +struct tty_port *tport = &port->port;unsigned int bps;unsigned long period;unsigned long expire;
@@ -287,7 +288,14 @@ void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout) __func__,jiffies_to_msecs (timeout), jiffies_to_msecs(period)); expire = jiffies + timeout; -while (!port->serial->type->tx_empty (port)) { +for (;;) { +mutex_lock (&tport->mutex); +if (tty_io_error (tty) || port->serial->type->tx_empty (port)) { +mutex_unlock (&tport->mutex); +break ; + } +mutex_unlock (&tport->mutex); +schedule_timeout_interruptible (period);if (signal_pending (current))break ;
drivers/usb/serial/usb-serial.c +73 -19
177 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 323/571 mtd: block2mtd: Fix divide error when erase_size is zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit b5965c4221165045e19736794ca5f48ae3d67142 ]
The erase size is parsed from the "block2mtd" module parameter and can be set to zero. add_device() then evaluates
if (size % erase_size)
with a zero divisor, which triggers a divide error:
divide error: 0000 [#1] PREEMPT SMP PTI
RIP: 0010:add_device drivers/mtd/devices/block2mtd.c:296 [inline] RIP: 0010:block2mtd_setup2+0x592/0xda0 drivers/mtd/devices/block2mtd.c:459 Call Trace: block2mtd_setup+0x27/0xe0 drivers/mtd/devices/block2mtd.c:476 param_attr_store+0x214/0x310 kernel/params.c:589 module_attr_store+0x65/0x90 kernel/params.c:904 kernfs_fop_write_iter+0x3a4/0x540 fs/kernfs/file.c:345
...
Reject a zero erase size before performing the modulo operation so the existing "erasesize must be a divisor of device size" error path reports the invalid argument and frees the device.
--- drivers/mtd/devices/block2mtd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/devices/block2mtd.c +1 -1
@@ -269,7 +269,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, goto err_free_block2mtd; } -if ((long )dev->blkdev->bd_inode->i_size % erase_size) { +if (!erase_size || (long )dev->blkdev->bd_inode->i_size % erase_size) {pr_err ("erasesize must be a divisor of device size\n" ); goto err_free_block2mtd; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 324/571 mtd: spinand: Enable QE on all dies
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Han Xu <[email protected]>
[ Upstream commit 63d6cace2c4a7f36c1cb44f1bb5e0f3ef19e5c7f ]
The QUAD ENABLE (QE) bit is stored in a per-die configuration register on some SPI-NAND devices. When a device contains multiple dies, updating the QE bit only on the currently selected die can leave the remaining dies operating in non-quad mode.
Iterate over all targets and update the QE setting on each die during initialization to ensure consistent quad I/O operation across the entire device.
Tested on ISSI IS38SMW04G8B.
--- drivers/mtd/nand/spi/core.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/mtd/nand/spi/core.c +19 -2
@@ -179,7 +179,10 @@ static int spinand_init_cfg_cache(struct spinand_device *spinand)static int spinand_init_quad_enable (struct spinand_device *spinand) { +struct nand_device *nand =spinand_to_nand (spinand); +unsigned int target;bool enable = false; +int ret;if (!(spinand->flags &SPINAND_HAS_QE_BIT ))return 0 ;
@@ -189,8 +192,22 @@ static int spinand_init_quad_enable(struct spinand_device *spinand) spinand->op_templates.update_cache->data.buswidth == 4) enable = true; -return spinand_upd_cfg (spinand,CFG_QUAD_ENABLE , - enable ?CFG_QUAD_ENABLE :0 ); +/* +* QE is a per-die setting on some devices. Program each target +* individually when enabling or disabling quad I/O mode. +*/ +for (target =0 ; target < nand->memorg.ntargets; target++) { + ret =spinand_select_target (spinand, target); +if (ret) +return ret; + + ret =spinand_upd_cfg (spinand,CFG_QUAD_ENABLE , + enable ?CFG_QUAD_ENABLE :0 ); +if (ret) +return ret; + } + +return 0 ; } static int spinand_ecc_enable(struct spinand_device *spinand,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 325/571 wifi: mac80211: account proxy paths against the mesh path limit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit a5f35d4b112af1415ff06bd501c8cc26cc08aa8b ]
Proxy-path churn can drive the interface path counter negative and let later mesh path additions exceed MESH_MAX_MPATHS.
mesh_path_free_rcu() decrements the interface mpaths counter for entries from both the mesh and proxy path tables, but mpp_path_add() never reserves a slot in that counter. Removing or expiring a proxy path therefore returns a slot that was never charged.
mesh_path_add() uses the same counter to enforce MESH_MAX_MPATHS, so once it falls below the number of installed paths the limit no longer holds.
Reserve the shared quota before allocating a proxy path and release it on every unsuccessful addition. Mesh and proxy paths now share one 1024-entry budget, so mpp_path_add() can return -ENOSPC at that limit.
--- net/mac80211/mesh_pathtbl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/mac80211/mesh_pathtbl.c +9 -2
@@ -449,10 +449,15 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata,if (is_multicast_ether_addr (dst))return -ENOTSUPP ; +if (!atomic_add_unless (&sdata->u.mesh.mpaths,1 ,MESH_MAX_MPATHS )) +return -ENOSPC ; + new_mpath =mesh_path_new (sdata, dst,GFP_ATOMIC ); -if (!new_mpath) +if (!new_mpath) { +atomic_dec (&sdata->u.mesh.mpaths);return -ENOMEM ; + }memcpy (new_mpath->mpp, mpp,ETH_ALEN ); tbl = &sdata->u.mesh.mpp_paths;
@@ -465,8 +470,10 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata,hlist_add_head_rcu (&new_mpath->walk_list, &tbl->walk_head);spin_unlock_bh (&tbl->walk_lock); -if (ret) +if (ret) {kfree (new_mpath); +atomic_dec (&sdata->u.mesh.mpaths); + } sdata->u.mesh.mpp_paths_generation++;return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/571 USB: serial: clean up core error labels
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 96a83c95c3da5ba55ea2cf6ce87de10fc03417a9 ]
Clean up the core error labels by consistently naming them after what they do rather than after from where they are jumped to.
Stable-dep-of: 646e5b28b4fd ("USB: serial: fix driver deregistration order")
--- drivers/usb/serial/usb-serial.c | 34 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-)
drivers/usb/serial/usb-serial.c +16 -18
@@ -225,17 +225,17 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty) serial = port->serial;if (!try_module_get (serial->type->driver.owner)) - goto error_module_get; + goto err_put_serial; retval =usb_autopm_get_interface (serial->interface);if (retval) - goto error_get_interface; + goto err_put_module; init_termios = (driver->termios[idx] ==NULL ); retval =tty_standard_install (driver, tty);if (retval) - goto error_init_termios; + goto err_put_autopm;mutex_unlock (&serial->disc_mutex);
@@ -247,11 +247,11 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)return retval; - error_init_termios: +err_put_autopm:usb_autopm_put_interface (serial->interface); - error_get_interface: +err_put_module:module_put (serial->type->driver.owner); - error_module_get: +err_put_serial:usb_serial_put (serial);mutex_unlock (&serial->disc_mutex);return retval;
@@ -1388,7 +1388,7 @@ static int __init usb_serial_init(void) result =bus_register (&usb_serial_bus_type);if (result) {pr_err ("%s - registering bus driver failed\n" , __func__); - goto exit_bus; + goto err_put_driver; } usb_serial_tty_driver->driver_name ="usbserial" ;
@@ -1406,25 +1406,23 @@ static int __init usb_serial_init(void) result =tty_register_driver (usb_serial_tty_driver);if (result) {pr_err ("%s - tty_register_driver failed\n" , __func__); - goto exit_reg_driver; + goto err_unregister_bus; }/* register the generic driver, if we should */ result =usb_serial_generic_register ();if (result <0 ) {pr_err ("%s - registering generic driver failed\n" , __func__); - goto exit_generic; + goto err_unregister_driver; }return result; -exit_generic: +err_unregister_driver:tty_unregister_driver (usb_serial_tty_driver); - -exit_reg_driver: +err_unregister_bus:bus_unregister (&usb_serial_bus_type); - -exit_bus: +err_put_driver:pr_err ("%s - returning with error %d\n" , __func__, result);tty_driver_kref_put (usb_serial_tty_driver);return result;
@@ -1569,13 +1567,13 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[] rc =usb_register (udriver);if (rc) - goto failed_usb_register; + goto err_free_driver;for (sd = serial_drivers; *sd; ++sd) { (*sd)->usb_driver = udriver; rc =usb_serial_register (*sd);if (rc) - goto failed; + goto err_deregister_drivers; }/* Now set udriver's id_table and look for matches */
@@ -1583,11 +1581,11 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[] rc =driver_attach (&udriver->drvwrap.driver);return 0 ; - failed: +err_deregister_drivers:while (sd-- > serial_drivers)usb_serial_deregister (*sd);usb_deregister (udriver); -failed_usb_register: +err_free_driver:kfree (udriver);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 327/571 USB: serial: fix driver deregistration order
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 646e5b28b4fdbc1b828a2398d6ced2c1dd308a46 ]
USB serial driver modules register one driver for the USB bus and one or more drivers for the ports on the USB serial bus.
When unloading a driver module, the USB driver must be deregistered before the USB serial bus drivers so that I/O is stopped before unbinding the ports to avoid use-after-free in completion handlers accessing port data.
Note that the "new_id" attributes must first be removed to prevent new ids from being added and triggering a probe of the USB driver after it has been deregistered.
--- drivers/usb/serial/bus.c | 4 ++++ drivers/usb/serial/usb-serial.c | 21 ++++++++++++++++++--- include/linux/usb/serial.h | 1 + 3 files changed, 23 insertions(+), 3 deletions(-)
drivers/usb/serial/bus.c +4 -0
@@ -171,3 +171,7 @@ void usb_serial_bus_deregister(struct usfree_dynids (driver); } +void usb_serial_bus_remove_new_id (struct usb_serial_driver *driver) +{ +driver_remove_file (&driver->driver, &driver_attr_new_id); +}
drivers/usb/serial/usb-serial.c +18 -3
@@ -1530,7 +1530,7 @@ int usb_serial_register_drivers(struct u {int rc;struct usb_driver *udriver; -struct usb_serial_driver *const *sd; +struct usb_serial_driver *const *sd, *const *s;/* * udriver must be registered before any of the serial drivers,
@@ -1582,9 +1582,11 @@ int usb_serial_register_drivers(struct ureturn 0 ; err_deregister_drivers: +for (s = serial_drivers; s < sd; ++s) +usb_serial_bus_remove_new_id (*s); +usb_deregister (udriver);while (sd-- > serial_drivers)usb_serial_deregister (*sd); -usb_deregister (udriver); err_free_driver:kfree (udriver);return rc;
@@ -1602,10 +1604,23 @@ EXPORT_SYMBOL_GPL(usb_serial_register_drvoid usb_serial_deregister_drivers (struct usb_serial_driver *const serial_drivers[]) {struct usb_driver *udriver = (*serial_drivers)->usb_driver; +struct usb_serial_driver *const *sd; + +/* +* udriver must be deregistered before the serial drivers so that +* I/O is stopped before unbinding the ports. +* +* Remove the new_id attributes to prevent ids from being added and +* triggering a probe of udriver after it has been deregistered. +*/ +for (sd = serial_drivers; *sd; ++sd) +usb_serial_bus_remove_new_id (*sd); + +usb_deregister (udriver);for (; *serial_drivers; ++serial_drivers)usb_serial_deregister (*serial_drivers); -usb_deregister (udriver); +kfree (udriver); }EXPORT_SYMBOL_GPL (usb_serial_deregister_drivers);
include/linux/usb/serial.h +1 -0
@@ -382,6 +382,7 @@ void usb_serial_handle_dcd_change(structint usb_serial_bus_register (struct usb_serial_driver *device);void usb_serial_bus_deregister (struct usb_serial_driver *device); +void usb_serial_bus_remove_new_id (struct usb_serial_driver *driver);extern struct bus_type usb_serial_bus_type;extern struct tty_driver *usb_serial_tty_driver;
Greg Kroah-Hartman
maintainerPATCH 328/571 bnxt_en: fix DMA mapping length for padded small packets
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 a51d233ccd4889aadb71dace863525cc2b00271e ]
Stefan Fleischmann reported Intel IOMMU DMA Read faults on BCM57412 NetXtreme-E NICs when transmitting packets on VLAN/macvlan interfaces:
DMAR: [DMA Read NO_PASID] Request device [18:00.0] fault addr 0xfc499000
[fault reason 0x06] PTE Read access is not set
bnxt_en 0000:18:00.0 eno1np0: Abandoning msg {0xb4 0x41a} len: 0 due to firmware status: 0x2000001
...
NETDEV WATCHDOG: eno1np0 (bnxt_en): transmit queue 0 timed out
The fault address (0xfc499000) is on an exact 4KB page boundary, pointing to a DMA read buffer overrun.
In bnxt_start_xmit(), packets smaller than BNXT_MIN_PKT_SIZE (52 bytes), such as 42-byte untagged ARP frames, are padded:
if (length < BNXT_MIN_PKT_SIZE) {
pad = BNXT_MIN_PKT_SIZE - length;
if (skb_pad(skb, pad))
goto tx_kick_pending;
length = BNXT_MIN_PKT_SIZE;
}
mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE);
...
dma_unmap_len_set(tx_buf, len, len);However, 'len' was initialized earlier to skb_headlen(skb) (e.g. 42 bytes) and is left unadjusted after padding. Consequently, dma_map_single() and dma_unmap_len_set() map and track only 42 bytes.
Later, the hardware TX buffer descriptor is programmed with the padded length:
txbd->tx_bd_len_flags_type =
cpu_to_le32(((len + pad) << TX_BD_LEN_SHIFT) | flags |
TX_BD_FLAGS_PACKET_END);The NIC DMA engine is thus instructed to read 52 bytes from a region where only 42 bytes were DMA-mapped. If skb->data ends near the boundary of a 4KB page (within 'pad' bytes of the next page), the hardware DMA read overruns into the unmapped adjacent page, triggering an IOMMU fault.
This issue was exposed after commit 447cbe95ebb9 ("vlan: fix skb_under_panic and races when toggling HW VLAN offload") because reserving extra VLAN headroom rounded LL_RESERVED_SPACE from 48 up to 64 bytes, shifting skb->data offsets and potentially causing small frames to land right against page boundaries.
Fix this by using skb_put_padto(skb, BNXT_MIN_PKT_SIZE) in bnxt_start_xmit(), before skb_shinfo(skb)->nr_frags is sampled, because padding might linearize the skb.
This ensures skb->len and skb_headlen(skb) reflect the padded size so that dma_map_single() maps the full buffer and the descriptor length is consistent. This also removes the temporary 'pad' variable and masking logic.
The padding is done after the SW USO branch, otherwise bnxt_sw_udp_gso_xmit() would account the padding as UDP payload and send it in extra segments.
Note that SW USO segments are still not padded: with IPv4, a segment carrying less than 10 bytes of UDP payload (small gso_size, or a short last segment) is sent as a frame shorter than BNXT_MIN_PKT_SIZE. This is a separate issue, left for a followup patch.
[ sashal: Dropped the SW USO and fragment linearize context, which this tree does not have. ]
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +10 -13
@@ -439,7 +439,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)struct netdev_queue *txq;int i;dma_addr_t mapping; -unsigned int length, pad =0 ; +unsigned int length;u32 len, free_size, vlan_tag_flags, cfa_action, flags;u16 prod, last_frag;struct pci_dev *pdev = bp->pdev;
@@ -458,6 +458,14 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) txr = &bp->tx_ring[bp->tx_ring_map[i]]; prod = txr->tx_prod; +/* Must be done before skb_shinfo(skb)->nr_frags is sampled, +* because skb_put_padto() might linearize the skb. +*/ +if (skb_put_padto (skb,BNXT_MIN_PKT_SIZE )) { +/* SKB already freed. */ + goto tx_kick_pending; + } + free_size =bnxt_tx_avail (bp, txr);if (unlikely (free_size <skb_shinfo (skb)->nr_frags +2 )) {/* We must have raced with NAPI cleanup */
@@ -586,14 +594,6 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) } normal_tx: -if (length <BNXT_MIN_PKT_SIZE ) { - pad =BNXT_MIN_PKT_SIZE - length; -if (skb_pad (skb, pad)) -/* SKB already freed. */ - goto tx_kick_pending; - length =BNXT_MIN_PKT_SIZE ; - } - mapping =dma_map_single (&pdev->dev, skb->data, len,DMA_TO_DEVICE );if (unlikely (dma_mapping_error (&pdev->dev, mapping)))
@@ -668,10 +668,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) txbd->tx_bd_len_flags_type =cpu_to_le32 (flags); } - flags &= ~TX_BD_LEN ; - txbd->tx_bd_len_flags_type = -cpu_to_le32 (((len + pad) <<TX_BD_LEN_SHIFT ) | flags | -TX_BD_FLAGS_PACKET_END ); + txbd->tx_bd_len_flags_type |=cpu_to_le32 (TX_BD_FLAGS_PACKET_END );netdev_tx_sent_queue (txq, skb->len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 329/571 tty: introduce and use tty_port_tty_vhangup() helper
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
[ Upstream commit 2b5eac0f8c6e79bc152c8804f9f88d16717013ab ]
This code (tty_get -> vhangup -> tty_put) is repeated on few places. Introduce a helper similar to tty_port_tty_hangup() (asynchronous) to handle even vhangup (synchronous).
And use it on those places.
In fact, reuse the tty_port_tty_hangup()'s code and call tty_vhangup() depending on a new bool parameter.
[ Ting-Han: adjust context in uart_remove_one_port(), which is still
called that and keeps its "ret" variable in this version ]
--- drivers/isdn/capi/capi.c | 8 +------- drivers/staging/greybus/uart.c | 7 +------ drivers/tty/serial/serial_core.c | 7 +------ drivers/tty/tty_port.c | 12 ++++++++---- drivers/usb/class/cdc-acm.c | 7 +------ drivers/usb/serial/usb-serial.c | 7 +------ include/linux/tty_port.h | 12 +++++++++++- net/bluetooth/rfcomm/tty.c | 7 +------ 8 files changed, 25 insertions(+), 42 deletions(-)
drivers/isdn/capi/capi.c +1 -7
@@ -304,15 +304,9 @@ static void capincci_alloc_minor(struct capidev *cdev, struct capincci *np)static void capincci_free_minor (struct capincci *np) {struct capiminor *mp = np->minorp; -struct tty_struct *tty;if (mp) { - tty =tty_port_tty_get (&mp->port); -if (tty) { -tty_vhangup (tty); -tty_kref_put (tty); - } - +tty_port_tty_vhangup (&mp->port);capiminor_free (mp); } }
drivers/staging/greybus/uart.c +1 -6
@@ -915,7 +915,6 @@ static void gb_uart_remove(struct gbphy_device *gbphy_dev) {struct gb_tty *gb_tty =gb_gbphy_get_data (gbphy_dev);struct gb_connection *connection = gb_tty->connection; -struct tty_struct *tty;int ret; ret =gbphy_runtime_get_sync (gbphy_dev);
@@ -928,11 +927,7 @@ static void gb_uart_remove(struct gbphy_device *gbphy_dev)wake_up_all (&gb_tty->wioctl);mutex_unlock (&gb_tty->mutex); - tty =tty_port_tty_get (&gb_tty->port); -if (tty) { -tty_vhangup (tty); -tty_kref_put (tty); - } +tty_port_tty_vhangup (&gb_tty->port);gb_connection_disable_rx (connection);tty_unregister_device (gb_tty_driver, gb_tty->minor);
drivers/tty/serial/serial_core.c +1 -6
@@ -3036,7 +3036,6 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport)struct uart_state *state = drv->state + uport->line;struct tty_port *port = &state->port;struct uart_port *uart_port; -struct tty_struct *tty;int ret =0 ;mutex_lock (&port_mutex);
@@ -3064,11 +3063,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport)*/ tty_port_unregister_device (port, drv->tty_driver, uport->line); - tty =tty_port_tty_get (port); -if (tty) { -tty_vhangup (port->tty); -tty_kref_put (tty); - } +tty_port_tty_vhangup (port);/* * If the port is used as a console, unregister it
drivers/tty/tty_port.c +8 -4
@@ -369,15 +369,19 @@ EXPORT_SYMBOL(tty_port_hangup);* @port: tty port * @check_clocal: hang only ttys with CLOCAL unset? */ -void tty_port_tty_hangup (struct tty_port *port,bool check_clocal) +void __tty_port_tty_hangup (struct tty_port *port,bool check_clocal,bool async) {struct tty_struct *tty =tty_port_tty_get (port); -if (tty && (!check_clocal || !C_CLOCAL (tty))) -tty_hangup (tty); +if (tty && (!check_clocal || !C_CLOCAL (tty))) { +if (async) +tty_hangup (tty); +else +tty_vhangup (tty); + }tty_kref_put (tty); } -EXPORT_SYMBOL_GPL (tty_port_tty_hangup); +EXPORT_SYMBOL_GPL (__tty_port_tty_hangup);/** * tty_port_tty_wakeup - helper to wake up a tty
drivers/usb/class/cdc-acm.c +1 -6
@@ -1562,7 +1562,6 @@ static int acm_probe(struct usb_interface *intf,static void acm_disconnect (struct usb_interface *intf) {struct acm *acm =usb_get_intfdata (intf); -struct tty_struct *tty;int i;/* sibling interface is already cleaning up */
@@ -1589,11 +1588,7 @@ static void acm_disconnect(struct usb_interface *intf)usb_set_intfdata (acm->data,NULL );mutex_unlock (&acm->mutex); - tty =tty_port_tty_get (&acm->port); -if (tty) { -tty_vhangup (tty); -tty_kref_put (tty); - } +tty_port_tty_vhangup (&acm->port);cancel_delayed_work_sync (&acm->dwork);
drivers/usb/serial/usb-serial.c +1 -6
@@ -1229,7 +1229,6 @@ static void usb_serial_disconnect(struct usb_interface *interface)struct usb_serial *serial =usb_get_intfdata (interface);struct device *dev = &interface->dev;struct usb_serial_port *port; -struct tty_struct *tty;/* sibling interface is cleaning up */ if (!serial)
@@ -1244,11 +1243,7 @@ static void usb_serial_disconnect(struct usb_interface *interface)for (i =0 ; i < serial->num_ports; ++i) { port = serial->port[i]; - tty =tty_port_tty_get (&port->port); -if (tty) { -tty_vhangup (tty); -tty_kref_put (tty); - } +tty_port_tty_vhangup (&port->port);usb_serial_port_poison_urbs (port);wake_up_interruptible (&port->port.delta_msr_wait);cancel_work_sync (&port->work);
include/linux/tty_port.h +11 -1
@@ -186,7 +186,7 @@ int tty_port_carrier_raised(struct tty_port *port);void tty_port_raise_dtr_rts (struct tty_port *port);void tty_port_lower_dtr_rts (struct tty_port *port);void tty_port_hangup (struct tty_port *port); -void tty_port_tty_hangup (struct tty_port *port,bool check_clocal); +void __tty_port_tty_hangup (struct tty_port *port,bool check_clocal,bool async);void tty_port_tty_wakeup (struct tty_port *port);int tty_port_block_til_ready (struct tty_port *port,struct tty_struct *tty,struct file *filp);
@@ -205,4 +205,14 @@ static inline int tty_port_users(struct tty_port *port) return port->count + port->blocked_open; } +static inline void tty_port_tty_hangup (struct tty_port *port,bool check_clocal) +{ +__tty_port_tty_hangup (port, check_clocal, true); +} + +static inline void tty_port_tty_vhangup (struct tty_port *port) +{ +__tty_port_tty_hangup (port, false, false); +} +#endif
net/bluetooth/rfcomm/tty.c +1 -6
@@ -439,7 +439,6 @@ static int __rfcomm_release_dev(void __user *arg) {struct rfcomm_dev_req req;struct rfcomm_dev *dev; -struct tty_struct *tty;if (copy_from_user (&req, arg,sizeof (req)))return -EFAULT ;
@@ -465,11 +464,7 @@ static int __rfcomm_release_dev(void __user *arg)rfcomm_dlc_close (dev->dlc,0 );/* Shut down TTY synchronously before freeing rfcomm_dev */ - tty =tty_port_tty_get (&dev->port); -if (tty) { -tty_vhangup (tty); -tty_kref_put (tty); - } +tty_port_tty_vhangup (&dev->port);if (!test_and_set_bit (RFCOMM_TTY_OWNED , &dev->status))tty_port_put (&dev->port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 330/571 tty: port: fix tty_port_tty_vhangup() race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit b48820de8c1a596c5b99775524dfce73c6576c5d ]
Drivers rely on tty_port_tty_vhangup() to synchronously hang up their ports before tearing down resources as part of deregistration (e.g. on physical disconnect).
If tty_port_tty_vhangup() races with another hangup it may however return before the port has been shut down. This is in turn can lead to use-after-free and NULL-pointer dereferences in racing ioctls (including a synchronous hangup) and in processing of racing asynchronous hangups (carrier loss).
Add the missing serialisation to tty_port_tty_vhangup() and tty_port_hangup() so that the former does not return until the port has been shut down also when there is a racing hangup.
Note that serial core does not use tty_port_hangup(), but it already holds the port mutex when clearing port->tty and shutting down the port in uart_hangup().
[ Ting-Han: use mutex_lock()/spin_lock_irqsave() instead of guard(),
scoped_guard() and the tty_port_tty class, matching the existing code in this version of tty_port.c; tty_port_shutdown() has no kernel-doc here, so there is none to move ]
--- drivers/tty/tty_port.c | 54 ++++++++++++++++++++++++++++------------ include/linux/tty_port.h | 13 ++-------- 2 files changed, 40 insertions(+), 27 deletions(-)
drivers/tty/tty_port.c +38 -16
@@ -312,11 +312,12 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) }EXPORT_SYMBOL (tty_port_tty_set); -static void tty_port_shutdown (struct tty_port *port,struct tty_struct *tty) +static void tty_port_shutdown_locked (struct tty_port *port,struct tty_struct *tty) { -mutex_lock (&port->mutex); +lockdep_assert_held (&port->mutex); +if (port->console) - goto out; +return ;if (tty_port_initialized (port)) {tty_port_set_initialized (port,0 );
@@ -330,7 +331,12 @@ static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty)if (port->ops->shutdown) port->ops->shutdown (port); } -out: +} + +static void tty_port_shutdown (struct tty_port *port,struct tty_struct *tty) +{ +mutex_lock (&port->mutex); +tty_port_shutdown_locked (port, tty);mutex_unlock (&port->mutex); }
@@ -348,6 +354,7 @@ void tty_port_hangup(struct tty_port *port)struct tty_struct *tty;unsigned long flags; +mutex_lock (&port->mutex);spin_lock_irqsave (&port->lock, flags); port->count =0 ; tty = port->tty;
@@ -356,7 +363,8 @@ void tty_port_hangup(struct tty_port *port) port->tty =NULL ;spin_unlock_irqrestore (&port->lock, flags);tty_port_set_active (port,0 ); -tty_port_shutdown (port, tty); +tty_port_shutdown_locked (port, tty); +mutex_unlock (&port->mutex);tty_kref_put (tty);wake_up_interruptible (&port->open_wait);wake_up_interruptible (&port->delta_msr_wait);
@@ -364,24 +372,38 @@ void tty_port_hangup(struct tty_port *port)EXPORT_SYMBOL (tty_port_hangup);/** -* tty_port_tty_hangup - helper to hang up a tty -* +* tty_port_tty_hangup - helper to hang up a tty asynchronously * @port: tty port -* @check_clocal: hang only ttys with CLOCAL unset? +* @check_clocal: hang only ttys with %CLOCAL unset? */ -void __tty_port_tty_hangup (struct tty_port *port,bool check_clocal,bool async) +void tty_port_tty_hangup (struct tty_port *port,bool check_clocal) {struct tty_struct *tty =tty_port_tty_get (port); -if (tty && (!check_clocal || !C_CLOCAL (tty))) { -if (async) -tty_hangup (tty); -else -tty_vhangup (tty); - } +if (tty && (!check_clocal || !C_CLOCAL (tty))) +tty_hangup (tty);tty_kref_put (tty); } -EXPORT_SYMBOL_GPL (__tty_port_tty_hangup); +EXPORT_SYMBOL_GPL (tty_port_tty_hangup); + +/** +* tty_port_tty_vhangup - helper to hang up a tty synchronously +* @port: tty port +*/ +void tty_port_tty_vhangup (struct tty_port *port) +{ +struct tty_struct *tty; + +mutex_lock (&port->mutex); + tty =tty_port_tty_get (port); +mutex_unlock (&port->mutex); + +if (tty) { +tty_vhangup (tty); +tty_kref_put (tty); + } +} +EXPORT_SYMBOL_GPL (tty_port_tty_vhangup);/** * tty_port_tty_wakeup - helper to wake up a tty
include/linux/tty_port.h +2 -11
@@ -186,7 +186,8 @@ int tty_port_carrier_raised(struct tty_port *port);void tty_port_raise_dtr_rts (struct tty_port *port);void tty_port_lower_dtr_rts (struct tty_port *port);void tty_port_hangup (struct tty_port *port); -void __tty_port_tty_hangup (struct tty_port *port,bool check_clocal,bool async); +void tty_port_tty_hangup (struct tty_port *port,bool check_clocal); +void tty_port_tty_vhangup (struct tty_port *port);void tty_port_tty_wakeup (struct tty_port *port);int tty_port_block_til_ready (struct tty_port *port,struct tty_struct *tty,struct file *filp);
@@ -205,14 +206,4 @@ static inline int tty_port_users(struct tty_port *port) return port->count + port->blocked_open; } -static inline void tty_port_tty_hangup (struct tty_port *port,bool check_clocal) -{ -__tty_port_tty_hangup (port, check_clocal, true); -} - -static inline void tty_port_tty_vhangup (struct tty_port *port) -{ -__tty_port_tty_hangup (port, false, false); -} -#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 331/571 wifi: mac80211: keep paired old chanctx alive
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 3412e9a800786d1dec4a58367db1cba275e7ef11 ]
An in-place replacement keeps reciprocal replace_ctx pointers between the old WILL_BE_REPLACED chanctx and the new REPLACES_OTHER chanctx. However, the early free paths only consider assigned and reserved link users when deciding whether to free the old chanctx.
That lets the old chanctx be freed too early while the replacement partner still points back to it, either when the last assigned link is released or when that link successfully reassigns to another existing context. Later unreserve and switch-finalization paths can then follow a stale replace_ctx pointer.
Keep a paired old chanctx alive until the replacement pair has been torn down. Apply the same check to both __ieee80211_link_release_channel() and ieee80211_link_use_reserved_reassign(). If the replacement is later abandoned, ieee80211_link_unreserve_chanctx() already tears down the pairing before freeing the old chanctx once no users remain.
--- net/mac80211/chan.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/mac80211/chan.c +12 -2
@@ -940,6 +940,7 @@ void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,int ieee80211_vif_unreserve_chanctx (struct ieee80211_sub_if_data *sdata) {struct ieee80211_chanctx *ctx = sdata->reserved_chanctx; +struct ieee80211_chanctx *old_ctx =NULL ;lockdep_assert_held (&sdata->local->chanctx_mtx);
@@ -954,6 +955,7 @@ int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata)if (WARN_ON (!ctx->replace_ctx))return -EINVAL ; + old_ctx = ctx->replace_ctx;WARN_ON (ctx->replace_ctx->replace_state !=IEEE80211_CHANCTX_WILL_BE_REPLACED );WARN_ON (ctx->replace_ctx->replace_ctx != ctx);
@@ -964,6 +966,10 @@ int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata)list_del_rcu (&ctx->list);kfree_rcu (ctx, rcu_head); + +if (ieee80211_chanctx_refcount (sdata->local, + old_ctx) ==0 ) +ieee80211_free_chanctx (sdata->local, old_ctx); }else {ieee80211_free_chanctx (sdata->local, ctx); }
@@ -1177,7 +1183,9 @@ ieee80211_vif_use_reserved_reassign(struct ieee80211_sub_if_data *sdata)ieee80211_check_fast_xmit_iface (sdata); -if (ieee80211_chanctx_refcount (local, old_ctx) ==0 ) +if (ieee80211_chanctx_refcount (local, old_ctx) ==0 && + !(old_ctx->replace_state ==IEEE80211_CHANCTX_WILL_BE_REPLACED && + old_ctx->replace_ctx))ieee80211_free_chanctx (local, old_ctx);ieee80211_recalc_chanctx_min_def (local, new_ctx);
@@ -1649,7 +1657,9 @@ static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata) }ieee80211_assign_vif_chanctx (sdata,NULL ); -if (ieee80211_chanctx_refcount (local, ctx) ==0 ) +if (ieee80211_chanctx_refcount (local, ctx) ==0 && + !(ctx->replace_state ==IEEE80211_CHANCTX_WILL_BE_REPLACED && + ctx->replace_ctx))ieee80211_free_chanctx (local, ctx); sdata->radar_required = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/571 wifi: mac80211: count only matching reservations in reserved switch
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 437f3727b4fd715266c296435c116288f82666fd ]
ieee80211_vif_use_reserved_switch() validates a replacement by counting assigned links on ctx->replace_ctx and treating reservations too broadly. A link can still be assigned to the old channel context while holding a reservation that belongs to a different replacement operation.
That can make the current replacement appear complete too early. If another link finalizes first, the function can free the WILL_BE_REPLACED chanctx while the unmatched link and driver still use it, leading to a use-after-free in later beacon generation.
Require an in-place reservation to point at the current replacement context, and require the reserved and assigned contexts to be the matching replacement pair, before counting or moving the link.
--- net/mac80211/chan.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
net/mac80211/chan.c +16 -6
@@ -1248,7 +1248,8 @@ ieee80211_vif_use_reserved_assign(struct ieee80211_sub_if_data *sdata) }static bool -ieee80211_vif_has_in_place_reservation (struct ieee80211_sub_if_data *sdata) +ieee80211_vif_has_in_place_reservation (struct ieee80211_sub_if_data *sdata, +struct ieee80211_chanctx *ctx) {struct ieee80211_chanctx *old_ctx, *new_ctx;
@@ -1257,6 +1258,9 @@ ieee80211_vif_has_in_place_reservation(struct ieee80211_sub_if_data *sdata) new_ctx = sdata->reserved_chanctx; old_ctx =ieee80211_vif_get_chanctx (sdata); +if (new_ctx != ctx) +return false; +if (!old_ctx)return false;
@@ -1269,6 +1273,12 @@ ieee80211_vif_has_in_place_reservation(struct ieee80211_sub_if_data *sdata)if (new_ctx->replace_state !=IEEE80211_CHANCTX_REPLACES_OTHER )return false; +if (new_ctx->replace_ctx != old_ctx) +return false; + +if (old_ctx->replace_ctx != new_ctx) +return false; +return true; }
@@ -1319,7 +1329,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,list_for_each_entry (sdata, &ctx->reserved_vifs, reserved_chanctx_list) {if (!ieee80211_vif_has_in_place_reservation ( - sdata)) + sdata, ctx))continue ; old_ctx =ieee80211_vif_get_chanctx (sdata);
@@ -1426,7 +1436,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)list_for_each_entry (sdata, &ctx->replace_ctx->assigned_vifs, assigned_chanctx_list) { n_assigned++; -if (sdata->reserved_chanctx) { +if (ieee80211_vif_has_in_place_reservation (sdata, ctx)) { n_reserved++;if (sdata->reserved_ready) n_ready++;
@@ -1447,7 +1457,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local) ctx->conf.radar_enabled = false;list_for_each_entry (sdata, &ctx->reserved_vifs, reserved_chanctx_list) { -if (ieee80211_vif_has_in_place_reservation (sdata) && +if (ieee80211_vif_has_in_place_reservation (sdata, ctx) && !sdata->reserved_ready)return -EAGAIN ;
@@ -1517,7 +1527,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local) reserved_chanctx_list) {u32 changed =0 ; -if (!ieee80211_vif_has_in_place_reservation (sdata)) +if (!ieee80211_vif_has_in_place_reservation (sdata, ctx))continue ;rcu_assign_pointer (sdata->vif.chanctx_conf, &ctx->conf);
@@ -1570,7 +1580,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)list_for_each_entry_safe (sdata, sdata_tmp, &ctx->reserved_vifs, reserved_chanctx_list) {if (WARN_ON (ieee80211_vif_has_in_place_reservation ( - sdata))) + sdata, ctx)))continue ;if (WARN_ON (sdata->reserved_chanctx != ctx))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/571 fs: Free any excess xarray nodes in clear_inode()
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 ee3f011250104129893d8e9599147e457d4d7280 ]
For many years we've had a hard to hit leak of xarray nodes. Hugh documented it well in commit 786b31121a2c. Recently people and syzbot have found ways to force it to happen with madvise. Rather than fix the leaks where they happen, just call xa_destroy() which has the side-effect of cycling the i_pages lock.
--- fs/inode.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
fs/inode.c +10 -13
@@ -584,21 +584,18 @@ EXPORT_SYMBOL(__remove_inode_hash);void clear_inode (struct inode *inode) {/* -* We have to cycle the i_pages lock here because reclaim can be in the -* process of removing the last page (in __delete_from_page_cache()) -* and we must not free the mapping under it. +* We have to cycle the i_pages lock here because reclaim +* can be in the process of removing the last page (in +* __delete_from_page_cache()) and we must not free the mapping +* under it. We also remove nodes which are empty; these +* can occur in two different ways. The first is that radix +* tree expansion can fail partway and the second is that THP +* collapse_file() can allocate some temporary nodes and not +* clean them up. */ -xa_lock_irq (&inode->i_data.i_pages); +xa_destroy (&inode->i_data.i_pages); +BUG_ON (inode->i_data.nrpages); -/* -* Almost always, mapping_empty(&inode->i_data) here; but there are -* two known and long-standing ways in which nodes may get left behind -* (when deep radix-tree node allocation failed partway; or when THP -* collapse_file() failed). Until those two known cases are cleaned up, -* or a cleanup function is called here, do not BUG_ON(!mapping_empty), -* nor even WARN_ON(!mapping_empty). -*/ -xa_unlock_irq (&inode->i_data.i_pages);BUG_ON (!list_empty (&inode->i_data.private_list));BUG_ON (!(inode->i_state &I_FREEING ));BUG_ON (inode->i_state &I_CLEAR );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/571 mm/hugetlb: fix avoid_reserve to allow taking folio from subpool
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Xu <[email protected]>
commit 58db7c5fbe7daa42098d4965133a864f98ba90ba upstream.
Patch series "mm/hugetlb: Refactor hugetlb allocation resv accounting", v2.
This is a follow up on Ackerley's series here as replacement:
https://lore.kernel.org/r/[email protected]
The goal of this series is to cleanup hugetlb resv accounting, especially during folio allocation, to decouple a few things:
- Hugetlb folios v.s. Hugetlbfs: IOW, the hope is in the future hugetlb folios can be allocated completely without hugetlbfs.
- Decouple VMA v.s. hugetlb folio allocations: allocating a hugetlb folio should not always require a hugetlbfs VMA. For example, either it got allocated from the inode level (see hugetlbfs_fallocate() where it used a pesudo VMA for allocation), or it can be allocated by other kernel subsystems.
It paves way for other users to allocate hugetlb folios out of either system reservations, or subpools (instead of hugetlbfs, as a file system). For longer term, this prepares hugetlb as a separate concept versus hugetlbfs, so that hugetlb folios can be allocated by not only hugetlbfs and other things.
Tests I've done:
- I had a reproducer in patch 1 for the bug I found, this will start to work after patch 1 or the whole set applied.
- Hugetlb regression tests (on x86_64 2MBs), includes:
- All vmtests on hugetlbfs
- libhugetlbfs test suite (which may fail some tests, but no new failures will be introduced by this series, so all such failures happen before this series so shouldn't be relevant).
This patch (of 7):
Since commit 04f2cbe35699 ("hugetlb: guarantee that COW faults for a process that called mmap(MAP_PRIVATE) on hugetlbfs will succeed"), avoid_reserve was introduced for a special case of CoW on hugetlb private mappings, and only if the owner VMA is trying to allocate yet another hugetlb folio that is not reserved within the private vma reserved map.
Later on, in commit d85f69b0b533 ("mm/hugetlb: alloc_huge_page handle areas hole punched by fallocate"), alloc_huge_page() enforced to not consume any global reservation as long as avoid_reserve=true. This operation doesn't look correct, because even if it will enforce the allocation to not use global reservation at all, it will still try to take one reservation from the spool (if the subpool existed). Then since the spool reserved pages take from global reservation, it'll also take one reservation globally.
Logically it can cause global reservation to go wrong.
I wrote a reproducer below, trigger this special path, and every run of such program will cause global reservation count to increment by one, until it hits the number of free pages:
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>
#define MSIZE (2UL << 20)
int main(int argc, char *argv[])
{
const char *path;
int *buf;
int fd, ret;
pid_t child; if (argc < 2) {
printf("usage: %s <hugetlb_file>\n", argv[0]);
return -1;
}
path = argv[1];
fd = open(path, O_RDWR | O_CREAT, 0666);
if (fd < 0) {
perror("open failed");
return -1;
}
ret = fallocate(fd, 0, 0, MSIZE);
if (ret != 0) {
perror("fallocate");
return -1;
}
buf = mmap(NULL, MSIZE, PROT_READ|PROT_WRITE,
MAP_PRIVATE, fd, 0);
if (buf == MAP_FAILED) {
perror("mmap() failed");
return -1;
}
/* Allocate a page */
*buf = 1;
child = fork();
if (child == 0) {
/* child doesn't need to do anything */
exit(0);
}
/* Trigger CoW from owner */
*buf = 2;
munmap(buf, MSIZE);
close(fd);
unlink(path);
return 0;}
It can only reproduce with a sub-mount when there're reserved pages on the spool, like:
# sysctl vm.nr_hugepages=128 # mkdir ./hugetlb-pool # mount -t hugetlbfs -o min_size=8M,pagesize=2M none ./hugetlb-pool
Then run the reproducer on the mountpoint:
# ./reproducer ./hugetlb-pool/test
Fix it by taking the reservation from spool if available. In general, avoid_reserve is IMHO more about "avoid vma resv map", not spool's.
I copied stable, however I have no intention for backporting if it's not a clean cherry-pick, because private hugetlb mapping, and then fork() on top is too rare to hit.
[ Karl Mehltretter: The upstream changes map directly to this stable tree's
page-based HugeTLB API. The backport retains this stable tree's inline free-minus-reserved calculation and direct -ENOSPC return; the functional changes otherwise match upstream. ]
--- mm/hugetlb.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
mm/hugetlb.c +3 -19
@@ -1144,8 +1144,7 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask,static struct page *dequeue_huge_page_vma (struct hstate *h,struct vm_area_struct *vma, -unsigned long address,int avoid_reserve, -long chg) +unsigned long address,long chg) {struct page *page =NULL ;struct mempolicy *mpol;
@@ -1162,10 +1161,6 @@ static struct page *dequeue_huge_page_vma(struct hstate *h, h->free_huge_pages - h->resv_huge_pages == 0) goto err; -/* If reserves cannot be used, ensure enough pages are in the pool */ -if (avoid_reserve && h->free_huge_pages - h->resv_huge_pages ==0 ) - goto err; - gfp_mask =htlb_alloc_mask (h); nid =huge_node (vma, address, gfp_mask, &mpol, &nodemask);
@@ -1179,7 +1174,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,if (!page) page =dequeue_huge_page_nodemask (h, gfp_mask, nid, nodemask); -if (page && !avoid_reserve &&vma_has_reserves (vma, chg)) { +if (page &&vma_has_reserves (vma, chg)) {SetHPageRestoreReserve (page); h->resv_huge_pages--; }
@@ -2775,17 +2770,6 @@ struct page *alloc_huge_page(struct vm_area_struct *vma,vma_end_reservation (h, vma, addr);return ERR_PTR (-ENOSPC ); } - -/* -* Even though there was no reservation in the region/reserve -* map, there could be reservations associated with the -* subpool that can be used. This would be indicated if the -* return value of hugepage_subpool_get_pages() is zero. -* However, if avoid_reserve is specified we still avoid even -* the subpool reservations. -*/ -if (avoid_reserve) - gbl_chg =1 ; }/* If this allocation is not consuming a reservation, charge it now.
@@ -2808,7 +2792,7 @@ struct page *alloc_huge_page(struct vm_area_struct *vma,* from the global free pool (global change). gbl_chg == 0 indicates * a reservation exists for the allocation. */ - page =dequeue_huge_page_vma (h, vma, addr, avoid_reserve, gbl_chg); + page =dequeue_huge_page_vma (h, vma, addr, gbl_chg);if (!page) {spin_unlock_irq (&hugetlb_lock); page =alloc_buddy_huge_page_with_mpol (h, vma, addr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/571 KVM: SVM: Use the active VMCBs MSR bitmap when checking if MSR is intercepted
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 9e06bbb9ade7cdf28d4a3b5b14e5812881c8df85 ]
Use the MSR permission bitmap of the active VMCB instead of assuming that KVM is always using vmcb02's bitmap when L2 is active, as KVM uses msrpm02 if and only if L1 wants to intercept MSR accesses, i.e. if and only if KVM needs to merge msprm01 with msrpm12.
Don't bother tracking the virtual address of the bitmap that's being used, as __va() is cheap on x86, and caching the virtual address would introduce yet another source of potentially stale information.
Message-ID: <[email protected]>
--- arch/x86/kvm/svm/svm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/svm/svm.c +1 -2
@@ -656,8 +656,7 @@ static bool msr_write_intercepted(struct kvm_vcpu *vcpu, u32 msr)u32 offset;u32 *msrpm; - msrpm =is_guest_mode (vcpu) ?to_svm (vcpu)->nested.msrpm: -to_svm (vcpu)->msrpm; + msrpm =__va (__sme_clr (to_svm (vcpu)->vmcb->control.msrpm_base_pa)); offset =svm_msrpm_offset (msr); bit_write =2 * (msr &0x0f ) +1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/571 wifi: mac80211: set info->band for 802.3 encap offload frames
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 4febc02cd02f021f2b6d0768332be643ef14a12d ]
Unlike the 802.11 TX paths, ieee80211_8023_xmit() does not set info->band from the channel context on non-MLD interfaces. It stays at 0, so ieee80211_get_tx_rates() uses the wrong band for these frames.
Set it the same way as ieee80211_build_hdr(): drop the frame if there is no channel context, and leave the band at 0 on MLD interfaces.
--- net/mac80211/tx.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/mac80211/tx.c +6 -0
@@ -4467,6 +4467,7 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, {struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);struct ieee80211_local *local = sdata->local; +struct ieee80211_chanctx_conf *chanctx_conf;struct tid_ampdu_tx *tid_tx;u8 tid;
@@ -4514,6 +4515,11 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, sdata =container_of (sdata->bss, struct ieee80211_sub_if_data, u.ap); + chanctx_conf =rcu_dereference (sdata->vif.chanctx_conf); +if (unlikely (!chanctx_conf)) + goto out_free; + info->band = chanctx_conf->def.chan->band; + info->flags |=IEEE80211_TX_CTL_HW_80211_ENCAP ; info->control.vif = &sdata->vif;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/571 smb: client: discard post-EOF pagecache when extending a file via zero range
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
[ Upstream commit da4fe97fb6c730d9c94a115c7bfa6f98e0d578d0 ]
smb3_zero_range() removed the pagecache only for the range being zeroed, so when it extends the file the folio straddling the old EOF - which may hold data dirtied past EOF through an mmap - was never dropped and became visible as file content once the file was extended.
Lower the discard boundary to the smaller of the zero-range offset and the old EOF.
--- fs/cifs/smb2ops.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/cifs/smb2ops.c +5 -1
@@ -3601,8 +3601,12 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,/* * We zero the range through ioctl, so we need remove the page caches * first, otherwise the data may be inconsistent with the server. +* +* Start at the old EOF when extending so the folio straddling it, which +* may hold data written past EOF through an mmap, is dropped too. */ -truncate_pagecache_range (inode, offset, offset + len -1 ); +truncate_pagecache_range (inode,min (offset,i_size_read (inode)), + offset + len -1 );/* if file not oplocked can't be sure whether asking to extend size */ if (!CIFS_CACHE_READ (cifsi))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/571 iio: adc: aspeed: propagate reset deassert errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 95e4eb426b4bd666fa2f37886c0ddf74a0cc6167 ]
aspeed_adc_probe() continues to register ADC resources after deasserting the shared reset, even if the reset controller reports a failure.
A failed deassertion leaves the hardware unavailable, so stop probing before installing the cleanup action and enabling the ADC.
--- drivers/iio/adc/aspeed_adc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/aspeed_adc.c +3 -1
@@ -221,7 +221,9 @@ static int aspeed_adc_probe(struct platform_device *pdev) ret =PTR_ERR (data->rst); goto reset_error; } -reset_control_deassert (data->rst); + ret =reset_control_deassert (data->rst); +if (ret) + goto reset_error; model_data =of_device_get_match_data (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/571 iio: adc: max1363: sign-extend bipolar differential channel reads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit 91908c0a78baddc8572aa3ab69e62ee2eb496ba4 ]
MAX1363 differential channels are bipolar, but max1363_read_single_chan() masks the raw value to the ADC resolution without sign-extending it. Negative differential readings are therefore reported to userspace as large positive values (e.g. -1 as 4095 on a 12-bit part).
Sign-extend the masked value from the resolution bit for differential channels. Single-ended channels are unipolar and are left unchanged.
--- drivers/iio/adc/max1363.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iio/adc/max1363.c +8 -0
@@ -409,6 +409,14 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev, } data = rxbuf[0 ]; } + +/* +* Differential channels are bipolar and the device returns the sample +* in two's complement, so sign-extend it from the resolution bit. +*/ +if (chan->differential) + data =sign_extend32 (data, st->chip_info->bits -1 ); + *val = data; error_ret:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/571 HID: core: introduce hid_safe_input_report()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Tissoires <[email protected]>
[ Upstream commit 206342541fc887ae919774a43942dc883161fece ]
hid_input_report() is used in too many places to have a commit that doesn't cross subsystem borders. Instead of changing the API, introduce a new one when things matters in the transport layers:
- usbhid
- i2chid
This effectively revert to the old behavior for those two transport layers.
[Lee: Implement hid_safe_input_report() directly and wrap it from
hid_input_report() as 67eccf151d76 ("HID: add source argument to HID low level functions") is not present. Use int for report type and literal 2 in i2c_hid_get_input() as 56fc4f7bc114 and 1bdbe0dcff2f are not present]
--- drivers/hid/hid-core.c | 26 ++++++++++++++++++++++++-- drivers/hid/i2c-hid/i2c-hid-core.c | 5 +++-- drivers/hid/usbhid/hid-core.c | 11 ++++++----- include/linux/hid.h | 2 ++ 4 files changed, 35 insertions(+), 9 deletions(-)
drivers/hid/hid-core.c +24 -2
@@ -1873,13 +1873,35 @@ EXPORT_SYMBOL_GPL(hid_report_raw_event);* @interrupt: distinguish between interrupt and control transfers * * This is data entry for lower layers. +* Legacy, please use hid_safe_input_report() instead. */ int hid_input_report (struct hid_device *hid,int type,u8 *data,u32 size,int interrupt) +{ +return hid_safe_input_report (hid, type, data, size, size, interrupt); +} +EXPORT_SYMBOL_GPL (hid_input_report); + +/** +* hid_safe_input_report - report data from lower layer (usb, bt...) +* +* @hid: hid device +* @type: HID report type (HID_*_REPORT) +* @data: report contents +* @bufsize: allocated size of the data buffer +* @size: useful size of data parameter +* @interrupt: distinguish between interrupt and control transfers +* +* This is data entry for lower layers. +* Please use this function instead of the non safe version because we provide +* here the size of the buffer, allowing hid-core to make smarter decisions +* regarding the incoming buffer. +*/ +int hid_safe_input_report (struct hid_device *hid,int type,u8 *data, +size_t bufsize,u32 size,int interrupt) {struct hid_report_enum *report_enum;struct hid_driver *hdrv;struct hid_report *report; -size_t bufsize = size;int ret =0 ;if (!hid)
@@ -1924,7 +1946,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, u32 size, int iup (&hid->driver_input_lock);return ret; } -EXPORT_SYMBOL_GPL (hid_input_report); +EXPORT_SYMBOL_GPL (hid_safe_input_report);bool hid_match_one_id (const struct hid_device *hdev,const struct hid_device_id *id)
drivers/hid/i2c-hid/i2c-hid-core.c +3 -2
@@ -518,8 +518,9 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)i2c_hid_dbg (ihid,"input: %*ph\n" , ret_size, ihid->inbuf);if (test_bit (I2C_HID_STARTED , &ihid->flags)) -hid_input_report (ihid->hid,HID_INPUT_REPORT , ihid->inbuf +2 , - ret_size -2 ,1 ); +hid_safe_input_report (ihid->hid,HID_INPUT_REPORT , + ihid->inbuf +2 , ihid->bufsize -2 , + ret_size -2 ,1 );return ; }
drivers/hid/usbhid/hid-core.c +6 -5
@@ -281,9 +281,9 @@ static void hid_irq_in(struct urb *urb)break ;usbhid_mark_busy (usbhid);if (!test_bit (HID_RESUME_RUNNING , &usbhid->iofl)) { -hid_input_report (urb->context,HID_INPUT_REPORT , - urb->transfer_buffer, - urb->actual_length,1 ); +hid_safe_input_report (urb->context,HID_INPUT_REPORT , + urb->transfer_buffer, urb->transfer_buffer_length, + urb->actual_length,1 );/* * autosuspend refused while keys are pressed * because most keyboards don't wake up when
@@ -480,9 +480,10 @@ static void hid_ctrl(struct urb *urb)switch (status) {case 0 :/* success */ if (usbhid->ctrl[usbhid->ctrltail].dir ==USB_DIR_IN ) -hid_input_report (urb->context, +hid_safe_input_report (urb->context, usbhid->ctrl[usbhid->ctrltail].report->type, - urb->transfer_buffer, urb->actual_length,0 ); + urb->transfer_buffer, urb->transfer_buffer_length, + urb->actual_length,0 );break ;case -ESHUTDOWN :/* unplug */ unplug =1 ;
include/linux/hid.h +2 -0
@@ -937,6 +937,8 @@ extern void hidinput_disconnect(struct hid_device *);int hid_set_field (struct hid_field *,unsigned ,__s32 );int hid_input_report (struct hid_device *,int type,u8 *,u32 ,int ); +int hid_safe_input_report (struct hid_device *hid,int type,u8 *data, +size_t bufsize,u32 size,int interrupt);int hidinput_find_field (struct hid_device *hid,unsigned int type,unsigned int code,struct hid_field **field);struct hid_field *hidinput_get_led_field (struct hid_device *hid);unsigned int hidinput_count_leds (struct hid_device *hid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/571 HID: uhid: convert to hid_safe_input_report()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Llamas <[email protected]>
[ Upstream commit 63a694c51bf120a37550890b8e7736b4888985e9 ]
Commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()"), added a check in hid_report_raw_event() to reject reports if the received data size is smaller than expected. This was intended to prevent OOB errors by no longer allowing zeroing-out of shorter reports due to the lack of buffer size information.
However, this leads to regressions in hid_report_raw_event(), where shorter than expected reports are rejected, even though their buffers are sufficiently large to be zero-padded.
To solve this issue, Benjamin introduced a safer alternative in commit 206342541fc8 ("HID: core: introduce hid_safe_input_report()"), which forwards the buffer size and allows hid_report_raw_event() to safely zero-pad the data.
Convert uhid to use hid_safe_input_report() and pass UHID_DATA_MAX as the buffer size. This prevents the reported regressions [1], allowing hid core to zero-pad the shorter reports safely as expected.
--- drivers/hid/uhid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hid/uhid.c +4 -4
@@ -597,8 +597,8 @@ static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)if (!READ_ONCE (uhid->running))return -EINVAL ; -hid_input_report (uhid->hid,HID_INPUT_REPORT , ev->u.input.data, -min_t (size_t, ev->u.input.size,UHID_DATA_MAX ),0 ); +hid_safe_input_report (uhid->hid,HID_INPUT_REPORT , ev->u.input.data,UHID_DATA_MAX , +min_t (size_t, ev->u.input.size,UHID_DATA_MAX ),0 );return 0 ; }
@@ -608,8 +608,8 @@ static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)if (!READ_ONCE (uhid->running))return -EINVAL ; -hid_input_report (uhid->hid,HID_INPUT_REPORT , ev->u.input2.data, -min_t (size_t, ev->u.input2.size,UHID_DATA_MAX ),0 ); +hid_safe_input_report (uhid->hid,HID_INPUT_REPORT , ev->u.input2.data,UHID_DATA_MAX , +min_t (size_t, ev->u.input2.size,UHID_DATA_MAX ),0 );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/571 crypto: drbg - Fix ineffective sanity check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 040ad83b0e8aa065fd2fc641cacba8491a8b186d upstream.
Fix drbg_healthcheck_sanity() to correctly check the return value of drbg_generate(). drbg_generate() returns 0 on success, or a negative errno value on failure. drbg_healthcheck_sanity() incorrectly assumed that it returned a positive value on success.
This didn't make the sanity check fail, but it made it ineffective.
--- crypto/drbg.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
crypto/drbg.c +5 -6
@@ -1976,7 +1976,6 @@ static int drbg_kcapi_seed(struct crypto_rng *tfm,*/ static inline int __init drbg_healthcheck_sanity (void ) { -int len =0 ;#define OUTBUFLEN 16unsigned char buf[OUTBUFLEN ];struct drbg_state *drbg =NULL ;
@@ -2018,12 +2017,12 @@ static inline int __init drbg_healthcheck_sanity(void) max_addtllen =drbg_max_addtl (drbg); max_request_bytes =drbg_max_request_bytes (drbg);drbg_string_fill (&addtl, buf, max_addtllen +1 ); -/* overflow addtllen with additonal info string */ - len =drbg_generate (drbg, buf,OUTBUFLEN , &addtl); -BUG_ON (0 < len); +/* overflow addtllen with additional info string */ + ret =drbg_generate (drbg, buf,OUTBUFLEN , &addtl); +BUG_ON (ret ==0 );/* overflow max_bits */ - len =drbg_generate (drbg, buf, (max_request_bytes +1 ),NULL ); -BUG_ON (0 < len); + ret =drbg_generate (drbg, buf, max_request_bytes +1 ,NULL ); +BUG_ON (ret ==0 );/* overflow max addtllen with personalization string */ ret =drbg_seed (drbg, &addtl, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/571 ipv4: stop PMTU walk when nexthop group shrinks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit 6619e01855e65ef35723685a557e3eb106f4ecf5 upstream.
Commit 7d3f3b4367f3 ("net: ipv4: Cache pmtu for all packet paths if multipath enabled") made __ip_rt_update_pmtu() update every path.
For nexthop objects, fib_info_num_path() and fib_info_nhc() independently load nh->nh_grp. RCU protects each group's lifetime but does not make the loads observe the same group. If replacement shrinks the group after the loop accepts an index, fib_info_nhc() returns NULL and update_or_create_fnhe() dereferences it.
A deterministic probe only widened the existing window between the real operations. On v7.2, an RTM_NEWNEXTHOP replacement published a one-member group after the PMTU reader accepted index 1 from a two-member group, producing:
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: update_or_create_fnhe+0x45/0x15b0
Stop when the indexed path is absent. Groups are dense, so no later index exists in that snapshot. The same real-writer window completed 114,423 PMTU iterations without an oops with this check. A reproducer is available on request.
Replacement requires CAP_NET_ADMIN in the network namespace. Where unprivileged user namespaces are permitted, a local user can obtain it in a new user and network namespace.
--- net/ipv4/route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/route.c +2 -0
@@ -1094,6 +1094,8 @@ static void __ip_rt_update_pmtu(struct rfor (nhsel =0 ; nhsel <fib_info_num_path (res.fi); nhsel++) { nhc =fib_info_nhc (res.fi, nhsel); +if (!nhc) +break ;update_or_create_fnhe (nhc, fl4->daddr,0 , mtu, lock, jiffies + net->ipv4.ip_rt_mtu_expires); }
Greg Kroah-Hartman
maintainerPATCH 344/571 ipv4: stop route notification sizing when nexthop group shrinks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit d3daa33c7af92e38f2274bbd2576f58bfbaf89e6 upstream.
Commit 680aea08e78c ("net: ipv4: Emit notification when fib hardware flags are changed") added an RCU-only fib_nlmsg_size() call for asynchronous hardware flag notifications.
fib_nlmsg_size() checks fib_info_num_path() before each iteration, then fib_info_nhc() independently reloads nh->nh_grp. If RTM_NEWNEXTHOP replaces a group with fewer paths between those loads, fib_info_nhc() returns NULL and fib_nexthop_nlmsg_size() dereferences it.
Stop sizing when the indexed path is absent. Nexthop groups are dense, so the current snapshot has no later path.
--- net/ipv4/fib_semantics.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/fib_semantics.c +3 -0
@@ -512,6 +512,9 @@ size_t fib_nlmsg_size(struct fib_info *fstruct fib_nh_common *nhc =fib_info_nhc (fi, i);size_t nhsize; +if (!nhc) +break ; + nhsize =fib_nexthop_nlmsg_size (nhc, nhs !=1 );if (nhs !=1 )
Greg Kroah-Hartman
maintainerPATCH 345/571 ipv4: do not warn on route notification size race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit e02a5b6588161673ef75a4bc5cdfb62bd493374d upstream.
Commit 680aea08e78c ("net: ipv4: Emit notification when fib hardware flags are changed") added asynchronous route notifications for hardware flag changes.
fib_alias_hw_flags_set() sizes the skb with fib_nlmsg_size() and later fills it with fib_dump_info() while holding only RCU. With nexthop compatibility mode enabled, a concurrent replacement can grow the group between these independent snapshots. fib_dump_info() can then legitimately return -EMSGSIZE, so the warning does not prove a sizing bug.
Remove the warning. The existing error path still frees the skb and reports the error to listeners.
--- net/ipv4/fib_trie.c | 2 -- 1 file changed, 2 deletions(-)
net/ipv4/fib_trie.c +0 -2
@@ -1079,8 +1079,6 @@ void fib_alias_hw_flags_set(struct net * err =fib_dump_info (skb,0 ,0 ,RTM_NEWROUTE , fri,0 );if (err <0 ) { -/* -EMSGSIZE implies BUG in fib_nlmsg_size() */ -WARN_ON (err == -EMSGSIZE );kfree_skb (skb); goto errout; }
Greg Kroah-Hartman
maintainerPATCH 346/571 ipv6: do not warn on route notification size race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit c97426ec649d99596d8969e1a052c16b14b7b485 upstream.
fib6_info_hw_flags_set() sizes the skb with rt6_nlmsg_size() and later fills it with rt6_fill_node(). With nexthop compatibility mode enabled, a concurrent replacement can grow the group between these independent snapshots. rt6_fill_node() can then legitimately return -EMSGSIZE, so the warning does not prove a sizing bug.
Remove the warning. The existing error path still frees the skb and reports the error to listeners.
--- net/ipv6/route.c | 2 -- 1 file changed, 2 deletions(-)
net/ipv6/route.c +0 -2
@@ -6270,8 +6270,6 @@ void fib6_info_hw_flags_set(struct net * err =rt6_fill_node (net, skb, f6i,NULL ,NULL ,NULL ,0 ,RTM_NEWROUTE ,0 ,0 ,0 );if (err <0 ) { -/* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ -WARN_ON (err == -EMSGSIZE );kfree_skb (skb); goto errout; }
Greg Kroah-Hartman
maintainerPATCH 347/571 btrfs: scrub: fix local_root reference leak in scrub_print_warning_inode()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 1fd742c7479961da6d0bb794ef8ac6b7b9442847 upstream.
When paths_from_inode() fails, scrub_print_warning_inode() jumps to err without dropping the reference taken by btrfs_get_fs_root(), leaking a reference to the root every time path resolution fails while printing scrub warnings. Every other error and success path of the function drops the reference.
Drop the reference on the paths_from_inode() failure path too.
--- fs/btrfs/scrub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/scrub.c +3 -1
@@ -685,8 +685,10 @@ static int scrub_print_warning_inode(u64 } ret =paths_from_inode (inum, ipath); -if (ret <0 ) +if (ret <0 ) { +btrfs_put_root (local_root); goto err; + }/* * we deliberately ignore the bit ipath might have been too small to
Greg Kroah-Hartman
maintainerPATCH 348/571 dm ioctl: dont let data_start run past the buffer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Palla Raghunath <[email protected]>
commit 9b3fcf519d370df94a56f3b272d9eddffffa5be8 upstream.
struct dm_ioctl has seven bytes of trailing padding, so the smallest buffer userspace is allowed to ask for, offsetof(struct dm_ioctl, data), is seven bytes shorter than sizeof(struct dm_ioctl).
get_result_buffer() sets data_start to sizeof(struct dm_ioctl) without looking at how big the buffer actually is. Ask for the minimum and data_start ends up seven bytes past the end. Callers add it to data_size, and ctl_ioctl() copies that much back to userspace:
BUG: KASAN: slab-out-of-bounds in _copy_to_user+0xad/0xd0 Read of size 312 at addr ffff8880169e4c00 by task repro-dm/140 ctl_ioctl+0x5e3/0xcb0 dm_ctl_ioctl+0x25/0x40 allocated 305-byte region [ffff8880169e4c00, ffff8880169e4d31)
A DM_LIST_DEVICES with data_size set to 305 is enough to hit it, and the seven bytes that leak are whatever sat next to the allocation.
Clamp data_start to the buffer size.
Note that this is not a security bug because the out-of-bounds read can only be triggered by root.
--- drivers/md/dm-ioctl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/md/dm-ioctl.c +8 -2
@@ -538,10 +538,16 @@ static void *get_result_buffer(struct dm { param->data_start =align_ptr (param +1 ) - (void *) param; -if (param->data_start < param_size) +if (param->data_start < param_size) { *len = param_size - param->data_start; -else + }else { +/* +* The buffer can be as small as offsetof(*param, data), which +* is less than sizeof(*param), so don't run off the end of it. +*/ *len =0 ; + param->data_start = param_size; + }return ((void *) param) + param->data_start; }
Greg Kroah-Hartman
maintainerPATCH 349/571 wifi: brcmfmac: fix P2P device removal race in brcmf_detach()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michele Dionisio <[email protected]>
commit 08a3f02fea636e97a7422d1512f76dacdb5b0887 upstream.
When the driver is removed while the user space process that created the P2P device (e.g. wpa_supplicant) is still exiting, the P2P device interface is removed twice and the kernel crashes.
The two paths are:
- wpa_supplicant, on exit, sends NL80211_CMD_DEL_INTERFACE for the P2P device. nl80211_del_interface() holds RTNL and the wiphy mutex and calls brcmf_p2p_del_vif(), which disables discovery and waits up to 1.5 s for BRCMF_E_IF_DEL. Then it calls brcmf_remove_interface(), which unregisters the wdev and frees the vif and the ifp.
- brcmf_detach() sets the bus down, so BRCMF_E_IF_DEL never arrives, and calls brcmf_remove_interface(ifp, false) for the same ifp. brcmf_p2p_ifp_removed() reads ifp->vif and then blocks on rtnl_lock(). When brcmf_p2p_del_vif() releases RTNL, it calls cfg80211_unregister_wdev() on the wdev that was already unregistered and freed.
The second list_del_rcu() of wdev->list faults on LIST_POISON2:
brcmfmac: brcmf_p2p_del_vif delete P2P vif
brcmfmac: brcmf_p2p_deinit_discovery enter
brcmfmac: brcmf_p2p_del_vif P2P: GO_NEG_PHASE status cleared
brcmfmac: brcmf_detach Enter
brcmfmac: brcmf_bus_change_state 1 -> 0
brcmfmac: brcmf_remove_interface Enter, bsscfgidx=1, ifidx=0
brcmfmac: brcmf_del_if Enter, bsscfgidx=1, ifidx=0
brcmfmac: brcmf_p2p_ifp_removed P2P: device interface removed [1.5 s later, brcmf_p2p_del_vif() timed out]
brcmfmac: brcmf_remove_interface Enter, bsscfgidx=1, ifidx=0
brcmfmac: brcmf_del_if Enter, bsscfgidx=1, ifidx=0
brcmfmac: brcmf_p2p_ifp_removed P2P: device interface removed
Unable to handle kernel paging request at virtual address dead000000000122 Internal error: Oops: 96000044 [#1] PREEMPT_RT SMP pc : _cfg80211_unregister_wdev+0x6c/0x264 [cfg80211] Call trace: _cfg80211_unregister_wdev+0x6c/0x264 [cfg80211] cfg80211_unregister_wdev+0x10/0x1c [cfg80211] brcmf_p2p_ifp_removed+0x84/0xb0 [brcmfmac] brcmf_remove_interface+0x1f4/0x254 [brcmfmac] brcmf_detach+0x88/0x180 [brcmfmac] brcmf_sdio_remove+0x90/0x7b0 [brcmfmac] brcmf_sdiod_remove+0x20/0xa0 [brcmfmac] brcmf_ops_sdio_remove+0xbc/0x12c [brcmfmac] sdio_bus_remove+0x38/0x144 device_release_driver_internal+0x1e8/0x2c0 device_release_driver+0x14/0x20 brcmf_sdio_bus_remove+0x2c/0x40 [brcmfmac] brcmf_fwvid_unregister_vendor+0xd8/0x170 [brcmfmac] __exit_compat+0x18/0x418 [brcmfmac_cyw] __arm64_sys_delete_module+0x1ac/0x244
The log was taken with debug=0x406 on an i.MX 8M Plus board with a CYW55513 (Sona IF513) on SDIO. The driver is the Ezurio backport of brcmfmac from v6.18.22 on a 5.4-rt kernel. The code involved is the same in mainline.
To reproduce:
1. Start wpa_supplicant on wlan0 and let it associate. It creates the P2P device (iw dev shows "type P2P-device").
2. Stop wpa_supplicant and remove the driver without waiting for wpa_supplicant to exit:
kill $(pidof wpa_supplicant)
rmmod brcmfmac_cyw brcmfmac
The crash is reproducible on that board.
For the interface without a netdev (the P2P device), take RTNL and the wiphy mutex in brcmf_detach() before reading iflist, and remove it with locked=true. If brcmf_p2p_del_vif() runs first, brcmf_detach() finds the slot empty. If brcmf_detach() runs first, nl80211 does not find the wdev any more. The interfaces with a netdev are removed as before, because brcmf_del_if() takes RTNL on its own for the primary interface.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 27 ++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +25 -2
@@ -1481,8 +1481,31 @@ void brcmf_detach(struct device *dev)brcmf_bus_change_state (bus_if,BRCMF_BUS_DOWN );/* make sure primary interface removed last */ for (i =BRCMF_MAX_IFS -1 ; i >-1 ; i--) { -if (drvr->iflist[i]) -brcmf_remove_interface (drvr->iflist[i], false); +struct brcmf_if *ifp = drvr->iflist[i]; + +if (!ifp) +continue ; + +if (ifp->ndev) { +brcmf_remove_interface (ifp, false); +continue ; + } + +/* The P2P device interface has no netdev. Its removal can +* race with NL80211_CMD_DEL_INTERFACE issued by a user space +* process that is exiting (e.g. wpa_supplicant), which ends +* in brcmf_p2p_del_vif() under RTNL and the wiphy mutex. If +* both paths remove the interface, the wdev is unregistered +* twice and the vif is used after being freed. Take the same +* locks and re-read iflist, so only one path removes it. +*/ +rtnl_lock (); +wiphy_lock (drvr->wiphy); + ifp = drvr->iflist[i]; +if (ifp) +brcmf_remove_interface (ifp, true); +wiphy_unlock (drvr->wiphy); +rtnl_unlock (); }brcmf_bus_stop (drvr->bus_if);
Greg Kroah-Hartman
maintainerPATCH 350/571 wireguard: noise: reject response consumption after intermediate initiation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
commit d0305f8d90029556260c6824b61c493c424eba9e upstream.
Two threads begin processing the identical response message, received twice. The first thread, A, runs. While it's running, the second one, B, gets partway through, and during that slow calculation, or even while blocking on down_write(), A completes and then also a handshake initiation that's already been queued up runs in thread C, which itself takes that same down_write(). The handshake initiation creation succeeds, and sets the state back to waiting-for-response, and calls up_write(), at which point thread B resumes, because either its finished its calculations or was finally allowed to acquire down_write(). Thread B then copies the state back to the peer, and begins a new session, using that state, which is the same session as the one made in thread A.
Thread A Thread B Thread C
down_read()
sA = handshake->state
memcpy(cA, handshake->crypto)up_read()
if (sA != 1)
goto failslow_crypto(cA)
down_read() sB = handshake->state memcpy(cB, handshake->crypto) up_read() if (sB != 1) goto fail slow_crypto(cB)
down_write()
if (sA != handshake->state)
goto fail
memcpy(handshake->crypto, cA)
handshake->state = 2up_write()down_write()
if (handshake->state != 2)
goto fail
derive_session(handshake->crypto)up_write()
down_write() slow_crypto(handshake->crypto) handshake->state = 1 up_write() down_write() if (sB != handshake->state) goto fail memcpy(handshake->crypto, cB) handshake->state = 2 up_write() down_write() if (handshake->state != 2) goto fail derive_session(handshake->crypto) up_write()
This seems basically impossible to hit in a meaningful way in practice, but ensure that it absolutely cannot happen by comparing the ephemeral private key that's on the stack with the latest one that the peer's handshake state has.
--- drivers/net/wireguard/noise.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireguard/noise.c +4 -3
@@ -784,10 +784,11 @@ wg_noise_handshake_consume_response(stru/* Success! Copy everything to peer */ down_write (&handshake->lock); -/* It's important to check that the state is still the same, while we -* have an exclusive lock. +/* Check that the state is the same and that this is still the +* initiation we started with, while we have an exclusive lock. */ -if (handshake->state != state) { +if (handshake->state != state || +crypto_memneq (handshake->ephemeral_private, ephemeral_private,NOISE_PUBLIC_KEY_LEN )) {up_write (&handshake->lock); goto fail; }
Greg Kroah-Hartman
maintainerPATCH 351/571 workqueue: Fix NULL current_pwq deref in chained work check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavankumar Kondeti <[email protected]>
commit 980db94e3eeefdd8a1c46f86412c33a7f7806f51 upstream.
current_wq_worker() only tells us that %current is a kworker. It does not guarantee that the worker is currently executing a work item, as worker->current_pwq is populated only while process_one_work() is running the work function.
is_chained_work() can be reached while queueing on a draining or destroying workqueue. If a kworker outside work-item execution reaches that path, current_wq_worker() returns a worker but worker->current_pwq is NULL, and the chained-work test can fault before it emits the intended warning.
Guard the chained-work test with worker->current_pwq. A kworker without current_pwq is not executing work on the target workqueue, so the helper should return false and let the draining/destroying warning fire.
--- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +1 -1
@@ -1394,7 +1394,7 @@ static bool is_chained_work(struct workq* Return %true iff I'm a worker executing a work item on @wq. If * I'm @worker, it's safe to dereference it without locking. */ -return worker && worker->current_pwq->wq == wq; +return worker && worker->current_pwq && worker->current_pwq->wq == wq; }/*
Greg Kroah-Hartman
maintainerPATCH 352/571 xen/netfront: dont leak the skb when xennet_fill_frags() fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 93ccaf1c26e2133396173b76a071e59024daa622 upstream.
When a response chain has more slots than fit in the skb's frags, xennet_fill_frags() returns an error and xennet_poll() jumps to its error path. That path moves what's left on tmpq to errq to be freed, but the skb being filled was already dequeued from tmpq, so it's never freed. Each chain that overflows leaks the skb and the pages attached to it as frags, and the backend decides how many slots it sends.
Put the skb back on tmpq before taking the error path, like the xennet_set_skb_gso() failure just above it does.
--- drivers/net/xen-netfront.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/xen-netfront.c +3 -1
@@ -1340,8 +1340,10 @@ err: skb->data_len = rx->status; skb->len += rx->status; -if (unlikely (xennet_fill_frags (queue, skb, &tmpq))) +if (unlikely (xennet_fill_frags (queue, skb, &tmpq))) { +__skb_queue_head (&tmpq, skb); goto err; + }if (rx->flags & XEN_NETRXF_csum_blank) skb->ip_summed =CHECKSUM_PARTIAL ;
Greg Kroah-Hartman
maintainerPATCH 353/571 strparser: make sure __strp_recv isnt running before tearing down the parser
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
commit 0984ebc631792acf8fff105112ee74a6b8f1efcc upstream.
The comment above strp_done() claims that if strp is stopped, strp_recv will no longer be called. That's only true if the caller has a mechanism (eg locking) to guarantee that strp_recv() calls that started before strp_stop() have completed by the time we call strp_done().
This adds a dummy lock_sock/release_sock pair to guarantee that any in-flight strp_recv() (which runs under either bh_lock_sock or lock_sock, depending if it's called from ->sk_data_ready or strp_work) has completed.
Only espintcp can be affected by this race condition, but this patch makes sure no future user of strp can have the bug.
This could crash on strp->sk ("general mode" of strp), but this mode has been here for 9 years and has never been used. It'll be gone soon, no point worrying about it.
Switch the stopped/paused/etc bits to u8's to avoid races between strp_stop() and strp_pause/unpause().
A reproducer has been published and turns the possible UAF into an exploit [1].
--- Documentation/networking/strparser.rst | 2 +- include/net/strparser.h | 10 +++++----- net/strparser/strparser.c | 6 +++++- 3 files changed, 11 insertions(+), 7 deletions(-)
Documentation/networking/strparser.rst +1 -1
@@ -77,7 +77,7 @@ Functions strp_done is called to release any resources held by the stream parser instance. This must be called after the stream processor - has been stopped. + has been stopped. The socket lock must not be held. ::
include/net/strparser.h +5 -5
@@ -86,11 +86,11 @@ static inline struct strp_msg *strp_msg(struct strparser {struct sock *sk; -u32 stopped :1 ; -u32 paused :1 ; -u32 aborted :1 ; -u32 interrupted :1 ; -u32 unrecov_intr :1 ; +u8 stopped; +u8 paused; +u8 aborted; +u8 interrupted; +u8 unrecov_intr;struct sk_buff **skb_nextp;struct sk_buff *skb_head;
net/strparser/strparser.c +5 -1
@@ -511,12 +511,16 @@ void strp_unpause(struct strparser *strpEXPORT_SYMBOL_GPL (strp_unpause);/* strp must already be stopped so that strp_recv will no longer be called. -* Note that strp_done is not called with the lower socket held. +* Note that strp_done must not be called with the lower socket held. */ void strp_done (struct strparser *strp) {WARN_ON (!strp->stopped); +lock_sock (strp->sk); +/* sync with pending strp_recv */ +release_sock (strp->sk); +cancel_delayed_work_sync (&strp->msg_timer_work);cancel_work_sync (&strp->work);
Greg Kroah-Hartman
maintainerPATCH 354/571 tipc: destroy topsrv workqueues before closing connections
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuqi Xu <[email protected]>
commit 3acdd44385bc7e2e57605e073691ce69cc5a960d upstream.
tipc_topsrv_stop() closed subscriber connections while the topology server's send and receive workqueues were still running. Socket callbacks and subscription events could then queue more work, and in-flight send/recv work could drop the last connection reference during the conn_idr walk.
That race produced several teardown failures: refcount_t addition on 0 from conn_get() on a connection whose release was blocked on idr_lock, a subsequent use-after-free in tipc_conn_close(), queue_work() on an already destroyed workqueue from the listener data-ready callback, and an RCU stall in tipc_topsrv_exit_net() while the walk spun under idr_lock.
Clear srv->listener under idr_lock so it acts as a shutdown flag, skip queue_work() once it is NULL, destroy the workqueues to flush in-flight work, and only then close the remaining connections. Refuse tipc_conn_lookup() after that flag is cleared, and drop idr_lock when the teardown walk finds no connection, so an in-flight subscription event cannot pin idr_in_use while the walk holds the lock.
v3 supersedes the narrower in-thread diff Tung Quang Nguyen posted on 2026-09-23. It keeps his teardown order and adds the lookup refusal and the empty-idr unlock.
--- net/tipc/topsrv.c | 80 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 15 deletions(-)
net/tipc/topsrv.c +65 -15
@@ -54,7 +54,7 @@/** * struct tipc_topsrv - TIPC server structure * @conn_idr: identifier set of connection -* @idr_lock: protect the connection identifier set +* @idr_lock: protect the connection identifier set and listener * @idr_in_use: amount of allocated identifier entry * @net: network namspace instance * @awork: accept work item
@@ -217,6 +217,10 @@ static struct tipc_conn *tipc_conn_lookustruct tipc_conn *con;spin_lock_bh (&s->idr_lock); +if (!s->listener) { +spin_unlock_bh (&s->idr_lock); +return NULL ; + } con =idr_find (&s->conn_idr, conid);if (!connected (con) || !kref_get_unless_zero (&con->kref)) con =NULL ;
@@ -300,10 +304,20 @@ static void tipc_conn_send_to_sock(strucstatic void tipc_conn_send_work (struct work_struct *work) { struct tipc_conn *con = container_of(work, struct tipc_conn, swork); +struct tipc_topsrv *srv; + + srv = con->server; +spin_lock_bh (&srv->idr_lock); +if (!srv->listener) { +spin_unlock_bh (&srv->idr_lock); + goto out; + } +spin_unlock_bh (&srv->idr_lock);if (connected (con))tipc_conn_send_to_sock (con); +out:conn_put (con); }
@@ -333,8 +347,14 @@ void tipc_topsrv_queue_evt(struct net *nlist_add_tail (&e->list, &con->outqueue);spin_unlock_bh (&con->outqueue_lock); -if (queue_work (srv->send_wq, &con->swork)) -return ; +spin_lock_bh (&srv->idr_lock); +if (srv->listener) { +if (queue_work (srv->send_wq, &con->swork)) { +spin_unlock_bh (&srv->idr_lock); +return ; + } + } +spin_unlock_bh (&srv->idr_lock); err:conn_put (con); }
@@ -345,14 +365,20 @@ err:*/ static void tipc_conn_write_space (struct sock *sk) { +struct tipc_topsrv *srv;struct tipc_conn *con;read_lock_bh (&sk->sk_callback_lock); con = sk->sk_user_data;if (connected (con)) { -conn_get (con); -if (!queue_work (con->server->send_wq, &con->swork)) -conn_put (con); + srv = con->server; +spin_lock_bh (&srv->idr_lock); +if (srv->listener) { +conn_get (con); +if (!queue_work (srv->send_wq, &con->swork)) +conn_put (con); + } +spin_unlock_bh (&srv->idr_lock); }read_unlock_bh (&sk->sk_callback_lock); }
@@ -417,8 +443,17 @@ static int tipc_conn_rcv_from_sock(strucstatic void tipc_conn_recv_work (struct work_struct *work) { struct tipc_conn *con = container_of(work, struct tipc_conn, rwork); +struct tipc_topsrv *srv;int count =0 ; + srv = con->server; +spin_lock_bh (&srv->idr_lock); +if (!srv->listener) { +spin_unlock_bh (&srv->idr_lock); + goto out; + } +spin_unlock_bh (&srv->idr_lock); +while (connected (con)) {if (tipc_conn_rcv_from_sock (con))break ;
@@ -429,6 +464,7 @@ static void tipc_conn_recv_work(struct w count =0 ; } } +out:conn_put (con); }
@@ -437,14 +473,20 @@ static void tipc_conn_recv_work(struct w*/ static void tipc_conn_data_ready (struct sock *sk) { +struct tipc_topsrv *srv;struct tipc_conn *con;read_lock_bh (&sk->sk_callback_lock); con = sk->sk_user_data;if (connected (con)) { -conn_get (con); -if (!queue_work (con->server->rcv_wq, &con->rwork)) -conn_put (con); + srv = con->server; +spin_lock_bh (&srv->idr_lock); +if (srv->listener) { +conn_get (con); +if (!queue_work (srv->rcv_wq, &con->rwork)) +conn_put (con); + } +spin_unlock_bh (&srv->idr_lock); }read_unlock_bh (&sk->sk_callback_lock); }
@@ -498,8 +540,12 @@ static void tipc_topsrv_listener_data_reread_lock_bh (&sk->sk_callback_lock); srv = sk->sk_user_data; -if (srv) -queue_work (srv->rcv_wq, &srv->awork); +if (srv) { +spin_lock_bh (&srv->idr_lock); +if (srv->listener) +queue_work (srv->rcv_wq, &srv->awork); +spin_unlock_bh (&srv->idr_lock); + }read_unlock_bh (&sk->sk_callback_lock); }
@@ -696,22 +742,26 @@ static void tipc_topsrv_stop(struct netint id;spin_lock_bh (&srv->idr_lock); + srv->listener =NULL ; +spin_unlock_bh (&srv->idr_lock); +tipc_topsrv_work_stop (srv); + +spin_lock_bh (&srv->idr_lock);for (id =0 ; srv->idr_in_use; id++) { con =idr_find (&srv->conn_idr, id);if (con) { -conn_get (con);spin_unlock_bh (&srv->idr_lock);tipc_conn_close (con); -conn_put (con);spin_lock_bh (&srv->idr_lock); +continue ; } +spin_unlock_bh (&srv->idr_lock); +spin_lock_bh (&srv->idr_lock); }__module_get (lsock->ops->owner);__module_get (lsock->sk->sk_prot_creator->owner); - srv->listener =NULL ;spin_unlock_bh (&srv->idr_lock); -tipc_topsrv_work_stop (srv);sock_release (lsock);idr_destroy (&srv->conn_idr);kfree (srv);
Greg Kroah-Hartman
maintainerPATCH 355/571 tipc: hold a reference to nodes found by link name
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit 17e73bae400f6a434dc006e3bee92c94cf781954 upstream.
tipc_node_find_by_name() returns a node after dropping its RCU read lock without taking a reference. The LINK_SET, LINK_GET and LINK_RESET_STATS handlers then lock and access the node, racing with timer-driven cleanup of a down peer. Generic netlink serialization does not exclude the node timer.
The following interleaving can leave a handler using a freed node:
CPU 0: find the node under RCU and release the node read lock CPU 1: tipc_node_timeout() clears the links and unlinks the down node CPU 1: drop the list and timer references, queuing tipc_node_free() CPU 0: leave the RCU read-side critical section
CPU 1: complete the grace period and free the node
CPU 0: acquire the node lock through the stale pointer
LINK_SET also uses the node's media address after releasing the node lock, when passing queued packets to tipc_bearer_xmit().
KASAN on v7.3-rc5 reported:
BUG: KASAN: slab-use-after-free in _raw_read_lock_bh Write of size 4 at addr ffff88807e06f008 by task poc/92 Call Trace: _raw_read_lock_bh kernel/locking/spinlock.c:287 tipc_nl_node_set_link net/tipc/node.c:2475 genl_family_rcv_msg_doit net/netlink/genetlink.c:1114 genl_rcv_msg net/netlink/genetlink.c:1209 netlink_rcv_skb net/netlink/af_netlink.c:2575 Allocated by task 0: tipc_node_create net/tipc/node.c:539 tipc_node_check_dest net/tipc/node.c:1196 tipc_disc_rcv net/tipc/discover.c:252 Freed by task 92: kfree mm/slub.c:6801 rcu_core kernel/rcu/tree.c:2919 Last potentially related work creation: __call_rcu_common.constprop.0 kernel/rcu/tree.c:3181 tipc_node_timeout net/tipc/node.c:814
Acquire a reference to the selected node with kref_get_unless_zero() before leaving RCU, returning NULL if the node has already been released. Release that reference on every caller exit after the last node access, including transmission in LINK_SET. Keep the existing link lookup order and locking so concurrent link removal still takes the existing error paths.
--- net/tipc/node.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/tipc/node.c +9 -1
@@ -2421,8 +2421,11 @@ static struct tipc_node *tipc_node_find_ } }tipc_node_read_unlock (n); -if (found_node) +if (found_node) { +if (!kref_get_unless_zero (&found_node->kref)) + found_node =NULL ;break ; + } }rcu_read_unlock ();
@@ -2507,6 +2510,7 @@ out:tipc_node_read_unlock (node);tipc_bearer_xmit (net, bearer_id, &xmitq, &node->links[bearer_id].maddr,NULL ); +tipc_node_put (node);return res; }
@@ -2558,12 +2562,14 @@ int tipc_nl_node_get_link(struct sk_buff link = node->links[bearer_id].link;if (!link) {tipc_node_read_unlock (node); +tipc_node_put (node); err = -EINVAL ; goto err_free; } err =__tipc_nl_add_link (net, &msg, link,0 );tipc_node_read_unlock (node); +tipc_node_put (node);if (err) goto err_free; }
@@ -2634,11 +2640,13 @@ int tipc_nl_node_reset_link_stats(structif (!link) {spin_unlock_bh (&le->lock);tipc_node_read_unlock (node); +tipc_node_put (node);return -EINVAL ; }tipc_link_reset_stats (link);spin_unlock_bh (&le->lock);tipc_node_read_unlock (node); +tipc_node_put (node);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 356/571 Revert "wifi: libertas: reject short monitor TX frames"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 9727d1c4e1c971fc42b049b645fdda6852758835 upstream.
This reverts commit 13ff543e0b2c713aedeaadadde686686e949dc78.
The 'goto free' just made things worse, causing a spinlock to be handled incorrectly. Revert this for now.
--- drivers/net/wireless/marvell/libertas/tx.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/net/wireless/marvell/libertas/tx.c +0 -7
@@ -116,13 +116,6 @@ netdev_tx_t lbs_hard_start_xmit(struct sif (priv->wdev->iftype ==NL80211_IFTYPE_MONITOR ) {struct tx_radiotap_hdr *rtap_hdr = (void *)skb->data; -if (skb->len <sizeof (*rtap_hdr) +4 +ETH_ALEN ) { -lbs_deb_tx ("tx err: short monitor frame %u\n" , skb->len); - dev->stats.tx_dropped++; - dev->stats.tx_errors++; - goto free; - } -/* set txpd fields from the radiotap header */ txpd->tx_control =cpu_to_le32 (convert_radiotap_rate_to_mv (rtap_hdr->rate));
Greg Kroah-Hartman
maintainerPATCH 357/571 selinux: preserve NATIVE_LABELS on already-initialized sb in set_mnt_opts
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Smalley <[email protected]>
commit 28b7260548af3d35773477993ad4e4de41578dd7 upstream.
When an NFSv4 filesystem exported with security_label is mounted a second time, sget_fc() returns the existing superblock and nfs_get_root() calls security_sb_set_mnt_opts() again on it. Since the superblock is already SB_INITIALIZED, selinux_set_mnt_opts() takes an early exit without setting SECURITY_LSM_NATIVE_LABELS in *set_kern_flags. nfs_get_root() then sees kflags without SECURITY_LSM_NATIVE_LABELS set and clears NFS_CAP_SECURITY_LABEL on the shared nfs_server, silently disabling per-file labeling for both the new and the original mount.
Commit 3815a245b501 ("security/selinux: fix SECURITY_LSM_NATIVE_LABELS on reused superblock") fixed the same problem in selinux_sb_clone_mnt_opts(). The reused-superblock path for a plain second mount now goes through sb_set_mnt_opts rather than sb_clone_mnt_opts, so it needs the same treatment: on both SE_SBINITIALIZED early exits, set SECURITY_LSM_NATIVE_LABELS in *set_kern_flags when the superblock was already using SECURITY_FS_USE_NATVE.
--- security/selinux/hooks.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
security/selinux/hooks.c +8 -1
@@ -677,8 +677,12 @@ static int selinux_set_mnt_opts(struct s* will be used for both mounts) */ if ((sbsec->flags &SE_SBINITIALIZED ) && (sb->s_type->fs_flags &FS_BINARY_MOUNTDATA ) - && !opts) + && !opts) { +if ((kern_flags &SECURITY_LSM_NATIVE_LABELS ) && + sbsec->behavior ==SECURITY_FS_USE_NATIVE ) + *set_kern_flags |=SECURITY_LSM_NATIVE_LABELS ; goto out; + } root_isec =backing_inode_security_novalidate (root);
@@ -730,6 +734,9 @@ static int selinux_set_mnt_opts(struct s/* previously mounted with options, but not on this attempt? */ if ((sbsec->flags &SE_MNTMASK ) && !opts) goto out_double_mount; +if ((kern_flags &SECURITY_LSM_NATIVE_LABELS ) && + sbsec->behavior ==SECURITY_FS_USE_NATIVE ) + *set_kern_flags |=SECURITY_LSM_NATIVE_LABELS ; rc =0 ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 358/571 sctp: copy zeroed stats to user in sctp_getsockopt_pr_streamstatus() when !streamoute
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
commit 538b529509c7ab0d909cb65bb7264edca1788d30 upstream.
When an SCTP stream output extension structure (streamoute) has not yet been allocated, sctp_getsockopt_pr_streamstatus() sets the local stack variables params.sprstat_abandoned_unsent = 0 and params.sprstat_abandoned_sent = 0, but then immediately jumps to 'out:', bypassing copy_to_user(). As a result, when an uninitialized user buffer is passed to getsockopt(SCTP_PR_STREAM_STATUS), the kernel returns success (0) without copying the zeroed stats back to user space, leaving uninitialized data in the user buffer.
Refactor the !streamoute check into an if-else chain so that when streamoute is NULL, params is zeroed and falls through to copy_to_user(), copying the zeroed stats to user space and setting retval = 0 once before returning.
Tested in QEMU against Linux 7.3.0-rc3 using an uninitialized sctp_prstatus user struct passed to getsockopt(SCTP_PR_STREAM_STATUS) on a freshly created stream: on the unfixed kernel the user struct contains uninitialized stack garbage; whereas with this fix applied, getsockopt() copies zeroed stats into user space and returns 0.
--- net/sctp/socket.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/sctp/socket.c +1 -5
@@ -7516,11 +7516,7 @@ static int sctp_getsockopt_pr_streamstat/* Not allocated yet, means all stats are 0 */ params.sprstat_abandoned_unsent =0 ; params.sprstat_abandoned_sent =0 ; - retval =0 ; - goto out; - } - -if (policy ==SCTP_PR_SCTP_ALL ) { + }else if (policy ==SCTP_PR_SCTP_ALL ) { params.sprstat_abandoned_unsent =0 ; params.sprstat_abandoned_sent =0 ;for (policy =0 ; policy <=SCTP_PR_INDEX (MAX ); policy++) {
Greg Kroah-Hartman
maintainerPATCH 359/571 gpio: xilinx: fix runtime PM leak on request error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridham Khurana <[email protected]>
commit ff82fc3a4a1d417dee1229681cc5285986edb1fa upstream.
pm_runtime_get_sync() leaves the usage counter incremented even when it fails, and xgpio_request() returns the error without dropping it.
gpiolib does not call ->free() when ->request() fails, so xgpio_free(), which holds the only matching pm_runtime_put(), never runs. The reference is leaked and the controller can no longer runtime-suspend, so its clock stays enabled.
Switch to pm_runtime_resume_and_get(), which only increments the usage counter on success.
--- drivers/gpio/gpio-xilinx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpio/gpio-xilinx.c +1 -8
@@ -291,14 +291,7 @@ static void xgpio_save_regs(struct xgpiostatic int xgpio_request (struct gpio_chip *chip,unsigned int offset) { -int ret; - - ret =pm_runtime_get_sync (chip->parent); -/* -* If the device is already active pm_runtime_get() will return 1 on -* success, but gpio_request still needs to return 0. -*/ -return ret <0 ? ret :0 ; +return pm_runtime_resume_and_get (chip->parent); }static void xgpio_free (struct gpio_chip *chip,unsigned int offset)
Greg Kroah-Hartman
maintainerPATCH 360/571 ibmveth: h_free logical LAN on open-fail after register
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
commit af0524bf4ce1a4cbd2946aa81751582951cfcab5 upstream.
ibmveth_open() registers the logical LAN, then allocates the RX buffer pools. A pool failure jumps to out_free_buffer_pools without h_free_logical_lan(), so PHYP still owns the buffer-list page when it is unmapped. request_irq() failure already issued the hypercall before taking the same label.
Move that h_free to the shared post-register unwind so both paths deregister before the buffer list is unmapped.
--- drivers/net/ethernet/ibm/ibmveth.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/ibm/ibmveth.c +3 -4
@@ -597,10 +597,6 @@ static int ibmveth_open(struct net_devicif (rc !=0 ) {netdev_err (netdev,"unable to request irq 0x%x, rc %d\n" , netdev->irq, rc); -do { - lpar_rc =h_free_logical_lan (adapter->vdev->unit_address); - }while (H_IS_LONG_BUSY (lpar_rc) || (lpar_rc ==H_BUSY )); - goto out_free_buffer_pools; }
@@ -632,6 +628,9 @@ out_free_bounce_buffer: out_free_irq:free_irq (netdev->irq, netdev); out_free_buffer_pools: +do { + lpar_rc =h_free_logical_lan (adapter->vdev->unit_address); + }while (H_IS_LONG_BUSY (lpar_rc) || (lpar_rc ==H_BUSY ));while (--i >=0 ) {if (adapter->rx_buff_pool[i].active) ibmveth_free_buffer_pool(adapter,
Greg Kroah-Hartman
maintainerPATCH 361/571 keys: finalize persistent keyring timeout after link attempt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
commit 25bf14f817168079f731975b8998fc2af380f29e upstream.
When no keyring exists for the requested UID, KEYCTL_GET_PERSISTENT creates and registers one before linking it to the requested destination. The configured timeout is set only after the destination link succeeds.
A destination restricted with KEYCTL_RESTRICT_KEYRING makes that link fail with -EPERM. With persistent_keyring_expiry set to 60 seconds, /proc/keys still reports the registered keyring's expiry as "perm".
The failed call therefore leaves a quota-exempt keyring in the namespace's hidden register, where it may remain until namespace teardown.
Rename the write-locked helper to key_get_or_create_persistent() and return the key reference through a result parameter. Return 0 when it creates a keyring and 1 when the retry finds an existing one. Return a negative error on failure. Another caller may create the keyring between the initial read-locked lookup and the retry under the write lock.
Set the timeout after permission checking and linking. Do this on success, or on failure if the call allocated the keyring. This leaves a new keyring collectible after failure without starting its timeout while linking is still in progress.
--- security/keys/persistent.c | 55 ++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 23 deletions(-)
security/keys/persistent.c +32 -23
@@ -33,25 +33,31 @@ static int key_create_persistent_registe }/* -* Create the persistent keyring for the specified user. +* Get or create the persistent keyring for the specified user. * * Called with the namespace's sem locked for writing. +* +* Returns a boolean indicating whether the keyring already existed, +* or a negative error. On success, *persistent_ref holds a reference +* to the keyring. */ -static key_ref_t key_create_persistent (struct user_namespace *ns,kuid_t uid, -struct keyring_index_key *index_key) +static int key_get_or_create_persistent (struct user_namespace *ns,kuid_t uid, +struct keyring_index_key *index_key, +key_ref_t *persistent_ref) {struct key *persistent; -key_ref_t reg_ref, persistent_ref; +key_ref_t reg_ref;if (!ns->persistent_keyring_register) { -long err =key_create_persistent_register (ns); +int err =key_create_persistent_register (ns); +if (err <0 ) -return ERR_PTR (err); +return err; }else { reg_ref =make_key_ref (ns->persistent_keyring_register, true); - persistent_ref =find_key_to_update (reg_ref, index_key); -if (persistent_ref) -return persistent_ref; + *persistent_ref =find_key_to_update (reg_ref, index_key); +if (*persistent_ref) +return 1 ; } persistent = keyring_alloc(index_key->description,
@@ -61,9 +67,10 @@ static key_ref_t key_create_persistent(sKEY_ALLOC_NOT_IN_QUOTA ,NULL , ns->persistent_keyring_register);if (IS_ERR (persistent)) -return ERR_CAST (persistent); +return PTR_ERR (persistent); -return make_key_ref (persistent, true); + *persistent_ref =make_key_ref (persistent, true); +return 0 ; }/*
@@ -78,6 +85,7 @@ static long key_get_persistent(struct uskey_ref_t reg_ref, persistent_ref;char buf[32 ];long ret; +bool created = false;/* Look in the register if it exists */ memset (&index_key,0 ,sizeof (index_key));
@@ -100,23 +108,24 @@ static long key_get_persistent(struct us* also need to create the register. */ down_write (&ns->keyring_sem); - persistent_ref =key_create_persistent (ns, uid, &index_key); + ret =key_get_or_create_persistent (ns, uid, &index_key, + &persistent_ref);up_write (&ns->keyring_sem); -if (!IS_ERR (persistent_ref)) - goto found; - -return PTR_ERR (persistent_ref); +if (ret <0 ) +return ret; + created = ret ==0 ; found: + persistent =key_ref_to_ptr (persistent_ref); ret =key_task_permission (persistent_ref,current_cred (),KEY_NEED_LINK ); -if (ret ==0 ) { - persistent =key_ref_to_ptr (persistent_ref); +if (ret ==0 ) ret =key_link (key_ref_to_ptr (dest_ref), persistent); -if (ret ==0 ) { -key_set_timeout (persistent, persistent_keyring_expiry); - ret = persistent->serial; - } - } + +if (ret ==0 || created) +key_set_timeout (persistent, persistent_keyring_expiry); + +if (ret ==0 ) + ret = persistent->serial;key_ref_put (persistent_ref);return ret;
Greg Kroah-Hartman
maintainerPATCH 362/571 KEYS: Fix add_key() race with keyring restriction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: 성병찬 <[email protected]>
commit dd3ea3fcba7c75493760cdbccd35f029597e8d5e upstream.
__key_create_or_update() snapshots keyring->restrict_link before taking the destination keyring's semaphore. keyring_restrict() installs a restriction while holding that semaphore.
This allows a writer to observe no restriction, wait for the keyring owner to install a reject-all restriction and return successfully, and then link a key using the stale NULL snapshot. The writer only needs write permission on the destination keyring.
Move the restrict_link read after __key_link_lock() and __key_link_begin(). The read and the subsequent restriction check are then serialized with restriction installation by keyring->sem.
The race was reproduced on v7.2.8 in 19 executions where restriction installation returned before the link completed. All 19 linked the key despite the reject-all restriction. With this change, 312 executions reached the same ordering and every add_key() call failed with -EPERM.
The issue was found by manual concurrency analysis assisted by AI-based analysis and independently verified with a QEMU reproducer and kernel instrumentation.
--- security/keys/key.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
security/keys/key.c +3 -3
@@ -845,9 +845,6 @@ key_ref_t key_create_or_update(key_ref_tkey_check (keyring); -if (!(flags &KEY_ALLOC_BYPASS_RESTRICTION )) - restrict_link = keyring->restrict_link; - key_ref =ERR_PTR (-ENOTDIR );if (keyring->type != &key_type_keyring) goto error_put_type;
@@ -885,6 +882,9 @@ key_ref_t key_create_or_update(key_ref_t goto error_link_end; } +if (!(flags &KEY_ALLOC_BYPASS_RESTRICTION )) + restrict_link = keyring->restrict_link; +if (restrict_link && restrict_link->check) { ret = restrict_link->check (keyring, index_key.type, &prep.payload, restrict_link->key);
Greg Kroah-Hartman
maintainerPATCH 363/571 memstick: core: wait for request completion before freeing card
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raj Ojha <[email protected]>
commit aa0a37b5024d921e96ac4f8f487c8bfbf1f1a582 upstream.
In memstick_alloc_card() and memstick_set_rw_addr(), wait_for_completion_timeout() is used to wait for device identification and address configuration requests to complete.
The memstick subsystem does not provide an abort or cancellation callback in struct memstick_host for in-flight requests. If wait_for_completion_timeout() expires (for instance, when a USB transfer or command retry is delayed), memstick_alloc_card() returns an error and frees the memstick_dev structure via kfree(card).
However, the host controller driver (such as rtsx_usb_ms) is still running the request asynchronously in worker context. When the transfer eventually finishes, the driver writes into host->req->data, which points to memory inside the already freed card structure. This leads to a KASAN slab-use-after-free write:
BUG: KASAN: slab-use-after-free in ms_read_bytes+0x8fe/0x990 Write of size 1 at addr ffff88813c188079 by task kworker/1:5/5239 Workqueue: events rtsx_usb_ms_handle_req Call Trace: ms_read_bytes+0x8fe/0x990 drivers/memstick/host/rtsx_usb_ms.c:450 rtsx_usb_ms_issue_cmd drivers/memstick/host/rtsx_usb_ms.c:477 [inline] rtsx_usb_ms_handle_req+0x557/0x1a00 drivers/memstick/host/rtsx_usb_ms.c:531 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396 worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560 kthread+0x373/0x450 kernel/kthread.c:436 Allocated by task 1662: memstick_alloc_card drivers/memstick/core/memstick.c:383 [inline] memstick_check+0x2c1/0x10d0 drivers/memstick/core/memstick.c:452 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396 Freed by task 1662: kfree+0x20c/0x650 mm/slub.c:6792 memstick_alloc_card drivers/memstick/core/memstick.c:420 [inline] memstick_check+0x72b/0x10d0 drivers/memstick/core/memstick.c:452 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
Host controller drivers (rtsx_usb_ms, jmb38x_ms, tifm_ms, r592) already implement their own hardware and bus timeouts, and callers in mspro_block and ms_block already rely on wait_for_completion() unconditionally.
Replace wait_for_completion_timeout() with wait_for_completion() in memstick_set_rw_addr() and memstick_alloc_card() so that the card structure is never freed while an asynchronous request is in flight.
--- drivers/memstick/core/memstick.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/memstick/core/memstick.c +2 -6
@@ -367,9 +367,7 @@ int memstick_set_rw_addr(struct memstick { card->next_request = h_memstick_set_rw_addr;memstick_new_req (card->host); -if (!wait_for_completion_timeout (&card->mrq_complete, -msecs_to_jiffies (500 ))) - card->current_mrq.error = -ETIMEDOUT ; +wait_for_completion (&card->mrq_complete);return card->current_mrq.error; }
@@ -403,9 +401,7 @@ static struct memstick_dev *memstick_all card->next_request = h_memstick_read_dev_id;memstick_new_req (host); -if (!wait_for_completion_timeout (&card->mrq_complete, -msecs_to_jiffies (500 ))) - card->current_mrq.error = -ETIMEDOUT ; +wait_for_completion (&card->mrq_complete);if (card->current_mrq.error) goto err_out;
Greg Kroah-Hartman
maintainerPATCH 364/571 memstick: rtsx_usb_ms: complete requests after eject instead of dropping them
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
commit c96ca94425b076dc398d929366e378d1e22ec794 upstream.
memstick_check() can pass its host->removing check just before rtsx_usb_ms_drv_remove() sets eject/removing. Its next request is then silently dropped: rtsx_usb_ms_request() skips schedule_work() once eject is set, and drv_remove's cancel_work_sync() can also cancel a queued handle_req before it picks the request up. Nobody completes card->mrq_complete.
Once memstick core waits for requests without a timeout ("memstick: core:
wait for request completion before freeing card"), this hangs removal:memstick_check() never returns and memstick_remove_host() blocks in flush_workqueue():
INFO: task kworker/u10:3:65 blocked for more than 20 seconds. Workqueue: kmemstick memstick_check __wait_for_common memstick_check INFO: task kworker/1:1:33 blocked for more than 20 seconds. Workqueue: usb_hub_wq hub_event __flush_workqueue memstick_remove_host rtsx_usb_ms_drv_remove
Never drop a request. rtsx_usb_ms_request() always schedules handle_req, and handle_req fails requests with -ENOMEDIUM once eject is set, without touching the device. drv_remove flushes handle_req instead of cancelling it, and cancels it only after memstick_remove_host(), when no new request can arrive, so it cannot run on a freed host.
The host_mutex drain in drv_remove is removed: handle_req always leaves host->req NULL when it finishes, so the drain never had anything to do, and it would now race with handle_req.
--- drivers/memstick/host/rtsx_usb_ms.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-)
drivers/memstick/host/rtsx_usb_ms.c +11 -20
@@ -27,7 +27,6 @@ struct rtsx_usb_ms {struct memstick_host *msh;struct memstick_request *req; -struct mutex host_mutex;struct work_struct handle_req;struct delayed_work poll_card;
@@ -511,6 +510,13 @@ static void rtsx_usb_ms_handle_req(strucstruct memstick_host *msh = host->msh;int rc; +/* Fail requests after eject so their waiters are released. */ +if (host->eject) { +while (!memstick_next_req (msh, &host->req)) + host->req->error = -ENOMEDIUM ; +return ; + } +if (!host->req) {pm_runtime_get_sync (ms_dev (host)); do {
@@ -544,8 +550,7 @@ static void rtsx_usb_ms_request(struct mdev_dbg (ms_dev (host),"--> %s\n" , __func__); -if (!host->eject) -schedule_work (&host->handle_req); +schedule_work (&host->handle_req); } static int rtsx_usb_ms_set_param(struct memstick_host *msh,
@@ -778,7 +783,6 @@ static int rtsx_usb_ms_drv_probe(struct host->power_mode =MEMSTICK_POWER_OFF ;platform_set_drvdata (pdev, host); -mutex_init (&host->host_mutex);INIT_WORK (&host->handle_req, rtsx_usb_ms_handle_req);INIT_DELAYED_WORK (&host->poll_card, rtsx_usb_ms_poll_card);
@@ -809,27 +813,12 @@ static int rtsx_usb_ms_drv_remove(struct {struct rtsx_usb_ms *host =platform_get_drvdata (pdev);struct memstick_host *msh = host->msh; -int err; host->eject = true; msh->removing = true; -cancel_work_sync (&host->handle_req); +flush_work (&host->handle_req);cancel_delayed_work_sync (&host->poll_card); -mutex_lock (&host->host_mutex); -if (host->req) { -dev_dbg (ms_dev (host), -"%s: Controller removed during transfer\n" , -dev_name (&msh->dev)); - host->req->error = -ENOMEDIUM ; -do { - err =memstick_next_req (msh, &host->req); -if (!err) - host->req->error = -ENOMEDIUM ; - }while (!err); - } -mutex_unlock (&host->host_mutex); -/* Balance possible unbalanced usage count * e.g. unconditional module removal */
@@ -838,6 +827,8 @@ static int rtsx_usb_ms_drv_remove(structpm_runtime_disable (ms_dev (host));memstick_remove_host (msh); +/* No card, no new requests; wait for the last failed one to finish. */ +cancel_work_sync (&host->handle_req);dev_dbg (ms_dev (host),": Realtek USB Memstick controller has been removed\n" );memstick_free_host (msh);
Greg Kroah-Hartman
maintainerPATCH 365/571 dm-crypt: reject the lmk IV mode with AEAD ciphers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Cressey <[email protected]>
commit 3195e0daf590683992edb4eed32269e569e04924 upstream.
A "capi:" table line that pairs an AEAD cipher with the lmk IV mode, for example "capi:gcm(aes)-lmk" with the integrity:28:aead option, causes an oops when it is loaded. lmk sets tfms_count to 64, but crypt_alloc_tfms_aead only allocates one transform, so crypt_setkey reads past the end of the tfms_aead array and calls crypto_aead_setkey on the values it finds there.
lmk exists for compatibility with Loop-AES, which uses CBC, so refuse it with an AEAD cipher rather than allocate 64 AEAD transforms. The check cannot go in crypt_iv_lmk_ctr with the other lmk checks, because the IV constructor runs after crypt_set_key.
Note that this is not a security bug because the memory corruption can only be triggered by root.
--- drivers/md/dm-crypt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/md/dm-crypt.c +6 -1
@@ -2854,8 +2854,13 @@ static int crypt_ctr_cipher_new(struct d } } -if (*ivmode && !strcmp (*ivmode,"lmk" )) +if (*ivmode && !strcmp (*ivmode,"lmk" )) { +if (crypt_integrity_aead (cc)) { + ti->error ="AEAD transforms not supported for LMK" ; +return -EINVAL ; + } cc->tfms_count =64 ; + }if (*ivmode && !strcmp (*ivmode,"essiv" )) {if (!*ivopts) {
Greg Kroah-Hartman
maintainerPATCH 366/571 dm-snap: reject the transient exception store for snapshot-merge
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Xinmeng <[email protected]>
commit fcbde6227fcc53c73f08c56b2539e462d545cac6 upstream.
snapshot_merge_next_chunks() calls s->store->type->prepare_merge() without checking it. The transient store ("N") implements neither prepare_merge nor commit_merge, and snapshot_ctr() validates those callbacks only on the handover path (__validate_exception_handover()), so a directly constructed snapshot-merge calls a NULL prepare_merge on resume:
snapshot_merge_resume -> snapshot_merge_next_chunks -> prepare_merge(...)
commit_merge() is NULL for the same reason. Userspace only issues documented device-mapper ioctls (CAP_SYS_ADMIN); this is a misconfiguration the kernel must reject rather than oops on.
Reject the combination in snapshot_ctr() at table-load time (-EINVAL), the same check the handover path already performs; this also covers the commit_merge() call site, which a guard local to the prepare_merge call would miss.
Tested on Linux v6.6.157 KASAN: unpatched, the dmsetup reproducer oopses in snapshot_merge_next_chunks(); with this patch, the table load fails with -EINVAL and no oops. Also present on v6.6.145; still present on the linux-dm tree (555f3d7be91a) and on torvalds/linux master (62f4c998b297) as of 2026-09-22.
Note that this is not a security bug because only root can trigger it.
--- drivers/md/dm-snap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/md/dm-snap.c +14 -0
@@ -1322,6 +1322,20 @@ static int snapshot_ctr(struct dm_target goto bad_store; } +/* +* snapshot-merge requires the optional prepare_merge/commit_merge +* callbacks; the transient exception store does not implement them. +* The handover path checks this in __validate_exception_handover(), +* but a directly constructed snapshot-merge never goes through it. +*/ +if (dm_target_is_snapshot_merge (ti) && + (!s->store->type->prepare_merge || + !s->store->type->commit_merge)) { + ti->error ="Snapshot exception store does not support snapshot-merge." ; + r = -EINVAL ; + goto bad_hash_tables; + } + argv += args_used; argc -= args_used;
Greg Kroah-Hartman
maintainerPATCH 367/571 mmc: cavium-octeon: destroy slot platform devices on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit 0f4d4424fc1d651ec3fa63a0a8060ba9087eb0ec upstream.
octeon_mmc_probe() creates host->slot_pdev[i] with of_platform_device_create(), while octeon_mmc_remove() does not destroy the child platform devices.
The probe failure path removes each MMC slot and destroys its associated platform device, but the normal remove path only removes the MMC slot. As a result, the child platform devices remain registered after the Octeon MMC controller is removed.
Destroy each slot platform device during removal after cleaning up the corresponding MMC slot, matching the probe failure cleanup path.
This issue was found by manual code inspection.
--- drivers/mmc/host/cavium-octeon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/cavium-octeon.c +4 -1
@@ -300,9 +300,12 @@ static int octeon_mmc_remove(struct platu64 dma_cfg;int i; -for (i =0 ; i <CAVIUM_MAX_MMC ; i++) +for (i =0 ; i <CAVIUM_MAX_MMC ; i++) {if (host->slot[i])cvm_mmc_of_slot_remove (host->slot[i]); +if (host->slot_pdev[i]) +of_platform_device_destroy (&host->slot_pdev[i]->dev,NULL ); + } dma_cfg =readq (host->dma_base +MIO_EMM_DMA_CFG (host)); dma_cfg &= ~MIO_EMM_DMA_CFG_EN ;
Greg Kroah-Hartman
maintainerPATCH 368/571 mmc: cavium-thunderx: destroy slot platform devices on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit 29ee8cf18a21b02cd0b2e35f741b61cd1fe3e14e upstream.
thunder_mmc_probe() creates host->slot_pdev[i] with of_platform_device_create(), while thunder_mmc_remove() does not destroy the child platform devices.
The probe failure path removes each MMC slot and destroys its associated platform device, but the normal remove path only removes the MMC slot. As a result, the child platform devices remain registered after the ThunderX MMC controller is removed.
Destroy each slot platform device during removal after cleaning up the corresponding MMC slot, matching the probe failure cleanup path. Keep an extra device reference around of_platform_device_destroy() as done in the existing error path.
This issue was found by manual code inspection.
--- drivers/mmc/host/cavium-thunderx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/cavium-thunderx.c +4 -1
@@ -173,9 +173,12 @@ static void thunder_mmc_remove(struct pcu64 dma_cfg;int i; -for (i =0 ; i <CAVIUM_MAX_MMC ; i++) +for (i =0 ; i <CAVIUM_MAX_MMC ; i++) {if (host->slot[i])cvm_mmc_of_slot_remove (host->slot[i]); +if (host->slot_pdev[i]) +of_platform_device_destroy (&host->slot_pdev[i]->dev,NULL ); + } dma_cfg =readq (host->dma_base +MIO_EMM_DMA_CFG (host)); dma_cfg &= ~MIO_EMM_DMA_CFG_EN ;
Greg Kroah-Hartman
maintainerPATCH 369/571 mmc: mtk-sd: Cancel request timeout work on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yibo Tan <[email protected]>
commit b38af5386a74416e898955443f2e26547b358cb2 upstream.
The driver queues req_timeout while a request is active. msdc_request_done() uses cancel_delayed_work(), which does not wait for a timeout callback that has already started.
The timeout callback calls mmc_request_done(), which wakes the request waiter, and then continues to use host->dev_comp and check the SDIO IRQ. During unbind, msdc_drv_remove() can return and the managed mmc_host can be freed before the callback finishes.
KASAN reported use-after-free accesses in msdc_request_done() and msdc_recheck_sdio_irq() in each of three unbind tests. The same tests completed without a kernel diagnostic after this change.
Call cancel_delayed_work_sync() after mmc_remove_host() has stopped new requests and before the driver releases the host resources.
--- drivers/mmc/host/mtk-sd.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/mtk-sd.c +1 -0
@@ -2702,6 +2702,7 @@ static int msdc_drv_remove(struct platfoplatform_set_drvdata (pdev,NULL );mmc_remove_host (mmc); +cancel_delayed_work_sync (&host->req_timeout);msdc_deinit_hw (host);msdc_gate_clock (host);
Greg Kroah-Hartman
maintainerPATCH 370/571 mmc: sdhci-sprd: disable runtime PM on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit e1c6c10a6a70a69e29b04fcc1ebe4b9bcbc7a49a upstream.
sdhci_sprd_probe() enables runtime PM, while sdhci_sprd_remove() does not perform the corresponding runtime PM cleanup.
The probe failure path disables runtime PM before disabling the clocks, but the normal remove path directly disables clocks that are also managed by the runtime PM callbacks. If the device is runtime suspended, those clocks may already be disabled.
Resume the device before removal, disable runtime PM and drop the temporary runtime PM reference before disabling the clocks.
This issue was found by manual code inspection.
--- drivers/mmc/host/sdhci-sprd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci-sprd.c +4 -0
@@ -743,6 +743,10 @@ static int sdhci_sprd_remove(struct platstruct sdhci_host *host =platform_get_drvdata (pdev);struct sdhci_sprd_host *sprd_host =TO_SPRD_HOST (host); +pm_runtime_get_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +sdhci_remove_host (host,0 );clk_disable_unprepare (sprd_host->clk_sdio);
Greg Kroah-Hartman
maintainerPATCH 371/571 net/packet: guard the ll header push in packet_rcv_spkt()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quchaosheng <[email protected]>
commit 28bc1ef699610ee09ce3d46a00552f5a0a0144bd upstream.
packet_rcv_spkt() restores the link layer header with
skb_push(skb, skb->data - skb_mac_header(skb));
That subtraction is only meaningful when the device actually has a link layer header. packet_rcv() and tpacket_rcv() both wrap it in dev_has_header(), which is also the predicate the block comment at the top of the file states the restore in terms of; packet_rcv_spkt() does not. commit d549699048b4 ("net/packet: fix packet receive on L3 devices without visible hard header") introduced the helper and changed the two call sites, and this one stayed behind.
A device without a visible ll header can leave skb->mac_header at the 0xFFFF sentinel that __alloc_skb() initialises it to. A CAN skb does:init_can_skb() sets pkt_type and ip_summed but does not reset the headers, and commit 9f10374bb024 ("can: remove private CAN skb headroom infrastructure") dropped the skb_reset_*_header() calls that used to be there. skb_mac_header() is then 0xFFFF, the length becomes a large negative number and skb_push() reports it through skb_under_panic() -- from softirq context, so it is a full system panic even with panic_on_oops=0:
skbuff: skb_under_panic: text:ffffffff8bd21bc1 len:-65455 put:-65471 head:... data:... tail:0x50 end:0x180 dev:can0 kernel BUG at net/core/skbuff.c:214!
RIP: 0010:skb_panic+0x50/0x60 Call Trace: <IRQ> skb_push+0x38/0x40 packet_rcv_spkt+0xe1/0x170 __netif_receive_skb_core.constprop.0+0x7e8/0xd30 ... Kernel panic - not syncing: Fatal exception in interrupt
The socket type is reachable: packet_create() accepts SOCK_PACKET alongside SOCK_RAW and SOCK_DGRAM behind the same CAP_NET_RAW check, and neither the socket length nor a capability check keeps it away from a CAN interface.
The missing skb_reset_*_header() calls in init_can_skb() are a regression in their own right and are being fixed separately, but a packet socket should not turn a link layer that did not initialise its mac header into a kernel panic. Guard the push the way the other two receive paths do.
Tested on v7.3-rc5 under QEMU with a slcan device on a pty, which is the driver RX path: vcan does not reproduce it, because can_send() resets the headers on the way out. One SOCK_PACKET socket bound to can0 and one frame written into the line discipline panics an unpatched kernel with the trace above; the same image with this patch prints no panic and powers off normally. Both kernels are this tree, defconfig plus CONFIG_CAN_SLCAN=y, differing only in this hunk.
--- net/packet/af_packet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/packet/af_packet.c +2 -1
@@ -1926,7 +1926,8 @@ static int packet_rcv_spkt(struct sk_buf spkt = &PACKET_SKB_CB (skb)->sa.pkt; -skb_push (skb, skb->data -skb_mac_header (skb)); +if (dev_has_header (dev)) +skb_push (skb, skb->data -skb_mac_header (skb));/* * The SOCK_PACKET socket receives _all_ frames.
Greg Kroah-Hartman
maintainerPATCH 372/571 net/smc: protect clcsock lifetime in smc_getname
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit 64a6b36b0e1855288080bc5f89769f27d6dc03c8 upstream.
smc_getname() dereferences smc->clcsock without holding clcsock_release_lock. Link-group termination can release the CLC socket through smc_close_active_abort() while the SMC socket is still open, for example after shutdown(SHUT_WR).
A getsockname() caller can load smc->clcsock, then the termination worker can clear the pointer and call sock_release() before the caller accesses clcsock->ops or invokes getname(). This causes a use-after-free; if the worker clears the pointer before the load, it causes a NULL dereference. The syscall's file reference keeps the SMC socket alive but does not prevent asynchronous release of its CLC socket.
KASAN reported the following with test-only timing instrumentation:
BUG: KASAN: slab-use-after-free in smc_getname+0x19e/0x1b0 Read of size 8 at addr ffff888109abb4e0 by task poc/103 Call Trace: smc_getname+0x19e/0x1b0 do_getsockname+0xe5/0x170 __sys_getsockname+0x8c/0x100 Allocated by task 95: sock_alloc_inode+0x1e/0x280 sock_alloc+0x3d/0x240 __sock_create+0x7e/0x430 smc_create+0x121/0x240 Freed by task 0: kmem_cache_free+0xcc/0x340 rcu_core+0x50a/0x1850 Last potentially related work creation: evict+0x446/0x6c0 smc_clcsock_release+0xa8/0xd0 smc_close_active_abort+0x26a/0x3a0 __smc_lgr_terminate.part.0+0x137/0x2e0
Hold clcsock_release_lock across the pointer check and the getname() callback to serialize with smc_clcsock_release(). Return -EBADF if the CLC socket has already been released, preserving the existing peer state check and the callback's return value otherwise.
--- net/smc/af_smc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/smc/af_smc.c +6 -1
@@ -2291,6 +2291,7 @@ static int smc_getname(struct socket *so int peer) {struct smc_sock *smc; +int rc = -EBADF ;if (peer && (sock->sk->sk_state !=SMC_ACTIVE ) && (sock->sk->sk_state !=SMC_APPCLOSEWAIT1 ))
@@ -2298,7 +2299,11 @@ static int smc_getname(struct socket *so smc =smc_sk (sock->sk); -return smc->clcsock->ops->getname (smc->clcsock, addr, peer); +mutex_lock (&smc->clcsock_release_lock); +if (smc->clcsock) + rc = smc->clcsock->ops->getname (smc->clcsock, addr, peer); +mutex_unlock (&smc->clcsock_release_lock); +return rc; }static int smc_sendmsg (struct socket *sock,struct msghdr *msg,size_t len)
Greg Kroah-Hartman
maintainerPATCH 373/571 net: bridge: avoid recursive multicast port cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zixuan Chai <[email protected]>
commit 5158353121bae4f552cb677ce8c5c3ef52f93a0d upstream.
br_multicast_sg_del_exclude_ports() removes automatically added STAR_EXCL port groups by calling br_multicast_del_pg(). For S,G entries, that deletion calls back into br_multicast_sg_del_exclude_ports(), so a large number of STAR_EXCL ports consumes one kernel stack frame per port and can hit the stack guard page.
Keep the complete port-group deletion path for cleanup, but suppress the S,G exclude-port cleanup while that helper is already walking the same entry. Normal deletion callers retain the existing behavior.
--- net/bridge/br_multicast.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
net/bridge/br_multicast.c +18 -5
@@ -80,6 +80,10 @@ __br_multicast_add_group(struct net_brid bool blocked);static void br_multicast_find_del_pg (struct net_bridge *br,struct net_bridge_port_group *pg); +static void __br_multicast_del_pg (struct net_bridge_mdb_entry *mp, +struct net_bridge_port_group *pg, +struct net_bridge_port_group __rcu **pp, +bool sg_del_exclude_ports);static void __br_multicast_stop (struct net_bridge_mcast *brmctx); static int br_mc_disabled_update(struct net_device *dev, bool value,
@@ -436,7 +440,7 @@ static void br_multicast_sg_del_exclude_for (pp = &sgmp->ports; (p =mlock_dereference (*pp, sgmp->br)) !=NULL ;) {if (!(p->flags &MDB_PG_FLAGS_PERMANENT )) -br_multicast_del_pg (sgmp, p, pp); +__br_multicast_del_pg (sgmp, p, pp, false);else pp = &p->next; }
@@ -675,9 +679,10 @@ static void br_multicast_destroy_port_grkfree_rcu (pg, rcu); } -void br_multicast_del_pg (struct net_bridge_mdb_entry *mp, -struct net_bridge_port_group *pg, -struct net_bridge_port_group __rcu **pp) +static void __br_multicast_del_pg (struct net_bridge_mdb_entry *mp, +struct net_bridge_port_group *pg, +struct net_bridge_port_group __rcu **pp, +bool sg_del_exclude_ports) {struct net_bridge *br = pg->key.port->br;struct net_bridge_group_src *ent;
@@ -692,7 +697,8 @@ void br_multicast_del_pg(struct net_bridif (!br_multicast_is_star_g (&mp->addr)) {rhashtable_remove_fast (&br->sg_port_tbl, &pg->rhnode, br_sg_port_rht_params); -br_multicast_sg_del_exclude_ports (mp); +if (sg_del_exclude_ports) +br_multicast_sg_del_exclude_ports (mp); }else {br_multicast_star_g_handle_mode (pg,MCAST_INCLUDE ); }
@@ -703,6 +709,13 @@ void br_multicast_del_pg(struct net_bridmod_timer (&mp->timer, jiffies); } +void br_multicast_del_pg (struct net_bridge_mdb_entry *mp, +struct net_bridge_port_group *pg, +struct net_bridge_port_group __rcu **pp) +{ +__br_multicast_del_pg (mp, pg, pp, true); +} +static void br_multicast_find_del_pg (struct net_bridge *br,struct net_bridge_port_group *pg) {
Greg Kroah-Hartman
maintainerPATCH 374/571 net: usb: ax88179_178a: fix rx frame length for non-last packets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fredrik Nyberg <[email protected]>
commit 9b6c20f788472d2042717a3c2f1bc60b2b77083e upstream.
Commit 4ce62d5b2f7a ("net: usb: ax88179_178a: stop lying about skb->truesize") replaced skb_clone() with a copy into a new skb for every packet of a bulk-in transfer except the last one. The copy skips the 2-byte IP alignment pseudo header but still copies pkt_len bytes, and pkt_len includes that header. Each of these frames is therefore delivered with two extra trailing bytes: the 0xeeee pseudo header of the next slot when the frame ends on an 8-byte boundary, or slot padding otherwise. The last packet is still trimmed to pkt_len - 2.
IPv4 and IPv6 trim the extra bytes, so most traffic is unaffected. Anything that relies on the frame length is not. MACsec takes the ICV from the last 16 bytes and drops every such frame as InPktsNotValid. In our setup that was 0.2-1.2% of received MACsec frames, depending on how many frames shared a transfer, including service discovery multicast.
Allocate and copy pkt_len - 2 bytes, like the last-packet path.
--- drivers/net/usb/ax88179_178a.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/ax88179_178a.c +3 -3
@@ -1483,11 +1483,11 @@ static int ax88179_rx_fixup(struct usbnereturn 1 ; } - ax_skb =netdev_alloc_skb_ip_align (dev->net, pkt_len); + ax_skb =netdev_alloc_skb_ip_align (dev->net, pkt_len -2 );if (!ax_skb)return 0 ; -skb_put (ax_skb, pkt_len); -memcpy (ax_skb->data, skb->data +2 , pkt_len); +skb_put (ax_skb, pkt_len -2 ); +memcpy (ax_skb->data, skb->data +2 , pkt_len -2 );ax88179_rx_checksum (ax_skb, pkt_hdr);usbnet_skb_return (dev, ax_skb);
Greg Kroah-Hartman
maintainerPATCH 375/571 nvme: fix swapped ZRASF zone state values for full and read only
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Bonde Torp <[email protected]>
commit 564e46d9f6e87912effa03f123d37a511d520f09 upstream.
The Zone Management Receive command Zone Receive Action Specific (ZRASF) reporting option values for the Full and Read Only zone states are swapped compared to the NVM Express Zoned Namespace Command Set Specification, Revision 1.5, Figure 35:
- 5h lists the zones in the ZSF:Full state.
- 6h lists the zones in the ZSRO:Read Only state.
The nvmet ZNS backend uses these constants to map the ZRASF value received from the host to a block layer zone condition when filtering zones in Report Zones. Because of the swap, a host asking for full zones was given the read only zones, and a host asking for read only zones was given the full zones.
Swap the values of NVME_ZRASF_ZONE_STATE_FULL and NVME_ZRASF_ZONE_STATE_READONLY to match the specification.
--- include/linux/nvme.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/nvme.h +2 -2
@@ -957,8 +957,8 @@ enum {NVME_ZRASF_ZONE_STATE_IMP_OPEN =0x02 ,NVME_ZRASF_ZONE_STATE_EXP_OPEN =0x03 ,NVME_ZRASF_ZONE_STATE_CLOSED =0x04 , -NVME_ZRASF_ZONE_STATE_READONLY =0x05 , -NVME_ZRASF_ZONE_STATE_FULL =0x06 , +NVME_ZRASF_ZONE_STATE_FULL =0x05 , +NVME_ZRASF_ZONE_STATE_READONLY =0x06 ,NVME_ZRASF_ZONE_STATE_OFFLINE =0x07 , NVME_REPORT_ZONE_PARTIAL = 1, };
Greg Kroah-Hartman
maintainerPATCH 376/571 openvswitch: fix soft lockup in the netlink flow dump
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis V. Lunev <[email protected]>
commit aaaaf87ea99b8766c9a8aa0e71aa42e6bc8a5320 upstream.
A production compute node carrying a few thousand datapath flows hit a soft lockup inside a single netlink flow dump and panicked.
ovs_flow_cmd_dump() calls ovs_flow_stats_get() for every flow it emits, and that releases stats->lock with spin_unlock_bh() once per CPU that has touched the flow. Every release is a local_bh_enable(), and each one runs the pending softirq backlog in the dumping thread's own context.
The skb bounds the flows one callback emits, but not the softirq work it absorbs. On a CPU that carries the box's packet load the backlog refills as fast as it drains, so the dumping thread becomes that CPU's softirq engine. It never sleeps and it has no reschedule point, so under voluntary preemption nothing can take the CPU away from it:
neither the ksoftirqd the kernel woke to take the work over, nor the stopper thread the softlockup detector dispatches to refresh its timestamp.
Hold BH off across the whole callback instead, the way ctnetlink_dump_table() does, so the nested spin_unlock_bh() stop draining softirqs. The loop already runs under rcu_read_lock() and cannot sleep. What it gives up is preemption under CONFIG_PREEMPT, since a BH-off region is not preemptible outside PREEMPT_RT. The region stays short: the skb caps the flows one callback emits, and empty buckets cost no skb space but are each visited once per dump, as the cursor only moves forward. The table grows on insert and shrinks only on flush, so the walk is bounded by the largest flow count the datapath has held. The softirq backlog the callback used to absorb has no bound at all.
--- net/openvswitch/datapath.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/openvswitch/datapath.c +8 -0
@@ -1474,6 +1474,12 @@ static int ovs_flow_cmd_dump(struct sk_breturn -ENODEV ; } +/* +* Not needed for safety. Stops every spin_unlock_bh() in +* ovs_flow_stats_get() from running the softirq backlog. +*/ +local_bh_disable (); + ti =rcu_dereference (dp->table.ti);for (;;) {struct sw_flow *flow;
@@ -1494,6 +1500,8 @@ static int ovs_flow_cmd_dump(struct sk_b cb->args[0 ] = bucket; cb->args[1 ] = obj; } + +local_bh_enable ();rcu_read_unlock ();return skb->len; }
Greg Kroah-Hartman
maintainerPATCH 377/571 regulator: ltc3676: dont read the write-only HRST and CLIRQ registers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Ojha <[email protected]>
commit 28c2388ee24cdbefbcc458fa41ef7bffaaa1cc83 upstream.
HRST (0x1e) and CLIRQ (0x1f) are write-only command strobes. Writing HRST triggers a hard reset of the chip and writing CLIRQ clears the interrupt; reading them returns nothing useful, and the read itself fires the command.
The result is that a plain register dump resets the board:
cat /sys/kernel/debug/regmap/2-003c/registers
walks every readable register, hits HRST, and the board reboots.
Split the callback back in two so HRST and CLIRQ stay writable but are no longer readable. The readable range is left unchanged (LTC3676_BUCK1 ... LTC3676_IRQSTAT).
--- drivers/regulator/ltc3676.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/regulator/ltc3676.c +12 -3
@@ -232,7 +232,7 @@ static const struct regulator_desc ltc36 LTC3676_FIXED_REG(LDO4, ldo4, LDOB, 2), }; -static bool ltc3676_readable_writeable_reg (struct device *dev,unsigned int reg) +static bool ltc3676_writeable_reg (struct device *dev,unsigned int reg) {switch (reg) { case LTC3676_BUCK1 ... LTC3676_IRQSTAT:
@@ -243,6 +243,15 @@ static bool ltc3676_readable_writeable_rreturn false; } +static bool ltc3676_readable_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { + case LTC3676_BUCK1 ... LTC3676_IRQSTAT: +return true; + } +return false; +} +static bool ltc3676_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {
@@ -255,8 +264,8 @@ static bool ltc3676_volatile_reg(structstatic const struct regmap_config ltc3676_regmap_config = { .reg_bits =8 , .val_bits =8 , - .writeable_reg = ltc3676_readable_writeable_reg, - .readable_reg = ltc3676_readable_writeable_reg, + .writeable_reg = ltc3676_writeable_reg, + .readable_reg = ltc3676_readable_reg, .volatile_reg = ltc3676_volatile_reg, .max_register =LTC3676_CLIRQ , .use_single_read = true,
Greg Kroah-Hartman
maintainerPATCH 378/571 scsi: qedi: Initialize callback state before registration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 85de8b3a5eaa23d153aff4c7c83dddbc949064c9 upstream.
qedi_get_protocol_tlv_data() can be called asynchronously by QED after qedi_ops->register_ops(). It takes stats_lock and reads ll2_mtu, but __qedi_probe() currently registers the callback before initializing the mutex and assigning the default MTU on the normal probe path.
Initialize the callback-visible state before registering qedi_cb_ops. Keep the recovery path from reinitializing state because it reuses the existing qedi context.
--- drivers/scsi/qedi/qedi_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/qedi/qedi_main.c +1 -2
@@ -2669,8 +2669,6 @@ retry_probe:snprintf (host_buf,sizeof (host_buf),"host_%d" , qedi->shost->host_no); qedi_ops->common->set_name (qedi->cdev, host_buf); - qedi_ops->register_ops (qedi->cdev, &qedi_cb_ops, qedi); -memset (¶ms,0 ,sizeof (params)); params.mtu =DEF_PATH_MTU +IPV6_HDR_LEN +TCP_HDR_LEN ; qedi->ll2_mtu =DEF_PATH_MTU ;
@@ -2687,6 +2685,7 @@ retry_probe:spin_lock_init (&qedi->task_idx_lock);mutex_init (&qedi->stats_lock); } + qedi_ops->register_ops (qedi->cdev, &qedi_cb_ops, qedi); qedi_ops->ll2->register_cb_ops (qedi->cdev, &qedi_ll2_cb_ops, qedi); qedi_ops->ll2->start (qedi->cdev, ¶ms);
Greg Kroah-Hartman
maintainerPATCH 379/571 Bluetooth: hci_sock: Serialize dead-device detachment
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit 381a0925c556a8d91a80a9b9e3e86651d60ffee3 upstream.
Rebinding an HCI socket after its controller is unregistered can race monitor control replay and crash the kernel. hci_sock_bind() clears hci_pi(sk)->hdev and drops the device reference under only the socket lock, whereas send_monitor_control_replay() holds hci_sk_list.lock for reading.
Replay can observe a non-NULL hdev, then bind can clear it and drop the last reference before create_monitor_ctrl_open() reads hdev->id. This can cause a NULL pointer dereference if the pointer is reloaded, or a use-after-free if the old pointer is retained.
The kernel reported:
KASAN: null-ptr-deref in range [0x0000000000000068-0x000000000000006f] RIP: 0010:create_monitor_ctrl_open+0x579/0x800 Call Trace: hci_sock_bind+0xd96/0x1190 __sys_bind+0x166/0x200 __x64_sys_bind+0x6d/0xb0 do_syscall_64+0xdd/0x4a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
The same missing serialization lets hci_send_to_sock() select a socket for the old device and queue its frame after bind has detached the socket or installed a new binding.
Take hci_sk_list.lock for writing when clearing the device pointer and resetting the socket state. This waits for existing replay and delivery readers to finish before detachment and prevents later readers from using the old binding. Keep hci_dev_put() outside the critical section because the final device release can sleep.
--- net/bluetooth/hci_sock.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/hci_sock.c +2 -0
@@ -1157,8 +1157,10 @@ static int hci_sock_bind(struct socket **/ hdev =hci_pi (sk)->hdev;if (hdev &&hci_dev_test_flag (hdev,HCI_UNREGISTER )) { +write_lock (&hci_sk_list.lock);hci_pi (sk)->hdev =NULL ; sk->sk_state =BT_OPEN ; +write_unlock (&hci_sk_list.lock);hci_dev_put (hdev); } hdev =NULL ;
Greg Kroah-Hartman
maintainerPATCH 380/571 Bluetooth: RFCOMM: free the skb when the DLC has no owner
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Skokov <[email protected]>
commit 9d1afbf60ed53c5b051cd124153e0ae3078c8b93 upstream.
rfcomm_recv_data() hands the skb to d->data_ready() and returns 0 without freeing it, so the callback owns the skb from that point on. The tty implementation frees it when the DLC has been detached from its device:
static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc,
struct sk_buff *skb)
{
struct rfcomm_dev *dev = dlc->owner; if (!dev) {
kfree_skb(skb);
return;
}The socket implementation returns without freeing it, and the skb is leaked.
A connected DLC can have no owner: rfcomm_sock_destruct() clears d->owner, while the DLC itself stays on the session until it is closed. Data frames that arrive in that window still find d->state == BT_CONNECTED in rfcomm_recv_data() and are handed to the callback, one leaked skb each.
The leak does not stop on its own either. The remote runs out of credits only once RFCOMM_RX_THROTTLED is set, and for a socket the only place that sets it is rfcomm_sk_data_ready() itself, below the return. rfcomm_process_dlcs() keeps granting credits, so the remote keeps sending and the leak keeps growing.
Free the skb, as the tty side does.
--- net/bluetooth/rfcomm/sock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/bluetooth/rfcomm/sock.c +4 -1
@@ -50,8 +50,11 @@ static void rfcomm_sock_kill(struct sockstatic void rfcomm_sk_data_ready (struct rfcomm_dlc *d,struct sk_buff *skb) {struct sock *sk = d->owner; -if (!sk) + +if (!sk) { +kfree_skb (skb);return ; + }atomic_add (skb->len, &sk->sk_rmem_alloc);skb_queue_tail (&sk->sk_receive_queue, skb);
Greg Kroah-Hartman
maintainerPATCH 381/571 Bluetooth: RFCOMM: Fix NULL tty_dev dereference in rfcomm_dev_shutdown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Palla Raghunath <[email protected]>
commit 08e90633377f1b2567ab5ad6810b74c552246a07 upstream.
syzbot hit a NULL pointer dereference in rfcomm_dev_shutdown() when an RFCOMM tty is closed.
rfcomm_dev_add() puts the new device on rfcomm_dev_list first and only then registers the tty device and saves it in dev->tty_dev. If that registration fails, dev->tty_dev is never set at all. The device can be looked up in the meantime, so an open() of /dev/rfcommN gets through rfcomm_tty_install() and attaches to it. When that tty is closed again, rfcomm_dev_shutdown() uses dev->tty_dev without checking it:
Oops: general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range [0x0000000000000040-0x0000000000000047] RIP: 0010:rfcomm_dev_shutdown+0x48/0xb0 net/bluetooth/rfcomm/tty.c:131 Call Trace: tty_port_shutdown+0x1bf/0x220 drivers/tty/tty_port.c:372 tty_port_close+0x4e/0x150 drivers/tty/tty_port.c:705 tty_release+0x359/0x1670 drivers/tty/tty_io.c:1718 __fput+0x418/0xa50 fs/file_table.c:512
rfcomm_dev_destruct() already copes with a NULL dev->tty_dev. Add the same check to rfcomm_dev_shutdown(), so the tty device is only moved when it was actually registered.
--- net/bluetooth/rfcomm/tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/rfcomm/tty.c +1 -1
@@ -132,7 +132,7 @@ static void rfcomm_dev_shutdown(struct t { struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); -if (dev->tty_dev->parent) +if (dev->tty_dev && dev->tty_dev->parent)device_move (dev->tty_dev,NULL ,DPM_ORDER_DEV_LAST );/* close the dlc */
Greg Kroah-Hartman
maintainerPATCH 382/571 drm/gud: dont keep a connector without a CRTC as connector_state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sajal Gupta <[email protected]>
commit 71ec70ea26e399eb8371fe9d2d5bf5dab09570fb upstream.
If the 'for_each_new_connector_in_state()' loop finishes without hitting the break, connector_state is left pointing at the last connector visited, which has no CRTC, instead of staying NULL.
That skips the "if (!connector_state)" fallback below the loop, which looks up the active connector when the state contains none. The function then carries on with a connector that is not driven.
Fix by resetting connector_state to NULL for each connector visited that has no CRTC, so that it is NULL when none was found and the fallback runs.
--- drivers/gpu/drm/gud/gud_pipe.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/gud/gud_pipe.c +1 -0
@@ -475,6 +475,7 @@ int gud_pipe_check(struct drm_simple_disfor_each_new_connector_in_state (state, connector, connector_state, i) {if (connector_state->crtc)break ; + connector_state =NULL ; }/*
Greg Kroah-Hartman
maintainerPATCH 383/571 drm/i915/gem: Prevent overstepping exec array boundary
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Karas <[email protected]>
commit ebe162db655881a38de43301151ff7ac940602b5 upstream.
It is possible for eb_relocate_parse_slow() to call kvfree() on entries outside the original exec array during following scenario inside eb_relocate_parse_slow():
1) eb_copy_relocations() allocates as many as eb->buffer_count copies for exec entries;
2) eb_parse() appends up to two VMAs, right after incrementing eb->buffer_count;
3) cleanup under "out" label uses this incremented buffer_count to release relocation pointers from exec array via kvfree(), not from VMA array.
To amend this problem, ensure that relocation cleanup uses the original exec object count, excluding the VMAs appended by the command parser.
--- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +1 -1
@@ -1680,6 +1680,7 @@ static int eb_reinit_userptr(struct i915 static noinline int eb_relocate_parse_slow(struct i915_execbuffer *eb,struct i915_request *rq) { +const unsigned int count = eb->buffer_count;bool have_copy = false;struct eb_vma *ev;int err =0 ;
@@ -1804,7 +1805,6 @@ err: out:if (have_copy) { -const unsigned int count = eb->buffer_count;unsigned int i;for (i =0 ; i < count; i++) {
Greg Kroah-Hartman
maintainerPATCH 384/571 drm/vc4: drain the hangcheck timer and works on V3D unbind
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 94cf5971b1d04c6382437387c4dc3836cc7a1437 upstream.
Nothing stops the hangcheck timer that submitted jobs arm, or the job_done_work that the render-done interrupt queues, at teardown:vc4_irq_disable() cancels only overflow_mem_work, and vc4_gem_destroy() runs from the drm-managed release, after vc4_v3d_unbind() has already uninstalled the V3D interrupt and cleared vc4->v3d. A timer still armed by then reads V3D registers through the NULL vc4->v3d pointer, and the late callbacks run on the vc4_dev embedding them after it has been freed.
Drain them in vc4_v3d_unbind(): shut the timer down and cancel reset_work before the interrupt is taken down, because its vc4_irq_reset() re-enables it, then flush job_done_work so that completions queued at teardown still release their jobs.
This issue was found by an in-house static analysis tool.
--- drivers/gpu/drm/vc4/vc4_v3d.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/vc4/vc4_v3d.c +8 -0
@@ -9,6 +9,7 @@#include <linux/component.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/timer.h> #include "vc4_drv.h" #include "vc4_regs.h"
@@ -476,8 +477,15 @@ static void vc4_v3d_unbind(struct devicepm_runtime_disable (dev); +/* A straggler vc4_reset() re-enables the interrupt. */ +timer_shutdown_sync (&vc4->hangcheck.timer); +cancel_work_sync (&vc4->hangcheck.reset_work); +vc4_irq_uninstall (drm); +/* Flush rather than cancel, so queued completions release their jobs. */ +flush_work (&vc4->job_done_work); +/* Disable the binner's overflow memory address, so the next * driver probe (if any) doesn't try to reuse our old * allocation.
Greg Kroah-Hartman
maintainerPATCH 385/571 drm/amdgpu: make Mac FB workaround generic
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit c7f44ec5c4ec760e74351f1843dcb8322f67cbf6 upstream.
Rather than adding a case of every chip where this is seen just check if the FB is at 0 and the ssid is apple. This should cover all chips which fall into this case.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +7 -10
@@ -693,20 +693,17 @@ void amdgpu_gmc_get_vbios_allocations(stcase CHIP_RENOIR : adev->mman.keep_stolen_vga_memory = true;break ; -case CHIP_POLARIS10 : -case CHIP_POLARIS11 : -case CHIP_POLARIS12 : -/* MacBookPros with switchable graphics put VRAM at 0 when -* the iGPU is enabled which results in cursor issues if -* the cursor ends up at 0. Reserve vram at 0 in that case. -*/ -if (adev->gmc.vram_start ==0 ) - adev->mman.keep_stolen_vga_memory = true; -break ;default : adev->mman.keep_stolen_vga_memory = false;break ; } +/* MacBookPros with switchable graphics put VRAM at 0 when +* the iGPU is enabled which results in cursor issues if +* the cursor ends up at 0. Reserve vram at 0 in that case. +*/ +if ((adev->pdev->subsystem_vendor ==PCI_VENDOR_ID_APPLE ) && + (adev->gmc.vram_start ==0 )) + adev->mman.keep_stolen_vga_memory = true;if (amdgpu_sriov_vf (adev) || !amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_DCE )) {
Greg Kroah-Hartman
maintainerPATCH 386/571 fs: refuse fspick() on internal superblocks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 02587a4af82adccaef8e3b3624b4e7f1c401632d upstream.
There's a few instances where a internal superblock is reachable by fspick(). Block that. graft_tree() and fsmount() already refuse them. fanotify refuses mount and superblock marks on them for the same reason.
--- fs/fsopen.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fsopen.c +3 -0
@@ -191,6 +191,9 @@ SYSCALL_DEFINE3(fspick, int, dfd, const ret = -EINVAL ;if (target.mnt->mnt_root != target.dentry) goto err_path; +/* kernel-internal superblocks are nobody's to reconfigure */ +if (target.dentry->d_sb->s_flags &SB_NOUSER ) + goto err_path; fc =fs_context_for_reconfigure (target.dentry,0 ,0 );if (IS_ERR (fc)) {
Greg Kroah-Hartman
maintainerPATCH 387/571 namespace: check a submount for references right before unmounting it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 32bf92416614a1e3ff3524fc6b780259c7aad3ef upstream.
shrink_submounts() and mark_mounts_for_expiry() first collect all the mounts they are allowed to unmount and then unmount them.
Whether a mount is busy is decided by propagate_mount_busy() on the tree. But unmounting the first mount changes the tree that the second one propagates into. propagate_umount()
moves a surviving overmount off a copy it unmounts and mounts it where the copy was mounted. If that's where the propagated copy of the second victim is looked up the overmount becomes a candidate of the second umount_tree(). It's childless and so trim_one() commits it without looking at its reference count.
So a synchronous umount pulls out a busy mount that is in use somewhere else and marks it MNT_SYNC_UMOUNT while it has users:
umount2(/tmp/plshrink/p1, 0) = 0 errno 0
cwd is (unreachable)
The same two umounts requested one after the other fail with EBUSY. This needs a mount with MNT_SHRINKABLE, i.e., automounted submounts of NFS, AFS and CIFS or the tracefs mount below debugfs. Bind mounts inherit the flag.
Check each mount right before it is unmounted under the same hold of namespace_sem and mount_lock as the umount itself. Make sure that the algorithm stays linear.
--- fs/namespace.c | 78 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 25 deletions(-)
fs/namespace.c +53 -25
@@ -3154,6 +3154,11 @@ void mark_mounts_for_expiry(struct list_ }while (!list_empty (&graveyard)) { mnt = list_first_entry(&graveyard, struct mount, mnt_expire); +/* an earlier umount_tree() may have moved a busy mount here */ +if (propagate_mount_busy (mnt,1 )) { +list_move (&mnt->mnt_expire, mounts); +continue ; + }touch_mnt_namespace (mnt->mnt_ns);umount_tree (mnt,UMOUNT_PROPAGATE |UMOUNT_SYNC ); }
@@ -3164,16 +3169,36 @@ void mark_mounts_for_expiry(struct list_EXPORT_SYMBOL_GPL (mark_mounts_for_expiry);/* +* Unmount @mnt if it's a shrinkable mount without children that nobody uses. +* +* mount_lock must be held for write +*/ +static bool shrink_submount (struct mount *mnt) +{ +if (propagate_mount_busy (mnt,1 )) +return false; +touch_mnt_namespace (mnt->mnt_ns); +umount_tree (mnt,UMOUNT_PROPAGATE |UMOUNT_SYNC ); +return true; +} + +/* * Ripoff of 'select_parent()' * -* search the list of submounts for a given mountpoint, and move any -* shrinkable submounts to the 'graveyard' list. +* unmount the shrinkable submounts of @parent that aren't busy, children +* before their parent, and say whether anything went +* +* The cursor into the children of @this_parent survives the umount of a +* child mount without child mounts. The mounts that get umounted together with +* it are located under receiving mounts of @this_parent and never under +* @this_parent itself. The one exception is @this_parent getting unmounted +* then the walk starts over. */ -static int select_submounts (struct mount *parent,struct list_head *graveyard) +static bool __shrink_submounts (struct mount *parent) {struct mount *this_parent = parent;struct list_head *next; -int found =0 ; +bool shrunk = false; repeat: next = this_parent->mnt_mounts.next;
@@ -3192,42 +3217,45 @@ resume: this_parent = mnt; goto repeat; } - -if (!propagate_mount_busy (mnt,1 )) { -list_move_tail (&mnt->mnt_expire, graveyard); - found++; - } +if (!shrink_submount (mnt)) +continue ; + shrunk = true; +if (unlikely (this_parent->mnt.mnt_flags &MNT_UMOUNT )) +return true; }/* * All done at this level ... ascend and resume the search */ if (this_parent != parent) { - next = this_parent->mnt_child.next; - this_parent = this_parent->mnt_parent; +struct mount *mnt = this_parent; + + next = mnt->mnt_child.next; + this_parent = mnt->mnt_parent; +/* its children are gone, maybe it can go as well */ +if (shrink_submount (mnt)) { + shrunk = true; +if (unlikely (this_parent->mnt.mnt_flags &MNT_UMOUNT )) +return true; + } goto resume; } -return found; +return shrunk; }/* -* process a list of expirable mountpoints with the intent of discarding any -* submounts of a specific parent mountpoint +* unmount the shrinkable submounts of @mnt that aren't busy +* +* The busy check and the umount of a mount are adjacent. An umount can +* still empty or move a mount in a part of the tree that was walked +* already, so walk again until nothing goes. * * mount_lock must be held for write */ static void shrink_submounts (struct mount *mnt) { -LIST_HEAD (graveyard); -struct mount *m; - -/* extract submounts of 'mountpoint' from the expiration list */ -while (select_submounts (mnt, &graveyard)) { -while (!list_empty (&graveyard)) { - m = list_first_entry(&graveyard, struct mount, - mnt_expire); -touch_mnt_namespace (m->mnt_ns); -umount_tree (m,UMOUNT_PROPAGATE |UMOUNT_SYNC ); - } +for (;;) { +if (!__shrink_submounts (mnt)) +break ; } }
Greg Kroah-Hartman
maintainerPATCH 388/571 dcache: dont put a mountpoint on a dentry thats being removed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 75f4197f1e11d2eb75c2d6f916a7d4764db621e5 upstream.
rmdir(), unlink() and rename() call dont_mount() on the victim and then detach_mounts() with the victim's inode locked. do_lock_mount() takes the inode lock of the mountpoint and checks cant_mount() so a mount can't show up after detach_mounts().
But attach_recursive_mnt() makes a second mountpoint for the root of the source mount so that the mounts already located at the destination can be put on top of it. No inode is locked for that one and d_set_mounted() only refuses a dentry that is unlinked. Between detach_mounts() and d_delete() the victim is still hashed:
rmrace: b passed dont_mount() and detach_mounts(), sleeping
T2: move_mount(S, /tmp/plcant/x, BENEATH) = 0 errno 0 ()
T1: rmdir(/tmp/plcant/d/b) = 0 errno 0
109 107 0:61 /d/b//deleted /tmp/plcant/x rw,relatime - tmpfs tmpfs rw
108 109 0:63 / /tmp/plcant/x rw,relatime - tmpfs T rwA bind mount of the directory that's being removed is moved beneath an existing mount while the rmdir() is located between the two calls. The mount ends up on the removed directory and nothing will ever detach it.
Check cant_mount() in d_set_mounted() as well. dont_mount() raises the flag under d_lock before detach_mounts() runs so either the mountpoint is set first and detach_mounts() finds the mount or the flag is seen and the mount is refused.
--- fs/dcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/dcache.c +3 -1
@@ -1477,6 +1477,8 @@ EXPORT_SYMBOL(path_has_submounts);* * Only one of d_invalidate() and d_set_mounted() must succeed. For * this reason take rename_lock and d_lock on dentry and ancestors. +* Likewise for dont_mount() which marks a dentry that is being removed +* under d_lock. */ int d_set_mounted (struct dentry *dentry) {
@@ -1493,7 +1495,7 @@ int d_set_mounted(struct dentry *dentry)spin_unlock (&p->d_lock); }spin_lock (&dentry->d_lock); -if (!d_unlinked (dentry)) { +if (!d_unlinked (dentry) && !cant_mount (dentry)) { ret = -EBUSY ;if (!d_mountpoint (dentry)) { dentry->d_flags |=DCACHE_MOUNTED ;
Greg Kroah-Hartman
maintainerPATCH 389/571 namespace: refuse an automount below a mount that is in no namespace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit ba985ce08471c555af2a2fbe217c1bc2e72a6d8c upstream.
It's possible to add autmounts even when the parent mount isn't in the mount namespace of the caller. The only requirement we have is that the parent mount namespace must not be NULL, i.e., unmounted.
Problem is that clone_private_mount() has MNT_NS_INTERNAL which makes that trivially true. So that passes the test and attach_recursive_mnt() accepts that as a mount point and funny enough, count_mounts() dereferences MNT_NS_INTERNAL. The problem is it is an error pointer...
So we can reach this in userspace via fanotify. A filesystem mark on the lower filesystem of an overlay reports paths on the layer clone and reading the event hands out a descriptor on it. For example with debugfs as the lower layer it goes kaboom:
openat(evfd, "tracing", O_DIRECTORY)
Oops: general protection fault KASAN: null-ptr-deref in range [0x1d0-0x1d7] RIP: 0010:count_mounts+0x35/0x200 attach_recursive_mnt finish_automount
And since that sleeping beauty happens under namespace_sem held for writing every mount operation on the system blocks from then on. Congrats.
Use is_mounted() instead which rejects unmounted and internal mounts alike. The open fails with EINVAL just as it did before clone_private_mount() used MNT_NS_INTERNAL.
--- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/namespace.c +1 -1
@@ -2921,7 +2921,7 @@ static int do_add_mount(struct mount *neif (!(mnt_flags &MNT_SHRINKABLE ))return -EINVAL ;/* ... and for those we'd better have mountpoint still alive */ -if (!parent->mnt_ns) +if (!is_mounted (&parent->mnt))return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 390/571 drm/dp: dont mark the AUX backlight enabled when enabling failed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Keri <[email protected]>
[ Upstream commit 707ce102521496c67860d81221b20c56d8255f2f ]
If drm_edp_backlight_enable() fails, dp_aux_backlight_update_status() still marks the backlight as enabled. From then on every brightness change only updates the level and the enable is never retried, so the panel stays dark until something blanks and unblanks the backlight.
Return the error instead, so the next update tries to enable again.
--- drivers/gpu/drm/drm_dp_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_helper.c +3 -1
@@ -3459,7 +3459,9 @@ static int dp_aux_backlight_update_status(struct backlight_device *bd)if (!backlight_is_blank (bd)) {if (!bl->enabled) { -drm_edp_backlight_enable (bl->aux, &bl->info, brightness); + ret =drm_edp_backlight_enable (bl->aux, &bl->info, brightness); +if (ret) +return ret; bl->enabled = true;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/571 gpio: exar: initialize the ID before registering its cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit 4d69e74034b208588636ecc177e0dd43a7696af3 ]
devm_add_action_or_reset() invokes the cleanup action immediately when registering the action fails. gpio_exar_probe() currently stores the allocated ID in exar_gpio only after registering the action, so that failure makes exar_devm_ida_free() release ID 0. If the allocated ID is nonzero, this leaks that ID and can free ID 0 belonging to another device.
Store the ID before registering the cleanup action so both the immediate failure path and normal device teardown release the correct allocation.
--- drivers/gpio/gpio-exar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-exar.c +1 -1
@@ -166,6 +166,7 @@ static int gpio_exar_probe(struct platform_device *pdev) index =ida_alloc (&ida_index,GFP_KERNEL );if (index <0 )return index; + exar_gpio->index = index; ret =devm_add_action_or_reset (dev, exar_devm_ida_free, exar_gpio);if (ret)
@@ -181,7 +182,6 @@ static int gpio_exar_probe(struct platform_device *pdev) exar_gpio->gpio_chip.set = exar_set_value; exar_gpio->gpio_chip.base =-1 ; exar_gpio->gpio_chip.ngpio = ngpios; - exar_gpio->index = index; exar_gpio->first_pin = first_pin; ret =devm_gpiochip_add_data (dev, &exar_gpio->gpio_chip, exar_gpio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/571 drm/aspeed: Balance the display clock enable on teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit ecce445c6489895463b7ddec2af66338287fee4c ]
aspeed_gfx_load() enables the display clock without checking the return value and never disables it on probe failure or removal. devm_clk_get() only releases the clock reference, leaving the enable unbalanced.
Use devm_clk_get_enabled() to handle enable failures and automatically disable and unprepare the clock on probe failure or removal.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +2 -3
@@ -181,13 +181,12 @@ static int aspeed_gfx_load(struct drm_device *drm) }reset_control_deassert (priv->rst); - priv->clk =devm_clk_get (drm->dev,NULL ); + priv->clk =devm_clk_get_enabled (drm->dev,NULL );if (IS_ERR (priv->clk)) {dev_err (&pdev->dev, -"missing or invalid clk device tree entry" ); +"failed to get and enable clock\n" );return PTR_ERR (priv->clk); } -clk_prepare_enable (priv->clk);/* Sanitize control registers */ writel (0 , priv->base +CRT_CTRL1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/571 drm/vc4: Free the BO cache size list on teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit b41ff8b529278216cba22a5dcdc93fea2a3a9619 ]
vc4_bo_cache_destroy() purges the cached BOs but never frees the size list, leaking it on every unbind.
--- drivers/gpu/drm/vc4/vc4_bo.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/vc4/vc4_bo.c +1 -0
@@ -994,6 +994,7 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused)cancel_work_sync (&vc4->bo_cache.time_work);vc4_bo_cache_purge (dev); +kfree (vc4->bo_cache.size_list);for (i =0 ; i < vc4->num_labels; i++) {if (vc4->bo_labels[i].num_allocated) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/571 net/sched: em_text: reject unterminated algo before autoload
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit c9728fcf2e7fb4a7a8d08ebd9524c3b02ae1a021 ]
This is a follow-up to commit 9c572a83037a ("net/sched: fix potential stack infoleak in em_text_dump()"), which zero-initialised the dump-side struct. Sashiko pointed at a pre-existing bug that exposed the change-side input-validation gap open.
em_text_change() casts the raw netlink attribute payload to struct tcf_em_text and passes conf->algo, a 16-byte array with no enforced NUL terminator, to textsearch_prepare(). On the TS_AUTOLOAD retry textsearch_prepare() calls request_module("ts_%s", algo); vsnprintf() walks %s until it finds a NUL, so an algo[] with no NUL reads past the array into the adjacent struct fields and payload and feeds those bytes to the usermode helper command line. This is an out-of-bounds read and a kernel memory disclosure.
Reject the attribute when no NUL exists within TC_EM_TEXT_ALGOSIZ bytes, matching the check xt_string has had since 3ab720881b6e.
Conditions to recreate the bug:
- CAP_NET_ADMIN on the target netns (namespace-local via unshare -Urn is enough)
- install clsact on an interface, then add a basic filter with one text ematch whose algo[] is 16 bytes with no NUL (e.g. "A"*16) and pattern_len at least 1
- the add fails with -ENOENT and the kernel invokes modprobe with a module name made of "ts_" plus the 16 bytes and the adjacent payload
--- net/sched/em_text.c | 3 +++ 1 file changed, 3 insertions(+)
net/sched/em_text.c +3 -0
@@ -51,6 +51,9 @@ static int em_text_change(struct net *net, void *data, int len,if (len <sizeof (*conf) || len < (sizeof (*conf) + conf->pattern_len))return -EINVAL ; +if (!memchr (conf->algo,'\0' ,sizeof (conf->algo))) +return -EINVAL ; +if (conf->from_layer > conf->to_layer)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/571 cxgb4/ch_ktls: disable softirqs around tid_list erases
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit 4c9dc0faca98084922caeb689579d338cf3e1c29 ]
chcr_ktls_cpl_act_open_rpl() inserts into tid_list from the receive path using xa_insert_bh(). The array is shared by the adapter's connections and initialized with XA_FLAGS_LOCK_BH. However, chcr_ktls_dev_del() and the chcr_ktls_dev_add() error path use xa_erase(), which takes the XArray lock without disabling softirqs.
When cleanup runs with softirqs enabled, a receive softirq for another connection on the same CPU can interrupt the erase and spin on the lock held by the interrupted task. Use xa_erase_bh() at both sites to match the insertion path.
--- .../net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c +2 -2
@@ -390,7 +390,7 @@ static void chcr_ktls_dev_del(struct net_device *netdev,cxgb4_remove_tid (&tx_info->adap->tids, tx_info->tx_chan, tx_info->tid, tx_info->ip_family); -xa_erase (&u_ctx->tid_list, tx_info->tid); +xa_erase_bh (&u_ctx->tid_list, tx_info->tid); } port_stats = &tx_info->adap->ch_ktls_stats.ktls_port[tx_info->port_id];
@@ -581,7 +581,7 @@ static int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk,cxgb4_remove_tid (&tx_info->adap->tids, tx_info->tx_chan, tx_info->tid, tx_info->ip_family); -xa_erase (&u_ctx->tid_list, tx_info->tid); +xa_erase_bh (&u_ctx->tid_list, tx_info->tid); put_module:/* release module refcount */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/571 nvmet: use the local P2P device on metadata allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit 4aa9c0f377a4de5e8fddce76b34ee4529639a1ff ]
nvmet_req_alloc_p2pmem_sgls() assigns req->p2p_dev only after the data and metadata SGL allocations succeed. If the data allocation succeeds but the metadata allocation fails, out_free_sg passes req->p2p_dev to pci_p2pmem_free_sgl() before that assignment has taken place.
Pass the local p2p_dev argument instead, so cleanup uses the same PCI device as the successful data allocation.
--- drivers/nvme/target/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/core.c +1 -1
@@ -1041,7 +1041,7 @@ static int nvmet_req_alloc_p2pmem_sgls(struct pci_dev *p2p_dev,return 0 ; out_free_sg: -pci_p2pmem_free_sgl (req->p2p_dev, req->sg); +pci_p2pmem_free_sgl (p2p_dev, req->sg); out_err:return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/571 ASoC: adau1372: allow sleepy powerdown GPIOs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alvin Šipraga <[email protected]>
[ Upstream commit 64dd172bbffe6135d79a06ddad53dd2da4d8bd62 ]
gpiod_set_value() emits a WARN when the GPIO provider indicates that it can sleep, as is typical for I2C controlled GPIO expanders. Since the powerdown GPIO is only manipulated in process context, use the _cansleep variant instead. This lets the driver use sleepy GPIOs to power off the chip.
--- sound/soc/codecs/adau1372.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/codecs/adau1372.c +3 -4
@@ -798,7 +798,7 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)if (ret)return ret;if (adau1372->pd_gpio) -gpiod_set_value (adau1372->pd_gpio,0 ); +gpiod_set_value_cansleep (adau1372->pd_gpio,0 );if (adau1372->switch_mode) adau1372->switch_mode (adau1372->dev);
@@ -818,8 +818,7 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)ADAU1372_CLK_CTRL_PLL_EN , 0);regcache_cache_only (adau1372->regmap, true); -if (adau1372->pd_gpio) -gpiod_set_value (adau1372->pd_gpio,1 ); +gpiod_set_value_cansleep (adau1372->pd_gpio,1 );clk_disable_unprepare (adau1372->mclk);return ret; }
@@ -836,7 +835,7 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)* map. No need to do any register writes to manually * turn things off. */ -gpiod_set_value (adau1372->pd_gpio,1 ); +gpiod_set_value_cansleep (adau1372->pd_gpio,1 );regcache_mark_dirty (adau1372->regmap); }else { regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/571 ASoC: adau1372: fix invalid default state of output ASRC and DAC muxes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alvin Šipraga <[email protected]>
[ Upstream commit 36d0e05815ce84266c8b138cd4f84c3feeaf15f4 ]
The chip has strange power-on reset values for the registers that control the output ASRC and DAC source muxes - the values are actually marked "Reserved" in the datasheet [1]. This means that until the underlying kcontrols are modified, the codec will not function as expected.
The registers in question are:
register / field reset value valid values
ASRCO_SOURCE_0_1 0x10 ASRC_OUT_SOURCE0 0 4 .. 16 ASRC_OUT_SOURCE1 1 4 .. 16 ASRCO_SOURCE_2_3 0x10 ASRC_OUT_SOURCE2 2 4 .. 16 ASRC_OUT_SOURCE3 3 4 .. 16 DAC_SOURCE_0_1 0x10 DAC_SOURCE_0 0 12 .. 13 DAC_SOURCE_1 1 12 .. 13
Set some sane defaults during the driver probe:
ADC Decimator0 -> Output ASRC0
ADC Decimator1 -> Output ASRC1
ADC Decimator2 -> Output ASRC2
ADC Decimator3 -> Output ASRC3
Input ASRC0 -> DAC0
Input ASRC1 -> DAC1
With this, the chip will behave as advertised by the default kcontrol state exposed by the driver.
[1] https://www.analog.com/media/en/technical-documentation/data-sheets/ADAU1372.pdf
--- sound/soc/codecs/adau1372.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/soc/codecs/adau1372.c +11 -0
@@ -999,6 +999,17 @@ int adau1372_probe(struct device *dev, struct regmap *regmap,regmap_write (regmap,ADAU1372_REG_OP_STAGE_MUTE ,0x0 ); +/* +* Set sane default values for the Output ASRC and DAC input muxes, +* since the power-on reset defaults are invalid "Reserved" states. +*/ +regmap_write (regmap,ADAU1372_REG_ASRCO_SOURCE_0_1 , +0x54 );/* Decimator0, Decimator1 */ +regmap_write (regmap,ADAU1372_REG_ASRCO_SOURCE_2_3 , +0x76 );/* Decimator2, Decimator3 */ +regmap_write (regmap,ADAU1372_REG_DAC_SOURCE , +0xdc );/* Input ASRC0, Input ASRC1 */ +regmap_write (regmap,0x7 ,0x01 );/* CLOCK OUT */ return devm_snd_soc_register_component (dev, &adau1372_driver, &adau1372_dai_driver,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/571 ASoC: samsung: i2s: enable op_clk in probe to balance runtime PM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 7529254014764ae0b8c33d5c61a58f36c65b1a1c ]
The probe function puts the device into the runtime PM active state with only the "iis" bus clock enabled, but it also sets priv->op_clk to the parent of the RCLK_SRC mux without enabling it. The runtime PM suspend callback disables both clocks, so the first runtime suspend after probe disables op_clk once more than it was enabled.
On Exynos5250 Arndale both clocks resolve to the same EXYNOS_I2S_BUS gate, so this triggers the following warning during boot:
WARNING: drivers/clk/clk.c:1270 at clk_core_disable+0xe4/0x23c, CPU#0: kworker/u8:3/45 i2s_bus already disabled ... Workqueue: pm pm_runtime_work Call trace: ... clk_core_disable from clk_disable+0x28/0x34 clk_disable from i2s_runtime_suspend+0x58/0x68 [snd_soc_i2s] i2s_runtime_suspend [snd_soc_i2s] from genpd_runtime_suspend+0xc4/0x298 genpd_runtime_suspend from __rpm_callback+0x48/0x18c __rpm_callback from rpm_callback+0x4c/0x50 rpm_callback from rpm_suspend+0xf4/0x718 rpm_suspend from pm_runtime_work+0x9c/0xa0 ...
Fix this by enabling op_clk in probe right after getting it, so the clock state matches the runtime PM active state, and by disabling it in remove.
--- sound/soc/samsung/i2s.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/samsung/i2s.c +8 -0
@@ -1525,9 +1525,16 @@ static int samsung_i2s_probe(struct platform_device *pdev) goto err_disable_pm; priv->op_clk =clk_get_parent (priv->clk_table[CLK_I2S_RCLK_SRC ]); + ret =clk_prepare_enable (priv->op_clk); +if (ret <0 ) { + priv->op_clk =NULL ; + goto err_unregister_clk; + }return 0 ; +err_unregister_clk: +i2s_unregister_clock_provider (priv); err_disable_pm:pm_runtime_disable (&pdev->dev); err_del_sec:
@@ -1550,6 +1557,7 @@ static int samsung_i2s_remove(struct platform_device *pdev)i2s_unregister_clock_provider (priv);i2s_delete_secondary_device (priv); +clk_disable_unprepare (priv->op_clk);clk_disable_unprepare (priv->clk);pm_runtime_put_noidle (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/571 flow_dissector: avoid u16 truncation of skb->len when computing thoff
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 99bda1ecbd56905f8bd934b9cdccd3bd251192b1 ]
__skb_flow_dissect() computes key_control->thoff using:
key_control->thoff = min_t(u16, nhoff, skb ? skb->len : hlen);
min_t(u16, ...) casts both arguments to u16 before comparing them. Whenever skb->len (or hlen) modulo 65536 is smaller than nhoff, the truncated length wins and thoff is set to a bogus small value, even when the dissection succeeded. For example, an IPv4/TCP frame with skb->len == 65540 and nhoff == 34 gets thoff == 4, so callers such as skb_probe_transport_header() point the transport header inside the Ethernet header.
Such skbs are not exotic:
- At the time of commit d0c081b49137 ("flow_dissector: properly cap thoff field"), AF_PACKET with PACKET_VNET_HDR could already build GSO skbs larger than 64KB (MTU checks are skipped for GSO, and alloc_skb_with_frags() accepted up to MAX_SKB_FRAGS (17) order-0 pages on top of the linear part).
- BIG TCP now makes skbs larger than 64KB common.
- The following patch makes tun_get_user() dissect IFF_TAP frames before eth_type_trans() pulls the Ethernet header, so a GSO frame carrying a 65522..65535 byte L3 packet will be dissected with skb->len in [65536, 65549].
Compare as u32 instead. If the resulting offset cannot be represented in the u16 key_control->thoff, cap it to U16_MAX and report the dissection as failed rather than silently returning a wrong transport offset. thoff is still set on failure, as some callers (such as eth_get_headlen()) use it regardless of the return value.
--- net/core/flow_dissector.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/core/flow_dissector.c +8 -1
@@ -943,6 +943,7 @@ bool __skb_flow_dissect(const struct net *net,int mpls_lse =0 ;int num_hdrs =0 ;u8 ip_proto =0 ; +u32 thoff;bool ret;if (!data) {
@@ -1500,7 +1501,13 @@ bool __skb_flow_dissect(const struct net *net, ret = true; out: - key_control->thoff =min_t (u16, nhoff, skb ? skb->len : hlen); + thoff =min_t (u32, nhoff, skb ? skb->len : hlen); +if (unlikely (thoff >U16_MAX )) { +/* Cannot be represented in key_control->thoff. */ + thoff =U16_MAX ; + ret = false; + } + key_control->thoff = thoff; key_basic->n_proto = proto; key_basic->ip_proto = ip_proto;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/571 flow_dissector: avoid u16 truncation of hlen in bpf_flow_dissect()
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 f202578efc738b883cfa04889eb97328914265a7 ]
bpf_flow_dissect() sanitizes the offsets returned by the BPF program with clamp_t(u16, ..., hlen).
If hlen is bigger than 65535, the upper bound is truncated before the comparison. For instance, with hlen == 65536, both nhoff and thoff are forced to zero, even if the program returned sane values.
This is the same class of bug as the one fixed in commit 99bda1ecbd56 ("flow_dissector: avoid u16 truncation of skb->len when computing thoff"). That fix does not cover the BPF path, because __skb_flow_dissect() returns early when a BPF flow dissector handles the packet.
struct bpf_flow_keys stores nhoff and thoff as u16, so cap hlen to U16_MAX before clamping.
Found by sashiko while reviewing the commit above.
--- net/core/flow_dissector.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/flow_dissector.c +2 -0
@@ -895,6 +895,8 @@ bool bpf_flow_dissect(struct bpf_prog *prog, struct bpf_flow_dissector *ctx, result =bpf_prog_run_pin_on_cpu (prog, ctx); +/* bpf_flow_keys offsets are u16: do not let @hlen be truncated. */ + hlen =min_t (int, hlen,U16_MAX ); flow_keys->nhoff =clamp_t (u16, flow_keys->nhoff, nhoff, hlen); flow_keys->thoff =clamp_t (u16, flow_keys->thoff, flow_keys->nhoff, hlen);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/571 net/mlx5e: Order ICOSQ cc update after CQ doorbell
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit b056ca4d3742d0769f91137bb1ce3215428398f7 ]
mlx5e_poll_ico_cq() requires sq->cc to be updated only after mlx5_cqwq_update_db_record(), otherwise a CQ overrun may occur.
The current implementation updates sq->cc before the CQ doorbell record, violating this ordering requirement.
Update the CQ doorbell record first and use dma_wmb() before updating sq->cc. This ensures that the CQ space is released to the device before the corresponding ICOSQ consumer index is updated by software.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +4 -2
@@ -704,10 +704,12 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq) }while (!last_wqe); }while ((++i <MLX5E_TX_CQ_POLL_BUDGET ) && (cqe =mlx5_cqwq_get_cqe (&cq->wq))); - sq->cc = sqcc; -mlx5_cqwq_update_db_record (&cq->wq); +/* ensure cq space is freed before enabling more cqes */ +dma_wmb (); + + sq->cc = sqcc;return i; }
Signature · 1 line
2.53.0