Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2023 23:50:44 GMT
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0c38bb448caa - stable/13 - traceroute6: fix capabilities for the rcv socket
Message-ID:  <202302012350.311Noill099641@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=0c38bb448caa426b7f238853d7841219819024be

commit 0c38bb448caa426b7f238853d7841219819024be
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2022-10-04 21:34:58 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2023-02-01 23:49:35 +0000

    traceroute6: fix capabilities for the rcv socket
    
    On the receive socket, recvmsg() and poll()/select() is called.
    Therefore, CAP_EVENT is needed in addition to CAP_RECV.
    
    While there, check the socket for readbility before calling recvmsg().
    
    Reviewed by:            markj@
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D36878
    
    (cherry picked from commit 8ff4fc03e6933dd69f99a8f34f2aa0760300f248)
---
 usr.sbin/traceroute6/traceroute6.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index a071c084ad07..d887acf5ae53 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -937,7 +937,7 @@ main(int argc, char *argv[])
 		    strerror(errno));
 		exit(1);
 	}
-	cap_rights_init(&rights, CAP_RECV);
+	cap_rights_init(&rights, CAP_RECV, CAP_EVENT);
 	if (caph_rights_limit(rcvsock, &rights) < 0) {
 		fprintf(stderr, "caph_rights_limit rcvsock: %s\n",
 		    strerror(errno));
@@ -1039,7 +1039,8 @@ wait_for_reply(int sock, struct msghdr *mhdr)
 	pfd[0].events = POLLIN;
 	pfd[0].revents = 0;
 
-	if (poll(pfd, 1, waittime * 1000) > 0)
+	if (poll(pfd, 1, waittime * 1000) > 0 &&
+	    pfd[0].revents & POLLIN)
 		cc = recvmsg(rcvsock, mhdr, 0);
 
 	return (cc);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302012350.311Noill099641>