From: Patrick McHardy <kaber@trash.net>
To: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [1/1] netlink: fix broadcasting to the wrong group.
Date: Mon, 17 Apr 2006 17:35:04 +0200 [thread overview]
Message-ID: <4443B5A8.9010604@trash.net> (raw)
In-Reply-To: <20060417093632.GA29057@2ka.mipt.ru>
Evgeniy Polyakov wrote:
> When application is bound to group N and it is less than 32
> and has first bit set (I tested with 1, 3, 5) and kernel broadcasts
> events to group number 1, application will receive messages, even if
> 1. it was not subscribed to that group
> 2. it was bound to different group
>
> Attached trivial test module and userspace program.
> make
> insmod nltest.ko
> ./nluser -g5
>
> see the dmesg.
> Test module sends data to group number 1, but application is bound and
> subscribed to group 5, but still receives messages.
>
> This issue happens due to the following check in do_one_broadcast():
>
> if (nlk->pid == p->pid || p->group - 1 >= nlk->ngroups ||
> !test_bit(p->group - 1, nlk->groups))
>
> nlk->groups is set at bind time to the userspace provided bind group.
> So in above case it will be 5.
> But above test_bit() is supposed to check subscribed groups, which are
> set using set_bit(users_group - 1, nlk->groups).
> So when kernelspace broadcasts to group 1 above test_bit() returns true
> and message is delivered to the wrong socket.
>
> Attached patch removes nlk->groups[0] assignment at bind time since it
> is completely meaningless due to subscription introduction.
> nltest.c - simple test module which broadcasts events to group 1.
> nluser.c - userspace application which receives data from socket bound
> to specified group.
This seems to be a misunderstanding, subscribing to groups using bind()
is kept for compatibility and doesn't use group numbers but bitmasks.
next prev parent reply other threads:[~2006-04-17 15:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-17 9:36 [1/1] netlink: fix broadcasting to the wrong group Evgeniy Polyakov
2006-04-17 15:35 ` Patrick McHardy [this message]
2006-04-17 19:49 ` Evgeniy Polyakov
2006-04-17 20:14 ` Patrick McHardy
2006-04-17 20:21 ` Evgeniy Polyakov
2006-04-17 23:13 ` Patrick McHardy
2006-04-18 5:18 ` Evgeniy Polyakov
2006-04-18 5:36 ` Patrick McHardy
2006-04-18 5:53 ` Evgeniy Polyakov
2006-04-18 6:00 ` Patrick McHardy
2006-04-18 6:09 ` Evgeniy Polyakov
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=4443B5A8.9010604@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=johnpol@2ka.mipt.ru \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).