* [PATCH] fpga: dfl: afu: prevent read-only port mappings from becoming writable
@ 2026-08-19 8:39 Abdifatah Suruur
0 siblings, 0 replies; 3+ messages in thread
From: Abdifatah Suruur @ 2026-08-19 8:39 UTC (permalink / raw)
To: linux-fpga; +Cc: linux-kernel, yilun.xu, trix
afu_mmap() rejects writable mappings of port regions without the WRITE
flag, but leaves VM_MAYWRITE set. Userspace can map such a region
read-only and then upgrade the mapping to writable with mprotect(),
writing to FPGA port control/status registers the host owns. A guest
assigned an AFU can use this to reconfigure or reset the port and
interfere with other tenants on the same FPGA.
Clear VM_MAYWRITE for regions without the WRITE flag, as i915 does for
its read-only objects and as fixed in drm/vc4 (CVE-2026-68445) and
drm/panthor (CVE-2024-53071) and ptp: vmclock (commit
a5edadbae57e2298a56cf7a4e774a027905a331f).
Fixes: 1a1527cf5ddac ("fpga: dfl: add FPGA Accelerated Function Unit driver basic framework")
Cc: stable@vger.kernel.org
Signed-off-by: Abdifatah Suruur <suruurism@gmail.com>
---
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -836,7 +836,11 @@
if ((vma->vm_flags & VM_WRITE) &&
!(region.flags & DFL_PORT_REGION_WRITE))
return -EPERM;
+ /* Prevent read-only port mappings from being upgraded with mprotect() */
+ if (!(region.flags & DFL_PORT_REGION_WRITE))
+ vm_flags_clear(vma, VM_MAYWRITE);
+
/* Support debug access to the mapping */
vma->vm_ops = &afu_vma_ops;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] fpga: dfl: afu: prevent read-only port mappings from becoming writable
@ 2026-08-19 8:42 Abdifatah Suruur
2026-08-19 11:23 ` Dinh Nguyen
0 siblings, 1 reply; 3+ messages in thread
From: Abdifatah Suruur @ 2026-08-19 8:42 UTC (permalink / raw)
To: linux-fpga; +Cc: linux-kernel, yilun.xu, trix
afu_mmap() rejects writable mappings of port regions without the WRITE
flag, but leaves VM_MAYWRITE set. Userspace can map such a region
read-only and then upgrade the mapping to writable with mprotect(),
writing to FPGA port control/status registers the host owns. A guest
assigned an AFU can use this to reconfigure or reset the port and
interfere with other tenants on the same FPGA.
Clear VM_MAYWRITE for regions without the WRITE flag, as i915 does for
its read-only objects and as fixed in drm/vc4 (CVE-2026-68445) and
drm/panthor (CVE-2024-53071) and ptp: vmclock (commit
a5edadbae57e2298a56cf7a4e774a027905a331f).
Fixes: 1a1527cf5ddac ("fpga: dfl: add FPGA Accelerated Function Unit driver basic framework")
Cc: stable@vger.kernel.org
Signed-off-by: Abdifatah Suruur <suruurism@gmail.com>
---
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -836,7 +836,11 @@
if ((vma->vm_flags & VM_WRITE) &&
!(region.flags & DFL_PORT_REGION_WRITE))
return -EPERM;
+ /* Prevent read-only port mappings from being upgraded with mprotect() */
+ if (!(region.flags & DFL_PORT_REGION_WRITE))
+ vm_flags_clear(vma, VM_MAYWRITE);
+
/* Support debug access to the mapping */
vma->vm_ops = &afu_vma_ops;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fpga: dfl: afu: prevent read-only port mappings from becoming writable
2026-08-19 8:42 [PATCH] fpga: dfl: afu: prevent read-only port mappings from becoming writable Abdifatah Suruur
@ 2026-08-19 11:23 ` Dinh Nguyen
0 siblings, 0 replies; 3+ messages in thread
From: Dinh Nguyen @ 2026-08-19 11:23 UTC (permalink / raw)
To: Abdifatah Suruur, linux-fpga; +Cc: linux-kernel, yilun.xu, trix
On 8/19/26 03:42, Abdifatah Suruur wrote:
> afu_mmap() rejects writable mappings of port regions without the WRITE
> flag, but leaves VM_MAYWRITE set. Userspace can map such a region
> read-only and then upgrade the mapping to writable with mprotect(),
> writing to FPGA port control/status registers the host owns. A guest
> assigned an AFU can use this to reconfigure or reset the port and
> interfere with other tenants on the same FPGA.
>
> Clear VM_MAYWRITE for regions without the WRITE flag, as i915 does for
> its read-only objects and as fixed in drm/vc4 (CVE-2026-68445) and
> drm/panthor (CVE-2024-53071) and ptp: vmclock (commit
> a5edadbae57e2298a56cf7a4e774a027905a331f).
>
> Fixes: 1a1527cf5ddac ("fpga: dfl: add FPGA Accelerated Function Unit driver basic framework")
Please used exactly 12 characters for the hash ID.
Dinh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-19 11:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 8:42 [PATCH] fpga: dfl: afu: prevent read-only port mappings from becoming writable Abdifatah Suruur
2026-08-19 11:23 ` Dinh Nguyen
-- strict thread matches above, loose matches on Subject: below --
2026-08-19 8:39 Abdifatah Suruur
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.