diff mbox series

[net-next] sfc: fix use-after-free in efx_tc_flower_record_encap_match()

Message ID 20230512153558.15025-1-edward.cree@amd.com (mailing list archive)
State Accepted
Commit befcc1fce564bdb20ee55be981a355b0a7d0eac5
Delegated to: Netdev Maintainers
Headers show
Series [net-next] sfc: fix use-after-free in efx_tc_flower_record_encap_match() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
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: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 86 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

edward.cree@amd.com May 12, 2023, 3:35 p.m. UTC
From: Edward Cree <ecree.xilinx@gmail.com>

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")
Reported-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
---
 drivers/net/ethernet/sfc/tc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Horman May 12, 2023, 3:56 p.m. UTC | #1
On Fri, May 12, 2023 at 04:35:58PM +0100, edward.cree@amd.com wrote:
> From: Edward Cree <ecree.xilinx@gmail.com>
> 
> 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")
> Reported-by: Simon Horman <simon.horman@corigine.com>
> Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>

Thanks,

Reviewed-by: Simon Horman <simon.horman@corigine.com>

> ---
>  drivers/net/ethernet/sfc/tc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c
> index da684b4b7211..6dfbdb39f2fe 100644
> --- a/drivers/net/ethernet/sfc/tc.c
> +++ b/drivers/net/ethernet/sfc/tc.c
> @@ -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;
>  		}
>
patchwork-bot+netdevbpf@kernel.org May 13, 2023, 8 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Fri, 12 May 2023 16:35:58 +0100 you wrote:
> From: Edward Cree <ecree.xilinx@gmail.com>
> 
> 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")
> Reported-by: Simon Horman <simon.horman@corigine.com>
> Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
> 
> [...]

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!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c
index da684b4b7211..6dfbdb39f2fe 100644
--- a/drivers/net/ethernet/sfc/tc.c
+++ b/drivers/net/ethernet/sfc/tc.c
@@ -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;
 		}