From owner-svn-src-stable-12@freebsd.org Sat May 30 13:39:57 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A005C332C39; Sat, 30 May 2020 13:39:57 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49Z2cF3qFRz3gdm; Sat, 30 May 2020 13:39:57 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64352993D; Sat, 30 May 2020 13:39:57 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04UDdvW2083037; Sat, 30 May 2020 13:39:57 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04UDduTZ083034; Sat, 30 May 2020 13:39:56 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <202005301339.04UDduTZ083034@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sat, 30 May 2020 13:39:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r361646 - in stable/12/bin/sh: . tests/execution X-SVN-Group: stable-12 X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: in stable/12/bin/sh: . tests/execution X-SVN-Commit-Revision: 361646 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2020 13:39:57 -0000 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 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