FROMLIST: mm: rust: add vm_area_struct methods that require read access

This adds a type called VmAreaRef which is used when referencing a vma
that you have read access to. Here, read access means that you hold
either the mmap read lock or the vma read lock (or stronger).

Additionally, a vma_lookup method is added to the mmap read guard, which
enables you to obtain a &VmAreaRef in safe Rust code.

This patch only provides a way to lock the mmap read lock, but a
follow-up patch also provides a way to just lock the vma read lock.

Acked-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> (for mm bits)
Reviewed-by: Jann Horn <jannh@google.com>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>

Bug: 370906207
Link: https://lore.kernel.org/all/20250115-vma-v12-2-375099ae017a@google.com/
Change-Id: I6e1fc0d60c1a578edac41680855a60401d05cafd
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
Alice Ryhl
2024-11-19 14:02:02 +01:00
parent 4deea7dce7
commit 84aa9d6318
3 changed files with 242 additions and 0 deletions
+6
View File
@@ -37,3 +37,9 @@ void rust_helper_mmap_read_unlock(struct mm_struct *mm)
{
mmap_read_unlock(mm);
}
struct vm_area_struct *rust_helper_vma_lookup(struct mm_struct *mm,
unsigned long addr)
{
return vma_lookup(mm, addr);
}