From nobody Tue Nov 23 23:13:10 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BDCAC18A2279; Tue, 23 Nov 2021 23:13:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HzKgX5yHpz3vr2; Tue, 23 Nov 2021 23:13:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 467D71F2B9; Tue, 23 Nov 2021 23:13:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1ANNDArV038041; Tue, 23 Nov 2021 23:13:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ANNDA3c038040; Tue, 23 Nov 2021 23:13:10 GMT (envelope-from git) Date: Tue, 23 Nov 2021 23:13:10 GMT Message-Id: <202111232313.1ANNDA3c038040@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: e91446cd84b3 - stable/13 - ktls: Add tests ensuring invalid receive cipher suites are rejected. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e91446cd84b3d03eb14d5c6dbd585057d0977a53 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637709193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=x88n0YIT5lUWrkENbQnrxgzIhquo2J5+tEccxs3hDHU=; b=myY3Sc95oK0EKIi14tq0P1UYwP2fEJ6LMhkX/Ye6WvMcZfkHsm+jngiYNr7dljLxek3omB KsGx8ZqY4SEoRpr7VpWW1cs2d72m0K+pBdB80OT3sPOczMMyxTo6o6u93LJW3Enf5mS+Mf SNQgGQRp0/k9Qte9OyJ8FBMs+oEtxDqPcn1G+EK8cgAfi+quourESqHWV6qgqShX0G8ebE Tw+yAJDzdDa1LuopwiHAeRcd3Xq1ozsaICFhpMnVbrIb3hj3tNkS5lLbyNGzGkNtV56bSr THCnSmWTf85Su31jV88RKzhaes2zYEIEChI4HA59uOnGupDcay8hZISLu7NPTA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637709193; a=rsa-sha256; cv=none; b=mtDKM6UvUWQxW68UQHwWLSsPnwFwgyJe4Rtn6Hcd1dtgTlypujeNYRkKSO/cF4MyJVvAvC zE8GUGGaBdP5xS2Fdvr/dR4+9+eA3Ax5X8eqs3BFfjL66BpOZTp9cLdM1Tyf4D2JH3qcsg RnNohVF57neD7QSA2e0c0KUVfasWJy0449GI4nlItVSq3C+41ZUgpaV4pWhOUGdeqGNm/1 M51+wIXuIrhftoDXiKYEpIGdNA8qIC/18evP+5ZwQlfZ6GmSw9z3ZuvFpncwjmJsaLXQlQ qIV5Kxk2WBsgkEaMfU5Ute6vbTje2iaVxDVX43iOtLlLPgv8JpOYZg40a2umOg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e91446cd84b3d03eb14d5c6dbd585057d0977a53 commit e91446cd84b3d03eb14d5c6dbd585057d0977a53 Author: John Baldwin AuthorDate: 2021-11-15 19:32:15 +0000 Commit: John Baldwin CommitDate: 2021-11-23 23:11:54 +0000 ktls: Add tests ensuring invalid receive cipher suites are rejected. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32981 (cherry picked from commit 233ce578a424a7a3e5cf21ea6ba2b2036950d54f) --- tests/sys/kern/ktls_test.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c index bdd2e62a546c..5aea56baa91f 100644 --- a/tests/sys/kern/ktls_test.c +++ b/tests/sys/kern/ktls_test.c @@ -1567,6 +1567,51 @@ ATF_TC_BODY(ktls_receive_##cipher_name##_##name, tc) \ */ TLS_12_TESTS(GEN_RECEIVE_TESTS); +static void +test_ktls_invalid_receive_cipher_suite(struct tls_enable *en) +{ + int sockets[2]; + + ATF_REQUIRE_MSG(socketpair_tcp(sockets), "failed to create sockets"); + + ATF_REQUIRE(setsockopt(sockets[1], IPPROTO_TCP, TCP_RXTLS_ENABLE, en, + sizeof(*en)) == -1); + + /* + * XXX: TLS 1.3 fails with ENOTSUP before checking for invalid + * ciphers. + */ + ATF_REQUIRE(errno == EINVAL || errno == ENOTSUP); + + close(sockets[1]); + close(sockets[0]); +} + +#define GEN_INVALID_RECEIVE_TEST(name, cipher_alg, key_size, auth_alg, \ + minor) \ +ATF_TC_WITHOUT_HEAD(ktls_receive_invalid_##name); \ +ATF_TC_BODY(ktls_receive_invalid_##name, tc) \ +{ \ + struct tls_enable en; \ + uint64_t seqno; \ + \ + ATF_REQUIRE_KTLS(); \ + seqno = random(); \ + build_tls_enable(cipher_alg, key_size, auth_alg, minor, seqno, \ + &en); \ + test_ktls_invalid_receive_cipher_suite(&en); \ + free_tls_enable(&en); \ +} + +#define ADD_INVALID_RECEIVE_TEST(name, cipher_alg, key_size, auth_alg, \ + minor) \ + ATF_TP_ADD_TC(tp, ktls_receive_invalid_##name); + +/* + * Ensure that invalid cipher suites are rejected for receive. + */ +INVALID_CIPHER_SUITES(GEN_INVALID_RECEIVE_TEST); + ATF_TP_ADD_TCS(tp) { /* Transmit tests */ @@ -1579,5 +1624,7 @@ ATF_TP_ADD_TCS(tp) /* Receive tests */ TLS_12_TESTS(ADD_RECEIVE_TESTS); + INVALID_CIPHER_SUITES(ADD_INVALID_RECEIVE_TEST); + return (atf_no_error()); }