netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/tls: Fix possible UAF in tls_set_device_offload
@ 2022-11-17 10:41 Lu Jialin
  2022-11-19  2:43 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Lu Jialin @ 2022-11-17 10:41 UTC (permalink / raw)
  To: Boris Pismenny, John Fastabend, Jakub Kicinski, David S . Miller,
	Eric Dumazet, Paolo Abeni, Aviad Yehezkel, Ilya Lesokhin
  Cc: Lu Jialin, linux-kernel, netdev

In tls_set_device_offload(), the error path "goto release_lock" will
not remove start_marker_record->list from offload_ctx->records_list,
but start_marker_record will be freed, then list traversal may cause UAF.

This fixes the following smatch warning:

net/tls/tls_device.c:1241 tls_set_device_offload() warn: '&start_marker_record->list' not removed from list

Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure")
Signed-off-by: Lu Jialin <lujialin4@huawei.com>
---
 net/tls/tls_device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index a03d66046ca3..2def20870c58 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -1234,6 +1234,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
 	up_read(&device_offload_lock);
 	clean_acked_data_disable(inet_csk(sk));
 	crypto_free_aead(offload_ctx->aead_send);
+	list_del(&start_marker_record->list);
 free_offload_ctx:
 	kfree(offload_ctx);
 	ctx->priv_ctx_tx = NULL;
-- 
2.17.1


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

* Re: [PATCH] net/tls: Fix possible UAF in tls_set_device_offload
  2022-11-17 10:41 [PATCH] net/tls: Fix possible UAF in tls_set_device_offload Lu Jialin
@ 2022-11-19  2:43 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2022-11-19  2:43 UTC (permalink / raw)
  To: Lu Jialin
  Cc: Boris Pismenny, John Fastabend, David S . Miller, Eric Dumazet,
	Paolo Abeni, Aviad Yehezkel, Ilya Lesokhin, linux-kernel, netdev

On Thu, 17 Nov 2022 18:41:32 +0800 Lu Jialin wrote:
> In tls_set_device_offload(), the error path "goto release_lock" will
> not remove start_marker_record->list from offload_ctx->records_list,
> but start_marker_record will be freed, then list traversal may cause UAF.

Nope, the two object which are linked together are freed one 
after another.

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

end of thread, other threads:[~2022-11-19  2:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 10:41 [PATCH] net/tls: Fix possible UAF in tls_set_device_offload Lu Jialin
2022-11-19  2:43 ` Jakub Kicinski

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