mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alban Crequy <alban.crequy@collabora.co.uk>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: Vincent Sanders <vincent.sanders@collabora.co.uk>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: Re: [PATCH net-next 09/15] net: bus: Add garbage collector for AF_BUS sockets.
Date: Tue, 3 Jul 2012 13:11:26 +0100	[thread overview]
Message-ID: <20120703131126.79d0ea05@rainbow.cbg.collabora.co.uk> (raw)
In-Reply-To: <1341251063.2590.5.camel@bwh-desktop.uk.solarflarecom.com>

Mon, 2 Jul 2012 18:44:23 +0100,
Ben Hutchings <bhutchings@solarflare.com> wrote :

> On Fri, 2012-06-29 at 17:45 +0100, Vincent Sanders wrote:
> > From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> > 
> > This patch adds a garbage collector for AF_BUS sockets.
> [...]
> > +struct sock *bus_get_socket(struct file *filp)
> > +{
> > +	struct sock *u_sock = NULL;
> > +	struct inode *inode = filp->f_path.dentry->d_inode;
> > +
> > +	/*
> > +	 *	Socket ?
> > +	 */
> > +	if (S_ISSOCK(inode->i_mode) && !(filp->f_mode &
> > FMODE_PATH)) {
> > +		struct socket *sock = SOCKET_I(inode);
> > +		struct sock *s = sock->sk;
> > +
> > +		/*
> > +		 *	PF_BUS ?
> > +		 */
> > +		if (s && sock->ops && sock->ops->family == PF_BUS)
> > +			u_sock = s;
> > +	}
> > +	return u_sock;
> > +}
> [...]
> 
> What about references cycles involving both AF_BUS and AF_UNIX
> sockets? I think you must either specifically prevent passing AF_UNIX
> sockets through AF_BUS sockets, or make a single garbage collector
> handle them both.

Indeed. Thanks for the feedback.

As far as I know, the current users of fd passing in D-Bus are Bluez
and Ofono and they pass AF_BLUETOOTH sockets. There might be
others, I am not sure what is in the wild. Passing AF_UNIX sockets in
D-Bus would be useful for Telepathy (for Tubes and File Transfer).

So I would like to be able to pass AF_UNIX sockets through AF_BUS
sockets.

I wrote the following small program to test this bug based on the
previous code <https://lkml.org/lkml/2010/11/25/8> referred by commit
25888e30:
http://people.collabora.com/~alban/d/2012/07/fd-passing/cmsg.c

The effect of the bug is to reach the file limit
in /proc/sys/fs/file-max and print "VFS: file-max limit 101771 reached"
even when the maximum of file descriptors per process ("ulimit -n") is
small.

I am not sure what is the best way to fix this. The easiest could be to
move the garbage collector related fields (recursion_level,
gc_candidate, etc.) from struct unix_sock and struct bus_sock to
struct sock and make a generic garbage collector for all sockets.

Best regards,
Alban

  reply	other threads:[~2012-07-03 12:11 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29 16:45 AF_BUS socket address family Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 01/15] net: bus: Add " Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 02/15] net: bus: Add documentation for AF_BUS Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 03/15] net: bus: Add AF_BUS socket and address definitions Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 04/15] security: Add Linux Security Modules hook for AF_BUS sockets Vincent Sanders
2012-07-09  3:32   ` James Morris
2012-07-09 18:02   ` Paul Moore
2012-06-29 16:45 ` [PATCH net-next 05/15] security: selinux: Add AF_BUS socket SELinux hooks Vincent Sanders
2012-07-09 18:38   ` Paul Moore
2012-06-29 16:45 ` [PATCH net-next 06/15] netfilter: Add NFPROTO_BUS hook constant for AF_BUS socket family Vincent Sanders
2012-07-01  2:15   ` Jan Engelhardt
2012-06-29 16:45 ` [PATCH net-next 07/15] scm: allow AF_BUS sockets to send ancillary data Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 08/15] net: bus: Add implementation of Bus domain sockets Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 09/15] net: bus: Add garbage collector for AF_BUS sockets Vincent Sanders
2012-07-02 17:44   ` Ben Hutchings
2012-07-03 12:11     ` Alban Crequy [this message]
2012-06-29 16:45 ` [PATCH net-next 10/15] net: bus: Add the AF_BUS socket address family to KBuild Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 11/15] netlink: connector: implement cn_netlink_reply Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 12/15] netlink: connector: Add idx and val identifiers for netfilter D-Bus Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 13/15] netfilter: nfdbus: Add D-bus message parsing Vincent Sanders
2012-06-29 17:11   ` Pablo Neira Ayuso
2012-07-02 15:43     ` Javier Martinez Canillas
2012-07-04 17:30       ` Pablo Neira Ayuso
2012-07-05 17:54         ` Javier Martinez Canillas
2012-06-29 16:45 ` [PATCH net-next 14/15] netfilter: nfdbus: Add D-bus match rule implementation Vincent Sanders
2012-06-29 16:45 ` [PATCH net-next 15/15] netfilter: add netfilter D-Bus module Vincent Sanders
2012-06-29 18:16 ` AF_BUS socket address family Chris Friesen
2012-06-29 19:33   ` Ben Hutchings
2012-06-29 18:45 ` Casey Schaufler
2012-06-29 23:22   ` Vincent Sanders
2012-06-29 22:36 ` David Miller
2012-06-29 23:12   ` Vincent Sanders
2012-06-29 23:18     ` David Miller
2012-06-29 23:42       ` Vincent Sanders
2012-06-29 23:50         ` David Miller
2012-06-30  0:09           ` Vincent Sanders
2012-06-30 13:12           ` Alan Cox
2012-07-01  0:33             ` David Miller
2012-07-01 14:16               ` Alan Cox
2012-07-01 21:45                 ` David Miller
2012-06-30  0:13         ` Benjamin LaHaise
2012-06-30 12:52           ` Alan Cox
2012-07-02 14:51             ` Vincent Sanders
2012-07-02  4:49       ` Chris Friesen
2012-07-05 21:06     ` Jan Engelhardt
2012-07-06 18:27       ` Chris Friesen
2012-06-30 20:41 ` Hans-Peter Jansen
2012-07-02 16:46   ` Alban Crequy
2012-07-05  7:59 ` Linus Walleij
2012-07-05 16:01   ` Daniel Walker

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=20120703131126.79d0ea05@rainbow.cbg.collabora.co.uk \
    --to=alban.crequy@collabora.co.uk \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=javier.martinez@collabora.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vincent.sanders@collabora.co.uk \
    /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

all inboxes | Powered by JetHome®