mailweb.openeuler.org
Manage this list

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

Kernel

Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
kernel@openeuler.org

  • 32 participants
  • 25501 discussions
[PATCH OLK-6.6] unicode: free the map after a grace period
by Zizhi Wo 26 Nov '26

26 Nov '26
stable inclusion from stable-v6.6.161 commit 5d7687b0b71601cc32f1bfd62f56cf5eea3e5a07 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20962 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id… -------------------------------- commit a96c5299bd7305eb984377681eb3222a57376405 upstream. generic_ci_d_hash() and generic_ci_d_compare() read sb->s_encoding and dereference the unicode map while a pathwalk in rcu mode holds nothing but rcu_read_lock(). The filesystems that use them, ext4, f2fs and tmpfs, drop the map with utf8_unload() from ->put_super(), which runs when the last reference to the mount goes away. A lookup that is still inside such a filesystem at that point reads a freed map. With a pathwalk held up in utf8_casefold_hash() while the last reference to a casefolded tmpfs goes away: BUG: KASAN: slab-use-after-free in utf8nlookup+0x74c/0x950 Read of size 8 at addr ff110001030fe658 by task walker/98 Call Trace: <TASK> utf8nlookup+0x74c/0x950 utf8byte+0x160/0x1560 utf8_casefold_hash+0x167/0x230 generic_ci_d_hash+0xdd/0x1c0 link_path_walk+0x11ad/0x1d30 path_lookupat+0x63/0xb00 filename_lookup+0x1f1/0x5b0 vfs_statx+0xd7/0x3b0 [...] Allocated by task 94: __kmalloc_cache_noprof+0x249/0x560 utf8_load+0x4e/0x570 shmem_parse_opt_casefold.isra.0+0x92/0x270 [...] Freed by task 97: kfree+0x1db/0x5b0 shmem_put_super+0x72/0x170 generic_shutdown_super+0x14c/0x530 kill_anon_super+0x3a/0x60 deactivate_locked_super+0x9c/0xf0 cleanup_mnt+0x9f/0x130 So far that has been hard to hit. umount(2) waits for a grace period in namespace_unlock() before it drops the mount, so only a mount whose last reference goes away elsewhere, like the close of a file or a chdir out of a lazily unmounted directory, can race a walker. So it is reachable. Delay the free until a grace period has passed. The map and the data table it holds a reference to then outlive any pathwalk that found the superblock before the mount went away. The reference on the data table module is dropped from the rcu callback as well. utf8-core is built in whenever CONFIG_UNICODE is set, so there is no module exit that would have to wait for the callbacks. Overlayfs points the s_encoding of an overlay at the map of its first layer without taking a reference of its own. That stays correct. The layer is held by the overlay, so its map is dropped only after the overlay is gone. [ OLK-6.6: struct unicode_map appears in the prototypes of exported symbols, so adding the rcu_head to it would change the kABI version of every symbol reachable through it. Keep the rcu_head in a private wrapper allocated by utf8_load(), the only allocator of struct unicode_map, so the exported symbol checksums stay unchanged. ] Fixes: b886ee3e778e ("ext4: Support case-insensitive file name lookups") Cc: stable(a)vger.kernel.org Link: https://patch.msgid.link/20261009-work-fixes-rcu-v1-6-7446d2d335e6@kernel.o… Signed-off-by: Christian Brauner (Amutable) <brauner(a)kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org> Signed-off-by: Zizhi Wo <wozizhi(a)huawei.com> --- fs/unicode/utf8-core.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c index 0400824ef493..7aa2df94c080 100644 --- a/fs/unicode/utf8-core.c +++ b/fs/unicode/utf8-core.c @@ -1,10 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/slab.h> +#include <linux/rcupdate.h> #include <linux/parser.h> #include <linux/errno.h> #include <linux/stringhash.h> #include "utf8n.h" @@ -170,17 +171,30 @@ static const struct utf8data *find_table_version(const struct utf8data *table, if (version > table[i].maxage) return NULL; return &table[i]; } +/* + * struct unicode_map appears in the prototypes of exported symbols. Adding + * an rcu_head to it would change the kABI checksum of every exported symbol + * that refers to it, so keep the rcu_head in this private wrapper instead. + * utf8_load() is the only allocator of struct unicode_map. + */ +struct utf8_map_rcu { + struct unicode_map um; + struct rcu_head rcu; +}; + struct unicode_map *utf8_load(unsigned int version) { + struct utf8_map_rcu *map; struct unicode_map *um; - um = kzalloc(sizeof(struct unicode_map), GFP_KERNEL); - if (!um) + map = kzalloc(sizeof(*map), GFP_KERNEL); + if (!map) return ERR_PTR(-ENOMEM); + um = &map->um; um->version = version; um->tables = symbol_request(utf8_data_table); if (!um->tables) goto out_free_um; @@ -198,19 +212,35 @@ struct unicode_map *utf8_load(unsigned int version) return um; out_symbol_put: symbol_put(utf8_data_table); out_free_um: - kfree(um); + kfree(map); return ERR_PTR(-EINVAL); } EXPORT_SYMBOL(utf8_load); +static void utf8_unload_rcu(struct rcu_head *head) +{ + struct utf8_map_rcu *map = container_of(head, struct utf8_map_rcu, rcu); + + symbol_put(utf8_data_table); + kfree(map); +} + +/* + * A pathwalk in rcu mode may still be in ->d_hash() or ->d_compare() of a + * filesystem that is being torn down and read the map through its + * superblock, so the map and the tables it points to have to outlive the + * grace period. + */ void utf8_unload(struct unicode_map *um) { + struct utf8_map_rcu *map; + if (um) { - symbol_put(utf8_data_table); - kfree(um); + map = container_of(um, struct utf8_map_rcu, um); + call_rcu(&map->rcu, utf8_unload_rcu); } } EXPORT_SYMBOL(utf8_unload); -- 2.52.0
2 1
0 0
[PATCH OLK-6.6] iommufd: Rollback IOPF and refcount when iopf/sva enabling fails
by Zhang Yuwei 26 Nov '26

