netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Dmitry Safonov <dima@arista.com>, linux-kernel@vger.kernel.org
Cc: Dmitry Safonov <0x7f454c46@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Florian Westphal <fw@strlen.de>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Jakub Kicinski <kuba@kernel.org>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Stephen Suryaputra <ssuryaextr@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v2 3/6] netlink/compat: Append NLMSG_DONE/extack to frag_list
Date: Wed, 26 Aug 2020 09:19:51 +0200	[thread overview]
Message-ID: <f579efc1375e46d9c2ff999ada1bcfed40ec2a8f.camel@sipsolutions.net> (raw)
In-Reply-To: <20200826014949.644441-4-dima@arista.com> (sfid-20200826_034955_677016_9C53E113)

On Wed, 2020-08-26 at 02:49 +0100, Dmitry Safonov wrote:
> Modules those use netlink may supply a 2nd skb, (via frag_list)
> that contains an alternative data set meant for applications
> using 32bit compatibility mode.

Do note, however, that until this day the facility here was only used by
(and originally intended for) wireless extensions, where it exclusively
applies to *event* messages. Hence, we really didn't worry about dump or
any other kind of netlink usage.

That said, it's really just a historic note explaining why it didn't
work for you out of the box :)

> In such a case, netlink_recvmsg will use this 2nd skb instead of the
> original one.
> 
> Without this patch, such compat applications will retrieve
> all netlink dump data, but will then get an unexpected EOF.
> 
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> Signed-off-by: Dmitry Safonov <dima@arista.com>
> ---
>  net/netlink/af_netlink.c | 48 ++++++++++++++++++++++++++++------------
>  1 file changed, 34 insertions(+), 14 deletions(-)
> 
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index b5f30d7d30d0..b096f2b4a50d 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -2186,13 +2186,36 @@ EXPORT_SYMBOL(__nlmsg_put);
>   * It would be better to create kernel thread.
>   */
>  
> +static int netlink_dump_done(struct netlink_sock *nlk, struct sk_buff *skb,
> +			     struct netlink_callback *cb,
> +			     struct netlink_ext_ack *extack)
> +{
> +	struct nlmsghdr *nlh;
> +
> +	nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(nlk->dump_done_errno),
> +			       NLM_F_MULTI | cb->answer_flags);
> +	if (WARN_ON(!nlh))
> +		return -ENOBUFS;
> +
> +	nl_dump_check_consistent(cb, nlh);
> +	memcpy(nlmsg_data(nlh), &nlk->dump_done_errno,
> +			sizeof(nlk->dump_done_errno));

nit: indentation here looks odd.

Other than that, looks reasonable to me.

Reviewed-by: Johannes Berg <johannes@sipsolutions.net>

johannes


  reply	other threads:[~2020-08-26  7:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26  1:49 [PATCH v2 0/6] xfrm: Add compat layer Dmitry Safonov
2020-08-26  1:49 ` [PATCH v2 1/6] xfrm/compat: Add 64=>32-bit messages translator Dmitry Safonov
2020-08-26  4:03   ` kernel test robot
2020-09-07 11:24   ` Steffen Klassert
2020-09-07 17:01     ` Dmitry Safonov
2020-08-26  1:49 ` [PATCH v2 2/6] xfrm/compat: Attach xfrm dumps to 64=>32 bit translator Dmitry Safonov
2020-08-26  1:49 ` [PATCH v2 3/6] netlink/compat: Append NLMSG_DONE/extack to frag_list Dmitry Safonov
2020-08-26  7:19   ` Johannes Berg [this message]
2020-09-07 16:41     ` Dmitry Safonov
2020-08-26  1:49 ` [PATCH v2 4/6] xfrm/compat: Add 32=>64-bit messages translator Dmitry Safonov
2020-08-26  1:49 ` [PATCH v2 5/6] xfrm/compat: Translate 32-bit user_policy from sockptr Dmitry Safonov
2020-08-26  1:49 ` [PATCH v2 6/6] selftest/net/xfrm: Add test for ipsec tunnel Dmitry Safonov
2020-09-07  9:43 ` [PATCH v2 0/6] xfrm: Add compat layer Steffen Klassert
2020-09-07 16:51   ` Dmitry Safonov

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=f579efc1375e46d9c2ff999ada1bcfed40ec2a8f.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=0x7f454c46@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dima@arista.com \
    --cc=fw@strlen.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ssuryaextr@gmail.com \
    --cc=steffen.klassert@secunet.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;
as well as URLs for NNTP newsgroup(s).