linux/fs
Ernie Petrides ee731f4f78 [PATCH] fix wrong error code on interrupted close syscalls
The problem is that close() syscalls can call a file system's flush
handler, which in turn might sleep interruptibly and ultimately pass back
an -ERESTARTSYS return value.  This happens for files backed by an
interruptible NFS mount under nfs_file_flush() when a large file has just
been written and nfs_wait_bit_interruptible() detects that there is a
signal pending.

I have a test case where the "strace" command is used to attach to a
process sleeping in such a close().  Since the SIGSTOP is forced onto the
victim process (removing it from the thread's "blocked" mask in
force_sig_info()), the RPC wait is interrupted and the close() is
terminated early.

But the file table entry has already been cleared before the flush handler
was called.  Thus, when the syscall is restarted, the file descriptor
appears closed and an EBADF error is returned (which is wrong).  What's
worse, there is the hypothetical case where another thread of a
multi-threaded application might have reused the file descriptor, in which
case that file would be mistakenly closed.

The bottom line is that close() syscalls are not restartable, and thus
-ERESTARTSYS return values should be mapped to -EINTR.  This is consistent
with the close(2) manual page.  The fix is below.

Signed-off-by: Ernie Petrides <petrides@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-29 09:18:13 -07:00
..
9p [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
adfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
affs [PATCH] Really ignore kmem_cache_destroy return value 2006-09-27 08:26:10 -07:00
afs [PATCH] afs: add lock annotations to afs_proc_cell_servers_{start,stop} 2006-09-29 09:18:07 -07:00
autofs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
autofs4 [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
befs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
bfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
cifs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
coda [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
configfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
cramfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
debugfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
devpts [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
efs [PATCH] Really ignore kmem_cache_destroy return value 2006-09-27 08:26:10 -07:00
exportfs
ext2 [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
ext3 [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
fat [PATCH] add -o flush for fat 2006-09-29 09:18:12 -07:00
freevxfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
fuse [PATCH] vfs: define new lookup flag for chdir 2006-09-29 09:18:08 -07:00
hfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
hfsplus [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
hostfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
hpfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
hppfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
hugetlbfs [PATCH] hugetlbfs: add lock annotation to hugetlbfs_forget_inode() 2006-09-29 09:18:08 -07:00
isofs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
jbd [PATCH] JBD: memory leak in "journal_init_dev()" 2006-09-29 09:18:03 -07:00
jffs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
jffs2 [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
jfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
lockd [PATCH] add newline to nfs dprintk 2006-09-27 08:26:19 -07:00
minix [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
msdos [PATCH] add -o flush for fat 2006-09-29 09:18:12 -07:00
ncpfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
nfs [PATCH] fs/nfs/: make code static 2006-09-27 08:26:20 -07:00
nfs_common
nfsd [PATCH] Really ignore kmem_cache_destroy return value 2006-09-27 08:26:10 -07:00
nls
ntfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
ocfs2 [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
openpromfs
partitions [PATCH] ignore partition table on disks with AIX label 2006-09-29 09:18:09 -07:00
proc [PATCH] NOMMU: move the fallback arch_vma_name() to a sensible place 2006-09-27 08:26:15 -07:00
qnx4 [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
ramfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
reiserfs [PATCH] reiserfs: ifdef ACL stuff from inode 2006-09-29 09:18:11 -07:00
romfs [PATCH] Really ignore kmem_cache_destroy return value 2006-09-27 08:26:10 -07:00
smbfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
sysfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
sysv [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
udf [PATCH] mount udf UDF_PART_FLAG_READ_ONLY partitions with MS_RDONLY 2006-09-29 09:18:09 -07:00
ufs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
vfat
xfs [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
aio.c
attr.c
bad_inode.c
binfmt_aout.c [PATCH] Require mmap handler for a.out executables 2006-09-29 09:18:08 -07:00
binfmt_elf_fdpic.c
binfmt_elf.c [PATCH] Fix unserialized task->files changing 2006-09-29 09:18:12 -07:00
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c [PATCH] Fix unserialized task->files changing 2006-09-29 09:18:12 -07:00
binfmt_script.c
binfmt_som.c
bio.c
block_dev.c [PATCH] blockdev.c: check driver layer errors 2006-09-29 09:18:04 -07:00
buffer.c [PATCH] mm: tracking shared dirty pages 2006-09-26 08:48:44 -07:00
char_dev.c [PATCH] Chardev checking of overlapping ranges 2006-09-29 09:18:12 -07:00
compat_ioctl.c
compat.c [PATCH] Check return value of copy_to_user in compat_sys_pselect7 2006-09-26 10:52:39 +02:00
dcache.c
dcookies.c
direct-io.c
dnotify.c
dquot.c
drop_caches.c
eventpoll.c [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
exec.c [PATCH] Fix unserialized task->files changing 2006-09-29 09:18:12 -07:00
fcntl.c
fifo.c
file_table.c [PATCH] inode-diet: Move i_cdev into a union 2006-09-27 08:26:17 -07:00
file.c [PATCH] alloc_fdtable() cleanup 2006-09-27 08:26:19 -07:00
filesystems.c
fs-writeback.c
inode.c [PATCH] fs.h: ifdef security fields 2006-09-29 09:18:11 -07:00
inotify_user.c
inotify.c
ioctl.c
ioprio.c
Kconfig [PATCH] sysctl: Allow /proc/sys without sys_sysctl 2006-09-27 08:26:19 -07:00
Kconfig.binfmt
libfs.c [PATCH] libfs: remove page up-to-date check from simple_readpage 2006-09-29 09:18:06 -07:00
locks.c
Makefile
mbcache.c [PATCH] mbcache: add lock annotation for __mb_cache_entry_release_unlock() 2006-09-29 09:18:07 -07:00
mpage.c
namei.c [PATCH] autofs4 needs to force fail return revalidate 2006-09-27 08:26:17 -07:00
namespace.c [PATCH] fs/namespace: handle init/registration errors 2006-09-29 09:18:05 -07:00
nfsctl.c
open.c [PATCH] fix wrong error code on interrupted close syscalls 2006-09-29 09:18:13 -07:00
pipe.c [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
pnode.c
pnode.h
posix_acl.c
quota_v1.c
quota_v2.c
quota.c
read_write.c
readdir.c
select.c
seq_file.c
splice.c
stat.c [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
super.c [PATCH] fs: add lock annotation to grab_super 2006-09-29 09:18:08 -07:00
sync.c
xattr_acl.c
xattr.c