netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfc: llcp: fix slab-out-of-bounds read in nfc_llcp_wks_sap()
@ 2026-09-03 16:49 Ömer Mete Kaya
  2026-09-05 22:48 ` [PATCH net v2] " Ömer Mete Kaya
  0 siblings, 1 reply; 7+ messages in thread
From: Ömer Mete Kaya @ 2026-09-03 16:49 UTC (permalink / raw)
  To: netdev
  Cc: david, davem, edumazet, kuba, pabeni, horms, oe-linux-nfc,
	linux-kernel, Ömer Mete Kaya, syzbot+1e3df0852e82c21ca418

nfc_llcp_wks_sap() passes service_name to pr_debug() using the %s
format specifier. The service_name buffer is allocated via kmemdup()
in llcp_sock_bind() and is not null-terminated, causing
__dynamic_pr_debug() to read beyond the allocated region:

  KASAN: slab-out-of-bounds Read in __dynamic_pr_debug

Fix by using %.*s with service_name_len to limit the output to the
actual length of the string.

Reported-by: syzbot+1e3df0852e82c21ca418@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1e3df0852e82c21ca418
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
 net/nfc/llcp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index cac1b5487064..fda236e4d9fd 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -341,7 +341,7 @@ static int nfc_llcp_wks_sap(const char *service_name, size_t service_name_len)
 {
 	int sap, num_wks;
 
-	pr_debug("%s\n", service_name);
+	pr_debug("%.*s\n", (int)service_name_len, service_name);
 
 	if (service_name == NULL)
 		return -EINVAL;
-- 
2.55.0


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

end of thread, other threads:[~2026-09-10  3:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 16:49 [PATCH] nfc: llcp: fix slab-out-of-bounds read in nfc_llcp_wks_sap() Ömer Mete Kaya
2026-09-05 22:48 ` [PATCH net v2] " Ömer Mete Kaya
2026-09-06  0:38   ` [PATCH net v3] nfc: llcp: fix slab-out-of-bounds reads when logging service names Ömer Mete Kaya
2026-09-08 15:41     ` Simon Horman
2026-09-08 16:12       ` Ömer Mete Kaya
2026-09-08 16:20         ` Simon Horman
2026-09-10  3:51   ` [PATCH net v2] nfc: llcp: fix slab-out-of-bounds read in nfc_llcp_wks_sap() netdev-bot+sashiko

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