[PATCH][BZ #12847] dprintf/vdprintf can cause fork to fail (child process crash)

Rich Felker dalias@aerifal.cx
Sat Feb 8 04:53:00 GMT 2014


On Sat, Sep 21, 2013 at 09:13:46PM +0200, Ondřej Bílka wrote:
> Hi,
> 
> This bug has a simple patch from Frank Reker in bugzilla, see
> http://sourceware.org/bugzilla/show_bug.cgi?id=12847
> 
> Is it ok to commit or is cause somewhere else?
> One possibility would be adding null check to _IO_lock_init.
> 
> 2013-09-21  Frank Reker <frekel@zes.com>
> 
> 	* nptl/sysdeps/unix/sysv/linux/fork.c (fresetlockfiles): Handle
> 	case when lock is NULL.
> 
> ---
>  nptl/sysdeps/unix/sysv/linux/fork.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/nptl/sysdeps/unix/sysv/linux/fork.c b/nptl/sysdeps/unix/sysv/linux/fork.c
> index ff08942..9704593 100644
> --- a/nptl/sysdeps/unix/sysv/linux/fork.c
> +++ b/nptl/sysdeps/unix/sysv/linux/fork.c
> @@ -45,7 +45,8 @@ fresetlockfiles (void)
>    _IO_ITER i;
>  
>    for (i = _IO_iter_begin(); i != _IO_iter_end(); i = _IO_iter_next(i))
> -    _IO_lock_init (*((_IO_lock_t *) _IO_iter_file(i)->_lock));
> +    if (_IO_iter_file(i)->_lock) 
> +      _IO_lock_init (*((_IO_lock_t *) _IO_iter_file(i)->_lock));
>  }

Perhaps this has been said before, but I'm replying because of the
latest ping: the above patch is not a correct fix. The problem is that
these FILEs are being added to the list at all. Fixing this bug should
be a "100% - lines" diff that removes the code from dprintf that's
adding its temporary FILE to the list; I wouldn't be surprised if it's
an exact revert of some historical commit, but I haven't looked up the
history.

Rich



More information about the Libc-alpha mailing list