diff mbox series

[v2] mptcp: make sure flag signal is set when add addr with port

Message ID c388d556-530c-ee11-3ab1-a8019fb2eb6f@163.com
State Superseded, archived
Commit eb86a8c1aeed144a3813b9ec976665c335746929
Headers show
Series [v2] mptcp: make sure flag signal is set when add addr with port | expand

Commit Message

Jianguo Wu April 23, 2021, 10:25 a.m. UTC
From: Jianguo Wu <wujianguo@chinatelecom.cn>

When add address with port, it is mean to create a listening socket,
and send an ADD_ADDR to remote, so it must have flag signal set,
add this check in mptcp_pm_parse_addr().

Fixes: a77e9179c7651 ("mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink")
Signed-off-by: Jianguo Wu <wujianguo@chinatelecom.cn>
---
 net/mptcp/pm_netlink.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Geliang Tang April 23, 2021, 10:28 a.m. UTC | #1
Hi Jianguo,

Jianguo Wu <wujianguo106@163.com> 于2021年4月23日周五 下午6:26写道:
>
> From: Jianguo Wu <wujianguo@chinatelecom.cn>
>
> When add address with port, it is mean to create a listening socket,
> and send an ADD_ADDR to remote, so it must have flag signal set,
> add this check in mptcp_pm_parse_addr().
>
> Fixes: a77e9179c7651 ("mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink")
> Signed-off-by: Jianguo Wu <wujianguo@chinatelecom.cn>
> ---
>  net/mptcp/pm_netlink.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index becc32b..90bba32 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -971,8 +971,14 @@ static int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
>         if (tb[MPTCP_PM_ADDR_ATTR_FLAGS])
>                 entry->flags = nla_get_u32(tb[MPTCP_PM_ADDR_ATTR_FLAGS]);
>
> -       if (tb[MPTCP_PM_ADDR_ATTR_PORT])
> +       if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {
> +               if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) {
> +                       NL_SET_ERR_MSG_ATTR(info->extack, attr,
> +                                           "flags must have signal when using port");
> +                       return -EINVAL;
> +               }
>                 entry->addr.port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]));
> +       }
>
>         return 0;
>  }

LGTM.

Acked-by: Geliang Tang <geliangtang@gmail.com>

-Geliang

> --
> 1.8.3.1
>
>
Matthieu Baerts April 24, 2021, 8:53 a.m. UTC | #2
Hi Jianguo, Geliang,

On 23/04/2021 12:25, Jianguo Wu wrote:
> From: Jianguo Wu <wujianguo@chinatelecom.cn>
> 
> When add address with port, it is mean to create a listening socket,
> and send an ADD_ADDR to remote, so it must have flag signal set,
> add this check in mptcp_pm_parse_addr().

Thank you for your patch and the review!

This is now in our tree:

- eb86a8c1aeed: mptcp: make sure flag signal is set when add addr with port
- Results: 3692d2b92d9f..5c90fe877090

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20210424T085242
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export/20210424T085242

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index becc32b..90bba32 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -971,8 +971,14 @@  static int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
 	if (tb[MPTCP_PM_ADDR_ATTR_FLAGS])
 		entry->flags = nla_get_u32(tb[MPTCP_PM_ADDR_ATTR_FLAGS]);

-	if (tb[MPTCP_PM_ADDR_ATTR_PORT])
+	if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {
+		if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) {
+			NL_SET_ERR_MSG_ATTR(info->extack, attr,
+					    "flags must have signal when using port");
+			return -EINVAL;
+		}
 		entry->addr.port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]));
+	}

 	return 0;
 }