7.2.6-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 1215/1815 Bluetooth: btqca: Fix qca_set_bdaddr() waiting for wrong HCI event
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit cf81f0a3db2a5c34ee6e4ea379c631fab6d13e01 ]
qca_set_bdaddr() waits for HCI_EV_VENDOR when sending EDL_WRITE_BD_ADDR_OPCODE (0xFC14), but the controller responds with Command Complete event as confirmed by btmon on WCN7850:
< HCI Command: Vendor (0x3f|0x0014) plen 6 #3 [hci0]
11 22 33 44 55 66
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #4 [hci0]
Vendor (0x3f|0x0014) ncmd 1
Status: Success (0x00)Fix by passing 0 as the event parameter to __hci_cmd_sync_ev() to wait for the command complete event instead.
--- drivers/bluetooth/btqca.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bluetooth/btqca.c +1 -2
@@ -1029,8 +1029,7 @@ int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)baswap (&bdaddr_swapped, bdaddr); skb =__hci_cmd_sync_ev (hdev,EDL_WRITE_BD_ADDR_OPCODE ,6 , - &bdaddr_swapped,HCI_EV_VENDOR , -HCI_INIT_TIMEOUT ); + &bdaddr_swapped,0 ,HCI_INIT_TIMEOUT );if (IS_ERR (skb)) { err =PTR_ERR (skb);bt_dev_err (hdev,"QCA Change address cmd failed (%d)" , err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1189/1815 md: wait for behind writes before destroying bitmap
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 2a79365b2278f16e163e4024086105693b421601 ]
__md_stop() destroyed the bitmap before calling mddev_detach(). That made mddev_detach() skip bitmap_ops->wait_behind_writes(), because the bitmap was already disconnected from mddev.
This was still safe for the legacy bitmap because bitmap_destroy() waits for behind writes itself. llbitmap keeps that wait in its ->wait_behind_writes() operation instead, while ->destroy() tears down the llbitmap storage. With the old ordering, RAID1 behind-write completions could still run after llbitmap storage had been freed.
Call mddev_detach() before md_bitmap_destroy() so the common detach path can wait for behind writes while the bitmap is still alive. Only destroy the bitmap after those users are gone.
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -7076,8 +7076,8 @@ static void __md_stop(struct mddev *mddev) {struct md_personality *pers = mddev->pers; -md_bitmap_destroy (mddev);mddev_detach (mddev); +md_bitmap_destroy (mddev);spin_lock (&mddev->lock); mddev->pers =NULL ;spin_unlock (&mddev->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1216/1815 Bluetooth: btusb: Fix BD_ADDR byte order in btusb_set_bdaddr_wcn6855()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit d0b15d812688d3f0f3fe1c4426e12814d0c294dc ]
btusb_set_bdaddr_wcn6855() sends the address without swapping byte order for VSC 0xFC14, but the command expects the address in reversed byte order compared to other HCI commands like HCI_Create_Connection, resulting in a wrong BD_ADDR being set.
btmon log on WCN6855 shows VSC 0xFC14 is sent with swapped bytes 11 22 33 44 55 66, and Read BD ADDR returns the expected address 11:22:33:44:55:66:
< HCI Command: Vendor (0x3f|0x0014) plen 6 #3 [hci0]
11 22 33 44 55 66
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #4 [hci0]
Vendor (0x3f|0x0014) ncmd 1
Status: Success (0x00)< HCI Command: Read BD ADDR (0x04|0x0009) plen 0 #11 [hci0]
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 10 #12 [hci0]
Read BD ADDR (0x04|0x0009) ncmd 1
Status: Success (0x00)
Address: 11:22:33:44:55:66 (OUI 11-22-33)Fix by swapping the input address before issuing the command.
--- drivers/bluetooth/btusb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/bluetooth/btusb.c +5 -4
@@ -3083,14 +3083,15 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev,static int btusb_set_bdaddr_wcn6855 (struct hci_dev *hdev,const bdaddr_t *bdaddr) { +bdaddr_t bdaddr_swapped;struct sk_buff *skb; -u8 buf[6 ];long ret; -memcpy (buf, bdaddr,sizeof (bdaddr_t)); +baswap (&bdaddr_swapped, bdaddr); - skb =__hci_cmd_sync_ev (hdev,0xfc14 ,sizeof (buf), buf, -HCI_EV_CMD_COMPLETE ,HCI_INIT_TIMEOUT ); + skb =__hci_cmd_sync_ev (hdev,0xfc14 ,sizeof (bdaddr_swapped), + &bdaddr_swapped,HCI_EV_CMD_COMPLETE , +HCI_INIT_TIMEOUT );if (IS_ERR (skb)) { ret =PTR_ERR (skb);bt_dev_err (hdev,"Change address command failed (%ld)" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1217/1815 Bluetooth: btusb: Record matched usb_device_id into btusb_data
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit ff50db7a522e7bd3bd1c4db6da715e4bdb53af97 ]
Add @match_id to btusb_data to record the matched usb_device_id which will be used later.
Stable-dep-of: 33c6a8d01889 ("Bluetooth: btusb: QCA: Fix populating devcoredump fields on unenabled devices")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -1021,6 +1021,7 @@ struct btusb_data {bool usb_alt6_packet_flow;int isoc_altsetting;int suspend_count; +const struct usb_device_id *match_id;int (*recv_event)(struct hci_dev *hdev,struct sk_buff *skb);int (*recv_acl)(struct hci_dev *hdev,struct sk_buff *skb);
@@ -4119,6 +4120,7 @@ static int btusb_probe(struct usb_interface *intf,if (!data)return -ENOMEM ; + data->match_id = id; err =usb_find_common_endpoints (intf->cur_altsetting, &data->bulk_rx_ep, &data->bulk_tx_ep, &data->intr_ep,NULL );if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1218/1815 Bluetooth: btusb: QCA: Fix populating devcoredump fields on unenabled devices
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 33c6a8d01889a84cc773c0c20c8323bce84af27d ]
Devcoredump is not enabled for ATH3012 or QCA_ROME, but they unconditionally populate devcoredump fields in btusb_setup_qca().
Fix by populating devcoredump fields only when BTUSB_QCA_WCN6855 is set, which marks the first generation of QCA BT SoCs for which devcoredump is enabled.
--- drivers/bluetooth/btusb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bluetooth/btusb.c +4 -2
@@ -3708,8 +3708,10 @@ static int btusb_setup_qca(struct hci_dev *hdev)if (err)return err; - btdata->qca_dump.fw_version =le32_to_cpu (ver.patch_version); - btdata->qca_dump.controller_id =le32_to_cpu (ver.rom_version); +if (btdata->match_id->driver_info &BTUSB_QCA_WCN6855 ) { + btdata->qca_dump.fw_version =le32_to_cpu (ver.patch_version); + btdata->qca_dump.controller_id =le32_to_cpu (ver.rom_version); + }if (!(status &QCA_SYSCFG_UPDATED )) { err =btusb_setup_qca_load_nvm (hdev, &ver, info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1219/1815 perf trace-event: Fix integer truncation in do_read() and skip()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tanushree Shah <[email protected]>
[ Upstream commit c108c1391be0826920991d24532fbae8f6373ddc ]
The do_read() and skip() functions use 'int' for size parameters, truncating 64-bit sizes from callers. This causes two issues:
1. Uninitialized memory dump: do_read() reads fewer bytes than allocated, leaving uninitialized heap memory that gets written to output files.
2. Out-of-bounds read: Parsing functions process the full 64-bit size while only partial data was read into the buffer.
Change do_read(), __do_read(), and skip() to use size_t for size parameters and ssize_t for return values (where applicable), matching read()/write() system calls.
Update callers to use ssize_t for storing return values.
--- tools/perf/util/trace-event-read.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
tools/perf/util/trace-event-read.c +14 -14
@@ -25,18 +25,18 @@ static int input_fd;static ssize_t trace_data_size;static bool repipe; -static int __do_read (int fd,void *buf,int size) +static ssize_t __do_read (int fd,void *buf,size_t size) { -int rsize = size; +size_t rsize = size;while (size) { -int ret =read (fd, buf, size); +ssize_t ret =read (fd, buf, size);if (ret <=0 )return -1 ;if (repipe) { -int retw =write (STDOUT_FILENO , buf, ret); +ssize_t retw =write (STDOUT_FILENO , buf, ret);if (retw <=0 || retw != ret) {pr_debug ("repiping input file" );
@@ -51,13 +51,13 @@ static int __do_read(int fd, void *buf, int size)return rsize; } -static int do_read (void *data,int size) +static ssize_t do_read (void *data,size_t size) { -int r; +ssize_t r; r =__do_read (input_fd, data, size);if (r <=0 ) { -pr_debug ("reading input file (size expected=%d received=%d)" , +pr_debug ("reading input file (size expected=%zu received=%zd)" , size, r);return -1 ; }
@@ -68,10 +68,10 @@ static int do_read(void *data, int size) }/* If it fails, the next read will report it */ -static void skip (int size) +static void skip (size_t size) {char buf[BUFSIZ ]; -int r; +size_t r;while (size) { r = size >BUFSIZ ?BUFSIZ : size;
@@ -202,7 +202,7 @@ static int read_header_files(struct tep_handle *pevent)unsigned long long size;char *header_page;char buf[BUFSIZ ]; -int ret =0 ; +ssize_t ret =0 ;if (do_read (buf,12 ) <0 )return -1 ;
@@ -250,7 +250,7 @@ static int read_header_files(struct tep_handle *pevent)static int read_ftrace_file (struct tep_handle *pevent,unsigned long long size) { -int ret; +ssize_t ret;char *buf; buf =malloc (size);
@@ -276,7 +276,7 @@ static int read_ftrace_file(struct tep_handle *pevent, unsigned long long size)static int read_event_file (struct tep_handle *pevent,char *sys,unsigned long long size) { -int ret; +ssize_t ret;char *buf; buf =malloc (size);
@@ -322,7 +322,7 @@ static int read_event_files(struct tep_handle *pevent)int systems;int count;int i,x; -int ret; +ssize_t ret; systems =read4 (pevent);
@@ -350,7 +350,7 @@ static int read_saved_cmdline(struct tep_handle *pevent) {unsigned long long size;char *buf; -int ret; +ssize_t ret;/* it can have 0 size */ size =read8 (pevent);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1220/1815 scsi: sd: Fix error handling in sd_probe() after large pool creation failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
[ Upstream commit e3cc6ea1a745e7f5d326f919a428b244fa119d8f ]
After device_add(&sdkp->disk_dev) succeeds, sd_large_pool_create() failure must unregister disk_dev and let scsi_disk_release() free sdkp. Going through out_free_index kfree()s an already registered device and leaks the sysfs entry.
--- drivers/scsi/sd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +3 -1
@@ -4089,7 +4089,9 @@ static int sd_probe(struct scsi_device *sdp)if (sdp->sector_size >PAGE_SIZE ) {if (sd_large_pool_create ()) { error = -ENOMEM ; - goto out_free_index; +device_unregister (&sdkp->disk_dev); +put_disk (gd); + goto out; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1221/1815 scsi: sd: Fix special_vec mempool leak when scsi_alloc_sgtables() fails
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
[ Upstream commit bb31844d88b77138b67aa20c3600203baff40140 ]
sd_set_special_bvec() allocates a special payload page for UNMAP and WRITE SAME commands. If scsi_alloc_sgtables() fails afterward in sd_setup_unmap_cmnd() or sd_setup_write_same{10,16}_cmnd(), the SCSI midlayer does not call uninit_command() because RQF_DONTPREP is not set yet, leaking the page.
Call sd_uninit_command() on error, and clear RQF_SPECIAL_PAYLOAD after freeing the page.
--- drivers/scsi/sd.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-)
drivers/scsi/sd.c +30 -17
@@ -958,6 +958,21 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,return protect; } +static void sd_uninit_command (struct scsi_cmnd *cmd) +{ +struct request *rq =scsi_cmd_to_rq (cmd); +struct scsi_device *sdp = cmd->device; + +if (!(rq->rq_flags &RQF_SPECIAL_PAYLOAD )) +return ; + +if (sdp->sector_size >PAGE_SIZE ) +mempool_free (rq->special_vec.bv_page, sd_large_page_pool); +else +mempool_free (rq->special_vec.bv_page, sd_page_pool); + rq->rq_flags &= ~RQF_SPECIAL_PAYLOAD ; +} +static void *sd_set_special_bvec (struct scsi_cmnd *cmd,unsigned int data_len) {struct page *page;
@@ -990,6 +1005,7 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));unsigned int data_len =24 ;char *buf; +blk_status_t ret; buf =sd_set_special_bvec (cmd, data_len);if (!buf)
@@ -1008,7 +1024,10 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd) cmd->transfersize = data_len; rq->timeout =SD_TIMEOUT ; -return scsi_alloc_sgtables (cmd); + ret =scsi_alloc_sgtables (cmd); +if (ret !=BLK_STS_OK ) +sd_uninit_command (cmd); +return ret; }static void sd_config_atomic (struct scsi_disk *sdkp,struct queue_limits *lim)
@@ -1079,6 +1098,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,u64 lba =sectors_to_logical (sdp,blk_rq_pos (rq));u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));u32 data_len = sdp->sector_size; +blk_status_t ret;if (!sd_set_special_bvec (cmd, data_len))return BLK_STS_RESOURCE ;
@@ -1094,7 +1114,10 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, cmd->transfersize = data_len; rq->timeout = unmap ?SD_TIMEOUT :SD_WRITE_SAME_TIMEOUT ; -return scsi_alloc_sgtables (cmd); + ret =scsi_alloc_sgtables (cmd); +if (ret !=BLK_STS_OK ) +sd_uninit_command (cmd); +return ret; } static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
@@ -1106,6 +1129,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,u64 lba =sectors_to_logical (sdp,blk_rq_pos (rq));u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));u32 data_len = sdp->sector_size; +blk_status_t ret;if (!sd_set_special_bvec (cmd, data_len))return BLK_STS_RESOURCE ;
@@ -1121,7 +1145,10 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, cmd->transfersize = data_len; rq->timeout = unmap ?SD_TIMEOUT :SD_WRITE_SAME_TIMEOUT ; -return scsi_alloc_sgtables (cmd); + ret =scsi_alloc_sgtables (cmd); +if (ret !=BLK_STS_OK ) +sd_uninit_command (cmd); +return ret; }static blk_status_t sd_setup_write_zeroes_cmnd (struct scsi_cmnd *cmd)
@@ -1550,20 +1577,6 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd) } } -static void sd_uninit_command (struct scsi_cmnd *SCpnt) -{ -struct request *rq =scsi_cmd_to_rq (SCpnt); -struct scsi_device *sdp = SCpnt->device; -unsigned sector_size = sdp->sector_size; - -if (rq->rq_flags &RQF_SPECIAL_PAYLOAD ) { -if (sector_size >PAGE_SIZE ) -mempool_free (rq->special_vec.bv_page, sd_large_page_pool); -else -mempool_free (rq->special_vec.bv_page, sd_page_pool); - } -} -static bool sd_need_revalidate (struct gendisk *disk,struct scsi_disk *sdkp) {if (sdkp->device->removable || sdkp->write_prot) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1222/1815 scsi: sd: Fix sd_done() sense handling condition
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
[ Upstream commit a640d4546b11be5709a82bdc63d7dafd8ddc6c9e ]
Only enter the sense_key switch when the command returned CHECK CONDITION with valid, non-deferred sense. The old condition let deferred or invalid sense fall through and mis-handle the I/O.
--- drivers/scsi/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +2 -2
@@ -2419,8 +2419,8 @@ static int sd_done(struct scsi_cmnd *SCpnt) } sdkp->medium_access_timed_out =0 ; -if (!scsi_status_is_check_condition (result) && - (!sense_valid || sense_deferred)) +if (!scsi_status_is_check_condition (result) || + !sense_valid || sense_deferred) goto out;switch (sshdr.sense_key) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1223/1815 btrfs: zoned: dont force read-only on transient -EAGAIN from reloc merge
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit e549093c11a2fff8430df3dfbdb45eb9811a69a5 ]
On a zoned FS, btrfs_delayed_refs_rsv_refill() returns -EAGAIN whenever the over-committed metadata plus the zone_unusable bytes exceeds the usable size in a metadata block-group to avoid heavy over-commit of metadata and early ENOSPC in one transaction.
If this happens while doing reclaim, the transaction is getting aborted.
Treat -EAGAIN as a soft, retryable condition in case of block-group reclaim.
--- fs/btrfs/block-group.c | 8 ++++++- fs/btrfs/relocation.c | 49 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 6 deletions(-)
fs/btrfs/block-group.c +7 -1
@@ -2047,6 +2047,11 @@ static int btrfs_reclaim_block_group(struct btrfs_block_group *bg, int *reclaimetrace_btrfs_reclaim_block_group (bg); ret =btrfs_relocate_chunk (fs_info, bg->start, false); +if (btrfs_is_zoned (fs_info) && ret == -EAGAIN ) { +btrfs_dec_block_group_ro (bg); +btrfs_debug (fs_info,"deferring reclaim of chunk %llu" , bg->start); +return ret; + }if (ret) {btrfs_dec_block_group_ro (bg); btrfs_err(fs_info, "error relocating chunk %llu",
@@ -2113,7 +2118,8 @@ void btrfs_reclaim_block_groups(struct btrfs_fs_info *fs_info, unsigned int limispin_unlock (&fs_info->unused_bgs_lock); ret =btrfs_reclaim_block_group (bg, &reclaimed); -if (ret && !READ_ONCE (space_info->periodic_reclaim)) +if ((btrfs_is_zoned (fs_info) && ret == -EAGAIN ) || + (ret && !READ_ONCE (space_info->periodic_reclaim)))btrfs_link_bg_list (bg, &retry_list);btrfs_put_block_group (bg);
fs/btrfs/relocation.c +44 -5
85 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1224/1815 btrfs: defrag: fix deadlock between defrag and delalloc space reservation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit ba02eab28041f9a4bbe9fc90c7249644fef6de0f ]
While running fsstress with autodefrag and flushoncommit, hit a deadlock due to the fact that defrag reserves delalloc space while it's holding dirty and locked folios, besides the extent range lock. The stack traces are the following:
[958.624] task:kworker/u50:3 state:D stack:0 pid:20365 tgid:20365 ppid:2 task_flags:0x4208060 flags:0x00080000 [958.626] Workqueue: events_unbound btrfs_async_reclaim_metadata_space [btrfs] [958.627] Call Trace: [958.628] <TASK> [958.628] __schedule+0x4be/0x10f0 [958.629] ? preempt_count_add+0x69/0xa0 [958.630] schedule+0x26/0xd0 [958.631] wait_current_trans+0x102/0x160 [btrfs] [958.632] ? __pfx_autoremove_wake_function+0x10/0x10 [958.633] start_transaction+0x374/0x900 [btrfs] [958.634] btrfs_commit_current_transaction+0x1d/0x70 [btrfs] [958.635] flush_space+0xca/0x5e0 [btrfs] [958.636] ? _raw_spin_unlock+0x15/0x30 [958.637] ? btrfs_reduce_alloc_profile+0x8c/0x190 [btrfs] [958.639] ? _raw_spin_unlock+0x15/0x30 [958.640] ? calc_available_free_space.isra.0+0x6f/0x110 [btrfs] [958.641] do_async_reclaim_metadata_space+0x84/0x190 [btrfs] [958.642] btrfs_async_reclaim_metadata_space+0x64/0x80 [btrfs] [958.644] process_one_work+0x19d/0x3a0 [958.644] worker_thread+0x1c4/0x330 [958.645] ? __pfx_worker_thread+0x10/0x10 [958.646] kthread+0xfc/0x130 [958.647] ? __pfx_kthread+0x10/0x10 [958.648] ret_from_fork+0x1f7/0x2c0 [958.648] ? __pfx_kthread+0x10/0x10 [958.649] ret_from_fork_asm+0x1a/0x30 [958.650] </TASK> [958.651] task:kworker/u49:7 state:D stack:0 pid:52990 tgid:52990 ppid:2 task_flags:0x4208060 flags:0x00080000 [958.653] Workqueue: writeback wb_workfn (flush-btrfs-334) [958.655] Call Trace: [958.655] <TASK> [958.656] __schedule+0x4be/0x10f0 [958.657] ? __blk_flush_plug+0xe9/0x140 [958.658] schedule+0x26/0xd0 [958.658] io_schedule+0x42/0x70 [958.659] folio_wait_bit_common+0x12b/0x330 [958.660] ? folio_wait_bit_common+0x100/0x330 [958.662] ? __pfx_wake_page_function+0x10/0x10 [958.663] extent_write_cache_pages+0x599/0x830 [btrfs] [958.664] ? acpi_fwnode_get_reference_args+0x1fa/0x270 [958.665] btrfs_writepages+0x77/0x130 [btrfs] [958.666] ? __pfx_end_bbio_data_write+0x10/0x10 [btrfs] [958.667] do_writepages+0xc6/0x160 [958.668] __writeback_single_inode+0x42/0x310 [958.669] writeback_sb_inodes+0x231/0x570 [958.670] wb_writeback+0x8a/0x340 [958.671] wb_workfn+0xbf/0x450 [958.672] ? finish_task_switch.isra.0+0xc1/0x350 [958.673] process_one_work+0x19d/0x3a0 [958.673] worker_thread+0x1c4/0x330 [958.674] ? __pfx_worker_thread+0x10/0x10 [958.675] kthread+0xfc/0x130 [958.676] ? __pfx_kthread+0x10/0x10 [958.676] ret_from_fork+0x1f7/0x2c0 [958.677] ? __pfx_kthread+0x10/0x10 [958.678] ret_from_fork_asm+0x1a/0x30 [958.679] </TASK> [958.679] task:btrfs-cleaner state:D stack:0 pid:296750 tgid:296750 ppid:2 task_flags:0x208040 flags:0x00080000 [958.681] Call Trace: [958.682] <TASK> [958.682] __schedule+0x4be/0x10f0 [958.683] schedule+0x26/0xd0 [958.684] handle_reserve_ticket+0x1b9/0x2c0 [btrfs] [958.685] ? __pfx_autoremove_wake_function+0x10/0x10 [958.686] reserve_bytes+0x283/0x4c0 [btrfs] [958.687] btrfs_reserve_metadata_bytes+0x18/0xb0 [btrfs] [958.688] btrfs_delalloc_reserve_metadata+0x121/0x320 [btrfs] [958.690] btrfs_delalloc_reserve_space+0x46/0xb0 [btrfs] [958.691] btrfs_defrag_file+0x903/0x1110 [btrfs] [958.692] btrfs_run_defrag_inodes+0x334/0x430 [btrfs] [958.694] cleaner_kthread+0x97/0x1c0 [btrfs] [958.694] ? __pfx_cleaner_kthread+0x10/0x10 [btrfs] [958.696] kthread+0xfc/0x130 [958.696] ? __pfx_kthread+0x10/0x10 [958.697] ret_from_fork+0x1f7/0x2c0 [958.698] ? __pfx_kthread+0x10/0x10 [958.699] ret_from_fork_asm+0x1a/0x30 [958.700] </TASK> [958.716] task:fsstress state:D stack:0 pid:296769 tgid:296769 ppid:296768 task_flags:0x400140 flags:0x00080000 [958.718] Call Trace: [958.719] <TASK> [958.719] __schedule+0x4be/0x10f0 [958.720] ? preempt_count_add+0x69/0xa0 [958.721] schedule+0x26/0xd0 [958.722] wb_wait_for_completion+0x79/0xc0 [958.723] ? __pfx_autoremove_wake_function+0x10/0x10 [958.724] __writeback_inodes_sb_nr+0xc5/0xf0 [958.725] try_to_writeback_inodes_sb+0x55/0x70 [958.726] btrfs_commit_transaction+0x19d/0xeb0 [btrfs] [958.727] ? start_transaction+0x343/0x900 [btrfs] [958.728] btrfs_mksubvol+0x28b/0x4e0 [btrfs] [958.729] btrfs_mksnapshot+0x74/0xa0 [btrfs] [958.730] __btrfs_ioctl_snap_create+0x194/0x210 [btrfs] [958.732] btrfs_ioctl_snap_create_v2+0xef/0x150 [btrfs] [958.733] btrfs_ioctl+0x7ec/0x2a70 [btrfs] [958.734] ? __virt_addr_valid+0xe4/0x180 [958.735] ? __check_object_size+0x1cd/0x1f0 [958.736] ? kmem_cache_free+0x146/0x380 [958.737] ? _raw_spin_unlock+0x15/0x30 [958.738] ? do_sys_openat2+0x83/0xd0 [958.739] __x64_sys_ioctl+0x92/0xe0 [958.740] do_syscall_64+0x60/0x590 [958.741] ? clear_bhb_loop+0x60/0xb0 [958.742] entry_SYSCALL_64_after_hwframe+0x76/0x7e [958.743] RIP: 0033:0x7f4431e108db [958.744] RSP: 002b:00007ffcd147db20 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [958.746] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f4431e108db [958.747] RDX: 00007ffcd147eb90 RSI: 0000000050009417 RDI: 0000000000000005 [958.749] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 [958.751] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffcd147fbf0 [958.752] R13: 00007ffcd147eb90 R14: 0000000000000005 R15: 0000000000000003 [958.754] </TASK>
What happens is the following:
1) The cleaner kthread is running autodefrag, and in defrag_one_range() it acquired all the folios for the range and locked them.
Then it locked the extent range in the inode's iotree.
It got two subranges from defrag_collect_targets(), the first one with folio A and the second one with folio B.
After it defragged the first subrange, folio A remains locked and dirty - it's only unlocked when defrag_one_range() returns.
When it attempts to defrag the second subrange (containing folio B), btrfs_delalloc_reserve_space() creates a space reservation ticket, due to lack of free metadata space and blocks waiting for the async metadata reclaim task to free space and wake it up;
2) The async reclaim metadata task attempts to commit the current transaction, but it blocks because there is another task that started the commit first;
3) A task creating a snapshot is committing the transaction and because the fs was mounted with flushoncommit, it calls try_to_writeback_inodes_sb(), which spawns a task to flush delalloc and waits for it to complete;
4) The task flushing delalloc (kworker/u49:7), finds that folio A for the inode being defragged is dirty, so it tries to lock it...
But it blocks because folio A is locked by the defrag task (the cleaner kthread) which is blocked waiting for the reservation ticket to be served, but the async reclaim metadata task is blocked waiting for the transaction commit, which in turn is blocked waiting for the delalloc flush task, which is trying to lock folio A, resulting in a deadlock.
The same type of problem can happen if the async reclaim task starts to flush delalloc, as that requires both locking the folio and the extent range in the inode's io tree, and in this case we don't need the fs to be mounted with flushoncommit. This type of problem has ocurred several times in the past with reflinks for example, where we had a dirty folio while holding the extent range locked and then starting a transaction blocked waiting for the async reclaim task due to lack of free metadata space.
So fix this by reserving delalloc space before locking folios and locking the extent range in the inode's iotree. We can not simply unlock the folios for each subrange given by defrag_collect_targets() after we defrag it because the same folio may be present too in the next subrange (due to large folios).
--- fs/btrfs/defrag.c | 50 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-)
fs/btrfs/defrag.c +33 -17
@@ -1130,20 +1130,15 @@ static_assert(PAGE_ALIGNED(CLUSTER_SIZE));* * - Extent bits are locked */ -static int defrag_one_locked_target (struct btrfs_inode *inode, -struct defrag_target_range *target, -struct folio **folios,int nr_pages, -struct extent_state **cached_state) +static void defrag_one_locked_target (struct btrfs_inode *inode, +struct defrag_target_range *target, +struct folio **folios,int nr_pages, +struct extent_state **cached_state) {struct btrfs_fs_info *fs_info = inode->root->fs_info; -struct extent_changeset *data_reserved =NULL ;const u64 start = target->start;const u64 len = target->len; -int ret =0 ; - ret =btrfs_delalloc_reserve_space (inode, &data_reserved, start, len); -if (ret <0 ) -return ret;btrfs_clear_extent_bit (&inode->io_tree, start, start + len -1 ,EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG , cached_state);
@@ -1164,10 +1159,6 @@ static int defrag_one_locked_target(struct btrfs_inode *inode,continue ;btrfs_folio_clamp_set_dirty (fs_info, folio, start, len); } -btrfs_delalloc_release_extents (inode, len); -extent_changeset_free (data_reserved); - -return ret; } static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,
@@ -1183,6 +1174,8 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,u64 cur = start;const unsigned int nr_pages = ((start + len -1 ) >>PAGE_SHIFT ) - (start >>PAGE_SHIFT ) +1 ; +struct extent_changeset *data_reserved =NULL ; +u64 last_defrag_end = start;int ret =0 ;ASSERT (nr_pages <=CLUSTER_SIZE /PAGE_SIZE );
@@ -1192,6 +1185,22 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,if (!folios)return -ENOMEM ; +/* +* Reserve delalloc space before locking the range and before locking +* and dirtying any folios - otherwise we could deadlock, for example +* after defrag of one range we dirty folios and keep them locked when +* we move to the next range, so reserving delalloc space right before +* each range could trigger flushing of delalloc and deadlock on the +* extent lock or trigger a transaction commit with flushoncommit, which +* can either deadlock on the lock of a folio made dirty in the previous +* range or the extent lock. +*/ + ret =btrfs_delalloc_reserve_space (inode, &data_reserved, start, len); +if (ret <0 ) { +kfree (folios); +return ret; + } +/* Prepare all pages */ for (int i =0 ; cur < start + len && i < nr_pages; i++) { folios[i] =defrag_prepare_one_folio (inode, cur >>PAGE_SHIFT );
@@ -1226,10 +1235,11 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len, goto unlock_extent;list_for_each_entry (entry, &target_list, list) { - ret =defrag_one_locked_target (inode, entry, folios, nr_pages, - &cached_state); -if (ret <0 ) -break ; +defrag_one_locked_target (inode, entry, folios, nr_pages, &cached_state); +if (entry->start > last_defrag_end) +btrfs_delalloc_release_space (inode, data_reserved, last_defrag_end, + entry->start - last_defrag_end, true); + last_defrag_end = entry->start + entry->len; }list_for_each_entry_safe (entry, tmp, &target_list, list) {
@@ -1246,6 +1256,12 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,folio_put (folios[i]); }kfree (folios); +btrfs_delalloc_release_extents (inode, len); +if (last_defrag_end < start + len) +btrfs_delalloc_release_space (inode, data_reserved, last_defrag_end, + start + len - last_defrag_end, true); +extent_changeset_free (data_reserved); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1225/1815 btrfs: always wait for ordered extents to avoid OE races
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit ec78575dde998c21be7e0cb2503b5620f34b6255 ]
[BUG]
Syzbot reported a bug that there can be conflicting OEs for the same range:
BTRFS critical (device loop4): panic in insert_ordered_extent:264: overlapping ordered extents, existing oe file_offset 16384 num_bytes 430080 flags 0x1089, new oe file_offset 16384 num_bytes 430080 flags 0x80 (errno=-17 Object alrea[ 179.162726][ T6897] BTRFS critical (device loop4): panic in insert_ordered_extent:264: overlapping ordered extents, existing oe file_offset 16384 num_bytes 430080 flags 0x1089, new oe file_offset 16384 num_bytes 430080 flags 0x80 (errno=-17 Object already exists)
------------[ cut here ]------------ kernel BUG at fs/btrfs/ordered-data.c:264! Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026 RIP: 0010:btrfs_alloc_ordered_extent+0x943/0xad0 Call Trace: <TASK> cow_file_range+0x744/0x12a0 fallback_to_cow+0x5ea/0xa00 run_delalloc_nocow+0x110c/0x17a0 btrfs_run_delalloc_range+0xbe4/0x1c20 writepage_delalloc+0x104d/0x1ba0 btrfs_writepages+0x1667/0x28b0 do_writepages+0x338/0x560 filemap_fdatawrite_range+0x1f2/0x300 btrfs_fdatawrite_range+0x54/0xf0 btrfs_direct_write+0x6a0/0xc30 btrfs_do_write_iter+0x329/0x790 do_iter_readv_writev+0x624/0x8d0 vfs_writev+0x34c/0x990 __se_sys_pwritev2+0x17a/0x2a0 do_syscall_64+0x174/0x580 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> ---[ end trace 0000000000000000 ]---
[CAUSE]
Since commit ff66fe666233 ("btrfs: fix incorrect buffered IO fallback for append direct writes"), if the direct IO finished short, we will revert the isize back to the original one, so that append writes can be respected during the buffered fallback.
Normally we rely on lock_and_cleanup_extent_if_need() function during buffered writeback to wait for any existing ordered extents.
But that ordered extent waiting only happens if the start_pos is inside the isize.
Since we have reverted the isize during failed direct IO, we will not wait for any ordered extents.
This means we can have a race where the direct IO OE is still in the tree, finished but not yet removed, then we're inserting the OE for the buffered write, causing the above crash.
[FIX]
Make the OE wait to be unconditional, to handle the reverted isize situation.
And since lock_and_cleanup_extent_if_need() now either lock the extents or return -EAGAIN, also remove the branches that handles no-extent-locked cases, and rename it to remove the "_if_need" suffix.
The following micro benchmark shows the runtime difference for btrfs_buffered_write(), doing xfs_io -f -c "pwrite 0 1m" workload, all values are the average runtime in nano seconds.
function runtime | before | after
-----------------------------------+-------------+---------------
lock_and_cleanup_extent_if_need() | 58.2 | 183.0 btrfs_buffered_write() | 2115.6 | 2973.3
The overall runtime of btrfs_buffered_write() is still pretty tiny (still less than 3 micro seconds), I'd say the extra cost is still acceptable.
An alternative to fix this problem is to wait ordered extents during iomap_end() where the isize revert is done.
But that solution will break nowait requirement, as if a nowait direct IO finished short, we have to wait for the OEs unconditionally or the next append buffered IO can still hit the same problem.
So here we have to move the wait cost to buffered write, but at least the code is slightly more streamline.
--- fs/btrfs/file.c | 102 +++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 62 deletions(-)
fs/btrfs/file.c +40 -62
@@ -875,62 +875,56 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_/* * Locks the extent and properly waits for data=ordered extents to finish -* before allowing the folios to be modified if need. +* before allowing the folios to be modified. * * Return: -* 1 - the extent is locked -* 0 - the extent is not locked, and everything is OK +* 0 - the extent is locked * -EAGAIN - need to prepare the folios again */ static noinline int -lock_and_cleanup_extent_if_need (struct btrfs_inode *inode,struct folio *folio, -loff_t pos,size_t write_bytes, -u64 *lockstart,u64 *lockend,bool nowait, -struct extent_state **cached_state) +lock_and_cleanup_extent (struct btrfs_inode *inode,struct folio *folio, +loff_t pos,size_t write_bytes, +u64 *lockstart,u64 *lockend,bool nowait, +struct extent_state **cached_state) {struct btrfs_fs_info *fs_info = inode->root->fs_info; +struct btrfs_ordered_extent *ordered;u64 start_pos;u64 last_pos; -int ret =0 ; start_pos =round_down (pos, fs_info->sectorsize); last_pos =round_up (pos + write_bytes, fs_info->sectorsize) -1 ; -if (start_pos < inode->vfs_inode.i_size) { -struct btrfs_ordered_extent *ordered; - -if (nowait) { -if (!btrfs_try_lock_extent (&inode->io_tree, start_pos, - last_pos, cached_state)) { -folio_unlock (folio); -folio_put (folio); -return -EAGAIN ; - } - }else { -btrfs_lock_extent (&inode->io_tree, start_pos, last_pos, - cached_state); - } - - ordered =btrfs_lookup_ordered_range (inode, start_pos, - last_pos - start_pos +1 ); -if (ordered && - ordered->file_offset + ordered->num_bytes > start_pos && - ordered->file_offset <= last_pos) { -btrfs_unlock_extent (&inode->io_tree, start_pos, last_pos, - cached_state); +if (nowait) { +if (!btrfs_try_lock_extent (&inode->io_tree, start_pos, + last_pos, cached_state)) {folio_unlock (folio);folio_put (folio); -btrfs_start_ordered_extent (ordered); -btrfs_put_ordered_extent (ordered);return -EAGAIN ; } -if (ordered) -btrfs_put_ordered_extent (ordered); + }else { +btrfs_lock_extent (&inode->io_tree, start_pos, last_pos, + cached_state); + } - *lockstart = start_pos; - *lockend = last_pos; - ret =1 ; + ordered =btrfs_lookup_ordered_range (inode, start_pos, + last_pos - start_pos +1 ); +if (ordered && + ordered->file_offset + ordered->num_bytes > start_pos && + ordered->file_offset <= last_pos) { +btrfs_unlock_extent (&inode->io_tree, start_pos, last_pos, + cached_state); +folio_unlock (folio); +folio_put (folio); +btrfs_start_ordered_extent (ordered); +btrfs_put_ordered_extent (ordered); +return -EAGAIN ; } +if (ordered) +btrfs_put_ordered_extent (ordered); + + *lockstart = start_pos; + *lockend = last_pos;/* * We should be called after prepare_one_folio() which should have locked
@@ -938,7 +932,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct folio *folio,*/ WARN_ON (!folio_test_locked (folio)); -return ret; +return 0 ; }/*
@@ -1195,7 +1189,6 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter,const u64 reserved_start =round_down (start, fs_info->sectorsize);u64 reserved_len;struct folio *folio =NULL ; -int extents_locked;u64 lockstart;u64 lockend;bool only_release_metadata = false;
@@ -1253,18 +1246,16 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter, reserved_len = last_block - reserved_start; } - extents_locked =lock_and_cleanup_extent_if_need (inode, folio, start, - write_bytes, &lockstart, - &lockend, nowait, - &cached_state); -if (extents_locked <0 ) { -if (!nowait && extents_locked == -EAGAIN ) + ret =lock_and_cleanup_extent (inode, folio, start, write_bytes, + &lockstart, &lockend, nowait, &cached_state); +if (ret <0 ) { +if (!nowait) goto again;btrfs_delalloc_release_extents (inode, reserved_len);release_space (inode, *data_reserved, reserved_start, reserved_len, only_release_metadata); -return extents_locked; +return ret; } copied = copy_folio_from_iter_atomic(folio, offset_in_folio(folio, start),
@@ -1288,11 +1279,8 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter,/* No copied bytes, unlock, release reserved space and exit. */ if (copied ==0 ) { -if (extents_locked) -btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, - &cached_state); -else -btrfs_free_extent_state (cached_state); +btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, + &cached_state);btrfs_delalloc_release_extents (inode, reserved_len);release_space (inode, *data_reserved, reserved_start, reserved_len, only_release_metadata);
@@ -1311,17 +1299,7 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter, ret =btrfs_dirty_folio (inode, folio, start, copied, &cached_state, only_release_metadata); -/* -* If we have not locked the extent range, because the range's start -* offset is >= i_size, we might still have a non-NULL cached extent -* state, acquired while marking the extent range as delalloc through -* btrfs_dirty_page(). Therefore free any possible cached extent state -* to avoid a memory leak. -*/ -if (extents_locked) -btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state); -else -btrfs_free_extent_state (cached_state); +btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);btrfs_delalloc_release_extents (inode, reserved_len);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1190/1815 md: avoid stale clone I/O accounting timestamps
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 45102fc8330525d35675b1c193242bba101df5ee ]
md_clone_bio() always allocates the clone from mddev->io_clone_set, even when queue I/O stats are disabled. In that case it does not call bio_start_io_acct(), but it also left md_io_clone->start_time untouched.
The clone private data comes from a mempool and can contain data from a previous user. md_end_clone_io() checks start_time to decide whether it needs to call bio_end_io_acct(), so a stale non-zero value can make the completion path end accounting that was never started for this bio.
Set start_time to 0 in the no-stats branch. This keeps the end path tied to whether bio_start_io_acct() actually ran.
--- drivers/md/md.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/md.c +2 -0
@@ -9439,6 +9439,8 @@ static void md_clone_bio(struct mddev *mddev, struct bio **bio) md_io_clone->mddev = mddev;if (blk_queue_io_stat (bdev->bd_disk->queue)) md_io_clone->start_time =bio_start_io_acct (*bio); +else + md_io_clone->start_time =0 ;if (bio_data_dir (*bio) ==WRITE &&md_bitmap_enabled (mddev, false)) { md_io_clone->offset = (*bio)->bi_iter.bi_sector;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1226/1815 btrfs: fix a lockdep caused by path resolution during device scan
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 108cc873398932af589c295f78c348513b8d70d9 ]
[BUG]
There is a lockdep report related to device scan:
======================================================
WARNING: possible circular locking dependency detected 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 Not tainted
------------------------------------------------------
(udev-worker)/1653 is trying to acquire lock:
0000006919232220 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: lookup_slow+0x3e/0x70
but task is already holding lock:00000069238564d8 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60 which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #5 (&fs_devs->device_list_mutex){+.+.}-{3:3}:
lock_acquire+0x150/0x3f0
__mutex_lock+0xba/0xdc0
mutex_lock_nested+0x32/0x40
write_all_supers+0x7a/0x670
btrfs_sync_log+0xae6/0xdd0
btrfs_sync_file+0x4fa/0x7a0
__s390x_sys_fsync+0x52/0xa0
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #4 (&fs_info->tree_log_mutex){+.+.}-{3:3}:
lock_acquire+0x150/0x3f0
__mutex_lock+0xba/0xdc0
mutex_lock_nested+0x32/0x40
btrfs_sync_log+0xaba/0xdd0
btrfs_sync_file+0x4fa/0x7a0
__s390x_sys_fsync+0x52/0xa0
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #3 (btrfs_trans_num_extwriters){.+.+}-{0:0}:
lock_acquire+0x150/0x3f0
join_transaction+0x108/0x680
start_transaction+0x21a/0x660
btrfs_join_transaction+0x32/0x40
btrfs_dirty_inode+0x52/0xf0
touch_atime+0x90/0xc0
filemap_read+0x446/0x450
vfs_read+0x208/0x370
ksys_read+0x88/0x120
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #2 (btrfs_trans_num_writers){.+.+}-{0:0}:
reacquire_held_locks+0x14c/0x240
__lock_release.isra.0+0xd8/0x380
lock_release+0xf6/0x270
percpu_up_read+0x28/0xf0
__btrfs_end_transaction+0x178/0x1f0
btrfs_dirty_inode+0x82/0xf0
touch_atime+0x90/0xc0
btrfs_file_mmap_prepare+0x8c/0xa0
__mmap_region+0x214/0x780
mmap_region+0x108/0x160
do_mmap+0x402/0x5a0
vm_mmap_pgoff+0x156/0x230
ksys_mmap_pgoff+0x17e/0x220
__s390x_sys_old_mmap+0xa8/0x140
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #1 (&mm->mmap_lock){++++}-{3:3}:
lock_acquire+0x150/0x3f0
__might_fault+0x7a/0xa0
filldir64+0x11c/0x210
offset_readdir+0x92/0x200
iterate_dir+0xcc/0x2d0
__do_sys_getdents64+0x7a/0x130
__do_syscall+0x172/0x750
system_call+0x72/0x90
-> #0 (&type->i_mutex_dir_key#2){++++}-{3:3}:
check_prev_add+0x160/0xf40
__lock_acquire+0x12aa/0x15a0
lock_acquire+0x150/0x3f0
down_read+0x5a/0x280
lookup_slow+0x3e/0x70
path_lookupat+0x1f0/0x370
filename_lookup+0xce/0x1f0
kern_path+0x48/0x70
is_same_device+0x146/0x300
device_list_add.constprop.0+0x1be/0xc60
btrfs_scan_one_device+0x13a/0x2f0
btrfs_control_ioctl+0x110/0x1e0
__s390x_sys_ioctl+0xfa/0x130
__do_syscall+0x172/0x750
system_call+0x72/0x90
other info that might help us debug this:
Chain exists of:
&type->i_mutex_dir_key#2 --> &fs_info->tree_log_mutex --> &fs_devs->device_list_mutex
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&fs_devs->device_list_mutex);
lock(&fs_info->tree_log_mutex);
lock(&fs_devs->device_list_mutex);
rlock(&type->i_mutex_dir_key#2);
*** DEADLOCK ***
2 locks held by (udev-worker)/1653:
#0: 0000016c727051c8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_control_ioctl+0x102/0x1e0
#1: 00000069238564d8 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60
stack backtrace:
CPU: 2 UID: 0 PID: 1653 Comm: (udev-worker) Not tainted 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 PREEMPT
Hardware name: IBM 3931 A01 701 (LPAR)
Call Trace:
[<0000016c70680e3e>] dump_stack_lvl+0xae/0x108
[<0000016c7078aa44>] print_circular_bug+0x1a4/0x230
[<0000016c7078ac5c>] check_noncircular+0x18c/0x1b0
[<0000016c7078c030>] check_prev_add+0x160/0xf40
[<0000016c7078fbaa>] __lock_acquire+0x12aa/0x15a0
[<0000016c7078fff0>] lock_acquire+0x150/0x3f0
[<0000016c7180e2fa>] down_read+0x5a/0x280
[<0000016c70b88dde>] lookup_slow+0x3e/0x70
[<0000016c70b8f5d0>] path_lookupat+0x1f0/0x370
[<0000016c70b900ae>] filename_lookup+0xce/0x1f0
[<0000016c70b90218>] kern_path+0x48/0x70
[<0000016c70f5b4a6>] is_same_device+0x146/0x300
[<0000016c70f67cfe>] device_list_add.constprop.0+0x1be/0xc60
[<0000016c70f688da>] btrfs_scan_one_device+0x13a/0x2f0
[<0000016c70ed9cb0>] btrfs_control_ioctl+0x110/0x1e0
[<0000016c70b97d0a>] __s390x_sys_ioctl+0xfa/0x130
[<0000016c718004d2>] __do_syscall+0x172/0x750
[<0000016c718155d2>] system_call+0x72/0x90[CAUSE]
Btrfs device scan will call is_same_device() with device_list_mutex held. But is_same_device() will call kern_path() which will do path resolution and lock the inode.
So device scan has the following lock sequence:
mutex_lock(device_list_mutex) from device_list_add()
|
v
inode_lock_shared() from lookup_slow() during kern_path().
Meanwhile another thread is fsyncing, which has the following lock sequence:
inode_lock() from btrfs_inode_lock() inside btrfs_direct_write()
|
v
mutex_lock(tree_log_mutex() from btrfs_sync_log(), which is further triggered from iomap_dio_complete()->generic_write_sync()->btrfs_sync_file().
|
v
mutex_lock(device_list_mutex) from write_all_supers() inside btrfs_sync_log().
So the device scan has a reversed lock sequence, compared to the fsync one, this means we can have the following deadlock:
Device scan | Fsync
----------------------------------------+--------------------------------
device_list_mutex locked |
| inode locked
| try to lock device_list_mutex
try to lock inode |
[FIX]
Instead of a full path lookup, use dev_t to determine if two device paths are pointing to the same block device.
Inside kernel dev_t is going to uniquely determine a block device, and the device path lookup is already done by lookup_bdev(), which is done without device_list_mutex held, thus no reversed locking sequence.
--- fs/btrfs/volumes.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
fs/btrfs/volumes.c +1 -36
@@ -740,41 +740,6 @@ const u8 *btrfs_sb_fsid_ptr(const struct btrfs_super_block *sb)return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; } -static bool is_same_device (struct btrfs_device *device,const char *new_path) -{ -struct path old = { .mnt =NULL , .dentry =NULL }; -struct path new = { .mnt =NULL , .dentry =NULL }; -char AUTO_KFREE (old_path ); -bool is_same = false; -int ret; - -if (!device->name) - goto out; - - old_path =kzalloc (PATH_MAX ,GFP_NOFS ); -if (!old_path) - goto out; - -rcu_read_lock (); - ret =strscpy (old_path,rcu_dereference (device->name),PATH_MAX ); -rcu_read_unlock (); -if (ret <0 ) - goto out; - - ret =kern_path (old_path,LOOKUP_FOLLOW , &old); -if (ret) - goto out; - ret =kern_path (new_path,LOOKUP_FOLLOW , &new); -if (ret) - goto out; -if (path_equal (&old, &new)) - is_same = true; -out: -path_put (&old); -path_put (&new); -return is_same; -} -/* * Add new device to list of registered devices *
@@ -895,7 +860,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,MAJOR (path_devt),MINOR (path_devt), current->comm, task_pid_nr(current)); - }else if (!device->name || !is_same_device (device, path)) { + }else if (!device->name || device->devt != path_devt) {const char *old_name;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1227/1815 btrfs: make sure EXTENT_BUFFER_READING is cleared under refs_lock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 690c2accacb1aca91ab8186d15dee56da8723f31 ]
[FALSE ALERTS]
There is a bug report that the warning inside invalidate_and_check_btree_folios() got triggered during btrfs/298:
BTRFS info (device sdd): first mount of filesystem f9bf732a-a19b-44b9-99a7-614ddff168e2
BTRFS info (device sdd): using crc32c checksum algorithm
BTRFS error (device sdd): failed to find fsid cb2fdb42-b638-4f2f-badd-4127467ba674 when attempting to open seed devices BTRFS error (device sdd): failed to read chunk tree: -2
------------[ cut here ]------------ WARNING: disk-io.c:3342 at invalidate_and_check_btree_folios+0x260/0x3c0 [btrfs], CPU#4: mount/125993 CPU: 4 UID: 0 PID: 125993 Comm: mount Tainted: G W OE 7.1.0-rc7-custom+ #1 PREEMPT(full) Hardware name: QEMU KVM Virtual Machine, BIOS edk2-20250812-19.fc42 08/12/2025 Call trace: invalidate_and_check_btree_folios+0x260/0x3c0 [btrfs] (P) open_ctree+0x1f50/0x23b0 [btrfs] btrfs_get_tree+0x89c/0xc48 [btrfs] vfs_get_tree+0x30/0x110 vfs_cmd_create+0x58/0xe8 __arm64_sys_fsconfig+0x39c/0x518 invoke_syscall.constprop.0+0x48/0x120 el0_svc_common.constprop.0+0x40/0xe8 do_el0_svc+0x24/0x38 el0_svc+0x50/0x310 el0t_64_sync_handler+0xa0/0xe8 el0t_64_sync+0x198/0x1a0 ---[ end trace 0000000000000000 ]--- BTRFS warning (device sdd): unable to release extent buffer 365985792 owner 3 gen 17 refs 3 flags 0x5
[CAUSE]
In that invalidate_and_check_btree_folios() we wait for the eb to finish its read, then check if it's only held by us and the btree inode.
If not, then do a warning as it may be still held, and could cause problems.
But there is a small window where the check can lead to false alerts:
Thread A (Read endio) | Thread B (Unmount)
----------------------------------+-------------------------------------
end_bbio_meta_read() | | The eb has one extra ref held | | by the reader, and has | | EXTENT_BUFFER_READING flag set | invalidate_and_check_btree_folios() | | | |- clear_extent_buffer_reading() | | | | |- wait_on_bit_io(); | | | The EXTENT_BUFFER_READING flag is | | | cleared | | |- if (refcount_read(eb->refs) > 2) | | The eb is held by the read, us | | and btree inode, thus it | | will trigger the warning |- free_extent_buffer() |
[FIX]
Introduce a helper, free_extent_buffer_clear_reading().
If the new parameter, @clear_reading, is set, we will hold the spinlock at the beginning of free_extent_buffer_clear_reading() to make sure the EXTENT_BUFFER_READING flag is cleared inside the same critical section of decreasing refs.
Now free_extent_buffer() will just call free_extent_buffer_clear_reading() with @clear_reading set to false, so no behavior change.
But for end_bbio_meta_read(), it will not clear_extent_buffer_reading() directly, but pass @clear_reading as true.
Then inside invalidate_and_check_btree_folios(), hold the refs_lock before reading refs.
So that we eliminate the race window completely.
--- fs/btrfs/disk-io.c | 16 ++++++++++++++-- fs/btrfs/extent_io.c | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 12 deletions(-)
fs/btrfs/disk-io.c +14 -2
@@ -3314,6 +3314,8 @@ static void invalidate_and_check_btree_folios(struct btrfs_fs_info *fs_info)*/ rcu_read_lock ();xa_for_each (&fs_info->buffer_tree, index, eb) { +unsigned int refs; +/* Increase the ref so that the eb won't disappear. */ if (!refcount_inc_not_zero (&eb->refs))continue ;
@@ -3323,17 +3325,27 @@ static void invalidate_and_check_btree_folios(struct btrfs_fs_info *fs_info)if (test_bit (EXTENT_BUFFER_READING , &eb->bflags))wait_on_bit_io (&eb->bflags,EXTENT_BUFFER_READING ,TASK_UNINTERRUPTIBLE ); +/* +* We hold the spinlock to make sure above +* EXTENT_BUFFER_READING flag is cleared with the held +* ref dropped. +* Or we can hit a race window and lead to false alerts. +*/ +spin_lock (&eb->refs_lock); + refs =refcount_read (&eb->refs); +spin_unlock (&eb->refs_lock); +/* * The refs threshold is 2, one held by us at the beginning * of the loop, one for the ownership in the buffer tree. */ -if (unlikely (refcount_read (&eb->refs) >2 ||extent_buffer_under_io (eb))) { +if (unlikely (refs >2 ||extent_buffer_under_io (eb))) {WARN_ON_ONCE (IS_ENABLED (CONFIG_BTRFS_DEBUG ));btrfs_warn (fs_info,"unable to release extent buffer %llu owner %llu gen %llu refs %u flags 0x%lx" , eb->start,btrfs_header_owner (eb),btrfs_header_generation (eb), -refcount_read (&eb->refs), eb->bflags); + refs, eb->bflags); }free_extent_buffer (eb);rcu_read_lock ();
fs/btrfs/extent_io.c +33 -10
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1228/1815 btrfs: check if root is readonly when setting posix acl
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sun YangKai <[email protected]>
[ Upstream commit 01c2f41fc441f75b3f9326443372faceb1cb6638 ]
For a filesystem which has btrfs read-only property set to true, all write operations including acl and xattr should be denied. However, acl can still be set even if btrfs ro property is true.
This happens because no function on the set_acl code path checks the root is readonly or not. It was checked in btrfs_setxattr_trans() but got removed in commit 353c2ea735e4 ("btrfs: remove redundant readonly root check in btrfs_setxattr_trans")
That commit didn't check if all the callers properly check the root's read-only flag. A previous fix is commit b51111271b03 ("btrfs: check if root is readonly while setting security xattr").
Always check if the root is read-only before performing the set acl operation.
--- fs/btrfs/acl.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/acl.c +4 -0
@@ -15,6 +15,7 @@#include "xattr.h" #include "acl.h" #include "misc.h" +#include "btrfs_inode.h" struct posix_acl *btrfs_get_acl (struct inode *inode,int type,bool rcu) {
@@ -107,6 +108,9 @@ int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,struct inode *inode =d_inode (dentry);umode_t old_mode = inode->i_mode; +if (btrfs_root_readonly (BTRFS_I (inode)->root)) +return -EROFS ; +if (type ==ACL_TYPE_ACCESS && acl) { ret =posix_acl_update_mode (idmap, inode, &inode->i_mode, &acl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1229/1815 btrfs: replace writeback inhibition xarray with a fixed inline buffer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Martins <[email protected]>
[ Upstream commit 67bd829a14b7d71ffea28147b98dadf9ee684568 ]
Commit f9a48549a15a ("btrfs: inhibit extent buffer writeback to prevent COW amplification") tracks the extent buffers a transaction handle has inhibited in a per-handle xarray. Keying the tracking to the transaction handle is correct, but using an xarray for it causes two problems in production.
First, a write_iops regression. Every COW calls btrfs_inhibit_eb_writeback() from btrfs_force_cow_block() and should_cow_block(), which does an xa_store() keyed by eb->start. The kernel test robot reported a 22.6% fio.write_iops regression on a single-task 4k randwrite workload (ftruncate ioengine, buffered IO) on btrfs. The cost is the per-COW xarray store done on every COW'd block. Replacing it with a non-allocating fixed buffer recovers the lost throughput, and that buffer does more per-COW bookkeeping yet still recovers, so the cost is the xarray operation itself rather than the extra tracking work.
Second, an unbounded cleanup walk. btrfs_uninhibit_all_eb_writeback() iterates every eb the handle inhibited with xa_for_each(). A single handle that COWs a very large number of blocks (inode eviction, or truncate of a file with many extents, where btrfs_truncate_inode_items() loops over many search_again descents under one handle) makes that walk arbitrarily long. It runs in __btrfs_end_transaction() before num_writers is dropped, so it blocks the committing thread; this shows up as multi-second stalls and RCU stall reports.
Replace the xarray with a fixed inline array on btrfs_trans_handle, managed with a CLOCK (second-chance) eviction policy. Inhibiting a buffer becomes an array append with no allocation and no tree walk, and the end-of-handle cleanup is bounded by the array size.
The set that actually needs protection is the working set the handle revisits across search_again descents, the search path frontier, which is on the order of the tree height. It is not every block the handle ever COWs. should_cow_block() re-inhibiting an already tracked buffer marks it referenced, so revisited buffers survive eviction while write-once buffers are reclaimed first. A small fixed buffer is therefore enough where a non-evicting array would either overflow or have to grow without bound. BTRFS_INHIBITED_EBS_SLOTS is 8 and the reference bits pack into a u32.
The CLOCK eviction is what justifies the extra complexity over a plain non-evicting array. The test workload stresses amplification: it removes 16 heavily fragmented 64 MiB files in one transaction while background writeback keeps writing out in-use metadata. A re-COW event is a buffer already COWed in the running transaction that was written back and then COWed again; the figure below is the ratio of re-COW events to first-COW events summed across the eviction (n=5, lower is better):
tracking re-COW per first-COW no inhibition 6.1 non-evicting array, 32 slots 3.8 CLOCK array, 8 slots (this patch) 1.6 unbounded xarray (reverted) 1.4
The non-evicting array fills with write-once buffers and stops covering the buffers the handle keeps revisiting, so even at four times the slots it leaves most of the amplification. CLOCK evicts the cold buffers and keeps the revisited ones, recovering almost all of the unbounded benefit. The eviction policy, not the buffer size, is what closes the gap.
eb->writeback_inhibitors and the WB_SYNC_ALL bypass in lock_extent_buffer_for_io() are unchanged, so fsync and commit behavior are unaffected. A reference is taken on each tracked buffer so it cannot be freed while the array points at it; eviction drops that reference and the inhibitor count.
There's another testing report, showing 20% latency improvement on
reflink and deduplication synthetic benchmark. Full detailed report at
https://github.com/lcf0399/linux-regression-evidence/tree/main/btrfs-remap-writeback-inhibition-v2 .
--- fs/btrfs/extent_io.c | 87 ++++++++++++++++++++++++++---------------- fs/btrfs/transaction.c | 2 - fs/btrfs/transaction.h | 25 ++++++++++-- 3 files changed, 77 insertions(+), 37 deletions(-)
fs/btrfs/extent_io.c +55 -32
@@ -3129,47 +3129,71 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)kmem_cache_free (extent_buffer_cache, eb); } +/* +* Claim a slot to track an extent buffer in, evicting the coldest tracked buffer +* when the array is full. +* +* Slots fill in order until the array is full. After that a CLOCK (second +* chance) scan advances the hand, clearing one reference bit per step, until +* it lands on an unreferenced slot whose buffer is evicted. Clearing a bit per +* step bounds the scan to BTRFS_INHIBITED_EBS_SLOTS iterations. +*/ +static int btrfs_inhibit_claim_slot (struct btrfs_trans_handle *trans) +{ +int slot; + +if (trans->nr_inhibited_ebs <BTRFS_INHIBITED_EBS_SLOTS ) +return trans->nr_inhibited_ebs++; + +while (trans->inhibited_ebs_referenced & (1U << trans->inhibited_ebs_hand)) { + trans->inhibited_ebs_referenced &= ~(1U << trans->inhibited_ebs_hand); + trans->inhibited_ebs_hand = + (trans->inhibited_ebs_hand +1 ) %BTRFS_INHIBITED_EBS_SLOTS ; + } + slot = trans->inhibited_ebs_hand; + trans->inhibited_ebs_hand = (trans->inhibited_ebs_hand +1 ) %BTRFS_INHIBITED_EBS_SLOTS ; + +atomic_dec (&trans->inhibited_ebs[slot]->writeback_inhibitors); +free_extent_buffer (trans->inhibited_ebs[slot]); + +return slot; +} +/* * Inhibit writeback on buffer during transaction. * * @trans: transaction handle that will own the inhibitor * @eb: extent buffer to inhibit writeback on * -* Attempt to track this extent buffer in the transaction's inhibited set. If -* memory allocation fails, the buffer is simply not tracked. It may be written -* back and need re-COW, which is the original behavior. This is acceptable -* since inhibiting writeback is an optimization. +* Attempt to track this extent buffer in the transaction's inhibited set. When +* the set is full the coldest tracked buffer is evicted instead. An untracked +* buffer may be written back and need re-COW, which is the original behavior. +* This is acceptable since inhibiting writeback is an optimization. */ void btrfs_inhibit_eb_writeback (struct btrfs_trans_handle *trans,struct extent_buffer *eb) { -unsigned long index = eb->start >> trans->fs_info->nodesize_bits; -void *old; +int slot;lockdep_assert_held (&eb->lock); -/* Check if already inhibited by this handle. */ - old =xa_load (&trans->writeback_inhibited_ebs, index); -if (old == eb) -return ; - -/* Take reference for the xarray entry. */ -refcount_inc (&eb->refs); - old =xa_store (&trans->writeback_inhibited_ebs, index, eb,GFP_NOFS ); -if (xa_is_err (old)) { -/* Allocation failed, just skip inhibiting this buffer. */ -free_extent_buffer (eb); -return ; +/* Already tracked: set its reference bit (second chance) and return. */ +for (int i =0 ; i < trans->nr_inhibited_ebs; i++) { +if (trans->inhibited_ebs[i] == eb) { + trans->inhibited_ebs_referenced |=1U << i; +return ; + } } -/* Handle replacement of different eb at same index. */ -if (old && old != eb) { -struct extent_buffer *old_eb = old; - -atomic_dec (&old_eb->writeback_inhibitors); -free_extent_buffer (old_eb); - } + slot =btrfs_inhibit_claim_slot (trans); +/* +* Pin the eb while the array holds a raw pointer to it; the counter is +* what lock_extent_buffer_for_io() checks. +*/ +refcount_inc (&eb->refs);atomic_inc (&eb->writeback_inhibitors); + trans->inhibited_ebs[slot] = eb; + trans->inhibited_ebs_referenced |=1U << slot; }/*
@@ -3177,14 +3201,13 @@ void btrfs_inhibit_eb_writeback(struct btrfs_trans_handle *trans, struct extent_*/ void btrfs_uninhibit_all_eb_writeback (struct btrfs_trans_handle *trans) { -struct extent_buffer *eb; -unsigned long index; - -xa_for_each (&trans->writeback_inhibited_ebs, index, eb) { -atomic_dec (&eb->writeback_inhibitors); -free_extent_buffer (eb); +for (int i =0 ; i < trans->nr_inhibited_ebs; i++) { +atomic_dec (&trans->inhibited_ebs[i]->writeback_inhibitors); +free_extent_buffer (trans->inhibited_ebs[i]); } -xa_destroy (&trans->writeback_inhibited_ebs); + trans->nr_inhibited_ebs =0 ; + trans->inhibited_ebs_referenced =0 ; + trans->inhibited_ebs_hand =0 ; } static struct extent_buffer *__alloc_extent_buffer(struct btrfs_fs_info *fs_info,
fs/btrfs/transaction.c +0 -2
@@ -698,8 +698,6 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, goto alloc_fail; } -xa_init (&h->writeback_inhibited_ebs); -/* * If we are JOIN_NOLOCK we're already committing a transaction and * waiting on this guy, so we don't need to do the sb_start_intwrite
fs/btrfs/transaction.h +22 -3
@@ -7,12 +7,12 @@#define BTRFS_TRANSACTION_H #include <linux/atomic.h> +#include <linux/build_bug.h> #include <linux/refcount.h> #include <linux/list.h> #include <linux/time64.h> #include <linux/mutex.h> #include <linux/wait.h> -#include <linux/xarray.h> #include "btrfs_inode.h" #include "delayed-ref.h"
@@ -23,6 +23,7 @@ struct btrfs_fs_info;struct btrfs_root_item ;struct btrfs_root ;struct btrfs_path ; +struct extent_buffer ;/* * Signal that a direct IO write is in progress, to avoid deadlock for sync
@@ -136,6 +137,18 @@ enum {#define TRANS_EXTWRITERS (__TRANS_START | __TRANS_ATTACH) +/* +* Number of extent buffers a transaction handle tracks for writeback +* inhibition. The CLOCK reference bits pack into a u32 so this must not exceed +* 32, and keeping it a power of two lets the compiler reduce the CLOCK hand +* modulo to a mask. +*/ +#define BTRFS_INHIBITED_EBS_SLOTS 8 + +static_assert (BTRFS_INHIBITED_EBS_SLOTS <=32 ); +static_assert (BTRFS_INHIBITED_EBS_SLOTS !=0 && + (BTRFS_INHIBITED_EBS_SLOTS & (BTRFS_INHIBITED_EBS_SLOTS -1 )) ==0 ); +struct btrfs_trans_handle {u64 transid;u64 bytes_reserved;
@@ -163,8 +176,14 @@ struct btrfs_trans_handle {struct btrfs_fs_info *fs_info;struct list_head new_bgs;struct btrfs_block_rsv delayed_rsv; -/* Extent buffers with writeback inhibited by this handle. */ -struct xarray writeback_inhibited_ebs; + +/* Extent buffers this handle has inhibited writeback on. */ +struct extent_buffer *inhibited_ebs[BTRFS_INHIBITED_EBS_SLOTS ]; +/* CLOCK reference bit per slot. */ +u32 inhibited_ebs_referenced; +u32 nr_inhibited_ebs; +/* CLOCK hand. */ +u32 inhibited_ebs_hand; };/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1230/1815 btrfs: retry verity reads for not-uptodate Merkle folios
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 8cc569696dac51fc62bb39b3b8f530582b916d29 ]
btrfs_read_merkle_tree_page() can find a folio in the mapping that is not uptodate. After taking the folio lock, the current code treats that state as a read error and returns -EIO.
That can make a previous transient read failure sticky. If the failed read left a not-uptodate folio in the mapping, later callers find that folio and fail instead of retrying the read.
Keep the existing page-cache insertion and locking order, but retry the Merkle item read when a not-uptodate folio is found in the mapping. Also unlock the folio when read_key_bytes() fails so that a later caller can lock it and retry the read.
--- fs/btrfs/verity.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/btrfs/verity.c +11 -5
@@ -720,14 +720,18 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, goto out;folio_lock (folio); -/* If it's not uptodate after we have the lock, we got a read error. */ -if (!folio_test_uptodate (folio)) { +/* Folio was truncated from mapping. */ +if (!folio->mapping) {folio_unlock (folio);folio_put (folio); -return ERR_PTR (-EIO ); + goto again; } -folio_unlock (folio); - goto out; +/* Another reader may have filled the folio while we waited. */ +if (folio_test_uptodate (folio)) { +folio_unlock (folio); + goto out; + } + goto read_folio; } folio = filemap_alloc_folio(mapping_gfp_constraint(inode->i_mapping, ~__GFP_FS),
@@ -744,6 +748,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode,return ERR_PTR (ret); } +read_folio:/* * Merkle item keys are indexed from byte 0 in the merkle tree. * They have the form:
@@ -753,6 +758,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, ret =read_key_bytes (BTRFS_I (inode),BTRFS_VERITY_MERKLE_ITEM_KEY , off,folio_address (folio),PAGE_SIZE , folio);if (ret <0 ) { +folio_unlock (folio);folio_put (folio);return ERR_PTR (ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1231/1815 btrfs: zoned: flush active metadata block group at btree_writepages() start
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit ecc05eda9a346848ae01a6c8bfa3f0bec133bd8b ]
btree_writepages() writes the btree inode's dirty metadata in ascending logical address order. On a zoned filesystem only one metadata and one system block group is active for writing at a time, and check_bg_is_active() (via btrfs_check_meta_write_pointer()) pivots the active block group as writeback moves from one block group to the next.
If the active block group sits at a higher logical address than another block group that also holds dirty metadata, the ascending walk reaches the lower one first and, to write it, has to finish the active block group and activate the lower one. It cannot finish a block group that still has unsent IO, and during WB_SYNC_ALL && !for_sync (commit) writeback it deliberately refuses to wait for that IO under fs_info->zoned_meta_io_lock, as that can deadlock. The pivot thus cannot issue the submission itself either, so it gives up:btrfs_check_meta_write_pointer() returns -EAGAIN, which btrfs_write_and_wait_transaction() treats as fatal and aborts the transaction, forcing the filesystem read-only. This happens intermittently under metadata-heavy relocation (e.g. fstests btrfs/187).
Flush the active metadata and system block groups at the start of btree_writepages(), under the fs_info->zoned_meta_io_lock it already holds, so they have no unsent IO left and the later pivot can finish them and make forward progress.
--- fs/btrfs/extent_io.c | 113 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 92 insertions(+), 21 deletions(-)
fs/btrfs/extent_io.c +92 -21
@@ -2496,6 +2496,76 @@ void btrfs_btree_wait_writeback_range(struct btrfs_fs_info *fs_info, u64 start, } } +static int write_meta_extent_buffer (struct btrfs_eb_write_context *ctx, +struct writeback_control *wbc) +{ +struct extent_buffer *eb = ctx->eb; +int ret; + + ret =btrfs_check_meta_write_pointer (eb->fs_info, ctx); +if (ret) +return ret; + +if (!lock_extent_buffer_for_io (eb, wbc)) +return 0 ; + +/* Implies write in zoned mode. */ +if (ctx->zoned_bg) { +/* Mark the last eb in the block group. */ +btrfs_schedule_zone_finish_bg (ctx->zoned_bg, eb); + ctx->zoned_bg->meta_write_pointer += eb->len; + } +write_one_eb (eb, wbc); +return 0 ; +} + +/* +* On a zoned filesystem, write out the currently dirty metadata extent buffers +* of @bg. Used to flush the active metadata/system block group before the +* ascending-address walk in btree_writepages(), so that walk can pivot the +* active block group away (finishing it) instead of aborting the commit; see +* the caller for details. +*/ +static void flush_active_meta_bg (struct address_space *mapping, +struct writeback_control *wbc, +struct btrfs_eb_write_context *ctx, +struct btrfs_block_group *bg) +{ +struct btrfs_fs_info *fs_info =inode_to_fs_info (mapping->host); +unsigned long index = bg->start >> fs_info->nodesize_bits; +unsigned long end = (btrfs_block_group_end (bg) -1 ) >> fs_info->nodesize_bits; +struct eb_batch batch; +unsigned int nr_ebs; + +ASSERT (btrfs_is_zoned (fs_info)); +lockdep_assert_held (&fs_info->zoned_meta_io_lock); + +eb_batch_init (&batch); +while (index <= end && + (nr_ebs =buffer_tree_get_ebs_tag (fs_info, &index, end, +PAGECACHE_TAG_DIRTY , &batch))) { +struct extent_buffer *eb; + +while ((eb =eb_batch_next (&batch)) !=NULL ) { + ctx->eb = eb; + +/* +* If the eb is behind the write pointer (-EBUSY, e.g. +* already being written by someone else) skip it and +* carry on. Only a hole at the write pointer (-EAGAIN) +* stops the flush. The main walk in btree_writepages() +* then deals with it. +*/ +if (write_meta_extent_buffer (ctx, wbc) == -EAGAIN ) { +eb_batch_release (&batch); +return ; + } + } +eb_batch_release (&batch); +cond_resched (); + } +} +int btree_writepages (struct address_space *mapping,struct writeback_control *wbc) {struct btrfs_eb_write_context ctx = { .wbc = wbc };
@@ -2531,6 +2601,22 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wbelse tag =PAGECACHE_TAG_DIRTY ;btrfs_zoned_meta_io_lock (fs_info); + +/* +* On a zoned filesystem, flush the currently active metadata/system +* block group(s) first, under this same lock, so the ascending-address +* walk below can pivot the active block group instead of aborting the +* transaction commit with -EAGAIN. +*/ +if (btrfs_is_zoned (fs_info) && wbc->sync_mode ==WB_SYNC_ALL && + !wbc->for_sync) { +if (fs_info->active_meta_bg) +flush_active_meta_bg (mapping, wbc, &ctx, + fs_info->active_meta_bg); +if (fs_info->active_system_bg) +flush_active_meta_bg (mapping, wbc, &ctx, + fs_info->active_system_bg); + } retry:if (wbc->sync_mode ==WB_SYNC_ALL )buffer_tree_tag_for_writeback (fs_info, index, end);
@@ -2541,28 +2627,13 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wbwhile ((eb =eb_batch_next (&batch)) !=NULL ) { ctx.eb = eb; - ret =btrfs_check_meta_write_pointer (eb->fs_info, &ctx); -if (ret) { -if (ret == -EBUSY ) - ret =0 ; - -if (ret) { - done = true; -break ; - } -continue ; - } - -if (!lock_extent_buffer_for_io (eb, wbc)) -continue ; - -/* Implies write in zoned mode. */ -if (ctx.zoned_bg) { -/* Mark the last eb in the block group. */ -btrfs_schedule_zone_finish_bg (ctx.zoned_bg, eb); - ctx.zoned_bg->meta_write_pointer += eb->len; + ret =write_meta_extent_buffer (&ctx, wbc); +if (ret == -EBUSY ) { + ret =0 ; + }else if (ret) { + done = true; +break ; } -write_one_eb (eb, wbc); } nr_to_write_done = (wbc->nr_to_write <=0 );eb_batch_release (&batch);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1191/1815 md/md-llbitmap: prevent create failure bitmap UAF
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 2116c2f0a0e547615886900e2ed8c529c016499b ]
llbitmap_create() publishes mddev->bitmap before reading the bitmap superblock. This is needed because llbitmap_read_sb() can initialize a new bitmap and flush it through helpers that use mddev->bitmap.
If llbitmap_read_sb() fails, the old cleanup dropped bitmap_info.mutex and freed llbitmap before clearing mddev->bitmap. Readers such as /proc/mdstat rely on bitmap_info.mutex to keep the bitmap pointer stable while collecting bitmap stats, so they could observe the stale pointer after the failed create path released the mutex.
Clear mddev->bitmap while still holding bitmap_info.mutex, then free the failed llbitmap after dropping the mutex. This makes mutex-protected readers see either a live bitmap or no bitmap.
--- drivers/md/md-llbitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/md-llbitmap.c +2 -1
@@ -1126,10 +1126,11 @@ static int llbitmap_create(struct mddev *mddev)mutex_lock (&mddev->bitmap_info.mutex); mddev->bitmap = llbitmap; ret =llbitmap_read_sb (llbitmap); +if (ret) + mddev->bitmap =NULL ;mutex_unlock (&mddev->bitmap_info.mutex);if (ret) {kfree (llbitmap); - mddev->bitmap =NULL ; }return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1192/1815 md/md-llbitmap: stop daemon timer rearm on destroy
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 5553d64e01d9a995be6c3de38501c6dd4ceede3b ]
llbitmap_destroy() deletes pending_timer before flushing md_llbitmap_io_wq. However, daemon_work can still be queued or running after the timer has been deleted, and the daemon path can arm pending_timer again when it finds dirty chunks that are not ready to flush yet.
If that happens during teardown, pending_timer can remain armed after llbitmap is freed and later dereference freed memory.
Add a BITMAP_SHUTDOWN bit to llbitmap->flags, set it before deleting the timer, and make the timer and daemon paths stop queueing or rearming work once teardown starts. Cancel daemon_work before flushing the shared workqueue so no already queued daemon instance can race with the free. Use timer_shutdown_sync() so a daemon instance that passed the shutdown check before teardown cannot rearm the timer afterward.
BITMAP_SHUTDOWN is a runtime-only state. Mask it out when reading and updating the llbitmap superblock so the shutdown state is never loaded from disk or persisted to disk.
--- drivers/md/md-bitmap.h | 1 + drivers/md/md-llbitmap.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/md/md-bitmap.h +1 -0
@@ -29,6 +29,7 @@ enum bitmap_state {BITMAP_FIRST_USE =3 ,/* llbitmap is just created */ BITMAP_CLEAN =4 ,/* llbitmap is created with assume_clean */ BITMAP_DAEMON_BUSY =5 ,/* llbitmap daemon is not finished after daemon_sleep */ +BITMAP_SHUTDOWN =6 ,/* llbitmap is being destroyed */ BITMAP_HOSTENDIAN =15, };
drivers/md/md-llbitmap.c +13 -4
@@ -789,6 +789,7 @@ static enum llbitmap_state llbitmap_state_machine(struct llbitmap *llbitmap,if (state == BitNeedSync || state == BitNeedSyncUnwritten) need_resync = !mddev->degraded;else if (state == BitDirty && + !test_bit (BITMAP_SHUTDOWN , &llbitmap->flags) && !timer_pending (&llbitmap->pending_timer))mod_timer (&llbitmap->pending_timer, jiffies + mddev->bitmap_info.daemon_sleep *HZ );
@@ -981,7 +982,7 @@ static int llbitmap_read_sb(struct llbitmap *llbitmap)else mddev->bitmap_info.space = mddev->bitmap_info.default_space; } - llbitmap->flags =le32_to_cpu (sb->state); + llbitmap->flags =le32_to_cpu (sb->state) & ~BIT (BITMAP_SHUTDOWN );if (test_and_clear_bit (BITMAP_FIRST_USE , &llbitmap->flags)) { ret =llbitmap_init (llbitmap); goto out_put_page;
@@ -1037,6 +1038,9 @@ static void llbitmap_pending_timer_fn(struct timer_list *pending_timer)struct llbitmap *llbitmap = container_of(pending_timer, struct llbitmap, pending_timer); +if (test_bit (BITMAP_SHUTDOWN , &llbitmap->flags)) +return ; +if (work_busy (&llbitmap->daemon_work)) { pr_warn("md/llbitmap: %s daemon_work not finished in %lu seconds\n", mdname(llbitmap->mddev),
@@ -1057,6 +1061,9 @@ static void md_llbitmap_daemon_fn(struct work_struct *work)bool restart;int idx; +if (test_bit (BITMAP_SHUTDOWN , &llbitmap->flags)) +return ; +if (llbitmap->mddev->degraded)return ; retry:
@@ -1096,7 +1103,7 @@ static void md_llbitmap_daemon_fn(struct work_struct *work) goto retry;/* If some page is dirty but not expired, setup timer again */ -if (restart) +if (restart && !test_bit (BITMAP_SHUTDOWN , &llbitmap->flags))mod_timer (&llbitmap->pending_timer, jiffies + llbitmap->mddev->bitmap_info.daemon_sleep *HZ ); }
@@ -1179,7 +1186,9 @@ static void llbitmap_destroy(struct mddev *mddev)mutex_lock (&mddev->bitmap_info.mutex); -timer_delete_sync (&llbitmap->pending_timer); +set_bit (BITMAP_SHUTDOWN , &llbitmap->flags); +timer_shutdown_sync (&llbitmap->pending_timer); +cancel_work_sync (&llbitmap->daemon_work);flush_workqueue (md_llbitmap_io_wq);flush_workqueue (md_llbitmap_unplug_wq);
@@ -1518,7 +1527,7 @@ static void llbitmap_update_sb(void *data) sb =kmap_local_page (sb_page); sb->events =cpu_to_le64 (mddev->events); - sb->state =cpu_to_le32 (llbitmap->flags); + sb->state =cpu_to_le32 (llbitmap->flags & ~BIT (BITMAP_SHUTDOWN )); sb->chunksize =cpu_to_le32 (llbitmap->chunksize); sb->sync_size =cpu_to_le64 (mddev->resync_max_sectors); sb->events_cleared =cpu_to_le64 (llbitmap->events_cleared);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1193/1815 md/raid1: dont set array_frozen in raid1_takeover()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bruce Johnston <[email protected]>
[ Upstream commit dc386aa0ac0a3ec06c9a3ea9b064b073fb72a916 ]
raid1_takeover() sets conf->array_frozen = 1 on the newly-allocated r1conf and nothing ever clears it, so every I/O to the array stalls permanently once _wait_barrier() sees it stuck at 1.
This used to be harmless: level_store() called mddev_resume() right after pers->run(), which called raid1_quiesce(mddev, 0) and cleared array_frozen back to 0 regardless of what raid1_takeover() set. Commit b39f35ebe86d ("md: don't quiesce in mddev_suspend()") removed that quiesce(mddev, 0) call, so the pre-set now sticks.
setup_conf() already zero-initializes the new r1conf via kzalloc, so just don't set array_frozen here.
Same class of bug as commit 892da88d1cd9 ("md/raid10: fix a 'conf->barrier' leakage in raid10_takeover()"), also triggered by b39f35ebe86d.
--- drivers/md/raid1.c | 2 -- 1 file changed, 2 deletions(-)
drivers/md/raid1.c +0 -2
@@ -3428,8 +3428,6 @@ static void *raid1_takeover(struct mddev *mddev) mddev->new_chunk_sectors =0 ; conf =setup_conf (mddev);if (!IS_ERR (conf)) { -/* Array must appear to be quiesced */ - conf->array_frozen =1 ;mddev_clear_unsupported_flags (mddev,UNSUPPORTED_MDDEV_FLAGS ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1194/1815 coresight: etm4x: fix wrong check of etm4x_sspcicrn_present()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 0e1cd4270b42a257c139165622091e1e8c7104a7 ]
According to Embedded Trace Macrocell Architecture Specification ETMv4.0 to ETM4.6 [0], TRCSSPCICR<n> is present only if all of the following are true:
- TRCIDR4.NUMSSCC > n.
- TRCIDR4.NUMPC > 0b0000.
- TRCSSCSR<n>.PC == 0b1.
Comment for etm4x_sspcicrn_present() is align with the specification. However, the check should use drvdata->nr_pe_cmp to check TRCIDR4.NUMPC not nr_pe.
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +1 -1
@@ -93,7 +93,7 @@ static int etm4_probe_cpu(unsigned int cpu);static bool etm4x_sspcicrn_present (struct etmv4_drvdata *drvdata,int n) {return (n < drvdata->nr_ss_cmp) && - drvdata->nr_pe && + drvdata->nr_pe_cmp && (drvdata->config.ss_status[n] & TRCSSCSRn_PC); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1195/1815 coresight: etm4x: fix underflow for usage of (nrseqstate - 1)
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 1674d9bff8073bdee5dbc200f56fc3caa28d0566 ]
According to IHI006H Embedded Trace Macrocell Architecture Specification[0], TRCSEQEVR<n> is implemented only when TRCIDR5.NUMSEQSTATE is 0b100, in which case n ranges from 0 to 2; otherwise, TRCIDR5.NUMSEQSTATE is 0b000.
IOW, the number of usage in the initialisation or setting TRCSEQEVR<n> with drvdata->nrseqstate - 1 in the loop could make underflow issue when TRCIDR5.NUMSEQSTATE is 0b000.
Therefore, introduce nr_seq_ctrls field and untie it from nrseqstate. As part of this introduce ETM_MAX_SEQ_TRANSITIONS macro and apply nr_seq_ctrls and above macro to TRCSEQEVR<n> relevant fields setup.
--- drivers/hwtracing/coresight/coresight-etm4x-cfg.c | 2 +- drivers/hwtracing/coresight/coresight-etm4x-core.c | 9 ++++++--- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 6 ++++-- drivers/hwtracing/coresight/coresight-etm4x.h | 7 +++++-- 4 files changed, 16 insertions(+), 8 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-cfg.c +1 -1
@@ -76,7 +76,7 @@ static int etm4_cfg_map_reg_offset(struct etmv4_drvdata *drvdata, }else if ((offset &GENMASK (11 ,4 )) ==TRCSEQEVRn (0 )) {/* sequencer state control registers */ idx = (offset &GENMASK (3 ,0 )) /4 ; -if (idx <ETM_MAX_SEQ_STATES ) { +if (idx <ETM_MAX_SEQ_TRANSITIONS ) { reg_csdev->driver_regval = &drvcfg->seq_ctrl[idx]; err =0 ; }
drivers/hwtracing/coresight/coresight-etm4x-core.c +6 -3
@@ -542,7 +542,8 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)etm4x_relaxed_write32 (csa, config->vissctlr,TRCVISSCTLR );if (drvdata->nr_pe_cmp)etm4x_relaxed_write32 (csa, config->vipcssctlr,TRCVIPCSSCTLR ); -for (i =0 ; i < drvdata->nrseqstate -1 ; i++) + +for (i =0 ; i < drvdata->nr_seq_ctrls; i++)etm4x_relaxed_write32 (csa, config->seq_ctrl[i],TRCSEQEVRn (i));if (drvdata->nrseqstate) {etm4x_relaxed_write32 (csa, config->seq_rst,TRCSEQRSTEVR );
@@ -1508,6 +1509,8 @@ static void etm4_init_arch_data(void *info) drvdata->lpoverride = (etmidr5 &TRCIDR5_LPOVERRIDE ) && (!drvdata->skip_power_up);/* NUMSEQSTATE, bits[27:25] number of sequencer states implemented */ drvdata->nrseqstate =FIELD_GET (TRCIDR5_NUMSEQSTATE_MASK , etmidr5); +if (drvdata->nrseqstate) + drvdata->nr_seq_ctrls =ETM_MAX_SEQ_TRANSITIONS ;/* NUMCNTR, bits[30:28] number of counters available for tracing */ drvdata->nr_cntr =FIELD_GET (TRCIDR5_NUMCNTR_MASK , etmidr5);
@@ -1896,7 +1899,7 @@ static int etm4_cpu_save(struct coresight_device *csdev)if (drvdata->nr_pe_cmp) state->trcvipcssctlr =etm4x_read32 (csa,TRCVIPCSSCTLR ); -for (i =0 ; i < drvdata->nrseqstate -1 ; i++) +for (i =0 ; i < drvdata->nr_seq_ctrls; i++) state->trcseqevr[i] =etm4x_read32 (csa,TRCSEQEVRn (i));if (drvdata->nrseqstate) {
@@ -2009,7 +2012,7 @@ static void etm4_cpu_restore(struct coresight_device *csdev)if (drvdata->nr_pe_cmp)etm4x_relaxed_write32 (csa, state->trcvipcssctlr,TRCVIPCSSCTLR ); -for (i =0 ; i < drvdata->nrseqstate -1 ; i++) +for (i =0 ; i < drvdata->nr_seq_ctrls; i++)etm4x_relaxed_write32 (csa, state->trcseqevr[i],TRCSEQEVRn (i));if (drvdata->nrseqstate) {
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +4 -2
@@ -223,7 +223,7 @@ static ssize_t reset_store(struct device *dev, config->vipcssctlr =0x0 ;/* Disable seq events */ -for (i =0 ; i < drvdata->nrseqstate-1 ; i++) +for (i =0 ; i < drvdata->nr_seq_ctrls; i++) config->seq_ctrl[i] =0x0 ; config->seq_rst =0x0 ; config->seq_state =0x0 ;
@@ -1395,9 +1395,11 @@ static ssize_t seq_idx_store(struct device *dev,struct etmv4_drvdata *drvdata =dev_get_drvdata (dev->parent);struct etmv4_config *config = &drvdata->config; +if (!drvdata->nr_seq_ctrls) +return -ENOTSUPP ;if (kstrtoul (buf,16 , &val))return -EINVAL ; -if (val >= drvdata->nrseqstate -1 ) +if (val >= drvdata->nr_seq_ctrls)return -EINVAL ;/*
drivers/hwtracing/coresight/coresight-etm4x.h +5 -2
@@ -614,6 +614,7 @@ static inline u32 etm4_res_sel_pair(u8 res_sel_idx)#define ETM_MAX_NR_PE 8#define ETMv4_MAX_CNTR 4#define ETM_MAX_SEQ_STATES 4 +#define ETM_MAX_SEQ_TRANSITIONS 3#define ETM_MAX_EXT_INP_SEL 4#define ETM_MAX_EXT_INP 256#define ETM_MAX_EXT_OUT 4
@@ -877,7 +878,7 @@ struct etmv4_config {u32 vipcssctlr;u8 seq_idx;u8 syncfreq; -u32 seq_ctrl[ETM_MAX_SEQ_STATES ]; +u32 seq_ctrl[ETM_MAX_SEQ_TRANSITIONS ];u32 seq_rst;u32 seq_state;u8 cntr_idx;
@@ -928,7 +929,7 @@ struct etmv4_save_state {u32 trcvissctlr;u32 trcvipcssctlr; -u32 trcseqevr[ETM_MAX_SEQ_STATES ]; +u32 trcseqevr[ETM_MAX_SEQ_TRANSITIONS ];u32 trcseqrstevr;u32 trcseqstr;u32 trcextinselr;
@@ -981,6 +982,7 @@ struct etmv4_save_state {* @numcidc: Number of contextID comparators. * @numvmidc: Number of VMID comparators. * @nrseqstate: The number of sequencer states that are implemented. +* @nr_seq_ctrls: The number of sequence state transition control registers. * @nr_event: Indicates how many events the trace unit support. * @nr_resource:The number of resource selection pairs available for tracing. * @nr_ss_cmp: Number of single-shot comparator controls that are available.
@@ -1046,6 +1048,7 @@ struct etmv4_drvdata {u8 numextinsel;u8 numvmidc;u8 nrseqstate; +u8 nr_seq_ctrls;u8 nr_event;u8 nr_resource;u8 nr_ss_cmp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1186/1815 phy: qcom: qmp-usb: Fix possible NULL-deref on early runtime suspend
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loic Poulain <[email protected]>
[ Upstream commit 142c5593379273264474f31d5956b1a0065cd576 ]
There is a small window where the runtime suspend callback may run after pm_runtime_enable() and before pm_runtime_forbid(). In this case, a crash occurs because runtime suspend/resume dereferences qmp->phy pointer, which is not yet initialized:
`if (!qmp->phy->init_count) {`This can also happen if user re-enables runtime-pm via the sysfs attribute before qmp phy is initialized.
Similarly to other qcom phy drivers, introduce a qmp->phy_initialized variable that can be used to avoid relying on the possibly uninitialized phy pointer.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +10 -2
@@ -1434,6 +1434,8 @@ struct qmp_usb {enum phy_mode mode; +bool phy_initialized; +struct phy *phy;struct clk_fixed_rate pipe_clk_fixed;
@@ -2009,6 +2011,7 @@ static int qmp_usb_power_off(struct phy *phy)static int qmp_usb_enable (struct phy *phy) { +struct qmp_usb *qmp =phy_get_drvdata (phy);int ret; ret =qmp_usb_init (phy);
@@ -2018,14 +2021,19 @@ static int qmp_usb_enable(struct phy *phy) ret =qmp_usb_power_on (phy);if (ret)qmp_usb_exit (phy); +else + qmp->phy_initialized = true;return ret; }static int qmp_usb_disable (struct phy *phy) { +struct qmp_usb *qmp =phy_get_drvdata (phy);int ret; + qmp->phy_initialized = false; + ret =qmp_usb_power_off (phy);if (ret)return ret;
@@ -2101,7 +2109,7 @@ static int __maybe_unused qmp_usb_runtime_suspend(struct device *dev)dev_vdbg (dev,"Suspending QMP phy, mode:%d\n" , qmp->mode); -if (!qmp->phy->init_count) { +if (!qmp->phy_initialized) {dev_vdbg (dev,"PHY not initialized, bailing out\n" );return 0 ; }
@@ -2121,7 +2129,7 @@ static int __maybe_unused qmp_usb_runtime_resume(struct device *dev)dev_vdbg (dev,"Resuming QMP phy, mode:%d\n" , qmp->mode); -if (!qmp->phy->init_count) { +if (!qmp->phy_initialized) {dev_vdbg (dev,"PHY not initialized, bailing out\n" );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1233/1815 btrfs: use aligned range for locking in extent_fiemap()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 681e073614515b892cacef0eeec0c761a2c2ab87 ]
The @end parameter for all extent io tree helpers is inclusive, but the call site in extent_fiemap() is passing an exclusive end into btrfs_lock_extent(), which will step into the next block unexpectedly.
Pass the inclusive end into btrfs_lock_extent() and btrfs_unlock_extent().
--- fs/btrfs/fiemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/fiemap.c +2 -2
@@ -660,7 +660,7 @@ static int extent_fiemap(struct btrfs_inode *inode, range_end =round_up (start + len, sectorsize); prev_extent_end = range_start; -btrfs_lock_extent (&inode->io_tree, range_start, range_end, &cached_state); +btrfs_lock_extent (&inode->io_tree, range_start, range_end -1 , &cached_state); ret =fiemap_find_last_extent_offset (inode, path, &last_extent_end);if (ret <0 )
@@ -840,7 +840,7 @@ static int extent_fiemap(struct btrfs_inode *inode, } out_unlock: -btrfs_unlock_extent (&inode->io_tree, range_start, range_end, &cached_state); +btrfs_unlock_extent (&inode->io_tree, range_start, range_end -1 , &cached_state);if (ret ==BTRFS_FIEMAP_FLUSH_CACHE ) {btrfs_release_path (path);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1242/1815 pinctrl: airoha: an7583: fix spi group pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit ccc41d25590645096bdbf420b43e7c22627b3f59 ]
pcm pins were used insted of spi pins. This patch fixes an issue.
Thanks to Daniel Schwierzeck for noticing it.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +1 -1
@@ -738,7 +738,7 @@ static const int an7583_jtag_udi_pins[] = { 23, 24, 22, 25, 26 };static const int an7583_jtag_dfd_pins[] = {23 ,24 ,22 ,25 ,26 };static const int an7583_pcm1_pins[] = {10 ,11 ,12 ,13 ,14 };static const int an7583_pcm2_pins[] = {28 ,29 ,30 ,31 ,24 }; -static const int an7583_spi_pins[] = {28 ,29 ,30 ,31 }; +static const int an7583_spi_pins[] = {45 ,46 ,47 ,48 };static const int an7583_spi_quad_pins[] = {25 ,26 };static const int an7583_spi_cs1_pins[] = {27 };static const int an7583_pcm_spi_pins[] = {28 ,29 ,30 ,31 ,10 ,11 ,12 ,13 };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1243/1815 pinctrl: airoha: add missed get_direction() function for gpio_chip
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit d6392502a9e6b11c3a93eb4c987672a8c638d749 ]
This patch adds missed get_direction() function for gpio_chip. Also it reimplements pinconf's get_direction() function using newly defined function.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 50 +++++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +34 -16
@@ -2504,6 +2504,22 @@ static int airoha_gpio_get(struct gpio_chip *chip, unsigned int gpio)return err ? err : !!(val &BIT (pin)); } +static int airoha_gpio_get_direction (struct gpio_chip *chip,unsigned int gpio) +{ +struct airoha_pinctrl *pinctrl =gpiochip_get_data (chip); +u32 val, mask; +u8 index; +int err; + + index = gpio /AIROHA_REG_GPIOCTRL_NUM_PIN ; + err =regmap_read (pinctrl->regmap, pinctrl->gpiochip.dir[index], &val); +if (err) +return err; + + mask =BIT (2 * (gpio %AIROHA_REG_GPIOCTRL_NUM_PIN )); +return val & mask ?GPIO_LINE_DIRECTION_OUT :GPIO_LINE_DIRECTION_IN ; +} +static int airoha_gpio_direction_output (struct gpio_chip *chip,unsigned int gpio,int value) {
@@ -2637,19 +2653,13 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,struct device *dev = &pdev->dev;int irq, err; - chip->data = gpio_data_regs; - chip->dir = gpio_dir_regs; - chip->out = gpio_out_regs; - chip->status = irq_status_regs; - chip->level = irq_level_regs; - chip->edge = irq_edge_regs; - gc->parent = dev; gc->label =dev_name (dev); gc->request = gpiochip_generic_request; gc->free = gpiochip_generic_free; gc->direction_input = pinctrl_gpio_direction_input; gc->direction_output = airoha_gpio_direction_output; + gc->get_direction = airoha_gpio_get_direction; gc->set = airoha_gpio_set; gc->get = airoha_gpio_get; gc->base =-1 ;
@@ -2859,21 +2869,18 @@ static int airoha_pinctrl_set_conf(struct airoha_pinctrl *pinctrl,static int airoha_pinconf_get_direction (struct pinctrl_dev *pctrl_dev,u32 p) {struct airoha_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctrl_dev); -u32 val, mask; -int err, pin; -u8 index; +int ret, pin; pin =airoha_convert_pin_to_reg_offset (pctrl_dev,NULL , p);if (pin <0 )return pin; - index = pin /AIROHA_REG_GPIOCTRL_NUM_PIN ; - err =regmap_read (pinctrl->regmap, pinctrl->gpiochip.dir[index], &val); -if (err) -return err; + ret =airoha_gpio_get_direction (&pinctrl->gpiochip.chip, pin); +if (ret <0 ) +return ret; - mask =BIT (2 * (pin %AIROHA_REG_GPIOCTRL_NUM_PIN )); -return val & mask ?PIN_CONFIG_OUTPUT_ENABLE :PIN_CONFIG_INPUT_ENABLE ; +return ret ==GPIO_LINE_DIRECTION_OUT ? +PIN_CONFIG_OUTPUT_ENABLE :PIN_CONFIG_INPUT_ENABLE ; } static int airoha_pinconf_get(struct pinctrl_dev *pctrl_dev,
@@ -3119,6 +3126,17 @@ static int airoha_pinctrl_probe(struct platform_device *pdev) pinctrl->desc.pins = data->pins; pinctrl->desc.npins = data->num_pins; +/* +* some pinctrl operations (ex: get_direction) might use gpio registers +* before gpio chip abstraction will be completely initialized. +*/ + pinctrl->gpiochip.data = gpio_data_regs; + pinctrl->gpiochip.dir = gpio_dir_regs; + pinctrl->gpiochip.out = gpio_out_regs; + pinctrl->gpiochip.status = irq_status_regs; + pinctrl->gpiochip.level = irq_level_regs; + pinctrl->gpiochip.edge = irq_edge_regs; + err =devm_pinctrl_register_and_init (dev, &pinctrl->desc, pinctrl, &pinctrl->ctrl);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1244/1815 pinctrl: airoha: fix getting gpiochip/pinctrl pointers in the IRQ handling code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit b8dd30554847bde27e8a4584dd447c1c3ac585ce ]
airoha_irq_unmask(), airoha_irq_mask(), airoha_irq_type() functions impements brain damaged logic to retrieve gpiochip and pinctrl pointers.
Details:
gpiochip = irq_data_get_irq_chip_data(data);
will initialize gpiochip variable with data->chip_data value. This value initialized inside gpiochip_irq_map() function
static int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
irq_hw_number_t hwirq)
{
struct gpio_chip *gc = d->host_data;
...
irq_set_chip_data(irq, gc);
...
}Thus gpiochip variable of 'struct airoha_pinctrl_gpiochip *' type will be initialized with a pointer to a variable of 'struct gpio_chip' type.
Luckily, gpio_chip is the first element of airoha_pinctrl_gpiochip, so gpiochip pointer will get a correct value.
This patch implements correct logic of getting gpiochip and pinctrl pointers.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +9 -11
@@ -2535,18 +2535,17 @@ static int airoha_gpio_direction_output(struct gpio_chip *chip,/* irq callbacks */ static void airoha_irq_unmask (struct irq_data *data) { +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip;u8 offset = data->hwirq %AIROHA_REG_GPIOCTRL_NUM_PIN ;u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); -struct airoha_pinctrl_gpiochip *gpiochip; -struct airoha_pinctrl *pinctrl;u32 val =BIT (2 * offset); - gpiochip =irq_data_get_irq_chip_data (data);if (WARN_ON_ONCE (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)))return ; - pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip);switch (gpiochip->irq_type[data->hwirq]) {case IRQ_TYPE_LEVEL_LOW : val = val <<1 ;
@@ -2572,14 +2571,12 @@ static void airoha_irq_unmask(struct irq_data *data)static void airoha_irq_mask (struct irq_data *data) { +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip;u8 offset = data->hwirq %AIROHA_REG_GPIOCTRL_NUM_PIN ;u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); -struct airoha_pinctrl_gpiochip *gpiochip; -struct airoha_pinctrl *pinctrl; - - gpiochip =irq_data_get_irq_chip_data (data); - pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip);regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask);
@@ -2587,9 +2584,10 @@ static void airoha_irq_mask(struct irq_data *data)static int airoha_irq_type (struct irq_data *data,unsigned int type) { -struct airoha_pinctrl_gpiochip *gpiochip; +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip; - gpiochip =irq_data_get_irq_chip_data (data);if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1245/1815 pinctrl: airoha: add missed IRQ resource helpers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a02fa031b9520e46e98bff17e12b472eba770670 ]
Without hooking .irq_request_resources, gpiolib cannot set GPIOD_FLAG_USED_AS_IRQ. This breaks pin direction locking and can allow userspace or another driver to reconfigure an active IRQ pin as an output
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/airoha/pinctrl-airoha.c +1 -0
@@ -2640,6 +2640,7 @@ static const struct irq_chip airoha_gpio_irq_chip = { .irq_mask_ack = airoha_irq_mask, .irq_set_type = airoha_irq_type, .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1246/1815 pinctrl: airoha: fix IRQ mask/unmask code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 20b996280640f492ebdd41c2d2c991801df75e61 ]
When using IRQCHIP_IMMUTABLE, airoha_irq_unmask() must manually call gpiochip_enable_irq() and airoha_irq_mask() must call gpiochip_disable_irq(). Without these calls, gpiolib never sets the GPIOD_FLAG_IRQ_IS_ENABLED bit. Because this bit is missing, gpiod_direction_output() will not realize the pin is actively used as an interrupt.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/airoha/pinctrl-airoha.c +2 -0
@@ -2546,6 +2546,7 @@ static void airoha_irq_unmask(struct irq_data *data)if (WARN_ON_ONCE (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)))return ; +gpiochip_enable_irq (gc,irqd_to_hwirq (data));switch (gpiochip->irq_type[data->hwirq]) {case IRQ_TYPE_LEVEL_LOW : val = val <<1 ;
@@ -2580,6 +2581,7 @@ static void airoha_irq_mask(struct irq_data *data)regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask); +gpiochip_disable_irq (gc,irqd_to_hwirq (data)); }static int airoha_irq_type (struct irq_data *data,unsigned int type)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1247/1815 pinctrl: airoha: fix edge-triggered interrupts handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 3de4686cdf0ccf6d78ca96ccaea621cbcf69fc3a ]
Edge-triggered interrupts are handled incorrectly because of
* no irq_ack() handler was defined,
* no handle_level_irq() handler was used,
This patch probably fixes an issue
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 37 ++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +33 -4
@@ -2579,11 +2579,28 @@ static void airoha_irq_mask(struct irq_data *data)u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); +if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)) +return ; +regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask);gpiochip_disable_irq (gc,irqd_to_hwirq (data)); } +static void airoha_irq_ack (struct irq_data *data) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip; +u8 offset = data->hwirq %AIROHA_PIN_BANK_SIZE ; +u8 index = data->hwirq /AIROHA_PIN_BANK_SIZE ; + +if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)) +return ; + +regmap_write (pinctrl->regmap, gpiochip->status[index],BIT (offset)); +} +static int airoha_irq_type (struct irq_data *data,unsigned int type) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data);
@@ -2593,13 +2610,26 @@ static int airoha_irq_type(struct irq_data *data, unsigned int type)if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type))return -EINVAL ; +if (type ==IRQ_TYPE_NONE ) { + gpiochip->irq_type[data->hwirq] =IRQ_TYPE_NONE ; +irq_set_handler_locked (data, handle_bad_irq); + +return 0 ; + } +if (type ==IRQ_TYPE_PROBE ) {if (gpiochip->irq_type[data->hwirq])return 0 ; type =IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING ; } + gpiochip->irq_type[data->hwirq] = type &IRQ_TYPE_SENSE_MASK ; +if (type &IRQ_TYPE_EDGE_BOTH ) +irq_set_handler_locked (data, handle_edge_irq); +else +irq_set_handler_locked (data, handle_level_irq); +return 0 ; }
@@ -2624,8 +2654,7 @@ static irqreturn_t airoha_irq_handler(int irq, void *data)for_each_set_bit (irq, &status,AIROHA_PIN_BANK_SIZE ) {u32 offset = irq + i *AIROHA_PIN_BANK_SIZE ; -generic_handle_irq (irq_find_mapping (girq->domain, - offset)); +generic_handle_domain_irq (girq->domain, offset);regmap_write (pinctrl->regmap, pinctrl->gpiochip.status[i],BIT (irq)); }
@@ -2639,7 +2668,7 @@ static const struct irq_chip airoha_gpio_irq_chip = { .name = "airoha-gpio-irq", .irq_unmask = airoha_irq_unmask, .irq_mask = airoha_irq_mask, - .irq_mask_ack = airoha_irq_mask, + .irq_ack = airoha_irq_ack, .irq_set_type = airoha_irq_type, .flags =IRQCHIP_SET_TYPE_MASKED |IRQCHIP_IMMUTABLE , GPIOCHIP_IRQ_RESOURCE_HELPERS,
@@ -2667,7 +2696,7 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl, gc->ngpio =AIROHA_NUM_PINS ; girq->default_type =IRQ_TYPE_NONE ; - girq->handler = handle_simple_irq; + girq->handler = handle_bad_irq;gpio_irq_chip_set_chip (girq, &airoha_gpio_irq_chip); irq =platform_get_irq (pdev,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1248/1815 Bluetooth: virtio_bt: avoid OOB read of build info string
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 502adc06ba76dee19c292ae4a07d74d202fe734d ]
The virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read Build Information) and hands the response to bt_dev_info() and hci_set_fw_info() as a "%s" string starting at skb->data + 1, without checking the length. A backend that answers with status only leaves that pointer past the end of the received data, so the walk reads adjacent slab memory until it meets a NUL. Those bytes reach the kernel log and the firmware-info debugfs file.
To fix this, print the string with a bounded "%.*s" limited to skb->len - 1. A short or unterminated response then prints as much as arrived instead of failing setup.
This mirrors commit dd068ef04412 ("Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup()"), which fixed the identical pattern.
--- drivers/bluetooth/virtio_bt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/virtio_bt.c +6 -2
@@ -120,9 +120,13 @@ static int virtbt_setup_zephyr(struct hci_dev *hdev)if (IS_ERR (skb))return PTR_ERR (skb); -bt_dev_info (hdev,"%s" , (char *)(skb->data +1 )); +/* Bounded print: the backend controls skb->len. */ +if (skb->len >1 ) { +int len = skb->len -1 ; -hci_set_fw_info (hdev,"%s" , skb->data +1 ); +bt_dev_info (hdev,"%.*s" , len, (char *)(skb->data +1 )); +hci_set_fw_info (hdev,"%.*s" , len, skb->data +1 ); + }kfree_skb (skb);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1249/1815 Bluetooth: L2CAP: use proto_lock for l2cap_data to fix l2cap_disconn_ind
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 2b66c83ff1751d6bd3201b3017206262ab46dc05 ]
hci_conn::l2cap_data is accessed without locks in l2cap_disconn_ind via hci_conn_timeout (disc_work) -> hci_proto_disconn_ind -> l2cap_disconn_ind. This is UAF if the l2cap_conn is deleted concurrently.
disc_work is disabled sync in hci_conn_del(), so we cannot take hci_dev_lock in disc_work.
Fix by using proto_lock to guard l2cap_data, in addition to hdev->lock which is held in other access paths.
--- net/bluetooth/l2cap_core.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
net/bluetooth/l2cap_core.c +17 -6
@@ -1833,7 +1833,10 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)hci_chan_del (conn->hchan); conn->hchan =NULL ; +spin_lock (&hcon->proto_lock); hcon->l2cap_data =NULL ; +spin_unlock (&hcon->proto_lock); +mutex_unlock (&conn->lock);l2cap_conn_put (conn); }
@@ -7168,8 +7171,6 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) }kref_init (&conn->ref); - hcon->l2cap_data = conn; - conn->hcon =hci_conn_get (hcon); conn->hchan = hchan;BT_DBG ("hcon %p conn %p hchan %p" , hcon, conn, hchan);
@@ -7198,6 +7199,11 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) conn->disc_reason =HCI_ERROR_REMOTE_USER_TERM ; +spin_lock (&hcon->proto_lock); + conn->hcon =hci_conn_get (hcon); + hcon->l2cap_data = conn; +spin_unlock (&hcon->proto_lock); +return conn; }
@@ -7582,13 +7588,18 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)int l2cap_disconn_ind (struct hci_conn *hcon) { -struct l2cap_conn *conn = hcon->l2cap_data; +struct l2cap_conn *conn; +int ret =HCI_ERROR_REMOTE_USER_TERM ;BT_DBG ("hcon %p" , hcon); -if (!conn) -return HCI_ERROR_REMOTE_USER_TERM ; -return conn->disc_reason; +spin_lock (&hcon->proto_lock); + conn = hcon->l2cap_data; +if (conn) + ret = conn->disc_reason; +spin_unlock (&hcon->proto_lock); + +return ret; }static void l2cap_disconn_cfm (struct hci_conn *hcon,u8 reason)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1250/1815 Bluetooth: btintel: Fix diagnostics event detection
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit ad0e7ac7da9a9a0095570bd6add3e27f259de104 ]
For a diagnostics VSE, diagnostics_hdr[] sits at the start of the event payload, skb->data[2], but btintel_recv_event() wrongly guards its memcmp with @len, which is measured from skb->data[3] for the earlier INTEL_BOOTLOADER check.
Fix by using (@len + 1) instead, which ==
(skb->len - HCI_EVENT_HDR_SIZE) exactly.
--- drivers/bluetooth/btintel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/btintel.c +1 -1
@@ -3834,7 +3834,7 @@ int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)/* Handle all diagnostics events separately. May still call * hci_recv_frame. */ -if (len >=sizeof (diagnostics_hdr) && +if (len +1 >=sizeof (diagnostics_hdr) &&memcmp (&skb->data[2 ], diagnostics_hdr,sizeof (diagnostics_hdr)) ==0 ) {return btintel_diagnostics (hdev, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1251/1815 Bluetooth: hci_conn: fix the SCO setup context lifetime
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 42de40abe25db9211107af8896d0fd741f10648d ]
hci_setup_sync() queues a conn_handle_t with a NULL destroy callback, so the context is only freed if hci_enhanced_setup_sync() actually runs. An entry that is cancelled instead is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered.
The context also stores a bare hci_conn pointer, so the connection can be freed while the work is queued. The dequeue in hci_conn_del() does not cover it either, as it matches on entry->data == conn and entry->data is the wrapper here. Same problem as commit 2f5d635ad590 ("Bluetooth:hci_sync: hold conn in hci_connect_acl/le_sync() callbacks").
Hold the connection and release both from a destroy callback. The submission failure path drops both, since hci_cmd_sync_submit() does not call the destroy callback when it fails to queue.
--- net/bluetooth/hci_conn.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/bluetooth/hci_conn.c +15 -5
@@ -283,8 +283,6 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)struct hci_cp_enhanced_setup_sync_conn cp;const struct sco_param *param; -kfree (conn_handle); -if (!hci_conn_valid (hdev, conn))return -ECANCELED ;
@@ -453,6 +451,15 @@ static bool hci_setup_sync_conn(struct hci_conn *conn, __u16 handle)return true; } +static void hci_enhanced_setup_sync_destroy (struct hci_dev *hdev,void *data, +int err) +{ +struct conn_handle_t *conn_handle = data; + +hci_conn_put (conn_handle->conn); +kfree (conn_handle); +} +bool hci_setup_sync (struct hci_conn *conn,__u16 handle) {int result;
@@ -464,12 +471,15 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle)if (!conn_handle)return false; - conn_handle->conn = conn; + conn_handle->conn =hci_conn_get (conn); conn_handle->handle = handle; result =hci_cmd_sync_queue (conn->hdev, hci_enhanced_setup_sync, - conn_handle,NULL ); -if (result <0 ) + conn_handle, + hci_enhanced_setup_sync_destroy); +if (result <0 ) { +hci_conn_put (conn);kfree (conn_handle); + }return result ==0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1234/1815 btrfs: qgroup: fix a wrong length calculation in qgroup_free_reserved_data()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 9102b179512e11644fb0489ae62010a09afa199c ]
In that function, we round down the start position and round up the ending position.
But during the calculation of @len, we use "round_up(start + len, sectorsize)", which is the rounded up end position, not the rounded up length.
Which results a much larger length, and later we are still using "start + len", which is completely incorrect.
Fix it by declaring a local @aligned_start and @aligned_len and use them instead.
--- fs/btrfs/qgroup.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
fs/btrfs/qgroup.c +11 -7
@@ -4339,12 +4339,13 @@ static int qgroup_free_reserved_data(struct btrfs_inode *inode,struct ulist_node *unode;struct ulist_iterator uiter;struct extent_changeset changeset; +const u32 sectorsize = root->fs_info->sectorsize; +const u64 aligned_start =round_down (start, sectorsize); +const u64 aligned_len =round_up (start + len, sectorsize) - aligned_start;u64 freed =0 ;int ret;extent_changeset_init_bytes_only (&changeset); - len =round_up (start + len, root->fs_info->sectorsize); - start =round_down (start, root->fs_info->sectorsize);ULIST_ITER_INIT (&uiter);while ((unode =ulist_next (&reserved->range_changed, &uiter))) {
@@ -4356,12 +4357,15 @@ static int qgroup_free_reserved_data(struct btrfs_inode *inode,extent_changeset_release (&changeset); -/* Only free range in range [start, start + len) */ -if (range_start >= start + len || - range_start + range_len <= start) +/* +* Only free the range within +* [aligned_start, aligned_start + aligned_len). +*/ +if (range_start >= aligned_start + aligned_len || + range_start + range_len <= aligned_start)continue ; - free_start =max (range_start, start); - free_len =min (start + len, range_start + range_len) - + free_start =max (range_start, aligned_start); + free_len =min (aligned_start + aligned_len, range_start + range_len) - free_start;/* * TODO: To also modify reserved->ranges_reserved to reflect
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1252/1815 Bluetooth: hci_sync: free the advertising instance on the failure and cancel paths
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 120d8dc042e3d45073bb6e50ee7b058a0b182627 ]
adv_timeout_expire() hands a kmalloc()ed instance byte to hci_cmd_sync_queue() with a NULL destroy callback, and only adv_timeout_expire_sync() frees it. That leaks on two paths:
- the return value is not checked, and hci_cmd_sync_queue() does not take ownership when it fails (-ENETDOWN, -ENODEV, -ENOMEM);
- a cancelled entry is not released, as _hci_cmd_sync_cancel_entry() does not free entry->data when there is no destroy callback. hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered.
Free the buffer from a destroy callback, and in the caller when the entry could not be queued at all.
--- net/bluetooth/hci_sync.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/bluetooth/hci_sync.c +9 -3
@@ -540,8 +540,6 @@ static int adv_timeout_expire_sync(struct hci_dev *hdev, void *data) {u8 instance = *(u8 *)data; -kfree (data); -hci_clear_adv_instance_sync (hdev,NULL , instance, false);if (list_empty (&hdev->adv_instances))
@@ -550,6 +548,12 @@ static int adv_timeout_expire_sync(struct hci_dev *hdev, void *data)return 0 ; } +static void adv_timeout_expire_destroy (struct hci_dev *hdev,void *data, +int err) +{ +kfree (data); +} +static void adv_timeout_expire (struct work_struct *work) {u8 *inst_ptr;
@@ -570,7 +574,9 @@ static void adv_timeout_expire(struct work_struct *work) goto unlock; *inst_ptr = hdev->cur_adv_instance; -hci_cmd_sync_queue (hdev, adv_timeout_expire_sync, inst_ptr,NULL ); +if (hci_cmd_sync_queue (hdev, adv_timeout_expire_sync, inst_ptr, + adv_timeout_expire_destroy) <0 ) +kfree (inst_ptr); unlock:hci_dev_unlock (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1253/1815 Bluetooth: MGMT: free the mesh send cancel command when it is cancelled
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 3c742feda8fcabf741a17bcf668b63c8f606f9c5 ]
mesh_send_cancel() queues the pending command with a NULL destroy callback, so it is only freed if send_cancel() runs. A cancelled entry is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered. Nothing else reclaims it either: mgmt_pending_new() does not put the command on hdev->mgmt_pending.
The leak also pins the socket reference taken by mgmt_pending_new(), so the mgmt socket is never released.
Free the command from a destroy callback.
--- net/bluetooth/mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +7 -2
@@ -2431,11 +2431,15 @@ static int send_cancel(struct hci_dev *hdev, void *data)mgmt_cmd_complete (cmd->sk, hdev->id,MGMT_OP_MESH_SEND_CANCEL ,0 ,NULL ,0 ); -mgmt_pending_free (cmd);return 0 ; } +static void send_cancel_destroy (struct hci_dev *hdev,void *data,int err) +{ +mgmt_pending_free (data); +} +static int mesh_send_cancel (struct sock *sk,struct hci_dev *hdev,void *data,u16 len) {
@@ -2456,7 +2460,8 @@ static int mesh_send_cancel(struct sock *sk, struct hci_dev *hdev,if (!cmd) err = -ENOMEM ;else - err =hci_cmd_sync_queue (hdev, send_cancel, cmd,NULL ); + err =hci_cmd_sync_queue (hdev, send_cancel, cmd, + send_cancel_destroy);if (err <0 ) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1254/1815 Bluetooth: MGMT: free the HCI command when it is cancelled
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 414b365ecea6c30357adee6b8a7c5edc03a03575 ]
mgmt_hci_cmd_sync() queues the pending command with a NULL destroy callback, so it is only freed if send_hci_cmd_sync() runs. A cancelled entry is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered. Nothing else reclaims it either: mgmt_pending_new() does not put the command on hdev->mgmt_pending.
The leak also pins the socket reference taken by mgmt_pending_new(), so the mgmt socket is never released.
Free the command from a destroy callback. The now-empty done label is replaced by a direct return.
--- net/bluetooth/mgmt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/bluetooth/mgmt.c +8 -5
@@ -2647,7 +2647,7 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)if (IS_ERR (skb)) {mgmt_cmd_status (cmd->sk, hdev->id,MGMT_OP_HCI_CMD_SYNC ,mgmt_status (PTR_ERR (skb))); - goto done; +return 0 ; } mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_HCI_CMD_SYNC, 0,
@@ -2655,12 +2655,14 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)kfree_skb (skb); -done: -mgmt_pending_free (cmd); -return 0 ; } +static void send_hci_cmd_sync_destroy (struct hci_dev *hdev,void *data,int err) +{ +mgmt_pending_free (data); +} +static int mgmt_hci_cmd_sync (struct sock *sk,struct hci_dev *hdev,void *data,u16 len) {
@@ -2686,7 +2688,8 @@ static int mgmt_hci_cmd_sync(struct sock *sk, struct hci_dev *hdev,if (!cmd) err = -ENOMEM ;else - err =hci_cmd_sync_queue (hdev, send_hci_cmd_sync, cmd,NULL ); + err =hci_cmd_sync_queue (hdev, send_hci_cmd_sync, cmd, + send_hci_cmd_sync_destroy);if (err <0 ) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_HCI_CMD_SYNC,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1255/1815 Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit b0c0b37940115383e7ea65d4d988f9b9e613ab92 ]
btmtksdio_setup() calls pm_runtime_use_autosuspend() when runtime PM is supported, but btmtksdio_remove() does not call the matching pm_runtime_dont_use_autosuspend() when removing the device.
If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without calling pm_runtime_dont_use_autosuspend() during driver teardown, this reference is not dropped and usage_count remains unbalanced.
Add the missing pm_runtime_dont_use_autosuspend() call in the remove path before restoring the runtime PM usage reference.
This issue was found by manual code inspection.
--- drivers/bluetooth/btmtksdio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bluetooth/btmtksdio.c +3 -0
@@ -1480,6 +1480,9 @@ static void btmtksdio_remove(struct sdio_func *func)if (test_bit (BTMTKSDIO_FUNC_ENABLED , &bdev->tx_state))btmtksdio_close (hdev); +if (bdev->data->pm_runtime_supported) +pm_runtime_dont_use_autosuspend (bdev->dev); +/* Be consistent the state in btmtksdio_probe */ pm_runtime_get_noresume (bdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1256/1815 Bluetooth: MSFT: validate evt_prefix_len against the response length
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
[ Upstream commit 0079e1a944634ab2dc1c7cdec1144486d096407e ]
read_supported_features() only checks that the response covers the fixed part of struct msft_rp_read_supported_features, which is 11 bytes:
if (skb->len < sizeof(*rp)) {
bt_dev_err(hdev, "MSFT supported features length mismatch");
goto failed;
}evt_prefix[] is a flexible array member and rp->evt_prefix_len is an unvalidated u8 taken straight out of that response, so
msft->evt_prefix = kmemdup(rp->evt_prefix, rp->evt_prefix_len, GFP_KERNEL);
copies up to 255 bytes from a reply that may have carried none of them. What is copied is data the controller never sent, and it is then used to match incoming vendor events in msft_vendor_evt().
This is not an out-of-bounds access. An skb data allocation always has at least SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) bytes past the payload, which is more than the 255 byte maximum, so the read stays inside the allocation and KASAN does not report it. It is still a read of bytes the host was never given, with the length fully controlled by the controller.
Reject a response that is too short for the prefix it declares.
Verified with an emulated controller over /dev/vhci on a KASAN kernel, with vhci made to advertise an MSFT opcode the way btintel, btqca, btmtk and btrtl do unconditionally. A reply of exactly 11 bytes declaring evt_prefix_len = 255 reaches kmemdup and copies 255 bytes ("skb->len=11 evt_prefix_len=255", with the copied buffer dumped); since the reply ends at the fixed part, all 255 come from past the end of the response. No KASAN report is produced, as expected from the allocation slack described above. With this patch the response is rejected with "MSFT event prefix length mismatch" and msft->evt_prefix is left unset.
--- net/bluetooth/msft.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/msft.c +5 -0
@@ -165,6 +165,11 @@ static bool read_supported_features(struct hci_dev *hdev,if (rp->sub_opcode !=MSFT_OP_READ_SUPPORTED_FEATURES ) goto failed; +if (skb->len <sizeof (*rp) + rp->evt_prefix_len) { +bt_dev_err (hdev,"MSFT event prefix length mismatch" ); + goto failed; + } +if (rp->evt_prefix_len >0 ) { msft->evt_prefix =kmemdup (rp->evt_prefix, rp->evt_prefix_len,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1257/1815 pinctrl: fix PINCTRL_GENERIC_MUX not always being selectable
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alvin Šipraga <[email protected]>
[ Upstream commit 465f276bb928093685c2a2b98bf0a7ccc4283b8d ]
CONFIG_MULTIPLEXER can only be enabled indirectly. If it's not already enabled, then CONFIG_PINCTRL_GENERIC_MUX cannot be selected at all in menuconfig. That's because it depends on MULTIPLEXER.
Follow similar consumers of the multiplexer core and select MULTIPLEXER instead. This way the driver will be visible in menuconfig as long as PINCTRL is selected.
--- drivers/pinctrl/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/Kconfig +1 -1
@@ -275,8 +275,8 @@ config PINCTRL_GEMINI config PINCTRL_GENERIC_MUX tristate "Generic Pinctrl driver by using multiplexer" - depends on MULTIPLEXER depends on OF + select MULTIPLEXER select PINMUX select GENERIC_PINCTRL help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1258/1815 bpf, cgroup: Fix storage null-ptr-deref after replacing prog
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 3f562c537e9ecf4bc5e206cfffc2cc047f1b7e94 ]
Syzkaller reported a storage null-ptr-deref issue after replacing prog. This occurs in the following scenario:
1. prog A, an empty prog, is attached to a cgrp.
2. prog B uses BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE and calls the bpf_get_local_storage helper.
3. link_update is called to replace prog A with prog B.
The reason is that __cgroup_bpf_replace fails to alloc and assign the required cgrp storage for the incoming replacement prog. Consequently, the new prog inherits an uninit storage, leading to null-ptr-deref panic when kick the new prog.
Fix this by rejecting a link update if new_prog's cgroup storage is incompatible with link->prog.
--- kernel/bpf/cgroup.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
kernel/bpf/cgroup.c +17 -0
@@ -1026,6 +1026,20 @@ static void replace_effective_prog(struct cgroup *cgrp, } } +static bool cgroup_bpf_storages_compatible (struct bpf_prog *old_prog, +struct bpf_prog *new_prog) +{ +enum bpf_cgroup_storage_type stype; + +for_each_cgroup_storage_type (stype) { +if (old_prog->aux->cgroup_storage[stype] != + new_prog->aux->cgroup_storage[stype]) +return false; + } + +return true; +} +/** * __cgroup_bpf_replace() - Replace link's program and propagate the change * to descendants
@@ -1064,6 +1078,9 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp,if (!found)return -ENOENT ; +if (!cgroup_bpf_storages_compatible (link->link.prog, new_prog)) +return -EINVAL ; + cgrp->bpf.revisions[atype] +=1 ; old_prog =xchg (&link->link.prog, new_prog);replace_effective_prog (cgrp, atype, pl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1259/1815 iio: light: opt4060: Fix pointer type passed to div_u64_rem()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidhu Sarwal <[email protected]>
[ Upstream commit 0ba0ed0d42ebd3144f0050c48374817f5f3f07d6 ]
div_u64_rem() expects a u32 * for the remainder, but opt4060_read_ev_period() passes val2, which is declared as an int *. While this has no functional impact, it triggers a pointer type mismatch.
There is no behavioural change because int and u32 have the same size and representation on all supported architectures, and the remainder is always less than MICRO, so it fits within the positive range of int.
Use a local u32 to receive the remainder before assigning it to *val2.
--- drivers/iio/light/opt4060.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/light/opt4060.c +3 -1
@@ -713,6 +713,7 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val, {int ret, pers, fault_count, int_time;u64 uval; +u32 rem; int_time = opt4060_int_time_reg[chip->int_time][0 ];
@@ -738,7 +739,8 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val, } uval =mul_u32_u32 (int_time, pers); - *val =div_u64_rem (uval,MICRO , val2); + *val =div_u64_rem (uval,MICRO , &rem); + *val2 = rem;return IIO_VAL_INT_PLUS_MICRO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1260/1815 iio: light: gp2ap002: Fix unbalanced runtime PM on repeated event writes
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 579c049b4cb6fc72ce2c505fc5334540be0efcd3 ]
The IIO core does not filter duplicate writes to the event enable attribute, so writing the same value twice invokes write_event_config() twice. Enabling twice leaks a runtime PM reference, preventing the device from ever suspending again; disabling twice underflows the usage count and triggers a "Runtime PM usage count underflow" warning.
Bail out early when the requested state matches the current state. While at it, switch to pm_runtime_resume_and_get() so a failed resume is propagated to userspace instead of silently marking the event enabled.
--- drivers/iio/light/gp2ap002.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/iio/light/gp2ap002.c +10 -3
@@ -342,6 +342,10 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev, bool state) {struct gp2ap002 *gp2ap002 =iio_priv (indio_dev); +int ret; + +if (state == gp2ap002->enabled) +return 0 ;if (state) {/*
@@ -349,13 +353,16 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev,* already) and reintialize the sensor by using runtime_pm * callbacks. */ -pm_runtime_get_sync (gp2ap002->dev); - gp2ap002->enabled = true; + ret =pm_runtime_resume_and_get (gp2ap002->dev); +if (ret) +return ret; + }else {pm_runtime_put_autosuspend (gp2ap002->dev); - gp2ap002->enabled = false; } + gp2ap002->enabled = state; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1261/1815 iio: light: gp2ap002: re-enable irq if runtime suspend fails
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 5d89e7cbac40057f5241a0832a86ce0fe97e4818 ]
gp2ap002_runtime_suspend() disables the irq before writing OPMOD. If the write fails, the callback returns an error with the irq still disabled while the PM core marks the device active again.
re-enable the irq before returning the error so the irq state matches the active state the PM core restores.
--- drivers/iio/light/gp2ap002.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/light/gp2ap002.c +1 -0
@@ -649,6 +649,7 @@ static int gp2ap002_runtime_suspend(struct device *dev)/* Disable chip and IRQ, everything off */ ret =regmap_write (gp2ap002->map,GP2AP002_OPMOD ,0x00 );if (ret) { +enable_irq (gp2ap002->irq);dev_err (gp2ap002->dev,"error setting up operation mode\n" );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1235/1815 perf sched: Suppress latency table output when trace samples are missing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit 4a81d59a9d81e6db4e76f84a3d2638e64ff79533 ]
When 'perf sched latency' is executed on a perf.data file that lacks tracepoint samples (i.e., a file recorded without the -R flag or containing only non-tracepoint events), perf_session__has_traces() correctly outputs an error message. However, perf_sched__read_events() subsequently falls through and returns 0 (success).
Consequently, caller functions such as perf_sched__lat() assume event processing succeeded and proceed to render empty latency header tables and total summary statistics.
Fix this behaviour by ensuring perf_sched__read_events() aborts early and returns a suitable error code when perf_session__has_traces() evaluates to false.
Additionally, validate thread__get_runtime() against NULL in map_switch_event() to prevent potential null-pointer dereferences.
--- tools/perf/builtin-sched.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
tools/perf/builtin-sched.c +12 -11
@@ -1833,7 +1833,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_sample *sampl sched_out:if (sched->map.task_name) { tr =thread__get_runtime (sched->curr_out_thread[this_cpu.cpu]); -if (strcmp (tr->shortname,"" ) ==0 ) +if (tr ==NULL ||strcmp (tr->shortname,"" ) ==0 ) goto out;if (proceed ==1 )
@@ -2001,7 +2001,7 @@ static int perf_sched__read_events(struct perf_sched *sched) .mode = PERF_DATA_MODE_READ, .force = sched->force, }; -int rc =-1 ; +int rc =-1 , err; session =perf_session__new (&data, &sched->tool);if (IS_ERR (session)) {
@@ -2018,18 +2018,19 @@ static int perf_sched__read_events(struct perf_sched *sched)if (perf_session__set_tracepoints_handlers (session, handlers)) goto out_delete; -if (perf_session__has_traces (session,"record -R" )) { -int err =perf_session__process_events (session); -if (err) { -pr_err ("Failed to process events, error %d" , err); - goto out_delete; - } +if (!perf_session__has_traces (session,"record -R" )) + goto out_delete; - sched->nr_events =evlist__stats (session->evlist)->nr_events[0 ]; - sched->nr_lost_events =evlist__stats (session->evlist)->total_lost; - sched->nr_lost_chunks =evlist__stats (session->evlist)->nr_events[PERF_RECORD_LOST ]; + err =perf_session__process_events (session); +if (err) { +pr_err ("Failed to process events, error %d" , err); + goto out_delete; } + sched->nr_events =evlist__stats (session->evlist)->nr_events[0 ]; + sched->nr_lost_events =evlist__stats (session->evlist)->total_lost; + sched->nr_lost_chunks =evlist__stats (session->evlist)->nr_events[PERF_RECORD_LOST ]; + rc =0 ; out_delete:perf_session__delete (session);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1262/1815 net/sched: cls_api: fix teardown of an adopted proto on insert-race loss
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit d4e359b3608a0e184bbe8d61a5c3b50d0831c44a ]
In tc_new_tfilter() the create branch sets tp_created = 1 before calling tcf_chain_tp_insert_unique(). When the caller loses the race (another request inserted a proto at the same chain/prio first), insert_unique() destroys the caller's own tp_new and returns the winner's proto with an extra reference. tp_created was never cleared, so the loser's errout path treated the winner's live proto as its own and called tcf_chain_tp_delete_empty() on it, silently unlinking an active classifier that the winning request already advertised via RTM_NEWTFILTER.
Track the outcome of the insert step in a single tri-state variable so each errout path reacts correctly:
- TP_NOT_CREATED: no proto created; pursue the old path.
- TP_CREATED: proto inserted successfully; same code path as before.
- TP_NOT_OWNED: New - lost the insert race; tp is another request's proto (chain ref already released by tp_new's destroy)
Both errout reactions are single expressions derived from the state.
This fix is motivated by the Sashiko's automated review of Patch (net/sched: cls_api: Always acquire rtnl_lock when destroying locked classifiers) [1][2]. The review identified the silent-unlink behaviour of an adopted proto's teardown when a request loses the tcf_chain_tp_insert_unique() race.
[1] https://sashiko.dev/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
[2] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
--- net/sched/cls_api.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
net/sched/cls_api.c +13 -5
@@ -2248,6 +2248,12 @@ static bool is_ingress_or_clsact(struct tcf_block *block, struct Qdisc *q)return tcf_block_shared (block) || (q && !!(q->flags &TCQ_F_INGRESS )); } +enum tcf_tp_insert_state { +TP_NOT_CREATED =0 ,/* did not create and insert a new tp */ +TP_CREATED ,/* created and inserted a new tp */ +TP_NOT_OWNED ,/* created a proto but failed to insert */ +}; +static int tc_new_tfilter (struct sk_buff *skb,struct nlmsghdr *n,struct netlink_ext_ack *extack) {
@@ -2268,12 +2274,12 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,unsigned long cl;void *fh;int err; -int tp_created; +enum tcf_tp_insert_state tp_state;bool rtnl_held = false;u32 flags; replay: - tp_created =0 ; + tp_state =TP_NOT_CREATED ; err =nlmsg_parse_deprecated (n,sizeof (*t), tca,TCA_MAX , rtm_tca_policy, extack);
@@ -2395,13 +2401,15 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, goto errout_tp; } - tp_created =1 ; + tp_state =TP_CREATED ; tp =tcf_chain_tp_insert_unique (chain, tp_new, protocol, prio, rtnl_held);if (IS_ERR (tp)) { err =PTR_ERR (tp); goto errout_tp; } +if (tp != tp_new) + tp_state =TP_NOT_OWNED ; }else {mutex_unlock (&chain->filter_chain_lock); }
@@ -2455,13 +2463,13 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } errout: -if (err && tp_created) +if (err && tp_state ==TP_CREATED )tcf_chain_tp_delete_empty (chain, tp, rtnl_held,NULL ); errout_tp:if (chain) {if (tp && !IS_ERR (tp))tcf_proto_put (tp, rtnl_held,NULL ); -if (!tp_created) +if (tp_state ==TP_NOT_CREATED )tcf_chain_put (chain); }tcf_block_release (q, block, rtnl_held);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1263/1815 riscv: cpufeature: Clarify ISA spec version for canonical order
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guodong Xu <[email protected]>
[ Upstream commit fdef048705daa3d4ed1fa212ee071bcbdac02d80 ]
Specify that chapter 27 refers to version 20191213 of the RISC-V ISA Unprivileged Architecture. The chapter numbering differs across specification versions - for example, in version 20250508, the ISA Extension Naming Conventions is chapter 36, not chapter 27.
Historical versions of the RISC-V specification can be found via Link [1].
--- arch/riscv/kernel/cpufeature.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/cpufeature.c +2 -1
@@ -452,7 +452,8 @@ static const unsigned int riscv_c_exts[] = {/* * The canonical order of ISA extension names in the ISA string is defined in -* chapter 27 of the unprivileged specification. +* Chapter 27 of the RISC-V Instruction Set Manual Volume I Unprivileged ISA +* (Document Version 20191213). * * Ordinarily, for in-kernel data structures, this order is unimportant but * isa_ext_arr defines the order of the ISA string in /proc/cpuinfo.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1264/1815 bpf: Fix mmap_lock leak in irq_work path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit fa9dcacdcdf487f0ffef64bf67622f1caed509f1 ]
stack_map_get_build_id_offset() introduced a per-CPU irq_work to defer mmap_read_unlock() from NMI context, and bpf_find_vma() later reused the same mmap_unlock_work. Both callers only check whether the work is busy before taking mmap_lock, so a nested caller can reuse the slot before the first caller queues it. Two read locks may then be acquired while only one deferred unlock runs, leaking a read lock and blocking exit_mmap().
Reserve the per-CPU slot before mmap_read_trylock(). Use the same wrapper in stackmap and bpf_find_vma() so both callers release the reservation on trylock failure. Keep rejecting the slot while the irq_work remains busy. Release it after the irq_work callback unlocks the mm.
--- kernel/bpf/mmap_unlock_work.h | 51 ++++++++++++++++++++--------------- kernel/bpf/stackmap.c | 28 +++++++++++-------- kernel/bpf/task_iter.c | 14 +++++++--- 3 files changed, 56 insertions(+), 37 deletions(-)
kernel/bpf/mmap_unlock_work.h +29 -22
@@ -4,12 +4,15 @@#ifndef __MMAP_UNLOCK_WORK_H__#define __MMAP_UNLOCK_WORK_H__ +#include <linux/atomic.h> +#include <linux/err.h> #include <linux/irq_work.h> /* irq_work to run mmap_read_unlock() in irq_work */ struct mmap_unlock_irq_work {struct irq_work irq_work;struct mm_struct *mm; +atomic_t active; }; DECLARE_PER_CPU(struct mmap_unlock_irq_work, mmap_unlock_work);
@@ -18,32 +21,36 @@ DECLARE_PER_CPU(struct mmap_unlock_irq_work, mmap_unlock_work);* We cannot do mmap_read_unlock() when the irq is disabled, because of * risk to deadlock with rq_lock. To look up vma when the irqs are * disabled, we need to run mmap_read_unlock() in irq_work. We use a -* percpu variable to do the irq_work. If the irq_work is already used -* by another lookup, we fall over. +* percpu variable to do the irq_work. The active flag reserves the slot +* before mmap_read_trylock() and until the irq_work callback consumes mm. */ -static inline bool bpf_mmap_unlock_get_irq_work (struct mmap_unlock_irq_work **work_ptr) +static inline struct mmap_unlock_irq_work *bpf_mmap_unlock_guard_get (void ) { -struct mmap_unlock_irq_work *work =NULL ; -bool irq_work_busy = false; +struct mmap_unlock_irq_work *work; -if (irqs_disabled ()) { -if (!IS_ENABLED (CONFIG_PREEMPT_RT )) { - work =this_cpu_ptr (&mmap_unlock_work); -if (irq_work_is_busy (&work->irq_work)) { -/* cannot queue more up_read, fallback */ - irq_work_busy = true; - } - }else { -/* -* PREEMPT_RT does not allow to trylock mmap sem in -* interrupt disabled context. Force the fallback code. -*/ - irq_work_busy = true; - } - } +if (!irqs_disabled ()) +return NULL ; + +/* +* PREEMPT_RT does not allow to trylock mmap sem in interrupt +* disabled context. Force the fallback code. +*/ +if (IS_ENABLED (CONFIG_PREEMPT_RT )) +return ERR_PTR (-EBUSY ); + + work =this_cpu_ptr (&mmap_unlock_work); +if (irq_work_is_busy (&work->irq_work) || +atomic_cmpxchg_acquire (&work->active,0 ,1 )) +return ERR_PTR (-EBUSY ); - *work_ptr = work; -return irq_work_busy; +return work; +} + +static inline void +bpf_mmap_unlock_guard_put (struct mmap_unlock_irq_work *work) +{ +if (work) +atomic_set_release (&work->active,0 ); }static inline void bpf_mmap_unlock_mm (struct mmap_unlock_irq_work *work,struct mm_struct *mm)
kernel/bpf/stackmap.c +17 -11
@@ -414,8 +414,7 @@ static void stack_map_get_build_id_offset_sleepable(struct bpf_stack_build_id *istatic void stack_map_get_build_id_offset (struct bpf_stack_build_id *id_offs,u32 trace_nr,bool user,bool may_fault) { -struct mmap_unlock_irq_work *work =NULL ; -bool irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); +struct mmap_unlock_irq_work *work;bool has_user_ctx = user && current && current->mm;struct stack_map_build_id_cache cache = {};struct vm_area_struct *vma;
@@ -426,15 +425,16 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,return ; } -/* If the irq_work is in use, fall back to report ips. Same -* fallback is used for kernel stack (!user) on a stackmap with -* build_id. -*/ -if (!has_user_ctx || irq_work_busy || !mmap_read_trylock (current->mm)) { -/* cannot access current->mm, fall back to ips */ -for (i =0 ; i < trace_nr; i++) -stack_map_build_id_set_ip (&id_offs[i]); -return ; +if (!has_user_ctx) + goto fallback; + + work =bpf_mmap_unlock_guard_get (); +if (IS_ERR (work)) + goto fallback; + +if (!mmap_read_trylock (current->mm)) { +bpf_mmap_unlock_guard_put (work); + goto fallback; }for (i =0 ; i < trace_nr; i++) {
@@ -465,6 +465,12 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, vma->vm_pgoff); }bpf_mmap_unlock_mm (work, current->mm); +return ; + +fallback: +/* cannot access current->mm, fall back to ips */ +for (i =0 ; i < trace_nr; i++) +stack_map_build_id_set_ip (&id_offs[i]); } static struct perf_callchain_entry *
kernel/bpf/task_iter.c +10 -4
@@ -753,9 +753,8 @@ static struct bpf_iter_reg task_vma_reg_info = { BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start, bpf_callback_t, callback_fn, void *, callback_ctx, u64, flags) { -struct mmap_unlock_irq_work *work =NULL ; +struct mmap_unlock_irq_work *work;struct vm_area_struct *vma; -bool irq_work_busy = false;bool __maybe_unused mmput_needed = false;struct mm_struct *mm;int ret = -ENOENT ;
@@ -792,9 +791,14 @@ BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start,if (!mm)return -ENOENT ; - irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); + work =bpf_mmap_unlock_guard_get (); +if (IS_ERR (work)) { + ret =PTR_ERR (work); + goto out; + } -if (irq_work_busy || !mmap_read_trylock (mm)) { +if (!mmap_read_trylock (mm)) { +bpf_mmap_unlock_guard_put (work); ret = -EBUSY ; goto out; }
@@ -1191,6 +1195,8 @@ static void do_mmap_read_unlock(struct irq_work *entry) work = container_of(entry, struct mmap_unlock_irq_work, irq_work);mmap_read_unlock_non_owner (work->mm); + work->mm =NULL ; +bpf_mmap_unlock_guard_put (work); }static int __init task_iter_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1265/1815 i3c: renesas: Return immediately if there is no transfer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 33b5ecc5a16e270c8e0dd9835e7d9d2522f64129 ]
There is no need to allocate a transfer structure when i2c_nxfers is zero. Return immediately instead of unnecessarily allocating memory.
Stable-dep-of: b6e56fd8c8a8 ("i3c: renesas: Don't register devices when ENTDAA times out")
--- drivers/i3c/master/renesas-i3c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/renesas-i3c.c +3 -3
@@ -957,13 +957,13 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *dev,u8 start_bit =CNDCTL_STCND ;int i; +if (!i2c_nxfers) +return 0 ; + struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);if (!xfer)return -ENOMEM ; -if (!i2c_nxfers) -return 0 ; -renesas_i3c_bus_enable (m, false);init_completion (&xfer->comp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1266/1815 i3c: renesas: Follow a unified pattern for transfer and command initialization
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 234a26e6febcf789d9f6779d67c01e3d0c1df5bc ]
Follow a unified pattern for transfer and command initialization across the driver. This keeps the code cleaner and easier to follow. Also, in some cases the I3C device was enabled before the transfer data structure was even allocated.
Stable-dep-of: b6e56fd8c8a8 ("i3c: renesas: Don't register devices when ENTDAA times out")
--- drivers/i3c/master/renesas-i3c.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/i3c/master/renesas-i3c.c +11 -11
@@ -663,6 +663,10 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)if (!xfer)return -ENOMEM ; +init_completion (&xfer->comp); + cmd = xfer->cmds; + cmd->rx_count =0 ; +/* Enable I3C bus. */ renesas_i3c_bus_enable (m, true);
@@ -684,10 +688,6 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)renesas_writel (i3c->regs,DATBAS (pos),datbas_dvdyad_with_parity (ret)); } -init_completion (&xfer->comp); - cmd = xfer->cmds; - cmd->rx_count =0 ; - ret =renesas_i3c_get_free_pos (i3c);if (ret <0 )return ret;
@@ -779,13 +779,13 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master_controller *m,if (!xfer)return -ENOMEM ; -renesas_i3c_bus_enable (m, true); -init_completion (&xfer->comp); cmd = xfer->cmds; cmd->rnw = ccc->rnw; cmd->cmd0 =0 ; +renesas_i3c_bus_enable (m, true); +/* Calculate the command descriptor. */ switch (ccc->id) {case I3C_CCC_SETDASA :
@@ -835,15 +835,15 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc *dev, struct i3c_xfer *i3c_struct renesas_i3c_i2c_dev_data *data =i3c_dev_get_master_data (dev);int i; -/* Enable I3C bus. */ -renesas_i3c_bus_enable (m, true); - struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);if (!xfer)return -ENOMEM ;init_completion (&xfer->comp); +/* Enable I3C bus. */ +renesas_i3c_bus_enable (m, true); +for (i =0 ; i < i3c_nxfers; i++) {struct renesas_i3c_cmd *cmd = xfer->cmds;
@@ -964,12 +964,12 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *dev,if (!xfer)return -ENOMEM ; -renesas_i3c_bus_enable (m, false); -init_completion (&xfer->comp); xfer->is_i2c_xfer = true; cmd = xfer->cmds; +renesas_i3c_bus_enable (m, false); +if (!(renesas_readl (i3c->regs,BCST ) &BCST_BFREF )) { cmd->err = -EBUSY ;return cmd->err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1267/1815 i3c: renesas: Dont register devices when ENTDAA times out
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tommaso Merciai <[email protected]>
[ Upstream commit b6e56fd8c8a8ac7992868a28702192372ab04015 ]
renesas_i3c_daa() derives the number of newly assigned dynamic addresses from cmd->rx_count, which the response ISR sets to the number of address slots ENTDAA left unassigned. It starts out as zero, which already means "every address was assigned", so a timed out transfer leaves that value in place and it gets used as a result.
On a bus with no target connected the ENTDAA times out and the driver registers RENESAS_I3C_MAX_DEVS devices that are not there, each costing the core two seconds on a GETPID that can only time out:
i3c i3c-0: Failed to add I3C device at address 9, error -110
...
i3c i3c-0: Failed to add I3C device at address 16, error -110
Start from maxdevs instead: no address is assigned before ENTDAA runs, and the existing rx_count >= maxdevs check then reports an empty bus.
--- drivers/i3c/master/renesas-i3c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/renesas-i3c.c +1 -1
@@ -665,7 +665,7 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)init_completion (&xfer->comp); cmd = xfer->cmds; - cmd->rx_count =0 ; + cmd->rx_count = i3c->maxdevs;/* Enable I3C bus. */ renesas_i3c_bus_enable (m, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1268/1815 arm64: dts: turris-mox: fix usb3 phys
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomáš Macholda <[email protected]>
[ Upstream commit 0c2a8eed95160e41b367a1fa605a2c1b24a9639a ]
After commit 00e6d608fe80b0f6 ("arm64: dts: marvell: armada-37xx: swap PHYs' order in USB3 controller node") swapped USB3 PHY order, USB initialization breaks on Turris MOX.
This regression was exposed by commit 91ddf6f722084383 ("phy: marvell:
mvebu-a3700-utmi: fix incorrect USB2_PHY_CTRL register access") which made USB2 devices not work at all.
Fix the issue by explicitly adding all USB3 PHYs and PHY names to Turris MOX device-tree.
--- arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +2 -1
@@ -290,7 +290,8 @@ connector { &usb3 { status = "okay"; - phys = <&comphy2 0>; + phys = <&usb2_utmi_otg_phy>, <&comphy2 0>; + phy-names = "usb2-phy", "usb3-phy"; }; &mdio {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1269/1815 ARM: dts: helios4: add vcc-supply to EEPROM
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit ef65cf08bd1aa723de2854d02fb8eb8cca273c90 ]
The at24 driver requests a 'vcc' supply for the EEPROM, producing 'supply vcc not found, using dummy regulator' at boot when the property is missing.
The EEPROM sits on the Helios 4 and is powered by the same always-on 3.3V rail used by other on-board I2C devices. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +4 -0
@@ -201,6 +201,10 @@ temp_sensor: temp@4c { reg = <0x4c>; vcc-supply = <®_3p3v>; }; + + eeprom@53 { + vcc-supply = <®_3p3v>; + }; }; i2c@11100 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1270/1815 ARM: dts: helios4: add vcc-supply to GPIO expander
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit c23988f84496e937dd255564cb30bec67608dcc6 ]
The pca953x driver requests a 'vcc' supply, producing:
pca953x 0-0020: supply vcc not found, using dummy regulator
The PCA9655 (PCA9555-compatible) expander is powered by the same always-on 3.3V rail as the other I2C devices on the bus. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +1 -0
@@ -169,6 +169,7 @@ expander0: gpio-expander@20 { gpio-controller; #gpio-cells = <2>; reg = <0x20>; + vcc-supply = <®_3p3v>; pinctrl-names = "default"; pinctrl-0 = <&pca0_pins>; interrupt-parent = <&gpio0>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1271/1815 ARM: dts: helios4: add SATA regulator supplies
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 7a90520e8c9a8f48fe6f3e741cf34d8c2b6dbc61 ]
The ahci-mvebu driver and libahci_platform request three supplies on SATA controller and port nodes:
- ahci-supply (controller power)
- phy-supply (PHY power)
- target-supply (disk power per port)
Without them the regulator core prints notices at boot, e.g.:
supply ahci not found, using dummy regulator supply phy not found, using dummy regulator supply target not found, using dummy regulator
The SATA controller and PHY inside the Armada 388 SoC are powered by the 3.3V I/O rail; the four disk bays are powered by the 5V HDD rail. Wire the existing fixed regulators accordingly.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +8 -0
@@ -222,13 +222,17 @@ sata@a8000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata0: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata1: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
@@ -236,13 +240,17 @@ sata@e0000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata2: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata3: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1236/1815 perf sched: Handle missing trace samples in pipe mode
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit 44f8dd1ee1d55db399a443e1715cd8cdd3268362 ]
For pipe mode streams, event attributes are received dynamically during event processing, meaning session->evlist is not populated prior to perf_session__process_events(). To handle pipe input correctly:
- Register the missing .attr, .tracing_data, .build_id, and .feature callbacks in cmd_sched()
- Promote the handlers array to file-scope (latency_handlers[]) and dynamically assign matching tracepoint handlers
(or process_sched_ignore) inside perf_sched__process_tracepoint_sample() when evsel->handler is NULL; replace process_sched_wakeup_ignore() with process_sched_ignore()
- Perform the trace check post-processing when handling pipe data
--- tools/perf/builtin-sched.c | 72 +++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 21 deletions(-)
tools/perf/builtin-sched.c +51 -21
@@ -1581,12 +1581,6 @@ static int process_sched_wakeup_event(const struct perf_tool *tool,return 0 ; } -static int process_sched_wakeup_ignore (const struct perf_tool *tool__maybe_unused , -struct perf_sample *sample__maybe_unused , -struct machine *machine__maybe_unused ) -{ -return 0 ; -}static bool thread__has_color (struct thread *thread) {
@@ -1938,6 +1932,22 @@ typedef int (*tracepoint_handler)(const struct perf_tool *tool,struct perf_sample *sample, struct machine *machine); +static struct evsel_str_handler latency_handlers[] = { + {"sched:sched_switch" , process_sched_switch_event, }, + {"sched:sched_stat_runtime" , process_sched_runtime_event, }, + {"sched:sched_wakeup" , process_sched_wakeup_event, }, + {"sched:sched_waking" , process_sched_wakeup_event, }, + {"sched:sched_wakeup_new" , process_sched_wakeup_event, }, + {"sched:sched_migrate_task" , process_sched_migrate_task_event, }, +}; + +static int process_sched_ignore (const struct perf_tool *tool__maybe_unused , +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) +{ +return 0 ; +} + static int perf_sched__process_tracepoint_sample(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample,
@@ -1946,7 +1956,23 @@ static int perf_sched__process_tracepoint_sample(const struct perf_tool *tool __struct evsel *evsel = sample->evsel;int err =0 ; -if (evsel->handler !=NULL ) { +if (evsel->handler ==NULL ) { + evsel->handler = process_sched_ignore; +for (size_t i =0 ; i <ARRAY_SIZE (latency_handlers); i++) { +if (!evsel__name_is (evsel, latency_handlers[i].name)) +continue ; + +if (!strcmp (latency_handlers[i].name,"sched:sched_wakeup" ) && + sample->evsel->evlist && +evlist__find_tracepoint_by_name (sample->evsel->evlist,"sched:sched_waking" )) +break ; + + evsel->handler = latency_handlers[i].handler; +break ; + } + } + +if (evsel->handler != process_sched_ignore) {tracepoint_handler f = evsel->handler; err =f (tool, sample, machine); }
@@ -1987,14 +2013,6 @@ static int perf_sched__process_comm(const struct perf_tool *tool __maybe_unused,static int perf_sched__read_events (struct perf_sched *sched) { -struct evsel_str_handler handlers[] = { - {"sched:sched_switch" , process_sched_switch_event, }, - {"sched:sched_stat_runtime" , process_sched_runtime_event, }, - {"sched:sched_wakeup" , process_sched_wakeup_event, }, - {"sched:sched_waking" , process_sched_wakeup_event, }, - {"sched:sched_wakeup_new" , process_sched_wakeup_event, }, - {"sched:sched_migrate_task" , process_sched_migrate_task_event, }, - };struct perf_session *session;struct perf_data data = { .path = input_name,
@@ -2011,14 +2029,17 @@ static int perf_sched__read_events(struct perf_sched *sched)symbol__init (perf_session__env (session)); -/* prefer sched_waking if it is captured */ -if (evlist__find_tracepoint_by_name (session->evlist,"sched:sched_waking" )) - handlers[2 ].handler = process_sched_wakeup_ignore; +if (!perf_data__is_pipe (session->data)) { +/* prefer sched_waking if it is captured */ +if (evlist__find_tracepoint_by_name (session->evlist,"sched:sched_waking" )) + latency_handlers[2 ].handler = process_sched_ignore; -if (perf_session__set_tracepoints_handlers (session, handlers)) - goto out_delete; +if (perf_session__set_tracepoints_handlers (session, latency_handlers)) + goto out_delete; + } -if (!perf_session__has_traces (session,"record -R" )) +if (!perf_data__is_pipe (session->data) && + !perf_session__has_traces (session,"record -R" )) goto out_delete; err =perf_session__process_events (session);
@@ -2027,6 +2048,11 @@ static int perf_sched__read_events(struct perf_sched *sched) goto out_delete; } +if (perf_data__is_pipe (session->data) && + !perf_session__has_traces (session,"record -R" )) { + goto out_delete; + } + sched->nr_events =evlist__stats (session->evlist)->nr_events[0 ]; sched->nr_lost_events =evlist__stats (session->evlist)->total_lost; sched->nr_lost_chunks =evlist__stats (session->evlist)->nr_events[PERF_RECORD_LOST ];
@@ -5172,6 +5198,10 @@ int cmd_sched(int argc, const char **argv) sched.tool.namespaces = perf_event__process_namespaces; sched.tool.lost = perf_event__process_lost; sched.tool.fork = perf_sched__process_fork_event; + sched.tool.attr = perf_event__process_attr; + sched.tool.tracing_data = perf_event__process_tracing_data; + sched.tool.build_id = perf_event__process_build_id; + sched.tool.feature = perf_event__process_feature; argc =parse_options_subcommand (argc, argv, sched_options, sched_subcommands, sched_usage,PARSE_OPT_STOP_AT_NON_OPTION );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1272/1815 perf script: Fix metric_evlist leak in script_find_metrics
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit d4171c774070e9d1c45324e3667d7dcba9be7749 ]
Fix a memory leak in script_find_metrics() where metric_evlist is leaked when returning early on error paths.
--- tools/perf/builtin-script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-script.c +1 -1
@@ -2276,8 +2276,8 @@ static int script_find_metrics(const struct pmu_metric *pm, }pr_debug ("Found metric '%s' whose evsels match those of in the perf data\n" , pm->metric_name); -evlist__put (metric_evlist); out: +evlist__put (metric_evlist);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1273/1815 perf stat: Fix evsel_list leak in cmd_stat
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 340641a4b5fff4f4b12261c9d92169f6e2ea11f4 ]
Fix a memory leak in cmd_stat() where evsel_list is leaked if an error occurs while opening the output file.
--- tools/perf/builtin-stat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/builtin-stat.c +6 -3
@@ -2726,7 +2726,8 @@ int cmd_stat(int argc, const char **argv) output =fopen (output_name, mode);if (!output) {perror ("failed to create output file" ); -return -1 ; + status =-1 ; + goto out; }if (!stat_config.json_output) {clock_gettime (CLOCK_REALTIME , &tm);
@@ -2737,7 +2738,8 @@ int cmd_stat(int argc, const char **argv) output =fdopen (output_fd, mode);if (!output) {perror ("Failed opening logfd" ); -return -errno; + status = -errno; + goto out; } }
@@ -2746,7 +2748,8 @@ int cmd_stat(int argc, const char **argv)parse_options_usage (stat_usage, stat_options,"o" ,1 );parse_options_usage (NULL , stat_options,"log-fd" ,0 );parse_options_usage (NULL , stat_options,"interval-clear" ,0 ); -return -1 ; + status =-1 ; + goto out; } stat_config.output = output;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1274/1815 perf tools: Fix sb_evlist leaks in top and record
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 08e96e3c737bf63d917c6c4e0bb67450ad53f1d8 ]
Fix a memory leak in cmd_top() where top.sb_evlist was not freed if evlist__add_bpf_sb_event() fails. Note that evlist__start_sb_thread() and evlist__stop_sb_thread() take ownership of the evlist and free it, so we must only free it if we fail before starting the thread. Also set top.sb_evlist to NULL to prevent use-after-free bugs.
Apply the same fix to builtin-record.c to avoid leaking rec->sb_evlist and calling pthread_join on uninitialized threads in the error path.
--- tools/perf/builtin-record.c | 2 ++ tools/perf/builtin-top.c | 2 ++ 2 files changed, 4 insertions(+)
tools/perf/builtin-record.c +2 -0
@@ -2258,6 +2258,8 @@ static int record__setup_sb_evlist(struct record *rec)if (evlist__add_bpf_sb_event (rec->sb_evlist,perf_session__env (rec->session))) {pr_err ("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n." ); +evlist__put (rec->sb_evlist); + rec->sb_evlist =NULL ;return -1 ; } }
tools/perf/builtin-top.c +2 -0
@@ -1881,6 +1881,8 @@ int cmd_top(int argc, const char **argv)if (evlist__add_bpf_sb_event (top.sb_evlist, &host_env)) {pr_err ("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n." ); status = -EINVAL ; +evlist__put (top.sb_evlist); + top.sb_evlist =NULL ; goto out_put_evlist; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1275/1815 perf python: Fix memory leak in pyrf_evlist__get_pollfd
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 38d778acbee3ee96c14e33863b747e674d975eae ]
Fix a Python list object leak in pyrf_evlist__get_pollfd() by adding a missing Py_DECREF on the error exit path.
--- tools/perf/util/python.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/python.c +3 -0
@@ -1781,6 +1781,8 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist, evlist = pevlist->evlist; list =PyList_New (0 ); +if (!list) +return NULL ;for (i =0 ; i <evlist__core (evlist)->pollfd.nr; ++i) {PyObject *file;
@@ -1799,6 +1801,7 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,return list; free_list: +Py_XDECREF (list);return PyErr_NoMemory (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1276/1815 perf synthetic-events: Fix uninitialized pthread_join
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 54ba44db4dddc4ca06b49bae0f9d6c5861430b18 ]
In perf_event__synthesize_threads(), fix an uninitialized pthread_join() call when thread creation fails by only joining the successfully created threads.
--- tools/perf/util/synthetic-events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/synthetic-events.c +2 -2
@@ -1104,8 +1104,8 @@ int perf_event__synthesize_threads(const struct perf_tool *tool, } err =0 ; out_join: -for (i =0 ; i < thread_nr; i++) -pthread_join (synthesize_threads[i],NULL ); +for (j =0 ; j < i; j++) +pthread_join (synthesize_threads[j],NULL );free (args); free_threads:free (synthesize_threads);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1277/1815 perf test: Fix skiplist leak in cmd_test
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 44e82c4d2ff37f073946b594840fd549ab6b9fb8 ]
Fix a memory leak in cmd_test() where skiplist was not freed on exit paths.
--- tools/perf/tests/builtin-test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/tests/builtin-test.c +7 -2
@@ -1796,9 +1796,14 @@ int cmd_test(int argc, const char **argv)rlimit__bump_memlock (); suites =build_suites (); -if (!suites) -return errno ? -errno : -ENOMEM ; +if (!suites) { +int err = errno; + +intlist__delete (skiplist); +return err ? -err : -ENOMEM ; + } ret =__cmd_test (suites, argc, argv, skiplist);free (suites); +intlist__delete (skiplist);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1237/1815 pinctrl: airoha: fix mdio bitfield names
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a8454680a6ce75fbbd8086bcb654eacf7897bc0f ]
Fix misprint in mdio bitfield name of GPIO_2ND_I2C_MODE register.
While at it also fix an7583 mdio. It should use an7583 specific mdio bitfield.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +6 -5
@@ -49,7 +49,7 @@/* MUX */ #define REG_GPIO_2ND_I2C_MODE 0x0214 -#define GPIO_MDC_IO_MASTER_MODE_MODE BIT(14) +#define GPIO_MDC_IO_MASTER_MODE_MASK BIT(14)#define GPIO_I2C_MASTER_MODE_MODE BIT(13)#define GPIO_I2S_MODE_MASK BIT(12)#define GPIO_I2C_SLAVE_MODE_MODE BIT(11)
@@ -66,6 +66,7 @@#define GPIO_2ND_I2C_MODE_MASK BIT(0)#define REG_GPIO_SPI_CS1_MODE 0x0218 +#define AN7583_GPIO_MDC_IO_MASTER_MODE_MASK BIT(22)#define GPIO_PCM_SPI_CS4_MODE_MASK BIT(21)#define GPIO_PCM_SPI_CS3_MODE_MASK BIT(20)#define GPIO_PCM_SPI_CS2_MODE_P156_MASK BIT(19)
@@ -1026,8 +1027,8 @@ static const struct airoha_pinctrl_func_group mdio_func_group[] = { .regmap[0] = {AIROHA_FUNC_MUX ,REG_GPIO_2ND_I2C_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE +GPIO_MDC_IO_MASTER_MODE_MASK , +GPIO_MDC_IO_MASTER_MODE_MASK }, .regmap[1] = { AIROHA_FUNC_MUX,
@@ -1051,8 +1052,8 @@ static const struct airoha_pinctrl_func_group an7583_mdio_func_group[] = { .regmap[1] = {AIROHA_FUNC_MUX ,REG_GPIO_SPI_CS1_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE +AN7583_GPIO_MDC_IO_MASTER_MODE_MASK , +AN7583_GPIO_MDC_IO_MASTER_MODE_MASK }, .regmap_size = 2, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1238/1815 pinctrl: airoha: an7581: fix pinconf of i2c_scl/i2c_sda pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 65ce9d5d781f872596194771d62ad6e1260fcf4f ]
Pinconfs of i2c_sda/i2c_scl pins are swapped, this needs to be fixed.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +8 -8
@@ -1844,8 +1844,8 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PU ,UART1_TXD_PU_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PU ,UART1_RXD_PU_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PU ,I2C_SCL_PU_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PU ,I2C_SCL_PU_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_PU ,SPI_CS0_PU_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_PU ,SPI_CLK_PU_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_PU ,SPI_MOSI_PU_MASK ),
@@ -1961,8 +1961,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PD ,UART1_TXD_PD_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PD ,UART1_RXD_PD_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PD ,I2C_SCL_PD_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PD ,I2C_SCL_PD_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_PD ,SPI_CS0_PD_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_PD ,SPI_CLK_PD_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_PD ,SPI_MOSI_PD_MASK ),
@@ -2078,8 +2078,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E2 ,UART1_TXD_E2_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E2 ,UART1_RXD_E2_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E2 ,I2C_SCL_E2_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E2 ,I2C_SCL_E2_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_E2 ,SPI_CS0_E2_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_E2 ,SPI_CLK_E2_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_E2 ,SPI_MOSI_E2_MASK ),
@@ -2195,8 +2195,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E4 ,UART1_TXD_E4_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E4 ,UART1_RXD_E4_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E4 ,I2C_SCL_E4_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E4 ,I2C_SCL_E4_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_E4 ,SPI_CS0_E4_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_E4 ,SPI_CLK_E4_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_E4 ,SPI_MOSI_E4_MASK ),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1239/1815 pinctrl: airoha: an7583: fix I2C0_SDA_PD register bit order
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit d560e28bdca824781898023496658404df01be9f ]
I2C1_SCL_PD and RG_I2C1_SDA_PD bits are swapped, fix it.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +2 -2
@@ -185,8 +185,8 @@#define I2C_SDA_PU_MASK BIT(0)#define REG_I2C_SDA_PD 0x0048 -#define AN7583_I2C1_SDA_PD_MASK BIT(16) -#define AN7583_I2C1_SCL_PD_MASK BIT(15) +#define AN7583_I2C1_SCL_PD_MASK BIT(16) +#define AN7583_I2C1_SDA_PD_MASK BIT(15)#define SPI_MISO_PD_MASK BIT(14)#define SPI_MOSI_PD_MASK BIT(13)#define SPI_CLK_PD_MASK BIT(12)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1240/1815 pinctrl: airoha: an7581: fix mux/conf of pcie_reset pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 739bc85aed14b739dca5b7aff4241b778af80220 ]
In the an7581 case
* gpio47 and pcie_reset0 shares pin 60,
* gpio48 and pcie_reset1 shares pin 61,
* gpio49 and pcie_reset2 shares pin 62.
but current driver treat them as pins 61--63. This is wrong.
Also current an7581 pinmux implementation have following issues:
* current pcie_reset pin function actually sets corresponding pins as gpios.
* there is no proper way to set pcie_reset pins as gpios.
* there is no way to set pcie_reset pins as pwm.
This patch fixes above issues.
WARNING:
There is a contradiction in the Airoha documentation. AN7581 programming guide claims:
- gpio44 and pcie_reset0 shares the same pin
- gpio45 and pcie_reset1 shares the same pin
- gpio46 and pcie_reset2 shares the same pin
While AN7581 datasheet claims:
- gpio47 and pcie_reset0 shares the same pin
- gpio48 and pcie_reset1 shares the same pin
- gpio49 and pcie_reset2 shares the same pin
The datasheet should be considered as a more reliable source. Thanks to Benjamin Larsson for clarification.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 122 +++++++++++++++++++----- 1 file changed, 97 insertions(+), 25 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +97 -25
@@ -470,9 +470,9 @@ static struct pinctrl_pin_desc en7581_pinctrl_pins[] = {PINCTRL_PIN (57 ,"gpio44" ),PINCTRL_PIN (58 ,"gpio45" ),PINCTRL_PIN (59 ,"gpio46" ), -PINCTRL_PIN (61 ,"pcie_reset0" ), -PINCTRL_PIN (62 ,"pcie_reset1" ), - PINCTRL_PIN(63, "pcie_reset2"), +PINCTRL_PIN (60 ,"pcie_reset0" ), +PINCTRL_PIN (61 ,"pcie_reset1" ), + PINCTRL_PIN(62, "pcie_reset2"), };static const int en7581_pon_pins[] = {49 ,50 ,51 ,52 ,53 ,54 };
@@ -555,9 +555,12 @@ static const int en7581_gpio43_pins[] = { 56 };static const int en7581_gpio44_pins[] = {57 };static const int en7581_gpio45_pins[] = {58 };static const int en7581_gpio46_pins[] = {59 }; -static const int en7581_pcie_reset0_pins[] = {61 }; -static const int en7581_pcie_reset1_pins[] = {62 }; -static const int en7581_pcie_reset2_pins[] = {63 }; +static const int en7581_gpio47_pins[] = {60 }; +static const int en7581_gpio48_pins[] = {61 }; +static const int en7581_gpio49_pins[] = {62 }; +static const int en7581_pcie_reset0_pins[] = {60 }; +static const int en7581_pcie_reset1_pins[] = {61 }; +static const int en7581_pcie_reset2_pins[] = {62 };static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("pon" , en7581_pon),
@@ -640,6 +643,9 @@ static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio44" , en7581_gpio44),PINCTRL_PIN_GROUP ("gpio45" , en7581_gpio45),PINCTRL_PIN_GROUP ("gpio46" , en7581_gpio46), +PINCTRL_PIN_GROUP ("gpio47" , en7581_gpio47), +PINCTRL_PIN_GROUP ("gpio48" , en7581_gpio48), +PINCTRL_PIN_GROUP ("gpio49" , en7581_gpio49),PINCTRL_PIN_GROUP ("pcie_reset0" , en7581_pcie_reset0),PINCTRL_PIN_GROUP ("pcie_reset1" , en7581_pcie_reset1), PINCTRL_PIN_GROUP("pcie_reset2", en7581_pcie_reset2),
@@ -883,6 +889,7 @@ static const char *const an7583_pcm_spi_groups[] = { "pcm_spi",static const char *const i2s_groups[] = {"i2s" };static const char *const emmc_groups[] = {"emmc" };static const char *const pnand_groups[] = {"pnand" }; +static const char *const gpio_groups[] = {"gpio47" ,"gpio48" ,"gpio49" };static const char *const pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" ,"pcie_reset2" };static const char *const an7583_pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" };
@@ -907,7 +914,8 @@ static const char *const pwm_groups[] = { "gpio0", "gpio1","gpio40" ,"gpio41" ,"gpio42" ,"gpio43" ,"gpio44" ,"gpio45" , - "gpio46" }; +"gpio46" ,"gpio47" , + "gpio48", "gpio49" };static const char *const an7583_pwm_groups[] = {"gpio0" ,"gpio1" ,"gpio2" ,"gpio3" , "gpio4", "gpio5",
@@ -1406,6 +1414,45 @@ static const struct airoha_pinctrl_func_group pnand_func_group[] = { }, }; +#define AIROHA_PINCTRL_GPIO (gpio, mux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap_size = 1, \ + } + +#define AIROHA_PINCTRL_GPIO_EXT (gpio, mux_val, smux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_EXT_MUX, \ + REG_GPIO_FLASH_MODE_CFG_EXT, \ + (mux_val), \ + 0 \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (smux_val), \ + (smux_val) \ + }, \ + .regmap_size = 2, \ + } + +static const struct airoha_pinctrl_func_group gpio_func_group[] = { +AIROHA_PINCTRL_GPIO_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET2_MASK ), +}; +static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { { .name ="pcie_reset0" ,
@@ -1413,7 +1460,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET0_MASK , -GPIO_PCIE_RESET0_MASK +0 }, .regmap_size = 1, }, {
@@ -1422,7 +1469,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET1_MASK , -GPIO_PCIE_RESET1_MASK +0 }, .regmap_size = 1, }, {
@@ -1431,7 +1478,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { AIROHA_FUNC_MUX,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET2_MASK , -GPIO_PCIE_RESET2_MASK + 0 }, .regmap_size = 1, },
@@ -1484,6 +1531,24 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { .regmap_size = 1, \ } \ +#define AIROHA_PINCTRL_PWM_EXT_SEC (gpio, mux_val, smux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_EXT_MUX, \ + REG_GPIO_FLASH_MODE_CFG_EXT, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (smux_val), \ + (smux_val) \ + }, \ + .regmap_size = 2, \ + } +static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM ("gpio0" ,GPIO0_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM ("gpio1" ,GPIO1_FLASH_MODE_CFG ),
@@ -1528,6 +1593,12 @@ static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio47" ,GPIO47_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio48" ,GPIO48_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio49" ,GPIO49_FLASH_MODE_CFG , + GPIO_PCIE_RESET2_MASK), }; static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = {
@@ -1804,6 +1875,7 @@ static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("i2s" , i2s),PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("gpio" , gpio),PINCTRL_FUNC_DESC ("pcie_reset" , pcie_reset),PINCTRL_FUNC_DESC ("pwm" , pwm), PINCTRL_FUNC_DESC("phy1_led0", phy1_led0),
@@ -1897,9 +1969,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_PU ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_PU ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_PU ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PU ,PCIE0_RESET_PU_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_PU ,PCIE1_RESET_PU_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_PU ,PCIE0_RESET_PU_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PU ,PCIE1_RESET_PU_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = {
@@ -2014,9 +2086,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_PD ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_PD ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_PD ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PD ,PCIE0_RESET_PD_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_PD ,PCIE1_RESET_PD_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_PD ,PCIE0_RESET_PD_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PD ,PCIE1_RESET_PD_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = {
@@ -2131,9 +2203,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_E2 ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_E2 ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_E2 ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E2 ,PCIE0_RESET_E2_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_E2 ,PCIE1_RESET_E2_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_E2 ,PCIE0_RESET_E2_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E2 ,PCIE1_RESET_E2_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = {
@@ -2248,9 +2320,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_E4 ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_E4 ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_E4 ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E4 ,PCIE0_RESET_E4_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_E4 ,PCIE1_RESET_E4_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_E4 ,PCIE0_RESET_E4_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E4 ,PCIE1_RESET_E4_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = {
@@ -2310,9 +2382,9 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = { };static const struct airoha_pinctrl_conf en7581_pinctrl_pcie_rst_od_conf[] = { -PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ), -PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ), -PINCTRL_CONF_DESC (63 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ), +PINCTRL_CONF_DESC (60 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ), +PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ), +PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ), };static const struct airoha_pinctrl_conf an7583_pinctrl_pcie_rst_od_conf[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1241/1815 pinctrl: airoha: an7583: fix muxing of non-gpio default pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit aaa41d8010c04635e035a9d334885b07edc8af21 ]
Current an7583 pinmux implementation have following issues:
* pins 51 and 52 can't be set as pcie_reset, current pcie_reset code will sets pins to gpio mode instead.
* there is no proper way to set pins 41--54 to gpio mode.
* pins 41--53 can't be actually set as pwm pins. These pins must be muxed to gpio mode as well.
This patch fixes above issues.
--- drivers/pinctrl/airoha/pinctrl-airoha.c | 99 +++++++++++++++++++++---- 1 file changed, 86 insertions(+), 13 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +86 -13
@@ -85,6 +85,18 @@#define GPIO_SPI_CS1_MODE_MASK BIT(0)#define REG_GPIO_PON_MODE 0x021c +#define AN7583_MDIO_0_GPIO_MODE_MASK BIT(26) +#define AN7583_MDC_0_GPIO_MODE_MASK BIT(25) +#define AN7583_UART_RXD_GPIO_MODE_MASK BIT(24) +#define AN7583_UART_TXD_GPIO_MODE_MASK BIT(23) +#define AN7583_SPI_MISO_GPIO_MODE_MASK BIT(22) +#define AN7583_SPI_MOSI_GPIO_MODE_MASK BIT(21) +#define AN7583_SPI_CS_GPIO_MODE_MASK BIT(20) +#define AN7583_SPI_CLK_GPIO_MODE_MASK BIT(19) +#define AN7583_I2C1_SDA_GPIO_MODE_MASK BIT(18) +#define AN7583_I2C1_SCL_GPIO_MODE_MASK BIT(17) +#define AN7583_I2C0_SDA_GPIO_MODE_MASK BIT(16) +#define AN7583_I2C0_SCL_GPIO_MODE_MASK BIT(15)#define GPIO_PARALLEL_NAND_MODE_MASK BIT(14)#define GPIO_SGMII_MDIO_MODE_MASK BIT(13)#define GPIO_PCIE_RESET2_MASK BIT(12)
@@ -783,6 +795,10 @@ static const int an7583_gpio45_pins[] = { 47 };static const int an7583_gpio46_pins[] = {48 };static const int an7583_gpio47_pins[] = {49 };static const int an7583_gpio48_pins[] = {50 }; +static const int an7583_gpio49_pins[] = {51 }; +static const int an7583_gpio50_pins[] = {52 }; +static const int an7583_gpio51_pins[] = {53 }; +static const int an7583_gpio52_pins[] = {54 };static const int an7583_pcie_reset0_pins[] = {51 };static const int an7583_pcie_reset1_pins[] = {52 };
@@ -863,6 +879,10 @@ static const struct pingroup an7583_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio46" , an7583_gpio46),PINCTRL_PIN_GROUP ("gpio47" , an7583_gpio47),PINCTRL_PIN_GROUP ("gpio48" , an7583_gpio48), +PINCTRL_PIN_GROUP ("gpio49" , an7583_gpio49), +PINCTRL_PIN_GROUP ("gpio50" , an7583_gpio50), +PINCTRL_PIN_GROUP ("gpio51" , an7583_gpio51), +PINCTRL_PIN_GROUP ("gpio52" , an7583_gpio52),PINCTRL_PIN_GROUP ("pcie_reset0" , an7583_pcie_reset0), PINCTRL_PIN_GROUP("pcie_reset1", an7583_pcie_reset1), };
@@ -892,6 +912,11 @@ static const char *const pnand_groups[] = { "pnand" };static const char *const gpio_groups[] = {"gpio47" ,"gpio48" ,"gpio49" };static const char *const pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" ,"pcie_reset2" }; +static const char *const an7583_gpio_groups[] = {"gpio39" ,"gpio40" ,"gpio41" , +"gpio42" ,"gpio43" ,"gpio44" , +"gpio45" ,"gpio46" ,"gpio47" , +"gpio48" ,"gpio49" ,"gpio50" , +"gpio51" ,"gpio52" };static const char *const an7583_pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" };static const char *const pwm_groups[] = {"gpio0" ,"gpio1" ,"gpio2" ,"gpio3" ,
@@ -938,7 +963,8 @@ static const char *const an7583_pwm_groups[] = { "gpio0", "gpio1","gpio42" ,"gpio43" ,"gpio44" ,"gpio45" ,"gpio46" ,"gpio47" , - "gpio48" }; +"gpio48" ,"gpio49" , + "gpio50", "gpio51" };static const char *const phy1_led0_groups[] = {"gpio33" ,"gpio34" ,"gpio35" ,"gpio42" }; static const char *const phy2_led0_groups[] = { "gpio33", "gpio34",
@@ -1484,6 +1510,36 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { }, }; +static const struct airoha_pinctrl_func_group an7583_gpio_func_group[] = { +AIROHA_PINCTRL_GPIO_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG , +AN7583_I2C0_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG , +AN7583_I2C0_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG , +AN7583_I2C1_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG , +AN7583_I2C1_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG , +AN7583_SPI_CLK_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG , +AN7583_SPI_CS_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG , +AN7583_SPI_MOSI_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG , +AN7583_SPI_MISO_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG , +AN7583_UART_TXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG , +AN7583_UART_RXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio50" ,GPIO50_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio51" ,GPIO51_FLASH_MODE_CFG , +AN7583_MDC_0_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO ("gpio52" ,AN7583_MDIO_0_GPIO_MODE_MASK ), +}; +static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { { .name ="pcie_reset0" ,
@@ -1491,7 +1547,7 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET0_MASK , -GPIO_PCIE_RESET0_MASK +0 }, .regmap_size = 1, }, {
@@ -1500,7 +1556,7 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { AIROHA_FUNC_MUX,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET1_MASK , -GPIO_PCIE_RESET1_MASK + 0 }, .regmap_size = 1, },
@@ -1637,16 +1693,32 @@ static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio36" ,GPIO36_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio37" ,GPIO37_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio38" ,GPIO38_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG ), - AIROHA_PINCTRL_PWM_EXT("gpio48", GPIO48_FLASH_MODE_CFG), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio39" ,GPIO39_FLASH_MODE_CFG , +AN7583_I2C0_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio40" ,GPIO40_FLASH_MODE_CFG , +AN7583_I2C0_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio41" ,GPIO41_FLASH_MODE_CFG , +AN7583_I2C1_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio42" ,GPIO42_FLASH_MODE_CFG , +AN7583_I2C1_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio43" ,GPIO43_FLASH_MODE_CFG , +AN7583_SPI_CLK_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio44" ,GPIO44_FLASH_MODE_CFG , +AN7583_SPI_CS_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio45" ,GPIO45_FLASH_MODE_CFG , +AN7583_SPI_MOSI_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio46" ,GPIO46_FLASH_MODE_CFG , +AN7583_SPI_MISO_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio47" ,GPIO47_FLASH_MODE_CFG , +AN7583_UART_TXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio48" ,GPIO48_FLASH_MODE_CFG , +AN7583_UART_RXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio50" ,GPIO50_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio51" ,GPIO51_FLASH_MODE_CFG , + AN7583_MDC_0_GPIO_MODE_MASK), };#define AIROHA_PINCTRL_PHY_LED0 (gpio, mux_val, map_mask, map_val) \
@@ -1901,6 +1973,7 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("pcm_spi" , an7583_pcm_spi),PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("gpio" , an7583_gpio),PINCTRL_FUNC_DESC ("pcie_reset" , an7583_pcie_reset),PINCTRL_FUNC_DESC ("pwm" , an7583_pwm), PINCTRL_FUNC_DESC("phy1_led0", an7583_phy1_led0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1232/1815 btrfs: zoned: dont clobber the extent buffer when zeroing it out
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit db4b9eefc8ee0bcaeee4d5e6a7313905f6a2fe7c ]
On a zoned filesystem a freed-but-still-dirty tree block is written out as zeros (EXTENT_BUFFER_ZONED_ZEROOUT) only to keep the zone write pointer advancing. btree_csum_one_bio() implemented this by memzeroing the extent buffer's own folios before submission.
That destroys the in-memory buffer while it may still be referenced. In particular btrfs_free_tree_block() can run on it afterwards and reads the header to add a delayed reference; once the header has been zeroed it frees bytenr 0 and corrupts the extent tree (the btrfs_header_bytenr(buf) != 0 ASSERT in btrfs_free_tree_block(), or an "unable to find ref" abort). It is flaky and reproduces under fsstress, e.g. generic/461 and generic/013.
Write the zeros to disk from the shared zero page instead and leave the extent buffer content untouched, so any later reference - including the delayed reference from btrfs_free_tree_block() - still sees a valid header. end_bbio_meta_write() now clears writeback on the buffer's own folios, as the bio no longer carries them.
--- fs/btrfs/disk-io.c | 13 +++++++------ fs/btrfs/extent_io.c | 31 ++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-)
fs/btrfs/disk-io.c +7 -6
@@ -271,14 +271,15 @@ int btree_csum_one_bio(struct btrfs_bio *bbio)return -EIO ;/* -* If an extent_buffer is marked as EXTENT_BUFFER_ZONED_ZEROOUT, don't -* checksum it but zero-out its content. This is done to preserve -* ordering of I/O without unnecessarily writing out data. +* An extent_buffer marked EXTENT_BUFFER_ZONED_ZEROOUT is written out as +* zeros to preserve ordering of I/O without persisting the now +* unnecessary block. The bio is fed from the shared zero page (see +* write_one_eb()), so there is nothing to checksum here. Crucially, the +* buffer's own content is left intact: it may still be referenced, e.g. +* btrfs_free_tree_block() reads its header to add a delayed reference. */ -if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) { -memzero_extent_buffer (eb,0 , eb->len); +if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags))return 0 ; - }if (WARN_ON_ONCE (found_start != eb->start))return -EIO ;
fs/btrfs/extent_io.c +24 -7
@@ -2379,14 +2379,17 @@ static struct extent_buffer *find_extent_buffer_nolock(static void end_bbio_meta_write (struct btrfs_bio *bbio) {struct extent_buffer *eb = bbio->private; -struct folio_iter fi;if (bbio->bio.bi_status !=BLK_STS_OK )set_btree_ioerr (eb); -bio_for_each_folio_all (fi, &bbio->bio) { -btrfs_meta_folio_clear_writeback (fi.folio, eb); - } +/* +* Clear writeback on the buffer's own folios. The bio may carry the +* shared zero page instead (EXTENT_BUFFER_ZONED_ZEROOUT), so iterate +* the extent buffer folios rather than the bio folios. +*/ +for (int i =0 ; i <num_extent_folios (eb); i++) +btrfs_meta_folio_clear_writeback (eb->folios[i], eb);buffer_tree_clear_mark (eb,PAGECACHE_TAG_WRITEBACK );clear_and_wake_up_bit (EXTENT_BUFFER_WRITEBACK , &eb->bflags);
@@ -2427,7 +2430,8 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,struct btrfs_fs_info *fs_info = eb->fs_info;struct btrfs_bio *bbio; -prepare_eb_write (eb); +if (!test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) +prepare_eb_write (eb); bbio = btrfs_bio_alloc(INLINE_EXTENT_BUFFER_PAGES, REQ_OP_WRITE | REQ_META | wbc_to_write_flags(wbc),
@@ -2447,8 +2451,21 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,btrfs_meta_folio_set_writeback (folio, eb);if (!folio_test_dirty (folio)) wbc->nr_to_write -=folio_nr_pages (folio); -bio_add_folio_nofail (&bbio->bio, folio, range_len, -offset_in_folio (folio, range_start)); +if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) { +u32 off =0 ; + +while (off < range_len) { +u32 add =min_t (u32,PAGE_SIZE , range_len - off); + +bio_add_folio_nofail (&bbio->bio, +page_folio (ZERO_PAGE (0 )), + add,0 ); + off += add; + } + }else { +bio_add_folio_nofail (&bbio->bio, folio, range_len, +offset_in_folio (folio, range_start)); + }wbc_account_cgroup_owner (wbc, folio, range_len);folio_unlock (folio); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1279/1815 perf python: Handle Py_None for thread and cpu maps
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 054d1c7717b95d9089cd3b80e9e85fe1f2ea0471 ]
The python stubs allow passing None for threads and cpus to the perf.parse_events() and perf.parse_metrics() bindings. However, PyArg_ParseTuple parses None into a Py_None object, which is not a NULL pointer. Because the C code lacked an explicit check for Py_None, it would cast Py_None to a pyrf_thread_map/pyrf_cpu_map struct pointer and dereference it, causing a memory corruption crash.
Fix this pre-existing issue by explicitly checking for Py_None alongside NULL in pyrf__parse_events, pyrf__parse_metrics, and pyrf_evsel__open.
Stable-dep-of: 9a142beb1eba ("perf python: Validate CPU and thread maps in pyrf_evsel__open")
--- tools/perf/util/python.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
tools/perf/util/python.c +10 -6
@@ -1107,10 +1107,10 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel, &pcpus, &pthreads, &group, &inherit))return NULL ; -if (pthreads !=NULL ) +if (pthreads !=NULL && pthreads != Py_None) threads = ((struct pyrf_thread_map *)pthreads)->threads; -if (pcpus !=NULL ) +if (pcpus !=NULL && pcpus != Py_None) cpus = ((struct pyrf_cpu_map *)pcpus)->cpus; evsel->core.attr.inherit = inherit;
@@ -2333,8 +2333,10 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)return NULL ; } - threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads :NULL ; - cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ; + threads = (pthreads && pthreads != Py_None) ? + ((struct pyrf_thread_map *)pthreads)->threads :NULL ; + cpus = (pcpus && pcpus != Py_None) ? + ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ;parse_events_error__init (&err);perf_evlist__set_maps (evlist__core (evlist), cpus, threads);
@@ -2367,8 +2369,10 @@ static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)return NULL ; } - threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads :NULL ; - cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ; + threads = (pthreads && pthreads != Py_None) ? + ((struct pyrf_thread_map *)pthreads)->threads :NULL ; + cpus = (pcpus && pcpus != Py_None) ? + ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ;perf_evlist__set_maps (evlist__core (evlist), cpus, threads); ret = metricgroup__parse_groups(evlist, pmu ?: "all",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1288/1815 fbdev: clps711x-fb: Remove unreachable unregister_framebuffer() call
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 39dd7598fbe90c5b4bb77fb34d8f3dad8385d11c ]
The unregister_framebuffer() call in clps711x_fb_probe() is unreachable. register_framebuffer() failure jumps to the unwind label, while success returns immediately.
Remove it.
Found with Clang's -Wunreachable-code.
--- drivers/video/fbdev/clps711x-fb.c | 2 -- 1 file changed, 2 deletions(-)
drivers/video/fbdev/clps711x-fb.c +0 -2
@@ -329,8 +329,6 @@ static int clps711x_fb_probe(struct platform_device *pdev)return 0 ; -unregister_framebuffer (info); - out_fb_dealloc_cmap:regmap_update_bits (cfb->syscon,SYSCON_OFFSET ,SYSCON1_LCDEN ,0 );fb_dealloc_cmap (&info->cmap);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1289/1815 iommu/dma: Restore locking around msi_page_list
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Jones <[email protected]>
[ Upstream commit 5a9e89ea34e0e34ac5d7e949042d665533549e40 ]
Unlike a group's default domain, which is always freshly allocated and privately owned (iommu_group_alloc_default_domain()), VFIO type1's legacy container merges any newly attached group into an existing domain whenever their iommu_ops and cache-coherency enforcement match.
iommu_dma_get_msi_page() only asserts the caller's own group mutex is held (iommu_group_mutex_assert()). On an IOMMU that publishes IOMMU_RESV_SW_MSI, e.g. ARM SMMU, a VM with two such devices assigned through the legacy container can have their guest drivers probe and allocate MSIs in parallel; each host-side VFIO_DEVICE_SET_IRQS lands on a different device fd and group mutex, but both devices' domains are the same merged domain, so both can enter iommu_dma_get_msi_page() concurrently and corrupt msi_page_list.
commit 288683c92b1a ("iommu: Make iommu_dma_prepare_msi() into a generic operation") dropped the prior msi_prepare_lock on the reasoning that "each iommu_domain is unique to a group," which holds for default domains but not this VFIO type1 case. Restore the static lock, since it's only guarding a corner case and will likely never be contended.
iommufd avoids the equivalent problem by having its own callers (iommufd_sw_map_msi()) take a ctx-wide sw_msi_lock before ever reaching the shared list. VFIO type1 can't mirror that since it dispatches to iommu_dma_sw_msi() which is outside VFIO's jurisdiction.
--- drivers/iommu/dma-iommu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/iommu/dma-iommu.c +13 -0
@@ -2207,6 +2207,19 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,dma_addr_t iova;int prot =IOMMU_WRITE |IOMMU_NOEXEC |IOMMU_MMIO ;size_t size =cookie_msi_granule (domain); +static DEFINE_MUTEX (msi_prepare_lock); + +/* +* Normally a device's default domain is only ever attached to that +* device's own group, and the group mutex held by +* iommu_group_mutex_assert()'s callers is enough on its own. A VFIO +* type1 container is the one case that breaks that assumption: it +* can merge devices from different groups onto one domain, so two +* devices' group mutexes don't serialize each other here. A static +* lock is sufficient due to the expectation that this is a corner +* case that will never be contended in practice. +*/ +guard (mutex)(&msi_prepare_lock); msi_addr &= ~(phys_addr_t)(size -1 );list_for_each_entry (msi_page, msi_page_list, list)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1290/1815 iommu/vt-d: Fix UCTP context table slot when copying root entries
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Desnes Nunes <[email protected]>
[ Upstream commit c6e63fc8e8fcefa5c32145dc0a3c82975b0ce152 ]
When translation is already enabled at boot (e.g. kdump), the vt-d driver copies context tables from the previous kernel's root table. In scalable mode, buses that only populate the upper root half (UCTP, devfn >= 0x80) should be written to ctxt_tbls[tbl_idx + 1] through copy_context_table(). However, the current copy path always uses tbl[tbl_idx + 0] in this situa- tion. Since idx wraps to 0 at devfn 0x80 due to a zeroed LCTP, new_ce for LCTP will be NULL and keep pos equals to 0. Thus, UCTP entries will be co- pied into tbl[tbl_idx + 0] instead of tbl[tbl_idx + 1], and written after- wards to root_entry[bus].lo instead of .hi in copy_translation_tables().
In short, devices on bus 0x80 with devfn >= 0x80 fail DMA with fault 0x39, which will break drivers running in kernels with translation pre-enabled. This fixes NO_PASID DMAR faults for UCTP-only buses such as:
DMAR: [DMA Read NO_PASID] Request device [80:14.0] fault addr 0xe81759000
[fault reason 0x39] SM: Present bit in Root Entry is clear
For instance, this fault yielded to locking issues between systemd and xHCI, blocking a system's reboot after a vmcore was captured with kdump:
systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 is taking a long time dracut-initqueue[277]: Timed out while waiting for udev queue to empty. systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 killed systemd-udevd[246]: usb3: Worker [255] terminated by signal 9 (KILL).
...
kdump[569]: saving vmcore complete
...
systemd-shutdown[1]: Rebooting.
INFO: task kworker/0:1:11 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:1 state:D stack:0 pid:11 tgid:11 ppid:2 task_flags:0x4208160 flags:0x00080000
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_timeout+0xbd/0x100
__wait_for_common+0x97/0x1b0
? __pfx_schedule_timeout+0x10/0x10
xhci_alloc_dev+0x9e/0x2b0
usb_alloc_dev+0x7a/0x3b0
hub_port_connect+0x285/0x960
hub_port_connect_change+0x94/0x290
port_event+0x4bb/0x840
hub_event+0x141/0x460
process_one_work+0x196/0x390
worker_thread+0x1af/0x320
? __pfx_worker_thread+0x10/0x10
kthread+0xe3/0x120
? __pfx_kthread+0x10/0x10
ret_from_fork+0x199/0x260
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
INFO: task systemd-shutdow:1 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:systemd-shutdow state:D stack:0 pid:1 tgid:1 ppid:0 task_flags:0x400100 flags:0x00080000
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_preempt_disabled+0x15/0x30
__mutex_lock.constprop.0+0x547/0xac0
device_shutdown+0xac/0x1b0
kernel_restart+0x3a/0x70
__do_sys_reboot+0x147/0x240
do_syscall_64+0x11b/0x6a0
? handle_mm_fault+0x110/0x350
? do_user_addr_fault+0x206/0x680
? irqentry_exit+0x7a/0x4d0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
RIP: 0033:0x7fe2958da917
RSP: 002b:00007ffc5c458618 EFLAGS: 00000206 ORIG_RAX: 00000000000000a9
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe2958da917
RDX: 0000000001234567 RSI: 0000000028121969 RDI: 00000000fee1dead
RBP: 00007ffc5c458790 R08: 0000000000000069 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 0000000000000000 R14: 00007ffc5c4588b8 R15: 0000000000000000
</TASK>
INFO: task systemd-shutdow:1 is blocked on a mutex likely owned by task kworker/0:1:11.--- drivers/iommu/intel/iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.c +6 -4
@@ -1446,7 +1446,7 @@ static int copy_context_table(struct intel_iommu *iommu,struct context_entry **tbl, int bus, bool ext) { - int tbl_idx, pos = 0, idx, devfn, ret = 0, did; + int tbl_idx, tbl_slot = 0, idx, devfn, ret = 0, did;struct context_entry *new_ce =NULL , ce;struct context_entry *old_ce =NULL ;struct root_entry re;
@@ -1462,10 +1462,9 @@ static int copy_context_table(struct intel_iommu *iommu,if (idx ==0 ) {/* First save what we may have and clean up */ if (new_ce) { - tbl[tbl_idx] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE ); - pos =1 ; }if (old_ce)
@@ -1487,6 +1486,9 @@ static int copy_context_table(struct intel_iommu *iommu, } } +/* Track if saving UCTP or LCTP entries in scalable mode */ + tbl_slot = ext && devfn >=0x80 ?1 :0 ; + ret = -ENOMEM ; old_ce =memremap (old_ce_phys,PAGE_SIZE ,MEMREMAP_WB );
@@ -1515,7 +1517,7 @@ static int copy_context_table(struct intel_iommu *iommu, new_ce[idx] = ce; } - tbl[tbl_idx + pos] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1291/1815 iommu/vt-d: Clear Present bit before tearing down copied context entry
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit f532c57985b1a7d6b7e37e05506b46d413e5cca4 ]
copied_context_tear_down() zeroes the 128-bit context entry with context_clear_entry() while the Present bit is still set, and only then issues the context-cache and IOTLB invalidations. This leaves a window in which hardware can fetch a torn entry, with some fields already zeroed while Present is still set, leading to unpredictable behaviour or spurious faults. While x86 provides strong write ordering, the compiler may reorder the writes to the two 64-bit halves of the entry, and the hardware fetch is not guaranteed to be atomic with respect to multiple CPU writes.
There is no cacheline flush before the invalidation either, so on an IOMMU without coherent access to the context table the zeroed entry may not be visible to hardware at the point the invalidation is submitted.
Apply the same ownership handshake described in the VT-d spec, Section 6.5.3.3 ("Guidance to Software for Invalidations"): clear only the Present bit, flush it out to the IOMMU, perform the invalidations, and only then zero the remainder of the entry.
--- drivers/iommu/intel/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +5 -1
@@ -1108,7 +1108,8 @@ static void copied_context_tear_down(struct intel_iommu *iommu,assert_spin_locked (&iommu->lock); did_old =context_domain_id (context); -context_clear_entry (context); +context_clear_present (context); +__iommu_flush_cache (iommu, context,sizeof (*context));if (did_old <cap_ndoms (iommu->cap)) { iommu->flush.flush_context(iommu, did_old,
@@ -1119,6 +1120,9 @@ static void copied_context_tear_down(struct intel_iommu *iommu, DMA_TLB_DSI_FLUSH); } +context_clear_entry (context); +__iommu_flush_cache (iommu, context,sizeof (*context)); +clear_context_copied (iommu, bus, devfn); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1292/1815 iommu/vt-d: Fix iopf_refcount leak on RID domain replacement
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit 236dd58fabd2e951b940a6ad88b81147899ed311 ]
intel_iommu_attach_device() enables IOPF for the new domain but never disables it for the old one. device_block_translation(), called at the start of the function, tears down translation but does not touch any IOPF state; blocking_domain_attach_dev() has to call iopf_for_domain_remove() explicitly before invoking it for exactly this reason.
identity_domain_attach_dev() has the same problem. Its comment claims that no PRI handling is needed because the device has been put in the blocking state, but the blocking state and the IOPF reference count are independent of each other.
As a result, replacing a domain that has an iopf_handler with another domain at RID level leaks a reference in info->iopf_refcount. The count never drops back to zero, so iopf_queue_remove_device() is never called and iommu_disable_pci_pri() triggers its WARN_ON(info->iopf_refcount) when the device is released.
The PASID paths already handle this correctly by way of iopf_for_domain_replace(); convert the two RID paths to do the same. Using the replace helper rather than a bare remove keeps the enable before the disable, so the reference count does not transiently reach zero and evict the device from the IOPF queue.
--- drivers/iommu/intel/iommu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/iommu/intel/iommu.c +8 -5
@@ -3141,13 +3141,13 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,if (ret)return ret; - ret =iopf_for_domain_set (domain, dev); + ret =iopf_for_domain_replace (domain, old, dev);if (ret)return ret; ret =dmar_domain_attach_device (to_dmar_domain (domain), dev);if (ret) -iopf_for_domain_remove (domain, dev); +iopf_for_domain_replace (old, domain, dev);return ret; }
@@ -3850,10 +3850,13 @@ static int identity_domain_attach_dev(struct iommu_domain *domain,return 0 ;/* -* No PRI support with the global identity domain. No need to enable or -* disable PRI in this path as the iommu has been put in the blocking -* state. +* The identity domain has no iopf_handler, so no IOPF reference is +* taken for it. The reference held by the old domain must still be +* released here; putting the device in the blocking state above does +* not affect the IOPF reference count. */ +iopf_for_domain_remove (old, dev); +if (sm_supported (iommu)) ret =intel_pasid_setup_pass_through (iommu, dev,IOMMU_NO_PASID );else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1293/1815 iommu/vt-d: Tear down scalable-mode context on probe failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit c509fb73a1093a15accd7d43a61645d4b520f6ac ]
intel_pasid_setup_sm_context() walks a PCI device’s DMA aliases via pci_for_each_dma_alias() and programs a scalable-mode context entry for each RID. For a device with a dma_alias_mask, the callback is invoked once for the device’s own RID and once for each alias bit, all with the same pci_dev, so device_pasid_table_setup() runs for multiple RIDs.
pci_for_each_dma_alias() stops at the first callback error. Therefore, a failure partway through the walk can leave context entries for already processed RIDs present and still pointing to the device’s PASID table.
On this error path, intel_iommu_probe_device() currently jumps directly to intel_pasid_free_table(), which frees the PASID table without first tearing down those context entries. The IOMMU may then walk a present context entry whose PASID table pointer references freed memory.
intel_iommu_release_device() already performs teardown before freeing the table. Apply the same ordering on the probe failure path.
device_pasid_table_teardown() safely handles RIDs that were never
programmed: iommu_context_addr() returns NULL when no context table has been allocated, and clearing the Present bit of an already non-present entry is a no-op. So unwind is safe for both the alias that failed and any aliases not yet reached.
--- drivers/iommu/intel/iommu.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/intel/iommu.c +1 -0
@@ -3322,6 +3322,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)return &iommu->iommu; free_table: +intel_pasid_teardown_sm_context (dev);intel_pasid_free_table (dev); clear_rbtree:device_rbtree_remove (info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1294/1815 iommu/vt-d: Flush context cache with correct SID when tearing down aliases
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit c54e4ae971b98e8d650400137d332cee56c03f55 ]
domain_context_clear_one() and device_pasid_table_teardown() are both invoked once per DMA alias of a device. Each function locates the context entry using the bus/devfn pair provided by the pci_for_each_dma_alias() callback, then calls intel_context_flush_no_pasid(), which constructs a device-selective context-cache invalidation from info->bus and info->devfn (that is, always the requester ID of the device itself).
As a result, for every alias other than the device’s own RID, the context entry that was just cleared in memory is never invalidated in the context cache. Hardware may continue using that stale cached entry. In the scalable-mode teardown path, intel_pasid_free_table() can then free the PASID directory still referenced by that stale entry, allowing the IOMMU to walk freed memory.
Fix this by passing the source ID of the entry being torn down to intel_context_flush_no_pasid(), instead of deriving it from @info.
--- drivers/iommu/intel/iommu.c | 2 +- drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/intel/pasid.c | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/iommu/intel/iommu.c +1 -1
@@ -1250,7 +1250,7 @@ static void domain_context_clear_one(struct device_domain_info *info, u8 bus, u8context_clear_present (context);__iommu_flush_cache (iommu, context,sizeof (*context));spin_unlock (&iommu->lock); -intel_context_flush_no_pasid (info, context, did); +intel_context_flush_no_pasid (info, context, did,PCI_DEVID (bus, devfn));context_clear_entry (context);__iommu_flush_cache (iommu, context,sizeof (*context)); }
drivers/iommu/intel/iommu.h +1 -1
@@ -1240,7 +1240,7 @@ void cache_tag_flush_range_np(struct dmar_domain *domain, unsigned long start, unsigned long end);void intel_context_flush_no_pasid (struct device_domain_info *info, -struct context_entry *context,u16 did); +struct context_entry *context,u16 did,u16 sid);int intel_iommu_enable_prq (struct intel_iommu *iommu);int intel_iommu_finish_prq (struct intel_iommu *iommu);
drivers/iommu/intel/pasid.c +6 -3
@@ -751,7 +751,7 @@ static void device_pasid_table_teardown(struct device *dev, u8 bus, u8 devfn)context_clear_present (context);__iommu_flush_cache (iommu, context,sizeof (*context));spin_unlock (&iommu->lock); -intel_context_flush_no_pasid (info, context, did); +intel_context_flush_no_pasid (info, context, did,PCI_DEVID (bus, devfn));context_clear_entry (context);__iommu_flush_cache (iommu, context,sizeof (*context)); }
@@ -955,9 +955,12 @@ static void __context_flush_dev_iotlb(struct device_domain_info *info)* This helper can only be used when IOMMU is working in the legacy mode or * IOMMU is in scalable mode but all PASID table entries of the device are * non-present. +* +* @sid identifies the context entry that was modified, which may be a DMA +* alias of @info->dev rather than its own requester ID. */ void intel_context_flush_no_pasid (struct device_domain_info *info, -struct context_entry *context,u16 did) +struct context_entry *context,u16 did,u16 sid) {struct intel_iommu *iommu = info->iommu;
@@ -967,7 +970,7 @@ void intel_context_flush_no_pasid(struct device_domain_info *info,* when operating in scalable mode. Therefore the @did value doesn't * matter in scalable mode. */ - iommu->flush.flush_context (iommu, did,PCI_DEVID (info->bus, info->devfn), + iommu->flush.flush_context (iommu, did, sid,DMA_CCMD_MASK_NOBIT ,DMA_CCMD_DEVICE_INVL );/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1295/1815 crypto: qat - use 2-arg strscpy where destination size is known
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 4525ac14115d07c3e4c57a8cd5c154916e9d1172 ]
To simplify the code, drop explicit and hard-coded size arguments from strscpy() where the destination buffer has a fixed size and strscpy() can automatically determine it using sizeof().
Stable-dep-of: 61135c1597af ("crypto: qat - remove dead ADF_HEX code")
--- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 7 ++++--- drivers/crypto/intel/qat/qat_common/adf_cfg_services.c | 2 +- drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c | 3 ++- drivers/crypto/intel/qat/qat_common/adf_transport_debug.c | 3 ++- drivers/crypto/intel/qat/qat_common/qat_compression.c | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg.c +4 -3
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/list.h> #include <linux/seq_file.h> #include "adf_accel_devices.h"
@@ -284,13 +285,13 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,return -ENOMEM ;INIT_LIST_HEAD (&key_val->list); -strscpy (key_val->key, key,sizeof (key_val->key)); +strscpy (key_val->key, key);if (type ==ADF_DEC ) {snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES ,"%ld" , (*((long *)val))); }else if (type ==ADF_STR ) { -strscpy (key_val->val, (char *)val,sizeof (key_val->val)); +strscpy (key_val->val, (char *)val); }else if (type ==ADF_HEX ) {snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES ,"0x%lx" , (unsigned long )val);
@@ -350,7 +351,7 @@ int adf_cfg_section_add(struct adf_accel_dev *accel_dev, const char *name)if (!sec)return -ENOMEM ; -strscpy (sec->name, name,sizeof (sec->name)); +strscpy (sec->name, name);INIT_LIST_HEAD (&sec->param_head);down_write (&cfg->lock);list_add_tail (&sec->list, &cfg->sec_list);
drivers/crypto/intel/qat/qat_common/adf_cfg_services.c +1 -1
@@ -60,7 +60,7 @@ static int adf_service_string_to_mask(struct adf_accel_dev *accel_dev, const chaif (len >ADF_CFG_MAX_VAL_LEN_IN_BYTES -1 )return -EINVAL ; -strscpy (services, buf,ADF_CFG_MAX_VAL_LEN_IN_BYTES ); +strscpy (services, buf); substr = services;while ((token =strsep (&substr,ADF_SERVICES_DELIMITER ))) {
drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2024 Intel Corporation */ #include <linux/slab.h> +#include <linux/string.h> #include <linux/types.h> #include "adf_mstate_mgr.h"
@@ -158,7 +159,7 @@ static struct adf_mstate_sect_h *adf_mstate_sect_add_header(struct adf_mstate_mgreturn NULL ; } -strscpy (sect->id, id,sizeof (sect->id)); +strscpy (sect->id, id); sect->size =0 ; sect->sub_sects =0 ; mgr->state +=sizeof (*sect);
drivers/crypto/intel/qat/qat_common/adf_transport_debug.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/seq_file.h> #include "adf_accel_devices.h" #include "adf_transport_internal.h"
@@ -103,7 +104,7 @@ int adf_ring_debugfs_add(struct adf_etr_ring_data *ring, const char *name)if (!ring_debug)return -ENOMEM ; -strscpy (ring_debug->ring_name, name,sizeof (ring_debug->ring_name)); +strscpy (ring_debug->ring_name, name);snprintf (entry_name,sizeof (entry_name),"ring_%02d" , ring->ring_number);
drivers/crypto/intel/qat/qat_common/qat_compression.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2022 Intel Corporation */ #include <linux/module.h> #include <linux/slab.h> +#include <linux/string.h> #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "adf_transport.h"
@@ -144,7 +145,7 @@ static int qat_compression_create_instances(struct adf_accel_dev *accel_dev)int i;INIT_LIST_HEAD (&accel_dev->compression_list); -strscpy (key,ADF_NUM_DC ,sizeof (key)); +strscpy (key,ADF_NUM_DC ); ret =adf_cfg_get_param_value (accel_dev,SEC , key, val);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1296/1815 crypto: qat - remove dead ADF_HEX code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 61135c1597af56eb454d53c9d7cda90d5e5dc566 ]
The ADF_HEX value type is defined in the adf_cfg_val_type enum and handled in adf_cfg_add_key_value_param(), but no caller in the tree uses it.
Remove the unused ADF_HEX enum value and its dead handling code.
--- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 3 --- drivers/crypto/intel/qat/qat_common/adf_cfg_common.h | 1 - 2 files changed, 4 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg.c +0 -3
@@ -292,9 +292,6 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev, "%ld", (*((long *)val))); }else if (type ==ADF_STR ) {strscpy (key_val->val, (char *)val); - }else if (type ==ADF_HEX ) { -snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES , -"0x%lx" , (unsigned long )val); }else {dev_err (&GET_DEV (accel_dev),"Unknown type given.\n" );kfree (key_val);
drivers/crypto/intel/qat/qat_common/adf_cfg_common.h +0 -1
@@ -28,7 +28,6 @@ enum adf_cfg_service_type {enum adf_cfg_val_type {ADF_DEC , -ADF_HEX ,ADF_STR };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1297/1815 hwrng: imx-rngc - Disable clock on registration failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 188bb9ad86c3b2d527385328a30c1d9510253202 ]
The RNGC clock is enabled manually before runtime PM is configured. If devm_hwrng_register() fails, probe returns without disabling the clock. The devm_pm_runtime_enable() cleanup only disables runtime PM and does not call imx_rngc_suspend().
Disable the clock before returning from this failure path.
--- drivers/char/hw_random/imx-rngc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/imx-rngc.c +3 -1
@@ -313,8 +313,10 @@ static int __init imx_rngc_probe(struct platform_device *pdev)devm_pm_runtime_enable (&pdev->dev); ret =devm_hwrng_register (&pdev->dev, &rngc->rng); -if (ret) +if (ret) { +clk_disable_unprepare (rngc->clk);return dev_err_probe (&pdev->dev, ret,"hwrng registration failed\n" ); + } dev_info(&pdev->dev, "Freescale RNG%c registered (HW revision %d.%02d)\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1280/1815 perf python: Validate CPU and thread maps in pyrf_evsel__open
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 9a142beb1eba42b986dc7016f4fc1a3bc28b8c09 ]
Add explicit Py_TYPE checks to ensure the arguments passed are actually of the correct pyrf_thread_map and pyrf_cpu_map types.
--- tools/perf/util/python.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
tools/perf/util/python.c +12 -2
@@ -1107,11 +1107,21 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel, &pcpus, &pthreads, &group, &inherit))return NULL ; -if (pthreads !=NULL && pthreads != Py_None) +if (pthreads !=NULL && pthreads != Py_None) { +if (!PyObject_TypeCheck (pthreads, &pyrf_thread_map__type)) { +PyErr_SetString (PyExc_TypeError,"threads must be a thread_map" ); +return NULL ; + } threads = ((struct pyrf_thread_map *)pthreads)->threads; + } -if (pcpus !=NULL && pcpus != Py_None) +if (pcpus !=NULL && pcpus != Py_None) { +if (!PyObject_TypeCheck (pcpus, &pyrf_cpu_map__type)) { +PyErr_SetString (PyExc_TypeError,"cpus must be a cpu_map" ); +return NULL ; + } cpus = ((struct pyrf_cpu_map *)pcpus)->cpus; + } evsel->core.attr.inherit = inherit;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1298/1815 media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifei Gao <[email protected]>
[ Upstream commit fea97ee13c5332f67850733d6cefc1fe99460bde ]
isp4if_alloc_fw_gpumem() allocates several GPU memory pools in sequence. If one of them fails, it jumps to error_no_memory and returns -ENOMEM without releasing the pools that were already allocated, leaking them.
Release the already-allocated pools before returning. isp4if_gpu_mem_free() is a no-op on pools that were not allocated, so calling isp4if_dealloc_fw_gpumem() here safely frees exactly the pools that succeeded.
isp4if_gpu_mem_free() previously logged an error for a NULL entry, which is a normal case during partial-allocation cleanup, so make it silent.
--- drivers/media/platform/amd/isp4/isp4_interface.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/platform/amd/isp4/isp4_interface.c +2 -4
@@ -148,12 +148,9 @@ static void isp4if_gpu_mem_free(struct isp4_interface *ispif, struct isp4if_gpu_mem_info **mem_info_ptr) {struct isp4if_gpu_mem_info *mem_info = *mem_info_ptr; -struct device *dev = ispif->dev; -if (!mem_info) { -dev_err (dev,"invalid mem_info\n" ); +if (!mem_info)return ; - } *mem_info_ptr =NULL ; isp_kernel_buffer_free(&mem_info->mem_handle, &mem_info->gpu_mc_addr,
@@ -201,6 +198,7 @@ static int isp4if_alloc_fw_gpumem(struct isp4_interface *ispif) error_no_memory:dev_err (dev,"failed to allocate gpu memory\n" ); +isp4if_dealloc_fw_gpumem (ispif);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1299/1815 media: amd: isp4: fix self-deadlock in isp4sd_pwron_and_init() error path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifei Gao <[email protected]>
[ Upstream commit ef46d80a7015269a98c9505b5912a83798799199 ]
isp4sd_pwron_and_init() holds ops_mutex via guard(mutex) and, on any init failure, jumps to err_deinit and calls isp4sd_pwroff_and_deinit(). That helper takes the same ops_mutex, re-acquiring a non-recursive mutex already held by the current thread, so any init failure deadlocks.
Unwind the error path in stages instead, releasing only what each failure point acquired. This also avoids the issues that an unconditional teardown would hit at the earlier failures, such as a runtime-PM underflow from pm_runtime_resume_and_get() and MMIO access while the device is unpowered.
--- drivers/media/platform/amd/isp4/isp4_subdev.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/media/platform/amd/isp4/isp4_subdev.c +22 -6
@@ -687,7 +687,7 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd)if (ret) {dev_err (dev,"fail to power on isp_subdev ret %d\n" , ret); - goto err_deinit; + goto err_module_disable; }/* ISPPG ISP Power Status */
@@ -697,7 +697,7 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd)dev_err (dev,"fail to set performance state %u, ret %d\n" , perf_state, ret); - goto err_deinit; + goto err_power_off; } ispif->status =ISP4IF_STATUS_PWR_ON ;
@@ -709,12 +709,12 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd) ret =isp4if_start (ispif);if (ret) {dev_err (dev,"fail to start isp_subdev interface\n" ); - goto err_deinit; + goto err_perf_restore; }if (isp4sd_start_resp_proc_threads (isp_subdev)) {dev_err (dev,"isp_start_resp_proc_threads fail\n" ); - goto err_deinit; + goto err_stop_interface; }dev_dbg (dev,"create resp threads ok\n" );
@@ -724,8 +724,24 @@ int isp4sd_pwron_and_init(struct v4l2_subdev *sd) isp_subdev->irq_enabled = true;return 0 ; -err_deinit: -isp4sd_pwroff_and_deinit (sd); + +err_stop_interface: +isp4if_stop (ispif); +err_perf_restore: + ret =dev_pm_genpd_set_performance_state (dev,ISP4SD_PERFORMANCE_STATE_LOW ); +if (ret) +dev_err (dev,"fail to set performance state %u, ret %d\n" , +ISP4SD_PERFORMANCE_STATE_LOW , ret); +err_power_off: +isp4hw_wreg (isp_subdev->mmio,ISP_SOFT_RESET ,0 ); +isp4hw_wreg (isp_subdev->mmio,ISP_POWER_STATUS ,0 ); + ret =pm_runtime_put_sync (dev); +if (ret) +dev_err (dev,"power off isp_subdev fail %d\n" , ret); + ispif->status =ISP4IF_STATUS_PWR_OFF ; +err_module_disable: +isp4sd_module_enable (isp_subdev, false); +msleep (20 );return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1300/1815 m68k: Fix backtraces for non-running tasks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 09f71dbeb287e367beea56d9ac8a3d356ef5e02a ]
When no stack pointer is supplied, show_stack() starts at thread.esp0. This is the saved userspace register frame, not where a task was switched out. For kernel threads it points to the zeroed frame created by copy_thread(), so sched_show_task() prints no useful backtrace.
Use thread.ksp for non-current tasks. It is saved by switch_to() and is already used by __get_wchan(). For current, start at the current stack frame, as is already done when no task is supplied.
Tested on qemu-system-m68k -M virt using SysRq-t. All task dumps contained resolved frames.
--- arch/m68k/kernel/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/kernel/traps.c +2 -2
@@ -936,8 +936,8 @@ void show_stack(struct task_struct *task, unsigned long *stack,int i;if (!stack) { -if (task) - stack = (unsigned long *)task->thread.esp0; +if (task && task != current) + stack = (unsigned long *)task->thread.ksp;else stack = (unsigned long *)&stack; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1301/1815 netfilter: nft_ct: support expectation creation for natted flows
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit d4beefc90a66672e43fdf82b43e4b3c0b1b18c5e ]
This feature only works for connections originating from the host and only if there no source address rewrite.
Add the needed nat glue to have the expectation follow the original nat binding.
Stable-dep-of: 3679da4ad8be ("netfilter: nft_ct: move custom expectation support to helper")
--- net/netfilter/nft_ct.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
net/netfilter/nft_ct.c +35 -0
@@ -1297,6 +1297,17 @@ static int nft_ct_expect_obj_dump(struct sk_buff *skb,return 0 ; } +#if IS_ENABLED (CONFIG_NF_NAT ) +static void nft_ct_nat_follow_master (struct nf_conn *ct,struct nf_conntrack_expect *this) +{ +const struct nf_ct_helper_expectfn *expfn; + + expfn =nf_ct_helper_expectfn_find_by_name ("nat-follow-master" ); +if (expfn) + expfn->expectfn (ct, this); +} +#endif +static void nft_ct_expect_obj_eval (struct nft_object *obj,struct nft_regs *regs,const struct nft_pktinfo *pkt)
@@ -1342,6 +1353,13 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj, priv->l4proto, NULL, &priv->dport); exp->timeout += priv->timeout; +#if IS_ENABLED (CONFIG_NF_NAT ) +if (ct->status &IPS_NAT_MASK ) { + exp->saved_proto.tcp.port = priv->dport; + exp->dir = !dir; + exp->expectfn = nft_ct_nat_follow_master; + } +#endif if (nf_ct_expect_related (exp,0 ) !=0 ) regs->verdict.code =NF_DROP ;
@@ -1375,6 +1393,13 @@ static struct nft_object_type nft_ct_expect_obj_type __read_mostly = { .owner = THIS_MODULE, }; +#if IS_ENABLED (CONFIG_NF_NAT ) +static struct nf_ct_helper_expectfn nft_ct_nat__read_mostly = { + .name ="nft_ct-follow-master" , + .expectfn = nft_ct_nat_follow_master, +}; +#endif +static int __init nft_ct_module_init (void ) {int err;
@@ -1400,6 +1425,9 @@ static int __init nft_ct_module_init(void) err =nft_register_obj (&nft_ct_timeout_obj_type);if (err <0 ) goto err4; +#endif +#if IS_ENABLED (CONFIG_NF_NAT ) +nf_ct_helper_expectfn_register (&nft_ct_nat);#endif return 0 ;
@@ -1425,6 +1453,13 @@ static void __exit nft_ct_module_exit(void)nft_unregister_obj (&nft_ct_helper_obj_type);nft_unregister_expr (&nft_notrack_type);nft_unregister_expr (&nft_ct_type); + +#if IS_ENABLED (CONFIG_NF_NAT ) +nf_ct_helper_expectfn_unregister (&nft_ct_nat); +synchronize_rcu (); +nf_ct_helper_expectfn_destroy (&nft_ct_nat); +synchronize_rcu (); +#endif }module_init (nft_ct_module_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1302/1815 netfilter: nft_ct: move custom expectation support to helper
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 3679da4ad8be84cddaf40bc307fef1fe13e051ff ]
Originally, the ct expectation support called nf_ct_helper_ext_add() for confirmed conntracks, which is invalid, triggering a splat. This was fixed by commit 1710eb913bdc ("netfilter: nft_ct: skip expectations for confirmed conntrack") which restricted it to unconfirmed conntracks.
However, early insertion of expectations into the expectations list when the conntrack is unconfirmed leads to stale entries pointing to the wrong hlist_head through .pprev due to ct extension reallocation.
Commit 7c9664351980 ("netfilter: move nat hlist_head to nf_conn") moved the nat hlist_head to nf_conn for this reason:
1. ...
2. When reallocation of extension area occurs we need to fixup the bysource hash head via hlist_replace_rcu.
I'd rather not increase the size of the struct nf_conn for this feature has very limited scope: only one expectation can be created at a time given expect_clash() will make nf_ct_expect_related() reports EBUSY. For this reason, relax nf_ct_expect_related() not to drop packets in case expectation creation fails, therefore, expectation creation becomes best effort.
To address this issue, add an internal ct helper and attach it to the conntrack entry to streamline the custom ct expectation support with existing ct helpers.
Expose a new nf_conntrack_helper_release() function to release the internal helper that is allocated and attached to the conntrack entry to create the custom expectations. The nft_ct module removal always waits for rcu grace period, then the NULL helper callback is observed after this.
This patch also restricts the creation of expectations to different helpers other than this custom helper that is created for this type of expectations.
--- include/net/netfilter/nf_conntrack_helper.h | 1 + net/netfilter/nf_conntrack_helper.c | 14 +- net/netfilter/nft_ct.c | 167 +++++++++++++++----- 3 files changed, 135 insertions(+), 47 deletions(-)
include/net/netfilter/nf_conntrack_helper.h +1 -0
@@ -108,6 +108,7 @@ void nf_ct_helper_init(struct nf_conntrack_helper *helper,int nf_conntrack_helper_register (struct nf_conntrack_helper *,struct nf_conntrack_helper **);int __nf_conntrack_helper_register (struct nf_conntrack_helper *);void nf_conntrack_helper_unregister (struct nf_conntrack_helper *); +void nf_conntrack_helper_release (struct nf_conntrack_helper *);int nf_conntrack_helpers_register (struct nf_conntrack_helper *,unsigned int ,struct nf_conntrack_helper **);
net/netfilter/nf_conntrack_helper.c +10 -4
@@ -456,6 +456,15 @@ static bool expect_iter_me(struct nf_conntrack_expect *exp, void *data)return this == me; } +void nf_conntrack_helper_release (struct nf_conntrack_helper *me) +{ +nf_ct_expect_iterate_destroy (expect_iter_me, me); + +if (refcount_dec_and_test (&me->ct_refcnt)) +kfree_rcu (me, rcu); +} +EXPORT_SYMBOL_GPL (nf_conntrack_helper_release); +void nf_conntrack_helper_unregister (struct nf_conntrack_helper *me) {mutex_lock (&nf_ct_helper_mutex);
@@ -471,10 +480,7 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)*/ synchronize_rcu (); -nf_ct_expect_iterate_destroy (expect_iter_me, me); - -if (refcount_dec_and_test (&me->ct_refcnt)) -kfree_rcu (me, rcu); +nf_conntrack_helper_release (me); }EXPORT_SYMBOL_GPL (nf_conntrack_helper_unregister);
net/netfilter/nft_ct.c +124 -43
227 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1303/1815 NFSD: Release the export reference when reaping open stateids
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 6480bd703684ed3f760e9e36c4a699033c0806ae ]
nfs4_put_stid() releases the svc_export tracked in nfs4_stid.sc_export, but free_ol_stateid_reaplist() frees open and lock stateids by calling ->sc_free() directly, bypassing that path. An open stateid takes an sc_export reference in nfs4_open() and a lock stateid takes its own in init_lock_stateid(); both reach free_ol_stateid_reaplist() through their normal teardown, the open stateid via release_open_stateid() and the lock stateid via nfsd4_release_lockowner(), each through put_ol_stateid_locked(). The reference is therefore never dropped, pinning the export and blocking unmount for the lifetime of the stateid.
Release sc_export in free_ol_stateid_reaplist() the way nfs4_put_stid() does. ->sc_free() runs once per stateid, and a stateid reaches free_ol_stateid_reaplist() or nfs4_put_stid() but never both, so the reference is dropped exactly once. Revoked stateids reach this path with sc_export already cleared by drop_stid_export(), so they are skipped rather than double-freed.
nfs4_put_stid() itself read sc_export before acquiring cl_lock. drop_stid_export() clears that field and releases the reference under cl_lock, so a concurrent revocation could drop the export in the window between the read and the final put, releasing the same reference twice. Read sc_export while cl_lock is held so the two paths serialize and the reference is released exactly once.
--- fs/nfsd/nfs4state.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +7 -1
@@ -1276,9 +1276,9 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp,void nfs4_put_stid (struct nfs4_stid *s) { -struct svc_export *exp = s->sc_export;struct nfs4_file *fp = s->sc_file;struct nfs4_client *clp = s->sc_client; +struct svc_export *exp;might_lock (&clp->cl_lock);
@@ -1289,6 +1289,8 @@ nfs4_put_stid(struct nfs4_stid *s)idr_remove (&clp->cl_stateids, s->sc_stateid.si_opaque.so_id);if (s->sc_status &SC_STATUS_ADMIN_REVOKED )atomic_dec (&s->sc_client->cl_admin_revoked); +/* Read under cl_lock to serialize with drop_stid_export(). */ + exp = s->sc_export;nfs4_free_cpntf_statelist (clp->net, s);spin_unlock (&clp->cl_lock); s->sc_free (s);
@@ -1745,6 +1747,7 @@ static void free_ol_stateid_reaplist(struct list_head *reaplist) {struct nfs4_ol_stateid *stp; +struct svc_export *exp;struct nfs4_file *fp;might_sleep ();
@@ -1754,7 +1757,10 @@ free_ol_stateid_reaplist(struct list_head *reaplist) st_locks);list_del (&stp->st_locks); fp = stp->st_stid.sc_file; + exp = stp->st_stid.sc_export; stp->st_stid.sc_free (&stp->st_stid); +if (exp) +exp_put (exp);if (fp)put_nfs4_file (fp); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1304/1815 nfsd: add protocol support for CB_NOTIFY
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit a0ac2a63d4b21455985436fbc70192da14a163fd ]
Add the necessary bits to nfs4_1.x and remove the duplicate definitions from nfs4.h and the uapi nfs4 header. Regenerate the xdr files.
Note that regenerating these files caused conflicts with the definitions of NFS4_VERIFIER_SIZE and NFS4_FHSIZE in include/uapi/linux/nfs4.h. These constants are defined by the RFC, and are not part of the kernel API. They have been removed. Userspace consumers who require those constants should plan to get them from more authoritative sources.
The nfsstat4 enum defined in the .x is fed to the xdrgen-generated wire encoder and decoder, which treat every enumerated value as legal on the wire. Do not carry the NFS4ERR_FIRST_FREE sentinel (which is not a protocol error code) into the .x; keeping it would make 10097 a value that could leak onto the wire. Instead base nfsd's internal error codes (NFSERR_EOF and friends) at an impossible nfsstat4 value, as lockd does for its nlm__int__* status codes.
Stable-dep-of: ec5a7c2dceb0 ("xdrgen: Emit a blank line ahead of enum declarations")
--- Documentation/sunrpc/xdr/nfs4_1.x | 241 ++++++++++- fs/nfsd/nfs4xdr_gen.c | 589 ++++++++++++++++++++++++++- fs/nfsd/nfs4xdr_gen.h | 2 +- fs/nfsd/nfsd.h | 9 +- fs/nfsd/trace.h | 1 + include/linux/nfs4.h | 127 ------ include/linux/sunrpc/xdrgen/nfs4_1.h | 279 ++++++++++++- include/uapi/linux/nfs4.h | 2 - 8 files changed, 1105 insertions(+), 145 deletions(-)
Documentation/sunrpc/xdr/nfs4_1.x +239 -2
@@ -45,19 +45,162 @@ pragma header nfs4; /* * Basic typedefs for RFC 1832 data type definitions */ -typedef hyper int64_t; -typedef unsigned int uint32_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef hyper int64_t; +typedef unsigned hyper uint64_t; + +const NFS4_VERIFIER_SIZE = 8; +const NFS4_FHSIZE = 128; + +enum nfsstat4 { + NFS4_OK = 0, /* everything is okay */ + NFS4ERR_PERM = 1, /* caller not privileged */ + NFS4ERR_NOENT = 2, /* no such file/directory */ + NFS4ERR_IO = 5, /* hard I/O error */ + NFS4ERR_NXIO = 6, /* no such device */ + NFS4ERR_ACCESS = 13, /* access denied */ + NFS4ERR_EXIST = 17, /* file already exists */ + NFS4ERR_XDEV = 18, /* different filesystems */ + + /* + * Please do not allocate value 19; it was used in NFSv3 + * and we do not want a value in NFSv3 to have a different + * meaning in NFSv4.x. + */ + + NFS4ERR_NOTDIR = 20, /* should be a directory */ + NFS4ERR_ISDIR = 21, /* should not be directory */ + NFS4ERR_INVAL = 22, /* invalid argument */ + NFS4ERR_FBIG = 27, /* file exceeds server max */ + NFS4ERR_NOSPC = 28, /* no space on filesystem */ + NFS4ERR_ROFS = 30, /* read-only filesystem */ + NFS4ERR_MLINK = 31, /* too many hard links */ + NFS4ERR_NAMETOOLONG = 63, /* name exceeds server max */ + NFS4ERR_NOTEMPTY = 66, /* directory not empty */ + NFS4ERR_DQUOT = 69, /* hard quota limit reached*/ + NFS4ERR_STALE = 70, /* file no longer exists */ + NFS4ERR_BADHANDLE = 10001,/* Illegal filehandle */ + NFS4ERR_BAD_COOKIE = 10003,/* READDIR cookie is stale */ + NFS4ERR_NOTSUPP = 10004,/* operation not supported */ + NFS4ERR_TOOSMALL = 10005,/* response limit exceeded */ + NFS4ERR_SERVERFAULT = 10006,/* undefined server error */ + NFS4ERR_BADTYPE = 10007,/* type invalid for CREATE */ + NFS4ERR_DELAY = 10008,/* file "busy" - retry */ + NFS4ERR_SAME = 10009,/* nverify says attrs same */ + NFS4ERR_DENIED = 10010,/* lock unavailable */ + NFS4ERR_EXPIRED = 10011,/* lock lease expired */ + NFS4ERR_LOCKED = 10012,/* I/O failed due to lock */ + NFS4ERR_GRACE = 10013,/* in grace period */ + NFS4ERR_FHEXPIRED = 10014,/* filehandle expired */ + NFS4ERR_SHARE_DENIED = 10015,/* share reserve denied */ + NFS4ERR_WRONGSEC = 10016,/* wrong security flavor */ + NFS4ERR_CLID_INUSE = 10017,/* clientid in use */ + + /* NFS4ERR_RESOURCE is not a valid error in NFSv4.1 */ + NFS4ERR_RESOURCE = 10018,/* resource exhaustion */ + + NFS4ERR_MOVED = 10019,/* filesystem relocated */ + NFS4ERR_NOFILEHANDLE = 10020,/* current FH is not set */ + NFS4ERR_MINOR_VERS_MISMATCH= 10021,/* minor vers not supp */ + NFS4ERR_STALE_CLIENTID = 10022,/* server has rebooted */ + NFS4ERR_STALE_STATEID = 10023,/* server has rebooted */ + NFS4ERR_OLD_STATEID = 10024,/* state is out of sync */ + NFS4ERR_BAD_STATEID = 10025,/* incorrect stateid */ + NFS4ERR_BAD_SEQID = 10026,/* request is out of seq. */ + NFS4ERR_NOT_SAME = 10027,/* verify - attrs not same */ + NFS4ERR_LOCK_RANGE = 10028,/* overlapping lock range */ + NFS4ERR_SYMLINK = 10029,/* should be file/directory*/ + NFS4ERR_RESTOREFH = 10030,/* no saved filehandle */ + NFS4ERR_LEASE_MOVED = 10031,/* some filesystem moved */ + NFS4ERR_ATTRNOTSUPP = 10032,/* recommended attr not sup*/ + NFS4ERR_NO_GRACE = 10033,/* reclaim outside of grace*/ + NFS4ERR_RECLAIM_BAD = 10034,/* reclaim error at server */ + NFS4ERR_RECLAIM_CONFLICT= 10035,/* conflict on reclaim */ + NFS4ERR_BADXDR = 10036,/* XDR decode failed */ + NFS4ERR_LOCKS_HELD = 10037,/* file locks held at CLOSE*/ + NFS4ERR_OPENMODE = 10038,/* conflict in OPEN and I/O*/ + NFS4ERR_BADOWNER = 10039,/* owner translation bad */ + NFS4ERR_BADCHAR = 10040,/* utf-8 char not supported*/ + NFS4ERR_BADNAME = 10041,/* name not supported */ + NFS4ERR_BAD_RANGE = 10042,/* lock range not supported*/ + NFS4ERR_LOCK_NOTSUPP = 10043,/* no atomic up/downgrade */ + NFS4ERR_OP_ILLEGAL = 10044,/* undefined operation */ + NFS4ERR_DEADLOCK = 10045,/* file locking deadlock */ + NFS4ERR_FILE_OPEN = 10046,/* open file blocks op. */ + NFS4ERR_ADMIN_REVOKED = 10047,/* lockowner state revoked */ + NFS4ERR_CB_PATH_DOWN = 10048,/* callback path down */ + + /* NFSv4.1 errors start here. */ + + NFS4ERR_BADIOMODE = 10049, + NFS4ERR_BADLAYOUT = 10050, + NFS4ERR_BAD_SESSION_DIGEST = 10051, + NFS4ERR_BADSESSION = 10052, + NFS4ERR_BADSLOT = 10053, + NFS4ERR_COMPLETE_ALREADY = 10054, + NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055, + NFS4ERR_DELEG_ALREADY_WANTED = 10056, + NFS4ERR_BACK_CHAN_BUSY = 10057,/*backchan reqs outstanding*/ + NFS4ERR_LAYOUTTRYLATER = 10058, + NFS4ERR_LAYOUTUNAVAILABLE = 10059, + NFS4ERR_NOMATCHING_LAYOUT = 10060, + NFS4ERR_RECALLCONFLICT = 10061, + NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062, + NFS4ERR_SEQ_MISORDERED = 10063,/* unexpected seq.ID in req*/ + NFS4ERR_SEQUENCE_POS = 10064,/* [CB_]SEQ. op not 1st op */ + NFS4ERR_REQ_TOO_BIG = 10065,/* request too big */ + NFS4ERR_REP_TOO_BIG = 10066,/* reply too big */ + NFS4ERR_REP_TOO_BIG_TO_CACHE =10067,/* rep. not all cached*/ + NFS4ERR_RETRY_UNCACHED_REP =10068,/* retry & rep. uncached*/ + NFS4ERR_UNSAFE_COMPOUND =10069,/* retry/recovery too hard */ + NFS4ERR_TOO_MANY_OPS = 10070,/*too many ops in [CB_]COMP*/ + NFS4ERR_OP_NOT_IN_SESSION =10071,/* op needs [CB_]SEQ. op */ + NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp. */ + /* Error 10073 is unused. */ + NFS4ERR_CLIENTID_BUSY = 10074,/* clientid has state */ + NFS4ERR_PNFS_IO_HOLE = 10075,/* IO to _SPARSE file hole */ + NFS4ERR_SEQ_FALSE_RETRY= 10076,/* Retry != original req. */ + NFS4ERR_BAD_HIGH_SLOT = 10077,/* req has bad highest_slot*/ + NFS4ERR_DEADSESSION = 10078,/*new req sent to dead sess*/ + NFS4ERR_ENCR_ALG_UNSUPP= 10079,/* encr alg. not supp. */ + NFS4ERR_PNFS_NO_LAYOUT = 10080,/* I/O without a layout */ + NFS4ERR_NOT_ONLY_OP = 10081,/* addl ops not allowed */ + NFS4ERR_WRONG_CRED = 10082,/* op done by wrong cred */ + NFS4ERR_WRONG_TYPE = 10083,/* op on wrong type object */ + NFS4ERR_DIRDELEG_UNAVAIL=10084,/* delegation not avail. */ + NFS4ERR_REJECT_DELEG = 10085,/* cb rejected delegation */ + NFS4ERR_RETURNCONFLICT = 10086,/* layout get before return*/ + NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */ + NFS4ERR_PARTNER_NOTSUPP = 10088, + NFS4ERR_PARTNER_NO_AUTH = 10089, + NFS4ERR_UNION_NOTSUPP = 10090, + NFS4ERR_OFFLOAD_DENIED = 10091, + NFS4ERR_WRONG_LFS = 10092, + NFS4ERR_BADLABEL = 10093, + NFS4ERR_OFFLOAD_NO_REQS = 10094, + NFS4ERR_NOXATTR = 10095, + NFS4ERR_XATTR2BIG = 10096 +}; /* * Basic data types */ +typedef opaque attrlist4<>; typedef uint32_t bitmap4<>; +typedef opaque verifier4[NFS4_VERIFIER_SIZE]; +typedef uint64_t nfs_cookie4; +typedef opaque nfs_fh4<NFS4_FHSIZE>; typedef opaque utf8string<>; typedef utf8string utf8str_cis; typedef utf8string utf8str_cs; typedef utf8string utf8str_mixed; +typedef utf8str_cs component4; +typedef utf8str_cs linktext4; +typedef component4 pathname4<>; + /* * Timeval */
@@ -66,6 +209,21 @@ struct nfstime4 { uint32_t nseconds; }; +/* + * File attribute container + */ +struct fattr4 { + bitmap4 attrmask; + attrlist4 attr_vals; +}; + +/* + * Stateid + */ +struct stateid4 { + uint32_t seqid; + opaque other[12]; +}; /* * The following content was extracted from draft-ietf-nfsv4-delstid
@@ -245,3 +403,82 @@ const FATTR4_ACL_TRUEFORM = 89; const FATTR4_ACL_TRUEFORM_SCOPE = 90; const FATTR4_POSIX_DEFAULT_ACL = 91; const FATTR4_POSIX_ACCESS_ACL = 92; + +/* + * Directory notification types. + */ +enum notify_type4 { + NOTIFY4_CHANGE_CHILD_ATTRS = 0, + NOTIFY4_CHANGE_DIR_ATTRS = 1, + NOTIFY4_REMOVE_ENTRY = 2, + NOTIFY4_ADD_ENTRY = 3, + NOTIFY4_RENAME_ENTRY = 4, + NOTIFY4_CHANGE_COOKIE_VERIFIER = 5 +}; + +/* Changed entry information. */ +struct notify_entry4 { + component4 ne_file; + fattr4 ne_attrs; +}; + +/* Previous entry information */ +struct prev_entry4 { + notify_entry4 pe_prev_entry; + /* what READDIR returned for this entry */ + nfs_cookie4 pe_prev_entry_cookie; +}; + +struct notify_remove4 { + notify_entry4 nrm_old_entry; + nfs_cookie4 nrm_old_entry_cookie; +}; + +struct notify_add4 { + /* + * Information on object + * possibly renamed over. + */ + notify_remove4 nad_old_entry<1>; + notify_entry4 nad_new_entry; + /* what READDIR would have returned for this entry */ + nfs_cookie4 nad_new_entry_cookie<1>; + prev_entry4 nad_prev_entry<1>; + bool nad_last_entry; +}; + +struct notify_attr4 { + notify_entry4 na_changed_entry; +}; + +struct notify_rename4 { + notify_remove4 nrn_old_entry; + notify_add4 nrn_new_entry; +}; + +struct notify_verifier4 { + verifier4 nv_old_cookieverf; + verifier4 nv_new_cookieverf; +}; + +/* + * Objects of type notify_<>4 and + * notify_device_<>4 are encoded in this. + */ +typedef opaque notifylist4<>; + +struct notify4 { + /* composed from notify_type4 or notify_deviceid_type4 */ + bitmap4 notify_mask; + notifylist4 notify_vals; +}; + +struct CB_NOTIFY4args { + stateid4 cna_stateid; + nfs_fh4 cna_fh; + notify4 cna_changes<>; +}; + +struct CB_NOTIFY4res { + nfsstat4 cnr_status; +};
fs/nfsd/nfs4xdr_gen.c +584 -5
660 lines not on this page · raw message
fs/nfsd/nfs4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Thu Jan 8 23:12:07 2026 */ +/* XDR specification modification time: Wed Mar 25 11:40:02 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H#define _LINUX_XDRGEN_NFS4_1_DECL_H
fs/nfsd/nfsd.h +5 -4
@@ -332,13 +332,14 @@ void nfsd_lockd_shutdown(void);#define nfserr_noxattr cpu_to_be32(NFS4ERR_NOXATTR)/* -* Error codes for internal use. We use enum to choose numbers that are -* not already assigned, then covert to be32 resulting in a number that -* cannot conflict with any existing be32 nfserr value. +* Error codes for internal use. These are based at an impossible +* nfsstat4 value so that, once converted to be32, they cannot conflict +* with any value defined by the protocol (compare the nlm__int__* codes +* in fs/lockd/lockd.h). */ enum {/* end-of-file indicator in readdir */ -NFSERR_EOF =NFS4ERR_FIRST_FREE , +NFSERR_EOF =30000 ,#define nfserr_eof cpu_to_be32(NFSERR_EOF)/* replay detected */
fs/nfsd/trace.h +1 -0
@@ -1677,6 +1677,7 @@ TRACE_EVENT(nfsd_cb_setup_err, { OP_CB_RECALL, "CB_RECALL" }, \ { OP_CB_LAYOUTRECALL, "CB_LAYOUTRECALL" }, \ { OP_CB_RECALL_ANY, "CB_RECALL_ANY" }, \ + { OP_CB_NOTIFY, "CB_NOTIFY" }, \ { OP_CB_NOTIFY_LOCK, "CB_NOTIFY_LOCK" }, \ { OP_CB_OFFLOAD, "CB_OFFLOAD" })
include/linux/nfs4.h +0 -127
133 lines not on this page · raw message
include/linux/sunrpc/xdrgen/nfs4_1.h +275 -4
332 lines not on this page · raw message
include/uapi/linux/nfs4.h +0 -2
@@ -17,11 +17,9 @@#include <linux/types.h> #define NFS4_BITMAP_SIZE 3 -#define NFS4_VERIFIER_SIZE 8#define NFS4_STATEID_SEQID_SIZE 4#define NFS4_STATEID_OTHER_SIZE 12#define NFS4_STATEID_SIZE (NFS4_STATEID_SEQID_SIZE + NFS4_STATEID_OTHER_SIZE) -#define NFS4_FHSIZE 128#define NFS4_MAXPATHLEN PATH_MAX#define NFS4_MAXNAMLEN NAME_MAX#define NFS4_OPAQUE_LIMIT 1024
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1305/1815 lockd: Regenerate NLMv4 XDR code
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit e1d6e968ee26eee9654e35cd8141e38cefe307a4 ]
The checked-in NLMv4 xdrgen output predates the addition of enum value validation to generated decoders. As a result the decoders for fsh4_mode, fsh4_access, and nlm4_stats still accept any 32-bit value, while the current generator rejects values outside the enumeration. Resync the generated files with the in-tree xdrgen by regenerating from the unchanged nlm4.x specification.
This is a plain regeneration with no specification change; it also refreshes the recorded specification modification time to show that all existing enum decoders have picked up the xdrgen tool fix.
Stable-dep-of: ec5a7c2dceb0 ("xdrgen: Emit a blank line ahead of enum declarations")
--- fs/lockd/nlm3xdr_gen.c | 2 +- fs/lockd/nlm3xdr_gen.h | 2 +- fs/lockd/nlm4xdr_gen.c | 47 ++++++++++++++++++++++++++-- fs/lockd/nlm4xdr_gen.h | 2 +- fs/nfsd/nfs4xdr_gen.c | 2 +- fs/nfsd/nfs4xdr_gen.h | 2 +- include/linux/sunrpc/xdrgen/nfs4_1.h | 2 +- include/linux/sunrpc/xdrgen/nlm3.h | 2 +- include/linux/sunrpc/xdrgen/nlm4.h | 2 +- 9 files changed, 53 insertions(+), 10 deletions(-)
fs/lockd/nlm3xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x -// XDR specification modification time: Thu Apr 23 10:56:34 2026 +// XDR specification modification time: Mon Jun 29 20:39:34 2026 #include <linux/sunrpc/svc.h>
fs/lockd/nlm3xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Thu Apr 23 10:56:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DECL_H#define _LINUX_XDRGEN_NLM3_DECL_H
fs/lockd/nlm4xdr_gen.c +45 -2
71 lines not on this page · raw message
fs/lockd/nlm4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Thu Dec 25 13:10:19 2025 */ +/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DECL_H#define _LINUX_XDRGEN_NLM4_DECL_H
fs/nfsd/nfs4xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x -// XDR specification modification time: Wed Mar 25 11:40:02 2026 +// XDR specification modification time: Tue Jun 30 11:56:05 2026 #include <linux/sunrpc/svc.h>
fs/nfsd/nfs4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Wed Mar 25 11:40:02 2026 */ +/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H#define _LINUX_XDRGEN_NFS4_1_DECL_H
include/linux/sunrpc/xdrgen/nfs4_1.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Wed Mar 25 11:40:02 2026 */ +/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DEF_H#define _LINUX_XDRGEN_NFS4_1_DEF_H
include/linux/sunrpc/xdrgen/nlm3.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Thu Apr 23 10:56:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DEF_H#define _LINUX_XDRGEN_NLM3_DEF_H
include/linux/sunrpc/xdrgen/nlm4.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Thu Dec 25 13:10:19 2025 */ +/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DEF_H#define _LINUX_XDRGEN_NLM4_DEF_H
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1306/1815 xdrgen: Emit a blank line ahead of enum declarations
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit ec5a7c2dceb09caf36262ecbd633eb7d4f9e4d3d ]
Clean up.
The declaration templates for structs, pointers, and typedefs each begin with a blank line, which keeps successive declarations and the include block above them visually separated. The enum declaration template omits that blank line. trim_blocks collapses the template's lone comment line to nothing, so the omission stayed invisible as long as every generated header happened to lead with a non-enum declaration.
--- fs/lockd/nlm3xdr_gen.c | 2 +- fs/lockd/nlm3xdr_gen.h | 2 +- fs/lockd/nlm4xdr_gen.c | 2 +- fs/lockd/nlm4xdr_gen.h | 2 +- fs/nfsd/nfs4xdr_gen.c | 2 +- fs/nfsd/nfs4xdr_gen.h | 5 ++++- include/linux/sunrpc/xdrgen/nfs4_1.h | 2 +- include/linux/sunrpc/xdrgen/nlm3.h | 2 +- include/linux/sunrpc/xdrgen/nlm4.h | 2 +- tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enum.j2 | 1 + 10 files changed, 13 insertions(+), 9 deletions(-)
fs/lockd/nlm3xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x -// XDR specification modification time: Mon Jun 29 20:39:34 2026 +// XDR specification modification time: Mon Jun 29 20:42:29 2026 #include <linux/sunrpc/svc.h>
fs/lockd/nlm3xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DECL_H#define _LINUX_XDRGEN_NLM3_DECL_H
fs/lockd/nlm4xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x -// XDR specification modification time: Mon Jun 29 20:39:36 2026 +// XDR specification modification time: Mon Jun 29 20:42:29 2026 #include <linux/sunrpc/svc.h>
fs/lockd/nlm4xdr_gen.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DECL_H#define _LINUX_XDRGEN_NLM4_DECL_H
fs/nfsd/nfs4xdr_gen.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x -// XDR specification modification time: Tue Jun 30 11:56:05 2026 +// XDR specification modification time: Tue Jun 30 11:57:21 2026 #include <linux/sunrpc/svc.h>
fs/nfsd/nfs4xdr_gen.h +4 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ +/* XDR specification modification time: Tue Jun 30 11:57:21 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H#define _LINUX_XDRGEN_NFS4_1_DECL_H
@@ -21,10 +21,13 @@ bool xdrgen_encode_fattr4_time_deleg_access(struct xdr_stream *xdr, const fattr4bool xdrgen_decode_fattr4_time_deleg_modify (struct xdr_stream *xdr,fattr4_time_deleg_modify *ptr);bool xdrgen_encode_fattr4_time_deleg_modify (struct xdr_stream *xdr,const fattr4_time_deleg_modify *value); +bool xdrgen_decode_aclmodel4 (struct xdr_stream *xdr,aclmodel4 *ptr);bool xdrgen_encode_aclmodel4 (struct xdr_stream *xdr,aclmodel4 value); +bool xdrgen_decode_aclscope4 (struct xdr_stream *xdr,aclscope4 *ptr);bool xdrgen_encode_aclscope4 (struct xdr_stream *xdr,aclscope4 value); +bool xdrgen_decode_posixacetag4 (struct xdr_stream *xdr,posixacetag4 *ptr);bool xdrgen_encode_posixacetag4 (struct xdr_stream *xdr,posixacetag4 value);
include/linux/sunrpc/xdrgen/nfs4_1.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Tue Jun 30 11:56:05 2026 */ +/* XDR specification modification time: Tue Jun 30 11:57:21 2026 */ #ifndef _LINUX_XDRGEN_NFS4_1_DEF_H#define _LINUX_XDRGEN_NFS4_1_DEF_H
include/linux/sunrpc/xdrgen/nlm3.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm3.x */ -/* XDR specification modification time: Mon Jun 29 20:39:34 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM3_DEF_H#define _LINUX_XDRGEN_NLM3_DEF_H
include/linux/sunrpc/xdrgen/nlm4.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ -/* XDR specification modification time: Mon Jun 29 20:39:36 2026 */ +/* XDR specification modification time: Mon Jun 29 20:42:29 2026 */ #ifndef _LINUX_XDRGEN_NLM4_DEF_H#define _LINUX_XDRGEN_NLM4_DEF_H
tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enum.j2 +1 -0
@@ -1,3 +1,4 @@ {# SPDX-License-Identifier: GPL-2.0 #} + bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ name }} *ptr); bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, {{ name }} value);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1307/1815 xdrgen: Do not declare union XDR functions in the definitions header
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit d4ca0b0a6c62bc12407060754df11b23a90f3e57 ]
Unlike the struct, enum, typedef, and pointer templates, the union definitions template also emits xdrgen_decode_*() and xdrgen_encode_*() prototypes for a public union into that header. Those prototypes name struct xdr_stream, which the definitions header neither includes nor forward-declares, so any translation unit that includes the definitions header without xdr.h already in scope draws -Wvisibility warnings. The same public prototypes are emitted into the declarations header, which does include <linux/sunrpc/xdr.h>, making the definitions-header copies redundant.
Drop the prototype emission from the union definitions template so it matches the other type templates. Public unions keep their encode and decode prototypes through the declarations header.
--- .../net/sunrpc/xdrgen/templates/C/union/definition/close.j2 | 6 ------ 1 file changed, 6 deletions(-)
tools/net/sunrpc/xdrgen/templates/C/union/definition/close.j2 +0 -6
@@ -1,9 +1,3 @@ {# SPDX-License-Identifier: GPL-2.0 #} } u; }; -{%- if name in public_apis %} - - -bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr); -bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *ptr); -{%- endif -%}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1281/1815 perf python: Validate attribute setters in pyrf_evsel
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 0b274050c4d427828595c12c2e4e53d98612b4f9 ]
If val is NULL when setting an attribute, PyErr_SetString should be called as deleting the attribute isn't supported. In addition, ensure PyErr_Occurred is checked before setting the attribute to avoid setting a garbage value.
--- tools/perf/util/python.c | 89 ++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 12 deletions(-)
tools/perf/util/python.c +77 -12
@@ -1295,6 +1295,11 @@ static int pyrf_evsel__set_tracking(PyObject *self, PyObject *val, void *closureCHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + is_true =PyObject_IsTrue (val);if (is_true <0 )return -1 ;
@@ -1306,11 +1311,21 @@ static int pyrf_evsel__set_tracking(PyObject *self, PyObject *val, void *closurestatic int pyrf_evsel__set_attr_config (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.config =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.config = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_config (PyObject *self,void *closure__maybe_unused )
@@ -1325,11 +1340,21 @@ static PyObject *pyrf_evsel__get_attr_config(PyObject *self, void *closure __maystatic int pyrf_evsel__set_attr_read_format (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.read_format =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.read_format = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_read_format (PyObject *self,void *closure__maybe_unused )
@@ -1344,11 +1369,21 @@ static PyObject *pyrf_evsel__get_attr_read_format(PyObject *self, void *closurestatic int pyrf_evsel__set_attr_sample_period (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.sample_period =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.sample_period = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_sample_period (PyObject *self,void *closure__maybe_unused )
@@ -1363,11 +1398,21 @@ static PyObject *pyrf_evsel__get_attr_sample_period(PyObject *self, void *closurstatic int pyrf_evsel__set_attr_sample_type (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.sample_type =PyLong_AsUnsignedLongLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLongLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.sample_type = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_sample_type (PyObject *self,void *closure__maybe_unused )
@@ -1391,11 +1436,21 @@ static PyObject *pyrf_evsel__get_attr_size(PyObject *self, void *closure __maybestatic int pyrf_evsel__set_attr_type (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.type =PyLong_AsUnsignedLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.type = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_type (PyObject *self,void *closure__maybe_unused )
@@ -1410,11 +1465,21 @@ static PyObject *pyrf_evsel__get_attr_type(PyObject *self, void *closure __maybestatic int pyrf_evsel__set_attr_wakeup_events (PyObject *self,PyObject *val,void *closure__maybe_unused ) {struct pyrf_evsel *pevsel = (void *)self; +unsigned long new_val;CHECK_INITIALIZED_INT (pevsel->evsel,"evsel" ); - pevsel->evsel->core.attr.wakeup_events =PyLong_AsUnsignedLong (val); -return PyErr_Occurred () ?-1 :0 ; +if (val ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } + + new_val =PyLong_AsUnsignedLong (val); +if (PyErr_Occurred ()) +return -1 ; + + pevsel->evsel->core.attr.wakeup_events = new_val; +return 0 ; }static PyObject *pyrf_evsel__get_attr_wakeup_events (PyObject *self,void *closure__maybe_unused )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1308/1815 xdrgen: Add XDR width macros for short integer types
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit c488328375beb4e3a3ca0526919c81767ce1de95 ]
Commit ae78eb497868 ("xdrgen: Implement short (16-bit) integer types") taught the generator to emit XDR_short and XDR_unsigned_short in the computed maxsize macros and added the matching encode and decode primitives to _builtins.h, but it left the two width macros themselves undefined in _defs.h.
Define XDR_short and XDR_unsigned_short, each one XDR unit wide, to match the width the generator's maxsize table assigns them.
--- include/linux/sunrpc/xdrgen/_defs.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/sunrpc/xdrgen/_defs.h +2 -0
@@ -25,6 +25,8 @@ typedef struct {#define XDR_void (0)#define XDR_bool (1) +#define XDR_short (1) +#define XDR_unsigned_short (1)#define XDR_int (1)#define XDR_unsigned_int (1)#define XDR_long (1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1309/1815 xdrgen: Fix opaque and string encoders for unbounded members
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit daa52e37851a5a1b5890e7a250a27e94a8b9f273 ]
The variable-length opaque and string encoder templates emit an unconditional bound check, "if (value->NAME.len > MAXSIZE) return false". XDR represents an unbounded specifier (opaque foo<>, string foo<>) as a maxsize of 0, so for an unbounded member the check degenerates to "len > 0" and the generated encoder refuses every non-empty value.
The decoder does not share this defect. It delegates to xdrgen_decode_opaque() and xdrgen_decode_string(), which treat a maxlen of 0 as unbounded and skip the length check. The sibling variable-length array templates already guard their bound check with maxsize != "0".
Guard the bound check the same way in each affected template -- the struct and pointer forms of both the opaque and string encoders -- so an unbounded member encodes a payload of any length while a bounded member keeps its limit.
An explicit zero-length bound (foo<0>) parses to the same maxsize of 0 and so also skips the check; xdrgen does not distinguish it from the unbounded form, matching the decoder and the array encoders.
--- tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/string.j2 | 2 ++ .../templates/C/pointer/encoder/variable_length_opaque.j2 | 2 ++ tools/net/sunrpc/xdrgen/templates/C/struct/encoder/string.j2 | 2 ++ .../xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 | 2 ++ 4 files changed, 8 insertions(+)
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/string.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length string) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_opaque.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length opaque) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/string.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length string) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length opaque) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1310/1815 arm64: Disable KCSAN instrumentation in delay.o
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Elver <[email protected]>
[ Upstream commit 5eaec4cf41a8f5ac1a0c69a607cdc5035a797f73 ]
KCSAN relies on udelay() for injecting delays. To avoid recursively triggering a watchpoint, where KCSAN sets up watchpoint on an address that is accessed by udelay() in the same thread, disable instrumentation in arm64's delay implementation.
Paul found a manifestation of this as follows:
| BUG: KCSAN: data-race in __delay / set_need_resched_current | | read (marked) to 0xffff000005899b48 of 8 bytes by interrupt on cpu 8: | __delay+0xb0/0x378 | __udelay+0x4c/0x60 | kcsan_setup_watchpoint+0x3b4/0x820 | __tsan_unaligned_write4+0x228/0x26c | set_need_resched_current+0x138/0x1a8 | rcu_exp_handler+0x418/0x4a0 | __flush_smp_call_function_queue+0x36c/0x4a0 | generic_smp_call_function_single_interrupt+0x20/0x30 | ipi_handler+0xec/0x558 | handle_percpu_devid_irq+0x220/0x2a0 | generic_handle_domain_irq+0x84/0xb4 | gic_handle_irq+0x64/0x144 | call_on_irq_stack+0x30/0x48 | do_interrupt_handler+0x80/0xb8 | el1_interrupt+0x3c/0x60 | el1h_64_irq_handler+0x18/0x24 | el1h_64_irq+0x6c/0x70 | smp_call_function_single+0x18c/0x25c | sync_rcu_exp_select_node_cpus+0x534/0x8bc | rcu_exp_sel_wait_wake+0x358/0xef4 | wait_rcu_exp_gp+0x30/0x44 | kthread_worker_fn+0x1b4/0x5dc | kthread+0x1d8/0x204 | ret_from_fork+0x10/0x20 | | write to 0xffff000005899b4c of 4 bytes by interrupt on cpu 8: | set_need_resched_current+0x138/0x1a8 | [...]
This matches what is already done in arch/x86/lib/Makefile.
--- arch/arm64/lib/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/lib/Makefile +4 -0
@@ -1,4 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 + +# KCSAN uses udelay for introducing watchpoint delay; avoid recursion. +KCSAN_SANITIZE_delay.o := n + lib-y := clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_page.o \ clear_page.o csum.o insn.o memchr.o memcpy.o \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1311/1815 hwmon: (cros_ec) Register the thermal devices after the hwmon ones
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 9f1012119f2a4cb5a7f589dc77d5e15dbab49d00 ]
To guarantee consistency for the read-modify-write access in cros_ec_hwmon_cooling_set_cur_state(), locking is necessary. The locking will use standard hwmon device locks, which requires the hwmon device to be ready before the fan devices are set up.
Reorder the initialization so this works.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- drivers/hwmon/cros_ec_hwmon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hwmon/cros_ec_hwmon.c +6 -2
@@ -570,13 +570,17 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev) priv->fan_control_supported =cros_ec_hwmon_probe_fan_control_supported (priv->cros_ec); priv->temp_threshold_supported =is_cros_ec_cmd_available (priv->cros_ec,EC_CMD_THERMAL_GET_THRESHOLD ,1 ); -cros_ec_hwmon_register_fan_cooling_devices (dev, priv); hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, &cros_ec_hwmon_chip_info,NULL ); +if (IS_ERR (hwmon_dev)) +return PTR_ERR (hwmon_dev); + +cros_ec_hwmon_register_fan_cooling_devices (dev, priv); +platform_set_drvdata (pdev, priv); -return PTR_ERR_OR_ZERO (hwmon_dev); +return 0 ; }static int cros_ec_hwmon_suspend (struct platform_device *pdev,pm_message_t state)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1312/1815 hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 434baf3aea987ae61d0d54b6cdf8fccf78383b4e ]
The upcoming locking scheme for thermal devices will require access to the hwmon device.
Add it do the priv struct.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- drivers/hwmon/cros_ec_hwmon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/cros_ec_hwmon.c +5 -5
@@ -24,6 +24,7 @@struct cros_ec_hwmon_priv {struct cros_ec_device *cros_ec; +struct device *hwmon_dev;const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES +EC_TEMP_SENSOR_B_ENTRIES ];u8 usable_fans;bool fan_control_supported;
@@ -547,7 +548,6 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)struct cros_ec_dev *ec_dev =dev_get_drvdata (dev->parent);struct cros_ec_device *cros_ec = ec_dev->ec_dev;struct cros_ec_hwmon_priv *priv; -struct device *hwmon_dev;u8 thermal_version;int ret;
@@ -571,10 +571,10 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev) priv->temp_threshold_supported =is_cros_ec_cmd_available (priv->cros_ec,EC_CMD_THERMAL_GET_THRESHOLD ,1 ); - hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, - &cros_ec_hwmon_chip_info,NULL ); -if (IS_ERR (hwmon_dev)) -return PTR_ERR (hwmon_dev); + priv->hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, + &cros_ec_hwmon_chip_info,NULL ); +if (IS_ERR (priv->hwmon_dev)) +return PTR_ERR (priv->hwmon_dev);cros_ec_hwmon_register_fan_cooling_devices (dev, priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1313/1815 hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 26db273640887276a24ca2546b06e334508871f8 ]
To guarantee consistency for the read-modify-write access in cros_ec_hwmon_cooling_set_cur_state(), locking is necessary.
Use the existing hwmon device lock to do so.
--- drivers/hwmon/cros_ec_hwmon.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwmon/cros_ec_hwmon.c +5 -0
@@ -5,6 +5,7 @@* Copyright (C) 2024 Thomas Weißschuh <[email protected]> */ +#include <linux/cleanup.h> #include <linux/device.h> #include <linux/hwmon.h> #include <linux/math.h>
@@ -402,6 +403,8 @@ static int cros_ec_hwmon_cooling_get_cur_state(struct thermal_cooling_device *cdu8 read_val;int ret; +guard (hwmon_lock)(priv->hwmon_priv->hwmon_dev); + ret =cros_ec_hwmon_read_pwm_value (priv->hwmon_priv->cros_ec, priv->index, &read_val);if (ret)return ret;
@@ -415,6 +418,8 @@ static int cros_ec_hwmon_cooling_set_cur_state(struct thermal_cooling_device *cd {const struct cros_ec_hwmon_cooling_priv *priv = cdev->devdata; +guard (hwmon_lock)(priv->hwmon_priv->hwmon_dev); +return cros_ec_hwmon_write_pwm_input (priv->hwmon_priv->cros_ec, priv->index, val); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1314/1815 hwmon: (pmbus/ltc4283) Add missing MODULE_DEVICE_TABLE for OF match table
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: surendra <[email protected]>
[ Upstream commit bd300460cee457c50a16a42654d6de4c85562785 ]
The driver registers ltc4283_of_match as the platform driver's .of_match_table so the kernel probes the device when a DT node with compatible "adi,ltc4283" is present, but the corresponding MODULE_DEVICE_TABLE(of, ...) call is absent.
Without it the module alias table (modules.alias) does not contain an "of:N*T*Cadi,ltc4283" entry, so udev / kmod cannot auto-load the module when the DT node appears, breaking modules-based deployments while built-in configurations happen to work by accident.
Add the missing MODULE_DEVICE_TABLE() to fix module auto-loading.
--- drivers/hwmon/ltc4283.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/ltc4283.c +1 -0
@@ -1772,6 +1772,7 @@ static const struct of_device_id ltc4283_of_match[] = { { .compatible = "adi,ltc4283" }, { } }; +MODULE_DEVICE_TABLE (of, ltc4283_of_match);static const struct i2c_device_id ltc4283_i2c_id[] = { {"ltc4283" },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1315/1815 SUNRPC: check rpc_sockaddr2uaddr() return value in rpcb_register_inet4/6
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit fd22370226a0d8109045d0831fd5aaadee921693 ]
rpcb_register_inet4() and rpcb_register_inet6() store the result of rpc_sockaddr2uaddr() into map->r_addr without checking it for NULL. rpc_sockaddr2uaddr() returns NULL when its final kstrdup() fails, and the unchecked NULL is then carried into the synchronous RPCBPROC_SET encode path: rpcb_register_call() -> rpc_call_sync() -> rpcb_enc_getaddr() -> encode_rpcb_string(), whose first statement is strlen(string), dereferencing NULL and oopsing the kernel.
The crash reproduces under failslab on v6.12; with KASAN the NULL dereference surfaces as a fault on the shadow of address zero:
Oops: general protection fault, probably for non-canonical address
0xdffffc0000000000 [#1] PREEMPT SMP KASAN
RIP: 0010:strlen (lib/string.c:409)
Call Trace:
encode_rpcb_string (net/sunrpc/rpcb_clnt.c:890)
rpcb_enc_getaddr (net/sunrpc/rpcb_clnt.c:910)
rpcauth_wrap_req_encode (net/sunrpc/auth.c:745)
call_encode (net/sunrpc/clnt.c:1966)
__rpc_execute (net/sunrpc/sched.c:952)
rpc_run_task (net/sunrpc/clnt.c:1243)
rpc_call_sync (net/sunrpc/clnt.c:1272)
rpcb_v4_register (net/sunrpc/rpcb_clnt.c:500)
svc_generic_rpcbind_set
nfsd_rpcbind_set
svc_register
svc_setup_socket
svc_addsock
write_ports
nfsctl_transaction_write
vfs_writeThe crash is reachable when an in-kernel RPC service (nfsd, lockd, nfs-callback) registers with the local rpcbind under enough memory pressure for the small GFP_KERNEL kstrdup() in rpc_sockaddr2uaddr() to fail. The asynchronous getport path already handles this exact failure mode by returning -ENOMEM; only the two register helpers omit the check.
Mirror that handling: bail out with -ENOMEM when rpc_sockaddr2uaddr() returns NULL, before the address is fed into the encoder.
--- net/sunrpc/rpcb_clnt.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sunrpc/rpcb_clnt.c +4 -0
@@ -490,6 +490,8 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
@@ -516,6 +518,8 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1316/1815 sunrpc: xprtsock: annotate shared socket callbacks with READ_ONCE/WRITE_ONCE
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 33930840b5f0a79f826e7c69dc6cd78f72a67481 ]
xprtsock replaces and restores sk->sk_data_ready and sk->sk_write_space on live sockets with plain stores, and xs_udp_do_set_buffer_size() invokes sk->sk_write_space via a plain load. These callback pointers are shared with generic socket and protocol paths that may read or invoke them concurrently, so xprtsock needs the same READ_ONCE()/WRITE_ONCE() callback visibility contract that the validated 4022 family applied elsewhere.
When SUNRPC takes over an AF_LOCAL, UDP, or TCP socket and later restores the lower-socket callbacks during teardown, another CPU may still hold an earlier callback snapshot. The plain replace/restore pattern leaves the same visibility hole as the validated 4022 family, so a stale snapshot can still invoke xs_data_ready() or xs_udp_write_space() after the live callback fields have already been restored to the lower-socket handlers.
Use WRITE_ONCE() for the shared sk_data_ready and sk_write_space stores in xs_local_finish_connecting(), xs_udp_finish_connecting(), xs_tcp_finish_connecting(), and xs_restore_old_callbacks(). Use READ_ONCE() for the direct sk_write_space invocation in xs_udp_do_set_buffer_size(). This matches the required callback visibility contract while leaving adjacent sk_state_change and sk_error_report handling unchanged.
--- net/sunrpc/xprtsock.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
net/sunrpc/xprtsock.c +11 -9
@@ -1202,9 +1202,9 @@ static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk)static void xs_restore_old_callbacks (struct sock_xprt *transport,struct sock *sk) { - sk->sk_data_ready = transport->old_data_ready; +WRITE_ONCE (sk->sk_data_ready, transport->old_data_ready); sk->sk_state_change = transport->old_state_change; - sk->sk_write_space = transport->old_write_space; +WRITE_ONCE (sk->sk_write_space, transport->old_write_space); sk->sk_error_report = transport->old_error_report; }
@@ -1664,6 +1664,7 @@ static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt) { struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);struct sock *sk = transport->inet; +void (*write_space)(struct sock *sock);if (transport->rcvsize) { sk->sk_userlocks |=SOCK_RCVBUF_LOCK ;
@@ -1672,7 +1673,8 @@ static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)if (transport->sndsize) { sk->sk_userlocks |=SOCK_SNDBUF_LOCK ; sk->sk_sndbuf = transport->sndsize * xprt->max_reqs *2 ; - sk->sk_write_space (sk); + write_space =READ_ONCE (sk->sk_write_space); +write_space (sk); } }
@@ -1988,8 +1990,8 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; - sk->sk_write_space = xs_udp_write_space; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); +WRITE_ONCE (sk->sk_write_space, xs_udp_write_space); sk->sk_state_change = xs_local_state_change; sk->sk_error_report = xs_error_report; sk->sk_use_task_frag = false;
@@ -2191,8 +2193,8 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; - sk->sk_write_space = xs_udp_write_space; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); +WRITE_ONCE (sk->sk_write_space, xs_udp_write_space); sk->sk_use_task_frag = false;xprt_set_connected (xprt);
@@ -2378,9 +2380,9 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); sk->sk_state_change = xs_tcp_state_change; - sk->sk_write_space = xs_tcp_write_space; +WRITE_ONCE (sk->sk_write_space, xs_tcp_write_space); sk->sk_error_report = xs_error_report; sk->sk_use_task_frag = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1317/1815 NFS: Return a delegation the client fails to record
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 220af23d863995091f0edeb1e6aa0945b3db8b37 ]
When an NFS server grants a delegation in an OPEN reply, nfs_inode_set_delegation() records it on the client. However, three of its error flows return without sending DELEGRETURN.
A delegation can be relinquished only by DELEGRETURN (RFC 8881 Section 20.2.4), so dropping one silently leaves the server believing the client still holds it. If the server happens to recall that delegation, the client answers CB_RECALL with NFS4ERR_BADHANDLE because it has no record of the stateid. The server revokes the delegation and moves it onto its cl_revoked list, because the client never sends the FREE_STATEID that would drain it. Every subsequent SEQUENCE reply then carries SEQ4_STATUS_RECALLABLE_STATE_REVOKED, and the client's state manager loops issuing TEST_STATEID across its delegations without ever clearing the condition.
The window is easy to reach now that a server offers a write delegation on any write OPEN: a delegation recalled for one opener races a re-open that the server answers with a fresh write delegation.
Instead of dropping it, hand the delegation back during these error flows.
--- fs/nfs/delegation.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
fs/nfs/delegation.c +14 -4
@@ -447,11 +447,14 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,struct nfs_inode *nfsi =NFS_I (inode);struct nfs_delegation *delegation, *old_delegation;struct nfs_delegation *freeme =NULL ; +bool orphaned = false;int status =0 ; delegation =kmalloc_obj (*delegation,GFP_KERNEL_ACCOUNT ); -if (delegation ==NULL ) +if (delegation ==NULL ) { +nfs4_proc_delegreturn (inode, cred, stateid,NULL ,0 );return -ENOMEM ; + }nfs4_stateid_copy (&delegation->stateid, stateid);refcount_set (&delegation->refcount,1 ); delegation->type = type;
@@ -500,11 +503,15 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, goto out; }if (test_and_set_bit (NFS_DELEGATION_RETURNING , - &old_delegation->flags)) + &old_delegation->flags)) { + orphaned = true; goto out; + } } -if (!nfs_detach_delegations_locked (nfsi, old_delegation, clp)) +if (!nfs_detach_delegations_locked (nfsi, old_delegation, clp)) { + orphaned = true; goto out; + } freeme = old_delegation; add_new:/*
@@ -539,8 +546,11 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,nfs_update_delegated_mtime (inode); out:spin_unlock (&clp->cl_lock); -if (delegation !=NULL ) +if (delegation !=NULL ) { +if (orphaned) +nfs_do_return_delegation (inode, delegation,0 );__nfs_free_delegation (delegation); + }if (freeme !=NULL ) {nfs_do_return_delegation (inode, freeme,0 );nfs_mark_delegation_revoked (server, freeme);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1282/1815 perf python: Fix count_values memory leak in pyrf_evsel__read
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit cb45ede21d02cc85de18ce6b60a51a7449f4179b ]
In pyrf_evsel__read, if PyArg_ParseTuple fails, the allocated count_values is leaked. Move the allocation of count_values after the PyArg_ParseTuple call to prevent the memory leak.
--- tools/perf/util/python.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
tools/perf/util/python.c +4 -5
@@ -1199,11 +1199,6 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel,CHECK_INITIALIZED (evsel,"evsel" ); - count_values = PyObject_New(struct pyrf_counts_values, - &pyrf_counts_values__type); -if (!count_values) -return NULL ; -if (!PyArg_ParseTuple (args,"ii" , &cpu, &thread))return NULL ;
@@ -1222,6 +1217,10 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel,if (evsel__ensure_counts (evsel))return PyErr_NoMemory (); + count_values = PyObject_New(struct pyrf_counts_values, &pyrf_counts_values__type); +if (!count_values) +return NULL ; +/* Set up pointers to the old and newly read counter values. */ old_count =perf_counts (evsel->prev_raw_counts, cpu_idx, thread_idx); new_count =perf_counts (evsel->counts, cpu_idx, thread_idx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1318/1815 nvmet: fix Reservation Register Replace for unregistered host with IEKEY
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengrong Li <[email protected]>
[ Upstream commit 0a96b9e440331bffbf049f80d7e5c96417d37e36 ]
When a host sends a Reservation Register command with RREGA=Replace and IEKEY=1 without being previously registered, nvmet returns Reservation Conflict.
The NVMe specification states:
"A host may replace its reservation key without regard to its
registration status or current reservation key value by setting the Ignore Existing Key (IEKEY) bit to '1' in the Reservation Register command."
Fix nvmet_pr_replace() to add a new registrant when the host is not found in the registrant list and IEKEY is set with a non-zero NRKEY. If IEKEY is set but NRKEY is zero, return Invalid Field since there is no valid reservation key to register.
Tested with nvme-cli against nvmet-tcp:
# no prior registration nvme resv-register /dev/nvmeXn1 -n 1 --rrega=2 --iekey --nrkey=0x9999
Before: RESERVATION_CONFLICT (0x4083)
After: success, registrant created with rkey 0x9999
--- drivers/nvme/target/pr.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/nvme/target/pr.c +25 -2
@@ -355,9 +355,15 @@ static u16 nvmet_pr_replace(struct nvmet_req *req,u16 status =NVME_SC_RESERVATION_CONFLICT |NVME_STATUS_DNR ;struct nvmet_ctrl *ctrl = req->sq->ctrl;struct nvmet_pr *pr = &req->ns->pr; -struct nvmet_pr_registrant *reg; +struct nvmet_pr_registrant *reg, *new =NULL ;u64 nrkey =le64_to_cpu (d->nrkey); +if (ignore_key && nrkey) { + new =kzalloc_obj (*new); +if (!new) +return NVME_SC_INTERNAL ; + } +down (&pr->pr_sem);list_for_each_entry_rcu (reg, &pr->registrant_list, entry) {if (uuid_equal (®->hostid, &ctrl->hostid)) {
@@ -365,9 +371,26 @@ static u16 nvmet_pr_replace(struct nvmet_req *req, status =nvmet_pr_update_reg_attr (pr, reg, nvmet_pr_update_reg_rkey, &nrkey); -break ; + goto free_data; + } + } + +if (ignore_key) { +if (!nrkey) { + status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; + goto free_data; } +INIT_LIST_HEAD (&new->entry); + new->rkey = nrkey; +uuid_copy (&new->hostid, &ctrl->hostid); +list_add_tail_rcu (&new->entry, &pr->registrant_list); + status =NVME_SC_SUCCESS ; + goto out; } + +free_data: +kfree (new); +out:up (&pr->pr_sem);return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1319/1815 nvmet: propagate percpu_ref_init() failure in nvmet_ns_enable()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 751709592d2626eaa8dc17ef8137796758a3c37f ]
The return value of percpu_ref_init() is discarded. At this point ret is 0 from the preceding successful steps, so when the allocation inside percpu_ref_init() fails the code jumps to the out_pr_exit cleanup chain which ends with "return ret", i.e. reports success. The configfs enable store then tells userspace the namespace was enabled even though it was not and its backing device has already been torn down.
Capture the return value so the failure is propagated.
--- drivers/nvme/target/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/core.c +2 -1
@@ -610,7 +610,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns) goto out_dev_put; } -if (percpu_ref_init (&ns->ref, nvmet_destroy_namespace,0 ,GFP_KERNEL )) + ret =percpu_ref_init (&ns->ref, nvmet_destroy_namespace,0 ,GFP_KERNEL ); +if (ret) goto out_pr_exit;nvmet_ns_changed (subsys, ns->nsid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1320/1815 nvme-pci: release descriptor pools on probe failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit cb144c2f67128abfa5c7ba33318617d19f192156 ]
The per-NUMA-node descriptor DMA pools are created lazily from nvme_init_hctx_common() once the admin tag set is allocated, but they are only destroyed in nvme_remove() via nvme_release_descriptor_pools(). Any probe failure after the admin tag set has been allocated unwinds through the out_disable label and nvme_pci_free_ctrl(), neither of which releases the pools, leaking the dma_pool objects.
Release the descriptor pools in the out_disable error path. It must not be added to nvme_pci_free_ctrl(), as that would double-free against nvme_remove() on the normal teardown path.
--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
@@ -3840,6 +3840,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)nvme_dev_remove_admin (dev);nvme_dbbuf_dma_free (dev);nvme_free_queues (dev,0 ); +nvme_release_descriptor_pools (dev); out_release_iod_mempool:mempool_destroy (dev->dmavec_mempool); out_dev_unmap:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1321/1815 cgroup/cpuset: Use WRITE_ONCE() for shared prs_err updates
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guopeng Zhang <[email protected]>
[ Upstream commit 26d3a59e0241c3ef9f66ae1ae990f9326acbc059 ]
cpuset_partition_show() reads cs->prs_err without cpuset_mutex using READ_ONCE(). The field is documented as not lock protected, but several updates to live cpusets still use plain stores.
Convert the remaining prs_err stores on live cpusets to WRITE_ONCE().
--- kernel/cgroup/cpuset.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
kernel/cgroup/cpuset.c +13 -11
@@ -1548,7 +1548,7 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,cpumask_copy (cs->effective_xcpus, tmp->new_cpus);spin_unlock_irq (&callback_lock);cpuset_force_rebuild (); - cs->prs_err =0 ; +WRITE_ONCE (cs->prs_err,0 );/* * Propagate changes in top_cpuset's effective_cpus down the hierarchy.
@@ -1622,7 +1622,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,WARN_ON_ONCE (!cpumask_subset (cs->effective_xcpus, subpartitions_cpus));if (cpumask_empty (excpus)) { - cs->prs_err =PERR_CPUSEMPTY ; +WRITE_ONCE (cs->prs_err,PERR_CPUSEMPTY ); goto invalidate; }
@@ -1637,13 +1637,13 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,if (adding) {WARN_ON_ONCE (cpumask_intersects (tmp->addmask, subpartitions_cpus));if (!capable (CAP_SYS_ADMIN )) - cs->prs_err =PERR_ACCESS ; +WRITE_ONCE (cs->prs_err,PERR_ACCESS );else if (cpumask_intersects (tmp->addmask, subpartitions_cpus) ||cpumask_subset (top_cpuset.effective_cpus, tmp->addmask)) - cs->prs_err =PERR_NOCPUS ; +WRITE_ONCE (cs->prs_err,PERR_NOCPUS );else if ((prs ==PRS_ISOLATED ) && !isolated_cpus_can_update (tmp->addmask, tmp->delmask)) - cs->prs_err =PERR_HKEEPING ; +WRITE_ONCE (cs->prs_err,PERR_HKEEPING );if (cs->prs_err) goto invalidate; }
@@ -2071,13 +2071,13 @@ static void compute_partition_effective_cpumask(struct cpuset *cs,* partition root. */ WARN_ON_ONCE (is_remote_partition (child)); - child->prs_err =0 ; +WRITE_ONCE (child->prs_err,0 );if (!cpumask_subset (child->effective_xcpus, cs->effective_xcpus)) - child->prs_err =PERR_INVCPUS ; +WRITE_ONCE (child->prs_err,PERR_INVCPUS );else if (populated &&cpumask_subset (new_ecpus, child->effective_xcpus)) - child->prs_err =PERR_NOCPUS ; +WRITE_ONCE (child->prs_err,PERR_NOCPUS );if (child->prs_err) {int old_prs = child->partition_root_state;
@@ -2381,8 +2381,10 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs,return ; prs_err =validate_partition (cs, trialcs); -if (prs_err) - trialcs->prs_err = cs->prs_err = prs_err; +if (prs_err) { +WRITE_ONCE (cs->prs_err, prs_err); + trialcs->prs_err = prs_err; + }if (is_remote_partition (cs)) {if (trialcs->prs_err)
@@ -3801,7 +3803,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)if (remote && (cpumask_empty (subpartitions_cpus) || (cpumask_empty (&new_cpus) &&partition_is_populated (cs,NULL )))) { - cs->prs_err =PERR_HOTPLUG ; +WRITE_ONCE (cs->prs_err,PERR_HOTPLUG );remote_partition_disable (cs, tmp);compute_effective_cpumask (&new_cpus, cs, parent); remote = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1322/1815 selftests/cgroup: Avoid awk -e in cpuset tests
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rui Qi <[email protected]>
[ Upstream commit 75e79a20190040800445ec95a4c4a84193d16992 ]
The cpuset selftests use awk -e to parse cgroup mount points. This works with gawk, but mawk rejects the option. In test_cpuset_prs.sh, this leaves CGROUP2 empty and causes the test to skip as if cgroup v2 were not mounted. The same non-portable invocation exists in the cpuset v1 hotplug test.
The scripts only need to pass a single awk program. Use the standard awk invocation without -e so mount point detection works with awk implementations that do not support the gawk extension.
--- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 2 +- tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/test_cpuset_prs.sh +1 -1
@@ -20,7 +20,7 @@ skip_test() { WAIT_INOTIFY=$(cd $(dirname $0); pwd)/wait_inotify # Find cgroup v2 mount point -CGROUP2=$(mount -t cgroup2 | head -1 | awk -e '{print $3}') +CGROUP2=$(mount -t cgroup2 | head -1 | awk '{print $3}') [[ -n "$CGROUP2" ]] || skip_test "Cgroup v2 mount point not found!" SUBPARTS_CPUS=$CGROUP2/.__DEBUG__.cpuset.cpus.subpartitions CPULIST=$(cat $CGROUP2/cpuset.cpus.effective)
tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh +1 -1
@@ -14,7 +14,7 @@ skip_test() { [[ $(id -u) -eq 0 ]] || skip_test "Test must be run as root!" # Find cpuset v1 mount point -CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk -e '{print $3}') +CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk '{print $3}') [[ -n "$CPUSET" ]] || skip_test "cpuset v1 mount point not found!" #
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1323/1815 selftests/sched_ext: Check skeleton open failure in exit test
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Luo <[email protected]>
[ Upstream commit 4dc310b41aba43e9d8dfafe46dce86f8b55c0354 ]
exit.c does not check the return value of exit__open(). If it returns NULL, which happens when the skeleton wrapper fails to allocate the object or open the BPF ELF, the very next line dereferences it via SCX_ENUM_INIT(). That macro expands to SCX_ENUM_SET(), which accesses skel->rodata, causing a NULL pointer dereference.
Every other selftest guards this with SCX_FAIL_IF(!skel, ...); exit.c is the only one missing it.
--- tools/testing/selftests/sched_ext/exit.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/sched_ext/exit.c +1 -0
@@ -31,6 +31,7 @@ static enum scx_test_status run(void *ctx)continue ; skel =exit__open (); +SCX_FAIL_IF (!skel,"Failed to open" );SCX_ENUM_INIT (skel); skel->rodata->exit_point = tc;SCX_FAIL_IF (exit__load (skel),"Failed to load skel" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1283/1815 perf python: Fix memory leak in pyrf__metrics_cb
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 1ec13016ba36f1bf7dc61e054068fe00f2f628c7 ]
In pyrf__metrics_cb, PyDict_SetItem does not steal the reference of the key and value, so they need to be decref'ed after successful insertion to avoid memory leaks.
--- tools/perf/util/python.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/python.c +2 -0
@@ -2508,6 +2508,8 @@ static int pyrf__metrics_cb(const struct pmu_metric *pm,Py_XDECREF (dict);return -ENOMEM ; } +Py_DECREF (key); +Py_DECREF (value); if (!add_to_dict(dict, "MetricName", pm->metric_name) || !add_to_dict(dict, "PMU", pm->pmu) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1284/1815 perf synthetic-events: Fix divide by zero in perf_event__synthesize_threads
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 16a12a54e9a1151a37aab74914a51b86f7f58d0e ]
If scandir() finds no matching tasks in /proc, n is 0. If thread_nr is > 1, we bypass the single-thread fast path and then clamp thread_nr to n, making it 0. This results in a divide by zero when calculating num_per_thread.
Handle n <= 1 early to use the single-thread fast path and prevent the crash.
--- tools/perf/util/synthetic-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/synthetic-events.c +1 -1
@@ -1058,7 +1058,7 @@ int perf_event__synthesize_threads(const struct perf_tool *tool,else thread_nr = nr_threads_synthesize; -if (thread_nr <=1 ) { +if (thread_nr <=1 || n <=1 ) { err = __perf_event__synthesize_threads(tool, process, machine, needs_mmap, mmap_data,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1285/1815 apparmor: fix integer overflow in verify_tags() bounds check
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Derepas <[email protected]>
[ Upstream commit 465946d3c560c0137e6a180ba054dddc4d049f5a ]
verify_tags() validates the tagset table unpacked from a policy blob. For each set it reads a count and checks that advancing the index by that count stays inside sets.table[]:
u32 cnt = tags->sets.table[i];
if (i+cnt >= tags->sets.size) {i, cnt and sets.size are all u32, so i+cnt is evaluated modulo 2^32. sets.table[] is filled by unpack_tagsets() with aa_unpack_u32(), so every entry is a raw unbounded 32-bit word taken from the policy blob, and verify_tags() is the function that is supposed to validate it. A count close to U32_MAX makes the sum wrap to a small value, the guard passes, and the inner loop then walks sets.table[++i] past the end of the kcalloc(size, sizeof(u32)) allocation.
Note that sets.size is bounded by 65535, because unpack_tagsets() reads it with aa_unpack_array() as a u16, so the wrap cannot be reached by growing the table; it is reached purely through the attacker-supplied count.
With sets.size = 2 and sets.table = { 0, 0xffffffff }:
i = 0: cnt = 0, guard 0 + 0 >= 2 is false, inner loop does not run i = 1: cnt = 0xffffffff, guard (1 + 0xffffffff) mod 2^32 == 0 >= 2 is
false, so the guard is bypassed and the inner loop reads sets.table[2] -- one element past a two element allocation
The walk continues until an out-of-bounds value happens to be >= hdrs.size or the access faults, so a crafted policy yields an out-of-bounds read on the policy load path (aa_replace_profiles -> aa_unpack -> unpack_policydb -> unpack_tags -> verify_tags). unpack_tags() runs before the perms and DFA tables are unpacked, so no other table needs to be well formed to reach it.
Policy load is gated by aa_may_manage_policy(), which checks CAP_MAC_ADMIN relative to the subject's own user namespace rather than the init user namespace, so with the default unprivileged_userns_apparmor_policy=1 the path is reachable from an unprivileged task in a matched-level nested namespace, not only by a globally privileged one.
Perform the addition in u64 so that it cannot wrap, restoring the intended i + cnt < sets.size guarantee.
--- security/apparmor/policy_unpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -1
@@ -730,7 +730,7 @@ static bool verify_tags(struct aa_tags_struct *tags, const char **info)/* count followed by count indexes into hdrs */ u32 cnt = tags->sets.table[i]; -if (i+cnt >= tags->sets.size) { +if ((u64 )i + cnt >= tags->sets.size) {AA_DEBUG (DEBUG_UNPACK ,"tagset too large %d+%d > sets.table[%d]" , i, cnt, tags->sets.size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1286/1815 fbdev: tdfxfb: fix PCI enable cleanup with pcim_enable_device()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 95a627143a696f70e17be5ed3b1e733bb6724b46 ]
tdfxfb_probe() enables the PCI device with pci_enable_device(), but several failure paths after that point return without disabling it. The framebuffer_alloc() failure path returns -ENOMEM directly, and the later shared out_err path releases the framebuffer and returns -ENXIO without balancing the PCI enable state.
The successful probe path has the same imbalance because tdfxfb_remove() releases the framebuffer, mappings and regions, but never calls pci_disable_device().
Use pcim_enable_device() so the PCI device is disabled automatically on probe failure and driver detach.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/video/fbdev/tdfxfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/tdfxfb.c +1 -1
@@ -1385,7 +1385,7 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err)return err; - err =pci_enable_device (pdev); + err =pcim_enable_device (pdev);if (err) {printk (KERN_ERR "tdfxfb: Can't enable pdev: %d\n" , err);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1287/1815 fbdev: kyro: Validate overlay viewport coordinates
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit 7b5c7bc55e13e7f5ac7b1eaf5c6d690389ea5ee3 ]
The overlay viewport end coordinates are computed from the viewport origin and dimensions using 32-bit unsigned arithmetic. Large input values can cause these calculations to wrap around before the resulting coordinates are passed to SetOverlayViewPort().
SetOverlayViewPort() packs the viewport coordinates into 16-bit register fields. The X coordinates are additionally adjusted by +2 and +1 before being written. Validate the coordinate calculations for 32-bit wraparound and ensure that the adjusted coordinates fit within their 16-bit register fields before calling SetOverlayViewPort().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/kyro/fbdev.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/video/fbdev/kyro/fbdev.c +23 -1
@@ -369,6 +369,9 @@ static int kyro_dev_overlay_create(u32 ulWidth,static int kyro_dev_overlay_viewport_set (u32 x,u32 y,u32 ulWidth,u32 ulHeight) { +u32 right; +u32 bottom; +if (deviceInfo.ulOverlayOffset ==0 )/* probably haven't called CreateOverlay yet */ return -EINVAL ;
@@ -378,11 +381,30 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight (x < 2 && ulWidth + 2 == 0))return -EINVAL ; +/* +* SetOverlayViewPort() adjusts X coordinates by +2 (left) and +1 +* (right) before packing them into 16-bit register fields. +*/ +if (x >U16_MAX -2 || y >U16_MAX ) +return -EINVAL ; + + right = x + ulWidth; + bottom = y + ulHeight; + +if (right < x || bottom < y) +return -EINVAL ; + + right--; + bottom--; + +if (right >U16_MAX -1 || bottom >U16_MAX ) +return -EINVAL ; +/* Stop Ramdac Output */ DisableRamdacOutput (deviceInfo.pSTGReg);SetOverlayViewPort (deviceInfo.pSTGReg, - x, y, x + ulWidth -1 , y + ulHeight -1 ); + x, y, right, bottom);EnableOverlayPlane (deviceInfo.pSTGReg);/* Start Ramdac Output */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1278/1815 perf python: Check counts_values size in set_values
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 612aca22a978d43f6e6765272676a17afdba8572 ]
The set_values function incorrectly assumed the list contained exactly 5 elements. Add a check to prevent out-of-bounds access.
--- tools/perf/util/python.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
tools/perf/util/python.c +30 -8
@@ -875,11 +875,11 @@ static void pyrf_counts_values__delete(struct pyrf_counts_values *pcounts_values 0, help }static PyMemberDef pyrf_counts_values_members[] = { -counts_values_member_def (val,T_ULONG ,"Value of event" ), -counts_values_member_def (ena,T_ULONG ,"Time for which enabled" ), -counts_values_member_def (run,T_ULONG ,"Time for which running" ), -counts_values_member_def (id,T_ULONG ,"Unique ID for an event" ), -counts_values_member_def (lost,T_ULONG ,"Num of lost samples" ), +counts_values_member_def (val,T_ULONGLONG ,"Value of event" ), +counts_values_member_def (ena,T_ULONGLONG ,"Time for which enabled" ), +counts_values_member_def (run,T_ULONGLONG ,"Time for which running" ), +counts_values_member_def (id,T_ULONGLONG ,"Unique ID for an event" ), +counts_values_member_def (lost,T_ULONGLONG ,"Num of lost samples" ), { .name =NULL , }, };
@@ -889,8 +889,15 @@ static PyObject *pyrf_counts_values_get_values(struct pyrf_counts_values *self,if (!vals)return NULL ; -for (int i =0 ; i <5 ; i++) -PyList_SetItem (vals, i,PyLong_FromLong (self->values.values[i])); +for (int i =0 ; i <5 ; i++) { +PyObject *val =PyLong_FromUnsignedLongLong (self->values.values[i]); + +if (!val) { +Py_DECREF (vals); +return NULL ; + } +PyList_SetItem (vals, i, val); + }return vals; }
@@ -901,19 +908,34 @@ static int pyrf_counts_values_set_values(struct pyrf_counts_values *self, PyObjePy_ssize_t size;PyObject *item =NULL ; +if (list ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } +if (!PyList_Check (list)) {PyErr_SetString (PyExc_TypeError,"Value assigned must be a list" );return -1 ; } size =PyList_Size (list); +if (size !=5 ) { +PyErr_SetString (PyExc_ValueError,"List must have exactly 5 entries" ); +return -1 ; + } +for (Py_ssize_t i =0 ; i < size; i++) { +unsigned long long val; + item =PyList_GetItem (list, i);if (!PyLong_Check (item)) {PyErr_SetString (PyExc_TypeError,"List members should be numbers" );return -1 ; } - self->values.values[i] =PyLong_AsLong (item); + val =PyLong_AsUnsignedLongLong (item); +if (val == (unsigned long long )-1 &&PyErr_Occurred ()) +return -1 ; + self->values.values[i] = val; }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1325/1815 amt: Dont support cross-netns setup.
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit e99ecc3046ea5f5c6b5e1f8b4ef854c6c6998e06 ]
When a lower device is unregistered, amt_device_event() tries to unregister its upper AMT device, but it has two problems.
1. amt_lookup_upper_dev() looks up an upper device in the lower device's netns only
2. amt_device_event() unregisters a single upper device only
If AMT device is created on a lower device in another netns, removing the lower device triggers the splat below and gets stuck until all upper devices are removed. [0]
The cross-netns setup seems unintentional considering 1. and the following points:
* amt_link_setup() sets dev->netns_immutable to true
* skb_scrub_packet() is not called in the fast path
* iproute2 binary fails to find cross-netns lower device via link-netns:
# ip -n ns1 link add amt0 link-netns ns2 type amt dev veth1 Cannot find device "veth1"
Instead of supporting it properly and preparing for per-netns netdev unreg, let's forbid cross-netns setup.
Note that the problem 2. needs a separate fix.
[0]:
WARNING: net/core/dev.c:12518 at unregister_netdevice_many_notify+0x1cce/0x2250, CPU#48: ip/2031
Modules linked in:
CPU: 48 UID: 0 PID: 2031 Comm: ip Not tainted 7.2.0-rc5+ #27 PREEMPT(full)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
RIP: 0010:unregister_netdevice_many_notify (net/core/dev.c:12518)
Code: 89 ef e8 d5 52 ae fe e9 d0 f4 ff ff 48 8d 3d f9 3b 9c 02 48 c7 c6 c0 0b 63 84 ba ab 1f 00 00 67 48 0f b9 3a e9 65 ff ff ff 90 <0f> 0b 90 eb 81 48 8d 3d f6 3b 9c 02 48 c7 c6 c0 0b 63 84 ba e2 1f
RSP: 0018:ffffc90004abf160 EFLAGS: 00010212
RAX: ffff888104d38260 RBX: ffff88800b0911b8 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffffffff85b9f880
RBP: ffffc90004abf2d0 R08: ffffffff85b9f887 R09: 1ffffffff0b73f10
R10: dffffc0000000000 R11: fffffbfff0b73f11 R12: ffff88800b091d08
R13: ffff88800b091178 R14: dffffc0000000000 R15: ffff88800b091000
FS: 00007f555b86c600(0000) GS:ffff8881942a0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000562107d489c0 CR3: 0000000109a40002 CR4: 0000000000372ef0
Call Trace:
<TASK>
rtnl_dellink (net/core/rtnetlink.c:3632 net/core/rtnetlink.c:3674)
rtnetlink_rcv_msg (net/core/rtnetlink.c:7112)
netlink_rcv_skb (net/netlink/af_netlink.c:2556)
netlink_unicast (net/netlink/af_netlink.c:1319)
netlink_sendmsg (net/netlink/af_netlink.c:1900)
____sys_sendmsg (net/socket.c:775)
__sys_sendmsg (net/socket.c:2738)
do_syscall_64 (arch/x86/entry/syscall_64.c:63)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
...
unregister_netdevice: waiting for veth0 to become free. Usage count = 7
ref_tracker: netdev@ffff88800d7496d8 has 3/3 users at
__netdev_adjacent_dev_insert (./include/linux/netdevice.h:4525 ./include/linux/netdevice.h:4554 net/core/dev.c:8791)
__netdev_upper_dev_link (net/core/dev.c:8879 net/core/dev.c:8963)
netdev_upper_dev_link (net/core/dev.c:9009)
amt_newlink (drivers/net/amt.c:3321)--- drivers/net/amt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/amt.c +3 -0
@@ -3221,6 +3221,9 @@ static int amt_newlink(struct net_device *dev,struct nlattr **tb = params->tb;int err = -EINVAL ; +if (!net_eq (link_net,dev_net (dev))) +return err; + amt->net = link_net; amt->mode =nla_get_u32 (data[IFLA_AMT_MODE ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1334/1815 phy: qcom: qmp-combo: Correct pre-emphasis table for QMP v4 DP PHYs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esteban Urrutia <[email protected]>
[ Upstream commit 481807f939077059db278edd0467e7e609b6c9a7 ]
Comparing sm8350 and sm8450 tables, this seems to be a typo.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +1 -1
@@ -2108,7 +2108,7 @@ static const u8 qmp_dp_v4_pre_emphasis_hbr3_hbr2[4][4] = {static const u8 qmp_dp_v4_pre_emphasis_hbr_rbr[4 ][4 ] = { {0x00 ,0x0d ,0x14 ,0x1a }, {0x00 ,0x0e ,0x15 ,0xff }, - {0x00 ,0x0d ,0xff ,0xff }, + {0x00 ,0x0e ,0xff ,0xff }, {0x03 ,0xff ,0xff ,0xff } };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1335/1815 phy: qcom: qmp-combo: Drop qmp_v4_calibrate_dp_phy
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esteban Urrutia <[email protected]>
[ Upstream commit 8fd2b30d187fa33e5dd30699d3e3a3662c1610c9 ]
There are no downstream device trees that specify five values in the qcom,aux-cfg1-settings array.
Plus, after cross referencing both downstream device trees and entries which refer this function, only 0x13 is specified.
Since 0x13 is written at initialization time, drop this function as a whole, and remove now unused variable assignations.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 31 ----------------------- 1 file changed, 31 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +0 -31
@@ -2325,7 +2325,6 @@ static int qmp_v3_calibrate_dp_phy(struct qmp_combo *qmp);static void qmp_v4_dp_aux_init (struct qmp_combo *qmp);static void qmp_v4_configure_dp_tx (struct qmp_combo *qmp);static int qmp_v4_configure_dp_phy (struct qmp_combo *qmp); -static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp);static void qmp_v8_dp_aux_init (struct qmp_combo *qmp);static int qmp_v8_configure_dp_clocks (struct qmp_combo *qmp);
@@ -2466,7 +2465,6 @@ static const struct qmp_phy_cfg sar2130p_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2603,7 +2601,6 @@ static const struct qmp_phy_cfg sc8180x_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2650,7 +2647,6 @@ static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2696,7 +2692,6 @@ static const struct qmp_phy_cfg x1e80100_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2785,7 +2780,6 @@ static const struct qmp_phy_cfg sm8250_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2834,7 +2828,6 @@ static const struct qmp_phy_cfg sm8350_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2882,7 +2875,6 @@ static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2928,7 +2920,6 @@ static const struct qmp_phy_cfg sm8650_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2974,7 +2965,6 @@ static const struct qmp_phy_cfg sm8750_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v8_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -3020,7 +3010,6 @@ static const struct qmp_phy_cfg glymur_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v8_configure_dp_clocks, .configure_dp_phy = qmp_v8_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v8_n3_usb43dpphy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -3316,7 +3305,6 @@ static void qmp_v4_dp_aux_init(struct qmp_combo *qmp)writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 );writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 );writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); - qmp->dp_aux_cfg =0 ; writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
@@ -3345,7 +3333,6 @@ static void qmp_v8_dp_aux_init(struct qmp_combo *qmp)writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 );writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 );writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); - qmp->dp_aux_cfg =0 ; writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
@@ -3605,24 +3592,6 @@ static int qmp_v8_configure_dp_phy(struct qmp_combo *qmp)return 0 ; } -/* -* We need to calibrate the aux setting here as many times -* as the caller tries -*/ -static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp) -{ -static const u8 cfg1_settings[] = {0x20 ,0x13 ,0x23 ,0x1d }; -u8 val; - - qmp->dp_aux_cfg++; - qmp->dp_aux_cfg %=ARRAY_SIZE (cfg1_settings); - val = cfg1_settings[qmp->dp_aux_cfg]; - -writel (val, qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG1 ); - -return 0 ; -} -static int qmp_combo_dp_configure (struct phy *phy,union phy_configure_opts *opts) {const struct phy_configure_opts_dp *dp_opts = &opts->dp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1336/1815 arm64: entry: Avoid unnecessary local_irq_disable() on kernel exit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Murzin <[email protected]>
[ Upstream commit 39aebe0e89469c2904e60b1e977e0d4dbf33326b ]
Currently, when exiting to kernel mode, we attempt involuntary preemption. The preemption logic expects IRQs to be disabled, which is why we call local_irq_disable() before attempting preemption.
However, depending on the context, local_irq_disable() may be unnecessary:
- __el1_irq(), the non-NMI EL1 IRQ path, already has IRQs disabled, so local_irq_disable() is redundant.
- irqentry_exit_to_kernel_mode_preempt() immediately returns when exiting from an NMI-like context, so calling local_irq_disable() beforehand is unnecessary work.
Furthermore, it confuses the pNMI state tracking when we are in a context with interrupts disabled and the GIC_PRIO_PSR_I_SET bit is set in the PMR, leading to a warning when CONFIG_ARM64_DEBUG_PRIORITY_MASKING=y:
WARNING: ./arch/arm64/include/asm/irqflags.h:63 at arm64_exit_to_kernel_mode+0xb8/0xc0, CPU#40: retsnoop/31805
CPU: 40 UID: 0 PID: 31805 Comm: retsnoop Not tainted 7.2.0-rc6-next-20260805 #7 PREEMPTLAZY
pstate: 234013c9 (nzCv DAIF +PAN -UAO +TCO +DIT +SSBS BTYPE=--)
pc : arm64_exit_to_kernel_mode (arch/arm64/kernel/entry-common.c:63)
lr : el1_abort (arch/arm64/kernel/entry-common.c:323)
pmr: 000000f0
Call trace:
arm64_exit_to_kernel_mode (arch/arm64/kernel/entry-common.c:63) (P)
el1_abort (arch/arm64/kernel/entry-common.c:323)
el1h_64_sync_handler (arch/arm64/kernel/entry-common.c:449)
el1h_64_sync (arch/arm64/kernel/entry.S:589)
[...]Split arm64_exit_to_kernel_mode() into preempt, non-preempt, and dispatch parts so that we can avoid this extra work where it is not needed and avoid breaking the pNMI tracking logic.
--- arch/arm64/kernel/entry-common.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
arch/arm64/kernel/entry-common.c +25 -5
@@ -52,16 +52,36 @@ static noinstr irqentry_state_t arm64_enter_from_kernel_mode(struct pt_regs *reg* After this function returns it is not safe to call regular kernel code, * instrumentable code, or any code which may trigger an exception. */ -static void noinstr arm64_exit_to_kernel_mode(struct pt_regs *regs, -irqentry_state_t state) +static void noinstr __arm64_exit_to_kernel_mode(struct pt_regs *regs, +irqentry_state_t state) { -local_irq_disable (); -irqentry_exit_to_kernel_mode_preempt (regs, state);local_daif_mask ();mte_check_tfsr_exit ();irqentry_exit_to_kernel_mode_after_preempt (regs, state); } +/* +* We are returning from the context which allows involuntary kernel preemption +*/ +static void noinstr arm64_exit_to_kernel_mode_preempt(struct pt_regs *regs, +irqentry_state_t state) +{ +irqentry_exit_to_kernel_mode_preempt (regs, state); +__arm64_exit_to_kernel_mode (regs, state); +} + +static void noinstr arm64_exit_to_kernel_mode(struct pt_regs *regs, +irqentry_state_t state) +{ +if (!regs_irqs_disabled (regs)) { +local_irq_disable (); +arm64_exit_to_kernel_mode_preempt (regs, state); +return ; + } + +__arm64_exit_to_kernel_mode (regs, state); +} + static __always_inline void arm64_syscall_enter_from_user_mode(struct pt_regs *regs) {enter_from_user_mode (regs);
@@ -509,7 +529,7 @@ static __always_inline void __el1_irq(struct pt_regs *regs,do_interrupt_handler (regs, handler);irq_exit_rcu (); -arm64_exit_to_kernel_mode (regs, state); +arm64_exit_to_kernel_mode_preempt (regs, state); } static void noinstr el1_interrupt(struct pt_regs *regs,void (*handler)(struct pt_regs *))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1337/1815 spi: sprd-adi: Fix probe succeeding without registering the controller
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit f092e1c935015ee0a0fea1a0374f4cab7b71953c ]
With CONFIG_HWSPINLOCK=n the of_hwspin_lock_get_id() stub returns 0 unconditionally. In sprd_adi_probe() the guard
if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0))
is false for that 0, so it takes the else branch, where the switch has no case for 0 and lands in
default: return dev_err_probe(&pdev->dev, ret, "failed to find hwlock id\n");
dev_err_probe() returns its err argument unchanged, so probe logs "failed to find hwlock id" and then returns 0, reporting success. sprd_adi_hw_init(), the restart handler and devm_spi_register_controller() are all skipped: the device binds but no SPI controller is ever registered.
The hardware spinlock is optional for this controller and the -ENOENT arm already covers "no hardware spinlock supplied". Treat the stub's 0 the same way and continue without a lock; all four users of sadi->hwlock already test it for NULL.
This is not reachable on production kernels. Kconfig has
depends on HWSPINLOCK || (COMPILE_TEST && !HWSPINLOCK)
so the affected configuration exists only under COMPILE_TEST, where no real hardware is present.
Found by smatch:drivers/spi/spi-sprd-adi.c:560 sprd_adi_probe() warn: passing zero to 'dev_err_probe'
--- drivers/spi/spi-sprd-adi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-sprd-adi.c +6 -0
@@ -553,6 +553,12 @@ static int sprd_adi_probe(struct platform_device *pdev)return -ENXIO ; }else {switch (ret) { +case 0 : +/* +* Only reachable with CONFIG_HWSPINLOCK=n, where the +* of_hwspin_lock_get_id() stub returns 0. +*/ + fallthrough;case -ENOENT :dev_info (&pdev->dev,"no hardware spinlock supplied\n" );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1338/1815 ASoC: qcom: q6apm: keep the graph start count in sync with the DSP
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jorijn van der Graaf <[email protected]>
[ Upstream commit daa7ffd765ae67a83e77dae32c66ce2d6d995d19 ]
q6apm_graph_start() increments start_count even when APM_CMD_GRAPH_START fails, leaving the graph counted as running while the DSP never started it. A later start - a retried prepare, or a resume after a failed start - then finds a non-zero count, skips the command and returns success with no data flowing.
Count the graph only once the DSP has accepted the start. The count then stays at zero for a graph that never started, so also stop decrementing below zero in q6apm_graph_stop(): the compressed free path stops unconditionally, and a negative count would make the next start skip the command in the same way.
--- sound/soc/qcom/qdsp6/q6apm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
sound/soc/qcom/qdsp6/q6apm.c +9 -3
@@ -802,14 +802,17 @@ EXPORT_SYMBOL_GPL(q6apm_graph_prepare);int q6apm_graph_start (struct q6apm_graph *graph) {struct audioreach_graph *ar_graph = graph->ar_graph; -int ret =0 ; +int ret; -if (ar_graph->start_count ==0 ) +if (ar_graph->start_count ==0 ) { ret =audioreach_graph_mgmt_cmd (ar_graph,APM_CMD_GRAPH_START ); +if (ret) +return ret; + } ar_graph->start_count++; -return ret; +return 0 ; }EXPORT_SYMBOL_GPL (q6apm_graph_start);
@@ -817,6 +820,9 @@ int q6apm_graph_stop(struct q6apm_graph *graph) {struct audioreach_graph *ar_graph = graph->ar_graph; +if (ar_graph->start_count ==0 ) +return 0 ; +if (--ar_graph->start_count >0 )return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1339/1815 arm64: bti: Disable in-kernel BTI with recent versions of Clang
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit d3359af21fc9e7a47577ff90e821b6510ec34dee ]
The following BTI exception was seen when loading a livepatch module:
Internal error: Oops - BTI: 0000000036000001 [#1] SMP pstate: 634004c9 (nZCv daIF +PAN -UAO +TCO +DIT -SSBS BTYPE=jc) pc : kill_orphaned_pgrp+0x0/0x150 lr : do_exit+0x498/0xaf0 [livepatch_combined]
The problem is that the patch module's do_exit() is branching to a static function in vmlinux using a module PLT veneer (indirect branch), but the target function doesn't have a BTI landing pad.
Clang 21+ omits the landing pad for static functions which can only be reached by a direct branch. That's normally fine for ordinary modules which only branch to global exported functions, but Mark Brown points out [1] that this isn't guaranteed if the module branches between sections. Futhermore, livepatch modules use klp relocations to reference arbitrary kernel symbols, so with CONFIG_RANDOMIZE_MODULE_REGION_FULL the module is far enough from the kernel that every R_AARCH64_CALL26 needs a PLT.
Put Clang 21+ in the naughty corner alongside GCC, which suffers from the same issue, by disabling CONFIG_ARM64_BTI_KERNEL until we have a version of the toolchain with the problem resolved.
--- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -2116,6 +2116,8 @@ config ARM64_BTI_KERNEL depends on !CC_IS_GCC || GCC_VERSION >= 100100 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671 depends on !CC_IS_GCC + # https://github.com/llvm/llvm-project/issues/215547 + depends on !CC_IS_CLANG || CLANG_VERSION < 210000 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_ARGS) help Build the kernel with Branch Target Identification annotations
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1340/1815 s390/irqflags: Add out-of-line definitions of arch_local_irq_*() for KMSAN
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Leoshkevich <[email protected]>
[ Upstream commit 3f7c9f9c36b47a2a5cdbc56597eddf32662ef7fa ]
Inline KMSAN arch_local_irq_*() definitions run afoul of -Wstatic-in-inline. Move them out-of-line. Make sure decompressor and non-GPL modules see the out-of-line definitions.
--- arch/s390/include/asm/irqflags.h | 20 +++++++++++++------- arch/s390/kernel/Makefile | 1 + arch/s390/kernel/irqflags.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 arch/s390/kernel/irqflags.c
arch/s390/include/asm/irqflags.h +13 -7
@@ -37,18 +37,24 @@ static __always_inline void __arch_local_irq_ssm(unsigned long flags) asmvolatile ("ssm %0" : :"Q" (flags) :"memory" ); } -#ifdef CONFIG_KMSAN -#define arch_local_irq_attributes noinline notrace __no_sanitize_memory __maybe_unused +#if defined(CONFIG_KMSAN ) && !defined(__DECOMPRESSOR) +unsigned long arch_local_save_flags (void ); +unsigned long arch_local_irq_save (void ); +void arch_local_irq_enable_external (void ); +void arch_local_irq_enable (void );#else -#define arch_local_irq_attributes __always_inline +#define arch_local_save_flags __arch_local_save_flags +#define arch_local_irq_save __arch_local_irq_save +#define arch_local_irq_enable_external __arch_local_irq_enable_external +#define arch_local_irq_enable __arch_local_irq_enable#endif -static arch_local_irq_attributes unsigned long arch_local_save_flags (void ) +static __always_inline unsigned long __arch_local_save_flags (void ) {return __arch_local_irq_stnsm (0xff ); } -static arch_local_irq_attributes unsigned long arch_local_irq_save (void ) +static __always_inline unsigned long __arch_local_irq_save (void ) {return __arch_local_irq_stnsm (0xfc ); }
@@ -58,12 +64,12 @@ static __always_inline void arch_local_irq_disable(void)arch_local_irq_save (); } -static arch_local_irq_attributes void arch_local_irq_enable_external(void) +static __always_inline void __arch_local_irq_enable_external(void) {__arch_local_irq_stosm (0x01 ); } -static arch_local_irq_attributes void arch_local_irq_enable(void) +static __always_inline void __arch_local_irq_enable(void) {__arch_local_irq_stosm (0x03 ); }
arch/s390/kernel/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_STACKPROTECTOR) += stackprotector.o obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o obj-$(CONFIG_CERT_STORE) += cert_store.o +obj-$(CONFIG_KMSAN) += irqflags.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf.o perf_cpum_sf.o
arch/s390/kernel/irqflags.c new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/export.h> +#include <asm/irqflags.h> + +noinstr unsigned long arch_local_save_flags (void ) +{ +return __arch_local_save_flags (); +} +EXPORT_SYMBOL (arch_local_save_flags); + +noinstr unsigned long arch_local_irq_save (void ) +{ +return __arch_local_irq_save (); +} +EXPORT_SYMBOL (arch_local_irq_save); + +noinstr void arch_local_irq_enable_external(void) +{ +__arch_local_irq_enable_external (); +} +EXPORT_SYMBOL (arch_local_irq_enable_external); + +noinstr void arch_local_irq_enable(void) +{ +__arch_local_irq_enable (); +} +EXPORT_SYMBOL (arch_local_irq_enable);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1341/1815 nvmet: fix heap out-of-bounds read in nvmet_auth_negotiate()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 5bb96cc218835769ab74ec7f3ea2bf81fbffe955 ]
nvmet_execute_auth_send() allocates the DH-HMAC-CHAP message buffer with the host-supplied transfer length (tl) and hands it to nvmet_auth_negotiate() without passing tl along. nvmet_auth_negotiate() then reads the negotiate header and, for each of the halen hash identifiers and dhlen DH group identifiers, indexes into the fixed idlist[60] array (hashes at idlist[0..halen), groups at idlist[30..]).
Neither the transfer length nor halen/dhlen is validated. A malicious or non-conformant host can report a tl smaller than the negotiate structure, or a halen/dhlen larger than the array (both are u8, up to 255), making the loops read past the end of the allocated buffer (heap out-of-bounds read). The sibling nvmet_auth_reply() already validates tl against the structure size; the negotiate path did not.
Pass tl into nvmet_auth_negotiate(), reject a tl that does not cover the negotiate data plus one full protocol descriptor, and reject halen/dhlen larger than NVME_AUTH_DHCHAP_MAX_DH_IDS.
--- drivers/nvme/target/fabrics-cmd-auth.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +10 -2
@@ -30,12 +30,16 @@ void nvmet_auth_sq_init(struct nvmet_sq *sq) sq->dhchap_step =NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ; } -static u8 nvmet_auth_negotiate (struct nvmet_req *req,void *d) +static u8 nvmet_auth_negotiate (struct nvmet_req *req,void *d,u32 tl) {struct nvmet_ctrl *ctrl = req->sq->ctrl;struct nvmf_auth_dhchap_negotiate_data *data = d;int i, hash_id =0 , fallback_hash_id =0 , dhgid, fallback_dhgid; +if (tl <sizeof (*data) + +sizeof (struct nvmf_auth_dhchap_protocol_descriptor )) +return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD ; + pr_debug("%s: ctrl %d qid %d: data sc_d %d napd %d authid %d halen %d dhlen %d\n", __func__, ctrl->cntlid, req->sq->qid, data->sc_c, data->napd, data->auth_protocol[0].dhchap.authid,
@@ -71,6 +75,10 @@ static u8 nvmet_auth_negotiate(struct nvmet_req *req, void *d) NVME_AUTH_DHCHAP_AUTH_ID)return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD ; +if (data->auth_protocol[0 ].dhchap.dhlen >NVME_AUTH_DHCHAP_MAX_DH_IDS || + data->auth_protocol[0 ].dhchap.halen >NVME_AUTH_DHCHAP_MAX_HASH_IDS ) +return NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD ; +for (i =0 ; i < data->auth_protocol[0 ].dhchap.halen; i++) {u8 host_hmac_id = data->auth_protocol[0 ].dhchap.idlist[i];
@@ -316,7 +324,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req) }else if (data->auth_id != req->sq->dhchap_step) goto done_failure1;/* Validate negotiation parameters */ - dhchap_status =nvmet_auth_negotiate (req, d); + dhchap_status =nvmet_auth_negotiate (req, d, tl);if (dhchap_status ==0 ) req->sq->dhchap_step =NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1342/1815 nvme-apple: Destroy the admin queue on removal
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit 87d5b9864c8118d26f54de4b66d2bddf2c659272 ]
The admin queue is allocated with blk_mq_alloc_queue() but never destroyed. nvme_free_ctrl() only drops the last reference and blk_mq_exit_queue() and blk_sync_queue() never run: the hctx is never moved to q->unused_hctx_list and the timeout timer and work stay armed on a queue that is about to be freed which will eventually oops inside blk_mq_timeout_work().
This can only be triggered when the controller fails to come up and is then immediately torn down again which is why no one ever ran into this before.
Let's just copy what the pcie driver does: unquiesce and destroy the admin queue before nvme_uninit_ctrl().
With this the following WARN followed by a panic no longer happens:
WARNING: block/blk-mq.c:4390 at blk_mq_release+0x194/0x238, CPU#4: kworker/u34:4/119
CPU: 4 UID: 0 PID: 119 Comm: kworker/u34:4 Not tainted 7.2.0-rc1-dirty #248 PREEMPT
Hardware name: Apple Mac mini (M1, 2020) (DT)
Workqueue: nvme-wq apple_nvme_remove_dead_ctrl_work
pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
pc : blk_mq_release+0x194/0x238
lr : blk_mq_release+0x58/0x238
sp : ffffc000833a3b50
x29: ffffc000833a3b50 x28: ffff80001d0450f8 x27: ffff800020c95200
x26: 0000000000000088 x25: 0000000000000000 x24: ffff800020f36805
x23: 0000000000000000 x22: ffffc00081a86878 x21: ffff800020be9c60
x20: 0000000000000000 x19: ffff800022501698 x18: 000000000000000a
x17: 7365757165722066 x16: 666f7265776f7020 x15: 0000000000000000
x14: 0000000000000028 x13: 0000000000004def x12: 0000000000000003
x11: 0000000000000000 x10: 0000000000000000 x9 : ffffc000805b4fc8
x8 : ffffc00081915820 x7 : ffffc00081c4f3c8 x6 : 0000000000000001
x5 : 0000000000000004 x4 : ffff800022498d80 x3 : ffffc000833a3b14
x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff800022501698
Call trace:
blk_mq_release+0x194/0x238 (P)
blk_put_queue+0x8c/0xf0
nvme_free_ctrl+0x4c/0x260
device_release+0x44/0x128
kobject_put+0xa0/0x120
put_device+0x1c/0x40
nvme_uninit_ctrl+0x48/0x60
apple_nvme_remove+0x54/0xb0
platform_remove+0x28/0x40
device_remove+0x54/0x98
device_release_driver_internal+
device_release_driver+0x20/0x38
apple_nvme_remove_dead_ctrl_wor
process_one_work+0x1f4/0x770
worker_thread+0x1b8/0x360
kthread+0x140/0x160
ret_from_fork+0x10/0x20
irq event stamp: 448
hardirqs last enabled at (447):in_unlock_irqrestore+0x74/0x80
hardirqs last disabled at (448): [<ffffc000811cf5c0>] el1_brk64+0x20/0x60
softirqs last enabled at (0): [ess+0xb28/0x2698
softirqs last disabled at (0): [<0000000000000000>] 0x0
---[ end trace 0000000000000000
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
Mem abort info:
ESR = 0x0000000096000005
EC = 0x25: DABT (current EL),
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x05: level 1 translation fault
Data abort info:
ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagA
GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[0000000000000000] user address
Internal error: Oops: 0000000096000005 [#1] SMP
CPU: 7 UID: 0 PID: 54 Comm: kwor 7.2.0-rc1-dirty #248PREEMPT
Tainted: [W]=WARN
Hardware name: Apple Mac mini (M1, 2020) (DT)
Workqueue: kblockd blk_mq_timeou
pstate: 01400005 (nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
pc : percpu_ref_tryget_many.cons
lr : percpu_ref_tryget_many.constprop.0+0xc0/0x168
sp : ffffc000829cbce0
x29: ffffc000829cbce0 x28: ffff800020be9f48 x27: ffff800013e503c0
x26: 0000000000000108 x25: 000009c05
x23: 0000000000000000 x22: ffffc000819f5000 x21: ffff800020be9f48
x20: ffff8001deda4808 x19: ffff8000a
x17: 00000000580e1fac x16: ffffc00082bbbb7c x15: 0000000000000000
x14: 0000000000000028 x13: 000000001
x11: 0000000000000000 x10: 0000000000000000 x9 : ffffc000829cbc20
x8 : ffffc00081915820 x7 : ffffc0001
x5 : ffff80001ca77d08 x4 : 0000000000000000 x3 : ffff80001ca77cb8
x2 : 0000000000000000 x1 : 000000007
Call trace:
percpu_ref_tryget_many.constpro
blk_mq_timeout_work+0x48/0x298
process_one_work+0x1f4/0x770
worker_thread+0x1b8/0x360
kthread+0x140/0x160
ret_from_fork+0x10/0x20
Code: 91282000 97ed44b2 17ffffd2
---[ end trace 0000000000000000 ]------ drivers/nvme/host/apple.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/nvme/host/apple.c +9 -0
@@ -1652,6 +1652,15 @@ static void apple_nvme_remove(struct platform_device *pdev)nvme_stop_ctrl (&anv->ctrl);nvme_remove_namespaces (&anv->ctrl);apple_nvme_disable (anv, true); +if (anv->ctrl.admin_q && !blk_queue_dying (anv->ctrl.admin_q)) { +/* +* If the controller was reset during removal, it's possible +* user requests may be waiting on a stopped queue. Start the +* queue to flush these to completion. +*/ +nvme_unquiesce_admin_queue (&anv->ctrl); +blk_mq_destroy_queue (anv->ctrl.admin_q); + }nvme_uninit_ctrl (&anv->ctrl);if (apple_rtkit_is_running (anv->rtk)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1343/1815 nvme-apple: Dont set a DMA direction for commands without a data transfer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit 94dd5804938d6681dbf26f023b1356d511f4fc48 ]
Setting the DMA direction for commands that don't do any transfer likely triggered the PRP NULL check for which we needed a chicken bit. That bit has disappeared starting with macOS 15 so let's just do this correctly instead.
--- drivers/nvme/host/apple.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/apple.c +3 -1
@@ -341,7 +341,9 @@ static void apple_nvme_submit_cmd_t8103(struct apple_nvme_queue *q, tcb->length = cmd->rw.length; tcb->command_id = tag; -if (nvme_is_write (cmd)) +if (!cmd->common.dptr.prp1) + tcb->dma_flags =0 ; +else if (nvme_is_write (cmd)) tcb->dma_flags =APPLE_ANS_TCB_DMA_TO_DEVICE ;else tcb->dma_flags =APPLE_ANS_TCB_DMA_FROM_DEVICE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1326/1815 PCI: ultrarisc: Get and enable DP1000 PCIe controller clocks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit e152c295d32a15975c480c352000454b9eb5fb07 ]
Add the required core, dbi, and aux clocks for the DP1000 PCIe controller and enable them before initializing the controller.
Also manage the clocks across system suspend and resume.
--- drivers/pci/controller/dwc/pcie-ultrarisc.c | 85 +++++++++++++++++++-- 1 file changed, 78 insertions(+), 7 deletions(-)
drivers/pci/controller/dwc/pcie-ultrarisc.c +78 -7
@@ -5,6 +5,7 @@* Copyright (C) 2026 UltraRISC Technology (Shanghai) Co., Ltd. */ +#include <linux/clk.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of_device.h>
@@ -23,6 +24,12 @@#define ULTRARISC_PCIE_COMP_TIMEOUT_65_210MS 0x6 +struct ultrarisc_pcie { +struct dw_pcie pci; +struct clk_bulk_data *clks; +int num_clks; +}; +static struct pci_ops ultrarisc_pci_ops = { .map_bus = dw_pcie_own_conf_map_bus, .read = pci_generic_config_read32,
@@ -98,17 +105,47 @@ static const struct dw_pcie_ops dw_pcie_ops = { .start_link = ultrarisc_pcie_start_link, }; +static int ultrarisc_pcie_enable_clks (struct ultrarisc_pcie *ultra) +{ +return clk_bulk_prepare_enable (ultra->num_clks, ultra->clks); +} + +static void ultrarisc_pcie_disable_clks (void *data) +{ +struct ultrarisc_pcie *ultra = data; + +clk_bulk_disable_unprepare (ultra->num_clks, ultra->clks); +} + +static int ultrarisc_pcie_init_clks (struct ultrarisc_pcie *ultra) +{ +struct device *dev = ultra->pci.dev; +int ret; + + ultra->num_clks =devm_clk_bulk_get_all (dev, &ultra->clks); +if (ultra->num_clks <0 ) +return dev_err_probe (dev, ultra->num_clks,"Failed to get clocks\n" ); + + ret =ultrarisc_pcie_enable_clks (ultra); +if (ret) +return dev_err_probe (dev, ret,"Failed to enable clocks\n" ); + +return devm_add_action_or_reset (dev, ultrarisc_pcie_disable_clks, ultra); +} +static int ultrarisc_pcie_probe (struct platform_device *pdev) { +struct ultrarisc_pcie *ultra;struct device *dev = &pdev->dev;struct dw_pcie_rp *pp;struct dw_pcie *pci;int ret; - pci =devm_kzalloc (dev,sizeof (*pci),GFP_KERNEL ); -if (!pci) + ultra =devm_kzalloc (dev,sizeof (*ultra),GFP_KERNEL ); +if (!ultra)return -ENOMEM ; + pci = &ultra->pci; pci->dev = dev; pci->ops = &dw_pcie_ops;
@@ -117,7 +154,11 @@ static int ultrarisc_pcie_probe(struct platform_device *pdev) pp = &pci->pp; -platform_set_drvdata (pdev, pci); +platform_set_drvdata (pdev, ultra); + + ret =ultrarisc_pcie_init_clks (ultra); +if (ret) +return ret; pp->num_vectors =MAX_MSI_IRQS ;/* No L2/L3 Ready indication is available on this platform */
@@ -135,16 +176,46 @@ static int ultrarisc_pcie_probe(struct platform_device *pdev)static int ultrarisc_pcie_suspend_noirq (struct device *dev) { -struct dw_pcie *pci =dev_get_drvdata (dev); +struct ultrarisc_pcie *ultra =dev_get_drvdata (dev); +struct dw_pcie *pci = &ultra->pci; +int ret; + +/* +* A failed resume leaves the DWC suspended and the clocks disabled. +* A later suspend must not access the controller or disable them again. +*/ +if (pci->suspended) +return 0 ; + + ret =dw_pcie_suspend_noirq (pci); +if (ret) +return ret; + +if (pci->suspended) +ultrarisc_pcie_disable_clks (ultra); -return dw_pcie_suspend_noirq (pci); +return 0 ; }static int ultrarisc_pcie_resume_noirq (struct device *dev) { -struct dw_pcie *pci =dev_get_drvdata (dev); +struct ultrarisc_pcie *ultra =dev_get_drvdata (dev); +struct dw_pcie *pci = &ultra->pci; +int ret; -return dw_pcie_resume_noirq (pci); +if (pci->suspended) { + ret =ultrarisc_pcie_enable_clks (ultra); +if (ret) +return ret; + + ret =dw_pcie_resume_noirq (pci); +if (ret) { +ultrarisc_pcie_disable_clks (ultra); +return ret; + } + } + +return 0 ; }static const struct dev_pm_ops ultrarisc_pcie_pm_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1344/1815 nvme-apple: Never set the opcode in the NVMMU TCB
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit cc0fec9b42cfbc69d70cb4c4b616408a7037b445 ]
macOS always sets this to zero and the firmware starting with macOS 15 has started to complain about what we're doing here.
--- drivers/nvme/host/apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/apple.c +1 -1
@@ -335,7 +335,7 @@ static void apple_nvme_submit_cmd_t8103(struct apple_nvme_queue *q,u32 tag =nvme_tag_from_cid (cmd->common.command_id);struct apple_nvmmu_tcb *tcb = &q->tcbs[tag]; - tcb->opcode = cmd->common.opcode; + tcb->opcode =0 ; tcb->prp1 = cmd->common.dptr.prp1; tcb->prp2 = cmd->common.dptr.prp2; tcb->length = cmd->rw.length;
Signature · 1 line
2.53.0
Re: [PATCH 7.2 1226/1815] btrfs: fix a lockdep caused by path resolution during device scan
In reply to Greg Kroah-HartmanQuoted 1 line · Greg Kroah-Hartman
7.2-stable review patch. If anyone has any objections, please let me know.
Please drop this one.
There are already users (although the minority of users) who do not use an initramfs to boot, and the device path of rootfs stays as "/dev/root".
With this patch, there will be no way to update the "/dev/root" name of the rootfs.
Normally it is just a cosmetic problem, but tools like grub2 will be unable to probe the driver for the rootfs.
I'd argue we should discourage root btrfs without an initramfs, and grub2 should use device number/libblkid to properly detect rootfs devices, but still there are users complaining.
There will be a special hot fix for it, but I'd prefer to at least delay this one.
The deadlock itself is not easy to trigger, it requires block device files created on btrfs, and doing block device scan on that file over btrfs.
Thanks,
Qu
Quoted 241 lines
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit
108cc873398932af589c295f78c348513b8d70d9][BUG]
There is a lockdep report related to device scan:======================================================
WARNING: possible circular locking dependency detected 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 Not tainted
------------------------------------------------------
(udev-worker)/1653 is trying to acquire lock:
0000006919232220 (&type->i_mutex_dir_key#2){++++}-{3:3}, at:lookup_slow+0x3e/0x70
but task is already holding lock:00000069238564d8(&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60 which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #5 (&fs_devs->device_list_mutex){+.+.}-{3:3}:lock_acquire+0x150/0x3f0 __mutex_lock+0xba/0xdc0 mutex_lock_nested+0x32/0x40 write_all_supers+0x7a/0x670 btrfs_sync_log+0xae6/0xdd0 btrfs_sync_file+0x4fa/0x7a0 __s390x_sys_fsync+0x52/0xa0 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #4 (&fs_info->tree_log_mutex){+.+.}-{3:3}: lock_acquire+0x150/0x3f0 __mutex_lock+0xba/0xdc0 mutex_lock_nested+0x32/0x40 btrfs_sync_log+0xaba/0xdd0 btrfs_sync_file+0x4fa/0x7a0 __s390x_sys_fsync+0x52/0xa0 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #3 (btrfs_trans_num_extwriters){.+.+}-{0:0}: lock_acquire+0x150/0x3f0 join_transaction+0x108/0x680 start_transaction+0x21a/0x660 btrfs_join_transaction+0x32/0x40 btrfs_dirty_inode+0x52/0xf0 touch_atime+0x90/0xc0 filemap_read+0x446/0x450 vfs_read+0x208/0x370 ksys_read+0x88/0x120 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #2 (btrfs_trans_num_writers){.+.+}-{0:0}: reacquire_held_locks+0x14c/0x240 __lock_release.isra.0+0xd8/0x380 lock_release+0xf6/0x270 percpu_up_read+0x28/0xf0 __btrfs_end_transaction+0x178/0x1f0 btrfs_dirty_inode+0x82/0xf0 touch_atime+0x90/0xc0 btrfs_file_mmap_prepare+0x8c/0xa0 __mmap_region+0x214/0x780 mmap_region+0x108/0x160 do_mmap+0x402/0x5a0 vm_mmap_pgoff+0x156/0x230 ksys_mmap_pgoff+0x17e/0x220 __s390x_sys_old_mmap+0xa8/0x140 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #1 (&mm->mmap_lock){++++}-{3:3}: lock_acquire+0x150/0x3f0 __might_fault+0x7a/0xa0 filldir64+0x11c/0x210 offset_readdir+0x92/0x200 iterate_dir+0xcc/0x2d0 __do_sys_getdents64+0x7a/0x130 __do_syscall+0x172/0x750 system_call+0x72/0x90 -> #0 (&type->i_mutex_dir_key#2){++++}-{3:3}: check_prev_add+0x160/0xf40 __lock_acquire+0x12aa/0x15a0 lock_acquire+0x150/0x3f0 down_read+0x5a/0x280 lookup_slow+0x3e/0x70 path_lookupat+0x1f0/0x370 filename_lookup+0xce/0x1f0 kern_path+0x48/0x70 is_same_device+0x146/0x300 device_list_add.constprop.0+0x1be/0xc60 btrfs_scan_one_device+0x13a/0x2f0 btrfs_control_ioctl+0x110/0x1e0 __s390x_sys_ioctl+0xfa/0x130 __do_syscall+0x172/0x750 system_call+0x72/0x90 other info that might help us debug this: Chain exists of: &type->i_mutex_dir_key#2 --> &fs_info->tree_log_mutex --> &fs_devs->device_list_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&fs_devs->device_list_mutex); lock(&fs_info->tree_log_mutex); lock(&fs_devs->device_list_mutex); rlock(&type->i_mutex_dir_key#2); *** DEADLOCK *** 2 locks held by (udev-worker)/1653: #0: 0000016c727051c8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_control_ioctl+0x102/0x1e0 #1: 00000069238564d8 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add.constprop.0+0x148/0xc60 stack backtrace: CPU: 2 UID: 0 PID: 1653 Comm: (udev-worker) Not tainted 7.2.0-20260712.rc2.git0.e3321fa3034d.300.fc44.s390x+debug #1 PREEMPT Hardware name: IBM 3931 A01 701 (LPAR) Call Trace: [<0000016c70680e3e>] dump_stack_lvl+0xae/0x108 [<0000016c7078aa44>] print_circular_bug+0x1a4/0x230 [<0000016c7078ac5c>] check_noncircular+0x18c/0x1b0 [<0000016c7078c030>] check_prev_add+0x160/0xf40 [<0000016c7078fbaa>] __lock_acquire+0x12aa/0x15a0 [<0000016c7078fff0>] lock_acquire+0x150/0x3f0 [<0000016c7180e2fa>] down_read+0x5a/0x280 [<0000016c70b88dde>] lookup_slow+0x3e/0x70 [<0000016c70b8f5d0>] path_lookupat+0x1f0/0x370 [<0000016c70b900ae>] filename_lookup+0xce/0x1f0 [<0000016c70b90218>] kern_path+0x48/0x70 [<0000016c70f5b4a6>] is_same_device+0x146/0x300 [<0000016c70f67cfe>] device_list_add.constprop.0+0x1be/0xc60 [<0000016c70f688da>] btrfs_scan_one_device+0x13a/0x2f0 [<0000016c70ed9cb0>] btrfs_control_ioctl+0x110/0x1e0 [<0000016c70b97d0a>] __s390x_sys_ioctl+0xfa/0x130 [<0000016c718004d2>] __do_syscall+0x172/0x750 [<0000016c718155d2>] system_call+0x72/0x90[CAUSE]
Btrfs device scan will callis_same_device()withdevice_list_mutexheld. Butis_same_device()will callkern_path()which will do path resolution and lock the inode.So device scan has the following lock sequence:
mutex_lock(device_list_mutex)fromdevice_list_add()| v
inode_lock_shared()fromlookup_slow()duringkern_path().Meanwhile another thread is fsyncing, which has the following lock sequence:
inode_lock()frombtrfs_inode_lock()insidebtrfs_direct_write()| v mutex_lock(tree_log_mutex() from btrfs_sync_log(), which is further triggered from iomap_dio_complete()->generic_write_sync()->btrfs_sync_file(). | v
mutex_lock(device_list_mutex)fromwrite_all_supers()insidebtrfs_sync_log().So the device scan has a reversed lock sequence, compared to the fsync one, this means we can have the following deadlock:
Device scan | Fsync
----------------------------------------+--------------------------------
device_list_mutexlocked |
| inode locked
| try to lockdevice_list_mutex
try to lock inode |[FIX]
Instead of a full path lookup, usedev_tto determine if two device paths are pointing to the same block device.Inside kernel
dev_tis going to uniquely determine a block device, and the device path lookup is already done bylookup_bdev(), which is done withoutdevice_list_mutexheld, thus no reversed locking sequence.Reported-by Christian Borntraeger <[email protected]>Fixes 2e8b6bc0ab41 ("btrfs: avoid unnecessary device path update for the same device")Reviewed-by Filipe Manana <[email protected]>Signed-off-by Qu Wenruo <[email protected]>Signed-off-by David Sterba <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/btrfs/volumes.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)fs/btrfs/volumes.c +1
-36@@ -740,41 +740,6 @@ const u8 *btrfs_sb_fsid_ptr(const struct btrfs_super_block *sb)return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; } -static bool is_same_device (struct btrfs_device *device,const char *new_path) -{ -struct path old = { .mnt =NULL , .dentry =NULL }; -struct path new = { .mnt =NULL , .dentry =NULL }; -char AUTO_KFREE (old_path ); -bool is_same = false; -int ret; - -if (!device->name) - goto out; - - old_path =kzalloc (PATH_MAX ,GFP_NOFS ); -if (!old_path) - goto out; - -rcu_read_lock (); - ret =strscpy (old_path,rcu_dereference (device->name),PATH_MAX ); -rcu_read_unlock (); -if (ret <0 ) - goto out; - - ret =kern_path (old_path,LOOKUP_FOLLOW , &old); -if (ret) - goto out; - ret =kern_path (new_path,LOOKUP_FOLLOW , &new); -if (ret) - goto out; -if (path_equal (&old, &new)) - is_same = true; -out: -path_put (&old); -path_put (&new); -return is_same; -} -/* * Add new device to list of registered devices * @@ -895,7 +860,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,MAJOR (path_devt),MINOR (path_devt), current->comm, task_pid_nr(current)); - }else if (!device->name || !is_same_device (device, path)) { + }else if (!device->name || device->devt != path_devt) {const char *old_name;/*
Greg Kroah-Hartman
maintainerPATCH 1345/1815 nvme: Add a quirk for page aligned admin queue buffers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Peter <[email protected]>
[ Upstream commit 69d22a6b2f6984200d92dac689f8b00cc3d7d736 ]
Apple controllers seem to require any queue buffers on the admin queue to be aligned to the NVMe controller page size. Weirdly, this constraint does not apply to the i/o queue where any alignment is fine. This has always been required on pre-M1 controllers and is required starting with macOS 15 firmware or post-M4 controllers again. On M1/M2/M3 we only got away with this because there was a chicken bit to disable this requirement. Let's add a quirk that enforces this alignment.
Stable-dep-of: ea2160c7b781 ("nvme-apple: Require page aligned buffers on the admin queue")
--- drivers/nvme/host/core.c | 5 ++++- drivers/nvme/host/nvme.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +4 -1
@@ -2071,7 +2071,10 @@ static void nvme_set_ctrl_limits(struct nvme_ctrl *ctrl, lim->max_integrity_segments = ctrl->max_integrity_segments; lim->virt_boundary_mask = ctrl->ops->get_virt_boundary (ctrl, is_admin); lim->max_segment_size =UINT_MAX ; - lim->dma_alignment =3 ; +if (is_admin && (ctrl->quirks &NVME_QUIRK_ADMIN_PAGE_ALIGN )) + lim->dma_alignment =NVME_CTRL_PAGE_SIZE -1 ; +else + lim->dma_alignment =3 ; } static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
drivers/nvme/host/nvme.h +7 -0
@@ -178,6 +178,11 @@ enum nvme_quirks {* Align dma pool segment size to 512 bytes */ NVME_QUIRK_DMAPOOL_ALIGN_512 = (1 <<22 ), + +/* +* Admin queue DMA buffers must be page aligned +*/ + NVME_QUIRK_ADMIN_PAGE_ALIGN = (1 << 23), };static inline char *nvme_quirk_name (enum nvme_quirks q)
@@ -229,6 +234,8 @@ static inline char *nvme_quirk_name(enum nvme_quirks q)return "broken_msi" ;case NVME_QUIRK_DMAPOOL_ALIGN_512 :return "dmapool_align_512" ; +case NVME_QUIRK_ADMIN_PAGE_ALIGN : +return "admin_page_align" ; }return "unknown" ;
Signature · 1 line
2.53.0