netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: tls: fix possible info leak in tls_set_device_offload()
@ 2023-02-24 10:28 Hangyu Hua
  2023-02-24 18:57 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Hangyu Hua @ 2023-02-24 10:28 UTC (permalink / raw)
  To: borisp, john.fastabend, kuba, davem, edumazet, pabeni, ilyal,
	aviadye, sd
  Cc: netdev, linux-kernel, Hangyu Hua

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")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---

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

 net/tls/tls_device.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 6c593788dc25..a63f6f727f58 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -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;
-- 
2.34.1


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

end of thread, other threads:[~2023-02-27  5:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 10:28 [PATCH v2] net: tls: fix possible info leak in tls_set_device_offload() Hangyu Hua
2023-02-24 18:57 ` Jakub Kicinski
2023-02-24 20:22   ` Sabrina Dubroca
2023-02-27  5:53     ` Hangyu Hua

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