From: Shigeru Yoshida <syoshida@redhat.com>
To: jmaloy@redhat.com, ying.xue@windriver.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
Shigeru Yoshida <syoshida@redhat.com>
Subject: [PATCH net] tipc: Return non-zero value from tipc_udp_addr2str() on error
Date: Tue, 16 Jul 2024 11:09:05 +0900 [thread overview]
Message-ID: <20240716020905.291388-1-syoshida@redhat.com> (raw)
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
next reply other threads:[~2024-07-16 2:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 2:09 Shigeru Yoshida [this message]
2024-07-16 7:35 ` [PATCH net] tipc: Return non-zero value from tipc_udp_addr2str() on error 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
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=20240716020905.291388-1-syoshida@redhat.com \
--to=syoshida@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.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;
as well as URLs for NNTP newsgroup(s).