Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Akshay Ubale
Tue, 20 Oct 2026 23:30
[PATCH net] niu: bounds-check phy-type and model VPD strings
Author: Akshay Ubale
Date: Tue, 20 Oct 2026 23:30
Date: Tue, 20 Oct 2026 23:30
65 lines
12959 bytes
12959 bytes
niu_get_of_props() copies the "phy-type" and "model" device-tree
properties into fixed-size np->vpd buffers with strcpy(), which does
not check the property length.
Use the length reported by of_get_property() to reject values that do
not fit, and copy with strscpy() so the destination is always
NUL-terminated.
Fixes: a3138df9f20e ("[NIU]: Add Sun Neptune ethernet driver.")
Fixes: f9af857489cc ("niu: Determine the # of ports from the card's VPD data")
Signed-off-by: Akshay Ubale <akshay.ubale001@gmail.com>
---
drivers/net/ethernet/sun/niu.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 54dd7281191d..fab6af105df2 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -9260,7 +9260,7 @@ static int niu_get_of_props(struct niu *np)
else
dp = pci_device_to_OF_node(np->pdev);
- phy_type = of_get_property(dp, "phy-type", NULL);
+ phy_type = of_get_property(dp, "phy-type", &prop_len);
if (!phy_type) {
netdev_err(dev, "%pOF: OF node lacks phy-type property\n", dp);
return -EINVAL;
@@ -9269,7 +9269,12 @@ static int niu_get_of_props(struct niu *np)
if (!strcmp(phy_type, "none"))
return -ENODEV;
- strcpy(np->vpd.phy_type, phy_type);
+ if (prop_len > sizeof(np->vpd.phy_type)) {
+ netdev_err(dev, "%pOF: phy-type property too long (%d)\n",
+ dp, prop_len);
+ return -EINVAL;
+ }
+ strscpy(np->vpd.phy_type, phy_type, sizeof(np->vpd.phy_type));
if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) {
netdev_err(dev, "%pOF: Illegal phy string [%s]\n",
@@ -9294,10 +9299,15 @@ static int niu_get_of_props(struct niu *np)
return -EINVAL;
}
- model = of_get_property(dp, "model", NULL);
-
- if (model)
- strcpy(np->vpd.model, model);
+ model = of_get_property(dp, "model", &prop_len);
+ if (model) {
+ if (prop_len > sizeof(np->vpd.model)) {
+ netdev_err(dev, "%pOF: model property too long (%d)\n",
+ dp, prop_len);
+ return -EINVAL;
+ }
+ strscpy(np->vpd.model, model, sizeof(np->vpd.model));
+ }
if (of_property_read_bool(dp, "hot-swappable-phy")) {
np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER |
--
2.53.0
Re: [PATCH net] niu: bounds-check phy-type and model VPD strings
Author: netdev-bot+sinfo
Date: Tue, 20 Oct 2026 23:43
Date: Tue, 20 Oct 2026 23:43
26 lines
8980 bytes
8980 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages. - What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net] niu: bounds-check phy-type and model VPD strings
Author: Jakub Kicinski
Date: Wed, 21 Oct 2026 01:10
Date: Wed, 21 Oct 2026 01:10
19 lines
8567 bytes
8567 bytes
On Wed, 21 Oct 2026 01:30:07 +0200 Akshay Ubale wrote:
> niu_get_of_props() copies the "phy-type" and "model" device-tree
> properties into fixed-size np->vpd buffers with strcpy(), which does
> not check the property length.
>
> Use the length reported by of_get_property() to reject values that do
> not fit, and copy with strscpy() so the destination is always
> NUL-terminated.
>
> Fixes: a3138df9f20e ("[NIU]: Add Sun Neptune ethernet driver.")
> Fixes: f9af857489cc ("niu: Determine the # of ports from the card's VPD data")
> Signed-off-by: Akshay Ubale <akshay.ubale001@gmail.com>
Please don't sent us low value patches like this during the merge window
When / if you repost make sure you add to the commit message the reply
to the questions asked by the sinfo bot.
--
pw-bot: cr
Re: [PATCH net] niu: bounds-check phy-type and model VPD strings
Author: Akshay Ubale
Date: Tue, 03 Nov 2026 21:13
Date: Tue, 03 Nov 2026 21:13
21 lines
11930 bytes
11930 bytes
Hi, Answers to the questions about this patch: - Discovery: manual code inspection. While reviewing unchecked strcpy() calls in the kernel, I found that niu_get_of_props() copies the "phy-type" and "model" device-tree properties into fixed-size buffers without checking their length. No syzbot report, production report, or static analysis tool was involved. - Triggered: not triggered. This is theoretical, found by code inspection. No symptoms were observed. Triggering needs a property longer than the destination buffer, which I have not seen reported. - Hardware: not tested on real hardware. The change was verified with a SPARC64 cross-build (gcc 13.3, W=1, no warnings) and a standalone test harness for the length-check logic. Thanks, Akshay Ubale
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads