2024-06-04 09:08:47

by Aleksandr Mishin

[permalink] [raw]
Subject: [PATCH net] net: wwan: iosm: Fix tainted pointer delete is case of region creation fail

In case of region creation fail in ipc_devlink_create_region(), previously
created regions delete process starts from tainted pointer which actually
holds error code value.
Fix this bug by decreasing region index before delete.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 4dcd183fbd67 ("net: wwan: iosm: devlink registration")
Signed-off-by: Aleksandr Mishin <[email protected]>
---
drivers/net/wwan/iosm/iosm_ipc_devlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wwan/iosm/iosm_ipc_devlink.c b/drivers/net/wwan/iosm/iosm_ipc_devlink.c
index bef6819986e9..33d6342124bc 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_devlink.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_devlink.c
@@ -211,7 +211,7 @@ static int ipc_devlink_create_region(struct iosm_devlink *devlink)
rc = PTR_ERR(devlink->cd_regions[i]);
dev_err(devlink->dev, "Devlink region fail,err %d", rc);
/* Delete previously created regions */
- for ( ; i >= 0; i--)
+ for (i--; i >= 0; i--)
devlink_region_destroy(devlink->cd_regions[i]);
goto region_create_fail;
}
--
2.30.2



2024-06-04 19:38:48

by Sergey Ryazanov

[permalink] [raw]
Subject: Re: [PATCH net] net: wwan: iosm: Fix tainted pointer delete is case of region creation fail

On 04.06.2024 11:25, Aleksandr Mishin wrote:
> In case of region creation fail in ipc_devlink_create_region(), previously
> created regions delete process starts from tainted pointer which actually
> holds error code value.
> Fix this bug by decreasing region index before delete.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 4dcd183fbd67 ("net: wwan: iosm: devlink registration")
> Signed-off-by: Aleksandr Mishin <[email protected]>

Nice catch!

Acked-by: Sergey Ryazanov <[email protected]>

2024-06-05 18:59:19

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH net] net: wwan: iosm: Fix tainted pointer delete is case of region creation fail

On Tue, Jun 04, 2024 at 11:25:00AM +0300, Aleksandr Mishin wrote:
> In case of region creation fail in ipc_devlink_create_region(), previously
> created regions delete process starts from tainted pointer which actually
> holds error code value.
> Fix this bug by decreasing region index before delete.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 4dcd183fbd67 ("net: wwan: iosm: devlink registration")
> Signed-off-by: Aleksandr Mishin <[email protected]>

Reviewed-by: Simon Horman <[email protected]>


2024-06-06 08:40:38

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net] net: wwan: iosm: Fix tainted pointer delete is case of region creation fail

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

On Tue, 4 Jun 2024 11:25:00 +0300 you wrote:
> In case of region creation fail in ipc_devlink_create_region(), previously
> created regions delete process starts from tainted pointer which actually
> holds error code value.
> Fix this bug by decreasing region index before delete.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> [...]

Here is the summary with links:
- [net] net: wwan: iosm: Fix tainted pointer delete is case of region creation fail
https://git.kernel.org/netdev/net/c/b0c9a2643541

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html