svn commit: r361646 - in stable/12/bin/sh: . tests/execution
Jilles Tjoelker
jilles at FreeBSD.org
Sat May 30 13:39:57 UTC 2020
Author: jilles
Date: Sat May 30 13:39:56 2020
New Revision: 361646
URL: https://svnweb.freebsd.org/changeset/base/361646
Log:
MFC r361112,r361117: 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.
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
Added:
- copied unchanged from r361112, head/bin/sh/tests/execution/unknown2.0
Directory Properties:
stable/12/bin/sh/tests/execution/unknown2.0 (props changed)
Modified:
stable/12/bin/sh/jobs.c
stable/12/bin/sh/tests/execution/Makefile
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/bin/sh/jobs.c
==============================================================================
--- stable/12/bin/sh/jobs.c Sat May 30 02:56:13 2020 (r361645)
+++ stable/12/bin/sh/jobs.c Sat May 30 13:39:56 2020 (r361646)
@@ -1007,9 +1007,11 @@ vforkexecshell(struct job *jp, char **argv, char **env
pid_t pid;
struct jmploc jmploc;
struct jmploc *savehandler;
+ int inton;
TRACE(("vforkexecshell(%%%td, %s, %p) called\n", jp - jobtab, argv[0],
(void *)pip));
+ inton = is_int_on();
INTOFF;
flushall();
savehandler = handler;
@@ -1044,7 +1046,7 @@ vforkexecshell(struct job *jp, char **argv, char **env
setcurjob(jp);
#endif
}
- INTON;
+ SETINTON(inton);
TRACE(("In parent shell: child = %d\n", (int)pid));
return pid;
}
Modified: stable/12/bin/sh/tests/execution/Makefile
==============================================================================
--- stable/12/bin/sh/tests/execution/Makefile Sat May 30 02:56:13 2020 (r361645)
+++ stable/12/bin/sh/tests/execution/Makefile Sat May 30 13:39:56 2020 (r361646)
@@ -59,6 +59,7 @@ ${PACKAGE}FILES+= subshell2.0
${PACKAGE}FILES+= subshell3.0
${PACKAGE}FILES+= subshell4.0
${PACKAGE}FILES+= unknown1.0
+${PACKAGE}FILES+= unknown2.0
${PACKAGE}FILES+= var-assign1.0
.include <bsd.test.mk>
Copied: stable/12/bin/sh/tests/execution/unknown2.0 (from r361112, head/bin/sh/tests/execution/unknown2.0)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/12/bin/sh/tests/execution/unknown2.0 Sat May 30 13:39:56 2020 (r361646, copy of r361112, head/bin/sh/tests/execution/unknown2.0)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+{
+ : $(/var/empty/nosuchtool)
+ : $(:)
+} 2>/dev/null
More information about the svn-src-all
mailing list