mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: johnpol@2ka.mipt.ru
Cc: guillaume.thouvenin@bull.net, greg@kroah.com,
	linux-kernel@vger.kernel.org, elsa-devel@lists.sourceforge.net,
	gh@us.ibm.com, efocht@hpce.nec.com
Subject: Re: [PATCH 2.6.11-rc3-mm2] connector: Add a fork connector
Date: Wed, 23 Feb 2005 02:58:06 -0800	[thread overview]
Message-ID: <20050223025806.5a39f8fb.akpm@osdl.org> (raw)
In-Reply-To: <20050223140818.4261c4d0@zanzibar.2ka.mipt.ru>

Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:
>
> On Wed, 23 Feb 2005 01:07:47 -0800
> Andrew Morton <akpm@osdl.org> wrote:
> 
> > Guillaume Thouvenin <guillaume.thouvenin@bull.net> wrote:
> > >
> > > Hello,
> > > 
> > >   This patch replaces the relay_fork module and it implements a fork
> > > connector in the kernel/fork.c:do_fork() routine. The connector sends
> > > information about parent PID and child PID over a netlink interface. It
> > > allows to several user space applications to be informed when a fork
> > > occurs in the kernel. The main drawback is that even if nobody listens,
> > > message is send. I don't know how to avoid that.
> > 
> > We really should find a way to fix that.  Especially if we want all the
> > distributors to enable the connector in their builds (we do).
> 
> Mesage is never reached anyone if there are no listeners, skb will be just freed,
> even without any linking.
> do_one_broadcast() in net/netlink/af_netlink.c takes care of it.
> Unicast message also will be discarded in cn_rx_skb().

We should assume that there will always be listeners.  (why was the
connector thing added anyway?  Its changelog is pathetic).

> These operations are quite cheap - just link/unlink skb to/from appropriate
> queues.

Please assume that <whatever secret application the connector stuff was
originally written for> will always be listening.

> > What happened to the idea of sending an on/off message down the netlink
> > socket?
> 
> ?

All those emails I sent last week.

Arrange for the userspace daemon to send a message to the fork_connector
subsystem turning it on or off.  So we can bypass all this code in the
common case where <secret application> is listening, but your daemon is
not.

> > > +		if (msg) {
> > > +			memset(msg, '\0', size);
> > 
> > Do we really need to memset the whole thing?
> 
> Yes, to not leak kernel memory context.

How would we do that?  There are no gaps in the payload and we tell netlink
the exact length.

> > > +			memcpy(&msg->id, &fork_id, sizeof(msg->id));
> > > +			msg->seq = seq++;
> > 
> > `seq' needs a lock to protect it.  Or use atomic_add_return(), maybe.
> 
> Not necessary, I doubt fork userspace listener uses protocol described in
> connector.c and relies on seq field since it is not needed to have acks/replays.
> Although it can be used as a flag that it is new fork, but message itself
> is already such an event.

Without a lock you can have two messages with the same sequence number. 
Even if the daemon which you're planning on implementing can handle that,
we shouldn't allow it.


  reply	other threads:[~2005-02-23 10:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1108649153.8379.137.camel@frecb000711.frec.bull.fr>
2005-02-23  8:52 ` Guillaume Thouvenin
2005-02-23  9:07   ` Andrew Morton
2005-02-23 11:08     ` Evgeniy Polyakov
2005-02-23 10:58       ` Andrew Morton [this message]
2005-02-23 11:41         ` Evgeniy Polyakov
2005-02-24  6:41           ` Guillaume Thouvenin
2005-02-24  9:17             ` Evgeniy Polyakov
2005-02-17 14:55 Guillaume Thouvenin
2005-02-17 15:50 ` Evgeniy Polyakov
2005-02-21  7:07   ` Guillaume Thouvenin
2005-02-21  8:41     ` Evgeniy Polyakov
2005-02-21  9:47     ` Paul Jackson
2005-02-21 10:33       ` Guillaume Thouvenin
2005-02-21 11:58         ` Paul Jackson
2005-02-21 14:43           ` Guillaume Thouvenin
2005-02-21 16:55             ` Erich Focht
2005-02-21 17:54             ` Paul Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050223025806.5a39f8fb.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=efocht@hpce.nec.com \
    --cc=elsa-devel@lists.sourceforge.net \
    --cc=gh@us.ibm.com \
    --cc=greg@kroah.com \
    --cc=guillaume.thouvenin@bull.net \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome