Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14200

Bash-4.4 Official Patch 20

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Bash-4.4 Official Patch 20
Date Fri, 1 Jun 2018 14:45:47 -0400
Lines 183
Sender Chet Ramey <chet@caleb.ins.cwru.edu>
Approved bug-bash@gnu.org
Message-ID <mailman.953.1527878781.1292.bug-bash@gnu.org> (permalink)
Reply-To chet.ramey@case.edu
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1527878782 23443 208.118.235.17 (1 Jun 2018 18:46:22 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
Read-Receipt-To chet.ramey@case.edu
X-Junkmail-Status score=8/90, host=mpv3-2015.case.edu
X-Junkmail-PrAS-Raw score=8/90, refid=2.7.2:2018.6.1.174216:17:8.317, ip=, rules=DATE_TZ_NA, __HAS_FROM, FROM_EDU_TLD, __TO_MALFORMED_2, __TO_NO_NAME, __HAS_CC_HDR, __HAS_REPLYTO, __HAS_MSGID, __SANE_MSGID, __MIME_VERSION, __CT, __CT_TEXT_PLAIN, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1, __REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH, URI_ENDS_IN_HTML, __URI_NO_WWW, __STOCK_PHRASE_24, __CP_URI_IN_BODY, __FRAUD_MONEY_BIG_COIN_DIG, BODY_PARA_IS_SENTENCE_URL, __SUBJ_ALPHA_NEGATE, __MULTIPLE_URI_TEXT, __URI_IN_BODY, __URI_NOT_IMG, __NO_HTML_TAG_RAW, BODY_SIZE_5000_5999, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_BIG_COIN, __FROM_DOMAIN_IN_RCPT, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, __PHISH_SPEAR_STRUCTURE_1, __MIME_TEXT_P, REPLYTO_SAMEAS_FROM, NO_URI_HTTPS, BODY_SIZE_7000_LESS, URI_WITH_PATH_ONLY, so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy]
X-Received-From 129.22.103.194
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14200

Show key headers only | View raw


			     BASH PATCH REPORT
			     =================

Bash-Release:	4.4
Patch-ID:	bash44-020

Bug-Reported-by:	Graham Northup <northug@clarkson.edu>
Bug-Reference-ID:	<537530c3-61f0-349b-9de6-fa4e2487f428@clarkson.edu>
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2017-02/msg00025.html

Bug-Description:

In circumstances involving long-running scripts that create and reap many
processes, it is possible for the hash table bash uses to store exit
statuses from asynchronous processes to develop loops. This patch fixes
the loop causes and adds code to detect any future loops.

