On Mon, Aug 15, 2005 at 09:45:22AM +0200, Patrick McHardy ([EMAIL PROTECTED])
wrote:
> David S. Miller wrote:
> >I applied patches 1 -> 7, but I had to stop after that.
> >
> >This patch here will break netlink on my workstation :-)
> >
> >These "u32" tricks with nlk->groups[0] will not work on
> >big-endian 64-bit. If unsigned long is 64-bit, you end
> >up accessing bits 32-63 of nlk->groups[0] in some instances
> >and then bits 0-31 in other situations.
> >
> >Please redo this patch, then I'll apply it and the rest.
> >You only need resend the fixed version of patch 8.
>
> This one should fix the problem. I also redid 9, it was missing a
> permission check for joining groups.
> [NETLINK]: Support dynamic number of multicast groups per netlink family
>
> Signed-off-by: Patrick McHardy <[EMAIL PROTECTED]>
>
> ---
> commit 5a78d0310e5039009bceab69f8b4de05b0ae73de
> tree dfa621961787223780026b7ffc51eaad85de8424
> parent 159b54716bcf5aea4c3141a64072613db7934e11
> author Patrick McHardy <[EMAIL PROTECTED]> Mon, 15 Aug 2005 09:22:12 +0200
> committer Patrick McHardy <[EMAIL PROTECTED]> Mon, 15 Aug 2005 09:22:12 +0200
>
> net/netlink/af_netlink.c | 69
> ++++++++++++++++++++++++++++++++++------------
> 1 files changed, 51 insertions(+), 18 deletions(-)
>
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -60,21 +60,24 @@
> #include <net/scm.h>
>
> #define Nprintk(a...)
> +#define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8)
>
> struct netlink_sock {
> /* struct sock has to be the first member of netlink_sock */
> struct sock sk;
> u32 pid;
> - unsigned int groups;
> u32 dst_pid;
> u32 dst_group;
> + u32 flags;
> + u32 subscriptions;
> + u32 ngroups;
> + unsigned long *groups;
> unsigned long state;
> wait_queue_head_t wait;
> struct netlink_callback *cb;
> spinlock_t cb_lock;
> void (*data_ready)(struct sock *sk, int bytes);
> struct module *module;
> - u32 flags;
> };
...
> + nlk->groups = kmalloc(NLGRPSZ(groups), GFP_KERNEL);
> + if (nlk->groups == NULL) {
> + err = -ENOMEM;
> goto out_module;
> + }
> + memset(nlk->groups, 0, NLGRPSZ(groups));
> + nlk->ngroups = groups;
...
> - if (!nladdr->nl_groups && !nlk->groups)
> + if (!nladdr->nl_groups && !(u32)nlk->groups[0])
> return 0;
...
> + nlk->groups[0] = (nlk->groups[0] & ~0xffffffffUL) | nladdr->nl_groups;
> netlink_table_ungrab();
I have some doubt about 64bit platforms.
> return 0;
> @@ -590,7 +619,7 @@ static int netlink_getname(struct socket
> nladdr->nl_groups = netlink_group_mask(nlk->dst_group);
> } else {
> nladdr->nl_pid = nlk->pid;
> - nladdr->nl_groups = nlk->groups;
> + nladdr->nl_groups = nlk->groups[0];
And here too.
nlk->groups[0] is an unsigned long, which is 64bit on 64bit platforms.
--
Evgeniy Polyakov
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html