All of lore.kernel.org
 help / color / mirror / Atom feed
* possible ERESTARTNOHAND leak into userspace
@ 2011-12-23 13:11 Michal Hocko
  2011-12-23 15:02 ` Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2011-12-23 13:11 UTC (permalink / raw)
  To: LKML
  Cc: Anders Johansson, David Miller, Linus Torvalds, Neil Horman,
	Oleg Nesterov

Hi,
this has already been discussed few years back with reports that select
returned with ERESTARTNOHAND in multi-threaded applications
(http://forum.soft32.com/linux/PATCH-select-fix-sys_select-leak-ERESTARTNOHAND-userspace-ftopict338572.html)

Dave has come up with a possible explanation of the race but there was
no further follow up with a conclusion.

Just for reference:
        Thread_A				Thread_B
	CPU0					CPU1
						syscall_XYZ
core_sys_select				
  ret = -ERESTARTNOHAND;
  if (signal_pending(current))
     					do_notify_resume
     					  do_signal (clear signal pending)
  return ret;
return from syscall
no pending signal
return ERESTARTNOHAND

The race window is rather small and hard to trigger but we have seen
reports where people really saw select returning ERESTARTNOHAND (on
2.6.16 based kernel - x86_64).
I am not able to reproduce that myself neither with .16 kernel nor with
the current vanilla so I am not sure whether the problem has been fixed
already. But I do not see what prevents the race with vanilla.

Is the issue real and fixable?

Thanks
-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: possible ERESTARTNOHAND leak into userspace
  2011-12-23 13:11 possible ERESTARTNOHAND leak into userspace Michal Hocko
@ 2011-12-23 15:02 ` Oleg Nesterov
  2011-12-23 16:16   ` Michal Hocko
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2011-12-23 15:02 UTC (permalink / raw)
  To: Michal Hocko
  Cc: LKML, Anders Johansson, David Miller, Linus Torvalds, Neil Horman

On 12/23, Michal Hocko wrote:
>
> Hi,
> this has already been discussed few years back with reports that select
> returned with ERESTARTNOHAND in multi-threaded applications
> (http://forum.soft32.com/linux/PATCH-select-fix-sys_select-leak-ERESTARTNOHAND-userspace-ftopict338572.html)
>
> Dave has come up with a possible explanation of the race but there was
> no further follow up with a conclusion.
>
> Just for reference:
>         Thread_A				Thread_B
> 	CPU0					CPU1
> 						syscall_XYZ
> core_sys_select
>   ret = -ERESTARTNOHAND;
>   if (signal_pending(current))
>      					do_notify_resume
>      					  do_signal (clear signal pending)

"clear signal pending" can't affect Thread_A. Even if it steals
the signal sent to Thread_A.

>   return ret;
> return from syscall
> no pending signal

please see above. Only the task itself can clear its TIF_DIGPENDING.

> return ERESTARTNOHAND

do_signal() should take care and restart the syscall.

> The race window is rather small and hard to trigger but we have seen
> reports where people really saw select returning ERESTARTNOHAND (on
> 2.6.16 based kernel - x86_64).
> I am not able to reproduce that myself neither with .16 kernel nor with
> the current vanilla so I am not sure whether the problem has been fixed
> already. But I do not see what prevents the race with vanilla.

I hope the problem was already fixed, at least I do not see anything
wrong in core_sys_select().

Oleg.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: possible ERESTARTNOHAND leak into userspace
  2011-12-23 15:02 ` Oleg Nesterov
@ 2011-12-23 16:16   ` Michal Hocko
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2011-12-23 16:16 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: LKML, Anders Johansson, David Miller, Linus Torvalds, Neil Horman

On Fri 23-12-11 16:02:27, Oleg Nesterov wrote:
> On 12/23, Michal Hocko wrote:
> >
> > Hi,
> > this has already been discussed few years back with reports that select
> > returned with ERESTARTNOHAND in multi-threaded applications
> > (http://forum.soft32.com/linux/PATCH-select-fix-sys_select-leak-ERESTARTNOHAND-userspace-ftopict338572.html)
> >
> > Dave has come up with a possible explanation of the race but there was
> > no further follow up with a conclusion.
> >
> > Just for reference:
> >         Thread_A				Thread_B
> > 	CPU0					CPU1
> > 						syscall_XYZ
> > core_sys_select
> >   ret = -ERESTARTNOHAND;
> >   if (signal_pending(current))
> >      					do_notify_resume
> >      					  do_signal (clear signal pending)
> 
> "clear signal pending" can't affect Thread_A. Even if it steals
> the signal sent to Thread_A.

Ah, I have totally missed that signal_pending is thread local.

[...]
> > The race window is rather small and hard to trigger but we have seen
> > reports where people really saw select returning ERESTARTNOHAND (on
> > 2.6.16 based kernel - x86_64).
> > I am not able to reproduce that myself neither with .16 kernel nor with
> > the current vanilla so I am not sure whether the problem has been fixed
> > already. But I do not see what prevents the race with vanilla.
> 
> I hope the problem was already fixed, at least I do not see anything
> wrong in core_sys_select().

And core_sys_select is basically same in 2.6.16 som I am still wondering
how we could leak the value.

Anyway this seems to be a .16 specific issue, sorry about the noise.

> 
> Oleg.
> 

Thanks a lot for the response.
-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-23 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-23 13:11 possible ERESTARTNOHAND leak into userspace Michal Hocko
2011-12-23 15:02 ` Oleg Nesterov
2011-12-23 16:16   ` Michal Hocko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.