From patchwork Fri Mar 1 18:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 209002 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp65210dyc; Fri, 1 Mar 2024 10:21:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVSi3NJzh2N8VU/fb5D+jREyFkCXbBoCL7t/0OYDQ2hB7PuNNAZXEW8WIDS1MT1JsPtVai2xh//fjkGpvADKJ6xjWePpg== X-Google-Smtp-Source: AGHT+IEC9VMUdxGexTsuiRaGp5en8T7EpHysiYV/DBca2n3N1tyy2I7SWn3QaYuOV385IBxeZNG9 X-Received: by 2002:a05:6808:114c:b0:3c1:c1e7:3363 with SMTP id u12-20020a056808114c00b003c1c1e73363mr2659448oiu.27.1709317295745; Fri, 01 Mar 2024 10:21:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709317295; cv=pass; d=google.com; s=arc-20160816; b=GhuCkWE4pWCCeg781qtTvPD+Pn2ywh82wSSZ95DddUYu6c6aygcjNKS5W7YbUCIXgJ QMCv0BWAc6MpuLEJDatsgXl8cGB7LRMSImFR4/q8a78lRex+O3rHVNaK9VxAAEE581J3 U5hLUrwiSERrFRK5V1akonOwozRnZHgq4mnC2H3441f/f4kMAn8SyVg/nUUn6xy53dHh JDLl/J/2xgWOnHC9erT43AKDgF+hvvErQrkjTq/9PUIJQoBXxw5NyyeQ14iQfvnLwlpN +yCQsvueTWg3OH48zFmv75+wmRaLoZIRoKV2slfy95V2l99CprYQTHkkERBZ+lY3XICw TiSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=RjgxOgwR3hfQlJJg6Qjf5HxAXyOf452TtTO3VE3wiQI=; fh=i1fHfqb3ms9PQICjX9LbYyHHX00fft5d6t57sCy1Fok=; b=PHCjq7PwooJlqIXFAvC78Y+1jSf7Ri4mgJ1+sPJszRvYq1JsXxTyqgDQE60xLIjtom hbaG4r0YRWnPh9TIz9/fHkjdCPWwZKaA/pDceEic4YEyOENyzzMfY46KoTT8IzXe7aKL sKS9Cl6lUIdldsKFnqv5KfRiRnLvDOucts1xtnjrV0eDUWsNJhCEzS5WEKjyBLJAiwM1 neECCOTP0jBOouXnfBfg3uG5kp0eRL+kuWQ8MKITs/3GhxedtQLOTVFb7hxxpZvbg5j7 HwxQ8TsR06+AGBRCAZ4UDwXTFn2f3vi+phX6tzzTRNDQUEriKWR6IZsiUTRIqYRllPcW U1CA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZZLSdb+N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88904-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88904-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j8-20020ac86648000000b0042eac5e2888si3803476qtp.688.2024.03.01.10.21.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:21:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88904-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZZLSdb+N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88904-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88904-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D0571C219A6 for ; Fri, 1 Mar 2024 18:21:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E22293B2A6; Fri, 1 Mar 2024 18:18:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZZLSdb+N" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E94733D0AD; Fri, 1 Mar 2024 18:18:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709317131; cv=none; b=sReflvjk6uT/OEyvPzRFMnJ9G1TNnSESSrzNqKZ1+/f1RLvTuId2cWf2sOO1RATQQpTVrpuOJC2GlGWP41GLfiXNoS9pLl0ePc0ZoEiPzWORV9elsyJtMzAo1Qrep7udk89xenCwyo9qocre784JrkiNKgWvqpNlXcaD1opqQbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709317131; c=relaxed/simple; bh=7lG7R/s1q6fLAI6wvapbUgxQWeobDoOOk1BJNjVurX4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Or917CM5yaIUWzt/08qHK+xktdyL2+Wcywd7eWnTAsKvHvSITmg7JJKh4IYV+exDJ5VG8lAfJhQzIbXsnOzCMtovs3N70EmQz9gLpJ2d+NmsxEaUOA077E70KIEzp+e/HfnQrBfQy02wGWro/9rVLsdVY8zZ/Jx9AuFLxDnvTH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZZLSdb+N; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6549C433C7; Fri, 1 Mar 2024 18:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709317130; bh=7lG7R/s1q6fLAI6wvapbUgxQWeobDoOOk1BJNjVurX4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZZLSdb+N5NXpJTaYIYXiX+5H/FwcVSGg7KIN7oClImmg/uIhgKsqdLpJQGB3P1kvy GW55w7Mm40vzu8sQu4oh9U8VZznVZwRS0iNfGvqnYC/OWJWW0JO1xNUQdYVuvVfL7l Uwzu8nlaDD7VMAdi55J7+NAyCBPhEtGoNQl8QftP758ufSa3kteXTCMbqQ5jHxabAb oLgXtVZQwmiS3qTgCGluX1UV3WuLps0Xxg2FMpFq69D1CBFakCFsHBxiIRdxdCc0tr swdofAUxMAkGfq2r2dGaJy5lO38SHv/uPj0tk9PvAsjzPJUKcdpugk5pC+dzdFsb3z ovHIzGB57YyNg== From: "Matthieu Baerts (NGI0)" Date: Fri, 01 Mar 2024 19:18:30 +0100 Subject: [PATCH net-next 06/15] mptcp: check userspace pm flags Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240301-upstream-net-next-20240301-mptcp-userspace-pm-dump-addr-v1-6-dc30a420b3a0@kernel.org> References: <20240301-upstream-net-next-20240301-mptcp-userspace-pm-dump-addr-v1-0-dc30a420b3a0@kernel.org> In-Reply-To: <20240301-upstream-net-next-20240301-mptcp-userspace-pm-dump-addr-v1-0-dc30a420b3a0@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Geliang Tang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2877; i=matttbe@kernel.org; h=from:subject:message-id; bh=nB2jr+h3crYGyM6lGO9/xWsi/9FVXdNk/IEW2/03A4s=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl4hv0aHCCdqzGFyKJ5B1lx+aiAndXV/nIkk7cf gU5gKvfPY+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeIb9AAKCRD2t4JPQmmg c/+xEADKUM0XrA6HwxFUnHiadXTzhVe8dW1u6ZBaWr4JMv7xPmJjZaP/RgATUAhPGYwrHWL/V4b LzYo4RGTjBHrwI0x+GgCgo+4CTCYDbbJt3M2bdfiSE+R7aILQZNfvGgPeXs1oyZfSCQFksx5Mqx TZ/B0tt7T9qsrdDQgc6AbghbmhotHY+i0/EV1lfFTRGlIiCE7xv5BQOu/gcNerMYtNz2JXvNBrK pQNWsTyxI2vSzcYuyT9rD7Lv3KN8waoTFh/3cbYH/86BpKekO5WMyf714T2nhUW6k/Dl/RmlDSo 7Y1gKUgJ08VttoK2ssbNc1GB3lyb3CBod1bkv7NrskKZoF9AlGt4IFPPGiUDtXez0+9CWVqft+8 c1pbaQfs2QQ2PstgzAn1Zn7aEVOH/RFo6raICKYhiH2u/6GogCzcwxwkyPHIsvKkT4zfgjzw0kV /A20TZlKSkpklyDvSPiXbSD0fW42ntSzYLBN3zPuiLlybL9Diz1J/LXOPEnUNq7MDgmbIIWe+dz tGZ/C/HrQgH1oGV9y6B4vwBM8RgmqhYKa2p8awI6muJnBV1u4ZGEKCw9uJPc8pq+H4/QtoiLm2e 2ZUX7A7DW9Phh0G0JKZKaOfLguGpkQKET0K3ronhYTxP5Mgb+aLokcgqRPaX7+VzEuEQ5x9AxMg z/Wc3YCbqsOvimw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792349092939463594 X-GMAIL-MSGID: 1792349092939463594 From: Geliang Tang Just like MPTCP_PM_ADDR_FLAG_SIGNAL flag is checked in userspace PM announce mptcp_pm_nl_announce_doit(), PM flags should be checked in mptcp_pm_nl_subflow_create_doit() too. If MPTCP_PM_ADDR_FLAG_SUBFLOW flag is not set, there's no flags field in the output of dump_addr. This looks a bit strange: id 10 flags 10.0.3.2 This patch uses mptcp_pm_parse_entry() instead of mptcp_pm_parse_addr() to get the PM flags of the entry and check it. MPTCP_PM_ADDR_FLAG_SIGNAL flag shouldn't be set here, and if MPTCP_PM_ADDR_FLAG_SUBFLOW flag is missing from the netlink attribute, always set this flag. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index d6b7be3afbe5..3bd13e94b568 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -334,7 +334,6 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry local = { 0 }; struct mptcp_addr_info addr_r; - struct mptcp_addr_info addr_l; struct mptcp_sock *msk; int err = -EINVAL; struct sock *sk; @@ -360,25 +359,31 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; } - err = mptcp_pm_parse_addr(laddr, info, &addr_l); + err = mptcp_pm_parse_entry(laddr, info, true, &local); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); goto create_err; } + if (local.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) { + GENL_SET_ERR_MSG(info, "invalid addr flags"); + err = -EINVAL; + goto create_err; + } + local.flags |= MPTCP_PM_ADDR_FLAG_SUBFLOW; + err = mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); goto create_err; } - if (!mptcp_pm_addr_families_match(sk, &addr_l, &addr_r)) { + if (!mptcp_pm_addr_families_match(sk, &local.addr, &addr_r)) { GENL_SET_ERR_MSG(info, "families mismatch"); err = -EINVAL; goto create_err; } - local.addr = addr_l; err = mptcp_userspace_pm_append_new_local_addr(msk, &local, false); if (err < 0) { GENL_SET_ERR_MSG(info, "did not match address and id"); @@ -387,7 +392,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) lock_sock(sk); - err = __mptcp_subflow_connect(sk, &addr_l, &addr_r); + err = __mptcp_subflow_connect(sk, &local.addr, &addr_r); release_sock(sk);