26 Nov '26
hulk inclusion category: bugfix bugzilla: https://gitcode.com/openeuler/kernel/issues/10441 ------------------ iommufd_fault_iopf_enable() has three problems on the failure paths, all introduced by commit 6b45626422f7 ("iommufd: enable SVA when IOPF enabled"): 1. When IOMMU_DEV_FEAT_SVA enabling fails, the function returns without unlocking idev->iopf_lock, leaving the mutex held forever and deadlocking any later enable()/disable(). 2. That same path returns without disabling the already-enabled IOMMU_DEV_FEAT_IOPF and without undoing the incremented idev->iopf_enabled. The leftover refcount makes the next enable() hit the "already enabled" shortcut and return success while SVA was never actually enabled, so the device is attached to a fault domain with SVA silently missing. 3. When IOMMU_DEV_FEAT_IOPF enabling fails, the error is not propagated: the code keeps going and enables SVA, overwriting the return value. If SVA happens to succeed, the function returns 0 although IOPF is off and the refcount is back to 0, and the later disable() path hits WARN_ON(iopf_enabled == 0). Fix all three by jumping to a common undo path when IOPF enabling fails, rolling back IOPF when SVA enabling fails, and dropping the refcount on any failure, so that a failed enable() leaves the device exactly as it was found, which is the contract its callers rely on. The unlock also converges back to a single exit, which also silences the unlock-missing.cocci warning. Fixes: 6b45626422f7 ("iommufd: enable SVA when IOPF enabled") Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com> --- drivers/iommu/iommufd/fault.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 6ae29981fe38..66015cb5e4da 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -44,12 +44,15 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_IOPF); if (ret) - --idev->iopf_enabled; + goto out_undo; - ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA); + ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA); if (ret) - return ret; + iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_IOPF); +out_undo: + if (ret) + --idev->iopf_enabled; mutex_unlock(&idev->iopf_lock); return ret; -- 2.22.0
2 1
0 0
[PATCH OLK-6.6] iommufd: Rollback IOPF and refcount when iopf/sva enabling fails
by Zhang Yuwei 26 Nov '26

