[PATCH mptcp-next v7 11/24] mptcp: check userspace pm subflow flag

Geliang Tang posted 24 patches 8 months, 1 week ago
There is a newer version of this series
[PATCH mptcp-next v7 11/24] mptcp: check userspace pm subflow flag
Posted by Geliang Tang 8 months, 1 week ago
This patch checks MPTCP_PM_ADDR_FLAG_SUBFLOW flag when creating a subflow
by userspace PM in mptcp_pm_nl_subflow_create_doit(). If it's not set,
don't create the subflow.

Signed-off-by: Geliang Tang <geliang.tang@linux.dev>
---
 net/mptcp/pm_userspace.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 98237108ddcf..b9f5dfe922f9 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -371,6 +371,12 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
 	}
 	addr_l = local.addr;
 
+	if (!(local.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) {
+		GENL_SET_ERR_MSG(info, "invalid addr flags");
+		err = -EINVAL;
+		goto create_err;
+	}
+
 	err = mptcp_pm_parse_addr(raddr, info, &addr_r);
 	if (err < 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr");
-- 
2.39.2
Re: [PATCH mptcp-next v7 11/24] mptcp: check userspace pm subflow flag
Posted by Mat Martineau 8 months ago
On Sat, 30 Dec 2023, Geliang Tang wrote:

> This patch checks MPTCP_PM_ADDR_FLAG_SUBFLOW flag when creating a subflow
> by userspace PM in mptcp_pm_nl_subflow_create_doit(). If it's not set,
> don't create the subflow.
>

Hi Geliang -

I took a quick look at mptcpd and I don't think it sets this flag. Why is 
it important to add this check?

- Mat

> Signed-off-by: Geliang Tang <geliang.tang@linux.dev>
> ---
> net/mptcp/pm_userspace.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 98237108ddcf..b9f5dfe922f9 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -371,6 +371,12 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
> 	}
> 	addr_l = local.addr;
>
> +	if (!(local.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) {
> +		GENL_SET_ERR_MSG(info, "invalid addr flags");
> +		err = -EINVAL;
> +		goto create_err;
> +	}
> +
> 	err = mptcp_pm_parse_addr(raddr, info, &addr_r);
> 	if (err < 0) {
> 		NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr");
> -- 
> 2.39.2
>
>
>