NetBSD Problem Report #46523

From  Sat Jun  2 16:45:49 2012
Return-Path: <>
Received: from ( [])
	by (Postfix) with ESMTP id E503863BA27
	for <>; Sat,  2 Jun 2012 16:45:48 +0000 (UTC)
Message-Id: <>
Date: Sat,  2 Jun 2012 16:45:48 +0000 (UTC)
Subject: kqueue descriptors can not be passed via SCM_RIGHTS anx. messages
X-Send-Pr-Version: 3.95

>Number:         46523
>Category:       kern
>Synopsis:       kqueue descriptors can not be passed via SCM_RIGHTS anx. messages
>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 sparc64
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


NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.