* [PATCH net] net: pse-pd: Fix out of bound for loop
@ 2024-10-15 13:02 Kory Maincent
2024-10-15 13:28 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kory Maincent @ 2024-10-15 13:02 UTC (permalink / raw)
To: Andrew Lunn, Jakub Kicinski, Kory Maincent (Dent Project), netdev,
linux-kernel
Cc: Kyle Swenson, thomas.petazzoni, Oleksij Rempel, David S. Miller,
Eric Dumazet, Paolo Abeni
Adjust the loop limit to prevent out-of-bounds access when iterating over
PI structures. The loop should not reach the index pcdev->nr_lines since
we allocate exactly pcdev->nr_lines number of PI structures. This fix
ensures proper bounds are maintained during iterations.
Fixes: 9be9567a7c59 ("net: pse-pd: Add support for PSE PIs")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
drivers/net/pse-pd/pse_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
index f8e6854781e6..2906ce173f66 100644
--- a/drivers/net/pse-pd/pse_core.c
+++ b/drivers/net/pse-pd/pse_core.c
@@ -113,7 +113,7 @@ static void pse_release_pis(struct pse_controller_dev *pcdev)
{
int i;
- for (i = 0; i <= pcdev->nr_lines; i++) {
+ for (i = 0; i < pcdev->nr_lines; i++) {
of_node_put(pcdev->pi[i].pairset[0].np);
of_node_put(pcdev->pi[i].pairset[1].np);
of_node_put(pcdev->pi[i].np);
@@ -647,7 +647,7 @@ static int of_pse_match_pi(struct pse_controller_dev *pcdev,
{
int i;
- for (i = 0; i <= pcdev->nr_lines; i++) {
+ for (i = 0; i < pcdev->nr_lines; i++) {
if (pcdev->pi[i].np == np)
return i;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: pse-pd: Fix out of bound for loop
2024-10-15 13:02 [PATCH net] net: pse-pd: Fix out of bound for loop Kory Maincent
@ 2024-10-15 13:28 ` Simon Horman
2024-10-15 14:06 ` Oleksij Rempel
2024-10-20 14:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-10-15 13:28 UTC (permalink / raw)
To: Kory Maincent
Cc: Andrew Lunn, Jakub Kicinski, netdev, linux-kernel, Kyle Swenson,
thomas.petazzoni, Oleksij Rempel, David S. Miller, Eric Dumazet,
Paolo Abeni
On Tue, Oct 15, 2024 at 03:02:54PM +0200, Kory Maincent wrote:
> Adjust the loop limit to prevent out-of-bounds access when iterating over
> PI structures. The loop should not reach the index pcdev->nr_lines since
> we allocate exactly pcdev->nr_lines number of PI structures. This fix
> ensures proper bounds are maintained during iterations.
>
> Fixes: 9be9567a7c59 ("net: pse-pd: Add support for PSE PIs")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: pse-pd: Fix out of bound for loop
2024-10-15 13:02 [PATCH net] net: pse-pd: Fix out of bound for loop Kory Maincent
2024-10-15 13:28 ` Simon Horman
@ 2024-10-15 14:06 ` Oleksij Rempel
2024-10-20 14:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Oleksij Rempel @ 2024-10-15 14:06 UTC (permalink / raw)
To: Kory Maincent
Cc: Andrew Lunn, Jakub Kicinski, netdev, linux-kernel, Kyle Swenson,
thomas.petazzoni, David S. Miller, Eric Dumazet, Paolo Abeni
On Tue, Oct 15, 2024 at 03:02:54PM +0200, Kory Maincent wrote:
> Adjust the loop limit to prevent out-of-bounds access when iterating over
> PI structures. The loop should not reach the index pcdev->nr_lines since
> we allocate exactly pcdev->nr_lines number of PI structures. This fix
> ensures proper bounds are maintained during iterations.
>
> Fixes: 9be9567a7c59 ("net: pse-pd: Add support for PSE PIs")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Thank you!
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: pse-pd: Fix out of bound for loop
2024-10-15 13:02 [PATCH net] net: pse-pd: Fix out of bound for loop Kory Maincent
2024-10-15 13:28 ` Simon Horman
2024-10-15 14:06 ` Oleksij Rempel
@ 2024-10-20 14:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-20 14:50 UTC (permalink / raw)
To: Kory Maincent
Cc: andrew, kuba, netdev, linux-kernel, kyle.swenson,
thomas.petazzoni, o.rempel, davem, edumazet, pabeni
Hello:
This patch was applied to netdev/net.git (main)
by Andrew Lunn <andrew@lunn.ch>:
On Tue, 15 Oct 2024 15:02:54 +0200 you wrote:
> Adjust the loop limit to prevent out-of-bounds access when iterating over
> PI structures. The loop should not reach the index pcdev->nr_lines since
> we allocate exactly pcdev->nr_lines number of PI structures. This fix
> ensures proper bounds are maintained during iterations.
>
> Fixes: 9be9567a7c59 ("net: pse-pd: Add support for PSE PIs")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
>
> [...]
Here is the summary with links:
- [net] net: pse-pd: Fix out of bound for loop
https://git.kernel.org/netdev/net/c/f2767a41959e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-20 14:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 13:02 [PATCH net] net: pse-pd: Fix out of bound for loop Kory Maincent
2024-10-15 13:28 ` Simon Horman
2024-10-15 14:06 ` Oleksij Rempel
2024-10-20 14:50 ` patchwork-bot+netdevbpf
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).