6.18.65-rc1 review
Greg Kroah-Hartman
maintainerPATCH 350/2151 RDMA/hns: Limit gmv_entry_num to avoid memory waste
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit bb464eeadd301c3a53e9f92a2a472b73c42b74c4 ]
The GMV entry is a HW object corresponding to a GID. Since gid_table_len is already limited to a maximum of 256, there is no need to allocate memory for those extra GMV entries as they will never be touched.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -2
@@ -2180,8 +2180,7 @@ static void apply_func_caps(struct hns_roce_dev *hr_dev) caps->gmv_bt_num * (HNS_HW_PAGE_SIZE / caps->gmv_entry_sz)); - caps->gmv_entry_num = caps->gmv_bt_num * (HNS_HW_PAGE_SIZE / - caps->gmv_entry_sz); + caps->gmv_entry_num = caps->gid_table_len[0 ]; }else {u32 func_num =max_t (u32,1 , hr_dev->func_num);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/2151 RDMA/hns: Fix GID capacity loss in 64K system
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 95761b8736c938759032e8d4eb42074d39d13007 ]
Our HW always handles GMV BT pages with a fixed 4K size, but the driver calculates the needed GMV BT pages number with PAGE_SIZE, which is 64K in 64K system. Only the first 4K (GMV index 0-127) can be reached by HW, causing GID capacity loss and memory waste.
Split a single 64K BT page into multiple 4K pages and register them to HW per 4K block so that HW can correctly reach all GMV entries.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 37 +++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +29 -8
@@ -4113,18 +4113,39 @@ static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type,static int config_gmv_ba_to_hw (struct hns_roce_dev *hr_dev,unsigned long obj,dma_addr_t base_addr) { +u32 obj_num_per_bt =HNS_HW_PAGE_SIZE / hr_dev->caps.gmv_entry_sz; +u32 chunk_size =1 << (hr_dev->caps.gmv_buf_pg_sz +PAGE_SHIFT ); +u32 bt_num_per_chunk = chunk_size /HNS_HW_PAGE_SIZE ; +u32 first = obj / obj_num_per_bt; +u32 last =min (first + bt_num_per_chunk, hr_dev->caps.gmv_bt_num);struct hns_roce_cmq_desc desc; -struct hns_roce_cmq_req *req = (struct hns_roce_cmq_req *)desc.data; -u32 idx = obj / (HNS_HW_PAGE_SIZE / hr_dev->caps.gmv_entry_sz); -u64 addr =to_hr_hw_page_addr (base_addr); +struct hns_roce_cmq_req *req; +u64 addr; +int ret; +u32 i; -hns_roce_cmq_setup_basic_desc (&desc,HNS_ROCE_OPC_CFG_GMV_BT , false); +/* The GMV BT entry of hardware covers a fixed 4K region, so a buffer +* chunk larger than 4K must be registered to hardware with one BT +* entry per 4K block, otherwise the GMV entries beyond the first +* 4K of the chunk are unreachable. +*/ +for (i = first; i < last; i++) { +hns_roce_cmq_setup_basic_desc (&desc,HNS_ROCE_OPC_CFG_GMV_BT , + false); + req = (struct hns_roce_cmq_req *)desc.data; -hr_reg_write (req,CFG_GMV_BT_BA_L ,lower_32_bits (addr)); -hr_reg_write (req,CFG_GMV_BT_BA_H ,upper_32_bits (addr)); -hr_reg_write (req,CFG_GMV_BT_IDX , idx); + addr =to_hr_hw_page_addr (base_addr + + (u64)(i - first) *HNS_HW_PAGE_SIZE ); +hr_reg_write (req,CFG_GMV_BT_BA_L ,lower_32_bits (addr)); +hr_reg_write (req,CFG_GMV_BT_BA_H ,upper_32_bits (addr)); +hr_reg_write (req,CFG_GMV_BT_IDX , i); -return hns_roce_cmq_send (hr_dev, &desc,1 ); + ret =hns_roce_cmq_send (hr_dev, &desc,1 ); +if (ret) +return ret; + } + +return 0 ; } static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/2151 usb: image: microtek: stop SG processing after transfer errors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Diego Fernando Mancera Gomez <[email protected]>
[ Upstream commit d937ca39cc44a01ce64865dd25b1e205a05ae3a0 ]
When an SG URB completes with an error, mts_do_sg() calls mts_transfer_cleanup(), which completes the SCSI command through scsi_done(). However, the callback continues advancing the scatterlist and may submit another URB for a command that has already been completed.
Return immediately after the cleanup so that no further processing is performed on the completed command.
--- drivers/usb/image/microtek.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/image/microtek.c +1 -0
@@ -495,6 +495,7 @@ static void mts_do_sg (struct urb* transfer)if (unlikely (status)) {set_host_byte (context->srb, (status == -ENOENT ?DID_ABORT :DID_ERROR ));mts_transfer_cleanup (transfer); +return ; } context->curr_sg =sg_next (context->curr_sg);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/2151 USB: usbmon: fix null-ptr-deref in mon_bus_remove() when mon_bus_init() fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangong.Han <[email protected]>
[ Upstream commit 0c6cae0f56239e3274b30dbe5b362cd297ccacc7 ]
When mon_bus_init() fails to allocate the mon_bus struct, it returns without setting ubus->mon_bus, so mbus->mon_bus remains NULL. mon_bus_add() intentionally ignores this failure because the USB core does not require monitoring to be established for normal operation. However, when the HCD is later removed, usb_remove_hcd() fires the USB_BUS_REMOVE notifier which calls mon_bus_remove(), it dereferences ubus->mon_bus without checking for NULL, causing a null-ptr deference.
Fix this by adding a NULL check for mbus at the top of mon_bus_remove(). If mon_bus_init() failed, ubus->mon_bus is NULL, meaning the bus was never tracked by the monitor, so there is nothing to clean up and returning early is correct.
--- drivers/usb/mon/mon_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/mon/mon_main.c +3 -0
@@ -199,6 +199,9 @@ static void mon_bus_remove(struct usb_bus *ubus) {struct mon_bus *mbus = ubus->mon_bus; +if (mbus ==NULL ) +return ; +mutex_lock (&mon_lock);list_del (&mbus->bus_link);if (mbus->text_inited)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/2151 USB: pci-quirks: Release EHCI device reference
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit e93731c29f749d5b2495a67109d1f0804ab3b89d ]
for_each_pci_dev() holds a reference to the current device. The Intel EHCI lookup breaks as soon as it finds a match, so the iterator does not get a chance to drop that reference on its next iteration.
Release the reference before leaving the loop.
--- drivers/usb/host/pci-quirks.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/pci-quirks.c +1 -0
@@ -1073,6 +1073,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)if (companion->class ==PCI_CLASS_SERIAL_USB_EHCI && companion->vendor ==PCI_VENDOR_ID_INTEL ) { ehci_found = true; +pci_dev_put (companion);break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/2151 usb-storage: alauda: do not do DMA from the stack
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit ec67dacb75ebd11fbe6d727e6f37c0ef5e3d3431 ]
alauda_check_status2(), alauda_get_redu_data(), alauda_erase_block(), alauda_read_block_raw() and alauda_write_block() build their commands in stack arrays and pass them to usb_stor_bulk_transfer_buf(). alauda_check_status2() and alauda_erase_block() also read the reply back into a stack array.
usb_stor_msg_common() sets URB_NO_TRANSFER_DMA_MAP only when the buffer is us->iobuf. Every other buffer reaches usb_hcd_map_urb_for_dma(), which has warned and returned -EAGAIN for a buffer on the stack since commit 4568136620c6 ("usb: core: Check URB setup_packet and transfer_buffer sanity"). On a host controller that uses DMA, all of these commands fail.
Use us->iobuf, as alauda_reset_media() in this driver and the other usb-storage subdrivers already do. The command is sent before the reply is read, so both can use it; sddr09_read_status() does the same.
--- drivers/usb/storage/alauda.c | 70 ++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 22 deletions(-)
drivers/usb/storage/alauda.c +48 -22
@@ -500,11 +500,14 @@ static int alauda_check_media(struct us_data *us)static int alauda_check_status2 (struct us_data *us) {int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_GET_STATUS2 , -0 ,0 ,0 ,0 ,3 ,0 ,MEDIA_PORT (us) - }; -unsigned char data[3 ]; +unsigned char *command = us->iobuf; +unsigned char *data = us->iobuf; + +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_GET_STATUS2 ; + command[6 ] =3 ; + command[8 ] =MEDIA_PORT (us); rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );
@@ -530,10 +533,15 @@ static int alauda_check_status2(struct us_data *us)static int alauda_get_redu_data (struct us_data *us,u16 pba,unsigned char *data) {int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_GET_REDU_DATA , -PBA_HI (pba),PBA_ZONE (pba),0 ,PBA_LO (pba),0 ,0 ,MEDIA_PORT (us) - }; +unsigned char *command = us->iobuf; + +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_GET_REDU_DATA ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba); + command[8 ] =MEDIA_PORT (us); rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );
@@ -702,14 +710,20 @@ static void alauda_ensure_map_for_zone(struct us_data *us, unsigned int zone)static int alauda_erase_block (struct us_data *us,u16 pba) {int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_ERASE_BLOCK ,PBA_HI (pba), -PBA_ZONE (pba),0 ,PBA_LO (pba),0x02 ,0 ,MEDIA_PORT (us) - }; -unsigned char buf[2 ]; +unsigned char *command = us->iobuf; +unsigned char *buf = us->iobuf;usb_stor_dbg (us,"Erasing PBA %d\n" , pba); +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_ERASE_BLOCK ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba); + command[6 ] =0x02 ; + command[8 ] =MEDIA_PORT (us); + rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );if (rc !=USB_STOR_XFER_GOOD )
@@ -732,13 +746,19 @@ static int alauda_read_block_raw(struct us_data *us, u16 pba, unsigned int page, unsigned int pages, unsigned char *data) { int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_READ_BLOCK ,PBA_HI (pba), -PBA_ZONE (pba),0 ,PBA_LO (pba) + page, pages,0 ,MEDIA_PORT (us) - }; +unsigned char *command = us->iobuf;usb_stor_dbg (us,"pba %d page %d count %d\n" , pba, page, pages); +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_READ_BLOCK ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba) + page; + command[6 ] = pages; + command[8 ] =MEDIA_PORT (us); + rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );if (rc !=USB_STOR_XFER_GOOD )
@@ -783,13 +803,19 @@ static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data) {int rc;struct alauda_info *info = (struct alauda_info *) us->extra; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_WRITE_BLOCK ,PBA_HI (pba), -PBA_ZONE (pba),0 ,PBA_LO (pba),32 ,0 ,MEDIA_PORT (us) - }; +unsigned char *command = us->iobuf;usb_stor_dbg (us,"pba %d\n" , pba); +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_WRITE_BLOCK ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba); + command[6 ] =32 ; + command[8 ] =MEDIA_PORT (us); + rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );if (rc !=USB_STOR_XFER_GOOD )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/2151 usb-storage: alauda: check the return value of alauda_read_map()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit eb882419790c6710646904c6b25132189152cf33 ]
alauda_ensure_map_for_zone() ignores the value alauda_read_map() returns. On failure lba_to_pba[zone] and pba_to_lba[zone] are left NULL, and both callers dereference them immediately:
pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset];
alauda_read_map() returns USB_STOR_TRANSPORT_ERROR when either kcalloc() fails or an alauda_get_redu_data() transfer fails, so one failed bulk transfer is enough to reach the NULL dereference.
Return that value from alauda_ensure_map_for_zone() and check it in alauda_read_data() and alauda_write_lba().
--- drivers/usb/storage/alauda.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/usb/storage/alauda.c +11 -4
@@ -697,11 +697,13 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)* Checks to see whether we have already mapped a certain zone * If we haven't, the map is generated */ -static void alauda_ensure_map_for_zone (struct us_data *us,unsigned int zone) +static int alauda_ensure_map_for_zone (struct us_data *us,unsigned int zone) {if (MEDIA_INFO (us).lba_to_pba[zone] ==NULL ||MEDIA_INFO (us).pba_to_lba[zone] ==NULL ) -alauda_read_map (us, zone); +return alauda_read_map (us, zone); + +return 0 ; }/*
@@ -849,7 +851,9 @@ static int alauda_write_lba(struct us_data *us, u16 lba,unsigned int new_pba_offset;unsigned int zone = lba / uzonesize; -alauda_ensure_map_for_zone (us, zone); + result =alauda_ensure_map_for_zone (us, zone); +if (result !=USB_STOR_TRANSPORT_GOOD ) +return result; pba =MEDIA_INFO (us).lba_to_pba[zone][lba_offset];if (pba ==1 ) {
@@ -980,7 +984,10 @@ static int alauda_read_data(struct us_data *us, unsigned long address,unsigned int lba_offset = lba - (zone * uzonesize);unsigned int pages;u16 pba; -alauda_ensure_map_for_zone (us, zone); + + result =alauda_ensure_map_for_zone (us, zone); +if (result !=USB_STOR_TRANSPORT_GOOD ) +break ;/* Not overflowing capacity? */ if (lba >= max_lba) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/2151 usb-storage: alauda: fix out-of-bounds zone index
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit c4542993c071fcafe7335698bf52650dee7e3555 ]
MEDIA_INFO(us).lba_to_pba and .pba_to_lba are arrays of num_zones pointers, allocated by kcalloc() in alauda_init_media(). alauda_ensure_map_for_zone() reads lba_to_pba[zone] and pba_to_lba[zone], and when either is NULL alauda_read_map() writes a pointer back to both. Two separate errors let zone reach num_zones, one element past the end.
max_lba is capacity >> (blockshift + pageshift), which counts physical blocks, but zone is lba / uzonesize and uzonesize is 125/128 of zonesize. On a 16 MB card (alauda_card_ids id 0x73) num_zones is 1 and uzonesize is 1000, so lba 1000 to 1023 pass the bounds check and index element 1 of a one-element array.
alauda_read_data() also calls alauda_ensure_map_for_zone() before it compares lba against max_lba, so any larger lba is used as an index before the check rejects it. alauda_write_data() already checks first.
Bound lba by num_zones * uzonesize on both paths and move the read side's call below the check. alauda_transport() reports num_zones * uzonesize * blocksize for READ_CAPACITY, so the new bound is exactly the range the device advertises and no block becomes unreachable.
sd never issues an lba past the reported capacity; an SG_IO READ_10 can.
--- drivers/usb/storage/alauda.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/usb/storage/alauda.c +12 -6
@@ -949,6 +949,7 @@ static int alauda_read_data(struct us_data *us, unsigned long address,unsigned char *buffer;u16 lba, max_lba;unsigned int page, len, offset; +unsigned int num_zones;unsigned int blockshift =MEDIA_INFO (us).blockshift;unsigned int pageshift =MEDIA_INFO (us).pageshift;unsigned int blocksize =MEDIA_INFO (us).blocksize;
@@ -973,7 +974,9 @@ static int alauda_read_data(struct us_data *us, unsigned long address,/* Figure out the initial LBA and page */ lba = address >> blockshift; page = (address &MEDIA_INFO (us).blockmask); - max_lba =MEDIA_INFO (us).capacity >> (blockshift + pageshift); + num_zones =MEDIA_INFO (us).capacity >> (MEDIA_INFO (us).zoneshift + + blockshift + pageshift); + max_lba = num_zones * uzonesize; result =USB_STOR_TRANSPORT_GOOD ; offset =0 ;
@@ -985,10 +988,6 @@ static int alauda_read_data(struct us_data *us, unsigned long address,unsigned int pages;u16 pba; - result =alauda_ensure_map_for_zone (us, zone); -if (result !=USB_STOR_TRANSPORT_GOOD ) -break ; -/* Not overflowing capacity? */ if (lba >= max_lba) { usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n",
@@ -997,6 +996,10 @@ static int alauda_read_data(struct us_data *us, unsigned long address,break ; } + result =alauda_ensure_map_for_zone (us, zone); +if (result !=USB_STOR_TRANSPORT_GOOD ) +break ; +/* Find number of pages we can read in this block */ pages =min (sectors, blocksize - page); len = pages << pageshift;
@@ -1052,6 +1055,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address,unsigned int pagesize =MEDIA_INFO (us).pagesize;struct scatterlist *sg;u16 lba, max_lba; +unsigned int num_zones;int result;/*
@@ -1078,7 +1082,9 @@ static int alauda_write_data(struct us_data *us, unsigned long address,/* Figure out the initial LBA and page */ lba = address >> blockshift; page = (address &MEDIA_INFO (us).blockmask); - max_lba =MEDIA_INFO (us).capacity >> (pageshift + blockshift); + num_zones =MEDIA_INFO (us).capacity >> (MEDIA_INFO (us).zoneshift + + blockshift + pageshift); + max_lba = num_zones *MEDIA_INFO (us).uzonesize; result =USB_STOR_TRANSPORT_GOOD ; offset =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/2151 usb: musb: da8xx: depopulate OF children on remove
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 4b30c89fb36924983be652bb24fc49e20390bf27 ]
da8xx_probe() creates CPPI platform devices with of_platform_populate(), but da8xx_remove() unregisters only the separately created MUSB device and the generic PHY. The OF children therefore remain registered after the glue driver is unbound.
Pair the successful population with of_platform_depopulate() during remove. Unregister the MUSB device first because it reuses the parent DT node but was not created by of_platform_populate().
--- drivers/usb/musb/da8xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/musb/da8xx.c +1 -0
@@ -592,6 +592,7 @@ static void da8xx_remove(struct platform_device *pdev)struct da8xx_glue *glue =platform_get_drvdata (pdev);platform_device_unregister (glue->musb); +of_platform_depopulate (&pdev->dev);usb_phy_generic_unregister (glue->usb_phy); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/2151 usb: musb: da8xx: depopulate OF children on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 8d70a378e702141424e27e0b8341e421f058635d ]
da8xx_probe() creates the CPPI child devices before registering the MUSB platform device. If population partially succeeds or the later MUSB registration fails, the probe path unregisters the generic PHY but leaves the OF children registered under a parent whose probe failed.
Depopulate the OF children before unregistering the PHY on both failure paths. Use one cleanup label so each resource is unwound in reverse publication order without introducing an unused label.
--- drivers/usb/musb/da8xx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/musb/da8xx.c +4 -3
@@ -562,7 +562,7 @@ static int da8xx_probe(struct platform_device *pdev) ret =of_platform_populate (pdev->dev.of_node,NULL , da8xx_auxdata_lookup, &pdev->dev);if (ret) - goto err_unregister_phy; + goto err_depopulate; pinfo = da8xx_dev_info; pinfo.parent = &pdev->dev;
@@ -577,12 +577,13 @@ static int da8xx_probe(struct platform_device *pdev) ret =PTR_ERR_OR_ZERO (glue->musb);if (ret) {dev_err (&pdev->dev,"failed to register musb device: %d\n" , ret); - goto err_unregister_phy; + goto err_depopulate; }return 0 ; -err_unregister_phy: +err_depopulate: +of_platform_depopulate (&pdev->dev);usb_phy_generic_unregister (glue->usb_phy);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/2151 dmaengine: sprd: use clk_bulk API to fix clock imbalance
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaithanya Lagisetty <[email protected]>
[ Upstream commit d09cd5e8bbc98969b5333015b45c525078ac0f6f ]
sprd_dma_enable() enabled sdev->clk and then the optional ashb_clk. If enabling ashb_clk failed, sdev->clk was left enabled: both callers (probe and resume) treat a non-zero return as "nothing was enabled" and bail out, leaking sdev->clk.
Convert the driver to the clk_bulk API. clk_bulk_prepare_enable() enables all clocks and unwinds them on failure, and clk_bulk_disable_unprepare() disables them, which fixes the imbalance and simplifies the enable/disable paths. Both clocks are fetched with devm_clk_bulk_get_optional(); the optional ashb_eb clock simply becomes a NULL entry that the bulk helpers treat as a no-op, while the mandatory enable clock is still checked explicitly.
--- drivers/dma/sprd-dma.c | 45 ++++++++++++------------------------------ 1 file changed, 13 insertions(+), 32 deletions(-)
drivers/dma/sprd-dma.c +13 -32
@@ -208,8 +208,7 @@ struct sprd_dma_chn {struct sprd_dma_dev {struct dma_device dma_dev;void __iomem *glb_base; -struct clk *clk; -struct clk *ashb_clk; +struct clk_bulk_data clks[2 ];int irq;u32 total_chns; struct sprd_dma_chn channels[] __counted_by(total_chns);
@@ -260,31 +259,12 @@ static void sprd_dma_chn_update(struct sprd_dma_chn *schan, u32 reg,static int sprd_dma_enable (struct sprd_dma_dev *sdev) { -int ret; - - ret =clk_prepare_enable (sdev->clk); -if (ret) -return ret; - -/* -* The ashb_clk is optional and only for AGCP DMA controller, so we -* need add one condition to check if the ashb_clk need enable. -*/ -if (!IS_ERR (sdev->ashb_clk)) - ret =clk_prepare_enable (sdev->ashb_clk); - -return ret; +return clk_bulk_prepare_enable (ARRAY_SIZE (sdev->clks), sdev->clks); }static void sprd_dma_disable (struct sprd_dma_dev *sdev) { -clk_disable_unprepare (sdev->clk); - -/* -* Need to check if we need disable the optional ashb_clk for AGCP DMA. -*/ -if (!IS_ERR (sdev->ashb_clk)) -clk_disable_unprepare (sdev->ashb_clk); +clk_bulk_disable_unprepare (ARRAY_SIZE (sdev->clks), sdev->clks); }static void sprd_dma_set_uid (struct sprd_dma_chn *schan)
@@ -1140,16 +1120,17 @@ static int sprd_dma_probe(struct platform_device *pdev)if (!sdev)return -ENOMEM ; - sdev->clk =devm_clk_get (&pdev->dev,"enable" ); -if (IS_ERR (sdev->clk)) { -dev_err (&pdev->dev,"get enable clock failed\n" ); -return PTR_ERR (sdev->clk); - } +/* The ashb_eb clock is optional and only present for AGCP DMA */ + sdev->clks[0 ].id ="enable" ; + sdev->clks[1 ].id ="ashb_eb" ; + ret =devm_clk_bulk_get_optional (&pdev->dev,ARRAY_SIZE (sdev->clks), + sdev->clks); +if (ret) +return dev_err_probe (&pdev->dev, ret,"get clocks failed\n" ); -/* ashb clock is optional for AGCP DMA */ - sdev->ashb_clk =devm_clk_get (&pdev->dev,"ashb_eb" ); -if (IS_ERR (sdev->ashb_clk)) -dev_warn (&pdev->dev,"no optional ashb eb clock\n" ); +if (!sdev->clks[0 ].clk) +return dev_err_probe (&pdev->dev, -ENOENT , +"get enable clock failed\n" );/* * We have three DMA controllers: AP DMA, AON DMA and AGCP DMA. For AGCP
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/2151 firmware: arm_scmi: Protect xfer->async_done with xfer->lock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roland Dreier <[email protected]>
[ Upstream commit 49fc5bc04eec2b7687d49ccceb7adf6ace640a3b ]
Asynchronous SCMI commands are completed by a delayed response. The RX path signals the response with complete(xfer->async_done). Unlike xfer->done, xfer->async_done is a pointer to a completion owned by whoever is waiting for the delayed response, and it stays valid only for as long as that waiter is still waiting. In do_xfer_with_response() it is a DECLARE_COMPLETION_ONSTACK() in the caller's stack frame.
Nothing serialises the RX path against a waiter that gives up on a timeout. scmi_msg_response_validate() does read xfer->async_done under xfer->lock, and documents that as a requirement, but the lock is dropped again before scmi_handle_response() dereferences the pointer, and neither the arming nor the disarming side takes it at all. So a delayed response arriving just as the wait times out can be signalled on a completion that is already gone:
waiter RX path (IRQ context)
------ ---------------------
do_xfer_with_response():
xfer->async_done = &async_response
do_xfer(xfer)
wait_for_completion_timeout(xfer->async_done, tmo)
/* returns 0, gives up */
/* response receive interrupt */
scmi_handle_response():
scmi_xfer_command_acquire()
lock xfer->lock
validate: async_done != NULL
unlock xfer->lock
xfer->async_done = NULL
return -ETIMEDOUT
/* async_response goes out of scope */
complete(xfer->async_done)That last complete() has two possible bad outcomes: it either dereferences the NULL just stored by the waiter or - if that store is not yet visible on the RX CPU - it takes a lock and writes to a stack frame that the waiter may already have returned from.
Fix this by making xfer->lock cover xfer->async_done end-to-end. Add helpers to arm and disarm it under the lock, use them on both the regular and the raw paths, and have the RX path read and signal the completion under that same lock. A waiter that is timing out then either completes its disarm before the RX path looks, in which case the delayed response is dropped, or blocks in the disarm until the RX path is done with the completion, in which case the completion is still alive.
Log the dropped case, so every path where a delayed response that was matched to a pending xfer and then discarded produces an error. (This is the same treatment scmi_msg_response_validate() already gives a delayed response that arrives after the waiter has disarmed the xfer)
--- drivers/firmware/arm_scmi/common.h | 22 ++++++++++++++++ drivers/firmware/arm_scmi/driver.c | 37 +++++++++++++++++++++++---- drivers/firmware/arm_scmi/protocols.h | 9 ++++--- drivers/firmware/arm_scmi/raw_mode.c | 4 +-- 4 files changed, 62 insertions(+), 10 deletions(-)
drivers/firmware/arm_scmi/common.h +22 -0
@@ -279,6 +279,28 @@ static inline bool is_polling_enabled(struct scmi_chan_info *cinfo,is_transport_polling_capable (desc); } +/** +* scmi_xfer_async_response_arm - Arm the delayed response completion +* +* @xfer: A reference to the xfer to arm +* @async_done: The completion to signal upon reception of a delayed response, +* or NULL to disarm @xfer. +*/ +static inline void scmi_xfer_async_response_arm (struct scmi_xfer *xfer, +struct completion *async_done) +{ +unsigned long flags; + +spin_lock_irqsave (&xfer->lock, flags); + xfer->async_done = async_done; +spin_unlock_irqrestore (&xfer->lock, flags); +} + +static inline void scmi_xfer_async_response_disarm (struct scmi_xfer *xfer) +{ +scmi_xfer_async_response_arm (xfer,NULL ); +} +void scmi_xfer_raw_put (const struct scmi_handle *handle,struct scmi_xfer *xfer);struct scmi_xfer *scmi_xfer_raw_get (const struct scmi_handle *handle);
drivers/firmware/arm_scmi/driver.c +32 -5
@@ -1063,6 +1063,29 @@ static inline void scmi_xfer_command_release(struct scmi_info *info,__scmi_xfer_put (&info->tx_minfo, xfer); } +/** +* scmi_xfer_async_response_complete - Signal a received delayed response +* +* @xfer: A reference to the xfer whose delayed response was received +* +* Return: True if a completion was still armed on @xfer and has been +* signalled, false if a waiter has already disarmed it due to +* timeout or other error. +*/ +static bool scmi_xfer_async_response_complete (struct scmi_xfer *xfer) +{ +unsigned long flags; +struct completion *async_done; + +spin_lock_irqsave (&xfer->lock, flags); + async_done = xfer->async_done; +if (async_done) +complete (async_done); +spin_unlock_irqrestore (&xfer->lock, flags); + +return !!async_done; +} +static inline void scmi_clear_channel (struct scmi_info *info,struct scmi_chan_info *cinfo) {
@@ -1166,8 +1189,12 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,if (xfer->hdr.type ==MSG_TYPE_DELAYED_RESP ) {scmi_clear_channel (info, cinfo); -complete (xfer->async_done); -scmi_inc_count (info->dbg,DELAYED_RESPONSE_OK ); +if (scmi_xfer_async_response_complete (xfer)) +scmi_inc_count (info->dbg,DELAYED_RESPONSE_OK ); +else +dev_err (cinfo->dev, +"Delayed Response for %d (protocol 0x%X msg 0x%X) received after waiter was disarmed, dropping\n" , + xfer->hdr.seq, xfer->hdr.protocol_id, xfer->hdr.id); }else {complete (&xfer->done);scmi_inc_count (info->dbg,RESPONSE_OK );
@@ -1509,7 +1536,7 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph,int ret, timeout =msecs_to_jiffies (SCMI_MAX_RESPONSE_TIMEOUT );DECLARE_COMPLETION_ONSTACK (async_response); - xfer->async_done = &async_response; +scmi_xfer_async_response_arm (xfer, &async_response);/* * Delayed responses should not be polled, so an async command should
@@ -1521,7 +1548,7 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph, ret =do_xfer (ph, xfer);if (!ret) { -if (!wait_for_completion_timeout (xfer->async_done, timeout)) { +if (!wait_for_completion_timeout (&async_response, timeout)) {dev_err (ph->dev,"timed out in delayed resp(caller: %pS)\n" , (void *)_RET_IP_);
@@ -1531,7 +1558,7 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph, } } - xfer->async_done =NULL ; +scmi_xfer_async_response_disarm (xfer);return ret; }
drivers/firmware/arm_scmi/protocols.h +6 -3
@@ -100,7 +100,10 @@ struct scmi_msg_hdr {* message. If request-ACK protocol is used, we can reuse the same * buffer for the rx path as we use for the tx path. * @done: command message transmit completion event -* @async_done: pointer to delayed response message received event completion +* @async_done: pointer to delayed response message received event completion, +* or NULL when no delayed response is expected. Protected by +* @lock, since the completion is owned by the waiter and can +* vanish once the wait times out. * @pending: True for xfers added to @pending_xfers hashtable * @node: An hlist_node reference used to store this xfer, alternatively, on * the free list @free_xfers or in the @pending_xfers hashtable
@@ -121,7 +124,7 @@ struct scmi_msg_hdr {* - SCMI_XFER_SENT_OK -> SCMI_XFER_DRESP_OK * (Missing synchronous response is assumed OK and ignored) * @flags: Optional flags associated to this xfer. -* @lock: A spinlock to protect state and busy fields. +* @lock: A spinlock to protect state, busy and async_done fields. * @priv: A pointer for transport private usage. */ struct scmi_xfer {
@@ -147,7 +150,7 @@ struct scmi_xfer {#define SCMI_XFER_IS_CHAN_SET (x) \ ((x)->flags & SCMI_XFER_FLAG_CHAN_SET)int flags; -/* A lock to protect state and busy fields */ +/* A lock to protect state, busy and async_done fields */ spinlock_t lock;void *priv; };
drivers/firmware/arm_scmi/raw_mode.c +2 -2
@@ -346,7 +346,7 @@ scmi_xfer_raw_waiter_get(struct scmi_raw_mode_info *raw, struct scmi_xfer *xfer,if (async) {reinit_completion (&rw->async_response); - xfer->async_done = &rw->async_response; +scmi_xfer_async_response_arm (xfer, &rw->async_response); } rw->cinfo = cinfo;
@@ -361,7 +361,7 @@ static void scmi_xfer_raw_waiter_put(struct scmi_raw_mode_info *raw, struct scmi_xfer_raw_waiter *rw) {if (rw->xfer) { - rw->xfer->async_done =NULL ; +scmi_xfer_async_response_disarm (rw->xfer); rw->xfer =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/2151 firmware: arm_scmi: Dont reuse raw xfers with async_done still armed
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roland Dreier <[email protected]>
[ Upstream commit 0543fc1443de1a0b04ec64684fb920d79e15de2f ]
In SCMI raw mode, scmi_xfer_raw_worker() releases the xfer before releasing the waiter that disarms xfer->async_done, and scmi_xfer_get() does not clear async_done when it hands out a recycled xfer. A concurrent transaction can therefore pick up the xfer while it still points at the old waiter's completion, so:
- a delayed response arriving for the new transaction can be signalled on the old waiter's completion, which may already be re-armed for yet another unrelated transaction, making that transaction's wait return early; and
- the old waiter's disarm, which still runs after the xfer has been released, clobbers the arming just installed by the new transaction, so the new waiter times out even if its delayed response arrives.
Release the waiter first, while the worker still holds a reference on the xfer, so that an xfer can never reach the free list still armed. Track whether a delayed response is expected in the waiter itself instead of peeking at xfer->async_done outside xfer->lock, and wait on the waiter's own embedded completion. (The new async flag is not strictly needed but it makes the logic easier to reason about)
Finally, harden scmi_xfer_get() to clear async_done when handing out an xfer, so that no future release-ordering change can leak a stale arming into a new transaction.
--- drivers/firmware/arm_scmi/driver.c | 1 + drivers/firmware/arm_scmi/raw_mode.c | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)
drivers/firmware/arm_scmi/driver.c +1 -0
@@ -717,6 +717,7 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle,refcount_set (&xfer->users,1 );atomic_set (&xfer->busy,SCMI_XFER_FREE ); + xfer->async_done =NULL ;spin_unlock_irqrestore (&minfo->xfer_lock, flags);return xfer;
drivers/firmware/arm_scmi/raw_mode.c +21 -4
@@ -198,6 +198,8 @@ struct scmi_raw_mode_info {* @async_response: A completion to be, optionally, used for async waits: it * will be setup by @scmi_do_xfer_raw_start, if needed, to be * pointed at by xfer->async_done. +* @async: True if @async_response was armed on @xfer, i.e. if a delayed +* response has to be waited for. * @node: A list node. */ struct scmi_xfer_raw_waiter {
@@ -205,6 +207,7 @@ struct scmi_xfer_raw_waiter {struct scmi_chan_info *cinfo;struct scmi_xfer *xfer;struct completion async_response; +bool async;struct list_head node; };
@@ -349,6 +352,7 @@ scmi_xfer_raw_waiter_get(struct scmi_raw_mode_info *raw, struct scmi_xfer *xfer,scmi_xfer_async_response_arm (xfer, &rw->async_response); } + rw->async = async; rw->cinfo = cinfo; rw->xfer = xfer; }
@@ -361,8 +365,16 @@ static void scmi_xfer_raw_waiter_put(struct scmi_raw_mode_info *raw, struct scmi_xfer_raw_waiter *rw) {if (rw->xfer) { +/* +* Disarm the delayed response before this waiter, and its +* embedded completion, can be picked up again for a new +* transaction: a delayed response received late, after the +* related wait timed out, must not signal a completion which +* has been in the meantime re-armed on a different xfer. +*/ scmi_xfer_async_response_disarm (rw->xfer); rw->xfer =NULL ; + rw->async = false; }mutex_lock (&raw->free_mtx);
@@ -479,18 +491,23 @@ static void scmi_xfer_raw_worker(struct work_struct *work) ret, scmi_inflight_count(raw->handle));/* Wait also for an async delayed response if needed */ -if (!ret && xfer->async_done) { +if (!ret && rw->async) {unsigned long tmo =msecs_to_jiffies (SCMI_MAX_RESPONSE_TIMEOUT ); -if (!wait_for_completion_timeout (xfer->async_done, tmo)) +if (!wait_for_completion_timeout (&rw->async_response, tmo))dev_err (dev,"timed out in RAW delayed resp - HDR:%08X\n" ,pack_scmi_header (&xfer->hdr)); } -/* Release waiter and xfer */ -scmi_xfer_raw_put (raw->handle, xfer); +/* +* Release the waiter first: this disarms the delayed response +* while we still hold a reference on the xfer, so that the xfer +* cannot be recycled by a new transaction while it still points +* at this waiter's completion. +*/ scmi_xfer_raw_waiter_put (raw, rw); +scmi_xfer_raw_put (raw->handle, xfer); }while (1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/2151 firmware: arm_scmi: Fix error path leak in scmi_raw_message_send()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roland Dreier <[email protected]>
[ Upstream commit 1adabdce41b93ee6f72f29daa1d3e1750e7b7bd1 ]
When the is_transport_polling_capable() check fails in scmi_raw_message_send(), it returns -EINVAL without doing scmi_xfer_raw_put(), which will leak a struct scmi_xfer.
--- drivers/firmware/arm_scmi/raw_mode.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/arm_scmi/raw_mode.c +1 -0
@@ -711,6 +711,7 @@ static int scmi_raw_message_send(struct scmi_raw_mode_info *raw, }else {dev_err (raw->handle->dev,"Failed to send RAW message - Polling NOT supported\n" ); +scmi_xfer_raw_put (raw->handle, xfer);return -EINVAL ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/2151 usb: gadget: composite: avoid warning on aborted delayed status
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keisuke Tsukuda <[email protected]>
[ Upstream commit 048884b782b137229399b9f727b6437d9b4f1071 ]
A SET_CONFIGURATION request that disables the current configuration, or a disconnect, can abort a control transfer whose status stage was delayed by a function driver. The asynchronous function work can nevertheless finish later and call usb_composite_setup_continue() after reset_config() has cleared delayed_status.
This is an expected consequence of aborting the old control transfer, and does not require a kernel warning. Keep the diagnostic available under dynamic debug and ignore the obsolete completion as before.
--- drivers/usb/gadget/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/composite.c +1 -1
@@ -2740,7 +2740,7 @@ void usb_composite_setup_continue(struct usb_composite_dev *cdev)spin_lock_irqsave (&cdev->lock, flags);if (cdev->delayed_status ==0 ) { -WARN (cdev,"%s: Unexpected call\n" , __func__); +DBG (cdev,"%s: Ignoring obsolete call\n" , __func__); }else if (--cdev->delayed_status ==0 ) {DBG (cdev,"%s: Completing delayed status\n" , __func__);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/2151 usb: gadget: f_mass_storage: ignore class requests while inactive
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keisuke Tsukuda <[email protected]>
[ Upstream commit e84caed6e7f58d96ea2e4aaa0b947ab05faa451b ]
SET_CONFIGURATION is handled asynchronously by the mass-storage thread. A class request can arrive after the composite core selects the function but before the thread installs common->fsg, or while the function is being disabled.
fsg_setup() already rejects this state with -EOPNOTSUPP, but checking it through fsg_is_set() also emits a warning. Check the active function directly so normal requests during a configuration transition are rejected without hiding fsg_is_set() warnings from other internal paths.
--- drivers/usb/gadget/function/f_mass_storage.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_mass_storage.c +6 -1
@@ -464,7 +464,12 @@ static int fsg_setup(struct usb_function *f,u16 w_value =le16_to_cpu (ctrl->wValue);u16 w_length =le16_to_cpu (ctrl->wLength); -if (!fsg_is_set (fsg->common)) +/* +* fsg_is_set() warns when common->fsg is NULL, but that can happen +* normally while a configuration change installs or removes the active +* function. +*/ +if (!fsg->common->fsg)return -EOPNOTSUPP ; ++fsg->common->ep0_req_tag;/* Record arrival of a new request */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/2151 dmaengine: fsl_raid: zero CF descriptor pool allocations
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 26d48e9fb6997f4026dd86daecf8d2c12258f698 ]
The compound frame descriptors and embedded CDBs are allocated from the cf_desc_pool with dma_pool_alloc(), which does not zero the memory. Only cdb32, the gfm coefficients and the frame address/length fields are programmed; the dpi_dest_spec/dpi_src_spec fields in the CDBs and the rbro32 field of each frame are left uninitialized. The hardware reads the whole block (frame 0 length is sizeof(struct fsl_re_xor_cdb) or sizeof(struct fsl_re_pq_cdb)), so uninitialized heap contents are exposed to the device on each new descriptor.
Use dma_pool_zalloc() in both fsl_re_chan_alloc_desc() and fsl_re_alloc_chan_resources() so the descriptor and CDB memory is zeroed before it is handed to the RAID engine.
--- drivers/dma/fsl_raid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/fsl_raid.c +4 -4
@@ -305,8 +305,8 @@ static struct fsl_re_desc *fsl_re_chan_alloc_desc(struct fsl_re_chan *re_chan,if (!desc)return NULL ; - cf =dma_pool_alloc (re_chan->re_dev->cf_desc_pool,GFP_NOWAIT , - &paddr); + cf =dma_pool_zalloc (re_chan->re_dev->cf_desc_pool,GFP_NOWAIT , + &paddr);if (!cf) {kfree (desc);return NULL ;
@@ -594,8 +594,8 @@ static int fsl_re_alloc_chan_resources(struct dma_chan *chan)if (!desc)break ; - cf =dma_pool_alloc (re_chan->re_dev->cf_desc_pool,GFP_KERNEL , - &paddr); + cf =dma_pool_zalloc (re_chan->re_dev->cf_desc_pool,GFP_KERNEL , + &paddr);if (!cf) {kfree (desc);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/2151 dmaengine: dw-axi-dmac: Fix AXI burst length encoding
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit 0d59891c42e11c3840276d8a632dbc355d6ddc4f ]
The snps,axi-max-burst-len property describes the number of beats in an AXI burst, while the ARLEN and AWLEN fields encode that value minus one.
The driver keeps axi_rw_burst_len as the actual burst length so that dma_device.max_burst reports the correct value. However, it also programs that unencoded value directly into the hardware fields. A value of 256 therefore overflows the 8-bit fields and can cause AXI decode errors.
Subtract one only when constructing hardware descriptors, while keeping the actual value for dma_device.max_burst.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +2 -2
@@ -706,7 +706,7 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan, ctlhi =CH_CTL_H_LLI_VALID ;if (chan->chip->dw->hdata->restrict_axi_burst_len) { - burst_len = chan->chip->dw->hdata->axi_rw_burst_len; + burst_len = chan->chip->dw->hdata->axi_rw_burst_len -1 ; ctlhi |=CH_CTL_H_ARLEN_EN |CH_CTL_H_AWLEN_EN | burst_len <<CH_CTL_H_ARLEN_POS | burst_len <<CH_CTL_H_AWLEN_POS ;
@@ -977,7 +977,7 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr, reg =CH_CTL_H_LLI_VALID ;if (chan->chip->dw->hdata->restrict_axi_burst_len) { -u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len; +u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len -1 ; reg |= (CH_CTL_H_ARLEN_EN | burst_len << CH_CTL_H_ARLEN_POS |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/2151 dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit e6b49f8016ee8b642e8e495d1704342ee0b35d72 ]
axi_chan_list_dump_lli() uses the channel-wide descs_allocated count to walk the hw_desc[] array of a single transaction. If multiple transactions have allocated LLIs, the channel count can exceed the transaction-local nr_hw_descs and make the DMA error path read past the end of hw_desc[].
Use the descriptor-local nr_hw_descs count when dumping LLIs.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +1 -4
@@ -1054,10 +1054,7 @@ static void axi_chan_dump_lli(struct axi_dma_chan *chan,static void axi_chan_list_dump_lli (struct axi_dma_chan *chan,struct axi_dma_desc *desc_head) { -int count =atomic_read (&chan->descs_allocated); -int i; - -for (i =0 ; i < count; i++) +for (unsigned int i =0 ; i < desc_head->nr_hw_descs; i++)axi_chan_dump_lli (chan, &desc_head->hw_desc[i]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 369/2151 dmaengine: dw-axi-dmac: Fix CH_CFG2 channel priority position
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit 2a9013c20c46216b92ff09e2283b5244a91c59da ]
The CH_CFG2 channel priority field occupies bits 51:47 of the 64-bit channel configuration register, corresponding to bits 19:15 of CH_CFG2_H.
The driver currently shifts the priority value by 20, programming the wrong bits. Use bit 15 as the field position.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac.h +1 -1
@@ -325,7 +325,7 @@ enum {#define CH_CFG2_H_TT_FC_POS 0#define CH_CFG2_H_HS_SEL_SRC_POS 3#define CH_CFG2_H_HS_SEL_DST_POS 4 -#define CH_CFG2_H_PRIORITY_POS 20 +#define CH_CFG2_H_PRIORITY_POS 15/** * DW AXI DMA channel interrupts
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/2151 PCI: endpoint: pci-epf-vntb: Serialize virtual PCI bus scan
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit 84c3520c9e8c14b09a5cf645cc4fa7c6d9d61127 ]
The virtual PCI bus is scanned without holding the PCI rescan/remove lock. This can race with other PCI topology changes.
Hold the lock across the bus scan and device addition.
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/endpoint/functions/pci-epf-vntb.c +5 -0
@@ -1099,15 +1099,20 @@ static int vpci_scan_bus(void *sysdata)struct pci_bus *vpci_bus;struct epf_ntb *ndev = sysdata; +pci_lock_rescan_remove (); + vpci_bus =pci_scan_bus (ndev->vbus_number, &vpci_ops, sysdata);if (!vpci_bus) {pr_err ("create pci bus failed\n" ); +pci_unlock_rescan_remove ();return -EINVAL ; } ndev->vpci_bus = vpci_bus;pci_bus_add_devices (vpci_bus); +pci_unlock_rescan_remove (); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 371/2151 regulator: ab8500: Fix AB8505 VANA voltage selectors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit dfdfda2a95843706428a9d95ab546cb10983e684 ]
The AB8505 VANA voltage table assumes selector 0 represents 1.05 V and all eight selectors increase linearly. Selector 0 actually represents 1.2 V. Selectors 1 through 6 cover 1.05 V through 1.175 V, and selector 7 represents 1.225 V.
Correct the table so each selector reports and programs the documented voltage.
Reference: AB8505 User Manual, DM00046744 Rev 3, p. 257
--- drivers/regulator/ab8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/ab8500.c +1 -1
@@ -265,13 +265,13 @@ static const unsigned int fixed_2050000_voltage[] = { };static const unsigned int ldo_vana_voltages[] = { +1200000 ,1050000 ,1075000 ,1100000 ,1125000 ,1150000 ,1175000 , -1200000 ,1225000 , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 372/2151 regulator: ab8500: Remove stale expand_register kernel-doc entry
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit 0991f3b4624ed713d1d5eb56520c1c9b2deaab7a ]
Commit aeee55b76bfd ("regulator: ab8500: Remove unused embedded struct expand_register") deleted the expand_register member from struct ab8500_regulator_info and, in the same hunk, added an empty "@expand_register:" line to the kernel-doc block. That traded one W=1 warning for another:
drivers/regulator/ab8500.c:196 Excess struct member 'expand_register' description in 'ab8500_regulator_info'
Drop the leftover line; the remaining @member entries all match the struct.
No functional changes.
Stable-dep-of: ac72c091a981 ("regulator: ab8500: Add AB8505 VAUX3 3.05 V setting")
--- drivers/regulator/ab8500.c | 1 - 1 file changed, 1 deletion(-)
drivers/regulator/ab8500.c +0 -1
@@ -173,7 +173,6 @@ struct ab8500_shared_mode {* @voltage_bank: bank to control regulator voltage * @voltage_reg: register to control regulator voltage * @voltage_mask: mask to control regulator voltage -* @expand_register: */ struct ab8500_regulator_info {struct device *dev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 373/2151 regulator: ab8500: Add AB8505 VAUX3 3.05 V setting
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit ac72c091a9810493ccd9209414d4f859276727ab ]
AB8505 has an additional VAUX3 voltage setting which is not encoded in the normal three-bit selector. ArmRegu2.Vaux3Sel3 overrides that selector and selects 3.05 V.
Add the missing voltage and use the override bit as an extended selector. Program the ordinary selector before clearing the override so VAUX3 does not briefly switch to a stale voltage.
Reference: AB8505 User Manual, DM00046744 Rev 3, pp. 229 and 254
--- drivers/regulator/ab8500.c | 101 +++++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 3 deletions(-)
drivers/regulator/ab8500.c +98 -3
@@ -173,6 +173,7 @@ struct ab8500_shared_mode {* @voltage_bank: bank to control regulator voltage * @voltage_reg: register to control regulator voltage * @voltage_mask: mask to control regulator voltage +* @expand_register: additional register used to select an extra voltage */ struct ab8500_regulator_info {struct device *dev;
@@ -193,6 +194,12 @@ struct ab8500_regulator_info {u8 voltage_bank;u8 voltage_reg;u8 voltage_mask; +struct { +u8 voltage_limit; +u8 voltage_bank; +u8 voltage_reg; +u8 voltage_mask; + } expand_register; };/* voltage tables for the vauxn/vintcore supplies */
@@ -226,6 +233,18 @@ static const unsigned int ldo_vaux3_voltages[] = { 2910000, }; +static const unsigned int ldo_vaux3_ab8505_voltages[] = { +1200000 , +1500000 , +1800000 , +2100000 , +2500000 , +2750000 , +2790000 , +2910000 , +3050000 , +}; +static const unsigned int ldo_vaux56_voltages[] = {1800000 ,1050000 ,
@@ -593,6 +612,64 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,return ret; } +static int ab8500_regulator_get_voltage_sel_expand (struct regulator_dev *rdev) +{ +struct ab8500_regulator_info *info =rdev_get_drvdata (rdev); +u8 regval; +int ret; + +if (!info) +return -EINVAL ; + + ret =abx500_get_register_interruptible (info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, ®val); +if (ret <0 ) { +dev_err (rdev_get_dev (rdev), +"couldn't read voltage expand reg for regulator\n" ); +return ret; + } + +if (regval & info->expand_register.voltage_mask) +return info->expand_register.voltage_limit; + +return ab8500_regulator_get_voltage_sel (rdev); +} + +static int ab8500_regulator_set_voltage_sel_expand (struct regulator_dev *rdev, +unsigned int selector) +{ +struct ab8500_regulator_info *info =rdev_get_drvdata (rdev); +u8 regval; +int ret; + +if (!info) +return -EINVAL ; + +if (selector > info->expand_register.voltage_limit) +return -EINVAL ; + +if (selector < info->expand_register.voltage_limit) { + ret =ab8500_regulator_set_voltage_sel (rdev, selector); +if (ret <0 ) +return ret; + + regval =0 ; + }else { + regval = info->expand_register.voltage_mask; + } + + ret =abx500_mask_and_set_register_interruptible (info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, + info->expand_register.voltage_mask, regval); +if (ret <0 ) +dev_err (rdev_get_dev (rdev), +"couldn't set voltage expand reg for regulator\n" ); + +return ret; +} +static const struct regulator_ops ab8500_regulator_volt_mode_ops = { .enable = ab8500_regulator_enable, .disable = ab8500_regulator_disable,
@@ -605,6 +682,18 @@ static const struct regulator_ops ab8500_regulator_volt_mode_ops = { .list_voltage = regulator_list_voltage_table, }; +static const struct regulator_ops ab8500_regulator_volt_mode_expand_ops = { + .enable = ab8500_regulator_enable, + .disable = ab8500_regulator_disable, + .is_enabled = ab8500_regulator_is_enabled, + .get_optimum_mode = ab8500_regulator_get_optimum_mode, + .set_mode = ab8500_regulator_set_mode, + .get_mode = ab8500_regulator_get_mode, + .get_voltage_sel = ab8500_regulator_get_voltage_sel_expand, + .set_voltage_sel = ab8500_regulator_set_voltage_sel_expand, + .list_voltage = regulator_list_voltage_table, +}; +static const struct regulator_ops ab8500_regulator_volt_ops = { .enable = ab8500_regulator_enable, .disable = ab8500_regulator_disable,
@@ -908,12 +997,12 @@ static struct ab8500_regulator_info [AB8505_LDO_AUX3] = { .desc = { .name = "LDO-AUX3", - .ops = &ab8500_regulator_volt_mode_ops, + .ops = &ab8500_regulator_volt_mode_expand_ops, .type = REGULATOR_VOLTAGE, .id = AB8505_LDO_AUX3, .owner = THIS_MODULE, - .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), - .volt_table = ldo_vaux3_voltages, + .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8505_voltages), + .volt_table = ldo_vaux3_ab8505_voltages, }, .load_lp_uA = 5000, .update_bank = 0x04,
@@ -925,6 +1014,12 @@ static struct ab8500_regulator_info .voltage_bank = 0x04, .voltage_reg = 0x21, .voltage_mask = 0x07, + .expand_register = { + .voltage_limit = 8, + .voltage_bank = 0x04, + .voltage_reg = 0x01, + .voltage_mask = 0x10, + }, }, [AB8505_LDO_AUX4] = { .desc = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 374/2151 regulator: ab8500: Handle AB8505 VINTCORE selector 7
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 4ec4df7e54182edb6955caace37684e535e462dc ]
The AB8505 VINTCORE table exposes only selectors 0 through 6. The hardware also accepts selector 7 and maps it to 1.35 V, just like selector 6. Omitting it can make an OTP-programmed selector 7 appear invalid to the regulator core.
Give AB8505 its own eight-entry selector table while leaving the AB8500 table unchanged.
Reference: AB8505 User Manual, DM00046744 Rev 3, p. 223
--- drivers/regulator/ab8500.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/regulator/ab8500.c +13 -2
@@ -266,6 +266,17 @@ static const unsigned int ldo_vintcore_voltages[] = { 1350000, }; +static const unsigned int ldo_vintcore_ab8505_voltages[] = { +1200000 , +1225000 , +1250000 , +1275000 , +1300000 , +1325000 , +1350000 , +1350000 , +}; +static const unsigned int fixed_1200000_voltage[] = {1200000 , };
@@ -1095,8 +1106,8 @@ static struct ab8500_regulator_info .type = REGULATOR_VOLTAGE, .id = AB8505_LDO_INTCORE, .owner = THIS_MODULE, - .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), - .volt_table = ldo_vintcore_voltages, + .n_voltages = ARRAY_SIZE(ldo_vintcore_ab8505_voltages), + .volt_table = ldo_vintcore_ab8505_voltages, }, .load_lp_uA = 5000, .update_bank = 0x03,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 375/2151 regulator: ab8500: Treat cut 1.0 VAUX3 as fixed
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b9fc8a8d31b914b09329240f532ff0e9c00cd727 ]
The early-cut workaround currently gives AB8500 cut 1.0 the 16 programmable VAUX3 settings introduced with cut 1.1. On cut 1.0 the selector is not programmable and VAUX3 is fixed at 1.2 V.
Register VAUX3 as a fixed-voltage regulator on cut 1.0 and retain the 16-value workaround only for cut 1.1.
Reference: AB8500 User Manual, UM0836 Rev 3, p. 240
--- drivers/regulator/ab8500.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/regulator/ab8500.c +8 -3
@@ -1783,9 +1783,14 @@ static int ab8500_regulator_register(struct platform_device *pdev, config.driver_data = info; config.of_node = np; -/* fix for hardware before ab8500v2.0 */ -if (is_ab8500_1p1_or_earlier (ab8500)) { -if (info->desc.id ==AB8500_LDO_AUX3 ) { +/* Handle the different VAUX3 implementations in early AB8500 cuts. */ +if (info->desc.id ==AB8500_LDO_AUX3 ) { +if (is_ab8500_1p0_or_earlier (ab8500)) { + info->desc.ops = &ab8500_regulator_mode_ops; + info->desc.n_voltages =1 ; + info->desc.volt_table = fixed_1200000_voltage; + info->voltage_mask =0 ; + }else if (is_ab8500_1p1_or_earlier (ab8500)) { info->desc.n_voltages =ARRAY_SIZE (ldo_vauxn_voltages); info->desc.volt_table = ldo_vauxn_voltages;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 376/2151 regulator: ab8500: Test dedicated enable bits only
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit a5ee78846015512b4d3d32f8aa463024a23234ce ]
Some regulator control registers have independent enable and low-power bits. is_enabled() currently tests their combined update mask, so an off regulator with its low-power bit set is incorrectly reported as enabled.
Add an optional enable mask and use it for VINTCORE, AB8500 TVOUT, AB8505 ADC, and AB8505 VAUX5/6. Regulators whose two-bit field encodes the complete operating state continue to test the full update mask.
References: AB8500 User Manual, UM0836 Rev 3, p. 214; AB8505 User Manual, DM00046744 Rev 3, pp. 171-172 and 223
--- drivers/regulator/ab8500.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/regulator/ab8500.c +13 -2
@@ -162,6 +162,7 @@ struct ab8500_shared_mode {* @update_bank: bank to control on/off * @update_reg: register to control on/off * @update_mask: mask to enable/disable and set mode of regulator +* @enable_mask: optional mask for an enable bit separate from the mode bit * @update_val: bits holding the regulator current mode * @update_val_idle: bits to enable the regulator in idle (low power) mode * @update_val_normal: bits to enable the regulator in normal (high power) mode
@@ -183,6 +184,7 @@ struct ab8500_regulator_info {u8 update_bank;u8 update_reg;u8 update_mask; +u8 enable_mask;u8 update_val;u8 update_val_idle;u8 update_val_normal;
@@ -377,6 +379,7 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) {int ret;struct ab8500_regulator_info *info =rdev_get_drvdata (rdev); +u8 enable_mask;u8 regval;if (info ==NULL ) {
@@ -392,13 +395,15 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)return ret; } + enable_mask = info->enable_mask ? info->enable_mask : info->update_mask; +dev_vdbg (rdev_get_dev (rdev),"%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," " 0x%x\n" , info->desc.name, info->update_bank, info->update_reg, - info->update_mask, regval); + enable_mask, regval); -if (regval & info->update_mask) +if (regval & enable_mask)return 1 ;else return 0 ;
@@ -833,6 +838,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x44, + .enable_mask = 0x04, .update_val = 0x44, .update_val_idle = 0x44, .update_val_normal = 0x04,
@@ -861,6 +867,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x82, + .enable_mask = 0x02, .update_val = 0x02, .update_val_idle = 0x82, .update_val_normal = 0x02,
@@ -1070,6 +1077,7 @@ static struct ab8500_regulator_info .update_bank = 0x01, .update_reg = 0x55, .update_mask = 0x18, + .enable_mask = 0x10, .update_val = 0x10, .update_val_idle = 0x18, .update_val_normal = 0x10,
@@ -1092,6 +1100,7 @@ static struct ab8500_regulator_info .update_bank = 0x01, .update_reg = 0x56, .update_mask = 0x18, + .enable_mask = 0x10, .update_val = 0x10, .update_val_idle = 0x18, .update_val_normal = 0x10,
@@ -1113,6 +1122,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x44, + .enable_mask = 0x04, .update_val = 0x04, .update_val_idle = 0x44, .update_val_normal = 0x04,
@@ -1141,6 +1151,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x82, + .enable_mask = 0x02, .update_val = 0x02, .update_val_idle = 0x82, .update_val_normal = 0x02,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 377/2151 regulator: ab8500: Propagate mode enable read errors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 71ac8878573058e2b85210760ccaeaac90796c35 ]
For regulators whose enable and mode share a state field, set_mode() first reads that field so changing the requested mode does not enable a disabled rail. A register read error is currently treated as true and the driver proceeds to write the new mode, potentially enabling a rail whose state is unknown.
Return the read error without changing the register or cached mode.
References: AB8500 User Manual, UM0836 Rev 3, p. 227; AB8505 User Manual, DM00046744 Rev 3, p. 237
--- drivers/regulator/ab8500.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/regulator/ab8500.c +12 -2
@@ -433,7 +433,7 @@ static unsigned int ab8500_regulator_get_optimum_mode(static int ab8500_regulator_set_mode (struct regulator_dev *rdev,unsigned int mode) { -int ret =0 ; +int enabled, ret =0 ;u8 bank, reg, mask, val;bool lp_mode_req = false;struct ab8500_regulator_info *info =rdev_get_drvdata (rdev);
@@ -490,7 +490,17 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev, goto out_unlock; } -if (info->mode_mask ||ab8500_regulator_is_enabled (rdev)) { +if (info->mode_mask) { + enabled =1 ; + }else { + enabled =ab8500_regulator_is_enabled (rdev); +if (enabled <0 ) { + ret = enabled; + goto out_unlock; + } + } + +if (enabled) { ret =abx500_mask_and_set_register_interruptible (info->dev, bank, reg, mask, val);if (ret <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 378/2151 arm64: dts: qcom: sm7225-fairphone-fp4: Disable PMK8350 PON
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 5c088a33e3a9bb236c475b7230df275fc1e51eda ]
Two PMICs on this phone have a PON block, the PM6350 and PMK8350. Only one should be enabled at one time, so disable PMK8350 PON and keep the PM6350 PON.
--- arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts +4 -0
@@ -925,6 +925,10 @@ xo-therm@0 { }; }; +&pmk8350_pon { + status = "disabled"; +}; + &pmk8350_rtc { status = "okay"; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 379/2151 sit: fix UAF in ipip6_tunnel_del_prl()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 5145bb6a2c2683d541828f86d5321e0565f2e30c ]
When flushing all potential router list (PRL) entries, ipip6_tunnel_del_prl() called call_rcu(&x->rcu_head, prl_list_destroy_rcu) before clearing t->prl.
A concurrent reader in isatap_chksrc() could enter an RCU read-side critical section after call_rcu() but before t->prl is set to NULL, allowing prl_list_destroy_rcu() to free nodes while the reader traverses them.
Clear t->prl using RCU_INIT_POINTER() before invoking call_rcu(). Also use rcu_assign_pointer() when unlinking individual entries.
--- net/ipv6/sit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/sit.c +2 -2
@@ -435,7 +435,7 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) (x =rtnl_dereference (*p)) !=NULL ; p = &x->next) {if (x->addr == a->addr) { - *p = x->next; +rcu_assign_pointer (*p,rtnl_dereference (x->next));kfree_rcu (x, rcu_head); t->prl_count--; goto out;
@@ -446,8 +446,8 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) x =rtnl_dereference (t->prl);if (x) { t->prl_count =0 ; +RCU_INIT_POINTER (t->prl,NULL );call_rcu (&x->rcu_head, prl_list_destroy_rcu); - t->prl =NULL ; } } out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 380/2151 ip_tunnel: use WRITE_ONCE in ip_tunnel_encap_setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 88b84cae6b94087d3a9679845fe28ad19c7bef8b ]
Update ip_tunnel_encap_setup() to use WRITE_ONCE() when writing to encap fields (type, sport, dport, flags) and hlen fields. This ensures that concurrent lockless readers (like fill_info) do not see torn writes.
Also remove the unsafe memset() on t->encap which could cause concurrent readers to transiently see zeroed fields. Removing it also fixes a bug where t->encap was left cleared even if ip_encap_hlen() failed, resulting in partial configuration.
--- net/ipv4/ip_tunnel.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/ipv4/ip_tunnel.c +6 -8
@@ -491,19 +491,17 @@ int ip_tunnel_encap_setup(struct ip_tunnel *t, {int hlen; -memset (&t->encap,0 ,sizeof (t->encap)); - hlen =ip_encap_hlen (ipencap);if (hlen <0 )return hlen; - t->encap.type = ipencap->type; - t->encap.sport = ipencap->sport; - t->encap.dport = ipencap->dport; - t->encap.flags = ipencap->flags; +WRITE_ONCE (t->encap.type, ipencap->type); +WRITE_ONCE (t->encap.sport, ipencap->sport); +WRITE_ONCE (t->encap.dport, ipencap->dport); +WRITE_ONCE (t->encap.flags, ipencap->flags); - t->encap_hlen = hlen; - t->hlen = t->encap_hlen + t->tun_hlen; +WRITE_ONCE (t->encap_hlen, hlen); +WRITE_ONCE (t->hlen, hlen + t->tun_hlen);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 381/2151 crypto: amlogic - Fix DMA memory leak in cipher error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Raizudeen <[email protected]>
[ Upstream commit 6c2373dd818b777d0a81eb02acebc03940552dcd ]
A DMA memory leak occurs in meson_cipher() on the mapping error paths. The driver jumps to the end of the function without unmapping the previously mapped source scatterlist and key/IV buffer when the destination apping fails.
Additionally, a memory leak occurs when a scatterlist mapping succeeds but the returned count exceeds the driver's MAXDESC limit. In this case, the driver rejects the mapping without unmapping it. The BIDIRECTIONAL mapping branch also lacks the required 'MAXDESC -3' upper bound check.
Fix this by introducing proper error labels, error_src and error_keyiv and unmap resources immediately inside the calidation checks to ensure all successfully mapped resources are cleaned up before returning the error.
--- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 25 ++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/crypto/amlogic/amlogic-gxl-cipher.c +20 -5
@@ -177,10 +177,13 @@ static int meson_cipher(struct skcipher_request *areq)if (areq->src == areq->dst) { nr_sgs =dma_map_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_BIDIRECTIONAL ); -if (!nr_sgs) { -dev_err (mc->dev,"Invalid SG count %d\n" , nr_sgs); +if (!nr_sgs || nr_sgs >MAXDESC -3 ) { +dev_err (mc->dev,"Invalid BIDIR SG count %d\n" , nr_sgs); err = -EINVAL ; - goto theend; + +if (nr_sgs) +dma_unmap_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_BIDIRECTIONAL ); + goto error_keyiv; } nr_sgd = nr_sgs; }else {
@@ -189,14 +192,20 @@ static int meson_cipher(struct skcipher_request *areq)if (!nr_sgs || nr_sgs >MAXDESC -3 ) {dev_err (mc->dev,"Invalid SG count %d\n" , nr_sgs); err = -EINVAL ; - goto theend; + +if (nr_sgs) +dma_unmap_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_TO_DEVICE ); + goto error_keyiv; } nr_sgd =dma_map_sg (mc->dev, areq->dst,sg_nents (areq->dst),DMA_FROM_DEVICE );if (!nr_sgd || nr_sgd >MAXDESC -3 ) {dev_err (mc->dev,"Invalid SG count %d\n" , nr_sgd); err = -EINVAL ; - goto theend; + +if (nr_sgd) +dma_unmap_sg (mc->dev, areq->dst,sg_nents (areq->dst),DMA_FROM_DEVICE ); + goto error_src; } }
@@ -251,6 +260,12 @@ static int meson_cipher(struct skcipher_request *areq) ivsize, 0); } } + goto theend; + +error_src: +dma_unmap_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_TO_DEVICE ); +error_keyiv: +dma_unmap_single (mc->dev, phykeyiv, keyivlen,DMA_TO_DEVICE ); theend:kfree_sensitive (bkeyiv);kfree_sensitive (backup_iv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 382/2151 crypto: qat - avoid OOB read when stripping RSA leading zeros
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit ac508238898058f0b09b18a7891fb31279617781 ]
The logical AND operator uses short-circuit evaluation: the first operand is always evaluated, while the second is evaluated only if the first is true. Because the first operand dereferences a pointer, it may cause an out-of-bounds access before the bounds check in the second operand is evaluated.
Resolve this by checking the vlen prior to the pointer being dereferenced.
--- drivers/crypto/intel/qat/qat_common/qat_asym_algs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/intel/qat/qat_common/qat_asym_algs.c +4 -4
@@ -987,7 +987,7 @@ static int qat_rsa_set_n(struct qat_rsa_ctx *ctx, const char *value,const char *ptr = value;int ret; -while (!*ptr && vlen) { +while (vlen && !*ptr) { ptr++; vlen--; }
@@ -1018,7 +1018,7 @@ static int qat_rsa_set_e(struct qat_rsa_ctx *ctx, const char *value,struct device *dev = &GET_DEV (inst->accel_dev);const char *ptr = value; -while (!*ptr && vlen) { +while (vlen && !*ptr) { ptr++; vlen--; }
@@ -1044,7 +1044,7 @@ static int qat_rsa_set_d(struct qat_rsa_ctx *ctx, const char *value,const char *ptr = value;int ret; -while (!*ptr && vlen) { +while (vlen && !*ptr) { ptr++; vlen--; }
@@ -1067,7 +1067,7 @@ static int qat_rsa_set_d(struct qat_rsa_ctx *ctx, const char *value,static void qat_rsa_drop_leading_zeros (const char **ptr,unsigned int *len) { -while (!**ptr && *len) { +while (*len && !**ptr) { (*ptr)++; (*len)--; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 383/2151 crypto: qat - release instance on DH fallback allocation failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 307e27d3e07f58b6d42a8c64d31304aa614ab7d2 ]
qat_dh_init_tfm() acquires a QAT crypto instance before allocating the software fallback transform. If fallback allocation fails, the instance reference is leaked and the device remains permanently in use.
Release the instance before returning the allocation error.
--- drivers/crypto/intel/qat/qat_common/qat_asym_algs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/qat_asym_algs.c +3 -1
@@ -535,8 +535,10 @@ static int qat_dh_init_tfm(struct crypto_kpp *tfm)return -EINVAL ; ctx->ftfm =crypto_alloc_kpp (alg,0 ,CRYPTO_ALG_NEED_FALLBACK ); -if (IS_ERR (ctx->ftfm)) +if (IS_ERR (ctx->ftfm)) { +qat_crypto_put_instance (inst);return PTR_ERR (ctx->ftfm); + }crypto_kpp_set_flags (ctx->ftfm,crypto_kpp_get_flags (tfm));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 384/2151 crypto: rsassa-pkcs1 - reject undersized keys when signing
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 4cf50332b5384ea13f6f896d5cf84e05b5b6484a ]
rsassa_pkcs1_sign() subtracts 11 from the unsigned key size before checking that the key is large enough for PKCS#1 v1.5 padding:
if (slen + hash_prefix->size > ctx->key_size - 11) return -EOVERFLOW;
If the RSA modulus is shorter than 11 bytes, the subtraction wraps. With a one-byte key and hash=none, the padding memset() writes past the output buffer.
KASAN reports:
BUG: KASAN: slab-out-of-bounds in rsassa_pkcs1_sign+0x1ad/0x3b0
Write of size 4294967294 at addr ...
The buggy address is located 0 bytes to the right of
allocated 1-byte region [...]Reject keys shorter than the minimum encoded message size.
--- crypto/rsassa-pkcs1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/rsassa-pkcs1.c +1 -1
@@ -169,7 +169,7 @@ static int rsassa_pkcs1_sign(struct crypto_sig *tfm,u8 *in_buf;int err; -if (!ctx->key_size) +if (ctx->key_size <11 )return -EINVAL ;if (dlen < ctx->key_size)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 385/2151 crypto: rsassa-pkcs1 - reject undersized keys when verifying
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 364e520095b26fa551a8e92f52119d0f38a4177b ]
rsassa_pkcs1_verify() accepts any nonzero key size.
With a one-byte key and a zero RSA result, the leading-zero handling decrements dst_len to zero and advances out_buf past the allocation. The next out_buf[0] access reads out of bounds.
KASAN reports:
BUG: KASAN: slab-out-of-bounds in rsassa_pkcs1_verify+0x79d/0x900
Read of size 1 at addr ...
The buggy address is located 0 bytes to the right of
allocated 73-byte region [...]Reject keys shorter than the minimum PKCS#1 v1.5 encoded message size.
--- crypto/rsassa-pkcs1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/rsassa-pkcs1.c +1 -1
@@ -231,7 +231,7 @@ static int rsassa_pkcs1_verify(struct crypto_sig *tfm,int err;/* RFC 8017 sec 8.2.2 step 1 - length checking */ -if (!ctx->key_size || +if (ctx->key_size <11 || slen != ctx->key_size ||rsassa_pkcs1_invalid_hash_len (dlen, hash_prefix))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 386/2151 crypto: mxs-dcp - handle zero-length skcipher requests
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit ac1d6a65a1e1f069f119df42c6b57dbdff5f6be8 ]
Zero-length skcipher requests are valid no-ops, but MXS-DCP queues them. When such a request reaches the worker, last_out_len remains zero. The CBC completion path then subtracts AES_BLOCK_SIZE from this unsigned value when updating the IV, causing the offset to underflow. On decryption, the resulting source address precedes aes_in_buf.
Return success before enqueueing zero-length requests. This avoids the invalid source access and leaves the IV unchanged for a no-op.
--- drivers/crypto/mxs-dcp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/mxs-dcp.c +3 -0
@@ -473,6 +473,9 @@ static int mxs_dcp_aes_enqueue(struct skcipher_request *req, int enc, int ecb)struct dcp_aes_req_ctx *rctx =skcipher_request_ctx (req);int ret; +if (!req->cryptlen) +return 0 ; +if (unlikely (actx->key_len !=AES_KEYSIZE_128 && !actx->key_referenced))return mxs_dcp_block_fallback (req, enc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 387/2151 crypto: lskcipher - preserve state across unaligned chunks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit ba871255f796d1f599ba710f03e1803d1b374a75 ]
crypto_lskcipher_crypt_unaligned() splits a request into page-sized chunks but never sets CRYPTO_LSKCIPHER_FLAG_CONT, so a stateful algorithm restarts from its keyed state at every page boundary. It also marks every chunk CRYPTO_LSKCIPHER_FLAG_FINAL, which is wrong but harmless: chunks are trimmed to a multiple of the chunk size, so the trailing partial block that FINAL guards against is caught after the loop instead.
ARC4 is the only lskcipher with internal state, and cbc, the other in-tree user of the direct API, never passes more than one block, so this went unnoticed. bpf_crypto_crypt() however hands __bpf_dynptr_data() to crypto_lskcipher_encrypt() unchecked, leaving both alignment and length to the BPF program. An 8192-byte ARC4 request offset by one byte comes back with its second page identical to its
first: the keystream is reused.
Set FINAL only on the last chunk and CONT after the first, mirroring the progression used by crypto_lskcipher_crypt_sg().
--- crypto/lskcipher.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
crypto/lskcipher.c +5 -1
@@ -75,6 +75,7 @@ static int crypto_lskcipher_crypt_unaligned(unsigned ivsize =crypto_lskcipher_ivsize (tfm);unsigned bs =crypto_lskcipher_blocksize (tfm);unsigned cs =crypto_lskcipher_chunksize (tfm); +u32 flags =0 ;int err;u8 *tiv;u8 *p;
@@ -98,13 +99,16 @@ static int crypto_lskcipher_crypt_unaligned(if (chunk > cs) chunk &= ~(cs -1 ); +if (chunk == len) + flags |=CRYPTO_LSKCIPHER_FLAG_FINAL ;memcpy (p, src, chunk); - err =crypt (tfm, p, p, chunk, tiv,CRYPTO_LSKCIPHER_FLAG_FINAL ); + err =crypt (tfm, p, p, chunk, tiv, flags);if (err) goto out;memcpy (dst, p, chunk); + flags |=CRYPTO_LSKCIPHER_FLAG_CONT ; src += chunk; dst += chunk; len -= chunk;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 388/2151 memory: exynos5422-dmc: handle clock enable failures
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Liu <[email protected]>
[ Upstream commit cce46902ea9fcd585cd200fffa3166f63bc571f1 ]
Check the return values of clk_prepare_enable() for fout_bpll and mout_bpll.
If enabling fout_bpll fails, propagate the error. If enabling mout_bpll fails, disable fout_bpll before returning. This keeps the clock enable count balanced on probe error paths.
--- drivers/memory/samsung/exynos5422-dmc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/memory/samsung/exynos5422-dmc.c +9 -2
@@ -1297,8 +1297,15 @@ static int exynos5_dmc_init_clks(struct exynos5_dmc *dmc)if (ret)return ret; -clk_prepare_enable (dmc->fout_bpll); -clk_prepare_enable (dmc->mout_bpll); + ret =clk_prepare_enable (dmc->fout_bpll); +if (ret) +return ret; + + ret =clk_prepare_enable (dmc->mout_bpll); +if (ret) { +clk_disable_unprepare (dmc->fout_bpll); +return ret; + }/* * Some bootloaders do not set clock routes correctly.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 389/2151 gfs2: Fix journaled truncate range end offset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit a52652efd8f985397e87669f505af83f06e335cf ]
The third argument to truncate_pagecache_range() is the inclusive end offset, but gfs2_journaled_truncate_range() passes the length of each chunk. A hole punch at an offset larger than its length therefore creates an inverted range.
Commit 86066914edff ("gfs2: Don't support fallocate on jdata files") disables fallocate for jdata files. Otherwise, the following bug could occur:
The MM truncation path then underflows the unsigned partial-folio length and passes an oversized range to folio_zero_range(), triggering a BUG. Pass the last byte of the chunk so page-cache invalidation covers the intended range.
--- fs/gfs2/bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/bmap.c +1 -1
@@ -2413,7 +2413,7 @@ static int gfs2_journaled_truncate_range(struct inode *inode, loff_t offset,if (offs && chunk >PAGE_SIZE ) chunk = offs + ((chunk - offs) &PAGE_MASK ); -truncate_pagecache_range (inode, offset, chunk); +truncate_pagecache_range (inode, offset, offset + chunk -1 ); offset += chunk; length -= chunk;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 390/2151 ACPI: glue: Carry out companion lookup under bus_type_sem
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit c94619c8a5b5d3b980433d247ac87a2d1c827cb6 ]
When acpi_device_notify() looks up an ACPI companion for the given device, it invokes callbacks from struct acpi_bus_type() without synchronization which may lead to a use-after-free if the driver module containing those callbacks is unloaded at the same time.
Address this by holding bus_type_sem throughout the entire ACPI companion lookup and the execution of the .setup() callback in struct acpi_bus_type (if present) instead of dropping the semaphore (prematurely) after finding a matching struct acpi_bus_type.
For this purpose, rename acpi_get_bus_type() to acpi_companion_lookup(), make it return a struct acpi_device pointer, and move the relevant code from acpi_device_notify() to it.
Also notice that the only case in which the .bind() callback from an ACPI scan handler may need to be invoked is when the given device is a platform one, so adjust acpi_device_notify() accordingly and drop the "done" label that is not used any more from it.
--- drivers/acpi/glue.c | 61 +++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 32 deletions(-)
drivers/acpi/glue.c +29 -32
@@ -59,19 +59,34 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type) }EXPORT_SYMBOL_GPL (unregister_acpi_bus_type); -static struct acpi_bus_type *acpi_get_bus_type (struct device *dev) +static struct acpi_device *acpi_companion_lookup (struct device *dev) { -struct acpi_bus_type *tmp, *ret =NULL ; +struct acpi_bus_type *type; -down_read (&bus_type_sem); -list_for_each_entry (tmp, &bus_type_list, list) { -if (tmp->match (dev)) { - ret = tmp; -break ; +guard (rwsem_read)(&bus_type_sem); + +list_for_each_entry (type, &bus_type_list, list) { +struct acpi_device *adev; + +if (!type->match (dev)) +continue ; + + adev = type->find_companion (dev); +if (!adev) { +dev_dbg (dev,"ACPI companion not found\n" ); +return NULL ; } +if (acpi_bind_one (dev, adev)) { +dev_dbg (dev,"Binding to ACPI companion failed\n" ); +return NULL ; + } +if (type->setup) + type->setup (dev); + +return adev; } -up_read (&bus_type_sem); -return ret; + +return NULL ; }#define FIND_CHILD_MIN_SCORE 1
@@ -360,40 +375,22 @@ void acpi_device_notify(struct device *dev) ret =acpi_bind_one (dev,NULL );if (ret) { -struct acpi_bus_type *type =acpi_get_bus_type (dev); - -if (!type) + adev =acpi_companion_lookup (dev); +if (!adev)return ; - - adev = type->find_companion (dev); -if (!adev) { -dev_dbg (dev,"ACPI companion not found\n" ); -return ; - } - ret =acpi_bind_one (dev, adev); -if (ret) { -dev_dbg (dev,"Binding to ACPI companion failed\n" ); -return ; - } -if (type->setup) { - type->setup (dev); - goto done; - } }else { adev =ACPI_COMPANION (dev);if (dev_is_pci (dev)) {pci_acpi_setup (dev, adev); - goto done; }else if (dev_is_platform (dev)) {acpi_configure_pmsi_domain (dev); + +if (adev->handler && adev->handler->bind) + adev->handler->bind (dev); } } -if (adev->handler && adev->handler->bind) - adev->handler->bind (dev); - -done:dev_dbg (dev,"Bound to ACPI device %s\n" ,acpi_dev_name (adev)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/2151 ACPI: glue: Fix up and adjust acpi_unbind_one()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 693546852656075e0247ac637b05625ead134eff ]
Since none of the acpi_unbind_one() callers check its return value and it always returns 0 anyway, make it void.
Also notice that unlocking physical_node_lock for the given ACPI device should be carried out before dropping the reference to it in case that reference is the last one (highly unlikely), so rearrange the code to make that happen.
--- drivers/acpi/glue.c | 10 ++++++---- include/acpi/acpi_bus.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/acpi/glue.c +6 -4
@@ -331,13 +331,13 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) }EXPORT_SYMBOL_GPL (acpi_bind_one); -int acpi_unbind_one (struct device *dev) +void acpi_unbind_one (struct device *dev) {struct acpi_device *acpi_dev =ACPI_COMPANION (dev);struct acpi_device_physical_node *entry;if (!acpi_dev) -return 0 ; +return ;mutex_lock (&acpi_dev->physical_node_lock);
@@ -352,15 +352,17 @@ int acpi_unbind_one(struct device *dev)sysfs_remove_link (&acpi_dev->dev.kobj, physnode_name);sysfs_remove_link (&dev->kobj,"firmware_node" );ACPI_COMPANION_SET (dev,NULL ); + +mutex_unlock (&acpi_dev->physical_node_lock); +/* Drop references taken by acpi_bind_one(). */ put_device (dev);acpi_dev_put (acpi_dev);kfree (entry); -break ; +return ; }mutex_unlock (&acpi_dev->physical_node_lock); -return 0 ; }EXPORT_SYMBOL_GPL (acpi_unbind_one);
include/acpi/acpi_bus.h +1 -1
@@ -720,7 +720,7 @@ struct acpi_bus_type {int register_acpi_bus_type (struct acpi_bus_type *);int unregister_acpi_bus_type (struct acpi_bus_type *);int acpi_bind_one (struct device *dev,struct acpi_device *adev); -int acpi_unbind_one (struct device *dev); +void acpi_unbind_one (struct device *dev);enum acpi_bridge_type {ACPI_BRIDGE_TYPE_PCIE =1 ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/2151 thermal: gov_power_allocator: Fix NULL pointer dereference in update_tz()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumeet Pawnikar <[email protected]>
[ Upstream commit d3515092f1bff9cfb4d99ea82dcd4ac66f32f50d ]
power_allocator_update_tz() unconditionally derives the trip descriptor of params->trip_max as below,
const struct thermal_trip_desc *td = trip_to_trip_desc(params->trip_max);
and then walks td->thermal_instances. However, params->trip_max is allowed to be NULL and in that case the list walk dereferences a bogus pointer derived from NULL which oops the kernel.
get_governor_trips() picks trip_switch_on and trip_max out of the trip table of the zone. When the zone has neither a passive nor an active trip point, last_active is NULL and params->trip_max is left NULL. This is an explicitly supported configuration, as documented in the function get_governor_trips() as below,
If there are no passive or active trip points, then the governor won't do anything. In fact, its throttle function won't be called at all.
Return early from power_allocator_update_tz() when params->trip_max is NULL and only compute the trip descriptor after that check. There is nothing to update in that case anyway, with no trip_max and there are no thermal instances for the governor to account for, num_actors stays zero and total_weight is irrelevant.
--- drivers/thermal/gov_power_allocator.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/thermal/gov_power_allocator.c +6 -1
@@ -661,10 +661,15 @@ static void power_allocator_update_tz(struct thermal_zone_device *tz, enum thermal_notify_event reason) {struct power_allocator_params *params = tz->governor_data; -const struct thermal_trip_desc *td =trip_to_trip_desc (params->trip_max); +const struct thermal_trip_desc *td;struct thermal_instance *instance;int num_actors =0 ; +if (!params->trip_max) +return ; + + td =trip_to_trip_desc (params->trip_max); +switch (reason) {case THERMAL_TZ_BIND_CDEV :case THERMAL_TZ_UNBIND_CDEV :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/2151 firewire: cdev: Fix FW_CDEV_IOC_CREATE_ISO_CONTEXT references in kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 0a6cf2b7adcbd362039e9d282f73aff3f24022ca ]
The fw_cdev_event_iso_interrupt and fw_cdev_event_iso_interrupt_mc comments refer to FW_CDEV_CREATE_ISO_CONTEXT, but the ioctl is named FW_CDEV_IOC_CREATE_ISO_CONTEXT.
Correct both references. The misspellings were introduced separately with the userspace interface documentation and multichannel reception support.
--- include/uapi/linux/firewire-cdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/firewire-cdev.h +2 -2
@@ -293,7 +293,7 @@ struct fw_cdev_event_request3 {/** * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed * @closure: See &fw_cdev_event_common; -* set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl +* set by %FW_CDEV_IOC_CREATE_ISO_CONTEXT ioctl * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT * @cycle: Cycle counter of the last completed packet * @header_length: Total length of following headers, in bytes
@@ -353,7 +353,7 @@ struct fw_cdev_event_iso_interrupt {/** * struct fw_cdev_event_iso_interrupt_mc - An iso buffer chunk was completed * @closure: See &fw_cdev_event_common; -* set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl +* set by %FW_CDEV_IOC_CREATE_ISO_CONTEXT ioctl * @type: %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL * @completed: Offset into the receive buffer; data before this offset is valid *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/2151 firewire: core: remove unused link field in fw_packet structure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 00d4d31e4fdfe51312f0184f8d162b8d4de172dc ]
The link field in fw_packet structure has never been used since it was added.
--- include/linux/firewire.h | 1 - 1 file changed, 1 deletion(-)
include/linux/firewire.h +0 -1
@@ -321,7 +321,6 @@ struct fw_packet {*/ fw_packet_callback_t callback;int ack; -struct list_head link;void *driver_data; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/2151 cpuidle: menu: Remove incorrect unlikely() annotation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit fcbd7897b871e157ee5c595e950c8466d86c0cd5 ]
The unlikely() annotation on the early-return condition in menu_select() is incorrect on systems with only one idle state (e.g., ARM64 servers with a single ACPI LPI state). Branch profiling shows 100% misprediction on such systems since drv->state_count <= 1 is always true.
On platforms where only state0 is available, this path is the common case, not an unlikely edge case. Remove the misleading annotation to let the branch predictor learn the actual behavior.
Stable-dep-of: d594187cafd5 ("cpuidle: menu: Do not return a disabled idle state")
--- drivers/cpuidle/governors/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/governors/menu.c +1 -1
@@ -281,7 +281,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, data->bucket =BUCKETS -1 ; } -if (unlikely (drv->state_count <=1 || latency_req ==0 ) || +if (drv->state_count <=1 || latency_req ==0 || ((data->next_timer_ns < drv->states[1 ].target_residency_ns || latency_req < drv->states[1 ].exit_latency_ns) && !dev->states_usage[0 ].disable)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/2151 cpuidle: menu: Remove single state handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Loehle <[email protected]>
[ Upstream commit 93983a9f3beea791c21d77c2425488ad327d4fda ]
cpuidle systems where the governor has no choice because there's only a single idle state are now handled by cpuidle core and bypass the governor, so remove the related handling.
Stable-dep-of: d594187cafd5 ("cpuidle: menu: Do not return a disabled idle state")
--- drivers/cpuidle/governors/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/governors/menu.c +1 -1
@@ -281,7 +281,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, data->bucket =BUCKETS -1 ; } -if (drv->state_count <=1 || latency_req ==0 || +if (latency_req ==0 || ((data->next_timer_ns < drv->states[1 ].target_residency_ns || latency_req < drv->states[1 ].exit_latency_ns) && !dev->states_usage[0 ].disable)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/2151 cpuidle: menu: Do not return a disabled idle state
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit d594187cafd5ad65afc5f00242f8fa20e1d8c0f1 ]
When idle state 0 is disabled and the PM QoS latency constraint is zero (latency_req == 0), the first branch of the || in the early-return condition of menu_select() is taken immediately, so state 0 is returned regardless of its disable flag.
Address this by making the !disable check a prerequisite for the entire early-return condition, so that when state 0 is disabled the normal state selection loop is used instead, which already skips disabled states.
--- drivers/cpuidle/governors/menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cpuidle/governors/menu.c +4 -4
@@ -281,10 +281,10 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, data->bucket =BUCKETS -1 ; } -if (latency_req ==0 || - ((data->next_timer_ns < drv->states[1 ].target_residency_ns || - latency_req < drv->states[1 ].exit_latency_ns) && - !dev->states_usage[0 ].disable)) { +if (!dev->states_usage[0 ].disable && + (latency_req ==0 || + data->next_timer_ns < drv->states[1 ].target_residency_ns || + latency_req < drv->states[1 ].exit_latency_ns)) {/* * In this case state[0] will be used no matter what, so return * it right away and keep the tick running if state[0] is a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/2151 ARM: dts: stm32: lxa-mc1: change stdout-path baud rate from 9600 to 115200
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmad Fatoum <[email protected]>
[ Upstream commit fc3c0ffefc169719316eddb8c36e2427e11ce713 ]
The default baud rate when none is specified is up to the DT consumer.
In the case of the Linux STM32 serial driver, it defaults to 9600 baud, which differs from the 115200 baud that this board's barebox bootloader configured.
This went unnoticed, because barebox automatically fixes up a console= command-line option that looks like this on the LXA boards:
console=ttySTM0,115200n8
This had precedence over the 9600 fallback baud rate.
But when EFI booting a kernel via GRUB, we run into this issue, because the barebox-provided command-line is disregarded by GRUB.
Fix this by explicitly setting the baud rate to the correct 115200.
--- arch/arm/boot/dts/st/stm32mp157c-lxa-mc1.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/st/stm32mp157c-lxa-mc1.dts +1 -1
@@ -33,7 +33,7 @@ backlight: backlight { }; chosen { - stdout-path = &uart4; + stdout-path = "serial0:115200n8"; }; led-controller-0 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/2151 ARM: dts: stm32: lxa-tac: change stdout-path baud rate from 9600 to 115200
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmad Fatoum <[email protected]>
[ Upstream commit 85bb59fc12ef439b248d5f4faf846d5566b701fe ]
The default baud rate when none is specified is up to the DT consumer.
In the case of the Linux STM32 serial driver, it defaults to 9600 baud, which differs from the 115200 baud that this board's barebox bootloader configured.
This went unnoticed, because barebox automatically fixes up a console= command-line option that looks like this on the LXA boards:
console=ttySTM0,115200n8
This had precedence over the 9600 fallback baud rate.
But when EFI booting a kernel via GRUB, we run into this issue, because the barebox-provided command-line is disregarded by GRUB.
Fix this by explicitly setting the baud rate to the correct 115200.
--- arch/arm/boot/dts/st/stm32mp15xc-lxa-tac.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/st/stm32mp15xc-lxa-tac.dtsi +1 -1
@@ -33,7 +33,7 @@ aliases { }; chosen { - stdout-path = &uart4; + stdout-path = "serial0:115200n8"; }; led-controller-0 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/2151 ARM: dts: stm32: fairytux2: change stdout-path baud rate from 9600 to 115200
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmad Fatoum <[email protected]>
[ Upstream commit 5404275bc121a7b06676777c3362d85fb75356fc ]
The default baud rate when none is specified is up to the DT consumer.
In the case of the Linux STM32 serial driver, it defaults to 9600 baud, which differs from the 115200 baud that this board's barebox bootloader configured.
This went unnoticed, because barebox automatically fixes up a console= command-line option that looks like this on the LXA boards:
console=ttySTM0,115200n8
This had precedence over the 9600 fallback baud rate.
But when EFI booting a kernel via GRUB, we run into this issue, because the barebox-provided command-line is disregarded by GRUB.
Fix this by explicitly setting the baud rate to the correct 115200.
--- arch/arm/boot/dts/st/stm32mp153c-lxa-fairytux2.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/st/stm32mp153c-lxa-fairytux2.dtsi +1 -1
@@ -28,7 +28,7 @@ aliases { }; chosen { - stdout-path = &uart4; + stdout-path = "serial0:115200n8"; }; backlight: backlight {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/2151 ARM: dts: stm32: add LTDC / DCMIPP access controller for STM32MP135
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
[ Upstream commit 0c354b85cc95b5d563a581c8dbca57b4942bfae7 ]
Add ETZPC as an access controller for the LTDC and DCMIPP found on the stm32mp135.
--- arch/arm/boot/dts/st/stm32mp135.dtsi | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-)
arch/arm/boot/dts/st/stm32mp135.dtsi +21 -21
@@ -6,29 +6,29 @@ #include "stm32mp133.dtsi" -/ { - soc { - dcmipp: dcmipp@5a000000 { - compatible = "st,stm32mp13-dcmipp"; - reg = <0x5a000000 0x400>; - interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; - resets = <&rcc DCMIPP_R>; - clocks = <&rcc DCMIPP_K>; - status = "disabled"; +&etzpc { + dcmipp: dcmipp@5a000000 { + compatible = "st,stm32mp13-dcmipp"; + reg = <0x5a000000 0x400>; + interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; + resets = <&rcc DCMIPP_R>; + clocks = <&rcc DCMIPP_K>; + access-controllers = <&etzpc 4>; + status = "disabled"; - port { - }; + port { }; + }; - ltdc: display-controller@5a001000 { - compatible = "st,stm32-ltdc"; - reg = <0x5a001000 0x400>; - interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>, - <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&rcc LTDC_PX>; - clock-names = "lcd"; - resets = <&scmi_reset RST_SCMI_LTDC>; - status = "disabled"; - }; + ltdc: display-controller@5a001000 { + compatible = "st,stm32-ltdc"; + reg = <0x5a001000 0x400>; + interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&rcc LTDC_PX>; + clock-names = "lcd"; + resets = <&scmi_reset RST_SCMI_LTDC>; + access-controllers = <&etzpc 3>; + status = "disabled"; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/2151 cpuidle: teo: Do not return a disabled idle state
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit 60d5fca628f94f8f23398ad62d80aa284dae6571 ]
If idle state 0 is disabled and none of the enabled idle states satisfies the PM QoS latency constraint, constraint_idx in teo_select() stays at its initial value of 0, because the loop that updates it starts at state 1, and so the candidate state index is capped at state 0, which is disabled, and that state is returned to the caller.
The cpuidle core does not validate the returned state index against the per-state disable flags, so the CPU ends up entering the disabled state 0.
To address this, ensure that constraint_idx is at least equal to the index of the first enabled idle state (idx0), so that the candidate state is never capped to a disabled one.
--- drivers/cpuidle/governors/teo.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/cpuidle/governors/teo.c +11 -0
@@ -413,6 +413,17 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, } } +/* +* If the latency constraint does not allow any of the enabled idle +* states to be used, the candidate state index will be capped to 0 +* by the check below, but state 0 may be disabled. To prevent the +* selection of a disabled state in that case, ensure that +* constraint_idx is at least equal to the index of the first +* enabled idle state. +*/ +if (constraint_idx < idx0) + constraint_idx = idx0; +/* * If there is a latency constraint, it may be necessary to select an * idle state shallower than the current candidate one.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/2151 PM: runtime: Only queue an idle check for RPM-linked suppliers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Norris <[email protected]>
[ Upstream commit be5755f023e7e02ec90bbd1d4ca63a0abe594733 ]
When a device RPM-suspends, it queues up an idle check for all of its suppliers, in case that device was the last consumer, and those suppliers are now able to suspend. Today, we do this for all suppliers, and not only for those suppliers that are marked for use by runtime PM. This isn't directly harmful, but it is a bit wasteful, and also may induce unexpected suspend attempts (e.g., if a device was purposely last touched with pm_runtime_put_noidle()).
To avoid excess idle checks, only call pm_request_idle() on linked suppliers that opted into runtime PM.
Noticed by inspection of trace logs.
This is not expected to have a functional impact on systems that are using device links properly, and should only be considered an optimization.
--- drivers/base/power/runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +2 -1
@@ -361,7 +361,8 @@ static void rpm_suspend_suppliers(struct device *dev)list_for_each_entry_rcu (link, &dev->links.suppliers, c_node,device_links_read_lock_held ()) -pm_request_idle (link->supplier); +if (device_link_test (link,DL_FLAG_PM_RUNTIME )) +pm_request_idle (link->supplier);device_links_read_unlock (idx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/2151 ARM: dts: stm32: Drop bias-disable from STM32MP15xx DHCOM SoM sdmmc1_b4_pins_a
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 3572825773791f4258b553391f4e2187df321731 ]
Drop bias-disable property from STM32MP15xx DHCOM SoM sdmmc1_b4_pins_a to fix the following DT checker warning. The bias-pull-up property is the only bias-related property that has to be present in those pinctrl node subnodes.
"arch/arm/boot/dts/st/stm32mp153c-dhcom-drc02.dtb: pinctrl@50002000 (st,stm32mp157-pinctrl): sdmmc1-b4-0:pins1: {'pinmux': [10253, 10509, 10765, 11021, 12813], 'slew-rate': 1, 'drive-push-pull': True, 'bias-disable': True, 'bias-pull-up': True} is valid under each of {'required': ['bias-pull-up']}, {'required': ['bias-disable']} "
--- arch/arm/boot/dts/st/stm32mp15xx-dhcom-som.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/st/stm32mp15xx-dhcom-som.dtsi +2 -0
@@ -505,9 +505,11 @@ &sdmmc1_b4_pins_a { * - mandatory on SoMs without SD voltage translator */ pins1 { + /delete-property/ bias-disable; bias-pull-up; }; pins2 { + /delete-property/ bias-disable; bias-pull-up; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/2151 HID: i2c-hid: Unfollow the panel on shutdown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Yeh <[email protected]>
[ Upstream commit 59fc35a1edbfa5405122d749cf8843da131fd796 ]
i2c_hid_core_shutdown() sends SET_POWER(SLEEP) even for panel followers, but nothing in device_shutdown() guarantees whether the panel, and hence our own power, is still on by the time we get there.
Do what i2c_hid_core_remove() does and just unfollow the panel. drm_panel_remove_follower() calls panel_unpreparing() only while the panel is still prepared, which powers us down properly; if it is already unprepared no transfer is attempted at all. On MT8196 the panel is unprepared long before us, so this also drops the ~2s i2c bus timeout from every reboot.
--- drivers/hid/i2c-hid/i2c-hid-core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid-core.c +10 -1
@@ -1355,7 +1355,16 @@ void i2c_hid_core_shutdown(struct i2c_client *client) {struct i2c_hid *ihid =i2c_get_clientdata (client); -i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP ); +/* +* Like in i2c_hid_core_remove(): if we're a follower, the act of +* unfollowing will cause us to be powered down. Otherwise we need to +* manually do it. +*/ +if (ihid->is_panel_follower) +drm_panel_remove_follower (&ihid->panel_follower); +else +i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP ); +free_irq (client->irq, ihid);i2c_hid_core_shutdown_tail (ihid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/2151 ARM: dts: stm32: fix vdda supply for onboard hub on stm32mp15 DK boards
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Gasnier <[email protected]>
[ Upstream commit 8d8f88e0f3e602cd967bdd8d7bc218ac7613650a ]
stm32mp15 DK boards use Microchip USB2514 HUB. Since vdda supply has been added, the regulator framework wrongly associates the 'vdda' supply dedicated to ADC, so the wrong regulator is referenced.
Only the 3v3 regulator is used to supply both the digital and the analog part of the HUB.
--- arch/arm/boot/dts/st/stm32mp157f-dk2-scmi.dtsi | 1 + arch/arm/boot/dts/st/stm32mp15xx-dkx.dtsi | 1 + 2 files changed, 2 insertions(+)
arch/arm/boot/dts/st/stm32mp157f-dk2-scmi.dtsi +1 -0
@@ -180,6 +180,7 @@ &sdmmc3 { &usbh_ehci { hub@1 { vdd-supply = <&scmi_v3v3>; + vdda-supply = <&scmi_v3v3>; }; };
arch/arm/boot/dts/st/stm32mp15xx-dkx.dtsi +1 -0
@@ -709,6 +709,7 @@ hub@1 { compatible = "usb424,2514"; reg = <1>; vdd-supply = <&v3v3>; + vdda-supply = <&v3v3>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/2151 ARM: dts: stm32: fix vdda supply for onboard hub on stm32mp157c-ev1
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Gasnier <[email protected]>
[ Upstream commit dae62eda0c987f3b80d622d00a45fb0cec854054 ]
stm32mp157c-ev1 uses Microchip USB2514 HUB. Since vdda supply has been added, the regulator framework wrongly associates the 'vdda' supply dedicated to ADC, so the wrong regulator is referenced.
Only the 3v3 regulator is used to supply both the digital and the analog part of the HUB.
--- arch/arm/boot/dts/st/stm32mp157c-ev1.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/st/stm32mp157c-ev1.dts +1 -0
@@ -379,6 +379,7 @@ hub@1 { compatible = "usb424,2514"; reg = <1>; vdd-supply = <&v3v3>; + vdda-supply = <&v3v3>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/2151 ARM: dts: stm32: fix vdda supply for onboard hub on stm32mp135f-dk
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Gasnier <[email protected]>
[ Upstream commit 2f92d900f262a16c8ae02daf53ae2910d07185f5 ]
stm32mp135f-dk uses Microchip USB2514 HUB. Since vdda supply has been added, the regulator framework wrongly associates the 'vdda' supply dedicated to ADC, so the wrong regulator is referenced.
Only the 3v3 regulator is used to supply both the digital and the analog part of the HUB.
--- arch/arm/boot/dts/st/stm32mp135f-dk.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/st/stm32mp135f-dk.dts +1 -0
@@ -567,6 +567,7 @@ hub@1 { compatible = "usb424,2514"; reg = <1>; vdd-supply = <&scmi_v3v3_sw>; + vdda-supply = <&scmi_v3v3_sw>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/2151 bpf: Fix program BTF use-after-free in sleepable programs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit 88c9c6d0a766dd146545990053e8a04422ccb367 ]
Object kfunc calls embed metadata owned by the program BTF. A sleepable program can remain active under Tasks Trace RCU after its last reference is dropped, while program teardown releases the BTF through ordinary RCU. The invocation can then dereference freed metadata in bpf_obj_new().
Move btf_put() into __bpf_prog_put_rcu(), the callback that frees the program. When teardown is deferred, that callback runs after the program's own grace period (Tasks Trace RCU for sleepable programs and ordinary RCU otherwise), so the BTF outlives every active invocation. The non-deferred path invokes the callback synchronously, so load-error cleanup stays direct.
--- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/syscall.c +1 -1
@@ -2384,6 +2384,7 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu) { struct bpf_prog_aux *aux = container_of(rcu, struct bpf_prog_aux, rcu); +btf_put (aux->btf);kvfree (aux->func_info);kfree (aux->func_info_aux);free_uid (aux->user);
@@ -2394,7 +2395,6 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu)static void __bpf_prog_put_noref (struct bpf_prog *prog,bool deferred) {bpf_prog_kallsyms_del_all (prog); -btf_put (prog->aux->btf);module_put (prog->aux->mod);kvfree (prog->aux->jited_linfo);kvfree (prog->aux->linfo);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/2151 ARM: dts: imx7-tqma7: correctly specify PMIC voltage constraints
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nora Schiffer <[email protected]>
[ Upstream commit f322f8f68c2c3291633ead663effa3b25c18f7b1 ]
regulator-(min|max)-microvolt refer to the supported voltages according to board design, not the possible range of the regulators themselves. Update the configuration for the TQMa7x's PMIC and also add a comment regarding the PMIC's VCC_SD switching feature.
--- arch/arm/boot/dts/nxp/imx/imx7-tqma7.dtsi | 40 +++++++++++++---------- 1 file changed, 23 insertions(+), 17 deletions(-)
arch/arm/boot/dts/nxp/imx/imx7-tqma7.dtsi +23 -17
@@ -46,8 +46,8 @@ pfuze3000: pmic@8 { regulators { sw1a_reg: sw1a { - regulator-min-microvolt = <700000>; - regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1225000>; regulator-boot-on; regulator-always-on; regulator-ramp-delay = <6250>;
@@ -55,34 +55,33 @@ sw1a_reg: sw1a { /* use sw1c_reg to align with pfuze100/pfuze200 */ sw1c_reg: sw1b { - regulator-min-microvolt = <700000>; - regulator-max-microvolt = <1475000>; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; regulator-boot-on; regulator-always-on; regulator-ramp-delay = <6250>; }; sw2_reg: sw2 { - regulator-min-microvolt = <1500000>; - regulator-max-microvolt = <1850000>; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; regulator-boot-on; regulator-always-on; }; sw3a_reg: sw3 { - regulator-min-microvolt = <900000>; - regulator-max-microvolt = <1650000>; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; regulator-boot-on; regulator-always-on; }; swbst_reg: swbst { - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5150000>; + /* Not connected and left unconfigured */ }; snvs_reg: vsnvs { - regulator-min-microvolt = <1000000>; + regulator-min-microvolt = <3000000>; regulator-max-microvolt = <3000000>; regulator-boot-on; regulator-always-on;
@@ -95,18 +94,25 @@ vref_reg: vrefddr { vgen1_reg: vldo1 { regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; + regulator-max-microvolt = <1800000>; regulator-always-on; }; vgen2_reg: vldo2 { - regulator-min-microvolt = <800000>; - regulator-max-microvolt = <1550000>; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; regulator-always-on; }; vgen3_reg: vccsd { - regulator-min-microvolt = <2850000>; + /* + * Specified values refer to 3.3V operation; voltage for 1.8V + * operation is derived from this. + * + * The base board should usually mux GPIO1_IO08 to SD1_VSELECT for + * automatic switching of SD card IO voltage. + */ + regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; };
@@ -118,13 +124,13 @@ vgen4_reg: v33 { }; vgen5_reg: vldo3 { - regulator-min-microvolt = <1800000>; + regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; }; vgen6_reg: vldo4 { - regulator-min-microvolt = <1800000>; + regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/2151 arm64: dts: ti: k3-j784s4-j742s2-evm-common: Set ACSPCIe refclk to MAIN_PLL2_HSDIV4 for pcie1
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jared McArthur <[email protected]>
[ Upstream commit 7e4b4f799bd043cb5b30176ddbe690a0fb5788bc ]
Commit e3dfcf482d07 ("arm64: dts: ti: k3-j784s4-j742s2-evm-common:
Enable ACSPCIE0 output for PCIe1") enabled the ACSPCIE0 buffers to provide the PCIe refclk for PCIe1, but introduced a bug where the clock is remporarily disabled during initialization. The ACSPCIe reference clock is muxable between multiple
sources: SERDESx_REF_DER_OUT_CLK, MAIN_PLL2_HSDIV4_CLKOUT, and SERDESx_REF_OUT_CLK [0]. On reset, the refclk is set to the SERDESx_REF_DER_OUT_CLK. In the J742S2 and J784S4, "the SerDes PCIe Reference Clock Output will be temporarily disabled when changing Data Rates to or from 8.0 GT/s in Derived Refclk mode" [1]. Some external PCIe devices cannot tolerate the reference clock being disabled and will therefore fail to link.
This advisory is described in more detail as: i2242 of the J784S4 Silicon Revision 1.0 (Rev. B) document [1].
The refclk for devices connected to PCIe1 is provided by the ACSPCIe buffers in the J742S2XH01EVM [2] and J784S4XEVM [3]. Work around the advisory by setting the ACSPCIe reference clock source to MAIN_PLL2_HSDIV4_CLKOUT. Use the TI SCI clock controller to assign the clock's source [4].
[0] https://www.ti.com/lit/zip/spruj52
[1] https://www.ti.com/lit/pdf/SPRZ536
[2] https://www.ti.com/lit/zip/SPAC001
[3] https://www.ti.com/lit/zip/SPRR458
[4] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j784s4/clocks.html
--- arch/arm64/boot/dts/ti/k3-j784s4-j742s2-evm-common.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/ti/k3-j784s4-j742s2-evm-common.dtsi +2 -0
@@ -1196,6 +1196,8 @@ &pcie1_rc { status = "okay"; clocks = <&k3_clks 333 0>, <&serdes0 CDNS_TORRENT_REFCLK_DRIVER>; clock-names = "fck", "pcie_refclk"; + assigned-clocks = <&k3_clks 415 0>; + assigned-clock-parents = <&k3_clks 415 2>; num-lanes = <2>; reset-gpios = <&exp1 2 GPIO_ACTIVE_HIGH>; phys = <&serdes0_pcie1_link>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/2151 x86/svm: Avoid sign extension of SVM_EVTINJ_VALID in 64-bit expressions
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaithanya Lagisetty <[email protected]>
[ Upstream commit c5991239b148d40d4981901968b3a6a838ff517b ]
SVM_EVTINJ_VALID is defined as (1 << 31), i.e. as an int with the sign bit set. Whenever it is used in a 64-bit expression the int is sign extended, so bits 63:32 end up set as well. Two 64-bit users are affected.
verify_exception_info() uses the macro as a mask against a 64-bit value when it sanity checks hypervisor supplied exception information:
u64 info = ghcb->save.sw_exit_info_2; ... if ((info & SVM_EVTINJ_VALID) &&
The mask is 0xffffffff80000000, so the check also passes when any bit of the error code in 63:32 is set while the valid bit itself is clear.
svm_vmgexit_inject_exception() builds the value that KVM hands to an SEV-ES guest in GHCB SW_EXITINFO2:
u64 data = SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_EXEPT | vector;
For vector == X86_TRAP_GP this yields 0xffffffff8000030d instead of 0x000000008000030d. The field uses the EVENTINJ format, which holds the error code in bits 63:32, so KVM asks the guest to inject #GP with an error code of 0xffffffff. Linux guests only consume the error code when SVM_EVTINJ_VALID_ERR is set, which it is not here, so they are not affected in practice, but the value KVM writes is not the one it intends.
Use BIT() instead, as is already done for most single bit definitions in this header. Every other user applies the macro to a u32, where the resulting bits are unchanged.
Opportunistically give SVM_EVTINJ_VALID_ERR the same treatment, there's zero reason to open code BIT().
--- arch/x86/include/asm/svm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/svm.h +2 -2
@@ -627,8 +627,8 @@ static inline void __unused_size_checks(void)#define SVM_EVTINJ_TYPE_EXEPT (3 << SVM_EVTINJ_TYPE_SHIFT)#define SVM_EVTINJ_TYPE_SOFT (4 << SVM_EVTINJ_TYPE_SHIFT) -#define SVM_EVTINJ_VALID (1 << 31) -#define SVM_EVTINJ_VALID_ERR (1 << 11) +#define SVM_EVTINJ_VALID BIT(31) +#define SVM_EVTINJ_VALID_ERR BIT(11)#define SVM_EXITINTINFO_VEC_MASK SVM_EVTINJ_VEC_MASK#define SVM_EXITINTINFO_TYPE_MASK SVM_EVTINJ_TYPE_MASK
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/2151 clk: mediatek: reset: Fix device registration kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8d5fa37307ac1f0612cf17ac0ccabcc258cc1526 ]
The comment for mtk_register_reset_controller_with_dev() names the older helper and documents np rather than dev. The new helper takes a struct device and obtains its device node internally.
Use the actual function and parameter names and clarify that failures return negative error codes.
--- drivers/clk/mediatek/reset.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/mediatek/reset.h +3 -3
@@ -60,11 +60,11 @@ struct mtk_clk_rst_data { };/** -* mtk_register_reset_controller - Register mediatek clock reset controller with device -* @np: Pointer to device. +* mtk_register_reset_controller_with_dev - Register a MediaTek reset controller +* @dev: Device used to manage the reset controller resources. * @desc: Constant pointer to description of clock reset. * -* Return: 0 on success and errorno otherwise. +* Return: 0 on success, negative errno otherwise. */ int mtk_register_reset_controller_with_dev (struct device *dev,const struct mtk_clk_rst_desc *desc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/2151 clk: rs9: Add clock index range check to rs9_of_clk_get()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit a2ef401bdfd19aa41d0e3e1b630a12fbc01ac184 ]
rs9_of_clk_get() does not validate the clock index in the passed DT clock specifier. If DT specifies an incorrect and out-of-range index, this will access memory beyond the end of the clk_dif[] array.
Fix by this adding a range check to rs9_of_clk_get().
--- drivers/clk/clk-renesas-pcie.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/clk-renesas-pcie.c +5 -0
@@ -277,6 +277,11 @@ rs9_of_clk_get(struct of_phandle_args *clkspec, void *data)struct rs9_driver_data *rs9 = data;unsigned int idx = clkspec->args[0 ]; +if (idx >= rs9->chip_info->num_clks) { +pr_err ("%s: Invalid clock index %u\n" , __func__, idx); +return ERR_PTR (-EINVAL ); + } +return rs9->clk_dif[idx]; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/2151 clk: s2mps11: Propagate OF provider registration failures
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 276741aac3b56ba50bef59715ba18ba3f0b953a2 ]
s2mps11_clk_probe() ignores of_clk_add_hw_provider() failures, stores driver data and returns success even though DT consumers cannot acquire the registered clocks.
Return the provider error through the existing lookup cleanup path. Skip empty lookup slots while unwinding because S2MPS14 omits its CP clock.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/clk/clk-s2mps11.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/clk/clk-s2mps11.c +8 -4
@@ -192,8 +192,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev) clk_data->hws[i] = &s2mps11_clks[i].hw; } -of_clk_add_hw_provider (s2mps11_clks->clk_np, of_clk_hw_onecell_get, - clk_data); + ret =of_clk_add_hw_provider (s2mps11_clks->clk_np, + of_clk_hw_onecell_get, clk_data); +if (ret) + goto err_reg;platform_set_drvdata (pdev, s2mps11_clks);
@@ -201,8 +203,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev) err_reg:of_node_put (s2mps11_clks[0 ].clk_np); -while (--i >=0 ) -clkdev_drop (s2mps11_clks[i].lookup); +while (--i >=0 ) { +if (s2mps11_clks[i].lookup) +clkdev_drop (s2mps11_clks[i].lookup); + }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/2151 spi: Fix the return value in spi_new_ancillary_device() kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 3742867ce96539100ed5f4c754f04273d8aa00d7 ]
spi_new_ancillary_device() returns the new struct spi_device, or an ERR_PTR() on failure, but its kernel-doc says "0 on success; negative errno on failure", which was never true. Describe the pointer.
--- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
@@ -2551,7 +2551,7 @@ static void of_register_spi_devices(struct spi_controller *ctlr) { }* * This may only be called from main SPI device's probe routine. * -* Return: 0 on success; negative errno on failure +* Return: the new device on success; an ERR_PTR() on failure */ struct spi_device *spi_new_ancillary_device (struct spi_device *spi,u8 chip_select)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/2151 ata: libata-scsi: Fix ata_scsi_hotplug() reference in kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 5915ab523e33057224a0240e27b88c6c2798b919 ]
The ata_scsi_remove_dev() comment misspells its caller as ata_eh_scsi_hotplug(). The caller is ata_scsi_hotplug(). Correct the reference, which predates libata's move from drivers/scsi to drivers/ata.
--- drivers/ata/libata-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-scsi.c +1 -1
@@ -4919,7 +4919,7 @@ bool ata_scsi_offline_dev(struct ata_device *dev)* ata_scsi_remove_dev - remove attached SCSI device * @dev: ATA device to remove attached SCSI device for * -* This function is called from ata_eh_scsi_hotplug() and +* This function is called from ata_scsi_hotplug() and * responsible for removing the SCSI device attached to @dev. * * LOCKING:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/2151 gfs2: Fix the return value in gfs2_get_link() kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 700a0a6892f7c0c541d5d23837cfab98cc744d17 ]
gfs2_get_link() returns the link target or an error pointer, but its kernel-doc still describes an integer status. The mismatch dates back to when gfs2_readlink() was replaced by generic_readlink() and persisted across the removal of nd_set_link().
Describe the returned pointer and error value.
--- fs/gfs2/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/inode.c +1 -1
@@ -1898,7 +1898,7 @@ static int gfs2_rename2(struct mnt_idmap *idmap, struct inode *odir,* * This can handle symlinks of any size. * -* Returns: 0 on success or error code +* Returns: the link target on success, an ERR_PTR() on failure */ static const char *gfs2_get_link(struct dentry *dentry,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/2151 virtio: synchronize callbacks after device reset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <[email protected]>
[ Upstream commit dd75508e6fe77116589c49658d0d18897688dc0b ]
virtio_reset_device says:
Note: this guarantees that vq callbacks are not in progress
but in practice, only virtio pci correctly synchronizes the cbs.
On other transports, a callback that is already executing, keeps running while the driver tears down the state it uses.
Add virtio_synchronize_cbs to virtio_reset_device fixing this for all transports that correctly implement synchronize_cbs().
Message-ID: <8ae2995ee649adcfe1398f7f1c4fc9f7028c3db1.1789204858.git.mst@redhat.com>
--- drivers/virtio/virtio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio.c +2 -0
@@ -264,6 +264,8 @@ void virtio_reset_device(struct virtio_device *dev)#endif dev->config->reset (dev); +/* Flush pending VQ/configuration callbacks. */ +virtio_synchronize_cbs (dev); }EXPORT_SYMBOL_GPL (virtio_reset_device);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/2151 virtio_pci_modern: move avq cleanup from reset to del_vqs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <[email protected]>
[ Upstream commit 2a12d96dd863cb23eadf07d8845e961580b5fcdf ]
vp_modern_avq_cleanup() detaches unused buffers from the admin virtqueue. Calling it from vp_reset() is incorrect:virtqueue_get_buf in the avq interrupt handler can race with virtqueue_detach_unused_buf in cleanup, and get_buf after detach is not documented as valid.
The root cause is that detaching buffers does not belong in reset at all - reset quiesces the device, while cleanup belongs where the virtqueue is about to be destroyed, from del_vqs.
Message-ID: <21fe35ad7b66e2c30dbdba6fe4df4824d1c0db66.1789204858.git.mst@redhat.com>
--- drivers/virtio/virtio_pci_modern.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/virtio/virtio_pci_modern.c +8 -4
@@ -364,6 +364,12 @@ static void vp_modern_avq_cleanup(struct virtio_device *vdev) } } +static void vp_modern_del_vqs (struct virtio_device *vdev) +{ +vp_modern_avq_cleanup (vdev); +vp_del_vqs (vdev); +} +static void vp_transport_features (struct virtio_device *vdev,u64 features) {struct virtio_pci_device *vp_dev =to_vp_device (vdev);
@@ -558,8 +564,6 @@ static void vp_reset(struct virtio_device *vdev)while (vp_modern_get_status (mdev))msleep (1 ); -vp_modern_avq_cleanup (vdev); -/* Flush pending VQ/configuration callbacks. */ vp_synchronize_vectors (vdev); }
@@ -1232,7 +1236,7 @@ static const struct virtio_config_ops virtio_pci_config_nodev_ops = { .set_status = vp_set_status, .reset = vp_reset, .find_vqs = vp_modern_find_vqs, - .del_vqs = vp_del_vqs, + .del_vqs = vp_modern_del_vqs, .synchronize_cbs = vp_synchronize_vectors, .get_extended_features = vp_get_features, .finalize_features = vp_finalize_features,
@@ -1252,7 +1256,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = { .set_status = vp_set_status, .reset = vp_reset, .find_vqs = vp_modern_find_vqs, - .del_vqs = vp_del_vqs, + .del_vqs = vp_modern_del_vqs, .synchronize_cbs = vp_synchronize_vectors, .get_extended_features = vp_get_features, .finalize_features = vp_finalize_features,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/2151 ALSA: control: Fix virtual master creation reference in kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit a347cc458d97ecd8adb5462b91559682a70aced6 ]
The snd_ctl_add_follower() comment refers to snd_ctl_create_virtual_master(), but virtual master controls are created with snd_ctl_make_virtual_master(). Correct the helper name.
--- include/sound/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sound/control.h +1 -1
@@ -241,7 +241,7 @@ int _snd_ctl_add_follower(struct snd_kcontrol *master,* @follower: follower element to add * * Add a virtual follower control to the given master element created via -* snd_ctl_create_virtual_master() beforehand. +* snd_ctl_make_virtual_master() beforehand. * * All followers must be the same type (returning the same information * via info callback). The function doesn't check it, so it's your
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/2151 ACPI: fan: Fix memory leak due to leftover devm_kcalloc() argument
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 2cf65d00347005eccf9a24801783377d7f920021 ]
An ACPI device object's dev field in passed as the first argument to devm_kcalloc() in acpi_fan_get_fps() which is incorrect and leads to a memory leak on driver probe errors and removal because the driver is not bound to that ACPI device.
Address this by replacing that pointer with a pointer to the device the driver is actually bound to.
While at it, drop a redundant error message after a memory allocation failure (that also gets printed relative to the ACPI device).
--- drivers/acpi/fan_core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/acpi/fan_core.c +3 -6
@@ -259,7 +259,7 @@ static int acpi_fan_speed_cmp(const void *a, const void *b)return fps1->speed - fps2->speed; } -static int acpi_fan_get_fps (struct acpi_device *device) +static int acpi_fan_get_fps (struct device *dev,struct acpi_device *device) {struct acpi_fan *fan =acpi_driver_data (device);struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL };
@@ -279,11 +279,8 @@ static int acpi_fan_get_fps(struct acpi_device *device) } fan->fps_count = obj->package.count -1 ;/* minus revision field */ - fan->fps =devm_kcalloc (&device->dev, - fan->fps_count,sizeof (struct acpi_fan_fps ), -GFP_KERNEL ); + fan->fps =devm_kcalloc (dev, fan->fps_count,sizeof (*fan->fps),GFP_KERNEL );if (!fan->fps) { -dev_err (&device->dev,"Not enough memory\n" ); status = -ENOMEM ; goto err; }
@@ -341,7 +338,7 @@ static int acpi_fan_probe(struct platform_device *pdev)if (result)return result; - result =acpi_fan_get_fps (device); + result =acpi_fan_get_fps (&pdev->dev, device);if (result)return result; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/2151 ACPI: video: Fix backlight unregistration ordering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 46577d36611953d1b99e86493289cfc824116ad2 ]
In acpi_video_dev_unregister_backlight(), the sysfs interface of the cooling class device may access the brightness object under the backlight device's ACPI companion, so that object cannot be freed before unregistering the cooling class device.
Adjust the code to take that into account.
--- drivers/acpi/acpi_video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/acpi/acpi_video.c +6 -6
@@ -1841,6 +1841,12 @@ static int acpi_video_bus_register_backlight(struct acpi_video_bus *video)static void acpi_video_dev_unregister_backlight (struct acpi_video_device *device) { +if (device->cooling_dev) { +sysfs_remove_link (&device->dev->dev.kobj,"thermal_cooling" ); +sysfs_remove_link (&device->cooling_dev->device.kobj,"device" ); +thermal_cooling_device_unregister (device->cooling_dev); + device->cooling_dev =NULL ; + }if (device->backlight) {backlight_device_unregister (device->backlight); device->backlight =NULL ;
@@ -1850,12 +1856,6 @@ static void acpi_video_dev_unregister_backlight(struct acpi_video_device *devicekfree (device->brightness); device->brightness =NULL ; } -if (device->cooling_dev) { -sysfs_remove_link (&device->dev->dev.kobj,"thermal_cooling" ); -sysfs_remove_link (&device->cooling_dev->device.kobj,"device" ); -thermal_cooling_device_unregister (device->cooling_dev); - device->cooling_dev =NULL ; - } }static int acpi_video_bus_unregister_backlight (struct acpi_video_bus *video)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/2151 cgroup/dmem: Fix eviction helper reference in dmem_cgroup_try_charge()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit e8f69fe59a104b4a97a3365dbb43c72996c2acde ]
The kernel-doc comment of dmem_cgroup_try_charge() refers to dmem_cgroup_evict_valuable, which does not exist. The name is dmem_cgroup_state_evict_valuable. Say dmem_cgroup_state_evict_valuable.
--- kernel/cgroup/dmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/dmem.c +2 -2
@@ -644,8 +644,8 @@ EXPORT_SYMBOL_GPL(dmem_cgroup_uncharge);* * When this function fails with -EAGAIN and @ret_limit_pool is non-null, it * will be set to the pool for which the limit is hit. This can be used for -* eviction as argument to dmem_cgroup_evict_valuable(). This reference must be freed -* with @dmem_cgroup_pool_state_put(). +* eviction as argument to dmem_cgroup_state_evict_valuable(). This reference +* must be freed with @dmem_cgroup_pool_state_put(). * * Return: 0 on success, -EAGAIN on hitting a limit, or a negative errno on failure. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/2151 clk: sunxi-ng: div: Add feature support to M clock macro
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhui Liu <[email protected]>
[ Upstream commit f43bed1fb1ddf7b350ceb7c371c624795a7820e8 ]
Add a variant of SUNXI_CCU_M_DATA_WITH_MUX_GATE() that accepts CCU feature flags, such as CCU_FEATURE_UPDATE_BIT.
Stable-dep-of: 59dced16a82d ("clk: sunxi-ng: sun55i-a523-ccu: Use M-only clocks for MBUS, IOMMU and DRAM")
--- drivers/clk/sunxi-ng/ccu_div.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/clk/sunxi-ng/ccu_div.h +14 -4
@@ -212,16 +212,17 @@ struct ccu_div {SUNXI_CCU_M_WITH_GATE (_struct, _name, _parent, _reg, \ _mshift, _mwidth, 0, _flags) -#define SUNXI_CCU_M_DATA_WITH_MUX_GATE (_struct, _name, _parents, _reg, \ - _mshift, _mwidth, \ - _muxshift, _muxwidth, \ - _gate, _flags) \ +#define SUNXI_CCU_M_DATA_WITH_MUX_GATE_FEAT (_struct, _name, _parents, _reg, \ + _mshift, _mwidth, \ + _muxshift, _muxwidth, \ + _gate, _flags, _features) \ struct ccu_div _struct = { \ .enable = _gate, \ .div = _SUNXI_CCU_DIV(_mshift, _mwidth), \ .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \ .common = { \ .reg = _reg, \ + .features = _features, \ .hw.init = CLK_HW_INIT_PARENTS_DATA(_name, \ _parents, \ &ccu_div_ops, \
@@ -229,6 +230,15 @@ struct ccu_div { }, \ } +#define SUNXI_CCU_M_DATA_WITH_MUX_GATE (_struct, _name, _parents, _reg, \ + _mshift, _mwidth, \ + _muxshift, _muxwidth, \ + _gate, _flags) \ + SUNXI_CCU_M_DATA_WITH_MUX_GATE_FEAT(_struct, _name, _parents, _reg, \ + _mshift, _mwidth, \ + _muxshift, _muxwidth, \ + _gate, _flags, 0) + #define SUNXI_CCU_M_DATA_WITH_MUX(_struct, _name, _parents, _reg, \ _mshift, _mwidth, \ _muxshift, _muxwidth, \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/2151 clk: sunxi-ng: sun55i-a523-ccu: Use M-only clocks for MBUS, IOMMU and DRAM
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhui Liu <[email protected]>
[ Upstream commit 59dced16a82d1ec685b88365c64dde27a0a0b46a ]
The MBUS, IOMMU, and DRAM clocks only have an M divider, but are currently modeled as MP clocks with a zero-width P divider.
ccu_mp_set_rate() generates an invalid mask for the zero-width P divider, clearing unrelated register fields. It also ignores CCU_FEATURE_UPDATE_BIT, so the new divider value does not take effect.
Model these clocks as M-only clocks instead. This avoids accessing a nonexistent P divider and uses ccu_div_set_rate(), which handles the update bit.
--- drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 45 ++++++++++++-------------- 1 file changed, 21 insertions(+), 24 deletions(-)
drivers/clk/sunxi-ng/ccu-sun55i-a523.c +21 -24
@@ -380,14 +380,13 @@ static const struct clk_parent_data mbus_parents[] = { { .hw = &pll_periph1_150M_clk.hw }, { .fw_name = "hosc" }, }; -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(mbus_clk, "mbus", mbus_parents, -0x540 , -0 ,5 ,/* M */ -0 ,0 ,/* no P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ -CLK_IS_CRITICAL , - CCU_FEATURE_UPDATE_BIT); +static SUNXI_CCU_M_DATA_WITH_MUX_GATE_FEAT(mbus_clk, "mbus", mbus_parents, +0x540 , +0 ,5 ,/* M */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ +CLK_IS_CRITICAL , + CCU_FEATURE_UPDATE_BIT);static const struct clk_hw *mbus_hws[] = { &mbus_clk.common.hw };
@@ -584,14 +583,13 @@ static const struct clk_parent_data iommu_parents[] = { { .fw_name = "hosc" }, }; -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(iommu_clk, "iommu", iommu_parents, -0x7b0 , -0 ,5 ,/* M */ -0 ,0 ,/* no P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ -CLK_SET_RATE_PARENT , - CCU_FEATURE_UPDATE_BIT); +static SUNXI_CCU_M_DATA_WITH_MUX_GATE_FEAT(iommu_clk, "iommu", iommu_parents, +0x7b0 , +0 ,5 ,/* M */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ +CLK_SET_RATE_PARENT , + CCU_FEATURE_UPDATE_BIT); static SUNXI_CCU_GATE_HWS(bus_iommu_clk, "bus-iommu", apb0_hws, 0x7bc, BIT(0), 0);
@@ -603,14 +601,13 @@ static const struct clk_parent_data dram_parents[] = { { .hw = &pll_periph0_400M_clk.hw }, { .hw = &pll_periph0_150M_clk.hw }, }; -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(dram_clk, "dram", dram_parents, -0x800 , -0 ,5 ,/* M */ -0 ,0 ,/* no P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ -CLK_IS_CRITICAL , - CCU_FEATURE_UPDATE_BIT); +static SUNXI_CCU_M_DATA_WITH_MUX_GATE_FEAT(dram_clk, "dram", dram_parents, +0x800 , +0 ,5 ,/* M */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ +CLK_IS_CRITICAL , + CCU_FEATURE_UPDATE_BIT); static SUNXI_CCU_GATE_HWS(mbus_dma_clk, "mbus-dma", mbus_hws, 0x804, BIT(0), 0);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/2151 clk: sunxi-ng: sun55i-a523-ccu: Use P-only clocks for high-speed timers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhui Liu <[email protected]>
[ Upstream commit f2aee33d06d5e1363596ae166459aa4354a8b5ae ]
The high-speed timer clocks only have a P divider, but are currently modeled as MP clocks with a zero-width M divider.
ccu_mp_set_rate() generates an invalid mask for the zero-width M divider, clearing unrelated register fields. Model these clocks as P-only clocks to avoid accessing a nonexistent M divider.
--- drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 83 +++++++++++--------------- 1 file changed, 36 insertions(+), 47 deletions(-)
drivers/clk/sunxi-ng/ccu-sun55i-a523.c +36 -47
@@ -512,58 +512,47 @@ static const struct clk_parent_data hstimer_parents[] = { { .fw_name = "losc" }, { .hw = &pll_periph0_200M_clk.hw }, }; -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(hstimer0_clk, "hstimer0", - hstimer_parents,0x730 , -0 ,0 ,/* M */ -0 ,3 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(hstimer0_clk, "hstimer0", + hstimer_parents,0x730 , +0 ,3 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(hstimer1_clk, "hstimer1", - hstimer_parents, -0x734 , -0 ,0 ,/* M */ -0 ,3 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(hstimer1_clk, "hstimer1", + hstimer_parents,0x734 , +0 ,3 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(hstimer2_clk, "hstimer2", - hstimer_parents, -0x738 , -0 ,0 ,/* M */ -0 ,3 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(hstimer2_clk, "hstimer2", + hstimer_parents,0x738 , +0 ,3 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(hstimer3_clk, "hstimer3", - hstimer_parents, -0x73c , -0 ,0 ,/* M */ -0 ,3 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(hstimer3_clk, "hstimer3", + hstimer_parents,0x73c , +0 ,3 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(hstimer4_clk, "hstimer4", - hstimer_parents, -0x740 , -0 ,0 ,/* M */ -0 ,3 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(hstimer4_clk, "hstimer4", + hstimer_parents,0x740 , +0 ,3 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(hstimer5_clk, "hstimer5", - hstimer_parents, -0x744 , -0 ,0 ,/* M */ -0 ,3 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(hstimer5_clk, "hstimer5", + hstimer_parents,0x744 , +0 ,3 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + 0); static SUNXI_CCU_GATE_HWS(bus_hstimer_clk, "bus-hstimer", ahb_hws, 0x74c, BIT(0), 0);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/2151 clk: sunxi-ng: sun55i-a523-r-ccu: Use P-only clocks for timers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhui Liu <[email protected]>
[ Upstream commit 1002cc9d60942f8f294d8de7f2805f82f4ebdda0 ]
The R timer clocks only have a P divider, but are currently modeled as MP clocks with a zero-width M divider.
ccu_mp_set_rate() generates an invalid mask for the zero-width M divider, clearing unrelated register fields. Model these clocks as P-only clocks to avoid accessing a nonexistent M divider.
--- drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c | 37 +++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-)
drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c +17 -20
@@ -43,27 +43,24 @@ static SUNXI_CCU_M_DATA_WITH_MUX(r_apb1_clk, "r-apb1",24 ,3 ,/* mux */ 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(r_cpu_timer0, "r-timer0", - r_ahb_apb_parents,0x100 , -0 ,0 ,/* no M */ -1 ,3 ,/* P */ -4 ,3 ,/* mux */ -BIT (0 ), +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(r_cpu_timer0, "r-timer0", + r_ahb_apb_parents,0x100 , +1 ,3 ,/* P */ +4 ,3 ,/* mux */ +BIT (0 ), + 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(r_cpu_timer1, "r-timer1", + r_ahb_apb_parents,0x104 , +1 ,3 ,/* P */ +4 ,3 ,/* mux */ +BIT (0 ), + 0); +static SUNXI_CCU_P_DATA_WITH_MUX_GATE(r_cpu_timer2, "r-timer2", + r_ahb_apb_parents,0x108 , +1 ,3 ,/* P */ +4 ,3 ,/* mux */ +BIT (0 ), 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(r_cpu_timer1, "r-timer1", - r_ahb_apb_parents,0x104 , -0 ,0 ,/* no M */ -1 ,3 ,/* P */ -4 ,3 ,/* mux */ -BIT (0 ), - 0); -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(r_cpu_timer2, "r-timer2", - r_ahb_apb_parents,0x108 , -0 ,0 ,/* no M */ -1 ,3 ,/* P */ -4 ,3 ,/* mux */ -BIT (0 ), - 0); static SUNXI_CCU_GATE_HW(bus_r_timer_clk, "bus-r-timer", &r_ahb_clk.common.hw, 0x11c, BIT(0), 0);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/2151 perf header: Fix potential memory corruption in cpu_cache_level__read
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit d964ffba01f5d0935dd6bc850029958a62c74491 ]
strim() may advance the pointer assigned to cache->size which causes later frees to crash.
Fix by performing the strim and then memmove-ing the potentially shifted string back over the original string.
The bug was introduced by the transition from rtrim() to strim(), as rtrim() wouldn't move on the left.
--- tools/perf/util/header.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
tools/perf/util/header.c +15 -3
@@ -1155,7 +1155,11 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 levreturn -1 ; cache->type[len] =0 ; - cache->type =strim (cache->type); + { +char *trimmed =strim (cache->type); + +memmove (cache->type, trimmed,strlen (trimmed) +1 ); + }scnprintf (file,PATH_MAX ,"%s/size" , path);if (sysfs__read_str (file, &cache->size, &len)) {
@@ -1164,7 +1168,11 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev } cache->size[len] =0 ; - cache->size =strim (cache->size); + { +char *trimmed =strim (cache->size); + +memmove (cache->size, trimmed,strlen (trimmed) +1 ); + }scnprintf (file,PATH_MAX ,"%s/shared_cpu_list" , path);if (sysfs__read_str (file, &cache->map, &len)) {
@@ -1174,7 +1182,11 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev } cache->map[len] =0 ; - cache->map =strim (cache->map); + { +char *trimmed =strim (cache->map); + +memmove (cache->map, trimmed,strlen (trimmed) +1 ); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/2151 regulator: qcom-rpmh: Fix the return value in rpmh_regulator_vrm_get_optimum_mode() kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 51d6888b51e0c962250311b2cbfe5666da31dc0e ]
rpmh_regulator_vrm_get_optimum_mode() returns REGULATOR_MODE_NORMAL or REGULATOR_MODE_IDLE and cannot fail, but its kernel-doc says "0 on success, or a negative error number on failure", which was never true. Describe the mode.
--- drivers/regulator/qcom-rpmh-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/qcom-rpmh-regulator.c +1 -1
@@ -319,7 +319,7 @@ static unsigned int rpmh_regulator_vrm_get_mode(struct regulator_dev *rdev)* This function is used in the regulator_ops for VRM type RPMh regulator * devices. * -* Return: 0 on success, or a negative error number on failure +* Return: the regulator mode to use for the load */ static unsigned int rpmh_regulator_vrm_get_optimum_mode (struct regulator_dev *rdev,int input_uV,int output_uV,int load_uA)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/2151 libbpf: fix log level propagation for light skeleton loaders
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahe Tardy <[email protected]>
[ Upstream commit e18e82ba9ed53f60acce5f9995ee357a9f7ab91d ]
bpftool's -d option is documented to enable bpf_trace_printk() messages from the generated syscall loader when used with -L as specified in commit d510296d331a ("bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.")
However commit b59e4ce8bcaa ("bpftool: Switch bpf_object__load_xattr() to bpf_object__load()") changed bpftool to use bpf_object__load() which call the internal bpf_object_load with extra_log_level to 0 instead of bpf_object__load_xattr with the user request log_level.
All the plumbing was still there to generate the bpf_trace_printk() instructions from the generator but was now unreachable because bpf_gen__init() was called with extra_log_level to 0, leaving gen->log_level at 0.
This uses the obj->log_level field introduced in commit e0e3ea888c69 ("libbpf: Allow passing user log setting through bpf_object_open_opts") set from reading verifier_logs in do_skeleton(). This preserves both object-level and explicit load-time logging settings.
--- tools/lib/bpf/libbpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +2 -1
@@ -8699,7 +8699,8 @@ static int bpf_object_load(struct bpf_object *obj, int extra_log_level, const ch* permit cross-endian creation of "light skeleton". */ if (obj->gen_loader) { -bpf_gen__init (obj->gen_loader, extra_log_level, obj->nr_programs, obj->nr_maps); +bpf_gen__init (obj->gen_loader, obj->log_level | extra_log_level, + obj->nr_programs, obj->nr_maps); }else if (!is_native_endianness (obj)) {pr_warn ("object '%s': loading non-native endianness is unsupported\n" , obj->name);return libbpf_err (-LIBBPF_ERRNO__ENDIAN );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/2151 fs/ntfs3: take run_lock when freeing offs_folio in ni_decompress_file
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit ad39d8d90fa0fd99b2714d4c84c6f4e1c399f1f4 ]
attr_wof_frame_info() allocates, caches and dereferences ni->file.offs_folio under down_write(&ni->file.run_lock). ni_decompress_file() frees the same folio with folio_put() without taking run_lock. When a WOF externally-compressed file is opened for write, ni_decompress_file() can drop the last reference while a concurrent O_RDONLY reader is dereferencing the folio in attr_wof_frame_info(), leading to a use-after-free:
BUG: KASAN: use-after-free in attr_wof_frame_info (fs/ntfs3/attrib.c:1619) Read of size 4 at addr ffff8880120c9000 by task exploit Call Trace: attr_wof_frame_info (fs/ntfs3/attrib.c:1619) ni_read_frame (fs/ntfs3/frecord.c:2421) ni_read_folio_cmpr (fs/ntfs3/frecord.c:1916) ntfs_read_folio (fs/ntfs3/inode.c:648) read_pages (mm/readahead.c:181) page_cache_ra_unbounded (mm/readahead.c:292) force_page_cache_ra (mm/readahead.c:364) page_cache_sync_ra (mm/readahead.c:573) filemap_get_pages (mm/filemap.c:2688) filemap_read (mm/filemap.c:2806) generic_file_read_iter (mm/filemap.c:2994) ntfs_file_read_iter (fs/ntfs3/file.c:842) vfs_read (fs/read_write.c:574) __x64_sys_pread64 (fs/read_write.c:773)
Take run_lock around the folio_put(), as is done for every other access to ni->file.offs_folio.
--- fs/ntfs3/frecord.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/frecord.c +3 -0
@@ -2338,10 +2338,13 @@ int ni_decompress_file(struct ntfs_inode *ni)/* Clear cached flag. */ ni->ni_flags &= ~NI_FLAG_COMPRESSED_MASK ; +/* offs_folio is accessed under run_lock in attr_wof_frame_info(). */ +down_write (&ni->file.run_lock);if (ni->file.offs_folio) {folio_put (ni->file.offs_folio); ni->file.offs_folio =NULL ; } +up_write (&ni->file.run_lock); mapping->a_ops = &ntfs_aops; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/2151 fs/ntfs3: update ctime only on successful setxattr
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baolin Liu <[email protected]>
[ Upstream commit bfa6296bb6a0e2333796a9507beb4605b92a9fdf ]
ntfs_setxattr() updates ctime and marks the inode dirty even when the xattr operation fails.
Do that only on success.
--- fs/ntfs3/xattr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ntfs3/xattr.c +4 -2
@@ -974,8 +974,10 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler, NULL); out: -inode_set_ctime_current (inode); -mark_inode_dirty (inode); +if (!err) { +inode_set_ctime_current (inode); +mark_inode_dirty (inode); + }return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/2151 ntfs: Do not kmap page cache pages for compression
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 953b79a7a124c3dae86544cea581a5bc7655aa13 ]
These pages are accessed through vmap; they are not accessed by calling page_address(), so they do not need to be kmapped.
Stable-dep-of: a32e893a077a ("fs/ntfs3: zero frame pages on read error")
--- fs/ntfs3/frecord.c | 11 ----------- 1 file changed, 11 deletions(-)
fs/ntfs3/frecord.c +0 -11
@@ -2447,9 +2447,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,* To simplify decompress algorithm do vmap for source * and target pages. */ -for (i =0 ; i < pages_per_frame; i++) -kmap (pages[i]); - frame_size = pages_per_frame <<PAGE_SHIFT ; frame_mem =vmap (pages, pages_per_frame,VM_MAP ,PAGE_KERNEL );if (!frame_mem) {
@@ -2706,7 +2703,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, out:for (i =0 ; i < pages_per_frame; i++) { pg = pages[i]; -kunmap (pg);SetPageUptodate (pg); }
@@ -2794,9 +2790,6 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages, goto out1; } -for (i =0 ; i < pages_per_frame; i++) -kmap (pages[i]); -/* Map in-memory frame for read-only. */ frame_mem =vmap (pages, pages_per_frame,VM_MAP ,PAGE_KERNEL_RO );if (!frame_mem) {
@@ -2862,11 +2855,7 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages, out3:vunmap (frame_mem); - out2: -for (i =0 ; i < pages_per_frame; i++) -kunmap (pages[i]); -vunmap (frame_ondisk); out1:for (i =0 ; i < pages_per_frame; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/2151 fs/ntfs3: zero frame pages on read error
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit a32e893a077a4b0d3b04c86cb7f69e354a187995 ]
ni_read_frame() marks every frame page uptodate at the 'out:' label regardless of the return value. The pages come from ntfs_lock_new_page() and are not zeroed, and several error paths reach 'out:' before anything is written to them (e.g. a failed decompress_lznt()/decompress_lzx_xpress() on a corrupted chunk, or an allocation failure).
A page marked uptodate is served directly from the page cache, so a later read() of the file returns the uninitialized page contents to userspace. On a crafted compressed image this leaks kernel memory, including pointers.
Zero each page on the error path before marking it uptodate. The success path is unchanged.
--- fs/ntfs3/frecord.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ntfs3/frecord.c +2 -0
@@ -2703,6 +2703,8 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, out:for (i =0 ; i < pages_per_frame; i++) { pg = pages[i]; +if (err) +clear_highpage (pg);SetPageUptodate (pg); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/2151 pinctrl: amd: add timeout to irq-enable readback
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 44c232e80adc26634e40b3dbeaa20711da9ecf0d ]
amd_gpio_irq_set_type() polls INTERRUPT_ENABLE with IRQs off and no timeout. Use readl_poll_timeout_atomic() and return -ETIMEDOUT.
--- drivers/pinctrl/pinctrl-amd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-amd.c +5 -3
@@ -18,6 +18,7 @@#include <linux/errno.h> #include <linux/log2.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/gpio/driver.h> #include <linux/slab.h> #include <linux/platform_device.h>
@@ -496,7 +497,7 @@ static void amd_gpio_irq_eoi(struct irq_data *d)static int amd_gpio_irq_set_type (struct irq_data *d,unsigned int type) {int ret =0 ; -u32 pin_reg, pin_reg_irq_en, mask; +u32 pin_reg, pin_reg_irq_en, mask, reg;unsigned long flags;struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc);
@@ -570,8 +571,9 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg_irq_en |= mask; pin_reg_irq_en &= ~BIT (INTERRUPT_MASK_OFF );writel (pin_reg_irq_en, gpio_dev->base + hwirq *4 ); -while ((readl (gpio_dev->base + hwirq *4 ) & mask) != mask) -continue ; +if (readl_poll_timeout_atomic (gpio_dev->base + hwirq *4 , reg, + (reg & mask) == mask,1 ,1000 )) + ret = -ETIMEDOUT ;writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/2151 microblaze: uaccess: Zero out destination on failed get_user()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 54c35131e628e1a18f02365495a24a73a1fb515e ]
On failure get_user() is supposed to zero out the destination variable. This is documented in the kdoc of the microblaze get_user() implementation and validated in lib/tests/usercopy_kunit.c.
Currently that zeroing is missing.
Add it.
--- arch/microblaze/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/microblaze/include/asm/uaccess.h +2 -1
@@ -95,7 +95,8 @@ extern long __user_bad(void);#define get_user (x, ptr) ({ \ const typeof(*(ptr)) __user *__gu_ptr = (ptr); \ access_ok(__gu_ptr, sizeof(*__gu_ptr)) ? \ - __get_user(x, __gu_ptr) : -EFAULT; \ + __get_user(x, __gu_ptr) : \ + ((x) = 0, -EFAULT); \ })#define __get_user (x, ptr) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/2151 microblaze: Pass -m{big,little}-endian through KBUILD_CPPFLAGS
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit b9eababe8c0b9f71ce7f35f903879a7fcb6daebe ]
These parameters are also necessary for preprocessed files which do not contain code. One example is arch/microblaze/kernel/vmlinux.lds.S which inspects __MICROBLAZEEL__ for the definition of 'jiffies_64'. As currently the endianness is not passed from the build system for this file, the preprocessor will instead use the default endianness of the toolchain. When a default big-endian toolchain is used to build a little-endian kernel, that kernel will hang during delay calibration as 'jiffies' never changes.
Make sure all preprocessor invocations know about the correct endianness by passing it through KBUILD_CPPFLAGS. This will also be inherited by CFLAGS and AFLAGS.
--- arch/microblaze/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/microblaze/Makefile +2 -4
@@ -34,12 +34,10 @@ CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare ifdef CONFIG_CPU_BIG_ENDIAN -KBUILD_CFLAGS += -mbig-endian -KBUILD_AFLAGS += -mbig-endian +KBUILD_CPPFLAGS += -mbig-endian KBUILD_LDFLAGS += -EB else -KBUILD_CFLAGS += -mlittle-endian -KBUILD_AFLAGS += -mlittle-endian +KBUILD_CPPFLAGS += -mlittle-endian KBUILD_LDFLAGS += -EL endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/2151 arm64: pi: Run the source checker on the libfdt objects under C=2
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 44b14ff4aebeae98663d0fd424b4ef88237ee981 ]
The custom lib-%.o rule reuses rule_cc_o_c, which hooks the source checker only for C=1, and that only when the object is rebuilt. The C=2 hook, cmd_force_checksrc, hangs off the standard %.o rule, so "make C=2" silently skips the two libfdt objects. Call cmd_force_checksrc after the compile rule, as the standard rule does.
--- arch/arm64/kernel/pi/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/pi/Makefile +1 -0
@@ -34,6 +34,7 @@ $(obj)/lib-%.pi.o: OBJCOPYFLAGS += --prefix-alloc-sections=.init $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE $(call if_changed_rule,cc_o_c) + $(call cmd,force_checksrc) obj-y := idreg-override.pi.o \ map_kernel.pi.o map_range.pi.o \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/2151 wifi: mac80211: Fix the return value in mesh_path_add() kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 5c7b043cb1ef4bca9aa2e793dab862c0989d59c3 ]
mesh_path_add() has returned the new (or the already existing) struct mesh_path, or an ERR_PTR(), since commit ae76eef027f7 ("mac80211: return new mpath from mesh_path_add()"), but its kernel-doc still says "Returns: 0 on success". Describe the pointer.
--- net/mac80211/mesh_pathtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +1 -1
@@ -679,7 +679,7 @@ void mesh_fast_tx_flush_addr(struct ieee80211_sub_if_data *sdata,* @sdata: local subif * @dst: destination address of the path (ETH_ALEN length) * -* Returns: 0 on success +* Returns: the new or the existing path on success, an ERR_PTR() on failure * * State: the initial state of the new path is set to 0 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/2151 wifi: mac80211: dont reset the TXQ scheduling round number
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Bairaktaris <[email protected]>
[ Upstream commit 8ea81827d3537db7cfcc82c008f052bb1bbe7567 ]
A round is ended when ieee80211_next_txq() meets a txq whose remembered round number is the current one, meaning it has gone full circle.
When the AC exceeds the airtime limit, ieee80211_txq_schedule_start() sets the round number to 0 to close the round. The next open round is
1. A txq from an earlier round 1 still remembers the "1", so the next round stops on it and serves nothing.
Fix: use a separate open/closed flag and let the round number keep counting.
Testing: ~4200 skipped selections per 20s without the fix and 20 skipped selections per 20s with the fix on ath11k (with my AQL series applied) at BE 500/1000.
--- net/mac80211/ieee80211_i.h | 1 + net/mac80211/tx.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
@@ -1419,6 +1419,7 @@ struct ieee80211_local {spinlock_t active_txq_lock[IEEE80211_NUM_ACS ];struct list_head active_txqs[IEEE80211_NUM_ACS ];u16 schedule_round[IEEE80211_NUM_ACS ]; +bool schedule_open[IEEE80211_NUM_ACS ];/* serializes ieee80211_handle_wake_tx_queue */ spinlock_t handle_wake_tx_queue_lock;
net/mac80211/tx.c +4 -4
@@ -4169,7 +4169,7 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)spin_lock_bh (&local->active_txq_lock[ac]); -if (!local->schedule_round[ac]) +if (!local->schedule_open[ac]) goto out; begin:
@@ -4394,12 +4394,12 @@ void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac)spin_lock_bh (&local->active_txq_lock[ac]); -if (ieee80211_txq_schedule_airtime_check (local, ac)) { + local->schedule_open[ac] = +ieee80211_txq_schedule_airtime_check (local, ac); +if (local->schedule_open[ac]) { local->schedule_round[ac]++;if (!local->schedule_round[ac]) local->schedule_round[ac]++; - }else { - local->schedule_round[ac] =0 ; }spin_unlock_bh (&local->active_txq_lock[ac]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/2151 mtd: spi-nor: spansion: Remove s25fs256s0
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takahiro Kuwano <[email protected]>
[ Upstream commit f917d9edf54c3dd578efc231b8fbcd35744f99cd ]
The Spansion ID table lists s25fs256s0 and s25fs256s1 as variants distinguished by id[4] (0x00 for 256 KB sectors and 0x01 for 64 KB sectors), following an incorrect statement in the datasheet.
The sector size of s25fs256s is configurable between 256 KB and 64 KB. The factory default is 64 KB, and id[4] is always 0x01 regardless of the configured sector size. Remove the invalid s25fs256s0 entry from the ID table.
--- drivers/mtd/spi-nor/spansion.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/mtd/spi-nor/spansion.c +0 -7
@@ -829,13 +829,6 @@ static const struct flash_info spansion_nor_parts[] = { .sector_size = SZ_256K, .no_sfdp_flags = SPI_NOR_SKIP_SFDP | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, .mfr_flags = USE_CLSR, - }, { - .id = SNOR_ID(0x01, 0x02, 0x19, 0x4d, 0x00, 0x81), - .name = "s25fs256s0", - .size = SZ_32M, - .sector_size = SZ_256K, - .no_sfdp_flags = SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, - .mfr_flags = USE_CLSR, }, { .id = SNOR_ID(0x01, 0x02, 0x19, 0x4d, 0x01, 0x80), .name = "s25fl256s1",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/2151 wifi: wfx: fix use-after-free of the cooling work on device removal
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérôme Pouiller <[email protected]>
[ Upstream commit 17402a869778f6c17b88fd360d7a96378779f97c ]
When the device reports that it is too hot, wfx_suspend_hot_dev() blocks the Tx queues and arms cooling_timeout_work with a 10s delay. If the device recovers a normal temperature before the delay expires, the work is canceled. Else, the work declares the chip frozen and unblocks the Tx queues.
However, this work is never canceled when the device is removed. cooling_timeout_work is queued on the system workqueue, while struct wfx_dev is released by wfx_free_common() (through ieee80211_free_hw()). So, if the device is unbound during this 10s window, the work fires after struct wfx_dev has been freed and dereferences it.
Cancel the work during the teardown. It has to be done after wfx_bh_unregister(): the "device too hot" indication is processed by the bh, so canceling the work earlier would allow the bh to rearm it. On the other hand, the work calls wfx_tx_unlock(), which may in turn call wfx_bh_request_tx(). So it has to be canceled before bh_wq is destroyed.
Note that the Tx queues are intentionally left blocked: the device is going away, so there is nothing to unblock.
The issue was reported by the Sashiko review bot and the fix has been written by Copilot (including the commit log). The use-case is difficult to reproduce, so this code has not been tested. However, I don't believe this patch could cause any regression.
--- drivers/net/wireless/silabs/wfx/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/silabs/wfx/main.c +2 -0
@@ -487,6 +487,7 @@ int wfx_probe(struct wfx_dev *wdev) wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv); bh_unregister:wfx_bh_unregister (wdev); +cancel_delayed_work_sync (&wdev->cooling_timeout_work);destroy_workqueue (wdev->bh_wq);return err; }
@@ -497,6 +498,7 @@ void wfx_release(struct wfx_dev *wdev)wfx_hif_shutdown (wdev); wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv);wfx_bh_unregister (wdev); +cancel_delayed_work_sync (&wdev->cooling_timeout_work);destroy_workqueue (wdev->bh_wq); }
Signature · 1 line
2.53.0
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.18.y
Best regards,
Pavel
Greg Kroah-Hartman
maintainerPATCH 444/2151 f2fs: quota: fix stale lock holder on remount failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianan Huang <[email protected]>
[ Upstream commit 3f140a60c92a5e2e9885adac70cd3686ba4ee19a ]
F2FS remount can fail while duplicating a journalled quota file name.
f2fs_remount()
- sbi->umount_lock_holder = current
- kstrdup(F2FS_OPTION(sbi).s_qf_names[i])
: fails
- free previously duplicated names
- return -ENOMEM
The direct return leaves umount_lock_holder pointing at the failed remount context. A later checkpoint may then wrongly treat another context as the s_umount lock holder.
Add a restore_holder cleanup path and use it before returning -ENOMEM.
--- fs/f2fs/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/super.c +3 -1
@@ -2733,7 +2733,8 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)if (!org_mount_opt.s_qf_names[i]) {for (j =0 ; j < i; j++)kfree (org_mount_opt.s_qf_names[j]); -return -ENOMEM ; + err = -ENOMEM ; + goto restore_holder; } }else { org_mount_opt.s_qf_names[i] =NULL ;
@@ -2991,6 +2992,7 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb) sbi->mount_opt = org_mount_opt; sb->s_flags = old_sb_flags; +restore_holder: sbi->umount_lock_holder =NULL ;return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/2151 firmware: imx: dsp: fix mailbox channel leak on kasprintf failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit e3631d0242842940f9e902afaea98202e56277e8 ]
If kasprintf() fails while setting up mailbox channels, already requested channels from earlier iterations were never freed. Route the failure through the existing cleanup path.
--- drivers/firmware/imx/imx-dsp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/firmware/imx/imx-dsp.c +4 -2
@@ -99,8 +99,10 @@ static int imx_dsp_setup_channels(struct imx_dsp_ipc *dsp_ipc)else chan_name =kasprintf (GFP_KERNEL ,"rxdb%d" , i -2 ); -if (!chan_name) -return -ENOMEM ; +if (!chan_name) { + ret = -ENOMEM ; + goto out; + } dsp_chan = &dsp_ipc->chans[i]; dsp_chan->name = chan_name;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/2151 memblock: reject non-page-aligned reserve_mem regions
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Heon Jeon <[email protected]>
[ Upstream commit 5728d3523f12826a2b180c1c5738f74e33197e14 ]
When map->start or map->size is not page aligned, reserved_mem_preserve() does not preserve the last one or two pages of the region from map->start to map->start + map->size.
After kexec the new kernel reserves only the preserved pages, so those pages are released to the buddy allocator. But reserve_mem_find_by_name() still returns the whole region including them, so they can be allocated while the subsystem is still using them.
So reject a reserve_mem= size or alignment that is not a multiple of PAGE_SIZE to keep both map->start and map->size page aligned.
--- Documentation/admin-guide/kernel-parameters.txt | 3 +++ mm/memblock.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -6473,6 +6473,9 @@ Kernel parameters reserve_mem=12M:4096:oops ramoops.mem_name=oops + Both the size and the alignment must be multiples of + the page size. + reservetop= [X86-32,EARLY] Format: nn[KMG] Reserves a hole at the top of the kernel virtual
mm/memblock.c +7 -2
@@ -2655,12 +2655,17 @@ static int __init reserve_mem(char *p)if (*p !=':' )return -EINVAL ; +if (!IS_ALIGNED (size,PAGE_SIZE ) || !IS_ALIGNED (align,PAGE_SIZE )) { +pr_err ("reserve_mem: size and align must be multiples of the page size\n" ); +return -EINVAL ; + } +/* * memblock_phys_alloc() doesn't like a zero size align, * but it is OK for this command to have it. */ -if (align <SMP_CACHE_BYTES ) - align =SMP_CACHE_BYTES ; +if (!align) + align =PAGE_SIZE ; name = p +1 ; len =strlen (name);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/2151 phy: hisilicon: hi3670: Fix OF node and device reference leaks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 1499f3d3407f5310731bcdf324387c321258fd75 ]
hi3670_pcie_get_resources_from_pcie() leaks two references:
1) The OF node returned by of_get_child_by_name() is never released.
2) The device returned by bus_find_device_by_of_node() is never put.
Fix both leaks by calling of_node_put() right after bus_find_device_by_of_node(), and put_device() after dev_get_regmap() when the temporary pcie_dev reference is no longer needed.
--- drivers/phy/hisilicon/phy-hi3670-pcie.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/hisilicon/phy-hi3670-pcie.c +2 -0
@@ -570,6 +570,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy) } pcie_dev =bus_find_device_by_of_node (&platform_bus_type, pcie_port); +of_node_put (pcie_port);if (!pcie_dev) {dev_err (dev,"Didn't find pcie device\n" );return -ENODEV ;
@@ -584,6 +585,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy)* right regmap. So, let's use the named version. */ phy->apb =dev_get_regmap (pcie_dev,"kirin_pcie_apb" ); +put_device (pcie_dev);if (!phy->apb) {dev_err (dev,"Failed to get APB regmap\n" );return -ENODEV ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/2151 phy: cadence: Sierra: Do not modify register when getting parent clock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory CLEMENT <[email protected]>
[ Upstream commit 955e68eb3067842067b7b5395a3f8c278428802a ]
The get_parent() callback for the PLL_CMNLC1 clock was incorrectly writing to the register while determining the parent clock index. This unintended register access forces the PHY back into training mode. If the PHY is already configured, this unexpected change prevents it from exiting training mode.
Remove the register write operation to ensure the PHY remains stable during the get_parent() callback.
--- drivers/phy/cadence/phy-cadence-sierra.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/phy/cadence/phy-cadence-sierra.c +2 -9
@@ -698,23 +698,16 @@ static const struct phy_ops noop_ops = {static u8 cdns_sierra_pll_mux_get_parent (struct clk_hw *hw) {struct cdns_sierra_pll_mux *mux =to_cdns_sierra_pll_mux (hw); -struct regmap_field *plllc1en_field = mux->plllc1en_field; -struct regmap_field *termen_field = mux->termen_field;struct regmap_field *field = mux->pfdclk_sel_preg;unsigned int val;int index;regmap_field_read (field, &val); -if (strstr (clk_hw_get_name (hw), clk_names[CDNS_SIERRA_PLL_CMNLC1 ])) { +if (strstr (clk_hw_get_name (hw), clk_names[CDNS_SIERRA_PLL_CMNLC1 ])) index =clk_mux_val_to_index (hw, cdns_sierra_pll_mux_table[CMN_PLLLC1 ],0 , val); -if (index ==1 ) { -regmap_field_write (plllc1en_field,1 ); -regmap_field_write (termen_field,1 ); - } - }else { +else index =clk_mux_val_to_index (hw, cdns_sierra_pll_mux_table[CMN_PLLLC ],0 , val); - }return index; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/2151 memory: emif: fix device_node reference leak on np_ddr
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miles Krause <[email protected]>
[ Upstream commit 314ef67d673284d4c070455bd62d332f6d0f8634 ]
of_get_memory_device_details() takes a reference on the DDR device node via of_parse_phandle() and stores it in emif->np_ddr for later use, but drops that reference without calling of_node_put() on two error paths: the devm_kzalloc() allocation-failure check and the is_dev_data_valid() check. Both return NULL immediately, leaking the node reference each time either failure triggers.
The same reference is also never released on the success path: it is kept for the life of the bound device (compared against a later instance's np_ddr in the duplicate-DDR-geometry check) but emif_remove() never calls of_node_put() on it, leaking it every time an EMIF device unbinds. of_node_put() on a NULL pointer is a no-op, so this is also safe for the non-DT get_device_details() path, where np_ddr is left NULL by devm_kzalloc().
--- drivers/memory/emif.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/memory/emif.c +3 -0
@@ -922,6 +922,7 @@ static struct emif_data *of_get_memory_device_details(if (!emif || !pd || !dev_info) {dev_err (dev,"%s: Out of memory!!\n" , __func__); +of_node_put (np_ddr); goto error; }
@@ -946,6 +947,7 @@ static struct emif_data *of_get_memory_device_details( pd->device_info->io_width, pd->phy_type, pd->ip_rev, emif->dev)) {dev_err (dev,"%s: invalid device data!!\n" , __func__); +of_node_put (np_ddr); goto error; }/*
@@ -1140,6 +1142,7 @@ static void emif_remove(struct platform_device *pdev)struct emif_data *emif =platform_get_drvdata (pdev);emif_debugfs_exit (emif); +of_node_put (emif->np_ddr); }static void emif_shutdown (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/2151 RDMA/rxe: Use validated num_sge in local buffer
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Morey <[email protected]>
[ Upstream commit a4368022a3ac5324356ae8d88e3a42d115956fd6 ]
For both SRQ and non-SRQ receive paths, the WQE is copied into a local buffer to provide a kernel-owned, validated copy. While calculating the memcpy size from the validated num_sge prevents overflow during the copy, memcpy() itself still copies num_sge from shared memory.
A concurrent userspace modification before or during memcpy() leaves an unvalidated num_sge in the local buffer, leading to potential out-of-bounds reads in rxe_resp_check_length() and copy_data() causing:
BUG: KASAN: slab-out-of-bounds in rxe_receiver+0x8109/0x9ec0 [rdma_rxe] Read of size 4 at addr ffff88812c4867f8 by task kworker/u9:6/361 Workqueue: rxe_wq do_work [rdma_rxe] Call Trace: rxe_receiver+0x8109/0x9ec0 [rdma_rxe] do_work+0x149/0x610 [rdma_rxe] process_one_work+0x726/0x10a0 The buggy address belongs to the object at ffff88812c486000 which belongs to the cache kmalloc-part-13-2k of size 2048 The buggy address is located 0 bytes to the right of allocated 2040-byte region [ffff88812c486000, ffff88812c4867f8)
Explicitly assign the validated num_sge to the local buffer after the copy to prevent this race.
--- drivers/infiniband/sw/rxe/rxe_resp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/sw/rxe/rxe_resp.c +2 -0
@@ -287,6 +287,7 @@ static enum resp_states get_srq_wqe(struct rxe_qp *qp) } size =sizeof (*wqe) + num_sge *sizeof (struct rxe_sge );memcpy (&qp->resp.srq_wqe, wqe, size); + qp->resp.srq_wqe.wqe.dma.num_sge = num_sge; qp->resp.wqe = &qp->resp.srq_wqe.wqe;queue_advance_consumer (q,QUEUE_TYPE_FROM_CLIENT );
@@ -327,6 +328,7 @@ static enum resp_states rxe_get_recv_wqe(struct rxe_qp *qp) } size =sizeof (*wqe) + num_sge *sizeof (struct rxe_sge );memcpy (&qp->resp.srq_wqe, wqe, size); + qp->resp.srq_wqe.wqe.dma.num_sge = num_sge; qp->resp.wqe = &qp->resp.srq_wqe.wqe;return RESPST_CHK_LENGTH ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 451/2151 RDMA/uverbs: Make CQ handle mandatory for WQ creation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit f7d28791433d373ecdab7b00f60ddb504e858e0a ]
UVERBS_ATTR_CREATE_WQ_CQ_HANDLE is declared UA_OPTIONAL in the ioctl method definition, so the mandatory attribute bitmap does not enforce its presence. When userspace omits it, uverbs_attr_get_obj() returns ERR_PTR(-ENOENT) and the handler stores that error pointer into wq_init_attr.cq without validation.
The bogus cq pointer is then passed to the driver's create_wq callback. In the mlx5 case, create_rq() calls to_mcq(init_attr->cq) which applies container_of to the ERR_PTR value, producing a near-NULL pointer. The subsequent access in get_rq_ts_format() triggers a kernel NULL pointer dereference:
BUG: kernel NULL pointer dereference, address: 0000000000000296 RIP: 0010:create_rq+0x32/0x550 [mlx5_ib] Call Trace: mlx5_ib_create_wq+0x14a/0x210 [mlx5_ib] ib_uverbs_handler_UVERBS_METHOD_WQ_CREATE+0x1f0/0x320 [ib_uverbs] ib_uverbs_run_method+0x296/0x320 [ib_uverbs] ib_uverbs_cmd_verbs+0x1a0/0x260 [ib_uverbs] ib_uverbs_ioctl+0xa8/0x120 [ib_uverbs]
A WQ without a CQ was never valid; the legacy write path always required one via uobj_get_obj_read() in ib_uverbs_ex_create_wq(). Declare the attribute UA_MANDATORY so the uverbs framework rejects the ioctl early when the CQ handle is missing, before the handler ever runs.
--- drivers/infiniband/core/uverbs_std_types_wq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_std_types_wq.c +1 -1
@@ -140,7 +140,7 @@ DECLARE_UVERBS_NAMED_METHOD(UVERBS_ATTR_IDR (UVERBS_ATTR_CREATE_WQ_CQ_HANDLE ,UVERBS_OBJECT_CQ ,UVERBS_ACCESS_READ , -UA_OPTIONAL ), +UA_MANDATORY ), UVERBS_ATTR_FD(UVERBS_ATTR_CREATE_WQ_EVENT_FD, UVERBS_OBJECT_ASYNC_EVENT, UVERBS_ACCESS_READ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/2151 media: i2c: ar0521: remove duplicate media entity cleanup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 069a0343581bfcaee44bc598e2b95be2e2789807 ]
The error path taken when ar0521_power_on() fails calls media_entity_cleanup() at the disable label and then falls through to the entity_cleanup label, where media_entity_cleanup() is called again.
There is no need to clean up the media entity twice. Remove the first call and let all error paths converge on the common entity_cleanup label.
This issue was found by manual code inspection.
--- drivers/media/i2c/ar0521.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/i2c/ar0521.c +0 -1
@@ -1139,7 +1139,6 @@ static int ar0521_probe(struct i2c_client *client) disable:v4l2_async_unregister_subdev (&sensor->sd); -media_entity_cleanup (&sensor->sd.entity); free_ctrls:v4l2_ctrl_handler_free (&sensor->ctrls.handler); entity_cleanup:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/2151 block: Fix the thaw_bdev reference in bdev_freeze() kernel-doc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit e14c3379be86854c203de1e0fdfdeaa0b45509df ]
The kernel-doc comment of bdev_freeze() refers to thaw_bdev, which was renamed to bdev_thaw by commit 982c3b305843 ("bdev: rename freeze and thaw helpers"). Say bdev_thaw.
--- block/bdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/bdev.c +1 -1
@@ -277,7 +277,7 @@ EXPORT_SYMBOL(sync_blockdev_range);* The reference counter (bd_fsfreeze_count) guarantees that only the last * unfreeze process can unfreeze the frozen filesystem actually when multiple * freeze requests arrive simultaneously. It counts up in bdev_freeze() and -* count down in bdev_thaw(). When it becomes 0, thaw_bdev() will unfreeze +* count down in bdev_thaw(). When it becomes 0, bdev_thaw() will unfreeze * actually. * * Return: On success zero is returned, negative error code on failure.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/2151 remoteproc: core: Set trace buffer name for diagnostics
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghao Zhang <[email protected]>
[ Upstream commit e23eab619b0d2dd796618406ba25da62f4d539a2 ]
rproc_trace_read() (in remoteproc_debugfs.c) prints the name of a trace buffer whose device address could not be resolved, but nothing ever assigns trace_mem.name, so that the diagnostics always prints an empty string:
Trace not available
Copy the generated "trace%d" name into the memory entry, so the diagnostics identifies the buffer failed to translate.
--- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/remoteproc_core.c +3 -0
@@ -579,6 +579,9 @@ static int rproc_handle_trace(struct rproc *rproc, void *ptr,/* create the debugfs entry */ trace->tfile =rproc_create_trace_file (name, rproc, trace); +/* keep the name for the diagnostic in rproc_trace_read() */ +strscpy (trace->trace_mem.name, name,sizeof (trace->trace_mem.name)); +list_add_tail (&trace->node, &rproc->traces); rproc->num_traces++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 455/2151 dmaengine: mv_xor: kill tasklet on channel add error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit bcb4d469b19d53dc21e4a1da12d4438e7489e150 ]
If request_irq() succeeds but a later step (self-test or device registration) fails, the error path at err_free_irq frees the IRQ but does not kill the tasklet. A previously scheduled tasklet can still run after the channel is freed, accessing freed memory.
Add tasklet_kill() after free_irq() on the error path.
--- drivers/dma/mv_xor.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/mv_xor.c +1 -0
@@ -1162,6 +1162,7 @@ mv_xor_channel_add(struct mv_xor_device *xordev, err_free_irq:free_irq (mv_chan->irq, mv_chan); +tasklet_kill (&mv_chan->irq_tasklet); err_free_dma:dma_free_wc (&pdev->dev,MV_XOR_POOL_SIZE , mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 456/2151 loadpin: Fix stale KEXEC_VERIFY_SIG reference in documentation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit eb0b0d222a832b6ec851e56d4922a775ac762955 ]
Commit 99d5cadfde2b ("kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE") removed CONFIG_KEXEC_VERIFY_SIG but left the LoadPin documentation pointing at it. Refer to CONFIG_KEXEC_SIG instead.
While at it, clean up the grammar of the sentence.
Message-ID: <[email protected]>
--- Documentation/admin-guide/LSM/LoadPin.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/admin-guide/LSM/LoadPin.rst +5 -5
@@ -23,9 +23,9 @@ sysctl allows for easy testing on systems with a mutable filesystem.) It's also possible to exclude specific file types from LoadPin using kernel command line option "``loadpin.exclude``". By default, all files are included, but they can be excluded using kernel command line option such -as "``loadpin.exclude=kernel-module,kexec-image``". This allows to use +as "``loadpin.exclude=kernel-module,kexec-image``". This allows using different mechanisms such as ``CONFIG_MODULE_SIG`` and -``CONFIG_KEXEC_VERIFY_SIG`` to verify kernel module and kernel image while -still use LoadPin to protect the integrity of other files kernel loads. The -full list of valid file types can be found in ``kernel_read_file_str`` -defined in ``include/linux/kernel_read_file.h``. +``CONFIG_KEXEC_SIG`` to verify kernel modules and kernel images while +still using LoadPin to protect the integrity of other files the kernel +loads. The full list of valid file types can be found in +``kernel_read_file_str`` defined in ``include/linux/kernel_read_file.h``.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 457/2151 platform/x86/intel/vsec: reset state before re-enumerating
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit ee26050614d02397eb743854d718689dcaf1889b ]
The change referenced by the Fixes tag split the VSEC enumeration logic out of intel_vsec_pci_probe() and made PCIe error recovery call intel_vsec_pci_init() directly. This avoids another pcim_enable_device() devm action and another devm allocation during slot reset, but it also means that error recovery reuses the priv structure allocated by probe.
On the initial probe, priv is zeroed by devm_kzalloc(), so state[], suppliers[] and found_caps start from their initial values. During slot reset, the existing aux devices are removed before re-enumerating, but the reused priv still records the old devices as registered and the old capabilities as found.
The next intel_vsec_pci_init() call can therefore short-circuit in intel_vsec_register_device() with -EEXIST, or stop early because found_caps already matches info->caps. The aux devices removed during slot reset are then not recreated, leaving VSEC functionality missing after PCIe error recovery.
Reset the VSEC registration state after removing the old aux devices and before re-enumerating them.
--- drivers/platform/x86/intel/vsec.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/platform/x86/intel/vsec.c +15 -0
@@ -49,6 +49,13 @@ struct vsec_priv {unsigned long found_caps; }; +static void intel_vsec_reset_state (struct vsec_priv *priv) +{ +memset (priv->suppliers,0 ,sizeof (priv->suppliers)); +memset (priv->state,0 ,sizeof (priv->state)); + priv->found_caps =0 ; +} +static const char *intel_vsec_name (enum intel_vsec_id id) {switch (id) {
@@ -829,6 +836,7 @@ static pci_ers_result_t intel_vsec_pci_slot_reset(struct pci_dev *pdev) {struct intel_vsec_device *intel_vsec_dev;pci_ers_result_t status =PCI_ERS_RESULT_DISCONNECT ; +struct vsec_priv *priv =pci_get_drvdata (pdev);unsigned long index;dev_info (&pdev->dev,"Resetting PCI slot\n" );
@@ -849,6 +857,13 @@ static pci_ers_result_t intel_vsec_pci_slot_reset(struct pci_dev *pdev)devm_release_action (&pdev->dev, intel_vsec_remove_aux, &intel_vsec_dev->auxdev); } + +/* +* intel_vsec_pci_init() reuses priv. Reset the registration state +* after tearing down old aux devices or the rewalk will skip them as +* already registered. +*/ +intel_vsec_reset_state (priv);pci_restore_state (pdev);intel_vsec_pci_init (pdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 458/2151 wifi: rtw88: sdio: zero the padding added to a TX transfer
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luka Gejak <[email protected]>
[ Upstream commit b81ead28aeb1fd9bc3b0de4e20342b6b538ac658 ]
rtw_sdio_write_port() rounds the transfer up with sdio_align_size() and then hands that length to sdio_memcpy_toio() while the skb still only holds skb->len bytes. The difference, between one and 511 bytes, is read from beyond the end of the frame and transmitted. Whether it stays inside the skb's allocation depends on how much tailroom the skb happens to have, so this is at best sending uninitialised memory over the air.
Pad the skb up to the transfer size first. __skb_pad() zeroes the added bytes, reallocates a cloned skb rather than writing into a buffer a clone still shares, and leaves skb->len alone, so nothing else in the transmit path has to change.
It must not free the skb on failure: rtw_sdio_write_data() frees the skb itself and rtw_sdio_process_tx_queue() requeues it, so both callers still own it and would double free.
Found while reworking this path for the RTL8723BS. Measured on RTL8723BS hardware, padding the transfer costs about 2% observable over transfer:
uplink is 19.5 to 19.8 Mbit/s padded against 20.9 to 21.1 Mbit/s unpadded in an interleaved A/B, with scans, reconnection and a UDP flood clean in both. The other SDIO parts sharing this path are untested; I have only the RTL8723BS.
--- drivers/net/wireless/realtek/rtw88/sdio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/wireless/realtek/rtw88/sdio.c +12 -0
@@ -636,6 +636,7 @@ static int rtw_sdio_write_port(struct rtw_dev *rtwdev, struct sk_buff *skb, enum rtw_tx_queue_type queue) {struct rtw_sdio *rtwsdio = (struct rtw_sdio *)rtwdev->priv; +size_t pad_size;bool bus_claim;size_t txsize;u32 txaddr;
@@ -646,6 +647,17 @@ static int rtw_sdio_write_port(struct rtw_dev *rtwdev, struct sk_buff *skb,return -EINVAL ; txsize =sdio_align_size (rtwsdio->sdio_func, skb->len); + pad_size = txsize - skb->len; + +if (pad_size >0 ) { +/* +* __skb_pad() must not free the skb on failure: both callers +* still own it, one requeues it and the other frees it. +*/ + ret =__skb_pad (skb, pad_size, false); +if (ret) +return ret; + } ret =rtw_sdio_check_free_txpg (rtwdev, queue, txsize);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 459/2151 ntfs3: fix out-of-bounds read in ntfs_read_mft()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 7a374d9be8267834dc534e55f01e5e01765cab4c ]
ntfs_read_mft() walks the attributes of an MFT record and, for each FILE_NAME attribute, compares the resident on-disk name with the name being looked up. The only size check before the compare is rsize >= SIZEOF_ATTRIBUTE_FILENAME, which covers the fixed header up to and including name_len, but not the variable-length name that follows it.
name_len comes straight from disk and is not validated against the resident data_size. A crafted image can set name_len large while keeping data_size at the header size, so ntfs_cmp_names_cpu() reads name_len le16 characters past the end of the MFT record buffer:
BUG: KASAN: slab-out-of-bounds in ntfs_cmp_names_cpu (fs/ntfs3/upcase.c:84) Read of size 2 at addr ffff888031879c00 by task a.out ntfs_cmp_names_cpu (fs/ntfs3/upcase.c:84) ntfs_iget5 (fs/ntfs3/inode.c:209) dir_search_u (fs/ntfs3/dir.c:265) ntfs_lookup (fs/ntfs3/namei.c:85) __lookup_slow (fs/namei.c:1915) lookup_slow (fs/namei.c:1932) path_lookupat (fs/namei.c:2278) vfs_statx (fs/stat.c) vfs_fstatat (fs/stat.c) __do_sys_newfstatat (fs/stat.c)
Allocated by task:
mi_init (fs/ntfs3/record.c)
ntfs_iget5 (fs/ntfs3/inode.c)
dir_search_u (fs/ntfs3/dir.c)
ntfs_lookup (fs/ntfs3/namei.c)
Check that the name fits in the resident data before using it.
--- fs/ntfs3/inode.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ntfs3/inode.c +5 -0
@@ -208,6 +208,11 @@ static struct inode *ntfs_read_mft(struct inode *inode, names +=1 ; fname =Add2Ptr (attr, roff); + +/* Make sure the full name fits in the resident data. */ +if (rsize <fname_full_size (fname)) + goto out; +if (fname->type ==FILE_NAME_DOS ) goto next_attr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 460/2151 fs/ntfs3: reject FS_IOC_SETFSLABEL on readonly mounts
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baolin Liu <[email protected]>
[ Upstream commit 5d3e03b70d05162ca49830efcd8b1cd2746a86a3 ]
FS_IOC_SETFSLABEL does not check for readonly mounts and can report success without persisting the label change.
Return -EROFS on readonly mounts.
--- fs/ntfs3/file.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/file.c +3 -0
@@ -65,6 +65,9 @@ static int ntfs_ioctl_set_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)if (!capable (CAP_SYS_ADMIN ))return -EPERM ; +if (sb_rdonly (sbi->sb)) +return -EROFS ; +if (copy_from_user (user, buf,FSLABEL_MAX ))return -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 461/2151 mm/gup_test: reject wrapped user ranges
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit e8ae6fd67021fafa9205330b3b248c9fc7216e0b ]
gup_test accepts an address and size from the debugfs ioctl and repeatedly compares against addr + size. If that addition wraps, the loop can be skipped and the ioctl returns success with size rewritten to zero.
Compute the end address once with overflow checking and use that checked end for the loop bounds.
Stable-dep-of: 44817a536aaa ("mm/gup_test: safely calculate GUP batch size")
--- mm/gup_test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/gup_test.c +8 -4
@@ -104,11 +104,15 @@ static int __gup_test_ioctl(unsigned int cmd,unsigned long i, nr_pages, addr, next;long nr;struct page **pages; +unsigned long end;int ret =0 ;bool needs_mmap_lock = cmd !=GUP_FAST_BENCHMARK && cmd !=PIN_FAST_BENCHMARK ; -if (gup->size >ULONG_MAX ) +if (gup->addr >ULONG_MAX || gup->size >ULONG_MAX ) +return -EINVAL ; +if (check_add_overflow ((unsigned long )gup->addr, + (unsigned long )gup->size, &end))return -EINVAL ; nr_pages = gup->size /PAGE_SIZE ;
@@ -124,13 +128,13 @@ static int __gup_test_ioctl(unsigned int cmd, i =0 ; nr = gup->nr_pages_per_call; start_time =ktime_get (); -for (addr = gup->addr; addr < gup->addr + gup->size; addr = next) { +for (addr = gup->addr; addr < end; addr = next) {if (nr != gup->nr_pages_per_call)break ; next = addr + nr *PAGE_SIZE ; -if (next > gup->addr + gup->size) { - next = gup->addr + gup->size; +if (next > end) { + next = end; nr = (next - addr) /PAGE_SIZE ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 462/2151 mm/gup_test: safely calculate GUP batch size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarthak Sharma <[email protected]>
[ Upstream commit 44817a536aaa5bfac0d316242e93e489d0a69d5f ]
__gup_test_ioctl() calculates the end of a GUP batch using:
next = addr + nr * PAGE_SIZE;
If nr is too large, it can cause next to overflow and wrap around. If it wraps, the next > end check is bypassed and a large value of nr is passed to the GUP call, even though the pages array was allocated according to gup->size. This can lead to out of bounds writes.
Also, when fewer than PAGE_SIZE bytes remain, the calculated batch contains zero pages. The code still calls GUP functions with pages + i, which can point past the allocated array.
Calculate nr by taking the minimum of the number of pages per call and the pages remaining in the address range. Reject zero sized and non page aligned gup->size values and zero nr_pages_per_call value.
--- mm/gup_test.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
mm/gup_test.c +4 -5
@@ -109,7 +109,8 @@ static int __gup_test_ioctl(unsigned int cmd,bool needs_mmap_lock = cmd !=GUP_FAST_BENCHMARK && cmd !=PIN_FAST_BENCHMARK ; -if (gup->addr >ULONG_MAX || gup->size >ULONG_MAX ) +if (gup->addr >ULONG_MAX || gup->size >ULONG_MAX || !gup->size || + !gup->nr_pages_per_call || !PAGE_ALIGNED (gup->size))return -EINVAL ;if (check_add_overflow ((unsigned long )gup->addr, (unsigned long )gup->size, &end))
@@ -132,11 +133,9 @@ static int __gup_test_ioctl(unsigned int cmd,if (nr != gup->nr_pages_per_call)break ; + nr = min_t(unsigned long, nr, (end - addr) / PAGE_SIZE); + next = addr + nr *PAGE_SIZE ; -if (next > end) { - next = end; - nr = (next - addr) /PAGE_SIZE ; - }switch (cmd) {case GUP_FAST_BENCHMARK :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 463/2151 mm/gup_test: report actual pinned bytes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarthak Sharma <[email protected]>
[ Upstream commit 65a79b9b693d8c7bd7e5e4865c02cce922a7cc50 ]
__gup_test_ioctl() advances addr to the end of the current batch before checking if GUP pinned the entire requested batch. If GUP pins more than 0 pages but less than the requested batch size, addr still advances by the requested batch size.
The next iteration detects the partial pinning and breaks out of the loop. Again gup->size is calculated using addr - gup->addr, so it also includes the unpinned pages of the requested batch.
Calculate gup->size using the actual number of pages pinned multiplied by PAGE_SIZE.
--- mm/gup_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/gup_test.c +1 -1
@@ -180,7 +180,7 @@ static int __gup_test_ioctl(unsigned int cmd, nr_pages = i; gup->get_delta_usec =ktime_us_delta (end_time, start_time); - gup->size = addr - gup->addr; + gup->size = nr_pages *PAGE_SIZE ;/* * Take an un-benchmark-timed moment to verify DMA pinned
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 464/2151 crypto: eip93 - fix ssl mac bit field definition
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksander Jan Bajkowski <[email protected]>
[ Upstream commit 8f808c8f32b67d42ba97457a7054bd5954d02856 ]
Checked the register definitions with the documentation[1]. Turns out that the EIP93_SA_CMD_SSL_MAC bit field has a bad value. It's used in SSL offload mode. This driver doesn't support SSL offload yet, so this causes no problems.
1. MT7621 ProgrammingGuide DMA
--- drivers/crypto/inside-secure/eip93/eip93-regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/inside-secure/eip93/eip93-regs.h +1 -1
@@ -281,7 +281,7 @@#define EIP93_SA_CMD_HASH_CRYPT_OFFSET GENMASK(23, 16)#define EIP93_SA_CMD_BYTE_OFFSET BIT(13)/* 0: CRYPT_OFFSET in 32bit word 1: CRYPT_OFFSET in 8bit bytes */ #define EIP93_SA_CMD_HMAC BIT(12) -#define EIP93_SA_CMD_SSL_MAC BIT(12) +#define EIP93_SA_CMD_SSL_MAC BIT(11)/* This mask can be either used for ARC4 or AES */ #define EIP93_SA_CMD_CHIPER_MODE GENMASK(9, 8)/* AES or DES operations */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 465/2151 arm64: dts: mediatek: mt8173: Fix MFG_ASYNC power domain clock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit c9b3c82c9f1f86cdb2449d47e4ca66a19159ee12 ]
The MFG_ASYNC domain, which is likely associated to the whole MFG block, currently specifies clk26m as its domain clock. This is bogus, since the clock is an external crystal with no controls. Also, the MFG block has a independent CLK_TOP_AXI_MFG_IN_SEL clock, which according to the block diagram, gates access to the hardware registers. Having this one as the domain clock makes much more sense. This also fixes access to the MFGTOP registers.
Change the MFG_ASYNC domain clock to CLK_TOP_AXI_MFG_IN_SEL.
--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +1 -1
@@ -505,7 +505,7 @@ power-domain@MT8173_POWER_DOMAIN_USB { }; mfg_async: power-domain@MT8173_POWER_DOMAIN_MFG_ASYNC { reg = <MT8173_POWER_DOMAIN_MFG_ASYNC>; - clocks = <&clk26m>; + clocks = <&topckgen CLK_TOP_AXI_MFG_IN_SEL>; clock-names = "mfg"; #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 466/2151 ACPI: tables: handle failed initrd override mappings
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit 047c834d939df75386cfc0603c7ddeaa23a349a4 ]
The runtime AML table-loading path can invoke initrd override after permanent mappings are enabled. Mapping bookkeeping can then fail.
Return AE_NO_MEMORY in that case to prevent a NULL pointer dereference when attempting to read the table length.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- drivers/acpi/tables.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/tables.c +3 -0
@@ -559,6 +559,9 @@ acpi_table_initrd_override(struct acpi_table_header *existing_table,while (table_offset +ACPI_HEADER_SIZE <= all_tables_size) { table =acpi_os_map_memory (acpi_tables_addr + table_offset,ACPI_HEADER_SIZE ); +if (!table) +return AE_NO_MEMORY ; +if (table_offset + table->length > all_tables_size) {acpi_os_unmap_memory (table,ACPI_HEADER_SIZE );WARN_ON (1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 467/2151 cxl/hdm: Reject switch decoder interleave ways that overflow targets
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 3696326ca14cf018788d64232a068fdf26b1ff31 ]
Switch decoder enumeration validates that the interleave ways encoding is legal, but not that the resulting number of ways fits the available targets. This can overrun the target array (target_list.target_id[]) during enumeration of 12 or 16 way interleaves.
Bound the target count where it is established rather than at each use. Reject an HDM capability whose reported target count is zero or exceeds the target list register capacity, and reject a zero target switch decoder allocation in cxl_switch_decoder_init(). Enumeration is then left with a single check: reject a decoder whose interleave ways exceed the targets it has.
Add a clarifying comment that target_count is a direct count, not 0-based like decoder_count.
--- drivers/cxl/core/hdm.c | 24 ++++++++++++++++++++++++ drivers/cxl/core/port.c | 2 +- drivers/cxl/cxl.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/cxl/core/hdm.c +24 -0
@@ -76,6 +76,8 @@ static void parse_hdm_decoder_caps(struct cxl_hdm *cxlhdm) hdm_cap =readl (cxlhdm->regs.hdm_decoder +CXL_HDM_DECODER_CAP_OFFSET ); cxlhdm->decoder_count =cxl_hdm_decoder_count (hdm_cap); + +/* target_count is a direct count (1h..8h), not 0-based like decoder_count */ cxlhdm->target_count =FIELD_GET (CXL_HDM_DECODER_TARGET_COUNT_MASK , hdm_cap);if (FIELD_GET (CXL_HDM_DECODER_INTERLEAVE_11_8 , hdm_cap))
@@ -1081,6 +1083,16 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, cxld->interleave_ways, cxld->interleave_granularity);if (!cxled) { +struct cxl_switch_decoder *cxlsd =to_cxl_switch_decoder (&cxld->dev); + +if (cxld->interleave_ways > cxlsd->nr_targets) { +dev_err (&port->dev, +"decoder%d.%d: interleave ways: %d exceeds targets: %d\n" , + port->id, cxld->id, cxld->interleave_ways, + cxlsd->nr_targets); +return -ENXIO ; + } + lo =readl (hdm +CXL_HDM_DECODER0_TL_LOW (which)); hi =readl (hdm +CXL_HDM_DECODER0_TL_HIGH (which)); target_list.value = (hi <<32 ) + lo;
@@ -1158,6 +1170,18 @@ static int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,int i;u64 dpa_base =0 ; +/* +* Per CXL 4.0 8.2.4.20.1 Target Count is the number of target ports +* per decoder, max 8. Endpoint decoders have no targets. +*/ +if (!is_cxl_endpoint (port) && + (cxlhdm->target_count <1 || + cxlhdm->target_count >CXL_HDM_DECODER0_TL_TARGETS )) { +dev_err (&port->dev,"Invalid decoder target count: %u\n" , + cxlhdm->target_count); +return -ENXIO ; + } +cxl_settle_decoders (cxlhdm);for (i =0 ; i < cxlhdm->decoder_count; i++) {
drivers/cxl/core/port.c +1 -1
@@ -1983,7 +1983,7 @@ static int cxl_switch_decoder_init(struct cxl_port *port, struct cxl_switch_decoder *cxlsd, int nr_targets) { -if (nr_targets >CXL_DECODER_MAX_INTERLEAVE ) +if (nr_targets <1 || nr_targets >CXL_DECODER_MAX_INTERLEAVE )return -EINVAL ; cxlsd->nr_targets = nr_targets;
drivers/cxl/cxl.h +2 -0
@@ -66,6 +66,8 @@ extern const struct nvdimm_security_ops *cxl_security_ops;#define CXL_HDM_DECODER0_CTRL_HOSTONLY BIT(12)#define CXL_HDM_DECODER0_TL_LOW (i) (0x20 * (i) + 0x24)#define CXL_HDM_DECODER0_TL_HIGH (i) (0x20 * (i) + 0x28) +/* Target list capacity, i.e. max interleave ways for a non-endpoint decoder */ +#define CXL_HDM_DECODER0_TL_TARGETS 8#define CXL_HDM_DECODER0_SKIP_LOW (i) CXL_HDM_DECODER0_TL_LOW(i)#define CXL_HDM_DECODER0_SKIP_HIGH (i) CXL_HDM_DECODER0_TL_HIGH(i)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 468/2151 cxl/hdm: Make switch decoder target parsing endian-safe
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 3f846646b3d3b5699139e686e1107d231a725860 ]
Switch decoder target IDs are stored one per byte, starting with target 0 in the least significant byte. The current code accesses those bytes in memory order, which only matches register order on little-endian hosts.
On big-endian hosts, the target IDs are reversed and the decoder is associated with the wrong downstream ports.
Place the register values in a byte array in little-endian order and index the target IDs from there, so the target mapping is independent of host endianness.
--- drivers/cxl/core/hdm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/cxl/core/hdm.c +7 -8
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ #include <linux/seq_file.h> +#include <linux/unaligned.h> #include <linux/device.h> #include <linux/delay.h>
@@ -972,15 +973,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, u64 *dpa_base, struct cxl_endpoint_dvsec_info *info) { struct cxl_endpoint_decoder *cxled = NULL; +u8 target_id[CXL_HDM_DECODER0_TL_TARGETS ];u64 size, base, skip, dpa_size, lo, hi;bool committed;u32 remainder;int i, rc;u32 ctrl; -union { -u64 value; -unsigned char target_id[8 ]; - } target_list; if (should_emulate_decoders(info)) return cxl_setup_hdm_decoder_from_dvsec(port, cxld, dpa_base,
@@ -1093,11 +1091,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,return -ENXIO ; } - lo =readl (hdm +CXL_HDM_DECODER0_TL_LOW (which)); - hi =readl (hdm +CXL_HDM_DECODER0_TL_HIGH (which)); - target_list.value = (hi <<32 ) + lo; +put_unaligned_le32 (readl (hdm +CXL_HDM_DECODER0_TL_LOW (which)), + &target_id[0 ]); +put_unaligned_le32 (readl (hdm +CXL_HDM_DECODER0_TL_HIGH (which)), + &target_id[4 ]);for (i =0 ; i < cxld->interleave_ways; i++) - cxld->target_map[i] = target_list.target_id[i]; + cxld->target_map[i] = target_id[i];return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 469/2151 cxl/hdm: Restore commit_end when decoder enumeration fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 7dae18c39e99813461db6ef3fc13f077452109ce ]
commit_end tracks the highest committed decoder on a port. It gets advanced before decoder enumeration is complete, so a later failure leaves it pointing at a decoder that was never added. The next probe then rejects decoder0 as out of order and enumeration fails.
Reset commit_end to the uncommitted baseline once the decoders are torn down, so a subsequent probe rebuilds it from scratch. Register the reset before the decoders are added so that on unwind it runs after every decoder has been unregistered. This prevents commit_end from dropping below the highest committed decoder still registered and exposing an inconsistent value to a concurrent reader.
Protect the commit_end advance in the DVSEC emulation path against concurrent readers, matching the register-programmed path.
--- drivers/cxl/core/hdm.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/cxl/core/hdm.c +20 -3
@@ -953,7 +953,8 @@ static int cxl_setup_hdm_decoder_from_dvsec(* change the range registers at run time. */ cxld->flags |=CXL_DECODER_F_ENABLE |CXL_DECODER_F_LOCK ; - port->commit_end = cxld->id; +scoped_guard (rwsem_write, &cxl_rwsem.region) + port->commit_end = cxld->id; rc =devm_cxl_dpa_reserve (cxled, *dpa_base, len,0 );if (rc) {
@@ -1156,6 +1157,14 @@ static void cxl_settle_decoders(struct cxl_hdm *cxlhdm)msleep (20 ); } +static void cxl_reset_commit_end (void *data) +{ +struct cxl_port *port = data; + +guard (rwsem_write)(&cxl_rwsem.region); + port->commit_end =-1 ; +} +/** * devm_cxl_enumerate_decoders - add decoder objects per HDM register set * @cxlhdm: Structure to populate with HDM capabilities
@@ -1166,8 +1175,8 @@ static int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, {void __iomem *hdm = cxlhdm->regs.hdm_decoder;struct cxl_port *port = cxlhdm->port; -int i;u64 dpa_base =0 ; +int i, rc;/* * Per CXL 4.0 8.2.4.20.1 Target Count is the number of target ports
@@ -1183,8 +1192,16 @@ static int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,cxl_settle_decoders (cxlhdm); +/* +* Reset commit_end after all decoders have been torn down so a +* subsequent probe rebuilds it from scratch. +*/ + rc =devm_add_action (&port->dev, cxl_reset_commit_end, port); +if (rc) +return rc; +for (i =0 ; i < cxlhdm->decoder_count; i++) { -int rc, target_count = cxlhdm->target_count; +int target_count = cxlhdm->target_count;struct cxl_decoder *cxld;if (is_cxl_endpoint (port)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 470/2151 cxl/port: Bound switch decoder target array access by nr_targets
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 4e42c398af136d62fac8c19c9f410ec83a8dd34a ]
Switch decoder target lookups walk the target array using interleave ways as the bound. The array is allocated with nr_targets entries, so a decoder whose interleave ways exceeds nr_targets reads and writes past the end of it. That happens during dport activation, during decoder target population, and when userspace reads the target_list attribute.
Bounding by nr_targets alone is not correct either. Commit d6488fee6647 ("cxl/port: Fix decoder initialization when nr_targets > interleave_ways") moved target population to interleave ways precisely so that targets a decoder does not use are left unpopulated. Neither field alone is a safe bound, so add a helper that returns the minimum of the two and use it at every walk of the target array.
Valid configurations keep interleave ways within nr_targets, so this is not a behavior change for them.
--- drivers/cxl/core/port.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/cxl/core/port.c +18 -7
@@ -147,20 +147,29 @@ static ssize_t target_type_show(struct device *dev, }static DEVICE_ATTR_RO (target_type); +/* +* Interleave ways selects how many targets a decoder uses, but the target +* array is only nr_targets long. Bound array access by both. +*/ +static int cxlsd_nr_used_targets (struct cxl_switch_decoder *cxlsd) +{ +return min (cxlsd->cxld.interleave_ways, cxlsd->nr_targets); +} +static ssize_t emit_target_list (struct cxl_switch_decoder *cxlsd,char *buf) { -struct cxl_decoder *cxld = &cxlsd->cxld; +int nr_used =cxlsd_nr_used_targets (cxlsd);ssize_t offset =0 ;int i, rc =0 ; -for (i =0 ; i < cxld->interleave_ways; i++) { +for (i =0 ; i < nr_used; i++) {struct cxl_dport *dport = cxlsd->target[i];struct cxl_dport *next =NULL ;if (!dport)break ; -if (i +1 < cxld->interleave_ways) +if (i +1 < nr_used) next = cxlsd->target[i +1 ]; rc =sysfs_emit_at (buf, offset,"%d%s" , dport->port_id, next ?"," :"" );
@@ -1602,7 +1611,7 @@ static int update_decoder_targets(struct device *dev, void *data)struct cxl_dport *dport = data;struct cxl_switch_decoder *cxlsd;struct cxl_decoder *cxld; -int i; +int i, nr_used;if (!is_switch_decoder (dev))return 0 ;
@@ -1610,8 +1619,9 @@ static int update_decoder_targets(struct device *dev, void *data) cxlsd =to_cxl_switch_decoder (dev); cxld = &cxlsd->cxld;guard (rwsem_write)(&cxl_rwsem.region); + nr_used =cxlsd_nr_used_targets (cxlsd); -for (i =0 ; i < cxld->interleave_ways; i++) { +for (i =0 ; i < nr_used; i++) {if (cxld->target_map[i] == dport->port_id) { cxlsd->target[i] = dport; dev_dbg(dev, "dport%d found in target list, index %d\n",
@@ -1914,7 +1924,7 @@ static int decoder_populate_targets(struct cxl_switch_decoder *cxlsd, struct cxl_port *port) {struct cxl_decoder *cxld = &cxlsd->cxld; -int i; +int i, nr_used;device_lock_assert (&port->dev);
@@ -1922,7 +1932,8 @@ static int decoder_populate_targets(struct cxl_switch_decoder *cxlsd,return 0 ;guard (rwsem_write)(&cxl_rwsem.region); -for (i =0 ; i < cxlsd->cxld.interleave_ways; i++) { + nr_used =cxlsd_nr_used_targets (cxlsd); +for (i =0 ; i < nr_used; i++) {struct cxl_dport *dport =find_dport (port, cxld->target_map[i]);if (!dport) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 471/2151 pinctrl: stm32: Drop the nonexistent CONFIG_MACH_STM32MP25 from the STM32MP257 default
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 01f20711d044f35a7a89ceec33df30e097147e8a ]
Commit 619f8ca4a73d ("pinctrl: stm32: add stm32mp257 pinctrl support") made CONFIG_PINCTRL_STM32MP257 default to MACH_STM32MP25, following the MACH_* pattern of the arm32 entries above it, but no Kconfig symbol of that name exists and git log -S finds no Kconfig file that ever defined
one: the STM32MP25 family is arm64 only, where CONFIG_ARCH_STM32 covers it. Commit dba0aff2b89b ("pinctrl: stm32: Allow compile as module for stm32mp257") added "|| (ARCH_STM32 && ARM64)" next to it, so the first half now evaluates to n and changes no configuration.
Drop the first half.
--- drivers/pinctrl/stm32/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/stm32/Kconfig +1 -1
@@ -55,7 +55,7 @@ config PINCTRL_STM32MP157 config PINCTRL_STM32MP257 tristate "STMicroelectronics STM32MP257 pin control" depends on OF && HAS_IOMEM - default MACH_STM32MP25 || (ARCH_STM32 && ARM64) + default ARCH_STM32 && ARM64 select PINCTRL_STM32 config PINCTRL_STM32_HDP
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 472/2151 ASoC: codecs: rt1015: convert to snd_soc_dapm_xxx()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit 8b1c56ae39d3bf304ab0c8de456e8f02081be9ed ]
This patch converts below functions.
dapm->dev -> snd_soc_dapm_to_dev()dapm->card -> snd_soc_dapm_to_card()dapm->component -> snd_soc_dapm_to_component()
dapm_kcontrol_get_value() -> snd_soc_dapm_kcontrol_get_value()
snd_soc_component_enable_pin() -> snd_soc_dapm_enable_pin()snd_soc_component_enable_pin_unlocked() -> snd_soc_dapm_enable_pin_unlocked()snd_soc_component_disable_pin() -> snd_soc_dapm_disable_pin()snd_soc_component_disable_pin_unlocked() -> snd_soc_dapm_disable_pin_unlocked()snd_soc_component_nc_pin() -> snd_soc_dapm_nc_pin()snd_soc_component_nc_pin_unlocked() -> snd_soc_dapm_nc_pin_unlocked()snd_soc_component_get_pin_status() -> snd_soc_dapm_get_pin_status()snd_soc_component_force_enable_pin() -> snd_soc_dapm_force_enable_pin()snd_soc_component_force_enable_pin_unlocked() -> snd_soc_dapm_force_enable_pin_unlocked()snd_soc_component_force_bias_level() -> snd_soc_dapm_force_bias_level()snd_soc_component_get_bias_level() -> snd_soc_dapm_get_bias_level()snd_soc_component_init_bias_level() -> snd_soc_dapm_init_bias_level()snd_soc_component_get_dapm() -> snd_soc_component_to_dapm()
snd_soc_dapm_kcontrol_component() -> snd_soc_dapm_kcontrol_to_component()snd_soc_dapm_kcontrol_widget() -> snd_soc_dapm_kcontrol_to_widget()snd_soc_dapm_kcontrol_dapm() -> snd_soc_dapm_kcontrol_to_dapm()snd_soc_dapm_np_pin() -> snd_soc_dapm_disable_pin()
Stable-dep-of: 98fe8aab04ce ("ASoC: rt1015: make control calibration failures observable")
--- sound/soc/codecs/rt1015.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/codecs/rt1015.c +3 -2
@@ -494,9 +494,10 @@ static int rt1015_bypass_boost_get(struct snd_kcontrol *kcontrol,static void rt1015_calibrate (struct rt1015_priv *rt1015) {struct snd_soc_component *component = rt1015->component; +struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component);struct regmap *regmap = rt1015->regmap; -snd_soc_dapm_mutex_lock (&component->dapm); +snd_soc_dapm_mutex_lock (dapm);regcache_cache_bypass (regmap, true);regmap_write (regmap,RT1015_CLK_DET ,0x0000 );
@@ -518,7 +519,7 @@ static void rt1015_calibrate(struct rt1015_priv *rt1015)regcache_cache_bypass (regmap, false);regcache_mark_dirty (regmap);regcache_sync (regmap); -snd_soc_dapm_mutex_unlock (&component->dapm); +snd_soc_dapm_mutex_unlock (dapm); } static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 473/2151 ASoC: rt1015: make control calibration failures observable
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 98fe8aab04cec6fcadeb10a757235225d550be36 ]
The bypass-boost control runs a hardware calibration while bypassing the register cache. It ignores every register access and cache restore failure, then publishes both the requested mode and calibration completion.
Return failures from the complete calibration sequence, always restore normal cache operation and unlock DAPM, and only publish the control state after the calibration and final mode write both succeed. The mixer control callback is an effective error consumer, independent of deferred component resume.
--- sound/soc/codecs/rt1015.c | 81 +++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 16 deletions(-)
sound/soc/codecs/rt1015.c +65 -16
@@ -491,35 +491,72 @@ static int rt1015_bypass_boost_get(struct snd_kcontrol *kcontrol,return 0 ; } -static void rt1015_calibrate (struct rt1015_priv *rt1015) +static int rt1015_calibrate (struct rt1015_priv *rt1015) {struct snd_soc_component *component = rt1015->component;struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component);struct regmap *regmap = rt1015->regmap; +int ret, sync_ret;snd_soc_dapm_mutex_lock (dapm);regcache_cache_bypass (regmap, true); -regmap_write (regmap,RT1015_CLK_DET ,0x0000 ); -regmap_write (regmap,RT1015_PWR4 ,0x00B2 ); -regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x0009 ); + ret =regmap_write (regmap,RT1015_CLK_DET ,0x0000 ); +if (ret) + goto restore_cache; + + ret =regmap_write (regmap,RT1015_PWR4 ,0x00B2 ); +if (ret) + goto restore_cache; + + ret =regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x0009 ); +if (ret) + goto restore_cache; +msleep (100 ); -regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x000A ); + ret =regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x000A ); +if (ret) + goto restore_cache; +msleep (100 ); -regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x000C ); + ret =regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x000C ); +if (ret) + goto restore_cache; +msleep (100 ); -regmap_write (regmap,RT1015_CLSD_INTERNAL8 ,0x2028 ); -regmap_write (regmap,RT1015_CLSD_INTERNAL9 ,0x0140 ); -regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x000D ); + ret =regmap_write (regmap,RT1015_CLSD_INTERNAL8 ,0x2028 ); +if (ret) + goto restore_cache; + + ret =regmap_write (regmap,RT1015_CLSD_INTERNAL9 ,0x0140 ); +if (ret) + goto restore_cache; + + ret =regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x000D ); +if (ret) + goto restore_cache; +msleep (300 ); -regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x0008 ); -regmap_write (regmap,RT1015_SYS_RST1 ,0x05F5 ); -regmap_write (regmap,RT1015_CLK_DET ,0x8000 ); + ret =regmap_write (regmap,RT1015_PWR_STATE_CTRL ,0x0008 ); +if (ret) + goto restore_cache; + + ret =regmap_write (regmap,RT1015_SYS_RST1 ,0x05F5 ); +if (ret) + goto restore_cache; + + ret =regmap_write (regmap,RT1015_CLK_DET ,0x8000 ); + +restore_cache:regcache_cache_bypass (regmap, false);regcache_mark_dirty (regmap); -regcache_sync (regmap); + sync_ret =regcache_sync (regmap); +if (!ret) + ret = sync_ret;snd_soc_dapm_mutex_unlock (dapm); + +return ret; } static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol,
@@ -529,6 +566,8 @@ static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol,snd_soc_kcontrol_component (kcontrol);struct rt1015_priv *rt1015 =snd_soc_component_get_drvdata (component); +int bypass_boost = rt1015->bypass_boost; +int ret;if (rt1015->dac_is_used) {dev_err (component->dev,"DAC is being used!\n" );
@@ -538,13 +577,23 @@ static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol, rt1015->bypass_boost = ucontrol->value.integer.value[0 ];if (rt1015->bypass_boost == RT1015_Bypass_Boost && !rt1015->cali_done) { -rt1015_calibrate (rt1015); - rt1015->cali_done =1 ; + ret =rt1015_calibrate (rt1015); +if (ret) + goto restore_boost; + + ret =regmap_write (rt1015->regmap,RT1015_MONO_DYNA_CTRL , +0x0010 ); +if (ret) + goto restore_boost; -regmap_write (rt1015->regmap,RT1015_MONO_DYNA_CTRL ,0x0010 ); + rt1015->cali_done =1 ; }return 0 ; + +restore_boost: + rt1015->bypass_boost = bypass_boost; +return ret; }static const char *const rt1015_dac_output_vol_select[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 474/2151 ASoC: SOF: imx: Prevent stack OOB read in DSP panic dump
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ștefan Ghețu <[email protected]>
[ Upstream commit 48ed992bfbe53537ad1cbc8ad68f7031e7ac0af3 ]
Commit 58bb5081cba1 ("ASoC: SOF: Xtensa: dump ar registers to restore call stack") added a shared Xtensa helper that iterates over a flexible array of AR registers (ar[]) controlled by plat_hdr.numaregs.
While Intel IPC4 allocates dynamic storage for the AR block, the i.MX IPC3 path reads the oops message into a stack-allocated struct without backing storage for ar[], while leaving numaregs unvalidated. This causes a stack out-of-bounds read when printing a DSP panic.
Clear numaregs to 0 on i.MX since the AR block is not fetched or supported on this platform, preventing unsafe out-of-bounds memory accesses in the shared Xtensa helper.
--- sound/soc/sof/imx/imx-common.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/sof/imx/imx-common.c +1 -0
@@ -34,6 +34,7 @@ void imx8_get_registers(struct snd_sof_dev *sdev,/* first read registers */ sof_mailbox_read (sdev, offset, xoops,sizeof (*xoops)); + xoops->plat_hdr.numaregs =0 ;/* then get panic info */ if (xoops->arch_hdr.totalsize >EXCEPT_MAX_HDR_SIZE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/2151 scsi: pm8001: Fix SATA FIS offset in struct hw_event_resp
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit cdc97921de02a0c1a8324afa03e8b3e30a72bbe6 ]
In struct hw_event_resp, sas_identify was defined using struct sas_identify_frame, which is 32 bytes long because it includes a 4-byte CRC field. However, PM8001 and PM80xx hardware does not send the CRC in the event response frame, providing only the 28-byte identify payload.
Because sas_identify had a size of 32 bytes, the following sata_fis member was located at byte offset 44 instead of the actual hardware offset 40. In hw_event_sata_phy_up(), this discrepancy was worked around with negative pointer arithmetic: ((u8 *)&pPayload->sata_fis - 4). This triggers a compiler error under Clang with -Wstringop-overread:
error: 'memcpy' reading 20 bytes from a region of size 0 [-Werror,-Wstringop-overread]
memcpy(phy->frame_rcvd, ((u8 *)&pPayload->sata_fis - 4),
Move struct sas_identify_frame_local (28 bytes) into pm8001_defs.h, and update struct hw_event_resp in both pm8001_hwi.h and pm80xx_hwi.h to use struct sas_identify_frame_local followed by sata_fis and a 4-byte padding word. This correctly aligns sata_fis at byte offset 40 while maintaining the 64-byte total payload size.
Update hw_event_sata_phy_up() in pm8001_hwi.c and pm80xx_hwi.c to copy directly from &pPayload->sata_fis.
Compile-tested only. Both the patch and its description have been generated by Gemini.
--- drivers/scsi/pm8001/pm8001_defs.h | 98 +++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.c | 2 +- drivers/scsi/pm8001/pm8001_hwi.h | 4 +- drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.h | 100 +----------------------------- 5 files changed, 106 insertions(+), 100 deletions(-)
drivers/scsi/pm8001/pm8001_defs.h +98 -0
@@ -41,6 +41,104 @@#ifndef _PM8001_DEFS_H_#define _PM8001_DEFS_H_ +#include <scsi/sas.h> + +#ifdef __LITTLE_ENDIAN_BITFIELD +struct sas_identify_frame_local { +/* Byte 0 */ +u8 frame_type:4 ; +u8 dev_type:3 ; +u8 _un0:1 ; + +/* Byte 1 */ +u8 _un1; + +/* Byte 2 */ +union { +struct { +u8 _un20:1 ; +u8 smp_iport:1 ; +u8 stp_iport:1 ; +u8 ssp_iport:1 ; +u8 _un247:4 ; + }; +u8 initiator_bits; + }; + +/* Byte 3 */ +union { +struct { +u8 _un30:1 ; +u8 smp_tport:1 ; +u8 stp_tport:1 ; +u8 ssp_tport:1 ; +u8 _un347:4 ; + }; +u8 target_bits; + }; + +/* Byte 4 - 11 */ +u8 _un4_11[8 ]; + +/* Byte 12 - 19 */ +u8 sas_addr[SAS_ADDR_SIZE ]; + +/* Byte 20 */ +u8 phy_id; + +u8 _un21_27[7 ]; + +} __packed; + +#elif defined(__BIG_ENDIAN_BITFIELD) +struct sas_identify_frame_local { +/* Byte 0 */ +u8 _un0:1 ; +u8 dev_type:3 ; +u8 frame_type:4 ; + +/* Byte 1 */ +u8 _un1; + +/* Byte 2 */ +union { +struct { +u8 _un247:4 ; +u8 ssp_iport:1 ; +u8 stp_iport:1 ; +u8 smp_iport:1 ; +u8 _un20:1 ; + }; +u8 initiator_bits; + }; + +/* Byte 3 */ +union { +struct { +u8 _un347:4 ; +u8 ssp_tport:1 ; +u8 stp_tport:1 ; +u8 smp_tport:1 ; +u8 _un30:1 ; + }; +u8 target_bits; + }; + +/* Byte 4 - 11 */ +u8 _un4_11[8 ]; + +/* Byte 12 - 19 */ +u8 sas_addr[SAS_ADDR_SIZE ]; + +/* Byte 20 */ +u8 phy_id; + +u8 _un21_27[7 ]; +} __packed; +#else +#error "Bitfield order not defined!" +#endif +enum chip_flavors { chip_8001, chip_8008,
drivers/scsi/pm8001/pm8001_hwi.c +1 -1
@@ -3208,7 +3208,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) phy->sas_phy.oob_mode =SATA_OOB_MODE ;sas_notify_phy_event (&phy->sas_phy,PHYE_OOB_DONE ,GFP_ATOMIC );spin_lock_irqsave (&phy->sas_phy.frame_rcvd_lock, flags); -memcpy (phy->frame_rcvd, ((u8 *)&pPayload->sata_fis -4 ), +memcpy (phy->frame_rcvd, &pPayload->sata_fis,sizeof (struct dev_to_host_fis )); phy->frame_rcvd_size =sizeof (struct dev_to_host_fis ); phy->identify.target_port_protocols =SAS_PROTOCOL_SATA ;
drivers/scsi/pm8001/pm8001_hwi.h +3 -1
@@ -42,6 +42,7 @@#include <linux/types.h> #include <scsi/libsas.h> +#include "pm8001_defs.h" /* for Request Opcode of IOMB */
@@ -229,8 +230,9 @@ struct hw_event_resp {__le32 lr_evt_status_phyid_portid;__le32 evt_param;__le32 npip_portstate; -struct sas_identify_frame sas_identify; +struct sas_identify_frame_local sas_identify;struct dev_to_host_fis sata_fis; +u32 _r_a; } __attribute__((packed, aligned(4)));
drivers/scsi/pm8001/pm80xx_hwi.c +1 -1
@@ -3296,7 +3296,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) phy->sas_phy.oob_mode =SATA_OOB_MODE ;sas_notify_phy_event (&phy->sas_phy,PHYE_OOB_DONE ,GFP_ATOMIC );spin_lock_irqsave (&phy->sas_phy.frame_rcvd_lock, flags); -memcpy (phy->frame_rcvd, ((u8 *)&pPayload->sata_fis -4 ), +memcpy (phy->frame_rcvd, &pPayload->sata_fis,sizeof (struct dev_to_host_fis )); phy->frame_rcvd_size =sizeof (struct dev_to_host_fis ); phy->identify.target_port_protocols =SAS_PROTOCOL_SATA ;
drivers/scsi/pm8001/pm80xx_hwi.h +3 -97
119 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/2151 staging: iio: adc: ad7816: Fix DMA safety issues in SPI transfers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdelnasser Hussein <[email protected]>
[ Upstream commit 69fa76f0af3414cc189c3b0b807cb59e327ecc00 ]
The SPI operations in this driver are not DMA safe:
1. spi_read() uses a stack-allocated buffer.
2. spi_write() in ad7816_spi_read() uses a struct member that shares a cacheline with other variables.
3. spi_write() in ad7816_spi_write() passes a stack parameter by reference.
Fix these violations by replacing all spi_read() and spi_write() calls with spi_write_then_read(). This safely handles DMA by internally allocating a bounce buffer for the transfers, avoiding cacheline sharing issues without needing dedicated aligned buffers. This implicitly corrects the size argument in read to sizeof(buf).
--- drivers/staging/iio/adc/ad7816.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7816.c +3 -3
@@ -69,7 +69,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)gpiod_set_value (chip->rdwr_pin,1 );gpiod_set_value (chip->rdwr_pin,0 ); - ret =spi_write (spi_dev, &chip->channel_id,sizeof (chip->channel_id)); + ret =spi_write_then_read (spi_dev, &chip->channel_id,sizeof (chip->channel_id),NULL ,0 );if (ret <0 ) {dev_err (&spi_dev->dev,"SPI channel setting error\n" );return ret;
@@ -91,7 +91,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)gpiod_set_value (chip->rdwr_pin,0 );gpiod_set_value (chip->rdwr_pin,1 ); - ret =spi_read (spi_dev, &buf,sizeof (*data)); + ret =spi_write_then_read (spi_dev,NULL ,0 , &buf,sizeof (buf));if (ret <0 ) {dev_err (&spi_dev->dev,"SPI data read error\n" );return ret;
@@ -109,7 +109,7 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data)gpiod_set_value (chip->rdwr_pin,1 );gpiod_set_value (chip->rdwr_pin,0 ); - ret =spi_write (spi_dev, &data,sizeof (data)); + ret =spi_write_then_read (spi_dev, &data,sizeof (data),NULL ,0 );if (ret <0 )dev_err (&spi_dev->dev,"SPI oti data write error\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/2151 selftests/bpf: Wait for links to come up in lwt_ip_encap
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
[ Upstream commit 71b75648d1a21c0a6379741d00f41086ec95f14a ]
lwt_ip_encap creates three fresh netns with veth pairs across them and then immediately pings over IPv6. The peer ends of the first veth pair end up with the same ifindex in their respective netns, so linkwatch does not treat the carrier-on as urgent and may deliver NETDEV_CHANGE up to one second later. Until that happens addrconf considers the link not
ready: no ff00::/8 multicast route and no link-local address are installed, and the neighbour solicitation for the next hop is dropped as a no-route packet. The NS retransmit a second later succeeds, but ping -W1 has already given up:
check_ping_ok:FAIL:ip netns exec ns-lwt-ip-encap-1-... ping -6 -c 1 -W1 -I veth1 fb04::1 > /dev/null unexpected error: 256 (errno 2) lwt_ip_encap:FAIL:ping OK unexpected error: -1 (errno 2)
#226/1 lwt_ip_encap_ipv4/egress:FAIL
This reproduces reliably when the test is run standalone on an idle system where setup completes well within a second. The original shell script had a "sleep 1 # reduce flakiness" after setup which was lost in the conversion to test_progs.
Instead of sleeping, poll SIOCGIFFLAGS for IFF_RUNNING on all veths at the end of setup_network() so traffic is only sent once every link is operationally up.
--- .../selftests/bpf/prog_tests/lwt_ip_encap.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)
tools/testing/selftests/bpf/prog_tests/lwt_ip_encap.c +53 -0
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only +#include <net/if.h> #include <netinet/in.h> +#include <sys/ioctl.h> #include "network_helpers.h" #include "test_progs.h"
@@ -141,6 +143,54 @@ static int set_bottom_addr(const char *ns1, const char *ns2, const char *ns3)return 1 ; } +/* +* A veth whose peer sits in another netns with the same ifindex gets its +* carrier-on handled as a non-urgent linkwatch event, i.e. up to 1s late. +* Until then IPv6 considers the link not ready (no ff00::/8 route, no +* link-local address) and silently drops neighbour solicitations, so wait +* for all links to be operationally up (IFF_RUNNING) before sending traffic. +*/ +static int wait_for_oper_up (const char *ns,const char *dev) +{ +struct nstoken *nstoken; +struct ifreq ifr = {}; +int i, fd, ret =-1 ; + + nstoken =open_netns (ns); +if (!ASSERT_OK_PTR (nstoken,"open ns" )) +return -1 ; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (!ASSERT_OK_FD (fd,"socket" )) + goto out; + +strncpy (ifr.ifr_name, dev,IFNAMSIZ -1 ); +for (i =0 ; i <50 ; i++) { +if (!ASSERT_OK (ioctl (fd,SIOCGIFFLAGS , &ifr),"SIOCGIFFLAGS" )) +break ; +if (ifr.ifr_flags &IFF_RUNNING ) { + ret =0 ; +break ; + } +usleep (100000 ); + } +close (fd); +out: +ASSERT_OK (ret, dev); +close_netns (nstoken); +return ret; +} + +static int wait_for_links (const char *ns1,const char *ns2,const char *ns3) +{ +if (wait_for_oper_up (ns1,"veth1" ) ||wait_for_oper_up (ns1,"veth5" ) || +wait_for_oper_up (ns2,"veth2" ) ||wait_for_oper_up (ns2,"veth3" ) || +wait_for_oper_up (ns2,"veth6" ) ||wait_for_oper_up (ns2,"veth7" ) || +wait_for_oper_up (ns3,"veth4" ) ||wait_for_oper_up (ns3,"veth8" )) +return -1 ; +return 0 ; +} +static int configure_vrf (const char *ns1,const char *ns2) {if (!ns1 || !ns2)
@@ -304,6 +354,9 @@ static int setup_network(char *ns1, char *ns2, char *ns3, const char *vrf)if (!ASSERT_OK (configure_ns3 (ns3),"configure ns3 routes" )) goto fail; +if (!ASSERT_OK (wait_for_links (ns1, ns2, ns3),"wait for links" )) + goto fail; +/* Link bottom route to the GRE tunnels */ SYS (fail,"ip -n %s route add %s/32 dev veth5 via %s %s" , ns1,IP4_ADDR_GRE ,IP4_ADDR_6 , vrf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/2151 md/raid10: fix missing wakeup in wait_barrier_nolock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit f00eb0ff45793383d5a62db2d2aea63ada0ccdbd ]
Fuzz testing triggered a hung raid10d thread:
INFO: task md0_raid10 blocked for more than 120 seconds. Call Trace: raid10d md_thread kthread
wait_barrier_nolock() speculatively increments nr_pending. If a concurrent writer changes resync_lock's sequence, it rolls the count back with atomic_dec_and_test(). The rollback currently wakes wait_barrier only when nr_pending reaches zero.
freeze_array() can be waiting for nr_pending == nr_queued + extra while array_freeze_pending is set. If the rollback changes nr_pending from 2 to 1, the condition becomes true but no wakeup is sent, leaving raid10d blocked indefinitely.
Also wake wait_barrier when array_freeze_pending is set, matching allow_barrier().
--- drivers/md/raid10.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid10.c +2 -1
@@ -996,7 +996,8 @@ static bool wait_barrier_nolock(struct r10conf *conf)if (!read_seqretry (&conf->resync_lock, seq))return true; -if (atomic_dec_and_test (&conf->nr_pending)) +if (atomic_dec_and_test (&conf->nr_pending) || +READ_ONCE (conf->array_freeze_pending))wake_up_barrier (conf);return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/2151 md: reject v0.90 arrays with too many devices
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 1a33a379e67853d6d778e6e80b214bdf1208f6f8 ]
The v0.90 superblock has room for MD_SB_DISKS device descriptors, but super_90_load() only rejects nonpositive raid_disks values. A crafted superblock can therefore copy a larger value into mddev->raid_disks. When metadata is next updated, super_90_sync() walks sb->disks[] up to that count and reads and writes beyond the 4 KiB superblock buffer.
A checksum-valid RAID1 member advertising 64 devices can be assembled by mdadm --incremental --run. The first write to the array then produces out-of-bounds writes from super_90_sync() under KASAN.
Reject device counts that cannot be represented by the v0.90 format while loading the superblock.
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -1393,7 +1393,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor goto abort; } -if (sb->raid_disks <=0 ) +if (sb->raid_disks <=0 || sb->raid_disks >MD_SB_DISKS ) goto abort;if (md_csum_fold (calc_sb_csum (sb)) !=md_csum_fold (sb->sb_csum)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/2151 md/raid5: dont BUG() on an inconsistent reshape state from the superblock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 0669c7dbd1d375f279e607a24addc2f1dae2d4f3 ]
raid5_run() branches on mddev->reshape_position. When it is MaxSector -- no reshape in progress -- the else branch asserts that nothing else describes one:
BUG_ON(mddev->level != mddev->new_level); BUG_ON(mddev->layout != mddev->new_layout); BUG_ON(mddev->chunk_sectors != mddev->new_chunk_sectors); BUG_ON(mddev->delta_disks != 0);
Nothing enforces that invariant. Both superblock validators copy the reshape fields straight off disk without cross-checking them against each other: super_1_validate() takes reshape_position, delta_disks, new_level, new_layout and new_chunk from the superblock whenever MD_FEATURE_RESHAPE_ACTIVE is set, and super_90_validate() does the same for minor version 91. A superblock that sets the reshape feature while leaving reshape_position at the MaxSector sentinel therefore reaches the else branch with a non-zero delta_disks, and assembling the array takes the machine down:
kernel BUG at drivers/md/raid5.c:8117!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:raid5_run+0x11a7/0x1670 drivers/md/raid5.c:8117 Call Trace: md_run+0xc2f/0x2510 drivers/md/md.c:6779 do_md_run+0x36/0x660 drivers/md/md.c:6880 array_state_store+0x9c5/0xcf0 drivers/md/md.c:4765 md_attr_store+0x1c5/0x330 drivers/md/md.c:6158 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345
This is reachable by anyone who can present an md superblock, so BUG() is the wrong response. Refuse to start the array instead, the way the reshape_position != MaxSector branch a few lines above already refuses a reshape it cannot resume. Nothing has been allocated at this point -- the journal-and-bitmap check just above returns -EINVAL the same way -- so there is nothing to unwind.
--- drivers/md/raid5.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/md/raid5.c +11 -5
@@ -7955,11 +7955,17 @@ static int raid5_run(struct mddev *mddev) }pr_debug ("md/raid:%s: reshape will continue\n" ,mdname (mddev));/* OK, we should be able to continue; */ - }else { -BUG_ON (mddev->level != mddev->new_level); -BUG_ON (mddev->layout != mddev->new_layout); -BUG_ON (mddev->chunk_sectors != mddev->new_chunk_sectors); -BUG_ON (mddev->delta_disks !=0 ); + }else if (mddev->level != mddev->new_level || + mddev->layout != mddev->new_layout || + mddev->chunk_sectors != mddev->new_chunk_sectors || + mddev->delta_disks !=0 ) { +/* No reshape is in progress, but the array describes one. +* The superblock validators do not cross-check these against +* reshape_position, so this is reachable from disk. +*/ +pr_warn ("md/raid:%s: inconsistent reshape state - aborting.\n" , +mdname (mddev)); +return -EINVAL ; } if (test_bit(MD_HAS_JOURNAL, &mddev->flags) &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/2151 md/raid5: reject raid4/5 arrays with too few disks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Cheng <[email protected]>
[ Upstream commit 0d9bbbb6fafa22659ccd4d7ab94329a43c2632d0 ]
raid4 and raid5 require at least two disks, while raid6 requires at least four disks. setup_conf() only rejects raid6 arrays with fewer than four disks. As a result, an invalid raid4 or raid5 array can be assembled with no data disks and later reach raid5_set_limits().
Reject such arrays before the r5conf is created. This prevents the invalid geometry from reaching queue limit setup, where roundup_pow_of_two() can be called with a zero stripe size.
--- drivers/md/raid5.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/raid5.c +5 -3
@@ -7509,9 +7509,11 @@ static struct r5conf *setup_conf(struct mddev *mddev) mdname(mddev), mddev->new_layout);return ERR_PTR (-EIO ); } -if (mddev->new_level ==6 && mddev->raid_disks <4 ) { -pr_warn ("md/raid:%s: not enough configured devices (%d, minimum 4)\n" , -mdname (mddev), mddev->raid_disks); +if ((mddev->new_level !=6 && mddev->raid_disks <2 ) || + (mddev->new_level ==6 && mddev->raid_disks <4 )) { +pr_warn ("md/raid:%s: not enough configured devices (%d, minimum %d)\n" , +mdname (mddev), mddev->raid_disks, + mddev->new_level ==6 ?4 :2 );return ERR_PTR (-EINVAL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/2151 md/raid5: setup_conf: Fix null-ptr-def in error handling path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit eba5f518701b1c7f2d883504f89c41611bd2de46 ]
For raid5 setup_conf, if an error(eg. bioset_init fails) happens before 'conf->mddev = mddev', following error handling path could trigger a null-ptr-def problem:
free_conf
log_exit
raid5_has_ppl
test_bit(MD_HAS_PPL, &conf->mddev->flags) // conf->mddev is NULL !
Fix it by initializing conf->mddev in advance.
--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
@@ -7529,6 +7529,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)if (conf ==NULL ) goto abort; + conf->mddev = mddev;#if PAGE_SIZE !=DEFAULT_STRIPE_SIZE conf->stripe_size =DEFAULT_STRIPE_SIZE ; conf->stripe_shift =ilog2 (DEFAULT_STRIPE_SIZE ) -9 ;
@@ -7602,7 +7603,6 @@ static struct r5conf *setup_conf(struct mddev *mddev) ret =bioset_init (&conf->bio_split,BIO_POOL_SIZE ,0 ,0 );if (ret) goto abort; - conf->mddev = mddev; ret = -ENOMEM ; conf->stripe_hashtbl =kzalloc (PAGE_SIZE ,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/2151 md/raid5: reject a per-device size smaller than one chunk
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit 370ca0760b18c64592a258bcb057ff0a2531aabf ]
Both raid5_run() and raid5_resize() align the per-device size down to a whole multiple of the chunk size:
mddev->dev_sectors &= ~(chunk_sectors - 1);
Neither checks the result, so a size smaller than one chunk silently becomes zero.
In raid5_run() that is harmless: the array size is derived from the same zero, so the disk just ends up with no capacity.
In raid5_resize() it leaves the array inconsistent -- mddev->dev_sectors becomes zero, while mddev->array_sectors and the gendisk capacity keep the previous. A later raid4/raid5 -> raid0 takeover copies the zero into every rdev->sectors (raid0_takeover_raid45()), so create_strip_zones() builds a strip zone table whose zone_end is zero. Any read then passes bio_check_eod() against the stale capacity and hits the BUG() in find_zone():
kernel BUG at drivers/md/raid0.c:318!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI Call Trace: raid0_make_request md_handle_request submit_bio_noacct_nocheck block_read_full_folio read_part_sector bdev_disk_changed bdev_open
Reject a size smaller than one chunk in both functions, so that a running raid4/raid5 array always has mddev->dev_sectors >= one chunk.
The check is done where the value takes effect, not where it is assigned. mddev->dev_sectors is written from several places, and none of them can tell whether the value is usable: the chunk size may still change later. raid5_run() and raid5_resize() are where every input is final, so one check in each covers them all.
--- drivers/md/raid5.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/md/raid5.c +8 -0
@@ -8056,6 +8056,12 @@ static int raid5_run(struct mddev *mddev)/* device size must be a multiple of chunk size */ mddev->dev_sectors &= ~((sector_t )mddev->chunk_sectors -1 ); +if (!mddev->dev_sectors) { +pr_warn ("md/raid:%s: device size is smaller than one chunk\n" , +mdname (mddev)); + ret = -EINVAL ; + goto abort; + } mddev->resync_max_sectors = mddev->dev_sectors; if (mddev->degraded > dirty_parity_disks &&
@@ -8388,6 +8394,8 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)if (raid5_has_log (conf) ||raid5_has_ppl (conf))return -EINVAL ; sectors &= ~((sector_t )conf->chunk_sectors -1 ); +if (!sectors) +return -EINVAL ; newsize =raid5_size (mddev, sectors, mddev->raid_disks);if (mddev->external_size && mddev->array_sectors > newsize)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/2151 kernfs: dont hold kernfs_rwsem across notification delivery
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 23985e2b1f31623468244a2149b2388cda4925eb ]
Recently at Meta we noticed that on multi-tenant systems, a workload under extreme memory pressure negatively impacts unrelated workloads and system daemons like below [1] and fb-oomd [2]. Mainly we observed that system daemons were stuck on kernfs_rwsem in cgroup-related interfaces for long periods of time.
On further inspection, we found that the workload under pressure had registered inotify watches on its memory.events and was continuously receiving limit-hitting notifications. The cgroup notification is done in kernfs_notify_workfn(), which holds kernfs_supers_rwsem and kernfs_rwsem and calls fsnotify(), which allocates the event with kmalloc(GFP_KERNEL_ACCOUNT|__GFP_RETRY_MAYFAIL) charged to the watching cgroup, which is already under memory pressure. So the notify worker ended up in memory reclaim of a cgroup already under pressure, and itself kept triggering the limit notifications.
This notification path takes the locks in read mode, but a waiting writer blocks all future readers. That is exactly what is happening in the Meta fleet, and it leaves daemons that are critical to the reliability of the system stuck for long periods of time.
Commit 400188ae361a ("kernfs: Acquire kernfs_rwsem in kernfs_notify_workfn().") added kernfs_rwsem just to safely read kernfs_node::name. Let's sample the name once before the loop and drop the lock. kernfs_supers_rwsem still covers the list, and the removal paths take that one for reading too, so a stalled worker can still hold a removal up once a mount or unmount is queued behind it.
Two things change for a watcher. A name longer than NAME_MAX now gives an event with no name, where before it gave one with the full name; fsnotify() takes the name as optional, so the event still arrives. And the name and the parent are no longer sampled under one lock, so a rename between the two would name a file against the directory it moved to. That cannot happen today: kernfs_notify() rejects anything that is not a file, and no caller of kernfs_rename_ns() renames one.
[1] https://github.com/facebookincubator/below
[2] https://github.com/facebookincubator/oomd
--- fs/kernfs/file.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
fs/kernfs/file.c +16 -9
@@ -911,9 +911,12 @@ static loff_t kernfs_fop_llseek(struct file *file, loff_t offset, int whence)static void kernfs_notify_workfn (struct work_struct *work) { -struct kernfs_node *kn; +char name_buf[NAME_MAX +1 ];struct kernfs_super_info *info; +struct kernfs_node *kn;struct kernfs_root *root; +struct qstr name; +bool have_name; repeat:/* pop one off the notify_list */ spin_lock_irq (&kernfs_notify_lock);
@@ -929,14 +932,20 @@ static void kernfs_notify_workfn(struct work_struct *work) root =kernfs_root (kn);/* kick fsnotify */ +/* +* Sample the name once so kernfs_rwsem need not be held across the +* loop. A name that does not fit is reported without one; fsnotify() +* takes the name as optional, so a watcher loses the name and not the +* event. +*/ + have_name =kernfs_name (kn, name_buf,sizeof (name_buf)) >=0 ; + name =QSTR (name_buf); +down_read (&root->kernfs_supers_rwsem); -down_read (&root->kernfs_rwsem); -list_for_each_entry (info, &kernfs_root (kn)->supers, node) { +list_for_each_entry (info, &root->supers, node) {struct kernfs_node *parent;struct inode *p_inode =NULL ; -const char *kn_name;struct inode *inode; -struct qstr name;/* * We want fsnotify_modify() on @kn but as the
@@ -948,15 +957,14 @@ static void kernfs_notify_workfn(struct work_struct *work)if (!inode)continue ; - kn_name =kernfs_rcu_name (kn); - name =QSTR (kn_name); parent =kernfs_get_parent (kn);if (parent) { p_inode =ilookup (info->sb,kernfs_ino (parent));if (p_inode) {fsnotify (FS_MODIFY |FS_EVENT_ON_CHILD , inode,FSNOTIFY_EVENT_INODE , - p_inode, &name, inode,0 ); + p_inode, have_name ? &name :NULL , + inode,0 );iput (p_inode); }
@@ -969,7 +977,6 @@ static void kernfs_notify_workfn(struct work_struct *work)iput (inode); } -up_read (&root->kernfs_rwsem);up_read (&root->kernfs_supers_rwsem);kernfs_put (kn); goto repeat;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/2151 kernfs: pass struct ns_common instead of const void * for namespace tags
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit e3b2cf6e5dba416a03152f299d99982dfe1e861d ]
kernfs has historically used const void * to pass around namespace tags used for directory-level namespace filtering. The only current user of this is sysfs network namespace tagging where struct net pointers are cast to void *.
Replace all const void * namespace parameters with const struct ns_common * throughout the kernfs, sysfs, and kobject namespace layers. This includes the kobj_ns_type_operations callbacks, kobject_namespace(), and all sysfs/kernfs APIs that accept or return namespace tags.
Passing struct ns_common is needed because various codepaths require access to the underlying namespace. A struct ns_common can always be converted back to the concrete namespace type (e.g., struct net) via container_of() or to_ns_common() in the reverse direction.
This is a preparatory change for switching to ns_id-based directory iteration to prevent a KASLR pointer leak through the current use of raw namespace pointers as hash seeds and comparison keys.
Stable-dep-of: 5ebcb578adee ("kernfs: don't repeat or skip an entry when readdir resumes")
--- drivers/base/class.c | 4 +-- drivers/base/core.c | 7 ++-- drivers/infiniband/core/device.c | 5 +-- drivers/infiniband/ulp/srp/ib_srp.c | 7 ++-- drivers/net/bonding/bond_sysfs.c | 4 +-- drivers/net/ipvlan/ipvtap.c | 5 +-- drivers/net/macvtap.c | 5 +-- fs/kernfs/dir.c | 30 +++++++++-------- fs/kernfs/file.c | 2 +- fs/kernfs/kernfs-internal.h | 2 +- fs/kernfs/mount.c | 2 +- fs/nfs/sysfs.c | 16 +++++---- fs/sysfs/dir.c | 6 ++-- fs/sysfs/file.c | 8 ++--- fs/sysfs/mount.c | 10 +++--- fs/sysfs/symlink.c | 7 ++-- fs/sysfs/sysfs.h | 4 +-- include/linux/device/class.h | 6 ++-- include/linux/kernfs.h | 40 ++++++++++++++--------- include/linux/kobject.h | 4 +-- include/linux/kobject_ns.h | 13 ++++---- include/linux/netdevice.h | 4 +-- include/linux/sysfs.h | 24 +++++++------- include/net/net_namespace.h | 8 ++--- lib/kobject.c | 8 ++--- lib/kobject_uevent.c | 13 +++++--- net/core/net-sysfs.c | 50 ++++++++++++++--------------- net/core/net_namespace.c | 8 ++--- net/sunrpc/sysfs.c | 17 ++++++---- net/wireless/sysfs.c | 4 +-- 30 files changed, 175 insertions(+), 148 deletions(-)
drivers/base/class.c +2 -2
@@ -127,7 +127,7 @@ static const struct kobj_type class_ktype = { };int class_create_file_ns (const struct class *cls,const struct class_attribute *attr, -const void *ns) +const struct ns_common *ns) {struct subsys_private *sp =class_to_subsys (cls);int error;
@@ -143,7 +143,7 @@ int class_create_file_ns(const struct class *cls, const struct class_attribute *EXPORT_SYMBOL_GPL (class_create_file_ns);void class_remove_file_ns (const struct class *cls,const struct class_attribute *attr, -const void *ns) +const struct ns_common *ns) {struct subsys_private *sp =class_to_subsys (cls);
drivers/base/core.c +3 -4
@@ -2636,15 +2636,14 @@ static void device_release(struct kobject *kobj)kfree (p); } -static const void *device_namespace (const struct kobject *kobj) +static const struct ns_common *device_namespace (const struct kobject *kobj) {const struct device *dev =kobj_to_dev (kobj); -const void *ns =NULL ;if (dev->class && dev->class->namespace) - ns = dev->class->namespace (dev); +return dev->class->namespace (dev); -return ns; +return NULL ; }static void device_get_ownership (const struct kobject *kobj,kuid_t *uid,kgid_t *gid)
drivers/infiniband/core/device.c +3 -2
@@ -537,12 +537,13 @@ static int ib_device_uevent(const struct device *device,return 0 ; } -static const void *net_namespace (const struct device *d) +static const struct ns_common *net_namespace (const struct device *d) {const struct ib_core_device *coredev = container_of(d, struct ib_core_device, dev); +struct net *net =read_pnet (&coredev->rdma_net); -return read_pnet (&coredev->rdma_net); +return net ?to_ns_common (net) :NULL ; }static struct class ib_class = {
drivers/infiniband/ulp/srp/ib_srp.c +4 -3
@@ -42,6 +42,7 @@#include <linux/jiffies.h> #include <linux/lockdep.h> #include <linux/inet.h> +#include <net/net_namespace.h> #include <rdma/ib_cache.h> #include <linux/atomic.h>
@@ -1047,7 +1048,7 @@ static void srp_remove_target(struct srp_target_port *target)scsi_remove_host (target->scsi_host);srp_stop_rport_timers (target->rport);srp_disconnect_target (target); -kobj_ns_drop (KOBJ_NS_TYPE_NET , target->net); +kobj_ns_drop (KOBJ_NS_TYPE_NET ,to_ns_common (target->net));for (i =0 ; i < target->ch_count; i++) { ch = &target->ch[i];srp_free_ch_ib (target, ch);
@@ -3746,7 +3747,7 @@ static ssize_t add_target_store(struct device *dev, target =host_to_target (target_host); - target->net =kobj_ns_grab_current (KOBJ_NS_TYPE_NET ); + target->net =to_net_ns (kobj_ns_grab_current (KOBJ_NS_TYPE_NET )); target->io_class =SRP_REV16A_IB_IO_CLASS ; target->scsi_host = target_host; target->srp_host = host;
@@ -3939,7 +3940,7 @@ static ssize_t add_target_store(struct device *dev,* earlier in this function. */ if (target->state !=SRP_TARGET_REMOVED ) -kobj_ns_drop (KOBJ_NS_TYPE_NET , target->net); +kobj_ns_drop (KOBJ_NS_TYPE_NET ,to_ns_common (target->net));scsi_host_put (target->scsi_host); }
drivers/net/bonding/bond_sysfs.c +2 -2
@@ -808,7 +808,7 @@ int __net_init bond_create_sysfs(struct bond_net *bn)sysfs_attr_init (&bn->class_attr_bonding_masters.attr); ret =netdev_class_create_file_ns (&bn->class_attr_bonding_masters, - bn->net); +to_ns_common (bn->net));/* Permit multiple loads of the module by ignoring failures to * create the bonding_masters sysfs file. Bonding devices * created by second or subsequent loads of the module will
@@ -835,7 +835,7 @@ int __net_init bond_create_sysfs(struct bond_net *bn)/* Remove /sys/class/net/bonding_masters. */ void __net_exit bond_destroy_sysfs(struct bond_net *bn) { -netdev_class_remove_file_ns (&bn->class_attr_bonding_masters, bn->net); +netdev_class_remove_file_ns (&bn->class_attr_bonding_masters,to_ns_common (bn->net)); }/* Initialize sysfs for each bond. This sets up and registers
drivers/net/ipvlan/ipvtap.c +3 -2
@@ -30,10 +30,11 @@static dev_t ipvtap_major;static struct cdev ipvtap_cdev; -static const void *ipvtap_net_namespace (const struct device *d) +static const struct ns_common *ipvtap_net_namespace (const struct device *d) {const struct net_device *dev =to_net_dev (d->parent); -return dev_net (dev); + +return to_ns_common (dev_net (dev)); }static struct class ipvtap_class = {
drivers/net/macvtap.c +3 -2
@@ -35,10 +35,11 @@ struct macvtap_dev {*/ static dev_t macvtap_major; -static const void *macvtap_net_namespace (const struct device *d) +static const struct ns_common *macvtap_net_namespace (const struct device *d) {const struct net_device *dev =to_net_dev (d->parent); -return dev_net (dev); + +return to_ns_common (dev_net (dev)); }static struct class macvtap_class = {
fs/kernfs/dir.c +17 -13
@@ -313,7 +313,8 @@ struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)* * Return: 31-bit hash of ns + name (so it fits in an off_t) */ -static unsigned int kernfs_name_hash (const char *name,const void *ns) +static unsigned int kernfs_name_hash (const char *name, +const struct ns_common *ns) {unsigned long hash =init_name_hash (ns);unsigned int len =strlen (name);
@@ -330,7 +331,7 @@ static unsigned int kernfs_name_hash(const char *name, const void *ns) }static int kernfs_name_compare (unsigned int hash,const char *name, -const void *ns,const struct kernfs_node *kn) +const struct ns_common *ns,const struct kernfs_node *kn) {if (hash < kn->hash)return -1 ;
@@ -860,7 +861,7 @@ int kernfs_add_one(struct kernfs_node *kn)*/ static struct kernfs_node *kernfs_find_ns (struct kernfs_node *parent,const unsigned char *name, -const void *ns) +const struct ns_common *ns) {struct rb_node *node = parent->dir.children.rb_node;bool has_ns =kernfs_ns_enabled (parent);
@@ -893,7 +894,7 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,static struct kernfs_node *kernfs_walk_ns (struct kernfs_node *parent,const unsigned char *path, -const void *ns) +const struct ns_common *ns) {ssize_t len;char *p, *name;
@@ -934,7 +935,8 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,* Return: pointer to the found kernfs_node on success, %NULL on failure. */ struct kernfs_node *kernfs_find_and_get_ns (struct kernfs_node *parent, -const char *name,const void *ns) +const char *name, +const struct ns_common *ns) {struct kernfs_node *kn;struct kernfs_root *root =kernfs_root (parent);
@@ -960,7 +962,8 @@ EXPORT_SYMBOL_GPL(kernfs_find_and_get_ns);* Return: pointer to the found kernfs_node on success, %NULL on failure. */ struct kernfs_node *kernfs_walk_and_get_ns (struct kernfs_node *parent, -const char *path,const void *ns) +const char *path, +const struct ns_common *ns) {struct kernfs_node *kn;struct kernfs_root *root =kernfs_root (parent);
@@ -1083,7 +1086,8 @@ struct kernfs_node *kernfs_root_to_node(struct kernfs_root *root)struct kernfs_node *kernfs_create_dir_ns (struct kernfs_node *parent,const char *name,umode_t mode,kuid_t uid,kgid_t gid, -void *priv,const void *ns) +void *priv, +const struct ns_common *ns) {struct kernfs_node *kn;int rc;
@@ -1225,7 +1229,7 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,struct kernfs_node *kn;struct kernfs_root *root;struct inode *inode =NULL ; -const void *ns =NULL ; +const struct ns_common *ns =NULL ; root =kernfs_root (parent);down_read (&root->kernfs_rwsem);
@@ -1706,7 +1710,7 @@ bool kernfs_remove_self(struct kernfs_node *kn)* Return: %0 on success, -ENOENT if such entry doesn't exist. */ int kernfs_remove_by_name_ns (struct kernfs_node *parent,const char *name, -const void *ns) +const struct ns_common *ns) {struct kernfs_node *kn;struct kernfs_root *root;
@@ -1745,7 +1749,7 @@ int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,* Return: %0 on success, -errno on failure. */ int kernfs_rename_ns (struct kernfs_node *kn,struct kernfs_node *new_parent, -const char *new_name,const void *new_ns) +const char *new_name,const struct ns_common *new_ns) {struct kernfs_node *old_parent;struct kernfs_root *root;
@@ -1836,7 +1840,7 @@ static int kernfs_dir_fop_release(struct inode *inode, struct file *filp)return 0 ; } -static struct kernfs_node *kernfs_dir_pos (const void *ns, +static struct kernfs_node *kernfs_dir_pos (const struct ns_common *ns,struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos) {if (pos) {
@@ -1871,7 +1875,7 @@ static struct kernfs_node *kernfs_dir_pos(const void *ns,return pos; } -static struct kernfs_node *kernfs_dir_next_pos (const void *ns, +static struct kernfs_node *kernfs_dir_next_pos (const struct ns_common *ns,struct kernfs_node *parent,ino_t ino,struct kernfs_node *pos) { pos =kernfs_dir_pos (ns, parent, ino, pos);
@@ -1893,7 +1897,7 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)struct kernfs_node *parent =kernfs_dentry_node (dentry);struct kernfs_node *pos = file->private_data;struct kernfs_root *root; -const void *ns =NULL ; +const struct ns_common *ns =NULL ;if (!dir_emit_dots (file, ctx))return 0 ;
fs/kernfs/file.c +1 -1
@@ -1052,7 +1052,7 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent, umode_t mode, kuid_t uid, kgid_t gid, loff_t size, const struct kernfs_ops *ops, - void *priv, const void *ns, + void *priv, const struct ns_common *ns, struct lock_class_key *key) { struct kernfs_node *kn;
fs/kernfs/kernfs-internal.h +1 -1
@@ -97,7 +97,7 @@ struct kernfs_super_info {* instance. If multiple tags become necessary, make the following * an array and compare kernfs_node tag against every entry. */ -const void *ns; +const struct ns_common *ns;/* anchored at kernfs_root->supers, protected by kernfs_rwsem */ struct list_head node;
fs/kernfs/mount.c +1 -1
@@ -344,7 +344,7 @@ static int kernfs_set_super(struct super_block *sb, struct fs_context *fc)* * Return: the namespace tag associated with kernfs super_block @sb. */ -const void *kernfs_super_ns (struct super_block *sb) +const struct ns_common *kernfs_super_ns (struct super_block *sb) {struct kernfs_super_info *info =kernfs_info (sb);
fs/nfs/sysfs.c +10 -6
@@ -11,6 +11,7 @@#include <linux/netdevice.h> #include <linux/string.h> #include <linux/nfs_fs.h> +#include <net/net_namespace.h> #include <linux/rcupdate.h> #include <linux/lockd/lockd.h>
@@ -127,9 +128,10 @@ static void nfs_netns_client_release(struct kobject *kobj)kfree (rcu_dereference_raw (c->identifier)); } -static const void *nfs_netns_client_namespace (const struct kobject *kobj) +static const struct ns_common *nfs_netns_client_namespace (const struct kobject *kobj) { - return container_of(kobj, struct nfs_netns_client, kobject)->net; + return to_ns_common(container_of(kobj, struct nfs_netns_client, + kobject)->net); } static struct kobj_attribute nfs_netns_client_id = __ATTR(identifier,
@@ -156,9 +158,10 @@ static void nfs_netns_object_release(struct kobject *kobj)kfree (c); } -static const void *nfs_netns_namespace (const struct kobject *kobj) +static const struct ns_common *nfs_netns_namespace (const struct kobject *kobj) { - return container_of(kobj, struct nfs_netns_client, nfs_net_kobj)->net; + return to_ns_common(container_of(kobj, struct nfs_netns_client, + nfs_net_kobj)->net); }static struct kobj_type nfs_netns_object_type = {
@@ -350,9 +353,10 @@ static void nfs_sysfs_sb_release(struct kobject *kobj)/* no-op: why? see lib/kobject.c kobject_cleanup() */ } -static const void *nfs_netns_server_namespace (const struct kobject *kobj) +static const struct ns_common *nfs_netns_server_namespace (const struct kobject *kobj) { - return container_of(kobj, struct nfs_server, kobj)->nfs_client->cl_net; + return to_ns_common(container_of(kobj, struct nfs_server, + kobj)->nfs_client->cl_net); }static struct kobj_type nfs_sb_ktype = {
fs/sysfs/dir.c +3 -3
@@ -37,7 +37,7 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)* @kobj: object we're creating directory for * @ns: the namespace tag to use */ -int sysfs_create_dir_ns (struct kobject *kobj,const void *ns) +int sysfs_create_dir_ns (struct kobject *kobj,const struct ns_common *ns) {struct kernfs_node *parent, *kn;kuid_t uid;
@@ -103,7 +103,7 @@ void sysfs_remove_dir(struct kobject *kobj) }int sysfs_rename_dir_ns (struct kobject *kobj,const char *new_name, -const void *new_ns) +const struct ns_common *new_ns) {struct kernfs_node *parent;int ret;
@@ -115,7 +115,7 @@ int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, }int sysfs_move_dir_ns (struct kobject *kobj,struct kobject *new_parent_kobj, -const void *new_ns) +const struct ns_common *new_ns) {struct kernfs_node *kn = kobj->sd;struct kernfs_node *new_parent;
fs/sysfs/file.c +4 -4
@@ -276,7 +276,7 @@ static const struct kernfs_ops sysfs_bin_kfops_mmap = {int sysfs_add_file_mode_ns (struct kernfs_node *parent,const struct attribute *attr,umode_t mode,kuid_t uid, -kgid_t gid,const void *ns) +kgid_t gid,const struct ns_common *ns) {struct kobject *kobj = parent->priv;const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops;
@@ -326,7 +326,7 @@ int sysfs_add_file_mode_ns(struct kernfs_node *parent,int sysfs_add_bin_file_mode_ns (struct kernfs_node *parent,const struct bin_attribute *battr,umode_t mode,size_t size, -kuid_t uid,kgid_t gid,const void *ns) +kuid_t uid,kgid_t gid,const struct ns_common *ns) {const struct attribute *attr = &battr->attr;struct lock_class_key *key =NULL ;
@@ -366,7 +366,7 @@ int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,* @ns: namespace the new file should belong to */ int sysfs_create_file_ns (struct kobject *kobj,const struct attribute *attr, -const void *ns) +const struct ns_common *ns) {kuid_t uid;kgid_t gid;
@@ -509,7 +509,7 @@ EXPORT_SYMBOL_GPL(sysfs_unbreak_active_protection);* Hash the attribute name and namespace tag and kill the victim. */ void sysfs_remove_file_ns (struct kobject *kobj,const struct attribute *attr, -const void *ns) +const struct ns_common *ns) {struct kernfs_node *parent = kobj->sd;
fs/sysfs/mount.c +6 -4
@@ -55,7 +55,7 @@ static const struct fs_context_operations sysfs_fs_context_ops = {static int sysfs_init_fs_context (struct fs_context *fc) {struct kernfs_fs_context *kfc; -struct net *netns; +struct ns_common *ns;if (!(fc->sb_flags &SB_KERNMOUNT )) {if (!kobj_ns_current_may_mount (KOBJ_NS_TYPE_NET ))
@@ -66,12 +66,14 @@ static int sysfs_init_fs_context(struct fs_context *fc)if (!kfc)return -ENOMEM ; - kfc->ns_tag = netns =kobj_ns_grab_current (KOBJ_NS_TYPE_NET ); + kfc->ns_tag = ns =kobj_ns_grab_current (KOBJ_NS_TYPE_NET ); kfc->root = sysfs_root; kfc->magic =SYSFS_MAGIC ; fc->fs_private = kfc; fc->ops = &sysfs_fs_context_ops; -if (netns) { +if (ns) { +struct net *netns =to_net_ns (ns); +put_user_ns (fc->user_ns); fc->user_ns =get_user_ns (netns->user_ns); }
@@ -81,7 +83,7 @@ static int sysfs_init_fs_context(struct fs_context *fc)static void sysfs_kill_sb (struct super_block *sb) { -void *ns = (void *)kernfs_super_ns (sb); +struct ns_common *ns = (struct ns_common *)kernfs_super_ns (sb);kernfs_kill_sb (sb);kobj_ns_drop (KOBJ_NS_TYPE_NET , ns);
fs/sysfs/symlink.c +4 -3
@@ -121,7 +121,7 @@ EXPORT_SYMBOL_GPL(sysfs_create_link_nowarn);void sysfs_delete_link (struct kobject *kobj,struct kobject *targ,const char *name) { -const void *ns =NULL ; +const struct ns_common *ns =NULL ;/* * We don't own @target and it may be removed at any time.
@@ -164,10 +164,11 @@ EXPORT_SYMBOL_GPL(sysfs_remove_link);* A helper function for the common rename symlink idiom. */ int sysfs_rename_link_ns (struct kobject *kobj,struct kobject *targ, -const char *old,const char *new,const void *new_ns) +const char *old,const char *new, +const struct ns_common *new_ns) {struct kernfs_node *parent, *kn =NULL ; -const void *old_ns =NULL ; +const struct ns_common *old_ns =NULL ;int result;if (!kobj)
fs/sysfs/sysfs.h +2 -2
@@ -29,10 +29,10 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name);*/ int sysfs_add_file_mode_ns (struct kernfs_node *parent,const struct attribute *attr,umode_t amode,kuid_t uid, -kgid_t gid,const void *ns); +kgid_t gid,const struct ns_common *ns);int sysfs_add_bin_file_mode_ns (struct kernfs_node *parent,const struct bin_attribute *battr,umode_t mode,size_t size, -kuid_t uid,kgid_t gid,const void *ns); +kuid_t uid,kgid_t gid,const struct ns_common *ns);/* * symlink.c
include/linux/device/class.h +3 -3
@@ -62,7 +62,7 @@ struct class {int (*shutdown_pre)(struct device *dev);const struct kobj_ns_type_operations *ns_type; -const void *(*namespace)(const struct device *dev); +const struct ns_common *(*namespace)(const struct device *dev);void (*get_ownership)(const struct device *dev,kuid_t *uid,kgid_t *gid);
@@ -180,9 +180,9 @@ struct class_attribute { struct class_attribute class_attr_##_name = __ATTR_WO(_name)int __must_check class_create_file_ns (const struct class *class,const struct class_attribute *attr, -const void *ns); +const struct ns_common *ns);void class_remove_file_ns (const struct class *class,const struct class_attribute *attr, -const void *ns); +const struct ns_common *ns);static inline int __must_check class_create_file (const struct class *class,const struct class_attribute *attr)
include/linux/kernfs.h +24 -16
@@ -23,6 +23,7 @@struct file ;struct dentry ;struct iattr ; +struct ns_common ;struct seq_file ;struct vm_area_struct ;struct vm_operations_struct ;
@@ -209,7 +210,7 @@ struct kernfs_node {struct rb_node rb; -const void *ns;/* namespace tag */ +const struct ns_common *ns;/* namespace tag */ unsigned int hash;/* ns + name hash */ unsigned short flags;umode_t mode;
@@ -331,7 +332,7 @@ struct kernfs_ops {*/ struct kernfs_fs_context {struct kernfs_root *root;/* Root of the hierarchy being mounted */ -void *ns_tag;/* Namespace tag of the mount (or NULL) */ +struct ns_common *ns_tag;/* Namespace tag of the mount (or NULL) */ unsigned long magic;/* File system specific magic number */ /* The following are set/used by kernfs_mount() */
@@ -406,9 +407,11 @@ void pr_cont_kernfs_name(struct kernfs_node *kn);void pr_cont_kernfs_path (struct kernfs_node *kn);struct kernfs_node *kernfs_get_parent (struct kernfs_node *kn);struct kernfs_node *kernfs_find_and_get_ns (struct kernfs_node *parent, -const char *name,const void *ns); +const char *name, +const struct ns_common *ns);struct kernfs_node *kernfs_walk_and_get_ns (struct kernfs_node *parent, -const char *path,const void *ns); +const char *path, +const struct ns_common *ns);void kernfs_get (struct kernfs_node *kn);void kernfs_put (struct kernfs_node *kn);
@@ -426,7 +429,8 @@ unsigned int kernfs_root_flags(struct kernfs_node *kn);struct kernfs_node *kernfs_create_dir_ns (struct kernfs_node *parent,const char *name,umode_t mode,kuid_t uid,kgid_t gid, -void *priv,const void *ns); +void *priv, +const struct ns_common *ns);struct kernfs_node *kernfs_create_empty_dir (struct kernfs_node *parent,const char *name); struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
@@ -434,7 +438,8 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent, kuid_t uid, kgid_t gid, loff_t size, const struct kernfs_ops *ops, - void *priv, const void *ns, + void *priv, + const struct ns_common *ns, struct lock_class_key *key); struct kernfs_node *kernfs_create_link(struct kernfs_node *parent, const char *name,
@@ -446,9 +451,9 @@ void kernfs_break_active_protection(struct kernfs_node *kn);void kernfs_unbreak_active_protection (struct kernfs_node *kn);bool kernfs_remove_self (struct kernfs_node *kn);int kernfs_remove_by_name_ns (struct kernfs_node *parent,const char *name, -const void *ns); +const struct ns_common *ns);int kernfs_rename_ns (struct kernfs_node *kn,struct kernfs_node *new_parent, -const char *new_name,const void *new_ns); +const char *new_name,const struct ns_common *new_ns);int kernfs_setattr (struct kernfs_node *kn,const struct iattr *iattr);__poll_t kernfs_generic_poll (struct kernfs_open_file *of,struct poll_table_struct *pt);
@@ -459,7 +464,7 @@ int kernfs_xattr_get(struct kernfs_node *kn, const char *name,int kernfs_xattr_set (struct kernfs_node *kn,const char *name,const void *value,size_t size,int flags); -const void *kernfs_super_ns (struct super_block *sb); +const struct ns_common *kernfs_super_ns (struct super_block *sb);int kernfs_get_tree (struct fs_context *fc);void kernfs_free_fs_context (struct fs_context *fc);void kernfs_kill_sb (struct super_block *sb);
@@ -494,11 +499,11 @@ static inline struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)static inline struct kernfs_node *kernfs_find_and_get_ns (struct kernfs_node *parent,const char *name, -const void *ns) +const struct ns_common *ns) {return NULL ; }static inline struct kernfs_node *kernfs_walk_and_get_ns (struct kernfs_node *parent,const char *path, -const void *ns) +const struct ns_common *ns) {return NULL ; }static inline void kernfs_get (struct kernfs_node *kn) { }
@@ -526,14 +531,15 @@ static inline unsigned int kernfs_root_flags(struct kernfs_node *kn)static inline struct kernfs_node *kernfs_create_dir_ns (struct kernfs_node *parent,const char *name,umode_t mode,kuid_t uid,kgid_t gid, -void *priv,const void *ns) +void *priv,const struct ns_common *ns) {return ERR_PTR (-ENOSYS ); }static inline struct kernfs_node *__kernfs_create_file (struct kernfs_node *parent,const char *name,umode_t mode,kuid_t uid,kgid_t gid,loff_t size,const struct kernfs_ops *ops, -void *priv,const void *ns,struct lock_class_key *key) +void *priv,const struct ns_common *ns, +struct lock_class_key *key) {return ERR_PTR (-ENOSYS ); } static inline struct kernfs_node *
@@ -549,12 +555,14 @@ static inline bool kernfs_remove_self(struct kernfs_node *kn) {return false; }static inline int kernfs_remove_by_name_ns (struct kernfs_node *kn, -const char *name,const void *ns) +const char *name, +const struct ns_common *ns) {return -ENOSYS ; }static inline int kernfs_rename_ns (struct kernfs_node *kn,struct kernfs_node *new_parent, -const char *new_name,const void *new_ns) +const char *new_name, +const struct ns_common *new_ns) {return -ENOSYS ; } static inline int kernfs_setattr(struct kernfs_node *kn,
@@ -575,7 +583,7 @@ static inline int kernfs_xattr_set(struct kernfs_node *kn, const char *name, const void *value, size_t size, int flags) { return -ENOSYS; } -static inline const void *kernfs_super_ns (struct super_block *sb) +static inline const struct ns_common *kernfs_super_ns (struct super_block *sb) {return NULL ; }static inline int kernfs_get_tree (struct fs_context *fc)
include/linux/kobject.h +2 -2
@@ -109,7 +109,7 @@ struct kobject *kobject_get(struct kobject *kobj);struct kobject *__must_check kobject_get_unless_zero (struct kobject *kobj);void kobject_put (struct kobject *kobj); -const void *kobject_namespace (const struct kobject *kobj); +const struct ns_common *kobject_namespace (const struct kobject *kobj);void kobject_get_ownership (const struct kobject *kobj,kuid_t *uid,kgid_t *gid);char *kobject_get_path (const struct kobject *kobj,gfp_t flag);
@@ -118,7 +118,7 @@ struct kobj_type {const struct sysfs_ops *sysfs_ops;const struct attribute_group **default_groups;const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobject *kobj); -const void *(*namespace)(const struct kobject *kobj); +const struct ns_common *(*namespace)(const struct kobject *kobj);void (*get_ownership)(const struct kobject *kobj,kuid_t *uid,kgid_t *gid); };
include/linux/kobject_ns.h +7 -6
@@ -16,6 +16,7 @@#ifndef _LINUX_KOBJECT_NS_H#define _LINUX_KOBJECT_NS_H +struct ns_common ;struct sock ;struct kobject ;
@@ -39,10 +40,10 @@ enum kobj_ns_type {struct kobj_ns_type_operations {enum kobj_ns_type type;bool (*current_may_mount)(void ); -void *(*grab_current_ns)(void ); -const void *(*netlink_ns)(struct sock *sk); -const void *(*initial_ns)(void ); -void (*drop_ns)(void *); +struct ns_common *(*grab_current_ns)(void ); +const struct ns_common *(*netlink_ns)(struct sock *sk); +const struct ns_common *(*initial_ns)(void ); +void (*drop_ns)(struct ns_common *); };int kobj_ns_type_register (const struct kobj_ns_type_operations *ops);
@@ -51,7 +52,7 @@ const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *paconst struct kobj_ns_type_operations *kobj_ns_ops (const struct kobject *kobj);bool kobj_ns_current_may_mount (enum kobj_ns_type type); -void *kobj_ns_grab_current (enum kobj_ns_type type); -void kobj_ns_drop (enum kobj_ns_type type,void *ns); +struct ns_common *kobj_ns_grab_current (enum kobj_ns_type type); +void kobj_ns_drop (enum kobj_ns_type type,struct ns_common *ns);#endif /* _LINUX_KOBJECT_NS_H */
include/linux/netdevice.h +2 -2
@@ -5319,9 +5319,9 @@ static inline netdev_tx_t netdev_start_xmit(struct sk_buff *skb, struct net_devi }int netdev_class_create_file_ns (const struct class_attribute *class_attr, -const void *ns); +const struct ns_common *ns);void netdev_class_remove_file_ns (const struct class_attribute *class_attr, -const void *ns); +const struct ns_common *ns);extern const struct kobj_ns_type_operations net_ns_type_operations;
include/linux/sysfs.h +12 -12
@@ -386,13 +386,13 @@ struct sysfs_ops {#ifdef CONFIG_SYSFS -int __must_check sysfs_create_dir_ns (struct kobject *kobj,const void *ns); +int __must_check sysfs_create_dir_ns (struct kobject *kobj,const struct ns_common *ns);void sysfs_remove_dir (struct kobject *kobj);int __must_check sysfs_rename_dir_ns (struct kobject *kobj,const char *new_name, -const void *new_ns); +const struct ns_common *new_ns);int __must_check sysfs_move_dir_ns (struct kobject *kobj,struct kobject *new_parent_kobj, -const void *new_ns); +const struct ns_common *new_ns);int __must_check sysfs_create_mount_point (struct kobject *parent_kobj,const char *name); void sysfs_remove_mount_point(struct kobject *parent_kobj,
@@ -400,7 +400,7 @@ void sysfs_remove_mount_point(struct kobject *parent_kobj,int __must_check sysfs_create_file_ns (struct kobject *kobj,const struct attribute *attr, -const void *ns); +const struct ns_common *ns);int __must_check sysfs_create_files (struct kobject *kobj,const struct attribute *const *attr); int __must_check sysfs_chmod_file(struct kobject *kobj,
@@ -409,7 +409,7 @@ struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj, const struct attribute *attr);void sysfs_unbreak_active_protection (struct kernfs_node *kn);void sysfs_remove_file_ns (struct kobject *kobj,const struct attribute *attr, -const void *ns); +const struct ns_common *ns);bool sysfs_remove_file_self (struct kobject *kobj,const struct attribute *attr);void sysfs_remove_files (struct kobject *kobj,const struct attribute *const *attr);
@@ -427,7 +427,7 @@ void sysfs_remove_link(struct kobject *kobj, const char *name);int sysfs_rename_link_ns (struct kobject *kobj,struct kobject *target,const char *old_name,const char *new_name, -const void *new_ns); +const struct ns_common *new_ns);void sysfs_delete_link (struct kobject *dir,struct kobject *targ,const char *name);
@@ -492,7 +492,7 @@ ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj,#else /* CONFIG_SYSFS */ -static inline int sysfs_create_dir_ns (struct kobject *kobj,const void *ns) +static inline int sysfs_create_dir_ns (struct kobject *kobj,const struct ns_common *ns) {return 0 ; }
@@ -502,14 +502,14 @@ static inline void sysfs_remove_dir(struct kobject *kobj) }static inline int sysfs_rename_dir_ns (struct kobject *kobj, -const char *new_name,const void *new_ns) +const char *new_name,const struct ns_common *new_ns) {return 0 ; }static inline int sysfs_move_dir_ns (struct kobject *kobj,struct kobject *new_parent_kobj, -const void *new_ns) +const struct ns_common *new_ns) {return 0 ; }
@@ -527,7 +527,7 @@ static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,static inline int sysfs_create_file_ns (struct kobject *kobj,const struct attribute *attr, -const void *ns) +const struct ns_common *ns) {return 0 ; }
@@ -557,7 +557,7 @@ static inline void sysfs_unbreak_active_protection(struct kernfs_node *kn)static inline void sysfs_remove_file_ns (struct kobject *kobj,const struct attribute *attr, -const void *ns) +const struct ns_common *ns) { }
@@ -602,7 +602,7 @@ static inline void sysfs_remove_link(struct kobject *kobj, const char *name)static inline int sysfs_rename_link_ns (struct kobject *k,struct kobject *t,const char *old_name, -const char *new_name,const void *ns) +const char *new_name,const struct ns_common *ns) {return 0 ; }
include/net/net_namespace.h +4 -4
@@ -259,14 +259,14 @@ void ipx_unregister_sysctl(void);#define ipx_unregister_sysctl ()#endif -#ifdef CONFIG_NET_NS -void __put_net (struct net *net); -static inline struct net *to_net_ns (struct ns_common *ns) { return container_of(ns, struct net, ns); } +#ifdef CONFIG_NET_NS +void __put_net (struct net *net); +/* Try using get_net_track() instead */ static inline struct net *get_net (struct net *net) {
@@ -304,7 +304,7 @@ static inline int check_net(const struct net *net) return ns_ref_read(net) != 0; } -void net_drop_ns (void *); +void net_drop_ns (struct ns_common *);void net_passive_dec (struct net *net);#else
lib/kobject.c +4 -4
@@ -27,7 +27,7 @@* and thus @kobj should have a namespace tag associated with it. Returns * %NULL otherwise. */ -const void *kobject_namespace (const struct kobject *kobj) +const struct ns_common *kobject_namespace (const struct kobject *kobj) {const struct kobj_ns_type_operations *ns_ops =kobj_ns_ops (kobj);
@@ -1083,9 +1083,9 @@ bool kobj_ns_current_may_mount(enum kobj_ns_type type)return may_mount; } -void *kobj_ns_grab_current (enum kobj_ns_type type) +struct ns_common *kobj_ns_grab_current (enum kobj_ns_type type) { -void *ns =NULL ; +struct ns_common *ns =NULL ;spin_lock (&kobj_ns_type_lock);if (kobj_ns_type_is_valid (type) && kobj_ns_ops_tbl[type])
@@ -1096,7 +1096,7 @@ void *kobj_ns_grab_current(enum kobj_ns_type type) }EXPORT_SYMBOL_GPL (kobj_ns_grab_current); -void kobj_ns_drop (enum kobj_ns_type type,void *ns) +void kobj_ns_drop (enum kobj_ns_type type,struct ns_common *ns) {spin_lock (&kobj_ns_type_lock); if (kobj_ns_type_is_valid(type) &&
lib/kobject_uevent.c +8 -5
@@ -238,7 +238,7 @@ static int kobj_usermode_filter(struct kobject *kobj) ops =kobj_ns_ops (kobj);if (ops) { -const void *init_ns, *ns; +const struct ns_common *init_ns, *ns; ns = kobj->ktype->namespace (kobj); init_ns = ops->initial_ns ();
@@ -388,7 +388,7 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,#ifdef CONFIG_NET const struct kobj_ns_type_operations *ops; -const struct net *net =NULL ; +const struct ns_common *ns =NULL ; ops =kobj_ns_ops (kobj);if (!ops && kobj->kset) {
@@ -404,14 +404,17 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,*/ if (ops && ops->netlink_ns && kobj->ktype->namespace)if (ops->type ==KOBJ_NS_TYPE_NET ) - net = kobj->ktype->namespace (kobj); + ns = kobj->ktype->namespace (kobj); -if (!net) +if (!ns) ret =uevent_net_broadcast_untagged (env, action_string, devpath); -else +else { + const struct net *net = container_of(ns, struct net, ns); + ret =uevent_net_broadcast_tagged (net->uevent_sock->sk, env, action_string, devpath); + }#endif return ret;
net/core/net-sysfs.c +25 -25
122 lines not on this page · raw message
net/core/net_namespace.c +3 -5
@@ -538,12 +538,10 @@ void net_passive_dec(struct net *net) } } -void net_drop_ns (void *p) +void net_drop_ns (struct ns_common *ns) { -struct net *net = (struct net *)p; - -if (net) -net_passive_dec (net); +if (ns) +net_passive_dec (to_net_ns (ns)); } struct net *copy_net_ns(u64 flags,
net/sunrpc/sysfs.c +10 -7
@@ -6,6 +6,7 @@#include <linux/kobject.h> #include <linux/sunrpc/addr.h> #include <linux/sunrpc/xprtsock.h> +#include <net/net_namespace.h> #include "sysfs.h"
@@ -553,20 +554,22 @@ static void rpc_sysfs_xprt_release(struct kobject *kobj)kfree (xprt); } -static const void *rpc_sysfs_client_namespace (const struct kobject *kobj) +static const struct ns_common *rpc_sysfs_client_namespace (const struct kobject *kobj) { - return container_of(kobj, struct rpc_sysfs_client, kobject)->net; + return to_ns_common(container_of(kobj, struct rpc_sysfs_client, + kobject)->net); } -static const void *rpc_sysfs_xprt_switch_namespace (const struct kobject *kobj) +static const struct ns_common *rpc_sysfs_xprt_switch_namespace (const struct kobject *kobj) { - return container_of(kobj, struct rpc_sysfs_xprt_switch, kobject)->net; + return to_ns_common(container_of(kobj, struct rpc_sysfs_xprt_switch, + kobject)->net); } -static const void *rpc_sysfs_xprt_namespace (const struct kobject *kobj) +static const struct ns_common *rpc_sysfs_xprt_namespace (const struct kobject *kobj) { - return container_of(kobj, struct rpc_sysfs_xprt, - kobject)->xprt->xprt_net; + return to_ns_common(container_of(kobj, struct rpc_sysfs_xprt, + kobject)->xprt->xprt_net); } static struct kobj_attribute rpc_sysfs_clnt_version = __ATTR(rpc_version,
net/wireless/sysfs.c +2 -2
@@ -154,11 +154,11 @@ static SIMPLE_DEV_PM_OPS(wiphy_pm_ops, wiphy_suspend, wiphy_resume);#define WIPHY_PM_OPS NULL#endif -static const void *wiphy_namespace (const struct device *d) +static const struct ns_common *wiphy_namespace (const struct device *d) { struct wiphy *wiphy = container_of(d, struct wiphy, dev); -return wiphy_net (wiphy); +return to_ns_common (wiphy_net (wiphy)); }struct class ieee80211_class = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/2151 kernfs: make directory seek namespace-aware
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit cb76a81c7cec37bdf525164561b02665cd763421 ]
The rbtree backing kernfs directories is ordered by (hash, ns_id, name) but kernfs_dir_pos() only searches by hash when seeking to a position during readdir. When two nodes from different namespaces share the same hash value, the binary search can land on a node in the wrong namespace. The subsequent skip-forward loop walks rb_next() and may overshoot the correct node, silently dropping an entry from the readdir results.
With the recent switch from raw namespace pointers to public namespace ids as hash seeds, computing hash collisions became an offline operation. An unprivileged user could unshare into a new network namespace, create a single interface whose name-hash collides with a target entry in init_net, and cause a victim's seekdir/readdir on /sys/class/net to miss that entry.
Fix this by extending the rbtree search in kernfs_dir_pos() to also compare namespace ids when hashes match. Since the rbtree is already ordered by (hash, ns_id, name), this makes the seek land directly in the correct namespace's range, eliminating the wrong-namespace overshoot.
Stable-dep-of: 5ebcb578adee ("kernfs: don't repeat or skip an entry when readdir resumes")
--- fs/kernfs/dir.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/kernfs/dir.c +5 -0
@@ -1853,6 +1853,7 @@ static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns, }if (!pos && (hash >1 ) && (hash <INT_MAX )) {struct rb_node *node = parent->dir.children.rb_node; +u64 ns_id =kernfs_ns_id (ns);while (node) { pos =rb_to_kn (node);
@@ -1860,6 +1861,10 @@ static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns, node = node->rb_left; else if (hash > pos->hash) node = node->rb_right; + else if (ns_id < kernfs_ns_id(pos->ns)) + node = node->rb_left; + else if (ns_id > kernfs_ns_id(pos->ns)) + node = node->rb_right; else break; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/2151 kernfs: dont repeat or skip an entry when readdir resumes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 5ebcb578adeec7407dd501108ab2f423ca8e3e55 ]
readdir keeps its place as a name hash in ctx->pos and pins the entry in file->private_data. If that entry is gone when the listing comes back, kernfs_dir_pos() searches the rbtree for the hash and keeps whatever node the descent stopped on. That is the entry before or after the missing one, depending on the shape of the tree.
Landing before it repeats an entry the previous getdents(2) call already reported. Landing after it, kernfs_dir_next_pos() calls rb_next() and steps over an unreported entry.
With children A(10), B(20), C(30):
report A, ctx->pos = 10
A removed
kernfs_dir_next_pos(10, A)
A is gone, the search for 10 stops at B
rb_next(B) -> C, so B is never reported
Only the repeat happens today, between two getdents(2) calls. The skip needs the pinned entry to go away inside one call, which the next patch allows when it drops kernfs_rwsem around dir_emit().
Before the commit 4e4d6d860b93 the descent kept a node only on the way left, which is a search for the first entry at or after the hash. That commit moved the assignment to the top of the loop, where it runs on right turns too. Restore that search, and step forward only when the pinned entry is still there rather than when the hash matches, since two entries in one directory can share a hash.
While here, kernfs_dir_next_pos() called the hash @ino. It is never an inode number, so name it @hash.
--- fs/kernfs/dir.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-)
fs/kernfs/dir.c +28 -15
@@ -1840,9 +1840,16 @@ static int kernfs_dir_fop_release(struct inode *inode, struct file *filp)return 0 ; } +/* +* Find where a listing left off. @resumed says whether @pos is still that +* entry; if not, the first entry at or after @hash is returned instead. +*/ static struct kernfs_node *kernfs_dir_pos (const struct ns_common *ns, -struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos) +struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos, +bool *resumed) { +if (resumed) + *resumed = false;if (pos) {int valid =kernfs_active (pos) && rcu_access_pointer(pos->__parent) == parent &&
@@ -1850,23 +1857,26 @@ static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns,kernfs_put (pos);if (!valid) pos =NULL ; +else if (resumed) + *resumed = true; }if (!pos && (hash >1 ) && (hash <INT_MAX )) {struct rb_node *node = parent->dir.children.rb_node; -u64 ns_id =kernfs_ns_id (ns); + +/* +* Keep a node only on the way left, so the search ends on the +* first entry at or after @hash. The empty name sorts before +* every entry sharing the hash, so it lands on the first. +*/ while (node) { - pos =rb_to_kn (node); +struct kernfs_node *kn =rb_to_kn (node); -if (hash < pos->hash) +if (kernfs_name_compare (hash,"" , ns, kn) <0 ) { + pos = kn; node = node->rb_left; -else if (hash > pos->hash) + }else { node = node->rb_right; -else if (ns_id <kernfs_ns_id (pos->ns)) - node = node->rb_left; -else if (ns_id >kernfs_ns_id (pos->ns)) - node = node->rb_right; -else -break ; + } } }/* Skip over entries which are dying/dead or in the wrong namespace */
@@ -1881,10 +1891,13 @@ static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns, }static struct kernfs_node *kernfs_dir_next_pos (const struct ns_common *ns, -struct kernfs_node *parent,ino_t ino,struct kernfs_node *pos) +struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos) { - pos =kernfs_dir_pos (ns, parent, ino, pos); -if (pos) { +bool resumed; + + pos =kernfs_dir_pos (ns, parent, hash, pos, &resumed); +/* Step over @pos only if it survived; two entries can share a hash. */ +if (pos && resumed) { do { struct rb_node *node = rb_next(&pos->rb); if (!node)
@@ -1913,7 +1926,7 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)if (kernfs_ns_enabled (parent)) ns =kernfs_info (dentry->d_sb)->ns; -for (pos =kernfs_dir_pos (ns, parent, ctx->pos, pos); +for (pos =kernfs_dir_pos (ns, parent, ctx->pos, pos,NULL ); pos; pos =kernfs_dir_next_pos (ns, parent, ctx->pos, pos)) {const char *name =kernfs_rcu_name (pos);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/2151 kernfs: dont hold kernfs_rwsem across dir_emit()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 341c65579de5b632eb7913bb68b3e375eeeb3ddf ]
kernfs_fop_readdir() holds kernfs_rwsem for reading across the whole listing, dir_emit() included. dir_emit() copies to userspace, so it can fault into reclaim while holding the lock that every create, remove and rename in the hierarchy needs. sysfs and cgroupfs have one per machine.
Under memory pressure the monitoring daemons fault on their own getdents(2) buffer with it held:
below: page allocation stall for 120 secs: order:0,
mode:0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO|__GFP_COMP)
nodemask=(null),cpuset=hostcritical.slice,mems_allowed=0
Call Trace:
<TASK>
dump_stack_lvl+0x5d/0x80
__alloc_frozen_pages_noprof+0x5f4d/0x6300
? memcg_list_lru_alloc+0x73/0x320
? ima_file_check+0xd0/0x7d0
vma_alloc_folio_noprof+0x145/0x560
handle_mm_fault+0x17c9/0x2720
? find_vma+0x27/0x30
do_user_addr_fault+0x39f/0x6e0
exc_page_fault+0x8f/0x110
asm_exc_page_fault+0x22/0x30
RIP: 0010:filldir64+0xd7/0x1a0
[Code:/RSP:/RAX:..R15: register block elided]
kernfs_fop_readdir+0x2de/0x420
iterate_dir+0x8c/0x1f0
__se_sys_getdents64+0x61/0xe0
? copy_page_from_iter+0x860/0x860
do_syscall_64+0x6a/0x250
entry_SYSCALL_64_after_hwframe+0x4b/0x53
</TASK>Commit 9aab10a0249e ("kernfs: Don't re-lock kernfs_root::kernfs_rwsem in kernfs_fop_readdir().") took the lock drop out because dir_emit() was handed kernfs_node::name, which a rename can free. The previous patch emits a copy instead, so drop the lock around dir_emit().
A listing is no longer atomic within one getdents(2) call, which for most sysfs and cgroup directories is all of it. POSIX leaves that unspecified for an entry added or removed since opendir(3).
--- fs/kernfs/dir.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/kernfs/dir.c +7 -3
@@ -1938,10 +1938,14 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx) file->private_data = pos;kernfs_get (pos); -if (!dir_emit (ctx, name, len, ino, type)) { -up_read (&root->kernfs_rwsem); +/* +* dir_emit() can fault, so run it unlocked. @pos is pinned +* above and kernfs_dir_pos() rechecks it on the way back. +*/ +up_read (&root->kernfs_rwsem); +if (!dir_emit (ctx, name, len, ino, type))return 0 ; - } +down_read (&root->kernfs_rwsem); }up_read (&root->kernfs_rwsem); file->private_data =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/2151 ASoC: SOF: amd: fix amd_sof_acp_remove() teardown ordering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijendar Mukunda <[email protected]>
[ Upstream commit db2167f2e3f72db64d01356cc9f2924d32fd5a51 ]
Call free_irq() before amd_sof_sdw_exit() in amd_sof_acp_remove(). amd_sof_sdw_exit() sets adata->sdw to NULL; if an IRQ fires between that point and the subsequent free_irq(), acp_irq_handler() may dereference the now-NULL pdev[] pointer, causing a use-after-free.
--- sound/soc/sof/amd/acp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/amd/acp.c +3 -3
@@ -949,12 +949,12 @@ void amd_sof_acp_remove(struct snd_sof_dev *sdev) {struct acp_dev_data *adata = sdev->pdata->hw_pdata; -if (adata->sdw) -amd_sof_sdw_exit (sdev); -if (sdev->ipc_irq)free_irq (sdev->ipc_irq, sdev); +if (adata->sdw) +amd_sof_sdw_exit (sdev); +if (adata->dmic_dev)platform_device_unregister (adata->dmic_dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 490/2151 ASoC: SOF: amd: fix amd_sof_acp_probe() error unwind ordering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijendar Mukunda <[email protected]>
[ Upstream commit b6aaef8ca8c305170de83e621c7e16d56731312a ]
Call amd_sof_sdw_exit() after free_irq() in the free_ipc_irq error label of amd_sof_acp_probe(). Without this, an IRQ that fires between sdw context teardown and free_irq() can dereference freed SoundWire resources.
--- sound/soc/sof/amd/acp.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sof/amd/acp.c +2 -0
@@ -939,6 +939,8 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) free_ipc_irq:free_irq (sdev->ipc_irq, sdev); +if (adata->sdw) +amd_sof_sdw_exit (sdev); unregister_dev:platform_device_unregister (adata->dmic_dev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/2151 spi: virtio: fix max frequency setting
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Valla <[email protected]>
[ Upstream commit 26f42ca8becd01877e762916865a168c1b6c4ff4 ]
The maximum transfer frequency is read from the virtio config space but never propagated to the SPI framework logic. Fix this behavior and drop the useless setting copy from the driver's private data.
--- drivers/spi/spi-virtio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/spi/spi-virtio.c +1 -3
@@ -33,8 +33,6 @@ struct virtio_spi_priv {struct virtqueue *vq;/* Copy of config space mode_func_supported */ u32 mode_func_supported; -/* Copy of config space max_freq_hz */ -u32 max_freq_hz; };static void virtio_spi_msg_done (struct virtqueue *vq)
@@ -305,7 +303,7 @@ static void virtio_spi_read_config(struct virtio_device *vdev)virtio_cread32 (vdev, offsetof(struct virtio_spi_config , bits_per_word_mask)); - priv->max_freq_hz = + ctrl->max_speed_hz =virtio_cread32 (vdev, offsetof(struct virtio_spi_config , max_freq_hz)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/2151 clk: si521xx: correct the SI52147 OF output enable map
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 7a4cc47d715f08309089d40b8c29fb0ba79917db ]
The SI52147 data sheet assigns DIFF0 through DIFF3 output-enable bits to 0x17 in control register 1. The OF match data uses 0x15, leaving the DIFF2 bit out of the map, while the I2C ID table already uses the documented value.
Use 0x17 for the SI52147 OF entry so both enumeration paths expose the documented outputs.
--- drivers/clk/clk-si521xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-si521xx.c +1 -1
@@ -375,7 +375,7 @@ MODULE_DEVICE_TABLE(i2c, si521xx_id);static const struct of_device_id clk_si521xx_of_match[] = { { .compatible ="skyworks,si52144" , .data = (void *)SI521XX_OE_MAP (0x5 ,0xc0 ) }, { .compatible ="skyworks,si52146" , .data = (void *)SI521XX_OE_MAP (0x15 ,0xe0 ) }, - { .compatible ="skyworks,si52147" , .data = (void *)SI521XX_OE_MAP (0x15 ,0xf8 ) }, + { .compatible ="skyworks,si52147" , .data = (void *)SI521XX_OE_MAP (0x17 ,0xf8 ) }, { } };MODULE_DEVICE_TABLE (of, clk_si521xx_of_match);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/2151 clk: milbeaut: Return divider update timeouts
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 92d0998090d1716ee6b47174c10eb9415a12fca8 ]
m10v_clk_divider_set_rate() logs when the hardware does not clear its write-valid request, but still returns success to the clock framework. It also uses the sleeping poll helper while holding the divider spinlock.
Use the atomic poll helper under the lock and return its timeout so the rate change is not reported as successful before the hardware accepts it.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/clk/clk-milbeaut.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/clk/clk-milbeaut.c +6 -4
@@ -414,8 +414,8 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) {struct m10v_clk_divider *divider =to_m10v_div (hw); -int value;unsigned long flags =0 ; +int value, ret =0 ;u32 val;u32 write_en =BIT (divider->width -1 );
@@ -437,8 +437,10 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,if (divider->write_valid_reg) {writel (M10V_DCHREQ , divider->write_valid_reg); -if (readl_poll_timeout (divider->write_valid_reg, val, - !val,M10V_UPOLL_RATE ,M10V_UTIMEOUT )) + ret =readl_poll_timeout_atomic (divider->write_valid_reg, val, + !val,M10V_UPOLL_RATE , +M10V_UTIMEOUT ); +if (ret)pr_err ("%s:%s couldn't stabilize\n" , __func__,clk_hw_get_name (hw)); }
@@ -448,7 +450,7 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,else __release (divider->lock); -return 0 ; +return ret; }static const struct clk_ops m10v_clk_divider_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/2151 drm/amd/pm: bound SCLK FCW range entries to the table size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Mishal <[email protected]>
[ Upstream commit f35aa5c77f5fca20fc269d6221df19c7b96704a5 ]
atomctrl_get_smc_sclk_range_table() copies ucSclkEntryNum entries from the VBIOS SMU_Info table into pp_atom_ctrl_sclk_range_table. Both the source (asSclkFcwRangeEntry[]) and destination (table->entry[]) arrays are fixed at MAX_SCLK_RANGE (8) entries, but ucSclkEntryNum is an unchecked u8 read straight from the VBIOS, so it can be up to 255. The destination is stack-allocated in both callers (polaris10_get_sclk_range_table(), vegam_get_sclk_range_table()), so a count above 8 overflows a stack buffer, not just a heap read.
Reject counts above MAX_SCLK_RANGE rather than clamping to it. Only one version of this VBIOS struct (ATOM_SMU_INFO_V2_1) has ever existed, so a count above 8 corresponds to no legitimate table format and means either a corrupted or a tampered VBIOS.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +3 -0
@@ -1025,6 +1025,9 @@ int atomctrl_get_smc_sclk_range_table(struct pp_hwmgr *hwmgr, struct pp_atom_ctrif (!psmu_info)return -EINVAL ; +if (psmu_info->ucSclkEntryNum >MAX_SCLK_RANGE ) +return -EINVAL ; +for (i =0 ; i < psmu_info->ucSclkEntryNum; i++) { table->entry[i].ucVco_setting = psmu_info->asSclkFcwRangeEntry[i].ucVco_setting; table->entry[i].ucPostdiv = psmu_info->asSclkFcwRangeEntry[i].ucPostdiv;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/2151 drm/amd: Add correct prefix for VBIOS message
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello (AMD) <[email protected]>
[ Upstream commit e6c7ebeaba4080562e71a59a788ac90b41e09240 ]
It's not obvious which GPU the ATOM BIOS message goes with. Use drm_info() to show the correct one.
Stable-dep-of: aee05c455ad3 ("drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters")
--- drivers/gpu/drm/amd/amdgpu/atom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/atom.c +1 -1
@@ -1474,7 +1474,7 @@ static void atom_get_vbios_pn(struct atom_context *ctx) ctx->vbios_pn[count] =0 ; } -pr_info ("ATOM BIOS: %s\n" , ctx->vbios_pn); +drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , ctx->vbios_pn); }static void atom_get_vbios_version (struct atom_context *ctx)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/2151 drm/amdgpu: Print full vbios info
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <[email protected]>
[ Upstream commit 4fd7b724a87a4051401ee2ed64c26c9249582040 ]
Add build number, version and date to the existing part number print.
Example:
[drm] ATOM BIOS: 113-PN000108-103, build: 00159017, ver: 022.040.003.043.000001, 2025/07/27
Stable-dep-of: aee05c455ad3 ("drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters")
--- drivers/gpu/drm/amd/amdgpu/atom.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +26 -2
@@ -1473,8 +1473,6 @@ static void atom_get_vbios_pn(struct atom_context *ctx) ctx->vbios_pn[count] =0 ; } - -drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , ctx->vbios_pn); }static void atom_get_vbios_version (struct atom_context *ctx)
@@ -1531,6 +1529,30 @@ static void atom_get_vbios_build(struct atom_context *ctx)strscpy (ctx->build_num, str, len); } +static inline void atom_print_vbios_info (struct atom_context *ctx) +{ +char vbios_info[256 ]; +int off =0 ; + +if (ctx->vbios_pn[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%s" , ctx->vbios_pn); +if (ctx->build_num[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%sbuild: %s" , off ?", " :"" , + ctx->build_num); +if (ctx->vbios_ver_str[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%sver: %s" , off ?", " :"" , + ctx->vbios_ver_str); +if (ctx->date[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%s%.10s" , off ?", " :"" , + ctx->date); +if (off) +drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , vbios_info); +} +struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios) {int base;
@@ -1593,6 +1615,8 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)atom_get_vbios_version (ctx);atom_get_vbios_build (ctx); +atom_print_vbios_info (ctx); +return ctx; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/2151 drm/amdgpu: bounds check ATOM IIO table parsing
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <[email protected]>
[ Upstream commit be88697602238c3dcb47bbc2db1eef923f63e78b ]
atom_index_iio() parsed the IIO bytecode without bounds checks, allowing out-of-bounds reads on a malformed VBIOS. Pass the BIOS size into amdgpu_atom_parse() and bound the parse loops by it.
Stable-dep-of: aee05c455ad3 ("drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 +- drivers/gpu/drm/amd/amdgpu/atom.c | 25 ++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/atom.h | 3 ++- 3 files changed, 23 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +1 -1
@@ -1923,7 +1923,7 @@ int amdgpu_atombios_init(struct amdgpu_device *adev) atom_card_info->pll_read = cail_pll_read; atom_card_info->pll_write = cail_pll_write; - adev->mode_info.atom_context =amdgpu_atom_parse (atom_card_info, adev->bios); + adev->mode_info.atom_context =amdgpu_atom_parse (atom_card_info, adev->bios, adev->bios_size);if (!adev->mode_info.atom_context) {amdgpu_atombios_fini (adev);return -ENOMEM ;
drivers/gpu/drm/amd/amdgpu/atom.c +20 -5
@@ -1327,11 +1327,25 @@ static void atom_index_iio(struct atom_context *ctx, int base) ctx->iio =kzalloc (2 *256 ,GFP_KERNEL );if (!ctx->iio)return ; -while (CU8 (base) ==ATOM_IIO_START ) { - ctx->iio[CU8 (base +1 )] = base +2 ; +while (base +1 < ctx->bios_size &&CU8 (base) ==ATOM_IIO_START ) { +uint8_t index =CU8 (base +1 ); +int start = base +2 ; base +=2 ; -while (CU8 (base) !=ATOM_IIO_END ) - base += atom_iio_len[CU8 (base)]; +while (base < ctx->bios_size &&CU8 (base) !=ATOM_IIO_END ) { +uint8_t op =CU8 (base); + +/* +* Unknown opcode: its length is unknown so the byte +* stream cannot be resynced reliably. +*/ +if (op >=ARRAY_SIZE (atom_iio_len)) +return ; + base += atom_iio_len[op]; + } +if (base >= ctx->bios_size) +return ; +/* Only index well-formed methods, others stay 0 */ + ctx->iio[index] = start; base +=3 ; } }
@@ -1553,7 +1567,7 @@ static inline void atom_print_vbios_info(struct atom_context *ctx)drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , vbios_info); } -struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios) +struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios,uint32_t bios_size) {int base; struct atom_context *ctx =
@@ -1567,6 +1581,7 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios) ctx->card = card; ctx->bios = bios; + ctx->bios_size = bios_size;if (CU16 (0 ) !=ATOM_BIOS_MAGIC ) {pr_info ("Invalid BIOS magic\n" );
drivers/gpu/drm/amd/amdgpu/atom.h +2 -1
@@ -133,6 +133,7 @@ struct atom_context {struct card_info *card;struct mutex mutex;void *bios; +uint32_t bios_size;uint32_t cmd_table, data_table;uint16_t *iio;
@@ -160,7 +161,7 @@ struct atom_context {extern int amdgpu_atom_debug; -struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios); +struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios,uint32_t bios_size);int amdgpu_atom_execute_table (struct atom_context *ctx,int index,uint32_t *params,int params_size);int amdgpu_atom_asic_init (struct atom_context *ctx);void amdgpu_atom_destroy (struct atom_context *ctx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/2151 drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Mishal <[email protected]>
[ Upstream commit aee05c455ad3e72df9a0591baf0b60da518800f3 ]
atom_get_vbios_date(), atom_get_vbios_pn(), atom_get_vbios_version() and atom_get_vbios_build() all walk the BIOS image using offsets and counts taken from the image itself, checked only against each other and never against ctx->bios_size:
- atom_get_vbios_date() reads 14 bytes at a fixed offset that check_atom_bios()'s minimum size (0x49) does not cover.
- atom_get_vbios_pn() dereferences an image-supplied u16 string offset unchecked, then walks and copies from it with only a length cap, not an image cap.
- atom_get_vbios_version() takes its search bounds from image u16s; atom_find_str_in_rom() already clamps the search itself, but the match is then advanced by a fixed 18 bytes and STRLEN_NORMAL bytes are copied from there with no check that this still lands inside the image.
- atom_get_vbios_build() walks from an image-supplied config-string offset toward the ROM header; a config offset at or past the header makes the pointer difference negative, wrapping through the u16 'len' and passing strscpy() a bound far larger than the 32-byte destination.
Bound each getter's reads, walks and copies to ctx->bios_size, falling back to an empty string on a malformed image.
--- drivers/gpu/drm/amd/amdgpu/atom.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +24 -5
@@ -1405,6 +1405,11 @@ static void atom_get_vbios_date(struct atom_context *ctx) p_rom = ctx->bios; +if (ctx->bios_size <OFFSET_TO_VBIOS_DATE +14 ) { + ctx->date[0 ] ='\0' ; +return ; + } + date_in_rom = p_rom +OFFSET_TO_VBIOS_DATE ; ctx->date[0 ] ='2' ;
@@ -1468,10 +1473,15 @@ static void atom_get_vbios_pn(struct atom_context *ctx) vbios_str = p_rom +OFFSET_TO_VBIOS_PART_NUMBER ; } -if (*vbios_str ==0 ) { +if (vbios_str >= p_rom + ctx->bios_size) + vbios_str =NULL ; + +if (vbios_str ==NULL || *vbios_str ==0 ) { vbios_str =atom_find_str_in_rom (ctx,BIOS_ATOM_PREFIX ,3 ,1024 ,64 );if (vbios_str ==NULL ) vbios_str +=sizeof (BIOS_ATOM_PREFIX ) -1 ; +if (vbios_str >= p_rom + ctx->bios_size) + vbios_str =NULL ; }OPTIMIZER_HIDE_VAR (vbios_str);if (vbios_str !=NULL && *vbios_str ==0 )
@@ -1479,7 +1489,9 @@ static void atom_get_vbios_pn(struct atom_context *ctx)if (vbios_str !=NULL ) { count =0 ; -while ((count <BIOS_STRING_LENGTH ) && vbios_str[count] >=' ' && +while ((count <BIOS_STRING_LENGTH ) && + vbios_str + count < p_rom + ctx->bios_size && + vbios_str[count] >=' ' && vbios_str[count] <='z' ) { ctx->vbios_pn[count] = vbios_str[count]; count++;
@@ -1512,9 +1524,10 @@ static void atom_get_vbios_version(struct atom_context *ctx)/* find anchor ATOMBIOSBK-AMD */ vbios_ver =atom_find_str_in_rom (ctx,BIOS_VERSION_PREFIX , start, end,64 ); -if (vbios_ver !=NULL ) { -/* skip ATOMBIOSBK-AMD VER */ - vbios_ver +=18 ; +if (vbios_ver !=NULL ) + vbios_ver +=18 ;/* skip ATOMBIOSBK-AMD VER */ + +if (vbios_ver !=NULL && vbios_ver +STRLEN_NORMAL <= p_rom + ctx->bios_size) {memcpy (ctx->vbios_ver_str, vbios_ver,STRLEN_NORMAL ); }else { ctx->vbios_ver_str[0 ] ='\0' ;
@@ -1530,7 +1543,13 @@ static void atom_get_vbios_build(struct atom_context *ctx) base =CU16 (ATOM_ROM_TABLE_PTR ); atom_rom_hdr =CSTR (base); +if ((uint32_t )base +ATOM_ROM_CFG_PTR +sizeof (uint16_t ) > ctx->bios_size) +return ; + str =CSTR (CU16 (base +ATOM_ROM_CFG_PTR )); +if (str >= atom_rom_hdr) +return ; +/* Skip config string */ while (str < atom_rom_hdr && *str++) ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/2151 ata: sata_dwc_460ex: Dont enable interrupt if libATA core registration fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Borisov <[email protected]>
[ Upstream commit e137035fcd66cb454c479bb989968561bbc60341 ]
Recent 4bbc16a353a9 commit changed the timing when interrupts are enabled. However it didn't account for the libATA registration step. So it's possible that interrupts are enabled when the device is not registered with libATA core.
Resolve the issue by failing the entire registration process in case of failure to register with libATA.
--- drivers/ata/sata_dwc_460ex.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/ata/sata_dwc_460ex.c +4 -1
@@ -1184,11 +1184,14 @@ static int sata_dwc_probe(struct platform_device *ofdev)* error_handler() to execute a dummy Softreset EH session */ err =ata_host_activate (host, irq, sata_dwc_isr,0 , &sata_dwc_sht); -if (err) +if (err) {dev_err (dev,"failed to activate host" ); + goto error_out; + }/* Enable SATA Interrupts */ sata_dwc_enable_interrupts (hsdev); +return 0 ; error_out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/2151 accel/amdxdna: Fully initialize map structure before registering notifier
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 5eee433b5c97821979e7de58476dc245ee168d89 ]
The map structure is currently only partially initialized when the notifier is registered. Although holding mmap_write_lock() prevents the notifier callback from running before the remaining initialization is complete, the ordering can be confusing during code review.
Fully initialize the map structure before registering the notifier so that the structure is completely constructed before it is published.
Stable-dep-of: 2d2c4b248bff ("accel/amdxdna: Set HMM_PFN_REQ_WRITE for writable BO faults")
--- drivers/accel/amdxdna/amdxdna_gem.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/accel/amdxdna/amdxdna_gem.c +9 -9
@@ -231,6 +231,15 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo, goto free_map; } + mapp->range.notifier = &mapp->notifier; + mapp->range.start = vma->vm_start; + mapp->range.end = vma->vm_end; + mapp->range.default_flags =HMM_PFN_REQ_FAULT ; + mapp->abo = abo; +kref_init (&mapp->refcnt); + +INIT_WORK (&mapp->hmm_unreg_work, amdxdna_hmm_unreg_work); + ret = mmu_interval_notifier_insert_locked(&mapp->notifier, current->mm, addr,
@@ -241,15 +250,6 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo, goto free_pfns; } - mapp->range.notifier = &mapp->notifier; - mapp->range.start = vma->vm_start; - mapp->range.end = vma->vm_end; - mapp->range.default_flags =HMM_PFN_REQ_FAULT ; - mapp->abo = abo; -kref_init (&mapp->refcnt); - -INIT_WORK (&mapp->hmm_unreg_work, amdxdna_hmm_unreg_work); -down_write (&xdna->notifier_lock);if (list_empty (&abo->mem.umap_list)) abo->mem.userptr = addr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/2151 accel/amdxdna: Set HMM_PFN_REQ_WRITE for writable BO faults
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 2d2c4b248bff9ee1ac06054a9138c1a308e2e7b8 ]
When aie2_populate_range() faults in pages, it only sets HMM_PFN_REQ_FAULT. Without HMM_PFN_REQ_WRITE, handle_mm_fault() does not request write permissions and may populate the CPU page tables with read-only PTEs.
Check the VMA flags and set HMM_PFN_REQ_WRITE when the VMA has VM_WRITE.
--- drivers/accel/amdxdna/amdxdna_gem.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/accel/amdxdna/amdxdna_gem.c +8 -0
@@ -234,7 +234,15 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo, mapp->range.notifier = &mapp->notifier; mapp->range.start = vma->vm_start; mapp->range.end = vma->vm_end; +/* +* Access permissions are fixed at mmap() time. Changing them later +* with mprotect() is not supported: the range keeps requesting the +* original permissions, so the application may see a fault failure +* or an IOMMU fault. +*/ mapp->range.default_flags =HMM_PFN_REQ_FAULT ; +if (vma->vm_flags &VM_WRITE ) + mapp->range.default_flags |=HMM_PFN_REQ_WRITE ; mapp->abo = abo;kref_init (&mapp->refcnt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/2151 dt-bindings: interrupt-controller: chrp,open-pic: Typo s/pci/pic/
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit f0597e96a23b0cc7877581cf907407645ca71c03 ]
The device_type for an OpenPIC node is "open-pic", not "open-pci".
--- .../devicetree/bindings/interrupt-controller/chrp,open-pic.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/interrupt-controller/chrp,open-pic.yaml +1 -1
@@ -24,7 +24,7 @@ properties: - const: chrp,open-pic device_type: - const: open-pci + const: open-pic deprecated: true reg:
Signature · 1 line
2.53.0