Page MenuHomeFreeBSD

Simplify IPsec transform-specific teardown.
ClosedPublic

Authored by jhb on Jun 25 2020, 12:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 20 2024, 11:56 AM
Unknown Object (File)
Feb 22 2024, 7:54 PM
Unknown Object (File)
Jan 16 2024, 4:50 PM
Unknown Object (File)
Jan 4 2024, 11:49 AM
Unknown Object (File)
Dec 25 2023, 4:41 AM
Unknown Object (File)
Sep 11 2023, 6:45 AM
Unknown Object (File)
Sep 5 2023, 12:43 PM
Unknown Object (File)
Aug 12 2023, 3:45 PM
Subscribers

Details

Summary
  • Rename from the teardown callback from 'zeroize' to 'cleanup' since this no longer zeroes keys.
  • Change the callback return type to void. Nothing checked the return value and it was always zero.
  • Don't have esp call into ah since it no longer needs to depend on this to clear the auth key. Instead, both are now private and self-contained.
Test Plan
  • IPsec tunnels over both IPv4 (AES-CBC + SHA1, AES-GCM) and IPv6 (AES-GCM)

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 31965
Build 29514: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Jun 25 2020, 12:43 AM

I'm not 100% comfortable with the removal of these = NULL's but it appears that the code didn't cared about their value being non-zero, so the change as-is seemed Okay.

I'd probably change key_cleansav() to perform a bzero on the whole 'sav' structure and remove all sav->* = NULL, but that's only a personal preference.

This revision is now accepted and ready to land.Jun 25 2020, 4:44 AM

I'm not 100% comfortable with the removal of these = NULL's but it appears that the code didn't cared about their value being non-zero, so the change as-is seemed Okay.

I'd probably change key_cleansav() to perform a bzero on the whole 'sav' structure and remove all sav->* = NULL, but that's only a personal preference.

I'd be fine doing a single zero of the sav. I'd much rather do that centralized than the current approach of partial clearing scattered about. I do think that in all these cases we are doing a zero just before freeing, and that none of these pointers being cleared currently are sensitive in the sense of requiring explicit_bzero().

In D25443#562009, @jhb wrote:

I'm not 100% comfortable with the removal of these = NULL's but it appears that the code didn't cared about their value being non-zero, so the change as-is seemed Okay.

I'd probably change key_cleansav() to perform a bzero on the whole 'sav' structure and remove all sav->* = NULL, but that's only a personal preference.

I'd be fine doing a single zero of the sav. I'd much rather do that centralized than the current approach of partial clearing scattered about. I do think that in all these cases we are doing a zero just before freeing, and that none of these pointers being cleared currently are sensitive in the sense of requiring explicit_bzero().

Hmm, this is not quite trivial. Some fields like sav->lock and sav->lftc_c probably need to not be zeroed in key_cleansav. Some of that I can fix by moving key_cleansav down in key_delsav just before the free and in that case we could even use zfree. This would potentially permit removing many of the NULL assignments from key_cleansav. However, key_cleansav is also called for the error case for key_setsaval. Hmm, looking at that more though, if that errors the key always gets freed, and in one of those cases we effectively duplicate key_freeval. Maybe I can clean this up.

In D25443#562018, @jhb wrote:
In D25443#562009, @jhb wrote:

I'm not 100% comfortable with the removal of these = NULL's but it appears that the code didn't cared about their value being non-zero, so the change as-is seemed Okay.

I'd probably change key_cleansav() to perform a bzero on the whole 'sav' structure and remove all sav->* = NULL, but that's only a personal preference.

I'd be fine doing a single zero of the sav. I'd much rather do that centralized than the current approach of partial clearing scattered about. I do think that in all these cases we are doing a zero just before freeing, and that none of these pointers being cleared currently are sensitive in the sense of requiring explicit_bzero().

Hmm, this is not quite trivial. Some fields like sav->lock and sav->lftc_c probably need to not be zeroed in key_cleansav. Some of that I can fix by moving key_cleansav down in key_delsav just before the free and in that case we could even use zfree. This would potentially permit removing many of the NULL assignments from key_cleansav. However, key_cleansav is also called for the error case for key_setsaval. Hmm, looking at that more though, if that errors the key always gets freed, and in one of those cases we effectively duplicate key_freeval. Maybe I can clean this up.

Hmmm, I guess for key_setsaval from key_update it is possible the ref count is greater than 0. I can put some of the NULL pointers back I suppose.

sys/netipsec/xform_tcp.c
361

I have to put this back since the call to xf_cleanup isn't conditional. I think having an empty function here is the simpler approach than checking xf_cleanup against NULL.

  • Restore an empty tcpsignature_cleanup.
  • Restore some NULL pointer assignments.
This revision now requires review to proceed.Jun 25 2020, 9:00 PM
jhb removed a reviewer: cem.
This revision is now accepted and ready to land.Jun 25 2020, 9:52 PM
This revision was automatically updated to reflect the committed changes.