From: netdev-bot+sashiko@kernel.org
To: hangbin.liu@linux.dev
Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, donald.hunter@gmail.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, liuhangbin@kylinos.cn
Subject: Re: [PATCH net-next 1/6] net: lwtunnel: change encap fill order
Date: Mon, 21 Sep 2026 06:38:11 +0000 [thread overview]
Message-ID: <178997269190.2160803.430062400277571051@kernel.org> (raw)
In-Reply-To: <20260917-ynl_rt_encap-v1-1-fbbe6e680571@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Incomplete rollback in lwtunnel_fill_encap()
(net/core/lwtunnel.c:229-268): the reorder commits the selector…
- [Low] Concern (assessed INVALID by baseline verification, retained only
for policy combination): the commit message justifies the reorder by a…
--
net: lwtunnel: change encap fill order
This moves the encap-type attribute so it is written before the encap
nest in lwtunnel_fill_encap(), so that YNL can read the sub-message
selector before the payload it selects. No other behaviour was
intended to change.
> diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
> index b01a395d9a966..f13dfa02e026e 100644
> --- a/net/core/lwtunnel.c
> +++ b/net/core/lwtunnel.c
> @@ -240,6 +240,10 @@ int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate,
> lwtstate->type > LWTUNNEL_ENCAP_MAX)
> return 0;
>
> + ret = nla_put_u16(skb, encap_type_attr, lwtstate->type);
> + if (ret)
> + return ret;
> +
> nest = nla_nest_start_noflag(skb, encap_attr);
> if (!nest)
> return -EMSGSIZE;
[Severity: Medium]
Now that the type attribute is committed to the skb before the nest is
opened, can the -EOPNOTSUPP path leave it behind?
In lwtunnel_fill_encap() the failure label only rewinds the nest, and
-EOPNOTSUPP is translated into a successful return:
net/core/lwtunnel.c:lwtunnel_fill_encap() {
ret = -EOPNOTSUPP;
rcu_read_lock();
ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
if (likely(ops && ops->fill_encap))
ret = ops->fill_encap(skb, lwtstate);
rcu_read_unlock();
if (ret)
goto nla_put_failure;
...
nla_put_failure:
nla_nest_cancel(skb, nest);
return (ret == -EOPNOTSUPP ? 0 : ret);
}
nla_nest_cancel() trims back only to the start of the nest, so the
encap_type_attr written just above it stays in the message. Before this
change the type attribute was emitted only after ops->fill_encap()
succeeded, so this path left the skb unchanged.
All callers treat the 0 return as success and finish the message, for
example fib_nexthop_info():
if (lwtunnel_fill_encap(skb, nhc->nhc_lwtstate,
RTA_ENCAP, RTA_ENCAP_TYPE) < 0)
goto nla_put_failure;
and the same "< 0" test appears in nh_fill_node(), rt_fill_info() and
rt6_fill_node(). Does that mean user space can now receive a route or
nexthop message carrying RTA_ENCAP_TYPE / NHA_ENCAP_TYPE with no encap
payload?
That shape is rejected by the kernel's own nexthop parser in
rtm_to_nh_config():
} else if (tb[NHA_ENCAP_TYPE]) {
NL_SET_ERR_MSG(extack, "LWT encapsulation attribute is missing");
goto out;
so tools that dump and replay nexthops would see -EINVAL on restore.
Would it work to record the write position before emitting the selector
and nlmsg_trim() back to it on the failure and -EOPNOTSUPP paths, or to
reserve the selector attribute and fill it in only once the payload fill
has succeeded?
The trigger requires lwtun_encaps[lwtstate->type] to be NULL or an ops
without a ->fill_encap handler while an lwtstate of that type is still
live, which the module reference taken in lwtunnel_build_state() makes
hard to reach in normal operation, but the code explicitly tests
ops->fill_encap so the branch does not look impossible.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260917-ynl_rt_encap-v1-0-fbbe6e680571%40kylinos.cn
next prev parent reply other threads:[~2026-09-21 6:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 6:35 [PATCH net-next 0/6] netlink: add lwtunnel encap sub-message support to rt-route Hangbin Liu
2026-09-17 6:35 ` [PATCH net-next 1/6] net: lwtunnel: change encap fill order Hangbin Liu
2026-09-21 6:38 ` netdev-bot+sashiko [this message]
2026-09-17 6:35 ` [PATCH net-next 2/6] tools: ynl: convert enum selector to string for sub-message parsing Hangbin Liu
2026-09-21 6:38 ` netdev-bot+sashiko
2026-09-17 6:35 ` [PATCH net-next 3/6] netlink: specs: rt-route: add lwtunnel encap sub-message support Hangbin Liu
2026-09-21 6:38 ` netdev-bot+sashiko
2026-09-17 6:35 ` [PATCH net-next 4/6] netlink: specs: rt-route: describe lwtunnel IP options Hangbin Liu
2026-09-21 6:38 ` netdev-bot+sashiko
2026-09-21 9:26 ` Hangbin Liu
2026-09-17 6:35 ` [PATCH net-next 5/6] netlink: specs: rt-route: describe lwt BPF program options Hangbin Liu
2026-09-21 6:38 ` netdev-bot+sashiko
2026-09-21 9:46 ` Hangbin Liu
2026-09-17 6:35 ` [PATCH net-next 6/6] netlink: specs: rt-route: describe seg6-local actions, counters and flavors Hangbin Liu
2026-09-21 6:38 ` netdev-bot+sashiko
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=178997269190.2160803.430062400277571051@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=hangbin.liu@linux.dev \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®