diff mbox series

[net] sfc: fix null pointer dereference in efx_hard_start_xmit

Message ID 20220914111135.21038-1-ihuguet@redhat.com (mailing list archive)
State Accepted
Commit 0a242eb2913a4aa3d6fbdb86559f27628e9466f3
Delegated to: Netdev Maintainers
Headers show
Series [net] sfc: fix null pointer dereference in efx_hard_start_xmit | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Íñigo Huguet Sept. 14, 2022, 11:11 a.m. UTC
Trying to get the channel from the tx_queue variable here is wrong
because we can only be here if tx_queue is NULL, so we shouldn't
dereference it. As the above comment in the code says, this is very
unlikely to happen, but it's wrong anyway so let's fix it.

I hit this issue because of a different bug that caused tx_queue to be
NULL. If that happens, this is the error message that we get here:
  BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
  [...]
  RIP: 0010:efx_hard_start_xmit+0x153/0x170 [sfc]

Fixes: 12804793b17c ("sfc: decouple TXQ type from label")
Reported-by: Tianhao Zhao <tizhao@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
---
 drivers/net/ethernet/sfc/tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Edward Cree Sept. 14, 2022, 5:50 p.m. UTC | #1
On 14/09/2022 12:11, Íñigo Huguet wrote:
> Trying to get the channel from the tx_queue variable here is wrong
> because we can only be here if tx_queue is NULL, so we shouldn't
> dereference it. As the above comment in the code says, this is very
> unlikely to happen, but it's wrong anyway so let's fix it.
> 
> I hit this issue because of a different bug that caused tx_queue to be
> NULL. If that happens, this is the error message that we get here:
>   BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
>   [...]
>   RIP: 0010:efx_hard_start_xmit+0x153/0x170 [sfc]
> 
> Fixes: 12804793b17c ("sfc: decouple TXQ type from label")
> Reported-by: Tianhao Zhao <tizhao@redhat.com>
> Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>

Acked-by: Edward Cree <ecree.xilinx@gmail.com>
patchwork-bot+netdevbpf@kernel.org Sept. 20, 2022, 1:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 14 Sep 2022 13:11:35 +0200 you wrote:
> Trying to get the channel from the tx_queue variable here is wrong
> because we can only be here if tx_queue is NULL, so we shouldn't
> dereference it. As the above comment in the code says, this is very
> unlikely to happen, but it's wrong anyway so let's fix it.
> 
> I hit this issue because of a different bug that caused tx_queue to be
> NULL. If that happens, this is the error message that we get here:
>   BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
>   [...]
>   RIP: 0010:efx_hard_start_xmit+0x153/0x170 [sfc]
> 
> [...]

Here is the summary with links:
  - [net] sfc: fix null pointer dereference in efx_hard_start_xmit
    https://git.kernel.org/netdev/net/c/0a242eb2913a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index d12474042c84..c5f88f7a7a04 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -549,7 +549,7 @@  netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb,
 		 * previous packets out.
 		 */
 		if (!netdev_xmit_more())
-			efx_tx_send_pending(tx_queue->channel);
+			efx_tx_send_pending(efx_get_tx_channel(efx, index));
 		return NETDEV_TX_OK;
 	}