nmap on FreeBSD 11 (current) fails with this error message. #50

Closed
ohauer opened this Issue Jan 19, 2015 · 3 comments

Comments

Projects
None yet
2 participants

ohauer commented Jan 19, 2015

# nmap $host
Starting Nmap 6.47 ( http://nmap.org ) at 2015-01-19 20:10 CET
sendto in send_ip_packet_sd: sendto(4, packet, 28, 0, 10.6.25.40, 16) => Invalid argument
Offending packet: ICMP [10.6.20.182 > 10.6.25.40 Echo request (type=8/code=0) id=64730 seq=0] IP [ttl=52 id=37096 iplen=7168 ]
sendto in send_ip_packet_sd: sendto(4, packet, 44, 0, 10.6.25.40, 16) => Invalid argument
Offending packet: TCP 10.6.20.182:56964 > 10.6.25.40:443 S ttl=51 id=39356 iplen=11264  seq=684099691 win=1024 
sendto in send_ip_packet_sd: sendto(4, packet, 40, 0, 10.6.25.40, 16) => Invalid argument
Offending packet: TCP 10.6.20.182:56964 > 10.6.25.40:80 A ttl=54 id=36790 iplen=10240  seq=0 win=1024

It seems the following patch will fix this.

--- libnetutil/netutil.cc.orig  2014-08-16 02:45:47 UTC
+++ libnetutil/netutil.cc
@@ -3605,20 +3605,23 @@ int send_ip_packet_sd(int sd, const stru
      must deal with it here rather than when building the packet,
      because they should be in NBO when I'm sending over raw
      ethernet */
+/* FreeBSD 11 fix (sendto in send_ip_packet_sd: sendto(4, packet, 44, 0, $IP, 16) => Invalid argument)
 #if FREEBSD || BSDI || NETBSD || DEC || MACOSX
   ip->ip_len = ntohs(ip->ip_len);
   ip->ip_off = ntohs(ip->ip_off);
 #endif
-
+*/
   res = Sendto("send_ip_packet_sd", sd, packet, packetlen, 0,
                (struct sockaddr *) &sock,
                (int) sizeof(struct sockaddr_in));
 
   /* Undo the byte order switching. */
+/* FreeBSD 11 fix (sendto in send_ip_packet_sd: sendto(4, packet, 44, 0, $IP, 16) => Invalid argument)
 #if FREEBSD || BSDI || NETBSD || DEC || MACOSX
   ip->ip_len = htons(ip->ip_len);
   ip->ip_off = htons(ip->ip_off);
 #endif
+*/
 
   return res;
 }

Thanks for the report! Can you elaborate a bit about what is going on here? Obviously we can't just comment-out a fix that is apparently still needed on several platforms. But if you could give some more detail on what has changed in the way FreeBSD 11 handles byte order, it would make fixing the problem much faster.

ohauer commented Jan 20, 2015

Hi Daniel,

I will check with the FreeBSD devs.
Don't know if it is a side affect during the stack rewrite for bhyve.

nmap-bot closed this in 9ab82ec Aug 6, 2015

ohauer commented Sep 27, 2015

Thanks for looking into this!
I suspect the __FreeBSD_version in beta5 is is not the correct one, I found the following hints.
https://svnweb.freebsd.org/base?view=revision&revision=270929
https://svnweb.freebsd.org/base/head/sys/sys/param.h?r1=270173&r2=270929

The following patch will set the correct __FreeBSD_version
http://people.freebsd.org/~ohauer/diffs/patch-libnetutil_netutil.cc.diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment