netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tipc: Return non-zero value from tipc_udp_addr2str() on error
@ 2024-07-16  2:09 Shigeru Yoshida
  2024-07-16  7:35 ` Tung Nguyen
  2024-07-24 11:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 14+ messages in thread
From: Shigeru Yoshida @ 2024-07-16  2:09 UTC (permalink / raw)
  To: jmaloy, ying.xue, davem, edumazet, kuba, pabeni
  Cc: netdev, tipc-discussion, linux-kernel, Shigeru Yoshida

tipc_udp_addr2str() should return non-zero value if the UDP media
address is invalid. Otherwise, a buffer overflow access can occur in
tipc_media_addr_printf(). Fix this by returning 1 on an invalid UDP
media address.

Fixes: d0f91938bede ("tipc: add ip/udp media type")
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
---
 net/tipc/udp_media.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index b849a3d133a0..439f75539977 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -135,8 +135,11 @@ static int tipc_udp_addr2str(struct tipc_media_addr *a, char *buf, int size)
 		snprintf(buf, size, "%pI4:%u", &ua->ipv4, ntohs(ua->port));
 	else if (ntohs(ua->proto) == ETH_P_IPV6)
 		snprintf(buf, size, "%pI6:%u", &ua->ipv6, ntohs(ua->port));
-	else
+	else {
 		pr_err("Invalid UDP media address\n");
+		return 1;
+	}
+
 	return 0;
 }
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-07-24 11:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16  2:09 [PATCH net] tipc: Return non-zero value from tipc_udp_addr2str() on error Shigeru Yoshida
2024-07-16  7:35 ` Tung Nguyen
2024-07-16  7:45   ` Shigeru Yoshida
2024-07-16 11:24     ` Paolo Abeni
2024-07-16 11:43       ` Tung Nguyen
2024-07-16 13:10         ` Paolo Abeni
2024-07-16 13:29           ` Tung Nguyen
2024-07-17  2:03             ` Shigeru Yoshida
2024-07-17  2:10               ` Tung Nguyen
2024-07-17  2:48                 ` Shigeru Yoshida
2024-07-17 15:31                 ` Jakub Kicinski
2024-07-18  1:30                   ` Tung Nguyen
2024-07-18  7:49                     ` Paolo Abeni
2024-07-24 11:20 ` patchwork-bot+netdevbpf

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).