lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 3 Oct 2023 18:58:40 +0200
From: Sabrina Dubroca <sd@...asysnail.net>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: Ayush Sawal <ayush.sawal@...lsio.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Rohit Maheshwari <rohitm@...lsio.com>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v2][next] cxgb4/ch_ktls: Fix undefined behavior bug in
 struct chcr_ktls_ofld_ctx_tx

2023-10-03, 12:56:54 +0200, Gustavo A. R. Silva wrote:
> `struct tls_offload_context_tx` is a flexible structure, which means
> that it contains a flexible-array member at the bottom. This could
> potentially lead to an overwrite of the objects following `base` in
> `struct chcr_ktls_ofld_ctx_tx` at run-time.
> 
> Notice that flexible-array member `driver_state` in `struct
> tls_offload_context_tx` can grow up to 16 bytes:
> 
> | include/net/tls.h-170:
> | #define TLS_DRIVER_STATE_SIZE_TX  16
> 
> | include/net/tls.h-173:
> | #define TLS_OFFLOAD_CONTEXT_SIZE_TX                                     \
> |	(sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX)
> 
> | net/tls/tls_device.c-1119:
> | offload_ctx = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE_TX, GFP_KERNEL);
> 
> Fix this by placing the declaration of object `base` at the end of
> `struct chcr_ktls_ofld_ctx_tx`.

AFAIU, chcr_ktls_ofld_ctx_tx just misuses the extra space allocated by
tls_set_device_offload. There's no bug, but the code is a bit
confusing. I don't think this patch works, since chcr_ktls doesn't
allocate its own memory for chcr_ktls_ofld_ctx_tx.

As part of a series of cleanups that I'll submit soon (hopefully this
week), I updated chcr_ktls to use the driver_state part of
tls_offload_context_tx (instead of the cast in
chcr_get_ktls_tx_context), and then removed the flexarrays from
tls_offload_context_tx and tls_offload_context_rx (since they're
actually a fixed size).

-- 
Sabrina


Powered by blists - more mailing lists