On 03/10/2025 17:00, Kiryl Shutsemau wrote:
On Fri, Oct 03, 2025 at 04:52:36PM +0100, Ryan Roberts wrote:
fsnotify_mmap_perm() requires a byte offset for the file about to be mmap'ed. But it is called from vm_mmap_pgoff(), which has a page offset. Previously the conversion was done incorrectly so let's fix it, being careful not to overflow on 32-bit platforms.
Discovered during code review.
Heh. Just submitted fix for the same issue:
https://lore.kernel.org/all/20251003155804.1571242-1-kirill@shutemov.name/T/...
Ha... great minds...
I notice that for your version you're just doing "pgoff << PAGE_SHIFT" without casting pgoff.
I'm not sure if that is safe?
pgoff is unsigned long (so 32 bits on 32 bit systems). loff_t is unsigned long long (so always 64 bits). So is it possible that you shift off the end of 32 bits and lose those bits without a cast to loff_t first?
TBH my knowledge of the exact rules is shaky...