Archived
14
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/fs/proc
Zhang Le ee6f779b9e filp->f_pos not correctly updated in proc_task_readdir
filp->f_pos only get updated at the end of the function. Thus d_off of those
dirents who are in the middle will be 0, and this will cause a problem in
glibc's readdir implementation, specifically endless loop. Because when overflow
occurs, f_pos will be set to next dirent to read, however it will be 0, unless
the next one is the last one. So it will start over again and again.

There is a sample program in man 2 gendents. This is the output of the program
running on a multithread program's task dir before this patch is applied:

  $ ./a.out /proc/3807/task
  --------------- nread=128 ---------------
  i-node#  file type  d_reclen  d_off   d_name
    506442  directory    16          1  .
    506441  directory    16          0  ..
    506443  directory    16          0  3807
    506444  directory    16          0  3809
    506445  directory    16          0  3812
    506446  directory    16          0  3861
    506447  directory    16          0  3862
    506448  directory    16          8  3863

This is the output after this patch is applied

  $ ./a.out /proc/3807/task
  --------------- nread=128 ---------------
  i-node#  file type  d_reclen  d_off   d_name
    506442  directory    16          1  .
    506441  directory    16          2  ..
    506443  directory    16          3  3807
    506444  directory    16          4  3809
    506445  directory    16          5  3812
    506446  directory    16          6  3861
    506447  directory    16          7  3862
    506448  directory    16          8  3863

Signed-off-by: Zhang Le <r0bertz@gentoo.org>
Acked-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-03-16 07:51:33 -07:00
..
array.c CRED: Use RCU to access another task's creds and to release a task's own creds 2008-11-14 10:39:19 +11:00
base.c filp->f_pos not correctly updated in proc_task_readdir 2009-03-16 07:51:33 -07:00
cmdline.c proc: switch /proc/cmdline to seq_file 2008-10-23 14:29:04 +04:00
cpuinfo.c proc: move /proc/cpuinfo code to fs/proc/cpuinfo.c 2008-10-23 15:05:11 +04:00
devices.c proc: move /proc/devices code to fs/proc/devices.c 2008-10-23 15:02:18 +04:00
generic.c proc: stop using BKL 2009-01-05 12:27:44 +03:00
inode-alloc.txt
inode.c proc: proc_get_inode should de_put when inode already initialized 2009-02-23 18:25:32 -08:00
internal.h NOMMU: Make VMAs per MM as for MMU-mode linux 2009-01-08 12:04:47 +00:00
interrupts.c proc: move /proc/interrupts boilerplate code to fs/proc/interrupts.c 2008-10-23 15:15:46 +04:00
Kconfig proc: move PROC_PAGE_MONITOR to fs/proc/Kconfig 2008-10-10 04:18:57 +04:00
kcore.c proc: move all /proc/kcore stuff to fs/proc/kcore.c 2008-10-23 18:32:38 +04:00
kmsg.c proc: move /proc/kmsg creation to fs/proc/kmsg.c 2008-10-23 14:35:08 +04:00
loadavg.c proc: switch /proc/loadavg to seq_file 2008-10-23 13:45:28 +04:00
Makefile proc: remove fs/proc/proc_misc.c 2008-10-23 18:54:05 +04:00
meminfo.c NOMMU: Make VMAs per MM as for MMU-mode linux 2009-01-08 12:04:47 +00:00
mmu.c fs/proc/mmu.c: headers butchery 2007-10-17 08:42:48 -07:00
nommu.c NOMMU: Make VMAs per MM as for MMU-mode linux 2009-01-08 12:04:47 +00:00
page.c proc: fix kflags to uflags copying in /proc/kpageflags 2009-03-11 07:43:33 -07:00
proc_devtree.c powerpc: Remove `have_of' global variable 2008-12-16 15:52:57 +11:00
proc_net.c proc: stop using BKL 2009-01-05 12:27:44 +03:00
proc_sysctl.c zero i_uid/i_gid on inode allocation 2009-01-05 11:54:28 -05:00
proc_tty.c tty: Ldisc revamp 2008-07-20 17:12:34 -07:00
root.c proc: stop using BKL 2009-01-05 12:27:44 +03:00
stat.c proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c 2008-12-26 09:48:18 +01:00
task_mmu.c mm: report the MMU pagesize in /proc/pid/smaps 2009-01-06 15:58:58 -08:00
task_nommu.c NOMMU: Improve procfs output using per-MM VMAs 2009-01-08 12:04:47 +00:00
uptime.c proc: revert /proc/uptime to ->read_proc hook 2008-10-27 22:56:56 +03:00
version.c proc: switch /proc/version to seq_file 2008-10-23 14:19:58 +04:00
vmcore.c vmcore: remove saved_max_pfn check 2009-01-08 08:31:14 -08:00