netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] selftests: tls: add a selftest for wrapping rec_seq
@ 2024-10-18 10:55 Sabrina Dubroca
  2024-10-19  8:03 ` Simon Horman
  2024-10-24 14:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Sabrina Dubroca @ 2024-10-18 10:55 UTC (permalink / raw)
  To: netdev
  Cc: Sabrina Dubroca, Boris Pismenny, John Fastabend, Jakub Kicinski,
	linux-kselftest

Set the initial rec_seq to 0xffffffffffffffff so that it wraps
immediately. The send() call should fail with EBADMSG.

A bug in this code was fixed in commit cfaa80c91f6f ("net/tls: do not
free tls_rec on async operation in bpf_exec_tx_verdict()").

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 tools/testing/selftests/net/tls.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index f27a12d2a2c9..1a706d03bb6b 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -266,6 +266,25 @@ TEST_F(tls_basic, bad_cipher)
 	EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, sizeof(struct tls12_crypto_info_aes_gcm_128)), -1);
 }
 
+TEST_F(tls_basic, recseq_wrap)
+{
+	struct tls_crypto_info_keys tls12;
+	char const *test_str = "test_read";
+	int send_len = 10;
+
+	if (self->notls)
+		SKIP(return, "no TLS support");
+
+	tls_crypto_info_init(TLS_1_2_VERSION, TLS_CIPHER_AES_GCM_128, &tls12);
+	memset(&tls12.aes128.rec_seq, 0xff, sizeof(tls12.aes128.rec_seq));
+
+	ASSERT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, tls12.len), 0);
+	ASSERT_EQ(setsockopt(self->cfd, SOL_TLS, TLS_RX, &tls12, tls12.len), 0);
+
+	EXPECT_EQ(send(self->fd, test_str, send_len, 0), -1);
+	EXPECT_EQ(errno, EBADMSG);
+}
+
 FIXTURE(tls)
 {
 	int fd, cfd;
-- 
2.47.0


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

* Re: [PATCH net-next] selftests: tls: add a selftest for wrapping rec_seq
  2024-10-18 10:55 [PATCH net-next] selftests: tls: add a selftest for wrapping rec_seq Sabrina Dubroca
@ 2024-10-19  8:03 ` Simon Horman
  2024-10-24 14:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-10-19  8:03 UTC (permalink / raw)
  To: Sabrina Dubroca
  Cc: netdev, Boris Pismenny, John Fastabend, Jakub Kicinski,
	linux-kselftest

On Fri, Oct 18, 2024 at 12:55:58PM +0200, Sabrina Dubroca wrote:
> Set the initial rec_seq to 0xffffffffffffffff so that it wraps
> immediately. The send() call should fail with EBADMSG.
> 
> A bug in this code was fixed in commit cfaa80c91f6f ("net/tls: do not
> free tls_rec on async operation in bpf_exec_tx_verdict()").
> 
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH net-next] selftests: tls: add a selftest for wrapping rec_seq
  2024-10-18 10:55 [PATCH net-next] selftests: tls: add a selftest for wrapping rec_seq Sabrina Dubroca
  2024-10-19  8:03 ` Simon Horman
@ 2024-10-24 14:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-24 14:20 UTC (permalink / raw)
  To: Sabrina Dubroca; +Cc: netdev, borisp, john.fastabend, kuba, linux-kselftest

Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Fri, 18 Oct 2024 12:55:58 +0200 you wrote:
> Set the initial rec_seq to 0xffffffffffffffff so that it wraps
> immediately. The send() call should fail with EBADMSG.
> 
> A bug in this code was fixed in commit cfaa80c91f6f ("net/tls: do not
> free tls_rec on async operation in bpf_exec_tx_verdict()").
> 
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> 
> [...]

Here is the summary with links:
  - [net-next] selftests: tls: add a selftest for wrapping rec_seq
    https://git.kernel.org/netdev/net-next/c/81bc949f640f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-10-24 14:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 10:55 [PATCH net-next] selftests: tls: add a selftest for wrapping rec_seq Sabrina Dubroca
2024-10-19  8:03 ` Simon Horman
2024-10-24 14:20 ` patchwork-bot+netdevbpf

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