6.10.14-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 246/482 ksmbd: add refcnt to ksmbd_conn struct
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit ee426bfb9d09b29987369b897fe9b6485ac2be27 ]
When sending an oplock break request, opinfo->conn is used, But freed ->conn can be used on multichannel.
This patch add a reference count to the ksmbd_conn struct so that it can be freed when it is no longer used.
--- fs/smb/server/connection.c | 4 ++- fs/smb/server/connection.h | 1 + fs/smb/server/oplock.c | 55 +++++++++++--------------------------- fs/smb/server/vfs_cache.c | 3 +++ 4 files changed, 23 insertions(+), 40 deletions(-)
fs/smb/server/connection.c +3 -1
@@ -39,7 +39,8 @@ void ksmbd_conn_free(struct ksmbd_conn *conn)xa_destroy (&conn->sessions);kvfree (conn->request_buf);kfree (conn->preauth_info); -kfree (conn); +if (atomic_dec_and_test (&conn->refcnt)) +kfree (conn); }/**
@@ -68,6 +69,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void) conn->um =NULL ;atomic_set (&conn->req_running,0 );atomic_set (&conn->r_count,0 ); +atomic_set (&conn->refcnt,1 ); conn->total_credits =1 ; conn->outstanding_credits =0 ;
fs/smb/server/connection.h +1 -0
@@ -106,6 +106,7 @@ struct ksmbd_conn {bool signing_negotiated;__le16 signing_algorithm;bool binding; +atomic_t refcnt; };struct ksmbd_conn_ops {
fs/smb/server/oplock.c +16 -39
148 lines not on this page · raw message
fs/smb/server/vfs_cache.c +3 -0
@@ -710,6 +710,8 @@ static bool session_fd_check(struct ksmbd_tree_connect *tcon,list_for_each_entry_rcu (op, &ci->m_op_list, op_entry) {if (op->conn != conn)continue ; +if (op->conn &&atomic_dec_and_test (&op->conn->refcnt)) +kfree (op->conn); op->conn =NULL ; }up_write (&ci->m_lock);
@@ -807,6 +809,7 @@ int ksmbd_reopen_durable_fd(struct ksmbd_work *work, struct ksmbd_file *fp)if (op->conn)continue ; op->conn = fp->conn; +atomic_inc (&op->conn->refcnt); }up_write (&ci->m_lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 247/482 platform/mellanox: mlxbf-pmc: fix lockdep warning
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Capitulino <[email protected]>
[ Upstream commit 305790dd91057a3f7497c9d128614a4f8486b62b ]
It seems the mlxbf-pmc driver is missing initializing sysfs attributes which causes the warning below when CONFIG_LOCKDEP and CONFIG_DEBUG_LOCK_ALLOC are enabled. This commit fixes it.
[ 155.380843] BUG: key ffff470f45dfa6d8 has not been registered! [ 155.386749] ------------[ cut here ]------------ [ 155.391361] DEBUG_LOCKS_WARN_ON(1) [ 155.391381] WARNING: CPU: 4 PID: 1828 at kernel/locking/lockdep.c:4894 lockdep_init_map_type+0x1d0/0x288 [ 155.404254] Modules linked in: mlxbf_pmc(+) xfs libcrc32c mmc_block mlx5_core crct10dif_ce mlxfw ghash_ce virtio_net tls net_failover sha2 _ce failover psample sha256_arm64 dw_mmc_bluefield pci_hyperv_intf sha1_ce dw_mmc_pltfm sbsa_gwdt dw_mmc micrel mmc_core nfit i2c_mlxbf pwr_m lxbf gpio_generic libnvdimm mlxbf_tmfifo mlxbf_gige dm_mirror dm_region_hash dm_log dm_mod [ 155.436786] CPU: 4 UID: 0 PID: 1828 Comm: modprobe Kdump: loaded Not tainted 6.11.0-rc7-rep1+ #1 [ 155.445562] Hardware name: https://www.mellanox.com BlueField SoC/BlueField SoC, BIOS 4.8.0.13249 Aug 7 2024 [ 155.455463] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 155.462413] pc : lockdep_init_map_type+0x1d0/0x288 [ 155.467196] lr : lockdep_init_map_type+0x1d0/0x288 [ 155.471976] sp : ffff80008a1734e0 [ 155.475279] x29: ffff80008a1734e0 x28: ffff470f45df0240 x27: 00000000ffffee4b [ 155.482406] x26: 00000000000011b4 x25: 0000000000000000 x24: 0000000000000000 [ 155.489532] x23: ffff470f45dfa6d8 x22: 0000000000000000 x21: ffffd54ef6bea000 [ 155.496659] x20: ffff470f45dfa6d8 x19: ffff470f49cdc638 x18: ffffffffffffffff [ 155.503784] x17: 2f30303a31444642 x16: ffffd54ef48a65e8 x15: ffff80010a172fe7 [ 155.510911] x14: 0000000000000000 x13: 284e4f5f4e524157 x12: 5f534b434f4c5f47 [ 155.518037] x11: 0000000000000001 x10: 0000000000000001 x9 : ffffd54ef3f48a14 [ 155.525163] x8 : 00000000000bffe8 x7 : c0000000ffff7fff x6 : 00000000002bffa8 [ 155.532289] x5 : ffff4712bdcb6088 x4 : 0000000000000000 x3 : 0000000000000027 [ 155.539416] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff470f43e5be00 [ 155.546542] Call trace: [ 155.548976] lockdep_init_map_type+0x1d0/0x288 [ 155.553410] __kernfs_create_file+0x80/0x138 [ 155.557673] sysfs_add_file_mode_ns+0x94/0x150 [ 155.562106] create_files+0xb0/0x248 [ 155.565672] internal_create_group+0x10c/0x328 [ 155.570105] internal_create_groups.part.0+0x50/0xc8 [ 155.575060] sysfs_create_groups+0x20/0x38 [ 155.579146] device_add_attrs+0x1b8/0x228 [ 155.583146] device_add+0x2a4/0x690 [ 155.586625] device_register+0x24/0x38 [ 155.590362] __hwmon_device_register+0x1e0/0x3c8 [ 155.594969] devm_hwmon_device_register_with_groups+0x78/0xe0 [ 155.600703] mlxbf_pmc_probe+0x224/0x3a0 [mlxbf_pmc] [ 155.605669] platform_probe+0x6c/0xe0 [ 155.609320] really_probe+0xc4/0x398 [ 155.612887] __driver_probe_device+0x80/0x168 [ 155.617233] driver_probe_device+0x44/0x120 [ 155.621405] __driver_attach+0xf4/0x200 [ 155.625230] bus_for_each_dev+0x7c/0xe8 [ 155.629055] driver_attach+0x28/0x38 [ 155.632619] bus_add_driver+0x110/0x238 [ 155.636445] driver_register+0x64/0x128 [ 155.640270] __platform_driver_register+0x2c/0x40 [ 155.644965] pmc_driver_init+0x24/0xff8 [mlxbf_pmc] [ 155.649833] do_one_initcall+0x70/0x3d0 [ 155.653660] do_init_module+0x64/0x220 [ 155.657400] load_module+0x628/0x6a8 [ 155.660964] init_module_from_file+0x8c/0xd8 [ 155.665222] idempotent_init_module+0x194/0x290 [ 155.669742] __arm64_sys_finit_module+0x6c/0xd8 [ 155.674261] invoke_syscall.constprop.0+0x74/0xd0 [ 155.678957] do_el0_svc+0xb4/0xd0 [ 155.682262] el0_svc+0x5c/0x248 [ 155.685394] el0t_64_sync_handler+0x134/0x150 [ 155.689739] el0t_64_sync+0x17c/0x180 [ 155.693390] irq event stamp: 6407 [ 155.696693] hardirqs last enabled at (6407): [<ffffd54ef3f48564>] console_unlock+0x154/0x1b8 [ 155.705207] hardirqs last disabled at (6406): [<ffffd54ef3f485ac>] console_unlock+0x19c/0x1b8 [ 155.713719] softirqs last enabled at (6404): [<ffffd54ef3e9740c>] handle_softirqs+0x4f4/0x518 [ 155.722320] softirqs last disabled at (6395): [<ffffd54ef3df0160>] __do_softirq+0x18/0x20 [ 155.730484] ---[ end trace 0000000000000000 ]---
--- drivers/platform/mellanox/mlxbf-pmc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/platform/mellanox/mlxbf-pmc.c +5 -0
@@ -1774,6 +1774,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_/* "event_list" sysfs to list events supported by the block */ attr = &pmc->block[blk_num].attr_event_list; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0444 ; attr->dev_attr.show = mlxbf_pmc_event_list_show; attr->nr = blk_num;
@@ -1787,6 +1788,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_if (strstr (pmc->block_name[blk_num],"l3cache" ) || ((pmc->block[blk_num].type ==MLXBF_PMC_TYPE_CRSPACE ))) { attr = &pmc->block[blk_num].attr_enable; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_enable_show; attr->dev_attr.store = mlxbf_pmc_enable_store;
@@ -1814,6 +1816,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_/* "eventX" and "counterX" sysfs to program and read counter values */ for (j =0 ; j < pmc->block[blk_num].counters; ++j) { attr = &pmc->block[blk_num].attr_counter[j]; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_counter_show; attr->dev_attr.store = mlxbf_pmc_counter_store;
@@ -1826,6 +1829,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_ attr =NULL ; attr = &pmc->block[blk_num].attr_event[j]; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_event_show; attr->dev_attr.store = mlxbf_pmc_event_store;
@@ -1861,6 +1865,7 @@ static int mlxbf_pmc_init_perftype_reg(struct device *dev, unsigned int blk_num)while (count >0 ) { --count; attr = &pmc->block[blk_num].attr_event[count]; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_counter_show; attr->dev_attr.store = mlxbf_pmc_counter_store;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 248/482 platform/x86: x86-android-tablets: Adjust Xiaomi Pad 2 bottom bezel touch buttons LED
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit df40a23cc34c200cfde559eda7ca540f3ae7bd9e ]
The "input-events" LED trigger used to turn on the backlight LEDs had to be rewritten to use led_trigger_register_simple() + led_trigger_event() to fix a serious locking issue.
This means it no longer supports using blink_brightness to set a per LED brightness for the trigger and it no longer sets LED_CORE_SUSPENDRESUME.
Adjust the MiPad 2 bottom bezel touch buttons LED class device to match:
1. Make LED_FULL the maximum brightness to fix the LED brightness being very low when on.
2. Set flags = LED_CORE_SUSPENDRESUME.
--- drivers/platform/x86/x86-android-tablets/other.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/x86/x86-android-tablets/other.c +5 -5
@@ -670,7 +670,7 @@ static const struct software_node *ktd2026_node_group[] = {* is controlled by the "pwm_soc_lpss_2" PWM output. */ #define XIAOMI_MIPAD2_LED_PERIOD_NS 19200 -#define XIAOMI_MIPAD2_LED_DEFAULT_DUTY 6000/* From Android kernel */ +#define XIAOMI_MIPAD2_LED_MAX_DUTY_NS 6000/* From Android kernel */ static struct pwm_device *xiaomi_mipad2_led_pwm;
@@ -679,7 +679,7 @@ static int xiaomi_mipad2_brightness_set(struct led_classdev *led_cdev, {struct pwm_state state = { .period =XIAOMI_MIPAD2_LED_PERIOD_NS , - .duty_cycle = val, + .duty_cycle =XIAOMI_MIPAD2_LED_MAX_DUTY_NS * val /LED_FULL ,/* Always set PWM enabled to avoid the pin floating */ .enabled = true, };
@@ -701,11 +701,11 @@ static int __init xiaomi_mipad2_init(struct device *dev)return -ENOMEM ; led_cdev->name ="mipad2:white:touch-buttons-backlight" ; - led_cdev->max_brightness =XIAOMI_MIPAD2_LED_PERIOD_NS ; -/* "input-events" trigger uses blink_brightness */ - led_cdev->blink_brightness =XIAOMI_MIPAD2_LED_DEFAULT_DUTY ; + led_cdev->max_brightness =LED_FULL ; led_cdev->default_trigger ="input-events" ; led_cdev->brightness_set_blocking = xiaomi_mipad2_brightness_set; +/* Turn LED off during suspend */ + led_cdev->flags =LED_CORE_SUSPENDRESUME ; ret =devm_led_classdev_register (dev, led_cdev);if (ret)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 249/482 ext4: dont set SB_RDONLY after filesystem errors
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit d3476f3dad4ad68ae5f6b008ea6591d1520da5d8 ]
When the filesystem is mounted with errors=remount-ro, we were setting SB_RDONLY flag to stop all filesystem modifications. We knew this misses proper locking (sb->s_umount) and does not go through proper filesystem remount procedure but it has been the way this worked since early ext2 days and it was good enough for catastrophic situation damage mitigation. Recently, syzbot has found a way (see link) to trigger warnings in filesystem freezing because the code got confused by SB_RDONLY changing under its hands. Since these days we set EXT4_FLAGS_SHUTDOWN on the superblock which is enough to stop all filesystem modifications, modifying SB_RDONLY shouldn't be needed. So stop doing that.
--- fs/ext4/super.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/ext4/super.c +5 -4
@@ -735,11 +735,12 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,ext4_msg (sb,KERN_CRIT ,"Remounting filesystem read-only" );/* -* Make sure updated value of ->s_mount_flags will be visible before -* ->s_flags update +* EXT4_FLAGS_SHUTDOWN was set which stops all filesystem +* modifications. We don't set SB_RDONLY because that requires +* sb->s_umount semaphore and setting it without proper remount +* procedure is confusing code such as freeze_super() leading to +* deadlocks and other problems. */ -smp_wmb (); - sb->s_flags |=SB_RDONLY ; }static void update_super_work (struct work_struct *work)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 250/482 bpf: Make the pointer returned by iter next method valid
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juntong Deng <[email protected]>
[ Upstream commit 4cc8c50c9abcb2646a7a4fcef3cea5dcb30c06cf ]
Currently we cannot pass the pointer returned by iter next method as argument to KF_TRUSTED_ARGS or KF_RCU kfuncs, because the pointer returned by iter next method is not "valid".
This patch sets the pointer returned by iter next method to be valid.
This is based on the fact that if the iterator is implemented correctly, then the pointer returned from the iter next method should be valid.
This does not make NULL pointer valid. If the iter next method has KF_RET_NULL flag, then the verifier will ask the ebpf program to check NULL pointer.
KF_RCU_PROTECTED iterator is a special case, the pointer returned by iter next method should only be valid within RCU critical section, so it should be with MEM_RCU, not PTR_TRUSTED.
Another special case is bpf_iter_num_next, which returns a pointer with base type PTR_TO_MEM. PTR_TO_MEM should not be combined with type flag PTR_TRUSTED (PTR_TO_MEM already means the pointer is valid).
The pointer returned by iter next method of other types of iterators is with PTR_TRUSTED.
In addition, this patch adds get_iter_from_state to help us get the current iterator from the current state.
--- kernel/bpf/verifier.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
kernel/bpf/verifier.c +22 -4
@@ -8017,6 +8017,15 @@ static int widen_imprecise_scalars(struct bpf_verifier_env *env,return 0 ; } +static struct bpf_reg_state *get_iter_from_state (struct bpf_verifier_state *cur_st, +struct bpf_kfunc_call_arg_meta *meta) +{ +int iter_frameno = meta->iter.frameno; +int iter_spi = meta->iter.spi; + +return &cur_st->frame[iter_frameno]->stack[iter_spi].spilled_ptr; +} +/* process_iter_next_call() is called when verifier gets to iterator's next * "method" (e.g., bpf_iter_num_next() for numbers iterator) call. We'll refer * to it as just "iter_next()" in comments below.
@@ -8101,12 +8110,10 @@ static int process_iter_next_call(struct bpf_verifier_env *env, int insn_idx,struct bpf_verifier_state *cur_st = env->cur_state, *queued_st, *prev_st;struct bpf_func_state *cur_fr = cur_st->frame[cur_st->curframe], *queued_fr;struct bpf_reg_state *cur_iter, *queued_iter; -int iter_frameno = meta->iter.frameno; -int iter_spi = meta->iter.spi;BTF_TYPE_EMIT (struct bpf_iter ); - cur_iter = &env->cur_state->frame[iter_frameno]->stack[iter_spi].spilled_ptr; + cur_iter =get_iter_from_state (cur_st, meta);if (cur_iter->iter.state !=BPF_ITER_STATE_ACTIVE && cur_iter->iter.state !=BPF_ITER_STATE_DRAINED ) {
@@ -8134,7 +8141,7 @@ static int process_iter_next_call(struct bpf_verifier_env *env, int insn_idx,if (!queued_st)return -ENOMEM ; - queued_iter = &queued_st->frame[iter_frameno]->stack[iter_spi].spilled_ptr; + queued_iter =get_iter_from_state (queued_st, meta); queued_iter->iter.state =BPF_ITER_STATE_ACTIVE ; queued_iter->iter.depth++;if (prev_st)
@@ -12675,6 +12682,17 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn, regs[BPF_REG_0 ].btf = desc_btf; regs[BPF_REG_0 ].type =PTR_TO_BTF_ID ; regs[BPF_REG_0 ].btf_id = ptr_type_id; + +if (is_iter_next_kfunc (&meta)) { +struct bpf_reg_state *cur_iter; + + cur_iter =get_iter_from_state (env->cur_state, &meta); + +if (cur_iter->type &MEM_RCU )/* KF_RCU_PROTECTED */ + regs[BPF_REG_0 ].type |=MEM_RCU ; +else + regs[BPF_REG_0 ].type |=PTR_TRUSTED ; + } }if (is_kfunc_ret_null (&meta)) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 251/482 ext4: ext4_search_dir should return a proper error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit cd69f8f9de280e331c9e6ff689ced0a688a9ce8f ]
ext4_search_dir currently returns -1 in case of a failure, while it returns 0 when the name is not found. In such failure cases, it should return an error code instead.
This becomes even more important when ext4_find_inline_entry returns an error code as well in the next commit.
-EFSCORRUPTED seems appropriate as such error code as these failures would be caused by unexpected record lengths and is in line with other instances of ext4_check_dir_entry failures.
In the case of ext4_dx_find_entry, the current use of ERR_BAD_DX_DIR was left as is to reduce the risk of regressions.
--- fs/ext4/namei.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/ext4/namei.c +7 -5
@@ -1526,7 +1526,7 @@ static bool ext4_match(struct inode *parent, }/* -* Returns 0 if not found, -1 on failure, and 1 on success +* Returns 0 if not found, -EFSCORRUPTED on failure, and 1 on success */ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, struct inode *dir, struct ext4_filename *fname,
@@ -1547,7 +1547,7 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,* a full check */ if (ext4_check_dir_entry (dir,NULL , de, bh, search_buf, buf_size, offset)) -return -1 ; +return -EFSCORRUPTED ; *res_dir = de;return 1 ; }
@@ -1555,7 +1555,7 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, de_len =ext4_rec_len_from_disk (de->rec_len, dir->i_sb->s_blocksize);if (de_len <=0 ) -return -1 ; +return -EFSCORRUPTED ; offset += de_len; de = (struct ext4_dir_entry_2 *) ((char *) de + de_len); }
@@ -1707,8 +1707,10 @@ static struct buffer_head *__ext4_find_entry(struct inode *dir, goto cleanup_and_exit; }else {brelse (bh); -if (i <0 ) +if (i <0 ) { + ret =ERR_PTR (i); goto cleanup_and_exit; + } } next:if (++block >= nblocks)
@@ -1802,7 +1804,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir,if (retval ==1 ) goto success;brelse (bh); -if (retval ==-1 ) { +if (retval <0 ) { bh =ERR_PTR (ERR_BAD_DX_DIR ); goto errout; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 252/482 ext4: avoid use-after-free in ext4_ext_show_leaf()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 4e2524ba2ca5f54bdbb9e5153bea00421ef653f5 ]
In ext4_find_extent(), path may be freed by error or be reallocated, so using a previously saved *ppath may have been freed and thus may trigger use-after-free, as follows:
ext4_split_extent
path = *ppath;
ext4_split_extent_at(ppath)
path = ext4_find_extent(ppath)
ext4_split_extent_at(ppath)
// ext4_find_extent fails to free path
// but zeroout succeeds ext4_ext_show_leaf(inode, path)
eh = path[depth].p_hdr
// path use-after-free !!!
Similar to ext4_split_extent_at(), we use *ppath directly as an input to ext4_ext_show_leaf(). Fix a spelling error by the way.
Same problem in ext4_ext_handle_unwritten_extents(). Since 'path' is only used in ext4_ext_show_leaf(), remove 'path' and use *ppath directly.
This issue is triggered only when EXT_DEBUG is defined and therefore does not affect functionality.
--- fs/ext4/extents.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/ext4/extents.c +4 -5
@@ -3287,7 +3287,7 @@ static int ext4_split_extent_at(handle_t *handle, }/* -* ext4_split_extents() splits an extent and mark extent which is covered +* ext4_split_extent() splits an extent and mark extent which is covered * by @map as split_flags indicates * * It may result in splitting the extent into multiple extents (up to three)
@@ -3363,7 +3363,7 @@ static int ext4_split_extent(handle_t *handle, goto out; } -ext4_ext_show_leaf (inode, path); +ext4_ext_show_leaf (inode, *ppath); out:return err ? err : allocated; }
@@ -3828,14 +3828,13 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, struct ext4_ext_path **ppath, int flags, unsigned int allocated, ext4_fsblk_t newblock) { - struct ext4_ext_path __maybe_unused *path = *ppath; int ret = 0;int err =0 ;ext_debug (inode,"logical block %llu, max_blocks %u, flags 0x%x, allocated %u\n" , (unsigned long long )map->m_lblk, map->m_len, flags, allocated); -ext4_ext_show_leaf (inode, path); +ext4_ext_show_leaf (inode, *ppath);/* * When writing into unwritten space, we should not fail to
@@ -3932,7 +3931,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,if (allocated > map->m_len) allocated = map->m_len; map->m_len = allocated; -ext4_ext_show_leaf (inode, path); +ext4_ext_show_leaf (inode, *ppath); out2:return err ? err : allocated; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 253/482 ext4: fix i_data_sem unlock order in ext4_ind_migrate()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artem Sadovnikov <[email protected]>
[ Upstream commit cc749e61c011c255d81b192a822db650c68b313f ]
Fuzzing reports a possible deadlock in jbd2_log_wait_commit.
This issue is triggered when an EXT4_IOC_MIGRATE ioctl is set to require synchronous updates because the file descriptor is opened with O_SYNC. This can lead to the jbd2_journal_stop() function calling jbd2_might_wait_for_commit(), potentially causing a deadlock if the EXT4_IOC_MIGRATE call races with a write(2) system call.
This problem only arises when CONFIG_PROVE_LOCKING is enabled. In this case, the jbd2_might_wait_for_commit macro locks jbd2_handle in the jbd2_journal_stop function while i_data_sem is locked. This triggers lockdep because the jbd2_journal_start function might also lock the same jbd2_handle simultaneously.
Found by Linux Verification Center (linuxtesting.org) with syzkaller.
Rule: add
--- fs/ext4/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/migrate.c +1 -1
@@ -663,8 +663,8 @@ int ext4_ind_migrate(struct inode *inode)if (unlikely (ret2 && !ret)) ret = ret2; errout: -ext4_journal_stop (handle);up_write (&EXT4_I (inode)->i_data_sem); +ext4_journal_stop (handle); out_unlock:ext4_writepages_up_write (inode->i_sb, alloc_ctx);return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 254/482 bpftool: Fix undefined behavior caused by shifting into the sign bit
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Wei Chiu <[email protected]>
[ Upstream commit 4cdc0e4ce5e893bc92255f5f734d983012f2bc2e ]
Replace shifts of '1' with '1U' in bitwise operations within __show_dev_tc_bpf() to prevent undefined behavior caused by shifting into the sign bit of a signed integer. By using '1U', the operations are explicitly performed on unsigned integers, avoiding potential integer overflow or sign-related issues.
--- tools/bpf/bpftool/net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/bpf/bpftool/net.c +4 -4
@@ -482,9 +482,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev,if (prog_flags[i] || json_output) {NET_START_ARRAY ("prog_flags" ,"%s " );for (j =0 ; prog_flags[i] && j <32 ; j++) { -if (!(prog_flags[i] & (1 << j))) +if (!(prog_flags[i] & (1U << j)))continue ; -NET_DUMP_UINT_ONLY (1 << j); +NET_DUMP_UINT_ONLY (1U << j); }NET_END_ARRAY ("" ); }
@@ -493,9 +493,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev,if (link_flags[i] || json_output) {NET_START_ARRAY ("link_flags" ,"%s " );for (j =0 ; link_flags[i] && j <32 ; j++) { -if (!(link_flags[i] & (1 << j))) +if (!(link_flags[i] & (1U << j)))continue ; -NET_DUMP_UINT_ONLY (1 << j); +NET_DUMP_UINT_ONLY (1U << j); }NET_END_ARRAY ("" ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 255/482 iomap: handle a post-direct I/O invalidate race in iomap_write_delalloc_release
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 7a9d43eace888a0ee6095035997bb138425844d3 ]
When direct I/O completions invalidates the page cache it holds neither the i_rwsem nor the invalidate_lock so it can be racing with iomap_write_delalloc_release. If the search for the end of the region that contains data returns the start offset we hit such a race and just need to look for the end of the newly created hole instead.
--- fs/iomap/buffered-io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/iomap/buffered-io.c +9 -1
@@ -1226,7 +1226,15 @@ static int iomap_write_delalloc_release(struct inode *inode, error = data_end; goto out_unlock; } -WARN_ON_ONCE (data_end <= start_byte); + +/* +* If we race with post-direct I/O invalidation of the page cache, +* there might be no data left at start_byte. +*/ +if (data_end == start_byte) +continue ; + +WARN_ON_ONCE (data_end < start_byte);WARN_ON_ONCE (data_end > scan_end_byte); error = iomap_write_delalloc_scan(inode, &punch_start_byte,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 256/482 bpftool: Fix undefined behavior in qsort(NULL, 0, ...)
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Wei Chiu <[email protected]>
[ Upstream commit f04e2ad394e2755d0bb2d858ecb5598718bf00d5 ]
When netfilter has no entry to display, qsort is called with qsort(NULL, 0, ...). This results in undefined behavior, as UBSan reports:
net.c:827:2: runtime error: null pointer passed as argument 1, which is declared to never be null
Although the C standard does not explicitly state whether calling qsort with a NULL pointer when the size is 0 constitutes undefined behavior, Section 7.1.4 of the C standard (Use of library functions) mentions:
"Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined."
To avoid this, add an early return when nf_link_info is NULL to prevent calling qsort with a NULL pointer.
--- tools/bpf/bpftool/net.c | 3 +++ 1 file changed, 3 insertions(+)
tools/bpf/bpftool/net.c +3 -0
@@ -824,6 +824,9 @@ static void show_link_netfilter(void) nf_link_count++; } +if (!nf_link_info) +return ; +qsort (nf_link_info, nf_link_count,sizeof (*nf_link_info), netfilter_link_compar);for (id =0 ; id < nf_link_count; id++) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 257/482 bpf: Fix a sdiv overflow issue
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 7dd34d7b7dcf9309fc6224caf4dd5b35bedddcb7 ]
Zac Ecob reported a problem where a bpf program may cause kernel crash due to the following error:
Oops: divide error: 0000 [#1] PREEMPT SMP KASAN PTI
The failure is due to the below signed divide:
LLONG_MIN/-1 where LLONG_MIN equals to -9,223,372,036,854,775,808.
LLONG_MIN/-1 is supposed to give a positive number 9,223,372,036,854,775,808, but it is impossible since for 64-bit system, the maximum positive number is 9,223,372,036,854,775,807. On x86_64, LLONG_MIN/-1 will cause a kernel exception. On arm64, the result for LLONG_MIN/-1 is LLONG_MIN.
Further investigation found all the following sdiv/smod cases may trigger an exception when bpf program is running on x86_64 platform:
- LLONG_MIN/-1 for 64bit operation
- INT_MIN/-1 for 32bit operation
- LLONG_MIN%-1 for 64bit operation
- INT_MIN%-1 for 32bit operation
where -1 can be an immediate or in a register.
On arm64, there are no exceptions:
- LLONG_MIN/-1 = LLONG_MIN
- INT_MIN/-1 = INT_MIN
- LLONG_MIN%-1 = 0
- INT_MIN%-1 = 0
where -1 can be an immediate or in a register.
Insn patching is needed to handle the above cases and the patched codes produced results aligned with above arm64 result. The below are pseudo codes to handle sdiv/smod exceptions including both divisor -1 and divisor 0 and the divisor is stored in a register.
sdiv:
tmp = rX
tmp += 1 /* [-1, 0] -> [0, 1]
if tmp >(unsigned) 1 goto L2
if tmp == 0 goto L1
rY = 0
L1:
rY = -rY;
goto L3 L2:
rY /= rX
L3:
smod:
tmp = rX
tmp += 1 /* [-1, 0] -> [0, 1]
if tmp >(unsigned) 1 goto L1
if tmp == 1 (is64 ? goto L2 : goto L3)
rY = 0;
goto L2 L1:
rY %= rX
L2:
goto L4 // only when !is64
L3:
wY = wY // only when !is64
L4:
--- kernel/bpf/verifier.c | 93 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 4 deletions(-)
kernel/bpf/verifier.c +89 -4
@@ -19951,13 +19951,46 @@ static int do_misc_fixups(struct bpf_verifier_env *env)/* Convert BPF_CLASS(insn->code) == BPF_ALU64 to 32-bit ALU */ insn->code =BPF_ALU |BPF_OP (insn->code) |BPF_SRC (insn->code); -/* Make divide-by-zero exceptions impossible. */ +/* Make sdiv/smod divide-by-minus-one exceptions impossible. */ +if ((insn->code == (BPF_ALU64 |BPF_MOD |BPF_K ) || + insn->code == (BPF_ALU64 |BPF_DIV |BPF_K ) || + insn->code == (BPF_ALU |BPF_MOD |BPF_K ) || + insn->code == (BPF_ALU |BPF_DIV |BPF_K )) && + insn->off ==1 && insn->imm ==-1 ) { +bool is64 =BPF_CLASS (insn->code) ==BPF_ALU64 ; +bool isdiv =BPF_OP (insn->code) ==BPF_DIV ; +struct bpf_insn *patchlet; +struct bpf_insn chk_and_sdiv[] = { +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_NEG |BPF_K , insn->dst_reg, +0 ,0 ,0 ), + }; +struct bpf_insn chk_and_smod[] = { +BPF_MOV32_IMM (insn->dst_reg,0 ), + }; + + patchlet = isdiv ? chk_and_sdiv : chk_and_smod; + cnt = isdiv ?ARRAY_SIZE (chk_and_sdiv) :ARRAY_SIZE (chk_and_smod); + + new_prog =bpf_patch_insn_data (env, i + delta, patchlet, cnt); +if (!new_prog) +return -ENOMEM ; + + delta += cnt -1 ; + env->prog = prog = new_prog; + insn = new_prog->insnsi + i + delta; + goto next_insn; + } + +/* Make divide-by-zero and divide-by-minus-one exceptions impossible. */ if (insn->code == (BPF_ALU64 |BPF_MOD |BPF_X ) || insn->code == (BPF_ALU64 |BPF_DIV |BPF_X ) || insn->code == (BPF_ALU |BPF_MOD |BPF_X ) || insn->code == (BPF_ALU |BPF_DIV |BPF_X )) {bool is64 =BPF_CLASS (insn->code) ==BPF_ALU64 ;bool isdiv =BPF_OP (insn->code) ==BPF_DIV ; +bool is_sdiv = isdiv && insn->off ==1 ; +bool is_smod = !isdiv && insn->off ==1 ;struct bpf_insn *patchlet;struct bpf_insn chk_and_div[] = {/* [R,W]x div 0 -> 0 */
@@ -19977,10 +20010,62 @@ static int do_misc_fixups(struct bpf_verifier_env *env)BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), BPF_MOV32_REG(insn->dst_reg, insn->dst_reg), }; +struct bpf_insn chk_and_sdiv[] = { +/* [R,W]x sdiv 0 -> 0 +* LLONG_MIN sdiv -1 -> LLONG_MIN +* INT_MIN sdiv -1 -> INT_MIN +*/ +BPF_MOV64_REG (BPF_REG_AX , insn->src_reg), +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_ADD |BPF_K ,BPF_REG_AX , +0 ,0 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JGT |BPF_K ,BPF_REG_AX , +0 ,4 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JEQ |BPF_K ,BPF_REG_AX , +0 ,1 ,0 ), +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_MOV |BPF_K , insn->dst_reg, +0 ,0 ,0 ), +/* BPF_NEG(LLONG_MIN) == -LLONG_MIN == LLONG_MIN */ +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_NEG |BPF_K , insn->dst_reg, +0 ,0 ,0 ), +BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), + *insn, + }; +struct bpf_insn chk_and_smod[] = { +/* [R,W]x mod 0 -> [R,W]x */ +/* [R,W]x mod -1 -> 0 */ +BPF_MOV64_REG (BPF_REG_AX , insn->src_reg), +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_ADD |BPF_K ,BPF_REG_AX , +0 ,0 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JGT |BPF_K ,BPF_REG_AX , +0 ,3 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JEQ |BPF_K ,BPF_REG_AX , +0 ,3 + (is64 ?0 :1 ),1 ), +BPF_MOV32_IMM (insn->dst_reg,0 ), +BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), + *insn, +BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), +BPF_MOV32_REG (insn->dst_reg, insn->dst_reg), + }; - patchlet = isdiv ? chk_and_div : chk_and_mod; - cnt = isdiv ?ARRAY_SIZE (chk_and_div) : -ARRAY_SIZE (chk_and_mod) - (is64 ?2 :0 ); +if (is_sdiv) { + patchlet = chk_and_sdiv; + cnt =ARRAY_SIZE (chk_and_sdiv); + }else if (is_smod) { + patchlet = chk_and_smod; + cnt =ARRAY_SIZE (chk_and_smod) - (is64 ?2 :0 ); + }else { + patchlet = isdiv ? chk_and_div : chk_and_mod; + cnt = isdiv ?ARRAY_SIZE (chk_and_div) : +ARRAY_SIZE (chk_and_mod) - (is64 ?2 :0 ); + } new_prog =bpf_patch_insn_data (env, i + delta, patchlet, cnt);if (!new_prog)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 258/482 EINJ, CXL: Fix CXL device SBDF calculation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Cheatham <[email protected]>
[ Upstream commit ee1e3c46ed19c096be22472c728fa7f68b1352c4 ]
The SBDF of the target CXL 2.0 compliant root port is required to inject a CXL protocol error as per ACPI 6.5. The SBDF given has to be in the following format:
31 24 23 16 15 11 10 8 7 0
+-------------------------------------------------+ | segment | bus | device | function | reserved | +-------------------------------------------------+
The SBDF calculated in cxl_dport_get_sbdf() doesn't account for the reserved bits currently, causing the wrong SBDF to be used. Fix said calculation to properly shift the SBDF.
Without this fix, error injection into CXL 2.0 root ports through the CXL debugfs interface (<debugfs>/cxl) is broken. Injection through the legacy interface (<debugfs>/apei/einj/) will still work because the SBDF is manually provided by the user.
--- drivers/acpi/apei/einj-cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/einj-cxl.c +1 -1
@@ -63,7 +63,7 @@ static int cxl_dport_get_sbdf(struct pci_dev *dport_dev, u64 *sbdf) seg = bridge->domain_nr; bus = pbus->number; - *sbdf = (seg <<24 ) | (bus <<16 ) | dport_dev->devfn; + *sbdf = (seg <<24 ) | (bus <<16 ) | (dport_dev->devfn <<8 );return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 259/482 spi: spi-imx: Fix pm_runtime_set_suspended() with runtime pm enabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit b6e05ba0844139dde138625906015c974c86aa93 ]
It is not valid to call pm_runtime_set_suspended() for devices with runtime PM enabled because it returns -EAGAIN if it is enabled already and working. So, call pm_runtime_disable() before to fix it.
--- drivers/spi/spi-imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-imx.c +1 -1
@@ -1870,8 +1870,8 @@ static int spi_imx_probe(struct platform_device *pdev)spi_imx_sdma_exit (spi_imx); out_runtime_pm_put:pm_runtime_dont_use_autosuspend (spi_imx->dev); -pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (spi_imx->dev); +pm_runtime_set_suspended (&pdev->dev);clk_disable_unprepare (spi_imx->clk_ipg); out_put_per:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 260/482 spi: spi-cadence: Fix pm_runtime_set_suspended() with runtime pm enabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 67d4a70faa662df07451e83db1546d3ca0695e08 ]
It is not valid to call pm_runtime_set_suspended() for devices with runtime PM enabled because it returns -EAGAIN if it is enabled already and working. So, call pm_runtime_disable() before to fix it.
--- drivers/spi/spi-cadence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-cadence.c +2 -2
@@ -665,8 +665,8 @@ static int cdns_spi_probe(struct platform_device *pdev) clk_dis_all:if (!spi_controller_is_target (ctlr)) { -pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev); } remove_ctlr:spi_controller_put (ctlr);
@@ -688,8 +688,8 @@ static void cdns_spi_remove(struct platform_device *pdev)cdns_spi_write (xspi,CDNS_SPI_ER ,CDNS_SPI_ER_DISABLE ); -pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev);spi_unregister_controller (ctlr); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 261/482 spi: spi-cadence: Fix missing spi_controller_is_target() check
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 3eae4a916fc0eb6f85b5d399e10335dbd24dd765 ]
The spi_controller_is_target() check is missing for pm_runtime_disable() in cdns_spi_remove(), add it.
--- drivers/spi/spi-cadence.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/spi/spi-cadence.c +4 -2
@@ -688,8 +688,10 @@ static void cdns_spi_remove(struct platform_device *pdev)cdns_spi_write (xspi,CDNS_SPI_ER ,CDNS_SPI_ER_DISABLE ); -pm_runtime_disable (&pdev->dev); -pm_runtime_set_suspended (&pdev->dev); +if (!spi_controller_is_target (ctlr)) { +pm_runtime_disable (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev); + }spi_unregister_controller (ctlr); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 262/482 selftest: hid: add missing run-hid-tools-tests.sh
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Lu <[email protected]>
[ Upstream commit 160c826b4dd0d570f0f51cf002cb49bda807e9f5 ]
HID test cases run tests using the run-hid-tools-tests.sh script. When installed with "make install", the run-hid-tools-tests.sh script will not be copied over, resulting in the following error message.
make -C tools/testing/selftests/ TARGETS=hid install \ INSTALL_PATH=$KSFT_INSTALL_PATH
cd $KSFT_INSTALL_PATH
./run_kselftest.sh -c hid
selftests: hid: hid-core.sh
bash: ./run-hid-tools-tests.sh: No such file or directory
Add the run-hid-tools-tests.sh script to the TEST_FILES in the Makefile for it to be installed.
--- tools/testing/selftests/hid/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/hid/Makefile +2 -0
@@ -17,6 +17,8 @@ TEST_PROGS += hid-tablet.sh TEST_PROGS += hid-usb_crash.sh TEST_PROGS += hid-wacom.sh +TEST_FILES := run-hid-tools-tests.sh + CXX ?= $(CROSS_COMPILE)g++ HOSTPKG_CONFIG := pkg-config
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 263/482 spi: s3c64xx: fix timeout counters in flush_fifo
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Dooks <[email protected]>
[ Upstream commit 68a16708d2503b6303d67abd43801e2ca40c208d ]
In the s3c64xx_flush_fifo() code, the loops counter is post-decremented in the do { } while(test && loops--) condition. This means the loops is left at the unsigned equivalent of -1 if the loop times out. The test after will never pass as if tests for loops == 0.
--- drivers/spi/spi-s3c64xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-s3c64xx.c +2 -2
@@ -245,7 +245,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) loops =msecs_to_loops (1 );do { val =readl (regs +S3C64XX_SPI_STATUS ); - }while (TX_FIFO_LVL (val, sdd) && loops--); + }while (TX_FIFO_LVL (val, sdd) && --loops);if (loops ==0 )dev_warn (&sdd->pdev->dev,"Timed out flushing TX FIFO\n" );
@@ -258,7 +258,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd)readl (regs +S3C64XX_SPI_RX_DATA ); else break; - }while (loops--); + }while (--loops);if (loops ==0 )dev_warn (&sdd->pdev->dev,"Timed out flushing RX FIFO\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 264/482 kselftest/devices/probe: Fix SyntaxWarning in regex strings for Python3
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alessandro Zanni <[email protected]>
[ Upstream commit a19008256d05e726f29f43c6a307e45482c082c3 ]
Insert raw strings to prevent Python3 from interpreting string literals as Unicode strings and "\d" as invalid escaped sequence.
Fix the warnings:
tools/testing/selftests/devices/probe/test_discoverable_devices.py:48:
SyntaxWarning: invalid escape sequence '\d' usb_controller_sysfs_dir = "usb[\d]+"
tools/testing/selftests/devices/probe/test_discoverable_devices.py: 94:
SyntaxWarning: invalid escape sequence '\d' re_usb_version = re.compile("PRODUCT=.*/(\d)/.*")
--- tools/testing/selftests/devices/test_discoverable_devices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/devices/test_discoverable_devices.py +2 -2
@@ -39,7 +39,7 @@ def find_pci_controller_dirs(): def find_usb_controller_dirs(): - usb_controller_sysfs_dir = "usb[\d]+" + usb_controller_sysfs_dir = r"usb[\d]+" dir_regex = re.compile(usb_controller_sysfs_dir) for d in os.scandir(sysfs_usb_devices):
@@ -69,7 +69,7 @@ def get_acpi_uid(sysfs_dev_dir): def get_usb_version(sysfs_dev_dir): - re_usb_version = re.compile("PRODUCT=.*/(\d)/.*") + re_usb_version = re.compile(r"PRODUCT=.*/(\d)/.*") with open(os.path.join(sysfs_dev_dir, "uevent")) as f: return int(re_usb_version.search(f.read()).group(1))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 265/482 selftests: breakpoints: use remaining time to check if suspend succeed
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifei Liu <[email protected]>
[ Upstream commit c66be905cda24fb782b91053b196bd2e966f95b7 ]
step_after_suspend_test fails with device busy error while writing to /sys/power/state to start suspend. The test believes it failed to enter suspend state with
$ sudo ./step_after_suspend_test TAP version 13 Bail out! Failed to enter Suspend state
However, in the kernel message, I indeed see the system get suspended and then wake up later.
[611172.033108] PM: suspend entry (s2idle) [611172.044940] Filesystems sync: 0.006 seconds [611172.052254] Freezing user space processes [611172.059319] Freezing user space processes completed (elapsed 0.001 seconds) [611172.067920] OOM killer disabled. [611172.072465] Freezing remaining freezable tasks [611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 seconds) [611172.089724] printk: Suspending console(s) (use no_console_suspend to debug) [611172.117126] serial 00:03: disabled some other hardware get reconnected [611203.136277] OOM killer enabled. [611203.140637] Restarting tasks ... [611203.141135] usb 1-8.1: USB disconnect, device number 7 [611203.141755] done. [611203.155268] random: crng reseeded on system resumption [611203.162059] PM: suspend exit
After investigation, I noticed that for the code block if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
ksft_exit_fail_msg("Failed to enter Suspend state\n");The write will return -1 and errno is set to 16 (device busy). It should be caused by the write function is not successfully returned before the system suspend and the return value get messed when waking up. As a result, It may be better to check the time passed of those few instructions to determine whether the suspend is executed correctly for it is pretty hard to execute those few lines for 5 seconds.
The timer to wake up the system is set to expire after 5 seconds and no re-arm. If the timer remaining time is 0 second and 0 nano secomd, it means the timer expired and wake the system up. Otherwise, the system could be considered to enter the suspend state failed if there is any remaining time.
After appling this patch, the test would not fail for it believes the system does not go to suspend by mistake. It now could continue to the rest part of the test after suspend.
--- .../testing/selftests/breakpoints/step_after_suspend_test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/breakpoints/step_after_suspend_test.c +4 -1
@@ -153,7 +153,10 @@ void suspend(void)if (err <0 )ksft_exit_fail_msg ("timerfd_settime() failed\n" ); -if (write (power_state_fd,"mem" ,strlen ("mem" )) !=strlen ("mem" )) +system ("(echo mem > /sys/power/state) 2> /dev/null" ); + +timerfd_gettime (timerfd, &spec); +if (spec.it_value.tv_sec !=0 || spec.it_value.tv_nsec !=0 )ksft_exit_fail_msg ("Failed to enter Suspend state\n" );close (timerfd);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/482 accel/ivpu: Add missing MODULE_FIRMWARE metadata
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander F. Lent <[email protected]>
[ Upstream commit 58b5618ba80a5e5a8d531a70eae12070e5bd713f ]
Modules that load firmware from various paths at runtime must declare those paths at compile time, via the MODULE_FIRMWARE macro, so that the firmware paths are included in the module's metadata.
The accel/ivpu driver loads firmware but lacks this metadata, preventing dracut from correctly locating firmware files. Fix it.
--- drivers/accel/ivpu/ivpu_fw.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/accel/ivpu/ivpu_fw.c +4 -0
@@ -58,6 +58,10 @@ static struct { { IVPU_HW_40XX, "intel/vpu/vpu_40xx_v0.0.bin" }, }; +/* Production fw_names from the table above */ +MODULE_FIRMWARE ("intel/vpu/vpu_37xx_v0.0.bin" ); +MODULE_FIRMWARE ("intel/vpu/vpu_40xx_v0.0.bin" ); +static int ivpu_fw_request (struct ivpu_device *vdev) {int ret = -ENOENT ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/482 spi: rpc-if: Add missing MODULE_DEVICE_TABLE
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 0880f669436028c5499901e5acd8f4b4ea0e0c6a ]
Add missing MODULE_DEVICE_TABLE definition for automatic loading of the driver when it is built as a module.
--- drivers/spi/spi-rpc-if.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/spi/spi-rpc-if.c +7 -0
@@ -198,9 +198,16 @@ static int __maybe_unused rpcif_spi_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(rpcif_spi_pm_ops, rpcif_spi_suspend, rpcif_spi_resume); +static const struct platform_device_id rpc_if_spi_id_table[] = { + { .name ="rpc-if-spi" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (platform, rpc_if_spi_id_table); +static struct platform_driver rpcif_spi_driver = { .probe = rpcif_spi_probe, .remove_new = rpcif_spi_remove, + .id_table = rpc_if_spi_id_table, .driver = { .name ="rpc-if-spi" , #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 268/482 ALSA: control: Fix power_ref lock order for compat code, too
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a1066453b5e49a28523f3ecbbfe4e06c6a29561c ]
In the previous change for swapping the power_ref and controls_rwsem lock order, the code path for the compat layer was forgotten. This patch covers the remaining code.
--- sound/core/control_compat.c | 45 ++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-)
sound/core/control_compat.c +37 -8
@@ -79,6 +79,7 @@ struct snd_ctl_elem_info32 {static int snd_ctl_elem_info_compat (struct snd_ctl_file *ctl,struct snd_ctl_elem_info32 __user *data32) { +struct snd_card *card = ctl->card; struct snd_ctl_elem_info *data __free(kfree) = NULL;int err;
@@ -95,7 +96,11 @@ static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl,if (get_user (data->value.enumerated.item, &data32->value.enumerated.item))return -EFAULT ; + err =snd_power_ref_and_wait (card); +if (err <0 ) +return err; err =snd_ctl_elem_info (ctl, data); +snd_power_unref (card);if (err <0 )return err;/* restore info to 32bit */
@@ -175,10 +180,7 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,if (info ==NULL )return -ENOMEM ; info->id = *id; - err =snd_power_ref_and_wait (card); -if (!err) - err = kctl->info (kctl, info); -snd_power_unref (card); + err = kctl->info (kctl, info);if (err >=0 ) { err = info->type; *countp = info->count;
@@ -275,8 +277,8 @@ static int copy_ctl_value_to_user(void __user *userdata,return 0 ; } -static int ctl_elem_read_user (struct snd_card *card, -void __user *userdata,void __user *valuep) +static int __ctl_elem_read_user (struct snd_card *card, +void __user *userdata,void __user *valuep) { struct snd_ctl_elem_value *data __free(kfree) = NULL;int err, type, count;
@@ -296,8 +298,21 @@ static int ctl_elem_read_user(struct snd_card *card,return copy_ctl_value_to_user (userdata, valuep, data, type, count); } -static int ctl_elem_write_user (struct snd_ctl_file *file, -void __user *userdata,void __user *valuep) +static int ctl_elem_read_user (struct snd_card *card, +void __user *userdata,void __user *valuep) +{ +int err; + + err =snd_power_ref_and_wait (card); +if (err <0 ) +return err; + err =__ctl_elem_read_user (card, userdata, valuep); +snd_power_unref (card); +return err; +} + +static int __ctl_elem_write_user (struct snd_ctl_file *file, +void __user *userdata,void __user *valuep) { struct snd_ctl_elem_value *data __free(kfree) = NULL;struct snd_card *card = file->card;
@@ -318,6 +333,20 @@ static int ctl_elem_write_user(struct snd_ctl_file *file,return copy_ctl_value_to_user (userdata, valuep, data, type, count); } +static int ctl_elem_write_user (struct snd_ctl_file *file, +void __user *userdata,void __user *valuep) +{ +struct snd_card *card = file->card; +int err; + + err =snd_power_ref_and_wait (card); +if (err <0 ) +return err; + err =__ctl_elem_write_user (file, userdata, valuep); +snd_power_unref (card); +return err; +} +static int snd_ctl_elem_read_user_compat (struct snd_card *card,struct snd_ctl_elem_value32 __user *data32) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 269/482 perf callchain: Fix stitch LBR memory leaks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 599c19397b17d197fc1184bbc950f163a292efc9 ]
The 'struct callchain_cursor_node' has a 'struct map_symbol' whose maps and map members are reference counted. Ensure these values use a _get routine to increment the reference counts and use map_symbol__exit() to release the reference counts.
Do similar for 'struct thread's prev_lbr_cursor, but save the size of the prev_lbr_cursor array so that it may be iterated.
Ensure that when stitch_nodes are placed on the free list the map_symbols are exited.
Fix resolve_lbr_callchain_sample() by replacing list_replace_init() to list_splice_init(), so the whole list is moved and nodes aren't leaked.
A reproduction of the memory leaks is possible with a leak sanitizer build in the perf report command of:
``` $ perf record -e cycles --call-graph lbr perf test -w thloop $ perf report --stitch-lbr ```
--- tools/perf/util/machine.c | 17 +++++++++++++++-- tools/perf/util/thread.c | 4 ++++ tools/perf/util/thread.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-)
tools/perf/util/machine.c +15 -2
@@ -2270,8 +2270,12 @@ static void save_lbr_cursor_node(struct thread *thread, cursor->curr = cursor->first; else cursor->curr = cursor->curr->next; + +map_symbol__exit (&lbr_stitch->prev_lbr_cursor[idx].ms);memcpy (&lbr_stitch->prev_lbr_cursor[idx], cursor->curr,sizeof (struct callchain_cursor_node )); + lbr_stitch->prev_lbr_cursor[idx].ms.maps =maps__get (cursor->curr->ms.maps); + lbr_stitch->prev_lbr_cursor[idx].ms.map =map__get (cursor->curr->ms.map); lbr_stitch->prev_lbr_cursor[idx].valid = true; cursor->pos++;
@@ -2482,6 +2486,9 @@ static bool has_stitched_lbr(struct thread *thread,memcpy (&stitch_node->cursor, &lbr_stitch->prev_lbr_cursor[i],sizeof (struct callchain_cursor_node )); + stitch_node->cursor.ms.maps =maps__get (lbr_stitch->prev_lbr_cursor[i].ms.maps); + stitch_node->cursor.ms.map =map__get (lbr_stitch->prev_lbr_cursor[i].ms.map); +if (callee)list_add (&stitch_node->node, &lbr_stitch->lists);else
@@ -2505,6 +2512,8 @@ static bool alloc_lbr_stitch(struct thread *thread, unsigned int max_lbr)if (!thread__lbr_stitch (thread)->prev_lbr_cursor) goto free_lbr_stitch; +thread__lbr_stitch (thread)->prev_lbr_cursor_size = max_lbr +1 ; +INIT_LIST_HEAD (&thread__lbr_stitch (thread)->lists);INIT_LIST_HEAD (&thread__lbr_stitch (thread)->free_lists);
@@ -2560,8 +2569,12 @@ static int resolve_lbr_callchain_sample(struct thread *thread, max_lbr, callee);if (!stitched_lbr && !list_empty (&lbr_stitch->lists)) { -list_replace_init (&lbr_stitch->lists, - &lbr_stitch->free_lists); +struct stitch_list *stitch_node; + +list_for_each_entry (stitch_node, &lbr_stitch->lists, node) +map_symbol__exit (&stitch_node->cursor.ms); + +list_splice_init (&lbr_stitch->lists, &lbr_stitch->free_lists); }memcpy (&lbr_stitch->prev_sample, sample,sizeof (*sample)); }
tools/perf/util/thread.c +4 -0
@@ -476,6 +476,7 @@ void thread__free_stitch_list(struct thread *thread)return ;list_for_each_entry_safe (pos, tmp, &lbr_stitch->lists, node) { +map_symbol__exit (&pos->cursor.ms);list_del_init (&pos->node);free (pos); }
@@ -485,6 +486,9 @@ void thread__free_stitch_list(struct thread *thread)free (pos); } +for (unsigned int i =0 ; i < lbr_stitch->prev_lbr_cursor_size; i++) +map_symbol__exit (&lbr_stitch->prev_lbr_cursor[i].ms); +zfree (&lbr_stitch->prev_lbr_cursor);free (thread__lbr_stitch (thread));thread__set_lbr_stitch (thread,NULL );
tools/perf/util/thread.h +1 -0
@@ -26,6 +26,7 @@ struct lbr_stitch {struct list_head free_lists;struct perf_sample prev_sample;struct callchain_cursor_node *prev_lbr_cursor; +unsigned int prev_lbr_cursor_size; };DECLARE_RC_STRUCT (thread) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 270/482 perf: Really fix event_function_call() locking
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit fe826cc2654e8561b64246325e6a51b62bf2488c ]
Commit 558abc7e3f89 ("perf: Fix event_function_call() locking") lost IRQ disabling by mistake.
--- kernel/events/core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/events/core.c +8 -5
@@ -263,8 +263,8 @@ static int event_function(void *info)static void event_function_call (struct perf_event *event,event_f func,void *data) {struct perf_event_context *ctx = event->ctx; -struct perf_cpu_context *cpuctx =this_cpu_ptr (&perf_cpu_context);struct task_struct *task =READ_ONCE (ctx->task);/* verified in event_function */ +struct perf_cpu_context *cpuctx;struct event_function_struct efs = { .event = event, .func = func,
@@ -292,22 +292,25 @@ static void event_function_call(struct perf_event *event, event_f func, void *daif (!task_function_call (task, event_function, &efs))return ; +local_irq_disable (); + cpuctx =this_cpu_ptr (&perf_cpu_context);perf_ctx_lock (cpuctx, ctx);/* * Reload the task pointer, it might have been changed by * a concurrent perf_event_context_sched_out(). */ task = ctx->task; -if (task ==TASK_TOMBSTONE ) { -perf_ctx_unlock (cpuctx, ctx); -return ; - } +if (task ==TASK_TOMBSTONE ) + goto unlock;if (ctx->is_active) {perf_ctx_unlock (cpuctx, ctx); +local_irq_enable (); goto again; }func (event,NULL , ctx, data); +unlock:perf_ctx_unlock (cpuctx, ctx); +local_irq_enable (); }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 271/482 drm/xe: fixup xe_alloc_pf_queue
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
[ Upstream commit 321d6b4b9cbe3dd0bc99937d5e5b4d730b5b5798 ]
kzalloc expects number of bytes, therefore we should convert the number of dw into bytes, otherwise we are likely just accessing beyond the array causing all kinds of carnage. Also fixup the error handling while we are here.
v2:
- Prefer kcalloc (dim)
--- drivers/gpu/drm/xe/xe_gt_pagefault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_gt_pagefault.c +4 -1
@@ -437,7 +437,10 @@ static int xe_alloc_pf_queue(struct xe_gt *gt, struct pf_queue *pf_queue) (num_eus +XE_NUM_HW_ENGINES ) *PF_MSG_LEN_DW ; pf_queue->gt = gt; - pf_queue->data =kzalloc (pf_queue->num_dw,GFP_KERNEL ); + pf_queue->data =kcalloc (pf_queue->num_dw,sizeof (u32),GFP_KERNEL ); +if (!pf_queue->data) +return -ENOMEM ; +spin_lock_init (&pf_queue->lock);INIT_WORK (&pf_queue->worker, pf_queue_work_func);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 272/482 drm/xe: Fix memory leak on xe_alloc_pf_queue failure
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nirmoy Das <[email protected]>
[ Upstream commit c5f728de696caa35481fd84202dfbc9fecc18e0b ]
Simplify memory unwinding on error also fixing current memory leak that can happen on error.
v2: use devm_kcalloc(Matt A)
--- drivers/gpu/drm/xe/xe_gt_pagefault.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_gt_pagefault.c +3 -5
@@ -408,20 +408,17 @@ static void pagefault_fini(void *arg) {struct xe_gt *gt = arg;struct xe_device *xe =gt_to_xe (gt); -int i;if (!xe->info.has_usm)return ;destroy_workqueue (gt->usm.acc_wq);destroy_workqueue (gt->usm.pf_wq); - -for (i =0 ; i <NUM_PF_QUEUE ; ++i) -kfree (gt->usm.pf_queue[i].data); }static int xe_alloc_pf_queue (struct xe_gt *gt,struct pf_queue *pf_queue) { +struct xe_device *xe =gt_to_xe (gt);xe_dss_mask_t all_dss;int num_dss, num_eus;
@@ -437,7 +434,8 @@ static int xe_alloc_pf_queue(struct xe_gt *gt, struct pf_queue *pf_queue) (num_eus +XE_NUM_HW_ENGINES ) *PF_MSG_LEN_DW ; pf_queue->gt = gt; - pf_queue->data =kcalloc (pf_queue->num_dw,sizeof (u32),GFP_KERNEL ); + pf_queue->data =devm_kcalloc (xe->drm.dev, pf_queue->num_dw, +sizeof (u32),GFP_KERNEL );if (!pf_queue->data)return -ENOMEM ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 273/482 selftests: vDSO: fix vDSO name for powerpc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 59eb856c3ed9b3552befd240c0c339f22eed3fa1 ]
Following error occurs when running vdso_test_correctness on powerpc:
~ # ./vdso_test_correctness
[WARN] failed to find vDSO
[SKIP] No vDSO, so skipping clock_gettime() tests
[SKIP] No vDSO, so skipping clock_gettime64() tests
[RUN] Testing getcpu...
[OK] CPU 0: syscall: cpu 0, node 0
On powerpc, vDSO is neither called linux-vdso.so.1 nor linux-gate.so.1 but linux-vdso32.so.1 or linux-vdso64.so.1.
Also search those two names before giving up.
--- tools/testing/selftests/vDSO/vdso_test_correctness.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/vDSO/vdso_test_correctness.c +6 -0
@@ -114,6 +114,12 @@ static void fill_function_pointers()if (!vdso) vdso =dlopen ("linux-gate.so.1" ,RTLD_LAZY |RTLD_LOCAL |RTLD_NOLOAD ); +if (!vdso) + vdso =dlopen ("linux-vdso32.so.1" , +RTLD_LAZY |RTLD_LOCAL |RTLD_NOLOAD ); +if (!vdso) + vdso =dlopen ("linux-vdso64.so.1" , +RTLD_LAZY |RTLD_LOCAL |RTLD_NOLOAD );if (!vdso) {printf ("[WARN]\tfailed to find vDSO\n" );return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 274/482 selftests: vDSO: fix vdso_config for powerpc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 7d297c419b08eafa69ce27243ee9bbecab4fcaa4 ]
Running vdso_test_correctness on powerpc64 gives the following warning:
~ # ./vdso_test_correctness
Warning: failed to find clock_gettime64 in vDSO
This is because vdso_test_correctness was built with VDSO_32BIT defined.
__powerpc__ macro is defined on both powerpc32 and powerpc64 so __powerpc64__ needs to be checked first in vdso_config.h
--- tools/testing/selftests/vDSO/vdso_config.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/vDSO/vdso_config.h +3 -3
@@ -18,13 +18,13 @@#elif defined(__aarch64__)#define VDSO_VERSION 3#define VDSO_NAMES 0 -#elif defined(__powerpc__) +#elif defined(__powerpc64__)#define VDSO_VERSION 1#define VDSO_NAMES 0 -#define VDSO_32BIT 1 -#elif defined(__powerpc64__) +#elif defined(__powerpc__)#define VDSO_VERSION 1#define VDSO_NAMES 0 +#define VDSO_32BIT 1#elif defined (__s390__)#define VDSO_VERSION 2#define VDSO_NAMES 0
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 275/482 selftests: vDSO: fix vDSO symbols lookup for powerpc64
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit ba83b3239e657469709d15dcea5f9b65bf9dbf34 ]
On powerpc64, following tests fail locating vDSO functions:
~ # ./vdso_test_abi
TAP version 13
1..16
# [vDSO kselftest] VDSO_VERSION: LINUX_2.6.15 # Couldn't find __kernel_gettimeofday
ok 1 # SKIP __kernel_gettimeofday
# clock_id: CLOCK_REALTIME
# Couldn't find __kernel_clock_gettime
ok 2 # SKIP __kernel_clock_gettime CLOCK_REALTIME # Couldn't find __kernel_clock_getres
ok 3 # SKIP __kernel_clock_getres CLOCK_REALTIME
...
# Couldn't find __kernel_time
ok 16 # SKIP __kernel_time
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:16 error:0
~ # ./vdso_test_getrandom
__kernel_getrandom is missing!
~ # ./vdso_test_gettimeofday
Could not find __kernel_gettimeofday
~ # ./vdso_test_getcpu
Could not find __kernel_getcpu
On powerpc64, as shown below by readelf, vDSO functions symbols have type NOTYPE, so also accept that type when looking for symbols.
$ powerpc64-linux-gnu-readelf -a arch/powerpc/kernel/vdso/vdso64.so.dbg ELF Header: Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: PowerPC64 Version: 0x1 ...
Symbol table '.dynsym' contains 12 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000524 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
2: 00000000000005f0 36 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
3: 0000000000000578 68 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
4: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LINUX_2.6.15
5: 00000000000006c0 48 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
6: 0000000000000614 172 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
7: 00000000000006f0 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
8: 000000000000047c 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
9: 0000000000000454 12 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
10: 00000000000004d0 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15
11: 00000000000005bc 52 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2.6.15Symbol table '.symtab' contains 56 entries:
Num: Value Size Type Bind Vis Ndx Name
...
45: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LINUX_2.6.15
46: 00000000000006c0 48 NOTYPE GLOBAL DEFAULT 8 __kernel_getcpu
47: 0000000000000524 84 NOTYPE GLOBAL DEFAULT 8 __kernel_clock_getres
48: 00000000000005f0 36 NOTYPE GLOBAL DEFAULT 8 __kernel_get_tbfreq
49: 000000000000047c 84 NOTYPE GLOBAL DEFAULT 8 __kernel_gettimeofday
50: 0000000000000614 172 NOTYPE GLOBAL DEFAULT 8 __kernel_sync_dicache
51: 00000000000006f0 84 NOTYPE GLOBAL DEFAULT 8 __kernel_getrandom
52: 0000000000000454 12 NOTYPE GLOBAL DEFAULT 8 __kernel_sigtram[...]
53: 0000000000000578 68 NOTYPE GLOBAL DEFAULT 8 __kernel_time
54: 00000000000004d0 84 NOTYPE GLOBAL DEFAULT 8 __kernel_clock_g[...]
55: 00000000000005bc 52 NOTYPE GLOBAL DEFAULT 8 __kernel_get_sys[...]--- tools/testing/selftests/vDSO/parse_vdso.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/vDSO/parse_vdso.c +2 -1
@@ -216,7 +216,8 @@ void *vdso_sym(const char *version, const char *name)ELF (Sym) *sym = &vdso_info.symtab[chain];/* Check for a defined global or weak function w/ right name. */ -if (ELF64_ST_TYPE (sym->st_info) !=STT_FUNC ) +if (ELF64_ST_TYPE (sym->st_info) !=STT_FUNC && +ELF64_ST_TYPE (sym->st_info) !=STT_NOTYPE )continue ;if (ELF64_ST_BIND (sym->st_info) !=STB_GLOBAL &&ELF64_ST_BIND (sym->st_info) !=STB_WEAK )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 276/482 selftests/mm: fix charge_reserved_hugetlb.sh test
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit c41a701d18efe6b8aa402efab16edbaba50c9548 ]
Currently, running the charge_reserved_hugetlb.sh selftest we can sometimes observe something like:
$ ./charge_reserved_hugetlb.sh -cgroup-v2 ... write_result is 0 After write: hugetlb_usage=0 reserved_usage=10485760 killing write_to_hugetlbfs Received 2. Deleting the memory Detach failure: Invalid argument umount: /mnt/huge: target is busy.
Both cases are issues in the test.
While the unmount error seems to be racy, it will make the test fail:
$ ./run_vmtests.sh -t hugetlb ... # [FAIL] not ok 10 charge_reserved_hugetlb.sh -cgroup-v2 # exit=32
The issue is that we are not waiting for the write_to_hugetlbfs process to quit. So it might still have a hugetlbfs file open, about which umount is not happy. Fix that by making "killall" wait for the process to quit.
The other error ("Detach failure: Invalid argument") does not seem to result in a test error, but is misleading. Turns out write_to_hugetlbfs.c unconditionally tries to cleanup using shmdt(), even when we only mmap()'ed a hugetlb file. Even worse, shmaddr is never even set for the SHM case. Fix that as well.
With this change it seems to work as expected.
--- .../selftests/mm/charge_reserved_hugetlb.sh | 2 +- .../testing/selftests/mm/write_to_hugetlbfs.c | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-)
tools/testing/selftests/mm/charge_reserved_hugetlb.sh +1 -1
@@ -254,7 +254,7 @@ function cleanup_hugetlb_memory() { local cgroup="$1" if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then echo killing write_to_hugetlbfs - killall -2 write_to_hugetlbfs + killall -2 --wait write_to_hugetlbfs wait_for_hugetlb_memory_to_get_depleted $cgroup fi set -e
tools/testing/selftests/mm/write_to_hugetlbfs.c +12 -9
@@ -28,7 +28,7 @@ enum method {/* Global variables. */ static const char *self; -static char *shmaddr; +static int *shmaddr;static int shmid;/*
@@ -47,15 +47,17 @@ void sig_handler(int signo) {printf ("Received %d.\n" , signo);if (signo ==SIGINT ) { -printf ("Deleting the memory\n" ); -if (shmdt ((const void *)shmaddr) !=0 ) { -perror ("Detach failure" ); +if (shmaddr) { +printf ("Deleting the memory\n" ); +if (shmdt ((const void *)shmaddr) !=0 ) { +perror ("Detach failure" ); +shmctl (shmid,IPC_RMID ,NULL ); +exit (4 ); + } +shmctl (shmid,IPC_RMID ,NULL ); -exit (4 ); +printf ("Done deleting the memory\n" ); } - -shmctl (shmid,IPC_RMID ,NULL ); -printf ("Done deleting the memory\n" ); }exit (2 ); }
@@ -211,7 +213,8 @@ int main(int argc, char **argv)shmctl (shmid,IPC_RMID ,NULL );exit (2 ); } -printf ("shmaddr: %p\n" , ptr); + shmaddr = ptr; +printf ("shmaddr: %p\n" , shmaddr);break ;default :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 277/482 nvme-tcp: fix link failure for TCP auth
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 2d5a333e09c388189238291577e443221baacba0 ]
The nvme fabric driver calls the nvme_tls_key_lookup() function from nvmf_parse_key() when the keyring is enabled, but this is broken in a configuration with CONFIG_NVME_FABRICS=y and CONFIG_NVME_TCP=m because this leads to the function definition being in a loadable module:
x86_64-linux-ld: vmlinux.o: in function `nvmf_parse_key':
fabrics.c:(.text+0xb1bdec): undefined reference to `nvme_tls_key_lookup'
Move the 'select' up to CONFIG_NVME_FABRICS itself to force this part to be built-in as well if needed.
--- drivers/nvme/host/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/Kconfig +1 -1
@@ -42,6 +42,7 @@ config NVME_HWMON config NVME_FABRICS select NVME_CORE + select NVME_KEYRING if NVME_TCP_TLS tristate config NVME_RDMA
@@ -95,7 +96,6 @@ config NVME_TCP config NVME_TCP_TLS bool "NVMe over Fabrics TCP TLS encryption support" depends on NVME_TCP - select NVME_KEYRING select NET_HANDSHAKE select KEYS help
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 278/482 f2fs: add write priority option based on zone UFS
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liao Yuanhong <[email protected]>
[ Upstream commit 8444ce524947daf441546b5b3a0c418706dade35 ]
Currently, we are using a mix of traditional UFS and zone UFS to support some functionalities that cannot be achieved on zone UFS alone. However, there are some issues with this approach. There exists a significant performance difference between traditional UFS and zone UFS. Under normal usage, we prioritize writes to zone UFS. However, in critical conditions (such as when the entire UFS is almost full), we cannot determine whether data will be written to traditional UFS or zone UFS. This can lead to significant performance fluctuations, which is not conducive to development and testing. To address this, we have added an option zlu_io_enable under sys with the following three modes:
1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to traditional UFS.
Stable-dep-of: 65a6ce4726c2 ("f2fs: fix to don't panic system for no free segment fault injection")
--- Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++ fs/f2fs/f2fs.h | 8 ++++++++ fs/f2fs/segment.c | 25 ++++++++++++++++++++++++- fs/f2fs/super.c | 1 + fs/f2fs/sysfs.c | 11 +++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-fs-f2fs +14 -0
@@ -763,3 +763,17 @@ Date: November 2023 Contact: "Chao Yu" <[email protected]> Description: It controls to enable/disable IO aware feature for background discard. By default, the value is 1 which indicates IO aware is on. + +What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy +Date: July 2024 +Contact: "Yuanhong Liao" <[email protected]> +Description: The zone UFS we are currently using consists of two parts: + conventional zones and sequential zones. It can be used to control which part + to prioritize for writes, with a default value of 0. + + ======================== ========================================= + value description + blkzone_alloc_policy = 0 Prioritize writing to sequential zones + blkzone_alloc_policy = 1 Only allow writing to sequential zones + blkzone_alloc_policy = 2 Prioritize writing to conventional zones + ======================== =========================================
fs/f2fs/f2fs.h +8 -0
@@ -134,6 +134,12 @@ typedef u32 nid_t;#define COMPRESS_EXT_NUM 16 +enum blkzone_allocation_policy { +BLKZONE_ALLOC_PRIOR_SEQ ,/* Prioritize writing to sequential zones */ +BLKZONE_ALLOC_ONLY_SEQ ,/* Only allow writing to sequential zones */ +BLKZONE_ALLOC_PRIOR_CONV ,/* Prioritize writing to conventional zones */ +}; +/* * An implementation of an rwsem that is explicitly unfair to readers. This * prevents priority inversion when a low-priority reader acquires the read lock
@@ -1563,6 +1569,8 @@ struct f2fs_sb_info {#ifdef CONFIG_BLK_DEV_ZONED unsigned int blocks_per_blkz;/* F2FS blocks per zone */ unsigned int max_open_zones;/* max open zone resources of the zoned device */ +/* For adjust the priority writing position of data in zone UFS */ +unsigned int blkzone_alloc_policy;#endif /* for node-related operations */
fs/f2fs/segment.c +24 -1
@@ -2701,17 +2701,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi, goto got_it; } +#ifdef CONFIG_BLK_DEV_ZONED /* * If we format f2fs on zoned storage, let's try to get pinned sections * from beginning of the storage, which should be a conventional one. */ if (f2fs_sb_has_blkzoned (sbi)) { - segno = pinning ?0 :max (first_zoned_segno (sbi), *newseg); +/* Prioritize writing to conventional zones */ +if (sbi->blkzone_alloc_policy ==BLKZONE_ALLOC_PRIOR_CONV || pinning) + segno =0 ; +else + segno =max (first_zoned_segno (sbi), *newseg); hint =GET_SEC_FROM_SEG (sbi, segno); } +#endif find_other_zone: secno =find_next_zero_bit (free_i->free_secmap,MAIN_SECS (sbi), hint); + +#ifdef CONFIG_BLK_DEV_ZONED +if (secno >=MAIN_SECS (sbi) &&f2fs_sb_has_blkzoned (sbi)) { +/* Write only to sequential zones */ +if (sbi->blkzone_alloc_policy ==BLKZONE_ALLOC_ONLY_SEQ ) { + hint =GET_SEC_FROM_SEG (sbi,first_zoned_segno (sbi)); + secno =find_next_zero_bit (free_i->free_secmap,MAIN_SECS (sbi), hint); + }else + secno =find_first_zero_bit (free_i->free_secmap, +MAIN_SECS (sbi)); +if (secno >=MAIN_SECS (sbi)) { + ret = -ENOSPC ; + goto out_unlock; + } + } +#endif +if (secno >=MAIN_SECS (sbi)) { secno =find_first_zero_bit (free_i->free_secmap,MAIN_SECS (sbi));
fs/f2fs/super.c +1 -0
@@ -4231,6 +4231,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) sbi->aligned_blksize = true;#ifdef CONFIG_BLK_DEV_ZONED sbi->max_open_zones =UINT_MAX ; + sbi->blkzone_alloc_policy =BLKZONE_ALLOC_PRIOR_SEQ ;#endif for (i =0 ; i < max_devices; i++) {
fs/f2fs/sysfs.c +11 -0
@@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a, }#endif +#ifdef CONFIG_BLK_DEV_ZONED +if (!strcmp (a->attr.name,"blkzone_alloc_policy" )) { +if (t <BLKZONE_ALLOC_PRIOR_SEQ || t >BLKZONE_ALLOC_PRIOR_CONV ) +return -EINVAL ; + sbi->blkzone_alloc_policy = t; +return count; + } +#endif +#ifdef CONFIG_F2FS_FS_COMPRESSION if (!strcmp (a->attr.name,"compr_written_block" ) || !strcmp (a->attr.name,"compr_saved_block" )) {
@@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);F2FS_SBI_GENERAL_RW_ATTR (last_age_weight);#ifdef CONFIG_BLK_DEV_ZONED F2FS_SBI_GENERAL_RO_ATTR (unusable_blocks_per_sec); +F2FS_SBI_GENERAL_RW_ATTR (blkzone_alloc_policy);#endif /* STAT_INFO ATTR */
@@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {#endif #ifdef CONFIG_BLK_DEV_ZONED ATTR_LIST(unusable_blocks_per_sec), + ATTR_LIST(blkzone_alloc_policy),#endif #ifdef CONFIG_F2FS_FS_COMPRESSION ATTR_LIST(compr_written_block),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 279/482 f2fs: fix to dont panic system for no free segment fault injection
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 65a6ce4726c27b45600303f06496fef46d00b57f ]
f2fs: fix to don't panic system for no free segment fault injection
syzbot reports a f2fs bug as below:
F2FS-fs (loop0): inject no free segment in get_new_segment of __allocate_new_segment+0x1ce/0x940 fs/f2fs/segment.c:3167 F2FS-fs (loop0): Stopped filesystem due to reason: 7
------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.c:2748! CPU: 0 UID: 0 PID: 5109 Comm: syz-executor304 Not tainted 6.11.0-rc6-syzkaller-00363-g89f5e14d05b4 #0 RIP: 0010:get_new_segment fs/f2fs/segment.c:2748 [inline] RIP: 0010:new_curseg+0x1f61/0x1f70 fs/f2fs/segment.c:2836 Call Trace: __allocate_new_segment+0x1ce/0x940 fs/f2fs/segment.c:3167 f2fs_allocate_new_section fs/f2fs/segment.c:3181 [inline] f2fs_allocate_pinning_section+0xfa/0x4e0 fs/f2fs/segment.c:3195 f2fs_expand_inode_data+0x5d6/0xbb0 fs/f2fs/file.c:1799 f2fs_fallocate+0x448/0x960 fs/f2fs/file.c:1903 vfs_fallocate+0x553/0x6c0 fs/open.c:334 do_vfs_ioctl+0x2592/0x2e50 fs/ioctl.c:886 __do_sys_ioctl fs/ioctl.c:905 [inline] __se_sys_ioctl+0x81/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0010:get_new_segment fs/f2fs/segment.c:2748 [inline] RIP: 0010:new_curseg+0x1f61/0x1f70 fs/f2fs/segment.c:2836
The root cause is when we inject no free segment fault into f2fs, we should not panic system, fix it.
--- fs/f2fs/segment.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/segment.c +3 -3
@@ -2730,6 +2730,7 @@ static int get_new_segment(struct f2fs_sb_info *sbi, MAIN_SECS(sbi));if (secno >=MAIN_SECS (sbi)) { ret = -ENOSPC ; +f2fs_bug_on (sbi,1 ); goto out_unlock; } }
@@ -2740,6 +2741,7 @@ static int get_new_segment(struct f2fs_sb_info *sbi, MAIN_SECS(sbi));if (secno >=MAIN_SECS (sbi)) { ret = -ENOSPC ; +f2fs_bug_on (sbi,1 ); goto out_unlock; } }
@@ -2781,10 +2783,8 @@ static int get_new_segment(struct f2fs_sb_info *sbi, out_unlock:spin_unlock (&free_i->segmap_lock); -if (ret == -ENOSPC ) { +if (ret == -ENOSPC )f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_NO_SEGMENT ); -f2fs_bug_on (sbi,1 ); - }return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 280/482 powerpc/vdso: Fix VDSO data access when running in a non-root time namespace
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit c73049389e58c01e2e3bbfae900c8daeee177191 ]
When running in a non-root time namespace, the global VDSO data page is replaced by a dedicated namespace data page and the global data page is mapped next to it. Detailed explanations can be found at commit 660fd04f9317 ("lib/vdso: Prepare for time namespace support").
When it happens, __kernel_get_syscall_map and __kernel_get_tbfreq and __kernel_sync_dicache don't work anymore because they read 0 instead of the data they need.
To address that, clock_mode has to be read. When it is set to VDSO_CLOCKMODE_TIMENS, it means it is a dedicated namespace data page and the global data is located on the following page.
Add a macro called get_realdatapage which reads clock_mode and add PAGE_SIZE to the pointer provided by get_datapage macro when clock_mode is equal to VDSO_CLOCKMODE_TIMENS. Use this new macro instead of get_datapage macro except for time functions as they handle it internally.
--- arch/powerpc/include/asm/vdso_datapage.h | 15 +++++++++++++++ arch/powerpc/kernel/asm-offsets.c | 2 ++ arch/powerpc/kernel/vdso/cacheflush.S | 2 +- arch/powerpc/kernel/vdso/datapage.S | 4 ++-- 4 files changed, 20 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/vdso_datapage.h +15 -0
@@ -111,6 +111,21 @@ extern struct vdso_arch_data *vdso_data; addi \ptr, \ptr, (_vdso_datapage - 999b)@l .endm +#include <asm/asm-offsets.h> +#include <asm/page.h> + +.macro get_realdatapage ptr scratch + get_datapage \ptr +#ifdef CONFIG_TIME_NS + lwz \scratch, VDSO_CLOCKMODE_OFFSET(\ptr) + xoris \scratch, \scratch, VDSO_CLOCKMODE_TIMENS@h + xori \scratch, \scratch, VDSO_CLOCKMODE_TIMENS@l + cntlzw \scratch, \scratch + rlwinm \scratch, \scratch, PAGE_SHIFT - 5, 1 << PAGE_SHIFT + add \ptr, \ptr, \scratch +#endif +.endm + #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/powerpc/kernel/asm-offsets.c +2 -0
@@ -346,6 +346,8 @@ int main(void)#else OFFSET (CFG_SYSCALL_MAP32 , vdso_arch_data, syscall_map);#endif +OFFSET (VDSO_CLOCKMODE_OFFSET , vdso_arch_data, data[0 ].clock_mode); +DEFINE (VDSO_CLOCKMODE_TIMENS ,VDSO_CLOCKMODE_TIMENS );#ifdef CONFIG_BUG DEFINE (BUG_ENTRY_SIZE ,sizeof (struct bug_entry ));
arch/powerpc/kernel/vdso/cacheflush.S +1 -1
@@ -30,7 +30,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) #ifdef CONFIG_PPC64 mflr r12 .cfi_register lr,r12 - get_datapage r10 + get_realdatapage r10, r11 mtlr r12 .cfi_restore lr #endif
arch/powerpc/kernel/vdso/datapage.S +2 -2
@@ -28,7 +28,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mflr r12 .cfi_register lr,r12 mr. r4,r3 - get_datapage r3 + get_realdatapage r3, r11 mtlr r12 #ifdef __powerpc64__ addi r3,r3,CFG_SYSCALL_MAP64
@@ -52,7 +52,7 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) .cfi_startproc mflr r12 .cfi_register lr,r12 - get_datapage r3 + get_realdatapage r3, r11 #ifndef __powerpc64__ lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3) #endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 281/482 selftests: vDSO: fix ELF hash table entry size for s390x
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Remus <[email protected]>
[ Upstream commit 14be4e6f35221c4731b004553ecf7cbc6dc1d2d8 ]
The vDSO self tests fail on s390x for a vDSO linked with the GNU linker ld as follows:
# ./vdso_test_gettimeofday Floating point exception (core dumped)
On s390x the ELF hash table entries are 64 bits instead of 32 bits in size (see Glibc sysdeps/unix/sysv/linux/s390/bits/elfclass.h).
--- tools/testing/selftests/vDSO/parse_vdso.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
tools/testing/selftests/vDSO/parse_vdso.c +10 -4
@@ -36,6 +36,12 @@#define ELF_BITS_XFORM (bits, x) ELF_BITS_XFORM2(bits, x)#define ELF (x) ELF_BITS_XFORM(ELF_BITS, x) +#ifdef __s390x__ +#define ELF_HASH_ENTRY ELF(Xword) +#else +#define ELF_HASH_ENTRY ELF(Word) +#endif + static struct vdso_info { bool valid;
@@ -47,8 +53,8 @@ static struct vdso_info/* Symbol table */ ELF (Sym) *symtab;const char *symstrings; -ELF (Word) *bucket, *chain; -ELF (Word) nbucket, nchain; +ELF_HASH_ENTRY *bucket, *chain; +ELF_HASH_ENTRY nbucket, nchain;/* Version table */ ELF (Versym) *versym;
@@ -115,7 +121,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)/* * Fish out the useful bits of the dynamic table. */ -ELF (Word) *hash =0 ; +ELF_HASH_ENTRY *hash =0 ; vdso_info.symstrings =0 ; vdso_info.symtab =0 ; vdso_info.versym =0 ;
@@ -133,7 +139,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) + vdso_info.load_offset);break ;case DT_HASH : - hash = (ELF (Word) *) + hash = (ELF_HASH_ENTRY *) ((uintptr_t )dyn[i].d_un.d_ptr + vdso_info.load_offset);break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 282/482 selftests: vDSO: fix vdso_config for s390
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit a6e23fb8d3c0e3904da70beaf5d7e840a983c97f ]
Running vdso_test_correctness on s390x (aka s390 64 bit) emits a warning:
Warning: failed to find clock_gettime64 in vDSO
This is caused by the "#elif defined (__s390__)" check in vdso_config.h which the defines VDSO_32BIT.
If __s390x__ is defined also __s390__ is defined. Therefore the correct check must make sure that only __s390__ is defined.
Therefore add the missing !defined(__s390x__). Also use common __s390x__ define instead of __s390X__.
--- tools/testing/selftests/vDSO/vdso_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/vDSO/vdso_config.h +2 -2
@@ -25,11 +25,11 @@#define VDSO_VERSION 1#define VDSO_NAMES 0#define VDSO_32BIT 1 -#elif defined (__s390__) +#elif defined (__s390__) && !defined(__s390x__)#define VDSO_VERSION 2#define VDSO_NAMES 0#define VDSO_32BIT 1 -#elif defined (__s390X__) +#elif defined (__s390x__)#define VDSO_VERSION 2#define VDSO_NAMES 0#elif defined(__mips__)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 283/482 f2fs: make BG GC more aggressive for zoned devices
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 5062b5bed4323275f2f89bc185c6a28d62cfcfd5 ]
Since we don't have any GC on device side for zoned devices, need more aggressive BG GC. So, tune the parameters for that.
Stable-dep-of: 5cc69a27abfa ("f2fs: forcibly migrate to secure space for zoned device file pinning")
--- fs/f2fs/f2fs.h | 20 ++++++++++++++++++-- fs/f2fs/gc.c | 25 +++++++++++++++++++++---- fs/f2fs/gc.h | 21 +++++++++++++++++++++ fs/f2fs/super.c | 5 +++++ 4 files changed, 65 insertions(+), 6 deletions(-)
fs/f2fs/f2fs.h +18 -2
@@ -2870,13 +2870,26 @@ static inline bool is_inflight_io(struct f2fs_sb_info *sbi, int type)return false; } +static inline bool is_inflight_read_io (struct f2fs_sb_info *sbi) +{ +return get_pages (sbi,F2FS_RD_DATA ) ||get_pages (sbi,F2FS_DIO_READ ); +} +static inline bool is_idle (struct f2fs_sb_info *sbi,int type) { +bool zoned_gc = (type ==GC_TIME && +F2FS_HAS_FEATURE (sbi,F2FS_FEATURE_BLKZONED )); +if (sbi->gc_mode ==GC_URGENT_HIGH )return true; -if (is_inflight_io (sbi, type)) -return false; +if (zoned_gc) { +if (is_inflight_read_io (sbi)) +return false; + }else { +if (is_inflight_io (sbi, type)) +return false; + }if (sbi->gc_mode ==GC_URGENT_MID )return true;
@@ -2885,6 +2898,9 @@ static inline bool is_idle(struct f2fs_sb_info *sbi, int type) (type == DISCARD_TIME || type == GC_TIME))return true; +if (zoned_gc) +return true; +return f2fs_time_over (sbi, type); }
fs/f2fs/gc.c +21 -4
@@ -116,7 +116,17 @@ static int gc_thread_func(void *data) goto next; } -if (has_enough_invalid_blocks (sbi)) +if (f2fs_sb_has_blkzoned (sbi)) { +if (has_enough_free_blocks (sbi,LIMIT_NO_ZONED_GC )) { + wait_ms = gc_th->no_gc_sleep_time; +f2fs_up_write (&sbi->gc_lock); + goto next; + } +if (wait_ms == gc_th->no_gc_sleep_time) + wait_ms = gc_th->max_sleep_time; + } + +if (need_to_boost_gc (sbi))decrease_sleep_time (gc_th, &wait_ms);else increase_sleep_time (gc_th, &wait_ms);
@@ -179,9 +189,16 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)return -ENOMEM ; gc_th->urgent_sleep_time =DEF_GC_THREAD_URGENT_SLEEP_TIME ; - gc_th->min_sleep_time =DEF_GC_THREAD_MIN_SLEEP_TIME ; - gc_th->max_sleep_time =DEF_GC_THREAD_MAX_SLEEP_TIME ; - gc_th->no_gc_sleep_time =DEF_GC_THREAD_NOGC_SLEEP_TIME ; + +if (f2fs_sb_has_blkzoned (sbi)) { + gc_th->min_sleep_time =DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED ; + gc_th->max_sleep_time =DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED ; + gc_th->no_gc_sleep_time =DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED ; + }else { + gc_th->min_sleep_time =DEF_GC_THREAD_MIN_SLEEP_TIME ; + gc_th->max_sleep_time =DEF_GC_THREAD_MAX_SLEEP_TIME ; + gc_th->no_gc_sleep_time =DEF_GC_THREAD_NOGC_SLEEP_TIME ; + } gc_th->gc_wake = false;
fs/f2fs/gc.h +21 -0
@@ -15,6 +15,11 @@#define DEF_GC_THREAD_MAX_SLEEP_TIME 60000#define DEF_GC_THREAD_NOGC_SLEEP_TIME 300000/* wait 5 min */ +/* GC sleep parameters for zoned deivces */ +#define DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED 10 +#define DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED 20 +#define DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED 60000 +/* choose candidates from sections which has age of more than 7 days */ #define DEF_GC_THREAD_AGE_THRESHOLD (60 * 60 * 24 * 7)#define DEF_GC_THREAD_CANDIDATE_RATIO 20/* select 20% oldest sections as candidates */
@@ -25,6 +30,9 @@#define LIMIT_INVALID_BLOCK 40/* percentage over total user space */ #define LIMIT_FREE_BLOCK 40/* percentage over invalid + free space */ +#define LIMIT_NO_ZONED_GC 60/* percentage over total user space of no gc for zoned devices */ +#define LIMIT_BOOST_ZONED_GC 25/* percentage over total user space of boosted gc for zoned devices */ +#define DEF_GC_FAILED_PINNED_FILES 2048#define MAX_GC_FAILED_PINNED_FILES USHRT_MAX
@@ -152,6 +160,12 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th, *wait -= min_time; } +static inline bool has_enough_free_blocks (struct f2fs_sb_info *sbi, +unsigned int limit_perc) +{ +return free_sections (sbi) > ((sbi->total_sections * limit_perc) /100 ); +} +static inline bool has_enough_invalid_blocks (struct f2fs_sb_info *sbi) {block_t user_block_count = sbi->user_block_count;
@@ -167,3 +181,10 @@ static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi)free_user_blocks (sbi) < limit_free_user_blocks(invalid_user_blocks)); } + +static inline bool need_to_boost_gc (struct f2fs_sb_info *sbi) +{ +if (f2fs_sb_has_blkzoned (sbi)) +return !has_enough_free_blocks (sbi,LIMIT_BOOST_ZONED_GC ); +return has_enough_invalid_blocks (sbi); +}
fs/f2fs/super.c +5 -0
@@ -711,6 +711,11 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)if (!strcmp (name,"on" )) {F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_ON ; }else if (!strcmp (name,"off" )) { +if (f2fs_sb_has_blkzoned (sbi)) { +f2fs_warn (sbi,"zoned devices need bggc" ); +kfree (name); +return -EINVAL ; + }F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_OFF ; }else if (!strcmp (name,"sync" )) {F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_SYNC ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 284/482 f2fs: introduce migration_window_granularity
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 8c890c4c60342719526520133fb1b6f69f196ab8 ]
We can control the scanning window granularity for GC migration. For more frequent scanning and GC on zoned devices, we need a fine grained control knob for it.
Stable-dep-of: 5cc69a27abfa ("f2fs: forcibly migrate to secure space for zoned device file pinning")
--- Documentation/ABI/testing/sysfs-fs-f2fs | 8 +++++++ fs/f2fs/f2fs.h | 2 ++ fs/f2fs/gc.c | 31 +++++++++++++++++-------- fs/f2fs/gc.h | 1 + fs/f2fs/super.c | 2 ++ fs/f2fs/sysfs.c | 7 ++++++ 6 files changed, 41 insertions(+), 10 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +8 -0
@@ -777,3 +777,11 @@ Description: The zone UFS we are currently using consists of two parts: blkzone_alloc_policy = 1 Only allow writing to sequential zones blkzone_alloc_policy = 2 Prioritize writing to conventional zones ======================== ========================================= + +What: /sys/fs/f2fs/<disk>/migration_window_granularity +Date: September 2024 +Contact: "Daeho Jeong" <[email protected]> +Description: Controls migration window granularity of garbage collection on large + section. it can control the scanning window granularity for GC migration + in a unit of segment, while migration_granularity controls the number + of segments which can be migrated at the same turn.
fs/f2fs/f2fs.h +2 -0
@@ -1697,6 +1697,8 @@ struct f2fs_sb_info {unsigned int max_victim_search;/* migration granularity of garbage collection, unit: segment */ unsigned int migration_granularity; +/* migration window granularity of garbage collection, unit: segment */ +unsigned int migration_window_granularity;/* * for stat information.
fs/f2fs/gc.c +21 -10
@@ -1708,24 +1708,34 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,struct blk_plug plug;unsigned int segno = start_segno;unsigned int end_segno = start_segno +SEGS_PER_SEC (sbi); +unsigned int sec_end_segno;int seg_freed =0 , migrated =0 ;unsigned char type =IS_DATASEG (get_seg_entry (sbi, segno)->type) ?SUM_TYPE_DATA :SUM_TYPE_NODE ;unsigned char data_type = (type ==SUM_TYPE_DATA ) ?DATA :NODE ;int submitted =0 ; -if (__is_large_section (sbi)) - end_segno =rounddown (end_segno,SEGS_PER_SEC (sbi)); +if (__is_large_section (sbi)) { + sec_end_segno =rounddown (end_segno,SEGS_PER_SEC (sbi)); -/* -* zone-capacity can be less than zone-size in zoned devices, -* resulting in less than expected usable segments in the zone, -* calculate the end segno in the zone which can be garbage collected -*/ -if (f2fs_sb_has_blkzoned (sbi)) - end_segno -=SEGS_PER_SEC (sbi) - +/* +* zone-capacity can be less than zone-size in zoned devices, +* resulting in less than expected usable segments in the zone, +* calculate the end segno in the zone which can be garbage +* collected +*/ +if (f2fs_sb_has_blkzoned (sbi)) + sec_end_segno -=SEGS_PER_SEC (sbi) -f2fs_usable_segs_in_sec (sbi, segno); +if (gc_type ==BG_GC ) + end_segno = start_segno + + sbi->migration_window_granularity; + +if (end_segno > sec_end_segno) + end_segno = sec_end_segno; + } +sanity_check_seg_type (sbi,get_seg_entry (sbi, segno)->type);/* readahead multi ssa blocks those have contiguous address */
@@ -1804,7 +1814,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,if (__is_large_section (sbi)) sbi->next_victim_seg[gc_type] = - (segno +1 < end_segno) ? segno +1 :NULL_SEGNO ; + (segno +1 < sec_end_segno) ? + segno +1 :NULL_SEGNO ; skip:f2fs_put_page (sum_page,0 ); }
fs/f2fs/gc.h +1 -0
@@ -32,6 +32,7 @@#define LIMIT_NO_ZONED_GC 60/* percentage over total user space of no gc for zoned devices */ #define LIMIT_BOOST_ZONED_GC 25/* percentage over total user space of boosted gc for zoned devices */ +#define DEF_MIGRATION_WINDOW_GRANULARITY_ZONED 3#define DEF_GC_FAILED_PINNED_FILES 2048#define MAX_GC_FAILED_PINNED_FILES USHRT_MAX
fs/f2fs/super.c +2 -0
@@ -3801,6 +3801,8 @@ static void init_sb_info(struct f2fs_sb_info *sbi) sbi->next_victim_seg[FG_GC ] =NULL_SEGNO ; sbi->max_victim_search =DEF_MAX_VICTIM_SEARCH ; sbi->migration_granularity =SEGS_PER_SEC (sbi); + sbi->migration_window_granularity =f2fs_sb_has_blkzoned (sbi) ? +DEF_MIGRATION_WINDOW_GRANULARITY_ZONED :SEGS_PER_SEC (sbi); sbi->seq_file_ra_mul =MIN_RA_MUL ; sbi->max_fragment_chunk =DEF_FRAGMENT_SIZE ; sbi->max_fragment_hole =DEF_FRAGMENT_SIZE ;
fs/f2fs/sysfs.c +7 -0
@@ -561,6 +561,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return -EINVAL ; } +if (!strcmp (a->attr.name,"migration_window_granularity" )) { +if (t ==0 || t >SEGS_PER_SEC (sbi)) +return -EINVAL ; + } +if (!strcmp (a->attr.name,"gc_urgent" )) {if (t ==0 ) { sbi->gc_mode =GC_NORMAL ;
@@ -1010,6 +1015,7 @@ F2FS_SBI_RW_ATTR(gc_pin_file_thresh, gc_pin_file_threshold);F2FS_SBI_RW_ATTR (gc_reclaimed_segments, gc_reclaimed_segs);F2FS_SBI_GENERAL_RW_ATTR (max_victim_search);F2FS_SBI_GENERAL_RW_ATTR (migration_granularity); +F2FS_SBI_GENERAL_RW_ATTR (migration_window_granularity);F2FS_SBI_GENERAL_RW_ATTR (dir_level);#ifdef CONFIG_F2FS_IOSTAT F2FS_SBI_GENERAL_RW_ATTR (iostat_enable);
@@ -1150,6 +1156,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (min_ssr_sections),ATTR_LIST (max_victim_search),ATTR_LIST (migration_granularity), +ATTR_LIST (migration_window_granularity),ATTR_LIST (dir_level),ATTR_LIST (ram_thresh), ATTR_LIST(ra_nid_pages),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 285/482 f2fs: increase BG GC migration window granularity when boosted for zoned devices
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 2223fe652f759649ae1d520e47e5f06727c0acbd ]
Need bigger BG GC migration window granularity when free section is running low.
Stable-dep-of: 5cc69a27abfa ("f2fs: forcibly migrate to secure space for zoned device file pinning")
--- fs/f2fs/gc.c | 12 ++++++++++-- fs/f2fs/gc.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)
fs/f2fs/gc.c +10 -2
@@ -1728,10 +1728,18 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, sec_end_segno -=SEGS_PER_SEC (sbi) -f2fs_usable_segs_in_sec (sbi, segno); -if (gc_type ==BG_GC ) - end_segno = start_segno + +if (gc_type ==BG_GC ) { +unsigned int window_granularity = sbi->migration_window_granularity; +if (f2fs_sb_has_blkzoned (sbi) && + !has_enough_free_blocks (sbi, +LIMIT_BOOST_ZONED_GC )) + window_granularity *=BOOST_GC_MULTIPLE ; + + end_segno = start_segno + window_granularity; + } +if (end_segno > sec_end_segno) end_segno = sec_end_segno; }
fs/f2fs/gc.h +1 -0
@@ -33,6 +33,7 @@#define LIMIT_NO_ZONED_GC 60/* percentage over total user space of no gc for zoned devices */ #define LIMIT_BOOST_ZONED_GC 25/* percentage over total user space of boosted gc for zoned devices */ #define DEF_MIGRATION_WINDOW_GRANULARITY_ZONED 3 +#define BOOST_GC_MULTIPLE 5#define DEF_GC_FAILED_PINNED_FILES 2048#define MAX_GC_FAILED_PINNED_FILES USHRT_MAX
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 286/482 f2fs: do FG_GC when GC boosting is required for zoned devices
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 9748c2ddea4a3f46a498bff4cf2bf9a5629e3f8b ]
Under low free section count, we need to use FG_GC instead of BG_GC to recover free sections.
Stable-dep-of: 5cc69a27abfa ("f2fs: forcibly migrate to secure space for zoned device file pinning")
--- fs/f2fs/f2fs.h | 1 + fs/f2fs/gc.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-)
fs/f2fs/f2fs.h +1 -0
@@ -1301,6 +1301,7 @@ struct f2fs_gc_control {bool no_bg_gc;/* check the space and stop bg_gc */ bool should_migrate_blocks;/* should migrate blocks */ bool err_gc_skipped;/* return EAGAIN if GC skipped */ +bool one_time;/* require one time GC in one migration unit */ unsigned int nr_free_secs;/* # of free sections to do GC */ };
fs/f2fs/gc.c +17 -7
@@ -81,6 +81,8 @@ static int gc_thread_func(void *data)continue ; } + gc_control.one_time = false; +/* * [GC triggering condition] * 0. GC is not conducted currently.
@@ -126,15 +128,19 @@ static int gc_thread_func(void *data) wait_ms = gc_th->max_sleep_time; } -if (need_to_boost_gc (sbi)) +if (need_to_boost_gc (sbi)) {decrease_sleep_time (gc_th, &wait_ms); -else +if (f2fs_sb_has_blkzoned (sbi)) + gc_control.one_time = true; + }else {increase_sleep_time (gc_th, &wait_ms); + } do_gc:stat_inc_gc_call_count (sbi, foreground ?FOREGROUND :BACKGROUND ); - sync_mode =F2FS_OPTION (sbi).bggc_mode ==BGGC_MODE_SYNC ; + sync_mode = (F2FS_OPTION (sbi).bggc_mode ==BGGC_MODE_SYNC ) || + gc_control.one_time;/* foreground GC was been triggered via f2fs_balance_fs() */ if (foreground)
@@ -1701,7 +1707,7 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim,static int do_garbage_collect (struct f2fs_sb_info *sbi,unsigned int start_segno,struct gc_inode_list *gc_list,int gc_type, -bool force_migrate) +bool force_migrate,bool one_time) {struct page *sum_page;struct f2fs_summary_block *sum;
@@ -1728,7 +1734,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, sec_end_segno -=SEGS_PER_SEC (sbi) -f2fs_usable_segs_in_sec (sbi, segno); -if (gc_type ==BG_GC ) { +if (gc_type ==BG_GC || one_time) {unsigned int window_granularity = sbi->migration_window_granularity;
@@ -1912,7 +1918,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) } seg_freed =do_garbage_collect (sbi, segno, &gc_list, gc_type, - gc_control->should_migrate_blocks); + gc_control->should_migrate_blocks, + gc_control->one_time);if (seg_freed <0 ) goto stop;
@@ -1923,6 +1930,9 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) total_sec_freed++; } +if (gc_control->one_time) + goto stop; +if (gc_type ==FG_GC ) { sbi->cur_victim_sec =NULL_SEGNO ;
@@ -2048,7 +2058,7 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi, };do_garbage_collect (sbi, segno, &gc_list,FG_GC , - dry_run_sections ==0 ); + dry_run_sections ==0 , false);put_gc_inode (&gc_list);if (!dry_run &&get_valid_blocks (sbi, segno, true))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 287/482 f2fs: forcibly migrate to secure space for zoned device file pinning
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 5cc69a27abfa91abbb39fc584f82d6c867b60f47 ]
We need to migrate data blocks even though it is full to secure space for zoned device file pinning.
--- fs/f2fs/gc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/gc.c +1 -2
@@ -2057,8 +2057,7 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi, .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS), }; -do_garbage_collect (sbi, segno, &gc_list,FG_GC , - dry_run_sections ==0 , false); +do_garbage_collect (sbi, segno, &gc_list,FG_GC , true, false);put_gc_inode (&gc_list);if (!dry_run &&get_valid_blocks (sbi, segno, true))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 288/482 Revert "ALSA: hda: Conditionally use snooping for AMD HDMI"
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 3f7f36a4559ef78a6418c5f0447fbfbdcf671956 upstream.
This reverts commit 478689b5990deb626a0b3f1ebf165979914d6be4.
The fix seems leading to regressions for other systems. Also, the way to check the presence of IOMMU via get_dma_ops() isn't reliable and it's no longer applicable for 6.12. After all, it's no right fix, so let's revert it at first.
To be noted, the PCM buffer allocation has been changed to try the continuous pages at first since 6.12, so the problem could be already addressed without this hackish workaround.
--- sound/pci/hda/hda_controller.h | 2 +- sound/pci/hda/hda_intel.c | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-)
sound/pci/hda/hda_controller.h +1 -1
@@ -28,7 +28,7 @@#else #define AZX_DCAPS_I915_COMPONENT 0/* NOP */ #endif -#define AZX_DCAPS_AMD_ALLOC_FIX (1 << 14)/* AMD allocation workaround */ +/* 14 unused */ #define AZX_DCAPS_CTX_WORKAROUND (1 << 15)/* X-Fi workaround */ #define AZX_DCAPS_POSFIX_LPIB (1 << 16)/* Use LPIB as default */ #define AZX_DCAPS_AMD_WORKAROUND (1 << 17)/* AMD-specific workaround */
sound/pci/hda/hda_intel.c +1 -9
@@ -40,7 +40,6 @@#ifdef CONFIG_X86 /* for snoop control */ -#include <linux/dma-map-ops.h> #include <asm/set_memory.h> #include <asm/cpufeature.h> #endif
@@ -307,7 +306,7 @@ enum {/* quirks for ATI HDMI with snoop off */ #define AZX_DCAPS_PRESET_ATI_HDMI_NS \ - (AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_AMD_ALLOC_FIX) + (AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_SNOOP_OFF)/* quirks for AMD SB */ #define AZX_DCAPS_PRESET_AMD_SB \
@@ -1703,13 +1702,6 @@ static void azx_check_snoop_available(stif (chip->driver_caps &AZX_DCAPS_SNOOP_OFF ) snoop = false; -#ifdef CONFIG_X86 -/* check the presence of DMA ops (i.e. IOMMU), disable snoop conditionally */ -if ((chip->driver_caps &AZX_DCAPS_AMD_ALLOC_FIX ) && - !get_dma_ops (chip->card->dev)) - snoop = false; -#endif - chip->snoop = snoop;if (!snoop) {dev_info (chip->card->dev,"Force to non-snoop mode\n" );
Greg Kroah-Hartman
maintainerPATCH 289/482 platform/x86: x86-android-tablets: Fix use after free on platform_device_register() errors
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 2fae3129c0c08e72b1fe93e61fd8fd203252094a upstream.
x86_android_tablet_remove() frees the pdevs[] array, so it should not be used after calling x86_android_tablet_remove().
When platform_device_register() fails, store the pdevs[x] PTR_ERR() value into the local ret variable before calling x86_android_tablet_remove() to avoid using pdevs[] after it has been freed.
--- drivers/platform/x86/x86-android-tablets/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/platform/x86/x86-android-tablets/core.c +4 -2
@@ -390,8 +390,9 @@ static __init int x86_android_tablet_profor (i =0 ; i < pdev_count; i++) { pdevs[i] =platform_device_register_full (&dev_info->pdev_info[i]);if (IS_ERR (pdevs[i])) { + ret =PTR_ERR (pdevs[i]);x86_android_tablet_remove (pdev); -return PTR_ERR (pdevs[i]); +return ret; } }
@@ -443,8 +444,9 @@ static __init int x86_android_tablet_proPLATFORM_DEVID_AUTO , &pdata, sizeof(pdata));if (IS_ERR (pdevs[pdev_count])) { + ret =PTR_ERR (pdevs[pdev_count]);x86_android_tablet_remove (pdev); -return PTR_ERR (pdevs[pdev_count]); +return ret; } pdev_count++; }
Greg Kroah-Hartman
maintainerPATCH 290/482 platform/x86: ISST: Fix the KASAN report slab-out-of-bounds bug
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zach Wade <[email protected]>
commit 7d59ac07ccb58f8f604f8057db63b8efcebeb3de upstream.
Attaching SST PCI device to VM causes "BUG: KASAN: slab-out-of-bounds". kasan report:
[ 19.411889] ================================================================== [ 19.413702] BUG: KASAN: slab-out-of-bounds in _isst_if_get_pci_dev+0x3d5/0x400 [isst_if_common] [ 19.415634] Read of size 8 at addr ffff888829e65200 by task cpuhp/16/113 [ 19.417368] [ 19.418627] CPU: 16 PID: 113 Comm: cpuhp/16 Tainted: G E 6.9.0 #10 [ 19.420435] Hardware name: VMware, Inc. VMware20,1/440BX Desktop Reference Platform, BIOS VMW201.00V.20192059.B64.2207280713 07/28/2022 [ 19.422687] Call Trace: [ 19.424091] <TASK> [ 19.425448] dump_stack_lvl+0x5d/0x80 [ 19.426963] ? _isst_if_get_pci_dev+0x3d5/0x400 [isst_if_common] [ 19.428694] print_report+0x19d/0x52e [ 19.430206] ? __pfx__raw_spin_lock_irqsave+0x10/0x10 [ 19.431837] ? _isst_if_get_pci_dev+0x3d5/0x400 [isst_if_common] [ 19.433539] kasan_report+0xf0/0x170 [ 19.435019] ? _isst_if_get_pci_dev+0x3d5/0x400 [isst_if_common] [ 19.436709] _isst_if_get_pci_dev+0x3d5/0x400 [isst_if_common] [ 19.438379] ? __pfx_sched_clock_cpu+0x10/0x10 [ 19.439910] isst_if_cpu_online+0x406/0x58f [isst_if_common] [ 19.441573] ? __pfx_isst_if_cpu_online+0x10/0x10 [isst_if_common] [ 19.443263] ? ttwu_queue_wakelist+0x2c1/0x360 [ 19.444797] cpuhp_invoke_callback+0x221/0xec0 [ 19.446337] cpuhp_thread_fun+0x21b/0x610 [ 19.447814] ? __pfx_cpuhp_thread_fun+0x10/0x10 [ 19.449354] smpboot_thread_fn+0x2e7/0x6e0 [ 19.450859] ? __pfx_smpboot_thread_fn+0x10/0x10 [ 19.452405] kthread+0x29c/0x350 [ 19.453817] ? __pfx_kthread+0x10/0x10 [ 19.455253] ret_from_fork+0x31/0x70 [ 19.456685] ? __pfx_kthread+0x10/0x10 [ 19.458114] ret_from_fork_asm+0x1a/0x30 [ 19.459573] </TASK> [ 19.460853] [ 19.462055] Allocated by task 1198: [ 19.463410] kasan_save_stack+0x30/0x50 [ 19.464788] kasan_save_track+0x14/0x30 [ 19.466139] __kasan_kmalloc+0xaa/0xb0 [ 19.467465] __kmalloc+0x1cd/0x470 [ 19.468748] isst_if_cdev_register+0x1da/0x350 [isst_if_common] [ 19.470233] isst_if_mbox_init+0x108/0xff0 [isst_if_mbox_msr] [ 19.471670] do_one_initcall+0xa4/0x380 [ 19.472903] do_init_module+0x238/0x760 [ 19.474105] load_module+0x5239/0x6f00 [ 19.475285] init_module_from_file+0xd1/0x130 [ 19.476506] idempotent_init_module+0x23b/0x650 [ 19.477725] __x64_sys_finit_module+0xbe/0x130 [ 19.476506] idempotent_init_module+0x23b/0x650 [ 19.477725] __x64_sys_finit_module+0xbe/0x130 [ 19.478920] do_syscall_64+0x82/0x160 [ 19.480036] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 19.481292] [ 19.482205] The buggy address belongs to the object at ffff888829e65000 which belongs to the cache kmalloc-512 of size 512 [ 19.484818] The buggy address is located 0 bytes to the right of allocated 512-byte region [ffff888829e65000, ffff888829e65200) [ 19.487447] [ 19.488328] The buggy address belongs to the physical page: [ 19.489569] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888829e60c00 pfn:0x829e60 [ 19.491140] head: order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 [ 19.492466] anon flags: 0x57ffffc0000840(slab|head|node=1|zone=2|lastcpupid=0x1fffff) [ 19.493914] page_type: 0xffffffff() [ 19.494988] raw: 0057ffffc0000840 ffff88810004cc80 0000000000000000 0000000000000001 [ 19.496451] raw: ffff888829e60c00 0000000080200018 00000001ffffffff 0000000000000000 [ 19.497906] head: 0057ffffc0000840 ffff88810004cc80 0000000000000000 0000000000000001 [ 19.499379] head: ffff888829e60c00 0000000080200018 00000001ffffffff 0000000000000000 [ 19.500844] head: 0057ffffc0000003 ffffea0020a79801 ffffea0020a79848 00000000ffffffff [ 19.502316] head: 0000000800000000 0000000000000000 00000000ffffffff 0000000000000000 [ 19.503784] page dumped because: kasan: bad access detected [ 19.505058] [ 19.505970] Memory state around the buggy address: [ 19.507172] ffff888829e65100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 19.508599] ffff888829e65180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 19.510013] >ffff888829e65200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 19.510014] ^ [ 19.510016] ffff888829e65280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 19.510018] ffff888829e65300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 19.515367] ==================================================================
The reason for this error is physical_package_ids assigned by VMware VMM are not continuous and have gaps. This will cause value returned by topology_physical_package_id() to be more than topology_max_packages().
Here the allocation uses topology_max_packages(). The call to topology_max_packages() returns maximum logical package ID not physical ID. Hence use topology_logical_package_id() instead of topology_physical_package_id().
--- drivers/platform/x86/intel/speed_select_if/isst_if_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/speed_select_if/isst_if_common.c +3 -1
@@ -316,7 +316,9 @@ static struct pci_dev *_isst_if_get_pci_ cpu >= nr_cpu_ids || cpu >= num_possible_cpus())return NULL ; - pkg_id =topology_physical_package_id (cpu); + pkg_id =topology_logical_package_id (cpu); +if (pkg_id >=topology_max_packages ()) +return NULL ; bus_number = isst_cpu_info[cpu].bus_info[bus_no];if (bus_number <0 )
Greg Kroah-Hartman
maintainerPATCH 291/482 KVM: arm64: Fix kvm_has_feat*() handling of negative features
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit a1d402abf8e3ff1d821e88993fc5331784fac0da upstream.
Oliver reports that the kvm_has_feat() helper is not behaviing as expected for negative feature. On investigation, the main issue seems to be caused by the following construct:
#define get_idreg_field(kvm, id, fld) \
(id##_##fld##_SIGNED ? \ get_idreg_field_signed(kvm, id, fld) : \ get_idreg_field_unsigned(kvm, id, fld))
where one side of the expression evaluates as something signed, and the other as something unsigned. In retrospect, this is totally braindead, as the compiler converts this into an unsigned expression. When compared to something that is 0, the test is simply elided.
Epic fail. Similar issue exists in the expand_field_sign() macro.
The correct way to handle this is to chose between signed and unsigned comparisons, so that both sides of the ternary expression are of the same type (bool).
In order to keep the code readable (sort of), we introduce new comparison primitives taking an operator as a parameter, and rewrite the kvm_has_feat*() helpers in terms of these primitives.
--- arch/arm64/include/asm/kvm_host.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
arch/arm64/include/asm/kvm_host.h +13 -12
@@ -1364,11 +1364,6 @@ bool kvm_arm_vcpu_stopped(struct kvm_vcp sign_extend64(__val, id##_##fld##_WIDTH - 1); \ }) -#define expand_field_sign (id, fld, val) \ - (id##_##fld##_SIGNED ? \ - __expand_field_sign_signed(id, fld, val) : \ - __expand_field_sign_unsigned(id, fld, val)) -#define get_idreg_field_unsigned (kvm, id, fld) \ ({ \ u64 __val = IDREG((kvm), SYS_##id); \
@@ -1384,20 +1379,26 @@ bool kvm_arm_vcpu_stopped(struct kvm_vcp#define get_idreg_field_enum (kvm, id, fld) \ get_idreg_field_unsigned(kvm, id, fld) -#define get_idreg_field (kvm, id, fld) \ +#define kvm_cmp_feat_signed (kvm, id, fld, op, limit) \ + (get_idreg_field_signed((kvm), id, fld) op __expand_field_sign_signed(id, fld, limit)) + +#define kvm_cmp_feat_unsigned (kvm, id, fld, op, limit) \ + (get_idreg_field_unsigned((kvm), id, fld) op __expand_field_sign_unsigned(id, fld, limit)) + +#define kvm_cmp_feat (kvm, id, fld, op, limit) \ (id##_##fld##_SIGNED ? \ - get_idreg_field_signed(kvm, id, fld) : \ - get_idreg_field_unsigned(kvm, id, fld)) + kvm_cmp_feat_signed(kvm, id, fld, op, limit) : \ + kvm_cmp_feat_unsigned(kvm, id, fld, op, limit))#define kvm_has_feat (kvm, id, fld, limit) \ - (get_idreg_field((kvm), id, fld) >= expand_field_sign(id, fld, limit)) + kvm_cmp_feat(kvm, id, fld, >=, limit)#define kvm_has_feat_enum (kvm, id, fld, val) \ - (get_idreg_field_unsigned((kvm), id, fld) == __expand_field_sign_unsigned(id, fld, val)) + kvm_cmp_feat_unsigned(kvm, id, fld, ==, val)#define kvm_has_feat_range (kvm, id, fld, min, max) \ - (get_idreg_field((kvm), id, fld) >= expand_field_sign(id, fld, min) && \ - get_idreg_field((kvm), id, fld) <= expand_field_sign(id, fld, max)) + (kvm_cmp_feat(kvm, id, fld, >=, min) && \ + kvm_cmp_feat(kvm, id, fld, <=, max))/* Check for a given level of PAuth support */ #define kvm_has_pauth (k, l) \
Greg Kroah-Hartman
maintainerPATCH 292/482 i2c: stm32f7: Do not prepare/unprepare clock during runtime suspend/resume
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
commit 048bbbdbf85e5e00258dfb12f5e368f908801d7b upstream.
In case there is any sort of clock controller attached to this I2C bus controller, for example Versaclock or even an AIC32x4 I2C codec, then an I2C transfer triggered from the clock controller clk_ops .prepare callback may trigger a deadlock on drivers/clk/clk.c prepare_lock mutex.
This is because the clock controller first grabs the prepare_lock mutex and then performs the prepare operation, including its I2C access. The I2C access resumes this I2C bus controller via .runtime_resume callback, which calls clk_prepare_enable(), which attempts to grab the prepare_lock mutex again and deadlocks.
Since the clock are already prepared since probe() and unprepared in remove(), use simple clk_enable()/clk_disable() calls to enable and disable the clock on runtime suspend and resume, to avoid hitting the prepare_lock mutex.
--- drivers/i2c/busses/i2c-stm32f7.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +3 -3
@@ -2395,7 +2395,7 @@ static int __maybe_unused stm32f7_i2c_rustruct stm32f7_i2c_dev *i2c_dev =dev_get_drvdata (dev);if (!stm32f7_i2c_is_slave_registered (i2c_dev)) -clk_disable_unprepare (i2c_dev->clk); +clk_disable (i2c_dev->clk);return 0 ; }
@@ -2406,9 +2406,9 @@ static int __maybe_unused stm32f7_i2c_ruint ret;if (!stm32f7_i2c_is_slave_registered (i2c_dev)) { - ret =clk_prepare_enable (i2c_dev->clk); + ret =clk_enable (i2c_dev->clk);if (ret) { -dev_err (dev,"failed to prepare_enable clock\n" ); +dev_err (dev,"failed to enable clock\n" );return ret; } }
Greg Kroah-Hartman
maintainerPATCH 293/482 i2c: qcom-geni: Use IRQF_NO_AUTOEN flag in request_irq()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
commit e2c85d85a05f16af2223fcc0195ff50a7938b372 upstream.
disable_irq() after request_irq() still has a time gap in which interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will disable IRQ auto-enable when request IRQ.
--- drivers/i2c/busses/i2c-qcom-geni.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +1 -3
@@ -818,15 +818,13 @@ static int geni_i2c_probe(struct platforinit_completion (&gi2c->done);spin_lock_init (&gi2c->lock);platform_set_drvdata (pdev, gi2c); - ret =devm_request_irq (dev, gi2c->irq, geni_i2c_irq,0 , + ret =devm_request_irq (dev, gi2c->irq, geni_i2c_irq,IRQF_NO_AUTOEN ,dev_name (dev), gi2c);if (ret) {dev_err (dev,"Request_irq failed:%d: err:%d\n" , gi2c->irq, ret);return ret; } -/* Disable the interrupt so that the system can enter low-power mode */ -disable_irq (gi2c->irq);i2c_set_adapdata (&gi2c->adap, gi2c); gi2c->adap.dev.parent = dev; gi2c->adap.dev.of_node = dev->of_node;
Greg Kroah-Hartman
maintainerPATCH 294/482 i2c: xiic: Wait for TX empty to avoid missed TX NAKs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Hancock <[email protected]>
commit 521da1e9225450bd323db5fa5bca942b1dc485b7 upstream.
Frequently an I2C write will be followed by a read, such as a register address write followed by a read of the register value. In this driver, when the TX FIFO half empty interrupt was raised and it was determined that there was enough space in the TX FIFO to send the following read command, it would do so without waiting for the TX FIFO to actually empty.
Unfortunately it appears that in some cases this can result in a NAK that was raised by the target device on the write, such as due to an unsupported register address, being ignored and the subsequent read being done anyway. This can potentially put the I2C bus into an invalid state and/or result in invalid read data being processed.
To avoid this, once a message has been fully written to the TX FIFO, wait for the TX FIFO empty interrupt before moving on to the next message, to ensure NAKs are handled properly.
--- drivers/i2c/busses/i2c-xiic.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/i2c/busses/i2c-xiic.c +9 -10
@@ -772,14 +772,17 @@ static irqreturn_t xiic_process(int irq, goto out; } -xiic_fill_tx_fifo (i2c); - -/* current message sent and there is space in the fifo */ -if (!xiic_tx_space (i2c) &&xiic_tx_fifo_space (i2c) >=2 ) { +if (xiic_tx_space (i2c)) { +xiic_fill_tx_fifo (i2c); + }else { +/* current message fully written */ dev_dbg (i2c->adap.dev.parent,"%s end of message sent, nmsgs: %d\n" , __func__, i2c->nmsgs); -if (i2c->nmsgs >1 ) { +/* Don't move onto the next message until the TX FIFO empties, +* to ensure that a NAK is not missed. +*/ +if (i2c->nmsgs >1 && (pend &XIIC_INTR_TX_EMPTY_MASK )) { i2c->nmsgs--; i2c->tx_msg++; xfer_more =1 ;
@@ -790,11 +793,7 @@ static irqreturn_t xiic_process(int irq,"%s Got TX IRQ but no more to do...\n" , __func__); } - }else if (!xiic_tx_space (i2c) && (i2c->nmsgs ==1 )) -/* current frame is sent and is last, -* make sure to disable tx half -*/ -xiic_irq_dis (i2c,XIIC_INTR_TX_HALF_MASK ); + } }if (pend &XIIC_INTR_BNB_MASK ) {
Greg Kroah-Hartman
maintainerPATCH 295/482 media: i2c: ar0521: Use cansleep version of gpiod_set_value()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Shiyan <[email protected]>
commit bee1aed819a8cda47927436685d216906ed17f62 upstream.
If we use GPIO reset from I2C port expander, we must use *_cansleep() variant of GPIO functions.
This was not done in ar0521_power_on()/ar0521_power_off() functions. Let's fix that.
------------[ cut here ]------------ WARNING: CPU: 0 PID: 11 at drivers/gpio/gpiolib.c:3496 gpiod_set_value+0x74/0x7c Modules linked in: CPU: 0 PID: 11 Comm: kworker/u16:0 Not tainted 6.10.0 #53 Hardware name: Diasom DS-RK3568-SOM-EVB (DT) Workqueue: events_unbound deferred_probe_work_func pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : gpiod_set_value+0x74/0x7c lr : ar0521_power_on+0xcc/0x290
sp : ffffff8001d7ab70
x29: ffffff8001d7ab70 x28: ffffff80027dcc90 x27: ffffff8003c82000
x26: ffffff8003ca9250 x25: ffffffc080a39c60 x24: ffffff8003ca9088
x23: ffffff8002402720 x22: ffffff8003ca9080 x21: ffffff8003ca9088
x20: 0000000000000000 x19: ffffff8001eb2a00 x18: ffffff80efeeac80
x17: 756d2d6332692f30 x16: 0000000000000000 x15: 0000000000000000
x14: ffffff8001d91d40 x13: 0000000000000016 x12: ffffffc080e98930
x11: ffffff8001eb2880 x10: 0000000000000890 x9 : ffffff8001d7a9f0 x8 : ffffff8001d92570 x7 : ffffff80efeeac80 x6 : 000000003fc6e780 x5 : ffffff8001d91c80 x4 : 0000000000000002 x3 : 0000000000000000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000001
Call trace: gpiod_set_value+0x74/0x7c ar0521_power_on+0xcc/0x290
...
--- drivers/media/i2c/ar0521.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/ar0521.c +3 -2
@@ -844,7 +844,8 @@ static int ar0521_power_off(struct devicclk_disable_unprepare (sensor->extclk);if (sensor->reset_gpio) -gpiod_set_value (sensor->reset_gpio,1 );/* assert RESET signal */ +/* assert RESET signal */ +gpiod_set_value_cansleep (sensor->reset_gpio,1 );for (i =ARRAY_SIZE (ar0521_supply_names) -1 ; i >=0 ; i--) {if (sensor->supplies[i])
@@ -878,7 +879,7 @@ static int ar0521_power_on(struct deviceif (sensor->reset_gpio)/* deassert RESET signal */ -gpiod_set_value (sensor->reset_gpio,0 ); +gpiod_set_value_cansleep (sensor->reset_gpio,0 );usleep_range (4500 ,5000 );/* min 45000 clocks */ for (cnt =0 ; cnt <ARRAY_SIZE (initial_regs); cnt++) {
Greg Kroah-Hartman
maintainerPATCH 296/482 i2c: core: Lock address during client device instantiation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit 8d3cefaf659265aa82b0373a563fdb9d16a2b947 upstream.
Krzysztof reported an issue [0] which is caused by parallel attempts to instantiate the same I2C client device. This can happen if driver supports auto-detection, but certain devices are also instantiated explicitly.
The original change isn't actually wrong, it just revealed that I2C core isn't prepared yet to handle this scenario.
Calls to i2c_new_client_device() can be nested, therefore we can't use a simple mutex here. Parallel instantiation of devices at different addresses is ok, so we just have to prevent parallel instantiation at the same address. We can use a bitmap with one bit per 7-bit I2C client address, and atomic bit operations to set/check/clear bits.
Now a parallel attempt to instantiate a device at the same address will result in -EBUSY being returned, avoiding the "sysfs: cannot create duplicate filename" splash.
Note: This patch version includes small cosmetic changes to the Tested-by
version, only functional change is that address locking is supported for slave addresses too.
[0] https://lore.kernel.org/linux-i2c/[email protected]/T/#m12706546e8e2414d8f1a0dc61c53393f731685cc
--- drivers/i2c/i2c-core-base.c | 28 ++++++++++++++++++++++++++++ include/linux/i2c.h | 3 +++ 2 files changed, 31 insertions(+)
drivers/i2c/i2c-core-base.c +28 -0
@@ -915,6 +915,27 @@ int i2c_dev_irq_from_resources(const strreturn 0 ; } +/* +* Serialize device instantiation in case it can be instantiated explicitly +* and by auto-detection +*/ +static int i2c_lock_addr (struct i2c_adapter *adap,unsigned short addr, +unsigned short flags) +{ +if (!(flags &I2C_CLIENT_TEN ) && +test_and_set_bit (addr, adap->addrs_in_instantiation)) +return -EBUSY ; + +return 0 ; +} + +static void i2c_unlock_addr (struct i2c_adapter *adap,unsigned short addr, +unsigned short flags) +{ +if (!(flags &I2C_CLIENT_TEN )) +clear_bit (addr, adap->addrs_in_instantiation); +} +/** * i2c_new_client_device - instantiate an i2c device * @adap: the adapter managing the device
@@ -962,6 +983,10 @@ i2c_new_client_device(struct i2c_adapter goto out_err_silent; } + status =i2c_lock_addr (adap, client->addr, client->flags); +if (status) + goto out_err_silent; +/* Check for address business */ status =i2c_check_addr_busy (adap,i2c_encode_flags_to_addr (client));if (status)
@@ -993,6 +1018,8 @@ i2c_new_client_device(struct i2c_adapterdev_dbg (&adap->dev,"client [%s] registered with bus id %s\n" , client->name,dev_name (&client->dev)); +i2c_unlock_addr (adap, client->addr, client->flags); +return client; out_remove_swnode:
@@ -1004,6 +1031,7 @@ out_err:dev_err (&adap->dev,"Failed to register i2c client %s at 0x%02x (%d)\n" , client->name, client->addr, status); +i2c_unlock_addr (adap, client->addr, client->flags); out_err_silent:if (need_put)put_device (&client->dev);
include/linux/i2c.h +3 -0
@@ -748,6 +748,9 @@ struct i2c_adapter {struct regulator *bus_regulator;struct dentry *debugfs; + +/* 7bit address space */ +DECLARE_BITMAP (addrs_in_instantiation,1 <<7 ); };#define to_i2c_adapter (d) container_of(d, struct i2c_adapter, dev)
Greg Kroah-Hartman
maintainerPATCH 297/482 i2c: xiic: Fix pm_runtime_set_suspended() with runtime pm enabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
commit 0c8d604dea437b69a861479b413d629bc9b3da70 upstream.
It is not valid to call pm_runtime_set_suspended() for devices with runtime PM enabled because it returns -EAGAIN if it is enabled already and working. So, call pm_runtime_disable() before to fix it.
--- drivers/i2c/busses/i2c-xiic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-xiic.c +1 -1
@@ -1337,8 +1337,8 @@ static int xiic_i2c_probe(struct platforreturn 0 ; err_pm_disable: -pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev);return ret; }
Greg Kroah-Hartman
maintainerPATCH 298/482 i2c: designware: fix controller is holding SCL low while ENABLE bit is disabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kimriver Liu <[email protected]>
commit 5d69d5a00f80488ddcb4dee7d1374a0709398178 upstream.
It was observed that issuing the ABORT bit (IC_ENABLE[1]) will not work when IC_ENABLE is already disabled.
Check if the ENABLE bit (IC_ENABLE[0]) is disabled when the controller is holding SCL low. If the ENABLE bit is disabled, the software needs to enable it before trying to issue the ABORT bit. otherwise, the controller ignores any write to ABORT bit.
These kernel logs show up whenever an I2C transaction is attempted after this failure.i2c_designware e95e0000.i2c: timeout waiting for bus ready i2c_designware e95e0000.i2c: timeout in disabling adapter
The patch fixes the issue where the controller cannot be disabled while SCL is held low if the ENABLE bit is already disabled.
--- drivers/i2c/busses/i2c-designware-common.c | 14 ++++++++++ drivers/i2c/busses/i2c-designware-core.h | 1 drivers/i2c/busses/i2c-designware-master.c | 38 +++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+)
drivers/i2c/busses/i2c-designware-common.c +14 -0
@@ -441,6 +441,7 @@ err_release_lock:void __i2c_dw_disable (struct dw_i2c_dev *dev) { +struct i2c_timings *t = &dev->timings;unsigned int raw_intr_stats;unsigned int enable;int timeout =100 ;
@@ -453,6 +454,19 @@ void __i2c_dw_disable(struct dw_i2c_dev abort_needed = raw_intr_stats &DW_IC_INTR_MST_ON_HOLD ;if (abort_needed) { +if (!(enable &DW_IC_ENABLE_ENABLE )) { +regmap_write (dev->map,DW_IC_ENABLE ,DW_IC_ENABLE_ENABLE ); +/* +* Wait 10 times the signaling period of the highest I2C +* transfer supported by the driver (for 400KHz this is +* 25us) to ensure the I2C ENABLE bit is already set +* as described in the DesignWare I2C databook. +*/ +fsleep (DIV_ROUND_CLOSEST_ULL (10 *MICRO , t->bus_freq_hz)); +/* Set ENABLE bit before setting ABORT */ + enable |=DW_IC_ENABLE_ENABLE ; + } +regmap_write (dev->map,DW_IC_ENABLE , enable |DW_IC_ENABLE_ABORT ); ret = regmap_read_poll_timeout(dev->map, DW_IC_ENABLE, enable, !(enable & DW_IC_ENABLE_ABORT), 10,
drivers/i2c/busses/i2c-designware-core.h +1 -0
@@ -109,6 +109,7 @@ DW_IC_INTR_RX_UNDER | \ DW_IC_INTR_RD_REQ) +#define DW_IC_ENABLE_ENABLE BIT(0)#define DW_IC_ENABLE_ABORT BIT(1)#define DW_IC_STATUS_ACTIVITY BIT(0)
drivers/i2c/busses/i2c-designware-master.c +38 -0
@@ -253,6 +253,34 @@ static void i2c_dw_xfer_init(struct dw_i__i2c_dw_write_intr_mask (dev,DW_IC_INTR_MASTER_MASK ); } +/* +* This function waits for the controller to be idle before disabling I2C +* When the controller is not in the IDLE state, the MST_ACTIVITY bit +* (IC_STATUS[5]) is set. +* +* Values: +* 0x1 (ACTIVE): Controller not idle +* 0x0 (IDLE): Controller is idle +* +* The function is called after completing the current transfer. +* +* Returns: +* False when the controller is in the IDLE state. +* True when the controller is in the ACTIVE state. +*/ +static bool i2c_dw_is_controller_active (struct dw_i2c_dev *dev) +{ +u32 status; + +regmap_read (dev->map,DW_IC_STATUS , &status); +if (!(status &DW_IC_STATUS_MASTER_ACTIVITY )) +return false; + +return regmap_read_poll_timeout (dev->map,DW_IC_STATUS , status, + !(status &DW_IC_STATUS_MASTER_ACTIVITY ), +1100 ,20000 ) !=0 ; +} +static int i2c_dw_check_stopbit (struct dw_i2c_dev *dev) {u32 val;
@@ -789,6 +817,16 @@ i2c_dw_xfer(struct i2c_adapter *adap, st }/* +* This happens rarely (~1:500) and is hard to reproduce. Debug trace +* showed that IC_STATUS had value of 0x23 when STOP_DET occurred, +* if disable IC_ENABLE.ENABLE immediately that can result in +* IC_RAW_INTR_STAT.MASTER_ON_HOLD holding SCL low. Check if +* controller is still ACTIVE before disabling I2C. +*/ +if (i2c_dw_is_controller_active (dev)) +dev_err (dev->dev,"controller active\n" ); + +/* * We must disable the adapter before returning and signaling the end * of the current transfer. Otherwise the hardware might continue * generating interrupts which in turn causes a race condition with
Greg Kroah-Hartman
maintainerPATCH 299/482 i2c: synquacer: Deal with optional PCLK correctly
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit f2990f8630531a99cad4dc5c44cb2a11ded42492 upstream.
ACPI boot does not provide clocks and regulators, but instead, provides the PCLK rate directly, and enables the clock in firmware. So deal gracefully with this.
--- drivers/i2c/busses/i2c-synquacer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-synquacer.c +3 -2
@@ -550,12 +550,13 @@ static int synquacer_i2c_probe(struct pldevice_property_read_u32 (&pdev->dev,"socionext,pclk-rate" , &i2c->pclkrate); - pclk =devm_clk_get_enabled (&pdev->dev,"pclk" ); + pclk =devm_clk_get_optional_enabled (&pdev->dev,"pclk" );if (IS_ERR (pclk))return dev_err_probe (&pdev->dev,PTR_ERR (pclk),"failed to get and enable clock\n" ); - i2c->pclkrate =clk_get_rate (pclk); +if (pclk) + i2c->pclkrate =clk_get_rate (pclk);if (i2c->pclkrate <SYNQUACER_I2C_MIN_CLK_RATE || i2c->pclkrate >SYNQUACER_I2C_MAX_CLK_RATE )
Greg Kroah-Hartman
maintainerPATCH 300/482 rust: sync: require `T: Sync` for `LockedBy::access`
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Ryhl <[email protected]>
commit a8ee30f45d5d57467ddb7877ed6914d0eba0af7f upstream.
The LockedBy::access method only requires a shared reference to the owner, so if we have shared access to the LockedBy from several threads at once, then two threads could call access in parallel and both obtain a shared reference to the inner value. Thus, require that T: Sync when calling the access method.
An alternative is to require T: Sync in the impl Sync for LockedBy. This patch does not choose that approach as it gives up the ability to use LockedBy with !Sync types, which is okay as long as you only use access_mut.
--- rust/kernel/sync/locked_by.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
rust/kernel/sync/locked_by.rs +14 -4
@@ -83,8 +83,12 @@ pub struct LockedBy<T: ?Sized, U: ?Sized// SAFETY: `LockedBy` can be transferred across thread boundaries iff the data it protects can. unsafe impl <T : ?Sized +Send ,U : ?Sized >Send for LockedBy <T ,U > {} -// SAFETY: `LockedBy` serialises the interior mutability it provides, so it is `Sync` as long as the -// data it protects is `Send`. +// SAFETY: If `T` is not `Sync`, then parallel shared access to this `LockedBy` allows you to use +// `access_mut` to hand out `&mut T` on one thread at the time. The requirement that `T: Send` is +// sufficient to allow that. +// +// If `T` is `Sync`, then the `access` method also becomes available, which allows you to obtain +// several `&T` from several threads at once. However, this is okay as `T` is `Sync`. unsafe impl <T : ?Sized +Send ,U : ?Sized >Sync for LockedBy <T ,U > {}impl <T ,U >LockedBy <T ,U > {
@@ -118,7 +122,10 @@ impl<T: ?Sized, U> LockedBy<T, U> {/// /// Panics if `owner` is different from the data protected by the lock used in /// [`new`](LockedBy::new). -pub fn access <'a>(&'a self, owner: &'aU ) -> &'aT { +pub fn access <'a>(&'a self, owner: &'aU ) -> &'aT +where +T :Sync , + {build_assert! (size_of ::<U >() >0 ,"`U` cannot be a ZST because `owner` wouldn't be unique"
@@ -127,7 +134,10 @@ impl<T: ?Sized, U> LockedBy<T, U> {panic! ("mismatched owners" ); } -// SAFETY: `owner` is evidence that the owner is locked. +// SAFETY: `owner` is evidence that there are only shared references to the owner for the +// duration of 'a, so it's not possible to use `Self::access_mut` to obtain a mutable +// reference to the inner value that aliases with this shared reference. The type is `Sync` +// so there are no other requirements. unsafe { &*self.data.get () } }
Greg Kroah-Hartman
maintainerPATCH 301/482 ovl: fail if trusted xattrs are needed but caller lacks permission
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Baynton <[email protected]>
commit 6c4a5f96450415735c31ed70ff354f0ee5cbf67b upstream.
Some overlayfs features require permission to read/write trusted.* xattrs. These include redirect_dir, verity, metacopy, and data-only layers. This patch adds additional validations at mount time to stop overlays from mounting in certain cases where the resulting mount would not function according to the user's expectations because they lack permission to access trusted.* xattrs (for example, not global root.)
Similar checks in ovl_make_workdir() that disable features instead of failing are still relevant and used in cases where the resulting mount can still work "reasonably well." Generally, if the feature was enabled through kernel config or module option, any mount that worked before will still work the same; this applies to redirect_dir and metacopy. The user must explicitly request these features in order to generate a mount failure. Verity and data-only layers on the other hand must be explictly requested and have no "reasonable" disabled or degraded alternative, so mounts attempting either always fail.
"lower data-only dirs require metacopy support" moved down in case userxattr is set, which disables metacopy.
--- fs/overlayfs/params.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-)
fs/overlayfs/params.c +33 -5
@@ -782,11 +782,6 @@ int ovl_fs_params_verify(const struct ov {struct ovl_opt_set set = ctx->set; -if (ctx->nr_data >0 && !config->metacopy) { -pr_err ("lower data-only dirs require metacopy support.\n" ); -return -EINVAL ; - } -/* Workdir/index are useless in non-upper mount */ if (!config->upperdir) {if (config->workdir) {
@@ -938,6 +933,39 @@ int ovl_fs_params_verify(const struct ov config->metacopy = false; } +/* +* Fail if we don't have trusted xattr capability and a feature was +* explicitly requested that requires them. +*/ +if (!config->userxattr && !capable (CAP_SYS_ADMIN )) { +if (set.redirect && + config->redirect_mode !=OVL_REDIRECT_NOFOLLOW ) { +pr_err ("redirect_dir requires permission to access trusted xattrs\n" ); +return -EPERM ; + } +if (config->metacopy && set.metacopy) { +pr_err ("metacopy requires permission to access trusted xattrs\n" ); +return -EPERM ; + } +if (config->verity_mode) { +pr_err ("verity requires permission to access trusted xattrs\n" ); +return -EPERM ; + } +if (ctx->nr_data >0 ) { +pr_err ("lower data-only dirs require permission to access trusted xattrs\n" ); +return -EPERM ; + } +/* +* Other xattr-dependent features should be disabled without +* great disturbance to the user in ovl_make_workdir(). +*/ + } + +if (ctx->nr_data >0 && !config->metacopy) { +pr_err ("lower data-only dirs require metacopy support.\n" ); +return -EINVAL ; + } +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 302/482 firmware: tegra: bpmp: Drop unused mbox_client_to_bpmp()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 9c3a62c20f7fb00294a4237e287254456ba8a48b upstream.
mbox_client_to_bpmp() is not used, W=1 builds:
drivers/firmware/tegra/bpmp.c:28:1: error: unused function 'mbox_client_to_bpmp' [-Werror,-Wunused-function]
--- drivers/firmware/tegra/bpmp.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/firmware/tegra/bpmp.c +0 -6
@@ -24,12 +24,6 @@#define MSG_RING BIT(1)#define TAG_SZ 32 -static inline struct tegra_bpmp * -mbox_client_to_bpmp (struct mbox_client *client) -{ - return container_of(client, struct tegra_bpmp, mbox.client); -} -static inline const struct tegra_bpmp_ops *channel_to_ops (struct tegra_bpmp_channel *channel) {
Greg Kroah-Hartman
maintainerPATCH 303/482 memory: tegra186-emc: drop unused to_tegra186_emc()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 67dd9e861add38755a7c5d29e25dd0f6cb4116ab upstream.
to_tegra186_emc() is not used, W=1 builds:
tegra186-emc.c:38:36: error: unused function 'to_tegra186_emc' [-Werror,-Wunused-function]
--- drivers/memory/tegra/tegra186-emc.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/memory/tegra/tegra186-emc.c +0 -5
@@ -35,11 +35,6 @@ struct tegra186_emc {struct icc_provider provider; }; -static inline struct tegra186_emc *to_tegra186_emc (struct icc_provider *provider) -{ - return container_of(provider, struct tegra186_emc, provider); -} -/* * debugfs interface *
Greg Kroah-Hartman
maintainerPATCH 304/482 dt-bindings: clock: exynos7885: Fix duplicated binding
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Virag <[email protected]>
commit abf3a3ea9acb5c886c8729191a670744ecd42024 upstream.
The numbering in Exynos7885's FSYS CMU bindings has 4 duplicated by accident, with the rest of the bindings continuing with 5.
Fix this by moving CLK_MOUT_FSYS_USB30DRD_USER to the end as 11.
Since CLK_MOUT_FSYS_USB30DRD_USER is not used in any device tree as of now, and there are no other clocks affected (maybe apart from CLK_MOUT_FSYS_MMC_SDIO_USER which the number was shared with, also not used in a device tree), this is the least impactful way to solve this problem.
--- include/dt-bindings/clock/exynos7885.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/dt-bindings/clock/exynos7885.h +1 -1
@@ -136,12 +136,12 @@#define CLK_MOUT_FSYS_MMC_CARD_USER 2#define CLK_MOUT_FSYS_MMC_EMBD_USER 3#define CLK_MOUT_FSYS_MMC_SDIO_USER 4 -#define CLK_MOUT_FSYS_USB30DRD_USER 4#define CLK_GOUT_MMC_CARD_ACLK 5#define CLK_GOUT_MMC_CARD_SDCLKIN 6#define CLK_GOUT_MMC_EMBD_ACLK 7#define CLK_GOUT_MMC_EMBD_SDCLKIN 8#define CLK_GOUT_MMC_SDIO_ACLK 9#define CLK_GOUT_MMC_SDIO_SDCLKIN 10 +#define CLK_MOUT_FSYS_USB30DRD_USER 11#endif /* _DT_BINDINGS_CLOCK_EXYNOS_7885_H */
Greg Kroah-Hartman
maintainerPATCH 305/482 spi: bcm63xx: Fix module autoloading
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
commit 909f34f2462a99bf876f64c5c61c653213e32fce upstream.
Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from platform_device_id table.
--- drivers/spi/spi-bcm63xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-bcm63xx.c +1 -0
@@ -466,6 +466,7 @@ static const struct platform_device_id b { }, }; +MODULE_DEVICE_TABLE (platform, bcm63xx_spi_dev_match);static const struct of_device_id bcm63xx_spi_of_match[] = { { .compatible ="brcm,bcm6348-spi" , .data = &bcm6348_spi_reg_offsets },
Greg Kroah-Hartman
maintainerPATCH 306/482 spi: bcm63xx: Fix missing pm_runtime_disable()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
commit 265697288ec2160ca84707565d6641d46f69b0ff upstream.
The pm_runtime_disable() is missing in the remove function, fix it by using devm_pm_runtime_enable(), so the pm_runtime_disable() in the probe error path can also be removed.
--- drivers/spi/spi-bcm63xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-bcm63xx.c +4 -4
@@ -584,13 +584,15 @@ static int bcm63xx_spi_probe(struct platbcm_spi_writeb (bs,SPI_INTR_CLEAR_ALL ,SPI_INT_STATUS ); -pm_runtime_enable (&pdev->dev); + ret =devm_pm_runtime_enable (&pdev->dev); +if (ret) + goto out_clk_disable;/* register and we are done */ ret =devm_spi_register_controller (dev, host);if (ret) {dev_err (dev,"spi register failed\n" ); - goto out_pm_disable; + goto out_clk_disable; } dev_info(dev, "at %pr (irq %d, FIFOs size %d)\n",
@@ -598,8 +600,6 @@ static int bcm63xx_spi_probe(struct platreturn 0 ; -out_pm_disable: -pm_runtime_disable (&pdev->dev); out_clk_disable:clk_disable_unprepare (clk); out_err:
Greg Kroah-Hartman
maintainerPATCH 307/482 power: supply: hwmon: Fix missing temp1_max_alarm attribute
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit e50a57d16f897e45de1112eb6478577b197fab52 upstream.
Temp channel 0 aka temp1 can have a temp1_max_alarm attribute for power_supply devices which have a POWER_SUPPLY_PROP_TEMP_ALERT_MAX property.
HWMON_T_MAX_ALARM was missing from power_supply_hwmon_info for temp channel 0, causing the hwmon temp1_max_alarm attribute to be missing from such power_supply devices.
Add this to power_supply_hwmon_info to fix this.
--- drivers/power/supply/power_supply_hwmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/power_supply_hwmon.c +2 -1
@@ -299,7 +299,8 @@ static const struct hwmon_channel_info *HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MIN | -HWMON_T_MIN_ALARM , +HWMON_T_MIN_ALARM | +HWMON_T_MAX_ALARM ,HWMON_T_LABEL | HWMON_T_INPUT |
Greg Kroah-Hartman
maintainerPATCH 308/482 mm, slub: avoid zeroing kmalloc redzone
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
commit 59090e479ac78ae18facd4c58eb332562a23020e upstream.
Since commit 946fa0dbf2d8 ("mm/slub: extend redzone check to extra allocated kmalloc space than requested"), setting orig_size treats the wasted space (object_size - orig_size) as a redzone. However with init_on_free=1 we clear the full object->size, including the redzone.
Additionally we clear the object metadata, including the stored orig_size, making it zero, which makes check_object() treat the whole object as a redzone.
These issues lead to the following BUG report with "slub_debug=FUZ init_on_free=1":
[ 0.000000] ============================================================================= [ 0.000000] BUG kmalloc-8 (Not tainted): kmalloc Redzone overwritten [ 0.000000] ----------------------------------------------------------------------------- [ 0.000000] [ 0.000000] 0xffff000010032858-0xffff00001003285f @offset=2136. First byte 0x0 instead of 0xcc [ 0.000000] FIX kmalloc-8: Restoring kmalloc Redzone 0xffff000010032858-0xffff00001003285f=0xcc [ 0.000000] Slab 0xfffffdffc0400c80 objects=36 used=23 fp=0xffff000010032a18 flags=0x3fffe0000000200(workingset|node=0|zone=0|lastcpupid=0x1ffff) [ 0.000000] Object 0xffff000010032858 @offset=2136 fp=0xffff0000100328c8 [ 0.000000] [ 0.000000] Redzone ffff000010032850: cc cc cc cc cc cc cc cc ........ [ 0.000000] Object ffff000010032858: cc cc cc cc cc cc cc cc ........ [ 0.000000] Redzone ffff000010032860: cc cc cc cc cc cc cc cc ........ [ 0.000000] Padding ffff0000100328b4: 00 00 00 00 00 00 00 00 00 00 00 00 ............ [ 0.000000] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.11.0-rc3-next-20240814-00004-g61844c55c3f4 #144 [ 0.000000] Hardware name: NXP i.MX95 19X19 board (DT) [ 0.000000] Call trace: [ 0.000000] dump_backtrace+0x90/0xe8 [ 0.000000] show_stack+0x18/0x24 [ 0.000000] dump_stack_lvl+0x74/0x8c [ 0.000000] dump_stack+0x18/0x24 [ 0.000000] print_trailer+0x150/0x218 [ 0.000000] check_object+0xe4/0x454 [ 0.000000] free_to_partial_list+0x2f8/0x5ec
To address the issue, use orig_size to clear the used area. And restore the value of orig_size after clear the remaining area.
When CONFIG_SLUB_DEBUG not defined, (get_orig_size()' directly returns s->object_size. So when using memset to init the area, the size can simply be orig_size, as orig_size returns object_size when CONFIG_SLUB_DEBUG not enabled. And orig_size can never be bigger than object_size.
--- mm/slub.c | 100 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 47 deletions(-)
mm/slub.c +53 -47
@@ -756,6 +756,50 @@ static inline bool slab_update_freelist(return false; } +/* +* kmalloc caches has fixed sizes (mostly power of 2), and kmalloc() API +* family will round up the real request size to these fixed ones, so +* there could be an extra area than what is requested. Save the original +* request size in the meta data area, for better debug and sanity check. +*/ +static inline void set_orig_size (struct kmem_cache *s, +void *object,unsigned int orig_size) +{ +void *p =kasan_reset_tag (object); +unsigned int kasan_meta_size; + +if (!slub_debug_orig_size (s)) +return ; + +/* +* KASAN can save its free meta data inside of the object at offset 0. +* If this meta data size is larger than 'orig_size', it will overlap +* the data redzone in [orig_size+1, object_size]. Thus, we adjust +* 'orig_size' to be as at least as big as KASAN's meta data. +*/ + kasan_meta_size =kasan_metadata_size (s, true); +if (kasan_meta_size > orig_size) + orig_size = kasan_meta_size; + + p +=get_info_end (s); + p +=sizeof (struct track ) *2 ; + + *(unsigned int *)p = orig_size; +} + +static inline unsigned int get_orig_size (struct kmem_cache *s,void *object) +{ +void *p =kasan_reset_tag (object); + +if (!slub_debug_orig_size (s)) +return s->object_size; + + p +=get_info_end (s); + p +=sizeof (struct track ) *2 ; + +return *(unsigned int *)p; +} +#ifdef CONFIG_SLUB_DEBUG static unsigned long object_map[BITS_TO_LONGS (MAX_OBJS_PER_PAGE )];static DEFINE_SPINLOCK (object_map_lock);
@@ -969,50 +1013,6 @@ static void print_slab_info(const struct folio_flags(folio, 0)); } -/* -* kmalloc caches has fixed sizes (mostly power of 2), and kmalloc() API -* family will round up the real request size to these fixed ones, so -* there could be an extra area than what is requested. Save the original -* request size in the meta data area, for better debug and sanity check. -*/ -static inline void set_orig_size (struct kmem_cache *s, -void *object,unsigned int orig_size) -{ -void *p =kasan_reset_tag (object); -unsigned int kasan_meta_size; - -if (!slub_debug_orig_size (s)) -return ; - -/* -* KASAN can save its free meta data inside of the object at offset 0. -* If this meta data size is larger than 'orig_size', it will overlap -* the data redzone in [orig_size+1, object_size]. Thus, we adjust -* 'orig_size' to be as at least as big as KASAN's meta data. -*/ - kasan_meta_size =kasan_metadata_size (s, true); -if (kasan_meta_size > orig_size) - orig_size = kasan_meta_size; - - p +=get_info_end (s); - p +=sizeof (struct track ) *2 ; - - *(unsigned int *)p = orig_size; -} - -static inline unsigned int get_orig_size (struct kmem_cache *s,void *object) -{ -void *p =kasan_reset_tag (object); - -if (!slub_debug_orig_size (s)) -return s->object_size; - - p +=get_info_end (s); - p +=sizeof (struct track ) *2 ; - -return *(unsigned int *)p; -} -void skip_orig_size_check (struct kmem_cache *s,const void *object) {set_orig_size (s, (void *)object, s->object_size);
@@ -1859,7 +1859,6 @@ static inline void inc_slabs_node(struct int objects) {}static inline void dec_slabs_node (struct kmem_cache *s,int node,int objects) {} -#ifndef CONFIG_SLUB_TINY static bool freelist_corrupted (struct kmem_cache *s,struct slab *slab,void **freelist,void *nextfree)
@@ -2187,14 +2186,21 @@ bool slab_free_hook(struct kmem_cache *s*/ if (unlikely (init)) {int rsize; -unsigned int inuse; +unsigned int inuse, orig_size; inuse =get_info_end (s); + orig_size =get_orig_size (s, x);if (!kasan_has_integrated_init ()) -memset (kasan_reset_tag (x),0 , s->object_size); +memset (kasan_reset_tag (x),0 , orig_size); rsize = (s->flags &SLAB_RED_ZONE ) ? s->red_left_pad :0 ;memset ((char *)kasan_reset_tag (x) + inuse,0 , s->size - inuse - rsize); +/* +* Restore orig_size, otherwize kmalloc redzone overwritten +* would be reported +*/ +set_orig_size (s, x, orig_size); + }/* KASAN might put x into memory quarantine, delaying its reuse. */ return !kasan_slab_free (s, x, init);
Greg Kroah-Hartman
maintainerPATCH 309/482 perf/core: Fix small negative period being ignored
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luo Gengkun <[email protected]>
commit 62c0b1061593d7012292f781f11145b2d46f43ab upstream.
In perf_adjust_period, we will first calculate period, and then use this period to calculate delta. However, when delta is less than 0, there will be a deviation compared to when delta is greater than or equal to 0. For example, when delta is in the range of [-14,-1], the range of delta = delta + 7 is between [-7,6], so the final value of delta/8 is 0. Therefore, the impact of -1 and -2 will be ignored. This is unacceptable when the target period is very short, because we will lose a lot of samples.
Here are some tests and analyzes:
before:
# perf record -e cs -F 1000 ./a.out [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.022 MB perf.data (518 samples) ]
# perf script ... a.out 396 257.956048: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.957891: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.959730: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.961545: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.963355: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.965163: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.966973: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.968785: 23 cs: ffffffff81f4eeec schedul> a.out 396 257.970593: 23 cs: ffffffff81f4eeec schedul> ...
after:
# perf record -e cs -F 1000 ./a.out [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.058 MB perf.data (1466 samples) ]
# perf script ... a.out 395 59.338813: 11 cs: ffffffff81f4eeec schedul> a.out 395 59.339707: 12 cs: ffffffff81f4eeec schedul> a.out 395 59.340682: 13 cs: ffffffff81f4eeec schedul> a.out 395 59.341751: 13 cs: ffffffff81f4eeec schedul> a.out 395 59.342799: 12 cs: ffffffff81f4eeec schedul> a.out 395 59.343765: 11 cs: ffffffff81f4eeec schedul> a.out 395 59.344651: 11 cs: ffffffff81f4eeec schedul> a.out 395 59.345539: 12 cs: ffffffff81f4eeec schedul> a.out 395 59.346502: 13 cs: ffffffff81f4eeec schedul> ...
test.c
int main() {
for (int i = 0; i < 20000; i++)
usleep(10);
return 0;
}# time ./a.out real 0m1.583s user 0m0.040s sys 0m0.298s
The above results were tested on x86-64 qemu with KVM enabled using test.c as test program. Ideally, we should have around 1500 samples, but the previous algorithm had only about 500, whereas the modified algorithm now has about 1400. Further more, the new version shows 1 sample per 0.001s, while the previous one is 1 sample per 0.002s.This indicates that the new algorithm is more sensitive to small negative values compared to old algorithm.
--- kernel/events/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/events/core.c +5 -1
@@ -4107,7 +4107,11 @@ static void perf_adjust_period(struct pe period =perf_calculate_period (event, nsec, count); delta = (s64)(period - hwc->sample_period); - delta = (delta +7 ) /8 ;/* low pass filter */ +if (delta >=0 ) + delta +=7 ; +else + delta -=7 ; + delta /=8 ;/* low pass filter */ sample_period = hwc->sample_period + delta;
Greg Kroah-Hartman
maintainerPATCH 310/482 drm/v3d: Prevent out of bounds access in performance query extensions
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
commit f32b5128d2c440368b5bf3a7a356823e235caabb upstream.
Check that the number of perfmons userspace is passing in the copy and reset extensions is not greater than the internal kernel storage where the ids will be copied into.
--- drivers/gpu/drm/v3d/v3d_submit.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/v3d/v3d_submit.c +6 -0
@@ -671,6 +671,9 @@ v3d_get_cpu_reset_performance_params(strif (reset.nperfmons >V3D_MAX_PERFMONS )return -EINVAL ; +if (reset.nperfmons >V3D_MAX_PERFMONS ) +return -EINVAL ; + job->job_type =V3D_CPU_JOB_TYPE_RESET_PERFORMANCE_QUERY ; job->performance_query.queries = kvmalloc_array(reset.count,
@@ -753,6 +756,9 @@ v3d_get_cpu_copy_performance_query_paramreturn -EINVAL ;if (copy.nperfmons >V3D_MAX_PERFMONS ) +return -EINVAL ; + +if (copy.nperfmons >V3D_MAX_PERFMONS )return -EINVAL ; job->job_type =V3D_CPU_JOB_TYPE_COPY_PERFORMANCE_QUERY ;
Greg Kroah-Hartman
maintainerPATCH 311/482 parisc: Fix itlb miss handler for 64-bit programs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 9542130937e9dc707dd7c6b7af73326437da2d50 upstream.
For an itlb miss when executing code above 4 Gb on ILP64 adjust the iasq/iaoq in the same way isr/ior was adjusted. This fixes signal delivery for the 64-bit static test program from
http://ftp.parisc-linux.org/src/64bit.tar.gz. Note that signals are handled by the signal trampoline code in the 64-bit VDSO which is mapped into high userspace memory region above 4GB for 64-bit processes.
--- arch/parisc/kernel/entry.S | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/parisc/kernel/entry.S +2 -4
@@ -1051,8 +1051,7 @@ ENTRY_CFI(intr_save) /* for os_hpmc */ STREG %r16, PT_ISR(%r29) STREG %r17, PT_IOR(%r29) -#if 0 && defined(CONFIG_64BIT) - /* Revisit when we have 64-bit code above 4Gb */ +#if defined(CONFIG_64BIT) b,n intr_save2 skip_save_ior:
@@ -1060,8 +1059,7 @@ skip_save_ior: * need to adjust iasq/iaoq here in the same way we adjusted isr/ior * above. */ - extrd,u,* %r8,PSW_W_BIT,1,%r1 - cmpib,COND(=),n 1,%r1,intr_save2 + bb,COND(>=),n %r8,PSW_W_BIT,intr_save2 LDREG PT_IASQ0(%r29), %r16 LDREG PT_IAOQ0(%r29), %r17 /* adjust iasq/iaoq */
Greg Kroah-Hartman
maintainerPATCH 312/482 drm/mediatek: ovl_adaptor: Add missing of_node_put()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
commit 5beb6fba25db235b52eab34bde8112f07bb31d75 upstream.
Error paths that exit for_each_child_of_node() need to call of_node_put() to decerement the child refcount and avoid memory leaks.
Add the missing of_node_put().
--- drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +3 -1
@@ -523,8 +523,10 @@ static int ovl_adaptor_comp_init(struct } comp_pdev =of_find_device_by_node (node); -if (!comp_pdev) +if (!comp_pdev) { +of_node_put (node);return -EPROBE_DEFER ; + } priv->ovl_adaptor_comp[id] = &comp_pdev->dev;
Greg Kroah-Hartman
maintainerPATCH 313/482 drm: Consistently use struct drm_mode_rect for FB_DAMAGE_CLIPS
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
commit 8b0d2f61545545ab5eef923ed6e59fc3be2385e0 upstream.
FB_DAMAGE_CLIPS is a plane property for damage handling. Its UAPI should only use UAPI types. Hence replace struct drm_rect with struct drm_mode_rect in drm_atomic_plane_set_property(). Both types are identical in practice, so there's no change in behavior.
--- drivers/gpu/drm/drm_atomic_uapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_uapi.c +1 -1
@@ -543,7 +543,7 @@ static int drm_atomic_plane_set_property &state->fb_damage_clips, val,-1 , -sizeof (struct drm_rect ), +sizeof (struct drm_mode_rect ), &replaced);return ret; }else if (property == plane->scaling_filter_property) {
Greg Kroah-Hartman
maintainerPATCH 314/482 ALSA: hda/tas2781: Add new quirk for Lenovo Y990 Laptop
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baojun Xu <[email protected]>
commit 49f5ee951f11f4d6a124f00f71b2590507811a55 upstream.
Add new vendor_id and subsystem_id in quirk for Lenovo Y990 Laptop.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10651,6 +10651,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x17aa ,0x38cd ,"Y790 VECO DUAL" ,ALC287_FIXUP_TAS2781_I2C ),SND_PCI_QUIRK (0x17aa ,0x38d2 ,"Lenovo Yoga 9 14IMH9" ,ALC287_FIXUP_YOGA9_14IMH9_BASS_SPK_PIN ),SND_PCI_QUIRK (0x17aa ,0x38d7 ,"Lenovo Yoga 9 14IMH9" ,ALC287_FIXUP_YOGA9_14IMH9_BASS_SPK_PIN ), +SND_PCI_QUIRK (0x17aa ,0x38df ,"Y990 YG DUAL" ,ALC287_FIXUP_TAS2781_I2C ),SND_PCI_QUIRK (0x17aa ,0x38f9 ,"Thinkbook 16P Gen5" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x38fa ,"Thinkbook 16P Gen5" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
Greg Kroah-Hartman
maintainerPATCH 315/482 ALSA: core: add isascii() check to card ID generator
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaroslav Kysela <[email protected]>
commit d278a9de5e1837edbe57b2f1f95a104ff6c84846 upstream.
The card identifier should contain only safe ASCII characters. The isalnum() returns true also for characters for non-ASCII characters.
--- sound/core/init.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sound/core/init.c +10 -4
@@ -654,13 +654,19 @@ void snd_card_free(struct snd_card *card }EXPORT_SYMBOL (snd_card_free); +/* check, if the character is in the valid ASCII range */ +static inline bool safe_ascii_char (char c) +{ +return isascii (c) &&isalnum (c); +} +/* retrieve the last word of shortname or longname */ static const char *retrieve_id_from_card_name (const char *name) {const char *spos = name;while (*name) { -if (isspace (*name) &&isalnum (name[1 ])) +if (isspace (*name) &&safe_ascii_char (name[1 ])) spos = name +1 ; name++; }
@@ -687,12 +693,12 @@ static void copy_valid_id_string(struct {char *id = card->id; -while (*nid && !isalnum (*nid)) +while (*nid && !safe_ascii_char (*nid)) nid++;if (isdigit (*nid)) *id++ =isalpha (*src) ? *src :'D' ;while (*nid && (size_t )(id - card->id) <sizeof (card->id) -1 ) { -if (isalnum (*nid)) +if (safe_ascii_char (*nid)) *id++ = *nid; nid++; }
@@ -787,7 +793,7 @@ static ssize_t id_store(struct device *dfor (idx =0 ; idx < copy; idx++) { c = buf[idx]; -if (!isalnum (c) && c !='_' && c !='-' ) +if (!safe_ascii_char (c) && c !='_' && c !='-' )return -EINVAL ; }memcpy (buf1, buf, copy);
Greg Kroah-Hartman
maintainerPATCH 316/482 ALSA: usb-audio: Add delay quirk for VIVO USB-C HEADSET
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lianqin Hu <[email protected]>
commit 73385f3e0d8088b715ae8f3f66d533c482a376ab upstream.
Audio control requests that sets sampling frequency sometimes fail on this card. Adding delay between control messages eliminates that problem.
--- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
@@ -2279,6 +2279,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_GENERIC_IMPLICIT_FB),DEVICE_FLG (0x2b53 ,0x0031 ,/* Fiero SC-01 (firmware v1.1.0) */ QUIRK_FLAG_GENERIC_IMPLICIT_FB ), +DEVICE_FLG (0x2d95 ,0x8011 ,/* VIVO USB-C HEADSET */ +QUIRK_FLAG_CTL_MSG_DELAY_1M ),DEVICE_FLG (0x2d95 ,0x8021 ,/* VIVO USB-C-XE710 HEADSET */ QUIRK_FLAG_CTL_MSG_DELAY_1M ), DEVICE_FLG(0x30be, 0x0101, /* Schiit Hel */
Greg Kroah-Hartman
maintainerPATCH 317/482 ALSA: usb-audio: Add native DSD support for Luxman D-08u
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Lalinsky <[email protected]>
commit 6b0bde5d8d4078ca5feec72fd2d828f0e5cf115d upstream.
Add native DSD support for Luxman D-08u DAC, by adding the PID/VID 1852:5062. This makes DSD playback work, and also sound quality when playing PCM files is improved, crackling sounds are gone.
--- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
@@ -2221,6 +2221,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_DISABLE_AUTOSUSPEND),DEVICE_FLG (0x17aa ,0x104d ,/* Lenovo ThinkStation P620 Internal Speaker + Front Headset */ QUIRK_FLAG_DISABLE_AUTOSUSPEND ), +DEVICE_FLG (0x1852 ,0x5062 ,/* Luxman D-08u */ +QUIRK_FLAG_ITF_USB_DSD_DAC |QUIRK_FLAG_CTL_MSG_DELAY ),DEVICE_FLG (0x1852 ,0x5065 ,/* Luxman DA-06 */ QUIRK_FLAG_ITF_USB_DSD_DAC |QUIRK_FLAG_CTL_MSG_DELAY ), DEVICE_FLG(0x1901, 0x0191, /* GE B850V3 CP2114 audio interface */
Greg Kroah-Hartman
maintainerPATCH 318/482 ALSA: line6: add hw monitor volume control to POD HD500X
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans P. Moller <[email protected]>
commit 703235a244e533652346844cfa42623afb36eed1 upstream.
Add hw monitor volume control for POD HD500X. This is done adding LINE6_CAP_HWMON_CTL to the capabilities
--- sound/usb/line6/podhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/line6/podhd.c +1 -1
@@ -507,7 +507,7 @@ static const struct line6_properties pod [LINE6_PODHD500X] = { .id = "PODHD500X", .name = "POD HD500X", - .capabilities =LINE6_CAP_CONTROL + .capabilities =LINE6_CAP_CONTROL |LINE6_CAP_HWMON_CTL | LINE6_CAP_PCM | LINE6_CAP_HWMON, .altsetting = 1, .ep_ctrl_r = 0x81,
Greg Kroah-Hartman
maintainerPATCH 319/482 ALSA: hda/realtek: fix mute/micmute LED for HP mt645 G8
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolai Afanasenkov <[email protected]>
commit cb2deca056d579fe008c8d0a4ceb04d2b368fe42 upstream.
The HP Elite mt645 G8 Mobile Thin Client uses an ALC236 codec and needs the ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF quirk to enable the mute and micmute LED functionality.
This patch adds the system ID of the HP Elite mt645 G8 to the alc269_fixup_tbl in patch_realtek.c to enable the required quirk.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10303,6 +10303,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8ca2 ,"HP ZBook Power" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ca4 ,"HP ZBook Fury" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ca7 ,"HP ZBook Fury" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8caf ,"HP Elite mt645 G8 Mobile Thin Client" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x8cbd ,"HP Pavilion Aero Laptop 13-bg0xxx" ,ALC245_FIXUP_HP_X360_MUTE_LEDS ),SND_PCI_QUIRK (0x103c ,0x8cdd ,"HP Spectre" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x103c, 0x8cde, "HP Spectre", ALC287_FIXUP_CS35L41_I2C_2),
Greg Kroah-Hartman
maintainerPATCH 320/482 ALSA: hda/realtek: Add quirk for Huawei MateBook 13 KLV-WX9
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ai Chao <[email protected]>
commit dee476950cbd83125655a3f49e00d63b79f6114e upstream.
The headset mic requires a fixup to be properly detected/used.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10687,6 +10687,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1854 ,0x0441 ,"LG CQ6 AIO" ,ALC256_FIXUP_HEADPHONE_AMP_VOL ),SND_PCI_QUIRK (0x19e5 ,0x3204 ,"Huawei MACH-WX9" ,ALC256_FIXUP_HUAWEI_MACH_WX9_PINS ),SND_PCI_QUIRK (0x19e5 ,0x320f ,"Huawei WRT-WX9 " ,ALC256_FIXUP_ASUS_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x19e5 ,0x3212 ,"Huawei KLV-WX9 " ,ALC256_FIXUP_ACER_HEADSET_MIC ),SND_PCI_QUIRK (0x1b35 ,0x1235 ,"CZC B20" ,ALC269_FIXUP_CZC_B20 ),SND_PCI_QUIRK (0x1b35 ,0x1236 ,"CZC TMI" ,ALC269_FIXUP_CZC_TMI ), SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101),
Greg Kroah-Hartman
maintainerPATCH 321/482 ALSA: hda/realtek: Add a quirk for HP Pavilion 15z-ec200
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Tamboli <[email protected]>
commit d75dba49744478c32f6ce1c16b5f391c2d5cef5f upstream.
Add the quirk for HP Pavilion Gaming laptop 15z-ec200 for enabling the mute led. The fix apply the ALC285_FIXUP_HP_MUTE_LED quirk for this model.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10162,6 +10162,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8896 ,"HP EliteBook 855 G8 Notebook PC" ,ALC285_FIXUP_HP_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x8898 ,"HP EliteBook 845 G8 Notebook PC" ,ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x103c ,0x88d0 ,"HP Pavilion 15-eh1xxx (mainboard 88D0)" ,ALC287_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x88dd ,"HP Pavilion 15z-ec200" ,ALC285_FIXUP_HP_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x8902 ,"HP OMEN 16" ,ALC285_FIXUP_HP_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x890e ,"HP 255 G8 Notebook PC" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ), SND_PCI_QUIRK(0x103c, 0x8919, "HP Pavilion Aero Laptop 13-be0xxx", ALC287_FIXUP_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 322/482 ext4: no need to continue when the number of entries is 1
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
commit 1a00a393d6a7fb1e745a41edd09019bd6a0ad64c upstream.
--- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/namei.c +1 -1
@@ -2046,7 +2046,7 @@ static struct ext4_dir_entry_2 *do_split split = count/2 ; hash2 = map[split].hash; - continued = hash2 == map[split -1 ].hash; + continued = split >0 ? hash2 == map[split -1 ].hash :0 ;dxtrace (printk (KERN_INFO "Split block %lu at %x, %i/%i\n" , (unsigned long )dx_get_block (frame->at), hash2, split, count-split));
Greg Kroah-Hartman
maintainerPATCH 323/482 ext4: correct encrypted dentry name hash when not casefolded
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: yao.ly <[email protected]>
commit 70dd7b573afeba9b8f8a33f2ae1e4a9a2ec8c1ec upstream.
EXT4_DIRENT_HASH and EXT4_DIRENT_MINOR_HASH will access struct ext4_dir_entry_hash followed ext4_dir_entry. But there is no ext4_dir_entry_hash followed when inode is encrypted and not casefolded
--- fs/ext4/dir.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/ext4/dir.c +11 -3
@@ -279,12 +279,20 @@ static int ext4_readdir(struct file *filstruct fscrypt_str de_name =FSTR_INIT (de->name, de->name_len); +u32 hash; +u32 minor_hash; + +if (IS_CASEFOLDED (inode)) { + hash =EXT4_DIRENT_HASH (de); + minor_hash =EXT4_DIRENT_MINOR_HASH (de); + }else { + hash =0 ; + minor_hash =0 ; + }/* Directory is encrypted */ err =fscrypt_fname_disk_to_usr (inode, -EXT4_DIRENT_HASH (de), -EXT4_DIRENT_MINOR_HASH (de), - &de_name, &fstr); + hash, minor_hash, &de_name, &fstr); de_name = fstr; fstr.len = save_len;if (err)
Greg Kroah-Hartman
maintainerPATCH 324/482 ext4: fix slab-use-after-free in ext4_split_extent_at()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit c26ab35702f8cd0cdc78f96aa5856bfb77be798f upstream.
We hit the following use-after-free:
==================================================================
BUG: KASAN: slab-use-after-free in ext4_split_extent_at+0xba8/0xcc0 Read of size 2 at addr ffff88810548ed08 by task kworker/u20:0/40 CPU: 0 PID: 40 Comm: kworker/u20:0 Not tainted 6.9.0-dirty #724 Call Trace: <TASK> kasan_report+0x93/0xc0 ext4_split_extent_at+0xba8/0xcc0 ext4_split_extent.isra.0+0x18f/0x500 ext4_split_convert_extents+0x275/0x750 ext4_ext_handle_unwritten_extents+0x73e/0x1580 ext4_ext_map_blocks+0xe20/0x2dc0 ext4_map_blocks+0x724/0x1700 ext4_do_writepages+0x12d6/0x2a70
[...]
Allocated by task 40: __kmalloc_noprof+0x1ac/0x480 ext4_find_extent+0xf3b/0x1e70 ext4_ext_map_blocks+0x188/0x2dc0 ext4_map_blocks+0x724/0x1700 ext4_do_writepages+0x12d6/0x2a70
[...]
Freed by task 40: kfree+0xf1/0x2b0 ext4_find_extent+0xa71/0x1e70 ext4_ext_insert_extent+0xa22/0x3260 ext4_split_extent_at+0x3ef/0xcc0 ext4_split_extent.isra.0+0x18f/0x500 ext4_split_convert_extents+0x275/0x750 ext4_ext_handle_unwritten_extents+0x73e/0x1580 ext4_ext_map_blocks+0xe20/0x2dc0 ext4_map_blocks+0x724/0x1700 ext4_do_writepages+0x12d6/0x2a70
[...]
==================================================================
The flow of issue triggering is as follows:
ext4_split_extent_at
path = *ppath ext4_ext_insert_extent(ppath)
ext4_ext_create_new_leaf(ppath)
ext4_find_extent(orig_path)
path = *orig_path read_extent_tree_block
// return -ENOMEM or -EIO
ext4_free_ext_path(path)
kfree(path)
*orig_path = NULL
a. If err is -ENOMEM:
ext4_ext_dirty(path + path->p_depth)
// path use-after-free !!!
b. If err is -EIO and we have EXT_DEBUG defined:
ext4_ext_show_leaf(path)
eh = path[depth].p_hdr
// path also use-after-free !!!
So when trying to zeroout or fix the extent length, call ext4_find_extent() to update the path.
In addition we use *ppath directly as an ext4_ext_show_leaf() input to avoid possible use-after-free when EXT_DEBUG is defined, and to avoid unnecessary path updates.
--- fs/ext4/extents.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
fs/ext4/extents.c +20 -1
@@ -3230,6 +3230,25 @@ static int ext4_split_extent_at(handle_tif (err != -ENOSPC && err != -EDQUOT && err != -ENOMEM ) goto out; +/* +* Update path is required because previous ext4_ext_insert_extent() +* may have freed or reallocated the path. Using EXT4_EX_NOFAIL +* guarantees that ext4_find_extent() will not return -ENOMEM, +* otherwise -ENOMEM will cause a retry in do_writepages(), and a +* WARN_ON may be triggered in ext4_da_update_reserve_space() due to +* an incorrect ee_len causing the i_reserved_data_blocks exception. +*/ + path =ext4_find_extent (inode, ee_block, ppath, + flags |EXT4_EX_NOFAIL ); +if (IS_ERR (path)) { +EXT4_ERROR_INODE (inode,"Failed split extent on %u, err %ld" , + split,PTR_ERR (path)); +return PTR_ERR (path); + } + depth =ext_depth (inode); + ex = path[depth].p_ext; + *ppath = path; +if (EXT4_EXT_MAY_ZEROOUT & split_flag) {if (split_flag & (EXT4_EXT_DATA_VALID1 |EXT4_EXT_DATA_VALID2 )) {if (split_flag &EXT4_EXT_DATA_VALID1 ) {
@@ -3282,7 +3301,7 @@ fix_extent_len:ext4_ext_dirty (handle, inode, path + path->p_depth);return err; out: -ext4_ext_show_leaf (inode, path); +ext4_ext_show_leaf (inode, *ppath);return err; }
Greg Kroah-Hartman
maintainerPATCH 325/482 ext4: propagate errors from ext4_find_extent() in ext4_insert_range()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 369c944ed1d7c3fb7b35f24e4735761153afe7b3 upstream.
Even though ext4_find_extent() returns an error, ext4_insert_range() still returns 0. This may confuse the user as to why fallocate returns success, but the contents of the file are not as expected. So propagate the error returned by ext4_find_extent() to avoid inconsistencies.
--- fs/ext4/extents.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/extents.c +1 -0
@@ -5553,6 +5553,7 @@ static int ext4_insert_range(struct file path =ext4_find_extent (inode, offset_lblk,NULL ,0 );if (IS_ERR (path)) {up_write (&EXT4_I (inode)->i_data_sem); + ret =PTR_ERR (path); goto out_stop; }
Greg Kroah-Hartman
maintainerPATCH 326/482 ext4: fix incorrect tid assumption in ext4_fc_mark_ineligible()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit ebc4b2c1ac92fc0f8bf3f5a9c285a871d5084a6b upstream.
Function jbd2_journal_shrink_checkpoint_list() assumes that '0' is not a valid value for transaction IDs, which is incorrect.
Furthermore, the sbi->s_fc_ineligible_tid handling also makes the same assumption by being initialised to '0'. Fortunately, the sb flag EXT4_MF_FC_INELIGIBLE can be used to check whether sbi->s_fc_ineligible_tid has been previously set instead of comparing it with '0'.
--- fs/ext4/fast_commit.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/ext4/fast_commit.c +11 -4
@@ -339,22 +339,29 @@ void ext4_fc_mark_ineligible(struct supe {struct ext4_sb_info *sbi =EXT4_SB (sb);tid_t tid; +bool has_transaction = true; +bool is_ineligible;if (ext4_fc_disabled (sb))return ; -ext4_set_mount_flag (sb,EXT4_MF_FC_INELIGIBLE );if (handle && !IS_ERR (handle)) tid = handle->h_transaction->t_tid;else {read_lock (&sbi->s_journal->j_state_lock); - tid = sbi->s_journal->j_running_transaction ? - sbi->s_journal->j_running_transaction->t_tid :0 ; +if (sbi->s_journal->j_running_transaction) + tid = sbi->s_journal->j_running_transaction->t_tid; +else + has_transaction = false;read_unlock (&sbi->s_journal->j_state_lock); }spin_lock (&sbi->s_fc_lock); -if (tid_gt (tid, sbi->s_fc_ineligible_tid)) + is_ineligible =ext4_test_mount_flag (sb,EXT4_MF_FC_INELIGIBLE ); +if (has_transaction && + (!is_ineligible || + (is_ineligible &&tid_gt (tid, sbi->s_fc_ineligible_tid)))) sbi->s_fc_ineligible_tid = tid; +ext4_set_mount_flag (sb,EXT4_MF_FC_INELIGIBLE );spin_unlock (&sbi->s_fc_lock);WARN_ON (reason >=EXT4_FC_REASON_MAX ); sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;
Greg Kroah-Hartman
maintainerPATCH 327/482 ext4: dax: fix overflowing extents beyond inode size when partially writing
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
commit dda898d7ffe85931f9cca6d702a51f33717c501e upstream.
The dax_iomap_rw() does two things in each iteration: map written blocks and copy user data to blocks. If the process is killed by user(See signal handling in dax_iomap_iter()), the copied data will be returned and added on inode size, which means that the length of written extents may exceed the inode size, then fsck will fail. An example is given as:
dd if=/dev/urandom of=file bs=4M count=1
dax_iomap_rw
iomap_iter // round 1
ext4_iomap_begin
ext4_iomap_alloc // allocate 0~2M extents(written flag)
dax_iomap_iter // copy 2M data
iomap_iter // round 2
iomap_iter_advance
iter->pos += iter->processed // iter->pos = 2M
ext4_iomap_begin
ext4_iomap_alloc // allocate 2~4M extents(written flag)
dax_iomap_iter
fatal_signal_pending
done = iter->pos - iocb->ki_pos // done = 2M
ext4_handle_inode_extension
ext4_update_inode_size // inode size = 2M
fsck reports: Inode 13, i_size is 2097152, should be 4194304. Fix?
Fix the problem by truncating extents if the written length is smaller than expected.
--- fs/ext4/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/ext4/file.c +4 -4
@@ -334,10 +334,10 @@ static ssize_t ext4_handle_inode_extensi* Clean up the inode after DIO or DAX extending write has completed and the * inode size has been updated using ext4_handle_inode_extension(). */ -static void ext4_inode_extension_cleanup (struct inode *inode,ssize_t count) +static void ext4_inode_extension_cleanup (struct inode *inode,bool need_trunc) {lockdep_assert_held_write (&inode->i_rwsem); -if (count <0 ) { +if (need_trunc) {ext4_truncate_failed_write (inode);/* * If the truncate operation failed early, then the inode may
@@ -586,7 +586,7 @@ static ssize_t ext4_dio_write_iter(struc* writeback of delalloc blocks. */ WARN_ON_ONCE (ret == -EIOCBQUEUED ); -ext4_inode_extension_cleanup (inode, ret); +ext4_inode_extension_cleanup (inode, ret <0 ); } out:
@@ -670,7 +670,7 @@ ext4_dax_write_iter(struct kiocb *iocb,if (extend) { ret =ext4_handle_inode_extension (inode, offset, ret); -ext4_inode_extension_cleanup (inode, ret); +ext4_inode_extension_cleanup (inode, ret < (ssize_t )count); } out:inode_unlock (inode);
Greg Kroah-Hartman
maintainerPATCH 328/482 ext4: fix incorrect tid assumption in __jbd2_log_wait_for_space()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit 972090651ee15e51abfb2160e986fa050cfc7a40 upstream.
Function __jbd2_log_wait_for_space() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Don't assume that and invoke jbd2_log_wait_commit() if the journal had a committing transaction instead.
--- fs/jbd2/checkpoint.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/jbd2/checkpoint.c +5 -2
@@ -79,9 +79,12 @@ __releases(&journal->j_state_lock)if (space_left < nblocks) {int chkpt = journal->j_checkpoint_transactions !=NULL ;tid_t tid =0 ; +bool has_transaction = false; -if (journal->j_committing_transaction) +if (journal->j_committing_transaction) { tid = journal->j_committing_transaction->t_tid; + has_transaction = true; + }spin_unlock (&journal->j_list_lock);write_unlock (&journal->j_state_lock);if (chkpt) {
@@ -89,7 +92,7 @@ __releases(&journal->j_state_lock) }else if (jbd2_cleanup_journal_tail (journal) ==0 ) {/* We were able to recover space; yay! */ ; - }else if (tid) { + }else if (has_transaction) {/* * jbd2_journal_commit_transaction() may want * to take the checkpoint_mutex if JBD2_FLUSHED
Greg Kroah-Hartman
maintainerPATCH 329/482 ext4: drop ppath from ext4_ext_replay_update_ex() to avoid double-free
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 5c0f4cc84d3a601c99bc5e6e6eb1cbda542cce95 upstream.
When calling ext4_force_split_extent_at() in ext4_ext_replay_update_ex(), the 'ppath' is updated but it is the 'path' that is freed, thus potentially triggering a double-free in the following process:
ext4_ext_replay_update_ex
ppath = path
ext4_force_split_extent_at(&ppath)
ext4_split_extent_at
ext4_ext_insert_extent
ext4_ext_create_new_leaf
ext4_ext_grow_indepth
ext4_find_extent
if (depth > path[0].p_maxdepth)
kfree(path) ---> path First freed
*orig_path = path = NULL ---> null ppathkfree(path) ---> path double-free !!!
So drop the unnecessary ppath and use path directly to avoid this problem. And use ext4_find_extent() directly to update path, avoiding unnecessary memory allocation and freeing. Also, propagate the error returned by ext4_find_extent() instead of using strange error codes.
--- fs/ext4/extents.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
fs/ext4/extents.c +10 -11
@@ -5899,7 +5899,7 @@ out:int ext4_ext_replay_update_ex (struct inode *inode,ext4_lblk_t start,int len,int unwritten,ext4_fsblk_t pblk) { -struct ext4_ext_path *path =NULL , *ppath; +struct ext4_ext_path *path;struct ext4_extent *ex;int ret;
@@ -5915,30 +5915,29 @@ int ext4_ext_replay_update_ex(struct inoif (le32_to_cpu (ex->ee_block) != start ||ext4_ext_get_actual_len (ex) != len) {/* We need to split this extent to match our extent first */ - ppath = path;down_write (&EXT4_I (inode)->i_data_sem); - ret =ext4_force_split_extent_at (NULL , inode, &ppath, start,1 ); + ret =ext4_force_split_extent_at (NULL , inode, &path, start,1 );up_write (&EXT4_I (inode)->i_data_sem);if (ret) goto out; -kfree (path); - path =ext4_find_extent (inode, start,NULL ,0 ); + + path =ext4_find_extent (inode, start, &path,0 );if (IS_ERR (path)) -return -1 ; - ppath = path; +return PTR_ERR (path); ex = path[path->p_depth].p_ext;WARN_ON (le32_to_cpu (ex->ee_block) != start); +if (ext4_ext_get_actual_len (ex) != len) {down_write (&EXT4_I (inode)->i_data_sem); - ret =ext4_force_split_extent_at (NULL , inode, &ppath, + ret =ext4_force_split_extent_at (NULL , inode, &path, start + len,1 );up_write (&EXT4_I (inode)->i_data_sem);if (ret) goto out; -kfree (path); - path =ext4_find_extent (inode, start,NULL ,0 ); + + path =ext4_find_extent (inode, start, &path,0 );if (IS_ERR (path)) -return -EINVAL ; +return PTR_ERR (path); ex = path[path->p_depth].p_ext; } }
Greg Kroah-Hartman
maintainerPATCH 330/482 ext4: aovid use-after-free in ext4_ext_insert_extent()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit a164f3a432aae62ca23d03e6d926b122ee5b860d upstream.
As Ojaswin mentioned in Link, in ext4_ext_insert_extent(), if the path is reallocated in ext4_ext_create_new_leaf(), we'll use the stale path and cause UAF. Below is a sample trace with dummy values:
ext4_ext_insert_extent
path = *ppath = 2000
ext4_ext_create_new_leaf(ppath)
ext4_find_extent(ppath)
path = *ppath = 2000
if (depth > path[0].p_maxdepth)
kfree(path = 2000);
*ppath = path = NULL;
path = kcalloc() = 3000
*ppath = 3000;
return path; /* here path is still 2000, UAF! */
eh = path[depth].p_hdr
==================================================================
BUG: KASAN: slab-use-after-free in ext4_ext_insert_extent+0x26d4/0x3330 Read of size 8 at addr ffff8881027bf7d0 by task kworker/u36:1/179 CPU: 3 UID: 0 PID: 179 Comm: kworker/u6:1 Not tainted 6.11.0-rc2-dirty #866 Call Trace: <TASK> ext4_ext_insert_extent+0x26d4/0x3330 ext4_ext_map_blocks+0xe22/0x2d40 ext4_map_blocks+0x71e/0x1700 ext4_do_writepages+0x1290/0x2800
[...]
Allocated by task 179: ext4_find_extent+0x81c/0x1f70 ext4_ext_map_blocks+0x146/0x2d40 ext4_map_blocks+0x71e/0x1700 ext4_do_writepages+0x1290/0x2800 ext4_writepages+0x26d/0x4e0 do_writepages+0x175/0x700
[...]
Freed by task 179: kfree+0xcb/0x240 ext4_find_extent+0x7c0/0x1f70 ext4_ext_insert_extent+0xa26/0x3330 ext4_ext_map_blocks+0xe22/0x2d40 ext4_map_blocks+0x71e/0x1700 ext4_do_writepages+0x1290/0x2800 ext4_writepages+0x26d/0x4e0 do_writepages+0x175/0x700
[...]
==================================================================
So use *ppath to update the path to avoid the above problem.
--- fs/ext4/extents.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/extents.c +1 -0
@@ -2103,6 +2103,7 @@ prepend: ppath, newext);if (err) goto cleanup; + path = *ppath; depth =ext_depth (inode); eh = path[depth].p_hdr;
Greg Kroah-Hartman
maintainerPATCH 331/482 ext4: fix double brelse() the buffer of the extents path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit dcaa6c31134c0f515600111c38ed7750003e1b9c upstream.
In ext4_ext_try_to_merge_up(), set path[1].p_bh to NULL after it has been released, otherwise it may be released twice. An example of what triggers this is as follows:
split2 map split1
|--------|-------|--------|
ext4_ext_map_blocks
ext4_ext_handle_unwritten_extents
ext4_split_convert_extents
// path->p_depth == 0
ext4_split_extent
// 1. do split1
ext4_split_extent_at
|ext4_ext_insert_extent
| ext4_ext_create_new_leaf
| ext4_ext_grow_indepth
| le16_add_cpu(&neh->eh_depth, 1)
| ext4_find_extent
| // return -ENOMEM
|// get error and try zeroout
|path = ext4_find_extent
| path->p_depth = 1
|ext4_ext_try_to_merge
| ext4_ext_try_to_merge_up
| path->p_depth = 0
| brelse(path[1].p_bh) ---> not set to NULL here
|// zeroout success
// 2. update path
ext4_find_extent
// 3. do split2
ext4_split_extent_at
ext4_ext_insert_extent
ext4_ext_create_new_leaf
ext4_ext_grow_indepth
le16_add_cpu(&neh->eh_depth, 1)
ext4_find_extent
path[0].p_bh = NULL;
path->p_depth = 1
read_extent_tree_block ---> return err
// path[1].p_bh is still the old value
ext4_free_ext_path
ext4_ext_drop_refs
// path->p_depth == 1
brelse(path[1].p_bh) ---> brelse a buffer twiceFinally got the following WARRNING when removing the buffer from lru:
============================================
VFS: brelse: Trying to free free buffer
WARNING: CPU: 2 PID: 72 at fs/buffer.c:1241 __brelse+0x58/0x90 CPU: 2 PID: 72 Comm: kworker/u19:1 Not tainted 6.9.0-dirty #716 RIP: 0010:__brelse+0x58/0x90 Call Trace: <TASK> __find_get_block+0x6e7/0x810 bdev_getblk+0x2b/0x480 __ext4_get_inode_loc+0x48a/0x1240 ext4_get_inode_loc+0xb2/0x150 ext4_reserve_inode_write+0xb7/0x230 __ext4_mark_inode_dirty+0x144/0x6a0 ext4_ext_insert_extent+0x9c8/0x3230 ext4_ext_map_blocks+0xf45/0x2dc0 ext4_map_blocks+0x724/0x1700 ext4_do_writepages+0x12d6/0x2a70
[...]
============================================
--- fs/ext4/extents.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/extents.c +1 -0
@@ -1877,6 +1877,7 @@ static void ext4_ext_try_to_merge_up(han path[0 ].p_hdr->eh_max =cpu_to_le16 (max_root);brelse (path[1 ].p_bh); + path[1 ].p_bh =NULL ;ext4_free_blocks (handle, inode,NULL , blk,1 ,EXT4_FREE_BLOCKS_METADATA |EXT4_FREE_BLOCKS_FORGET ); }
Greg Kroah-Hartman
maintainerPATCH 332/482 ext4: fix timer use-after-free on failed mount
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaxi Shen <[email protected]>
commit 0ce160c5bdb67081a62293028dc85758a8efb22a upstream.
Syzbot has found an ODEBUG bug in ext4_fill_super
The del_timer_sync function cancels the s_err_report timer, which reminds about filesystem errors daily. We should guarantee the timer is no longer active before kfree(sbi).
When filesystem mounting fails, the flow goes to failed_mount3, where an error occurs when ext4_stop_mmpd is called, causing a read I/O failure. This triggers the ext4_handle_error function that ultimately re-arms the timer,
leaving the s_err_report timer active before kfree(sbi) is called.
Fix the issue by canceling the s_err_report timer after calling ext4_stop_mmpd.
--- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/super.c +1 -1
@@ -5633,8 +5633,8 @@ failed_mount3a: failed_mount3:/* flush s_sb_upd_work before sbi destroy */ flush_work (&sbi->s_sb_upd_work); -del_timer_sync (&sbi->s_err_report);ext4_stop_mmpd (sbi); +del_timer_sync (&sbi->s_err_report);ext4_group_desc_free (sbi); failed_mount:if (sbi->s_chksum_driver)
Greg Kroah-Hartman
maintainerPATCH 333/482 ext4: fix access to uninitialised lock in fc replay path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit 23dfdb56581ad92a9967bcd720c8c23356af74c1 upstream.
The following kernel trace can be triggered with fstest generic/629 when executed against a filesystem with fast-commit feature enabled:
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator.
CPU: 0 PID: 866 Comm: mount Not tainted 6.10.0+ #11 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-3-gd478f380-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x66/0x90 register_lock_class+0x759/0x7d0 __lock_acquire+0x85/0x2630 ? __find_get_block+0xb4/0x380 lock_acquire+0xd1/0x2d0 ? __ext4_journal_get_write_access+0xd5/0x160 _raw_spin_lock+0x33/0x40 ? __ext4_journal_get_write_access+0xd5/0x160 __ext4_journal_get_write_access+0xd5/0x160 ext4_reserve_inode_write+0x61/0xb0 __ext4_mark_inode_dirty+0x79/0x270 ? ext4_ext_replay_set_iblocks+0x2f8/0x450 ext4_ext_replay_set_iblocks+0x330/0x450 ext4_fc_replay+0x14c8/0x1540 ? jread+0x88/0x2e0 ? rcu_is_watching+0x11/0x40 do_one_pass+0x447/0xd00 jbd2_journal_recover+0x139/0x1b0 jbd2_journal_load+0x96/0x390 ext4_load_and_init_journal+0x253/0xd40 ext4_fill_super+0x2cc6/0x3180
...
In the replay path there's an attempt to lock sbi->s_bdev_wb_lock in function ext4_check_bdev_write_error(). Unfortunately, at this point this spinlock has not been initialized yet. Moving it's initialization to an earlier point in __ext4_fill_super() fixes this splat.
--- fs/ext4/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/super.c +2 -1
@@ -5332,6 +5332,8 @@ static int __ext4_fill_super(struct fs_cINIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ mutex_init (&sbi->s_orphan_lock); +spin_lock_init (&sbi->s_bdev_wb_lock); +ext4_fast_commit_init (sb); sb->s_root =NULL ;
@@ -5553,7 +5555,6 @@ static int __ext4_fill_super(struct fs_c* Save the original bdev mapping's wb_err value which could be * used to detect the metadata async write error. */ -spin_lock_init (&sbi->s_bdev_wb_lock);errseq_check_and_advance (&sb->s_bdev->bd_mapping->wb_err, &sbi->s_bdev_wb_err);EXT4_SB (sb)->s_mount_state |=EXT4_ORPHAN_FS ;
Greg Kroah-Hartman
maintainerPATCH 334/482 ext4: update orig_path in ext4_find_extent()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 5b4b2dcace35f618fe361a87bae6f0d13af31bc1 upstream.
In ext4_find_extent(), if the path is not big enough, we free it and set *orig_path to NULL. But after reallocating and successfully initializing the path, we don't update *orig_path, in which case the caller gets a valid path but a NULL ppath, and this may cause a NULL pointer dereference or a path memory leak. For example:
ext4_split_extent
path = *ppath = 2000
ext4_find_extent
if (depth > path[0].p_maxdepth)
kfree(path = 2000);
*orig_path = path = NULL;
path = kcalloc() = 3000
ext4_split_extent_at(*ppath = NULL)
path = *ppath;
ex = path[depth].p_ext;
// NULL pointer dereference!==================================================================
BUG: kernel NULL pointer dereference, address: 0000000000000010 CPU: 6 UID: 0 PID: 576 Comm: fsstress Not tainted 6.11.0-rc2-dirty #847 RIP: 0010:ext4_split_extent_at+0x6d/0x560 Call Trace: <TASK> ext4_split_extent.isra.0+0xcb/0x1b0 ext4_ext_convert_to_initialized+0x168/0x6c0 ext4_ext_handle_unwritten_extents+0x325/0x4d0 ext4_ext_map_blocks+0x520/0xdb0 ext4_map_blocks+0x2b0/0x690 ext4_iomap_begin+0x20e/0x2c0
[...]
==================================================================
Therefore, *orig_path is updated when the extent lookup succeeds, so that the caller can safely use path or *ppath.
--- fs/ext4/extents.c | 3 ++- fs/ext4/move_extent.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/extents.c +2 -1
@@ -957,6 +957,8 @@ ext4_find_extent(struct inode *inode, exext4_ext_show_path (inode, path); +if (orig_path) + *orig_path = path;return path; err:
@@ -3249,7 +3251,6 @@ static int ext4_split_extent_at(handle_t } depth =ext_depth (inode); ex = path[depth].p_ext; - *ppath = path;if (EXT4_EXT_MAY_ZEROOUT & split_flag) {if (split_flag & (EXT4_EXT_DATA_VALID1 |EXT4_EXT_DATA_VALID2 )) {
fs/ext4/move_extent.c +0 -1
@@ -36,7 +36,6 @@ get_ext_path(struct inode *inode, ext4_l *ppath =NULL ;return -ENODATA ; } - *ppath = path;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 335/482 ext4: fix incorrect tid assumption in ext4_wait_for_tail_page_commit()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit dd589b0f1445e1ea1085b98edca6e4d5dedb98d0 upstream.
Function ext4_wait_for_tail_page_commit() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Don't assume that and invoke jbd2_log_wait_commit() if the journal had a committing transaction instead.
--- fs/ext4/inode.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
fs/ext4/inode.c +7 -4
@@ -5233,8 +5233,9 @@ static void ext4_wait_for_tail_page_comm {unsigned offset;journal_t *journal =EXT4_SB (inode->i_sb)->s_journal; -tid_t commit_tid =0 ; +tid_t commit_tid;int ret; +bool has_transaction; offset = inode->i_size & (PAGE_SIZE -1 );/*
@@ -5259,12 +5260,14 @@ static void ext4_wait_for_tail_page_commfolio_put (folio);if (ret != -EBUSY )return ; - commit_tid =0 ; + has_transaction = false;read_lock (&journal->j_state_lock); -if (journal->j_committing_transaction) +if (journal->j_committing_transaction) { commit_tid = journal->j_committing_transaction->t_tid; + has_transaction = true; + }read_unlock (&journal->j_state_lock); -if (commit_tid) +if (has_transaction)jbd2_log_wait_commit (journal, commit_tid); } }
Greg Kroah-Hartman
maintainerPATCH 336/482 ext4: fix incorrect tid assumption in jbd2_journal_shrink_checkpoint_list()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit 7a6443e1dad70281f99f0bd394d7fd342481a632 upstream.
Function jbd2_journal_shrink_checkpoint_list() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Don't assume that and use two extra boolean variables to control the loop iterations and keep track of the first and last tid.
--- fs/jbd2/checkpoint.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/jbd2/checkpoint.c +5 -2
@@ -410,6 +410,7 @@ unsigned long jbd2_journal_shrink_checkptid_t tid =0 ;unsigned long nr_freed =0 ;unsigned long freed; +bool first_set = false; again:spin_lock (&journal->j_list_lock);
@@ -429,8 +430,10 @@ again:else transaction = journal->j_checkpoint_transactions; -if (!first_tid) +if (!first_set) { first_tid = transaction->t_tid; + first_set = true; + } last_transaction = journal->j_checkpoint_transactions->t_cpprev; next_transaction = transaction; last_tid = last_transaction->t_tid;
@@ -460,7 +463,7 @@ again:spin_unlock (&journal->j_list_lock);cond_resched (); -if (*nr_to_scan && next_tid) +if (*nr_to_scan && journal->j_shrink_transaction) goto again; out: trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid,
Greg Kroah-Hartman
maintainerPATCH 337/482 ext4: fix fast commit inode enqueueing during a full journal commit
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit 6db3c1575a750fd417a70e0178bdf6efa0dd5037 upstream.
When a full journal commit is on-going, any fast commit has to be enqueued into a different queue: FC_Q_STAGING instead of FC_Q_MAIN. This enqueueing is done only once, i.e. if an inode is already queued in a previous fast commit entry it won't be enqueued again. However, if a full commit starts _after_ the inode is enqueued into FC_Q_MAIN, the next fast commit needs to be done into FC_Q_STAGING. And this is not being done in function ext4_fc_track_template().
This patch fixes the issue by re-enqueuing an inode into the STAGING queue during the fast commit clean-up callback when doing a full commit. However, to prevent a race with a fast-commit, the clean-up callback has to be called with the journal locked.
This bug was found using fstest generic/047. This test creates several 32k bytes files, sync'ing each of them after it's creation, and then shutting down the filesystem. Some data may be loss in this operation; for example a file may have it's size truncated to zero.
--- fs/ext4/fast_commit.c | 15 ++++++++++++++- fs/jbd2/journal.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-)
fs/ext4/fast_commit.c +14 -1
@@ -1295,8 +1295,21 @@ static void ext4_fc_cleanup(journal_t *jlist_del_init (&iter->i_fc_list);ext4_clear_inode_state (&iter->vfs_inode,EXT4_STATE_FC_COMMITTING ); -if (tid_geq (tid, iter->i_sync_tid)) +if (tid_geq (tid, iter->i_sync_tid)) {ext4_fc_reset_inode (&iter->vfs_inode); + }else if (full) { +/* +* We are called after a full commit, inode has been +* modified while the commit was running. Re-enqueue +* the inode into STAGING, which will then be splice +* back into MAIN. This cannot happen during +* fastcommit because the journal is locked all the +* time in that case (and tid doesn't increase so +* tid check above isn't reliable). +*/ +list_add_tail (&EXT4_I (&iter->vfs_inode)->i_fc_list, + &sbi->s_fc_q[FC_Q_STAGING ]); + }/* Make sure EXT4_STATE_FC_COMMITTING bit is clear */ smp_mb ();#if (BITS_PER_LONG <64 )
fs/jbd2/journal.c +1 -1
@@ -755,9 +755,9 @@ EXPORT_SYMBOL(jbd2_fc_begin_commit);*/ static int __jbd2_fc_end_commit (journal_t *journal,tid_t tid,bool fallback) { -jbd2_journal_unlock_updates (journal);if (journal->j_fc_cleanup_callback) journal->j_fc_cleanup_callback (journal,0 , tid); +jbd2_journal_unlock_updates (journal);write_lock (&journal->j_state_lock); journal->j_flags &= ~JBD2_FAST_COMMIT_ONGOING ;if (fallback)
Greg Kroah-Hartman
maintainerPATCH 338/482 ext4: use handle to mark fc as ineligible in __track_dentry_update()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit faab35a0370fd6e0821c7a8dd213492946fc776f upstream.
Calling ext4_fc_mark_ineligible() with a NULL handle is racy and may result in a fast-commit being done before the filesystem is effectively marked as ineligible. This patch fixes the calls to this function in __track_dentry_update() by adding an extra parameter to the callback used in ext4_fc_track_template().
--- fs/ext4/fast_commit.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
fs/ext4/fast_commit.c +11 -8
@@ -379,7 +379,7 @@ void ext4_fc_mark_ineligible(struct supe*/ static int ext4_fc_track_template (handle_t *handle,struct inode *inode, -int (*__fc_track_fn)(struct inode *,void *,bool ), +int (*__fc_track_fn)(handle_t *handle,struct inode *,void *,bool ),void *args,int enqueue) {bool update = false;
@@ -396,7 +396,7 @@ static int ext4_fc_track_template(ext4_fc_reset_inode (inode); ei->i_sync_tid = tid; } - ret =__fc_track_fn (inode, args, update); + ret =__fc_track_fn (handle, inode, args, update);mutex_unlock (&ei->i_fc_lock);if (!enqueue)
@@ -420,7 +420,8 @@ struct __track_dentry_update_args { };/* __track_fn for directory entry updates. Called with ei->i_fc_lock. */ -static int __track_dentry_update (struct inode *inode,void *arg,bool update) +static int __track_dentry_update (handle_t *handle,struct inode *inode, +void *arg,bool update) {struct ext4_fc_dentry_update *node;struct ext4_inode_info *ei =EXT4_I (inode);
@@ -435,14 +436,14 @@ static int __track_dentry_update(structif (IS_ENCRYPTED (dir)) {ext4_fc_mark_ineligible (sb,EXT4_FC_REASON_ENCRYPTED_FILENAME , -NULL ); + handle);mutex_lock (&ei->i_fc_lock);return -EOPNOTSUPP ; } node =kmem_cache_alloc (ext4_fc_dentry_cachep,GFP_NOFS );if (!node) { -ext4_fc_mark_ineligible (sb,EXT4_FC_REASON_NOMEM ,NULL ); +ext4_fc_mark_ineligible (sb,EXT4_FC_REASON_NOMEM , handle);mutex_lock (&ei->i_fc_lock);return -ENOMEM ; }
@@ -454,7 +455,7 @@ static int __track_dentry_update(struct node->fcd_name.name =kmalloc (dentry->d_name.len,GFP_NOFS );if (!node->fcd_name.name) {kmem_cache_free (ext4_fc_dentry_cachep, node); -ext4_fc_mark_ineligible (sb,EXT4_FC_REASON_NOMEM ,NULL ); +ext4_fc_mark_ineligible (sb,EXT4_FC_REASON_NOMEM , handle);mutex_lock (&ei->i_fc_lock);return -ENOMEM ; }
@@ -576,7 +577,8 @@ void ext4_fc_track_create(handle_t *hand }/* __track_fn for inode tracking */ -static int __track_inode (struct inode *inode,void *arg,bool update) +static int __track_inode (handle_t *handle,struct inode *inode,void *arg, +bool update) {if (update)return -EEXIST ;
@@ -614,7 +616,8 @@ struct __track_range_args { };/* __track_fn for tracking data updates */ -static int __track_range (struct inode *inode,void *arg,bool update) +static int __track_range (handle_t *handle,struct inode *inode,void *arg, +bool update) {struct ext4_inode_info *ei =EXT4_I (inode);ext4_lblk_t oldstart;
Greg Kroah-Hartman
maintainerPATCH 339/482 ext4: mark fc as ineligible using an handle in ext4_xattr_set()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques (SUSE) <[email protected]>
commit 04e6ce8f06d161399e5afde3df5dcfa9455b4952 upstream.
Calling ext4_fc_mark_ineligible() with a NULL handle is racy and may result in a fast-commit being done before the filesystem is effectively marked as ineligible. This patch moves the call to this function so that an handle can be used. If a transaction fails to start, then there's not point in trying to mark the filesystem as ineligible, and an error will eventually be returned to user-space.
--- fs/ext4/xattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/xattr.c +2 -1
@@ -2559,6 +2559,8 @@ retry: error =ext4_xattr_set_handle (handle, inode, name_index, name, value, value_len, flags); +ext4_fc_mark_ineligible (inode->i_sb,EXT4_FC_REASON_XATTR , + handle); error2 =ext4_journal_stop (handle);if (error == -ENOSPC &&ext4_should_retry_alloc (sb, &retries))
@@ -2566,7 +2568,6 @@ retry:if (error ==0 ) error = error2; } -ext4_fc_mark_ineligible (inode->i_sb,EXT4_FC_REASON_XATTR ,NULL );return error; }
Greg Kroah-Hartman
maintainerPATCH 340/482 ext4: fix off by one issue in alloc_flex_gd()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 6121258c2b33ceac3d21f6a221452692c465df88 upstream.
Wesley reported an issue:
==================================================================
EXT4-fs (dm-5): resizing filesystem from 7168 to 786432 blocks
------------[ cut here ]------------ kernel BUG at fs/ext4/resize.c:324! CPU: 9 UID: 0 PID: 3576 Comm: resize2fs Not tainted 6.11.0+ #27 RIP: 0010:ext4_resize_fs+0x1212/0x12d0 Call Trace: __ext4_ioctl+0x4e0/0x1800 ext4_ioctl+0x12/0x20 __x64_sys_ioctl+0x99/0xd0 x64_sys_call+0x1206/0x20d0 do_syscall_64+0x72/0x110 entry_SYSCALL_64_after_hwframe+0x76/0x7e ==================================================================
While reviewing the patch, Honza found that when adjusting resize_bg in alloc_flex_gd(), it was possible for flex_gd->resize_bg to be bigger than flexbg_size.
The reproduction of the problem requires the following:
o_group = flexbg_size * 2 * n;
o_size = (o_group + 1) * group_size;
n_group: [o_group + flexbg_size, o_group + flexbg_size * 2) o_size = (n_group + 1) * group_size;
Take n=0,flexbg_size=16 as an example:
last:15 |o---------------|--------------n-| o_group:0 resize to n_group:30
The corresponding reproducer is:
img=test.img
rm -f $img
truncate -s 600M $img
mkfs.ext4 -F $img -b 1024 -G 16 8M
dev=losetup -f --show $img
mkdir -p /tmp/test
mount $dev /tmp/test
resize2fs $dev 248M
Delete the problematic plus 1 to fix the issue, and add a WARN_ON_ONCE() to prevent the issue from happening again.
[ Note: another reproucer which this commit fixes is:
img=test.img rm -f $img truncate -s 25MiB $img mkfs.ext4 -b 4096 -E nodiscard,lazy_itable_init=0,lazy_journal_init=0 $img truncate -s 3GiB $img dev=`losetup -f --show $img` mkdir -p /tmp/test mount $dev /tmp/test resize2fs $dev 3G umount $dev losetup -d $dev
-- TYT ]
--- fs/ext4/resize.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
fs/ext4/resize.c +10 -8
@@ -230,8 +230,8 @@ struct ext4_new_flex_group_data {#define MAX_RESIZE_BG 16384/* -* alloc_flex_gd() allocates a ext4_new_flex_group_data with size of -* @flexbg_size. +* alloc_flex_gd() allocates an ext4_new_flex_group_data that satisfies the +* resizing from @o_group to @n_group, its size is typically @flexbg_size. * * Returns NULL on failure otherwise address of the allocated structure. */
@@ -239,25 +239,27 @@ static struct ext4_new_flex_group_data * ext4_group_t o_group, ext4_group_t n_group) {ext4_group_t last_group; +unsigned int max_resize_bg;struct ext4_new_flex_group_data *flex_gd; flex_gd =kmalloc (sizeof (*flex_gd),GFP_NOFS );if (flex_gd ==NULL ) goto out3; -if (unlikely (flexbg_size >MAX_RESIZE_BG )) - flex_gd->resize_bg =MAX_RESIZE_BG ; -else - flex_gd->resize_bg = flexbg_size; + max_resize_bg =umin (flexbg_size,MAX_RESIZE_BG ); + flex_gd->resize_bg = max_resize_bg;/* Avoid allocating large 'groups' array if not needed */ last_group = o_group | (flex_gd->resize_bg -1 );if (n_group <= last_group) - flex_gd->resize_bg =1 <<fls (n_group - o_group +1 ); + flex_gd->resize_bg =1 <<fls (n_group - o_group);else if (n_group - last_group < flex_gd->resize_bg) - flex_gd->resize_bg =1 <<max (fls (last_group - o_group +1 ), + flex_gd->resize_bg =1 <<max (fls (last_group - o_group),fls (n_group - last_group)); +if (WARN_ON_ONCE (flex_gd->resize_bg > max_resize_bg)) + flex_gd->resize_bg = max_resize_bg; + flex_gd->groups =kmalloc_array (flex_gd->resize_bg,sizeof (struct ext4_new_group_data ),GFP_NOFS );
Greg Kroah-Hartman
maintainerPATCH 341/482 parisc: Fix 64-bit userspace syscall path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit d24449864da5838936669618356b0e30ca2999c3 upstream.
Currently the glibc isn't yet ported to 64-bit for hppa, so there is no usable userspace available yet.
But it's possible to manually build a static 64-bit binary and run that for testing. One such 64-bit test program is available at http://ftp.parisc-linux.org/src/64bit.tar.gz
and it shows various issues with the existing 64-bit syscall path in the kernel.
This patch fixes those issues.
--- arch/parisc/kernel/syscall.S | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/parisc/kernel/syscall.S +8 -6
@@ -243,10 +243,10 @@ linux_gateway_entry: #ifdef CONFIG_64BIT ldil L%sys_call_table, %r1 - or,= %r2,%r2,%r2 - addil L%(sys_call_table64-sys_call_table), %r1 + or,ev %r2,%r2,%r2 + ldil L%sys_call_table64, %r1 ldo R%sys_call_table(%r1), %r19 - or,= %r2,%r2,%r2 + or,ev %r2,%r2,%r2 ldo R%sys_call_table64(%r1), %r19 #else load32 sys_call_table, %r19
@@ -379,10 +379,10 @@ tracesys_next: extrd,u %r19,63,1,%r2 /* W hidden in bottom bit */ ldil L%sys_call_table, %r1 - or,= %r2,%r2,%r2 - addil L%(sys_call_table64-sys_call_table), %r1 + or,ev %r2,%r2,%r2 + ldil L%sys_call_table64, %r1 ldo R%sys_call_table(%r1), %r19 - or,= %r2,%r2,%r2 + or,ev %r2,%r2,%r2 ldo R%sys_call_table64(%r1), %r19 #else load32 sys_call_table, %r19
@@ -1327,6 +1327,8 @@ ENTRY(sys_call_table) END(sys_call_table) #ifdef CONFIG_64BIT +#undef __SYSCALL_WITH_COMPAT +#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native) .align 8 ENTRY(sys_call_table64) #include <asm/syscall_table_64.h> /* 64-bit syscalls */
Greg Kroah-Hartman
maintainerPATCH 342/482 parisc: Allow mmap(MAP_STACK) memory to automatically expand upwards
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 5d698966fa7b452035c44c937d704910bf3440dd upstream.
When userspace allocates memory with mmap() in order to be used for stack, allow this memory region to automatically expand upwards up until the current maximum process stack size.
The fault handler checks if the VM_GROWSUP bit is set in the vm_flags field of a memory area before it allows it to expand.
This patch modifies the parisc specific code only.
A RFC for a generic patch to modify mmap() for all architectures was sent to the mailing list but did not get enough Acks.
--- arch/parisc/include/asm/mman.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/parisc/include/asm/mman.h +14 -0
@@ -11,4 +11,18 @@ static inline bool arch_memory_deny_writ }#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported +static inline unsigned long arch_calc_vm_flag_bits (unsigned long flags) +{ +/* +* The stack on parisc grows upwards, so if userspace requests memory +* for a stack, mark it with VM_GROWSUP so that the stack expansion in +* the fault handler will work. +*/ +if (flags &MAP_STACK ) +return VM_GROWSUP ; + +return 0 ; +} +#define arch_calc_vm_flag_bits (flags) arch_calc_vm_flag_bits(flags) +#endif /* __ASM_MMAN_H__ */
Greg Kroah-Hartman
maintainerPATCH 343/482 parisc: Fix stack start for ADDR_NO_RANDOMIZE personality
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit f31b256994acec6929306dfa86ac29716e7503d6 upstream.
Fix the stack start address calculation for the parisc architecture in setup_arg_pages() when address randomization is disabled. When the ADDR_NO_RANDOMIZE process personality is disabled there is no need to add additional space for the stack.
Note that this patch touches code inside an #ifdef CONFIG_STACK_GROWSUP hunk, which is why only the parisc architecture is affected since it's the only Linux architecture where the stack grows upwards.
Without this patch you will find the stack in the middle of some mapped libaries and suddenly limited to 6MB instead of 8MB:
root@parisc:~# setarch -R /bin/bash -c "cat /proc/self/maps" 00010000-00019000 r-xp 00000000 08:05 1182034 /usr/bin/cat 00019000-0001a000 rwxp 00009000 08:05 1182034 /usr/bin/cat 0001a000-0003b000 rwxp 00000000 00:00 0 [heap] f90c4000-f9283000 r-xp 00000000 08:05 1573004 /usr/lib/hppa-linux-gnu/libc.so.6 f9283000-f9285000 r--p 001bf000 08:05 1573004 /usr/lib/hppa-linux-gnu/libc.so.6 f9285000-f928a000 rwxp 001c1000 08:05 1573004 /usr/lib/hppa-linux-gnu/libc.so.6 f928a000-f9294000 rwxp 00000000 00:00 0 f9301000-f9323000 rwxp 00000000 00:00 0 [stack] f98b4000-f98e4000 r-xp 00000000 08:05 1572869 /usr/lib/hppa-linux-gnu/ld.so.1 f98e4000-f98e5000 r--p 00030000 08:05 1572869 /usr/lib/hppa-linux-gnu/ld.so.1 f98e5000-f98e9000 rwxp 00031000 08:05 1572869 /usr/lib/hppa-linux-gnu/ld.so.1 f9ad8000-f9b00000 rw-p 00000000 00:00 0 f9b00000-f9b01000 r-xp 00000000 00:00 0 [vdso]
With the patch the stack gets correctly mapped at the end of the process memory map:
root@panama:~# setarch -R /bin/bash -c "cat /proc/self/maps" 00010000-00019000 r-xp 00000000 08:13 16385582 /usr/bin/cat 00019000-0001a000 rwxp 00009000 08:13 16385582 /usr/bin/cat 0001a000-0003b000 rwxp 00000000 00:00 0 [heap] fef29000-ff0eb000 r-xp 00000000 08:13 16122400 /usr/lib/hppa-linux-gnu/libc.so.6 ff0eb000-ff0ed000 r--p 001c2000 08:13 16122400 /usr/lib/hppa-linux-gnu/libc.so.6 ff0ed000-ff0f2000 rwxp 001c4000 08:13 16122400 /usr/lib/hppa-linux-gnu/libc.so.6 ff0f2000-ff0fc000 rwxp 00000000 00:00 0 ff4b4000-ff4e4000 r-xp 00000000 08:13 16121913 /usr/lib/hppa-linux-gnu/ld.so.1 ff4e4000-ff4e6000 r--p 00030000 08:13 16121913 /usr/lib/hppa-linux-gnu/ld.so.1 ff4e6000-ff4ea000 rwxp 00032000 08:13 16121913 /usr/lib/hppa-linux-gnu/ld.so.1 ff6d7000-ff6ff000 rw-p 00000000 00:00 0 ff6ff000-ff700000 r-xp 00000000 00:00 0 [vdso] ff700000-ff722000 rwxp 00000000 00:00 0 [stack]
--- fs/exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/exec.c +2 -1
@@ -782,7 +782,8 @@ int setup_arg_pages(struct linux_binprm stack_base =calc_max_stack_size (stack_base);/* Add space for stack randomization. */ - stack_base += (STACK_RND_MASK <<PAGE_SHIFT ); +if (current->flags &PF_RANDOMIZE ) + stack_base += (STACK_RND_MASK <<PAGE_SHIFT );/* Make sure we didn't let the argument array grow too large. */ if (vma->vm_end - vma->vm_start > stack_base)
Greg Kroah-Hartman
maintainerPATCH 344/482 drm/rockchip: vop: clear DMA stop bit on RK3066
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
commit 6b44aa559d6c7f4ea591ef9d2352a7250138d62a upstream.
The RK3066 VOP sets a dma_stop bit when it's done scanning out a frame and needs the driver to acknowledge that by clearing the bit.
Unless we clear it "between" frames, the RGB output only shows noise instead of the picture. atomic_flush is the place for it that least affects other code (doing it on vblank would require converting all other usages of the reg_lock to spin_(un)lock_irq, which would affect performance for everyone).
This seems to be a redundant synchronization mechanism that was removed in later iterations of the VOP hardware block.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++++ drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 1 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + 3 files changed, 6 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +4 -0
@@ -1583,6 +1583,10 @@ static void vop_crtc_atomic_flush(structVOP_AFBC_SET (vop, enable, s->enable_afbc);vop_cfg_done (vop); +/* Ack the DMA transfer of the previous frame (RK3066). */ +if (VOP_HAS_REG (vop, common, dma_stop)) +VOP_REG_SET (vop, common, dma_stop,0 ); +spin_unlock (&vop->reg_lock);/*
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +1 -0
@@ -122,6 +122,7 @@ struct vop_common {struct vop_reg lut_buffer_index;struct vop_reg gate_en;struct vop_reg mmu_en; +struct vop_reg dma_stop;struct vop_reg out_mode;struct vop_reg standby; };
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +1 -0
@@ -466,6 +466,7 @@ static const struct vop_output rk3066_ou };static const struct vop_common rk3066_common = { + .dma_stop =VOP_REG (RK3066_SYS_CTRL0 ,0x1 ,0 ), .standby =VOP_REG (RK3066_SYS_CTRL0 ,0x1 ,1 ), .out_mode =VOP_REG (RK3066_DSP_CTRL0 ,0xf ,0 ), .cfg_done =VOP_REG (RK3066_REG_CFG_DONE ,0x1 ,0 ),
Greg Kroah-Hartman
maintainerPATCH 345/482 of: address: Report error on resource bounds overflow
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 000f6d588a8f3d128f89351058dc04d38e54a327 upstream.
The members "start" and "end" of struct resource are of type "resource_size_t" which can be 32bit wide.
Values read from OF however are always 64bit wide.
Avoid silently truncating the value and instead return an error value.
This can happen on real systems when the DT was created for a PAE-enabled kernel and a non-PAE kernel is actually running. For example with an arm defconfig and "qemu-system-arm -M virt".
--- drivers/of/address.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/of/address.c +5 -0
@@ -8,6 +8,7 @@#include <linux/logic_pio.h> #include <linux/module.h> #include <linux/of_address.h> +#include <linux/overflow.h> #include <linux/pci.h> #include <linux/pci_regs.h> #include <linux/sizes.h>
@@ -1061,7 +1062,11 @@ static int __of_address_to_resource(struif (of_mmio_is_nonposted (dev)) flags |=IORESOURCE_MEM_NONPOSTED ; +if (overflows_type (taddr, r->start)) +return -EOVERFLOW ; r->start = taddr; +if (overflows_type (taddr + size -1 , r->end)) +return -EOVERFLOW ; r->end = taddr + size -1 ; r->flags = flags; r->name = name ? name : dev->full_name;
Greg Kroah-Hartman
maintainerPATCH 346/482 of/irq: Support #msi-cells=<0> in of_msi_get_domain
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Jones <[email protected]>
commit db8e81132cf051843c9a59b46fa5a071c45baeb3 upstream.
An 'msi-parent' property with a single entry and no accompanying '#msi-cells' property is considered the legacy definition as opposed to its definition after being expanded with commit 126b16e2ad98 ("Docs: dt: add generic MSI bindings"). However, the legacy definition is completely compatible with the current definition and, since of_phandle_iterator_next() tolerates missing and present-but- zero *cells properties since commit e42ee61017f5 ("of: Let of_for_each_phandle fallback to non-negative cell_count"), there's no need anymore to special case the legacy definition in of_msi_get_domain().
Indeed, special casing has turned out to be harmful, because, as of commit 7c025238b47a ("dt-bindings: irqchip: Describe the IMX MU block as a MSI controller"), MSI controller DT bindings have started specifying '#msi-cells' as a required property (even when the value must be zero) as an effort to make the bindings more explicit. But, since the special casing of 'msi-parent' only uses the existence of '#msi-cells' for its heuristic, and not whether or not it's also nonzero, the legacy path is not taken. Furthermore, the path to support the new, broader definition isn't taken either since that path has been restricted to the platform-msi bus.
But, neither the definition of 'msi-parent' nor the definition of '#msi-cells' is platform-msi-specific (the platform-msi bus was just the first bus that needed '#msi-cells'), so remove both the special casing and the restriction. The code removal also requires changing to of_parse_phandle_with_optional_args() in order to ensure the legacy (but compatible) use of 'msi-parent' remains supported. This not only simplifies the code but also resolves an issue with PCI devices finding their MSI controllers on riscv, as the riscv,imsics binding requires '#msi-cells=<0>'.
--- drivers/of/irq.c | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-)
drivers/of/irq.c +7 -27
@@ -716,8 +716,7 @@ struct irq_domain *of_msi_map_get_device* @np: device node for @dev * @token: bus type for this domain * -* Parse the msi-parent property (both the simple and the complex -* versions), and returns the corresponding MSI domain. +* Parse the msi-parent property and returns the corresponding MSI domain. * * Returns: the MSI domain for this device (or NULL on failure). */
@@ -725,33 +724,14 @@ struct irq_domain *of_msi_get_domain(strstruct device_node *np, enum irq_domain_bus_token token) { - struct device_node *msi_np; + struct of_phandle_iterator it;struct irq_domain *d; +int err; -/* Check for a single msi-parent property */ - msi_np =of_parse_phandle (np,"msi-parent" ,0 ); -if (msi_np && !of_property_read_bool (msi_np,"#msi-cells" )) { - d =irq_find_matching_host (msi_np, token); -if (!d) -of_node_put (msi_np); -return d; - } - -if (token ==DOMAIN_BUS_PLATFORM_MSI ) { -/* Check for the complex msi-parent version */ -struct of_phandle_args args; -int index =0 ; - -while (!of_parse_phandle_with_args (np,"msi-parent" , -"#msi-cells" , - index, &args)) { - d =irq_find_matching_host (args.np, token); -if (d) -return d; - -of_node_put (args.np); - index++; - } +of_for_each_phandle (&it, err, np,"msi-parent" ,"#msi-cells" ,0 ) { + d =irq_find_matching_host (it.node, token); +if (d) +return d; }return NULL ;
Greg Kroah-Hartman
maintainerPATCH 347/482 drm: omapdrm: Add missing check for alloc_ordered_workqueue
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit e794b7b9b92977365c693760a259f8eef940c536 upstream.
As it may return NULL pointer and cause NULL pointer dereference. Add check for the return value of alloc_ordered_workqueue.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/omapdrm/omap_drv.c +5 -0
@@ -695,6 +695,10 @@ static int omapdrm_init(struct omap_drm_ soc =soc_device_match (omapdrm_soc_devices); priv->omaprev = soc ? (uintptr_t )soc->data :0 ; priv->wq =alloc_ordered_workqueue ("omapdrm" ,0 ); +if (!priv->wq) { + ret = -ENOMEM ; + goto err_alloc_workqueue; + }mutex_init (&priv->list_lock);INIT_LIST_HEAD (&priv->obj_list);
@@ -753,6 +757,7 @@ err_gem_deinit:drm_mode_config_cleanup (ddev);omap_gem_deinit (ddev);destroy_workqueue (priv->wq); +err_alloc_workqueue:omap_disconnect_pipelines (ddev);drm_dev_put (ddev);return ret;
Greg Kroah-Hartman
maintainerPATCH 348/482 resource: fix region_intersects() vs add_memory_driver_managed()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huang Ying <[email protected]>
commit b4afe4183ec77f230851ea139d91e5cf2644c68b upstream.
On a system with CXL memory, the resource tree (/proc/iomem) related to CXL memory may look like something as follows.
490000000-50fffffff : CXL Window 0
490000000-50fffffff : region0
490000000-50fffffff : dax0.0
490000000-50fffffff : System RAM (kmem)Because drivers/dax/kmem.c calls add_memory_driver_managed() during onlining CXL memory, which makes "System RAM (kmem)" a descendant of "CXL Window X". This confuses region_intersects(), which expects all "System RAM" resources to be at the top level of iomem_resource. This can lead to bugs.
For example, when the following command line is executed to write some memory in CXL memory range via /dev/mem,
$ dd if=data of=/dev/mem bs=$((1 << 10)) seek=$((0x490000000 >> 10)) count=1 dd: error writing '/dev/mem': Bad address 1+0 records in 0+0 records out 0 bytes copied, 0.0283507 s, 0.0 kB/s
the command fails as expected. However, the error code is wrong. It should be "Operation not permitted" instead of "Bad address". More seriously, the /dev/mem permission checking in devmem_is_allowed() passes incorrectly. Although the accessing is prevented later because ioremap() isn't allowed to map system RAM, it is a potential security issue. During command executing, the following warning is reported in the kernel log for calling ioremap() on system RAM.
ioremap on RAM at 0x0000000490000000 - 0x0000000490000fff
WARNING: CPU: 2 PID: 416 at arch/x86/mm/ioremap.c:216 __ioremap_caller.constprop.0+0x131/0x35d Call Trace: memremap+0xcb/0x184 xlate_dev_mem_ptr+0x25/0x2f write_mem+0x94/0xfb vfs_write+0x128/0x26d ksys_write+0xac/0xfe do_syscall_64+0x9a/0xfd entry_SYSCALL_64_after_hwframe+0x4b/0x53
The details of command execution process are as follows. In the above resource tree, "System RAM" is a descendant of "CXL Window 0" instead of a top level resource. So, region_intersects() will report no System RAM resources in the CXL memory region incorrectly, because it only checks the top level resources. Consequently, devmem_is_allowed() will return 1 (allow access via /dev/mem) for CXL memory region incorrectly. Fortunately, ioremap() doesn't allow to map System RAM and reject the access.
So, region_intersects() needs to be fixed to work correctly with the resource tree with "System RAM" not at top level as above. To fix it, if we found a unmatched resource in the top level, we will continue to search matched resources in its descendant resources. So, we will not miss any matched resources in resource tree anymore.
In the new implementation, an example resource tree
|------------- "CXL Window 0" ------------| |-- "System RAM" --|
will behave similar as the following fake resource tree for region_intersects(, IORESOURCE_SYSTEM_RAM, ),
|-- "System RAM" --||-- "CXL Window 0a" --|
Where "CXL Window 0a" is part of the original "CXL Window 0" that isn't covered by "System RAM".
--- kernel/resource.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-)
kernel/resource.c +50 -8
@@ -548,20 +548,62 @@ static int __region_intersects(struct re size_t size, unsigned long flags, unsigned long desc) { - struct resource res; + resource_size_t ostart, oend;int type =0 ;int other =0 ; -struct resource *p; +struct resource *p, *dp; +bool is_type, covered; +struct resource res; res.start = start; res.end = start + size -1 ;for (p = parent->child; p ; p = p->sibling) { -bool is_type = (((p->flags & flags) == flags) && - ((desc ==IORES_DESC_NONE ) || - (desc == p->desc))); - -if (resource_overlaps (p, &res)) - is_type ? type++ : other++; +if (!resource_overlaps (p, &res)) +continue ; + is_type = (p->flags & flags) == flags && + (desc ==IORES_DESC_NONE || desc == p->desc); +if (is_type) { + type++; +continue ; + } +/* +* Continue to search in descendant resources as if the +* matched descendant resources cover some ranges of 'p'. +* +* |------------- "CXL Window 0" ------------| +* |-- "System RAM" --| +* +* will behave similar as the following fake resource +* tree when searching "System RAM". +* +* |-- "System RAM" --||-- "CXL Window 0a" --| +*/ + covered = false; + ostart =max (res.start, p->start); + oend =min (res.end, p->end); +for_each_resource (p, dp, false) { +if (!resource_overlaps (dp, &res)) +continue ; + is_type = (dp->flags & flags) == flags && + (desc ==IORES_DESC_NONE || desc == dp->desc); +if (is_type) { + type++; +/* +* Range from 'ostart' to 'dp->start' +* isn't covered by matched resource. +*/ +if (dp->start > ostart) +break ; +if (dp->end >= oend) { + covered = true; +break ; + } +/* Remove covered range */ + ostart =max (ostart, dp->end +1 ); + } + } +if (!covered) + other++; }if (type ==0 )
Greg Kroah-Hartman
maintainerPATCH 349/482 jbd2: stop waiting for space when jbd2_cleanup_journal_tail() returns error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit f5cacdc6f2bb2a9bf214469dd7112b43dd2dd68a upstream.
In __jbd2_log_wait_for_space(), we might call jbd2_cleanup_journal_tail() to recover some journal space. But if an error occurs while executing jbd2_cleanup_journal_tail() (e.g., an EIO), we don't stop waiting for free space right away, we try other branches, and if j_committing_transaction is NULL (i.e., the tid is 0), we will get the following complain:
============================================
JBD2: I/O error when updating journal superblock for sdd-8. __jbd2_log_wait_for_space: needed 256 blocks and only had 217 space available __jbd2_log_wait_for_space: no way to get more journal space in sdd-8
------------[ cut here ]------------ WARNING: CPU: 2 PID: 139804 at fs/jbd2/checkpoint.c:109 __jbd2_log_wait_for_space+0x251/0x2e0 Modules linked in: CPU: 2 PID: 139804 Comm: kworker/u8:3 Not tainted 6.6.0+ #1 RIP: 0010:__jbd2_log_wait_for_space+0x251/0x2e0 Call Trace: <TASK> add_transaction_credits+0x5d1/0x5e0 start_this_handle+0x1ef/0x6a0 jbd2__journal_start+0x18b/0x340 ext4_dirty_inode+0x5d/0xb0 __mark_inode_dirty+0xe4/0x5d0 generic_update_time+0x60/0x70
[...]
============================================
So only if jbd2_cleanup_journal_tail() returns 1, i.e., there is nothing to clean up at the moment, continue to try to reclaim free space in other ways.
Note that this fix relies on commit 6f6a6fda2945 ("jbd2: fix ocfs2 corrupt when updating journal superblock fails") to make jbd2_cleanup_journal_tail return the correct error code.
--- fs/jbd2/checkpoint.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/jbd2/checkpoint.c +5 -2
@@ -89,8 +89,11 @@ __releases(&journal->j_state_lock)write_unlock (&journal->j_state_lock);if (chkpt) {jbd2_log_do_checkpoint (journal); - }else if (jbd2_cleanup_journal_tail (journal) ==0 ) { -/* We were able to recover space; yay! */ + }else if (jbd2_cleanup_journal_tail (journal) <=0 ) { +/* +* We were able to recover space or the +* journal was aborted due to an error. +*/ ; }else if (has_transaction) {/*
Greg Kroah-Hartman
maintainerPATCH 350/482 jbd2: correctly compare tids with tid_geq function in jbd2_fc_begin_commit
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit f0e3c14802515f60a47e6ef347ea59c2733402aa upstream.
Use tid_geq to compare tids to work over sequence number wraps.
--- fs/jbd2/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jbd2/journal.c +1 -1
@@ -725,7 +725,7 @@ int jbd2_fc_begin_commit(journal_t *jourreturn -EINVAL ;write_lock (&journal->j_state_lock); -if (tid <= journal->j_commit_sequence) { +if (tid_geq (journal->j_commit_sequence, tid)) {write_unlock (&journal->j_state_lock);return -EALREADY ; }
Greg Kroah-Hartman
maintainerPATCH 351/482 mm: krealloc: consider spare memory for __GFP_ZERO
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danilo Krummrich <[email protected]>
commit 1a83a716ec233990e1fd5b6fbb1200ade63bf450 upstream.
As long as krealloc() is called with __GFP_ZERO consistently, starting with the initial memory allocation, __GFP_ZERO should be fully honored.
However, if for an existing allocation krealloc() is called with a decreased size, it is not ensured that the spare portion the allocation is zeroed. Thus, if krealloc() is subsequently called with a larger size again, __GFP_ZERO can't be fully honored, since we don't know the previous size, but only the bucket size.
Example:
buf = kzalloc(64, GFP_KERNEL); memset(buf, 0xff, 64); buf = krealloc(buf, 48, GFP_KERNEL | __GFP_ZERO); /* After this call the last 16 bytes are still 0xff. */ buf = krealloc(buf, 64, GFP_KERNEL | __GFP_ZERO);
Fix this, by explicitly setting spare memory to zero, when shrinking an allocation with __GFP_ZERO flag set or init_on_alloc enabled.
--- mm/slab_common.c | 7 +++++++ 1 file changed, 7 insertions(+)
mm/slab_common.c +7 -0
@@ -1176,6 +1176,13 @@ __do_krealloc(const void *p, size_t new_/* If the object still fits, repoison it precisely. */ if (ks >= new_size) { +/* Zero out spare memory. */ +if (want_init_on_alloc (flags)) { +kasan_disable_current (); +memset ((void *)p + new_size,0 , ks - new_size); +kasan_enable_current (); + } + p =kasan_krealloc ((void *)p, new_size, flags);return (void *)p; }
Greg Kroah-Hartman
maintainerPATCH 352/482 ocfs2: fix the la space leak when unmounting an ocfs2 volume
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heming Zhao <[email protected]>
commit dfe6c5692fb525e5e90cefe306ee0dffae13d35f upstream.
This bug has existed since the initial OCFS2 code. The code logic in ocfs2_sync_local_to_main() is wrong, as it ignores the last contiguous free bits, which causes an OCFS2 volume to lose the last free clusters of LA window on each umount command.
--- fs/ocfs2/localalloc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
fs/ocfs2/localalloc.c +19 -0
@@ -1002,6 +1002,25 @@ static int ocfs2_sync_local_to_main(stru start = bit_off +1 ; } +/* clear the contiguous bits until the end boundary */ +if (count) { + blkno = la_start_blk + +ocfs2_clusters_to_blocks (osb->sb, + start - count); + +trace_ocfs2_sync_local_to_main_free ( + count, start - count, + (unsigned long long )la_start_blk, + (unsigned long long )blkno); + + status =ocfs2_release_clusters (handle, + main_bm_inode, + main_bm_bh, blkno, + count); +if (status <0 ) +mlog_errno (status); + } + bail:if (status)mlog_errno (status);
Greg Kroah-Hartman
maintainerPATCH 353/482 ocfs2: fix uninit-value in ocfs2_get_block()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
commit 2af148ef8549a12f8025286b8825c2833ee6bcb8 upstream.
syzbot reported an uninit-value BUG:
BUG: KMSAN: uninit-value in ocfs2_get_block+0xed2/0x2710 fs/ocfs2/aops.c:159 ocfs2_get_block+0xed2/0x2710 fs/ocfs2/aops.c:159 do_mpage_readpage+0xc45/0x2780 fs/mpage.c:225 mpage_readahead+0x43f/0x840 fs/mpage.c:374 ocfs2_readahead+0x269/0x320 fs/ocfs2/aops.c:381 read_pages+0x193/0x1110 mm/readahead.c:160 page_cache_ra_unbounded+0x901/0x9f0 mm/readahead.c:273 do_page_cache_ra mm/readahead.c:303 [inline] force_page_cache_ra+0x3b1/0x4b0 mm/readahead.c:332 force_page_cache_readahead mm/internal.h:347 [inline] generic_fadvise+0x6b0/0xa90 mm/fadvise.c:106 vfs_fadvise mm/fadvise.c:185 [inline] ksys_fadvise64_64 mm/fadvise.c:199 [inline] __do_sys_fadvise64 mm/fadvise.c:214 [inline] __se_sys_fadvise64 mm/fadvise.c:212 [inline] __x64_sys_fadvise64+0x1fb/0x3a0 mm/fadvise.c:212 x64_sys_call+0xe11/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:222 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
This is because when ocfs2_extent_map_get_blocks() fails, p_blkno is uninitialized. So the error log will trigger the above uninit-value access.
The error log is out-of-date since get_blocks() was removed long time ago. And the error code will be logged in ocfs2_extent_map_get_blocks() once ocfs2_get_cluster() fails, so fix this by only logging inode and block.
--- fs/ocfs2/aops.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/ocfs2/aops.c +2 -3
@@ -156,9 +156,8 @@ int ocfs2_get_block(struct inode *inode, err =ocfs2_extent_map_get_blocks (inode, iblock, &p_blkno, &count, &ext_flags);if (err) { -mlog (ML_ERROR ,"Error %d from get_blocks(0x%p, %llu, 1, " -"%llu, NULL)\n" , err, inode, (unsigned long long )iblock, - (unsigned long long )p_blkno); +mlog (ML_ERROR ,"get_blocks() failed, inode: 0x%p, " +"block: %llu\n" , inode, (unsigned long long )iblock); goto bail; }
Greg Kroah-Hartman
maintainerPATCH 354/482 ocfs2: reserve space for inline xattr before attaching reflink tree
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautham Ananthakrishna <[email protected]>
commit 5ca60b86f57a4d9648f68418a725b3a7de2816b0 upstream.
One of our customers reported a crash and a corrupted ocfs2 filesystem. The crash was due to the detection of corruption. Upon troubleshooting, the fsck -fn output showed the below corruption
[EXTENT_LIST_FREE] Extent list in owner 33080590 claims 230 as the next free chain record, but fsck believes the largest valid value is 227. Clamp the next record value? n
The stat output from the debugfs.ocfs2 showed the following corruption where the "Next Free Rec:" had overshot the "Count:" in the root metadata block.
Inode: 33080590 Mode: 0640 Generation: 2619713622 (0x9c25a856)
FS Generation: 904309833 (0x35e6ac49)
CRC32: 00000000 ECC: 0000
Type: Regular Attr: 0x0 Flags: Valid
Dynamic Features: (0x16) HasXattr InlineXattr Refcounted
Extended Attributes Block: 0 Extended Attributes Inline Size: 256
User: 0 (root) Group: 0 (root) Size: 281320357888
Links: 1 Clusters: 141738
ctime: 0x66911b56 0x316edcb8 -- Fri Jul 12 06:02:30.829349048 2024
atime: 0x66911d6b 0x7f7a28d -- Fri Jul 12 06:11:23.133669517 2024
mtime: 0x66911b56 0x12ed75d7 -- Fri Jul 12 06:02:30.317552087 2024
dtime: 0x0 -- Wed Dec 31 17:00:00 1969
Refcount Block: 2777346
Last Extblk: 2886943 Orphan Slot: 0
Sub Alloc Slot: 0 Sub Alloc Bit: 14
Tree Depth: 1 Count: 227 Next Free Rec: 230
## Offset Clusters Block#
0 0 2310 2776351
1 2310 2139 2777375
2 4449 1221 2778399
3 5670 731 2779423
4 6401 566 2780447
....... .... .......
....... .... .......The issue was in the reflink workfow while reserving space for inline xattr. The problematic function is ocfs2_reflink_xattr_inline(). By the time this function is called the reflink tree is already recreated at the destination inode from the source inode. At this point, this function reserves space for inline xattrs at the destination inode without even checking if there is space at the root metadata block. It simply reduces the l_count from 243 to 227 thereby making space of 256 bytes for inline xattr whereas the inode already has extents beyond this index (in this case up to 230), thereby causing corruption.
The fix for this is to reserve space for inline metadata at the destination inode before the reflink tree gets recreated. The customer has verified the fix.
--- fs/ocfs2/refcounttree.c | 26 ++++++++++++++++++++++++-- fs/ocfs2/xattr.c | 11 +---------- 2 files changed, 25 insertions(+), 12 deletions(-)
fs/ocfs2/refcounttree.c +24 -2
@@ -25,6 +25,7 @@#include "namei.h" #include "ocfs2_trace.h" #include "file.h" +#include "symlink.h" #include <linux/bio.h> #include <linux/blkdev.h>
@@ -4155,8 +4156,9 @@ static int __ocfs2_reflink(struct dentryint ret;struct inode *inode =d_inode (old_dentry);struct buffer_head *new_bh =NULL ; +struct ocfs2_inode_info *oi =OCFS2_I (inode); -if (OCFS2_I (inode)->ip_flags &OCFS2_INODE_SYSTEM_FILE ) { +if (oi->ip_flags &OCFS2_INODE_SYSTEM_FILE ) { ret = -EINVAL ;mlog_errno (ret); goto out;
@@ -4182,6 +4184,26 @@ static int __ocfs2_reflink(struct dentry goto out_unlock; } +if ((oi->ip_dyn_features &OCFS2_HAS_XATTR_FL ) && + (oi->ip_dyn_features &OCFS2_INLINE_XATTR_FL )) { +/* +* Adjust extent record count to reserve space for extended attribute. +* Inline data count had been adjusted in ocfs2_duplicate_inline_data(). +*/ +struct ocfs2_inode_info *new_oi =OCFS2_I (new_inode); + +if (!(new_oi->ip_dyn_features &OCFS2_INLINE_DATA_FL ) && + !(ocfs2_inode_is_fast_symlink (new_inode))) { +struct ocfs2_dinode *new_di = (struct ocfs2_dinode *)new_bh->b_data; +struct ocfs2_dinode *old_di = (struct ocfs2_dinode *)old_bh->b_data; +struct ocfs2_extent_list *el = &new_di->id2.i_list; +int inline_size =le16_to_cpu (old_di->i_xattr_inline_size); + +le16_add_cpu (&el->l_count, -(inline_size / +sizeof (struct ocfs2_extent_rec ))); + } + } + ret =ocfs2_create_reflink_node (inode, old_bh, new_inode, new_bh, preserve);if (ret) {
@@ -4189,7 +4211,7 @@ static int __ocfs2_reflink(struct dentry goto inode_unlock; } -if (OCFS2_I (inode)->ip_dyn_features &OCFS2_HAS_XATTR_FL ) { +if (oi->ip_dyn_features &OCFS2_HAS_XATTR_FL ) { ret =ocfs2_reflink_xattrs (inode, old_bh, new_inode, new_bh, preserve);
fs/ocfs2/xattr.c +1 -10
@@ -6520,16 +6520,7 @@ static int ocfs2_reflink_xattr_inline(st } new_oi =OCFS2_I (args->new_inode); -/* -* Adjust extent record count to reserve space for extended attribute. -* Inline data count had been adjusted in ocfs2_duplicate_inline_data(). -*/ -if (!(new_oi->ip_dyn_features &OCFS2_INLINE_DATA_FL ) && - !(ocfs2_inode_is_fast_symlink (args->new_inode))) { -struct ocfs2_extent_list *el = &new_di->id2.i_list; -le16_add_cpu (&el->l_count, -(inline_size / -sizeof (struct ocfs2_extent_rec ))); - } +spin_lock (&new_oi->ip_lock); new_oi->ip_dyn_features |=OCFS2_HAS_XATTR_FL |OCFS2_INLINE_XATTR_FL ; new_di->i_dyn_features =cpu_to_le16 (new_oi->ip_dyn_features);
Greg Kroah-Hartman
maintainerPATCH 355/482 ocfs2: cancel dqi_sync_work before freeing oinfo
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
commit 35fccce29feb3706f649726d410122dd81b92c18 upstream.
ocfs2_global_read_info() will initialize and schedule dqi_sync_work at the end, if error occurs after successfully reading global quota, it will trigger the following warning with CONFIG_DEBUG_OBJECTS_* enabled:
ODEBUG: free active (active state 0) object: 00000000d8b0ce28 object type: timer_list hint: qsync_work_fn+0x0/0x16c
This reports that there is an active delayed work when freeing oinfo in error handling, so cancel dqi_sync_work first. BTW, return status instead of -1 when .read_file_info fails.
--- fs/ocfs2/quota_local.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ocfs2/quota_local.c +6 -2
@@ -692,7 +692,7 @@ static int ocfs2_local_read_info(structint status;struct buffer_head *bh =NULL ;struct ocfs2_quota_recovery *rec; -int locked =0 ; +int locked =0 , global_read =0 ; info->dqi_max_spc_limit =0x7fffffffffffffffLL ; info->dqi_max_ino_limit =0x7fffffffffffffffLL ;
@@ -700,6 +700,7 @@ static int ocfs2_local_read_info(structif (!oinfo) {mlog (ML_ERROR ,"failed to allocate memory for ocfs2 quota" " info." ); + status = -ENOMEM ; goto out_err; } info->dqi_priv = oinfo;
@@ -712,6 +713,7 @@ static int ocfs2_local_read_info(struct status =ocfs2_global_read_info (sb, type);if (status <0 ) goto out_err; + global_read =1 ; status =ocfs2_inode_lock (lqinode, &oinfo->dqi_lqi_bh,1 );if (status <0 ) {
@@ -782,10 +784,12 @@ out_err:if (locked)ocfs2_inode_unlock (lqinode,1 );ocfs2_release_local_quota_bitmaps (&oinfo->dqi_chunk); +if (global_read) +cancel_delayed_work_sync (&oinfo->dqi_sync_work);kfree (oinfo); }brelse (bh); -return -1 ; +return status; }/* Write local info to quota file */
Greg Kroah-Hartman
maintainerPATCH 356/482 ocfs2: remove unreasonable unlock in ocfs2_read_blocks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Xu <[email protected]>
commit c03a82b4a0c935774afa01fd6d128b444fd930a1 upstream.
Patch series "Misc fixes for ocfs2_read_blocks", v5.
This series contains 2 fixes for ocfs2_read_blocks(). The first patch fix the issue reported by syzbot, which detects bad unlock balance in ocfs2_read_blocks(). The second patch fixes an issue reported by Heming Zhao when reviewing above fix.
This patch (of 2):
There was a lock release before exiting, so remove the unreasonable unlock.
--- fs/ocfs2/buffer_head_io.c | 1 - 1 file changed, 1 deletion(-)
fs/ocfs2/buffer_head_io.c +0 -1
@@ -235,7 +235,6 @@ int ocfs2_read_blocks(struct ocfs2_cachiif (bhs[i] ==NULL ) { bhs[i] =sb_getblk (sb, block++);if (bhs[i] ==NULL ) { -ocfs2_metadata_cache_io_unlock (ci); status = -ENOMEM ;mlog_errno (status);/* Don't forget to put previous bh! */
Greg Kroah-Hartman
maintainerPATCH 357/482 ocfs2: fix null-ptr-deref when journal load failed.
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
commit 5784d9fcfd43bd853654bb80c87ef293b9e8e80a upstream.
During the mounting process, if journal_reset() fails because of too short journal, then lead to jbd2_journal_load() fails with NULL j_sb_buffer. Subsequently, ocfs2_journal_shutdown() calls jbd2_journal_flush()->jbd2_cleanup_journal_tail()-> __jbd2_update_log_tail()->jbd2_journal_update_sb_log_tail() ->lock_buffer(journal->j_sb_buffer), resulting in a null-pointer dereference error.
To resolve this issue, we should check the JBD2_LOADED flag to ensure the journal was properly loaded. Additionally, use journal instead of osb->journal directly to simplify the code.
--- fs/ocfs2/journal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/ocfs2/journal.c +4 -3
@@ -1055,7 +1055,7 @@ void ocfs2_journal_shutdown(struct ocfs2if (!igrab (inode))BUG (); - num_running_trans =atomic_read (&(osb->journal->j_num_trans)); + num_running_trans =atomic_read (&(journal->j_num_trans));trace_ocfs2_journal_shutdown (num_running_trans);/* Do a commit_cache here. It will flush our journal, *and*
@@ -1074,9 +1074,10 @@ void ocfs2_journal_shutdown(struct ocfs2 osb->commit_task =NULL ; } -BUG_ON (atomic_read (&(osb->journal->j_num_trans)) !=0 ); +BUG_ON (atomic_read (&(journal->j_num_trans)) !=0 ); -if (ocfs2_mount_local (osb)) { +if (ocfs2_mount_local (osb) && + (journal->j_journal->j_flags &JBD2_LOADED )) {jbd2_journal_lock_updates (journal->j_journal); status =jbd2_journal_flush (journal->j_journal,0 );jbd2_journal_unlock_updates (journal->j_journal);
Greg Kroah-Hartman
maintainerPATCH 358/482 ocfs2: fix possible null-ptr-deref in ocfs2_set_buffer_uptodate
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Xu <[email protected]>
commit 33b525cef4cff49e216e4133cc48452e11c0391e upstream.
When doing cleanup, if flags without OCFS2_BH_READAHEAD, it may trigger NULL pointer dereference in the following ocfs2_set_buffer_uptodate() if bh is NULL.
--- fs/ocfs2/buffer_head_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ocfs2/buffer_head_io.c +2 -1
@@ -388,7 +388,8 @@ read_failure:/* Always set the buffer in the cache, even if it was * a forced read, or read-ahead which hasn't yet * completed. */ -ocfs2_set_buffer_uptodate (ci, bh); +if (bh) +ocfs2_set_buffer_uptodate (ci, bh); }ocfs2_metadata_cache_io_unlock (ci);
Greg Kroah-Hartman
maintainerPATCH 359/482 scripts/gdb: fix timerlist parsing issue
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Ying Lee <[email protected]>
commit a633a4b8001a7f2a12584f267a3280990d9ababa upstream.
Patch series "Fix some GDB command error and add some GDB commands", v3.
Fix some GDB command errors and add some useful GDB commands.
This patch (of 5):
Commit 7988e5ae2be7 ("tick: Split nohz and highres features from nohz_mode") and commit 7988e5ae2be7 ("tick: Split nohz and highres features from nohz_mode") move 'tick_stopped' and 'nohz_mode' to flags field which will break the gdb lx-mounts command:
(gdb) lx-timerlist
Python Exception <class 'gdb.error'>: There is no member named nohz_mode. Error occurred in Python: There is no member named nohz_mode.
(gdb) lx-timerlist
Python Exception <class 'gdb.error'>: There is no member named tick_stopped. Error occurred in Python: There is no member named tick_stopped.
We move 'tick_stopped' and 'nohz_mode' to flags field instead.
--- scripts/gdb/linux/timerlist.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
scripts/gdb/linux/timerlist.py +16 -15
@@ -87,21 +87,22 @@ def print_cpu(hrtimer_bases, cpu, max_clock_bases): text += "\n" if constants.LX_CONFIG_TICK_ONESHOT: - fmts = [(" .{} : {}", 'nohz_mode'), - (" .{} : {} nsecs", 'last_tick'), - (" .{} : {}", 'tick_stopped'), - (" .{} : {}", 'idle_jiffies'), - (" .{} : {}", 'idle_calls'), - (" .{} : {}", 'idle_sleeps'), - (" .{} : {} nsecs", 'idle_entrytime'), - (" .{} : {} nsecs", 'idle_waketime'), - (" .{} : {} nsecs", 'idle_exittime'), - (" .{} : {} nsecs", 'idle_sleeptime'), - (" .{}: {} nsecs", 'iowait_sleeptime'), - (" .{} : {}", 'last_jiffies'), - (" .{} : {}", 'next_timer'), - (" .{} : {} nsecs", 'idle_expires')] - text += "\n".join([s.format(f, ts[f]) for s, f in fmts]) + TS_FLAG_STOPPED = 1 << 1 + TS_FLAG_NOHZ = 1 << 4 + text += f" .{'nohz':15s}: {int(bool(ts['flags'] & TS_FLAG_NOHZ))}\n" + text += f" .{'last_tick':15s}: {ts['last_tick']}\n" + text += f" .{'tick_stopped':15s}: {int(bool(ts['flags'] & TS_FLAG_STOPPED))}\n" + text += f" .{'idle_jiffies':15s}: {ts['idle_jiffies']}\n" + text += f" .{'idle_calls':15s}: {ts['idle_calls']}\n" + text += f" .{'idle_sleeps':15s}: {ts['idle_sleeps']}\n" + text += f" .{'idle_entrytime':15s}: {ts['idle_entrytime']} nsecs\n" + text += f" .{'idle_waketime':15s}: {ts['idle_waketime']} nsecs\n" + text += f" .{'idle_exittime':15s}: {ts['idle_exittime']} nsecs\n" + text += f" .{'idle_sleeptime':15s}: {ts['idle_sleeptime']} nsecs\n" + text += f" .{'iowait_sleeptime':15s}: {ts['iowait_sleeptime']} nsecs\n" + text += f" .{'last_jiffies':15s}: {ts['last_jiffies']}\n" + text += f" .{'next_timer':15s}: {ts['next_timer']}\n" + text += f" .{'idle_expires':15s}: {ts['idle_expires']} nsecs\n" text += "\njiffies: {}\n".format(jiffies) text += "\n"
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 360/482 scripts/gdb: add iteration function for rbtree
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Ying Lee <[email protected]>
commit 0c77e103c45fa1b119f5d3bb4625eee081c1a6cf upstream.
Add inorder iteration function for rbtree usage.
This is a preparation patch for the next patch to fix the gdb mounts issue.
--- scripts/gdb/linux/rbtree.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
scripts/gdb/linux/rbtree.py +12 -0
@@ -9,6 +9,18 @@ from linux import utils rb_root_type = utils.CachedType("struct rb_root") rb_node_type = utils.CachedType("struct rb_node") +def rb_inorder_for_each(root): + def inorder(node): + if node: + yield from inorder(node['rb_left']) + yield node + yield from inorder(node['rb_right']) + + yield from inorder(root['rb_node']) + +def rb_inorder_for_each_entry(root, gdbtype, member): + for node in rb_inorder_for_each(root): + yield utils.container_of(node, gdbtype, member) def rb_first(root): if root.type == rb_root_type.get_type():
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 361/482 scripts/gdb: fix lx-mounts command error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Ying Lee <[email protected]>
commit 4b183f613924ad536be2f8bd12b307e9c5a96bf6 upstream.
(gdb) lx-mounts
mount super_block devname pathname fstype options
Python Exception <class 'gdb.error'>: There is no member named list. Error occurred in Python: There is no member named list.
We encounter the above issue after commit 2eea9ce4310d ("mounts: keep list of mounts in an rbtree"). The commit move a mount from list into rbtree.
So we can instead use rbtree to iterate all mounts information.
--- scripts/gdb/linux/proc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/gdb/linux/proc.py +2 -2
@@ -18,6 +18,7 @@ from linux import utils from linux import tasks from linux import lists from linux import vfs +from linux import rbtree from struct import *
@@ -172,8 +173,7 @@ values of that process namespace""" gdb.write("{:^18} {:^15} {:>9} {} {} options\n".format( "mount", "super_block", "devname", "pathname", "fstype")) - for mnt in lists.list_for_each_entry(namespace['list'], - mount_ptr_type, "mnt_list"): + for mnt in rbtree.rb_inorder_for_each_entry(namespace['mounts'], mount_ptr_type, "mnt_node"): devname = mnt['mnt_devname'].string() devname = devname if devname else "none"
Greg Kroah-Hartman
maintainerPATCH 362/482 arm64: fix selection of HAVE_DYNAMIC_FTRACE_WITH_ARGS
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit b3d6121eaeb22aee8a02f46706745b1968cc0292 upstream.
The Kconfig logic to select HAVE_DYNAMIC_FTRACE_WITH_ARGS is incorrect, and HAVE_DYNAMIC_FTRACE_WITH_ARGS may be selected when it is not supported by the combination of clang and GNU LD, resulting in link-time errors:
aarch64-linux-gnu-ld: .init.data has both ordered [__patchable_function_entries' in init/main.o] and unordered [.meminit.data' in mm/sparse.o] sections
aarch64-linux-gnu-ld: final link failed: bad value
... which can be seen when building with CC=clang using a binutils version older than 2.36.
We originally fixed that in commit:
45bd8951806eb5e8 ("arm64: Improve HAVE_DYNAMIC_FTRACE_WITH_REGS selection for clang")
... by splitting the "select HAVE_DYNAMIC_FTRACE_WITH_ARGS" statement into separete CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS and GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS options which individually select HAVE_DYNAMIC_FTRACE_WITH_ARGS.
Subsequently we accidentally re-introduced the common "select HAVE_DYNAMIC_FTRACE_WITH_ARGS" statement in commit:
26299b3f6ba26bfc ("ftrace: arm64: move from REGS to ARGS")
... then we removed it again in commit:
68a63a412d18bd2e ("arm64: Fix build with CC=clang, CONFIG_FTRACE=y and CONFIG_STACK_TRACER=y")
... then we accidentally re-introduced it again in commit:
2aa6ac03516d078c ("arm64: ftrace: Add direct call support")
Fix this for the third time by keeping the unified select statement and making this depend onf either GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS or CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS. This is more consistent with usual style and less likely to go wrong in future.
--- arch/arm64/Kconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arm64/Kconfig +2 -3
@@ -195,7 +195,8 @@ config ARM64 select HAVE_DMA_CONTIGUOUS select HAVE_DYNAMIC_FTRACE select HAVE_DYNAMIC_FTRACE_WITH_ARGS \ - if $(cc-option,-fpatchable-function-entry=2) + if (GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS || \ + CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS) select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS \ if DYNAMIC_FTRACE_WITH_ARGS && DYNAMIC_FTRACE_WITH_CALL_OPS select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS \
@@ -268,12 +269,10 @@ config CLANG_SUPPORTS_DYNAMIC_FTRACE_WIT def_bool CC_IS_CLANG # https://github.com/ClangBuiltLinux/linux/issues/1507 depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600)) - select HAVE_DYNAMIC_FTRACE_WITH_ARGS config GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS def_bool CC_IS_GCC depends on $(cc-option,-fpatchable-function-entry=2) - select HAVE_DYNAMIC_FTRACE_WITH_ARGS config 64BIT def_bool y
Greg Kroah-Hartman
maintainerPATCH 363/482 arm64: Subscribe Microsoft Azure Cobalt 100 to erratum 3194386
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Easwar Hariharan <[email protected]>
commit 3eddb108abe3de6723cc4b77e8558ce1b3047987 upstream.
Add the Microsoft Azure Cobalt 100 CPU to the list of CPUs suffering from erratum 3194386 added in commit 75b3c43eab59 ("arm64: errata:
Expand speculative SSBS workaround")
--- Documentation/arch/arm64/silicon-errata.rst | 2 ++ arch/arm64/kernel/cpu_errata.c | 1 + 2 files changed, 3 insertions(+)
Documentation/arch/arm64/silicon-errata.rst +2 -0
@@ -289,3 +289,5 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Microsoft | Azure Cobalt 100| #2253138 | ARM64_ERRATUM_2253138 | +----------------+-----------------+-----------------+-----------------------------+ +| Microsoft | Azure Cobalt 100| #3324339 | ARM64_ERRATUM_3194386 | ++----------------+-----------------+-----------------+-----------------------------+
arch/arm64/kernel/cpu_errata.c +1 -0
@@ -447,6 +447,7 @@ static const struct midr_range erratum_sMIDR_ALL_VERSIONS (MIDR_CORTEX_X3 ),MIDR_ALL_VERSIONS (MIDR_CORTEX_X4 ),MIDR_ALL_VERSIONS (MIDR_CORTEX_X925 ), +MIDR_ALL_VERSIONS (MIDR_MICROSOFT_AZURE_COBALT_100 ),MIDR_ALL_VERSIONS (MIDR_NEOVERSE_N1 ),MIDR_ALL_VERSIONS (MIDR_NEOVERSE_N2 ), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1),
Greg Kroah-Hartman
maintainerPATCH 364/482 sched/deadline: Comment sched_dl_entity::dl_server variable
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Bristot de Oliveira <[email protected]>
commit f23c042ce34ba265cf3129d530702b5d218e3f4b upstream.
Add an explanation for the newly added variable.
--- include/linux/sched.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/sched.h +2 -0
@@ -637,6 +637,8 @@ struct sched_dl_entity {* * @dl_overrun tells if the task asked to be informed about runtime * overruns. +* +* @dl_server tells if this is a server entity. */ unsigned int dl_throttled : 1; unsigned int dl_yielded : 1;
Greg Kroah-Hartman
maintainerPATCH 365/482 sched/core: Add clearing of ->dl_server in put_prev_task_balance()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joel Fernandes (Google) <[email protected]>
commit c245910049d04fbfa85bb2f5acd591c24e9907c7 upstream.
Paths using put_prev_task_balance() need to do a pick shortly after. Make sure they also clear the ->dl_server on prev as a part of that.
--- kernel/sched/core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
kernel/sched/core.c +8 -8
@@ -6005,6 +6005,14 @@ static void put_prev_task_balance(struct#endif put_prev_task (rq, prev); + +/* +* We've updated @prev and no longer need the server link, clear it. +* Must be done before ->pick_next_task() because that can (re)set +* ->dl_server. +*/ +if (prev->dl_server) + prev->dl_server =NULL ; }/*
@@ -6048,14 +6056,6 @@ __pick_next_task(struct rq *rq, struct t restart:put_prev_task_balance (rq, prev, rf); -/* -* We've updated @prev and no longer need the server link, clear it. -* Must be done before ->pick_next_task() because that can (re)set -* ->dl_server. -*/ -if (prev->dl_server) - prev->dl_server =NULL ; -for_each_class (class) { p = class->pick_next_task (rq);if (p)
Greg Kroah-Hartman
maintainerPATCH 366/482 sched/core: Clear prev->dl_server in CFS pick fast path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youssef Esmat <[email protected]>
commit a741b82423f41501e301eb6f9820b45ca202e877 upstream.
In case the previous pick was a DL server pick, ->dl_server might be set. Clear it in the fast path as well.
--- kernel/sched/core.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/sched/core.c +7 -0
@@ -6044,6 +6044,13 @@ __pick_next_task(struct rq *rq, struct t }/* +* This is a normal CFS pick, but the previous could be a DL pick. +* Clear it as previous is no longer picked. +*/ +if (prev->dl_server) + prev->dl_server =NULL ; + +/* * This is the fast path; it cannot be a DL server pick; * therefore even if @p == @prev, ->dl_server must be NULL. */
Greg Kroah-Hartman
maintainerPATCH 367/482 riscv: define ILLEGAL_POINTER_VALUE for 64bit
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jisheng Zhang <[email protected]>
commit 5c178472af247c7b50f962495bb7462ba453b9fb upstream.
This is used in poison.h for poison pointer offset. Based on current SV39, SV48 and SV57 vm layout, 0xdead000000000000 is a proper value that is not mappable, this can avoid potentially turning an oops to an expolit.
--- arch/riscv/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
arch/riscv/Kconfig +5 -0
@@ -312,6 +312,11 @@ config GENERIC_HWEIGHT config FIX_EARLYCON_MEM def_bool MMU +config ILLEGAL_POINTER_VALUE + hex + default 0 if 32BIT + default 0xdead000000000000 if 64BIT + config PGTABLE_LEVELS int default 5 if 64BIT
Greg Kroah-Hartman
maintainerPATCH 368/482 exfat: fix memory leak in exfat_load_bitmap()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuezhang Mo <[email protected]>
commit d2b537b3e533f28e0d97293fe9293161fe8cd137 upstream.
If the first directory entry in the root directory is not a bitmap directory entry, 'bh' will not be released and reassigned, which will cause a memory leak.
--- fs/exfat/balloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/exfat/balloc.c +5 -5
@@ -91,11 +91,8 @@ int exfat_load_bitmap(struct super_blockreturn -EIO ; type =exfat_get_entry_type (ep); -if (type ==TYPE_UNUSED ) -break ; -if (type !=TYPE_BITMAP ) -continue ; -if (ep->dentry.bitmap.flags ==0x0 ) { +if (type ==TYPE_BITMAP && + ep->dentry.bitmap.flags ==0x0 ) {int err; err =exfat_allocate_bitmap (sb, ep);
@@ -103,6 +100,9 @@ int exfat_load_bitmap(struct super_blockreturn err; }brelse (bh); + +if (type ==TYPE_UNUSED ) +return -EINVAL ; }if (exfat_get_next_cluster (sb, &clu.dir))
Greg Kroah-Hartman
maintainerPATCH 369/482 perf python: Disable -Wno-cast-function-type-mismatch if present on clang
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
commit 00dc514612fe98cfa117193b9df28f15e7c9db9c upstream.
The -Wcast-function-type-mismatch option was introduced in clang 19 and its enabled by default, since we use -Werror, and python bindings do casts that are valid but trips this warning, disable it if present.
--- tools/perf/util/setup.py | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/setup.py +2 -0
@@ -63,6 +63,8 @@ cflags = getenv('CFLAGS', '').split() cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls', '-DPYTHON_PERF' ] if cc_is_clang: cflags += ["-Wno-unused-command-line-argument" ] + if clang_has_option("-Wno-cast-function-type-mismatch"): + cflags += ["-Wno-cast-function-type-mismatch" ] else: cflags += ['-Wno-cast-function-type' ]
Greg Kroah-Hartman
maintainerPATCH 370/482 perf hist: Update hist symbol when updating maps
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit ac01c8c4246546fd8340a232f3ada1921dc0ee48 upstream.
AddressSanitizer found a use-after-free bug in the symbol code which manifested as 'perf top' segfaulting.
==1238389==ERROR: AddressSanitizer: heap-use-after-free on address 0x60b00c48844b at pc 0x5650d8035961 bp 0x7f751aaecc90 sp 0x7f751aaecc80 READ of size 1 at 0x60b00c48844b thread T193
#0 0x5650d8035960 in _sort__sym_cmp util/sort.c:310
#1 0x5650d8043744 in hist_entry__cmp util/hist.c:1286
#2 0x5650d8043951 in hists__findnew_entry util/hist.c:614
#3 0x5650d804568f in __hists__add_entry util/hist.c:754
#4 0x5650d8045bf9 in hists__add_entry util/hist.c:772
#5 0x5650d8045df1 in iter_add_single_normal_entry util/hist.c:997
#6 0x5650d8043326 in hist_entry_iter__add util/hist.c:1242
#7 0x5650d7ceeefe in perf_event__process_sample /home/matt/src/linux/tools/perf/builtin-top.c:845
#8 0x5650d7ceeefe in deliver_event /home/matt/src/linux/tools/perf/builtin-top.c:1208
#9 0x5650d7fdb51b in do_flush util/ordered-events.c:245
#10 0x5650d7fdb51b in __ordered_events__flush util/ordered-events.c:324
#11 0x5650d7ced743 in process_thread /home/matt/src/linux/tools/perf/builtin-top.c:1120
#12 0x7f757ef1f133 in start_thread nptl/pthread_create.c:442
#13 0x7f757ef9f7db in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81When updating hist maps it's also necessary to update the hist symbol reference because the old one gets freed in map__put().
While this bug was probably introduced with 5c24b67aae72f54c ("perf
tools: Replace map->referenced & maps->removed_maps with map->refcnt"), the symbol objects were leaked until c087e9480cf33672 ("perf machine:
Fix refcount usage when processing PERF_RECORD_KSYMBOL") was merged so the bug was masked.
--- tools/perf/util/hist.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/util/hist.c +5 -0
@@ -637,6 +637,11 @@ static struct hist_entry *hists__findnew* the history counter to increment. */ if (he->ms.map != entry->ms.map) { +if (he->ms.sym) { +u64 addr = he->ms.sym->start; + he->ms.sym =map__find_symbol (entry->ms.map, addr); + } +map__put (he->ms.map); he->ms.map =map__get (entry->ms.map); }
Greg Kroah-Hartman
maintainerPATCH 371/482 nfsd: fix delegation_blocked() to block correctly for at least 30 seconds
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 45bb63ed20e02ae146336412889fe5450316a84f upstream.
The pair of bloom filtered used by delegation_blocked() was intended to block delegations on given filehandles for between 30 and 60 seconds. A new filehandle would be recorded in the "new" bit set. That would then be switch to the "old" bit set between 0 and 30 seconds later, and it would remain as the "old" bit set for 30 seconds.
Unfortunately the code intended to clear the old bit set once it reached 30 seconds old, preparing it to be the next new bit set, instead cleared the *new* bit set before switching it to be the old bit set. This means that the "old" bit set is always empty and delegations are blocked between 0 and 30 seconds.
This patch updates bd->new before clearing the set with that index, instead of afterwards.
--- fs/nfsd/nfs4state.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4state.c +3 -2
@@ -1077,7 +1077,8 @@ static void nfs4_free_deleg(struct nfs4_* When a delegation is recalled, the filehandle is stored in the "new" * filter. * Every 30 seconds we swap the filters and clear the "new" one, -* unless both are empty of course. +* unless both are empty of course. This results in delegations for a +* given filehandle being blocked for between 30 and 60 seconds. * * Each filter is 256 bits. We hash the filehandle to 32bit and use the * low 3 bytes as hash-table indices.
@@ -1106,9 +1107,9 @@ static int delegation_blocked(struct knfif (ktime_get_seconds () - bd->swap_time >30 ) { bd->entries -= bd->old_entries; bd->old_entries = bd->entries; + bd->new =1 -bd->new;memset (bd->set[bd->new],0 ,sizeof (bd->set[0 ])); - bd->new =1 -bd->new; bd->swap_time =ktime_get_seconds (); }spin_unlock (&blocked_delegations_lock);
Greg Kroah-Hartman
maintainerPATCH 372/482 nfsd: map the EBADMSG to nfserr_io to avoid warning
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Lingfeng <[email protected]>
commit 340e61e44c1d2a15c42ec72ade9195ad525fd048 upstream.
Ext4 will throw -EBADMSG through ext4_readdir when a checksum error occurs, resulting in the following WARNING.
Fix it by mapping EBADMSG to nfserr_io.
nfsd_buffered_readdir
iterate_dir // -EBADMSG -74
ext4_readdir // .iterate_shared
ext4_dx_readdir
ext4_htree_fill_tree
htree_dirblock_to_tree
ext4_read_dirblock
__ext4_read_dirblock
ext4_dirblock_csum_verify
warn_no_space_for_csum
__warn_no_space_for_csum
return ERR_PTR(-EFSBADCRC) // -EBADMSG -74
nfserrno // WARNING
[ 161.115610] ------------[ cut here ]------------ [ 161.116465] nfsd: non-standard errno: -74 [ 161.117315] WARNING: CPU: 1 PID: 780 at fs/nfsd/nfsproc.c:878 nfserrno+0x9d/0xd0 [ 161.118596] Modules linked in: [ 161.119243] CPU: 1 PID: 780 Comm: nfsd Not tainted 5.10.0-00014-g79679361fd5d #138 [ 161.120684] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qe mu.org 04/01/2014 [ 161.123601] RIP: 0010:nfserrno+0x9d/0xd0 [ 161.124676] Code: 0f 87 da 30 dd 00 83 e3 01 b8 00 00 00 05 75 d7 44 89 ee 48 c7 c7 c0 57 24 98 89 44 24 04 c6 05 ce 2b 61 03 01 e8 99 20 d8 00 <0f> 0b 8b 44 24 04 eb b5 4c 89 e6 48 c7 c7 a0 6d a4 99 e8 cc 15 33 [ 161.127797] RSP: 0018:ffffc90000e2f9c0 EFLAGS: 00010286 [ 161.128794] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 161.130089] RDX: 1ffff1103ee16f6d RSI: 0000000000000008 RDI: fffff520001c5f2a [ 161.131379] RBP: 0000000000000022 R08: 0000000000000001 R09: ffff8881f70c1827 [ 161.132664] R10: ffffed103ee18304 R11: 0000000000000001 R12: 0000000000000021 [ 161.133949] R13: 00000000ffffffb6 R14: ffff8881317c0000 R15: ffffc90000e2fbd8 [ 161.135244] FS: 0000000000000000(0000) GS:ffff8881f7080000(0000) knlGS:0000000000000000 [ 161.136695] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 161.137761] CR2: 00007fcaad70b348 CR3: 0000000144256006 CR4: 0000000000770ee0 [ 161.139041] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 161.140291] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 161.141519] PKRU: 55555554 [ 161.142076] Call Trace: [ 161.142575] ? __warn+0x9b/0x140 [ 161.143229] ? nfserrno+0x9d/0xd0 [ 161.143872] ? report_bug+0x125/0x150 [ 161.144595] ? handle_bug+0x41/0x90 [ 161.145284] ? exc_invalid_op+0x14/0x70 [ 161.146009] ? asm_exc_invalid_op+0x12/0x20 [ 161.146816] ? nfserrno+0x9d/0xd0 [ 161.147487] nfsd_buffered_readdir+0x28b/0x2b0 [ 161.148333] ? nfsd4_encode_dirent_fattr+0x380/0x380 [ 161.149258] ? nfsd_buffered_filldir+0xf0/0xf0 [ 161.150093] ? wait_for_concurrent_writes+0x170/0x170 [ 161.151004] ? generic_file_llseek_size+0x48/0x160 [ 161.151895] nfsd_readdir+0x132/0x190 [ 161.152606] ? nfsd4_encode_dirent_fattr+0x380/0x380 [ 161.153516] ? nfsd_unlink+0x380/0x380 [ 161.154256] ? override_creds+0x45/0x60 [ 161.155006] nfsd4_encode_readdir+0x21a/0x3d0 [ 161.155850] ? nfsd4_encode_readlink+0x210/0x210 [ 161.156731] ? write_bytes_to_xdr_buf+0x97/0xe0 [ 161.157598] ? __write_bytes_to_xdr_buf+0xd0/0xd0 [ 161.158494] ? lock_downgrade+0x90/0x90 [ 161.159232] ? nfs4svc_decode_voidarg+0x10/0x10 [ 161.160092] nfsd4_encode_operation+0x15a/0x440 [ 161.160959] nfsd4_proc_compound+0x718/0xe90 [ 161.161818] nfsd_dispatch+0x18e/0x2c0 [ 161.162586] svc_process_common+0x786/0xc50 [ 161.163403] ? nfsd_svc+0x380/0x380 [ 161.164137] ? svc_printk+0x160/0x160 [ 161.164846] ? svc_xprt_do_enqueue.part.0+0x365/0x380 [ 161.165808] ? nfsd_svc+0x380/0x380 [ 161.166523] ? rcu_is_watching+0x23/0x40 [ 161.167309] svc_process+0x1a5/0x200 [ 161.168019] nfsd+0x1f5/0x380 [ 161.168663] ? nfsd_shutdown_threads+0x260/0x260 [ 161.169554] kthread+0x1c4/0x210 [ 161.170224] ? kthread_insert_work_sanity_check+0x80/0x80 [ 161.171246] ret_from_fork+0x1f/0x30
--- fs/nfsd/vfs.c | 1 + 1 file changed, 1 insertion(+)
fs/nfsd/vfs.c +1 -0
@@ -100,6 +100,7 @@ nfserrno (int errno) { nfserr_io, -EUCLEAN }, { nfserr_perm, -ENOKEY }, { nfserr_no_grace, -ENOGRACE}, + { nfserr_io, -EBADMSG }, };int i;
Greg Kroah-Hartman
maintainerPATCH 373/482 NFSD: Fix NFSv4s PUTPUBFH operation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
commit 202f39039a11402dcbcd5fece8d9fa6be83f49ae upstream.
According to RFC 8881, all minor versions of NFSv4 support PUTPUBFH.
Replace the XDR decoder for PUTPUBFH with a "noop" since we no longer want the minorversion check, and PUTPUBFH has no arguments to decode. (Ideally nfsd4_decode_noop should really be called nfsd4_decode_void).
PUTPUBFH should now behave just like PUTROOTFH.
--- fs/nfsd/nfs4xdr.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
fs/nfsd/nfs4xdr.c +1 -9
@@ -1246,14 +1246,6 @@ nfsd4_decode_putfh(struct nfsd4_compound }static __be32 -nfsd4_decode_putpubfh (struct nfsd4_compoundargs *argp,union nfsd4_op_u *p) -{ -if (argp->minorversion ==0 ) -return nfs_ok; -return nfserr_notsupp; -} - -static __be32 nfsd4_decode_read (struct nfsd4_compoundargs *argp,union nfsd4_op_u *u) {struct nfsd4_read *read = &u->read;
@@ -2374,7 +2366,7 @@ static const nfsd4_dec nfsd4_dec_ops[] = [OP_OPEN_CONFIRM] = nfsd4_decode_open_confirm, [OP_OPEN_DOWNGRADE] = nfsd4_decode_open_downgrade, [OP_PUTFH] = nfsd4_decode_putfh, - [OP_PUTPUBFH] = nfsd4_decode_putpubfh, + [OP_PUTPUBFH] = nfsd4_decode_noop, [OP_PUTROOTFH] = nfsd4_decode_noop, [OP_READ] = nfsd4_decode_read, [OP_READDIR] = nfsd4_decode_readdir,
Greg Kroah-Hartman
maintainerPATCH 374/482 i3c: master: svc: Fix use after free vulnerability in svc_i3c_master Driver Due to Race Condition
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixin Wang <[email protected]>
commit 61850725779709369c7e907ae8c7c75dc7cec4f3 upstream.
In the svc_i3c_master_probe function, &master->hj_work is bound with svc_i3c_master_hj_work, &master->ibi_work is bound with svc_i3c_master_ibi_work. And svc_i3c_master_ibi_work can start the hj_work, svc_i3c_master_irq_handler can start the ibi_work.
If we remove the module which will call svc_i3c_master_remove to make cleanup, it will free master->base through i3c_master_unregister while the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| svc_i3c_master_hj_work
svc_i3c_master_remove |
i3c_master_unregister(&master->base)|
device_unregister(&master->dev) |
device_release |
//free master->base |
| i3c_master_do_daa(&master->base)
| //use master->baseFix it by ensuring that the work is canceled before proceeding with the cleanup in svc_i3c_master_remove.
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -1750,6 +1750,7 @@ static void svc_i3c_master_remove(struct {struct svc_i3c_master *master =platform_get_drvdata (pdev); +cancel_work_sync (&master->hj_work);i3c_master_unregister (&master->base);pm_runtime_dont_use_autosuspend (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 375/482 sysctl: avoid spurious permanent empty tables
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 559d4c6a9d3b60f239493239070eb304edaea594 upstream.
The test if a table is a permanently empty one, inspects the address of the registered ctl_table argument.
However as sysctl_mount_point is an empty array and does not occupy and space it can end up sharing an address with another object in memory. If that other object itself is a "struct ctl_table" then registering that table will fail as it's incorrectly recognized as permanently empty.
Avoid this issue by adding a dummy element to the array so that is not empty anymore.
Explicitly register the table with zero elements as otherwise the dummy element would be recognized as a sentinel element which would lead to a runtime warning from the sysctl core.
While the issue seems not being encountered at this time, this seems mostly to be due to luck.
Also a future change, constifying sysctl_mount_point and root_table, can reliably trigger this issue on clang 18.
Given that empty arrays are non-standard in the first place it seems prudent to avoid them if possible.
--- fs/proc/proc_sysctl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/proc/proc_sysctl.c +8 -3
@@ -29,8 +29,13 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static struct ctl_table sysctl_mount_point[] = { }; +/* +* Support for permanently empty directories. +* Must be non-empty to avoid sharing an address with other tables. +*/ +static struct ctl_table sysctl_mount_point[] = { + { } +};/** * register_sysctl_mount_point() - registers a sysctl mount point
@@ -42,7 +47,7 @@ static struct ctl_table sysctl_mount_point[] = { };*/ struct ctl_table_header *register_sysctl_mount_point (const char *path) { -return register_sysctl (path, sysctl_mount_point); +return register_sysctl_sz (path, sysctl_mount_point,0 ); }EXPORT_SYMBOL (register_sysctl_mount_point);
Signature · 1 line
2.46.2
Greg Kroah-Hartman
maintainerPATCH 376/482 RDMA/mana_ib: use the correct page size for mapping user-mode doorbell page
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
commit 4a3b99bc04e501b816db78f70064e26a01257910 upstream.
When mapping doorbell page from user-mode, the driver should use the system page size as this memory is allocated via mmap() from user-mode.
--- drivers/infiniband/hw/mana/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mana/main.c +3 -3
@@ -511,13 +511,13 @@ int mana_ib_mmap(struct ib_ucontext *ibcPAGE_SHIFT ; prot =pgprot_writecombine (vma->vm_page_prot); - ret =rdma_user_mmap_io (ibcontext, vma, pfn, gc->db_page_size, prot, + ret =rdma_user_mmap_io (ibcontext, vma, pfn,PAGE_SIZE , prot,NULL );if (ret)ibdev_dbg (ibdev,"can't rdma_user_mmap_io ret %d\n" , ret);else -ibdev_dbg (ibdev,"mapped I/O pfn 0x%llx page_size %u, ret %d\n" , - pfn, gc->db_page_size, ret); +ibdev_dbg (ibdev,"mapped I/O pfn 0x%llx page_size %lu, ret %d\n" , + pfn,PAGE_SIZE , ret);return ret; }
Greg Kroah-Hartman
maintainerPATCH 377/482 drivers/perf: riscv: Align errno for unsupported perf event
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
commit c625154993d0d24a962b1830cd5ed92adda2cf86 upstream.
RISC-V perf driver does not yet support PERF_TYPE_BREAKPOINT. It would be more appropriate to return -EOPNOTSUPP or -ENOENT for this type in pmu_sbi_event_map. Considering that other implementations return -ENOENT for unsupported perf types, let's synchronize this behavior. Due to this reason, a riscv bpf testcases perf_skip fail. Meanwhile, align that behavior to the rest of proper place.
--- drivers/perf/riscv_pmu_legacy.c | 4 ++-- drivers/perf/riscv_pmu_sbi.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/perf/riscv_pmu_legacy.c +2 -2
@@ -22,13 +22,13 @@ static int pmu_legacy_ctr_get_idx(structstruct perf_event_attr *attr = &event->attr;if (event->attr.type !=PERF_TYPE_HARDWARE ) -return -EOPNOTSUPP ; +return -ENOENT ;if (attr->config ==PERF_COUNT_HW_CPU_CYCLES )return RISCV_PMU_LEGACY_CYCLE ;else if (attr->config ==PERF_COUNT_HW_INSTRUCTIONS )return RISCV_PMU_LEGACY_INSTRET ;else -return -EOPNOTSUPP ; +return -ENOENT ; }/* For legacy config & counter index are same */
drivers/perf/riscv_pmu_sbi.c +2 -2
@@ -305,7 +305,7 @@ static void pmu_sbi_check_event(struct s ret.value, 0x1, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0); }else if (ret.error ==SBI_ERR_NOT_SUPPORTED ) {/* This event cannot be monitored by any counter */ - edata->event_idx = -EINVAL ; + edata->event_idx = -ENOENT ; } }
@@ -539,7 +539,7 @@ static int pmu_sbi_event_map(struct perf }break ;default : - ret = -EINVAL ; + ret = -ENOENT ;break ; }
Greg Kroah-Hartman
maintainerPATCH 378/482 riscv: Fix kernel stack size when KASAN is enabled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Ghiti <[email protected]>
commit cfb10de18538e383dbc4f3ce7f477ce49287ff3d upstream.
We use Kconfig to select the kernel stack size, doubling the default size if KASAN is enabled.
But that actually only works if KASAN is selected from the beginning, meaning that if KASAN config is added later (for example using menuconfig), CONFIG_THREAD_SIZE_ORDER won't be updated, keeping the default size, which is not enough for KASAN as reported in [1].
So fix this by moving the logic to compute the right kernel stack into a header.
--- arch/riscv/Kconfig | 3 +-- arch/riscv/include/asm/thread_info.h | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-)
arch/riscv/Kconfig +1 -2
@@ -715,8 +715,7 @@ config IRQ_STACKS config THREAD_SIZE_ORDER int "Kernel stack size (in power-of-two numbers of page size)" if VMAP_STACK && EXPERT range 0 4 - default 1 if 32BIT && !KASAN - default 3 if 64BIT && KASAN + default 1 if 32BIT default 2 help Specify the Pages of thread stack size (from 4KB to 64KB), which also
arch/riscv/include/asm/thread_info.h +6 -1
@@ -12,7 +12,12 @@#include <linux/const.h> /* thread information allocation */ -#define THREAD_SIZE_ORDER CONFIG_THREAD_SIZE_ORDER +#ifdef CONFIG_KASAN +#define KASAN_STACK_ORDER 1 +#else +#define KASAN_STACK_ORDER 0 +#endif +#define THREAD_SIZE_ORDER (CONFIG_THREAD_SIZE_ORDER + KASAN_STACK_ORDER)#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)/*
Greg Kroah-Hartman
maintainerPATCH 379/482 aoe: fix the potential use-after-free problem in more places
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chun-Yi Lee <[email protected]>
commit 6d6e54fc71ad1ab0a87047fd9c211e75d86084a3 upstream.
For fixing CVE-2023-6270, f98364e92662 ("aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts") makes tx() calling dev_put() instead of doing in aoecmd_cfg_pkts(). It avoids that the tx() runs into use-after-free.
Then Nicolai Stange found more places in aoe have potential use-after-free problem with tx(). e.g. revalidate(), aoecmd_ata_rw(), resend(), probe() and aoecmd_cfg_rsp(). Those functions also use aoenet_xmit() to push packet to tx queue. So they should also use dev_hold() to increase the refcnt of skb->dev.
On the other hand, moving dev_put() to tx() causes that the refcnt of skb->dev be reduced to a negative value, because corresponding dev_hold() are not called in revalidate(), aoecmd_ata_rw(), resend(), probe(), and aoecmd_cfg_rsp(). This patch fixed this issue.
--- drivers/block/aoe/aoecmd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/block/aoe/aoecmd.c +12 -1
@@ -361,6 +361,7 @@ ata_rw_frameinit(struct frame *f) } ah->cmdstat =ATA_CMD_PIO_READ | writebit | extbit; +dev_hold (t->ifp->nd); skb->dev = t->ifp->nd; }
@@ -401,6 +402,8 @@ aoecmd_ata_rw(struct aoedev *d)__skb_queue_head_init (&queue);__skb_queue_tail (&queue, skb);aoenet_xmit (&queue); + }else { +dev_put (f->t->ifp->nd); }return 1 ; }
@@ -483,10 +486,13 @@ resend(struct aoedev *d, struct frame *fmemcpy (h->dst, t->addr,sizeof h->dst);memcpy (h->src, t->ifp->nd->dev_addr,sizeof h->src); +dev_hold (t->ifp->nd); skb->dev = t->ifp->nd; skb =skb_clone (skb,GFP_ATOMIC ); -if (skb ==NULL ) +if (skb ==NULL ) { +dev_put (t->ifp->nd);return ; + } f->sent =ktime_get ();__skb_queue_head_init (&queue);__skb_queue_tail (&queue, skb);
@@ -617,6 +623,8 @@ probe(struct aoetgt *t)__skb_queue_head_init (&queue);__skb_queue_tail (&queue, skb);aoenet_xmit (&queue); + }else { +dev_put (f->t->ifp->nd); } }
@@ -1395,6 +1403,7 @@ aoecmd_ata_id(struct aoedev *d) ah->cmdstat =ATA_CMD_ID_ATA ; ah->lba3 =0xa0 ; +dev_hold (t->ifp->nd); skb->dev = t->ifp->nd; d->rttavg =RTTAVG_INIT ;
@@ -1404,6 +1413,8 @@ aoecmd_ata_id(struct aoedev *d) skb =skb_clone (skb,GFP_ATOMIC );if (skb) f->sent =ktime_get (); +else +dev_put (t->ifp->nd);return skb; }
Greg Kroah-Hartman
maintainerPATCH 380/482 media: imx335: Fix reset-gpio handling
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Umang Jain <[email protected]>
commit 99d30e2fdea4086be4e66e2deb10de854b547ab8 upstream.
Rectify the logical value of reset-gpio so that it is set to 0 (disabled) during power-on and to 1 (enabled) during power-off.
Set the reset-gpio to GPIO_OUT_HIGH at initialization time to make sure it starts off in reset. Also drop the "Set XCLR" comment which is not-so-informative.
The existing usage of imx335 had reset-gpios polarity inverted (GPIO_ACTIVE_HIGH) in their device-tree sources. With this patch included, those DTS will not be able to stream imx335 anymore. The reset-gpio polarity will need to be rectified in the device-tree sources as shown in [1] example, in order to get imx335 functional again (as it remains in reset prior to this fix).
--- drivers/media/i2c/imx335.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/i2c/imx335.c +4 -5
@@ -997,7 +997,7 @@ static int imx335_parse_hw_config(struct/* Request optional reset pin */ imx335->reset_gpio =devm_gpiod_get_optional (imx335->dev,"reset" , -GPIOD_OUT_LOW ); +GPIOD_OUT_HIGH );if (IS_ERR (imx335->reset_gpio)) {dev_err (imx335->dev,"failed to get reset gpio %ld\n" ,PTR_ERR (imx335->reset_gpio));
@@ -1110,8 +1110,7 @@ static int imx335_power_on(struct deviceusleep_range (500 ,550 );/* Tlow */ -/* Set XCLR */ -gpiod_set_value_cansleep (imx335->reset_gpio,1 ); +gpiod_set_value_cansleep (imx335->reset_gpio,0 ); ret =clk_prepare_enable (imx335->inclk);if (ret) {
@@ -1124,7 +1123,7 @@ static int imx335_power_on(struct devicereturn 0 ; error_reset: -gpiod_set_value_cansleep (imx335->reset_gpio,0 ); +gpiod_set_value_cansleep (imx335->reset_gpio,1 );regulator_bulk_disable (ARRAY_SIZE (imx335_supply_name), imx335->supplies);return ret;
@@ -1141,7 +1140,7 @@ static int imx335_power_off(struct devicstruct v4l2_subdev *sd =dev_get_drvdata (dev);struct imx335 *imx335 =to_imx335 (sd); -gpiod_set_value_cansleep (imx335->reset_gpio,0 ); +gpiod_set_value_cansleep (imx335->reset_gpio,1 );clk_disable_unprepare (imx335->inclk);regulator_bulk_disable (ARRAY_SIZE (imx335_supply_name), imx335->supplies);
Greg Kroah-Hartman
maintainerPATCH 381/482 media: ov5675: Fix power on/off delay timings
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 719ec29fceda2f19c833d2784b1574638320400f upstream.
The ov5675 specification says that the gap between XSHUTDN deassert and the first I2C transaction should be a minimum of 8192 XVCLK cycles.
Right now we use a usleep_rage() that gives a sleep time of between about 430 and 860 microseconds.
On the Lenovo X13s we have observed that in about 1/20 cases the current timing is too tight and we start transacting before the ov5675's reset cycle completes, leading to I2C bus transaction failures.
The reset racing is sometimes triggered at initial chip probe but, more usually on a subsequent power-off/power-on cycle e.g.
[ 71.451662] ov5675 24-0010: failed to write reg 0x0103. error = -5 [ 71.451686] ov5675 24-0010: failed to set plls
The current quiescence period we have is too tight. Instead of expressing the post reset delay in terms of the current XVCLK this patch converts the power-on and power-off delays to the maximum theoretical delay @ 6 MHz with an additional buffer.
1.365 milliseconds on the power-on path is 1.5 milliseconds with grace. 85.3 microseconds on the power-off path is 90 microseconds with grace.
--- drivers/media/i2c/ov5675.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/i2c/ov5675.c +6 -6
@@ -972,12 +972,10 @@ static int ov5675_set_stream(struct v4l2static int ov5675_power_off (struct device *dev) { -/* 512 xvclk cycles after the last SCCB transation or MIPI frame end */ -u32 delay_us =DIV_ROUND_UP (512 ,OV5675_XVCLK_19_2 /1000 /1000 );struct v4l2_subdev *sd =dev_get_drvdata (dev);struct ov5675 *ov5675 =to_ov5675 (sd); -usleep_range (delay_us, delay_us *2 ); +usleep_range (90 ,100 );clk_disable_unprepare (ov5675->xvclk);gpiod_set_value_cansleep (ov5675->reset_gpio,1 );
@@ -988,7 +986,6 @@ static int ov5675_power_off(struct devicstatic int ov5675_power_on (struct device *dev) { -u32 delay_us =DIV_ROUND_UP (8192 ,OV5675_XVCLK_19_2 /1000 /1000 );struct v4l2_subdev *sd =dev_get_drvdata (dev);struct ov5675 *ov5675 =to_ov5675 (sd);int ret;
@@ -1014,8 +1011,11 @@ static int ov5675_power_on(struct devicegpiod_set_value_cansleep (ov5675->reset_gpio,0 ); -/* 8192 xvclk cycles prior to the first SCCB transation */ -usleep_range (delay_us, delay_us *2 ); +/* Worst case quiesence gap is 1.365 milliseconds @ 6MHz XVCLK +* Add an additional threshold grace period to ensure reset +* completion before initiating our first I2C transaction. +*/ +usleep_range (1500 ,1600 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 382/482 clk: rockchip: fix error for unknown clocks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
commit 12fd64babaca4dc09d072f63eda76ba44119816a upstream.
There is a clk == NULL check after the switch to check for unsupported clk types. Since clk is re-assigned in a loop, this check is useless right now for anything but the first round. Let's fix this up by assigning clk = NULL in the loop before the switch statement.
--- drivers/clk/rockchip/clk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/rockchip/clk.c +2 -1
@@ -450,12 +450,13 @@ void rockchip_clk_register_branches(stru struct rockchip_clk_branch *list, unsigned int nr_clk) { -struct clk *clk =NULL ; +struct clk *clk;unsigned int idx;unsigned long flags;for (idx =0 ; idx < nr_clk; idx++, list++) { flags = list->flags; + clk =NULL ;/* catch simple muxes */ switch (list->branch_type) {
Greg Kroah-Hartman
maintainerPATCH 383/482 remoteproc: k3-r5: Fix error handling when power-up failed
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kiszka <[email protected]>
commit 9ab27eb5866ccbf57715cfdba4b03d57776092fb upstream.
By simply bailing out, the driver was violating its rule and internal assumptions that either both or no rproc should be initialized. E.g., this could cause the first core to be available but not the second one, leading to crashes on its shutdown later on while trying to dereference that second instance.
--- drivers/remoteproc/ti_k3_r5_remoteproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +2 -1
@@ -1332,7 +1332,7 @@ init_rmem:dev_err (dev,"Timed out waiting for %s core to power up!\n" , rproc->name); -return ret; + goto err_powerup; } }
@@ -1348,6 +1348,7 @@ err_split: } } +err_powerup:rproc_del (rproc); err_add:k3_r5_reserved_mem_exit (kproc);
Greg Kroah-Hartman
maintainerPATCH 384/482 media: videobuf2: Drop minimum allocation requirement of 2 buffers
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit e5700c9037727d5a69a677d6dba25010b485d65b upstream.
When introducing the ability for drivers to indicate the minimum number of buffers they require an application to allocate, commit 6662edcd32cc ("media: videobuf2: Add min_reqbufs_allocation field to vb2_queue structure") also introduced a global minimum of 2 buffers. It turns out this breaks the Renesas R-Car VSP test suite, where a test that allocates a single buffer fails when two buffers are used.
One may consider debatable whether test suite failures without failures in production use cases should be considered as a regression, but operation with a single buffer is a valid use case. While full frame rate can't be maintained, memory-to-memory devices can still be used with a decent efficiency, and requiring applications to allocate multiple buffers for single-shot use cases with capture devices would just waste memory.
For those reasons, fix the regression by dropping the global minimum of buffers. Individual drivers can still set their own minimum.
--- drivers/media/common/videobuf2/videobuf2-core.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/media/common/videobuf2/videobuf2-core.c +0 -7
@@ -2603,13 +2603,6 @@ int vb2_core_queue_init(struct vb2_queuereturn -EINVAL ;/* -* The minimum requirement is 2: one buffer is used -* by the hardware while the other is being processed by userspace. -*/ -if (q->min_reqbufs_allocation <2 ) - q->min_reqbufs_allocation =2 ; - -/* * If the driver needs 'min_queued_buffers' in the queue before * calling start_streaming() then the minimum requirement is * 'min_queued_buffers + 1' to keep at least one buffer available
Greg Kroah-Hartman
maintainerPATCH 385/482 clk: qcom: dispcc-sm8250: use CLK_SET_RATE_PARENT for branch clocks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
commit 0e93c6320ecde0583de09f3fe801ce8822886fec upstream.
Add CLK_SET_RATE_PARENT for several branch clocks. Such clocks don't have a way to change the rate, so set the parent rate instead.
--- drivers/clk/qcom/dispcc-sm8250.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/qcom/dispcc-sm8250.c +3 -0
@@ -849,6 +849,7 @@ static struct clk_branch disp_cc_mdss_dp &disp_cc_mdss_dp_link1_div_clk_src.clkr.hw, }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, .ops = &clk_branch2_ops, }, },
@@ -884,6 +885,7 @@ static struct clk_branch disp_cc_mdss_dp &disp_cc_mdss_dp_link_div_clk_src.clkr.hw, }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, .ops = &clk_branch2_ops, }, },
@@ -1009,6 +1011,7 @@ static struct clk_branch disp_cc_mdss_md &disp_cc_mdss_mdp_clk_src.clkr.hw, }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, .ops = &clk_branch2_ops, }, },
Greg Kroah-Hartman
maintainerPATCH 386/482 media: sun4i_csi: Implement link validate for sun4i_csi subdev
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit 2dc5d5d401f5c6cecd97800ffef82e8d17d228f0 upstream.
The sun4i_csi driver doesn't implement link validation for the subdev it registers, leaving the link between the subdev and its source unvalidated. Fix it, using the v4l2_subdev_link_validate() helper.
--- drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c +5 -0
@@ -39,6 +39,10 @@ static const struct media_entity_operati .link_validate = v4l2_subdev_link_validate, }; +static const struct media_entity_operations sun4i_csi_subdev_entity_ops = { + .link_validate = v4l2_subdev_link_validate, +}; +static int sun4i_csi_notify_bound (struct v4l2_async_notifier *notifier,struct v4l2_subdev *subdev,struct v4l2_async_connection *asd)
@@ -214,6 +218,7 @@ static int sun4i_csi_probe(struct platfo subdev->internal_ops = &sun4i_csi_subdev_internal_ops; subdev->flags =V4L2_SUBDEV_FL_HAS_DEVNODE |V4L2_SUBDEV_FL_HAS_EVENTS ; subdev->entity.function =MEDIA_ENT_F_VID_IF_BRIDGE ; + subdev->entity.ops = &sun4i_csi_subdev_entity_ops; subdev->owner =THIS_MODULE ;snprintf (subdev->name,sizeof (subdev->name),"sun4i-csi-0" );v4l2_set_subdevdata (subdev, csi);
Greg Kroah-Hartman
maintainerPATCH 387/482 clk: qcom: gcc-sm8450: Do not turn off PCIe GDSCs during gdsc_disable()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
commit 889e1332310656961855c0dcedbb4dbe78e39d22 upstream.
With PWRSTS_OFF_ON, PCIe GDSCs are turned off during gdsc_disable(). This can happen during scenarios such as system suspend and breaks the resume of PCIe controllers from suspend.
So use PWRSTS_RET_ON to indicate the GDSC driver to not turn off the GDSCs during gdsc_disable() and allow the hardware to transition the GDSCs to retention when the parent domain enters low power state during system suspend.
--- drivers/clk/qcom/gcc-sm8450.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8450.c +2 -2
@@ -2974,7 +2974,7 @@ static struct gdsc pcie_0_gdsc = { .pd = { .name = "pcie_0_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, };static struct gdsc pcie_1_gdsc = {
@@ -2982,7 +2982,7 @@ static struct gdsc pcie_1_gdsc = { .pd = { .name = "pcie_1_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, };static struct gdsc ufs_phy_gdsc = {
Greg Kroah-Hartman
maintainerPATCH 388/482 media: uapi/linux/cec.h: cec_msg_set_reply_to: zero flags
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 599f6899051cb70c4e0aa9fd591b9ee220cb6f14 upstream.
The cec_msg_set_reply_to() helper function never zeroed the struct cec_msg flags field, this can cause unexpected behavior if flags was uninitialized to begin with.
--- include/uapi/linux/cec.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/uapi/linux/cec.h +5 -1
@@ -132,6 +132,8 @@ static inline void cec_msg_init(struct c* Set the msg destination to the orig initiator and the msg initiator to the * orig destination. Note that msg and orig may be the same pointer, in which * case the change is done in place. +* +* It also zeroes the reply, timeout and flags fields. */ static inline void cec_msg_set_reply_to (struct cec_msg *msg,struct cec_msg *orig)
@@ -139,7 +141,9 @@ static inline void cec_msg_set_reply_to(/* The destination becomes the initiator and vice versa */ msg->msg[0 ] = (cec_msg_destination (orig) <<4 ) |cec_msg_initiator (orig); - msg->reply = msg->timeout =0 ; + msg->reply =0 ; + msg->timeout =0 ; + msg->flags =0 ; }/**
Greg Kroah-Hartman
maintainerPATCH 389/482 dt-bindings: clock: qcom: Add GPLL9 support on gcc-sc8180x
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Satya Priya Kakitapalli <[email protected]>
commit 648b4bde0aca2980ebc0b90cdfbb80d222370c3d upstream.
Add the missing GPLL9 which is required for the gcc sdcc2 clock.
--- include/dt-bindings/clock/qcom,gcc-sc8180x.h | 1 + 1 file changed, 1 insertion(+)
include/dt-bindings/clock/qcom,gcc-sc8180x.h +1 -0
@@ -248,6 +248,7 @@#define GCC_USB3_SEC_CLKREF_CLK 238#define GCC_UFS_MEM_CLKREF_EN 239#define GCC_UFS_CARD_CLKREF_EN 240 +#define GPLL9 241#define GCC_EMAC_BCR 0#define GCC_GPU_BCR 1
Greg Kroah-Hartman
maintainerPATCH 390/482 clk: qcom: clk-rpmh: Fix overflow in BCM vote
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Tipton <[email protected]>
commit a4e5af27e6f6a8b0d14bc0d7eb04f4a6c7291586 upstream.
Valid frequencies may result in BCM votes that exceed the max HW value. Set vote ceiling to BCM_TCS_CMD_VOTE_MASK to ensure the votes aren't truncated, which can result in lower frequencies than desired.
--- drivers/clk/qcom/clk-rpmh.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/qcom/clk-rpmh.c +2 -0
@@ -263,6 +263,8 @@ static int clk_rpmh_bcm_send_cmd(struct cmd_state =0 ; } + cmd_state =min (cmd_state,BCM_TCS_CMD_VOTE_MASK ); +if (c->last_sent_aggr_state != cmd_state) { cmd.addr = c->res_addr; cmd.data =BCM_TCS_CMD (1 , enable,0 , cmd_state);
Greg Kroah-Hartman
maintainerPATCH 391/482 clk: samsung: exynos7885: Update CLKS_NR_FSYS after bindings fix
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Virag <[email protected]>
commit 217a5f23c290c349ceaa37a6f2c014ad4c2d5759 upstream.
Update CLKS_NR_FSYS to the proper value after a fix in DT bindings. This should always be the last clock in a CMU + 1.
--- drivers/clk/samsung/clk-exynos7885.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/samsung/clk-exynos7885.c +1 -1
@@ -20,7 +20,7 @@#define CLKS_NR_TOP (CLK_GOUT_FSYS_USB30DRD + 1)#define CLKS_NR_CORE (CLK_GOUT_TREX_P_CORE_PCLK_P_CORE + 1)#define CLKS_NR_PERI (CLK_GOUT_WDT1_PCLK + 1) -#define CLKS_NR_FSYS (CLK_GOUT_MMC_SDIO_SDCLKIN + 1) +#define CLKS_NR_FSYS (CLK_MOUT_FSYS_USB30DRD_USER + 1)/* ---- CMU_TOP ------------------------------------------------------------- */
Greg Kroah-Hartman
maintainerPATCH 392/482 clk: qcom: gcc-sm8150: De-register gcc_cpuss_ahb_clk_src
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Satya Priya Kakitapalli <[email protected]>
commit bab0c7a0bc586e736b7cd2aac8e6391709a70ef2 upstream.
The branch clocks of gcc_cpuss_ahb_clk_src are marked critical and hence these clocks vote on XO blocking the suspend. De-register these clocks and its source as there is no rate setting happening on them.
--- drivers/clk/qcom/gcc-sc8180x.c | 63 ----------------------------------------- 1 file changed, 63 deletions(-)
drivers/clk/qcom/gcc-sc8180x.c +0 -63
@@ -260,28 +260,6 @@ static const struct clk_parent_data gcc_ { .hw = &gpll0_out_even.clkr.hw }, }; -static const struct freq_tbl ftbl_gcc_cpuss_ahb_clk_src[] = { -F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), -F (50000000 ,P_GPLL0_OUT_MAIN ,12 ,0 ,0 ), -F (100000000 ,P_GPLL0_OUT_MAIN ,6 ,0 ,0 ), - { } -}; - -static struct clk_rcg2 gcc_cpuss_ahb_clk_src = { - .cmd_rcgr =0x48014 , - .mnd_width =0 , - .hid_width =5 , - .parent_map = gcc_parent_map_0, - .freq_tbl = ftbl_gcc_cpuss_ahb_clk_src, - .clkr.hw.init = &(struct clk_init_data ){ - .name ="gcc_cpuss_ahb_clk_src" , - .parent_data = gcc_parents_0, - .num_parents =ARRAY_SIZE (gcc_parents_0), - .flags =CLK_SET_RATE_PARENT , - .ops = &clk_rcg2_ops, - }, -}; -static const struct freq_tbl ftbl_gcc_emac_ptp_clk_src[] = {F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ),F (50000000 ,P_GPLL0_OUT_EVEN ,6 ,0 ,0 ),
@@ -1599,25 +1577,6 @@ static struct clk_branch gcc_cfg_noc_usb }, }; -/* For CPUSS functionality the AHB clock needs to be left enabled */ -static struct clk_branch gcc_cpuss_ahb_clk = { - .halt_reg =0x48000 , - .halt_check =BRANCH_HALT_VOTED , - .clkr = { - .enable_reg =0x52004 , - .enable_mask =BIT (21 ), - .hw.init = &(struct clk_init_data ){ - .name ="gcc_cpuss_ahb_clk" , - .parent_hws = (const struct clk_hw *[]){ - &gcc_cpuss_ahb_clk_src.clkr.hw - }, - .num_parents =1 , - .flags =CLK_IS_CRITICAL |CLK_SET_RATE_PARENT , - .ops = &clk_branch2_ops, - }, - }, -}; -static struct clk_branch gcc_cpuss_rbcpr_clk = { .halt_reg =0x48008 , .halt_check =BRANCH_HALT ,
@@ -3150,25 +3109,6 @@ static struct clk_branch gcc_sdcc4_apps_ }, }; -/* For CPUSS functionality the SYS NOC clock needs to be left enabled */ -static struct clk_branch gcc_sys_noc_cpuss_ahb_clk = { - .halt_reg =0x4819c , - .halt_check =BRANCH_HALT_VOTED , - .clkr = { - .enable_reg =0x52004 , - .enable_mask =BIT (0 ), - .hw.init = &(struct clk_init_data ){ - .name ="gcc_sys_noc_cpuss_ahb_clk" , - .parent_hws = (const struct clk_hw *[]){ - &gcc_cpuss_ahb_clk_src.clkr.hw - }, - .num_parents =1 , - .flags =CLK_IS_CRITICAL |CLK_SET_RATE_PARENT , - .ops = &clk_branch2_ops, - }, - }, -}; -static struct clk_branch gcc_tsif_ahb_clk = { .halt_reg =0x36004 , .halt_check =BRANCH_HALT ,
@@ -4284,8 +4224,6 @@ static struct clk_regmap *gcc_sc8180x_cl [GCC_CFG_NOC_USB3_MP_AXI_CLK] = &gcc_cfg_noc_usb3_mp_axi_clk.clkr, [GCC_CFG_NOC_USB3_PRIM_AXI_CLK] = &gcc_cfg_noc_usb3_prim_axi_clk.clkr, [GCC_CFG_NOC_USB3_SEC_AXI_CLK] = &gcc_cfg_noc_usb3_sec_axi_clk.clkr, - [GCC_CPUSS_AHB_CLK] = &gcc_cpuss_ahb_clk.clkr, - [GCC_CPUSS_AHB_CLK_SRC] = &gcc_cpuss_ahb_clk_src.clkr, [GCC_CPUSS_RBCPR_CLK] = &gcc_cpuss_rbcpr_clk.clkr, [GCC_DDRSS_GPU_AXI_CLK] = &gcc_ddrss_gpu_axi_clk.clkr, [GCC_DISP_HF_AXI_CLK] = &gcc_disp_hf_axi_clk.clkr,
@@ -4422,7 +4360,6 @@ static struct clk_regmap *gcc_sc8180x_cl [GCC_SDCC4_AHB_CLK] = &gcc_sdcc4_ahb_clk.clkr, [GCC_SDCC4_APPS_CLK] = &gcc_sdcc4_apps_clk.clkr, [GCC_SDCC4_APPS_CLK_SRC] = &gcc_sdcc4_apps_clk_src.clkr, - [GCC_SYS_NOC_CPUSS_AHB_CLK] = &gcc_sys_noc_cpuss_ahb_clk.clkr, [GCC_TSIF_AHB_CLK] = &gcc_tsif_ahb_clk.clkr, [GCC_TSIF_INACTIVITY_TIMERS_CLK] = &gcc_tsif_inactivity_timers_clk.clkr, [GCC_TSIF_REF_CLK] = &gcc_tsif_ref_clk.clkr,
Greg Kroah-Hartman
maintainerPATCH 393/482 media: venus: fix use after free bug in venus_remove due to race condition
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Wang <[email protected]>
commit c5a85ed88e043474161bbfe54002c89c1cb50ee2 upstream.
in venus_probe, core->work is bound with venus_sys_error_handler, which is used to handle error. The code use core->sys_err_done to make sync work. The core->work is started in venus_event_notify.
If we call venus_remove, there might be an unfished work. The possible sequence is as follows:
CPU0 CPU1
|venus_sys_error_handlervenus_remove |hfi_destroy |venus_hfi_destroy |
kfree(hdev); |
|hfi_reinit
|venus_hfi_queues_reinit
|//use hdevFix it by canceling the work in venus_remove.
--- drivers/media/platform/qcom/venus/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/venus/core.c +1 -0
@@ -426,6 +426,7 @@ static void venus_remove(struct platformstruct device *dev = core->dev;int ret; +cancel_delayed_work_sync (&core->work); ret =pm_runtime_get_sync (dev);WARN_ON (ret <0 );
Greg Kroah-Hartman
maintainerPATCH 394/482 clk: qcom: gcc-sm8250: Do not turn off PCIe GDSCs during gdsc_disable()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
commit ade508b545c969c72cd68479f275a5dd640fd8b9 upstream.
With PWRSTS_OFF_ON, PCIe GDSCs are turned off during gdsc_disable(). This can happen during scenarios such as system suspend and breaks the resume of PCIe controllers from suspend.
So use PWRSTS_RET_ON to indicate the GDSC driver to not turn off the GDSCs during gdsc_disable() and allow the hardware to transition the GDSCs to retention when the parent domain enters low power state during system suspend.
--- drivers/clk/qcom/gcc-sm8250.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/qcom/gcc-sm8250.c +3 -3
@@ -3226,7 +3226,7 @@ static struct gdsc pcie_0_gdsc = { .pd = { .name = "pcie_0_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, };static struct gdsc pcie_1_gdsc = {
@@ -3234,7 +3234,7 @@ static struct gdsc pcie_1_gdsc = { .pd = { .name = "pcie_1_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, };static struct gdsc pcie_2_gdsc = {
@@ -3242,7 +3242,7 @@ static struct gdsc pcie_2_gdsc = { .pd = { .name = "pcie_2_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, };static struct gdsc ufs_card_gdsc = {
Greg Kroah-Hartman
maintainerPATCH 395/482 media: qcom: camss: Remove use_count guard in stop_streaming
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 25f18cb1b673220b76a86ebef8e7fb79bd303b27 upstream.
The use_count check was introduced so that multiple concurrent Raw Data Interfaces RDIs could be driven by different virtual channels VCs on the CSIPHY input driving the video pipeline.
This is an invalid use of use_count though as use_count pertains to the number of times a video entity has been opened by user-space not the number of active streams.
If use_count and stream-on count don't agree then stop_streaming() will break as is currently the case and has become apparent when using CAMSS with libcamera's released softisp 0.3.
The use of use_count like this is a bit hacky and right now breaks regular usage of CAMSS for a single stream case. Stopping qcam results in the splat below, and then it cannot be started again and any attempts to do so fails with -EBUSY.
[ 1265.509831] WARNING: CPU: 5 PID: 919 at drivers/media/common/videobuf2/videobuf2-core.c:2183 __vb2_queue_cancel+0x230/0x2c8 [videobuf2_common] ... [ 1265.510630] Call trace: [ 1265.510636] __vb2_queue_cancel+0x230/0x2c8 [videobuf2_common] [ 1265.510648] vb2_core_streamoff+0x24/0xcc [videobuf2_common] [ 1265.510660] vb2_ioctl_streamoff+0x5c/0xa8 [videobuf2_v4l2] [ 1265.510673] v4l_streamoff+0x24/0x30 [videodev] [ 1265.510707] __video_do_ioctl+0x190/0x3f4 [videodev] [ 1265.510732] video_usercopy+0x304/0x8c4 [videodev] [ 1265.510757] video_ioctl2+0x18/0x34 [videodev] [ 1265.510782] v4l2_ioctl+0x40/0x60 [videodev] ... [ 1265.510944] videobuf2_common: driver bug: stop_streaming operation is leaving buffer 0 in active state [ 1265.511175] videobuf2_common: driver bug: stop_streaming operation is leaving buffer 1 in active state [ 1265.511398] videobuf2_common: driver bug: stop_streaming operation is leaving buffer 2 in active st
One CAMSS specific way to handle multiple VCs on the same RDI might be:
- Reference count each pipeline enable for CSIPHY, CSID, VFE and RDIx.
- The video buffers are already associated with msm_vfeN_rdiX so release video buffers when told to do so by stop_streaming.
- Only release the power-domains for the CSIPHY, CSID and VFE when their internal refcounts drop.
Either way refusing to release video buffers based on use_count is erroneous and should be reverted. The silicon enabling code for selecting VCs is perfectly fine. Its a "known missing feature" that concurrent VCs won't work with CAMSS right now.
Initial testing with this code didn't show an error but, SoftISP and "real" usage with Google Hangouts breaks the upstream code pretty quickly, we need to do a partial revert and take another pass at VCs.
This commit partially reverts commit 89013969e232 ("media: camss: sm8250:
Pipeline starting and stopping for multiple virtual channels")
--- drivers/media/platform/qcom/camss/camss-video.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/media/platform/qcom/camss/camss-video.c +0 -6
@@ -557,12 +557,6 @@ static void video_stop_streaming(struct ret =v4l2_subdev_call (subdev, video, s_stream,0 ); -if (entity->use_count >1 ) { -/* Don't stop if other instances of the pipeline are still running */ -dev_dbg (video->camss->dev,"Video pipeline still used, don't stop streaming.\n" ); -return ; - } -if (ret) {dev_err (video->camss->dev,"Video pipeline stop failed: %d\n" , ret);return ;
Greg Kroah-Hartman
maintainerPATCH 396/482 clk: qcom: gcc-sc8180x: Add GPLL9 support
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Satya Priya Kakitapalli <[email protected]>
commit 818a2f8d5e4ad2c1e39a4290158fe8e39a744c70 upstream.
Add the missing GPLL9 pll and fix the gcc_parents_7 data to use the correct pll hw.
--- drivers/clk/qcom/gcc-sc8180x.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/clk/qcom/gcc-sc8180x.c +19 -1
@@ -142,6 +142,23 @@ static struct clk_alpha_pll gpll7 = { }, }; +static struct clk_alpha_pll gpll9 = { + .offset =0x1c000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_TRION ], + .clkr = { + .enable_reg =0x52000 , + .enable_mask =BIT (9 ), + .hw.init = &(const struct clk_init_data ) { + .name ="gpll9" , + .parent_data = &(const struct clk_parent_data ) { + .fw_name ="bi_tcxo" , + }, + .num_parents =1 , + .ops = &clk_alpha_pll_fixed_trion_ops, + }, + }, +}; +static const struct parent_map gcc_parent_map_0[] = { {P_BI_TCXO ,0 }, {P_GPLL0_OUT_MAIN ,1 },
@@ -241,7 +258,7 @@ static const struct parent_map gcc_parenstatic const struct clk_parent_data gcc_parents_7[] = { { .fw_name ="bi_tcxo" , }, { .hw = &gpll0.clkr.hw }, - { .name ="gppl9" }, + { .hw = &gpll9.clkr.hw }, { .hw = &gpll4.clkr.hw }, { .hw = &gpll0_out_even.clkr.hw }, };
@@ -4448,6 +4465,7 @@ static struct clk_regmap *gcc_sc8180x_cl [GPLL1] = &gpll1.clkr, [GPLL4] = &gpll4.clkr, [GPLL7] = &gpll7.clkr, + [GPLL9] = &gpll9.clkr, };static const struct qcom_reset_map gcc_sc8180x_resets[] = {
Greg Kroah-Hartman
maintainerPATCH 397/482 media: qcom: camss: Fix ordering of pm_runtime_enable
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit a151766bd3688f6803e706c6433a7c8d3c6a6a94 upstream.
pm_runtime_enable() should happen prior to vfe_get() since vfe_get() calls pm_runtime_resume_and_get().
This is a basic race condition that doesn't show up for most users so is not widely reported. If you blacklist qcom-camss in modules.d and then subsequently modprobe the module post-boot it is possible to reliably show this error up.
The kernel log for this error looks like this:
qcom-camss ac5a000.camss: Failed to power up pipeline: -13
--- drivers/media/platform/qcom/camss/camss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/camss/camss.c +3 -2
@@ -1985,6 +1985,8 @@ static int camss_probe(struct platform_dv4l2_async_nf_init (&camss->notifier, &camss->v4l2_dev); +pm_runtime_enable (dev); + num_subdevs =camss_of_parse_ports (camss);if (num_subdevs <0 ) { ret = num_subdevs;
@@ -2021,8 +2023,6 @@ static int camss_probe(struct platform_d } } -pm_runtime_enable (dev); -return 0 ; err_register_subdevs:
@@ -2030,6 +2030,7 @@ err_register_subdevs: err_v4l2_device_unregister:v4l2_device_unregister (&camss->v4l2_dev);v4l2_async_nf_cleanup (&camss->notifier); +pm_runtime_disable (dev); err_genpd_cleanup:camss_genpd_cleanup (camss);
Greg Kroah-Hartman
maintainerPATCH 398/482 clk: qcom: gcc-sc8180x: Fix the sdcc2 and sdcc4 clocks freq table
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Satya Priya Kakitapalli <[email protected]>
commit b8acaf2de8081371761ab4cf1e7a8ee4e7acc139 upstream.
Update the frequency tables of gcc_sdcc2_apps_clk and gcc_sdcc4_apps_clk as per the latest frequency plan.
--- drivers/clk/qcom/gcc-sc8180x.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clk/qcom/gcc-sc8180x.c +2 -3
@@ -911,7 +911,7 @@ static const struct freq_tbl ftbl_gcc_sdF (25000000 ,P_GPLL0_OUT_MAIN ,12 ,1 ,2 ),F (50000000 ,P_GPLL0_OUT_MAIN ,12 ,0 ,0 ),F (100000000 ,P_GPLL0_OUT_MAIN ,6 ,0 ,0 ), - F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0), + F(202000000, P_GPLL9_OUT_MAIN, 4, 0, 0), { } };
@@ -934,9 +934,8 @@ static const struct freq_tbl ftbl_gcc_sdF (400000 ,P_BI_TCXO ,12 ,1 ,4 ),F (9600000 ,P_BI_TCXO ,2 ,0 ,0 ),F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), -F (37500000 ,P_GPLL0_OUT_MAIN ,16 ,0 ,0 ),F (50000000 ,P_GPLL0_OUT_MAIN ,12 ,0 ,0 ), - F(75000000, P_GPLL0_OUT_MAIN, 8, 0, 0), + F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0), { } };