public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Shiraz Saleem <shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH for-4.14-rc] RDMA/netlink: Restore nlmsg_len calculation in ibnl_put_attr
Date: Thu, 28 Sep 2017 16:24:57 +0300	[thread overview]
Message-ID: <20170928132457.GW2297@mtr-leonro.local> (raw)
In-Reply-To: <20170928114953.9600-1-shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1702 bytes --]

On Thu, Sep 28, 2017 at 06:49:53AM -0500, Shiraz Saleem wrote:
> Commit 1a1c116f3dcf removes nlmsg_len calculation in
> ibnl_put_attr causing netlink messages to be rejected due
> to incorrect length.
>
> Restore the netlink message header length calculation
> to include the added attribute.
>
> Fixes: 1a1c116f3dcf ("RDMA/netlink: Simplify the put_msg and put_attr")
> Signed-off-by: Shiraz Saleem <shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/infiniband/core/netlink.c | 4 ++++
>  1 file changed, 4 insertions(+)
>

The length supposed to be updated in ibnl_put_msg, where you should
supply correct length from the beginning. The suggested way to supply
length for unknown data is to provide NLMSG_DEFAULT_SIZE while allocating
new netlink message.

NLMSG_DEFAULT_SIZE ensures that netlink fits into one page.

It is better to avoid messing with message length after allocations,
especially for the attributes.

Thanks

> diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
> index e685148..889d091 100644
> --- a/drivers/infiniband/core/netlink.c
> +++ b/drivers/infiniband/core/netlink.c
> @@ -150,10 +150,14 @@ EXPORT_SYMBOL(ibnl_put_msg);
>  int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
>  		  int len, void *data, int type)
>  {
> +	unsigned char *prev_tail;
> +
> +	prev_tail = skb_tail_pointer(skb);
>  	if (nla_put(skb, type, len, data)) {
>  		nlmsg_cancel(skb, nlh);
>  		return -EMSGSIZE;
>  	}
> +	nlh->nlmsg_len += skb_tail_pointer(skb) - prev_tail;
>  	return 0;
>  }
>  EXPORT_SYMBOL(ibnl_put_attr);
> --
> 2.8.3
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2017-09-28 13:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 11:49 [PATCH for-4.14-rc] RDMA/netlink: Restore nlmsg_len calculation in ibnl_put_attr Shiraz Saleem
     [not found] ` <20170928114953.9600-1-shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-09-28 13:24   ` Leon Romanovsky [this message]
     [not found]     ` <20170928132457.GW2297-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-09-28 19:00       ` Shiraz Saleem
     [not found]         ` <20170928190033.GA12760-GOXS9JX10wfOxmVO0tvppfooFf0ArEBIu+b9c/7xato@public.gmane.org>
2017-09-28 19:47           ` Leon Romanovsky

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=20170928132457.GW2297@mtr-leonro.local \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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