From: Simon Horman <horms@kernel.org>
To: Stefan Wiehler <stefan.wiehler@nokia.com>
Cc: Xin Long <lucien.xin@gmail.com>,
"David S . Miller " <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 1/3] sctp: Hold RCU read lock while iterating over address list
Date: Wed, 29 Oct 2025 16:38:39 +0000 [thread overview]
Message-ID: <aQJDD7FH1EWe2Quc@horms.kernel.org> (raw)
In-Reply-To: <20251028161506.3294376-2-stefan.wiehler@nokia.com>
On Tue, Oct 28, 2025 at 05:12:26PM +0100, Stefan Wiehler wrote:
> With CONFIG_PROVE_RCU_LIST=y and by executing
>
> $ netcat -l --sctp &
> $ netcat --sctp localhost &
> $ ss --sctp
>
> one can trigger the following Lockdep-RCU splat(s):
...
> diff --git a/net/sctp/diag.c b/net/sctp/diag.c
> index 996c2018f0e6..1a8761f87bf1 100644
> --- a/net/sctp/diag.c
> +++ b/net/sctp/diag.c
> @@ -73,19 +73,23 @@ static int inet_diag_msg_sctpladdrs_fill(struct sk_buff *skb,
> struct nlattr *attr;
> void *info = NULL;
>
> + rcu_read_lock();
> list_for_each_entry_rcu(laddr, address_list, list)
> addrcnt++;
> + rcu_read_unlock();
>
> attr = nla_reserve(skb, INET_DIAG_LOCALS, addrlen * addrcnt);
> if (!attr)
> return -EMSGSIZE;
>
> info = nla_data(attr);
Hi Stefan,
If the number of entries in list increases while rcu_read_lock is not held,
between when addrcnt is calculated and when info is written, then can an
overrun occur while writing info?
> + rcu_read_lock();
> list_for_each_entry_rcu(laddr, address_list, list) {
> memcpy(info, &laddr->a, sizeof(laddr->a));
> memset(info + sizeof(laddr->a), 0, addrlen - sizeof(laddr->a));
> info += addrlen;
> }
> + rcu_read_unlock();
>
> return 0;
> }
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-10-29 16:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 16:12 [PATCH net v3 0/3] Fix SCTP diag locking issues Stefan Wiehler
2025-10-28 16:12 ` [PATCH net v3 1/3] sctp: Hold RCU read lock while iterating over address list Stefan Wiehler
2025-10-29 16:38 ` Simon Horman [this message]
2025-10-29 16:40 ` Simon Horman
2025-10-31 19:28 ` Kuniyuki Iwashima
2025-10-28 16:12 ` [PATCH net v3 2/3] sctp: Prevent TOCTOU out-of-bounds write Stefan Wiehler
2025-10-31 19:27 ` Kuniyuki Iwashima
2025-10-28 16:12 ` [PATCH net v3 3/3] sctp: Hold sock lock while iterating over address list Stefan Wiehler
2025-11-03 19:41 ` [PATCH net v3 0/3] Fix SCTP diag locking issues Xin Long
2025-11-04 1: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=aQJDD7FH1EWe2Quc@horms.kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--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=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stefan.wiehler@nokia.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