v1
2026-11-02
mlock 零长与溢出范围修正 · v1
mlock/munlock 零长度改为 no-op,并拒绝 start+len 或页对齐溢出的范围,补充 mlock2-tests。
原始补丁链接
子 Patch(3)
1/3
mm/mlock: make a zero length request a no-op whatever the alignment
A zero length mlock() or munlock() at an unaligned address is rounded up to a page, so mlock(addr + 5, 0) locks a page that was never asked for, and munlock(addr + 5, 0) unlocks one the caller may sti
2/3
mm/mlock: reject ranges that cannot be represented
A length within a page of ULONG_MAX wraps when mlock() and munlock() round the range to pages. At an aligned address the length becomes 0 and the call is a silent success; at an unaligned one it becom
3/3
selftests/mm: test mlock() and munlock() range normalisation
Add mlock2-tests cases for a zero length at aligned and unaligned addresses, for a length that wraps when rounded to pages, and for an overflowing start + len, checking the return value and VmLck. The