On Fri, 3 Sep 2010 13:58:44 -0700 Andrew Morton <akpm at linux-foundation.org> wrote: > On Thu, 2 Sep 2010 14:20:19 +0200 > Arnd Bergmann <arnd at arndb.de> wrote: > > > Commit 73296bc611 "procfs: Use generic_file_llseek in /proc/vmcore" broke > > seeking on /proc/vmcore. This changes it back to use default_llseek > > in order to restore the original behaviour. > > "broke" isn't a useful description of a bug :( > > A bit of list-trolling indicates that this change caused makedumpfile > to hang during kexec dumping, yes? If so, why did this happen? How > did the switch to generic_file_llseek() cause the /proc/vmcore seek > behaviour to change? > > I'm not seeing a lot of difference between default_llseek() and > generic_file_llseek() apart from file->f_mapping->host versus > file->f_path.dentry->d_inode. Was it that, or what? > > etcetera. Better patch descriptions, please! > > Ah...not related to this issue itself..but... This is a patch for mmotm, which supports "unsigned file offset". Now, mmotm, only /dev/mem support == From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> vfs-introduce-fmode_neg_offset-for-allowing-negative-f_pos.patch adds "UNSIGINED" fpos support. But it dones't handle llseek. Fix it. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com> --- fs/read_write.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) Index: mmotm-0827/fs/read_write.c =================================================================== --- mmotm-0827.orig/fs/read_write.c +++ mmotm-0827/fs/read_write.c @@ -31,6 +31,20 @@ const struct file_operations generic_ro_ EXPORT_SYMBOL(generic_ro_fops); +static int +__negative_fpos_check(struct file *file, loff_t pos, size_t count) +{ + /* + * pos or pos+count is negative here, check overflow. + * too big "count" will be caught in rw_verify_area(). + */ + if ((pos < 0) && (pos + count < pos)) + return -EOVERFLOW; + if (file->f_mode & FMODE_UNSIGNED_OFFSET) + return 0; + return -EINVAL; +} + /** * generic_file_llseek_unlocked - lockless generic llseek implementation * @file: file structure to seek on @@ -62,7 +76,9 @@ generic_file_llseek_unlocked(struct file break; } - if (offset < 0 || offset > inode->i_sb->s_maxbytes) + if (offset < 0 && __negative_fpos_check(file, offset, 0)) + return -EINVAL; + if (offset > inode->i_sb->s_maxbytes) return -EINVAL; /* Special lock needed here? */ @@ -137,7 +153,7 @@ loff_t default_llseek(struct file *file, offset += file->f_pos; } retval = -EINVAL; - if (offset >= 0) { + if (offset >= 0 || !__negative_fpos_check(file, offset, 0)) { if (offset != file->f_pos) { file->f_pos = offset; file->f_version = 0; @@ -222,19 +238,6 @@ bad: } #endif -static int -__negative_fpos_check(struct file *file, loff_t pos, size_t count) -{ - /* - * pos or pos+count is negative here, check overflow. - * too big "count" will be caught in rw_verify_area(). - */ - if ((pos < 0) && (pos + count < pos)) - return -EOVERFLOW; - if (file->f_mode & FMODE_UNSIGNED_OFFSET) - return 0; - return -EINVAL; -} /* * rw_verify_area doesn't like huge counts. We limit