From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD89C51588E; Wed, 30 Sep 2026 16:43:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786635; cv=none; b=K4TmEWAY8o1CVUkt39/PQi2r+R6TLea3KPkYj+28qtWzQel0ZHAFtvJxUp7tLe4TEv4KnzSRNQQKw5rpHzh47DCatQPtMOZ7/WSesisMnsrbbiqkX7jdtMWy7GVoOxbhYjZYwV5fI9iKGJMKKAKB+LK3KfmWVTbBaL+ORuBbrMs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786635; c=relaxed/simple; bh=d+Gvf2zh2up+jTWyo7kG/3a85OrNdsb3gXrvErZFE9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u/uoz+paGxSZddIRyAWRT5MftnbDMLvcHsEs9xFGXEeRy9oYZzR4n9MeoQ0PFiyEDgzx1qNaQ+XchQnqjAGSHP1U4p3GIE2acyRlQTJb3d3XBmZZMLHsI4v0tR8H70q1Owlutfjx2+3RxN1wi/LHW+xOPxrZ/op6eCSvXvB5JZg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BgHFSeK/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="BgHFSeK/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 342E61F00898; Wed, 30 Sep 2026 16:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786633; bh=0LoqIBU16FT8PWwUFvTGBxOYN6zbLNS0FyTkTVxGrlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BgHFSeK/2FKC/FlHI0YIxc7i7z+XUTZ/VeGwPZdQnT2NFEgb4Kc6kdVzVAZTWhV7Y ZScSuCnslGQ2qlem+/DFc+/mkKTt0O3Z2+VgvgvAIkffgCdV6YnRZjpU/vBo988/Ol Vn38tFLQ2eU5JgcVfls6Fg5z8Y4ZgfGugO7+HA+g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+1e3df0852e82c21ca418@syzkaller.appspotmail.com, =?UTF-8?q?=C3=96mer=20Mete=20Kaya?= , David Heidelberg , Sasha Levin Subject: [PATCH 6.1 886/982] nfc: llcp: fix slab-out-of-bounds reads when logging service names Date: Wed, 30 Sep 2026 17:27:02 +0200 Message-ID: <20260930152435.778470113@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ömer Mete Kaya [ Upstream commit 7dcf371a35632f035baf77bcf2c129165f772ce4 ] nfc_llcp_wks_sap() and nfc_llcp_build_sdreq_tlv() pass non-null- terminated strings to pr_debug() using the %s format specifier. The buffers are allocated via kmemdup() or come from netlink attributes and are not guaranteed to be null-terminated, causing __dynamic_pr_debug() to read beyond the allocated region: KASAN: slab-out-of-bounds Read in __dynamic_pr_debug Fix both call sites by using %.*s with the explicit length to limit the output to the actual length of the string. Fixes: d9b8d8e19b07 ("NFC: llcp: Service Name Lookup netlink interface") Reported-by: syzbot+1e3df0852e82c21ca418@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=1e3df0852e82c21ca418 Signed-off-by: Ömer Mete Kaya Link: https://patch.msgid.link/20260908161952.731468-1-omermetekaya0@gmail.com Signed-off-by: David Heidelberg Signed-off-by: Sasha Levin --- net/nfc/llcp_commands.c | 2 +- net/nfc/llcp_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c index a93bf0b43d504..2d9e0925b1cc7 100644 --- a/net/nfc/llcp_commands.c +++ b/net/nfc/llcp_commands.c @@ -135,7 +135,7 @@ struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, const char *uri, { struct nfc_llcp_sdp_tlv *sdreq; - pr_debug("uri: %s, len: %zu\n", uri, uri_len); + pr_debug("uri: %.*s, len: %zu\n", (int)uri_len, uri, uri_len); /* sdreq->tlv_len is u8, takes uri_len, + 3 for header, + 1 for NULL */ if (WARN_ON_ONCE(uri_len > U8_MAX - 4)) diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c index 0b1a2755f58ac..49f7793ab0312 100644 --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c @@ -356,7 +356,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.53.0