mptcp: gate diag sequence counters on CAP_NET_ADMIN
In net/mptcp/diag.c, subflow_get_info() restricts MPTCP sequence-related
subflow attributes (rel_write_seq, map_seq, map_subflow_seq, ssn_offset)
to callers holding CAP_NET_ADMIN in the network namespace.
However, mptcp_diag_get_info() unconditionally exports mptcpi_write_seq,
mptcpi_snd_una, and mptcpi_rcv_nxt via INET_DIAG_INFO because
.idiag_get_info does not receive the caller's net_admin status. Any
unprivileged local user can therefore dump or query cross-UID MPTCP
sockets by token via SOCK_DIAG_BY_FAMILY and read live 64-bit MPTCP Data
Sequence Numbers.
Emit INET_DIAG_INFO from an .idiag_get_aux callback in mptcp_diag (which
already receives net_admin from inet_sk_diag_fill(), while msk never
sets icsk_ca_ops so netlink attribute ordering is unchanged) and zero
mptcpi_write_seq, mptcpi_snd_una, and mptcpi_rcv_nxt when !net_admin.
getsockopt(SOL_MPTCP, MPTCP_INFO) for the socket owner and token-based
lookup in mptcp_diag_dump_one() remain unchanged.
This issue was discovered with an AI-assisted code review tool (ARTIST)
and reproduced in QEMU/KVM on an unmodified v7.4-rc3 kernel without
kernel modifications or error injection.
Fixes: ac3b45f60954 ("mptcp: add MPTCP socket diag interface")
Cc: stable@vger.kernel.org
Signed-off-by: Dominik Maier <dmnk@google.com>
Tested-by: Kalpan Jani <kalpan.jani@mpiricsoftware.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20261119192159.2646113-1-dmnk@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 file changed