26 Nov '26
Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitcode.com/openeuler/kernel/issues/10441 ------------------ iommufd_fault_iopf_enable() has three problems on the failure paths, all introduced by commit 6b45626422f7 ("iommufd: enable SVA when IOPF enabled"): 1. When IOMMU_DEV_FEAT_SVA enabling fails, the function returns without unlocking idev->iopf_lock, leaving the mutex held forever and deadlocking any later enable()/disable(). 2. That same path returns without disabling the already-enabled IOMMU_DEV_FEAT_IOPF and without undoing the incremented idev->iopf_enabled. The leftover refcount makes the next enable() hit the "already enabled" shortcut and return success while SVA was never actually enabled, so the device is attached to a fault domain with SVA silently missing. 3. When IOMMU_DEV_FEAT_IOPF enabling fails, the error is not propagated: the code keeps going and enables SVA, overwriting the return value. If SVA happens to succeed, the function returns 0 although IOPF is off and the refcount is back to 0, and the later disable() path hits WARN_ON(iopf_enabled == 0). Fix all three by jumping to a common undo path when IOPF enabling fails, rolling back IOPF when SVA enabling fails, and dropping the refcount on any failure, so that a failed enable() leaves the device exactly as it was found, which is the contract its callers rely on. The unlock also converges back to a single exit, which also silences the unlock-missing.cocci warning. Fixes: 6b45626422f7 ("iommufd: enable SVA when IOPF enabled") Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com> --- drivers/iommu/iommufd/fault.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 6ae29981fe38..66015cb5e4da 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -44,12 +44,15 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_IOPF); if (ret) - --idev->iopf_enabled; + goto out_undo; - ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA); + ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA); if (ret) - return ret; + iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_IOPF); +out_undo: + if (ret) + --idev->iopf_enabled; mutex_unlock(&idev->iopf_lock); return ret; -- 2.22.0
2 1
0 0
[PATCH OLK-6.6] mm: memcontrol: fix NULL pointer deref and UAF from high_work_func() on dying memcg
by Yi Yang 26 Nov '26

