[PATCH RFC 2/5] mm/mprotect: minor can_change_pte_writable() cleanups
David Hildenbrand
david at redhat.com
Tue Sep 27 01:26:15 AEST 2022
We want to replicate this code for handling PMDs soon. No need to crash
the kernel, warning and rejecting is good enough. As this will no longer
get optimized out, drop the pte_write() check: no harm would be done.
While at it, add a comment why PROT_NONE mapped pages are excluded.
Signed-off-by: David Hildenbrand <david at redhat.com>
---
mm/mprotect.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index c6c13a0a4bcc..95323bc9a951 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -43,8 +43,10 @@ static inline bool can_change_pte_writable(struct vm_area_struct *vma,
{
struct page *page;
- VM_BUG_ON(!(vma->vm_flags & VM_WRITE) || pte_write(pte));
+ if (WARN_ON_ONCE(!(vma->vm_flags & VM_WRITE)))
+ return false;
+ /* Don't touch entries that are not even readable (NUMA hinting). */
if (pte_protnone(pte))
return false;
--
2.37.3
More information about the Linuxppc-dev
mailing list