mm/memory-failure: cast index to loff_t before shifting it
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 18 Dec 2023 13:58:37 +0000 (13:58 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 20 Dec 2023 21:46:20 +0000 (13:46 -0800)
On 32-bit systems, we'll lose the top bits of index because arithmetic
will be performed in unsigned long instead of unsigned long long.  This
affects files over 4GB in size.

Link: https://lkml.kernel.org/r/20231218135837.3310403-4-willy@infradead.org
Fixes: 6100e34b2526 ("mm, memory_failure: Teach memory_failure() about dev_pagemap pages")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory-failure.c

index 82e15baabb4827b078c254e24d91b18c61a00218..455093f73a70c4eae5444f1ce5d46c6b326caa8f 100644 (file)
@@ -1704,7 +1704,7 @@ static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn,
                 * mapping being torn down is communicated in siginfo, see
                 * kill_proc()
                 */
-               loff_t start = (index << PAGE_SHIFT) & ~(size - 1);
+               loff_t start = ((loff_t)index << PAGE_SHIFT) & ~(size - 1);
 
                unmap_mapping_range(mapping, start, size, 0);
        }