26 Nov '26
stable inclusion from stable-v6.6.163 commit 16062b71048d8ef85ca6a99d5ef26f0143d0e0c7 category: bugfix CVE: CVE-2026-99697 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id… -------------------------------- [ Upstream commit dd94d8c7660a60dbfcd425e0d10120de6d02a7bd ] When memory.high is exceeded in non-task context, try_charge_memcg() schedules memcg->high_work without taking a reference on the memcg, and high_work_func() invokes reclaim_high() without pinning the memcg. With obj_cgroup reparenting, introduced in commit bf4f059954dc ("mm: memcg/slab: obj_cgroup API"), objects charged to a child memcg are reparented to its parent in mem_cgroup_css_offline() instead of holding a reference on the child until uncharged. Subsequent uncharges of those objects go to the parent, which can leave the child's memory use permanently above its high limit, so any later charge on the offlined memcg in non-task context schedules high_work. This was later widened from kernel memory to LRU folios when commit f1cf8d2f36dc ("mm: memcontrol: eliminate the problem of dying memory cgroup for LRU folios") converted LRU folios to use obj_cgroup reparenting. cancel_work_sync(&memcg->high_work) only runs at the end of teardown in mem_cgroup_css_free(), so high_work_func() can start or still be running reclaim_high() after mem_cgroup_css_released() or shrink_many() has called lru_gen_release_memcg() and unhashed lruvec->lrugen.list. If reclaim tries to rotate the memcg, lru_gen_rotate_memcg() dereferences a NULL pprev pointer. This issue is specific to MGLRU and was introduced with the memcg LRU in commit e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists"). With either traditional LRU or MGLRU, css_free_rwork_fn() calls css_rstat_exit() which frees per-CPU rstat data before calling mem_cgroup_css_free(). If reclaim_high() is still running, rstat updates via mod_lruvec_state() -> __css_rstat_updated() cause a use-after-free on the per-CPU rstat data. This was introduced when commit 5da3bfa029d6 ("cgroup: use separate rstat trees for each subsystem") moved css_rstat_exit() ahead of ss->css_free(). Fix both problems by acquiring a reference with css_tryget_online() in high_work_func() before calling reclaim_high(), and by resetting memory.high and swap.high to PAGE_COUNTER_MAX in mem_cgroup_css_offline() so that charges via references on an offlined memcg do not trigger high_work on the dead child and skip checking live ancestors in try_charge_memcg(). Acquiring the reference in high_work_func() rather than before scheduling high_work is safe because mem_cgroup_css_free() calls irq_work_sync() and cancel_work_sync() which cancels pending work and waits for an already running high_work_func() to complete before mem_cgroup_free() frees the memcg. css_tryget_online() uses percpu_ref_tryget_live() and is safe to call after percpu_ref_exit() before the cgroup is freed unlike css_tryget(). Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 1 UID: 0 PID: 27 Comm: kworker/1:0 Tainted: G B W 7.3.0-rc5-g2bba28e98578 #284 PREEMPT(full) Tainted: [B]=BAD_PAGE, [W]=WARN <-- Taint from lru_gen_rotate_memcg() VM_WARN_ON_ONCE Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 Workqueue: events high_work_func RIP: 0010:lru_gen_rotate_memcg+0x1a3/0xe90 Call Trace: <TASK> ? read_ctrl_pos+0x22f/0x3f0 shrink_lruvec+0x16cb/0x1b80 ? ret_from_fork_asm+0x1a/0x30 ? lapic_next_event+0x15/0x20 ? clockevents_program_event+0x2bb/0x6f0 ? lapic_next_event+0x15/0x20 ? __pfx_shrink_lruvec+0x10/0x10 ? __pfx_clockevents_program_event+0x10/0x10 ? _raw_spin_lock+0x84/0xe0 ? __pfx__raw_spin_lock+0x10/0x10 ? kasan_save_stack+0x30/0x50 ? psi_group_change+0x381/0x740 ? __pfx_sched_clock_cpu+0x10/0x10 ? save_fpregs_to_fpstate+0xc4/0x2c0 ? finish_task_switch.isra.0+0x1de/0xac0 ? __schedule+0xf62/0x42c0 ? __pfx___schedule+0x10/0x10 ? __pfx___irq_work_queue_local+0x10/0x10 ? shrink_node+0x626/0x31e0 shrink_node+0x626/0x31e0 ? ring_buffer_unlock_commit+0x11d/0x5c0 ? kswapd_clear_hopeless+0xa0/0x150 ? __pfx_shrink_node+0x10/0x10 ? 0xffffffffc0000095 do_try_to_free_pages+0x255/0x13b0 ? ring_buffer_unlock_commit+0x11d/0x5c0 ? reclaim_high+0x10a/0x1b0 try_to_free_mem_cgroup_pages+0x1f9/0x5a0 ? __pfx_try_to_free_mem_cgroup_pages+0x10/0x10 ? irqentry_exit+0xc6/0x670 reclaim_high+0x10a/0x1b0 ? __pfx_reclaim_high+0x10/0x10 ? process_one_work+0x5ff/0x1030 ? __pfx_high_work_func+0x10/0x10 process_one_work+0x6e2/0x1030 ? __pfx___schedule+0x10/0x10 ? __pfx_process_one_work+0x10/0x10 worker_thread+0x422/0xbb0 ? __pfx_worker_thread+0x10/0x10 kthread+0x2cd/0x3a0 ? recalc_sigpending+0x15c/0x200 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x368/0x590 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x588/0xf50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Link: https://lore.kernel.org/20261029201858.2932905-1-tjmercier@google.com Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists") Fixes: 5da3bfa029d6 ("cgroup: use separate rstat trees for each subsystem") Signed-off-by: T.J. Mercier <tjmercier(a)google.com> Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org> Reviewed-by: Johannes Weiner <hannes(a)cmpxchg.org> Acked-by: Muchun Song <muchun.song(a)linux.dev> Acked-by: Shakeel Butt <shakeel.butt(a)linux.dev> Acked-by: Michal Hocko <mhocko(a)suse.com> Cc: Michal Hocko <mhocko(a)kernel.org> Cc: Roman Gushchin <roman.gushchin(a)linux.dev> Cc: Qi Zheng <qi.zheng(a)linux.dev> Cc: JP Kobryn <jp.kobryn(a)linux.dev> Cc: <stable(a)vger.kernel.org> Signed-off-by: Sasha Levin <sashal(a)kernel.org> Conflicts: mm/memcontrol.c [Context differences are due to the local CONFIG_MEMCG_QOS extension in high_work_func() (async_reclaim_high() path), which is not present upstream. css_tryget_online()/css_put() are placed around the whole if/else block so the QOS path is protected as well. ] Signed-off-by: Yi Yang <yiyang13(a)huawei.com> --- mm/memcontrol.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 27ec983a00c7..da4f011d205e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2624,12 +2624,16 @@ static void high_work_func(struct work_struct *work) struct mem_cgroup *memcg = container_of(work, struct mem_cgroup, high_work); + if (!css_tryget_online(&memcg->css)) + return; + #ifdef CONFIG_MEMCG_QOS if (READ_ONCE(memcg->high_async_reclaim)) async_reclaim_high(memcg); else #endif reclaim_high(memcg, MEMCG_CHARGE_BATCH, GFP_KERNEL); + css_put(&memcg->css); } /* @@ -6940,6 +6944,8 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) page_counter_set_min(&memcg->memory, 0); page_counter_set_low(&memcg->memory, 0); + page_counter_set_high(&memcg->memory, PAGE_COUNTER_MAX); + page_counter_set_high(&memcg->swap, PAGE_COUNTER_MAX); memcg_offline_kmem(memcg); reparent_shrinker_deferred(memcg); -- 2.25.1
2 1
0 0
[PATCH OLK-6.6] iommufd: Rollback IOPF and refcount when iopf/sva enabling fails
by Zhang Yuwei 26 Nov '26

