lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070701122225.GB3400@zakalwe.fi>
Date:	Sun, 1 Jul 2007 15:22:25 +0300
From:	Heikki Orsila <shdl@...alwe.fi>
To:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc:	mtk-manpages@....net, Davide Libenzi <davidel@...ilserver.org>
Subject: Man page correction: epoll (7)

Here's a bit of email I exchanged with Davide Libenzi on epoll (7) man 
page. There is an error in answer 9:

Davide Libenzi wrote:
> On Mon, 25 Jun 2007, Heikki Orsila wrote:
>> >From epoll man page:
>>
>>        Q9     Do I need to continuously read/write an  fd  until  EAGAIN when
>>               using the EPOLLET flag ( Edge Triggered behaviour ) ?
>>
>>        A9     No you don't.
>>             ...
>>             For example, if you call read(2) by asking to  read
>>             a  certain  amount of data and read(2) returns a lower number of
>>             bytes, you can be sure to have exhausted the read I/O space  for
>>             such  file  descriptor.
>>             ...
>>
>> This doesn't seem very true in the general case. Afaik, terminal
>> devices can be configured to return only one line per read(). For
>> example,
>>
>>       read(terminal_fd, buf, 4096)
>>
>> will return 34 (the length of the line) but obviously the IO space would
>> not be exhausted if _two_ lines arrived into terminal fd during IO wait.
>> And thus, arrival of the second line went unnoticed.
>>
>> Teaching to optimise nonblocking reads will likely cause more bugs.
>>
>> I'm I correct? If yes, that number should be removed from the question
>> list.
> 
> Yes, you are correct. Although the above is true for the majority of
> stream files, so it better be fixed with the few counter-examples 
> instead of being removed.
> 
> - Davide

and

Davide Libenzi wrote:
> Heikki Orsila wrote:
>> Maybe so that we say that as a general rule one must read until EAGAIN,
>> but mention specific cases where one only needs to wait for "short"
>> reads?
> 
> Yes, that's fine with me.


So, the Q9 should be changed:

Q9	Do I need to continuously read/write an  fd  until  EAGAIN when
	using the EPOLLET flag ( Edge Triggered behaviour ) ?

A9	As a general rule, yes. However, there are exceptions.
	With some types of fds it is enough to wait until
	read returns less bytes than was requested by the read call.

Are there any fd types where such behavior is guaranteed by the Linux 
kernel (for the future)? I.e. one can assume that edge-triggered fds 
will behave properly if

	x = read(fd, data, count) and x < count ?

Regular files? Sockets? What?

-- 
Heikki Orsila			Barbie's law:
heikki.orsila@....fi		"Math is hard, let's go shopping!"
http://www.iki.fi/shd
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