Don't touch user-controlled stdio locks in forked child
diff mbox

Message ID mvm61djvkep.fsf@hawking.suse.de
State New
Headers show

Commit Message

Andreas Schwab Dec. 10, 2014, 11:01 a.m. UTC
The stdio locks for streams with the _IO_USER_LOCK flag should not be
touched by internal code.

Andreas.

	[BZ #12847]
	* sysdeps/nptl/fork.c (fresetlockfiles): Skip files with
	user-controlled locks.
---
 sysdeps/nptl/fork.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ondřej Bílka Dec. 10, 2014, 1:13 p.m. UTC | #1
On Wed, Dec 10, 2014 at 12:01:02PM +0100, Andreas Schwab wrote:
> The stdio locks for streams with the _IO_USER_LOCK flag should not be
> touched by internal code.
>
ok for me.
 
> Andreas.
> 
> 	[BZ #12847]
> 	* sysdeps/nptl/fork.c (fresetlockfiles): Skip files with
> 	user-controlled locks.
> ---
>  sysdeps/nptl/fork.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
> index a7dafa8..7ef693d 100644
> --- a/sysdeps/nptl/fork.c
> +++ b/sysdeps/nptl/fork.c
> @@ -46,7 +46,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)->_flags & _IO_USER_LOCK) == 0)
> +      _IO_lock_init (*((_IO_lock_t *) _IO_iter_file(i)->_lock));
>  }
>  
>  
> -- 
> 2.2.0
> 
> -- 
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."

Patch
diff mbox

diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
index a7dafa8..7ef693d 100644
--- a/sysdeps/nptl/fork.c
+++ b/sysdeps/nptl/fork.c
@@ -46,7 +46,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)->_flags & _IO_USER_LOCK) == 0)
+      _IO_lock_init (*((_IO_lock_t *) _IO_iter_file(i)->_lock));
 }