From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Pirko <jiri@resnulli.us>,
Ilya Maximets <i.maximets@redhat.com>,
Frode Nordahl <frode.nordahl@canonical.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org
Subject: Re: [PATCH net] tc: Ensure we have enough buffer space when sending filter netlink notifications
Date: Thu, 10 Apr 2025 12:28:43 +0200 [thread overview]
Message-ID: <874iywux7o.fsf@toke.dk> (raw)
In-Reply-To: <Z/awKFETLHDwN6dE@pop-os.localdomain>
Cong Wang <xiyou.wangcong@gmail.com> writes:
> On Mon, Apr 07, 2025 at 12:55:34PM +0200, Toke Høiland-Jørgensen wrote:
>> +static struct sk_buff *tfilter_notify_prep(struct net *net,
>> + struct sk_buff *oskb,
>> + struct nlmsghdr *n,
>> + struct tcf_proto *tp,
>> + struct tcf_block *block,
>> + struct Qdisc *q, u32 parent,
>> + void *fh, int event,
>> + u32 portid, bool rtnl_held,
>> + struct netlink_ext_ack *extack)
>> +{
>> + unsigned int size = oskb ? max(NLMSG_GOODSIZE, oskb->len) : NLMSG_GOODSIZE;
>> + struct sk_buff *skb;
>> + int ret;
>> +
>> +retry:
>> + skb = alloc_skb(size, GFP_KERNEL);
>> + if (!skb)
>> + return ERR_PTR(-ENOBUFS);
>> +
>> + ret = tcf_fill_node(net, skb, tp, block, q, parent, fh, portid,
>> + n->nlmsg_seq, n->nlmsg_flags, event, false,
>> + rtnl_held, extack);
>> + if (ret <= 0) {
>> + kfree_skb(skb);
>> + if (ret == -EMSGSIZE) {
>> + size += NLMSG_GOODSIZE;
>> + goto retry;
>
> It is a bit concerning to see this technically unbound loop.
Well, I did think about that. The loop will terminate eventually by
either succeeding, or failing the allocation. Most likely the former,
since this is only called after a filter has been successfully
installed. I.e., it's not like the amount of data being put into the skb
is unbounded.
>> + }
>> + return ERR_PTR(-EINVAL);
>
> I think you probably want to propagate the error code from
> tcf_fill_node() here.
I just kept the existing return value (of tfilter_notify()) for the same
error case. tcf_fill_node() always returns -1 on error, so I think it
makes more sense to keep this?
Paolo already merged the patch, and I don't think it's worth it to
follow up with any fixes, cf the above. WDYT?
-Toke
next prev parent reply other threads:[~2025-04-10 10:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 10:55 [PATCH net] tc: Ensure we have enough buffer space when sending filter netlink notifications Toke Høiland-Jørgensen
2025-04-07 11:12 ` Jiri Pirko
2025-04-08 11:57 ` Paolo Abeni
2025-04-08 12:59 ` Toke Høiland-Jørgensen
2025-04-08 12:10 ` patchwork-bot+netdevbpf
2025-04-09 17:36 ` Cong Wang
2025-04-10 10:28 ` Toke Høiland-Jørgensen [this message]
2025-04-14 21:00 ` Cong Wang
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=874iywux7o.fsf@toke.dk \
--to=toke@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=frode.nordahl@canonical.com \
--cc=horms@kernel.org \
--cc=i.maximets@redhat.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xiyou.wangcong@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;
as well as URLs for NNTP newsgroup(s).