epoll: avoid double-inserts in case of EFAULT
Davide Libenzi authored
In commit f337b9c5

 ("epoll: drop
unnecessary test") Thomas found that there is an unnecessary (always
true) test in ep_send_events().  The callback never inserts into
->rdllink while the send loop is performed, and also does the
~EP_PRIVATE_BITS test.  Given we're holding the mutex during this time,
the conditions tested inside the loop are always true.

HOWEVER.

The test "!ep_is_linked(&epi->rdllink)" wasn't there because we insert
into ->rdllink, but because the send-events loop might terminate before
the whole list is scanned (-EFAULT).

In such cases, when the loop terminates early, and when a (leftover)
file received an event while we're performing the lockless loop, we need
such test to avoid to double insert the epoll items.  The list_splice()
done a few steps below, will correctly re-insert the ones that were left
on "txlist".

This should fix the kenrel.org bugzilla entry 11831.
Signed-off-by: default avatarDavide Libenzi <davidel@xmailserver.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
9ce209d6
Name Last commit Last update
..
9p 9p: fix format warning
adfs vfs: Use const for kernel parser table
affs vfs: Use const for kernel parser table
afs [PATCH] fix ->llseek for more directories
autofs vfs: Use const for kernel parser table
autofs4 autofs4: add miscellaneous device for ioctls
befs befs: annotate fs32 on tests for superblock endianness
bfs [PATCH] fix ->llseek for more directories
cifs Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
coda [PATCH] move executable checking into ->permission()
configfs [PATCH] assorted path_lookup() -> kern_path() conversions
cramfs cramfs: fix named-pipe handling
debugfs integrity: special fs magic
devpts vfs: Use const for kernel parser table
dlm dlm: choose better identifiers
ecryptfs [PATCH] assorted path_lookup() -> kern_path() conversions
efs [PATCH] switch all filesystems over to d_obtain_alias
exportfs [PATCH] prepare vfs_readdir() callers to returning filldir result
ext2 Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/bdev
ext3 ext3: Fix duplicate entries returned from getdents() system call
ext4 ext4: Fix duplicate entries returned from getdents() system call
fat [PATCH] fix ->llseek for more directories
freevxfs fs/freevxfs/: proper externs
fuse [PATCH] switch all filesystems over to d_obtain_alias
gfs2 [PATCH] switch all filesystems over to d_obtain_alias
hfs
hfsplus
hostfs
hpfs
hppfs
hugetlbfs
isofs
jbd
jbd2
jffs2
jfs
lockd
minix
msdos
ncpfs
nfs
nfs_common
nfsd
nls
ntfs
ocfs2
omfs
openpromfs
partitions
proc
qnx4
ramfs
reiserfs
romfs
smbfs
sysfs
sysv
ubifs
udf
ufs
vfat
xfs
Kconfig
Kconfig.binfmt
Makefile
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf.c
binfmt_elf_fdpic.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
binfmt_som.c
bio-integrity.c
bio.c
block_dev.c
buffer.c
char_dev.c
compat.c
compat_binfmt_elf.c
compat_ioctl.c
dcache.c
dcookies.c
direct-io.c
dnotify.c
dquot.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c
fcntl.c
fifo.c
file.c
file_table.c
filesystems.c
fs-writeback.c
generic_acl.c
inode.c
inotify.c
inotify_user.c
internal.h
ioctl.c
ioprio.c
libfs.c
locks.c
mbcache.c
mpage.c
namei.c
namespace.c
nfsctl.c
no-block.c
open.c
pipe.c
pnode.c
pnode.h
posix_acl.c
quota.c
quota_v1.c
quota_v2.c
read_write.c
read_write.h
readdir.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
super.c
sync.c
timerfd.c
utimes.c
xattr.c
xattr_acl.c