From: Jakub Kicinski <kuba@kernel.org>
To: Lin Ma <linma@zju.edu.cn>
Cc: jk@codeconstruct.com.au, matt@codeconstruct.com.au,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v1] net: mctp: use deprecated parser in mctp_set_link_af
Date: Wed, 3 Jan 2024 17:47:19 -0800 [thread overview]
Message-ID: <20240103174719.2b2c1565@kernel.org> (raw)
In-Reply-To: <20231228070258.3052422-1-linma@zju.edu.cn>
On Thu, 28 Dec 2023 15:02:58 +0800 Lin Ma wrote:
> In mctp set_link_af implementation `mctp_set_link_af`, it uses strict
> parser nla_parse_nested to parse the nested attribute. This is fine in
> most cases but not here, as the rtnetlink uses *bad magic* in setlink
> code, see code snippet in function `do_setlink`.
>
> nla_for_each_nested(af, tb[IFLA_AF_SPEC], rem) {
> const struct rtnl_af_ops *af_ops;
> BUG_ON(!(af_ops = rtnl_af_lookup(nla_type(af)))); <= (1)
> err = af_ops->set_link_af(dev, af, extack); <= (2)
>
> That is, in line (1), the attribute type of af will used to look up the
> af_ops, and for MCTP case will use AF_MCTP here to get mctp_af_ops.
> Therefore, the attribute with type AF_MCTP will never survive in the
> check within the nla_parse_nested.
>
> if (!(nla->nla_type & NLA_F_NESTED)) { <= nla_type is AF_MCTP
> NL_SET_ERR_MSG_ATTR(extack, nla, "NLA_F_NESTED is missing");
> return -EINVAL; <= always invalid
> }
>
> For other set_link_af users IPV4 and IPV6 both make a trick here by
> using nla_parse_nested_deprecated, which will check the NLA_F_NESTED
> then able to use this type field as family value. This patch simply port
> the MCTP code also to deprecated parser to make it work.
Did you test this? It's a suspiciously detailed and yet seemingly
incorrect explanation..
--
pv-bot: s
pw-bot: cr
next prev parent reply other threads:[~2024-01-04 1:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-28 7:02 [PATCH net-next v1] net: mctp: use deprecated parser in mctp_set_link_af Lin Ma
2024-01-04 1:47 ` Jakub Kicinski [this message]
2024-01-04 6:32 ` Lin Ma
2024-01-04 6:43 ` Jeremy Kerr
2024-01-04 7:04 ` Lin Ma
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=20240103174719.2b2c1565@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jk@codeconstruct.com.au \
--cc=linma@zju.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeconstruct.com.au \
--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;
as well as URLs for NNTP newsgroup(s).