26 Nov '26
Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitcode.com/openeuler/kernel/issues/10441 ------------------ iommufd_fault_iopf_enable() has two state-consistency problems on the failure paths, both introduced by commit 6b45626422f7 ("iommufd: enable SVA when IOPF enabled"): 1. When IOMMU_DEV_FEAT_SVA enabling fails, the function returns without disabling the already-enabled IOMMU_DEV_FEAT_IOPF and without undoing the incremented idev->iopf_enabled. The leftover refcount makes the next enable() hit the "already enabled" shortcut and return success while SVA was never actually enabled, so the device is attached to a fault domain with SVA silently missing. 2. When IOMMU_DEV_FEAT_IOPF enabling fails, the error is not propagated: the code keeps going and enables SVA, overwriting the return value. If SVA happens to succeed, the function returns 0 although IOPF is off and the refcount is back to 0, and the later disable() path hits WARN_ON(iopf_enabled == 0). Fix both by jumping to a common undo path when IOPF enabling fails, rolling back IOPF when SVA enabling fails, and dropping the refcount on any failure, so that a failed enable() leaves the device exactly as it was found, which is the contract its callers rely on. The unlock also converges back to a single exit, superseding the previous partial fix. Fixes: 6b45626422f7 ("iommufd: enable SVA when IOPF enabled") Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com> --- drivers/iommu/iommufd/fault.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 5935c44c58e2..66015cb5e4da 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -44,14 +44,15 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_IOPF); if (ret) - --idev->iopf_enabled; + goto out_undo; - ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA); - if (ret) { - mutex_unlock(&idev->iopf_lock); - return ret; - } + ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA); + if (ret) + iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_IOPF); +out_undo: + if (ret) + --idev->iopf_enabled; mutex_unlock(&idev->iopf_lock); return ret; -- 2.22.0
2 1
0 0
[PATCH OLK-6.6] iommufd: Rollback IOPF and refcount when iopf/sva enabling fails
by Zhang Yuwei 26 Nov '26

