Nmap Development mailing list archives

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


From: Michal Hlavinka <mhlavink () redhat com>
Date: Mon, 13 Aug 2012 12:41:27 +0200

On 08/04/2012 12:04 AM, Henri Doreau wrote:
Hi,

I had to make a tough choice: either introduce a cheesy hack into the
code of ncat or bloat nsock.

As explained in the link I posted earlier[1], epoll(7) can't deal with
regular files the same way it does with sockets and pipes.
...

To sum up what I did (maybe someone comes up with a smarter approach):
   - hook epoll_ctl() when registering/unregistering events for STDIN_FILENO
   - create an eventfd(), stored in the engine_info structure (hurk!)
   - Schedule an aio_read() as a replacement for the actual read().
This is where it started to become way too intrusive.

The second approach I tried (patch attached) is hackish but simple,
efficient and far less intrusive. If we're on linux (then epoll() is
expected to be used, but not even necessarily) and stdin is a regular
file, then we enforce the use of the select(2)-based nsock engine.

Thank you for the patch, I tested it and it did fix the issue.

I asked a few people about epoll & regular files and I was told, that epoll does not work with regular files not because some feature is missing, but because it won't make sense there. Correct approach when epoll returns EPERM should be to treat it as always ready to write and ready to read until EOF is reached. At least that's what I've been told.

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: