Skip to contentSkip to conversation

net: tls: fix possible info leak in tls_set_device_offload()

PATCH In review Hangyu Hua 3 participants 4 messages Feb 24, 2023 – Feb 27, 2023

Subsystems (3)
lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH v2 1/1 net: tls: fix possible info leak in tls_set_device_offload()

After tls_set_device_offload() fails, we enter tls_set_sw_offload(). But tls_set_sw_offload can't set cctx->iv and cctx->rec_seq to NULL if it fails before kmalloc cctx->iv. It is better to Set them to NULL to avoid any potential info leak.

Fixes e8f69799810c ("net/tls: Add generic NIC offload infrastructure")

---

v2: change commit log. The original issue will be fixed in another patch.

 net/tls/tls_device.c | 2 ++
 1 file changed, 2 insertions(+)
net/tls/tls_device.c +2 -0
index 6c593788dc25..a63f6f727f58 100644
@@ -1241,8 +1241,10 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
 	kfree(start_marker_record);
 free_rec_seq:
 	kfree(ctx->tx.rec_seq);
+	ctx->tx.rec_seq = NULL;
 free_iv:
 	kfree(ctx->tx.iv);
+	ctx->tx.iv = NULL;
 release_netdev:
 	dev_put(netdev);
 	return rc;
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 4 lines · On Fri, 24 Feb 2023 18:28:39 +0800 Hangyu Hua wrote:

After tls_set_device_offload() fails, we enter tls_set_sw_offload(). But tls_set_sw_offload can't set cctx->iv and cctx->rec_seq to NULL if it fails before kmalloc cctx->iv. It is better to Set them to NULL to avoid any potential info leak.

Please show clear chain of events which can lead to a use-after-free or info leak. And if you can't please don't send the patch.

maintainer
#2 lore raw
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Fri, 24 Feb 2023 18:28:39 +0800 Hangyu Hua wrote:

After tls_set_device_offload() fails, we enter tls_set_sw_offload(). But tls_set_sw_offload can't set cctx->iv and cctx->rec_seq to NULL if it fails before kmalloc cctx->iv. It is better to Set them to NULL to avoid any potential info leak.

Please show clear chain of events which can lead to a use-after-free or info leak. And if you can't please don't send the patch.

Sorry, I thought in this morning's discussion Hangyu had agreed to remove all mentions of possible info leak while sending v2, since we agreed [1] that this patch didn't fix any issue, just that it looked more consistent, as tls_set_sw_offload NULLs iv and rec_seq on failure. We can also drop the patch completely. Anyway since net-next is closed, I should have told Hangyu to wait for 2 weeks.

[1] https://lore.kernel.org/all/[email protected]/

Signature · 1 line
Sabrina
author
#3 lore raw
Quoted 10 lines · Sabrina Dubroca
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Fri, 24 Feb 2023 18:28:39 +0800 Hangyu Hua wrote:

After tls_set_device_offload() fails, we enter tls_set_sw_offload(). But tls_set_sw_offload can't set cctx->iv and cctx->rec_seq to NULL if it fails before kmalloc cctx->iv. It is better to Set them to NULL to avoid any potential info leak.

Please show clear chain of events which can lead to a use-after-free or info leak. And if you can't please don't send the patch.

Quoted 9 lines

Sorry, I thought in this morning's discussion Hangyu had agreed to remove all mentions of possible info leak while sending v2, since we agreed [1] that this patch didn't fix any issue, just that it looked more consistent, as tls_set_sw_offload NULLs iv and rec_seq on failure. We can also drop the patch completely. Anyway since net-next is closed, I should have told Hangyu to wait for 2 weeks.

[1] https://lore.kernel.org/all/[email protected]/

Oops. I will make a whole new patch without mentions of info leak in a few weeks. Please ignore this patch.