From: Kalpan Jani <kalpan.jani@mpiricsoftware.com>
To: mptcp@lists.linux.dev
Cc: matttbe@kernel.org, Kalpan Jani <kalpan.jani@mpiricsoftware.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Neal Cardwell <ncardwell@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Xin Long <lucien.xin@gmail.com>, Kees Cook <kees@kernel.org>,
David Ahern <dsahern@kernel.org>,
Willem de Bruijn <willemb@google.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-sctp@vger.kernel.org
Subject: [RFC net-next v11 1/2] inet_diag: pass net_admin to get_info
Date: Wed, 28 Oct 2026 13:57:00 +0530 [thread overview]
Message-ID: <20261028082704.1609493-2-kalpan.jani@mpiricsoftware.com> (raw)
In-Reply-To: <20261028082704.1609493-1-kalpan.jani@mpiricsoftware.com>
Pass the request's CAP_NET_ADMIN status to idiag_get_info()
so protocol-specific diagnostic handlers can restrict privileged
information.
Socket-destruction notifications have no individual requesting user,
so the callback receives net_admin set to false for that path.
Signed-off-by: Kalpan Jani <kalpan.jani@mpiricsoftware.com>
---
include/linux/inet_diag.h | 3 ++-
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/mptcp_diag.c | 2 +-
net/sctp/diag.c | 6 +++---
7 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index 704fd415c2b49..8db96bfd3e67f 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -18,7 +18,8 @@ struct inet_diag_handler {
void (*idiag_get_info)(struct sock *sk,
struct inet_diag_msg *r,
- void *info);
+ void *info,
+ bool net_admin);
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 34b77aa87d0a4..362161bf39fe3 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_connection_sock *icsk,
}
if (!icsk) {
- handler->idiag_get_info(sk, r, NULL);
+ handler->idiag_get_info(sk, r, NULL, net_admin);
goto out;
}
@@ -327,7 +327,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
goto errout;
}
- handler->idiag_get_info(sk, r, info);
+ handler->idiag_get_info(sk, r, info, net_admin);
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, struct sock *sk)
if (attr)
info = nla_data(attr);
- handler->idiag_get_info(sk, r, info);
+ handler->idiag_get_info(sk, r, info, false);
inet_diag_unlock_handler(handler);
nlmsg_end(skb, nlh);
diff --git a/net/ipv4/raw_diag.c b/net/ipv4/raw_diag.c
index 943e5998e0ad5..264912d0cb9fc 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 netlink_callback *cb,
}
static void raw_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
- void *info)
+ void *info, bool net_admin)
{
r->idiag_rqueue = sk_rmem_alloc_get(sk);
r->idiag_wqueue = sk_wmem_alloc_get(sk);
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index ba1fdbe9807fd..cac32575282e3 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -19,7 +19,7 @@
#include <net/tcp.h>
static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
- void *_info)
+ void *_info, bool net_admin)
{
struct tcp_info *info = _info;
diff --git a/net/ipv4/udp_diag.c b/net/ipv4/udp_diag.c
index f4b24e628cf8d..5a1fa627cbee8 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 netlink_callback *cb,
}
static void udp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
- void *info)
+ void *info, bool net_admin)
{
r->idiag_rqueue = udp_rqueue_get(sk);
r->idiag_wqueue = sk_wmem_alloc_get(sk);
diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c
index 136c2d05c0eeb..9ed7a6be1e628 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,
}
static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
- void *_info)
+ void *_info, bool net_admin)
{
struct mptcp_sock *msk = mptcp_sk(sk);
struct mptcp_info *info = _info;
diff --git a/net/sctp/diag.c b/net/sctp/diag.c
index c2a0de2adf6fd..ab6c560fde053 100644
--- a/net/sctp/diag.c
+++ b/net/sctp/diag.c
@@ -20,7 +20,7 @@
#include <net/sctp/sctp.h>
static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
- void *info);
+ void *info, bool net_admin);
/* 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 = (struct sctp_info *)info;
infox.asoc = asoc;
- sctp_diag_get_info(sk, r, &infox);
+ sctp_diag_get_info(sk, r, &infox, net_admin);
addr_list = 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)
/* define the functions for sctp_diag_handler*/
static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
- void *info)
+ void *info, bool net_admin)
{
struct sctp_infox *infox = (struct sctp_infox *)info;
--
2.43.0
next parent reply other threads:[~2026-10-28 8:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1ec0c2b5-a0fa-44e8-9ae8-dca9b7f90ec6@kernel.org>
[not found] ` <20261028082704.1609493-1-kalpan.jani@mpiricsoftware.com>
2026-10-28 8:27 ` Kalpan Jani [this message]
2026-10-28 8:31 ` netdev-bot+sinfo
2026-10-28 8:27 ` [RFC net-next v11 2/2] mptcp: hide seq counters without net_admin Kalpan Jani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261028082704.1609493-2-kalpan.jani@mpiricsoftware.com \
--to=kalpan.jani@mpiricsoftware.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®