freebsd-dev/bin/sh
Jilles Tjoelker 6bc7175f31 sh: Fix double INTON with vfork
The shell maintains a count of the number of times SIGINT processing has
been disabled via INTOFF, so SIGINT processing resumes when all disables
have enabled again (INTON).

If an error occurs in a vfork() child, the processing of the error enables
SIGINT processing again, and the INTON in vforkexecshell() causes the count
to become negative.

As a result, a later INTOFF may not actually disable SIGINT processing. This
might cause memory corruption if a SIGINT arrives at an inopportune time. As
of r360452, it causes the shell to abort when it would unsafely allocate or
free memory in certain ways.

Note that various places such as errors in non-special builtins
unconditionally reset the count to 0, so the problem might still not always
be visible.

PR:		246497
Reported by:	jbeich
MFC after:	2 weeks
2020-05-16 16:29:23 +00:00
..
bltin General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
funcs Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
tests sh: Fix double INTON with vfork 2020-05-16 16:29:23 +00:00
alias.c sh: Fix use after free when resetting an in-use alias. 2017-04-16 22:10:02 +00:00
alias.h Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
arith_yacc.c sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) 2019-02-10 22:23:05 +00:00
arith_yacc.h sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) 2019-02-10 22:23:05 +00:00
arith_yylex.c sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) 2019-02-10 22:23:05 +00:00
arith.h sh: Remove unused function declaration for arith_lex_reset(). 2017-03-18 20:41:07 +00:00
builtins.def sh: Remove remnants to compile out fc completely 2020-04-22 21:45:43 +00:00
cd.c sh: Fix rare memory leak with SIGINT 2020-01-01 12:06:37 +00:00
cd.h Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
dot.profile Install .shrc for root, and set PS1 for the toor account. 2019-01-24 23:34:51 +00:00
dot.shrc Comment out the default sh(1) aliases for root, introduced in r343416. 2019-01-25 17:09:26 +00:00
error.c sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
error.h sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
eval.c sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
eval.h Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
exec.c sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
exec.h sh: Use exitstatus instead of exerrno to pass EXEXEC status 2018-10-27 20:17:57 +00:00
expand.c sh: Fix ${param?} default error message 2018-11-28 20:03:53 +00:00
expand.h Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
histedit.c Fix build with NO_HISTORY set 2020-04-21 00:37:55 +00:00
input.c sh: remove duplicate el definition 2020-03-28 17:02:32 +00:00
input.h Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
jobs.c sh: Fix double INTON with vfork 2020-05-16 16:29:23 +00:00
jobs.h sh: Move various structs from jobs.h to jobs.c 2018-01-01 22:31:52 +00:00
mail.c sh: Don't use padvance() for MAIL/MAILPATH 2018-07-15 09:14:30 +00:00
mail.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
main.c sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
main.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
Makefile Bump WARNS for sh(1). 2020-04-01 15:12:51 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
memalloc.c sh: Assert INTOFF rather than applying it in ck* 2020-04-28 20:34:27 +00:00
memalloc.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
miscbltin.c [sh] Fix a "may be unused" warning on mips-gcc 2020-04-16 23:31:39 +00:00
mkbuiltins sh: Remove remnants to compile out fc completely 2020-04-22 21:45:43 +00:00
mknodes.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
mksyntax.c sh: Split CNL syntax category to avoid a check on state[level].syntax 2018-05-21 21:52:48 +00:00
mktokens Don't hardcode /usr/bin as the path for mktemp in build tools 2018-02-06 15:41:35 +00:00
myhistedit.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
mystring.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
mystring.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
nodes.c.pat Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
nodetypes Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
options.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
options.h sh: Add set -o pipefail 2019-02-24 21:05:13 +00:00
output.c sh: Send normal output from bind builtin to stdout 2019-02-19 21:27:30 +00:00
output.h sh: Send normal output from bind builtin to stdout 2019-02-19 21:27:30 +00:00
parser.c Make sh(1) support \u in PS1. This removes one fork/exec on interactive 2019-01-24 11:59:46 +00:00
parser.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
profile Don't mess with BLOCKSIZE in shell startup files - it's set by login.conf(5); 2019-01-20 22:08:49 +00:00
redir.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
redir.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
sh.1 sh: Add set -o pipefail 2019-02-24 21:05:13 +00:00
shell.h sh: Restore $((x)) error checking after fix for $((-9223372036854775808)) 2019-02-10 22:23:05 +00:00
show.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
show.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
TOUR sh: Unify EXERROR and EXEXEC 2018-11-09 14:58:24 +00:00
trap.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
trap.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
var.c sh: Do not place exported but unset variables into the environment 2019-01-03 20:22:35 +00:00
var.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00