linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ixgbe/ipsec: use memzero_explicit() for stack SA structs
@ 2025-05-12 10:58 Zilin Guan
  2025-05-12 12:53 ` Dawid Osuchowski
  0 siblings, 1 reply; 8+ messages in thread
From: Zilin Guan @ 2025-05-12 10:58 UTC (permalink / raw)
  To: anthony.l.nguyen
  Cc: przemyslaw.kitszel, andrew+netdev, davem, edumazet, kuba, pabeni,
	intel-wired-lan, netdev, linux-kernel, jianhao.xu, Zilin Guan

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 <zilin@seu.edu.cn>
---
 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));
 			return ret;
 		}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-05-16 15:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 10:58 [PATCH] ixgbe/ipsec: use memzero_explicit() for stack SA structs Zilin Guan
2025-05-12 12:53 ` Dawid Osuchowski
2025-05-13 12:24   ` Zilin Guan
2025-05-13 13:21     ` Dawid Osuchowski
2025-05-13 13:31   ` Zilin Guan
2025-05-13 13:54     ` Dawid Osuchowski
2025-05-15  9:27       ` Przemek Kitszel
2025-05-16 15:04         ` Zilin Guan

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).