* [Bug libc/29417] poll() declared with write-only fds
2022-07-27 12:46 [Bug libc/29417] New: poll() declared with write-only fds mlichvar at redhat dot com
@ 2022-07-27 15:03 ` fweimer at redhat dot com
2022-07-27 15:18 ` mlichvar at redhat dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2022-07-27 15:03 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29417
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
CC| |fweimer at redhat dot com,
| |siddhesh at sourceware dot org
--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
I believe write_only is correct here because read_write would require full
initialization of all struct pollfd members. According to the poll manual page,
the revents member does not need to be initialized because the kernel
overwrites it.
Siddhesh, what do you think?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/29417] poll() declared with write-only fds
2022-07-27 12:46 [Bug libc/29417] New: poll() declared with write-only fds mlichvar at redhat dot com
2022-07-27 15:03 ` [Bug libc/29417] " fweimer at redhat dot com
@ 2022-07-27 15:18 ` mlichvar at redhat dot com
2022-07-27 15:39 ` fweimer at redhat dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mlichvar at redhat dot com @ 2022-07-27 15:18 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29417
--- Comment #2 from Miroslav Lichvar <mlichvar at redhat dot com> ---
FWIW, a poll() function using that declaration triggers a compiler warning:
#include <poll.h>
int poll(struct pollfd *fds, nfds_t nfds, int timeout) {
return nfds >= 1 && fds[0].fd >= 0;
}
x.c: In function ‘poll’:
x.c:4:35: warning: ‘*fds.fd’ may be used uninitialized [-Wmaybe-uninitialized]
4 | return nfds >= 1 && fds[0].fd >= 0;
| ~~~~~~^~~
x.c:3:25: note: accessing argument 1 of a function declared with attribute
‘access (write_only, 1, 2)’
3 | int poll(struct pollfd *fds, nfds_t nfds, int timeout) {
| ~~~~~~~~~~~~~~~^~~
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/29417] poll() declared with write-only fds
2022-07-27 12:46 [Bug libc/29417] New: poll() declared with write-only fds mlichvar at redhat dot com
2022-07-27 15:03 ` [Bug libc/29417] " fweimer at redhat dot com
2022-07-27 15:18 ` mlichvar at redhat dot com
@ 2022-07-27 15:39 ` fweimer at redhat dot com
2022-07-27 18:40 ` siddhesh at sourceware dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2022-07-27 15:39 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29417
--- Comment #3 from Florian Weimer <fweimer at redhat dot com> ---
It's a warning in the implementation, and that doesn't matter to us.
What would be problematic if GCC decided to eliminate stores to the fds array,
assuming that it will be overwritten completely. But I don't think the
specification for write_only allows that. (write_only is perhaps misnamed.)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/29417] poll() declared with write-only fds
2022-07-27 12:46 [Bug libc/29417] New: poll() declared with write-only fds mlichvar at redhat dot com
` (2 preceding siblings ...)
2022-07-27 15:39 ` fweimer at redhat dot com
@ 2022-07-27 18:40 ` siddhesh at sourceware dot org
2022-07-27 18:44 ` siddhesh at sourceware dot org
2022-07-27 18:56 ` fweimer at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: siddhesh at sourceware dot org @ 2022-07-27 18:40 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29417
--- Comment #4 from Siddhesh Poyarekar <siddhesh at sourceware dot org> ---
(In reply to Florian Weimer from comment #3)
> What would be problematic if GCC decided to eliminate stores to the fds
> array, assuming that it will be overwritten completely. But I don't think
> the specification for write_only allows that. (write_only is perhaps
> misnamed.)
The compiler cannot eliminate stores because it doesn't know if poll will
overwrite the object. That said, I wouldn't stick out my neck and say that the
write_only attribute is absolutely correct in this context; the structure does
need to be read further down ithe stack n the syscall.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/29417] poll() declared with write-only fds
2022-07-27 12:46 [Bug libc/29417] New: poll() declared with write-only fds mlichvar at redhat dot com
` (3 preceding siblings ...)
2022-07-27 18:40 ` siddhesh at sourceware dot org
@ 2022-07-27 18:44 ` siddhesh at sourceware dot org
2022-07-27 18:56 ` fweimer at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: siddhesh at sourceware dot org @ 2022-07-27 18:44 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29417
--- Comment #5 from Siddhesh Poyarekar <siddhesh at sourceware dot org> ---
Sorry, hit send a bit too soon. read_write is also not appropriate for reasons
Florian mentioned. So to conclude, while the strictly correct option here is
to not have any annotations, it will also get rid of object size related
protection, which is a worse place to be in IMO.
So IMO, the current state of this declaration is the most useful.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/29417] poll() declared with write-only fds
2022-07-27 12:46 [Bug libc/29417] New: poll() declared with write-only fds mlichvar at redhat dot com
` (4 preceding siblings ...)
2022-07-27 18:44 ` siddhesh at sourceware dot org
@ 2022-07-27 18:56 ` fweimer at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2022-07-27 18:56 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29417
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |NOTABUG
Status|NEW |RESOLVED
--- Comment #6 from Florian Weimer <fweimer at redhat dot com> ---
Thanks for your comments, Siddhesh? Would it make sense to enhance the GCC
documentation? If only to start a discussion among GCC developers what these
attributes mean, exactly. 8-)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread