* [PATCH net v2] tg3: prevent use of uninitialized remote_adv and local_adv variables
@ 2025-10-14 16:47 Alexey Simakov
2025-10-15 4:15 ` Pavan Chebbi
2025-10-16 0:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Simakov @ 2025-10-14 16:47 UTC (permalink / raw)
To: Pavan Chebbi
Cc: Alexey Simakov, Michael Chan, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nithin Nayak Sujir,
netdev, linux-kernel, lvc-project, Alexandr Sapozhnikov
Some execution paths that jump to the fiber_setup_done label
could leave the remote_adv and local_adv variables uninitialized
and then use it.
Initialize this variables at the point of definition to avoid this.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 85730a631f0c ("tg3: Add SGMII phy support for 5719/5718 serdes")
Co-developed-by: Alexandr Sapozhnikov <alsp705@gmail.com>
Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
Signed-off-by: Alexey Simakov <bigalex934@gmail.com>
---
v2 - remove bogus lines with initialization of variables in function,
since its initialized at definition point now.
link to v1: https://lore.kernel.org/netdev/20251002091224.11-1-alsp705@gmail.com/
drivers/net/ethernet/broadcom/tg3.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 7f00ec7fd7b9..d78cafdb2094 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -5803,7 +5803,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)
u32 current_speed = SPEED_UNKNOWN;
u8 current_duplex = DUPLEX_UNKNOWN;
bool current_link_up = false;
- u32 local_adv, remote_adv, sgsr;
+ u32 local_adv = 0, remote_adv = 0, sgsr;
if ((tg3_asic_rev(tp) == ASIC_REV_5719 ||
tg3_asic_rev(tp) == ASIC_REV_5720) &&
@@ -5944,9 +5944,6 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)
else
current_duplex = DUPLEX_HALF;
- local_adv = 0;
- remote_adv = 0;
-
if (bmcr & BMCR_ANENABLE) {
u32 common;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] tg3: prevent use of uninitialized remote_adv and local_adv variables
2025-10-14 16:47 [PATCH net v2] tg3: prevent use of uninitialized remote_adv and local_adv variables Alexey Simakov
@ 2025-10-15 4:15 ` Pavan Chebbi
2025-10-16 0:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Pavan Chebbi @ 2025-10-15 4:15 UTC (permalink / raw)
To: Alexey Simakov
Cc: Michael Chan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Nithin Nayak Sujir, netdev,
linux-kernel, lvc-project, Alexandr Sapozhnikov
[-- Attachment #1: Type: text/plain, Size: 2044 bytes --]
On Tue, Oct 14, 2025 at 10:18 PM Alexey Simakov <bigalex934@gmail.com> wrote:
>
> Some execution paths that jump to the fiber_setup_done label
> could leave the remote_adv and local_adv variables uninitialized
> and then use it.
>
> Initialize this variables at the point of definition to avoid this.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 85730a631f0c ("tg3: Add SGMII phy support for 5719/5718 serdes")
> Co-developed-by: Alexandr Sapozhnikov <alsp705@gmail.com>
> Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
> Signed-off-by: Alexey Simakov <bigalex934@gmail.com>
LGTM.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
> ---
>
> v2 - remove bogus lines with initialization of variables in function,
> since its initialized at definition point now.
>
> link to v1: https://lore.kernel.org/netdev/20251002091224.11-1-alsp705@gmail.com/
>
> drivers/net/ethernet/broadcom/tg3.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 7f00ec7fd7b9..d78cafdb2094 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -5803,7 +5803,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)
> u32 current_speed = SPEED_UNKNOWN;
> u8 current_duplex = DUPLEX_UNKNOWN;
> bool current_link_up = false;
> - u32 local_adv, remote_adv, sgsr;
> + u32 local_adv = 0, remote_adv = 0, sgsr;
>
> if ((tg3_asic_rev(tp) == ASIC_REV_5719 ||
> tg3_asic_rev(tp) == ASIC_REV_5720) &&
> @@ -5944,9 +5944,6 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)
> else
> current_duplex = DUPLEX_HALF;
>
> - local_adv = 0;
> - remote_adv = 0;
> -
> if (bmcr & BMCR_ANENABLE) {
> u32 common;
>
> --
> 2.34.1
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5469 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] tg3: prevent use of uninitialized remote_adv and local_adv variables
2025-10-14 16:47 [PATCH net v2] tg3: prevent use of uninitialized remote_adv and local_adv variables Alexey Simakov
2025-10-15 4:15 ` Pavan Chebbi
@ 2025-10-16 0:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-16 0:20 UTC (permalink / raw)
To: Alexey Simakov
Cc: pavan.chebbi, mchan, andrew+netdev, davem, edumazet, kuba,
pabeni, nsujir, netdev, linux-kernel, lvc-project, alsp705
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 14 Oct 2025 19:47:38 +0300 you wrote:
> Some execution paths that jump to the fiber_setup_done label
> could leave the remote_adv and local_adv variables uninitialized
> and then use it.
>
> Initialize this variables at the point of definition to avoid this.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> [...]
Here is the summary with links:
- [net,v2] tg3: prevent use of uninitialized remote_adv and local_adv variables
https://git.kernel.org/netdev/net/c/0c3f2e62815a
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] 3+ messages in thread
end of thread, other threads:[~2025-10-16 0:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-14 16:47 [PATCH net v2] tg3: prevent use of uninitialized remote_adv and local_adv variables Alexey Simakov
2025-10-15 4:15 ` Pavan Chebbi
2025-10-16 0:20 ` 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
all inboxes | Powered by JetHome®