From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: David Wei <dw@davidwei.uk>, Jakub Kicinski <kuba@kernel.org>,
Sasha Levin <sashal@kernel.org>,
donald.hunter@gmail.com, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com,
nicolas.dichtel@6wind.com, colin.i.king@gmail.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.12 05/11] tools: ynl-gen: validate 0 len strings from kernel
Date: Mon, 12 May 2025 14:04:20 -0400 [thread overview]
Message-ID: <20250512180426.437627-5-sashal@kernel.org> (raw)
In-Reply-To: <20250512180426.437627-1-sashal@kernel.org>
From: David Wei <dw@davidwei.uk>
[ Upstream commit 4720f9707c783f642332dee3d56dccaefa850e42 ]
Strings from the kernel are guaranteed to be null terminated and
ynl_attr_validate() checks for this. But it doesn't check if the string
has a len of 0, which would cause problems when trying to access
data[len - 1]. Fix this by checking that len is positive.
Signed-off-by: David Wei <dw@davidwei.uk>
Link: https://patch.msgid.link/20250503043050.861238-1-dw@davidwei.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/net/ynl/lib/ynl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/net/ynl/lib/ynl.c b/tools/net/ynl/lib/ynl.c
index ce32cb35007d6..c4da34048ef85 100644
--- a/tools/net/ynl/lib/ynl.c
+++ b/tools/net/ynl/lib/ynl.c
@@ -364,7 +364,7 @@ int ynl_attr_validate(struct ynl_parse_arg *yarg, const struct nlattr *attr)
"Invalid attribute (binary %s)", policy->name);
return -1;
case YNL_PT_NUL_STR:
- if ((!policy->len || len <= policy->len) && !data[len - 1])
+ if (len && (!policy->len || len <= policy->len) && !data[len - 1])
break;
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
"Invalid attribute (string %s)", policy->name);
--
2.39.5
next prev parent reply other threads:[~2025-05-12 18:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 18:04 [PATCH AUTOSEL 6.12 01/11] btrfs: compression: adjust cb->compressed_folios allocation type Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 02/11] btrfs: correct the order of prelim_ref arguments in btrfs__prelim_ref Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 03/11] btrfs: handle empty eb->folios in num_extent_folios() Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 04/11] btrfs: avoid NULL pointer dereference if no valid csum tree Sasha Levin
2025-05-12 18:04 ` Sasha Levin [this message]
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 06/11] block: only update request sector if needed Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 07/11] wifi: iwlwifi: add support for Killer on MTL Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 08/11] x86/Kconfig: make CFI_AUTO_DEFAULT depend on !RUST or Rust >= 1.88 Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 09/11] xenbus: Allow PVH dom0 a non-local xenstore Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 10/11] drm/amd/display: Call FP Protect Before Mode Programming/Mode Support Sasha Levin
2025-05-12 18:04 ` [PATCH AUTOSEL 6.12 11/11] __legitimize_mnt(): check for MNT_SYNC_UMOUNT should be under mount_lock Sasha Levin
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=20250512180426.437627-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=colin.i.king@gmail.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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