5.15.99-rc1 review
Subsystems (10)
Greg Kroah-Hartman
maintainerPATCH 303/567 eeprom: idt_89hpesx: Fix error handling in idt_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit d717a3ab282f51ec45142f911f7ef8a55c057de5 ]
A problem about idt_89hpesx create debugfs failed is triggered with the following log given:
[ 4973.269647] debugfs: Directory 'idt_csr' with parent '/' already present!
The reason is that idt_init() returns i2c_add_driver() directly without checking its return value, if i2c_add_driver() failed, it returns without destroy the newly created debugfs, resulting the debugfs of idt_csr can never be created later.
idt_init()
debugfs_create_dir() # create debugfs directory i2c_add_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when i2c_add_driver() returns error.
--- drivers/misc/eeprom/idt_89hpesx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/misc/eeprom/idt_89hpesx.c +9 -1
@@ -1568,12 +1568,20 @@ static struct i2c_driver idt_driver = {*/ static int __init idt_init (void ) { +int ret; +/* Create Debugfs directory first */ if (debugfs_initialized ()) csr_dbgdir =debugfs_create_dir ("idt_csr" ,NULL );/* Add new i2c-device driver */ -return i2c_add_driver (&idt_driver); + ret =i2c_add_driver (&idt_driver); +if (ret) { +debugfs_remove_recursive (csr_dbgdir); +return ret; + } + +return 0 ; }module_init (idt_init);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 304/567 applicom: Fix PCI device refcount leak in applicom_init()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit ce4273d89c52167d6fe20572136c58117eae0657 ]
As comment of pci_get_class() says, it returns a pci_device with its refcount increased and decreased the refcount for the input parameter @from if it is not NULL.
If we break the loop in applicom_init() with 'dev' not NULL, we need to call pci_dev_put() to decrease the refcount. Add the missing pci_dev_put() to avoid refcount leak.
--- drivers/char/applicom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/char/applicom.c +4 -1
@@ -197,8 +197,10 @@ static int __init applicom_init(void)if (!pci_match_id (applicom_pci_tbl, dev))continue ; -if (pci_enable_device (dev)) +if (pci_enable_device (dev)) { +pci_dev_put (dev);return -EIO ; + } RamIO =ioremap (pci_resource_start (dev,0 ),LEN_RAM_IO );
@@ -207,6 +209,7 @@ static int __init applicom_init(void)"space at 0x%llx\n" , (unsigned long long)pci_resource_start(dev, 0));pci_disable_device (dev); +pci_dev_put (dev);return -EIO ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 305/567 firmware: stratix10-svc: add missing gen_pool_destroy() in stratix10_svc_drv_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 9175ee1a99d57ec07d66ff572e1d5a724477ab37 ]
In error path in stratix10_svc_drv_probe(), gen_pool_destroy() should be called to destroy the memory pool that created by svc_create_memory_pool().
--- drivers/firmware/stratix10-svc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/firmware/stratix10-svc.c +11 -5
@@ -994,13 +994,17 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)/* allocate service controller and supporting channel */ controller =devm_kzalloc (dev,sizeof (*controller),GFP_KERNEL ); -if (!controller) -return -ENOMEM ; +if (!controller) { + ret = -ENOMEM ; + goto err_destroy_pool; + } chans =devm_kmalloc_array (dev,SVC_NUM_CHANNEL ,sizeof (*chans),GFP_KERNEL | __GFP_ZERO); -if (!chans) -return -ENOMEM ; +if (!chans) { + ret = -ENOMEM ; + goto err_destroy_pool; + } controller->dev = dev; controller->num_chans =SVC_NUM_CHANNEL ;
@@ -1015,7 +1019,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) ret =kfifo_alloc (&controller->svc_fifo, fifo_size,GFP_KERNEL );if (ret) {dev_err (dev,"failed to allocate FIFO\n" ); -return ret; + goto err_destroy_pool; }spin_lock_init (&controller->svc_fifo_lock);
@@ -1060,6 +1064,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)platform_device_put (svc->stratix10_svc_rsu); err_free_kfifo:kfifo_free (&controller->svc_fifo); +err_destroy_pool: +gen_pool_destroy (genpool);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 306/567 VMCI: check context->notify_page after call to get_user_pages_fast() to avoid GPF
In reply to Greg Kroah-HartmanFrom: George Kennedy <[email protected]>
[ Upstream commit 1a726cb47fd204109c767409fa9ca15a96328f14 ]
The call to get_user_pages_fast() in vmci_host_setup_notify() can return NULL context->notify_page causing a GPF. To avoid GPF check if context->notify_page == NULL and return error if so.
general protection fault, probably for non-canonical address
0xe0009d1000000060: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: maybe wild-memory-access in range [0x0005088000000300-
0x0005088000000307]
CPU: 2 PID: 26180 Comm: repro_34802241 Not tainted 6.1.0-rc4 #1
Hardware name: Red Hat KVM, BIOS 1.15.0-2.module+el8.6.0 04/01/2014
RIP: 0010:vmci_ctx_check_signal_notify+0x91/0xe0
Call Trace:
<TASK>
vmci_host_unlocked_ioctl+0x362/0x1f40
__x64_sys_ioctl+0x1a1/0x230
do_syscall_64+0x3a/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd--- drivers/misc/vmw_vmci/vmci_host.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/vmw_vmci/vmci_host.c +2 -0
@@ -242,6 +242,8 @@ static int vmci_host_setup_notify(struct vmci_ctx *context, context->notify_page =NULL ;return VMCI_ERROR_GENERIC ; } +if (context->notify_page ==NULL ) +return VMCI_ERROR_UNAVAILABLE ;/* * Map the locked page and set up notify pointer.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 307/567 misc/mei/hdcp: Use correct macros to initialize uuid_le
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 512ba04d8211dd1a54dd36adc3ecc527a28069c5 ]
GUID_INIT() is for internal guid_t type and shouldn't be used for the uuid_le. I.o.w. relying on the implementation details is layering violation. Use correct macros to initialize uuid_le.
--- drivers/misc/mei/hdcp/mei_hdcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mei/hdcp/mei_hdcp.c +2 -2
@@ -859,8 +859,8 @@ static void mei_hdcp_remove(struct mei_cl_device *cldev)dev_warn (&cldev->dev,"mei_cldev_disable() failed\n" ); } -#define MEI_UUID_HDCP GUID_INIT(0xB638AB7E, 0x94E2, 0x4EA2, 0xA5, \ - 0x52, 0xD1, 0xC5, 0x4B, 0x62, 0x7F, 0x04) +#define MEI_UUID_HDCP UUID_LE(0xB638AB7E, 0x94E2, 0x4EA2, 0xA5, \ + 0x52, 0xD1, 0xC5, 0x4B, 0x62, 0x7F, 0x04)static const struct mei_cl_device_id mei_hdcp_tbl[] = { { .uuid =MEI_UUID_HDCP , .version =MEI_CL_VERSION_ANY },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 308/567 driver core: fix resource leak in device_add()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 6977b1a5d67097eaa4d02b0c126c04cc6e8917c0 ]
When calling kobject_add() failed in device_add(), it will call cleanup_glue_dir() to free resource. But in kobject_add(), dev->kobj.parent has been set to NULL. This will cause resource leak.
The process is as follows:device_add()
get_device_parent() class_dir_create_and_add() kobject_add() //kobject_get() ... dev->kobj.parent = kobj; ... kobject_add() //failed, but set dev->kobj.parent = NULL ... glue_dir = get_glue_dir(dev) //glue_dir = NULL, and goto //"Error" label ... cleanup_glue_dir() //becaues glue_dir is NULL, not call //kobject_put()
The preceding problem may cause insmod mac80211_hwsim.ko to failed.
sysfs: cannot create duplicate filename '/devices/virtual/mac80211_hwsim'
Call Trace: <TASK> dump_stack_lvl+0x8e/0xd1 sysfs_warn_dup.cold+0x1c/0x29 sysfs_create_dir_ns+0x224/0x280 kobject_add_internal+0x2aa/0x880 kobject_add+0x135/0x1a0 get_device_parent+0x3d7/0x590 device_add+0x2aa/0x1cb0 device_create_groups_vargs+0x1eb/0x260 device_create+0xdc/0x110 mac80211_hwsim_new_radio+0x31e/0x4790 [mac80211_hwsim] init_mac80211_hwsim+0x48d/0x1000 [mac80211_hwsim] do_one_initcall+0x10f/0x630 do_init_module+0x19f/0x5e0 load_module+0x64b7/0x6eb0 __do_sys_finit_module+0x140/0x200 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 </TASK>
kobject_add_internal failed for mac80211_hwsim with -EEXIST, don't try to register things with the same name in the same directory.
--- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/core.c +1 -1
@@ -3328,7 +3328,7 @@ int device_add(struct device *dev)/* we require the name to be set before, and pass NULL */ error =kobject_add (&dev->kobj, dev->kobj.parent,NULL );if (error) { - glue_dir =get_glue_dir (dev); + glue_dir = kobj; goto Error; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 309/567 drivers: base: transport_class: fix possible memory leak
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit a86367803838b369fe5486ac18771d14723c258c ]
Current some drivers(like iscsi) call transport_register_device() failed, they don't call transport_destroy_device() to release the memory allocated in transport_setup_device(), because they don't know what was done, it should be internal thing to release the resource in register function. So fix this leak by calling destroy function inside register function.
--- include/linux/transport_class.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/transport_class.h +7 -1
@@ -70,8 +70,14 @@ void transport_destroy_device(struct device *);static inline int transport_register_device (struct device *dev) { +int ret; +transport_setup_device (dev); -return transport_add_device (dev); + ret =transport_add_device (dev); +if (ret) +transport_destroy_device (dev); + +return ret; } static inline void
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 310/567 drivers: base: transport_class: fix resource leak when transport_add_device() fails
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e5da06b27ff5a148e42265c8e306670a9d913969 ]
The normal call sequence of using transport class is:
Add path:transport_setup_device()
transport_setup_classdev() // call sas_host_setup() heretransport_add_device() // if fails, need call transport_destroy_device()transport_configure_device()
Remove path:transport_remove_device()
transport_remove_classdev // call sas_host_remove() heretransport_destroy_device()
If transport_add_device() fails, need call transport_destroy_device() to free memory, but in this case, ->remove() is not called, and the resources allocated in ->setup() are leaked. So fix these leaks by calling ->remove() in transport_add_class_device() if it returns error.
--- drivers/base/transport_class.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/base/transport_class.c +16 -1
@@ -155,12 +155,27 @@ static int transport_add_class_device(struct attribute_container *cont,struct device *dev, struct device *classdev) { + struct transport_class *tclass = class_to_transport_class(cont->class);int error =attribute_container_add_class_device (classdev);struct transport_container *tcont =attribute_container_to_transport_container (cont); -if (!error && tcont->statistics) +if (error) + goto err_remove; + +if (tcont->statistics) { error =sysfs_create_group (&classdev->kobj, tcont->statistics); +if (error) + goto err_del; + } + +return 0 ; + +err_del: +attribute_container_class_device_del (classdev); +err_remove: +if (tclass->remove) + tclass->remove (tcont, dev, classdev);return error; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 311/567 firmware: dmi-sysfs: Fix null-ptr-deref in dmi_sysfs_register_handle
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 18e126e97c961f7a93823795c879d7c085fe5098 ]
KASAN reported a null-ptr-deref error:
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 1373 Comm: modprobe Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:dmi_sysfs_entry_release ... Call Trace: <TASK> kobject_put dmi_sysfs_register_handle (drivers/firmware/dmi-sysfs.c:540) dmi_sysfs dmi_decode_table (drivers/firmware/dmi_scan.c:133) dmi_walk (drivers/firmware/dmi_scan.c:1115) dmi_sysfs_init (drivers/firmware/dmi-sysfs.c:149) dmi_sysfs do_one_initcall (init/main.c:1296) ... Kernel panic - not syncing: Fatal exception Kernel Offset: 0x4000000 from 0xffffffff81000000 ---[ end Kernel panic - not syncing: Fatal exception ]---
It is because previous patch added kobject_put() to release the memory which will call dmi_sysfs_entry_release() and list_del().
However, list_add_tail(entry->list) is called after the error block, so the list_head is uninitialized and cannot be deleted.
Move error handling to after list_add_tail to fix this.
--- drivers/firmware/dmi-sysfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/firmware/dmi-sysfs.c +5 -5
@@ -602,16 +602,16 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh, *ret =kobject_init_and_add (&entry->kobj, &dmi_sysfs_entry_ktype,NULL ,"%d-%d" , dh->type, entry->instance); -if (*ret) { -kobject_put (&entry->kobj); -return ; - } -/* Thread on the global list for cleanup */ spin_lock (&entry_list_lock);list_add_tail (&entry->list, &entry_list);spin_unlock (&entry_list_lock); +if (*ret) { +kobject_put (&entry->kobj); +return ; + } +/* Handle specializations by type */ switch (dh->type) {case DMI_ENTRY_SYSTEM_EVENT_LOG :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 312/567 fotg210-udc: Add missing completion handler
In reply to Greg Kroah-HartmanFrom: Fabian Vogt <[email protected]>
[ Upstream commit e55f67391fa986f7357edba0ca59e668d99c3a5f ]
This is used when responding to GET_STATUS requests. Without this, it crashes on completion.
--- drivers/usb/gadget/udc/fotg210-udc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/usb/gadget/udc/fotg210-udc.c +16 -0
@@ -706,6 +706,20 @@ static int fotg210_is_epnstall(struct fotg210_ep *ep)return value &INOUTEPMPSR_STL_EP ?1 :0 ; } +/* For EP0 requests triggered by this driver (currently GET_STATUS response) */ +static void fotg210_ep0_complete (struct usb_ep *_ep,struct usb_request *req) +{ +struct fotg210_ep *ep; +struct fotg210_udc *fotg210; + + ep = container_of(_ep, struct fotg210_ep, ep); + fotg210 = ep->fotg210; + +if (req->status || req->actual != req->length) { +dev_warn (&fotg210->gadget.dev,"EP0 request failed: %d\n" , req->status); + } +} +static void fotg210_get_status (struct fotg210_udc *fotg210,struct usb_ctrlrequest *ctrl) {
@@ -1172,6 +1186,8 @@ static int fotg210_udc_probe(struct platform_device *pdev)if (fotg210->ep0_req ==NULL ) goto err_map; + fotg210->ep0_req->complete = fotg210_ep0_complete; +fotg210_init (fotg210);fotg210_disable_unplug (fotg210);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 313/567 dmaengine: dw-edma: Fix missing src/dst address of interleaved xfers
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 13b6299cf66165a442089fa895a7f70250703584 ]
Interleaved DMA transfer support was added by 85e7518f42c8 ("dmaengine:
dw-edma: Add device_prep_interleave_dma() support"), but depending on the selected channel, either source or destination address are left uninitialized which was obviously wrong.
Initialize the destination address of the eDMA burst descriptors for DEV_TO_MEM interleaved operations and the source address for MEM_TO_DEV operations.
--- drivers/dma/dw-edma/dw-edma-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/dma/dw-edma/dw-edma-core.c +4 -0
@@ -438,6 +438,8 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)* and destination addresses are increased * by the same portion (data length) */ + }else if (xfer->type ==EDMA_XFER_INTERLEAVED ) { + burst->dar = dst_addr; } }else { burst->dar = dst_addr;
@@ -453,6 +455,8 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)* and destination addresses are increased * by the same portion (data length) */ + }else if (xfer->type ==EDMA_XFER_INTERLEAVED ) { + burst->sar = src_addr; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 314/567 usb: early: xhci-dbc: Fix a potential out-of-bound memory access
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit a4a97ab3db5c081eb6e7dba91306adefb461e0bd ]
If xdbc_bulk_write() fails, the values in 'buf' can be anything. So the string is not guaranteed to be NULL terminated when xdbc_trace() is called.
Reserve an extra byte, which will be zeroed automatically because 'buf' is a static variable, in order to avoid troubles, should it happen.
--- drivers/usb/early/xhci-dbc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/early/xhci-dbc.c +2 -1
@@ -871,7 +871,8 @@ static int xdbc_bulk_write(const char *bytes, int size)static void early_xdbc_write (struct console *con,const char *str,u32 n) { -static char buf[XDBC_MAX_PACKET ]; +/* static variables are zeroed, so buf is always NULL terminated */ +static char buf[XDBC_MAX_PACKET +1 ];int chunk, ret;int use_cr =0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 315/567 tty: serial: fsl_lpuart: Fix the wrong RXWATER setting for rx dma case
In reply to Greg Kroah-HartmanFrom: Sherry Sun <[email protected]>
[ Upstream commit 9ad9df8447547febe9dd09b040f4528a09e495f0 ]
The RXWATER value must be greater than 0 according to the LPUART reference manual. And when the number of datawords in the receive FIFO is greater than RXWATER, an interrupt or a DMA request is generated, so no need to set the different value for lpuart interrupt case and dma case. Here delete the wrong RXWATER setting for dma case directly.
--- drivers/tty/serial/fsl_lpuart.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/tty/serial/fsl_lpuart.c +0 -6
@@ -1700,12 +1700,6 @@ static void lpuart32_configure(struct lpuart_port *sport) {unsigned long temp; -if (sport->lpuart_dma_rx_use) { -/* RXWATER must be 0 */ - temp =lpuart32_read (&sport->port,UARTWATER ); - temp &= ~(UARTWATER_WATER_MASK <<UARTWATER_RXWATER_OFF ); -lpuart32_write (&sport->port, temp,UARTWATER ); - } temp =lpuart32_read (&sport->port,UARTCTRL );if (!sport->lpuart_dma_rx_use) temp |=UARTCTRL_RIE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 316/567 RDMA/cxgb4: add null-ptr-check after ip_dev_find()
In reply to Greg Kroah-HartmanFrom: Nikita Zhandarovich <[email protected]>
[ Upstream commit ef42520240aacfc0d46c8d780c051d135a8dc9b7 ]
ip_dev_find() may return NULL and assign it to pdev which is dereferenced later.
Fix this by checking the return value of ip_dev_find() for NULL similar to the way it is done with other instances of said function.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/hw/cxgb4/cm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/hw/cxgb4/cm.c +4 -0
@@ -4150,6 +4150,10 @@ static int rx_pkt(struct c4iw_dev *dev, struct sk_buff *skb)if (neigh->dev->flags &IFF_LOOPBACK ) { pdev =ip_dev_find (&init_net, iph->daddr); +if (!pdev) { +pr_err ("%s - failed to find device!\n" , __func__); + goto free_dst; + } e =cxgb4_l2t_get (dev->rdev.lldi.l2t, neigh, pdev,0 ); pi = (struct port_info *)netdev_priv (pdev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 317/567 usb: musb: mediatek: dont unregister something that wasnt registered
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit ba883de971d1ad018f3083d9195b8abe54d87407 ]
This function only calls mtk_otg_switch_init() when the ->port_mode is MUSB_OTG so the clean up code should only call mtk_otg_switch_exit() for that mode.
--- drivers/usb/musb/mediatek.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/musb/mediatek.c +2 -1
@@ -346,7 +346,8 @@ static int mtk_musb_init(struct musb *musb) err_phy_power_on:phy_exit (glue->phy); err_phy_init: -mtk_otg_switch_exit (glue); +if (musb->port_mode ==MUSB_OTG ) +mtk_otg_switch_exit (glue);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 318/567 usb: gadget: configfs: use to_config_usb_cfg() in os_desc_link()
In reply to Greg Kroah-HartmanFrom: Linyu Yuan <[email protected]>
[ Upstream commit 5d143ec451429891385a21617b292f2ceaa684ea ]
replace open-coded container_of() with to_config_usb_cfg() helper.
Stable-dep-of: 89e7252d6c7e ("usb: gadget: configfs: Restrict symlink creation is UDC already binded")
--- drivers/usb/gadget/configfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/configfs.c +1 -3
@@ -890,9 +890,7 @@ static int os_desc_link(struct config_item *os_desc_ci,struct gadget_info *gi =container_of (to_config_group (os_desc_ci), struct gadget_info, os_desc_group);struct usb_composite_dev *cdev = &gi->cdev; -struct config_usb_cfg *c_target = -container_of (to_config_group (usb_cfg_ci), - struct config_usb_cfg, group); +struct config_usb_cfg *c_target =to_config_usb_cfg (usb_cfg_ci);struct usb_configuration *c;int ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 319/567 usb: gadget: configfs: use to_usb_function_instance() in cfg (un)link func
In reply to Greg Kroah-HartmanFrom: Linyu Yuan <[email protected]>
[ Upstream commit 5284acccc4a501f38dbeceabaa0340401c107654 ]
replace open-coded container_of() with to_usb_function_instance() helper.
Stable-dep-of: 89e7252d6c7e ("usb: gadget: configfs: Restrict symlink creation is UDC already binded")
--- drivers/usb/gadget/configfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/usb/gadget/configfs.c +4 -6
@@ -416,9 +416,8 @@ static int config_usb_cfg_link(struct usb_composite_dev *cdev = cfg->c.cdev; struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev); -struct config_group *group =to_config_group (usb_func_ci); -struct usb_function_instance *fi =container_of (group, - struct usb_function_instance, group); +struct usb_function_instance *fi = +to_usb_function_instance (usb_func_ci);struct usb_function_instance *a_fi;struct usb_function *f;int ret;
@@ -467,9 +466,8 @@ static void config_usb_cfg_unlink(struct usb_composite_dev *cdev = cfg->c.cdev; struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev); -struct config_group *group =to_config_group (usb_func_ci); -struct usb_function_instance *fi =container_of (group, - struct usb_function_instance, group); +struct usb_function_instance *fi = +to_usb_function_instance (usb_func_ci);struct usb_function *f;/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 320/567 usb: gadget: configfs: remove using list iterator after loop body as a ptr
In reply to Greg Kroah-HartmanFrom: Jakob Koschel <[email protected]>
[ Upstream commit 36f4c25ce32ed8a2e6304ebee6246b7f0b3b9a6f ]
If the list does not contain the expected element, the value of list_for_each_entry() iterator will not point to a valid structure. To avoid type confusion in such case, the list iterator scope will be limited to list_for_each_entry() loop.
In preparation to limiting scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Determining if an element was found is then simply checking if the pointer is != NULL instead of using the potentially bogus pointer.
Stable-dep-of: 89e7252d6c7e ("usb: gadget: configfs: Restrict symlink creation is UDC already binded")
--- drivers/usb/gadget/configfs.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/usb/gadget/configfs.c +14 -10
@@ -418,7 +418,7 @@ static int config_usb_cfg_link(struct usb_function_instance *fi =to_usb_function_instance (usb_func_ci); -struct usb_function_instance *a_fi; +struct usb_function_instance *a_fi =NULL , *iter;struct usb_function *f;int ret;
@@ -428,11 +428,13 @@ static int config_usb_cfg_link(* from another gadget or a random directory. * Also a function instance can only be linked once. */ -list_for_each_entry (a_fi, &gi->available_func, cfs_list) { -if (a_fi == fi) -break ; +list_for_each_entry (iter, &gi->available_func, cfs_list) { +if (iter != fi) +continue ; + a_fi = iter; +break ; } -if (a_fi != fi) { +if (!a_fi) { ret = -EINVAL ; goto out; }
@@ -889,15 +891,17 @@ static int os_desc_link(struct config_item *os_desc_ci, struct gadget_info, os_desc_group);struct usb_composite_dev *cdev = &gi->cdev;struct config_usb_cfg *c_target =to_config_usb_cfg (usb_cfg_ci); -struct usb_configuration *c; +struct usb_configuration *c =NULL , *iter;int ret;mutex_lock (&gi->lock); -list_for_each_entry (c, &cdev->configs, list) { -if (c == &c_target->c) -break ; +list_for_each_entry (iter, &cdev->configs, list) { +if (iter != &c_target->c) +continue ; + c = iter; +break ; } -if (c != &c_target->c) { +if (!c) { ret = -EINVAL ; goto out; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 321/567 usb: gadget: configfs: Restrict symlink creation is UDC already binded
In reply to Greg Kroah-HartmanFrom: Udipto Goswami <[email protected]>
[ Upstream commit 89e7252d6c7e7eeb31971cd7df987316ecc64ff5 ]
During enumeration or composition switch,a userspace process agnostic of the conventions of configs can try to create function symlinks even after the UDC is bound to current config which is not correct. Potentially it can create duplicates within the current config.
Prevent this by adding a check if udc_name already exists, then bail out of cfg_link.
Following is an example:
Step1:
ln -s X1 ffs.a
-->cfg_link
--> usb_get_function(ffs.a)
->ffs_alloc CFG->FUNC_LIST: <ffs.a> C->FUNCTION: <empty>
Step2:
echo udc.name > /config/usb_gadget/g1/UDC
--> UDC_store
->composite_bind ->usb_add_function CFG->FUNC_LIST: <empty> C->FUNCTION: <ffs.a>
Step3:
ln -s Y1 ffs.a
-->cfg_link
-->usb_get_function(ffs.a)
->ffs_alloc CFG->FUNC_LIST: <ffs.a> C->FUNCTION: <ffs.a>
both the lists corresponds to the same function instance ffs.a but the usb_function* pointer is different because in step 3 ffs_alloc has created a new reference to usb_function* for ffs.a and added it to cfg_list.
Step4:
Now a composition switch involving <ffs.b,ffs.a> is executed.
the composition switch will involve 3 things:
1. unlinking the previous functions existing
2. creating new symlinks
3. writing UDC
However, the composition switch is generally taken care by userspace process which creates the symlinks in its own nomenclature(X*) and removes only those.
So it won't be able to remove Y1 which user had created by own.
Due to this the new symlinks cannot be created for ffs.a since the entry already exists in CFG->FUNC_LIST.
The state of the CFG->FUNC_LIST is as follows:
CFG->FUNC_LIST: <ffs.a>
--- drivers/usb/gadget/configfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/gadget/configfs.c +6 -0
@@ -428,6 +428,12 @@ static int config_usb_cfg_link(* from another gadget or a random directory. * Also a function instance can only be linked once. */ + +if (gi->composite.gadget_driver.udc_name) { + ret = -EINVAL ; + goto out; + } +list_for_each_entry (iter, &gi->available_func, cfs_list) {if (iter != fi)continue ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 322/567 iommu/vt-d: Set No Execute Enable bit in PASID table entry
In reply to Greg Kroah-HartmanFrom: Lu Baolu <[email protected]>
[ Upstream commit e06d24435596c8afcaa81c0c498f5b0ec4ee2b7c ]
Setup No Execute Enable bit (Bit 133) of a scalable mode PASID entry. This is to allow the use of XD bit of the first level page table.
--- drivers/iommu/intel/pasid.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/iommu/intel/pasid.c +11 -0
@@ -425,6 +425,16 @@ static inline void pasid_set_page_snoop(struct pasid_entry *pe, bool value)pasid_set_bits (&pe->val[1 ],1 <<23 , value <<23 ); } +/* +* Setup No Execute Enable bit (Bit 133) of a scalable mode PASID +* entry. It is required when XD bit of the first level page table +* entry is about to be set. +*/ +static inline void pasid_set_nxe (struct pasid_entry *pe) +{ +pasid_set_bits (&pe->val[2 ],1 <<5 ,1 <<5 ); +} +/* * Setup the Page Snoop (PGSNP) field (Bit 88) of a scalable mode * PASID entry.
@@ -631,6 +641,7 @@ int intel_pasid_setup_first_level(struct intel_iommu *iommu,pasid_set_domain_id (pte, did);pasid_set_address_width (pte, iommu->agaw);pasid_set_page_snoop (pte, !!ecap_smpwc (iommu->ecap)); +pasid_set_nxe (pte);/* Setup Present and PASID Granular Transfer Type: */ pasid_set_translation_type (pte,PASID_ENTRY_PGTT_FL_ONLY );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 323/567 power: supply: remove faulty cooling logic
In reply to Greg Kroah-HartmanFrom: Andreas Kemnade <[email protected]>
[ Upstream commit c85c191694cb1cf290b11059b3d2de8a2732ffd0 ]
The rn5t618 power driver fails to register
a cooling device because POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX is missing but availability is not checked before registering cooling device. After improved error checking in the thermal code, the registration of the power supply fails entirely.
Checking for availability of _MAX before registering cooling device fixes the rn5t618 problem. But the whole logic feels questionable.
First, the logic is inverted here:
the code tells: max_current = max_cooling but
0 = max_cooling, so there needs to be some inversion
in the code which cannot be found. Comparing with other cooling devices, it can be found that value for fan speed is not inverted, value for cpufreq cooling is inverted (similar situation as here lowest frequency = max cooling)
Second, analyzing usage of _MAX: it is seems that maximum capabilities of charging controller are specified and not of the battery. Probably there is not too much mismatch in the drivers actually implementing that. So nothing has exploded yet. So there is no easy and safe way to specifify a max cooling value now.
Conclusion for now (as a regression fix) just remove the cooling device registration and do it properly later on.
--- drivers/power/supply/power_supply_core.c | 97 ------------------------ 1 file changed, 97 deletions(-)
drivers/power/supply/power_supply_core.c +0 -97
@@ -1014,87 +1014,6 @@ static void psy_unregister_thermal(struct power_supply *psy) thermal_zone_device_unregister(psy->tzd); } -/* thermal cooling device callbacks */ -static int ps_get_max_charge_cntl_limit (struct thermal_cooling_device *tcd, -unsigned long *state) -{ -struct power_supply *psy; -union power_supply_propval val; -int ret; - - psy = tcd->devdata; - ret =power_supply_get_property (psy, -POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX , &val); -if (ret) -return ret; - - *state = val.intval; - -return ret; -} - -static int ps_get_cur_charge_cntl_limit (struct thermal_cooling_device *tcd, -unsigned long *state) -{ -struct power_supply *psy; -union power_supply_propval val; -int ret; - - psy = tcd->devdata; - ret =power_supply_get_property (psy, -POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT , &val); -if (ret) -return ret; - - *state = val.intval; - -return ret; -} - -static int ps_set_cur_charge_cntl_limit (struct thermal_cooling_device *tcd, -unsigned long state) -{ -struct power_supply *psy; -union power_supply_propval val; -int ret; - - psy = tcd->devdata; - val.intval = state; - ret = psy->desc->set_property (psy, -POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT , &val); - -return ret; -} - -static const struct thermal_cooling_device_ops psy_tcd_ops = { - .get_max_state = ps_get_max_charge_cntl_limit, - .get_cur_state = ps_get_cur_charge_cntl_limit, - .set_cur_state = ps_set_cur_charge_cntl_limit, -}; - -static int psy_register_cooler (struct power_supply *psy) -{ -int i; - -/* Register for cooling device if psy can control charging */ -for (i =0 ; i < psy->desc->num_properties; i++) { -if (psy->desc->properties[i] == -POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT ) { - psy->tcd =thermal_cooling_device_register ( - (char *)psy->desc->name, - psy, &psy_tcd_ops); -return PTR_ERR_OR_ZERO (psy->tcd); - } - } -return 0 ; -} - -static void psy_unregister_cooler (struct power_supply *psy) -{ -if (IS_ERR_OR_NULL (psy->tcd)) -return ; -thermal_cooling_device_unregister (psy->tcd); -}#else static int psy_register_thermal (struct power_supply *psy) {
@@ -1104,15 +1023,6 @@ static int psy_register_thermal(struct power_supply *psy)static void psy_unregister_thermal (struct power_supply *psy) { } - -static int psy_register_cooler (struct power_supply *psy) -{ -return 0 ; -} - -static void psy_unregister_cooler (struct power_supply *psy) -{ -}#endif static struct power_supply *__must_check
@@ -1188,10 +1098,6 @@ __power_supply_register(struct device *parent,if (rc) goto register_thermal_failed; - rc =psy_register_cooler (psy); -if (rc) - goto register_cooler_failed; - rc =power_supply_create_triggers (psy);if (rc) goto create_triggers_failed;
@@ -1221,8 +1127,6 @@ __power_supply_register(struct device *parent, add_hwmon_sysfs_failed:power_supply_remove_triggers (psy); create_triggers_failed: -psy_unregister_cooler (psy); -register_cooler_failed:psy_unregister_thermal (psy); register_thermal_failed: wakeup_init_failed:
@@ -1374,7 +1278,6 @@ void power_supply_unregister(struct power_supply *psy)sysfs_remove_link (&psy->dev.kobj,"powers" );power_supply_remove_hwmon_sysfs (psy);power_supply_remove_triggers (psy); -psy_unregister_cooler (psy);psy_unregister_thermal (psy);device_init_wakeup (&psy->dev, false);device_unregister (&psy->dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 324/567 RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()
In reply to Greg Kroah-HartmanFrom: Nikita Zhandarovich <[email protected]>
[ Upstream commit 283861a4c52c1ea4df3dd1b6fc75a50796ce3524 ]
If get_ep_from_tid() fails to lookup non-NULL value for ep, ep is dereferenced later regardless of whether it is empty. This patch adds a simple sanity check to fix the issue.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/hw/cxgb4/cm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/cxgb4/cm.c +3 -0
@@ -2682,6 +2682,9 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb)u16 tcp_opt =ntohs (req->tcp_opt); ep =get_ep_from_tid (dev, tid); +if (!ep) +return 0 ; +pr_debug ("ep %p tid %u\n" , ep, ep->hwtid); ep->snd_seq =be32_to_cpu (req->snd_isn); ep->rcv_seq =be32_to_cpu (req->rcv_isn);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 325/567 usb: max-3421: Fix setting of I/O pins
In reply to Greg Kroah-HartmanFrom: Mark Tomlinson <[email protected]>
[ Upstream commit a7efe3fc7cbe27c6eb2c2a3ab612194f8f800f4c ]
To update the I/O pins, the registers are read/modified/written. The read operation incorrectly always read the first register. Although wrong, there wasn't any impact as all the output pins are always written, and the inputs are read only anyway.
--- drivers/usb/host/max3421-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/max3421-hcd.c +1 -1
@@ -1436,7 +1436,7 @@ max3421_spi_thread(void *dev_id)* use spi_wr_buf(). */ for (i =0 ; i <ARRAY_SIZE (max3421_hcd->iopins); ++i) { -u8 val =spi_rd8 (hcd,MAX3421_REG_IOPINS1 ); +u8 val =spi_rd8 (hcd,MAX3421_REG_IOPINS1 + i); val = ((val &0xf0 ) | (max3421_hcd->iopins[i] &0x0f ));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 326/567 RDMA/irdma: Cap MSIX used to online CPUs + 1
In reply to Greg Kroah-HartmanFrom: Mustafa Ismail <[email protected]>
[ Upstream commit 9cd9842c46996ef62173c36619c746f57416bcb0 ]
The irdma driver can use a maximum number of msix vectors equal to num_online_cpus() + 1 and the kernel warning stack below is shown if that number is exceeded.
The kernel throws a warning as the driver tries to update the affinity hint with a CPU mask greater than the max CPU IDs. Fix this by capping the MSIX vectors to num_online_cpus() + 1.
WARNING: CPU: 7 PID: 23655 at include/linux/cpumask.h:106 irdma_cfg_ceq_vector+0x34c/0x3f0 [irdma] RIP: 0010:irdma_cfg_ceq_vector+0x34c/0x3f0 [irdma] Call Trace: irdma_rt_init_hw+0xa62/0x1290 [irdma] ? irdma_alloc_local_mac_entry+0x1a0/0x1a0 [irdma] ? __is_kernel_percpu_address+0x63/0x310 ? rcu_read_lock_held_common+0xe/0xb0 ? irdma_lan_unregister_qset+0x280/0x280 [irdma] ? irdma_request_reset+0x80/0x80 [irdma] ? ice_get_qos_params+0x84/0x390 [ice] irdma_probe+0xa40/0xfc0 [irdma] ? rcu_read_lock_bh_held+0xd0/0xd0 ? irdma_remove+0x140/0x140 [irdma] ? rcu_read_lock_sched_held+0x62/0xe0 ? down_write+0x187/0x3d0 ? auxiliary_match_id+0xf0/0x1a0 ? irdma_remove+0x140/0x140 [irdma] auxiliary_bus_probe+0xa6/0x100 __driver_probe_device+0x4a4/0xd50 ? __device_attach_driver+0x2c0/0x2c0 driver_probe_device+0x4a/0x110 __driver_attach+0x1aa/0x350 bus_for_each_dev+0x11d/0x1b0 ? subsys_dev_iter_init+0xe0/0xe0 bus_add_driver+0x3b1/0x610 driver_register+0x18e/0x410 ? 0xffffffffc0b88000 irdma_init_module+0x50/0xaa [irdma] do_one_initcall+0x103/0x5f0 ? perf_trace_initcall_level+0x420/0x420 ? do_init_module+0x4e/0x700 ? __kasan_kmalloc+0x7d/0xa0 ? kmem_cache_alloc_trace+0x188/0x2b0 ? kasan_unpoison+0x21/0x50 do_init_module+0x1d1/0x700 load_module+0x3867/0x5260 ? layout_and_allocate+0x3990/0x3990 ? rcu_read_lock_held_common+0xe/0xb0 ? rcu_read_lock_sched_held+0x62/0xe0 ? rcu_read_lock_bh_held+0xd0/0xd0 ? __vmalloc_node_range+0x46b/0x890 ? lock_release+0x5c8/0xba0 ? alloc_vm_area+0x120/0x120 ? selinux_kernel_module_from_file+0x2a5/0x300 ? __inode_security_revalidate+0xf0/0xf0 ? __do_sys_init_module+0x1db/0x260 __do_sys_init_module+0x1db/0x260 ? load_module+0x5260/0x5260 ? do_syscall_64+0x22/0x450 do_syscall_64+0xa5/0x450 entry_SYSCALL_64_after_hwframe+0x66/0xdb
--- drivers/infiniband/hw/irdma/hw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/irdma/hw.c +2 -0
@@ -483,6 +483,8 @@ static enum irdma_status_code irdma_save_msix_info(struct irdma_pci_f *rf) iw_qvlist->num_vectors = rf->msix_count;if (rf->msix_count <=num_online_cpus ()) rf->msix_shared = true; +else if (rf->msix_count >num_online_cpus () +1 ) + rf->msix_count =num_online_cpus () +1 ; pmsix = rf->msix_entries;for (i =0 , ceq_idx =0 ; i < rf->msix_count; i++, iw_qvinfo++) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 327/567 serial: fsl_lpuart: fix RS485 RTS polariy inverse issue
In reply to Greg Kroah-HartmanFrom: Shenwei Wang <[email protected]>
[ Upstream commit 3957b9501a5a8fa709ae4a47483714491471f6db ]
The previous 'commit 846651eca073 ("serial: fsl_lpuart: RS485 RTS polariy is inverse")' only fixed the inverse issue on lpuart 8bit platforms.
This is a follow-up patch to fix the RS485 polarity inverse issue on lpuart 32bit platforms.
--- drivers/tty/serial/fsl_lpuart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/fsl_lpuart.c +2 -2
@@ -1406,9 +1406,9 @@ static int lpuart32_config_rs485(struct uart_port *port,* Note: UART is assumed to be active high. */ if (rs485->flags &SER_RS485_RTS_ON_SEND ) - modem &= ~UARTMODEM_TXRTSPOL ; -else if (rs485->flags &SER_RS485_RTS_AFTER_SEND ) modem |=UARTMODEM_TXRTSPOL ; +else if (rs485->flags &SER_RS485_RTS_AFTER_SEND ) + modem &= ~UARTMODEM_TXRTSPOL ; }/* Store the new configuration */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 328/567 tty: serial: imx: Handle RS485 DE signal active high
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 79d0224f6bf296d04cd843cfc49921b19c97bb09 ]
The default polarity of RS485 DE signal is active high. This driver does not handle such case properly. Currently, when a pin is multiplexed as a UART CTS_B on boot, this pin is pulled HIGH by the i.MX UART CTS circuit, which activates DE signal on the RS485 transceiver and thus behave as if the RS485 was transmitting data, so the system blocks the RS485 bus when it starts and until user application takes over. This behavior is not OK. The problem consists of two separate parts.
First, the i.MX UART IP requires UCR1 UARTEN and UCR2 RXEN to be set for UCR2 CTSC and CTS bits to have any effect. The UCR2 CTSC bit permits the driver to set CTS (RTS_B or RS485 DE signal) to either level sychronous to the internal UART IP clock. Compared to other options, like GPIO CTS control, this has the benefit of being synchronous to the UART IP clock and thus without glitches or bus delays. The reason for the CTS design is likely because when the Receiver is disabled, the UART IP can never indicate that it is ready to receive data by assering CTS signal, so the CTS is always pulled HIGH by default.
When the port is closed by user space, imx_uart_stop_rx() clears UCR2 RXEN bit, and imx_uart_shutdown() clears UCR1 UARTEN bit. This disables UART Receiver and UART itself, and forces CTS signal HIGH, which leads to the RS485 bus being blocked because RS485 DE is incorrectly active.
The proposed solution for this problem is to keep the Receiver running even after the port is closed, but in loopback mode. This disconnects the RX FIFO input from the RXD external signal, and since UCR2 TXEN is cleared, the UART Transmitter is disabled, so nothing can feed data in the RX FIFO. Because the Receiver is still enabled, the UCR2 CTSC and CTS bits still have effect and the CTS (RS485 DE) control is retained.
Note that in case of RS485 DE signal active low, there is no problem and no special handling is necessary. The CTS signal defaults to HIGH, thus the RS485 is by default set to Receive and the bus is not blocked.
Note that while there is the possibility to control CTS using GPIO with either CTS polarity, this has the downside of not being synchronous to the UART IP clock and thus glitchy and susceptible to slow DE switching.
Second, on boot, before the UART driver probe callback is called, the driver core triggers pinctrl_init_done() and configures the IOMUXC to default state. At this point, UCR1 UARTEN and UCR2 RXEN are both still cleared, but UART CTS_B (RS485 DE) is configured as CTS function, thus the RTS signal is pulled HIGH by the UART IP CTS circuit.
One part of the solution here is to enable UCR1 UARTEN and UCR2 RXEN and UTS loopback in this driver probe callback, thus unblocking the CTSC and CTS control early on. But this is still too late, since the pin control is already configured and CTS has been pulled HIGH for a short period of time.
When Linux kernel boots and this driver is bound, the pin control is set to special "init" state if the state is available, and driver can switch the "default" state afterward when ready. This state can be used to set the CTS line as a GPIO in DT temporarily, and a GPIO hog can force such GPIO to LOW, thus keeping the RS485 DE line LOW early on boot. Once the driver takes over and UCR1 UARTEN and UCR2 RXEN and UTS loopback are all enabled, the driver can switch to "default" pin control state and control the CTS line as function instead. DT binding example is below:
"
&gpio6 {
rts-init-hog {
gpio-hog;
gpios = <5 0>;
output-low;
line-name = "rs485-de"; };
};
&uart5 { /* DHCOM UART2 */
pinctrl-0 = <&pinctrl_uart5>;
pinctrl-1 = <&pinctrl_uart5_init>;
pinctrl-names = "default", "init";
...
};pinctrl_uart5_init: uart5-init-grp {
fsl,pins = <
...
MX6QDL_PAD_CSI0_DAT19__GPIO6_IO05 0x30b1
Quoted 1 line
;
};
pinctrl_uart5: uart5-grp {
fsl,pins = <
...
MX6QDL_PAD_CSI0_DAT19__UART5_CTS_B 0x30b1
Quoted 1 line
;
};
"
Stable-dep-of: ef25e16ea967 ("tty: serial: imx: disable Ageing Timer interrupt request irq")
--- drivers/tty/serial/imx.c | 64 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-)
drivers/tty/serial/imx.c +58 -6
@@ -484,7 +484,7 @@ static void imx_uart_stop_tx(struct uart_port *port)static void imx_uart_stop_rx (struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port; -u32 ucr1, ucr2, ucr4; +u32 ucr1, ucr2, ucr4, uts; ucr1 =imx_uart_readl (sport,UCR1 ); ucr2 =imx_uart_readl (sport,UCR2 );
@@ -500,7 +500,18 @@ static void imx_uart_stop_rx(struct uart_port *port)imx_uart_writel (sport, ucr1,UCR1 );imx_uart_writel (sport, ucr4,UCR4 ); - ucr2 &= ~UCR2_RXEN ; +/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ +if (port->rs485.flags &SER_RS485_ENABLED && + port->rs485.flags &SER_RS485_RTS_ON_SEND && + sport->have_rtscts && !sport->have_rtsgpio) { + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts |=UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); + ucr2 |=UCR2_RXEN ; + }else { + ucr2 &= ~UCR2_RXEN ; + } +imx_uart_writel (sport, ucr2,UCR2 ); }
@@ -1383,7 +1394,7 @@ static int imx_uart_startup(struct uart_port *port)int retval, i;unsigned long flags;int dma_is_inited =0 ; -u32 ucr1, ucr2, ucr3, ucr4; +u32 ucr1, ucr2, ucr3, ucr4, uts; retval =clk_prepare_enable (sport->clk_per);if (retval)
@@ -1488,6 +1499,11 @@ static int imx_uart_startup(struct uart_port *port)imx_uart_writel (sport, ucr2,UCR2 ); } +/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts &= ~UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); +spin_unlock_irqrestore (&sport->port.lock, flags);return 0 ;
@@ -1497,7 +1513,7 @@ static void imx_uart_shutdown(struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port;unsigned long flags; -u32 ucr1, ucr2, ucr4; +u32 ucr1, ucr2, ucr4, uts;if (sport->dma_is_enabled) {dmaengine_terminate_sync (sport->dma_chan_tx);
@@ -1541,7 +1557,18 @@ static void imx_uart_shutdown(struct uart_port *port)spin_lock_irqsave (&sport->port.lock, flags); ucr1 =imx_uart_readl (sport,UCR1 ); - ucr1 &= ~(UCR1_TRDYEN |UCR1_RRDYEN |UCR1_RTSDEN |UCR1_UARTEN |UCR1_RXDMAEN |UCR1_ATDMAEN ); + ucr1 &= ~(UCR1_TRDYEN |UCR1_RRDYEN |UCR1_RTSDEN |UCR1_RXDMAEN |UCR1_ATDMAEN ); +/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ +if (port->rs485.flags &SER_RS485_ENABLED && + port->rs485.flags &SER_RS485_RTS_ON_SEND && + sport->have_rtscts && !sport->have_rtsgpio) { + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts |=UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); + ucr1 |=UCR1_UARTEN ; + }else { + ucr1 &= ~UCR1_UARTEN ; + }imx_uart_writel (sport, ucr1,UCR1 ); ucr4 =imx_uart_readl (sport,UCR4 );
@@ -2189,7 +2216,7 @@ static int imx_uart_probe(struct platform_device *pdev)void __iomem *base;u32 dma_buf_conf[2 ];int ret =0 ; -u32 ucr1; +u32 ucr1, ucr2, uts;struct resource *res;int txirq, rxirq, rtsirq;
@@ -2321,6 +2348,31 @@ static int imx_uart_probe(struct platform_device *pdev) ucr1 &= ~(UCR1_ADEN |UCR1_TRDYEN |UCR1_IDEN |UCR1_RRDYEN |UCR1_RTSDEN );imx_uart_writel (sport, ucr1,UCR1 ); +/* +* In case RS485 is enabled without GPIO RTS control, the UART IP +* is used to control CTS signal. Keep both the UART and Receiver +* enabled, otherwise the UART IP pulls CTS signal always HIGH no +* matter how the UCR2 CTSC and CTS bits are set. To prevent any +* data from being fed into the RX FIFO, enable loopback mode in +* UTS register, which disconnects the RX path from external RXD +* pin and connects it to the Transceiver, which is disabled, so +* no data can be fed to the RX FIFO that way. +*/ +if (sport->port.rs485.flags &SER_RS485_ENABLED && + sport->have_rtscts && !sport->have_rtsgpio) { + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts |=UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); + + ucr1 =imx_uart_readl (sport,UCR1 ); + ucr1 |=UCR1_UARTEN ; +imx_uart_writel (sport, ucr1,UCR1 ); + + ucr2 =imx_uart_readl (sport,UCR2 ); + ucr2 |=UCR2_RXEN ; +imx_uart_writel (sport, ucr2,UCR2 ); + } +if (!imx_uart_is_imx1 (sport) && sport->dte_mode) {/* * The DCEDTE bit changes the direction of DSR, DCD, DTR and RI
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 329/567 tty: serial: imx: disable Ageing Timer interrupt request irq
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
[ Upstream commit ef25e16ea9674b713a68c3bda821556ce9901254 ]
There maybe pending USR interrupt before requesting irq, however uart_add_one_port has not executed, so there will be kernel panic:
[ 0.795668] Unable to handle kernel NULL pointer dereference at virtual addre ss 0000000000000080 [ 0.802701] Mem abort info: [ 0.805367] ESR = 0x0000000096000004 [ 0.808950] EC = 0x25: DABT (current EL), IL = 32 bits [ 0.814033] SET = 0, FnV = 0 [ 0.816950] EA = 0, S1PTW = 0 [ 0.819950] FSC = 0x04: level 0 translation fault [ 0.824617] Data abort info: [ 0.827367] ISV = 0, ISS = 0x00000004 [ 0.831033] CM = 0, WnR = 0 [ 0.833866] [0000000000000080] user address but active_mm is swapper [ 0.839951] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP [ 0.845953] Modules linked in: [ 0.848869] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.1.1+g56321e101aca #1 [ 0.855617] Hardware name: Freescale i.MX8MP EVK (DT) [ 0.860452] pstate: 000000c5 (nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.867117] pc : __imx_uart_rxint.constprop.0+0x11c/0x2c0 [ 0.872283] lr : imx_uart_int+0xf8/0x1ec
The issue only happends in the inmate linux when Jailhouse hypervisor enabled. The test procedure is:
while true; do
jailhouse enable imx8mp.cell
jailhouse cell linux xxxx
sleep 10
jailhouse cell destroy 1
jailhouse disable
sleep 5
done
And during the upper test, press keys to the 2nd linux console. When jailhouse cell destroy 1, the 2nd linux has no chance to put the uart to a quiese state, so USR1/2 may has pending interrupts. Then when jailhosue cell linux xx to start 2nd linux again, the issue trigger.
In order to disable irqs before requesting them, both UCR1 and UCR2 irqs should be disabled, so here fix that, disable the Ageing Timer interrupt in UCR2 as UCR1 does.
--- drivers/tty/serial/imx.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/imx.c +5 -0
@@ -2348,6 +2348,11 @@ static int imx_uart_probe(struct platform_device *pdev) ucr1 &= ~(UCR1_ADEN |UCR1_TRDYEN |UCR1_IDEN |UCR1_RRDYEN |UCR1_RTSDEN );imx_uart_writel (sport, ucr1,UCR1 ); +/* Disable Ageing Timer interrupt */ + ucr2 =imx_uart_readl (sport,UCR2 ); + ucr2 &= ~UCR2_ATEN ; +imx_uart_writel (sport, ucr2,UCR2 ); +/* * In case RS485 is enabled without GPIO RTS control, the UART IP * is used to control CTS signal. Keep both the UART and Receiver
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 330/567 driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit 67cad5c67019c38126b749621665b6723d3ae7e6 ]
fw_devlink uses DL_FLAG_SYNC_STATE_ONLY device link flag for two purposes:
1. To allow a parent device to proxy its child device's dependency on a supplier so that the supplier doesn't get its sync_state() callback before the child device/consumer can be added and probed. In this usage scenario, we need to ignore cycles for ensure correctness of sync_state() callbacks.
2. When there are dependency cycles in firmware, we don't know which of those dependencies are valid. So, we have to ignore them all wrt probe ordering while still making sure the sync_state() callbacks come correctly.
However, when detecting dependency cycles, there can be multiple dependency cycles between two devices that we need to detect. For example:
A -> B -> A and A -> C -> B -> A.
To detect multiple cycles correct, we need to be able to differentiate DL_FLAG_SYNC_STATE_ONLY device links used for (1) vs (2) above.
To allow this differentiation, add a DL_FLAG_CYCLE that can be use to mark use case (2). We can then use the DL_FLAG_CYCLE to decide which DL_FLAG_SYNC_STATE_ONLY device links to follow when looking for dependency cycles.
--- drivers/base/core.c | 28 ++++++++++++++++++---------- include/linux/device.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
drivers/base/core.c +18 -10
@@ -269,6 +269,12 @@ static bool device_is_ancestor(struct device *dev, struct device *target)return false; } +static inline bool device_link_flag_is_sync_state_only (u32 flags) +{ +return (flags & ~(DL_FLAG_INFERRED |DL_FLAG_CYCLE )) == + (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED ); +} +/** * device_is_dependent - Check if one device depends on another one * @dev: Device to check dependencies for.
@@ -295,8 +301,7 @@ int device_is_dependent(struct device *dev, void *target)return ret;list_for_each_entry (link, &dev->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (device_link_flag_is_sync_state_only (link->flags))continue ;if (link->consumer == target)
@@ -369,8 +374,7 @@ static int device_reorder_to_tail(struct device *dev, void *not_used)device_for_each_child (dev,NULL , device_reorder_to_tail);list_for_each_entry (link, &dev->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (device_link_flag_is_sync_state_only (link->flags))continue ;device_reorder_to_tail (link->consumer,NULL ); }
@@ -621,7 +625,8 @@ postcore_initcall(devlink_class_init);DL_FLAG_AUTOREMOVE_SUPPLIER | \DL_FLAG_AUTOPROBE_CONSUMER | \DL_FLAG_SYNC_STATE_ONLY | \ - DL_FLAG_INFERRED) +DL_FLAG_INFERRED | \ + DL_FLAG_CYCLE) #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \DL_FLAG_PM_RUNTIME |DL_FLAG_RPM_ACTIVE )
@@ -690,8 +695,6 @@ struct device_link *device_link_add(struct device *consumer,if (!consumer || !supplier || consumer == supplier || flags & ~DL_ADD_VALID_FLAGS || (flags &DL_FLAG_STATELESS && flags &DL_MANAGED_LINK_FLAGS ) || - (flags &DL_FLAG_SYNC_STATE_ONLY && - (flags & ~DL_FLAG_INFERRED ) !=DL_FLAG_SYNC_STATE_ONLY ) || (flags &DL_FLAG_AUTOPROBE_CONSUMER && flags & (DL_FLAG_AUTOREMOVE_CONSUMER |DL_FLAG_AUTOREMOVE_SUPPLIER )))
@@ -707,6 +710,10 @@ struct device_link *device_link_add(struct device *consumer,if (!(flags &DL_FLAG_STATELESS )) flags |=DL_FLAG_MANAGED ; +if (flags &DL_FLAG_SYNC_STATE_ONLY && + !device_link_flag_is_sync_state_only (flags)) +return NULL ; +device_links_write_lock ();device_pm_lock ();
@@ -1627,7 +1634,7 @@ static void fw_devlink_relax_link(struct device_link *link)if (!(link->flags &DL_FLAG_INFERRED ))return ; -if (link->flags == (DL_FLAG_MANAGED |FW_DEVLINK_FLAGS_PERMISSIVE )) +if (device_link_flag_is_sync_state_only (link->flags))return ;pm_runtime_drop_link (link);
@@ -1695,8 +1702,8 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup)return ret;list_for_each_entry (link, &con->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (!(link->flags &DL_FLAG_CYCLE ) && +device_link_flag_is_sync_state_only (link->flags))continue ;if (!fw_devlink_relax_cycle (link->consumer, sup))
@@ -1705,6 +1712,7 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup) ret =1 ;fw_devlink_relax_link (link); + link->flags |=DL_FLAG_CYCLE ; }return ret; }
include/linux/device.h +1 -0
@@ -326,6 +326,7 @@ enum device_link_state {#define DL_FLAG_MANAGED BIT(6)#define DL_FLAG_SYNC_STATE_ONLY BIT(7)#define DL_FLAG_INFERRED BIT(8) +#define DL_FLAG_CYCLE BIT(9)/** * enum dl_dev_state - Device driver presence tracking information.
Signature · 1 line
2.39.2
Re: [PATCH 5.15 330/567] driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links
Quoted 43 lines · Greg Kroah-Hartman
From: Saravana Kannan <[email protected]>
[ Upstream commit
67cad5c67019c38126b749621665b6723d3ae7e6]
fw_devlinkusesDL_FLAG_SYNC_STATE_ONLYdevice link flag for two purposes:1. To allow a parent device to proxy its child device's dependency on a supplier so that the supplier doesn't get its
sync_state()callback before the child device/consumer can be added and probed. In this usage scenario, we need to ignore cycles for ensure correctness ofsync_state()callbacks.2. When there are dependency cycles in firmware, we don't know which of those dependencies are valid. So, we have to ignore them all wrt probe ordering while still making sure the
sync_state()callbacks come correctly.However, when detecting dependency cycles, there can be multiple dependency cycles between two devices that we need to detect. For example:
A -> B -> A and A -> C -> B -> A.
To detect multiple cycles correct, we need to be able to differentiate
DL_FLAG_SYNC_STATE_ONLYdevice links used for (1) vs (2) above.To allow this differentiation, add a
DL_FLAG_CYCLEthat can be use to mark use case (2). We can then use theDL_FLAG_CYCLEto decide whichDL_FLAG_SYNC_STATE_ONLYdevice links to follow when looking for dependency cycles.Fixes 2de9d8e0d2fe ("driver core: fw_devlink: Improve handling of cyclic dependencies")Signed-off-by Saravana Kannan <[email protected]>Tested-by Colin Foster <[email protected]>Tested-by Sudeep Holla <[email protected]>Tested-by Douglas Anderson <[email protected]>Tested-by Geert Uytterhoeven <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 1 line
---
These fw_devlink patches weren't tested with 5.15. It's also an extensive refactor. So I'm a little worried if it'll be finicky and break things in a kernel that's a year old.
Unless someone specifically wants these patches in 5.15, I'd prefer we don't pick it up in 5.15.
-Saravana
Quoted 116 lines
drivers/base/core.c | 28 ++++++++++++++++++---------- include/linux/device.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)drivers/base/core.c +18
-10@@ -269,6 +269,12 @@ static bool device_is_ancestor(struct device *dev, struct device *target)return false; } +static inline bool device_link_flag_is_sync_state_only (u32 flags) +{ +return (flags & ~(DL_FLAG_INFERRED |DL_FLAG_CYCLE )) == + (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED ); +} +/** * device_is_dependent - Check if one device depends on another one * @dev: Device to check dependencies for. @@ -295,8 +301,7 @@ int device_is_dependent(struct device *dev, void *target)return ret;list_for_each_entry (link, &dev->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (device_link_flag_is_sync_state_only (link->flags))continue ;if (link->consumer == target)@@ -369,8 +374,7 @@ static int device_reorder_to_tail(struct device *dev, void *not_used)device_for_each_child (dev,NULL , device_reorder_to_tail);list_for_each_entry (link, &dev->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (device_link_flag_is_sync_state_only (link->flags))continue ;device_reorder_to_tail (link->consumer,NULL ); }@@ -621,7 +625,8 @@ postcore_initcall(devlink_class_init);DL_FLAG_AUTOREMOVE_SUPPLIER | \DL_FLAG_AUTOPROBE_CONSUMER | \DL_FLAG_SYNC_STATE_ONLY | \ - DL_FLAG_INFERRED) +DL_FLAG_INFERRED | \ + DL_FLAG_CYCLE) #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \DL_FLAG_PM_RUNTIME |DL_FLAG_RPM_ACTIVE )@@ -690,8 +695,6 @@ struct device_link *device_link_add(struct device *consumer,if (!consumer || !supplier || consumer == supplier || flags & ~DL_ADD_VALID_FLAGS || (flags &DL_FLAG_STATELESS && flags &DL_MANAGED_LINK_FLAGS ) || - (flags &DL_FLAG_SYNC_STATE_ONLY && - (flags & ~DL_FLAG_INFERRED ) !=DL_FLAG_SYNC_STATE_ONLY ) || (flags &DL_FLAG_AUTOPROBE_CONSUMER && flags & (DL_FLAG_AUTOREMOVE_CONSUMER |DL_FLAG_AUTOREMOVE_SUPPLIER )))@@ -707,6 +710,10 @@ struct device_link *device_link_add(struct device *consumer,if (!(flags &DL_FLAG_STATELESS )) flags |=DL_FLAG_MANAGED ; +if (flags &DL_FLAG_SYNC_STATE_ONLY && + !device_link_flag_is_sync_state_only (flags)) +return NULL ; +device_links_write_lock ();device_pm_lock ();@@ -1627,7 +1634,7 @@ static void fw_devlink_relax_link(struct device_link *link)if (!(link->flags &DL_FLAG_INFERRED ))return ; -if (link->flags == (DL_FLAG_MANAGED |FW_DEVLINK_FLAGS_PERMISSIVE )) +if (device_link_flag_is_sync_state_only (link->flags))return ;pm_runtime_drop_link (link);@@ -1695,8 +1702,8 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup)return ret;list_for_each_entry (link, &con->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (!(link->flags &DL_FLAG_CYCLE ) && +device_link_flag_is_sync_state_only (link->flags))continue ;if (!fw_devlink_relax_cycle (link->consumer, sup))@@ -1705,6 +1712,7 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup) ret =1 ;fw_devlink_relax_link (link); + link->flags |=DL_FLAG_CYCLE ; }return ret; }include/linux/device.h +1
-1@@ -326,6 +326,7 @@ enum device_link_state {#define DL_FLAG_MANAGED BIT(6)#define DL_FLAG_SYNC_STATE_ONLY BIT(7)#define DL_FLAG_INFERRED BIT(8) +#define DL_FLAG_CYCLE BIT(9)/** * enum dl_dev_state - Device driver presence tracking information. -- 2.39.2
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 330/567] driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links
Quoted 47 lines · Saravana Kannan
Quoted 43 lines · Greg Kroah-Hartman
From: Saravana Kannan <[email protected]>
[ Upstream commit
67cad5c67019c38126b749621665b6723d3ae7e6]
fw_devlinkusesDL_FLAG_SYNC_STATE_ONLYdevice link flag for two purposes:1. To allow a parent device to proxy its child device's dependency on a supplier so that the supplier doesn't get its
sync_state()callback before the child device/consumer can be added and probed. In this usage scenario, we need to ignore cycles for ensure correctness ofsync_state()callbacks.2. When there are dependency cycles in firmware, we don't know which of those dependencies are valid. So, we have to ignore them all wrt probe ordering while still making sure the
sync_state()callbacks come correctly.However, when detecting dependency cycles, there can be multiple dependency cycles between two devices that we need to detect. For example:
A -> B -> A and A -> C -> B -> A.
To detect multiple cycles correct, we need to be able to differentiate
DL_FLAG_SYNC_STATE_ONLYdevice links used for (1) vs (2) above.To allow this differentiation, add a
DL_FLAG_CYCLEthat can be use to mark use case (2). We can then use theDL_FLAG_CYCLEto decide whichDL_FLAG_SYNC_STATE_ONLYdevice links to follow when looking for dependency cycles.Fixes 2de9d8e0d2fe ("driver core: fw_devlink: Improve handling of cyclic dependencies")Signed-off-by Saravana Kannan <[email protected]>Tested-by Colin Foster <[email protected]>Tested-by Sudeep Holla <[email protected]>Tested-by Douglas Anderson <[email protected]>Tested-by Geert Uytterhoeven <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>Quoted 1 line
---
Quoted 6 lines
These
fw_devlinkpatches weren't tested with 5.15. It's also an extensive refactor. So I'm a little worried if it'll be finicky and break things in a kernel that's a year old.Unless someone specifically wants these patches in 5.15, I'd prefer we don't pick it up in 5.15.
Good point, I'll go drop this from the 5.15.y queue.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 331/567 dmaengine: dw-edma: Fix readq_ch() return value truncation
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 5fdca4a995bcd4cf61bda40af154a730589dc524 ]
Previously, readq_ch() did a 64-bit readq(), but truncated the result by storing it in the u32 "value". Change "value" to u64 to avoid the truncation.
Note: the method is currently unused, so the bug hasn't caused any problem so far.
--- drivers/dma/dw-edma/dw-edma-v0-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dw-edma/dw-edma-v0-core.c +1 -1
@@ -192,7 +192,7 @@ static inline void writeq_ch(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch,static inline u64 readq_ch (struct dw_edma *dw,enum dw_edma_dir dir,u16 ch,const void __iomem *addr) { -u32 value; +u64 value;if (dw->mf ==EDMA_MF_EDMA_LEGACY ) {u32 viewport_sel;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 332/567 phy: rockchip-typec: fix tcphy_get_mode error case
In reply to Greg Kroah-HartmanFrom: Neill Kapron <[email protected]>
[ Upstream commit 4ca651df07183e29cdad7272255e23aec0169a1b ]
The existing logic in tcphy_get_mode() can cause the phy to be incorrectly configured to USB UFP or DisplayPort mode when extcon_get_state returns an error code.
extcon_get_state() can return 0, 1, or a negative error code.
It is possible to get into the failing state with an extcon driver which does not support the extcon connector id specified as the second argument to extcon_get_state().
tcphy_get_mode()
->extcon_get_state()
-->find_cable_index_by_id()
--->return -EINVAL;
--- drivers/phy/rockchip/phy-rockchip-typec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-typec.c +2 -2
@@ -821,10 +821,10 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy) mode =MODE_DFP_USB ; id =EXTCON_USB_HOST ; -if (ufp) { +if (ufp >0 ) { mode =MODE_UFP_USB ; id =EXTCON_USB ; - }else if (dp) { + }else if (dp >0 ) { mode =MODE_DFP_DP ; id =EXTCON_DISP_DP ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 333/567 iw_cxgb4: Fix potential NULL dereference in c4iw_fill_res_cm_id_entry()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 4ca446b127c568b59cb8d9748b6f70499624bb18 ]
This condition needs to match the previous "if (epcp->state == LISTEN) {" exactly to avoid a NULL dereference of either "listen_ep" or "ep". The problem is that "epcp" has been re-assigned so just testing "if (epcp->state == LISTEN) {" a second time is not sufficient.
--- drivers/infiniband/hw/cxgb4/restrack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/restrack.c +1 -1
@@ -238,7 +238,7 @@ int c4iw_fill_res_cm_id_entry(struct sk_buff *msg,if (rdma_nl_put_driver_u64_hex (msg,"history" , epcp->history)) goto err_cancel_table; -if (epcp->state ==LISTEN ) { +if (listen_ep) {if (rdma_nl_put_driver_u32 (msg,"stid" , listen_ep->stid)) goto err_cancel_table;if (rdma_nl_put_driver_u32 (msg,"backlog" , listen_ep->backlog))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 334/567 iommu: Fix error unwind in iommu_group_alloc()
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 4daa861174d56023c2068ddb03de0752f07fa199 ]
If either iommu_group_grate_file() fails then theiommu_group is leaked.
Destroy it on these error paths.
Found by kselftest/iommu/iommufd_fail_nth
--- drivers/iommu/iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iommu/iommu.c +6 -2
@@ -656,12 +656,16 @@ struct iommu_group *iommu_group_alloc(void) ret =iommu_group_create_file (group, &iommu_group_attr_reserved_regions); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + } ret =iommu_group_create_file (group, &iommu_group_attr_type); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + }pr_debug ("Allocated group %d\n" , group->id);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 335/567 dmaengine: sf-pdma: pdma_desc memory leak fix
In reply to Greg Kroah-HartmanFrom: Shravan Chippa <[email protected]>
[ Upstream commit b02e07015a5ac7bbc029da931ae17914b8ae0339 ]
Commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel") changed sf_pdma_prep_dma_memcpy() to unconditionally allocate a new sf_pdma_desc each time it is called.
The driver previously recycled descs, by checking the in_use flag, only allocating additional descs if the existing one was in use. This logic was removed in commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel"), but sf_pdma_free_desc() was not changed to handle the new behaviour.
As a result, each time sf_pdma_prep_dma_memcpy() is called, the previous descriptor is leaked, over time leading to memory starvation:
unreferenced object 0xffffffe008447300 (size 192):
comm "irq/39-mchp_dsc", pid 343, jiffies 4294906910 (age 981.200s) hex dump (first 32 bytes):
00 00 00 ff 00 00 00 00 b8 c1 00 00 00 00 00 00 ................
00 00 70 08 10 00 00 00 00 00 00 c0 00 00 00 00 ..p.............
backtrace:
[<00000000064a04f4>] kmemleak_alloc+0x1e/0x28
[<00000000018927a7>] kmem_cache_alloc+0x11e/0x178
[<000000002aea8d16>] sf_pdma_prep_dma_memcpy+0x40/0x112Add the missing kfree() to sf_pdma_free_desc(), and remove the redundant in_use flag.
--- drivers/dma/sf-pdma/sf-pdma.c | 3 +-- drivers/dma/sf-pdma/sf-pdma.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sf-pdma/sf-pdma.c +1 -2
@@ -96,7 +96,6 @@ sf_pdma_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dest, dma_addr_t src,if (!desc)return NULL ; - desc->in_use = true; desc->dirn =DMA_MEM_TO_MEM ; desc->async_tx =vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);
@@ -290,7 +289,7 @@ static void sf_pdma_free_desc(struct virt_dma_desc *vdesc)struct sf_pdma_desc *desc; desc =to_sf_pdma_desc (vdesc); - desc->in_use = false; +kfree (desc); }static void sf_pdma_donebh_tasklet (struct tasklet_struct *t)
drivers/dma/sf-pdma/sf-pdma.h +0 -1
@@ -82,7 +82,6 @@ struct sf_pdma_desc {u64 src_addr;struct virt_dma_desc vdesc;struct sf_pdma_chan *chan; -bool in_use;enum dma_transfer_direction dirn;struct dma_async_tx_descriptor *async_tx; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 336/567 dmaengine: dw-axi-dmac: Do not dereference NULL structure
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit be4d46edeee4b2459d2f53f37ada88bbfb634b6c ]
If "vdesc" is NULL, it cannot be used with vd_to_axi_desc(). Leave "bytes" unchanged at 0. Seen under GCC 13 with -Warray-bounds:
../drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c: In function 'dma_chan_tx_status':../drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:329:46: warning: array subscript 0 is outside array bounds of 'struct virt_dma_desc[46116860184273879]' [-Warray-bounds=]
329 | bytes = vd_to_axi_desc(vdesc)->length;
| ^~
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 2 -- 1 file changed, 2 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +0 -2
@@ -288,8 +288,6 @@ dma_chan_tx_status(struct dma_chan *dchan, dma_cookie_t cookie, len =vd_to_axi_desc (vdesc)->hw_desc[0 ].len; completed_length = completed_blocks * len; bytes = length - completed_length; - }else { - bytes =vd_to_axi_desc (vdesc)->length; }spin_unlock_irqrestore (&chan->vc.lock, flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 337/567 iommu/vt-d: Fix error handling in sva enable/disable paths
In reply to Greg Kroah-HartmanFrom: Lu Baolu <[email protected]>
[ Upstream commit 60b1daa3b168fbc648ae2ad28a84759223e49e18 ]
Roll back all previous actions in error paths of intel_iommu_enable_sva() and intel_iommu_disable_sva().
--- drivers/iommu/intel/iommu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.c +12 -4
@@ -5405,8 +5405,12 @@ static int intel_iommu_enable_sva(struct device *dev)return -EINVAL ; ret =iopf_queue_add_device (iommu->iopf_queue, dev); -if (!ret) - ret =iommu_register_device_fault_handler (dev, iommu_queue_iopf, dev); +if (ret) +return ret; + + ret =iommu_register_device_fault_handler (dev, iommu_queue_iopf, dev); +if (ret) +iopf_queue_remove_device (iommu->iopf_queue, dev);return ret; }
@@ -5418,8 +5422,12 @@ static int intel_iommu_disable_sva(struct device *dev)int ret; ret =iommu_unregister_device_fault_handler (dev); -if (!ret) - ret =iopf_queue_remove_device (iommu->iopf_queue, dev); +if (ret) +return ret; + + ret =iopf_queue_remove_device (iommu->iopf_queue, dev); +if (ret) +iommu_register_device_fault_handler (dev, iommu_queue_iopf, dev);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 338/567 iommu/vt-d: Remove duplicate identity domain flag
In reply to Greg Kroah-HartmanFrom: Lu Baolu <[email protected]>
[ Upstream commit b34380a6d767c54480a937951e6189a7f9699443 ]
The iommu_domain data structure already has the "type" field to keep the type of a domain. It's unnecessary to have the DOMAIN_FLAG_STATIC_IDENTITY flag in the vt-d implementation. This cleans it up with no functionality change.
Stable-dep-of: 257ec2907419 ("iommu/vt-d: Allow to use flush-queue when first level is default")
--- drivers/iommu/intel/iommu.c | 9 ++++----- include/linux/intel-iommu.h | 3 --- 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/iommu/intel/iommu.c +4 -5
@@ -514,7 +514,7 @@ static inline void free_devinfo_mem(void *vaddr)static inline int domain_type_is_si (struct dmar_domain *domain) { -return domain->flags &DOMAIN_FLAG_STATIC_IDENTITY ; +return domain->domain.type ==IOMMU_DOMAIN_IDENTITY ; }static inline bool domain_use_first_level (struct dmar_domain *domain)
@@ -1922,7 +1922,7 @@ static bool first_level_by_default(void)return scalable_mode_support () &&intel_cap_flts_sanity (); } -static struct dmar_domain *alloc_domain (int flags) +static struct dmar_domain *alloc_domain (unsigned int type) {struct dmar_domain *domain;
@@ -1932,7 +1932,6 @@ static struct dmar_domain *alloc_domain(int flags)memset (domain,0 ,sizeof (*domain)); domain->nid =NUMA_NO_NODE ; - domain->flags = flags;if (first_level_by_default ()) domain->flags |=DOMAIN_FLAG_USE_FIRST_LEVEL ; domain->has_iotlb_device = false;
@@ -2753,7 +2752,7 @@ static int __init si_domain_init(int hw)struct device *dev;int i, nid, ret; - si_domain =alloc_domain (DOMAIN_FLAG_STATIC_IDENTITY ); + si_domain =alloc_domain (IOMMU_DOMAIN_IDENTITY );if (!si_domain)return -EFAULT ;
@@ -4555,7 +4554,7 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)case IOMMU_DOMAIN_DMA :case IOMMU_DOMAIN_DMA_FQ :case IOMMU_DOMAIN_UNMANAGED : - dmar_domain =alloc_domain (0 ); + dmar_domain =alloc_domain (type);if (!dmar_domain) {pr_err ("Can't allocate dmar_domain\n" );return NULL ;
include/linux/intel-iommu.h +0 -3
@@ -515,9 +515,6 @@ struct context_entry {u64 hi; }; -/* si_domain contains mulitple devices */ -#define DOMAIN_FLAG_STATIC_IDENTITY BIT(0) -/* * When VT-d works in the scalable mode, it allows DMA translation to * happen through either first level or second level page table. This
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 339/567 iommu/vt-d: Check FL and SL capability sanity in scalable mode
In reply to Greg Kroah-HartmanFrom: Lu Baolu <[email protected]>
[ Upstream commit 7afd7f6aa21a2929aff3a059b741933ee1819c6b ]
An iommu domain could be allocated and mapped before it's attached to any device. This requires that in scalable mode, when the domain is allocated, the format (FL or SL) of the page table must be determined. In order to achieve this, the platform should support consistent SL or FL capabilities on all IOMMU's. This adds a check for this and aborts IOMMU probing if it doesn't meet this requirement.
Stable-dep-of: 257ec2907419 ("iommu/vt-d: Allow to use flush-queue when first level is default")
--- drivers/iommu/intel/cap_audit.c | 13 +++++++++++++ drivers/iommu/intel/cap_audit.h | 1 + 2 files changed, 14 insertions(+)
drivers/iommu/intel/cap_audit.c +13 -0
@@ -163,6 +163,14 @@ static int cap_audit_static(struct intel_iommu *iommu, enum cap_audit_type type)check_irq_capabilities (iommu, i); } +/* +* If the system is sane to support scalable mode, either SL or FL +* should be sane. +*/ +if (intel_cap_smts_sanity () && + !intel_cap_flts_sanity () && !intel_cap_slts_sanity ()) +return -EOPNOTSUPP ; + out:rcu_read_unlock ();return 0 ;
@@ -203,3 +211,8 @@ bool intel_cap_flts_sanity(void) {return ecap_flts (intel_iommu_ecap_sanity); } + +bool intel_cap_slts_sanity (void ) +{ +return ecap_slts (intel_iommu_ecap_sanity); +}
drivers/iommu/intel/cap_audit.h +1 -0
@@ -111,6 +111,7 @@ bool intel_cap_smts_sanity(void);bool intel_cap_pasid_sanity (void );bool intel_cap_nest_sanity (void );bool intel_cap_flts_sanity (void ); +bool intel_cap_slts_sanity (void );static inline bool scalable_mode_support (void ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 340/567 iommu/vt-d: Use second level for GPA->HPA translation
In reply to Greg Kroah-HartmanFrom: Lu Baolu <[email protected]>
[ Upstream commit 032c5ee40e9fc68ed650a3f86f23259376ec93fc ]
The IOMMU VT-d implementation uses the first level for GPA->HPA translation by default. Although both the first level and the second level could handle the DMA translation, they're different in some way. For example, the second level translation has separate controls for the Access/Dirty page tracking. With the first level translation, there's no such control. On the other hand, the second level translation has the page-level control for forcing snoop, but the first level only has global control with pasid granularity.
This uses the second level for GPA->HPA translation so that we can provide a consistent hardware interface for use cases like dirty page tracking for live migration.
Stable-dep-of: 257ec2907419 ("iommu/vt-d: Allow to use flush-queue when first level is default")
--- drivers/iommu/intel/iommu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/iommu/intel/iommu.c +12 -3
@@ -1917,9 +1917,18 @@ static void free_dmar_iommu(struct intel_iommu *iommu)* Check and return whether first level is used by default for * DMA translation. */ -static bool first_level_by_default (void ) +static bool first_level_by_default (unsigned int type) { -return scalable_mode_support () &&intel_cap_flts_sanity (); +/* Only SL is available in legacy mode */ +if (!scalable_mode_support ()) +return false; + +/* Only level (either FL or SL) is available, just use it */ +if (intel_cap_flts_sanity () ^intel_cap_slts_sanity ()) +return intel_cap_flts_sanity (); + +/* Both levels are available, decide it based on domain type */ +return type !=IOMMU_DOMAIN_UNMANAGED ; }static struct dmar_domain *alloc_domain (unsigned int type)
@@ -1932,7 +1941,7 @@ static struct dmar_domain *alloc_domain(unsigned int type)memset (domain,0 ,sizeof (*domain)); domain->nid =NUMA_NO_NODE ; -if (first_level_by_default ()) +if (first_level_by_default (type)) domain->flags |=DOMAIN_FLAG_USE_FIRST_LEVEL ; domain->has_iotlb_device = false;INIT_LIST_HEAD (&domain->devices);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 341/567 iommu/vt-d: Allow to use flush-queue when first level is default
In reply to Greg Kroah-HartmanFrom: Tina Zhang <[email protected]>
[ Upstream commit 257ec290741924f8df678927d0dfecb1deebb9c5 ]
Commit 29b32839725f ("iommu/vt-d: Do not use flush-queue when caching-mode is on") forced default domains to be strict mode as long as IOMMU caching-mode is flagged. The reason for doing this is that when vIOMMU uses VT-d caching mode to synchronize shadowing page tables, the strict mode shows better performance.
However, this optimization is orthogonal to the first-level page table because the Intel VT-d architecture does not define the caching mode of the first-level page table. Refer to VT-d spec, section 6.1, "When the CM field is reported as Set, any software updates to remapping structures other than first-stage mapping (including updates to not- present entries or present entries whose programming resulted in translation faults) requires explicit invalidation of the caches." Exclude the first-level page table from this optimization.
Generally using first-stage translation in vIOMMU implies nested translation enabled in the physical IOMMU. In this case the first-stage page table is wholly captured by the guest. The vIOMMU only needs to transfer the cache invalidations on vIOMMU to the physical IOMMU. Forcing the default domain to strict mode will cause more frequent cache invalidations, resulting in performance degradation. In a real performance benchmark test measured by iperf receive, the performance result on Sapphire Rapids 100Gb NIC shows:
w/ this fix ~51 Gbits/s, w/o this fix ~39.3 Gbits/s.
Theoretically a first-stage IOMMU page table can still be shadowed in absence of the caching mode, e.g. with host write-protecting guest IOMMU page table to synchronize changed PTEs with the physical IOMMU page table. In this case the shadowing overhead is decoupled from emulating IOTLB invalidation then the overhead of the latter part is solely decided by the frequency of IOTLB invalidations. Hence allowing guest default dma domain to be lazy can also benefit the overall performance by reducing the total VM-exit numbers.
--- drivers/iommu/intel/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +2 -1
@@ -4423,7 +4423,8 @@ int __init intel_iommu_init(void)* is likely to be much lower than the overhead of synchronizing * the virtual and physical IOMMU page-tables. */ -if (cap_caching_mode (iommu->cap)) { +if (cap_caching_mode (iommu->cap) && + !first_level_by_default (IOMMU_DOMAIN_DMA )) {pr_info_once ("IOMMU batching disallowed due to virtualization\n" );iommu_set_dma_strict (); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 342/567 IB/hfi1: Fix math bugs in hfi1_can_pin_pages()
In reply to Greg Kroah-HartmanFrom: Patrick Kelsey <[email protected]>
[ Upstream commit a0d198f79a8d033bd46605b779859193649f1f99 ]
Fix arithmetic and logic errors in hfi1_can_pin_pages() that would allow hfi1 to attempt pinning pages in cases where it should not because of resource limits or lack of required capability.
--- drivers/infiniband/hw/hfi1/user_pages.c | 61 ++++++++++++++++--------- 1 file changed, 40 insertions(+), 21 deletions(-)
drivers/infiniband/hw/hfi1/user_pages.c +40 -21
@@ -29,33 +29,52 @@ MODULE_PARM_DESC(cache_size, "Send and receive side cache size limit (in MB)");bool hfi1_can_pin_pages (struct hfi1_devdata *dd,struct mm_struct *mm,u32 nlocked,u32 npages) { -unsigned long ulimit =rlimit (RLIMIT_MEMLOCK ), pinned, cache_limit, - size = (cache_size * (1UL <<20 ));/* convert to bytes */ -unsigned int usr_ctxts = - dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt; -bool can_lock =capable (CAP_IPC_LOCK ); +unsigned long ulimit_pages; +unsigned long cache_limit_pages; +unsigned int usr_ctxts;/* -* Calculate per-cache size. The calculation below uses only a quarter -* of the available per-context limit. This leaves space for other -* pinning. Should we worry about shared ctxts? +* Perform RLIMIT_MEMLOCK based checks unless CAP_IPC_LOCK is present. */ - cache_limit = (ulimit / usr_ctxts) /4 ; - -/* If ulimit isn't set to "unlimited" and is smaller than cache_size. */ -if (ulimit != (-1UL ) && size > cache_limit) - size = cache_limit; - -/* Convert to number of pages */ - size =DIV_ROUND_UP (size,PAGE_SIZE ); - - pinned =atomic64_read (&mm->pinned_vm); +if (!capable (CAP_IPC_LOCK )) { + ulimit_pages = +DIV_ROUND_DOWN_ULL (rlimit (RLIMIT_MEMLOCK ),PAGE_SIZE ); + +/* +* Pinning these pages would exceed this process's locked memory +* limit. +*/ +if (atomic64_read (&mm->pinned_vm) + npages > ulimit_pages) +return false; + +/* +* Only allow 1/4 of the user's RLIMIT_MEMLOCK to be used for HFI +* caches. This fraction is then equally distributed among all +* existing user contexts. Note that if RLIMIT_MEMLOCK is +* 'unlimited' (-1), the value of this limit will be > 2^42 pages +* (2^64 / 2^12 / 2^8 / 2^2). +* +* The effectiveness of this check may be reduced if I/O occurs on +* some user contexts before all user contexts are created. This +* check assumes that this process is the only one using this +* context (e.g., the corresponding fd was not passed to another +* process for concurrent access) as there is no per-context, +* per-process tracking of pinned pages. It also assumes that each +* user context has only one cache to limit. +*/ + usr_ctxts = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt; +if (nlocked + npages > (ulimit_pages / usr_ctxts /4 )) +return false; + } -/* First, check the absolute limit against all pinned pages. */ -if (pinned + npages >= ulimit && !can_lock) +/* +* Pinning these pages would exceed the size limit for this cache. +*/ + cache_limit_pages = cache_size * (1024 *1024 ) /PAGE_SIZE ; +if (nlocked + npages > cache_limit_pages)return false; -return ((nlocked + npages) <= size) || can_lock; +return true; } int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t npages,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 343/567 IB/hfi1: Fix sdma.h tx->num_descs off-by-one errors
In reply to Greg Kroah-HartmanFrom: Patrick Kelsey <[email protected]>
[ Upstream commit fd8958efe8779d3db19c9124fce593ce681ac709 ]
Fix three sources of error involving struct sdma_txreq.num_descs.
When _extend_sdma_tx_descs() extends the descriptor array, it uses the value of tx->num_descs to determine how many existing entries from the tx's original, internal descriptor array to copy to the newly allocated one. As this value was incremented before the call, the copy loop will access one entry past the internal descriptor array, copying its contents into the corresponding slot in the new array.
If the call to _extend_sdma_tx_descs() fails, _pad_smda_tx_descs() then invokes __sdma_tx_clean() which uses the value of tx->num_desc to drive a loop that unmaps all descriptor entries in use. As this value was incremented before the call, the unmap loop will invoke sdma_unmap_desc() on a descriptor entry whose contents consist of whatever random data was copied into it during (1), leading to cascading further calls into the kernel and driver using arbitrary data.
_sdma_close_tx() was using tx->num_descs instead of tx->num_descs - 1.
Fix all of the above by:
- Only increment .num_descs after .descp is extended.
- Use .num_descs - 1 instead of .num_descs for last .descp entry.
--- drivers/infiniband/hw/hfi1/sdma.c | 4 ++-- drivers/infiniband/hw/hfi1/sdma.h | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-)
drivers/infiniband/hw/hfi1/sdma.c +2 -2
@@ -3160,8 +3160,7 @@ int _pad_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx) {int rval =0 ; - tx->num_desc++; -if ((unlikely (tx->num_desc == tx->desc_limit))) { +if ((unlikely (tx->num_desc +1 == tx->desc_limit))) { rval =_extend_sdma_tx_descs (dd, tx);if (rval) {__sdma_txclean (dd, tx);
@@ -3174,6 +3173,7 @@ int _pad_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx)SDMA_MAP_NONE , dd->sdma_pad_phys, sizeof(u32) - (tx->packet_len & (sizeof(u32) - 1))); + tx->num_desc++;_sdma_close_tx (dd, tx);return rval; }
drivers/infiniband/hw/hfi1/sdma.h +7 -8
@@ -631,14 +631,13 @@ static inline void sdma_txclean(struct hfi1_devdata *dd, struct sdma_txreq *tx)static inline void _sdma_close_tx (struct hfi1_devdata *dd,struct sdma_txreq *tx) { - tx->descp[tx->num_desc].qw[0 ] |= -SDMA_DESC0_LAST_DESC_FLAG ; - tx->descp[tx->num_desc].qw[1 ] |= - dd->default_desc1; +u16 last_desc = tx->num_desc -1 ; + + tx->descp[last_desc].qw[0 ] |=SDMA_DESC0_LAST_DESC_FLAG ; + tx->descp[last_desc].qw[1 ] |= dd->default_desc1;if (tx->flags &SDMA_TXREQ_F_URGENT ) - tx->descp[tx->num_desc].qw[1 ] |= - (SDMA_DESC1_HEAD_TO_HOST_FLAG | -SDMA_DESC1_INT_REQ_FLAG ); + tx->descp[last_desc].qw[1 ] |= (SDMA_DESC1_HEAD_TO_HOST_FLAG | +SDMA_DESC1_INT_REQ_FLAG ); } static inline int _sdma_txadd_daddr(
@@ -655,6 +654,7 @@ static inline int _sdma_txadd_daddr( type, addr, len);WARN_ON (len > tx->tlen); + tx->num_desc++; tx->tlen -= len;/* special cases for last */ if (!tx->tlen) {
@@ -666,7 +666,6 @@ static inline int _sdma_txadd_daddr(_sdma_close_tx (dd, tx); } } - tx->num_desc++;return rval; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 344/567 remoteproc: qcom_q6v5_mss: Use a carveout to authenticate modem headers
In reply to Greg Kroah-HartmanFrom: Sibi Sankar <[email protected]>
[ Upstream commit 57f72170a2b2a362c35bb9407fc844eac5afdec1 ]
Any access to the dynamically allocated metadata region by the application processor after assigning it to the remote Q6 will result in a XPU violation. Fix this by replacing the dynamically allocated memory region with a no-map carveout and unmap the modem metadata memory region before passing control to the remote Q6.
--- drivers/remoteproc/qcom_q6v5_mss.c | 59 +++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +53 -6
@@ -17,6 +17,7 @@#include <linux/module.h> #include <linux/of_address.h> #include <linux/of_device.h> +#include <linux/of_reserved_mem.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> #include <linux/pm_runtime.h>
@@ -192,6 +193,9 @@ struct q6v5 {size_t mba_size;size_t dp_size; +phys_addr_t mdata_phys; +size_t mdata_size; +phys_addr_t mpss_phys;phys_addr_t mpss_reloc;size_t mpss_size;
@@ -832,15 +836,35 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw)if (IS_ERR (metadata))return PTR_ERR (metadata); - ptr =dma_alloc_attrs (qproc->dev, size, &phys,GFP_KERNEL , dma_attrs); -if (!ptr) { -kfree (metadata); -dev_err (qproc->dev,"failed to allocate mdt buffer\n" ); -return -ENOMEM ; +if (qproc->mdata_phys) { +if (size > qproc->mdata_size) { + ret = -EINVAL ; +dev_err (qproc->dev,"metadata size outside memory range\n" ); + goto free_metadata; + } + + phys = qproc->mdata_phys; + ptr =memremap (qproc->mdata_phys, size,MEMREMAP_WC ); +if (!ptr) { + ret = -EBUSY ; +dev_err (qproc->dev,"unable to map memory region: %pa+%zx\n" , + &qproc->mdata_phys, size); + goto free_metadata; + } + }else { + ptr =dma_alloc_attrs (qproc->dev, size, &phys,GFP_KERNEL , dma_attrs); +if (!ptr) { + ret = -ENOMEM ; +dev_err (qproc->dev,"failed to allocate mdt buffer\n" ); + goto free_metadata; + } }memcpy (ptr, metadata, size); +if (qproc->mdata_phys) +memunmap (ptr); +/* Hypervisor mapping to access metadata by modem */ mdata_perm =BIT (QCOM_SCM_VMID_HLOS ); ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm, false, true,
@@ -869,7 +893,9 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw) "mdt buffer not reclaimed system may become unstable\n"); free_dma_attrs: -dma_free_attrs (qproc->dev, size, ptr, phys, dma_attrs); +if (!qproc->mdata_phys) +dma_free_attrs (qproc->dev, size, ptr, phys, dma_attrs); +free_metadata:kfree (metadata);return ret <0 ? ret :0 ;
@@ -1615,6 +1641,7 @@ static int q6v5_init_reset(struct q6v5 *qproc)static int q6v5_alloc_memory_region (struct q6v5 *qproc) {struct device_node *child; +struct reserved_mem *rmem;struct device_node *node;struct resource r;int ret;
@@ -1661,6 +1688,26 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc) qproc->mpss_phys = qproc->mpss_reloc = r.start; qproc->mpss_size =resource_size (&r); +if (!child) { + node =of_parse_phandle (qproc->dev->of_node,"memory-region" ,2 ); + }else { + child =of_get_child_by_name (qproc->dev->of_node,"metadata" ); + node =of_parse_phandle (child,"memory-region" ,0 ); +of_node_put (child); + } + +if (!node) +return 0 ; + + rmem =of_reserved_mem_lookup (node); +if (!rmem) { +dev_err (qproc->dev,"unable to resolve metadata region\n" ); +return -EINVAL ; + } + + qproc->mdata_phys = rmem->base; + qproc->mdata_size = rmem->size; +return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 345/567 media: ti: cal: fix possible memory leak in cal_ctx_create()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 7acd650a0484d92985a0d6d867d980c6dd019885 ]
The memory of ctx is allocated in cal_ctx_create(), but it will not be freed when cal_ctx_v4l2_init() fails, so add kfree() when cal_ctx_v4l2_init() fails to fix it.
--- drivers/media/platform/ti-vpe/cal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/ti-vpe/cal.c +3 -1
@@ -940,8 +940,10 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst) ctx->datatype =CAL_CSI2_CTX_DT_ANY ; ret =cal_ctx_v4l2_init (ctx); -if (ret) +if (ret) { +kfree (ctx);return NULL ; + }return ctx; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 346/567 media: platform: ti: Add missing check for devm_regulator_get
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit da8e05f84a11c3cc3b0ba0a3c62d20e358002d99 ]
Add check for the return value of devm_regulator_get since it may return error pointer.
--- drivers/media/platform/omap3isp/isp.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/platform/omap3isp/isp.c +9 -0
@@ -2306,7 +2306,16 @@ static int isp_probe(struct platform_device *pdev)/* Regulators */ isp->isp_csiphy1.vdd =devm_regulator_get (&pdev->dev,"vdd-csiphy1" ); +if (IS_ERR (isp->isp_csiphy1.vdd)) { + ret =PTR_ERR (isp->isp_csiphy1.vdd); + goto error; + } + isp->isp_csiphy2.vdd =devm_regulator_get (&pdev->dev,"vdd-csiphy2" ); +if (IS_ERR (isp->isp_csiphy2.vdd)) { + ret =PTR_ERR (isp->isp_csiphy2.vdd); + goto error; + }/* Clocks *
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 347/567 powerpc: Remove linker flag from KBUILD_AFLAGS
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 31f48f16264bc70962fb3e7ec62da64d0a2ba04a ]
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it points out that KBUILD_AFLAGS contains a linker flag, which will be unused:
clang: error: -Wl,-a32: 'linker' input unused [-Werror,-Wunused-command-line-argument]
This was likely supposed to be '-Wa,-a$(BITS)'. However, this change is unnecessary, as all supported versions of clang and gcc will pass '-a64' or '-a32' to GNU as based on the value of '-m'; the behavior of the latest stable release of the oldest supported major version of each compiler is shown below and each compiler's latest release exhibits the same behavior (GCC 12.2.0 and Clang 15.0.6).
$ powerpc64-linux-gcc --version | head -1 powerpc64-linux-gcc (GCC) 5.5.0
$ powerpc64-linux-gcc -m64 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as ' .../as -a64 -mppc64 -many -mbig -o /dev/null /tmp/cctwuBzZ.s
$ powerpc64-linux-gcc -m32 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as ' .../as -a32 -mppc -many -mbig -o /dev/null /tmp/ccaZP4mF.sg
$ clang --version | head -1 Ubuntu clang version 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214622.5
$ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
-x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
"/usr/bin/powerpc64-linux-gnu-as" "-a64" "-mppc64" "-many" "-o" "/dev/null" "/tmp/null-80267c.s" $ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
-x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
"/usr/bin/powerpc64-linux-gnu-as" "-a32" "-mppc" "-many" "-o" "/dev/null" "/tmp/null-ab8f8d.s"Remove this flag altogether to avoid future issues.
--- arch/powerpc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Makefile +1 -1
@@ -92,7 +92,7 @@ aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ifeq ($(HAS_BIARCH),y) KBUILD_CFLAGS += -m$(BITS) -KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) +KBUILD_AFLAGS += -m$(BITS) KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION) endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 348/567 s390/vdso: remove -nostdlib compiler flag
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 7b737adc10d269e7fdf714ae2caa2281b6a801cf ]
The -nostdlib option requests the compiler to not use the standard system startup files or libraries when linking. It is effective only when $(CC) is used as a linker driver.
Since commit 2b2a25845d53 ("s390/vdso: Use $(LD) instead of $(CC) to link vDSO"), $(LD) is directly used, hence -nostdlib is unneeded.
Stable-dep-of: fd8589dce810 ("s390/vdso: Drop '-shared' from KBUILD_CFLAGS_64")
--- arch/s390/kernel/vdso32/Makefile | 2 +- arch/s390/kernel/vdso64/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/vdso32/Makefile +1 -1
@@ -22,7 +22,7 @@ KBUILD_AFLAGS_32 += -m31 -s KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin -LDFLAGS_vdso32.so.dbg += -fPIC -shared -nostdlib -soname=linux-vdso32.so.1 \ +LDFLAGS_vdso32.so.dbg += -fPIC -shared -soname=linux-vdso32.so.1 \ --hash-style=both --build-id=sha1 -melf_s390 -T $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
arch/s390/kernel/vdso64/Makefile +1 -1
@@ -26,7 +26,7 @@ KBUILD_AFLAGS_64 += -m64 -s KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin -ldflags-y := -fPIC -shared -nostdlib -soname=linux-vdso64.so.1 \ +ldflags-y := -fPIC -shared -soname=linux-vdso64.so.1 \ --hash-style=both --build-id=sha1 -T $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 349/567 s390/vdso: Drop -shared from KBUILD_CFLAGS_64
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit fd8589dce8107e2ce62e92f76089654462dd67b4 ]
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it points out that there is a linking phase flag added to CFLAGS, which will only be used for compiling
clang-16: error: argument unused during compilation: '-shared' [-Werror,-Wunused-command-line-argument]
'-shared' is already present in ldflags-y so it can just be dropped.
--- arch/s390/kernel/vdso64/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/vdso64/Makefile +1 -1
@@ -25,7 +25,7 @@ KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS)) KBUILD_AFLAGS_64 += -m64 -s KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) -KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin +KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin ldflags-y := -fPIC -shared -soname=linux-vdso64.so.1 \ --hash-style=both --build-id=sha1 -T
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 350/567 builddeb: clean generated package content
In reply to Greg Kroah-HartmanFrom: Bastian Germann <[email protected]>
[ Upstream commit c9f9cf2560e40b62015c6c4a04be60f55ce5240e ]
For each binary Debian package, a directory with the package name is created in the debian directory. Correct the generated file matches in the package's clean target, which were renamed without adjusting the target.
--- scripts/package/mkdebian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkdebian +1 -1
@@ -236,7 +236,7 @@ binary-arch: build-arch KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg clean: - rm -rf debian/*tmp debian/files + rm -rf debian/files debian/linux-* \$(MAKE) clean binary: binary-arch
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 351/567 media: max9286: Fix memleak in max9286_v4l2_register()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 8636c5fc7658c7c6299fb8b352d24ea4b9ba99e2 ]
There is a kmemleak when testing the media/i2c/max9286.c with bpf mock device:
kmemleak: 5 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
unreferenced object 0xffff88810defc400 (size 256):
comm "python3", pid 278, jiffies 4294737563 (age 31.978s) hex dump (first 32 bytes):
28 06 a7 0a 81 88 ff ff 00 fe 22 12 81 88 ff ff (.........".....
10 c4 ef 0d 81 88 ff ff 10 c4 ef 0d 81 88 ff ff ................
backtrace:
[<00000000191de6a7>] __kmalloc_node+0x44/0x1b0
[<000000002f4912b7>] kvmalloc_node+0x34/0x180
[<0000000057dc4cae>] v4l2_ctrl_new+0x325/0x10f0 [videodev]
[<0000000026030272>] v4l2_ctrl_new_std+0x16f/0x210 [videodev]
[<00000000f0d9ea2f>] max9286_probe+0x76e/0xbff [max9286]
[<00000000ea8f6455>] i2c_device_probe+0x28d/0x680
[<0000000087529af3>] really_probe+0x17c/0x3f0
[<00000000b08be526>] __driver_probe_device+0xe3/0x170
[<000000004382edea>] driver_probe_device+0x49/0x120
[<000000007bde528a>] __device_attach_driver+0xf7/0x150
[<000000009f9c6ab4>] bus_for_each_drv+0x114/0x180
[<00000000c8aaf588>] __device_attach+0x1e5/0x2d0
[<0000000041cc06b9>] bus_probe_device+0x126/0x140
[<000000002309860d>] device_add+0x810/0x1130
[<000000002827bf98>] i2c_new_client_device+0x359/0x4f0
[<00000000593bdc85>] of_i2c_register_device+0xf1/0x110max9286_v4l2_register() calls v4l2_ctrl_new_std(), but won't free the created v412_ctrl when fwnode_graph_get_endpoint_by_id() failed, which causes the memleak. Call v4l2_ctrl_handler_free() to free the v412_ctrl.
--- drivers/media/i2c/max9286.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/max9286.c +1 -0
@@ -928,6 +928,7 @@ static int max9286_v4l2_register(struct max9286_priv *priv) err_put_node:fwnode_handle_put (ep); err_async: +v4l2_ctrl_handler_free (&priv->ctrls);max9286_v4l2_notifier_unregister (priv);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 352/567 media: ov2740: Fix memleak in ov2740_init_controls()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 2d899592ed7829d0d5140853bac4d58742a6b8af ]
There is a kmemleak when testing the media/i2c/ov2740.c with bpf mock device:
unreferenced object 0xffff8881090e19e0 (size 16):
comm "51-i2c-ov2740", pid 278, jiffies 4294781584 (age 23.613s) hex dump (first 16 bytes):
00 f3 7c 0b 81 88 ff ff 80 75 6a 09 81 88 ff ff ..|......uj.....
backtrace:
[<000000004e9fad8f>] __kmalloc_node+0x44/0x1b0
[<0000000039c802f4>] kvmalloc_node+0x34/0x180
[<000000009b8b5c63>] v4l2_ctrl_handler_init_class+0x11d/0x180
[videodev]
[<0000000038644056>] ov2740_probe+0x37d/0x84f [ov2740]
[<0000000092489f59>] i2c_device_probe+0x28d/0x680
[<000000001038babe>] really_probe+0x17c/0x3f0
[<0000000098c7af1c>] __driver_probe_device+0xe3/0x170
[<00000000e1b3dc24>] device_driver_attach+0x34/0x80
[<000000005a04a34d>] bind_store+0x10b/0x1a0
[<00000000ce25d4f2>] drv_attr_store+0x49/0x70
[<000000007d9f4e9a>] sysfs_kf_write+0x8c/0xb0
[<00000000be6cff0f>] kernfs_fop_write_iter+0x216/0x2e0
[<0000000031ddb40a>] vfs_write+0x658/0x810
[<0000000041beecdd>] ksys_write+0xd6/0x1b0
[<0000000023755840>] do_syscall_64+0x38/0x90
[<00000000b2cc2da2>] entry_SYSCALL_64_after_hwframe+0x63/0xcdov2740_init_controls() won't clean all the allocated resources in fail path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to prevent memleak.
--- drivers/media/i2c/ov2740.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/ov2740.c +3 -1
@@ -603,8 +603,10 @@ static int ov2740_init_controls(struct ov2740 *ov2740)V4L2_CID_TEST_PATTERN ,ARRAY_SIZE (ov2740_test_pattern_menu) -1 , 0, 0, ov2740_test_pattern_menu); -if (ctrl_hdlr->error) +if (ctrl_hdlr->error) { +v4l2_ctrl_handler_free (ctrl_hdlr);return ctrl_hdlr->error; + } ov2740->sd.ctrl_handler = ctrl_hdlr;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 353/567 media: ov5675: Fix memleak in ov5675_init_controls()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit dd74ed6c213003533e3abf4c204374ef01d86978 ]
There is a kmemleak when testing the media/i2c/ov5675.c with bpf mock device:
AssertionError: unreferenced object 0xffff888107362160 (size 16):
comm "python3", pid 277, jiffies 4294832798 (age 20.722s) hex dump (first 16 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000abe7d67c>] __kmalloc_node+0x44/0x1b0
[<000000008a725aac>] kvmalloc_node+0x34/0x180
[<000000009a53cd11>] v4l2_ctrl_handler_init_class+0x11d/0x180
[videodev]
[<0000000055b46db0>] ov5675_probe+0x38b/0x897 [ov5675]
[<00000000153d886c>] i2c_device_probe+0x28d/0x680
[<000000004afb7e8f>] really_probe+0x17c/0x3f0
[<00000000ff2f18e4>] __driver_probe_device+0xe3/0x170
[<000000000a001029>] driver_probe_device+0x49/0x120
[<00000000e39743c7>] __device_attach_driver+0xf7/0x150
[<00000000d32fd070>] bus_for_each_drv+0x114/0x180
[<000000009083ac41>] __device_attach+0x1e5/0x2d0
[<0000000015b4a830>] bus_probe_device+0x126/0x140
[<000000007813deaf>] device_add+0x810/0x1130
[<000000007becb867>] i2c_new_client_device+0x386/0x540
[<000000007f9cf4b4>] of_i2c_register_device+0xf1/0x110
[<00000000ebfdd032>] of_i2c_notify+0xfc/0x1f0ov5675_init_controls() won't clean all the allocated resources in fail path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to prevent memleak.
--- drivers/media/i2c/ov5675.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/ov5675.c +3 -1
@@ -791,8 +791,10 @@ static int ov5675_init_controls(struct ov5675 *ov5675)v4l2_ctrl_new_std (ctrl_hdlr, &ov5675_ctrl_ops,V4L2_CID_VFLIP ,0 ,1 ,1 ,0 ); -if (ctrl_hdlr->error) +if (ctrl_hdlr->error) { +v4l2_ctrl_handler_free (ctrl_hdlr);return ctrl_hdlr->error; + } ov5675->sd.ctrl_handler = ctrl_hdlr;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 354/567 media: i2c: ov772x: Fix memleak in ov772x_probe()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 7485edb2b6ca5960205c0a49bedfd09bba30e521 ]
A memory leak was reported when testing ov772x with bpf mock device:
AssertionError: unreferenced object 0xffff888109afa7a8 (size 8):
comm "python3", pid 279, jiffies 4294805921 (age 20.681s) hex dump (first 8 bytes):
80 22 88 15 81 88 ff ff ."......
backtrace:
[<000000009990b438>] __kmalloc_node+0x44/0x1b0
[<000000009e32f7d7>] kvmalloc_node+0x34/0x180
[<00000000faf48134>] v4l2_ctrl_handler_init_class+0x11d/0x180 [videodev]
[<00000000da376937>] ov772x_probe+0x1c3/0x68c [ov772x]
[<000000003f0d225e>] i2c_device_probe+0x28d/0x680
[<00000000e0b6db89>] really_probe+0x17c/0x3f0
[<000000001b19fcee>] __driver_probe_device+0xe3/0x170
[<0000000048370519>] driver_probe_device+0x49/0x120
[<000000005ead07a0>] __device_attach_driver+0xf7/0x150
[<0000000043f452b8>] bus_for_each_drv+0x114/0x180
[<00000000358e5596>] __device_attach+0x1e5/0x2d0
[<0000000043f83c5d>] bus_probe_device+0x126/0x140
[<00000000ee0f3046>] device_add+0x810/0x1130
[<00000000e0278184>] i2c_new_client_device+0x359/0x4f0
[<0000000070baf34f>] of_i2c_register_device+0xf1/0x110
[<00000000a9f2159d>] of_i2c_notify+0x100/0x160
unreferenced object 0xffff888119825c00 (size 256):
comm "python3", pid 279, jiffies 4294805921 (age 20.681s)
hex dump (first 32 bytes):
00 b4 a5 17 81 88 ff ff 00 5e 82 19 81 88 ff ff .........^......
10 5c 82 19 81 88 ff ff 10 5c 82 19 81 88 ff ff .\.......\......
backtrace:
[<000000009990b438>] __kmalloc_node+0x44/0x1b0
[<000000009e32f7d7>] kvmalloc_node+0x34/0x180
[<0000000073d88e0b>] v4l2_ctrl_new.cold+0x19b/0x86f [videodev]
[<00000000b1f576fb>] v4l2_ctrl_new_std+0x16f/0x210 [videodev]
[<00000000caf7ac99>] ov772x_probe+0x1fa/0x68c [ov772x]
[<000000003f0d225e>] i2c_device_probe+0x28d/0x680
[<00000000e0b6db89>] really_probe+0x17c/0x3f0
[<000000001b19fcee>] __driver_probe_device+0xe3/0x170
[<0000000048370519>] driver_probe_device+0x49/0x120
[<000000005ead07a0>] __device_attach_driver+0xf7/0x150
[<0000000043f452b8>] bus_for_each_drv+0x114/0x180
[<00000000358e5596>] __device_attach+0x1e5/0x2d0
[<0000000043f83c5d>] bus_probe_device+0x126/0x140
[<00000000ee0f3046>] device_add+0x810/0x1130
[<00000000e0278184>] i2c_new_client_device+0x359/0x4f0
[<0000000070baf34f>] of_i2c_register_device+0xf1/0x110The reason is that if priv->hdl.error is set, ov772x_probe() jumps to the error_mutex_destroy without doing v4l2_ctrl_handler_free(), and all resources allocated in v4l2_ctrl_handler_init() and v4l2_ctrl_new_std() are leaked.
--- drivers/media/i2c/ov772x.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/ov772x.c +1 -2
@@ -1462,7 +1462,7 @@ static int ov772x_probe(struct i2c_client *client) priv->subdev.ctrl_handler = &priv->hdl;if (priv->hdl.error) { ret = priv->hdl.error; - goto error_mutex_destroy; + goto error_ctrl_free; } priv->clk =clk_get (&client->dev,NULL );
@@ -1515,7 +1515,6 @@ static int ov772x_probe(struct i2c_client *client)clk_put (priv->clk); error_ctrl_free:v4l2_ctrl_handler_free (&priv->hdl); -error_mutex_destroy:mutex_destroy (&priv->lock);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 355/567 media: i2c: imx219: Split common registers from mode tables
In reply to Greg Kroah-HartmanFrom: Adam Ford <[email protected]>
[ Upstream commit 8508455961d5a9e8907bcfd8dcd58f19d9b6ce47 ]
There are four modes, and each mode has a table of registers. Some of the registers are common to all modes, so create new tables for these common registers to reduce duplicate code.
Stable-dep-of: ef86447e775f ("media: i2c: imx219: Fix binning for RAW8 capture")
--- drivers/media/i2c/imx219.c | 206 +++++++++++-------------------------- 1 file changed, 59 insertions(+), 147 deletions(-)
drivers/media/i2c/imx219.c +59 -147
@@ -145,23 +145,61 @@ struct imx219_mode {struct imx219_reg_list reg_list; }; -/* -* Register sets lifted off the i2C interface from the Raspberry Pi firmware -* driver. -* 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7. -*/ -static const struct imx219_reg mode_3280x2464_regs[] = { - {0x0100 ,0x00 }, +static const struct imx219_reg imx219_common_regs[] = { + {0x0100 ,0x00 },/* Mode Select */ + +/* To Access Addresses 3000-5fff, send the following commands */ {0x30eb ,0x0c }, {0x30eb ,0x05 }, {0x300a ,0xff }, {0x300b ,0xff }, {0x30eb ,0x05 }, {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, + +/* PLL Clock Table */ + {0x0301 ,0x05 },/* VTPXCK_DIV */ + {0x0303 ,0x01 },/* VTSYSCK_DIV */ + {0x0304 ,0x03 },/* PREPLLCK_VT_DIV 0x03 = AUTO set */ + {0x0305 ,0x03 },/* PREPLLCK_OP_DIV 0x03 = AUTO set */ + {0x0306 ,0x00 },/* PLL_VT_MPY */ + {0x0307 ,0x39 }, + {0x030b ,0x01 },/* OP_SYS_CLK_DIV */ + {0x030c ,0x00 },/* PLL_OP_MPY */ + {0x030d ,0x72 }, + +/* Undocumented registers */ + {0x455e ,0x00 }, + {0x471e ,0x4b }, + {0x4767 ,0x0f }, + {0x4750 ,0x14 }, + {0x4540 ,0x00 }, + {0x47b4 ,0x14 }, + {0x4713 ,0x30 }, + {0x478b ,0x10 }, + {0x478f ,0x10 }, + {0x4793 ,0x10 }, + {0x4797 ,0x0e }, + {0x479b ,0x0e }, + +/* Frame Bank Register Group "A" */ + {0x0162 ,0x0d },/* Line_Length_A */ + {0x0163 ,0x78 }, + {0x0170 ,0x01 },/* X_ODD_INC_A */ + {0x0171 ,0x01 },/* Y_ODD_INC_A */ + +/* Output setup registers */ + {0x0114 ,0x01 },/* CSI 2-Lane Mode */ + {0x0128 ,0x00 },/* DPHY Auto Mode */ + {0x012a ,0x18 },/* EXCK_Freq */ {0x012b ,0x00 }, +}; + +/* +* Register sets lifted off the i2C interface from the Raspberry Pi firmware +* driver. +* 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7. +*/ +static const struct imx219_reg mode_3280x2464_regs[] = { {0x0164 ,0x00 }, {0x0165 ,0x00 }, {0x0166 ,0x0c },
@@ -174,53 +212,15 @@ static const struct imx219_reg mode_3280x2464_regs[] = { {0x016d, 0xd0}, {0x016e, 0x09}, {0x016f, 0xa0}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x00}, + {0x0174, 0x00}, /* No-Binning */ {0x0175, 0x00}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x0c}, {0x0625, 0xd0}, {0x0626, 0x09}, {0x0627, 0xa0}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, - {0x0162, 0x0d}, - {0x0163, 0x78}, };static const struct imx219_reg mode_1920_1080_regs[] = { - {0x0100 ,0x00 }, - {0x30eb ,0x05 }, - {0x30eb ,0x0c }, - {0x300a ,0xff }, - {0x300b ,0xff }, - {0x30eb ,0x05 }, - {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, - {0x012b ,0x00 }, - {0x0162 ,0x0d }, - {0x0163 ,0x78 }, {0x0164 ,0x02 }, {0x0165 ,0xa8 }, {0x0166, 0x0a},
@@ -233,49 +233,15 @@ static const struct imx219_reg mode_1920_1080_regs[] = { {0x016d, 0x80}, {0x016e, 0x04}, {0x016f, 0x38}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x00}, + {0x0174, 0x00}, /* No-Binning */ {0x0175, 0x00}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x07}, {0x0625, 0x80}, {0x0626, 0x04}, {0x0627, 0x38}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, };static const struct imx219_reg mode_1640_1232_regs[] = { - {0x0100 ,0x00 }, - {0x30eb ,0x0c }, - {0x30eb ,0x05 }, - {0x300a ,0xff }, - {0x300b ,0xff }, - {0x30eb ,0x05 }, - {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, - {0x012b ,0x00 }, {0x0164 ,0x00 }, {0x0165 ,0x00 }, {0x0166, 0x0c},
@@ -288,53 +254,15 @@ static const struct imx219_reg mode_1640_1232_regs[] = { {0x016d, 0x68}, {0x016e, 0x04}, {0x016f, 0xd0}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x01}, + {0x0174, 0x01}, /* x2-Binning */ {0x0175, 0x01}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04}, {0x0627, 0xd0}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, - {0x0162, 0x0d}, - {0x0163, 0x78}, };static const struct imx219_reg mode_640_480_regs[] = { - {0x0100 ,0x00 }, - {0x30eb ,0x05 }, - {0x30eb ,0x0c }, - {0x300a ,0xff }, - {0x300b ,0xff }, - {0x30eb ,0x05 }, - {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, - {0x012b ,0x00 }, - {0x0162 ,0x0d }, - {0x0163 ,0x78 }, {0x0164 ,0x03 }, {0x0165 ,0xe8 }, {0x0166, 0x08},
@@ -347,35 +275,12 @@ static const struct imx219_reg mode_640_480_regs[] = { {0x016d, 0x80}, {0x016e, 0x01}, {0x016f, 0xe0}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x03}, + {0x0174, 0x03}, /* x2-analog binning */ {0x0175, 0x03}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04}, {0x0627, 0xd0}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, }; static const struct imx219_reg raw8_framefmt_regs[] = {
@@ -1041,6 +946,13 @@ static int imx219_start_streaming(struct imx219 *imx219)if (ret <0 )return ret; +/* Send all registers that are common to all modes */ + ret =imx219_write_regs (imx219, imx219_common_regs,ARRAY_SIZE (imx219_common_regs)); +if (ret) { +dev_err (&client->dev,"%s failed to send mfg header\n" , __func__); + goto err_rpm_put; + } +/* Apply default values of current mode */ reg_list = &imx219->mode->reg_list; ret =imx219_write_regs (imx219, reg_list->regs, reg_list->num_of_regs);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 356/567 media: i2c: imx219: Fix binning for RAW8 capture
In reply to Greg Kroah-HartmanFrom: Jai Luthra <[email protected]>
[ Upstream commit ef86447e775fb1f2ced00d4c7fff2c0a1c63f165 ]
2x2 binning works fine for RAW10 capture, but for RAW8 1232p mode it leads to corrupted frames [1][2].
Using the special 2x2 analog binning mode fixes the issue, but causes artefacts for RAW10 1232p capture. So here we choose the binning mode depending upon the frame format selected.
As both binning modes work fine for 480p RAW8 and RAW10 capture, it can share the same code path as 1232p for selecting binning mode.
[1] https://forums.raspberrypi.com/viewtopic.php?t=332103
[2] https://github.com/raspberrypi/libcamera-apps/issues/281
--- drivers/media/i2c/imx219.c | 57 ++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-)
drivers/media/i2c/imx219.c +49 -8
@@ -89,6 +89,12 @@#define IMX219_REG_ORIENTATION 0x0172 +/* Binning Mode */ +#define IMX219_REG_BINNING_MODE 0x0174 +#define IMX219_BINNING_NONE 0x0000 +#define IMX219_BINNING_2X2 0x0101 +#define IMX219_BINNING_2X2_ANALOG 0x0303 +/* Test Pattern Control */ #define IMX219_REG_TEST_PATTERN 0x0600#define IMX219_TEST_PATTERN_DISABLE 0
@@ -143,6 +149,9 @@ struct imx219_mode {/* Default register values */ struct imx219_reg_list reg_list; + +/* 2x2 binning is used */ +bool binning; };static const struct imx219_reg imx219_common_regs[] = {
@@ -212,8 +221,6 @@ static const struct imx219_reg mode_3280x2464_regs[] = { {0x016d, 0xd0}, {0x016e, 0x09}, {0x016f, 0xa0}, - {0x0174, 0x00}, /* No-Binning */ - {0x0175, 0x00}, {0x0624, 0x0c}, {0x0625, 0xd0}, {0x0626, 0x09},
@@ -233,8 +240,6 @@ static const struct imx219_reg mode_1920_1080_regs[] = { {0x016d, 0x80}, {0x016e, 0x04}, {0x016f, 0x38}, - {0x0174, 0x00}, /* No-Binning */ - {0x0175, 0x00}, {0x0624, 0x07}, {0x0625, 0x80}, {0x0626, 0x04},
@@ -254,8 +259,6 @@ static const struct imx219_reg mode_1640_1232_regs[] = { {0x016d, 0x68}, {0x016e, 0x04}, {0x016f, 0xd0}, - {0x0174, 0x01}, /* x2-Binning */ - {0x0175, 0x01}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04},
@@ -275,8 +278,6 @@ static const struct imx219_reg mode_640_480_regs[] = { {0x016d, 0x80}, {0x016e, 0x01}, {0x016f, 0xe0}, - {0x0174, 0x03}, /* x2-analog binning */ - {0x0175, 0x03}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04},
@@ -390,6 +391,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_3280x2464_regs), .regs = mode_3280x2464_regs, }, + .binning = false, }, {/* 1080P 30fps cropped */
@@ -406,6 +408,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_1920_1080_regs), .regs = mode_1920_1080_regs, }, + .binning = false, }, {/* 2x2 binned 30fps mode */
@@ -422,6 +425,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_1640_1232_regs), .regs = mode_1640_1232_regs, }, + .binning = true, }, {/* 640x480 30fps mode */
@@ -438,6 +442,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_640_480_regs), .regs = mode_640_480_regs, }, + .binning = true, }, };
@@ -884,6 +889,35 @@ static int imx219_set_framefmt(struct imx219 *imx219)return -EINVAL ; } +static int imx219_set_binning (struct imx219 *imx219) +{ +if (!imx219->mode->binning) { +return imx219_write_reg (imx219,IMX219_REG_BINNING_MODE , +IMX219_REG_VALUE_16BIT , +IMX219_BINNING_NONE ); + } + +switch (imx219->fmt.code) { +case MEDIA_BUS_FMT_SRGGB8_1X8 : +case MEDIA_BUS_FMT_SGRBG8_1X8 : +case MEDIA_BUS_FMT_SGBRG8_1X8 : +case MEDIA_BUS_FMT_SBGGR8_1X8 : +return imx219_write_reg (imx219,IMX219_REG_BINNING_MODE , +IMX219_REG_VALUE_16BIT , +IMX219_BINNING_2X2_ANALOG ); + +case MEDIA_BUS_FMT_SRGGB10_1X10 : +case MEDIA_BUS_FMT_SGRBG10_1X10 : +case MEDIA_BUS_FMT_SGBRG10_1X10 : +case MEDIA_BUS_FMT_SBGGR10_1X10 : +return imx219_write_reg (imx219,IMX219_REG_BINNING_MODE , +IMX219_REG_VALUE_16BIT , +IMX219_BINNING_2X2 ); + } + +return -EINVAL ; +} +static const struct v4l2_rect * __imx219_get_pad_crop(struct imx219 *imx219, struct v4l2_subdev_state *sd_state,
@@ -968,6 +1002,13 @@ static int imx219_start_streaming(struct imx219 *imx219) goto err_rpm_put; } + ret =imx219_set_binning (imx219); +if (ret) { +dev_err (&client->dev,"%s failed to set binning: %d\n" , + __func__, ret); + goto err_rpm_put; + } +/* Apply customized values from user */ ret =__v4l2_ctrl_handler_setup (imx219->sd.ctrl_handler);if (ret)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 357/567 media: v4l2-jpeg: correct the skip count in jpeg_parse_app14_data
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 41959c4f973b837a12061b84d3a436fc64c73a30 ]
The curr pointer has advanced 14 bytes in jpeg_parse_app14_data.
1. jpeg_get_word_be(stream), it goes forward 2 bytes.
2. jpeg_skip(stream, 11), it goes forward 11 bytes.
3. jpeg_get_byte(stream), it goes forward 1 bytes.
so the remain bytes of this segment should be (lp - 2 - 11 - 1), but not (lp - 2 - 11).
if driver skip 1 extra bytes, the following parsing may go wrong.
--- drivers/media/v4l2-core/v4l2-jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-jpeg.c +1 -1
@@ -474,7 +474,7 @@ static int jpeg_parse_app14_data(struct jpeg_stream *stream, *tf = ret;/* skip the rest of the segment, this ensures at least it is complete */ - skip = lp -2 -11 ; + skip = lp -2 -11 -1 ;return jpeg_skip (stream, skip); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 358/567 media: v4l2-jpeg: ignore the unknown APP14 marker
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 251c0ea6efd3c3ea0f8a55fdd96c749a98639bd3 ]
The legal identifier of APP14 is "Adobe\0",
but sometimes it may be
"This is an unknown APP marker . Compliant decoders must ignore it." In this case, just ignore it.
It won't affect the decode result.
--- drivers/media/v4l2-core/v4l2-jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-jpeg.c +1 -1
@@ -460,7 +460,7 @@ static int jpeg_parse_app14_data(struct jpeg_stream *stream,/* Check for "Adobe\0" in Ap1..6 */ if (stream->curr +6 > stream->end ||strncmp (stream->curr,"Adobe\0" ,6 )) -return -EINVAL ; +return jpeg_skip (stream, lp -2 );/* get to Ap12 */ ret =jpeg_skip (stream,11 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 359/567 media: imx-jpeg: Apply clk_bulk api instead of operating specific clk
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 61fe43dc9f454bc3caa99dbdd8f5fa3ba813981a ]
using the api of clk_bulk can simplify the code. and the clock of the jpeg codec may be changed, the clk_bulk api can be compatible with the future change.
--- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 35 +++++----------------- drivers/media/platform/imx-jpeg/mxc-jpeg.h | 4 +-- 2 files changed, 10 insertions(+), 29 deletions(-)
drivers/media/platform/imx-jpeg/mxc-jpeg.c +8 -27
@@ -2105,19 +2105,12 @@ static int mxc_jpeg_probe(struct platform_device *pdev) jpeg->mode = mode;/* Get clocks */ - jpeg->clk_ipg =devm_clk_get (dev,"ipg" ); -if (IS_ERR (jpeg->clk_ipg)) { -dev_err (dev,"failed to get clock: ipg\n" ); - ret =PTR_ERR (jpeg->clk_ipg); - goto err_clk; - } - - jpeg->clk_per =devm_clk_get (dev,"per" ); -if (IS_ERR (jpeg->clk_per)) { -dev_err (dev,"failed to get clock: per\n" ); - ret =PTR_ERR (jpeg->clk_per); + ret =devm_clk_bulk_get_all (&pdev->dev, &jpeg->clks); +if (ret <0 ) { +dev_err (dev,"failed to get clock\n" ); goto err_clk; } + jpeg->num_clks = ret; ret =mxc_jpeg_attach_pm_domains (jpeg);if (ret <0 ) {
@@ -2214,32 +2207,20 @@ static int mxc_jpeg_runtime_resume(struct device *dev)struct mxc_jpeg_dev *jpeg =dev_get_drvdata (dev);int ret; - ret =clk_prepare_enable (jpeg->clk_ipg); -if (ret <0 ) { -dev_err (dev,"failed to enable clock: ipg\n" ); - goto err_ipg; - } - - ret =clk_prepare_enable (jpeg->clk_per); + ret =clk_bulk_prepare_enable (jpeg->num_clks, jpeg->clks);if (ret <0 ) { -dev_err (dev,"failed to enable clock: per\n" ); - goto err_per; +dev_err (dev,"failed to enable clock\n" ); +return ret; }return 0 ; - -err_per: -clk_disable_unprepare (jpeg->clk_ipg); -err_ipg: -return ret; }static int mxc_jpeg_runtime_suspend (struct device *dev) {struct mxc_jpeg_dev *jpeg =dev_get_drvdata (dev); -clk_disable_unprepare (jpeg->clk_ipg); -clk_disable_unprepare (jpeg->clk_per); +clk_bulk_disable_unprepare (jpeg->num_clks, jpeg->clks);return 0 ; }
drivers/media/platform/imx-jpeg/mxc-jpeg.h +2 -2
@@ -112,8 +112,8 @@ struct mxc_jpeg_dev {spinlock_t hw_lock;/* hardware access lock */ unsigned int mode;struct mutex lock;/* v4l2 ioctls serialization */ -struct clk *clk_ipg; -struct clk *clk_per; +struct clk_bulk_data *clks; +int num_clks;struct platform_device *pdev;struct device *dev;void __iomem *base_reg;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 360/567 media: rc: Fix use-after-free bugs caused by ene_tx_irqsim()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 29b0589a865b6f66d141d79b2dd1373e4e50fe17 ]
When the ene device is detaching, function ene_remove() will be called. But there is no function to cancel tx_sim_timer in ene_remove(), the timer handler ene_tx_irqsim() could race with ene_remove(). As a result, the UAF bugs could happen, the process is shown below.
(cleanup routine) | (timer routine)
| mod_timer(&dev->tx_sim_timer, ..)
ene_remove() | (wait a time)
| ene_tx_irqsim()
| dev->hw_lock //USE
| ene_tx_sample(dev) //USEFix by adding del_timer_sync(&dev->tx_sim_timer) in ene_remove(), The tx_sim_timer could stop before ene device is deallocated.
What's more, The rc_unregister_device() and del_timer_sync() should be called first in ene_remove() and the deallocated functions such as free_irq(), release_region() and so on should be called behind them. Because the rc_unregister_device() is well synchronized. Otherwise, race conditions may happen. The situations that may lead to race conditions are shown below.
Firstly, the rx receiver is disabled with ene_rx_disable() before rc_unregister_device() in ene_remove(), which means it can be enabled again if a process opens /dev/lirc0 between ene_rx_disable() and rc_unregister_device().
Secondly, the irqaction descriptor is freed by free_irq() before the rc device is unregistered, which means irqaction descriptor may be accessed again after it is deallocated.
Thirdly, the timer can call ene_tx_sample() that can write to the io ports, which means the io ports could be accessed again after they are deallocated by release_region().
Therefore, the rc_unregister_device() and del_timer_sync() should be called first in ene_remove().
Suggested by: Sean Young <[email protected]>
--- drivers/media/rc/ene_ir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/rc/ene_ir.c +2 -1
@@ -1106,6 +1106,8 @@ static void ene_remove(struct pnp_dev *pnp_dev)struct ene_device *dev =pnp_get_drvdata (pnp_dev);unsigned long flags; +rc_unregister_device (dev->rdev); +del_timer_sync (&dev->tx_sim_timer);spin_lock_irqsave (&dev->hw_lock, flags);ene_rx_disable (dev);ene_rx_restore_hw_buffer (dev);
@@ -1113,7 +1115,6 @@ static void ene_remove(struct pnp_dev *pnp_dev)free_irq (dev->irq, dev);release_region (dev->hw_io,ENE_IO_SIZE ); -rc_unregister_device (dev->rdev);kfree (dev); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 361/567 media: i2c: ov7670: 0 instead of -EINVAL was returned
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 6a4c664539e6de9b32b65ddcf767ec1bcc1d7f8a ]
If the media bus is unsupported, then return -EINVAL. Instead it returned 'ret' which happened to be 0.
This fixes a smatch warning:
ov7670.c:1843 ov7670_parse_dt() warn: missing error code? 'ret'
--- drivers/media/i2c/ov7670.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov7670.c +1 -1
@@ -1841,7 +1841,7 @@ static int ov7670_parse_dt(struct device *dev,if (bus_cfg.bus_type !=V4L2_MBUS_PARALLEL ) {dev_err (dev,"Unsupported media bus type\n" ); -return ret; +return -EINVAL ; } info->mbus_config = bus_cfg.bus.parallel.flags;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 362/567 media: usb: siano: Fix use after free bugs caused by do_submit_urb
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit ebad8e731c1c06adf04621d6fd327b860c0861b5 ]
There are UAF bugs caused by do_submit_urb(). One of the KASan reports is shown below:
[ 36.403605] BUG: KASAN: use-after-free in worker_thread+0x4a2/0x890 [ 36.406105] Read of size 8 at addr ffff8880059600e8 by task kworker/0:2/49 [ 36.408316] [ 36.408867] CPU: 0 PID: 49 Comm: kworker/0:2 Not tainted 6.2.0-rc3-15798-g5a41237ad1d4-dir8 [ 36.411696] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g15584 [ 36.416157] Workqueue: 0x0 (events) [ 36.417654] Call Trace: [ 36.418546] <TASK> [ 36.419320] dump_stack_lvl+0x96/0xd0 [ 36.420522] print_address_description+0x75/0x350 [ 36.421992] print_report+0x11b/0x250 [ 36.423174] ? _raw_spin_lock_irqsave+0x87/0xd0 [ 36.424806] ? __virt_addr_valid+0xcf/0x170 [ 36.426069] ? worker_thread+0x4a2/0x890 [ 36.427355] kasan_report+0x131/0x160 [ 36.428556] ? worker_thread+0x4a2/0x890 [ 36.430053] worker_thread+0x4a2/0x890 [ 36.431297] ? worker_clr_flags+0x90/0x90 [ 36.432479] kthread+0x166/0x190 [ 36.433493] ? kthread_blkcg+0x50/0x50 [ 36.434669] ret_from_fork+0x22/0x30 [ 36.435923] </TASK> [ 36.436684] [ 36.437215] Allocated by task 24: [ 36.438289] kasan_set_track+0x50/0x80 [ 36.439436] __kasan_kmalloc+0x89/0xa0 [ 36.440566] smsusb_probe+0x374/0xc90 [ 36.441920] usb_probe_interface+0x2d1/0x4c0 [ 36.443253] really_probe+0x1d5/0x580 [ 36.444539] __driver_probe_device+0xe3/0x130 [ 36.446085] driver_probe_device+0x49/0x220 [ 36.447423] __device_attach_driver+0x19e/0x1b0 [ 36.448931] bus_for_each_drv+0xcb/0x110 [ 36.450217] __device_attach+0x132/0x1f0 [ 36.451470] bus_probe_device+0x59/0xf0 [ 36.452563] device_add+0x4ec/0x7b0 [ 36.453830] usb_set_configuration+0xc63/0xe10 [ 36.455230] usb_generic_driver_probe+0x3b/0x80 [ 36.456166] printk: console [ttyGS0] disabled [ 36.456569] usb_probe_device+0x90/0x110 [ 36.459523] really_probe+0x1d5/0x580 [ 36.461027] __driver_probe_device+0xe3/0x130 [ 36.462465] driver_probe_device+0x49/0x220 [ 36.463847] __device_attach_driver+0x19e/0x1b0 [ 36.465229] bus_for_each_drv+0xcb/0x110 [ 36.466466] __device_attach+0x132/0x1f0 [ 36.467799] bus_probe_device+0x59/0xf0 [ 36.469010] device_add+0x4ec/0x7b0 [ 36.470125] usb_new_device+0x863/0xa00 [ 36.471374] hub_event+0x18c7/0x2220 [ 36.472746] process_one_work+0x34c/0x5b0 [ 36.474041] worker_thread+0x4b7/0x890 [ 36.475216] kthread+0x166/0x190 [ 36.476267] ret_from_fork+0x22/0x30 [ 36.477447] [ 36.478160] Freed by task 24: [ 36.479239] kasan_set_track+0x50/0x80 [ 36.480512] kasan_save_free_info+0x2b/0x40 [ 36.481808] ____kasan_slab_free+0x122/0x1a0 [ 36.483173] __kmem_cache_free+0xc4/0x200 [ 36.484563] smsusb_term_device+0xcd/0xf0 [ 36.485896] smsusb_probe+0xc85/0xc90 [ 36.486976] usb_probe_interface+0x2d1/0x4c0 [ 36.488303] really_probe+0x1d5/0x580 [ 36.489498] __driver_probe_device+0xe3/0x130 [ 36.491140] driver_probe_device+0x49/0x220 [ 36.492475] __device_attach_driver+0x19e/0x1b0 [ 36.493988] bus_for_each_drv+0xcb/0x110 [ 36.495171] __device_attach+0x132/0x1f0 [ 36.496617] bus_probe_device+0x59/0xf0 [ 36.497875] device_add+0x4ec/0x7b0 [ 36.498972] usb_set_configuration+0xc63/0xe10 [ 36.500264] usb_generic_driver_probe+0x3b/0x80 [ 36.501740] usb_probe_device+0x90/0x110 [ 36.503084] really_probe+0x1d5/0x580 [ 36.504241] __driver_probe_device+0xe3/0x130 [ 36.505548] driver_probe_device+0x49/0x220 [ 36.506766] __device_attach_driver+0x19e/0x1b0 [ 36.508368] bus_for_each_drv+0xcb/0x110 [ 36.509646] __device_attach+0x132/0x1f0 [ 36.510911] bus_probe_device+0x59/0xf0 [ 36.512103] device_add+0x4ec/0x7b0 [ 36.513215] usb_new_device+0x863/0xa00 [ 36.514736] hub_event+0x18c7/0x2220 [ 36.516130] process_one_work+0x34c/0x5b0 [ 36.517396] worker_thread+0x4b7/0x890 [ 36.518591] kthread+0x166/0x190 [ 36.519599] ret_from_fork+0x22/0x30 [ 36.520851] [ 36.521405] Last potentially related work creation: [ 36.523143] kasan_save_stack+0x3f/0x60 [ 36.524275] kasan_record_aux_stack_noalloc+0x9d/0xb0 [ 36.525831] insert_work+0x25/0x130 [ 36.527039] __queue_work+0x4d4/0x620 [ 36.528236] queue_work_on+0x72/0xb0 [ 36.529344] __usb_hcd_giveback_urb+0x13f/0x1b0 [ 36.530819] dummy_timer+0x350/0x1a40 [ 36.532149] call_timer_fn+0x2c/0x190 [ 36.533567] expire_timers+0x69/0x1f0 [ 36.534736] __run_timers+0x289/0x2d0 [ 36.535841] run_timer_softirq+0x2d/0x60 [ 36.537110] __do_softirq+0x116/0x380 [ 36.538377] [ 36.538950] Second to last potentially related work creation: [ 36.540855] kasan_save_stack+0x3f/0x60 [ 36.542084] kasan_record_aux_stack_noalloc+0x9d/0xb0 [ 36.543592] insert_work+0x25/0x130 [ 36.544891] __queue_work+0x4d4/0x620 [ 36.546168] queue_work_on+0x72/0xb0 [ 36.547328] __usb_hcd_giveback_urb+0x13f/0x1b0 [ 36.548805] dummy_timer+0x350/0x1a40 [ 36.550116] call_timer_fn+0x2c/0x190 [ 36.551570] expire_timers+0x69/0x1f0 [ 36.552762] __run_timers+0x289/0x2d0 [ 36.553916] run_timer_softirq+0x2d/0x60 [ 36.555118] __do_softirq+0x116/0x380 [ 36.556239] [ 36.556807] The buggy address belongs to the object at ffff888005960000 [ 36.556807] which belongs to the cache kmalloc-4k of size 4096 [ 36.560652] The buggy address is located 232 bytes inside of [ 36.560652] 4096-byte region [ffff888005960000, ffff888005961000) [ 36.564791] [ 36.565355] The buggy address belongs to the physical page: [ 36.567212] page:000000004f0a0731 refcount:1 mapcount:0 mapping:0000000000000000 index:0x00 [ 36.570534] head:000000004f0a0731 order:3 compound_mapcount:0 subpages_mapcount:0 compound0 [ 36.573717] flags: 0x100000000010200(slab|head|node=0|zone=1) [ 36.575481] raw: 0100000000010200 ffff888001042140 dead000000000122 0000000000000000 [ 36.577842] raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000 [ 36.580175] page dumped because: kasan: bad access detected [ 36.581994] [ 36.582548] Memory state around the buggy address: [ 36.583983] ffff88800595ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 36.586240] ffff888005960000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.588884] >ffff888005960080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.591071] ^ [ 36.593295] ffff888005960100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.595705] ffff888005960180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.598026] ================================================================== [ 36.600224] Disabling lock debugging due to kernel taint [ 36.602681] general protection fault, probably for non-canonical address 0x43600a000000060I [ 36.607129] CPU: 0 PID: 49 Comm: kworker/0:2 Tainted: G B 6.2.0-rc3-15798-8 [ 36.611115] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g15584 [ 36.615026] Workqueue: events do_submit_urb [ 36.616290] RIP: 0010:_raw_spin_lock_irqsave+0x8a/0xd0 [ 36.618107] Code: 24 00 00 00 00 48 89 df be 04 00 00 00 e8 9e b5 c6 fe 48 89 ef be 04 00 5 [ 36.623522] RSP: 0018:ffff888004b6fcf0 EFLAGS: 00010046 [ 36.625072] RAX: 0000000000000000 RBX: 043600a000000060 RCX: ffffffff9fc0e0d7 [ 36.627206] RDX: 0000000000000000 RSI: dffffc0000000000 RDI: ffff888004b6fcf0 [ 36.629813] RBP: ffff888004b6fcf0 R08: dffffc0000000000 R09: ffffed100096df9f [ 36.631974] R10: dfffe9100096dfa0 R11: 1ffff1100096df9e R12: ffff888005960020 [ 36.634285] R13: ffff8880059600f0 R14: 0000000000000246 R15: 0000000000000001 [ 36.636438] FS: 0000000000000000(0000) GS:ffff88806d600000(0000) knlGS:0000000000000000 [ 36.639092] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.640951] CR2: 00007f07476819a3 CR3: 0000000004a34000 CR4: 00000000000006f0 [ 36.643411] Call Trace: [ 36.644215] <TASK> [ 36.644902] smscore_getbuffer+0x3e/0x1e0 [ 36.646147] do_submit_urb+0x4f/0x190 [ 36.647449] process_one_work+0x34c/0x5b0 [ 36.648777] worker_thread+0x4b7/0x890 [ 36.649984] ? worker_clr_flags+0x90/0x90 [ 36.651166] kthread+0x166/0x190 [ 36.652151] ? kthread_blkcg+0x50/0x50 [ 36.653547] ret_from_fork+0x22/0x30 [ 36.655051] </TASK> [ 36.655733] Modules linked in: [ 36.656787] ---[ end trace 0000000000000000 ]--- [ 36.658328] RIP: 0010:_raw_spin_lock_irqsave+0x8a/0xd0 [ 36.660045] Code: 24 00 00 00 00 48 89 df be 04 00 00 00 e8 9e b5 c6 fe 48 89 ef be 04 00 5 [ 36.665730] RSP: 0018:ffff888004b6fcf0 EFLAGS: 00010046 [ 36.667448] RAX: 0000000000000000 RBX: 043600a000000060 RCX: ffffffff9fc0e0d7 [ 36.669675] RDX: 0000000000000000 RSI: dffffc0000000000 RDI: ffff888004b6fcf0 [ 36.672645] RBP: ffff888004b6fcf0 R08: dffffc0000000000 R09: ffffed100096df9f [ 36.674921] R10: dfffe9100096dfa0 R11: 1ffff1100096df9e R12: ffff888005960020 [ 36.677034] R13: ffff8880059600f0 R14: 0000000000000246 R15: 0000000000000001 [ 36.679184] FS: 0000000000000000(0000) GS:ffff88806d600000(0000) knlGS:0000000000000000 [ 36.681655] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.683383] CR2: 00007f07476819a3 CR3: 0000000004a34000 CR4: 00000000000006f0 [ 36.685733] Kernel panic - not syncing: Fatal exception [ 36.688585] Kernel Offset: 0x1d400000 from 0xffffffff81000000 (relocation range: 0xfffffff) [ 36.692199] ---[ end Kernel panic - not syncing: Fatal exception ]---
When the siano device is plugged in, it may call the following functions to initialize the device.
smsusb_probe()-->smsusb_init_device()-->smscore_start_device().
When smscore_start_device() gets failed, the function smsusb_term_device() will be called and smsusb_device_t will be deallocated. Although we use usb_kill_urb() in smsusb_stop_streaming() to cancel transfer requests and wait for them to finish, the worker threads that are scheduled by smsusb_onresponse() may be still running. As a result, the UAF bugs could happen.
We add cancel_work_sync() in smsusb_stop_streaming() in order that the worker threads could finish before the smsusb_device_t is deallocated.
--- drivers/media/usb/siano/smsusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/siano/smsusb.c +1 -0
@@ -179,6 +179,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)for (i =0 ; i <MAX_URBS ; i++) {usb_kill_urb (&dev->surbs[i].urb); +cancel_work_sync (&dev->surbs[i].wq);if (dev->surbs[i].cb) {smscore_putbuffer (dev->coredev, dev->surbs[i].cb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 363/567 media: saa7134: Use video_unregister_device for radio_dev
In reply to Greg Kroah-HartmanFrom: Tasos Sahanidis <[email protected]>
[ Upstream commit bc7635c6435c77a0c168e2cc6535740adfaff4e4 ]
The radio device doesn't use vb2, thus calling vb2_video_unregister_device() which results in the following warning being printed on module unload.
WARNING: CPU: 1 PID: 215963 at drivers/media/common/videobuf2/videobuf2-v4l2.c:1236 vb2_video_unregister_device+0xc6/0xe0 [videobuf2_v4l2]
--- drivers/media/pci/saa7134/saa7134-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/saa7134/saa7134-core.c +1 -1
@@ -978,7 +978,7 @@ static void saa7134_unregister_video(struct saa7134_dev *dev) }if (dev->radio_dev) {if (video_is_registered (dev->radio_dev)) -vb2_video_unregister_device (dev->radio_dev); +video_unregister_device (dev->radio_dev);else video_device_release (dev->radio_dev); dev->radio_dev =NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 364/567 rpmsg: glink: Avoid infinite loop on intent for missing channel
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
[ Upstream commit 3e74ec2f39362bffbd42854acbb67c7f4cb808f9 ]
In the event that an intent advertisement arrives on an unknown channel the fifo is not advanced, resulting in the same message being handled over and over.
--- drivers/rpmsg/qcom_glink_native.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/qcom_glink_native.c +1 -0
@@ -929,6 +929,7 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,spin_unlock_irqrestore (&glink->idr_lock, flags);if (!channel) {dev_err (glink->dev,"intents for non-existing channel\n" ); +qcom_glink_rx_advance (glink,ALIGN (msglen,8 ));return ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 365/567 udf: Define EFSCORRUPTED error code
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit 3d2d7e61553dbcc8ba45201d8ae4f383742c8202 ]
Similarly to other filesystems define EFSCORRUPTED error code for reporting internal filesystem corruption.
--- fs/udf/udf_sb.h | 2 ++ 1 file changed, 2 insertions(+)
fs/udf/udf_sb.h +2 -0
@@ -51,6 +51,8 @@#define MF_DUPLICATE_MD 0x01#define MF_MIRROR_FE_LOADED 0x02 +#define EFSCORRUPTED EUCLEAN +struct udf_meta_data {__u32 s_meta_file_loc;__u32 s_mirror_file_loc;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 366/567 ARM: dts: exynos: Use Exynos5420 compatible for the MIPI video phy
In reply to Greg Kroah-HartmanFrom: Markuss Broks <[email protected]>
[ Upstream commit 5d5aa219a790d61cad2c38e1aa32058f16ad2f0b ]
For some reason, the driver adding support for Exynos5420 MIPI phy back in 2016 wasn't used on Exynos5420, which caused a kernel panic. Add the proper compatible for it.
--- arch/arm/boot/dts/exynos5420.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/exynos5420.dtsi +1 -1
@@ -602,7 +602,7 @@ dp_phy: dp-video-phy { }; mipi_phy: mipi-video-phy { - compatible = "samsung,s5pv210-mipi-video-phy"; + compatible = "samsung,exynos5420-mipi-video-phy"; syscon = <&pmu_system_controller>; #phy-cells = <1>; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 367/567 blk-iocost: fix divide by 0 error in calc_lcoefs()
In reply to Greg Kroah-HartmanFrom: Li Nan <[email protected]>
[ Upstream commit 984af1e66b4126cf145153661cc24c213e2ec231 ]
echo max of u64 to cost.model can cause divide by 0 error.
# echo 8:0 rbps=18446744073709551615 > /sys/fs/cgroup/io.cost.model
divide error: 0000 [#1] PREEMPT SMP
RIP: 0010:calc_lcoefs+0x4c/0xc0 Call Trace: <TASK> ioc_refresh_params+0x2b3/0x4f0 ioc_cost_model_write+0x3cb/0x4c0 ? _copy_from_iter+0x6d/0x6c0 ? kernfs_fop_write_iter+0xfc/0x270 cgroup_file_write+0xa0/0x200 kernfs_fop_write_iter+0x17d/0x270 vfs_write+0x414/0x620 ksys_write+0x73/0x160 __x64_sys_write+0x1e/0x30 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
calc_lcoefs() uses the input value of cost.model in DIV_ROUND_UP_ULL, overflow would happen if bps plus IOC_PAGE_SIZE is greater than ULLONG_MAX, it can cause divide by 0 error.
Fix the problem by setting basecost
--- block/blk-iocost.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
block/blk-iocost.c +8 -3
@@ -870,9 +870,14 @@ static void calc_lcoefs(u64 bps, u64 seqiops, u64 randiops, *page = *seqio = *randio =0 ; -if (bps) - *page =DIV64_U64_ROUND_UP (VTIME_PER_SEC , -DIV_ROUND_UP_ULL (bps,IOC_PAGE_SIZE )); +if (bps) { +u64 bps_pages =DIV_ROUND_UP_ULL (bps,IOC_PAGE_SIZE ); + +if (bps_pages) + *page =DIV64_U64_ROUND_UP (VTIME_PER_SEC , bps_pages); +else + *page =1 ; + }if (seqiops) { v =DIV64_U64_ROUND_UP (VTIME_PER_SEC , seqiops);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 368/567 trace/blktrace: fix memory leak with using debugfs_lookup()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 83e8864fee26f63a7435e941b7c36a20fd6fe93e ]
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.
--- kernel/trace/blktrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/blktrace.c +2 -2
@@ -319,8 +319,8 @@ static void blk_trace_free(struct request_queue *q, struct blk_trace *bt)* under 'q->debugfs_dir', thus lookup and remove them. */ if (!bt->dir) { -debugfs_remove (debugfs_lookup ("dropped" , q->debugfs_dir)); -debugfs_remove (debugfs_lookup ("msg" , q->debugfs_dir)); +debugfs_lookup_and_remove ("dropped" , q->debugfs_dir); +debugfs_lookup_and_remove ("msg" , q->debugfs_dir); }else {debugfs_remove (bt->dir); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 369/567 wifi: ath9k: Fix use-after-free in ath9k_hif_usb_disconnect()
In reply to Greg Kroah-HartmanFrom: Minsuk Kang <[email protected]>
[ Upstream commit f099c5c9e2ba08a379bd354a82e05ef839ae29ac ]
This patch fixes a use-after-free in ath9k that occurs in ath9k_hif_usb_disconnect() when ath9k_destroy_wmi() is trying to access 'drv_priv' that has already been freed by ieee80211_free_hw(), called by ath9k_htc_hw_deinit(). The patch moves ath9k_destroy_wmi() before ieee80211_free_hw(). Note that urbs from the driver should be killed before freeing 'wmi' with ath9k_destroy_wmi() as their callbacks will access 'wmi'.
Found by a modified version of syzkaller.
==================================================================
BUG: KASAN: use-after-free in ath9k_destroy_wmi+0x38/0x40
Read of size 8 at addr ffff8881069132a0 by task kworker/0:1/7
CPU: 0 PID: 7 Comm: kworker/0:1 Tainted: G O 5.14.0+ #131
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
Workqueue: usb_hub_wq hub_event
Call Trace:
dump_stack_lvl+0x8e/0xd1
print_address_description.constprop.0.cold+0x93/0x334
? ath9k_destroy_wmi+0x38/0x40
? ath9k_destroy_wmi+0x38/0x40
kasan_report.cold+0x83/0xdf
? ath9k_destroy_wmi+0x38/0x40
ath9k_destroy_wmi+0x38/0x40
ath9k_hif_usb_disconnect+0x329/0x3f0
? ath9k_hif_usb_suspend+0x120/0x120
? usb_disable_interface+0xfc/0x180
usb_unbind_interface+0x19b/0x7e0
? usb_autoresume_device+0x50/0x50
device_release_driver_internal+0x44d/0x520
bus_remove_device+0x2e5/0x5a0
device_del+0x5b2/0xe30
? __device_link_del+0x370/0x370
? usb_remove_ep_devs+0x43/0x80
? remove_intf_ep_devs+0x112/0x1a0
usb_disable_device+0x1e3/0x5a0
usb_disconnect+0x267/0x870
hub_event+0x168d/0x3950
? rcu_read_lock_sched_held+0xa1/0xd0
? hub_port_debounce+0x2e0/0x2e0
? check_irq_usage+0x860/0xf20
? drain_workqueue+0x281/0x360
? lock_release+0x640/0x640
? rcu_read_lock_sched_held+0xa1/0xd0
? rcu_read_lock_bh_held+0xb0/0xb0
? lockdep_hardirqs_on_prepare+0x273/0x3e0
process_one_work+0x92b/0x1460
? pwq_dec_nr_in_flight+0x330/0x330
? rwlock_bug.part.0+0x90/0x90
worker_thread+0x95/0xe00
? __kthread_parkme+0x115/0x1e0
? process_one_work+0x1460/0x1460
kthread+0x3a1/0x480
? set_kthread_struct+0x120/0x120
ret_from_fork+0x1f/0x30
The buggy address belongs to the page:
page:ffffea00041a44c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106913
flags: 0x200000000000000(node=0|zone=2)
raw: 0200000000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), pid 7, ts 38347963444, free_ts 41399957635
prep_new_page+0x1aa/0x240
get_page_from_freelist+0x159a/0x27c0
__alloc_pages+0x2da/0x6a0
alloc_pages+0xec/0x1e0
kmalloc_order+0x39/0xf0
kmalloc_order_trace+0x19/0x120
__kmalloc+0x308/0x390
wiphy_new_nm+0x6f5/0x1dd0
ieee80211_alloc_hw_nm+0x36d/0x2230
ath9k_htc_probe_device+0x9d/0x1e10
ath9k_htc_hw_init+0x34/0x50
ath9k_hif_usb_firmware_cb+0x25f/0x4e0
request_firmware_work_func+0x131/0x240
process_one_work+0x92b/0x1460
worker_thread+0x95/0xe00
kthread+0x3a1/0x480
page last free stack trace:
free_pcp_prepare+0x3d3/0x7f0
free_unref_page+0x1e/0x3d0
device_release+0xa4/0x240
kobject_put+0x186/0x4c0
put_device+0x20/0x30
ath9k_htc_disconnect_device+0x1cf/0x2c0
ath9k_htc_hw_deinit+0x26/0x30
ath9k_hif_usb_disconnect+0x2d9/0x3f0
usb_unbind_interface+0x19b/0x7e0
device_release_driver_internal+0x44d/0x520
bus_remove_device+0x2e5/0x5a0
device_del+0x5b2/0xe30
usb_disable_device+0x1e3/0x5a0
usb_disconnect+0x267/0x870
hub_event+0x168d/0x3950
process_one_work+0x92b/0x1460
Memory state around the buggy address:
ffff888106913180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888106913200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888106913280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888106913300: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888106913380: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================--- drivers/net/wireless/ath/ath9k/hif_usb.c | 2 -- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +0 -2
@@ -1424,8 +1424,6 @@ static void ath9k_hif_usb_disconnect(struct usb_interface *interface)if (hif_dev->flags &HIF_USB_READY ) {ath9k_htc_hw_deinit (hif_dev->htc_handle, unplugged); -ath9k_hif_usb_dev_deinit (hif_dev); -ath9k_destroy_wmi (hif_dev->htc_handle->drv_priv);ath9k_htc_hw_free (hif_dev->htc_handle); }
drivers/net/wireless/ath/ath9k/htc_drv_init.c +2 -0
@@ -988,6 +988,8 @@ void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug)ath9k_deinit_device (htc_handle->drv_priv);ath9k_stop_wmi (htc_handle->drv_priv); +ath9k_hif_usb_dealloc_urbs ((struct hif_device_usb *)htc_handle->hif_dev); +ath9k_destroy_wmi (htc_handle->drv_priv);ieee80211_free_hw (htc_handle->drv_priv->hw); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 370/567 wifi: brcmfmac: Fix potential stack-out-of-bounds in brcmf_c_preinit_dcmds()
In reply to Greg Kroah-HartmanFrom: Jisoo Jang <[email protected]>
[ Upstream commit 0a06cadcc2a0044e4a117cc0e61436fc3a0dad69 ]
This patch fixes a stack-out-of-bounds read in brcmfmac that occurs when 'buf' that is not null-terminated is passed as an argument of strsep() in brcmf_c_preinit_dcmds(). This buffer is filled with a firmware version string by memcpy() in brcmf_fil_iovar_data_get().
The patch ensures buf is null-terminated.
Found by a modified version of syzkaller.
[ 47.569679][ T1897] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43236b for chip BCM43236/3 [ 47.582839][ T1897] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available [ 47.601565][ T1897] ================================================================== [ 47.602574][ T1897] BUG: KASAN: stack-out-of-bounds in strsep+0x1b2/0x1f0 [ 47.603447][ T1897] Read of size 1 at addr ffffc90001f6f000 by task kworker/0:2/1897 [ 47.604336][ T1897] [ 47.604621][ T1897] CPU: 0 PID: 1897 Comm: kworker/0:2 Tainted: G O 5.14.0+ #131 [ 47.605617][ T1897] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [ 47.606907][ T1897] Workqueue: usb_hub_wq hub_event [ 47.607453][ T1897] Call Trace: [ 47.607801][ T1897] dump_stack_lvl+0x8e/0xd1 [ 47.608295][ T1897] print_address_description.constprop.0.cold+0xf/0x334 [ 47.609009][ T1897] ? strsep+0x1b2/0x1f0 [ 47.609434][ T1897] ? strsep+0x1b2/0x1f0 [ 47.609863][ T1897] kasan_report.cold+0x83/0xdf [ 47.610366][ T1897] ? strsep+0x1b2/0x1f0 [ 47.610882][ T1897] strsep+0x1b2/0x1f0 [ 47.611300][ T1897] ? brcmf_fil_iovar_data_get+0x3a/0xf0 [ 47.611883][ T1897] brcmf_c_preinit_dcmds+0x995/0xc40 [ 47.612434][ T1897] ? brcmf_c_set_joinpref_default+0x100/0x100 [ 47.613078][ T1897] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 47.613662][ T1897] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 47.614208][ T1897] ? lock_acquire+0x19d/0x4e0 [ 47.614704][ T1897] ? find_held_lock+0x2d/0x110 [ 47.615236][ T1897] ? brcmf_usb_deq+0x1a7/0x260 [ 47.615741][ T1897] ? brcmf_usb_rx_fill_all+0x5a/0xf0 [ 47.616288][ T1897] brcmf_attach+0x246/0xd40 [ 47.616758][ T1897] ? wiphy_new_nm+0x1703/0x1dd0 [ 47.617280][ T1897] ? kmemdup+0x43/0x50 [ 47.617720][ T1897] brcmf_usb_probe+0x12de/0x1690 [ 47.618244][ T1897] ? brcmf_usbdev_qinit.constprop.0+0x470/0x470 [ 47.618901][ T1897] usb_probe_interface+0x2aa/0x760 [ 47.619429][ T1897] ? usb_probe_device+0x250/0x250 [ 47.619950][ T1897] really_probe+0x205/0xb70 [ 47.620435][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.621048][ T1897] __driver_probe_device+0x311/0x4b0 [ 47.621595][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.622209][ T1897] driver_probe_device+0x4e/0x150 [ 47.622739][ T1897] __device_attach_driver+0x1cc/0x2a0 [ 47.623287][ T1897] bus_for_each_drv+0x156/0x1d0 [ 47.623796][ T1897] ? bus_rescan_devices+0x30/0x30 [ 47.624309][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.624907][ T1897] ? trace_hardirqs_on+0x46/0x160 [ 47.625437][ T1897] __device_attach+0x23f/0x3a0 [ 47.625924][ T1897] ? device_bind_driver+0xd0/0xd0 [ 47.626433][ T1897] ? kobject_uevent_env+0x287/0x14b0 [ 47.627057][ T1897] bus_probe_device+0x1da/0x290 [ 47.627557][ T1897] device_add+0xb7b/0x1eb0 [ 47.628027][ T1897] ? wait_for_completion+0x290/0x290 [ 47.628593][ T1897] ? __fw_devlink_link_to_suppliers+0x5a0/0x5a0 [ 47.629249][ T1897] usb_set_configuration+0xf59/0x16f0 [ 47.629829][ T1897] usb_generic_driver_probe+0x82/0xa0 [ 47.630385][ T1897] usb_probe_device+0xbb/0x250 [ 47.630927][ T1897] ? usb_suspend+0x590/0x590 [ 47.631397][ T1897] really_probe+0x205/0xb70 [ 47.631855][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.632469][ T1897] __driver_probe_device+0x311/0x4b0 [ 47.633002][ T1897] ? usb_generic_driver_match+0x75/0x90 [ 47.633573][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.634170][ T1897] driver_probe_device+0x4e/0x150 [ 47.634703][ T1897] __device_attach_driver+0x1cc/0x2a0 [ 47.635248][ T1897] bus_for_each_drv+0x156/0x1d0 [ 47.635748][ T1897] ? bus_rescan_devices+0x30/0x30 [ 47.636271][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.636881][ T1897] ? trace_hardirqs_on+0x46/0x160 [ 47.637396][ T1897] __device_attach+0x23f/0x3a0 [ 47.637904][ T1897] ? device_bind_driver+0xd0/0xd0 [ 47.638426][ T1897] ? kobject_uevent_env+0x287/0x14b0 [ 47.638985][ T1897] bus_probe_device+0x1da/0x290 [ 47.639512][ T1897] device_add+0xb7b/0x1eb0 [ 47.639977][ T1897] ? __fw_devlink_link_to_suppliers+0x5a0/0x5a0 [ 47.640612][ T1897] ? kfree+0x14a/0x6b0 [ 47.641055][ T1897] ? __usb_get_extra_descriptor+0x116/0x160 [ 47.641679][ T1897] usb_new_device.cold+0x49c/0x1029 [ 47.642245][ T1897] ? hub_disconnect+0x450/0x450 [ 47.642756][ T1897] ? rwlock_bug.part.0+0x90/0x90 [ 47.643273][ T1897] ? _raw_spin_unlock_irq+0x24/0x30 [ 47.643822][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.644445][ T1897] hub_event+0x1c98/0x3950 [ 47.644939][ T1897] ? hub_port_debounce+0x2e0/0x2e0 [ 47.645467][ T1897] ? check_irq_usage+0x861/0xf20 [ 47.645975][ T1897] ? drain_workqueue+0x280/0x360 [ 47.646506][ T1897] ? lock_release+0x640/0x640 [ 47.646994][ T1897] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 47.647572][ T1897] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 47.648111][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.648735][ T1897] process_one_work+0x92b/0x1460 [ 47.649262][ T1897] ? pwq_dec_nr_in_flight+0x330/0x330 [ 47.649816][ T1897] ? rwlock_bug.part.0+0x90/0x90 [ 47.650336][ T1897] worker_thread+0x95/0xe00 [ 47.650830][ T1897] ? __kthread_parkme+0x115/0x1e0 [ 47.651361][ T1897] ? process_one_work+0x1460/0x1460 [ 47.651904][ T1897] kthread+0x3a1/0x480 [ 47.652329][ T1897] ? set_kthread_struct+0x120/0x120 [ 47.652878][ T1897] ret_from_fork+0x1f/0x30 [ 47.653370][ T1897] [ 47.653608][ T1897] [ 47.653848][ T1897] addr ffffc90001f6f000 is located in stack of task kworker/0:2/1897 at offset 512 in frame: [ 47.654891][ T1897] brcmf_c_preinit_dcmds+0x0/0xc40 [ 47.655442][ T1897] [ 47.655690][ T1897] this frame has 4 objects: [ 47.656151][ T1897] [48, 56) 'ptr' [ 47.656159][ T1897] [80, 148) 'revinfo' [ 47.656534][ T1897] [192, 210) 'eventmask' [ 47.656953][ T1897] [256, 512) 'buf' [ 47.657410][ T1897] [ 47.658035][ T1897] Memory state around the buggy address: [ 47.658743][ T1897] ffffc90001f6ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 47.659577][ T1897] ffffc90001f6ef80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 47.660394][ T1897] >ffffc90001f6f000: f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00 [ 47.661199][ T1897] ^ [ 47.661625][ T1897] ffffc90001f6f080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 47.662455][ T1897] ffffc90001f6f100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 [ 47.663318][ T1897] ================================================================== [ 47.664147][ T1897] Disabling lock debugging due to kernel taint
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1 -0
@@ -264,6 +264,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) err); goto done; } + buf[sizeof (buf) -1 ] ='\0' ; ptr = (char *)buf;strsep (&ptr,"\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 371/567 rcu: Make RCU_LOCKDEP_WARN() avoid early lockdep checks
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 0cae5ded535c3a80aed94f119bbd4ee3ae284a65 ]
Currently, RCU_LOCKDEP_WARN() checks the condition before checking to see if lockdep is still enabled. This is necessary to avoid the false-positive splats fixed by commit 3066820034b5dd ("rcu: Reject RCU_LOCKDEP_WARN() false positives"). However, the current state can result in false-positive splats during early boot before lockdep is fully initialized. This commit therefore checks debug_lockdep_rcu_enabled() both before and after checking the condition, thus avoiding both sets of false-positive error reports.
--- include/linux/rcupdate.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
include/linux/rcupdate.h +8 -1
@@ -313,11 +313,18 @@ static inline int rcu_read_lock_any_held(void)* RCU_LOCKDEP_WARN - emit lockdep splat if specified condition is met * @c: condition to check * @s: informative message +* +* This checks debug_lockdep_rcu_enabled() before checking (c) to +* prevent early boot splats due to lockdep not yet being initialized, +* and rechecks it after checking (c) to prevent false-positive splats +* due to races with lockdep being disabled. See commit 3066820034b5dd +* ("rcu: Reject RCU_LOCKDEP_WARN() false positives") for more detail. */ #define RCU_LOCKDEP_WARN (c, s) \ do { \ static bool __section(".data.unlikely") __warned; \ - if ((c) && debug_lockdep_rcu_enabled() && !__warned) { \ + if (debug_lockdep_rcu_enabled() && (c) && \ + debug_lockdep_rcu_enabled() && !__warned) { \ __warned = true; \ lockdep_rcu_suspicious(__FILE__, __LINE__, s); \ } \
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 372/567 rcu: Suppress smp_processor_id() complaint in synchronize_rcu_expedited_wait()
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 2d7f00b2f01301d6e41fd4a28030dab0442265be ]
The normal grace period's RCU CPU stall warnings are invoked from the scheduling-clock interrupt handler, and can thus invoke smp_processor_id() with impunity, which allows them to directly invoke dump_cpu_task(). In contrast, the expedited grace period's RCU CPU stall warnings are invoked from process context, which causes the dump_cpu_task() function's calls to smp_processor_id() to complain bitterly in debug kernels.
This commit therefore causes synchronize_rcu_expedited_wait() to disable preemption around its call to dump_cpu_task().
--- kernel/rcu/tree_exp.h | 2 ++ 1 file changed, 2 insertions(+)
kernel/rcu/tree_exp.h +2 -0
@@ -565,7 +565,9 @@ static void synchronize_rcu_expedited_wait(void) mask =leaf_node_cpu_bit (rnp, cpu);if (!(READ_ONCE (rnp->expmask) & mask))continue ; +preempt_disable ();// For smp_processor_id() in dump_cpu_task(). dump_cpu_task (cpu); +preempt_enable (); } } jiffies_stall =3 *rcu_jiffies_till_stall_check () +3 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 373/567 rcu-tasks: Make rude RCU-Tasks work well with CPU hotplug
In reply to Greg Kroah-HartmanFrom: Zqiang <[email protected]>
[ Upstream commit ea5c8987fef20a8cca07e428aa28bc64649c5104 ]
The synchronize_rcu_tasks_rude() function invokes rcu_tasks_rude_wait_gp() to wait one rude RCU-tasks grace period. The rcu_tasks_rude_wait_gp() function in turn checks if there is only a single online CPU. If so, it will immediately return, because a call to synchronize_rcu_tasks_rude() is by definition a grace period on a single-CPU system. (We could have blocked!)
Unfortunately, this check uses num_online_cpus() without synchronization, which can result in too-short grace periods. To see this, consider the following scenario:
CPU0 CPU1 (going offline)
migration/1 task:
cpu_stopper_thread
-> take_cpu_down
-> _cpu_disable
(dec __num_online_cpus)
->cpuhp_invoke_callback
preempt_disable
access old_data0
task1
del old_data0 .....
synchronize_rcu_tasks_rude()
task1 schedule out
....
task2 schedule in
rcu_tasks_rude_wait_gp()
->__num_online_cpus == 1
->return ....
task1 schedule in
->free old_data0
preempt_enable
When CPU1 decrements __num_online_cpus, its value becomes 1. However, CPU1 has not finished going offline, and will take one last trip through the scheduler and the idle loop before it actually stops executing instructions. Because synchronize_rcu_tasks_rude() is mostly used for tracing, and because both the scheduler and the idle loop can be traced, this means that CPU0's prematurely ended grace period might disrupt the tracing on CPU1. Given that this disruption might include CPU1 executing instructions in memory that was just now freed (and maybe reallocated), this is a matter of some concern.
This commit therefore removes that problematic single-CPU check from the rcu_tasks_rude_wait_gp() function. This dispenses with the single-CPU optimization, but there is no evidence indicating that this optimization is important. In addition, synchronize_rcu_tasks_generic() contains a similar optimization (albeit only for early boot), which also splats. (As in exactly why are you invoking synchronize_rcu_tasks_rude() so early in boot, anyway???)
It is OK for the synchronize_rcu_tasks_rude() function's check to be unsynchronized because the only times that this check can evaluate to true is when there is only a single CPU running with preemption disabled.
While in the area, this commit also fixes a minor bug in which a call to synchronize_rcu_tasks_rude() would instead be attributed to synchronize_rcu_tasks().
[ paulmck: Add "synchronize_" prefix and "()" suffix. ]
--- kernel/rcu/tasks.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/rcu/tasks.h +3 -5
@@ -171,8 +171,9 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,static void synchronize_rcu_tasks_generic (struct rcu_tasks *rtp) {/* Complain if the scheduler has not started. */ -WARN_ONCE (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE , -"synchronize_rcu_tasks called too soon" ); +if (WARN_ONCE (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE , +"synchronize_%s() called too soon" , rtp->name)) +return ;/* Wait for the grace period. */ wait_rcu_gp (rtp->call_func);
@@ -688,9 +689,6 @@ static void rcu_tasks_be_rude(struct work_struct *work)// Wait for one rude RCU-tasks grace period. static void rcu_tasks_rude_wait_gp (struct rcu_tasks *rtp) { -if (num_online_cpus () <=1 ) -return ;// Fastpath for only one CPU. - rtp->n_ipis +=cpumask_weight (cpu_online_mask);schedule_on_each_cpu (rcu_tasks_be_rude); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 374/567 wifi: ath11k: debugfs: fix to work with multiple PCI devices
In reply to Greg Kroah-HartmanFrom: Kalle Valo <[email protected]>
[ Upstream commit 323d91d4684d238f6bc3693fed93caf795378fe0 ]
ath11k fails to load if there are multiple ath11k PCI devices with same name:
ath11k_pci 0000:01:00.0: Hardware name qcn9074 hw1.0
debugfs: Directory 'ath11k' with parent '/' already present! ath11k_pci 0000:01:00.0: failed to create ath11k debugfs ath11k_pci 0000:01:00.0: failed to create soc core: -17 ath11k_pci 0000:01:00.0: failed to init core: -17
ath11k_pci: probe of 0000:01:00.0 failed with error -17
Fix this by creating a directory for each ath11k device using schema <bus>-<devname>, for example "pci-0000:06:00.0". This directory created under the top-level ath11k directory, for example /sys/kernel/debug/ath11k.
The reference to the toplevel ath11k directory is not stored anymore within ath11k, instead it's retrieved using debugfs_lookup(). If the directory does not exist it will be created. After the last directory from the ath11k directory is removed, for example when doing rmmod ath11k, the empty ath11k directory is left in place, it's a minor cosmetic issue anyway.
Here's an example hierarchy with one WCN6855:
ath11k
`-- pci-0000:06:00.0
|-- mac0
| |-- dfs_block_radar_events
| |-- dfs_simulate_radar
| |-- ext_rx_stats
| |-- ext_tx_stats
| |-- fw_dbglog_config
| |-- fw_stats
| | |-- beacon_stats
| | |-- pdev_stats
| | `-- vdev_stats
| |-- htt_stats
| |-- htt_stats_reset
| |-- htt_stats_type
| `-- pktlog_filter
|-- simulate_fw_crash
`-- soc_dp_statsI didn't have a test setup where I could connect multiple ath11k devices to the same the host, so I have only tested this with one device.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.9
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/core.h | 1 - drivers/net/wireless/ath/ath11k/debugfs.c | 48 +++++++++++++++++++---- 2 files changed, 40 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +0 -1
@@ -731,7 +731,6 @@ struct ath11k_base {enum ath11k_dfs_region dfs_region;#ifdef CONFIG_ATH11K_DEBUGFS struct dentry *debugfs_soc; -struct dentry *debugfs_ath11k;#endif struct ath11k_soc_dp_stats soc_stats;
drivers/net/wireless/ath/ath11k/debugfs.c +40 -8
65 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 375/567 thermal: intel: Fix unsigned comparison with less than zero
In reply to Greg Kroah-HartmanFrom: Yang Li <[email protected]>
[ Upstream commit e7fcfe67f9f410736b758969477b17ea285e8e6c ]
The return value from the call to intel_tcc_get_tjmax() is int, which can be a negative error code. However, the return value is being assigned to an u32 variable 'tj_max', so making 'tj_max' an int.
Eliminate the following warning:
./drivers/thermal/intel/intel_soc_dts_iosf.c:394:5-11: WARNING: Unsigned expression compared with zero: tj_max < 0
--- drivers/thermal/intel/intel_soc_dts_iosf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/intel_soc_dts_iosf.c +1 -1
@@ -405,7 +405,7 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init( {struct intel_soc_dts_sensors *sensors;bool notification; -u32 tj_max; +int tj_max;int ret;int i;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 376/567 timers: Prevent union confusion from unexpected restart_syscall()
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
[ Upstream commit 9f76d59173d9d146e96c66886b671c1915a5c5e5 ]
The nanosleep syscalls use the restart_block mechanism, with a quirk:
The type and rmtp/compat_rmtp fields are set up unconditionally on syscall entry, while the rest of the restart_block is only set up in the unlikely case that the syscall is actually interrupted by a signal (or pseudo-signal) that doesn't have a signal handler.
If the restart_block was set up by a previous syscall (futex(..., FUTEX_WAIT, ...) or poll()) and hasn't been invalidated somehow since then, this will clobber some of the union fields used by futex_wait_restart() and do_restart_poll().
If userspace afterwards wrongly calls the restart_syscall syscall, futex_wait_restart()/do_restart_poll() will read struct fields that have been clobbered.
This doesn't actually lead to anything particularly interesting because none of the union fields contain trusted kernel data, and futex(..., FUTEX_WAIT, ...) and poll() aren't syscalls where it makes much sense to apply seccomp filters to their arguments.
So the current consequences are just of the "if userspace does bad stuff, it can damage itself, and that's not a problem" flavor.
But still, it seems like a hazard for future developers, so invalidate the restart_block when partly setting it up in the nanosleep syscalls.
--- kernel/time/hrtimer.c | 2 ++ kernel/time/posix-stubs.c | 2 ++ kernel/time/posix-timers.c | 2 ++ 3 files changed, 6 insertions(+)
kernel/time/hrtimer.c +2 -0
@@ -2126,6 +2126,7 @@ SYSCALL_DEFINE2(nanosleep, struct __kernel_timespec __user *, rqtp,if (!timespec64_valid (&tu))return -EINVAL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_NATIVE :TT_NONE ; current->restart_block.nanosleep.rmtp = rmtp; return hrtimer_nanosleep(timespec64_to_ktime(tu), HRTIMER_MODE_REL,
@@ -2147,6 +2148,7 @@ SYSCALL_DEFINE2(nanosleep_time32, struct old_timespec32 __user *, rqtp,if (!timespec64_valid (&tu))return -EINVAL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_COMPAT :TT_NONE ; current->restart_block.nanosleep.compat_rmtp = rmtp; return hrtimer_nanosleep(timespec64_to_ktime(tu), HRTIMER_MODE_REL,
kernel/time/posix-stubs.c +2 -0
@@ -146,6 +146,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_NATIVE :TT_NONE ; current->restart_block.nanosleep.rmtp = rmtp; texp =timespec64_to_ktime (t);
@@ -239,6 +240,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_COMPAT :TT_NONE ; current->restart_block.nanosleep.compat_rmtp = rmtp; texp =timespec64_to_ktime (t);
kernel/time/posix-timers.c +2 -0
@@ -1270,6 +1270,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_NATIVE :TT_NONE ; current->restart_block.nanosleep.rmtp = rmtp;
@@ -1297,6 +1298,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_COMPAT :TT_NONE ; current->restart_block.nanosleep.compat_rmtp = rmtp;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 377/567 x86/bugs: Reset speculation control settings on init
In reply to Greg Kroah-HartmanFrom: Breno Leitao <[email protected]>
[ Upstream commit 0125acda7d76b943ca55811df40ed6ec0ecf670f ]
Currently, x86_spec_ctrl_base is read at boot time and speculative bits are set if Kconfig items are enabled. For example, IBRS is enabled if CONFIG_CPU_IBRS_ENTRY is configured, etc. These MSR bits are not cleared if the mitigations are disabled.
This is a problem when kexec-ing a kernel that has the mitigation disabled from a kernel that has the mitigation enabled. In this case, the MSR bits are not cleared during the new kernel boot. As a result, this might have some performance degradation that is hard to pinpoint.
This problem does not happen if the machine is (hard) rebooted because the bit will be cleared by default.
[ bp: Massage. ]
--- arch/x86/include/asm/msr-index.h | 4 ++++ arch/x86/kernel/cpu/bugs.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/include/asm/msr-index.h +4 -0
@@ -54,6 +54,10 @@#define SPEC_CTRL_RRSBA_DIS_S_SHIFT 6/* Disable RRSBA behavior */ #define SPEC_CTRL_RRSBA_DIS_S BIT(SPEC_CTRL_RRSBA_DIS_S_SHIFT) +/* A mask for bits which the kernel toggles when controlling mitigations */ +#define SPEC_CTRL_MITIGATIONS_MASK (SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_SSBD \ + | SPEC_CTRL_RRSBA_DIS_S) +#define MSR_IA32_PRED_CMD 0x00000049/* Prediction Command */ #define PRED_CMD_IBPB BIT(0)/* Indirect Branch Prediction Barrier */
arch/x86/kernel/cpu/bugs.c +9 -1
@@ -144,9 +144,17 @@ void __init check_bugs(void)* have unknown values. AMD64_LS_CFG MSR is cached in the early AMD * init code as it is not enumerated and depends on the family. */ -if (boot_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) +if (cpu_feature_enabled (X86_FEATURE_MSR_SPEC_CTRL )) {rdmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); +/* +* Previously running kernel (kexec), may have some controls +* turned ON. Clear them and let the mitigations setup below +* rediscover them based on configuration. +*/ + x86_spec_ctrl_base &= ~SPEC_CTRL_MITIGATIONS_MASK ; + } +/* Select the proper CPU mitigations before patching alternatives: */ spectre_v1_select_mitigation ();spectre_v2_select_mitigation ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 378/567 wifi: brcmfmac: ensure CLM version is null-terminated to prevent stack-out-of-bounds
In reply to Greg Kroah-HartmanFrom: Jisoo Jang <[email protected]>
[ Upstream commit 660145d708be52f946a82e5b633c020f58f996de ]
Fix a stack-out-of-bounds read in brcmfmac that occurs when 'buf' that is not null-terminated is passed as an argument of strreplace() in brcmf_c_preinit_dcmds(). This buffer is filled with a CLM version string by memcpy() in brcmf_fil_iovar_data_get(). Ensure buf is null-terminated.
Found by a modified version of syzkaller.
[ 33.004414][ T1896] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available [ 33.013486][ T1896] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43236/3 wl0: Nov 30 2011 17:33:42 version 5.90.188.22 [ 33.021554][ T1896] ================================================================== [ 33.022379][ T1896] BUG: KASAN: stack-out-of-bounds in strreplace+0xf2/0x110 [ 33.023122][ T1896] Read of size 1 at addr ffffc90001d6efc8 by task kworker/0:2/1896 [ 33.023852][ T1896] [ 33.024096][ T1896] CPU: 0 PID: 1896 Comm: kworker/0:2 Tainted: G O 5.14.0+ #132 [ 33.024927][ T1896] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [ 33.026065][ T1896] Workqueue: usb_hub_wq hub_event [ 33.026581][ T1896] Call Trace: [ 33.026896][ T1896] dump_stack_lvl+0x57/0x7d [ 33.027372][ T1896] print_address_description.constprop.0.cold+0xf/0x334 [ 33.028037][ T1896] ? strreplace+0xf2/0x110 [ 33.028403][ T1896] ? strreplace+0xf2/0x110 [ 33.028807][ T1896] kasan_report.cold+0x83/0xdf [ 33.029283][ T1896] ? strreplace+0xf2/0x110 [ 33.029666][ T1896] strreplace+0xf2/0x110 [ 33.029966][ T1896] brcmf_c_preinit_dcmds+0xab1/0xc40 [ 33.030351][ T1896] ? brcmf_c_set_joinpref_default+0x100/0x100 [ 33.030787][ T1896] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 33.031223][ T1896] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 33.031661][ T1896] ? lock_acquire+0x19d/0x4e0 [ 33.032091][ T1896] ? find_held_lock+0x2d/0x110 [ 33.032605][ T1896] ? brcmf_usb_deq+0x1a7/0x260 [ 33.033087][ T1896] ? brcmf_usb_rx_fill_all+0x5a/0xf0 [ 33.033582][ T1896] brcmf_attach+0x246/0xd40 [ 33.034022][ T1896] ? wiphy_new_nm+0x1476/0x1d50 [ 33.034383][ T1896] ? kmemdup+0x30/0x40 [ 33.034722][ T1896] brcmf_usb_probe+0x12de/0x1690 [ 33.035223][ T1896] ? brcmf_usbdev_qinit.constprop.0+0x470/0x470 [ 33.035833][ T1896] usb_probe_interface+0x25f/0x710 [ 33.036315][ T1896] really_probe+0x1be/0xa90 [ 33.036656][ T1896] __driver_probe_device+0x2ab/0x460 [ 33.037026][ T1896] ? usb_match_id.part.0+0x88/0xc0 [ 33.037383][ T1896] driver_probe_device+0x49/0x120 [ 33.037790][ T1896] __device_attach_driver+0x18a/0x250 [ 33.038300][ T1896] ? driver_allows_async_probing+0x120/0x120 [ 33.038986][ T1896] bus_for_each_drv+0x123/0x1a0 [ 33.039906][ T1896] ? bus_rescan_devices+0x20/0x20 [ 33.041412][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.041861][ T1896] ? trace_hardirqs_on+0x1c/0x120 [ 33.042330][ T1896] __device_attach+0x207/0x330 [ 33.042664][ T1896] ? device_bind_driver+0xb0/0xb0 [ 33.043026][ T1896] ? kobject_uevent_env+0x230/0x12c0 [ 33.043515][ T1896] bus_probe_device+0x1a2/0x260 [ 33.043914][ T1896] device_add+0xa61/0x1ce0 [ 33.044227][ T1896] ? __mutex_unlock_slowpath+0xe7/0x660 [ 33.044891][ T1896] ? __fw_devlink_link_to_suppliers+0x550/0x550 [ 33.045531][ T1896] usb_set_configuration+0x984/0x1770 [ 33.046051][ T1896] ? kernfs_create_link+0x175/0x230 [ 33.046548][ T1896] usb_generic_driver_probe+0x69/0x90 [ 33.046931][ T1896] usb_probe_device+0x9c/0x220 [ 33.047434][ T1896] really_probe+0x1be/0xa90 [ 33.047760][ T1896] __driver_probe_device+0x2ab/0x460 [ 33.048134][ T1896] driver_probe_device+0x49/0x120 [ 33.048516][ T1896] __device_attach_driver+0x18a/0x250 [ 33.048910][ T1896] ? driver_allows_async_probing+0x120/0x120 [ 33.049437][ T1896] bus_for_each_drv+0x123/0x1a0 [ 33.049814][ T1896] ? bus_rescan_devices+0x20/0x20 [ 33.050164][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.050579][ T1896] ? trace_hardirqs_on+0x1c/0x120 [ 33.050936][ T1896] __device_attach+0x207/0x330 [ 33.051399][ T1896] ? device_bind_driver+0xb0/0xb0 [ 33.051888][ T1896] ? kobject_uevent_env+0x230/0x12c0 [ 33.052314][ T1896] bus_probe_device+0x1a2/0x260 [ 33.052688][ T1896] device_add+0xa61/0x1ce0 [ 33.053121][ T1896] ? __fw_devlink_link_to_suppliers+0x550/0x550 [ 33.053568][ T1896] usb_new_device.cold+0x463/0xf66 [ 33.053953][ T1896] ? hub_disconnect+0x400/0x400 [ 33.054313][ T1896] ? rwlock_bug.part.0+0x90/0x90 [ 33.054661][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.055094][ T1896] hub_event+0x10d5/0x3330 [ 33.055530][ T1896] ? hub_port_debounce+0x280/0x280 [ 33.055934][ T1896] ? __lock_acquire+0x1671/0x5790 [ 33.056387][ T1896] ? wq_calc_node_cpumask+0x170/0x2a0 [ 33.056924][ T1896] ? lock_release+0x640/0x640 [ 33.057383][ T1896] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 33.057916][ T1896] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 33.058402][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.059019][ T1896] process_one_work+0x873/0x13e0 [ 33.059488][ T1896] ? lock_release+0x640/0x640 [ 33.059932][ T1896] ? pwq_dec_nr_in_flight+0x320/0x320 [ 33.060446][ T1896] ? rwlock_bug.part.0+0x90/0x90 [ 33.060898][ T1896] worker_thread+0x8b/0xd10 [ 33.061348][ T1896] ? __kthread_parkme+0xd9/0x1d0 [ 33.061810][ T1896] ? process_one_work+0x13e0/0x13e0 [ 33.062288][ T1896] kthread+0x379/0x450 [ 33.062660][ T1896] ? _raw_spin_unlock_irq+0x24/0x30 [ 33.063148][ T1896] ? set_kthread_struct+0x100/0x100 [ 33.063606][ T1896] ret_from_fork+0x1f/0x30 [ 33.064070][ T1896] [ 33.064313][ T1896] [ 33.064545][ T1896] addr ffffc90001d6efc8 is located in stack of task kworker/0:2/1896 at offset 512 in frame: [ 33.065478][ T1896] brcmf_c_preinit_dcmds+0x0/0xc40 [ 33.065973][ T1896] [ 33.066191][ T1896] this frame has 4 objects: [ 33.066614][ T1896] [48, 56) 'ptr' [ 33.066618][ T1896] [80, 148) 'revinfo' [ 33.066957][ T1896] [192, 210) 'eventmask' [ 33.067338][ T1896] [256, 512) 'buf' [ 33.067742][ T1896] [ 33.068304][ T1896] Memory state around the buggy address: [ 33.068838][ T1896] ffffc90001d6ee80: f2 00 00 02 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 [ 33.069545][ T1896] ffffc90001d6ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 33.070626][ T1896] >ffffc90001d6ef80: 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3 f3 [ 33.072052][ T1896] ^ [ 33.073043][ T1896] ffffc90001d6f000: f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 33.074230][ T1896] ffffc90001d6f080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 33.074914][ T1896] ================================================================== [ 33.075713][ T1896] Disabling lock debugging due to kernel taint
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +4 -2
@@ -281,15 +281,17 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)if (err) {brcmf_dbg (TRACE ,"retrieving clmver failed, %d\n" , err); }else { + buf[sizeof (buf) -1 ] ='\0' ; clmver = (char *)buf; -/* store CLM version for adding it to revinfo debugfs file */ -memcpy (ifp->drvr->clmver, clmver,sizeof (ifp->drvr->clmver));/* Replace all newline/linefeed characters with space * character */ strreplace (clmver,'\n' ,' ' ); +/* store CLM version for adding it to revinfo debugfs file */ +memcpy (ifp->drvr->clmver, clmver,sizeof (ifp->drvr->clmver)); +brcmf_dbg (INFO ,"CLM version = %s\n" , clmver); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 379/567 wifi: mt7601u: fix an integer underflow
In reply to Greg Kroah-HartmanFrom: Jisoo Jang <[email protected]>
[ Upstream commit 803f3176c5df3b5582c27ea690f204abb60b19b9 ]
Fix an integer underflow that leads to a null pointer dereference in 'mt7601u_rx_skb_from_seg()'. The variable 'dma_len' in the URB packet could be manipulated, which could trigger an integer underflow of 'seg_len' in 'mt7601u_rx_process_seg()'. This underflow subsequently causes the 'bad_frame' checks in 'mt7601u_rx_skb_from_seg()' to be bypassed, eventually leading to a dereference of the pointer 'p', which is a null pointer.
Ensure that 'dma_len' is greater than 'min_seg_len'.
Found by a modified version of syzkaller.
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 12 Comm: ksoftirqd/0 Tainted: G W O 5.14.0+ #139 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 RIP: 0010:skb_add_rx_frag+0x143/0x370 Code: e2 07 83 c2 03 38 ca 7c 08 84 c9 0f 85 86 01 00 00 4c 8d 7d 08 44 89 68 08 48 b8 00 00 00 00 00 fc ff df 4c 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 cd 01 00 00 48 8b 45 08 a8 01 0f 85 3d 01 00 00 RSP: 0018:ffffc900000cfc90 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: ffff888115520dc0 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff8881118430c0 RDI: ffff8881118430f8 RBP: 0000000000000000 R08: 0000000000000e09 R09: 0000000000000010 R10: ffff888111843017 R11: ffffed1022308602 R12: 0000000000000000 R13: 0000000000000e09 R14: 0000000000000010 R15: 0000000000000008 FS: 0000000000000000(0000) GS:ffff88811a800000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000004035af40 CR3: 00000001157f2000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace: mt7601u_rx_tasklet+0xc73/0x1270 ? mt7601u_submit_rx_buf.isra.0+0x510/0x510 ? tasklet_action_common.isra.0+0x79/0x2f0 tasklet_action_common.isra.0+0x206/0x2f0 __do_softirq+0x1b5/0x880 ? tasklet_unlock+0x30/0x30 run_ksoftirqd+0x26/0x50 smpboot_thread_fn+0x34f/0x7d0 ? smpboot_register_percpu_thread+0x370/0x370 kthread+0x3a1/0x480 ? set_kthread_struct+0x120/0x120 ret_from_fork+0x1f/0x30 Modules linked in: 88XXau(O) 88x2bu(O) ---[ end trace 57f34f93b4da0f9b ]--- RIP: 0010:skb_add_rx_frag+0x143/0x370 Code: e2 07 83 c2 03 38 ca 7c 08 84 c9 0f 85 86 01 00 00 4c 8d 7d 08 44 89 68 08 48 b8 00 00 00 00 00 fc ff df 4c 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 cd 01 00 00 48 8b 45 08 a8 01 0f 85 3d 01 00 00 RSP: 0018:ffffc900000cfc90 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: ffff888115520dc0 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff8881118430c0 RDI: ffff8881118430f8 RBP: 0000000000000000 R08: 0000000000000e09 R09: 0000000000000010 R10: ffff888111843017 R11: ffffed1022308602 R12: 0000000000000000 R13: 0000000000000e09 R14: 0000000000000010 R15: 0000000000000008 FS: 0000000000000000(0000) GS:ffff88811a800000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000004035af40 CR3: 00000001157f2000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
--- drivers/net/wireless/mediatek/mt7601u/dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt7601u/dma.c +2 -1
@@ -123,7 +123,8 @@ static u16 mt7601u_rx_next_seg_len(u8 *data, u32 data_len)if (data_len < min_seg_len ||WARN_ON_ONCE (!dma_len) ||WARN_ON_ONCE (dma_len +MT_DMA_HDRS > data_len) || -WARN_ON_ONCE (dma_len &0x3 )) +WARN_ON_ONCE (dma_len &0x3 ) || +WARN_ON_ONCE (dma_len < min_seg_len))return 0 ;return MT_DMA_HDRS + dma_len;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 380/567 inet: fix fast path in __inet_hash_connect()
In reply to Greg Kroah-HartmanFrom: Pietro Borrello <[email protected]>
[ Upstream commit 21cbd90a6fab7123905386985e3e4a80236b8714 ]
__inet_hash_connect() has a fast path taken if sk_head(&tb->owners) is equal to the sk parameter.sk_head() returns the hlist_entry() with respect to the sk_node field. However entries in the tb->owners list are inserted with respect to the sk_bind_node field with sk_add_bind_node().
Thus the check would never pass and the fast path never execute.
This fast path has never been executed or tested as this bug seems to be present since commit 1da177e4c3f4 ("Linux-2.6.12-rc2"), thus remove it to reduce code complexity.
--- net/ipv4/inet_hashtables.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
net/ipv4/inet_hashtables.c +1 -11
@@ -760,17 +760,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,u32 index;if (port) { - head = &hinfo->bhash[inet_bhashfn (net, port, - hinfo->bhash_size)]; - tb =inet_csk (sk)->icsk_bind_hash; -spin_lock_bh (&head->lock); -if (sk_head (&tb->owners) == sk && !sk->sk_bind_node.next) { -inet_ehash_nolisten (sk,NULL ,NULL ); -spin_unlock_bh (&head->lock); -return 0 ; - } -spin_unlock (&head->lock); -/* No definite answer... Walk to established hash table */ +local_bh_disable (); ret =check_established (death_row, sk, port,NULL );local_bh_enable ();return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 381/567 ice: restrict PTP HW clock freq adjustments to 100, 000, 000 PPB
In reply to Greg Kroah-HartmanFrom: Siddaraju DH <[email protected]>
[ Upstream commit 8aa4318c3a122b8670bc09af142de3872ca63b88 ]
The PHY provides only 39b timestamp. With current timing implementation, we discard lower 7b, leaving 32b timestamp. The driver reconstructs the full 64b timestamp by correlating the 32b timestamp with cached_time for performance. The reconstruction algorithm does both forward & backward interpolation.
The 32b timeval has overflow duration of 2^32 counts ~= 4.23 second. Due to interpolation in both direction, its now ~= 2.125 second IIRC, going with at least half a duration, the cached_time is updated with periodic thread of 1 second (worst-case) periodicity.
But the 1 second periodicity is based on System-timer. With PPB adjustments, if the 1588 timers increments at say double the rate, (2s in-place of 1s), the Nyquist rate/half duration sampling/update of cached_time with 1 second periodic thread will lead to incorrect interpolations.
Hence we should restrict the PPB adjustments to at least half duration of cached_time update which translates to 500,000,000 PPB.
Since the periodicity of the cached-time system thread can vary, it is good to have some buffer time and considering practicality of PPB adjustments, limiting the max_adj to 100,000,000.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -1
@@ -1090,7 +1090,7 @@ static void ice_ptp_set_caps(struct ice_pf *pf)snprintf (info->name,sizeof (info->name) -1 ,"%s-%s-clk" ,dev_driver_string (dev),dev_name (dev)); info->owner =THIS_MODULE ; - info->max_adj =999999999 ; + info->max_adj =100000000 ; info->adjtime = ice_ptp_adjtime; info->adjfine = ice_ptp_adjfine; info->gettimex64 = ice_ptp_gettimex64;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 382/567 ice: add missing checks for PF vsi type
In reply to Greg Kroah-HartmanFrom: Jesse Brandeburg <[email protected]>
[ Upstream commit 6a8d013e904ad9a66706fcc926ec9993bed7d190 ]
There were a few places we had missed checking the VSI type to make sure it was definitely a PF VSI, before calling setup functions intended only for the PF VSI.
This doesn't fix any explicit bugs but cleans up the code in a few places and removes one explicit != vsi->type check that can be superseded by this code (it's a super set)
--- drivers/net/ethernet/intel/ice/ice_main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +8 -9
@@ -5477,15 +5477,12 @@ int ice_vsi_cfg(struct ice_vsi *vsi) {int err; -if (vsi->netdev) { +if (vsi->netdev && vsi->type ==ICE_VSI_PF ) {ice_set_rx_mode (vsi->netdev); -if (vsi->type !=ICE_VSI_LB ) { - err =ice_vsi_vlan_setup (vsi); - -if (err) -return err; - } + err =ice_vsi_vlan_setup (vsi); +if (err) +return err; }ice_vsi_cfg_dcb_rings (vsi);
@@ -5651,7 +5648,7 @@ static int ice_up_complete(struct ice_vsi *vsi)if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - vsi->netdev) { + vsi->netdev && vsi->type ==ICE_VSI_PF ) {ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);
@@ -5661,7 +5658,9 @@ static int ice_up_complete(struct ice_vsi *vsi)* set the baseline so counters are ready when interface is up */ ice_update_eth_stats (vsi); -ice_service_task_schedule (pf); + +if (vsi->type ==ICE_VSI_PF ) +ice_service_task_schedule (pf);return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 383/567 ACPI: Dont build ACPICA with -Os
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit 8f9e0a52810dd83406c768972d022c37e7a18f1f ]
The ACPICA code has been built with '-Os' since the beginning of git history, though there's no explanatory comment as to why.
This is unfortunate as GCC drops the alignment specificed by '-falign-functions=N' when '-Os' is used, as reported in GCC bug 88345:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345
This prevents CONFIG_FUNCTION_ALIGNMENT and CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B from having their expected effect on the ACPICA code. This is doubly unfortunate as in subsequent patches arm64 will depend upon CONFIG_FUNCTION_ALIGNMENT for its ftrace implementation.
Drop the '-Os' flag when building the ACPICA code. With this removed, the code builds cleanly and works correctly in testing so far.
I've tested this by selecting CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B=y, building and booting a kernel using ACPI, and looking for misaligned text symbols:
* arm64:
Before, v6.2-rc3:
# uname -rm
6.2.0-rc3 aarch64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
5009 Before, v6.2-rc3 + fixed __cold:
# uname -rm
6.2.0-rc3-00001-g2a2bedf8bfa9 aarch64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
919After:
# uname -rm
6.2.0-rc3-00002-g267bddc38572 aarch64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
323
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | grep acpi | wc -l
0* x86_64:
Before, v6.2-rc3:
# uname -rm
6.2.0-rc3 x86_64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
11537 Before, v6.2-rc3 + fixed __cold:
# uname -rm
6.2.0-rc3-00001-g2a2bedf8bfa9 x86_64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
2805After:
# uname -rm
6.2.0-rc3-00002-g267bddc38572 x86_64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
1357
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | grep acpi | wc -l
0With the patch applied, the remaining unaligned text labels are a combination of static call trampolines and labels in assembly, which can be dealt with in subsequent patches.
--- drivers/acpi/acpica/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/Makefile +1 -1
@@ -3,7 +3,7 @@ # Makefile for ACPICA Core interpreter # -ccflags-y := -Os -D_LINUX -DBUILDING_ACPICA +ccflags-y := -D_LINUX -DBUILDING_ACPICA ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT # use acpi.o to put all files here into acpi.o modparam namespace
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 384/567 thermal: intel: intel_pch: Add support for Wellsburg PCH
In reply to Greg Kroah-HartmanFrom: Tim Zimmermann <[email protected]>
[ Upstream commit 40dc1929089fc844ea06d9f8bdb6211ed4517c2e ]
Add the PCI ID for the Wellsburg C610 series chipset PCH.
The driver can read the temperature from the Wellsburg PCH with only the PCI ID added and no other modifications.
--- drivers/thermal/intel/intel_pch_thermal.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/thermal/intel/intel_pch_thermal.c +8 -0
@@ -29,6 +29,7 @@#define PCH_THERMAL_DID_CNL_LP 0x02F9/* CNL-LP PCH */ #define PCH_THERMAL_DID_CML_H 0X06F9/* CML-H PCH */ #define PCH_THERMAL_DID_LWB 0xA1B1/* Lewisburg PCH */ +#define PCH_THERMAL_DID_WBG 0x8D24/* Wellsburg PCH */ /* Wildcat Point-LP PCH Thermal registers */ #define WPT_TEMP 0x0000/* Temperature */
@@ -345,6 +346,7 @@ enum board_ids { board_cnl, board_cml, board_lwb, + board_wbg, }; static const struct board_info {
@@ -375,6 +377,10 @@ static const struct board_info { .name = "pch_lewisburg", .ops = &pch_dev_ops_wpt, }, + [board_wbg] = { + .name = "pch_wellsburg", + .ops = &pch_dev_ops_wpt, + }, }; static int intel_pch_thermal_probe(struct pci_dev *pdev,
@@ -490,6 +496,8 @@ static const struct pci_device_id intel_pch_thermal_id[] = { .driver_data = board_cml, }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_LWB), .driver_data = board_lwb, }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_WBG), + .driver_data = board_wbg, }, { 0, }, };MODULE_DEVICE_TABLE (pci, intel_pch_thermal_id);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 385/567 clocksource: Suspend the watchdog temporarily when high read latency detected
In reply to Greg Kroah-HartmanFrom: Feng Tang <[email protected]>
[ Upstream commit b7082cdfc464bf9231300605d03eebf943dda307 ]
Bugs have been reported on 8 sockets x86 machines in which the TSC was wrongly disabled when the system is under heavy workload.
[ 818.380354] clocksource: timekeeping watchdog on CPU336: hpet wd-wd read-back delay of 1203520ns [ 818.436160] clocksource: wd-tsc-wd read-back delay of 181880ns, clock-skew test skipped! [ 819.402962] clocksource: timekeeping watchdog on CPU338: hpet wd-wd read-back delay of 324000ns [ 819.448036] clocksource: wd-tsc-wd read-back delay of 337240ns, clock-skew test skipped! [ 819.880863] clocksource: timekeeping watchdog on CPU339: hpet read-back delay of 150280ns, attempt 3, marking unstable [ 819.936243] tsc: Marking TSC unstable due to clocksource watchdog [ 820.068173] TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'. [ 820.092382] sched_clock: Marking unstable (818769414384, 1195404998) [ 820.643627] clocksource: Checking clocksource tsc synchronization from CPU 267 to CPUs 0,4,25,70,126,430,557,564. [ 821.067990] clocksource: Switched to clocksource hpet
This can be reproduced by running memory intensive 'stream' tests, or some of the stress-ng subcases such as 'ioport'.
The reason for these issues is the when system is under heavy load, the read latency of the clocksources can be very high. Even lightweight TSC reads can show high latencies, and latencies are much worse for external clocksources such as HPET or the APIC PM timer. These latencies can result in false-positive clocksource-unstable determinations.
These issues were initially reported by a customer running on a production system, and this problem was reproduced on several generations of Xeon servers, especially when running the stress-ng test. These Xeon servers were not production systems, but they did have the latest steppings and firmware.
Given that the clocksource watchdog is a continual diagnostic check with frequency of twice a second, there is no need to rush it when the system is under heavy load. Therefore, when high clocksource read latencies are detected, suspend the watchdog timer for 5 minutes.
--- kernel/time/clocksource.c | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-)
kernel/time/clocksource.c +32 -13
@@ -378,6 +378,15 @@ void clocksource_verify_percpu(struct clocksource *cs) }EXPORT_SYMBOL_GPL (clocksource_verify_percpu); +static inline void clocksource_reset_watchdog (void ) +{ +struct clocksource *cs; + +list_for_each_entry (cs, &watchdog_list, wd_list) + cs->flags &= ~CLOCK_SOURCE_WATCHDOG ; +} + +static void clocksource_watchdog (struct timer_list *unused) {u64 csnow, wdnow, cslast, wdlast, delta;
@@ -385,6 +394,7 @@ static void clocksource_watchdog(struct timer_list *unused)int64_t wd_nsec, cs_nsec;struct clocksource *cs;enum wd_read_status read_ret; +unsigned long extra_wait =0 ;u32 md;spin_lock (&watchdog_lock);
@@ -404,13 +414,30 @@ static void clocksource_watchdog(struct timer_list *unused) read_ret =cs_watchdog_read (cs, &csnow, &wdnow); -if (read_ret !=WD_READ_SUCCESS ) { -if (read_ret ==WD_READ_UNSTABLE ) -/* Clock readout unreliable, so give it up. */ -__clocksource_unstable (cs); +if (read_ret ==WD_READ_UNSTABLE ) { +/* Clock readout unreliable, so give it up. */ +__clocksource_unstable (cs);continue ; } +/* +* When WD_READ_SKIP is returned, it means the system is likely +* under very heavy load, where the latency of reading +* watchdog/clocksource is very big, and affect the accuracy of +* watchdog check. So give system some space and suspend the +* watchdog check for 5 minutes. +*/ +if (read_ret ==WD_READ_SKIP ) { +/* +* As the watchdog timer will be suspended, and +* cs->last could keep unchanged for 5 minutes, reset +* the counters. +*/ +clocksource_reset_watchdog (); + extra_wait =HZ *300 ; +break ; + } +/* Clocksource initialized ? */ if (!(cs->flags &CLOCK_SOURCE_WATCHDOG ) ||atomic_read (&watchdog_reset_pending)) {
@@ -506,7 +533,7 @@ static void clocksource_watchdog(struct timer_list *unused)* pair clocksource_stop_watchdog() clocksource_start_watchdog(). */ if (!timer_pending (&watchdog_timer)) { - watchdog_timer.expires +=WATCHDOG_INTERVAL ; + watchdog_timer.expires +=WATCHDOG_INTERVAL + extra_wait;add_timer_on (&watchdog_timer, next_cpu); } out:
@@ -531,14 +558,6 @@ static inline void clocksource_stop_watchdog(void) watchdog_running =0 ; } -static inline void clocksource_reset_watchdog (void ) -{ -struct clocksource *cs; - -list_for_each_entry (cs, &watchdog_list, wd_list) - cs->flags &= ~CLOCK_SOURCE_WATCHDOG ; -} -static void clocksource_resume_watchdog (void ) {atomic_inc (&watchdog_reset_pending);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 386/567 crypto: hisilicon: Wipe entire pool on error
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit aa85923a954e7704bc9d3847dabeb8540aa98d13 ]
To work around a Clang __builtin_object_size bug that shows up under CONFIG_FORTIFY_SOURCE and UBSAN_BOUNDS, move the per-loop-iteration mem_block wipe into a single wipe of the entire pool structure after the loop.
--- drivers/crypto/hisilicon/sgl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/crypto/hisilicon/sgl.c +1 -2
@@ -122,9 +122,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,for (j =0 ; j < i; j++) {dma_free_coherent (dev, block_size, block[j].sgl, block[j].sgl_dma); -memset (block + j,0 ,sizeof (*block)); } -kfree (pool); +kfree_sensitive (pool);return ERR_PTR (-ENOMEM ); }EXPORT_SYMBOL_GPL (hisi_acc_create_sgl_pool);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 387/567 net: bcmgenet: Add a check for oversized packets
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 5c0862c2c962052ed5055220a00ac1cefb92fbcd ]
Occasionnaly we may get oversized packets from the hardware which exceed the nomimal 2KiB buffer size we allocate SKBs with. Add an early check which drops the packet to avoid invoking skb_over_panic() and move on to processing the next packet.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -0
@@ -2267,6 +2267,14 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, __func__, p_index, ring->c_index, ring->read_ptr, dma_length_status); +if (unlikely (len >RX_BUF_LENGTH )) { +netif_err (priv, rx_status, dev,"oversized packet\n" ); + dev->stats.rx_length_errors++; + dev->stats.rx_errors++; +dev_kfree_skb_any (skb); + goto next; + } +if (unlikely (!(dma_flag &DMA_EOP ) || !(dma_flag &DMA_SOP ))) {netif_err (priv, rx_status, dev,"dropping fragmented packet!\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 388/567 m68k: Check syscall_trace_enter() return code
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
[ Upstream commit 2ca8a1de4437f21562e57f9ac123914747a8e7a1 ]
Check return code of syscall_trace_enter(), and skip syscall if -1. Return code will be left at what had been set by ptrace or seccomp (in regs->d0).
No regression seen in testing with strace on ARAnyM.
--- arch/m68k/68000/entry.S | 2 ++ arch/m68k/coldfire/entry.S | 2 ++ arch/m68k/kernel/entry.S | 3 +++ 3 files changed, 7 insertions(+)
arch/m68k/68000/entry.S +2 -0
@@ -45,6 +45,8 @@ do_trace: jbsr syscall_trace_enter RESTORE_SWITCH_STACK addql #4,%sp + addql #1,%d0 + jeq ret_from_exception movel %sp@(PT_OFF_ORIG_D0),%d1 movel #-ENOSYS,%d0 cmpl #NR_syscalls,%d1
arch/m68k/coldfire/entry.S +2 -0
@@ -90,6 +90,8 @@ ENTRY(system_call) jbsr syscall_trace_enter RESTORE_SWITCH_STACK addql #4,%sp + addql #1,%d0 + jeq ret_from_exception movel %d3,%a0 jbsr %a0@ movel %d0,%sp@(PT_OFF_D0) /* save the return value */
arch/m68k/kernel/entry.S +3 -0
@@ -184,9 +184,12 @@ do_trace_entry: jbsr syscall_trace RESTORE_SWITCH_STACK addql #4,%sp + addql #1,%d0 | optimization for cmpil #-1,%d0 + jeq ret_from_syscall movel %sp@(PT_OFF_ORIG_D0),%d0 cmpl #NR_syscalls,%d0 jcs syscall + jra ret_from_syscall badsys: movel #-ENOSYS,%sp@(PT_OFF_D0) jra ret_from_syscall
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 389/567 netfilter: nf_tables: NULL pointer dereference in nf_tables_updobj()
In reply to Greg Kroah-HartmanFrom: Alok Tiwari <[email protected]>
[ Upstream commit dac7f50a45216d652887fb92d6cd3b7ca7f006ea ]
static analyzer detect null pointer dereference case for 'type' function __nft_obj_type_get() can return NULL value which require to handle if type is NULL pointer return -ENOENT.
This is a theoretical issue, since an existing object has a type, but better add this failsafe check.
--- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_tables_api.c +3 -0
@@ -6794,6 +6794,9 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info,return -EOPNOTSUPP ; type =__nft_obj_type_get (objtype); +if (WARN_ON_ONCE (!type)) +return -ENOENT ; +nft_ctx_init (&ctx, net, skb, info->nlh, family, table,NULL , nla);return nf_tables_updobj (&ctx, type, nla[NFTA_OBJ_DATA ], obj);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 390/567 tools/power/x86/intel-speed-select: Add Emerald Rapid quirk
In reply to Greg Kroah-HartmanFrom: Zhang Rui <[email protected]>
[ Upstream commit 61f9fdcdcd01f9a996b6db4e7092fcdfe8414ad5 ]
Need memory frequency quirk as Sapphire Rapids in Emerald Rapids. So add Emerald Rapids CPU model check in is_spr_platform().
--- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/intel-speed-select/isst-config.c +1 -1
@@ -108,7 +108,7 @@ int is_skx_based_platform(void)int is_spr_platform (void ) { -if (cpu_model ==0x8F ) +if (cpu_model ==0x8F || cpu_model ==0xCF )return 1 ;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 391/567 wifi: mt76: dma: free rx_head in mt76_dma_rx_cleanup
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 1b88b47e898edef0e56e3a2f4e49f052a136153d ]
Free rx_head skb in mt76_dma_rx_cleanup routine in order to avoid possible memory leak at module unload.
--- drivers/net/wireless/mediatek/mt76/dma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +7 -6
@@ -486,6 +486,7 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q)bool more;spin_lock_bh (&q->lock); + do { buf = mt76_dma_dequeue(dev, q, true, NULL, NULL, &more); if (!buf)
@@ -493,6 +494,12 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q)skb_free_frag (buf); }while (1 ); + +if (q->rx_head) { +dev_kfree_skb (q->rx_head); + q->rx_head =NULL ; + } +spin_unlock_bh (&q->lock);if (!q->rx_page.va)
@@ -515,12 +522,6 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)mt76_dma_rx_cleanup (dev, q);mt76_dma_sync_idx (dev, q);mt76_dma_rx_fill (dev, q); - -if (!q->rx_head) -return ; - -dev_kfree_skb (q->rx_head); - q->rx_head =NULL ; } static void
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 392/567 ACPI: video: Fix Lenovo Ideapad Z570 DMI match
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 2d11eae42d52a131f06061015e49dc0f085c5bfc ]
Multiple Ideapad Z570 variants need acpi_backlight=native to force native use on these pre Windows 8 machines since acpi_video backlight control does not work here.
The original DMI quirk matches on a product_name of "102434U" but other variants may have different product_name-s such as e.g. "1024D9U".
Move to checking product_version instead as is more or less standard for Lenovo DMI quirks for similar reasons.
--- drivers/acpi/video_detect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/video_detect.c +1 -1
@@ -313,7 +313,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { .ident = "Lenovo Ideapad Z570", .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), - DMI_MATCH(DMI_PRODUCT_NAME, "102434U"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"), }, }, {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 393/567 net/mlx5: fw_tracer: Fix debug print
In reply to Greg Kroah-HartmanFrom: Shay Drory <[email protected]>
[ Upstream commit 988c2352273997a242f15c4fc3711773515006a2 ]
The debug message specify tdsn, but takes as an argument the tmsn. The correct argument is tmsn, hence, fix the print.
--- drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c +1 -1
@@ -603,7 +603,7 @@ static int mlx5_tracer_handle_string_trace(struct mlx5_fw_tracer *tracer, }else { cur_string =mlx5_tracer_message_get (tracer, tracer_event);if (!cur_string) { -pr_debug ("%s Got string event for unknown string tdsm: %d\n" , +pr_debug ("%s Got string event for unknown string tmsn: %d\n" , __func__, tracer_event->string_event.tmsn);return -1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 394/567 coda: Avoid partial allocation of sig_inputArgs
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 48df133578c70185a95a49390d42df1996ddba2a ]
GCC does not like having a partially allocated object, since it cannot reason about it for bounds checking when it is passed to other code. Instead, fully allocate sig_inputArgs. (Alternatively, sig_inputArgs should be defined as a struct coda_in_hdr, if it is actually not using any other part of the union.) Seen under GCC 13:
../fs/coda/upcall.c: In function 'coda_upcall':../fs/coda/upcall.c:801:22: warning: array subscript 'union inputArgs[0]' is partly outside array bounds of 'unsigned char[20]' [-Warray-bounds=]
801 | sig_inputArgs->ih.opcode = CODA_SIGNAL;
| ^~
--- fs/coda/upcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/coda/upcall.c +1 -1
@@ -790,7 +790,7 @@ static int coda_upcall(struct venus_comm *vcp, sig_req =kmalloc (sizeof (struct upc_req ),GFP_KERNEL );if (!sig_req) goto exit; - sig_inputArgs =kvzalloc (sizeof (struct coda_in_hdr ),GFP_KERNEL ); + sig_inputArgs =kvzalloc (sizeof (*sig_inputArgs),GFP_KERNEL );if (!sig_inputArgs) {kfree (sig_req); goto exit;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 395/567 uaccess: Add minimum bounds check on kernel buffer size
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 04ffde1319a715bd0550ded3580d4ea3bc003776 ]
While there is logic about the difference between ksize and usize, copy_struct_from_user() didn't check the size of the destination buffer (when it was known) against ksize. Add this check so there is an upper bounds check on the possible memset() call, otherwise lower bounds checks made by callers will trigger bounds warnings under -Warray-bounds. Seen under GCC 13:
In function 'copy_struct_from_user',
inlined from 'iommufd_fops_ioctl' at../drivers/iommu/iommufd/main.c:333:8:../include/linux/fortify-string.h:59:33: warning: '__builtin_memset' offset [57, 4294967294] is out of the bounds [0, 56] of object 'buf' with type 'union ucmd_buffer' [-Warray-bounds=]
59 | #define __underlying_memset __builtin_memset
| ^
../include/linux/fortify-string.h:453:9: note: in expansion of macro '__underlying_memset'
453 | __underlying_memset(p, c, __fortify_size); \
| ^~~~~~~~~~~~~~~~~~~
../include/linux/fortify-string.h:461:25: note: in expansion of macro '__fortify_memset_chk'
461 | #define memset(p, c, s) __fortify_memset_chk(p, c, s, \
| ^~~~~~~~~~~~~~~~~~~~
../include/linux/uaccess.h:334:17: note: in expansion of macro 'memset'
334 | memset(dst + size, 0, rest);
| ^~~~~~../drivers/iommu/iommufd/main.c: In function 'iommufd_fops_ioctl':../drivers/iommu/iommufd/main.c:311:27: note: 'buf' declared here
311 | union ucmd_buffer buf;
| ^~~
--- include/linux/uaccess.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/uaccess.h +4 -0
@@ -338,6 +338,10 @@ copy_struct_from_user(void *dst, size_t ksize, const void __user *src,size_t size =min (ksize, usize);size_t rest =max (ksize, usize) - size; +/* Double check if ksize is larger than a known object size. */ +if (WARN_ON_ONCE (ksize >__builtin_object_size (dst,1 ))) +return -E2BIG ; +/* Deal with trailing bytes. */ if (usize < ksize) {memset (dst + size,0 , rest);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 396/567 s390/idle: mark arch_cpu_idle() noinstr
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
[ Upstream commit a9cbc1b471d291c865907542394f1c483b93a811 ]
linux-next commit ("cpuidle: tracing: Warn about !rcu_is_watching()") adds a new warning which hits on s390's arch_cpu_idle() function:
RCU not on for: arch_cpu_idle+0x0/0x28
WARNING: CPU: 2 PID: 0 at include/linux/trace_recursion.h:162 arch_ftrace_ops_list_func+0x24c/0x258
Modules linked in:
CPU: 2 PID: 0 Comm: swapper/2 Not tainted 6.2.0-rc6-next-20230202 #4
Hardware name: IBM 8561 T01 703 (z/VM 7.3.0)
Krnl PSW : 0404d00180000000 00000000002b55c0 (arch_ftrace_ops_list_func+0x250/0x258)
R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3
Krnl GPRS: c0000000ffffbfff 0000000080000002 0000000000000026 0000000000000000
0000037ffffe3a28 0000037ffffe3a20 0000000000000000 0000000000000000
0000000000000000 0000000000f4acf6 00000000001044f0 0000037ffffe3cb0
0000000000000000 0000000000000000 00000000002b55bc 0000037ffffe3bb8
Krnl Code: 00000000002b55b0: c02000840051 larl %r2,0000000001335652
00000000002b55b6: c0e5fff512d1 brasl %r14,0000000000157b58
#00000000002b55bc: af000000 mc 0,0
>00000000002b55c0: a7f4ffe7 brc 15,00000000002b558e
00000000002b55c4: 0707 bcr 0,%r7
00000000002b55c6: 0707 bcr 0,%r7
00000000002b55c8: eb6ff0480024 stmg %r6,%r15,72(%r15)
00000000002b55ce: b90400ef lgr %r14,%r15
Call Trace:
[<00000000002b55c0>] arch_ftrace_ops_list_func+0x250/0x258
([<00000000002b55bc>] arch_ftrace_ops_list_func+0x24c/0x258)
[<0000000000f5f0fc>] ftrace_common+0x1c/0x20
[<00000000001044f6>] arch_cpu_idle+0x6/0x28
[<0000000000f4acf6>] default_idle_call+0x76/0x128
[<00000000001cc374>] do_idle+0xf4/0x1b0
[<00000000001cc6ce>] cpu_startup_entry+0x36/0x40
[<0000000000119d00>] smp_start_secondary+0x140/0x150
[<0000000000f5d2ae>] restart_int_handler+0x6e/0x90Mark arch_cpu_idle() noinstr like all other architectures with CONFIG_ARCH_WANTS_NO_INSTR (should) have it to fix this.
--- arch/s390/kernel/idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/idle.c +1 -1
@@ -44,7 +44,7 @@ void account_idle_time_irq(void) S390_lowcore.last_update_timer = idle->timer_idle_exit; } -void arch_cpu_idle (void ) +void noinstr arch_cpu_idle(void) {struct s390_idle_data *idle =this_cpu_ptr (&s390_idle);unsigned long idle_time;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 397/567 time/debug: Fix memory leak with using debugfs_lookup()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 5b268d8abaec6cbd4bd70d062e769098d96670aa ]
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.
--- kernel/time/test_udelay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/test_udelay.c +1 -1
@@ -149,7 +149,7 @@ module_init(udelay_test_init); static void __exit udelay_test_exit(void) {mutex_lock (&udelay_test_lock); -debugfs_remove (debugfs_lookup (DEBUGFS_FILENAME ,NULL )); +debugfs_lookup_and_remove (DEBUGFS_FILENAME ,NULL );mutex_unlock (&udelay_test_lock); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 398/567 PM: domains: fix memory leak with using debugfs_lookup()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 0b6200e1e9f53dabdc30d0f6c51af9a5f664d32b ]
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.
--- drivers/base/power/domain.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/base/power/domain.c +1 -4
@@ -217,13 +217,10 @@ static void genpd_debug_add(struct generic_pm_domain *genpd);static void genpd_debug_remove (struct generic_pm_domain *genpd) { -struct dentry *d; -if (!genpd_debugfs_dir)return ; - d =debugfs_lookup (genpd->name, genpd_debugfs_dir); -debugfs_remove (d); +debugfs_lookup_and_remove (genpd->name, genpd_debugfs_dir); }static void genpd_update_accounting (struct generic_pm_domain *genpd)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 399/567 PM: EM: fix memory leak with using debugfs_lookup()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit a0e8c13ccd6a9a636d27353da62c2410c4eca337 ]
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.
--- kernel/power/energy_model.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/power/energy_model.c +1 -4
@@ -85,10 +85,7 @@ static void em_debug_create_pd(struct device *dev)static void em_debug_remove_pd (struct device *dev) { -struct dentry *debug_dir; - - debug_dir =debugfs_lookup (dev_name (dev), rootdir); -debugfs_remove_recursive (debug_dir); +debugfs_lookup_and_remove (dev_name (dev), rootdir); }static int __init em_debug_init (void )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 400/567 Bluetooth: btusb: Add VID:PID 13d3:3529 for Realtek RTL8821CE
In reply to Greg Kroah-HartmanFrom: Moises Cardona <[email protected]>
[ Upstream commit 1eec3b95b5ce7fb2cdd273ac4f8b24b1ed6776a1 ]
This patch adds VID:PID 13d3:3529 to the btusb.c file.
This VID:PID is found in the Realtek RTL8821CE module (M.2 module AW-CB304NF on an ASUS E210MA laptop)
Output of /sys/kernel/debug/usb/devices:
T: Bus=01 Lev=01 Prnt=01 Port=07 Cnt=02 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3529 Rev= 1.10 S: Manufacturer=Realtek S: Product=Bluetooth Radio C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btusb.c +4 -0
@@ -400,6 +400,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), .driver_info = BTUSB_IGNORE }, + /* Realtek 8821CE Bluetooth devices */ + { USB_DEVICE(0x13d3, 0x3529), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, + /* Realtek 8822CE Bluetooth devices */ { USB_DEVICE(0x0bda, 0xb00c), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 401/567 hv_netvsc: Check status in SEND_RNDIS_PKT completion message
In reply to Greg Kroah-HartmanFrom: Michael Kelley <[email protected]>
[ Upstream commit dca5161f9bd052e9e73be90716ffd57e8762c697 ]
Completion responses to SEND_RNDIS_PKT messages are currently processed regardless of the status in the response, so that resources associated with the request are freed. While this is appropriate, code bugs that cause sending a malformed message, or errors on the Hyper-V host, go undetected. Fix this by checking the status and outputting a rate-limited message if there is an error.
--- drivers/net/hyperv/netvsc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/hyperv/netvsc.c +18 -0
@@ -814,6 +814,7 @@ static void netvsc_send_completion(struct net_device *ndev,u32 msglen =hv_pkt_datalen (desc);struct nvsp_message *pkt_rqst;u64 cmd_rqst; +u32 status;/* First check if this is a VMBUS completion without data payload */ if (!msglen) {
@@ -885,6 +886,23 @@ static void netvsc_send_completion(struct net_device *ndev,break ;case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE : +if (msglen <sizeof (struct nvsp_message_header ) + +sizeof (struct nvsp_1_message_send_rndis_packet_complete )) { +if (net_ratelimit ()) +netdev_err (ndev,"nvsp_rndis_pkt_complete length too small: %u\n" , + msglen); +return ; + } + +/* If status indicates an error, output a message so we know +* there's a problem. But process the completion anyway so the +* resources are released. +*/ + status = nvsp_packet->msg.v1_msg.send_rndis_pkt_complete.status; +if (status !=NVSP_STAT_SUCCESS &&net_ratelimit ()) +netdev_err (ndev,"nvsp_rndis_pkt_complete error status: %x\n" , + status); +netvsc_send_tx_complete (ndev, net_device, incoming_channel, desc, budget);break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 402/567 scm: add user copy checks to put_cmsg()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 5f1eb1ff58ea122e24adf0bc940f268ed2227462 ]
This is a followup of commit 2558b8039d05 ("net: use a bounce buffer for copying skb->mark")
x86 and powerpc define user_access_begin, meaning that they are not able to perform user copy checks when using user_write_access_begin() / unsafe_copy_to_user() and friends [1]
Instead of waiting bugs to trigger on other arches, add a check_object_size() in put_cmsg() to make sure that new code tested on x86 with CONFIG_HARDENED_USERCOPY=y will perform more security checks.
[1] We can not generically call check_object_size() from unsafe_copy_to_user() because UACCESS is enabled at this point.
--- net/core/scm.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/scm.c +2 -0
@@ -229,6 +229,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)if (msg->msg_control_is_user) {struct cmsghdr __user *cm = msg->msg_control_user; +check_object_size (data, cmlen -sizeof (*cm), true); +if (!user_write_access_begin (cm, cmlen)) goto efault;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 403/567 drm/amd/display: Revert Reduce delay when sink device not able to ACK 00340h write
In reply to Greg Kroah-HartmanFrom: Ian Chen <[email protected]>
[ Upstream commit 639f6ad6df7f47db48b59956b469a6917a136afb ]
[WHY]
It causes regression AMD source will not write DPCD 340.
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 6 ------ drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 14 +++----------- drivers/gpu/drm/amd/display/dc/dc_dp_types.h | 1 - 3 files changed, 3 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +0 -6
@@ -1665,12 +1665,6 @@ struct dc_link *link_create(const struct link_init_data *init_params)if (false ==dc_link_construct (link, init_params)) goto construct_fail; -/* -* Must use preferred_link_setting, not reported_link_cap or verified_link_cap, -* since struct preferred_link_setting won't be reset after S3. -*/ - link->preferred_link_setting.dpcd_source_device_specific_field_support = true; -return link; construct_fail:
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +3 -11
@@ -4841,18 +4841,10 @@ void dpcd_set_source_specific_data(struct dc_link *link)uint8_t hblank_size = (uint8_t )link->dc->caps.min_horizontal_blanking_period; -if (link->preferred_link_setting.dpcd_source_device_specific_field_support) { - result_write_min_hblank =core_link_write_dpcd (link, -DP_SOURCE_MINIMUM_HBLANK_SUPPORTED , (uint8_t *)(&hblank_size), -sizeof (hblank_size)); - -if (result_write_min_hblank ==DC_ERROR_UNEXPECTED ) - link->preferred_link_setting.dpcd_source_device_specific_field_support = false; - }else { -DC_LOG_DC ("Sink device does not support 00340h DPCD write. Skipping on purpose.\n" ); - } + result_write_min_hblank =core_link_write_dpcd (link, +DP_SOURCE_MINIMUM_HBLANK_SUPPORTED , (uint8_t *)(&hblank_size), +sizeof (hblank_size)); } - DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, WPP_BIT_FLAG_DC_DETECTION_DP_CAPS, "result=%u link_index=%u enum dce_version=%d DPCD=0x%04X min_hblank=%u branch_dev_id=0x%x branch_dev_name='%c%c%c%c%c%c'",
drivers/gpu/drm/amd/display/dc/dc_dp_types.h +0 -1
@@ -109,7 +109,6 @@ struct dc_link_settings {enum dc_link_spread link_spread;bool use_link_rate_set;uint8_t link_rate_set; -bool dpcd_source_device_specific_field_support; };struct dc_lane_settings {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 404/567 drm/amd/display: Fix potential null-deref in dm_resume
In reply to Greg Kroah-HartmanFrom: Roman Li <[email protected]>
[ Upstream commit 7a7175a2cd84b7874bebbf8e59f134557a34161b ]
[Why]
Fixing smatch error:dm_resume() error: we previously assumed 'aconnector->dc_link' could be null
[How]
Check if dc_link null at the beginning of the loop, so further checks can be dropped.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -2
@@ -2687,12 +2687,14 @@ static int dm_resume(void *handle)drm_for_each_connector_iter (connector, &iter) { aconnector =to_amdgpu_dm_connector (connector); +if (!aconnector->dc_link) +continue ; +/* * this is the case when traversing through already created * MST connectors, should be skipped */ -if (aconnector->dc_link && - aconnector->dc_link->type == dc_connection_mst_branch) +if (aconnector->dc_link->type == dc_connection_mst_branch)continue ;mutex_lock (&aconnector->hpd_lock);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 405/567 drm/omap: dsi: Fix excessive stack usage
In reply to Greg Kroah-HartmanFrom: Tomi Valkeinen <[email protected]>
[ Upstream commit cfca78971b9233aef0891507a98fba62046d4542 ]
dsi_dump_dsi_irqs(), a function used for debugfs prints, has a large struct in its frame, which can result in:
drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes [-Wframe-larger-than=]
As the performance of the function is of no concern, let's allocate the struct with kmalloc instead.
Compile-tested only.
--- drivers/gpu/drm/omapdrm/dss/dsi.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/gpu/drm/omapdrm/dss/dsi.c +16 -10
@@ -1039,22 +1039,26 @@ static int dsi_dump_dsi_irqs(struct seq_file *s, void *p) {struct dsi_data *dsi = s->private;unsigned long flags; -struct dsi_irq_stats stats; +struct dsi_irq_stats *stats; + + stats =kmalloc (sizeof (*stats),GFP_KERNEL ); +if (!stats) +return -ENOMEM ;spin_lock_irqsave (&dsi->irq_stats_lock, flags); - stats = dsi->irq_stats; + *stats = dsi->irq_stats;memset (&dsi->irq_stats,0 ,sizeof (dsi->irq_stats)); dsi->irq_stats.last_reset = jiffies;spin_unlock_irqrestore (&dsi->irq_stats_lock, flags);seq_printf (s,"period %u ms\n" , -jiffies_to_msecs (jiffies - stats.last_reset)); +jiffies_to_msecs (jiffies - stats->last_reset)); -seq_printf (s,"irqs %d\n" , stats.irq_count); +seq_printf (s,"irqs %d\n" , stats->irq_count);#define PIS (x) \ - seq_printf(s, "%-20s %10d\n", #x, stats.dsi_irqs[ffs(DSI_IRQ_##x)-1]); + seq_printf(s, "%-20s %10d\n", #x, stats->dsi_irqs[ffs(DSI_IRQ_##x)-1]);seq_printf (s,"-- DSI%d interrupts --\n" , dsi->module_id +1 );PIS (VC0 );
@@ -1078,10 +1082,10 @@ static int dsi_dump_dsi_irqs(struct seq_file *s, void *p)#define PIS (x) \ seq_printf(s, "%-20s %10d %10d %10d %10d\n", #x, \ - stats.vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \ - stats.vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \ - stats.vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \ - stats.vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]); + stats->vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \ + stats->vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \ + stats->vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \ + stats->vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]);seq_printf (s,"-- VC interrupts --\n" );PIS (CS );
@@ -1097,7 +1101,7 @@ static int dsi_dump_dsi_irqs(struct seq_file *s, void *p)#define PIS (x) \ seq_printf(s, "%-20s %10d\n", #x, \ - stats.cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]); + stats->cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]);seq_printf (s,"-- CIO interrupts --\n" );PIS (ERRSYNCESC1 );
@@ -1122,6 +1126,8 @@ static int dsi_dump_dsi_irqs(struct seq_file *s, void *p)PIS (ULPSACTIVENOT_ALL1 );#undef PIS +kfree (stats); + return 0; }#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 406/567 HID: Add Mapping for System Microphone Mute
In reply to Greg Kroah-HartmanFrom: Jingyuan Liang <[email protected]>
[ Upstream commit 2d60f9f4f26785a00273cb81fe60eff129ebd449 ]
HUTRR110 added a new usage code for a key that is supposed to mute/unmute microphone system-wide.
Map the new usage code(0x01 0xa9) to keycode KEY_MICMUTE. Additionally hid-debug is adjusted to recognize this keycode as well.
--- drivers/hid/hid-debug.c | 1 + drivers/hid/hid-input.c | 8 ++++++++ 2 files changed, 9 insertions(+)
drivers/hid/hid-debug.c +1 -0
@@ -937,6 +937,7 @@ static const char *keys[KEY_MAX + 1] = { [KEY_KBD_LAYOUT_NEXT] = "KbdLayoutNext", [KEY_EMOJI_PICKER] = "EmojiPicker", [KEY_DICTATE] = "Dictate", + [KEY_MICMUTE] = "MicrophoneMute", [KEY_BRIGHTNESS_MIN] = "BrightnessMin", [KEY_BRIGHTNESS_MAX] = "BrightnessMax", [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
drivers/hid/hid-input.c +8 -0
@@ -709,6 +709,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielbreak ; } +if ((usage->hid &0xf0 ) ==0xa0 ) {/* SystemControl */ +switch (usage->hid &0xf ) { +case 0x9 :map_key_clear (KEY_MICMUTE );break ; +default : goto ignore; + } +break ; + } +if ((usage->hid &0xf0 ) ==0xb0 ) {/* SC - Display */ switch (usage->hid &0xf ) {case 0x05 :map_key_clear (KEY_SWITCHVIDEOMODE );break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 407/567 drm/tiny: ili9486: Do not assume 8-bit only SPI controllers
In reply to Greg Kroah-HartmanFrom: Carlo Caione <[email protected]>
[ Upstream commit 77772e607522daa61f3af74df018559db75c43d6 ]
The pixel data for the ILI9486 is always 16-bits wide and it must be sent over the SPI bus. When the controller is only able to deal with 8-bit transfers, this 16-bits data needs to be swapped before the sending to account for the big endian bus, this is on the contrary not needed when the SPI controller already supports 16-bits transfers.
The decision about swapping the pixel data or not is taken in the MIPI DBI code by probing the controller capabilities: if the controller only suppors 8-bit transfers the data is swapped, otherwise it is not.
This swapping/non-swapping is relying on the assumption that when the controller does support 16-bit transactions then the data is sent unswapped in 16-bits-per-word over SPI.
The problem with the ILI9486 driver is that it is forcing 8-bit transactions also for controllers supporting 16-bits, violating the assumption and corrupting the pixel data.
Align the driver to what is done in the MIPI DBI code by adjusting the transfer size to the maximum allowed by the SPI controller.
--- drivers/gpu/drm/tiny/ili9486.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/tiny/ili9486.c +9 -4
@@ -43,6 +43,7 @@ static int waveshare_command(struct mipi_dbi *mipi, u8 *cmd, u8 *par, size_t num) {struct spi_device *spi = mipi->spi; +unsigned int bpw =8 ;void *data = par;u32 speed_hz;int i, ret;
@@ -56,8 +57,6 @@ static int waveshare_command(struct mipi_dbi *mipi, u8 *cmd, u8 *par,* The displays are Raspberry Pi HATs and connected to the 8-bit only * SPI controller, so 16-bit command and parameters need byte swapping * before being transferred as 8-bit on the big endian SPI bus. -* Pixel data bytes have already been swapped before this function is -* called. */ buf[0 ] =cpu_to_be16 (*cmd);gpiod_set_value_cansleep (mipi->dc,0 );
@@ -71,12 +70,18 @@ static int waveshare_command(struct mipi_dbi *mipi, u8 *cmd, u8 *par,for (i =0 ; i < num; i++) buf[i] =cpu_to_be16 (par[i]); num *=2 ; - speed_hz =mipi_dbi_spi_cmd_max_speed (spi, num); data = buf; } +/* +* Check whether pixel data bytes needs to be swapped or not +*/ +if (*cmd ==MIPI_DCS_WRITE_MEMORY_START && !mipi->swap_bytes) + bpw =16 ; +gpiod_set_value_cansleep (mipi->dc,1 ); - ret =mipi_dbi_spi_transfer (spi, speed_hz,8 , data, num); + speed_hz =mipi_dbi_spi_cmd_max_speed (spi, num); + ret =mipi_dbi_spi_transfer (spi, speed_hz, bpw, data, num); free:kfree (buf);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 408/567 drm/radeon: free iio for atombios when driver shutdown
In reply to Greg Kroah-HartmanFrom: Liwei Song <[email protected]>
[ Upstream commit 4773fadedca918faec443daaca5e4ea1c0ced144 ]
Fix below kmemleak when unload radeon driver:
unreferenced object 0xffff9f8608ede200 (size 512):
comm "systemd-udevd", pid 326, jiffies 4294682822 (age 716.338s) hex dump (first 32 bytes):
00 00 00 00 c4 aa ec aa 14 ab 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000062fadebe>] kmem_cache_alloc_trace+0x2f1/0x500
[<00000000b6883cea>] atom_parse+0x117/0x230 [radeon]
[<00000000158c23fd>] radeon_atombios_init+0xab/0x170 [radeon]
[<00000000683f672e>] si_init+0x57/0x750 [radeon]
[<00000000566cc31f>] radeon_device_init+0x559/0x9c0 [radeon]
[<0000000046efabb3>] radeon_driver_load_kms+0xc1/0x1a0 [radeon]
[<00000000b5155064>] drm_dev_register+0xdd/0x1d0
[<0000000045fec835>] radeon_pci_probe+0xbd/0x100 [radeon]
[<00000000e69ecca3>] pci_device_probe+0xe1/0x160
[<0000000019484b76>] really_probe.part.0+0xc1/0x2c0
[<000000003f2649da>] __driver_probe_device+0x96/0x130
[<00000000231c5bb1>] driver_probe_device+0x24/0xf0
[<0000000000a42377>] __driver_attach+0x77/0x190
[<00000000d7574da6>] bus_for_each_dev+0x7f/0xd0
[<00000000633166d2>] driver_attach+0x1e/0x30
[<00000000313b05b8>] bus_add_driver+0x12c/0x1e0iio was allocated in atom_index_iio() called by atom_parse(), but it doesn't got released when the dirver is shutdown. Fix this kmemleak by free it in radeon_atombios_fini().
--- drivers/gpu/drm/radeon/radeon_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_device.c +1 -0
@@ -1022,6 +1022,7 @@ void radeon_atombios_fini(struct radeon_device *rdev) {if (rdev->mode_info.atom_context) {kfree (rdev->mode_info.atom_context->scratch); +kfree (rdev->mode_info.atom_context->iio); }kfree (rdev->mode_info.atom_context); rdev->mode_info.atom_context =NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 409/567 scsi: lpfc: Fix use-after-free KFENCE violation during sysfs firmware write
In reply to Greg Kroah-HartmanFrom: Justin Tee <[email protected]>
[ Upstream commit 21681b81b9ae548c5dae7ae00d931197a27f480c ]
During the sysfs firmware write process, a use-after-free read warning is logged from the lpfc_wr_object() routine:
BUG: KFENCE: use-after-free read in lpfc_wr_object+0x235/0x310 [lpfc] Use-after-free read at 0x0000000000cf164d (in kfence-#111): lpfc_wr_object+0x235/0x310 [lpfc] lpfc_write_firmware.cold+0x206/0x30d [lpfc] lpfc_sli4_request_firmware_update+0xa6/0x100 [lpfc] lpfc_request_firmware_upgrade_store+0x66/0xb0 [lpfc] kernfs_fop_write_iter+0x121/0x1b0 new_sync_write+0x11c/0x1b0 vfs_write+0x1ef/0x280 ksys_write+0x5f/0xe0 do_syscall_64+0x59/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
The driver accessed wr_object pointer data, which was initialized into mailbox payload memory, after the mailbox object was released back to the mailbox pool.
Fix by moving the mailbox free calls to the end of the routine ensuring that we don't reference internal mailbox memory after release.
--- drivers/scsi/lpfc/lpfc_sli.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/scsi/lpfc/lpfc_sli.c +13 -6
@@ -21066,6 +21066,7 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,struct lpfc_mbx_wr_object *wr_object;LPFC_MBOXQ_t *mbox;int rc =0 , i =0 ; +int mbox_status =0 ;uint32_t shdr_status, shdr_add_status, shdr_add_status_2;uint32_t shdr_change_status =0 , shdr_csf =0 ;uint32_t mbox_tmo;
@@ -21111,11 +21112,15 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list, wr_object->u.request.bde_count = i;bf_set (lpfc_wr_object_write_length, &wr_object->u.request, written);if (!phba->sli4_hba.intr_enable) - rc =lpfc_sli_issue_mbox (phba, mbox,MBX_POLL ); + mbox_status =lpfc_sli_issue_mbox (phba, mbox,MBX_POLL );else { mbox_tmo =lpfc_mbox_tmo_val (phba, mbox); - rc =lpfc_sli_issue_mbox_wait (phba, mbox, mbox_tmo); + mbox_status =lpfc_sli_issue_mbox_wait (phba, mbox, mbox_tmo); } + +/* The mbox status needs to be maintained to detect MBOX_TIMEOUT. */ + rc = mbox_status; +/* The IOCTL status is embedded in the mailbox subheader. */ shdr_status =bf_get (lpfc_mbox_hdr_status, &wr_object->header.cfg_shdr.response);
@@ -21130,10 +21135,6 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list, &wr_object->u.response); } -if (!phba->sli4_hba.intr_enable) -mempool_free (mbox, phba->mbox_mem_pool); -else if (rc !=MBX_TIMEOUT ) -mempool_free (mbox, phba->mbox_mem_pool);if (shdr_status || shdr_add_status || shdr_add_status_2 || rc) {lpfc_printf_log (phba,KERN_ERR ,LOG_TRACE_EVENT , "3025 Write Object mailbox failed with "
@@ -21151,6 +21152,12 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,lpfc_log_fw_write_cmpl (phba, shdr_status, shdr_add_status, shdr_add_status_2, shdr_change_status, shdr_csf); + +if (!phba->sli4_hba.intr_enable) +mempool_free (mbox, phba->mbox_mem_pool); +else if (mbox_status !=MBX_TIMEOUT ) +mempool_free (mbox, phba->mbox_mem_pool); +return rc; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 410/567 Revert "fbcon: dont lose the console font across generic->chip driver switch"
In reply to Greg Kroah-HartmanFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit 12d5796d55f9fd9e4b621003127c99e176665064 ]
This reverts commit ae1287865f5361fa138d4d3b1b6277908b54eac9.
Always free the console font when deinitializing the framebuffer console. Subsequent framebuffer consoles will then use the default font. Rely on userspace to load any user-configured font for these consoles.
Commit ae1287865f53 ("fbcon: don't lose the console font across generic->chip driver switch") was introduced to work around losing the font during graphics-device handover. [1][2] It kept a dangling pointer with the font data between loading the two consoles, which is fairly adventurous hack. It also never covered cases when the other consoles, such as VGA text mode, where involved.
The problem has meanwhile been solved in userspace. Systemd comes with a udev rule that re-installs the configured font when a console comes up. [3] So the kernel workaround can be removed.
This also removes one of the two special cases triggered by setting FBINFO_MISC_FIRMWARE in an fbdev driver.
Tested during device handover from efifb and simpledrm to radeon. Udev reloads the configured console font for the new driver's terminal.
--- drivers/video/fbdev/core/fbcon.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/video/fbdev/core/fbcon.c +6 -11
@@ -989,7 +989,7 @@ static const char *fbcon_startup(void)set_blitting_type (vc, info);/* Setup default font */ -if (!p->fontdata && !vc->vc_font.data) { +if (!p->fontdata) {if (!fontname[0 ] || !(font =find_font (fontname))) font = get_default_font(info->var.xres, info->var.yres,
@@ -999,8 +999,6 @@ static const char *fbcon_startup(void) vc->vc_font.height = font->height; vc->vc_font.data = (void *)(p->fontdata = font->data); vc->vc_font.charcount = font->charcount; - }else { - p->fontdata = vc->vc_font.data; } cols =FBCON_SWAP (ops->rotate, info->var.xres, info->var.yres);
@@ -1167,9 +1165,9 @@ static void fbcon_init(struct vc_data *vc, int init) ops->p = &fb_display[fg_console]; } -static void fbcon_free_font (struct fbcon_display *p,bool freefont) +static void fbcon_free_font (struct fbcon_display *p) { -if (freefont && p->userfont && p->fontdata && (--REFCOUNT (p->fontdata) ==0 )) +if (p->userfont && p->fontdata && (--REFCOUNT (p->fontdata) ==0 ))kfree (p->fontdata -FONT_EXTRA_WORDS *sizeof (int )); p->fontdata =NULL ; p->userfont =0 ;
@@ -1183,8 +1181,8 @@ static void fbcon_deinit(struct vc_data *vc)struct fb_info *info;struct fbcon_ops *ops;int idx; -bool free_font = true; +fbcon_free_font (p); idx = con2fb_map[vc->vc_num];if (idx ==-1 )
@@ -1195,8 +1193,6 @@ static void fbcon_deinit(struct vc_data *vc)if (!info) goto finished; -if (info->flags &FBINFO_MISC_FIRMWARE ) - free_font = false; ops = info->fbcon_par;if (!ops)
@@ -1208,9 +1204,8 @@ static void fbcon_deinit(struct vc_data *vc) ops->flags &= ~FBCON_FLAGS_INIT ; finished: -fbcon_free_font (p, free_font); -if (free_font) - vc->vc_font.data =NULL ; +fbcon_free_font (p); + vc->vc_font.data =NULL ;if (vc->vc_hi_font_mask && vc->vc_screenbuf)set_vc_hi_font (vc, false);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 411/567 drm: amd: display: Fix memory leakage
In reply to Greg Kroah-HartmanFrom: Konstantin Meskhidze <[email protected]>
[ Upstream commit 6b8701be1f66064ca72733c5f6e13748cdbf8397 ]
This commit fixes memory leakage in dc_construct_ctx() function.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -0
@@ -771,6 +771,7 @@ static bool dc_construct_ctx(struct dc *dc, dc_ctx->perf_trace =dc_perf_trace_create ();if (!dc_ctx->perf_trace) { +kfree (dc_ctx);ASSERT_CRITICAL (false);return false; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 412/567 drm/msm/dsi: Add missing check for alloc_ordered_workqueue
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 115906ca7b535afb1fe7b5406c566ccd3873f82b ]
Add check for the return value of alloc_ordered_workqueue as it may return NULL pointer and cause NULL pointer dereference.
Patchwork: https://patchwork.freedesktop.org/patch/517646/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/dsi/dsi_host.c +3 -0
@@ -1929,6 +1929,9 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)/* setup workqueue */ msm_host->workqueue =alloc_ordered_workqueue ("dsi_drm_work" ,0 ); +if (!msm_host->workqueue) +return -ENOMEM ; +INIT_WORK (&msm_host->err_work, dsi_err_worker);INIT_WORK (&msm_host->hpd_work, dsi_hpd_worker);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 413/567 docs/scripts/gdb: add necessary make scripts_gdb step
In reply to Greg Kroah-HartmanFrom: Jakob Koschel <[email protected]>
[ Upstream commit 6b219431037bf98c9efd49716aea9b68440477a3 ]
In order to debug the kernel successfully with gdb you need to run 'make scripts_gdb' nowadays.
This was changed with the following commit:
Commit 67274c083438340ad16c ("scripts/gdb: delay generation of gdb constants.py")
In order to have a complete guide for beginners this remark should be added to the offial documentation.
--- Documentation/dev-tools/gdb-kernel-debugging.rst | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/dev-tools/gdb-kernel-debugging.rst +4 -0
@@ -39,6 +39,10 @@ Setup this mode. In this case, you should build the kernel with CONFIG_RANDOMIZE_BASE disabled if the architecture supports KASLR. +- Build the gdb scripts (required on kernels v5.1 and above):: + + make scripts_gdb + - Enable the gdb stub of QEMU/KVM, either - at VM startup time by appending "-s" to the QEMU command line
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 414/567 ASoC: soc-compress: Reposition and add pcm_mutex
In reply to Greg Kroah-HartmanFrom: 강신형 <[email protected]>
[ Upstream commit aa9ff6a4955fdba02b54fbc4386db876603703b7 ]
If panic_on_warn is set and compress stream(DPCM) is started, then kernel panic occurred because card->pcm_mutex isn't held appropriately. In the following functions, warning were issued at this line "snd_soc_dpcm_mutex_assert_held".
static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
struct snd_soc_pcm_runtime *be, int stream)
{
...
snd_soc_dpcm_mutex_assert_held(fe);
...
}void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
{
...
snd_soc_dpcm_mutex_assert_held(fe);
...
}void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
int stream, int action)
{
...
snd_soc_dpcm_mutex_assert_held(rtd);
...
}int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
int event)
{
...
snd_soc_dpcm_mutex_assert_held(fe);
...
}These functions are called by soc_compr_set_params_fe, soc_compr_open_fe and soc_compr_free_fe
without pcm_mutex locking. And this is call stack.
[ 414.527841][ T2179] pc : dpcm_process_paths+0x5a4/0x750 [ 414.527848][ T2179] lr : dpcm_process_paths+0x37c/0x750 [ 414.527945][ T2179] Call trace: [ 414.527949][ T2179] dpcm_process_paths+0x5a4/0x750 [ 414.527955][ T2179] soc_compr_open_fe+0xb0/0x2cc [ 414.527972][ T2179] snd_compr_open+0x180/0x248 [ 414.527981][ T2179] snd_open+0x15c/0x194 [ 414.528003][ T2179] chrdev_open+0x1b0/0x220 [ 414.528023][ T2179] do_dentry_open+0x30c/0x594 [ 414.528045][ T2179] vfs_open+0x34/0x44 [ 414.528053][ T2179] path_openat+0x914/0xb08 [ 414.528062][ T2179] do_filp_open+0xc0/0x170 [ 414.528068][ T2179] do_sys_openat2+0x94/0x18c [ 414.528076][ T2179] __arm64_sys_openat+0x78/0xa4 [ 414.528084][ T2179] invoke_syscall+0x48/0x10c [ 414.528094][ T2179] el0_svc_common+0xbc/0x104 [ 414.528099][ T2179] do_el0_svc+0x34/0xd8 [ 414.528103][ T2179] el0_svc+0x34/0xc4 [ 414.528125][ T2179] el0t_64_sync_handler+0x8c/0xfc [ 414.528133][ T2179] el0t_64_sync+0x1a0/0x1a4 [ 414.528142][ T2179] Kernel panic - not syncing: panic_on_warn set ...
So, I reposition and add pcm_mutex to resolve lockdep error.
--- sound/soc/soc-compress.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/soc-compress.c +6 -3
@@ -116,6 +116,8 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)if (ret <0 ) goto be_err; +mutex_lock_nested (&fe->card->pcm_mutex, fe->card->pcm_subclass); +/* calculate valid and active FE <-> BE dpcms */ dpcm_process_paths (fe, stream, &list,1 ); fe->dpcm[stream].runtime = fe_substream->runtime;
@@ -151,7 +153,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) fe->dpcm[stream].state =SND_SOC_DPCM_STATE_OPEN ; fe->dpcm[stream].runtime_update =SND_SOC_DPCM_UPDATE_NO ; -mutex_lock_nested (&fe->card->pcm_mutex, fe->card->pcm_subclass);snd_soc_runtime_activate (fe, stream);mutex_unlock (&fe->card->pcm_mutex);
@@ -182,7 +183,6 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)mutex_lock_nested (&fe->card->pcm_mutex, fe->card->pcm_subclass);snd_soc_runtime_deactivate (fe, stream); -mutex_unlock (&fe->card->pcm_mutex); fe->dpcm[stream].runtime_update =SND_SOC_DPCM_UPDATE_FE ;
@@ -201,6 +201,8 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)dpcm_be_disconnect (fe, stream); +mutex_unlock (&fe->card->pcm_mutex); + fe->dpcm[stream].runtime =NULL ;snd_soc_link_compr_shutdown (cstream,0 );
@@ -376,8 +378,9 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, ret =snd_soc_link_compr_set_params (cstream);if (ret <0 ) goto out; - +mutex_lock_nested (&fe->card->pcm_mutex, fe->card->pcm_subclass);dpcm_dapm_stream_event (fe, stream,SND_SOC_DAPM_STREAM_START ); +mutex_unlock (&fe->card->pcm_mutex); fe->dpcm[stream].state =SND_SOC_DPCM_STATE_PREPARE ; out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 415/567 ASoC: kirkwood: Iterate over array indexes instead of using pointer math
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit b3bcedc0402fcdc5c8624c433562d9d1882749d8 ]
Walking the dram->cs array was seen as accesses beyond the first array item by the compiler. Instead, use the array index directly. This allows for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen with GCC 13 with -fstrict-flex-arrays:
../sound/soc/kirkwood/kirkwood-dma.c: In function
'kirkwood_dma_conf_mbus_windows.constprop':../sound/soc/kirkwood/kirkwood-dma.c:90:24: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
90 | if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) {
| ~~^~~~~~--- sound/soc/kirkwood/kirkwood-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/kirkwood/kirkwood-dma.c +1 -1
@@ -86,7 +86,7 @@ kirkwood_dma_conf_mbus_windows(void __iomem *base, int win,/* try to find matching cs for current dma address */ for (i =0 ; i < dram->num_cs; i++) { -const struct mbus_dram_window *cs = dram->cs + i; +const struct mbus_dram_window *cs = &dram->cs[i];if ((cs->base &0xffff0000 ) < (dma &0xffff0000 )) {writel (cs->base &0xffff0000 , base +KIRKWOOD_AUDIO_WIN_BASE_REG (win));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 416/567 regulator: max77802: Bounds check regulator id against opmode
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 4fd8bcec5fd7c0d586206fa2f42bd67b06cdaa7e ]
Explicitly bounds-check the id before accessing the opmode array. Seen with GCC 13:
../drivers/regulator/max77802-regulator.c: In function 'max77802_enable':../drivers/regulator/max77802-regulator.c:217:29: warning: array subscript [0, 41] is outside array bounds of 'unsigned int[42]' [-Warray-bounds=]
217 | if (max77802->opmode[id] == MAX77802_OFF_PWRREQ)
| ~~~~~~~~~~~~~~~~^~~~
../drivers/regulator/max77802-regulator.c:62:22: note: while referencing 'opmode'
62 | unsigned int opmode[MAX77802_REG_MAX];
| ^~~~~~
--- drivers/regulator/max77802-regulator.c | 34 ++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/regulator/max77802-regulator.c +24 -10
@@ -94,9 +94,11 @@ static int max77802_set_suspend_disable(struct regulator_dev *rdev) {unsigned int val =MAX77802_OFF_PWRREQ ;struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);int shift =max77802_get_opmode_shift (id); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ; max77802->opmode[id] = val;return regmap_update_bits (rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val << shift);
@@ -110,7 +112,7 @@ static int max77802_set_suspend_disable(struct regulator_dev *rdev)static int max77802_set_mode (struct regulator_dev *rdev,unsigned int mode) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);unsigned int val;int shift =max77802_get_opmode_shift (id);
@@ -127,6 +129,9 @@ static int max77802_set_mode(struct regulator_dev *rdev, unsigned int mode)return -EINVAL ; } +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ; + max77802->opmode[id] = val;return regmap_update_bits (rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val << shift);
@@ -135,8 +140,10 @@ static int max77802_set_mode(struct regulator_dev *rdev, unsigned int mode)static unsigned max77802_get_mode (struct regulator_dev *rdev) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ;return max77802_map_mode (max77802->opmode[id]); }
@@ -160,10 +167,13 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev, unsigned int mode) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);unsigned int val;int shift =max77802_get_opmode_shift (id); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ; +/* * If the regulator has been disabled for suspend * then is invalid to try setting a suspend mode.
@@ -209,9 +219,11 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev,static int max77802_enable (struct regulator_dev *rdev) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);int shift =max77802_get_opmode_shift (id); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ;if (max77802->opmode[id] ==MAX77802_OFF_PWRREQ ) max77802->opmode[id] =MAX77802_OPMODE_NORMAL ;
@@ -495,7 +507,7 @@ static int max77802_pmic_probe(struct platform_device *pdev)for (i =0 ; i <MAX77802_REG_MAX ; i++) {struct regulator_dev *rdev; -int id = regulators[i].id; +unsigned int id = regulators[i].id;int shift =max77802_get_opmode_shift (id);int ret;
@@ -513,10 +525,12 @@ static int max77802_pmic_probe(struct platform_device *pdev)* the hardware reports OFF as the regulator operating mode. * Default to operating mode NORMAL in that case. */ -if (val ==MAX77802_STATUS_OFF ) - max77802->opmode[id] =MAX77802_OPMODE_NORMAL ; -else - max77802->opmode[id] = val; +if (id <ARRAY_SIZE (max77802->opmode)) { +if (val ==MAX77802_STATUS_OFF ) + max77802->opmode[id] =MAX77802_OPMODE_NORMAL ; +else + max77802->opmode[id] = val; + } rdev =devm_regulator_register (&pdev->dev, ®ulators[i], &config);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 417/567 regulator: s5m8767: Bounds check id indexing into arrays
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit e314e15a0b58f9d051c00b25951073bcdae61953 ]
The compiler has no way to know if "id" is within the array bounds of the regulators array. Add a check for this and a build-time check that the regulators and reg_voltage_map arrays are sized the same. Seen with GCC 13:
../drivers/regulator/s5m8767.c: In function 's5m8767_pmic_probe':../drivers/regulator/s5m8767.c:936:35: warning: array subscript [0, 36] is outside array bounds of 'struct regulator_desc[37]' [-Warray-bounds=]
936 | regulators[id].vsel_reg =
| ~~~~~~~~~~^~~~--- drivers/regulator/s5m8767.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/regulator/s5m8767.c +5 -1
@@ -923,10 +923,14 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)for (i =0 ; i < pdata->num_regulators; i++) {const struct sec_voltage_desc *desc; -int id = pdata->regulators[i].id; +unsigned int id = pdata->regulators[i].id;int enable_reg, enable_val;struct regulator_dev *rdev; +BUILD_BUG_ON (ARRAY_SIZE (regulators) !=ARRAY_SIZE (reg_voltage_map)); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (regulators))) +continue ; + desc = reg_voltage_map[id];if (desc) { regulators[id].n_voltages =
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 418/567 gfs2: Improve gfs2_make_fs_rw error handling
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit b66f723bb552ad59c2acb5d45ea45c890f84498b ]
In gfs2_make_fs_rw(), make sure to call gfs2_consist() to report an inconsistency and mark the filesystem as withdrawn when gfs2_find_jhead() fails.
At the end of gfs2_make_fs_rw(), when we discover that the filesystem has been withdrawn, make sure we report an error. This also replaces the gfs2_withdrawn() check after gfs2_find_jhead().
--- fs/gfs2/super.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/gfs2/super.c +6 -2
@@ -138,8 +138,10 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)return -EIO ; error =gfs2_find_jhead (sdp->sd_jdesc, &head, false); -if (error ||gfs2_withdrawn (sdp)) +if (error) { +gfs2_consist (sdp);return error; + }if (!(head.lh_flags &GFS2_LOG_HEAD_UNMOUNT )) {gfs2_consist (sdp);
@@ -151,7 +153,9 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)gfs2_log_pointers_init (sdp, head.lh_blkno); error =gfs2_quota_init (sdp); -if (!error && !gfs2_withdrawn (sdp)) +if (!error &&gfs2_withdrawn (sdp)) + error = -EIO ; +if (!error)set_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags);return error; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 419/567 hwmon: (coretemp) Simplify platform device handling
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit 6d03bbff456befeccdd4d663177c4d6c75d0c4ff ]
Coretemp's platform driver is unconventional. All the real work is done globally by the initcall and CPU hotplug notifiers, while the "driver" effectively just wraps an allocation and the registration of the hwmon interface in a long-winded round-trip through the driver core. The whole logic of dynamically creating and destroying platform devices to bring the interfaces up and down is error prone, since it assumes platform_device_add() will synchronously bind the driver and set drvdata before it returns, thus results in a NULL dereference if drivers_autoprobe is turned off for the platform bus. Furthermore, the unusual approach of doing that from within a CPU hotplug notifier, already commented in the code that it deadlocks suspend, also causes lockdep issues for other drivers or subsystems which may want to legitimately register a CPU hotplug notifier from a platform bus notifier.
All of these issues can be solved by ripping this unusual behaviour out completely, simply tying the platform devices to the lifetime of the module itself, and directly managing the hwmon interfaces from the hotplug notifiers. There is a slight user-visible change in that /sys/bus/platform/drivers/coretemp will no longer appear, and /sys/devices/platform/coretemp.n will remain present if package n is hotplugged off, but hwmon users should really only be looking for the presence of the hwmon interfaces, whose behaviour remains unchanged.
--- drivers/hwmon/coretemp.c | 128 ++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 70 deletions(-)
drivers/hwmon/coretemp.c +58 -70
@@ -550,66 +550,49 @@ static void coretemp_remove_core(struct platform_data *pdata, int indx)ida_free (&pdata->ida, indx -BASE_SYSFS_ATTR_NO ); } -static int coretemp_probe (struct platform_device *pdev) +static int coretemp_device_add (int zoneid) { -struct device *dev = &pdev->dev; +struct platform_device *pdev;struct platform_data *pdata; +int err;/* Initialize the per-zone data structures */ - pdata =devm_kzalloc (dev,sizeof (struct platform_data ),GFP_KERNEL ); + pdata =kzalloc (sizeof (*pdata),GFP_KERNEL );if (!pdata)return -ENOMEM ; - pdata->pkg_id = pdev->id; + pdata->pkg_id = zoneid;ida_init (&pdata->ida); -platform_set_drvdata (pdev, pdata); - pdata->hwmon_dev =devm_hwmon_device_register_with_groups (dev,DRVNAME , - pdata,NULL ); -return PTR_ERR_OR_ZERO (pdata->hwmon_dev); -} - -static int coretemp_remove (struct platform_device *pdev) -{ -struct platform_data *pdata =platform_get_drvdata (pdev); -int i; + pdev =platform_device_alloc (DRVNAME , zoneid); +if (!pdev) { + err = -ENOMEM ; + goto err_free_pdata; + } -for (i =MAX_CORE_DATA -1 ; i >=0 ; --i) -if (pdata->core_data[i]) -coretemp_remove_core (pdata, i); + err =platform_device_add (pdev); +if (err) + goto err_put_dev; -ida_destroy (&pdata->ida); +platform_set_drvdata (pdev, pdata); + zone_devices[zoneid] = pdev;return 0 ; -} -static struct platform_driver coretemp_driver = { - .driver = { - .name =DRVNAME , - }, - .probe = coretemp_probe, - .remove = coretemp_remove, -}; +err_put_dev: +platform_device_put (pdev); +err_free_pdata: +kfree (pdata); +return err; +} -static struct platform_device *coretemp_device_add (unsigned int cpu) +static void coretemp_device_remove (int zoneid) { -int err, zoneid =topology_logical_die_id (cpu); -struct platform_device *pdev; - -if (zoneid <0 ) -return ERR_PTR (-ENOMEM ); - - pdev =platform_device_alloc (DRVNAME , zoneid); -if (!pdev) -return ERR_PTR (-ENOMEM ); - - err =platform_device_add (pdev); -if (err) { -platform_device_put (pdev); -return ERR_PTR (err); - } +struct platform_device *pdev = zone_devices[zoneid]; +struct platform_data *pdata =platform_get_drvdata (pdev); - zone_devices[zoneid] = pdev; -return pdev; +ida_destroy (&pdata->ida); +kfree (pdata); +platform_device_unregister (pdev); }static int coretemp_cpu_online (unsigned int cpu)
@@ -633,7 +616,10 @@ static int coretemp_cpu_online(unsigned int cpu)if (!cpu_has (c,X86_FEATURE_DTHERM ))return -ENODEV ; -if (!pdev) { + pdata =platform_get_drvdata (pdev); +if (!pdata->hwmon_dev) { +struct device *hwmon; +/* Check the microcode version of the CPU */ if (chk_ucode_version (cpu))return -EINVAL ;
@@ -644,9 +630,11 @@ static int coretemp_cpu_online(unsigned int cpu)* online. So, initialize per-pkg data structures and * then bring this core online. */ - pdev =coretemp_device_add (cpu); -if (IS_ERR (pdev)) -return PTR_ERR (pdev); + hwmon =hwmon_device_register_with_groups (&pdev->dev,DRVNAME , + pdata,NULL ); +if (IS_ERR (hwmon)) +return PTR_ERR (hwmon); + pdata->hwmon_dev = hwmon;/* * Check whether pkgtemp support is available.
@@ -656,7 +644,6 @@ static int coretemp_cpu_online(unsigned int cpu)coretemp_add_core (pdev, cpu,1 ); } - pdata =platform_get_drvdata (pdev);/* * Check whether a thread sibling is already online. If not add the * interface for this CPU core.
@@ -675,18 +662,14 @@ static int coretemp_cpu_offline(unsigned int cpu)struct temp_data *tdata;int i, indx =-1 , target; -/* -* Don't execute this on suspend as the device remove locks -* up the machine. -*/ +/* No need to tear down any interfaces for suspend */ if (cpuhp_tasks_frozen)return 0 ;/* If the physical CPU device does not exist, just return */ -if (!pdev) -return 0 ; - pd =platform_get_drvdata (pdev); +if (!pd->hwmon_dev) +return 0 ;for (i =0 ; i <NUM_REAL_CORES ; i++) {if (pd->cpu_map[i] ==topology_core_id (cpu)) {
@@ -718,13 +701,14 @@ static int coretemp_cpu_offline(unsigned int cpu) }/* -* If all cores in this pkg are offline, remove the device. This -* will invoke the platform driver remove function, which cleans up -* the rest. +* If all cores in this pkg are offline, remove the interface. */ + tdata = pd->core_data[PKG_SYSFS_ATTR_NO ];if (cpumask_empty (&pd->cpumask)) { - zone_devices[topology_logical_die_id (cpu)] =NULL ; -platform_device_unregister (pdev); +if (tdata) +coretemp_remove_core (pd,PKG_SYSFS_ATTR_NO ); +hwmon_device_unregister (pd->hwmon_dev); + pd->hwmon_dev =NULL ;return 0 ; }
@@ -732,7 +716,6 @@ static int coretemp_cpu_offline(unsigned int cpu)* Check whether this core is the target for the package * interface. We need to assign it to some other cpu. */ - tdata = pd->core_data[PKG_SYSFS_ATTR_NO ];if (tdata && tdata->cpu == cpu) { target =cpumask_first (&pd->cpumask);mutex_lock (&tdata->update_lock);
@@ -751,7 +734,7 @@ static enum cpuhp_state coretemp_hp_online;static int __init coretemp_init (void ) { -int err; +int i, err;/* * CPUID.06H.EAX[0] indicates whether the CPU has thermal
@@ -767,20 +750,22 @@ static int __init coretemp_init(void)if (!zone_devices)return -ENOMEM ; - err =platform_driver_register (&coretemp_driver); -if (err) - goto outzone; +for (i =0 ; i < max_zones; i++) { + err =coretemp_device_add (i); +if (err) + goto outzone; + } err =cpuhp_setup_state (CPUHP_AP_ONLINE_DYN ,"hwmon/coretemp:online" , coretemp_cpu_online, coretemp_cpu_offline);if (err <0 ) - goto outdrv; + goto outzone; coretemp_hp_online = err;return 0 ; -outdrv: -platform_driver_unregister (&coretemp_driver); outzone: +while (i--) +coretemp_device_remove (i);kfree (zone_devices);return err; }
@@ -788,8 +773,11 @@ module_init(coretemp_init) static void __exit coretemp_exit(void) { +int i; +cpuhp_remove_state (coretemp_hp_online); -platform_driver_unregister (&coretemp_driver); +for (i =0 ; i < max_zones; i++) +coretemp_device_remove (i);kfree (zone_devices); }module_exit (coretemp_exit)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 420/567 pinctrl: at91: use devm_kasprintf() to avoid potential leaks
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 1c4e5c470a56f7f7c649c0c70e603abc1eab15c4 ]
Use devm_kasprintf() instead of kasprintf() to avoid any potential leaks. At the moment drivers have no remove functionality thus there is no need for fixes tag.
--- drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++-- drivers/pinctrl/pinctrl-at91.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-at91-pio4.c +2 -2
@@ -1126,8 +1126,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) pin_desc[i].number = i;/* Pin naming convention: P(bank_name)(bank_pin_number). */ - pin_desc[i].name =kasprintf (GFP_KERNEL ,"P%c%d" , - bank +'A' , line); + pin_desc[i].name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"P%c%d" , + bank +'A' , line); group->name = group_names[i] = pin_desc[i].name; group->pin = pin_desc[i].number;
drivers/pinctrl/pinctrl-at91.c +1 -1
@@ -1891,7 +1891,7 @@ static int at91_gpio_probe(struct platform_device *pdev) }for (i =0 ; i < chip->ngpio; i++) - names[i] =kasprintf (GFP_KERNEL ,"pio%c%d" , alias_idx +'A' , i); + names[i] =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"pio%c%d" , alias_idx +'A' , i); chip->names = (const char *const *)names;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 421/567 scsi: snic: Fix memory leak with using debugfs_lookup()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit ad0e4e2fab928477f74d742e6e77d79245d3d3e7 ]
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.
--- drivers/scsi/snic/snic_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/snic/snic_debugfs.c +2 -2
@@ -451,6 +451,6 @@ void snic_trc_debugfs_init(void)void snic_trc_debugfs_term (void ) { -debugfs_remove (debugfs_lookup (TRC_FILE , snic_glob->trc_root)); -debugfs_remove (debugfs_lookup (TRC_ENABLE_FILE , snic_glob->trc_root)); +debugfs_lookup_and_remove (TRC_FILE , snic_glob->trc_root); +debugfs_lookup_and_remove (TRC_ENABLE_FILE , snic_glob->trc_root); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 422/567 HID: logitech-hidpp: Dont restart communication if not necessary
In reply to Greg Kroah-HartmanFrom: Bastien Nocera <[email protected]>
[ Upstream commit 498ba20690357691103de0f766960355247c78be ]
Don't stop and restart communication with the device unless we need to modify the connect flags used because of a device quirk.
--- drivers/hid/hid-logitech-hidpp.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
drivers/hid/hid-logitech-hidpp.c +20 -12
@@ -4049,6 +4049,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)bool connected;unsigned int connect_mask =HID_CONNECT_DEFAULT ;struct hidpp_ff_private_data data; +bool will_restart = false;/* report_fixup needs drvdata to be set before we call hid_parse */ hidpp =devm_kzalloc (&hdev->dev,sizeof (*hidpp),GFP_KERNEL );
@@ -4104,6 +4105,10 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)return ret; } +if (hidpp->quirks &HIDPP_QUIRK_DELAYED_INIT || + hidpp->quirks &HIDPP_QUIRK_UNIFYING ) + will_restart = true; +INIT_WORK (&hidpp->work, delayed_work_cb);mutex_init (&hidpp->send_mutex);init_waitqueue_head (&hidpp->wait);
@@ -4118,7 +4123,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)* Plain USB connections need to actually call start and open * on the transport driver to allow incoming data. */ - ret =hid_hw_start (hdev,0 ); + ret =hid_hw_start (hdev, will_restart ?0 : connect_mask);if (ret) {hid_err (hdev,"hw start failed\n" ); goto hid_hw_start_fail;
@@ -4155,6 +4160,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) hidpp->wireless_feature_index =0 ; else if (ret) goto hid_hw_init_fail; + ret = 0; }if (connected && (hidpp->quirks &HIDPP_QUIRK_CLASS_WTP )) {
@@ -4169,19 +4175,21 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)hidpp_connect_event (hidpp); -/* Reset the HID node state */ -hid_device_io_stop (hdev); -hid_hw_close (hdev); -hid_hw_stop (hdev); +if (will_restart) { +/* Reset the HID node state */ +hid_device_io_stop (hdev); +hid_hw_close (hdev); +hid_hw_stop (hdev); -if (hidpp->quirks &HIDPP_QUIRK_NO_HIDINPUT ) - connect_mask &= ~HID_CONNECT_HIDINPUT ; +if (hidpp->quirks &HIDPP_QUIRK_NO_HIDINPUT ) + connect_mask &= ~HID_CONNECT_HIDINPUT ; -/* Now export the actual inputs and hidraw nodes to the world */ - ret =hid_hw_start (hdev, connect_mask); -if (ret) { -hid_err (hdev,"%s:hid_hw_start returned error\n" , __func__); - goto hid_hw_start_fail; +/* Now export the actual inputs and hidraw nodes to the world */ + ret =hid_hw_start (hdev, connect_mask); +if (ret) { +hid_err (hdev,"%s:hid_hw_start returned error\n" , __func__); + goto hid_hw_start_fail; + } }if (hidpp->quirks &HIDPP_QUIRK_CLASS_G920 ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 423/567 drm: panel-orientation-quirks: Add quirk for Lenovo IdeaPad Duet 3 10IGL5
In reply to Greg Kroah-HartmanFrom: Darrell Kavanagh <[email protected]>
[ Upstream commit 38b2d8efd03d2e56431b611e3523f0158306451d ]
Another Lenovo convertable where the panel is installed landscape but is reported to the kernel as portrait.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +6 -0
@@ -278,6 +278,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad D330-10IGL"), }, .driver_data = (void *)&lcd800x1280_rightside_up, + }, { /* Lenovo IdeaPad Duet 3 10IGL5 */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "IdeaPad Duet 3 10IGL5"), + }, + .driver_data = (void *)&lcd1200x1920_rightside_up, }, { /* Lenovo Yoga Book X90F / X91F / X91L */ .matches = {/* Non exact match to match all versions */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 424/567 dm thin: add cond_resched() to various workqueue loops
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
[ Upstream commit e4f80303c2353952e6e980b23914e4214487f2a6 ]
Otherwise on resource constrained systems these workqueues may be too greedy.
--- drivers/md/dm-thin.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/dm-thin.c +2 -0
@@ -2217,6 +2217,7 @@ static void process_thin_deferred_bios(struct thin_c *tc)throttle_work_update (&pool->throttle);dm_pool_issue_prefetches (pool->pmd); } +cond_resched (); }blk_finish_plug (&plug); }
@@ -2299,6 +2300,7 @@ static void process_thin_deferred_cells(struct thin_c *tc)else pool->process_cell (tc, cell); } +cond_resched (); }while (!list_empty (&cells)); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 425/567 dm cache: add cond_resched() to various workqueue loops
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
[ Upstream commit 76227f6dc805e9e960128bcc6276647361e0827c ]
Otherwise on resource constrained systems these workqueues may be too greedy.
--- drivers/md/dm-cache-target.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/dm-cache-target.c +4 -0
@@ -1813,6 +1813,7 @@ static void process_deferred_bios(struct work_struct *ws)else commit_needed =process_bio (cache, bio) || commit_needed; +cond_resched (); }if (commit_needed)
@@ -1835,6 +1836,7 @@ static void requeue_deferred_bios(struct cache *cache)while ((bio =bio_list_pop (&bios))) { bio->bi_status =BLK_STS_DM_REQUEUE ;bio_endio (bio); +cond_resched (); } }
@@ -1875,6 +1877,8 @@ static void check_migrations(struct work_struct *ws) r =mg_start (cache, op,NULL );if (r)break ; + +cond_resched (); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 426/567 nfsd: zero out pointers after putting nfsd_files on COPY setup error
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
[ Upstream commit 1f0001d43d0c0ac2a19a34a914f6595ad97cbc1d ]
At first, I thought this might be a source of nfsd_file overputs, but the current callers seem to avoid an extra put when nfsd4_verify_copy returns an error.
Still, it's "bad form" to leave the pointers filled out when we don't have a reference to them anymore, and that might lead to bugs later. Zero them out as a defensive coding measure.
--- fs/nfsd/nfs4proc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfsd/nfs4proc.c +2 -0
@@ -1088,8 +1088,10 @@ nfsd4_verify_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,return status; out_put_dst:nfsd_file_put (*dst); + *dst =NULL ; out_put_src:nfsd_file_put (*src); + *src =NULL ; goto out; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 427/567 drm/shmem-helper: Revert accidental non-GPL export
In reply to Greg Kroah-HartmanFrom: Asahi Lina <[email protected]>
[ Upstream commit 047a754558d640eaa080fce3b22ca9f3d4e04626 ]
The referenced commit added a wrapper for drm_gem_shmem_get_pages_sgt(), but in the process it accidentally changed the export type from GPL to non-GPL. Switch it back to GPL.
--- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +1 -1
@@ -717,7 +717,7 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)return sgt; } -EXPORT_SYMBOL (drm_gem_shmem_get_pages_sgt); +EXPORT_SYMBOL_GPL (drm_gem_shmem_get_pages_sgt);/** * drm_gem_shmem_prime_import_sg_table - Produce a shmem GEM object from
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 428/567 wifi: rtl8xxxu: fixing transmisison failure for rtl8192eu
In reply to Greg Kroah-HartmanFrom: Jun ASAKA <[email protected]>
commit c6015bf3ff1ffb3caa27eb913797438a0fc634a0 upstream.
Fixing transmission failure which results in "authentication with ... timed out". This can be fixed by disable the REG_TXPAUSE.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +5 -0
@@ -1669,6 +1669,11 @@ static void rtl8192e_enable_rf(struct rt val8 =rtl8xxxu_read8 (priv,REG_PAD_CTRL1 ); val8 &= ~BIT (0 );rtl8xxxu_write8 (priv,REG_PAD_CTRL1 , val8); + +/* +* Fix transmission failure of rtl8192e. +*/ +rtl8xxxu_write8 (priv,REG_TXPAUSE ,0x00 ); }struct rtl8xxxu_fileops rtl8192eu_fops = {
Greg Kroah-Hartman
maintainerPATCH 429/567 firmware: coreboot: framebuffer: Ignore reserved pixel color bits
In reply to Greg Kroah-HartmanFrom: Alper Nebi Yasak <[email protected]>
commit e6acaf25cba14661211bb72181c35dd13b24f5b3 upstream.
The coreboot framebuffer doesn't support transparency, its 'reserved' bit field is merely padding for byte/word alignment of pixel colors [1]. When trying to match the framebuffer to a simplefb format, the kernel driver unnecessarily requires the format's transparency bit field to exactly match this padding, even if the former is zero-width.
Due to a coreboot bug [2] (fixed upstream), some boards misreport the reserved field's size as equal to its position (0x18 for both on a 'Lick' Chromebook), and the driver fails to probe where it would have otherwise worked fine with e.g. the a8r8g8b8 or x8r8g8b8 formats.
Remove the transparency comparison with reserved bits. When the bits-per-pixel and other color components match, transparency will already be in a subset of the reserved field. Not forcing it to match reserved bits allows the driver to work on the boards which misreport the reserved field. It also enables using simplefb formats that don't have transparency bits, although this doesn't currently happen due to format support and ordering in linux/platform_data/simplefb.h.
[1] https://review.coreboot.org/plugins/gitiles/coreboot/+/4.19/src/commonlib/include/commonlib/coreboot_tables.h#255
[2] https://review.coreboot.org/plugins/gitiles/coreboot/+/4.13/src/drivers/intel/fsp2_0/graphics.c#82
--- drivers/firmware/google/framebuffer-coreboot.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/google/framebuffer-coreboot.c +1 -3
@@ -43,9 +43,7 @@ static int framebuffer_probe(struct core fb->green_mask_pos == formats[i].green.offset && fb->green_mask_size == formats[i].green.length && fb->blue_mask_pos == formats[i].blue.offset && - fb->blue_mask_size == formats[i].blue.length && - fb->reserved_mask_pos == formats[i].transp.offset && - fb->reserved_mask_size == formats[i].transp.length) + fb->blue_mask_size == formats[i].blue.length) pdata.format = formats[i].name; }if (!pdata.format)
Greg Kroah-Hartman
maintainerPATCH 430/567 block: dont allow multiple bios for IOCB_NOWAIT issue
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 67d59247d4b52c917e373f05a807027756ab216f upstream.
If we're doing a large IO request which needs to be split into multiple bios for issue, then we can run into the same situation as the below marked commit fixes - parts will complete just fine, one or more parts will fail to allocate a request. This will result in a partially completed read or write request, where the caller gets EAGAIN even though parts of the IO completed just fine.
Do the same for large bios as we do for splits - fail a NOWAIT request with EAGAIN. This isn't technically fixing an issue in the below marked patch, but for stable purposes, we should have either none of them or both.
This depends on: 613b14884b85 ("block: handle bio_split_to_limits() NULL return")
--- block/fops.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
block/fops.c +18 -3
@@ -243,6 +243,24 @@ static ssize_t __blkdev_direct_IO(structbio_endio (bio);break ; } +if (iocb->ki_flags &IOCB_NOWAIT ) { +/* +* This is nonblocking IO, and we need to allocate +* another bio if we have data left to map. As we +* cannot guarantee that one of the sub bios will not +* fail getting issued FOR NOWAIT and as error results +* are coalesced across all of them, be safe and ask for +* a retry of this from blocking context. +*/ +if (unlikely (iov_iter_count (iter))) { +bio_release_pages (bio, false); +bio_clear_flag (bio,BIO_REFFED ); +bio_put (bio); +blk_finish_plug (&plug); +return -EAGAIN ; + } + bio->bi_opf |=REQ_NOWAIT ; + }if (is_read) { bio->bi_opf =REQ_OP_READ ;
@@ -252,9 +270,6 @@ static ssize_t __blkdev_direct_IO(struct bio->bi_opf =dio_bio_write_op (iocb);task_io_account_write (bio->bi_iter.bi_size); } -if (iocb->ki_flags &IOCB_NOWAIT ) - bio->bi_opf |=REQ_NOWAIT ; - dio->size += bio->bi_iter.bi_size; pos += bio->bi_iter.bi_size;
Greg Kroah-Hartman
maintainerPATCH 431/567 rtc: pm8xxx: fix set-alarm race
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit c88db0eff9722fc2b6c4d172a50471d20e08ecc6 upstream.
Make sure to disable the alarm before updating the four alarm time registers to avoid spurious alarms during the update.
Note that the disable needs to be done outside of the ctrl_reg_lock section to prevent a racing alarm interrupt from disabling the newly set alarm when the lock is released.
--- drivers/rtc/rtc-pm8xxx.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/rtc/rtc-pm8xxx.c +10 -14
@@ -220,7 +220,6 @@ static int pm8xxx_rtc_set_alarm(struct d {int rc, i;u8 value[NUM_8_BIT_RTC_REGS ]; -unsigned int ctrl_reg;unsigned long secs, irq_flags;struct pm8xxx_rtc *rtc_dd =dev_get_drvdata (dev);const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
@@ -232,6 +231,11 @@ static int pm8xxx_rtc_set_alarm(struct d secs >>=8 ; } + rc =regmap_update_bits (rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en,0 ); +if (rc) +return rc; +spin_lock_irqsave (&rtc_dd->ctrl_reg_lock, irq_flags); rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value,
@@ -241,19 +245,11 @@ static int pm8xxx_rtc_set_alarm(struct d goto rtc_rw_fail; } - rc =regmap_read (rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); -if (rc) - goto rtc_rw_fail; - -if (alarm->enabled) - ctrl_reg |= regs->alarm_en; -else - ctrl_reg &= ~regs->alarm_en; - - rc =regmap_write (rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); -if (rc) { -dev_err (dev,"Write to RTC alarm control register failed\n" ); - goto rtc_rw_fail; +if (alarm->enabled) { + rc =regmap_update_bits (rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en, regs->alarm_en); +if (rc) + goto rtc_rw_fail; } dev_dbg(dev, "Alarm Set for h:m:s=%ptRt, y-m-d=%ptRdr\n",
Greg Kroah-Hartman
maintainerPATCH 432/567 ipmi:ssif: resend_msg() cannot fail
In reply to Greg Kroah-HartmanFrom: Corey Minyard <[email protected]>
commit 95767ed78a181d5404202627499f9cde56053b96 upstream.
The resend_msg() function cannot fail, but there was error handling around using it. Rework the handling of the error, and fix the out of retries debug reporting that was wrong around this, too.
--- drivers/char/ipmi/ipmi_ssif.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-)
drivers/char/ipmi/ipmi_ssif.c +7 -21
@@ -602,7 +602,7 @@ static void ssif_alert(struct i2c_clientstart_get (ssif_info); } -static int start_resend (struct ssif_info *ssif_info); +static void start_resend (struct ssif_info *ssif_info);static void msg_done_handler (struct ssif_info *ssif_info,int result,unsigned char *data,unsigned int len)
@@ -909,31 +909,17 @@ static void msg_written_handler(struct sif (result <0 ) { ssif_info->retries_left--;if (ssif_info->retries_left >0 ) { -if (!start_resend (ssif_info)) { -ssif_inc_stat (ssif_info, send_retries); -return ; - } -/* request failed, just return the error. */ -ssif_inc_stat (ssif_info, send_errors); - -if (ssif_info->ssif_debug &SSIF_DEBUG_MSG ) -dev_dbg (&ssif_info->client->dev, -"%s: Out of retries\n" , __func__); -msg_done_handler (ssif_info, -EIO ,NULL ,0 ); +start_resend (ssif_info);return ; }ssif_inc_stat (ssif_info, send_errors); -/* -* Got an error on transmit, let the done routine -* handle it. -*/ if (ssif_info->ssif_debug &SSIF_DEBUG_MSG )dev_dbg (&ssif_info->client->dev, -"%s: Error %d\n" , __func__, result); +"%s: Out of retries\n" , __func__); -msg_done_handler (ssif_info, result,NULL ,0 ); +msg_done_handler (ssif_info, -EIO ,NULL ,0 );return ; }
@@ -996,7 +982,7 @@ static void msg_written_handler(struct s } } -static int start_resend (struct ssif_info *ssif_info) +static void start_resend (struct ssif_info *ssif_info) {int command;
@@ -1021,7 +1007,6 @@ static int start_resend(struct ssif_infossif_i2c_send (ssif_info, msg_written_handler,I2C_SMBUS_WRITE , command, ssif_info->data,I2C_SMBUS_BLOCK_DATA ); -return 0 ; } static int start_send(struct ssif_info *ssif_info,
@@ -1036,7 +1021,8 @@ static int start_send(struct ssif_info * ssif_info->retries_left =SSIF_SEND_RETRIES ;memcpy (ssif_info->data +1 , data, len); ssif_info->data_len = len; -return start_resend (ssif_info); +start_resend (ssif_info); +return 0 ; }/* Must be called with the message lock held. */
Greg Kroah-Hartman
maintainerPATCH 433/567 ipmi_ssif: Rename idle state and check
In reply to Greg Kroah-HartmanFrom: Corey Minyard <[email protected]>
commit 8230831c43a328c2be6d28c65d3f77e14c59986b upstream.
Rename the SSIF_IDLE() to IS_SSIF_IDLE(), since that is more clear, and rename SSIF_NORMAL to SSIF_IDLE, since that's more accurate.
--- drivers/char/ipmi/ipmi_ssif.c | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/char/ipmi/ipmi_ssif.c +23 -23
@@ -92,7 +92,7 @@#define SSIF_WATCH_WATCHDOG_TIMEOUT msecs_to_jiffies(250)enum ssif_intf_state { -SSIF_NORMAL , +SSIF_IDLE ,SSIF_GETTING_FLAGS ,SSIF_GETTING_EVENTS ,SSIF_CLEARING_FLAGS ,
@@ -100,8 +100,8 @@ enum ssif_intf_state {/* FIXME - add watchdog stuff. */ }; -#define SSIF_IDLE (ssif) ((ssif)->ssif_state == SSIF_NORMAL \ - && (ssif)->curr_msg == NULL) +#define IS_SSIF_IDLE (ssif) ((ssif)->ssif_state == SSIF_IDLE \ + && (ssif)->curr_msg == NULL)/* * Indexes into stats[] in ssif_info below.
@@ -348,9 +348,9 @@ static void return_hosed_msg(struct ssif/* * Must be called with the message lock held. This will release the -* message lock. Note that the caller will check SSIF_IDLE and start a -* new operation, so there is no need to check for new messages to -* start in here. +* message lock. Note that the caller will check IS_SSIF_IDLE and +* start a new operation, so there is no need to check for new +* messages to start in here. */ static void start_clear_flags (struct ssif_info *ssif_info,unsigned long *flags) {
@@ -367,7 +367,7 @@ static void start_clear_flags(struct ssiif (start_send (ssif_info, msg,3 ) !=0 ) {/* Error, just go to normal state. */ - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ; } }
@@ -382,7 +382,7 @@ static void start_flag_fetch(struct ssif mb[0 ] = (IPMI_NETFN_APP_REQUEST <<2 ); mb[1 ] =IPMI_GET_MSG_FLAGS_CMD ;if (start_send (ssif_info, mb,2 ) !=0 ) - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ; } static void check_start_send(struct ssif_info *ssif_info, unsigned long *flags,
@@ -393,7 +393,7 @@ static void check_start_send(struct ssif flags =ipmi_ssif_lock_cond (ssif_info, &oflags); ssif_info->curr_msg =NULL ; - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ;ipmi_ssif_unlock_cond (ssif_info, flags);ipmi_free_smi_msg (msg); }
@@ -407,7 +407,7 @@ static void start_event_fetch(struct ssi msg =ipmi_alloc_smi_msg ();if (!msg) { - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ;ipmi_ssif_unlock_cond (ssif_info, flags);return ; }
@@ -430,7 +430,7 @@ static void start_recv_msg_fetch(struct msg =ipmi_alloc_smi_msg ();if (!msg) { - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ;ipmi_ssif_unlock_cond (ssif_info, flags);return ; }
@@ -448,9 +448,9 @@ static void start_recv_msg_fetch(struct/* * Must be called with the message lock held. This will release the -* message lock. Note that the caller will check SSIF_IDLE and start a -* new operation, so there is no need to check for new messages to -* start in here. +* message lock. Note that the caller will check IS_SSIF_IDLE and +* start a new operation, so there is no need to check for new +* messages to start in here. */ static void handle_flags (struct ssif_info *ssif_info,unsigned long *flags) {
@@ -466,7 +466,7 @@ static void handle_flags(struct ssif_inf/* Events available. */ start_event_fetch (ssif_info, flags); else { - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ;ipmi_ssif_unlock_cond (ssif_info, flags); } }
@@ -568,7 +568,7 @@ static void watch_timeout(struct timer_lif (ssif_info->watch_timeout) {mod_timer (&ssif_info->watch_timer, jiffies + ssif_info->watch_timeout); -if (SSIF_IDLE (ssif_info)) { +if (IS_SSIF_IDLE (ssif_info)) {start_flag_fetch (ssif_info, flags);/* Releases lock */ return ; }
@@ -756,7 +756,7 @@ static void msg_done_handler(struct ssif }switch (ssif_info->ssif_state) { -case SSIF_NORMAL : +case SSIF_IDLE :ipmi_ssif_unlock_cond (ssif_info, flags);if (!msg)break ;
@@ -774,7 +774,7 @@ static void msg_done_handler(struct ssif* Error fetching flags, or invalid length, * just give up for now. */ - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ;ipmi_ssif_unlock_cond (ssif_info, flags); dev_warn(&ssif_info->client->dev, "Error getting flags: %d %d, %x\n",
@@ -809,7 +809,7 @@ static void msg_done_handler(struct ssif"Invalid response clearing flags: %x %x\n" , data[0], data[1]); } - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ;ipmi_ssif_unlock_cond (ssif_info, flags);break ;
@@ -887,7 +887,7 @@ static void msg_done_handler(struct ssif } flags =ipmi_ssif_lock_cond (ssif_info, &oflags); -if (SSIF_IDLE (ssif_info) && !ssif_info->stopping) { +if (IS_SSIF_IDLE (ssif_info) && !ssif_info->stopping) {if (ssif_info->req_events)start_event_fetch (ssif_info, flags);else if (ssif_info->req_flags)
@@ -1032,7 +1032,7 @@ static void start_next_msg(struct ssif_iunsigned long oflags; restart: -if (!SSIF_IDLE (ssif_info)) { +if (!IS_SSIF_IDLE (ssif_info)) {ipmi_ssif_unlock_cond (ssif_info, flags);return ; }
@@ -1255,7 +1255,7 @@ static void shutdown_ssif(void *send_infdev_set_drvdata (&ssif_info->client->dev,NULL );/* make sure the driver is not looking for flags any more. */ -while (ssif_info->ssif_state !=SSIF_NORMAL ) +while (ssif_info->ssif_state !=SSIF_IDLE )schedule_timeout (1 ); ssif_info->stopping = true;
@@ -1827,7 +1827,7 @@ static int ssif_probe(struct i2c_client }spin_lock_init (&ssif_info->lock); - ssif_info->ssif_state =SSIF_NORMAL ; + ssif_info->ssif_state =SSIF_IDLE ;timer_setup (&ssif_info->retry_timer, retry_timeout,0 );timer_setup (&ssif_info->watch_timer, watch_timeout,0 );
Greg Kroah-Hartman
maintainerPATCH 434/567 s390/extmem: return correct segment type in __segment_load()
In reply to Greg Kroah-HartmanFrom: Gerald Schaefer <[email protected]>
commit 8c42dd78df148c90e48efff204cce38743906a79 upstream.
Commit f05f62d04271f ("s390/vmem: get rid of memory segment list") reshuffled the call to vmem_add_mapping() in __segment_load(), which now overwrites rc after it was set to contain the segment type code.
As result, __segment_load() will now always return 0 on success, which corresponds to the segment type code SEG_TYPE_SW, i.e. a writeable segment. This results in a kernel crash when loading a read-only segment as dcssblk block device, and trying to write to it.
Instead of reshuffling code again, make sure to return the segment type on success, and also describe this rather delicate and unexpected logic in the function comment. Also initialize new segtype variable with invalid value, to prevent possible future confusion.
--- arch/s390/mm/extmem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/s390/mm/extmem.c +7 -5
@@ -289,15 +289,17 @@ segment_overlaps_others (struct dcss_seg/* * real segment loading function, called from segment_load +* Must return either an error code < 0, or the segment type code >= 0 */ static int __segment_load (char *name,int do_nonshared,unsigned long *addr,unsigned long *end) {unsigned long start_addr, end_addr, dummy;struct dcss_segment *seg; -int rc, diag_cc; +int rc, diag_cc, segtype; start_addr = end_addr =0 ; + segtype =-1 ; seg =kmalloc (sizeof (*seg),GFP_KERNEL |GFP_DMA );if (seg ==NULL ) { rc = -ENOMEM ;
@@ -326,9 +328,9 @@ __segment_load (char *name, int do_nonsh seg->res_name[8 ] ='\0' ;strlcat (seg->res_name," (DCSS)" ,sizeof (seg->res_name)); seg->res->name = seg->res_name; - rc = seg->vm_segtype; -if (rc ==SEG_TYPE_SC || - ((rc ==SEG_TYPE_SR || rc ==SEG_TYPE_ER ) && !do_nonshared)) + segtype = seg->vm_segtype; +if (segtype ==SEG_TYPE_SC || + ((segtype ==SEG_TYPE_SR || segtype ==SEG_TYPE_ER ) && !do_nonshared)) seg->res->flags |=IORESOURCE_READONLY ;/* Check for overlapping resources before adding the mapping. */
@@ -386,7 +388,7 @@ __segment_load (char *name, int do_nonsh out_free:kfree (seg); out: -return rc; +return rc <0 ? rc : segtype; }/*
Greg Kroah-Hartman
maintainerPATCH 435/567 s390: discard .interp section
In reply to Greg Kroah-HartmanFrom: Ilya Leoshkevich <[email protected]>
commit e9c9cb90e76ffaabcc7ca8f275d9e82195fd6367 upstream.
When debugging vmlinux with QEMU + GDB, the following GDB error may occur:
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint -1.
Cannot access memory at address 0xffffffffffff95c0
Command aborted.
(gdb)The reason is that, when .interp section is present, GDB tries to locate the file specified in it in memory and put a number of breakpoints there (see enable_break() function in gdb/solib-svr4.c). Sometimes GDB finds a bogus location that matches its heuristics, fails to set a breakpoint and stops. This makes further debugging impossible.
The .interp section contains misleading information anyway (vmlinux does not need ld.so), so fix by discarding it.
--- arch/s390/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+)
arch/s390/kernel/vmlinux.lds.S +1 -0
@@ -227,5 +227,6 @@ SECTIONS DISCARDS /DISCARD/ : { *(.eh_frame) + *(.interp) } }
Greg Kroah-Hartman
maintainerPATCH 436/567 s390/kprobes: fix irq mask clobbering on kprobe reenter from post_handler
In reply to Greg Kroah-HartmanFrom: Vasily Gorbik <[email protected]>
commit 42e19e6f04984088b6f9f0507c4c89a8152d9730 upstream.
Recent test_kprobe_missed kprobes kunit test uncovers the following error (reported when CONFIG_DEBUG_ATOMIC_SLEEP is enabled):
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 662, name: kunit_try_catchpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
no locks held by kunit_try_catch/662.
irq event stamp: 280 hardirqs last enabled at (279): [<00000003e60a3d42>] __do_pgm_check+0x17a/0x1c0 hardirqs last disabled at (280): [<00000003e3bd774a>] kprobe_exceptions_notify+0x27a/0x318 softirqs last enabled at (0): [<00000003e3c5c890>] copy_process+0x14a8/0x4c80 softirqs last disabled at (0): [<0000000000000000>] 0x0 CPU: 46 PID: 662 Comm: kunit_try_catch Tainted: G N 6.2.0-173644-g44c18d77f0c0 #2 Hardware name: IBM 3931 A01 704 (LPAR) Call Trace: [<00000003e60a3a00>] dump_stack_lvl+0x120/0x198 [<00000003e3d02e82>] __might_resched+0x60a/0x668 [<00000003e60b9908>] __mutex_lock+0xc0/0x14e0 [<00000003e60bad5a>] mutex_lock_nested+0x32/0x40 [<00000003e3f7b460>] unregister_kprobe+0x30/0xd8 [<00000003e51b2602>] test_kprobe_missed+0xf2/0x268 [<00000003e51b5406>] kunit_try_run_case+0x10e/0x290 [<00000003e51b7dfa>] kunit_generic_run_threadfn_adapter+0x62/0xb8 [<00000003e3ce30f8>] kthread+0x2d0/0x398 [<00000003e3b96afa>] __ret_from_fork+0x8a/0xe8 [<00000003e60ccada>] ret_from_fork+0xa/0x40
The reason for this error report is that kprobes handling code failed to restore irqs.
The problem is that when kprobe is triggered from another kprobe post_handler current sequence of enable_singlestep / disable_singlestep is the following:enable_singlestep <- original kprobe (saves kprobe_saved_imask) enable_singlestep <- kprobe triggered from post_handler (clobbers kprobe_saved_imask) disable_singlestep <- kprobe triggered from post_handler (restores kprobe_saved_imask) disable_singlestep <- original kprobe (restores wrong clobbered kprobe_saved_imask)
There is just one kprobe_ctlblk per cpu and both calls saves and loads irq mask to kprobe_saved_imask. To fix the problem simply move resume_execution (which calls disable_singlestep) before calling post_handler. This also fixes the problem that post_handler is called with pt_regs which were not yet adjusted after single-stepping.
--- arch/s390/kernel/kprobes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/kernel/kprobes.c +1 -2
@@ -394,12 +394,11 @@ static int post_kprobe_handler(struct ptif (!p)return 0 ; +resume_execution (p, regs);if (kcb->kprobe_status !=KPROBE_REENTER && p->post_handler) { kcb->kprobe_status =KPROBE_HIT_SSDONE ; p->post_handler (p, regs,0 ); } - -resume_execution (p, regs);pop_kprobe (kcb);preempt_enable_no_resched ();
Greg Kroah-Hartman
maintainerPATCH 437/567 s390/kprobes: fix current_kprobe never cleared after kprobes reenter
In reply to Greg Kroah-HartmanFrom: Vasily Gorbik <[email protected]>
commit cd57953936f2213dfaccce10d20f396956222c7d upstream.
Recent test_kprobe_missed kprobes kunit test uncovers the following problem. Once kprobe is triggered from another kprobe (kprobe reenter), all future kprobes on this cpu are considered as kprobe reenter, thus pre_handler and post_handler are not being called and kprobes are counted as "missed".
Commit b9599798f953 ("[S390] kprobes: activation and deactivation") introduced a simpler scheme for kprobes (de)activation and status tracking by using push_kprobe/pop_kprobe, which supposed to work for both initial kprobe entry as well as kprobe reentry and helps to avoid handling those two cases differently. The problem is that a sequence of calls in case of kprobes reenter:push_kprobe() <- NULL (current_kprobe)push_kprobe() <- kprobe1 (current_kprobe)pop_kprobe() -> kprobe1 (current_kprobe)pop_kprobe() -> kprobe1 (current_kprobe)
leaves "kprobe1" as "current_kprobe" on this cpu, instead of setting it to NULL. In fact push_kprobe/pop_kprobe can only store a single state (there is just one prev_kprobe in kprobe_ctlblk). Which is a hack but sufficient, there is no need to have another prev_kprobe just to store NULL. To make a simple and backportable fix simply reset "prev_kprobe" when kprobe is poped from this "stack". No need to worry about "kprobe_status" in this case, because its value is only checked when current_kprobe != NULL.
--- arch/s390/kernel/kprobes.c | 1 + 1 file changed, 1 insertion(+)
arch/s390/kernel/kprobes.c +1 -0
@@ -233,6 +233,7 @@ static void pop_kprobe(struct kprobe_ctl {__this_cpu_write (current_kprobe, kcb->prev_kprobe.kp); kcb->kprobe_status = kcb->prev_kprobe.status; + kcb->prev_kprobe.kp =NULL ; }NOKPROBE_SYMBOL (pop_kprobe);
Greg Kroah-Hartman
maintainerPATCH 438/567 cifs: Fix uninitialized memory read in smb3_qfs_tcon()
In reply to Greg Kroah-HartmanFrom: Volker Lendecke <[email protected]>
commit d447e794a37288ec7a080aa1b044a8d9deebbab7 upstream.
oparms was not fully initialized
--- fs/cifs/smb2ops.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/cifs/smb2ops.c +7 -6
@@ -966,12 +966,13 @@ smb3_qfs_tcon(const unsigned int xid, ststruct cifs_fid fid;struct cached_fid *cfid =NULL ; - oparms.tcon = tcon; - oparms.desired_access =FILE_READ_ATTRIBUTES ; - oparms.disposition =FILE_OPEN ; - oparms.create_options =cifs_create_options (cifs_sb,0 ); - oparms.fid = &fid; - oparms.reconnect = false; + oparms = (struct cifs_open_parms ) { + .tcon = tcon, + .desired_access =FILE_READ_ATTRIBUTES , + .disposition =FILE_OPEN , + .create_options =cifs_create_options (cifs_sb,0 ), + .fid = &fid, + }; rc =open_cached_dir (xid, tcon,"" , cifs_sb, &cfid);if (rc ==0 )
Greg Kroah-Hartman
maintainerPATCH 439/567 btrfs: hold block group refcount during async discard
In reply to Greg Kroah-HartmanFrom: Boris Burkov <[email protected]>
commit 2b5463fcbdfb24e898916bcae2b1359042d26963 upstream.
Async discard does not acquire the block group reference count while it holds a reference on the discard list. This is generally OK, as the paths which destroy block groups tend to try to synchronize on cancelling async discard work. However, relying on cancelling work requires careful analysis to be sure it is safe from races with unpinning scheduling more work.
While I am unable to find a race with unpinning in the current code for either the unused bgs or relocation paths, I believe we have one in an older version of auto relocation in a Meta internal build. This suggests that this is in fact an error prone model, and could be fragile to future changes to these bg deletion paths.
To make this ownership more clear, add a refcount for async discard. If work is queued for a block group, its refcount should be incremented, and when work is completed or canceled, it should be decremented.
--- fs/btrfs/discard.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-)
fs/btrfs/discard.c +38 -3
@@ -77,6 +77,7 @@ static struct list_head *get_discard_lisstatic void __add_to_discard_list (struct btrfs_discard_ctl *discard_ctl,struct btrfs_block_group *block_group) { +lockdep_assert_held (&discard_ctl->lock);if (!btrfs_run_discard_work (discard_ctl))return ;
@@ -88,6 +89,8 @@ static void __add_to_discard_list(struct BTRFS_DISCARD_DELAY); block_group->discard_state =BTRFS_DISCARD_RESET_CURSOR ; } +if (list_empty (&block_group->discard_list)) +btrfs_get_block_group (block_group);list_move_tail (&block_group->discard_list,get_discard_list (discard_ctl, block_group));
@@ -107,8 +110,12 @@ static void add_to_discard_list(struct bstatic void add_to_discard_unused_list (struct btrfs_discard_ctl *discard_ctl,struct btrfs_block_group *block_group) { +bool queued; +spin_lock (&discard_ctl->lock); + queued = !list_empty (&block_group->discard_list); +if (!btrfs_run_discard_work (discard_ctl)) {spin_unlock (&discard_ctl->lock);return ;
@@ -120,6 +127,8 @@ static void add_to_discard_unused_list(s block_group->discard_eligible_time = (ktime_get_ns () +BTRFS_DISCARD_UNUSED_DELAY ); block_group->discard_state =BTRFS_DISCARD_RESET_CURSOR ; +if (!queued) +btrfs_get_block_group (block_group);list_add_tail (&block_group->discard_list, &discard_ctl->discard_list[BTRFS_DISCARD_INDEX_UNUSED ]);
@@ -130,6 +139,7 @@ static bool remove_from_discard_list(str struct btrfs_block_group *block_group) {bool running = false; +bool queued = false;spin_lock (&discard_ctl->lock);
@@ -139,7 +149,16 @@ static bool remove_from_discard_list(str } block_group->discard_eligible_time =0 ; + queued = !list_empty (&block_group->discard_list);list_del_init (&block_group->discard_list); +/* +* If the block group is currently running in the discard workfn, we +* don't want to deref it, since it's still being used by the workfn. +* The workfn will notice this case and deref the block group when it is +* finished. +*/ +if (queued && !running) +btrfs_put_block_group (block_group);spin_unlock (&discard_ctl->lock);
@@ -212,10 +231,12 @@ again:if (block_group && now >= block_group->discard_eligible_time) {if (block_group->discard_index ==BTRFS_DISCARD_INDEX_UNUSED && block_group->used !=0 ) { -if (btrfs_is_block_group_data_only (block_group)) +if (btrfs_is_block_group_data_only (block_group)) {__add_to_discard_list (discard_ctl, block_group); -else + }else {list_del_init (&block_group->discard_list); +btrfs_put_block_group (block_group); + } goto again; }if (block_group->discard_state ==BTRFS_DISCARD_RESET_CURSOR ) {
@@ -502,6 +523,15 @@ static void btrfs_discard_workfn(structspin_lock (&discard_ctl->lock); discard_ctl->prev_discard = trimmed; discard_ctl->prev_discard_time = now; +/* +* If the block group was removed from the discard list while it was +* running in this workfn, then we didn't deref it, since this function +* still owned that reference. But we set the discard_ctl->block_group +* back to NULL, so we can use that condition to know that now we need +* to deref the block_group. +*/ +if (discard_ctl->block_group ==NULL ) +btrfs_put_block_group (block_group); discard_ctl->block_group =NULL ;__btrfs_discard_schedule_work (discard_ctl, now, false);spin_unlock (&discard_ctl->lock);
@@ -638,8 +668,12 @@ void btrfs_discard_punt_unused_bgs_list(list_for_each_entry_safe (block_group, next, &fs_info->unused_bgs, bg_list) {list_del_init (&block_group->bg_list); -btrfs_put_block_group (block_group);btrfs_discard_queue_work (&fs_info->discard_ctl, block_group); +/* +* This put is for the get done by btrfs_mark_bg_unused. +* Queueing discard incremented it for discard's reference. +*/ +btrfs_put_block_group (block_group); }spin_unlock (&fs_info->unused_bgs_lock); }
@@ -669,6 +703,7 @@ static void btrfs_discard_purge_list(strif (block_group->used ==0 )btrfs_mark_bg_unused (block_group);spin_lock (&discard_ctl->lock); +btrfs_put_block_group (block_group); } }spin_unlock (&discard_ctl->lock);
Greg Kroah-Hartman
maintainerPATCH 440/567 locking/rwsem: Prevent non-first waiter from spinning in down_write() slowpath
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
commit b613c7f31476c44316bfac1af7cac714b7d6bef9 upstream.
A non-first waiter can potentially spin in the for loop of rwsem_down_write_slowpath() without sleeping but fail to acquire the lock even if the rwsem is free if the following sequence happens:
Non-first RT waiter First waiter Lock holder
------------------- ------------ -----------
Acquire wait_lock
rwsem_try_write_lock():
Set handoff bit if RT or
wait too long
Set waiter->handoff_set
Release wait_lock
Acquire wait_lock
Inherit waiter->handoff_set
Release wait_lock
Clear owner
Release lock
if (waiter.handoff_set) {
rwsem_spin_on_owner(();
if (OWNER_NULL)
goto trylock_again;
}
trylock_again:
Acquire wait_lock
rwsem_try_write_lock():
if (first->handoff_set && (waiter != first))
return false; Release wait_lock
A non-first waiter cannot really acquire the rwsem even if it mistakenly believes that it can spin on OWNER_NULL value. If that waiter happens to be an RT task running on the same CPU as the first waiter, it can block the first waiter from acquiring the rwsem leading to live lock. Fix this problem by making sure that a non-first waiter cannot spin in the slowpath loop without sleeping.
--- kernel/locking/rwsem.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
kernel/locking/rwsem.c +9 -10
@@ -586,18 +586,16 @@ static inline bool rwsem_try_write_lock(*/ if (first->handoff_set && (waiter != first))return false; - -/* -* First waiter can inherit a previously set handoff -* bit and spin on rwsem if lock acquisition fails. -*/ -if (waiter == first) - waiter->handoff_set = true; } new = count;if (count &RWSEM_LOCK_MASK ) { +/* +* A waiter (first or not) can set the handoff bit +* if it is an RT task or wait in the wait queue +* for too long. +*/ if (has_handoff || (!rt_task (waiter->task) && !time_after (jiffies, waiter->timeout)))return false;
@@ -613,11 +611,12 @@ static inline bool rwsem_try_write_lock( }while (!atomic_long_try_cmpxchg_acquire (&sem->count, &count, new));/* -* We have either acquired the lock with handoff bit cleared or -* set the handoff bit. +* We have either acquired the lock with handoff bit cleared or set +* the handoff bit. Only the first waiter can have its handoff_set +* set here to enable optimistic spinning in slowpath loop. */ if (new &RWSEM_FLAG_HANDOFF ) { - waiter->handoff_set = true; + first->handoff_set = true;lockevent_inc (rwsem_wlock_handoff);return false; }
Greg Kroah-Hartman
maintainerPATCH 441/567 ksmbd: fix wrong data area length for smb2 lock request
In reply to Greg Kroah-HartmanFrom: Namjae Jeon <[email protected]>
commit 8f8c43b125882ac14372f8dca0c8e50a59e78d79 upstream.
When turning debug mode on, The following error message from ksmbd_smb2_check_message() is coming.
ksmbd: cli req padded more than expected. Length 112 not 88 for cmd:10 mid:14
data area length calculation for smb2 lock request in smb2_get_data_area_len() is incorrect.
--- fs/ksmbd/smb2misc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/ksmbd/smb2misc.c +3 -7
@@ -150,15 +150,11 @@ static int smb2_get_data_area_len(unsignbreak ;case SMB2_LOCK : { -int lock_count; +unsigned short lock_count; -/* -* smb2_lock request size is 48 included single -* smb2_lock_element structure size. -*/ - lock_count =le16_to_cpu (((struct smb2_lock_req *)hdr)->LockCount) -1 ; + lock_count =le16_to_cpu (((struct smb2_lock_req *)hdr)->LockCount);if (lock_count >0 ) { - *off = __SMB2_HEADER_STRUCTURE_SIZE +48 ; + *off = offsetof(struct smb2_lock_req , locks); *len =sizeof (struct smb2_lock_element ) * lock_count; }break ;
Greg Kroah-Hartman
maintainerPATCH 442/567 ksmbd: do not allow the actual frame length to be smaller than the rfc1002 length
In reply to Greg Kroah-HartmanFrom: Namjae Jeon <[email protected]>
commit fb533473d1595fe79ecb528fda1de33552b07178 upstream.
ksmbd allowed the actual frame length to be smaller than the rfc1002 length. If allowed, it is possible to allocates a large amount of memory that can be limited by credit management and can eventually cause memory exhaustion problem. This patch do not allow it except SMB2 Negotiate request which will be validated when message handling proceeds. Also, Allow a message that padded to 8byte boundary.
--- fs/ksmbd/smb2misc.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
fs/ksmbd/smb2misc.c +10 -11
@@ -414,20 +414,19 @@ int ksmbd_smb2_check_message(struct ksmb goto validate_credit;/* -* windows client also pad up to 8 bytes when compounding. -* If pad is longer than eight bytes, log the server behavior -* (once), since may indicate a problem but allow it and -* continue since the frame is parseable. +* SMB2 NEGOTIATE request will be validated when message +* handling proceeds. */ -if (clc_len < len) { -ksmbd_debug (SMB , -"cli req padded more than expected. Length %d not %d for cmd:%d mid:%llu\n" , - len, clc_len, command, -le64_to_cpu (hdr->MessageId)); +if (command ==SMB2_NEGOTIATE_HE ) goto validate_credit; - } -ksmbd_debug (SMB , +/* +* Allow a message that padded to 8byte boundary. +*/ +if (clc_len < len && (len - clc_len) <8 ) + goto validate_credit; + +pr_err_ratelimited ("cli req too short, len %d not %d. cmd:%d mid:%llu\n" , len, clc_len, command,le64_to_cpu (hdr->MessageId));
Greg Kroah-Hartman
maintainerPATCH 443/567 ARM: dts: exynos: correct HDMI phy compatible in Exynos4
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit af1c89ddb74f170eccd5a57001d7317560b638ea upstream.
The HDMI phy compatible was missing vendor prefix.
--- arch/arm/boot/dts/exynos4.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/exynos4.dtsi +1 -1
@@ -605,7 +605,7 @@ status = "disabled"; hdmi_i2c_phy: hdmiphy@38 { - compatible = "exynos4210-hdmiphy"; + compatible = "samsung,exynos4210-hdmiphy"; reg = <0x38>; }; };
Greg Kroah-Hartman
maintainerPATCH 444/567 hfs: fix missing hfs_bnode_get() in __hfs_bnode_create
In reply to Greg Kroah-HartmanFrom: Liu Shixin <[email protected]>
commit a9dc087fd3c484fd1ed18c5efb290efaaf44ce03 upstream.
Syzbot found a kernel BUG in hfs_bnode_put():
kernel BUG at fs/hfs/bnode.c:466!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 3634 Comm: kworker/u4:5 Not tainted 6.1.0-rc7-syzkaller-00190-g97ee9d1c1696 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Workqueue: writeback wb_workfn (flush-7:0) RIP: 0010:hfs_bnode_put+0x46f/0x480 fs/hfs/bnode.c:466 Code: 8a 80 ff e9 73 fe ff ff 89 d9 80 e1 07 80 c1 03 38 c1 0f 8c a0 fe ff ff 48 89 df e8 db 8a 80 ff e9 93 fe ff ff e8 a1 68 2c ff <0f> 0b e8 9a 68 2c ff 0f 0b 0f 1f 84 00 00 00 00 00 55 41 57 41 56 RSP: 0018:ffffc90003b4f258 EFLAGS: 00010293 RAX: ffffffff825e318f RBX: 0000000000000000 RCX: ffff8880739dd7c0 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffc90003b4f430 R08: ffffffff825e2d9b R09: ffffed10045157d1 R10: ffffed10045157d1 R11: 1ffff110045157d0 R12: ffff8880228abe80 R13: ffff88807016c000 R14: dffffc0000000000 R15: ffff8880228abe00 FS: 0000000000000000(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa6ebe88718 CR3: 000000001e93d000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> hfs_write_inode+0x1bc/0xb40 write_inode fs/fs-writeback.c:1440 [inline] __writeback_single_inode+0x4d6/0x670 fs/fs-writeback.c:1652 writeback_sb_inodes+0xb3b/0x18f0 fs/fs-writeback.c:1878 __writeback_inodes_wb+0x125/0x420 fs/fs-writeback.c:1949 wb_writeback+0x440/0x7b0 fs/fs-writeback.c:2054 wb_check_start_all fs/fs-writeback.c:2176 [inline] wb_do_writeback fs/fs-writeback.c:2202 [inline] wb_workfn+0x827/0xef0 fs/fs-writeback.c:2235 process_one_work+0x877/0xdb0 kernel/workqueue.c:2289 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436 kthread+0x266/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 </TASK>
The BUG_ON() is triggered at here:
/* Dispose of resources used by a node */
void hfs_bnode_put(struct hfs_bnode *node)
{
if (node) { <skipped>
BUG_ON(!atomic_read(&node->refcnt)); <- we have issue here!!!! <skipped>
}
}
By tracing the refcnt, I found the node is created by hfs_bmap_alloc() with refcnt 1. Then the node is used by hfs_btree_write(). There is a missing of hfs_bnode_get() after find the node. The issue happened in following path:
<alloc>
hfs_bmap_alloc
hfs_bnode_find
__hfs_bnode_create <- allocate a new node with refcnt 1.
hfs_bnode_put <- decrease the refcnt
<write>
hfs_btree_write
hfs_bnode_find
__hfs_bnode_create
hfs_bnode_findhash <- find the node without refcnt increased.
hfs_bnode_put <- trigger the BUG_ON() since refcnt is 0.
--- fs/hfs/bnode.c | 1 + 1 file changed, 1 insertion(+)
fs/hfs/bnode.c +1 -0
@@ -281,6 +281,7 @@ static struct hfs_bnode *__hfs_bnode_cre tree->node_hash[hash] = node; tree->node_hash_cnt++; }else { +hfs_bnode_get (node2);spin_unlock (&tree->hash_lock);kfree (node);wait_event (node2->lock_wq, !test_bit (HFS_BNODE_NEW , &node2->flags));
Greg Kroah-Hartman
maintainerPATCH 445/567 fs: hfsplus: fix UAF issue in hfsplus_put_super
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
commit 07db5e247ab5858439b14dd7cc1fe538b9efcf32 upstream.
The current hfsplus_put_super first calls hfs_btree_close on sbi->ext_tree, then invokes iput on sbi->hidden_dir, resulting in an use-after-free issue in hfsplus_release_folio.
As shown in hfsplus_fill_super, the error handling code also calls iput before hfs_btree_close.
To fix this error, we move all iput calls before hfsplus_btree_close.
Note that this patch is tested on Syzbot.
--- fs/hfsplus/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/hfsplus/super.c +2 -2
@@ -295,11 +295,11 @@ static void hfsplus_put_super(struct suphfsplus_sync_fs (sb,1 ); } +iput (sbi->alloc_file); +iput (sbi->hidden_dir);hfs_btree_close (sbi->attr_tree);hfs_btree_close (sbi->cat_tree);hfs_btree_close (sbi->ext_tree); -iput (sbi->alloc_file); -iput (sbi->hidden_dir);kfree (sbi->s_vhdr_buf);kfree (sbi->s_backup_vhdr_buf);unload_nls (sbi->nls);
Greg Kroah-Hartman
maintainerPATCH 446/567 exfat: fix reporting fs error when reading dir beyond EOF
In reply to Greg Kroah-HartmanFrom: Yuezhang Mo <[email protected]>
commit 706fdcac002316893434d753be8cfb549fe1d40d upstream.
Since seekdir() does not check whether the position is valid, the position may exceed the size of the directory. We found that for a directory with discontinuous clusters, if the position exceeds the size of the directory and the excess size is greater than or equal to the cluster size, exfat_readdir() will return -EIO, causing a file system error and making the file system unavailable.
Reproduce this bug by:
seekdir(dir, dir_size + cluster_size);
dirent = readdir(dir);
The following log will be printed if mount with 'errors=remount-ro'.
[11166.712896] exFAT-fs (sdb1): error, invalid access to FAT (entry 0xffffffff) [11166.712905] exFAT-fs (sdb1): Filesystem has been set read-only
--- fs/exfat/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/dir.c +1 -1
@@ -103,7 +103,7 @@ static int exfat_readdir(struct inode *i clu.dir = ei->hint_bmap.clu; } -while (clu_offset >0 ) { +while (clu_offset >0 && clu.dir !=EXFAT_EOF_CLUSTER ) {if (exfat_get_next_cluster (sb, &(clu.dir)))return -EIO ;
Greg Kroah-Hartman
maintainerPATCH 447/567 exfat: fix unexpected EOF while reading dir
In reply to Greg Kroah-HartmanFrom: Yuezhang Mo <[email protected]>
commit 6cb5d1a16a51d080fbc1649a5144cbc5ca7d6f88 upstream.
If the position is not aligned with the dentry size, the return value of readdir() will be NULL and errno is 0, which means the end of the directory stream is reached.
If the position is aligned with dentry size, but there is no file or directory at the position, exfat_readdir() will continue to get dentry from the next dentry. So the dentry gotten by readdir() may not be at the position.
After this commit, if the position is not aligned with the dentry size, round the position up to the dentry size and continue to get the dentry.
--- fs/exfat/dir.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/exfat/dir.c +1 -4
@@ -237,10 +237,7 @@ static int exfat_iterate(struct file *fi fake_offset =1 ; } -if (cpos & (DENTRY_SIZE -1 )) { - err = -ENOENT ; - goto unlock; - } + cpos =round_up (cpos,DENTRY_SIZE );/* name buffer should be allocated before use */ err =exfat_alloc_namebuf (nb);
Greg Kroah-Hartman
maintainerPATCH 448/567 exfat: redefine DIR_DELETED as the bad cluster number
In reply to Greg Kroah-HartmanFrom: Sungjong Seo <[email protected]>
commit bdaadfd343e3cba49ad0b009ff4b148dad0fa404 upstream.
When a file or a directory is deleted, the hint for the cluster of its parent directory in its in-memory inode is set as DIR_DELETED. Therefore, DIR_DELETED must be one of invalid cluster numbers. According to the exFAT specification, a volume can have at most 2^32-11 clusters. However, DIR_DELETED is wrongly defined as 0xFFFF0321, which could be a valid cluster number. To fix it, let's redefine DIR_DELETED as 0xFFFFFFF7, the bad cluster number.
--- fs/exfat/exfat_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/exfat_fs.h +1 -1
@@ -42,7 +42,7 @@ enum {#define ES_2_ENTRIES 2#define ES_ALL_ENTRIES 0 -#define DIR_DELETED 0xFFFF0321 +#define DIR_DELETED 0xFFFFFFF7/* type values */ #define TYPE_UNUSED 0x0000
Greg Kroah-Hartman
maintainerPATCH 449/567 exfat: fix inode->i_blocks for non-512 byte sector size device
In reply to Greg Kroah-HartmanFrom: Yuezhang Mo <[email protected]>
commit 39c1ce8eafc0ff64fb9e28536ccc7df6a8e2999d upstream.
inode->i_blocks is not real number of blocks, but 512 byte ones.
--- fs/exfat/file.c | 3 +-- fs/exfat/inode.c | 6 ++---- fs/exfat/namei.c | 2 +- fs/exfat/super.c | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-)
fs/exfat/file.c +1 -2
@@ -251,8 +251,7 @@ void exfat_truncate(struct inode *inode,else mark_inode_dirty (inode); - inode->i_blocks =round_up (i_size_read (inode), sbi->cluster_size) >> - inode->i_blkbits; + inode->i_blocks =round_up (i_size_read (inode), sbi->cluster_size) >>9 ; write_size: aligned_size =i_size_read (inode);if (aligned_size & (blocksize -1 )) {
fs/exfat/inode.c +2 -4
@@ -243,8 +243,7 @@ static int exfat_map_cluster(struct inodreturn err; }/* end of if != DIR_DELETED */ - inode->i_blocks += - num_to_be_allocated << sbi->sect_per_clus_bits; + inode->i_blocks +=EXFAT_CLU_TO_B (num_to_be_allocated, sbi) >>9 ;/* * Move *clu pointer along FAT chains (hole care) because the
@@ -602,8 +601,7 @@ static int exfat_fill_inode(struct inodeexfat_save_attr (inode, info->attr); - inode->i_blocks =round_up (i_size_read (inode), sbi->cluster_size) >> - inode->i_blkbits; + inode->i_blocks =round_up (i_size_read (inode), sbi->cluster_size) >>9 ; inode->i_mtime = info->mtime; inode->i_ctime = info->mtime; ei->i_crtime = info->crtime;
fs/exfat/namei.c +1 -1
@@ -398,7 +398,7 @@ static int exfat_find_empty_entry(struct ei->i_size_ondisk += sbi->cluster_size; ei->i_size_aligned += sbi->cluster_size; ei->flags = p_dir->flags; - inode->i_blocks +=1 << sbi->sect_per_clus_bits; + inode->i_blocks += sbi->cluster_size >>9 ; }return dentry;
fs/exfat/super.c +1 -2
@@ -364,8 +364,7 @@ static int exfat_read_root(struct inode inode->i_op = &exfat_dir_inode_operations; inode->i_fop = &exfat_dir_operations; - inode->i_blocks =round_up (i_size_read (inode), sbi->cluster_size) >> - inode->i_blkbits; + inode->i_blocks =round_up (i_size_read (inode), sbi->cluster_size) >>9 ; ei->i_pos = ((loff_t )sbi->root_dir <<32 ) |0xffffffff ; ei->i_size_aligned =i_size_read (inode); ei->i_size_ondisk =i_size_read (inode);
Greg Kroah-Hartman
maintainerPATCH 450/567 fs: dlm: dont set stop rx flag after node reset
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
commit 15c63db8e86a72e0d5cfb9bf0cd1870e39a3e5fe upstream.
Similar to the stop tx flag, the rx flag should warn about a dlm message being received at DLM_FIN state change, when we are assuming no other dlm application messages. If we receive a FIN message and we are in the state DLM_FIN_WAIT2 we call midcomms_node_reset() which puts the midcomms node into DLM_CLOSED state. Afterwards we should not set the DLM_NODE_FLAG_STOP_RX flag any more. This patch changes the setting DLM_NODE_FLAG_STOP_RX in those state changes when we receive a FIN message and we assume there will be no other dlm application messages received until we hit DLM_CLOSED state.
--- fs/dlm/midcomms.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/dlm/midcomms.c +1 -2
@@ -504,6 +504,7 @@ static void dlm_midcomms_receive_buffer(break ;case DLM_FIN_WAIT1 : node->state =DLM_CLOSING ; +set_bit (DLM_NODE_FLAG_STOP_RX , &node->flags);pr_debug ("switch node %d to state %s\n" , node->nodeid,dlm_state_str (node->state));break ;
@@ -524,8 +525,6 @@ static void dlm_midcomms_receive_buffer(return ; }spin_unlock (&node->state_lock); - -set_bit (DLM_NODE_FLAG_STOP_RX , &node->flags);break ;default :WARN_ON (test_bit (DLM_NODE_FLAG_STOP_RX , &node->flags));
Greg Kroah-Hartman
maintainerPATCH 451/567 fs: dlm: move sending fin message into state change handling
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
commit a58496361802070996f9bd76e941d109c4a85ebd upstream.
This patch moves the send fin handling, which should appear in a specific state change, into the state change handling while the per node state_lock is held. I experienced issues with other messages because we changed the state and a fin message was sent out in a different state.
--- fs/dlm/midcomms.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-)
fs/dlm/midcomms.c +9 -24
@@ -394,7 +394,7 @@ static int dlm_send_fin(struct midcomms_struct dlm_mhandle *mh;char *ppc; - mh =dlm_midcomms_get_mhandle (node->nodeid, mb_len,GFP_NOFS , &ppc); + mh =dlm_midcomms_get_mhandle (node->nodeid, mb_len,GFP_ATOMIC , &ppc);if (!mh)return -ENOMEM ;
@@ -498,8 +498,8 @@ static void dlm_midcomms_receive_buffer( node->state =DLM_LAST_ACK ;pr_debug ("switch node %d to state %s case 1\n" , node->nodeid,dlm_state_str (node->state)); -spin_unlock (&node->state_lock); - goto send_fin; +set_bit (DLM_NODE_FLAG_STOP_RX , &node->flags); +dlm_send_fin (node, dlm_pas_fin_ack_rcv); }break ;case DLM_FIN_WAIT1 :
@@ -542,12 +542,6 @@ static void dlm_midcomms_receive_buffer(log_print_ratelimited ("ignore dlm msg because seq mismatch, seq: %u, expected: %u, nodeid: %d" , seq, node->seq_next, node->nodeid); } - -return ; - -send_fin: -set_bit (DLM_NODE_FLAG_STOP_RX , &node->flags); -dlm_send_fin (node, dlm_pas_fin_ack_rcv); } static struct midcomms_node *
@@ -1268,11 +1262,11 @@ void dlm_midcomms_remove_member(int nodecase DLM_CLOSE_WAIT :/* passive shutdown DLM_LAST_ACK case 2 */ node->state =DLM_LAST_ACK ; -spin_unlock (&node->state_lock); -pr_debug ("switch node %d to state %s case 2\n" , node->nodeid,dlm_state_str (node->state)); - goto send_fin; +set_bit (DLM_NODE_FLAG_STOP_RX , &node->flags); +dlm_send_fin (node, dlm_pas_fin_ack_rcv); +break ;case DLM_LAST_ACK :/* probably receive fin caught it, do nothing */ break ;
@@ -1288,12 +1282,6 @@ void dlm_midcomms_remove_member(int nodespin_unlock (&node->state_lock);srcu_read_unlock (&nodes_srcu, idx); -return ; - -send_fin: -set_bit (DLM_NODE_FLAG_STOP_RX , &node->flags); -dlm_send_fin (node, dlm_pas_fin_ack_rcv); -srcu_read_unlock (&nodes_srcu, idx); }static void midcomms_node_release (struct rcu_head *rcu)
@@ -1324,6 +1312,7 @@ static void midcomms_shutdown(struct mid node->state =DLM_FIN_WAIT1 ;pr_debug ("switch node %d to state %s case 2\n" , node->nodeid,dlm_state_str (node->state)); +dlm_send_fin (node, dlm_act_fin_ack_rcv);break ;case DLM_CLOSED :/* we have what we want */
@@ -1337,12 +1326,8 @@ static void midcomms_shutdown(struct mid }spin_unlock (&node->state_lock); -if (node->state ==DLM_FIN_WAIT1 ) { -dlm_send_fin (node, dlm_act_fin_ack_rcv); - -if (DLM_DEBUG_FENCE_TERMINATION ) -msleep (5000 ); - } +if (DLM_DEBUG_FENCE_TERMINATION ) +msleep (5000 );/* wait for other side dlm + fin */ ret = wait_event_timeout(node->shutdown_wait,
Greg Kroah-Hartman
maintainerPATCH 452/567 fs: dlm: send FIN ack back in right cases
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
commit 00908b3388255fc1d3782b744d07f327712f401f upstream.
This patch moves to send a ack back for receiving a FIN message only when we are in valid states. In other cases and there might be a sender waiting for a ack we just let it timeout at the senders time and hopefully all other cleanups will remove the FIN message on their sending queue. As an example we should never send out an ACK being in LAST_ACK state or we cannot assume a working socket communication when we are in CLOSED state.
--- fs/dlm/midcomms.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/dlm/midcomms.c +5 -4
@@ -366,7 +366,7 @@ static int dlm_send_ack(int nodeid, uintstruct dlm_msg *msg;char *ppc; - msg =dlm_lowcomms_new_msg (nodeid, mb_len,GFP_NOFS , &ppc, + msg =dlm_lowcomms_new_msg (nodeid, mb_len,GFP_ATOMIC , &ppc,NULL ,NULL );if (!msg)return -ENOMEM ;
@@ -478,15 +478,14 @@ static void dlm_midcomms_receive_buffer(switch (p->header.h_cmd) {case DLM_FIN : -/* send ack before fin */ -dlm_send_ack (node->nodeid, node->seq_next); -spin_lock (&node->state_lock);pr_debug ("receive fin msg from node %d with state %s\n" , node->nodeid,dlm_state_str (node->state));switch (node->state) {case DLM_ESTABLISHED : +dlm_send_ack (node->nodeid, node->seq_next); + node->state =DLM_CLOSE_WAIT ;pr_debug ("switch node %d to state %s\n" , node->nodeid,dlm_state_str (node->state));
@@ -503,12 +502,14 @@ static void dlm_midcomms_receive_buffer( }break ;case DLM_FIN_WAIT1 : +dlm_send_ack (node->nodeid, node->seq_next); node->state =DLM_CLOSING ;set_bit (DLM_NODE_FLAG_STOP_RX , &node->flags);pr_debug ("switch node %d to state %s\n" , node->nodeid,dlm_state_str (node->state));break ;case DLM_FIN_WAIT2 : +dlm_send_ack (node->nodeid, node->seq_next);midcomms_node_reset (node);pr_debug ("switch node %d to state %s\n" , node->nodeid,dlm_state_str (node->state));
Greg Kroah-Hartman
maintainerPATCH 453/567 f2fs: fix information leak in f2fs_move_inline_dirents()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 9a5571cff4ffcfc24847df9fd545cc5799ac0ee5 upstream.
When converting an inline directory to a regular one, f2fs is leaking uninitialized memory to disk because it doesn't initialize the entire directory block. Fix this by zero-initializing the block.
This bug was introduced by commit 4ec17d688d74 ("f2fs: avoid unneeded initializing when converting inline dentry"), which didn't consider the security implications of leaking uninitialized memory to disk.
This was found by running xfstest generic/435 on a KMSAN-enabled kernel.
--- fs/f2fs/inline.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
fs/f2fs/inline.c +6 -7
@@ -427,18 +427,17 @@ static int f2fs_move_inline_dirents(stru dentry_blk =page_address (page); +/* +* Start by zeroing the full block, to ensure that all unused space is +* zeroed and no uninitialized memory is leaked to disk. +*/ +memset (dentry_blk,0 ,F2FS_BLKSIZE ); +make_dentry_ptr_inline (dir, &src, inline_dentry);make_dentry_ptr_block (dir, &dst, dentry_blk);/* copy data from inline dentry block to new dentry block */ memcpy (dst.bitmap, src.bitmap, src.nr_bitmap); -memset (dst.bitmap + src.nr_bitmap,0 , dst.nr_bitmap - src.nr_bitmap); -/* -* we do not need to zero out remainder part of dentry and filename -* field, since we have used bitmap for marking the usage status of -* them, besides, we can also ignore copying/zeroing reserved space -* of dentry block, because them haven't been used so far. -*/ memcpy (dst.dentry, src.dentry,SIZE_OF_DIR_ENTRY * src.max);memcpy (dst.filename, src.filename, src.max *F2FS_SLOT_LEN );
Greg Kroah-Hartman
maintainerPATCH 454/567 f2fs: fix cgroup writeback accounting with fs-layer encryption
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 844545c51a5b2a524b22a2fe9d0b353b827d24b4 upstream.
When writing a page from an encrypted file that is using filesystem-layer encryption (not inline encryption), f2fs encrypts the pagecache page into a bounce page, then writes the bounce page.
It also passes the bounce page to wbc_account_cgroup_owner(). That's incorrect, because the bounce page is a newly allocated temporary page that doesn't have the memory cgroup of the original pagecache page. This makes wbc_account_cgroup_owner() not account the I/O to the owner of the pagecache page as it should.
Fix this by always passing the pagecache page towbc_account_cgroup_owner().
--- fs/f2fs/data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/data.c +3 -3
@@ -677,7 +677,7 @@ int f2fs_submit_page_bio(struct f2fs_io_ }if (fio->io_wbc && !is_read_io (fio->op)) -wbc_account_cgroup_owner (fio->io_wbc, page,PAGE_SIZE ); +wbc_account_cgroup_owner (fio->io_wbc, fio->page,PAGE_SIZE );__attach_io_flag (fio);bio_set_op_attrs (bio, fio->op, fio->op_flags);
@@ -887,7 +887,7 @@ alloc_new: }if (fio->io_wbc) -wbc_account_cgroup_owner (fio->io_wbc, page,PAGE_SIZE ); +wbc_account_cgroup_owner (fio->io_wbc, fio->page,PAGE_SIZE );inc_page_count (fio->sbi,WB_DATA_TYPE (page));
@@ -961,7 +961,7 @@ alloc_new: }if (fio->io_wbc) -wbc_account_cgroup_owner (fio->io_wbc, bio_page,PAGE_SIZE ); +wbc_account_cgroup_owner (fio->io_wbc, fio->page,PAGE_SIZE ); io->last_block_in_bio = fio->new_blkaddr;
Greg Kroah-Hartman
maintainerPATCH 455/567 ocfs2: fix defrag path triggering jbd2 ASSERT
In reply to Greg Kroah-HartmanFrom: Heming Zhao via Ocfs2-devel <[email protected]>
commit 60eed1e3d45045623e46944ebc7c42c30a4350f0 upstream.
code path:
ocfs2_ioctl_move_extents
ocfs2_move_extents
ocfs2_defrag_extent
__ocfs2_move_extent
+ ocfs2_journal_access_di
+ ocfs2_split_extent //sub-paths call jbd2_journal_restart
+ ocfs2_journal_dirty //crash by jbs2 ASSERT
crash stacks:
PID: 11297 TASK: ffff974a676dcd00 CPU: 67 COMMAND: "defragfs.ocfs2"
#0 [ffffb25d8dad3900] machine_kexec at ffffffff8386fe01
#1 [ffffb25d8dad3958] __crash_kexec at ffffffff8395959d
#2 [ffffb25d8dad3a20] crash_kexec at ffffffff8395a45d
#3 [ffffb25d8dad3a38] oops_end at ffffffff83836d3f
#4 [ffffb25d8dad3a58] do_trap at ffffffff83833205
#5 [ffffb25d8dad3aa0] do_invalid_op at ffffffff83833aa6
#6 [ffffb25d8dad3ac0] invalid_op at ffffffff84200d18
[exception RIP: jbd2_journal_dirty_metadata+0x2ba]
RIP: ffffffffc09ca54a RSP: ffffb25d8dad3b70 RFLAGS: 00010207
RAX: 0000000000000000 RBX: ffff9706eedc5248 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffff97337029ea28 RDI: ffff9706eedc5250
RBP: ffff9703c3520200 R8: 000000000f46b0b2 R9: 0000000000000000
R10: 0000000000000001 R11: 00000001000000fe R12: ffff97337029ea28
R13: 0000000000000000 R14: ffff9703de59bf60 R15: ffff9706eedc5250
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #7 [ffffb25d8dad3ba8] ocfs2_journal_dirty at ffffffffc137fb95 [ocfs2] #8 [ffffb25d8dad3be8] __ocfs2_move_extent at ffffffffc139a950 [ocfs2] #9 [ffffb25d8dad3c80] ocfs2_defrag_extent at ffffffffc139b2d2 [ocfs2]
Analysis
This bug has the same root cause of 'commit 7f27ec978b0e ("ocfs2: call ocfs2_journal_access_di() before ocfs2_journal_dirty() in ocfs2_write_end_nolock()")'. For this bug, jbd2_journal_restart() is called by ocfs2_split_extent() during defragmenting.
How to fix
For ocfs2_split_extent() can handle journal operations totally by itself. Caller doesn't need to call journal access/dirty pair, and caller only needs to call journal start/stop pair. The fix method is to remove journal access/dirty from __ocfs2_move_extent().
The discussion for this patch:
https://oss.oracle.com/pipermail/ocfs2-devel/2023-February/000647.html
--- fs/ocfs2/move_extents.c | 10 ---------- 1 file changed, 10 deletions(-)
fs/ocfs2/move_extents.c +0 -10
@@ -105,14 +105,6 @@ static int __ocfs2_move_extent(handle_t*/ replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED ; - ret =ocfs2_journal_access_di (handle,INODE_CACHE (inode), - context->et.et_root_bh, -OCFS2_JOURNAL_ACCESS_WRITE ); -if (ret) { -mlog_errno (ret); - goto out; - } - ret =ocfs2_split_extent (handle, &context->et, path, index, &replace_rec, context->meta_ac, &context->dealloc);
@@ -121,8 +113,6 @@ static int __ocfs2_move_extent(handle_t goto out; } -ocfs2_journal_dirty (handle, context->et.et_root_bh); - context->new_phys_cpos = new_p_cpos;/*