On Sun, 2014-11-02 at 02:34 +0100, Christian Hofstaedtler wrote:
> * Ben Hutchings <b...@decadent.org.uk> [141101 14:02]:
> > On Sat, 2014-11-01 at 13:22 +0100, Christian Hofstaedtler wrote:
> > > * Ben Hutchings <b...@decadent.org.uk> [141101 06:26]:
> > > > On Sat, 2014-11-01 at 04:44 +0100, Christian Hofstaedtler wrote:
> > > > > I've tried to debug this a bit more tonight, and after a good 4
> > > > > hours there are two things I can report:
> > > > > 
> > > > > 1. with the default ruleset, udev leaks an ethtool socket to
> > > > > net.agent (and by extension to ifup, dhclient, ...)
> > > > 
> > > > This is a bug but probably harmless.  SIOCETHTOOL doesn't depend on any
> > > > socket state so it is normally used with an unconnected socket of an
> > > > arbitrary address family.
> > > 
> > > While it may be harmless from a security POV, the leaked FD causes
> > > the udev worker to hold on to the forked-away net.agent process.
> > 
> > How is that?
> 
> You're obviously correct; the extra FDs are red herrings.
> 
> dash "backs up" any FDs it redirects, so it can restore them
> later on. bash just closes them outright in this situation (forked
> subshell + parent exits), causing udev's spawn_read to immediately,
> thereby marking the udev event as finished.

That makes *much* more sense.

[...]
> I'd suggest the following patch, as a stop gap for sysvinit users:
> 
> Index: systemd-215/debian/extra/net.agent
> ===================================================================
> --- systemd-215.orig/debian/extra/net.agent     2014-09-27 17:50:52.000000000 
> +0200
> +++ systemd-215/debian/extra/net.agent  2014-11-02 02:33:40.970469131 +0100
> @@ -1,4 +1,4 @@
> -#!/bin/sh -e
> +#!/bin/bash -e
>  #
>  # run /sbin/{ifup,ifdown} with the --allow=hotplug option.
>  #
> @@ -100,9 +100,12 @@ esac
>  
>  }
>  
> -# When udev_log="debug" stdout and stderr are pipes connected to udevd.
> +# When udev_log="info" (default) or "debug", stdout and stderr are
> +# pipes connected to udevd.
>  # They need to be closed or udevd will wait for this process which will
>  # deadlock with udevsettle until the timeout.
> +# Note that this trick does not work under dash, which "backs up" any
> +# redirected FDs to FD 10 and higher.
>  do_everything > /dev/null 2> /dev/null &

This seems to work under both bash and dash:

exec > /dev/null 2> /dev/null
do_everything &

Ben.

>  exit 0
> 

-- 
Ben Hutchings
A free society is one where it is safe to be unpopular. - Adlai Stevenson

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to