On 2025-05-12 12:58 PM, Zilin Guan wrote:
The function ixgbe_ipsec_add_sa() currently uses memset() to zero out
stack-allocated SA structs (rsa and tsa) before return, but the gcc-11.4.0
compiler optimizes these calls away. This leaves sensitive key and salt
material on the stack after return.

Replace these memset() calls with memzero_explicit() to prevent the
compiler from optimizing them away. This guarantees that the SA key and
salt are reliably cleared from the stack.

Signed-off-by: Zilin Guan <[email protected]>

Thanks for your patch.

Please use the correct target iwl-net for fixes, iwl-next for features and others.

Maybe add a tag? Fixes: 63a67fe229ea ("ixgbe: add ipsec offload add and remove SA")

In the future when sending patches against Intel networking drivers please send them directly To: [email protected] and Cc: [email protected].

---
  drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 07ea1954a276..e8c84f7e937b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -678,7 +678,7 @@ static int ixgbe_ipsec_add_sa(struct xfrm_state *xs,
                } else {
                        /* no match and no empty slot */
                        NL_SET_ERR_MSG_MOD(extack, "No space for SA in Rx IP SA 
table");
-                       memset(&rsa, 0, sizeof(rsa));
+                       memzero_explicit(&rsa, sizeof(rsa));
                        return -ENOSPC;
                }
@@ -727,7 +727,7 @@ static int ixgbe_ipsec_add_sa(struct xfrm_state *xs,
                ret = ixgbe_ipsec_parse_proto_keys(xs, tsa.key, &tsa.salt);
                if (ret) {
                        NL_SET_ERR_MSG_MOD(extack, "Failed to get key data for Tx SA 
table");
-                       memset(&tsa, 0, sizeof(tsa));
+                       memzero_explicit(&tsa, sizeof(tsa));

As for the code change itself, LGTM.

Acked-by: Dawid Osuchowski <[email protected]>

Thanks,
Dawid

                        return ret;
                }

Reply via email to