Skip to content

Commit e74cb9e

Browse files
cyrillosgregkh
authored andcommitted
kernel/sys.c: prctl: fix false positive in validate_prctl_map()
[ Upstream commit a9e7399 ] While validating new map we require the @start_data to be strictly less than @end_data, which is fine for regular applications (this is why this nit didn't trigger for that long). These members are set from executable loaders such as elf handers, still it is pretty valid to have a loadable data section with zero size in file, in such case the start_data is equal to end_data once kernel loader finishes. As a result when we're trying to restore such programs the procedure fails and the kernel returns -EINVAL. From the image dump of a program: | "mm_start_code": "0x400000", | "mm_end_code": "0x8f5fb4", | "mm_start_data": "0xf1bfb0", | "mm_end_data": "0xf1bfb0", Thus we need to change validate_prctl_map from strictly less to less or equal operator use. Link: http://lkml.kernel.org/r/[email protected] Fixes: f606b77 ("prctl: PR_SET_MM -- introduce PR_SET_MM_MAP operation") Signed-off-by: Cyrill Gorcunov <[email protected]> Cc: Andrey Vagin <[email protected]> Cc: Dmitry Safonov <[email protected]> Cc: Pavel Emelyanov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5dd3345 commit e74cb9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ static int validate_prctl_map(struct prctl_mm_map *prctl_map)
17621762
((unsigned long)prctl_map->__m1 __op \
17631763
(unsigned long)prctl_map->__m2) ? 0 : -EINVAL
17641764
error = __prctl_check_order(start_code, <, end_code);
1765-
error |= __prctl_check_order(start_data, <, end_data);
1765+
error |= __prctl_check_order(start_data,<=, end_data);
17661766
error |= __prctl_check_order(start_brk, <=, brk);
17671767
error |= __prctl_check_order(arg_start, <=, arg_end);
17681768
error |= __prctl_check_order(env_start, <=, env_end);

0 commit comments

Comments
 (0)