hugetlbfs: skip VMAs without shareable locks in hugetlb_vmdelete_list
Subsystems (2)
PATCH 1/1 hugetlbfs: skip VMAs without shareable locks in hugetlb_vmdelete_list
hugetlb_vmdelete_list() uses trylock to acquire VMA locks during truncate operations. As per the original design in commit 40549ba8f8e0 ("hugetlb:
use new vma_lock for pmd sharing synchronization"), if the trylock fails or the VMA has no lock, it should skip that VMA. Any remaining mapped pages are handled by remove_inode_hugepages() which is called after hugetlb_vmdelete_list() and uses proper lock ordering to guarantee unmapping success.
Currently, when hugetlb_vma_trylock_write() returns success (1) for VMAs without shareable locks, the code proceeds to call unmap_hugepage_range(). This causes assertion failures in huge_pmd_unshare() → hugetlb_vma_assert_locked() because no lock is actually held:
WARNING: CPU: 1 PID: 6594 Comm: syz.0.28 Not tainted Call Trace: hugetlb_vma_assert_locked+0x1dd/0x250 huge_pmd_unshare+0x2c8/0x540 __unmap_hugepage_range+0x6e3/0x1aa0 unmap_hugepage_range+0x32e/0x410 hugetlb_vmdelete_list+0x189/0x1f0
Fix by explicitly skipping VMAs without shareable locks after trylock succeeds, consistent with the original design where such VMAs are deferred to remove_inode_hugepages() for proper handling.
--- fs/hugetlbfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/hugetlbfs/inode.c +2 -1
@@ -487,7 +487,8 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end,if (!hugetlb_vma_trylock_write (vma))continue ; - +if (!__vma_shareable_lock (vma)) +continue ; v_start =vma_offset_start (vma, start); v_end =vma_offset_end (vma, end);
Signature · 1 line
2.43.0
syzbot ci has tested the following series
syzbot ci has tested the following series
[v1] hugetlbfs: skip VMAs without shareable locks in hugetlb_vmdelete_list
https://lore.kernel.org/all/[email protected]
* [PATCH] hugetlbfs: skip VMAs without shareable locks in hugetlb_vmdelete_list
and found the following issue:
WARNING: lock held when returning to user space in hugetlb_vmdelete_list
Full report is available here:
https://ci.syzbot.org/series/7d3a090c-ec8f-4d0c-8f7b-8797e63f1fde
***
WARNING: lock held when returning to user space in hugetlb_vmdelete_list
tree: torvalds URL: https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux base: 07e27ad16399afcd693be20211b0dfae63e0615f arch: amd64 compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8 config: https://ci.syzbot.org/builds/06671e7c-eebd-4d11-9f0d-d9dae5637c0a/config C repro: https://ci.syzbot.org/findings/75fcdb87-67fc-45ee-a70d-3064e8c1126c/c_repro syz repro: https://ci.syzbot.org/findings/75fcdb87-67fc-45ee-a70d-3064e8c1126c/syz_repro
================================================
WARNING: lock held when returning to user space!
syzkaller #0 Not tainted
------------------------------------------------
syz.0.17/5991 is leaving the kernel with locks still held!
1 lock held by syz.0.17/5991:
#0: ffff88801f7dcce8 (&resv_map->rw_sema){+.+.}-{4:4}, at: hugetlb_vmdelete_list+0x67/0x230 fs/hugetlbfs/inode.c:490
***
If these findings have caused you to resend the series or submit a separate fix, please add the following tag to your commit message:
---
This report is generated by a bot. It may contain errors. syzbot ci engineers can be reached at [email protected].
Andrew Morton
maintainerQuoted 25 lines · On Thu, 25 Sep 2025 14:06:49 -0700 syzbot ci…
syzbot ci has tested the following series
[v1] hugetlbfs: skip VMAs without shareable locks in
hugetlb_vmdelete_list
https://lore.kernel.org/all/[email protected]
* [PATCH] hugetlbfs: skip VMAs without shareable locks inhugetlb_vmdelete_listand found the following issue:
WARNING: lock held when returning to user space inhugetlb_vmdelete_listFull report is available here:
https://ci.syzbot.org/series/7d3a090c-ec8f-4d0c-8f7b-8797e63f1fde***
WARNING: lock held when returning to user space in
hugetlb_vmdelete_listtree: torvalds URL: https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux base: 07e27ad16399afcd693be20211b0dfae63e0615f arch: amd64 compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8 config: https://ci.syzbot.org/builds/06671e7c-eebd-4d11-9f0d-d9dae5637c0a/config C repro: https://ci.syzbot.org/findings/75fcdb87-67fc-45ee-a70d-3064e8c1126c/c_repro syz repro: https://ci.syzbot.org/findings/75fcdb87-67fc-45ee-a70d-3064e8c1126c/syz_repro
Quoted 3 lines
================================================
WARNING: lock held when returning to user space!
syzkaller #0 Not tainted
um yes. Presumably something like the below is needed.
I'm wondering how this passed runtime testing?
If resending, please let's add a comment telling readers why we're skipping !__vma_shareable_lock vmas.
I'll drop the patch, thanks.
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~hugetlbfs-skip-vmas-without-shareable-locks-in-hugetlb_vmdelete_list-fix +2 -1
@@ -488,7 +488,7 @@ hugetlb_vmdelete_list(struct rb_root_cacif (!hugetlb_vma_trylock_write (vma))continue ;if (!__vma_shareable_lock (vma)) -continue ; + goto skip; v_start =vma_offset_start (vma, start); v_end =vma_offset_end (vma, end);
@@ -499,6 +499,7 @@ hugetlb_vmdelete_list(struct rb_root_cac* vmas. Therefore, lock is not held when calling * unmap_hugepage_range for private vmas. */ +skip:hugetlb_vma_unlock_write (vma); } }
_