mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01:00
ptp: vmclock: prevent read-only mappings from becoming writable
vmclock_miscdev_mmap() rejects writable mappings of the shared vmclock
ABI page with -EROFS, but leaves VM_MAYWRITE set. Userspace can map the
page read-only and then upgrade it to writable with mprotect(), after
which the guest can corrupt the host-written timekeeping data (sequence
counter, UTC time, TSC offset) that the vmclock ABI defines as read-only.
Clear VM_MAYWRITE on the read-only path so the mapping cannot be
upgraded, as i915 does for its read-only objects and as fixed in drm/vc4
(CVE-2026-68445) and drm/panthor (CVE-2024-53071).
Cc: [email protected]
Fixes: 2050327242 ("ptp: Add support for the AMZNC10C 'vmclock' device")
Signed-off-by: Abdifatah Suruur <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
This commit is contained in:
1 parent
c0726f0caf
commit
a5edadbae5
1 file changed
+6
@@ -372,6 +372,12 @@ static int vmclock_miscdev_mmap(struct file *fp, struct vm_area_struct *vma)
|
||||
if ((vma->vm_flags & (VM_READ|VM_WRITE)) != VM_READ)
|
||||
return -EROFS;
|
||||
|
||||
/*
|
||||
* Restrict the read-only mapping so it cannot be upgraded to
|
||||
* writable later with mprotect().
|
||||
*/
|
||||
vm_flags_clear(vma, VM_MAYWRITE);
|
||||
|
||||
if (vma->vm_end - vma->vm_start != PAGE_SIZE || vma->vm_pgoff)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
Reference in new issue
Block a user