Searched +hist:7904 +hist:ac84 (Results 1 - 1 of 1) sorted by relevance

/linux-master/fs/
H A Dseq_file.cdiff 7904ac84 Wed Mar 21 17:33:43 MDT 2012 Earl Chew <echew@ixiacom.com> seq_file: fix mishandling of consecutive pread() invocations.

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.

To fix, make seq_read() mirror seq_lseek() when processing changes in
*ppos. Restore m->version first, then if required traverse and update
read_pos on success.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=11856

Signed-off-by: Earl Chew <echew@ixiacom.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff 7904ac84 Wed Mar 21 17:33:43 MDT 2012 Earl Chew <echew@ixiacom.com> seq_file: fix mishandling of consecutive pread() invocations.

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.

To fix, make seq_read() mirror seq_lseek() when processing changes in
*ppos. Restore m->version first, then if required traverse and update
read_pos on success.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=11856

Signed-off-by: Earl Chew <echew@ixiacom.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Completed in 272 milliseconds