mm: mremap - Fix extent calculation
Guenter Roeck
Tested-byQuoted 7 lines · Kalesh Singh
When
next < old_addr,next - old_addrarithmetic underflows causingextentto be incorrect.Make
extentthe smaller ofnext - old_addrorold_end - old_addr.Reported-by Guenter Roeck <[email protected]>Signed-off-by Kalesh Singh <[email protected]>
This patch fixes the problem I had observed when booting 'parisc' images.
Tested-by Guenter Roeck <[email protected]>
Guenter
Quoted 22 lines
--- mm/mremap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/mremap.c +3
-1@@ -358,7 +358,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;Signature · 1 line
2.29.2.729.g45daf8777d-goog