26 Nov '26
Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitcode.com/openeuler/kernel/issues/10441 ------------------ iommufd_fault_iopf_enable() has two state-consistency problems on the failure paths, both introduced by commit 6b45626422f7 ("iommufd: enable SVA when IOPF enabled"): 1. When IOMMU_DEV_FEAT_SVA enabling fails, the function returns without disabling the already-enabled IOMMU_DEV_FEAT_IOPF and without undoing the incremented idev->iopf_enabled. The leftover refcount makes the next enable() hit the "already enabled" shortcut and return success while SVA was never actually enabled, so the device is attached to a fault domain with SVA silently missing. 2. When IOMMU_DEV_FEAT_IOPF enabling fails, the error is not propagated: the code keeps going and enables SVA, overwriting the return value. If SVA happens to succeed, the function returns 0 although IOPF is off and the refcount is back to 0, and the later disable() path hits WARN_ON(iopf_enabled == 0). Fix both by jumping to a common undo path when IOPF enabling fails, rolling back IOPF when SVA enabling fails, and dropping the refcount on any failure, so that a failed enable() leaves the device exactly as it was found, which is the contract its callers rely on. The unlock also converges back to a single exit, superseding the previous partial fix. Fixes: 6b45626422f7 ("iommufd: enable SVA when IOPF enabled") Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com> --- drivers/iommu/iommufd/fault.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 5935c44c58e2..66015cb5e4da 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -44,14 +44,15 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_IOPF); if (ret) - --idev->iopf_enabled; + goto out_undo; - ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA); - if (ret) { - mutex_unlock(&idev->iopf_lock); - return ret; - } + ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA); + if (ret) + iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_IOPF); +out_undo: + if (ret) + --idev->iopf_enabled; mutex_unlock(&idev->iopf_lock); return ret; -- 2.22.0
2 1
0 0
[PATCH OLK-6.6] iommufd: Fix unlock-missing.cocci warning in iommufd_fault_iopf_enable
by Zhang Yuwei 26 Nov '26

26 Nov '26
From: Wang Wensheng <wangwensheng4(a)huawei.com> Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitcode.com/openeuler/kernel/issues/10441 ------------------ Add the missing mutex_unlock in iommufd_fault_iopf_enable() when iommu_dev_enable_feature() return unzero value. Fixes: 6b45626422f7 ("iommufd: enable SVA when IOPF enabled") Signed-off-by: Wang Wensheng <wangwensheng4(a)huawei.com> Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com> --- drivers/iommu/iommufd/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 6ae29981fe38..5935c44c58e2 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -47,8 +47,10 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) --idev->iopf_enabled; ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA); - if (ret) + if (ret) { + mutex_unlock(&idev->iopf_lock); return ret; + } mutex_unlock(&idev->iopf_lock); -- 2.22.0
2 2
0 0
[PATCH OLK-6.6] mm/vma: don't leak the charge for stack growth
by Yi Yang 26 Nov '26

