Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alban Crequy <alban.crequy@collabora.co.uk>
Cc: "David S. Miller" <davem@davemloft.net>,
	Stephen Hemminger <shemminger@vyatta.com>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Lennart Poettering <lennart@poettering.net>,
	Kay Sievers <kay.sievers@vrfy.org>,
	Ian Molton <ian.molton@collabora.co.uk>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	dbus@freedesktop.org
Subject: Re: [PATCH 4/5] AF_UNIX: find peers on multicast Unix stream sockets
Date: Fri, 24 Sep 2010 20:00:37 +0200	[thread overview]
Message-ID: <1285351237.2478.7.camel@edumazet-laptop> (raw)
In-Reply-To: <1285349116-17529-4-git-send-email-alban.crequy@collabora.co.uk>

Le vendredi 24 septembre 2010 à 18:25 +0100, Alban Crequy a écrit :

> @@ -1612,7 +1671,12 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
>  	} else {
>  		sunaddr = NULL;
>  		err = -ENOTCONN;
> -		other = NULL; /* FIXME: get the list of other connection */
> +		max_others = atomic_read(&unix_nr_multicast_socks);
> +		others = kzalloc((max_others + 1) * sizeof(void *), GFP_KERNEL);
> +		unix_find_other(sock_net(sk), u->addr->name,
> +		    u->addr->len, 0, u->addr->hash, 1, others, max_others, &err);
> +		other = others[0];
> +		kfree(others);
>  		if (!other)
>  			goto out_err;
>  	}

Seriously, this block sizing against unix_nr_multicast_socks is not
scalable. What happens if we have 1000 sockets ?
kzalloc() to clear 8000 bytes ?
Its also unsafe.

(say you kzalloc() a buffer for 2 sockets, and another cpu inserts a new
socket. unix_find_socket_byname() can overflow the buffer)


You should use a list, and allocates elements in
unix_find_socket_byname()

struct item {
	struct item *next;
	struct sock *s;
};



  reply	other threads:[~2010-09-24 18:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100924182257.11abd9a6@chocolatine.cbg.collabora.co.uk>
2010-09-24 17:25 ` [PATCH 1/5] AF_UNIX: add getsockopt and setsockopt on stream sockets Alban Crequy
2010-09-24 17:25 ` [PATCH 2/5] AF_UNIX: enable/disable multicast with getsockopt/setsockopt Alban Crequy
2010-09-24 17:46   ` Eric Dumazet
2010-09-24 18:02     ` Eric Dumazet
2010-09-24 17:25 ` [PATCH 3/5] AF_UNIX: implement connect() on multicast Unix stream socket Alban Crequy
2010-09-24 17:25 ` [PATCH 4/5] AF_UNIX: find peers on multicast Unix stream sockets Alban Crequy
2010-09-24 18:00   ` Eric Dumazet [this message]
2010-09-30 19:24     ` Alban Crequy
2010-09-24 17:25 ` [PATCH 5/5] AF_UNIX: deliver the data to all the multicast peers Alban Crequy

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=1285351237.2478.7.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=alban.crequy@collabora.co.uk \
    --cc=davem@davemloft.net \
    --cc=dbus@freedesktop.org \
    --cc=gorcunov@openvz.org \
    --cc=ian.molton@collabora.co.uk \
    --cc=kay.sievers@vrfy.org \
    --cc=lennart@poettering.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /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