Latest working kernel version: 2.6.27 Earliest failing kernel version: commit 9617760287eec9091d26e6967bd3e4194de18f97 Distribution: Debian Hardware Environment: Software Environment: Problem Description: pread() does not work on seq_file. That makes some VMware utilities unhappy, as to save some opens & closes these apps open /proc/uptime on start, and keep it open until exit. And because they are multithreaded, they are using pread()... And it works until seq_file conversion, but not after. Steps to reproduce: #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <errno.h> void main(void) { int fd = open("/proc/uptime", O_RDONLY); while (1) { char buffer[1234]; int err = pread(fd, buffer, sizeof buffer - 1, 0); if (err == -1) { perror("Oops: %m\n"); } else { buffer[err] = 0; printf("Another second, uptime info is %s\n", err); } sleep(1); } }
BTW, does anything but 0 offset is used?
crap, ->read hook has absolutely no way of telling read from pread
No, in real app it is used with offset 0 only. I've looked at code, and it looks to me like that modifying seq_file itself to handle pread is not that hard if you are OK with saying that if you mix read() and pread() you are on your own. That's why I did not assign it to you...
Well, /proc/uptime issue is fixed by moving /proc/uptime away from seq_file, so it is not regression anymore, but it does not fix what subject of this bug says - that seq_file does not handle pread, so issue may resurface at any time when some other file gets converted to seq_file...
commit 8f19d472935c83d823fa4cf02bcc0a7b9952db30 "seq_file: properly cope with pread" and previous patches.
(In reply to comment #4) > Well, /proc/uptime issue is fixed by moving /proc/uptime away from seq_file, > so > it is not regression anymore, but it does not fix what subject of this bug > says > - that seq_file does not handle pread, so issue may resurface at any time > when > some other file gets converted to seq_file... https://lkml.org/lkml/2012/1/18/21
A patch referencing this bug report has been merged in Linux v3.4-rc1: commit 7904ac84244b59f536c2a5d1066a10f46df07b08 Author: Earl Chew <echew@ixiacom.com> Date: Wed Mar 21 16:33:43 2012 -0700 seq_file: fix mishandling of consecutive pread() invocations.