NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/46523: kqueue descriptors can not be passed via SCM_RIGHTS anx. messages

>Number:         46523
>Category:       kern
>Synopsis:       kqueue descriptors can not be passed via SCM_RIGHTS anx. 
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 02 16:50:00 +0000 2012
>Originator:     Martin Husemann
>Release:        NetBSD 6.99.7
The NetBSD Foundation, Inc.
System: NetBSD 6.99.7 NetBSD 6.99.7 (MODULAR) #58: Sat 
Jun 2 18:10:22 CEST 2012
Architecture: sparc64
Machine: sparc64

As a stopgap fix for PR kern/46463, the passing of kqueue descriptors via
SCM_RIGHTS messages on sockets to other processes has been inhibited and
will fail with EBADF.

While kqueues where originally designed to be local process only, there seems
to be support for the idea to make them work with multiple processe. All
OSes implementing kqueue prevent inheritence of these descriptors on fork.

If consensus is to add this functionality, the kqueue implementation needs
changes, depending on the exact semantic definition of "shared" kqueues.

A use case for passing a kqueue descriptor would be a privileged process
setting up the kqueue, passing it to a non privileged child, which is supposed
to act on the events then.

The main semantic queustion is what happens if both processes sharing the same
kqueue keep adding events - are they effective in both processes? If so, there
needs to be a common knote queue for both descriptors. The current 
implementation has a filedesc_t *kq_fdp in struct kqueue, which points to the
p_fd pointer of the process which originally created the kqueue, and all
knotes are collected there. AFAICT it does not hold another refcount on
the filedesc_t though. Locking needs to be sorted out, and a few places
in kern_event.c use curlwp->l_fd, where (in the new world) kq->kq_fdp
should be used.

But first question to answer: do we realy want this all?


cd /usr/tests/lib/libc/sys && atf-run t_kevent | atf-report


Home | Main Index | Thread Index | Old Index