[PATCH mptcp-net v13] mptcp: hide sequence numbers in Netlink diagnostics

Kalpan Jani posted 1 patch 6 days, 15 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20261117050804.134954-1-kalpan.jani@mpiricsoftware.com
There is a newer version of this series
net/mptcp/mptcp_diag.c                        |   4 +
tools/testing/selftests/net/mptcp/diag.sh     |  13 ++
.../testing/selftests/net/mptcp/mptcp_diag.c  | 122 ++++++++++++++----
3 files changed, 115 insertions(+), 24 deletions(-)
[PATCH mptcp-net v13] mptcp: hide sequence numbers in Netlink diagnostics
Posted by Kalpan Jani 6 days, 15 hours ago
MPTCP Netlink diagnostics expose sequence numbers that can reveal
internal connection state.

Clear mptcpi_write_seq, mptcpi_snd_una and mptcpi_rcv_nxt in the
Netlink diagnostic callback.

Keep the getsockopt() interface and its reported sequence numbers
unchanged.

Add a selftest to verify that the sequence-number fields are zero in
Netlink diagnostic responses.

Fixes: ac3b45f60954 ("mptcp: add MPTCP socket diag interface")
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/445
Signed-off-by: Kalpan Jani <kalpan.jani@mpiricsoftware.com>
---
Changes since v12:
- Drop address-based sequence number normalization.
- Zero the three sequence-number fields in the Netlink diagnostic callback.
- Preserve sequence-number values reported through getsockopt().
- Add a selftest verifying zero sequence-number fields in Netlink diagnostics.
- Check NLMSG_DONE error status in the Netlink selftest.

v12: https://lore.kernel.org/all/20261106111645.786225-1-kalpan.jani@mpiricsoftware.com/
---
 net/mptcp/mptcp_diag.c                        |   4 +
 tools/testing/selftests/net/mptcp/diag.sh     |  13 ++
 .../testing/selftests/net/mptcp/mptcp_diag.c  | 122 ++++++++++++++----
 3 files changed, 115 insertions(+), 24 deletions(-)

diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c
index 136c2d05c0eeb..fe1603ce80162 100644
--- a/net/mptcp/mptcp_diag.c
+++ b/net/mptcp/mptcp_diag.c
@@ -215,6 +215,10 @@ static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
 		return;
 
 	mptcp_diag_fill_info(msk, info);
+
+	info->mptcpi_write_seq = 0;
+	info->mptcpi_snd_una = 0;
+	info->mptcpi_rcv_nxt = 0;
 }
 
 static const struct inet_diag_handler mptcp_diag_handler = {
diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index 27cbda68144e8..abe732a5c1c37 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -205,6 +205,7 @@ chk_dump_one()
 	local ss_token
 	local token
 	local msg
+	local zero_msg
 
 	ss_token="$(ss -inmHMN $ns |
 		    mptcp_lib_get_info_value "token" "token")"
@@ -223,6 +224,18 @@ chk_dump_one()
 		mptcp_lib_result_fail "${msg}"
 		ret=${KSFT_FAIL}
 	fi
+
+	zero_msg="....chk dump_one zero sequence fields"
+	mptcp_lib_print_title "$zero_msg"
+	if [ -n "$ss_token" ] &&
+	   ip netns exec "$ns" ./mptcp_diag -z -t "$ss_token"; then
+		mptcp_lib_pr_ok
+		mptcp_lib_result_pass "${zero_msg}"
+	else
+		mptcp_lib_pr_fail "MPTCP diagnostic sequence fields are not zero"
+		mptcp_lib_result_fail "${zero_msg}"
+		ret=${KSFT_FAIL}
+	fi
 }
 
 chk_dump_subflow()
diff --git a/tools/testing/selftests/net/mptcp/mptcp_diag.c b/tools/testing/selftests/net/mptcp/mptcp_diag.c
index 3b8d2c8a62160..6f72ca30d7c20 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_diag.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_diag.c
@@ -3,6 +3,7 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -29,6 +30,7 @@
 			    NLA_F_NESTED))
 
 struct params {
+	bool check_zero_seq;
 	__u32 target_token;
 	char subflow_addrs[1024];
 };
@@ -101,6 +103,7 @@ static void die_usage(int r)
 {
 	fprintf(stderr, "Usage:\n"
 			"mptcp_diag -t <token>\n"
+			"mptcp_diag -z -t <token>  (check zero sequence fields)\n"
 			"mptcp_diag -s \"<saddr>:<sport> <daddr>:<dport>\"\n");
 	exit(r);
 }
