From owner-freebsd-hackers Fri Jan 31 12:26:12 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id MAA10249 for hackers-outgoing; Fri, 31 Jan 1997 12:26:12 -0800 (PST) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id MAA10244 for ; Fri, 31 Jan 1997 12:26:09 -0800 (PST) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.3/8.6.9) id HAA30173; Sat, 1 Feb 1997 07:21:35 +1100 Date: Sat, 1 Feb 1997 07:21:35 +1100 From: Bruce Evans Message-Id: <199701312021.HAA30173@godzilla.zeta.org.au> To: hackers@freebsd.org, hans@brandinnovators.com Subject: Re: tunnel device and SIGIO weirdness Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >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