Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: tls: add a selftest for wrapping rec_seq

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>
Link: https://patch.msgid.link/20775fcfd0371422921ee60a42de170c0398ac10.1729244987.git.sd@queasysnail.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Sabrina Dubroca and committed by
Paolo Abeni
81bc949f 8b448f0d

+19
+19
tools/testing/selftests/net/tls.c
··· 266 266 EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, sizeof(struct tls12_crypto_info_aes_gcm_128)), -1); 267 267 } 268 268 269 + TEST_F(tls_basic, recseq_wrap) 270 + { 271 + struct tls_crypto_info_keys tls12; 272 + char const *test_str = "test_read"; 273 + int send_len = 10; 274 + 275 + if (self->notls) 276 + SKIP(return, "no TLS support"); 277 + 278 + tls_crypto_info_init(TLS_1_2_VERSION, TLS_CIPHER_AES_GCM_128, &tls12); 279 + memset(&tls12.aes128.rec_seq, 0xff, sizeof(tls12.aes128.rec_seq)); 280 + 281 + ASSERT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, tls12.len), 0); 282 + ASSERT_EQ(setsockopt(self->cfd, SOL_TLS, TLS_RX, &tls12, tls12.len), 0); 283 + 284 + EXPECT_EQ(send(self->fd, test_str, send_len, 0), -1); 285 + EXPECT_EQ(errno, EBADMSG); 286 + } 287 + 269 288 FIXTURE(tls) 270 289 { 271 290 int fd, cfd;