KeyUpdate Support
Currently tlshd uses fork() to fork the entire process after the kernel sends a netlink message. tlshd then calls the tlshd_service_socket() function from the child process and exits.
This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between tlshd_service_socket() and the parent process. For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.
In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the gnutls_session_t session information for a connection to allow us to issue a KeyUpdate later on.
AFAIK there is no way to re-create the gnutls_session_t session so we need to store it somewhere. We could pass it to the kernel and have the kernel pass it back. But gnutls_session_t session is gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls updates between a handshake and KeyUpdate.
The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current fork() multi-process mechanism to a g_thread_new() threading mechanism.
In the future this will allow us to maintain the gnutls_session_t session in the parent process, allowing KeyUpdate support. This could also be supported with fork() and IPC as well, but that is clunky-ier.
My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
1: https://github.com/oracle/ktls-utils/pull/95
Alistair
Quoted 30 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process. For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()threading mechanism.
Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.
So not that easy.
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Quoted 56 lines · Hannes Reinecke
Quoted 35 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process.
For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a
connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need
to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls
updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()
threading mechanism.Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.
Quoted 5 lines
So not that easy.
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
I was about to suggest something similar. Depending on what APIs are available in (or might be added to) gnuTLS, preserve the session's metadata in a key ring, and return the key's serial number to the kernel as part of the handshake result. When requesting a KeyUpdate, pass that serial number back to tlshd.
It would help if someone could review gnuTLS to see what is available now, and start a discussion with that community if we need a capability or API that doesn't already exist. (Eg: translate a gnutls_session_t object into a JSON string; translate a JSON string into a gnutls_session_t object)
The other aspect of this is that tlshd will have to prevent saved session state from growing without bound. Probably the kernel will have to notify tlshd when a session is terminated so that associated saved session state can be discarded.
Signature · 1 line
Chuck Lever
Quoted 69 lines · Chuck Lever
Quoted 56 lines · Hannes Reinecke
Quoted 35 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process.
For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a
connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need
to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls
updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()
threading mechanism.Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.Quoted 5 lines
So not that easy.
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
I was about to suggest something similar. Depending on what APIs are available in (or might be added to) gnuTLS, preserve the session's metadata in a key ring, and return the key's serial number to the kernel as part of the handshake result. When requesting a KeyUpdate, pass that serial number back to tlshd.
Quoted 5 lines
It would help if someone could review gnuTLS to see what is available now, and start a discussion with that community if we need a capability or API that doesn't already exist. (Eg: translate a
gnutls_session_tobject into a JSON string; translate a JSON string into agnutls_session_tobject)
I believe gnutls_session_{get,set}_data will serialize the session object. It would be trivial to store in a key.
I could test, but not until next week.
Ben
Quoted 71 lines · Benjamin Coddington
Quoted 69 lines · Chuck Lever
Quoted 56 lines · Hannes Reinecke
Quoted 35 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process.
For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a
connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need
to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls
updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()
threading mechanism.Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.Quoted 5 lines
So not that easy.
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
I was about to suggest something similar. Depending on what APIs are available in (or might be added to) gnuTLS, preserve the session's metadata in a key ring, and return the key's serial number to the kernel as part of the handshake result. When requesting a KeyUpdate, pass that serial number back to tlshd.
Quoted 8 lines
Quoted 5 lines
It would help if someone could review gnuTLS to see what is available now, and start a discussion with that community if we need a capability or API that doesn't already exist. (Eg: translate a
gnutls_session_tobject into a JSON string; translate a JSON string into agnutls_session_tobject)I believe gnutls_session_{get,set}_data will serialize the session object. It would be trivial to store in a key.
Oh, very cool.
Quoted 4 lines
Quoted 4 lines
The other aspect of this is that tlshd will have to prevent saved session state from growing without bound. Probably the kernel will have to notify tlshd when a session is terminated so that associated saved session state can be discarded.
It occurs to me that tlshd doesn't need to be involved in this aspect. The kernel can delete a key by serial number when it notices that a session has been permanently terminated.
Signature · 1 line
Chuck Lever
Quoted 79 lines · Chuck Lever
Quoted 77 lines · Benjamin Coddington
Quoted 74 lines · Chuck Lever
Quoted 56 lines · Hannes Reinecke
Quoted 35 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process.
For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a
connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need
to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls
updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()
threading mechanism.Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.Quoted 5 lines
So not that easy.
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
I was about to suggest something similar. Depending on what APIs are available in (or might be added to) gnuTLS, preserve the session's metadata in a key ring, and return the key's serial number to the kernel as part of the handshake result. When requesting a KeyUpdate, pass that serial number back to tlshd.
It would help if someone could review gnuTLS to see what is available now, and start a discussion with that community if we need a capability or API that doesn't already exist. (Eg: translate a
gnutls_session_tobject into a JSON string; translate a JSON string into agnutls_session_tobject)
Quoted 5 lines
Quoted 2 lines
I believe gnutls_session_{get,set}_data will serialize the session object. It would be trivial to store in a key.
Oh, very cool.
gnutls_session_{get,set}_data() is for session resumption and used on client side, it's been used in the quic handshake code in tlshd.
It would be surprising if the session resumed could be used for TLS keyUpdate, and I'm also looking forward to seeing the test result.
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
The other aspect of this is that tlshd will have to prevent saved session state from growing without bound. Probably the kernel will have to notify tlshd when a session is terminated so that associated saved session state can be discarded.
It occurs to me that tlshd doesn't need to be involved in this aspect. The kernel can delete a key by serial number when it notices that a session has been permanently terminated.
FYI, for the gnutls_anti_replay_t in early data transmission, which I try to support in quic handshake, it's another object that needs to be serialized.
gnutls_anti_replay_t is opaque, gnutls provides setters for all its members *expect* 'start_time'. Otherwise, I could simply recreate it for each handshake.
Thanks.
Quoted 62 lines · Chuck Lever
Quoted 61 lines · Benjamin Coddington
Quoted 59 lines · Chuck Lever
Quoted 58 lines · Hannes Reinecke
Quoted 35 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process.
For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a
connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need
to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls
updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()
threading mechanism.Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.So not that easy.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
I was about to suggest something similar. Depending on what APIs are available in (or might be added to) gnuTLS, preserve the session's metadata in a key ring, and return the key's serial number to the kernel as part of the handshake result. When requesting a KeyUpdate, pass that serial number back to tlshd.
Ok, that seems pretty do-able
I'm working on some kernel patches now that start to implement the basics of this
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
It would help if someone could review gnuTLS to see what is available now, and start a discussion with that community if we need a capability or API that doesn't already exist. (Eg: translate a
gnutls_session_tobject into a JSON string; translate a JSON string into agnutls_session_tobject)I believe gnutls_session_{get,set}_data will serialize the session object. It would be trivial to store in a key.
Oh, very cool.
I didn't see that previously. That does seem to do exactly what we need
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
The other aspect of this is that tlshd will have to prevent saved session state from growing without bound. Probably the kernel will have to notify tlshd when a session is terminated so that associated saved session state can be discarded.
It occurs to me that tlshd doesn't need to be involved in this aspect. The kernel can delete a key by serial number when it notices that a session has been permanently terminated.
Oh good point. That will help with freeing memory.
Alistair
Quoted 2 lines
Quoted 86 lines · Alistair
Quoted 62 lines · Chuck Lever
Quoted 61 lines · Benjamin Coddington
Quoted 59 lines · Chuck Lever
Quoted 58 lines · Hannes Reinecke
Quoted 35 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process.
For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a
connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need
to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls
updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()
threading mechanism.Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.So not that easy.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
I was about to suggest something similar. Depending on what APIs are available in (or might be added to) gnuTLS, preserve the session's metadata in a key ring, and return the key's serial number to the kernel as part of the handshake result. When requesting a KeyUpdate, pass that serial number back to tlshd.
Ok, that seems pretty do-able
I'm working on some kernel patches now that start to implement the basics of this
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
It would help if someone could review gnuTLS to see what is available now, and start a discussion with that community if we need a capability or API that doesn't already exist. (Eg: translate a
gnutls_session_tobject into a JSON string; translate a JSON string into agnutls_session_tobject)
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
I believe gnutls_session_{get,set}_data will serialize the session object. It would be trivial to store in a key.
Oh, very cool.
I didn't see that previously. That does seem to do exactly what we need
A follow up on this, gnutls_session_{get,set}_data doesn't seem to store enough data to easily resume a session to handle a KeyUpdate. So we probably need to modify gnutls to get this working.
Alistair
Quoted 23 lines
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
The other aspect of this is that tlshd will have to prevent saved session state from growing without bound. Probably the kernel will have to notify tlshd when a session is terminated so that associated saved session state can be discarded.
It occurs to me that tlshd doesn't need to be involved in this aspect. The kernel can delete a key by serial number when it notices that a session has been permanently terminated.
Oh good point. That will help with freeing memory.
Alistair
Quoted 2 lines
Quoted 89 lines · Alistair
Quoted 88 lines · Alistair
Quoted 62 lines · Chuck Lever
Quoted 61 lines · Benjamin Coddington
Quoted 59 lines · Chuck Lever
Quoted 58 lines · Hannes Reinecke
Quoted 35 lines · Alistair
Currently tlshd uses
fork()to fork the entire process after the kernel sends a netlink message. tlshd then calls thetlshd_service_socket()function from the child process and exits.This provides a high barrier between different handshake requests and ensures everything is freed when a handshake is complete.
The problem with the current setup is that it makes it very difficult to share information between
tlshd_service_socket()and the parent process.
For security and system resources that's great, but it has the large down side of not supporting the TLS KeyUpdate.In the future we would like to support the TLS KeyUpdate mechanism, which means we need to maintain the
gnutls_session_t sessioninformation for a
connection to allow us to issue a KeyUpdate later on.AFAIK there is no way to re-create the
gnutls_session_t sessionso we need
to store it somewhere. We could pass it to the kernel and have the kernel pass it back. Butgnutls_session_t sessionis gnutls internal state, so it's not fixed size making that tricky to do. Plus it will break if gnutls
updates between a handshake and KeyUpdate.The other option is to pass the session data from the child process back to the tlshd parent process. The parent can then store the session data (maybe in a database?) and use it as required.
I submitted the first step towards supporting that as a PR [1]. The PR changes the current
fork()multi-process mechanism to ag_thread_new()
threading mechanism.Quoted 9 lines
In the future this will allow us to maintain the
gnutls_session_tsession in the parent process, allowing KeyUpdate support. This could also be supported withfork()and IPC as well, but that is clunky-ier.My approach [1] hasn't been accepted, so now I'm trying to see what ideas other people have for supporting KeyUpdate?
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.So not that easy.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
I was about to suggest something similar. Depending on what APIs are available in (or might be added to) gnuTLS, preserve the session's metadata in a key ring, and return the key's serial number to the kernel as part of the handshake result. When requesting a KeyUpdate, pass that serial number back to tlshd.
Ok, that seems pretty do-able
I'm working on some kernel patches now that start to implement the basics of this
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
It would help if someone could review gnuTLS to see what is available now, and start a discussion with that community if we need a capability or API that doesn't already exist. (Eg: translate a
gnutls_session_tobject into a JSON string; translate a JSON string into agnutls_session_tobject)I believe gnutls_session_{get,set}_data will serialize the session object. It would be trivial to store in a key.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Oh, very cool.
I didn't see that previously. That does seem to do exactly what we need
A follow up on this, gnutls_session_{get,set}_data doesn't seem to store enough data to easily resume a session to handle a KeyUpdate. So we probably need to modify gnutls to get this working.
Thanks for checking.
I would start by joining the gnutls development community and asking them for advice.
Quoted 25 lines
Alistair
Quoted 23 lines
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
The other aspect of this is that tlshd will have to prevent saved session state from growing without bound. Probably the kernel will have to notify tlshd when a session is terminated so that associated saved session state can be discarded.
It occurs to me that tlshd doesn't need to be involved in this aspect. The kernel can delete a key by serial number when it notices that a session has been permanently terminated.
Oh good point. That will help with freeing memory.
Alistair
Quoted 2 lines
Signature · 1 line
Chuck Lever
On 5/21/25 08:43, Hannes Reinecke wrote:
[ .. ]
Quoted 11 lines
Hehe. I knew it would come up.
The reason we didn't implement it for now is that there's an overlap with session reset. In NVMe any error will be causing a session reset, which then will trigger a TLS handshake. And, what's more, with secure concatenation we even generate a new set of TLS PSKs on every reset. All of this is transparent to the upper layers, so they will only see a (hopefully short) delay.
Additionally, with the current in-kernel TLS the connection will be reset when the IV values are being changed, which again would trigger a reconnect on the NVMe side.
Quoted 6 lines
So not that easy.
But if you insist on doing that, why don't you use the keyring to store the temporary session key? That is persistent, and required to be present for tlshd to work ...
Oh, and I forgot the most crucial thing: NVMe-TCP can't do it with the current implementation. It's using the ->read_sock() interface which gets the skb (not the msg), so we won't be getting the control message which we need to get notified about the KeyUpdate event.
Meaning we would need to switch over to a recvmsg-based receive flow; I have patches for that, but they are on hold as we can't easily do a digest calculation there.
But now that Eric Biggers send a patch series to use the 'crc32' calculation directly I guess I should revisit those patches.
Unless someone beats me to it ...
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich