Skip to contentSkip to conversation

sfc: fix use-after-free in efx_tc_flower_record_encap_match()

PATCH Applied [email protected] 3 participants 3 messages May 12, 2023 – May 13, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sfc: fix use-after-free in efx_tc_flower_record_encap_match()

From: Edward Cree <[email protected]>

When writing error messages to extack for pseudo collisions, we can't
use encap->type as encap has already been freed. Fortunately the same value is stored in local variable em_type, so use that instead.

Fixes 3c9561c0a5b9 ("sfc: support TC decap rules matching on enc_ip_tos")
---
 drivers/net/ethernet/sfc/tc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/sfc/tc.c +2 -2
index da684b4b7211..6dfbdb39f2fe 100644
@@ -504,7 +504,7 @@ static int efx_tc_flower_record_encap_match(struct efx_nic *efx,
 			if (em_type != EFX_TC_EM_PSEUDO_MASK) {
 				NL_SET_ERR_MSG_FMT_MOD(extack,
 						       "%s encap match conflicts with existing pseudo(MASK) entry",
-						       encap->type ? "Pseudo" : "Direct");
+						       em_type ? "Pseudo" : "Direct");
 				return -EEXIST;
 			}
 			if (child_ip_tos_mask != old->child_ip_tos_mask) {
@@ -525,7 +525,7 @@ static int efx_tc_flower_record_encap_match(struct efx_nic *efx,
 		default: /* Unrecognised pseudo-type.  Just say no */
 			NL_SET_ERR_MSG_FMT_MOD(extack,
 					       "%s encap match conflicts with existing pseudo(%d) entry",
-					       encap->type ? "Pseudo" : "Direct",
+					       em_type ? "Pseudo" : "Direct",
 					       old->type);
 			return -EEXIST;
 		}
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Fri, May 12, 2023 at 04:35:58PM +0100, [email protected] wrote:

From: Edward Cree <[email protected]>

When writing error messages to extack for pseudo collisions, we can't
use encap->type as encap has already been freed. Fortunately the same value is stored in local variable em_type, so use that instead.

Fixes 3c9561c0a5b9 ("sfc: support TC decap rules matching on enc_ip_tos")

Thanks,

Quoted 27 lines
---
 drivers/net/ethernet/sfc/tc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/sfc/tc.c +2 -2
index da684b4b7211..6dfbdb39f2fe 100644
@@ -504,7 +504,7 @@ static int efx_tc_flower_record_encap_match(struct efx_nic *efx,
 			if (em_type != EFX_TC_EM_PSEUDO_MASK) {
 				NL_SET_ERR_MSG_FMT_MOD(extack,
 						       "%s encap match conflicts with existing pseudo(MASK) entry",
-						       encap->type ? "Pseudo" : "Direct");
+						       em_type ? "Pseudo" : "Direct");
 				return -EEXIST;
 			}
 			if (child_ip_tos_mask != old->child_ip_tos_mask) {
@@ -525,7 +525,7 @@ static int efx_tc_flower_record_encap_match(struct efx_nic *efx,
 		default: /* Unrecognised pseudo-type.  Just say no */
 			NL_SET_ERR_MSG_FMT_MOD(extack,
 					       "%s encap match conflicts with existing pseudo(%d) entry",
-					       encap->type ? "Pseudo" : "Direct",
+					       em_type ? "Pseudo" : "Direct",
 					       old->type);
 			return -EEXIST;
 		}
#2 lore raw
In reply to [email protected]
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 11 lines · On Fri, 12 May 2023 16:35:58 +0100 you wrote:

From: Edward Cree <[email protected]>

When writing error messages to extack for pseudo collisions, we can't
use encap->type as encap has already been freed. Fortunately the same value is stored in local variable em_type, so use that instead.

Fixes 3c9561c0a5b9 ("sfc: support TC decap rules matching on enc_ip_tos")

[...]

Here is the summary with links:
- [net-next] sfc: fix use-after-free in efx_tc_flower_record_encap_match()

    https://git.kernel.org/netdev/net-next/c/befcc1fce564

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html