git: 4bf16a282503 - stable/13 - Revert "socket tests: Add a regression test for ktrace+recv(MSG_TRUNC)"

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 24 Oct 2023 18:04:00 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4bf16a282503fb1b9091e7e431220d97e72e25f9

commit 4bf16a282503fb1b9091e7e431220d97e72e25f9
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-24 18:03:49 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-24 18:03:49 +0000

    Revert "socket tests: Add a regression test for ktrace+recv(MSG_TRUNC)"
    
    This reverts commit f5a9a849e9034c597c2b0a9014673a44834b9516.
    
    This test will require extra work to port to stable/13.
---
 tests/sys/kern/socket_msg_trunc.c | 57 ---------------------------------------
 1 file changed, 57 deletions(-)

diff --git a/tests/sys/kern/socket_msg_trunc.c b/tests/sys/kern/socket_msg_trunc.c
index 279170158643..469b9e1503cd 100644
--- a/tests/sys/kern/socket_msg_trunc.c
+++ b/tests/sys/kern/socket_msg_trunc.c
@@ -27,13 +27,11 @@
 
 #include <sys/param.h>
 #include <sys/errno.h>
-#include <sys/ktrace.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 
 #include <netinet/in.h>
 
-#include <fcntl.h>
 #include <poll.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -184,67 +182,12 @@ ATF_TC_BODY(recv_trunc_afunix_seqpacket, tc)
 	ATF_REQUIRE(close(ss) == 0);
 }
 
-/*
- * Exercise the case where ktrace was used to dump a truncated buffer.
- */
-ATF_TC_WITHOUT_HEAD(recvmsg_trunc_ktrace_uio);
-ATF_TC_BODY(recvmsg_trunc_ktrace_uio, tc)
-{
-	struct ktr_header ktr;
-	struct msghdr msg;
-	struct iovec iov;
-	const char *tracepath;
-	char buf[128];
-	ssize_t nbytes;
-	int error, fd, sd[2];
-
-	tracepath = "ktrace";
-
-	error = socketpair(AF_UNIX, SOCK_DGRAM, 0, sd);
-	ATF_REQUIRE(error == 0);
-
-	memset(buf, 0, sizeof(buf));
-	nbytes = send(sd[0], buf, sizeof(buf), 0);
-	ATF_REQUIRE_MSG(nbytes >= 0, "send failed: %s", strerror(errno));
-	ATF_REQUIRE((size_t)nbytes == sizeof(buf));
-
-	fd = open(tracepath, O_RDWR | O_CREAT | O_TRUNC, 0644);
-	ATF_REQUIRE_MSG(fd >= 0, "open failed: %s", strerror(errno));
-	error = ktrace(tracepath, KTROP_SET, KTRFAC_GENIO, getpid());
-	ATF_REQUIRE_MSG(error == 0,
-	    "ktrace(SET) failed: %s", strerror(errno));
-
-	iov.iov_base = buf;
-	iov.iov_len = sizeof(buf) - 1; /* truncate */
-	memset(&msg, 0, sizeof(msg));
-	msg.msg_iov = &iov;
-	msg.msg_iovlen = 1;
-	nbytes = recvmsg(sd[1], &msg, MSG_TRUNC);
-	ATF_REQUIRE_MSG(nbytes >= 0, "recvmsg failed: %s", strerror(errno));
-	ATF_REQUIRE((size_t)nbytes == sizeof(buf));
-	ATF_REQUIRE((msg.msg_flags & MSG_TRUNC) != 0);
-
-	error = ktrace(tracepath, KTROP_CLEARFILE, 0, getpid());
-	ATF_REQUIRE_MSG(error == 0,
-	    "ktrace(CLEARFILE) failed: %s", strerror(errno));
-
-	nbytes = read(fd, &ktr, sizeof(ktr));
-	ATF_REQUIRE_MSG(nbytes >= 0, "read failed: %s", strerror(errno));
-	ATF_REQUIRE((size_t)nbytes == sizeof(ktr));
-	ATF_REQUIRE_MSG((ktr.ktr_type & ~KTR_TYPE) == KTR_GENIO);
-
-	ATF_REQUIRE(close(fd) == 0);
-	ATF_REQUIRE(close(sd[0]) == 0);
-	ATF_REQUIRE(close(sd[1]) == 0);
-}
-
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, recv_trunc_afinet_udp);
 	ATF_TP_ADD_TC(tp, recv_trunc_afinet6_udp);
 	ATF_TP_ADD_TC(tp, recv_trunc_afunix_dgram);
 	ATF_TP_ADD_TC(tp, recv_trunc_afunix_seqpacket);
-	ATF_TP_ADD_TC(tp, recvmsg_trunc_ktrace_uio);
 
 	return (atf_no_error());
 }