* [PATCH] net/sun3_82586: Avoid reading past buffer in debug output
@ 2024-02-06 16:16 Kees Cook
2024-02-08 12:11 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kees Cook @ 2024-02-06 16:16 UTC (permalink / raw)
To: Sam Creasey
Cc: Kees Cook, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Gustavo A . R . Silva, netdev, linux-kernel,
linux-hardening
Since NUM_XMIT_BUFFS is always 1, building m68k with sun3_defconfig and
-Warraybounds, this build warning is visible[1]:
drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout':
drivers/net/ethernet/i825xx/sun3_82586.c:990:122: warning: array subscript 1 is above array bounds of 'volatile struct transmit_cmd_struct *[1]' [-Warray-bounds=]
990 | printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
| ~~~~~~~~~~~~^~~
...
drivers/net/ethernet/i825xx/sun3_82586.c:156:46: note: while referencing 'xmit_cmds'
156 | volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
Avoid accessing index 1 since it doesn't exist.
Link: https://github.com/KSPP/linux/issues/325 [1]
Cc: Sam Creasey <sammy@sammy.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/net/ethernet/i825xx/sun3_82586.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/i825xx/sun3_82586.c b/drivers/net/ethernet/i825xx/sun3_82586.c
index 5e27470c6b1e..f2d4669c81cf 100644
--- a/drivers/net/ethernet/i825xx/sun3_82586.c
+++ b/drivers/net/ethernet/i825xx/sun3_82586.c
@@ -987,7 +987,7 @@ static void sun3_82586_timeout(struct net_device *dev, unsigned int txqueue)
{
#ifdef DEBUG
printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
- printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
+ printk("%s: command-stats: %04x\n", dev->name, swab16(p->xmit_cmds[0]->cmd_status));
printk("%s: check, whether you set the right interrupt number!\n",dev->name);
#endif
sun3_82586_close(dev);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net/sun3_82586: Avoid reading past buffer in debug output
2024-02-06 16:16 [PATCH] net/sun3_82586: Avoid reading past buffer in debug output Kees Cook
@ 2024-02-08 12:11 ` Simon Horman
2024-02-08 14:12 ` Gustavo A. R. Silva
2024-02-09 3:11 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-02-08 12:11 UTC (permalink / raw)
To: Kees Cook
Cc: Sam Creasey, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Gustavo A . R . Silva, netdev, linux-kernel,
linux-hardening
On Tue, Feb 06, 2024 at 08:16:54AM -0800, Kees Cook wrote:
> Since NUM_XMIT_BUFFS is always 1, building m68k with sun3_defconfig and
> -Warraybounds, this build warning is visible[1]:
>
> drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout':
> drivers/net/ethernet/i825xx/sun3_82586.c:990:122: warning: array subscript 1 is above array bounds of 'volatile struct transmit_cmd_struct *[1]' [-Warray-bounds=]
> 990 | printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
> | ~~~~~~~~~~~~^~~
> ...
> drivers/net/ethernet/i825xx/sun3_82586.c:156:46: note: while referencing 'xmit_cmds'
> 156 | volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
>
> Avoid accessing index 1 since it doesn't exist.
>
> Link: https://github.com/KSPP/linux/issues/325 [1]
> Cc: Sam Creasey <sammy@sammy.net>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Simon Horman <horms@kernel.org> # build-tested
...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net/sun3_82586: Avoid reading past buffer in debug output
2024-02-06 16:16 [PATCH] net/sun3_82586: Avoid reading past buffer in debug output Kees Cook
2024-02-08 12:11 ` Simon Horman
@ 2024-02-08 14:12 ` Gustavo A. R. Silva
2024-02-09 3:11 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2024-02-08 14:12 UTC (permalink / raw)
To: Kees Cook, Sam Creasey
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Gustavo A . R . Silva, netdev, linux-kernel, linux-hardening
On 2/6/24 10:16, Kees Cook wrote:
> Since NUM_XMIT_BUFFS is always 1, building m68k with sun3_defconfig and
> -Warraybounds, this build warning is visible[1]:
>
> drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout':
> drivers/net/ethernet/i825xx/sun3_82586.c:990:122: warning: array subscript 1 is above array bounds of 'volatile struct transmit_cmd_struct *[1]' [-Warray-bounds=]
> 990 | printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
> | ~~~~~~~~~~~~^~~
> ...
> drivers/net/ethernet/i825xx/sun3_82586.c:156:46: note: while referencing 'xmit_cmds'
> 156 | volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
>
> Avoid accessing index 1 since it doesn't exist.
>
> Link: https://github.com/KSPP/linux/issues/325 [1]
> Cc: Sam Creasey <sammy@sammy.net>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks!
--
Gustavo
> ---
> drivers/net/ethernet/i825xx/sun3_82586.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/i825xx/sun3_82586.c b/drivers/net/ethernet/i825xx/sun3_82586.c
> index 5e27470c6b1e..f2d4669c81cf 100644
> --- a/drivers/net/ethernet/i825xx/sun3_82586.c
> +++ b/drivers/net/ethernet/i825xx/sun3_82586.c
> @@ -987,7 +987,7 @@ static void sun3_82586_timeout(struct net_device *dev, unsigned int txqueue)
> {
> #ifdef DEBUG
> printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
> - printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
> + printk("%s: command-stats: %04x\n", dev->name, swab16(p->xmit_cmds[0]->cmd_status));
> printk("%s: check, whether you set the right interrupt number!\n",dev->name);
> #endif
> sun3_82586_close(dev);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net/sun3_82586: Avoid reading past buffer in debug output
2024-02-06 16:16 [PATCH] net/sun3_82586: Avoid reading past buffer in debug output Kees Cook
2024-02-08 12:11 ` Simon Horman
2024-02-08 14:12 ` Gustavo A. R. Silva
@ 2024-02-09 3:11 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-09 3:11 UTC (permalink / raw)
To: Kees Cook
Cc: sammy, davem, edumazet, kuba, pabeni, gustavoars, netdev,
linux-kernel, linux-hardening
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 6 Feb 2024 08:16:54 -0800 you wrote:
> Since NUM_XMIT_BUFFS is always 1, building m68k with sun3_defconfig and
> -Warraybounds, this build warning is visible[1]:
>
> drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout':
> drivers/net/ethernet/i825xx/sun3_82586.c:990:122: warning: array subscript 1 is above array bounds of 'volatile struct transmit_cmd_struct *[1]' [-Warray-bounds=]
> 990 | printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
> | ~~~~~~~~~~~~^~~
> ...
> drivers/net/ethernet/i825xx/sun3_82586.c:156:46: note: while referencing 'xmit_cmds'
> 156 | volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
>
> [...]
Here is the summary with links:
- net/sun3_82586: Avoid reading past buffer in debug output
https://git.kernel.org/netdev/net-next/c/4bea747f3fbe
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-02-09 3:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 16:16 [PATCH] net/sun3_82586: Avoid reading past buffer in debug output Kees Cook
2024-02-08 12:11 ` Simon Horman
2024-02-08 14:12 ` Gustavo A. R. Silva
2024-02-09 3:11 ` 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).