On 23.01.24 15:17, Ryan Roberts wrote:
Commit c33c794828f2 ("mm: ptep_get() conversion") converted all
(non-arch) call sites to use ptep_get() instead of doing a direct
dereference of the pte. Full rationale can be found in that commit's
log.
Since then, UFFDIO_MOVE has been implemented which does 7 direct pte
dereferences. Let's fix those up to use ptep_get().
Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx>
---
Hi All,
This applies on top of v6.8-rc1. I'm hoping this can be merged into the
next rc.
I've asserted in the past that there is no reliable automated mechanism
to catch these; I'm relying on a combination of Coccinelle (which throws
up a lot of false positives) and some compiler magic to force a compiler
error on dereference. But given the frequency with which new issues are
coming up, I'll add it to my todo list to try to find an automated
solution.
If we'd use a distinct type for pte pointers that are only passed around
(and not worked on), the compiler would bail out when doing such
assignments.
Like
typedef struct { unsigned long pte; } pte_t;
typedef struct { unsigned long pte; } pte2_t;
pte_t pte = { 2 };
pte2_t pte2;
pte2 = pte;
-> "error: incompatible types when assigning to type 'pte2_t' from type
'pte_t'"
pte_get() would do the conversion.
... but just thinking about it this would require a lot of work.
--
Cheers,
David / dhildenb