@@ -170,6 +173,22 @@ static void parse_rtattr_flags(struct rtattr *tb[], int max, struct rtattr *rta,
 	}
 }
 
+static bool check_zero_seq(struct mptcp_info *info)
+{
+	if (info->mptcpi_write_seq ||
+	    info->mptcpi_snd_una ||
+	    info->mptcpi_rcv_nxt) {
+		fprintf(stderr,
+			"Unexpected sequence values: write_seq=%llu snd_una=%llu rcv_nxt=%llu\n",
+			(unsigned long long)info->mptcpi_write_seq,
+			(unsigned long long)info->mptcpi_snd_una,
+			(unsigned long long)info->mptcpi_rcv_nxt);
+		return false;
+	}
+
+	return true;
+}
+
 static void print_info_msg(struct mptcp_info *info)
 {
 	printf("Token & Flags\n");
@@ -262,7 +281,7 @@ static void print_subflow_info(struct rtattr *tb[])
 	printf("\n");
 }
 
-static void parse_nlmsg(struct nlmsghdr *nlh, __u32 proto)
+static void parse_nlmsg(struct nlmsghdr *nlh, __u32 proto, bool check_zero, bool *seen_info)
 {
 	struct inet_diag_msg *r = NLMSG_DATA(nlh);
 	struct rtattr *tb[INET_DIAG_MAX + 1];
@@ -284,6 +303,11 @@ static void parse_nlmsg(struct nlmsghdr *nlh, __u32 proto)
 			info = RTA_DATA(tb[INET_DIAG_INFO]);
 		}
 		print_info_msg(info);
+		if (check_zero) {
+			*seen_info = true;
+			if (!check_zero_seq(info))
+				exit(EXIT_FAILURE);
+		}
 	}
 	if (proto == IPPROTO_TCP && tb[INET_DIAG_ULP_INFO]) {
 		struct rtattr *ulpinfo[INET_ULP_INFO_MAX + 1] = { 0 };
@@ -303,10 +327,10 @@ static void parse_nlmsg(struct nlmsghdr *nlh, __u32 proto)
 	}
 }
 
-static void recv_nlmsg(int fd, __u32 proto)
+static void recv_nlmsg(int fd, __u32 proto, bool check_zero)
 {
 	char rcv_buff[8192];
-	struct nlmsghdr *nlh = (struct nlmsghdr *)rcv_buff;
+	struct nlmsghdr *nlh;
 	struct sockaddr_nl rcv_nladdr = {
 		.nl_family = AF_NETLINK
 	};
@@ -320,28 +344,70 @@ static void recv_nlmsg(int fd, __u32 proto)
 		.msg_iov = &rcv_iov,
 		.msg_iovlen = 1
 	};
