]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sh: Fix double INTON with vfork
authorjilles <jilles@FreeBSD.org>
Sat, 16 May 2020 16:29:23 +0000 (16:29 +0000)
committerjilles <jilles@FreeBSD.org>
Sat, 16 May 2020 16:29:23 +0000 (16:29 +0000)
commitf4b455ec720506901d3b6698192fcaadb57045bb
tree4ade7aafa8cb1c0b70d280f17fc250a21b9a5f72
parent9cbc80006f86da06ce9d5039e4b26c9ad160cbbf
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
bin/sh/jobs.c
bin/sh/tests/execution/Makefile
bin/sh/tests/execution/unknown2.0 [new file with mode: 0644]