Nmap Development mailing list archives

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


From: Michal Hlavinka <mhlavink () redhat com>
Date: Thu, 02 Aug 2012 13:25:29 +0200

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
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: