Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Feb 1997 07:21:35 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        hackers@freebsd.org, hans@brandinnovators.com
Subject:   Re: tunnel device and SIGIO weirdness
Message-ID:  <199701312021.HAA30173@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>As I ran into something that looks like missing or late arrival of
>SIGIOs I decided to take a closer look at how SIGIOs are delivered:
>
>	[net/if_tun.c]
>	if (tp->tun_flags & TUN_ASYNC && tp->tun_pgrp) {
>		if (tp->tun_pgrp > 0)
>			gsignal(tp->tun_pgrp, SIGIO);
>		else if (p = pfind(-tp->tun_pgrp))
>			psignal(p, SIGIO);
>	}

>As far as I can see is the delivery of SIGIOs in the tunnel driver
>wrong.  The `... && tp->tun_pgrp) { if (tp->tun_pgrp > 0) ...' looks
>redundant or in error.  Can someone enlighten me?  Thanks in advance,

I think it just uses a different sign convention.  The bugs are probably
in the initialization of tp->tun_pgrp.  The FSETOWN ioctl has many bugs.
It is documented to apply to files, but it actually applies to the
underlying sockets or devices.  It works better for sockets because
fcntl() knows too much about sockets and initializes the socket directly
without checking anything.  This makes it easy to initialize the pgid
to any process id or any process group id (including ones that don't
exist and ones that you don't have permission to send signals to :-().
For non-sockets, it converts positive pgid's to the process group id, so
it is impossible to send SIGIO to single processes and the (tp->tun_pgrp
< 0) code is unreachable.  It is more broken for ttys.  For ttys, the
ASYNC pgrp must match the POSIX pgrp it it's often inconvenient to set
up a POSIX pgrp.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701312021.HAA30173>