From: Stefano Brivio <sbrivio@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, jiri@resnulli.us, idosch@idosch.org,
johannes@sipsolutions.net, fw@strlen.de, pablo@netfilter.org,
Martin Pitt <mpitt@redhat.com>,
Paul Holzinger <pholzing@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH net-next v2 3/3] genetlink: fit NLMSG_DONE into same read() as families
Date: Fri, 15 Mar 2024 12:48:08 +0100 [thread overview]
Message-ID: <20240315124808.033ff58d@elisabeth> (raw)
In-Reply-To: <20240303052408.310064-4-kuba@kernel.org>
Hi,
On Sat, 2 Mar 2024 21:24:08 -0800
Jakub Kicinski <kuba@kernel.org> wrote:
> Make sure ctrl_fill_info() returns sensible error codes and
> propagate them out to netlink core. Let netlink core decide
> when to return skb->len and when to treat the exit as an
> error. Netlink core does better job at it, if we always
> return skb->len the core doesn't know when we're done
> dumping and NLMSG_DONE ends up in a separate read().
While this change is obviously correct, it breaks... well, broken
applications that _wrongly_ rely on the fact that NLMSG_DONE is
delivered in a separate datagram.
This was the (embarrassing) case for passt(1), which I just fixed:
https://archives.passt.top/passt-dev/20240315112432.382212-1-sbrivio@redhat.com/
but the "separate" NLMSG_DONE is such an established behaviour,
I think, that this might raise a more general concern.
From my perspective, I'm just happy that this change revealed the
issue, but I wanted to report this anyway in case somebody has
similar possible breakages in mind.
> Reviewed-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: jiri@resnulli.us
> ---
> net/netlink/genetlink.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index 50ec599a5cff..3b7666944b11 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -1232,7 +1232,7 @@ static int ctrl_fill_info(const struct genl_family *family, u32 portid, u32 seq,
>
> hdr = genlmsg_put(skb, portid, seq, &genl_ctrl, flags, cmd);
> if (hdr == NULL)
> - return -1;
> + return -EMSGSIZE;
>
> if (nla_put_string(skb, CTRL_ATTR_FAMILY_NAME, family->name) ||
> nla_put_u16(skb, CTRL_ATTR_FAMILY_ID, family->id) ||
> @@ -1355,6 +1355,7 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
> struct net *net = sock_net(skb->sk);
> int fams_to_skip = cb->args[0];
> unsigned int id;
> + int err = 0;
>
> idr_for_each_entry(&genl_fam_idr, rt, id) {
> if (!rt->netnsok && !net_eq(net, &init_net))
> @@ -1363,16 +1364,17 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
> if (n++ < fams_to_skip)
> continue;
>
> - if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid,
> - cb->nlh->nlmsg_seq, NLM_F_MULTI,
> - skb, CTRL_CMD_NEWFAMILY) < 0) {
> + err = ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid,
> + cb->nlh->nlmsg_seq, NLM_F_MULTI,
> + skb, CTRL_CMD_NEWFAMILY);
> + if (err) {
> n--;
> break;
> }
> }
>
> cb->args[0] = n;
> - return skb->len;
> + return err;
> }
>
> static struct sk_buff *ctrl_build_family_msg(const struct genl_family *family,
--
Stefano
next prev parent reply other threads:[~2024-03-15 11:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 5:24 [PATCH net-next v2 0/3] netlink: handle EMSGSIZE errors in the core Jakub Kicinski
2024-03-03 5:24 ` [PATCH net-next v2 1/3] " Jakub Kicinski
2024-03-03 15:01 ` Ido Schimmel
2024-03-03 5:24 ` [PATCH net-next v2 2/3] netdev: let netlink core handle -EMSGSIZE errors Jakub Kicinski
2024-03-03 15:08 ` Ido Schimmel
2024-03-03 5:24 ` [PATCH net-next v2 3/3] genetlink: fit NLMSG_DONE into same read() as families Jakub Kicinski
2024-03-03 15:10 ` Ido Schimmel
2024-03-15 11:48 ` Stefano Brivio [this message]
2024-03-19 15:55 ` Jakub Kicinski
2024-03-19 17:17 ` Eric Dumazet
2024-03-19 17:40 ` Jakub Kicinski
2024-03-21 12:56 ` Gal Pressman
2024-03-21 13:51 ` Ido Schimmel
2024-03-21 15:03 ` Gal Pressman
2024-03-21 17:26 ` Eric Dumazet
2024-03-21 17:41 ` Ido Schimmel
2024-04-03 22:52 ` Ilya Maximets
2024-04-11 15:16 ` Jakub Kicinski
2024-04-11 15:39 ` Ilya Maximets
2024-04-11 15:52 ` Jakub Kicinski
2024-04-11 16:38 ` Ilya Maximets
2024-04-11 18:03 ` Jakub Kicinski
2024-04-11 18:04 ` Jakub Kicinski
2024-03-19 23:36 ` David Gibson
2024-03-06 8:10 ` [PATCH net-next v2 0/3] netlink: handle EMSGSIZE errors in the core patchwork-bot+netdevbpf
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=20240315124808.033ff58d@elisabeth \
--to=sbrivio@redhat.com \
--cc=davem@davemloft.net \
--cc=david@gibson.dropbear.id.au \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=idosch@idosch.org \
--cc=jiri@resnulli.us \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=mpitt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=pholzing@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.