libc blocking functions/with_libc inside thread

Christian Helmuth christian.helmuth at ...1...
Mon Jun 26 16:17:31 CEST 2017


Hello Boris,

On Mon, Jun 26, 2017 at 02:46:08PM +0200, Boris Mulder wrote:
> Actually the OpenVPN code hangs once it calls the libc socket()
> function. Internally, this function calls a blocking write(), and this
> write() is handled by Libc::Kernel.

thanks to your provided test case and the hint with "blocking write" I
was able to validate my suspicion about the blocker in your scenario.
A rough sketch of my solution can be found here

  https://github.com/chelmuth/genode/commits/openvpn_17.05.

The issue is the unfortunate interplay of I/O-signal handling in the
initial entrypoint and the current implementation of the VFS plugin,
which interfaces with our file-system session. In the case of
"blocking write" the VFS plugin calls
wait_and_dispatch_one_io_signal() directly on the initial entrypoint.
In your scenario this results in the initial-entrypoint thread and the
OpenVPN thread racing on the handling of first I/O signal. As the
entrypoint always wins, the OpenVPN thread is blocked until another
I/O signal occurs (which may never happen in the startup phase).

The sketched solution just reverses the roles of the first and second
application thread. Now, the initial entrypoint implements OpenVPN
(handling its own I/O signals) and the additional entrypoint
implements the NIC server (with root and session component).

I hope this helps.

Greets
-- 
Christian Helmuth
Genode Labs

https://www.genode-labs.com/ · https://genode.org/
https://twitter.com/GenodeLabs · /ˈdʒiː.nəʊd/

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth

> So openVPN does not send or receive any packet yet as it is blocked at
> socket().
> 
> Earlier, we have used lwip as a socket library. When we did that,
> socket() (and connect() in TCP mode) did work, but it failed to send any
> initial data to the server, likewise blocking on some function.
> 
> We are reaching the limit of our knowledge of genode libc and the
> side-effects of the asynchronous entrypoint. At this point our debugging
> went down into the libc kernel and there is a limit how deep we can go.
> Help on this topic would be appreciated.
> 
> We uploaded the new 17.05 ready code of openVPN (including a run script
> which can be run through make run/openvpn) onto
> https://github.com/nlcsl/genode/tree/openvpn_17.05 .
> 
> If you have the time, could you try to run it and see if it is possible
> to let it produce a single UDP packet? For this, it is not necessary to
> setup a server. From there, we could pick it up again.
> 
> We appreciate it,
> 
> Boris
> 
> 
> On 26-06-17 10:57, Christian Helmuth wrote:
> > Hello Boris,
> >
> > On Fri, Jun 23, 2017 at 03:59:53PM +0200, Boris Mulder wrote:
> >> The entrypoint creates the root component, spawns the thread and
> >> returns. It will then handle RPC requests, as entrypoints do IIRC.
> >>
> >> The program acts as a server (serving Nic sessions asynchronously) and
> >> as a client to lxip vfs with libc. the code can be found in [1].
> >>
> >> How can I have the entrypoint handle I/O signals in libc while also
> >> being able to serve clients in Genode?
> > This should happen automatically under the hood as libc processes
> > signals in ordinary I/O signal handlers in the entrypoint.
> >
> > Are you able to run the scenario under linux and inspect the
> > processing of both threads via GDB? I fear that I cannot help with
> > specifics of OpenVPN, but may guide with more details about the
> > blocking situation. It may be interesting to know if any network
> > packets reach the OpenVPN code.
> >
> > Greets
> 
> -- 
> 
> Met vriendelijke groet / kind regards,
> 
> Boris Mulder
> 
> Cyber Security Labs B.V. | Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
> +31 35 631 3253 (office)
> 
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> genode-main mailing list
> genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main




More information about the users mailing list