Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

execve: make responsive to SIGKILL with large arguments

An execve with a very large total of argument/environment strings
can take a really long time in the execve system call. It runs
uninterruptibly to count and copy all the strings. This change
makes it abort the exec quickly if sent a SIGKILL.

Note that this is the conservative change, to interrupt only for
SIGKILL, by using fatal_signal_pending(). It would be perfectly
correct semantics to let any signal interrupt the string-copying in
execve, i.e. use signal_pending() instead of fatal_signal_pending().
We'll save that change for later, since it could have user-visible
consequences, such as having a timer set too quickly make it so that
an execve can never complete, though it always happened to work before.

Signed-off-by: Roland McGrath <roland@redhat.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Roland McGrath and committed by
Linus Torvalds
9aea5a65 7993bc1f

+7
+7
fs/exec.c
··· 376 376 argv++; 377 377 if (i++ >= max) 378 378 return -E2BIG; 379 + 380 + if (fatal_signal_pending(current)) 381 + return -ERESTARTNOHAND; 379 382 cond_resched(); 380 383 } 381 384 } ··· 422 419 while (len > 0) { 423 420 int offset, bytes_to_copy; 424 421 422 + if (fatal_signal_pending(current)) { 423 + ret = -ERESTARTNOHAND; 424 + goto out; 425 + } 425 426 cond_resched(); 426 427 427 428 offset = pos % PAGE_SIZE;