[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAVpQUAHHVUBQZ=fgCUe8Mg9CD6d=CutyEsE4m82TGdt+VqpNQ@mail.gmail.com>
Date: Mon, 27 Oct 2025 10:51:42 -0700
From: Kuniyuki Iwashima <kuniyu@...gle.com>
To: Stefan Wiehler <stefan.wiehler@...ia.com>
Cc: Xin Long <lucien.xin@...il.com>, "David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>, linux-sctp@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net v2] sctp: Prevent TOCTOU out-of-bounds write
Thanks for the patch.
On Mon, Oct 27, 2025 at 3:16 AM Stefan Wiehler <stefan.wiehler@...ia.com> wrote:
>
> Make sure not to exceed bounds in case the address list has grown
> between buffer allocation (time-of-check) and write (time-of-use).
Could you elaborate a bit more context here like which path
we don't hold lock_sock() as Xin confirmed in this thread ?
https://lore.kernel.org/netdev/CADvbK_ddE0oUPXijkFJbWF6tFTq5TntpFMzDWH+uV_kc+KB7VA@mail.gmail.com/
Also, it would be better to post the two patches as a series
git send-email --annotate --cover-letter --thread --no-chain-reply-to \
--subject-prefix "PATCH v3 net" \
--to ...
>
> Suggested-by: Kuniyuki Iwashima <kuniyu@...gle.com>
> Fixes: 8f840e47f190 ("sctp: add the sctp_diag.c file")
> Signed-off-by: Stefan Wiehler <stefan.wiehler@...ia.com>
> ---
> V1 -> V2: Add changelog and credit
> ---
> net/sctp/diag.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/sctp/diag.c b/net/sctp/diag.c
> index 996c2018f0e6..4ee44e0111ae 100644
> --- a/net/sctp/diag.c
> +++ b/net/sctp/diag.c
> @@ -85,6 +85,9 @@ static int inet_diag_msg_sctpladdrs_fill(struct sk_buff *skb,
> memcpy(info, &laddr->a, sizeof(laddr->a));
> memset(info + sizeof(laddr->a), 0, addrlen - sizeof(laddr->a));
> info += addrlen;
> +
> + if (!--addrcnt)
> + break;
> }
>
> return 0;
> --
> 2.51.0
>
Powered by blists - more mailing lists