Nmap Development mailing list archives

Re: BUG: ncat does not work when file is used as input


From: Henri Doreau <henri.doreau () gmail com>
Date: Fri, 3 Aug 2012 13:56:10 +0200

(forgot to CC the list, resending).

2012/8/2 Michal Hlavinka <mhlavink () redhat com>:
Hi,

we found a bug in ncat (tested with both 6.00 and svn snapshot).
When file is redirected as input for ncat, it fails with:

Unable to register IOD #2: Operation not permitted

This error comes from nsock:engine_epoll.c:epoll_iod_register( ):

if (epoll_ctl(einfo->epfd, EPOLL_CTL_ADD, sd, &epev) < 0)
  fatal("Unable to register IOD #%lu: %s", iod->id, strerror(errno));

The reason is epoll_ctl returns error - EPERM, strace:
...
epoll_ctl(3, EPOLL_CTL_MOD, 4, {...})   = 0
epoll_ctl(3, EPOLL_CTL_MOD, 4, {...})   = 0
epoll_ctl(3, EPOLL_CTL_ADD, 0, {...})   = -1 EPERM (Operation not permitted)
write(2, "Unable to register IOD #2: Opera"..., 50) = 50
write(2, "\n", 1)                       = 1
exit_group(1)                           = ?

The reason for this is that fd 0 is regular file and epoll
is not supported on regular files. man epoll_ctl(2):

ERRORS
...
   EPERM  The target file fd does not support epoll.

Reproducer:
$ ncat -l 1234 &
$ touch /tmp/foo
$ ncat localhost 1234 < /tmp/foo
Unable to register IOD #2: Operation not permitted

Let me know if you need more information.

Cheers,
Michal

Hello,

thanks for the detailed bug report. According to [1] there's no
trivial solution to address this issue but I'll work on a fix. The
--nsock-engine=select option can be used as a workaround meanwhile.

Regards.

[1] https://bugzilla.kernel.org/show_bug.cgi?id=15272

-- 
Henri
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: