[PATCH net 1/3] netlink: specs: mptcp: fix if-idx attribute type

Matthieu Baerts (NGI0) posted 3 patches 1 day, 4 hours ago
[PATCH net 1/3] netlink: specs: mptcp: fix if-idx attribute type
Posted by Matthieu Baerts (NGI0) 1 day, 4 hours ago
This attribute is used as a signed number in the code in pm_netlink.c:

  nla_put_s32(skb, MPTCP_ATTR_IF_IDX, ssk->sk_bound_dev_if))

The specs should then reflect that. Note that other 'if-idx' attributes
from the same .yaml file use a signed number as well.

Fixes: bc8aeb2045e2 ("Documentation: netlink: add a YAML spec for mptcp")
Cc: stable@vger.kernel.org
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 Documentation/netlink/specs/mptcp_pm.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/netlink/specs/mptcp_pm.yaml b/Documentation/netlink/specs/mptcp_pm.yaml
index 02f1ddcfbf1cfd81a398dd03c52bb9f281c1aa08..d15335684ec3d6256505f2b3887ce5818eb57462 100644
--- a/Documentation/netlink/specs/mptcp_pm.yaml
+++ b/Documentation/netlink/specs/mptcp_pm.yaml
@@ -256,7 +256,7 @@ attribute-sets:
         type: u32
       -
         name: if-idx
-        type: u32
+        type: s32
       -
         name: reset-reason
         type: u32

-- 
2.51.0
Re: [PATCH net 1/3] netlink: specs: mptcp: fix if-idx attribute type
Posted by Donald Hunter 17 hours ago
"Matthieu Baerts (NGI0)" <matttbe@kernel.org> writes:

> This attribute is used as a signed number in the code in pm_netlink.c:
>
>   nla_put_s32(skb, MPTCP_ATTR_IF_IDX, ssk->sk_bound_dev_if))
>
> The specs should then reflect that. Note that other 'if-idx' attributes
> from the same .yaml file use a signed number as well.

Note that mptcp_pm_parse_entry has this, which should maybe be fixed at
the same time:

	u32 val = nla_get_s32(tb[MPTCP_PM_ADDR_ATTR_IF_IDX]);


https://elixir.bootlin.com/linux/v6.16.5/source/net/mptcp/pm_netlink.c#L116

>
> Fixes: bc8aeb2045e2 ("Documentation: netlink: add a YAML spec for mptcp")
> Cc: stable@vger.kernel.org
> Reviewed-by: Geliang Tang <geliang@kernel.org>
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
>  Documentation/netlink/specs/mptcp_pm.yaml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/netlink/specs/mptcp_pm.yaml b/Documentation/netlink/specs/mptcp_pm.yaml
> index 02f1ddcfbf1cfd81a398dd03c52bb9f281c1aa08..d15335684ec3d6256505f2b3887ce5818eb57462 100644
> --- a/Documentation/netlink/specs/mptcp_pm.yaml
> +++ b/Documentation/netlink/specs/mptcp_pm.yaml
> @@ -256,7 +256,7 @@ attribute-sets:
>          type: u32
>        -
>          name: if-idx
> -        type: u32
> +        type: s32
>        -
>          name: reset-reason
>          type: u32
Re: [PATCH net 1/3] netlink: specs: mptcp: fix if-idx attribute type
Posted by Matthieu Baerts 16 hours ago
Hi Donald,

On 09/09/2025 10:44, Donald Hunter wrote:
> "Matthieu Baerts (NGI0)" <matttbe@kernel.org> writes:
> 
>> This attribute is used as a signed number in the code in pm_netlink.c:
>>
>>   nla_put_s32(skb, MPTCP_ATTR_IF_IDX, ssk->sk_bound_dev_if))
>>
>> The specs should then reflect that. Note that other 'if-idx' attributes
>> from the same .yaml file use a signed number as well.
> 
> Note that mptcp_pm_parse_entry has this, which should maybe be fixed at
> the same time:
> 
> 	u32 val = nla_get_s32(tb[MPTCP_PM_ADDR_ATTR_IF_IDX]);

Good catch!

This should be fixed in a dedicated patch, because this fixes commit:
ef0da3b8a2f1 ("mptcp: move address attribute into mptcp_addr_info"), a
different commit than the one being fixed here.

I can send that separately later on if that's OK.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH net 1/3] netlink: specs: mptcp: fix if-idx attribute type
Posted by Jakub Kicinski 12 minutes ago
On Tue, 9 Sep 2025 11:08:46 +0200 Matthieu Baerts wrote:
> > Note that mptcp_pm_parse_entry has this, which should maybe be fixed at
> > the same time:
> > 
> > 	u32 val = nla_get_s32(tb[MPTCP_PM_ADDR_ATTR_IF_IDX]);  
> 
> Good catch!

indeed!

> This should be fixed in a dedicated patch, because this fixes commit:
> ef0da3b8a2f1 ("mptcp: move address attribute into mptcp_addr_info"), a
> different commit than the one being fixed here.

int = u32 is unlikely to cause issues AFAIU. We recently applied 
a bunch of such fixes to net-next. I think this can also go to -next.