Re: [PATCH 1/1] Fix seq_file mishandling of consecutive pread() invocations.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 22 Jan 2012 11:01:21 -0800
Earl Chew <echew@xxxxxxxxxxx> wrote:

> [ Added Maintainers; Added reference to bugzilla.kernel.org in commit log ]
> 
> Also reported in:
> 
>     https://bugzilla.kernel.org/show_bug.cgi?id=11856
> 
> The following program illustrates the problem:
> 
>     char buf[8192];
> 
>     int fd = open("/proc/self/maps", O_RDONLY);
> 
>     n = pread(fd, buf, sizeof(buf), 0);
>     printf("%d\n", n);
> 
>     /* lseek(fd, 0, SEEK_CUR); */ /* Uncomment to work around */
> 
>     n = pread(fd, buf, sizeof(buf), 0);
>     printf("%d\n", n);
> 
> The second printf() prints zero, but uncommenting the lseek()
> corrects its behaviour.

I'm stunned and confused.  That sequence of operations is the only sane
way in which to poll the contents of a procfs file.

Surely there are many applications which open a procfs file then
repeatedly read it with pread(fd, ..., 0).  How can this problem not
have been noticed in the first five minutes??
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux