Netdev List
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH net] netlink: Properly unbind in error conditions.
Date: Wed, 12 Nov 2014 14:44:54 -0500	[thread overview]
Message-ID: <20141112194454.GC28076@madcap2.tricolour.ca> (raw)
In-Reply-To: <20141113042410.013c5d044aa442a05832d6d9@gmail.com>

On 14/11/13, Hiroaki SHIMODA wrote:
> Even if netlink_kernel_cfg::unbind is implemented the unbind() method is
> not called, because cfg->unbind is omitted in __netlink_kernel_create().
> And fix wrong argument of test_bit() and off by one problem.
> 
> At this point, no unbind() method is implemented, so there is no real
> issue.
> 
> Fixes: 4f520900522f ("netlink: have netlink per-protocol bind function return an error code.")
> Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
> Cc: Richard Guy Briggs <rgb@redhat.com>
> ---
>  net/netlink/af_netlink.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index f1de72de273e..0007b8180397 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -1440,7 +1440,7 @@ static void netlink_unbind(int group, long unsigned int groups,
>  		return;
>  
>  	for (undo = 0; undo < group; undo++)
> -		if (test_bit(group, &groups))
> +		if (test_bit(undo, &groups))

Nice find!  (Cut-and-waste from line 1480...)

>  			nlk->netlink_unbind(undo);
>  }
>  
> @@ -1492,7 +1492,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
>  			netlink_insert(sk, net, nladdr->nl_pid) :
>  			netlink_autobind(sock);
>  		if (err) {
> -			netlink_unbind(nlk->ngroups - 1, groups, nlk);
> +			netlink_unbind(nlk->ngroups, groups, nlk);

Yup, agreed.

>  			return err;
>  		}
>  	}
> @@ -2509,6 +2509,7 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
>  		nl_table[unit].module = module;
>  		if (cfg) {
>  			nl_table[unit].bind = cfg->bind;
> +			nl_table[unit].unbind = cfg->unbind;

Yup, thanks.

>  			nl_table[unit].flags = cfg->flags;
>  			if (cfg->compare)
>  				nl_table[unit].compare = cfg->compare;

Acked-by: Richard Guy Briggs <rgb@redhat.com>

> -- 
> 2.0.4
> 

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

  reply	other threads:[~2014-11-12 19:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 19:24 [PATCH net] netlink: Properly unbind in error conditions Hiroaki SHIMODA
2014-11-12 19:44 ` Richard Guy Briggs [this message]
2014-11-12 20:49 ` David Miller

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=20141112194454.GC28076@madcap2.tricolour.ca \
    --to=rgb@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shimoda.hiroaki@gmail.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