mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 21:53:44 +00:00
mm: do_xip_mapping_read: fix length calculation
upstream commit: 58984ce21d
The calculation of the value nr in do_xip_mapping_read is incorrect. If
the copy required more than one iteration in the do while loop the copies
variable will be non-zero. The maximum length that may be passed to the
call to copy_to_user(buf+copied, xip_mem+offset, nr) is len-copied but the
check only compares against (nr > len).
This bug is the cause for the heap corruption Carsten has been chasing
for so long:
This commit is contained in:
parent
398e94c43b
commit
e655a1eaa9
@ -89,8 +89,8 @@ do_xip_mapping_read(struct address_space *mapping,
|
||||
}
|
||||
}
|
||||
nr = nr - offset;
|
||||
if (nr > len)
|
||||
nr = len;
|
||||
if (nr > len - copied)
|
||||
nr = len - copied;
|
||||
|
||||
error = mapping->a_ops->get_xip_mem(mapping, index, 0,
|
||||
&xip_mem, &xip_pfn);
|
||||
|
Loading…
Reference in New Issue
Block a user