Skip to content

Commit c857ab6

Browse files
cyrillostorvalds
authored andcommitted
fs,eventpoll: don't test for bitfield with stack value
In case if epoll_ctl is called with operation EPOLL_CTL_DEL then @epds.events variable allocated on stack may contain random bits which we test then for EPOLLEXCLUSIVE. Since currently the test look like if (epds.events & EPOLLEXCLUSIVE) { if (op == EPOLL_CTL_MOD) goto error_tgt_fput; if (op == EPOLL_CTL_ADD && (is_file_epoll(tf.file) || (epds.events & ~EPOLLEXCLUSIVE_OK_BITS))) goto error_tgt_fput; } Nothing serious will happen even if epds.events has this bit set, still better to be on safe side and make sure that we're to test this bit at all. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Cyrill Gorcunov <[email protected]> Cc: Al Viro <[email protected]> Cc: Andrey Vagin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e3b5a34 commit c857ab6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/eventpoll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
18951895
* so EPOLLEXCLUSIVE is not allowed for a EPOLL_CTL_MOD operation.
18961896
* Also, we do not currently supported nested exclusive wakeups.
18971897
*/
1898-
if (epds.events & EPOLLEXCLUSIVE) {
1898+
if (ep_op_has_event(op) && (epds.events & EPOLLEXCLUSIVE)) {
18991899
if (op == EPOLL_CTL_MOD)
19001900
goto error_tgt_fput;
19011901
if (op == EPOLL_CTL_ADD && (is_file_epoll(tf.file) ||

0 commit comments

Comments
 (0)