mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
sctp: Prevent TOCTOU out-of-bounds write
[ Upstream commit95aef86ab2] For the following path not holding the sock lock, sctp_diag_dump() -> sctp_for_each_endpoint() -> sctp_ep_dump() make sure not to exceed bounds in case the address list has grown between buffer allocation (time-of-check) and write (time-of-use). Suggested-by: Kuniyuki Iwashima <kuniyu@google.com> Fixes:8f840e47f1("sctp: add the sctp_diag.c file") Signed-off-by: Stefan Wiehler <stefan.wiehler@nokia.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Acked-by: Xin Long <lucien.xin@gmail.com> Link: https://patch.msgid.link/20251028161506.3294376-3-stefan.wiehler@nokia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
97a2bb90a6
commit
2fe08fcaac
@@ -88,6 +88,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;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user