public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Safonov via B4 Relay <devnull+0x7f454c46.gmail.com@kernel.org>
To: "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>,
	 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>,
	Boris Pismenny <borisp@nvidia.com>,
	 John Fastabend <john.fastabend@gmail.com>,
	 Davide Caratti <dcaratti@redhat.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 mptcp@lists.linux.dev, Dmitry Safonov <0x7f454c46@gmail.com>
Subject: [PATCH net v2 2/5] net/diag: Warn only once on EMSGSIZE
Date: Wed, 13 Nov 2024 18:46:41 +0000	[thread overview]
Message-ID: <20241113-tcp-md5-diag-prep-v2-2-00a2a7feb1fa@gmail.com> (raw)
In-Reply-To: <20241113-tcp-md5-diag-prep-v2-0-00a2a7feb1fa@gmail.com>

From: Dmitry Safonov <0x7f454c46@gmail.com>

The code clearly expects that the pre-allocated skb will be enough for
the netlink reply message. But if in an unbelievable situation there is
a kernel issue and sk_diag_fill() fails with -EMSGSIZE, this WARN_ON()
can be triggered from userspace. That aggravates the issue from KASLR
leak into possible DOS vector. Use WARN_ON_ONCE() which is clearly
enough to provide an information on a kernel issue.

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
---
 net/ipv4/inet_diag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 67b9cc4c0e47a596a4d588e793b7f13ee040a1e3..ca9a7e61d8d7de80cb234c45c41d6357fde50c11 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -583,7 +583,7 @@ int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
 
 	err = sk_diag_fill(sk, rep, cb, req, 0, net_admin);
 	if (err < 0) {
-		WARN_ON(err == -EMSGSIZE);
+		WARN_ON_ONCE(err == -EMSGSIZE);
 		nlmsg_free(rep);
 		goto out;
 	}

-- 
2.42.2



  parent reply	other threads:[~2024-11-13 18:47 UTC|newest]

Thread overview: 15+ 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 ` Dmitry Safonov via B4 Relay [this message]
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 ` [PATCH net v2 0/5] Make TCP-MD5-diag slightly less broken Jakub Kicinski
2024-11-16  0:48   ` 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-16  0:20 ` patchwork-bot+netdevbpf

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=20241113-tcp-md5-diag-prep-v2-2-00a2a7feb1fa@gmail.com \
    --to=devnull+0x7f454c46.gmail.com@kernel.org \
    --cc=0x7f454c46@gmail.com \
    --cc=borisp@nvidia.com \
    --cc=colona@arista.com \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=geliang@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --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