Skip to content

Commit 049439e

Browse files
nbouchinet-anssiJoelgranados
authored andcommitted
coredump: Fixes core_pipe_limit sysctl proc_handler
proc_dointvec converts a string to a vector of signed int, which is stored in the unsigned int .data core_pipe_limit. It was thus authorized to write a negative value to core_pipe_limit sysctl which once stored in core_pipe_limit, leads to the signed int dump_count check against core_pipe_limit never be true. The same can be achieved with core_pipe_limit set to INT_MAX. Any negative write or >= to INT_MAX in core_pipe_limit sysctl would hypothetically allow a user to create very high load on the system by running processes that produces a coredump in case the core_pattern sysctl is configured to pipe core files to user space helper. Memory or PID exhaustion should happen before but it anyway breaks the core_pipe_limit semantic. This commit fixes this by changing core_pipe_limit sysctl's proc_handler to proc_dointvec_minmax and bound checking between SYSCTL_ZERO and SYSCTL_INT_MAX. Fixes: a293980 ("exec: let do_coredump() limit the number of concurrent dumps to pipes") Signed-off-by: Nicolas Bouchinet <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent dccf3c9 commit 049439e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/coredump.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,9 @@ static const struct ctl_table coredump_sysctls[] = {
10151015
.data = &core_pipe_limit,
10161016
.maxlen = sizeof(unsigned int),
10171017
.mode = 0644,
1018-
.proc_handler = proc_dointvec,
1018+
.proc_handler = proc_dointvec_minmax,
1019+
.extra1 = SYSCTL_ZERO,
1020+
.extra2 = SYSCTL_INT_MAX,
10191021
},
10201022
{
10211023
.procname = "core_file_note_size_limit",

0 commit comments

Comments
 (0)