From: Jakub Kicinski <kuba@kernel.org>
To: Dmitry Safonov via B4 Relay <devnull+0x7f454c46.gmail.com@kernel.org>
Cc: 0x7f454c46@gmail.com, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
David Ahern <dsahern@kernel.org>,
Ivan Delalande <colona@arista.com>,
Matthieu Baerts <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Davide Caratti <dcaratti@redhat.com>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
mptcp@lists.linux.dev, Johannes Berg <johannes@sipsolutions.net>
Subject: Re: [PATCH net v2 0/5] Make TCP-MD5-diag slightly less broken
Date: Fri, 15 Nov 2024 16:08:16 -0800 [thread overview]
Message-ID: <20241115160816.09df40eb@kernel.org> (raw)
In-Reply-To: <20241113-tcp-md5-diag-prep-v2-0-00a2a7feb1fa@gmail.com>
On Wed, 13 Nov 2024 18:46:39 +0000 Dmitry Safonov via B4 Relay wrote:
> 2. Inet-diag allocates netlink message for sockets in
> inet_diag_dump_one_icsk(), which uses a TCP-diag callback
> .idiag_get_aux_size(), that pre-calculates the needed space for
> TCP-diag related information. But as neither socket lock nor
> rcu_readlock() are held between allocation and the actual TCP
> info filling, the TCP-related space requirement may change before
> reaching tcp_diag_put_md5sig(). I.e., the number of TCP-MD5 keys on
> a socket. Thankfully, TCP-MD5-diag won't overwrite the skb, but will
> return EMSGSIZE, triggering WARN_ON() in inet_diag_dump_one_icsk().
Would it be too ugly if we simply retried with a 32kB skb if the initial
dump failed with EMSGSIZE?
Another option would be to automatically grow the skb. The size
accounting is an endless source of bugs. We'd just need to scan
the codebase to make sure there are no cases where someone does
ptr = __nla_reserve();
nla_put();
*ptr = 0;
Which may be too much of a project and source of bugs in itself.
Or do both, retry as a fix, and auto-grow in net-next.
> In order to remove the new limit from (4) solution, my plan is to
> convert the dump of TCP-MD5 keys from an array to
> NL_ATTR_TYPE_NESTED_ARRAY (or alike), which should also address (1).
> And for (3), it's needed to teach tcp-diag how-to remember not only
> socket on which previous recvmsg() stopped, but potentially TCP-MD5
> key as well.
Just putting the same attribute type multiple times is preferable
to array types.
next prev parent reply other threads:[~2024-11-16 0:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 18:46 [PATCH net v2 0/5] Make TCP-MD5-diag slightly less broken Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 1/5] net/diag: Do not race on dumping MD5 keys with adding new MD5 keys Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 2/5] net/diag: Warn only once on EMSGSIZE Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 3/5] net/diag: Pre-allocate optional info only if requested Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 4/5] net/diag: Always pre-allocate tcp_ulp info Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 5/5] net/netlink: Correct the comment on netlink message max cap Dmitry Safonov via B4 Relay
2024-11-16 0:13 ` Jakub Kicinski
2024-11-16 0:08 ` Jakub Kicinski [this message]
2024-11-16 0:48 ` [PATCH net v2 0/5] Make TCP-MD5-diag slightly less broken Dmitry Safonov
2024-11-16 1:58 ` Jakub Kicinski
2024-11-16 3:52 ` Dmitry Safonov
2024-11-19 0:12 ` Jakub Kicinski
2024-11-20 0:19 ` Dmitry Safonov
2024-11-20 8:44 ` Johannes Berg
2024-11-20 16:13 ` Dmitry Safonov
2024-11-20 19:36 ` Johannes Berg
2024-11-16 0:20 ` patchwork-bot+netdevbpf
2024-12-05 1:13 ` Jakub Kicinski
2024-12-05 9:09 ` Eric Dumazet
2024-12-06 0:31 ` Jakub Kicinski
2024-12-06 2:49 ` Dmitry Safonov
2024-12-06 15:14 ` Eric Dumazet
2024-12-06 20:35 ` Dmitry Safonov
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=20241115160816.09df40eb@kernel.org \
--to=kuba@kernel.org \
--cc=0x7f454c46@gmail.com \
--cc=colona@arista.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=devnull+0x7f454c46.gmail.com@kernel.org \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=john.fastabend@gmail.com \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).