26 Nov '26
From: "David Hildenbrand (Arm)" <david(a)kernel.org> stable inclusion from stable-v6.6.163 commit bbe903084b7dfdce65c605f94dc298c7eaaa9d9f category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/21541 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id… -------------------------------- [ Upstream commit b1ee87802111156e27557e82acc31fa7dfc76e2a ] acct_stack_growth() charges stack expansion even without VM_ACCOUNT. This can happen for read-only or MAP_NORESERVE mappings created with MAP_GROWSDOWN. Unmapping these VMAs does not release the charge, leaking Committed_AS. Only check and charge growth for VM_ACCOUNT VMAs, matching mremap(). Unaccounted growth skips the overcommit check while remaining subject to the other stack-growth limits. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable(a)vger.kernel.org Reported-by: Josef Bacik <josef(a)toxicpanda.com> Reviewed-by: Lorenzo Stoakes (ARM) <ljs(a)kernel.org> Reviewed-by: Pedro Falcato <pfalcato(a)suse.de> Reviewed-by: Harry Yoo (Meta) <harry(a)kernel.org> Tested-by: Muhammad Usama Anjum <usama.anjum(a)arm.com> Link: https://patch.msgid.link/20261031-fixes_core-v3-44-d6437171ecc3@kernel.org Signed-off-by: David Hildenbrand (Arm) <david(a)kernel.org> [ sashal: Replaced vma_test(vma, VMA_ACCOUNT_BIT) with a direct vma->vm_flags & VM_ACCOUNT check. ] Signed-off-by: Sasha Levin <sashal(a)kernel.org> Signed-off-by: Yi Yang <yiyang13(a)huawei.com> --- mm/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index bb21bb960f27..777b61d3d644 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2084,7 +2084,8 @@ static int acct_stack_growth(struct vm_area_struct *vma, * Overcommit.. This must be the final test, as it will * update security statistics. */ - if (security_vm_enough_memory_mm(mm, grow)) + if ((vma->vm_flags & VM_ACCOUNT) && + security_vm_enough_memory_mm(mm, grow)) return -ENOMEM; return 0; -- 2.25.1
2 1
0 0
[PATCH OLK-6.6] iommufd: Fix unlock-missing.cocci warning in iommufd_fault_iopf_enable
by Zhang Yuwei 26 Nov '26

26 Nov '26
From: Wang Wensheng <wangwensheng4(a)huawei.com> Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitcode.com/openeuler/kernel/issues/10441 CVE: NA ------------------ Add the missing mutex_unlock in iommufd_fault_iopf_enable() when iommu_dev_enable_feature() return unzero value. Fixes: a0c4fb56541d ("[Backport] iommufd: enable SVA when IOPF enabled") Signed-off-by: Wang Wensheng <wangwensheng4(a)huawei.com> Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com> --- drivers/iommu/iommufd/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 6ae29981fe38..5935c44c58e2 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -47,8 +47,10 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) --idev->iopf_enabled; ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA); - if (ret) + if (ret) { + mutex_unlock(&idev->iopf_lock); return ret; + } mutex_unlock(&idev->iopf_lock); -- 2.22.0
2 1
0 0
[PATCH OLK-6.6] iommufd: Fix unlock-missing.cocci warning in iommufd_fault_iopf_enable
by Zhang Yuwei 26 Nov '26

26 Nov '26
From: Wang Wensheng <wangwensheng4(a)huawei.com> Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitcode.com/src-openeuler/kernel/issues/21618 CVE: NA ------------------ Add the missing mutex_unlock in iommufd_fault_iopf_enable() when iommu_dev_enable_feature() return unzero value. Fixes: a0c4fb56541d ("[Backport] iommufd: enable SVA when IOPF enabled") Signed-off-by: Wang Wensheng <wangwensheng4(a)huawei.com> Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com> --- drivers/iommu/iommufd/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 6ae29981fe38..5935c44c58e2 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -47,8 +47,10 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev) --idev->iopf_enabled; ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA); - if (ret) + if (ret) { + mutex_unlock(&idev->iopf_lock); return ret; + } mutex_unlock(&idev->iopf_lock); -- 2.22.0
2 2
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • ...
  • 2551
  • Older →

HyperKitty Powered by HyperKitty