mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 04:12:04 -04:00
UPSTREAM: mm/mremap.c: fix extent calculation
When `next < old_addr`, `next - old_addr` arithmetic underflows causing `extent` to be incorrect. Make `extent` the smaller of `next - old_addr` or `old_end - old_addr`. Link: https://lkml.kernel.org/r/20201219170433.2418867-1-kaleshsingh@google.com Fixes: c49dd34018026 ("mm: speedup mremap on 1GB or larger regions") Signed-off-by: Kalesh Singh <kaleshsingh@google.com> Reported-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Lokesh Gidra <lokeshgidra@google.com> Cc: Helge Deller <deller@gmx.de> Cc: Kalesh Singh <kaleshsingh@google.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit e05986ee7a5814bec0e0075d813daca3d46e4a9e) Bug: 151772539 Signed-off-by: Kalesh Singh <kaleshsingh@google.com> Change-Id: Ibcbd39dfa16f8ebd1aeca469540b0ef43fb849c9
This commit is contained in:
parent
4a832e8627
commit
b254e3e87d
1 changed files with 3 additions and 1 deletions
|
|
@ -385,7 +385,9 @@ static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
|
|||
|
||||
next = (old_addr + size) & mask;
|
||||
/* even if next overflowed, extent below will be ok */
|
||||
extent = (next > old_end) ? old_end - old_addr : next - old_addr;
|
||||
extent = next - old_addr;
|
||||
if (extent > old_end - old_addr)
|
||||
extent = old_end - old_addr;
|
||||
next = (new_addr + size) & mask;
|
||||
if (extent > next - new_addr)
|
||||
extent = next - new_addr;
|
||||
|
|
|
|||
Loading…
Reference in a new issue