From nobody Mon Nov 23 20:21:23 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.54 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793963821; b=ucfXoVLu1UeOtfO/wi4OS1fiN0qi6YTI2953wIetaWigBYT0Enqz/hHoitipWpYT6IH+ 8R+a02bgTN5bOsUOrdrYLOOokMEE9DxWX2nNIzsZVzGK1S4s5ijPfVjcWHgbk9l5iVc7o KGwa79RvW2j4pb/GnkydI7yiWJXsF2kiTlu6ltdAhYRzLM9uBcYTdt1tMWKlYZcuvRJal EGG5TLReQNahqwbXzoCOLG4i10wYbOdpDq72fNg+44DfaiqyTUlOJ3Mx89CSj6Y2E+rHX lvOxhNBcaz5H8H3GE3tMkUZu4Kcawr+PILNTwxX9LnYuImGxzp3akeyXJdqVgc++kBw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793963821; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-ZohoMailClient; bh=cwGH8Evc1SAVfmlRxY9B22vYUgw0i2hZd7M8QHRkkLY=; b=PDp6By44MtyI9b1UstslJ0xWT3jc1z6hyMRux8UOgfcEVM1Er4JvTNHiPmEW8YJDXLFi Vnv4aeu1Q5krh9ofOx5lqIzrZq6twrYzYOmK8ve8maaQO4S4AiuvjstDdzs7DAulPFUeW Tqs6CD3rZTXOMdO7UnYr0JXFVqp2b5BdmLaYKbyOPLhL6ax0YORPLloI7f4foKbPHW3wR pz8ZADnNs481W9n9P+MjhoQ0nq51CB3SPpCNdhS93wM6K3pUUILKVrtVhyNetxjZGQNvD 8pMH3lgRefem0DNxcXW2FMqh8p/y6CefwfSXPS40Jk7+1SRSBAC8pzDX+EaynprZGkA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=mpiricsoftware.com; spf=pass smtp.mailfrom=mpiricsoftware.com; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.54 Received: from sender6-of-o54.zoho.com (sender6-of-o54.zoho.com [165.173.180.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7199E606A326 for ; Fri, 6 Nov 2026 11:17:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7199E606A326 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mpiricsoftware.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mpiricsoftware.com ARC-Seal: i=1; a=rsa-sha256; t=1793963817; cv=none; d=zohomail.com; s=zohoarc; b=lR2oEoUdgkq68nryoOxs4/JwXph1zhCzNSTEDvv4QALIt9qXrKLJe2VmL1KDFTi1pfSBr6FRkYgoPq0HWlXJqO1IwU/1lP/e7nelrxHK90nU8oCf9q4uB9hx3SlVuwFiBEakuUwRTAgp7bcNG0i7QYdVd5K9lBoBrRL5Z51L1E0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793963817; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=cwGH8Evc1SAVfmlRxY9B22vYUgw0i2hZd7M8QHRkkLY=; b=H3W4RsPPvkQqvPiTxFDkLchen9NB/2qxlzfscUmGP1UPDJAZEwvfiPbobFSJ3RHBTniuIl7BZMJ0c019Kx4zmgggEl6CbFlh20eQWTWEhjaCWITNfuHmNsTpusnySdh3BFPVjjoCN5dRXBKi9v700F9t2caeM79ezuijRiy/IKQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=mpiricsoftware.com; spf=pass smtp.mailfrom=kalpan.jani@mpiricsoftware.com; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=sXxzjJLx2lZMf6t9DIHsDNDVzaZERzjmGhl0ScLsZMgRi6YaaPOryCU+Ps26vH4mj15qu9Ippwp5Vh+7qV1hhnIFhTHtsHKEV1z6MWJJ6u1uQwlRrd/Thx2x2eT5v3vnZFaQJ2caons/JabOfmE6EkTY2pxpQ76j8v8TZa/Xd+8=; c=relaxed/relaxed; s=mpiric; d=mpiricsoftware.com; v=1; bh=cwGH8Evc1SAVfmlRxY9B22vYUgw0i2hZd7M8QHRkkLY=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1793963816572483.56885533266245; Fri, 6 Nov 2026 03:16:56 -0800 (PST) From: Kalpan Jani To: mptcp@lists.linux.dev Cc: shardul.b@mpiricsoftware.com, janak@mpiric.us, kalpanjani009@gmail.com, Kalpan Jani Subject: [RFC net-next v12] mptcp: normalize sequence numbers using socket address Date: Fri, 6 Nov 2026 16:46:45 +0530 Message-ID: <20261106111645.786225-1-kalpan.jani@mpiricsoftware.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Use the MPTCP socket address as an offset when reporting write_seq, snd_una, ack_seq and map_seq. This removes the need to maintain separate local_idsn and remote_idsn fields for sequence number normalization. With normalized sequence numbers available in MPTCP diagnostics, remove the masking of MPTCP-level sequence fields for unprivileged users while retaining the existing net_admin checks for sensitive subflow diagnostic attributes. Update the inet_diag get_info callback signature accordingly across the affected protocol implementations. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/445 Signed-off-by: Kalpan Jani --- Changes since v11: - Replace CAP_NET_ADMIN-based sequence counter masking with sequence-number normalization using the MPTCP socket address. - Remove the net_admin argument from idiag_get_info callbacks, as MPTCP-level sequence counters are now normalized. - Remove local_idsn and remote_idsn fields and their assignments. - Normalize MPTCP subflow map_seq using the MPTCP socket address instead of remote_idsn. - Consolidate the previous two-patch approach into a single sequence-number normalization patch. v11: https://lore.kernel.org/all/20261028082704.1609493-1-kalpan.jani@mpiri= csoftware.com/ --- include/linux/inet_diag.h | 2 +- net/ipv4/inet_diag.c | 6 +++--- net/ipv4/raw_diag.c | 2 +- net/ipv4/tcp_diag.c | 2 +- net/ipv4/udp_diag.c | 2 +- net/mptcp/diag.c | 5 ++--- net/mptcp/mptcp_diag.c | 9 +-------- net/mptcp/protocol.c | 4 ---- net/mptcp/protocol.h | 2 -- net/mptcp/sockopt.c | 13 ++++--------- net/mptcp/subflow.c | 1 - net/sctp/diag.c | 6 +++--- 12 files changed, 17 insertions(+), 37 deletions(-) diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h index 85f6278d5db1d..704fd415c2b49 100644 --- a/include/linux/inet_diag.h +++ b/include/linux/inet_diag.h @@ -18,7 +18,7 @@ struct inet_diag_handler { =20 void (*idiag_get_info)(struct sock *sk, struct inet_diag_msg *r, - void *info, bool net_admin); + void *info); =20 int (*idiag_get_aux)(struct sock *sk, bool net_admin, diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 362161bf39fe3..34b77aa87d0a4 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -276,7 +276,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_conn= ection_sock *icsk, } =20 if (!icsk) { - handler->idiag_get_info(sk, r, NULL, net_admin); + handler->idiag_get_info(sk, r, NULL); goto out; } =20 @@ -327,7 +327,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_conn= ection_sock *icsk, goto errout; } =20 - handler->idiag_get_info(sk, r, info, net_admin); + handler->idiag_get_info(sk, r, info); =20 if (ext & (1 << (INET_DIAG_INFO - 1)) && handler->idiag_get_aux) if (handler->idiag_get_aux(sk, net_admin, skb) < 0) @@ -1027,7 +1027,7 @@ int inet_diag_handler_get_info(struct sk_buff *skb, s= truct sock *sk) if (attr) info =3D nla_data(attr); =20 - handler->idiag_get_info(sk, r, info, false); + handler->idiag_get_info(sk, r, info); inet_diag_unlock_handler(handler); =20 nlmsg_end(skb, nlh); diff --git a/net/ipv4/raw_diag.c b/net/ipv4/raw_diag.c index 264912d0cb9fc..943e5998e0ad5 100644 --- a/net/ipv4/raw_diag.c +++ b/net/ipv4/raw_diag.c @@ -185,7 +185,7 @@ static void raw_diag_dump(struct sk_buff *skb, struct n= etlink_callback *cb, } =20 static void raw_diag_get_info(struct sock *sk, struct inet_diag_msg *r, - void *info, bool net_admin) + void *info) { r->idiag_rqueue =3D sk_rmem_alloc_get(sk); r->idiag_wqueue =3D sk_wmem_alloc_get(sk); diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c index cac32575282e3..ba1fdbe9807fd 100644 --- a/net/ipv4/tcp_diag.c +++ b/net/ipv4/tcp_diag.c @@ -19,7 +19,7 @@ #include =20 static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, - void *_info, bool net_admin) + void *_info) { struct tcp_info *info =3D _info; =20 diff --git a/net/ipv4/udp_diag.c b/net/ipv4/udp_diag.c index 5a1fa627cbee8..f4b24e628cf8d 100644 --- a/net/ipv4/udp_diag.c +++ b/net/ipv4/udp_diag.c @@ -142,7 +142,7 @@ static void udp_diag_dump(struct sk_buff *skb, struct n= etlink_callback *cb, } =20 static void udp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, - void *info, bool net_admin) + void *info) { r->idiag_rqueue =3D udp_rqueue_get(sk); r->idiag_wqueue =3D sk_wmem_alloc_get(sk); diff --git a/net/mptcp/diag.c b/net/mptcp/diag.c index 590cdee419ef9..66695d17a63cc 100644 --- a/net/mptcp/diag.c +++ b/net/mptcp/diag.c @@ -16,7 +16,7 @@ static int subflow_get_info(struct sock *sk, struct sk_bu= ff *skb, bool net_admin { struct mptcp_subflow_context *sf; struct nlattr *start; - u64 map_seq; + u64 map_seq =3D 0; u32 flags =3D 0; bool slow; int err; @@ -36,10 +36,9 @@ static int subflow_get_info(struct sock *sk, struct sk_b= uff *skb, bool net_admin goto nla_failure; } =20 - map_seq =3D 0; if (sf->conn && sf->map_seq) map_seq =3D sf->map_seq - - READ_ONCE(mptcp_sk(sf->conn)->remote_idsn); + (unsigned long)mptcp_sk(sf->conn); =20 if (sf->mp_capable) flags |=3D MPTCP_SUBFLOW_FLAG_MCAP_REM; diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c index d526b1015da16..136c2d05c0eeb 100644 --- a/net/mptcp/mptcp_diag.c +++ b/net/mptcp/mptcp_diag.c @@ -190,7 +190,7 @@ static void mptcp_diag_dump(struct sk_buff *skb, struct= netlink_callback *cb, } =20 static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, - void *_info, bool net_admin) + void *_info) { struct mptcp_sock *msk =3D mptcp_sk(sk); struct mptcp_info *info =3D _info; @@ -215,13 +215,6 @@ static void mptcp_diag_get_info(struct sock *sk, struc= t inet_diag_msg *r, return; =20 mptcp_diag_fill_info(msk, info); - - if (!net_admin) { - /* Hide data sequence numbers from unprivileged users. */ - info->mptcpi_write_seq =3D 0; - info->mptcpi_snd_una =3D 0; - info->mptcpi_rcv_nxt =3D 0; - } } =20 static const struct inet_diag_handler mptcp_diag_handler =3D { diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e59209b6fc41c..f22d64ab1c53b 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3216,8 +3216,6 @@ static void __mptcp_init_sock(struct sock *sk) INIT_WORK(&msk->work, mptcp_worker); msk->out_of_order_queue =3D RB_ROOT; msk->first_pending =3D NULL; - WRITE_ONCE(msk->local_idsn, 0); - WRITE_ONCE(msk->remote_idsn, 0); =20 /* msk does not go through tcp_init_sock(); seed RTO bounds. */ icsk->icsk_rto_min =3D @@ -3765,7 +3763,6 @@ struct sock *mptcp_sk_clone_init(const struct sock *s= k, =20 msk =3D mptcp_sk(nsk); WRITE_ONCE(msk->local_key, subflow_req->local_key); - WRITE_ONCE(msk->local_idsn, subflow_req->idsn); WRITE_ONCE(msk->token, subflow_req->token); msk->in_accept_queue =3D 1; WRITE_ONCE(msk->fully_established, false); @@ -4204,7 +4201,6 @@ static int mptcp_connect(struct sock *sk, struct sock= addr_unsized *uaddr, MPTCP_MIB_TOKENFALLBACKINIT); } =20 - WRITE_ONCE(msk->local_idsn, subflow->idsn); WRITE_ONCE(msk->write_seq, subflow->idsn); WRITE_ONCE(msk->snd_nxt, subflow->idsn); WRITE_ONCE(msk->snd_una, subflow->idsn); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index fc6858863fa89..3d250e8204d52 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -288,8 +288,6 @@ struct mptcp_sock { * lockless access read */ u64 remote_key; /* same as above */ - u64 local_idsn; - u64 remote_idsn; u64 write_seq; u64 bytes_sent; u64 snd_nxt; diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index b20263b4cd55c..6ee9dcfea5c79 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1047,7 +1047,7 @@ static int mptcp_getsockopt_first_sf_only(struct mptc= p_sock *msk, int level, int void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) { struct sock *sk =3D (struct sock *)msk; - u64 local_idsn =3D 0, remote_idsn =3D 0; + u64 offset =3D (unsigned long)msk; u32 flags =3D 0; bool slow; u32 now; @@ -1085,11 +1085,9 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, st= ruct mptcp_info *info) info->mptcpi_flags =3D flags; =20 slow =3D lock_sock_fast(sk); - local_idsn =3D READ_ONCE(msk->local_idsn); - info->mptcpi_csum_enabled =3D READ_ONCE(msk->csum_enabled); info->mptcpi_token =3D msk->token; - info->mptcpi_write_seq =3D msk->write_seq - local_idsn; + info->mptcpi_write_seq =3D msk->write_seq - offset; info->mptcpi_retransmits =3D inet_csk(sk)->icsk_retransmits; info->mptcpi_bytes_sent =3D msk->bytes_sent; info->mptcpi_bytes_received =3D msk->bytes_received; @@ -1102,20 +1100,17 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, s= truct mptcp_info *info) unlock_sock_fast(sk, slow); =20 mptcp_data_lock(sk); - if (READ_ONCE(msk->can_ack)) - remote_idsn =3D READ_ONCE(msk->remote_idsn); info->mptcpi_last_ack_recv =3D jiffies_to_msecs(now - msk->last_ack_recv); - info->mptcpi_snd_una =3D msk->snd_una - local_idsn; - info->mptcpi_rcv_nxt =3D msk->ack_seq - remote_idsn; + info->mptcpi_snd_una =3D msk->snd_una - offset; + info->mptcpi_rcv_nxt =3D msk->ack_seq - offset; info->mptcpi_bytes_acked =3D msk->bytes_acked; mptcp_data_unlock(sk); - } EXPORT_SYMBOL_GPL(mptcp_diag_fill_info); =20 static int mptcp_getsockopt_info(struct mptcp_sock *msk, char __user *optv= al, int __user *optlen) { struct mptcp_info m_info =3D {}; int len; =20 if (get_user(len, optlen)) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 39c7422afa779..55de605226ad0 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -490,12 +490,11 @@ static void subflow_set_remote_key(struct mptcp_sock = *msk, subflow->map_seq =3D subflow->iasn; =20 WRITE_ONCE(msk->remote_key, subflow->remote_key); - WRITE_ONCE(msk->remote_idsn, subflow->iasn - 1); WRITE_ONCE(msk->ack_seq, subflow->iasn); WRITE_ONCE(msk->can_ack, true); atomic64_set(&msk->rcv_wnd_sent, subflow->iasn); =20 /* publish last, once iasn and the fields above are fully populated */ subflow->remote_key_valid =3D 1; } =20 diff --git a/net/sctp/diag.c b/net/sctp/diag.c index ab6c560fde053..c2a0de2adf6fd 100644 --- a/net/sctp/diag.c +++ b/net/sctp/diag.c @@ -20,7 +20,7 @@ #include =20 static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, - void *info, bool net_admin); + void *info); =20 /* define some functions to make asoc/ep fill look clean */ static void inet_diag_msg_sctpasoc_fill(struct inet_diag_msg *r, @@ -200,7 +200,7 @@ static int inet_sctp_diag_fill(struct sock *sk, struct = sctp_association *asoc, } infox.sctpinfo =3D (struct sctp_info *)info; infox.asoc =3D asoc; - sctp_diag_get_info(sk, r, &infox, net_admin); + sctp_diag_get_info(sk, r, &infox); =20 addr_list =3D asoc ? &asoc->base.bind_addr.address_list : &ep->base.bind_addr.address_list; @@ -412,7 +412,7 @@ static int sctp_ep_dump(struct sctp_endpoint *ep, void = *p) =20 /* define the functions for sctp_diag_handler*/ static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, - void *info, bool net_admin) + void *info) { struct sctp_infox *infox =3D (struct sctp_infox *)info; =20 --=20 2.43.0