Patch (apply with `patch -p0'):

*** ../bash-4.4-patched/jobs.c	2016-11-11 13:42:55.000000000 -0500
--- jobs.c	2017-02-22 15:16:28.000000000 -0500
***************
*** 813,818 ****
    struct pidstat *ps;
  
!   bucket = pshash_getbucket (pid);
!   psi = bgp_getindex ();
    ps = &bgpids.storage[psi];
  
--- 796,815 ----
    struct pidstat *ps;
  
!   /* bucket == existing chain of pids hashing to same value
!      psi = where were going to put this pid/status */
! 
!   bucket = pshash_getbucket (pid);	/* index into pidstat_table */
!   psi = bgp_getindex ();		/* bgpids.head, index into storage */
! 
!   /* XXX - what if psi == *bucket? */
!   if (psi == *bucket)
!     {
! #ifdef DEBUG
!       internal_warning ("hashed pid %d (pid %d) collides with bgpids.head, skipping", psi, pid);
! #endif
!       bgpids.storage[psi].pid = NO_PID;		/* make sure */
!       psi = bgp_getindex ();			/* skip to next one */
!     }
! 
    ps = &bgpids.storage[psi];
  
***************
*** 842,845 ****
--- 839,843 ----
  {
    struct pidstat *ps;
+   ps_index_t *bucket;
  
    ps = &bgpids.storage[psi];
***************
*** 847,856 ****
      return;
  
!   if (ps->bucket_next != NO_PID)
      bgpids.storage[ps->bucket_next].bucket_prev = ps->bucket_prev;
!   if (ps->bucket_prev != NO_PID)
      bgpids.storage[ps->bucket_prev].bucket_next = ps->bucket_next;
    else
!     *(pshash_getbucket (ps->pid)) = ps->bucket_next;
  }
  
--- 845,861 ----
      return;
  
!   if (ps->bucket_next != NO_PIDSTAT)
      bgpids.storage[ps->bucket_next].bucket_prev = ps->bucket_prev;
!   if (ps->bucket_prev != NO_PIDSTAT)
      bgpids.storage[ps->bucket_prev].bucket_next = ps->bucket_next;
    else
!     {
!       bucket = pshash_getbucket (ps->pid);
!       *bucket = ps->bucket_next;	/* deleting chain head in hash table */
!     }
! 
!   /* clear out this cell, just in case */
!   ps->pid = NO_PID;
!   ps->bucket_next = ps->bucket_prev = NO_PIDSTAT;
  }
  
***************
*** 859,863 ****
       pid_t pid;
  {
!   ps_index_t psi;
  
    if (bgpids.storage == 0 || bgpids.nalloc == 0 || bgpids.npid == 0)
--- 864,868 ----
       pid_t pid;
  {
!   ps_index_t psi, orig_psi;
  
    if (bgpids.storage == 0 || bgpids.nalloc == 0 || bgpids.npid == 0)
***************
*** 865,871 ****
  
    /* Search chain using hash to find bucket in pidstat_table */
!   for (psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
!     if (bgpids.storage[psi].pid == pid)
!       break;
  
    if (psi == NO_PIDSTAT)
--- 870,883 ----
  
    /* Search chain using hash to find bucket in pidstat_table */
!   for (orig_psi = psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
!     {
!       if (bgpids.storage[psi].pid == pid)
! 	break;
!       if (orig_psi == bgpids.storage[psi].bucket_next)	/* catch reported bug */
! 	{
! 	  internal_warning ("bgp_delete: LOOP: psi (%d) == storage[psi].bucket_next", psi);
! 	  return 0;
! 	}
!     }
  
    if (psi == NO_PIDSTAT)
***************
*** 905,909 ****
       pid_t pid;
  {
!   ps_index_t psi;
  
    if (bgpids.storage == 0 || bgpids.nalloc == 0 || bgpids.npid == 0)
--- 917,921 ----
       pid_t pid;
  {
!   ps_index_t psi, orig_psi;
  
    if (bgpids.storage == 0 || bgpids.nalloc == 0 || bgpids.npid == 0)
***************
*** 911,917 ****
  
    /* Search chain using hash to find bucket in pidstat_table */
!   for (psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
!     if (bgpids.storage[psi].pid == pid)
!       return (bgpids.storage[psi].status);
  
    return -1;
--- 923,936 ----
  
    /* Search chain using hash to find bucket in pidstat_table */
!   for (orig_psi = psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
!     {
!       if (bgpids.storage[psi].pid == pid)
! 	return (bgpids.storage[psi].status);
!       if (orig_psi == bgpids.storage[psi].bucket_next)	/* catch reported bug */
! 	{
! 	  internal_warning ("bgp_search: LOOP: psi (%d) == storage[psi].bucket_next", psi);
! 	  return -1;
! 	}
!     }
  
    return -1;
*** ../bash-4.4/patchlevel.h	2016-06-22 14:51:03.000000000 -0400
--- patchlevel.h	2016-10-01 11:01:28.000000000 -0400
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 19
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 20
  
  #endif /* _PATCHLEVEL_H_ */

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Bash-4.4 Official Patch 20 Chet Ramey <chet.ramey@case.edu> - 2018-06-01 14:45 -0400

csiph-web