-	int len;
-
-	len = recvmsg(fd, &rcv_msg, 0);
-
-	while (NLMSG_OK(nlh, len)) {
-		if (nlh->nlmsg_type == NLMSG_DONE) {
-			printf("NLMSG_DONE\n");
-			break;
-		} else if (nlh->nlmsg_type == NLMSG_ERROR) {
-			struct nlmsgerr *err;
+	bool seen_info = false;
+	bool done = false;
+
+	while (!done) {
+		int len;
+
+		nlh = (struct nlmsghdr *)rcv_buff;
+		len = recvmsg(fd, &rcv_msg, 0);
+		if (len < 0)
+			die_perror("Netlink recvmsg");
+		if (!len) {
+			fprintf(stderr, "Empty Netlink response\n");
+			exit(EXIT_FAILURE);
+		}
 
-			err = (struct nlmsgerr *)NLMSG_DATA(nlh);
-			printf("Error %d:%s\n",
-			       -(err->error), strerror(-(err->error)));
-			break;
+		while (NLMSG_OK(nlh, len)) {
+			if (nlh->nlmsg_type == NLMSG_DONE) {
+				int error = 0;
+
+				if (nlh->nlmsg_len >= NLMSG_LENGTH(sizeof(error)))
+					memcpy(&error, NLMSG_DATA(nlh), sizeof(error));
+
+				if (error) {
+					fprintf(stderr, "Netlink dump failed: %s\n",
+						strerror(-error));
+					exit(EXIT_FAILURE);
+				}
+
+				done = true;
+				break;
+			} else if (nlh->nlmsg_type == NLMSG_ERROR) {
+				struct nlmsgerr *err;
+
+				err = (struct nlmsgerr *)NLMSG_DATA(nlh);
+				if (err->error) {
+					fprintf(stderr,
+						"Netlink request failed: %s\n",
+						strerror(-err->error));
+					exit(EXIT_FAILURE);
+				}
+			} else {
+				parse_nlmsg(nlh, proto, check_zero, &seen_info);
+
+				/*
+				 * Single-socket diagnostic responses are not
+				 * multipart and do not end with NLMSG_DONE.
+				 */
+				if (!(nlh->nlmsg_flags & NLM_F_MULTI)) {
+					done = true;
+					break;
+				}
+			}
+
+			nlh = NLMSG_NEXT(nlh, len);
 		}
-		parse_nlmsg(nlh, proto);
-		nlh = NLMSG_NEXT(nlh, len);
+	}
+
+	if (check_zero && !seen_info) {
+		fprintf(stderr, "No MPTCP diagnostic info received\n");
+		exit(EXIT_FAILURE);
 	}
 }
 
-static void get_mptcpinfo(__u32 token)
+static void get_mptcpinfo(__u32 token, bool check_zero)
 {
 	struct inet_diag_req_v2 r = {
 		.sdiag_family           = AF_INET,
@@ -358,7 +424,7 @@ static void get_mptcpinfo(__u32 token)
 		die_perror("Netlink socket");
 
 	send_query(fd, &r, proto);
-	recv_nlmsg(fd, proto);
+	recv_nlmsg(fd, proto, check_zero);
 
 	close(fd);
 }
@@ -394,7 +460,7 @@ static void get_subflow_info(char *subflow_addrs)
 	inet_pton(AF_INET, saddr, &r.id.idiag_src);
 	inet_pton(AF_INET, daddr, &r.id.idiag_dst);
 	send_query(fd, &r, IPPROTO_TCP);
-	recv_nlmsg(fd, IPPROTO_TCP);
+	recv_nlmsg(fd, IPPROTO_TCP, false);
 }
 
 static void parse_opts(int argc, char **argv, struct params *p)
@@ -404,8 +470,11 @@ static void parse_opts(int argc, char **argv, struct params *p)
 	if (argc < 2)
 		die_usage(1);
 
-	while ((c = getopt(argc, argv, "ht:s:")) != -1) {
+	while ((c = getopt(argc, argv, "ht:s:z")) != -1) {
 		switch (c) {
+		case 'z':
+			p->check_zero_seq = true;
+			break;
 		case 'h':
 			die_usage(0);
 			break;
@@ -429,8 +498,13 @@ int main(int argc, char *argv[])
 
 	parse_opts(argc, argv, &p);
 
+	if (p.check_zero_seq && !p.target_token) {
+		fprintf(stderr, "-z requires -t <token>\n");
+		return EXIT_FAILURE;
+	}
+
 	if (p.target_token)
-		get_mptcpinfo(p.target_token);
+		get_mptcpinfo(p.target_token, p.check_zero_seq);
 
 	if (p.subflow_addrs[0] != '\0')
 		get_subflow_info(p.subflow_addrs);
-- 
2.43.0
Re: [PATCH mptcp-net v13] mptcp: hide sequence numbers in Netlink diagnostics
Posted by Matthieu Baerts 3 days, 5 hours ago
Hi Kalpan,

On 17/11/2026 06:08, Kalpan Jani wrote:
> MPTCP Netlink diagnostics expose sequence numbers that can reveal
> internal connection state.
> 
> Clear mptcpi_write_seq, mptcpi_snd_una and mptcpi_rcv_nxt in the
> Netlink diagnostic callback.
> 
> Keep the getsockopt() interface and its reported sequence numbers
> unchanged.

Thank you for the new version!

> Add a selftest to verify that the sequence-number fields are zero in
> Netlink diagnostic responses.

I really don't think it is worth it to add ~110 lines just to check that
some values you explicitly set to 0 are indeed shown as is.

In general, you should split the code from the tests, (except eventually
if a modification breaks the tests, but I don't think that's the case
here). But especially here: that makes the fix hard to backport.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-net v13] mptcp: hide sequence numbers in Netlink diagnostics
Posted by netdev-bot+sashiko@kernel.org 5 days, 1 hour ago
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 3

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In net/mptcp/mptcp_diag.c, mptcp_diag_get_info() now always
  sets mptcpi_write_seq, mptcpi_snd_una and mptcpi_rcv_nxt to 0 in…
- [Medium] The new 'chk dump_one zero sequence fields' subtest in
  tools/testing/selftests/net/mptcp/diag.sh:chk_dump_one() hard-FAILs…
- [Low] The commit message does not say who the change protects against
  or what users will see change.
- [Low] diag.sh:chk_dump_one() calls `ip netns exec "$ns" ./mptcp_diag -z
  -t "$ss_token"` with no stdout redirect, between mptcp_lib_print_title…
- [Low] struct mptcp_info (include/uapi/linux/mptcp.h) is a single uAPI
  object with two producers that now disagree.

--

mptcp: hide sequence numbers in Netlink diagnostics

This commit zeroes mptcpi_write_seq, mptcpi_snd_una and mptcpi_rcv_nxt in
the MPTCP sock_diag INET_DIAG_INFO reply. The getsockopt() interface is
left unchanged. The mptcp_diag selftest helper gets a -z mode, and diag.sh
gets a subtest that checks these fields are zero.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/445

> MPTCP Netlink diagnostics expose sequence numbers that can reveal
> internal connection state.

[Severity: Low]
This isn't a bug, but could the commit message say who this change
protects against? For example, unprivileged users in the same netns
reading data-level sequence numbers of other users' MPTCP sockets through
sock_diag.

The message also doesn't say that these three fields become 0 over
netlink for every requester, including root and tools like ss -M. It only
says getsockopt() is unchanged.

The Fixes: tag means this user-visible change will go to stable. With the
current wording, it is hard for backporters to judge its impact or to
weigh it against CAP_NET_ADMIN gating.

> diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c
> index 136c2d05c0eeb..fe1603ce80162 100644
> --- a/net/mptcp/mptcp_diag.c
> +++ b/net/mptcp/mptcp_diag.c
> @@ -215,6 +215,10 @@ static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
>  		return;
>  
>  	mptcp_diag_fill_info(msk, info);
> +
> +	info->mptcpi_write_seq = 0;
> +	info->mptcpi_snd_una = 0;
> +	info->mptcpi_rcv_nxt = 0;

[Severity: Medium]
Does this also hide the values from CAP_NET_ADMIN callers? The fields are
cleared in mptcp_diag_get_info() for every sock_diag requester. Root
running ss -M -i, or a monitoring daemon, now always gets 0 where it used
to get the real msk-level data sequence values.

The subflow side of the same reply family already uses a different rule:

net/mptcp/diag.c:subflow_get_info() {
	...
	/* Only export seq related counters to user with CAP_NET_ADMIN */
	if (net_admin &&
	    (nla_put_u32(skb, MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ,
			 sf->rel_write_seq) ||
	     nla_put_u64_64bit(skb, MPTCP_SUBFLOW_ATTR_MAP_SEQ, sf->map_seq,
	...
}

The privilege bit is already in scope. mptcp_diag_dump_one() passes
netlink_net_capable(in_skb, CAP_NET_ADMIN) into inet_sk_diag_fill(), but
inet_sk_diag_fill() only hands it to idiag_get_aux():

net/ipv4/inet_diag.c:inet_sk_diag_fill() {
	...
	handler->idiag_get_info(sk, r, info);

	if (ext & (1 << (INET_DIAG_INFO - 1)) && handler->idiag_get_aux)
		if (handler->idiag_get_aux(sk, net_admin, skb) < 0)
	...
}

If the concern is unprivileged readers, would it fit better to gate these
fields on net_admin, as the subflow attributes are?

If the concern is all readers, a privileged user still receives
MPTCP_SUBFLOW_ATTR_MAP_SEQ, which is in the same data sequence space. Is
the hiding complete in that case?

The new selftest runs as root and requires zeros, so it would lock in the
unconditional behaviour. The Fixes: tag also carries this into stable.

[Severity: Low]
Is it intended that struct mptcp_info now has two producers that disagree?
getsockopt(MPTCP_INFO) and getsockopt(MPTCP_FULL_INFO) go through
mptcp_diag_fill_info() in net/mptcp/sockopt.c and still report the real
values:

	info->mptcpi_write_seq = msk->write_seq;
	...
	info->mptcpi_snd_una = msk->snd_una;
	info->mptcpi_rcv_nxt = msk->ack_seq;

INET_DIAG_INFO now always reports 0 for the same fields. Nothing in
include/uapi/linux/mptcp.h or in mptcpi_flags marks the values as
suppressed.

How would a netlink consumer tell a hidden value from a real 0? A
TCP_LISTEN msk, for example, really does report 0, because
mptcp_diag_fill_info() returns right after the memset(). The in-tree
print_info_msg() also still prints these fields as if they were real.

Should the per-interface meaning of these fields be documented?

>  }

[ ... ]

> diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
> index 27cbda68144e8..abe732a5c1c37 100755
> --- a/tools/testing/selftests/net/mptcp/diag.sh
> +++ b/tools/testing/selftests/net/mptcp/diag.sh

[ ... ]

> @@ -223,6 +224,18 @@ chk_dump_one()
>  		mptcp_lib_result_fail "${msg}"
>  		ret=${KSFT_FAIL}
>  	fi
> +
> +	zero_msg="....chk dump_one zero sequence fields"
> +	mptcp_lib_print_title "$zero_msg"
> +	if [ -n "$ss_token" ] &&
> +	   ip netns exec "$ns" ./mptcp_diag -z -t "$ss_token"; then

[Severity: Low]
Should stdout be redirected here? Even in -z mode, parse_nlmsg() in
mptcp_diag.c prints the full info block before it runs the check:

		print_info_msg(info);
		if (check_zero) {

This puts about 30 lines of info output between the title and the result
marker. The other two mptcp_diag call sites in chk_dump_one() and
chk_dump_subflow() pipe the output through awk or grep.

The failure text "MPTCP diagnostic sequence fields are not zero" is also
printed for every failure of this condition. That includes an empty
$ss_token, where the tool never runs.

It also covers the other non-zero exits this patch adds to the tool:
a recvmsg error, "Empty Netlink response", "Netlink dump failed",
"Netlink request failed" and "No MPTCP diagnostic info received". Could
the message be made more generic?

> +		mptcp_lib_pr_ok
> +		mptcp_lib_result_pass "${zero_msg}"
> +	else
> +		mptcp_lib_pr_fail "MPTCP diagnostic sequence fields are not zero"
> +		mptcp_lib_result_fail "${zero_msg}"
> +		ret=${KSFT_FAIL}
> +	fi

[Severity: Medium]
Will this subtest fail outright on kernels without this change?

On an older or stable kernel, mptcp_diag -z sees non-zero write_seq,
snd_una and rcv_nxt. check_zero_seq() then returns false, the tool calls
exit(EXIT_FAILURE), and this branch sets ret=${KSFT_FAIL}.

__chk_nr() in the same file handles unsupported features like this:

		if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then
			mptcp_lib_pr_skip "Feature probably not supported"

Should this subtest report a skip in the same way when
mptcp_lib_expect_all_features is false?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117050804.134954-1-kalpan.jani%40mpiricsoftware.com
Re: [PATCH mptcp-net v13] mptcp: hide sequence numbers in Netlink diagnostics
Posted by Matthieu Baerts 3 days, 5 hours ago
Hi Kalpan,

On 18/11/2026 19:53, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 5 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 2 · Low: 3
> 
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
> 
> - [Medium] In net/mptcp/mptcp_diag.c, mptcp_diag_get_info() now always
>   sets mptcpi_write_seq, mptcpi_snd_una and mptcpi_rcv_nxt to 0 in…
> - [Medium] The new 'chk dump_one zero sequence fields' subtest in
>   tools/testing/selftests/net/mptcp/diag.sh:chk_dump_one() hard-FAILs…
> - [Low] The commit message does not say who the change protects against
>   or what users will see change.
> - [Low] diag.sh:chk_dump_one() calls `ip netns exec "$ns" ./mptcp_diag -z
>   -t "$ss_token"` with no stdout redirect, between mptcp_lib_print_title…
> - [Low] struct mptcp_info (include/uapi/linux/mptcp.h) is a single uAPI
>   object with two producers that now disagree.
> 
> --
> 
> mptcp: hide sequence numbers in Netlink diagnostics
> 
> This commit zeroes mptcpi_write_seq, mptcpi_snd_una and mptcpi_rcv_nxt in
> the MPTCP sock_diag INET_DIAG_INFO reply. The getsockopt() interface is
> left unchanged. The mptcp_diag selftest helper gets a -z mode, and diag.sh
> gets a subtest that checks these fields are zero.
> 
> Link: https://github.com/multipath-tcp/mptcp_net-next/issues/445
> 
>> MPTCP Netlink diagnostics expose sequence numbers that can reveal
>> internal connection state.
> 
> [Severity: Low]
> This isn't a bug, but could the commit message say who this change
> protects against? For example, unprivileged users in the same netns
> reading data-level sequence numbers of other users' MPTCP sockets through
> sock_diag.
> 
> The message also doesn't say that these three fields become 0 over
> netlink for every requester, including root and tools like ss -M. It only
> says getsockopt() is unchanged.

I guess the commit message can indeed be clearer: "sequence numbers that
can reveal internal connection state" is a bit vague. We can say that
the TCP seq num are not exposed for the same reasons: not to let someone
else on the machine getting access to them which can eventually be used
to mess with the connection by injecting some specific packets.

>> diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c
>> index 136c2d05c0eeb..fe1603ce80162 100644
>> --- a/net/mptcp/mptcp_diag.c
>> +++ b/net/mptcp/mptcp_diag.c
>> @@ -215,6 +215,10 @@ static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
>>  		return;
>>  
>>  	mptcp_diag_fill_info(msk, info);
>> +
>> +	info->mptcpi_write_seq = 0;
>> +	info->mptcpi_snd_una = 0;
>> +	info->mptcpi_rcv_nxt = 0;
> 
> [Severity: Medium]
> Does this also hide the values from CAP_NET_ADMIN callers? The fields are
> cleared in mptcp_diag_get_info() for every sock_diag requester. Root
> running ss -M -i, or a monitoring daemon, now always gets 0 where it used
> to get the real msk-level data sequence values.
> 
> The subflow side of the same reply family already uses a different rule:
> 
> net/mptcp/diag.c:subflow_get_info() {
> 	...
> 	/* Only export seq related counters to user with CAP_NET_ADMIN */
> 	if (net_admin &&
> 	    (nla_put_u32(skb, MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ,
> 			 sf->rel_write_seq) ||
> 	     nla_put_u64_64bit(skb, MPTCP_SUBFLOW_ATTR_MAP_SEQ, sf->map_seq,
> 	...
> }
> 
> The privilege bit is already in scope. mptcp_diag_dump_one() passes
> netlink_net_capable(in_skb, CAP_NET_ADMIN) into inet_sk_diag_fill(), but
> inet_sk_diag_fill() only hands it to idiag_get_aux():
> 
> net/ipv4/inet_diag.c:inet_sk_diag_fill() {
> 	...
> 	handler->idiag_get_info(sk, r, info);
> 
> 	if (ext & (1 << (INET_DIAG_INFO - 1)) && handler->idiag_get_aux)
> 		if (handler->idiag_get_aux(sk, net_admin, skb) < 0)
> 	...
> }
> 
> If the concern is unprivileged readers, would it fit better to gate these
> fields on net_admin, as the subflow attributes are?
> 
> If the concern is all readers, a privileged user still receives
> MPTCP_SUBFLOW_ATTR_MAP_SEQ, which is in the same data sequence space. Is
> the hiding complete in that case?
> 
> The new selftest runs as root and requires zeros, so it would lock in the
> unconditional behaviour. The Fixes: tag also carries this into stable.

The commit message can explain why: ideally, it would be good to only
reset these fields for unprivileged readers, but with the current
architecture, we cannot distinguish the different readers. So we keep
this fix small for the moment.

> [Severity: Low]
> Is it intended that struct mptcp_info now has two producers that disagree?
> getsockopt(MPTCP_INFO) and getsockopt(MPTCP_FULL_INFO) go through
> mptcp_diag_fill_info() in net/mptcp/sockopt.c and still report the real
> values:
> 
> 	info->mptcpi_write_seq = msk->write_seq;
> 	...
> 	info->mptcpi_snd_una = msk->snd_una;
> 	info->mptcpi_rcv_nxt = msk->ack_seq;
> 
> INET_DIAG_INFO now always reports 0 for the same fields. Nothing in
> include/uapi/linux/mptcp.h or in mptcpi_flags marks the values as
> suppressed.
> 
> How would a netlink consumer tell a hidden value from a real 0? A
> TCP_LISTEN msk, for example, really does report 0, because
> mptcp_diag_fill_info() returns right after the memset(). The in-tree
> print_info_msg() also still prints these fields as if they were real.
> 
> Should the per-interface meaning of these fields be documented?

Also for the commit message: yes, that's intended. That's OK, the seq
nums shouldn't have been exposed initially, and don't have a lot of
value for Netlink readers. Instead, they can have access to other info
from TCP subflows, or the bytes sent/received.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.

Re: [PATCH mptcp-net v13] mptcp: hide sequence numbers in Netlink diagnostics
Posted by MPTCP CI 6 days, 13 hours ago
Hi Kalpan,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Unstable: 1 failed test(s): validation:sched-weak-secondary ⚠️ 
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/44024671433

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/bd9eb2c9b4cb
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1213422


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)