From f7e54b46ff4e34aeeddadc8dcee8a4fe7f70c8af Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 2 Mar 2009 17:34:41 -0800 Subject: [PATCH] .28 patches --- .../seq_file-properly-cope-with-pread.patch | 119 ++++++++++++++++++ queue-2.6.28/series | 3 + ...ead-fmode_pwrite-into-separate-flags.patch | 71 +++++++++++ ...o_cmap-gio_cmap-as-compatbile-ioctls.patch | 33 +++++ 4 files changed, 226 insertions(+) create mode 100644 queue-2.6.28/seq_file-properly-cope-with-pread.patch create mode 100644 queue-2.6.28/vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags.patch create mode 100644 queue-2.6.28/vt-declare-pio_cmap-gio_cmap-as-compatbile-ioctls.patch diff --git a/queue-2.6.28/seq_file-properly-cope-with-pread.patch b/queue-2.6.28/seq_file-properly-cope-with-pread.patch new file mode 100644 index 00000000000..67798f2a515 --- /dev/null +++ b/queue-2.6.28/seq_file-properly-cope-with-pread.patch @@ -0,0 +1,119 @@ +From 8f19d472935c83d823fa4cf02bcc0a7b9952db30 Mon Sep 17 00:00:00 2001 +From: Eric Biederman +Date: Wed, 18 Feb 2009 14:48:16 -0800 +Subject: seq_file: properly cope with pread + +From: Eric Biederman + +commit 8f19d472935c83d823fa4cf02bcc0a7b9952db30 upstream. + +Currently seq_read assumes that the offset passed to it is always the +offset it passed to user space. In the case pread this assumption is +broken and we do the wrong thing when presented with pread. + +To solve this I introduce an offset cache inside of struct seq_file so we +know where our logical file position is. Then in seq_read if we try to +read from another offset we reset our data structures and attempt to go to +the offset user space wanted. + +[akpm@linux-foundation.org: restore FMODE_PWRITE] +[pjt@google.com: seq_open needs its fmode opened up to take advantage of this] +Signed-off-by: Eric Biederman +Cc: Alexey Dobriyan +Cc: Al Viro +Cc: Paul Turner +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + fs/seq_file.c | 36 ++++++++++++++++++++++++++++++++---- + include/linux/seq_file.h | 1 + + 2 files changed, 33 insertions(+), 4 deletions(-) + +--- a/fs/seq_file.c ++++ b/fs/seq_file.c +@@ -48,8 +48,16 @@ int seq_open(struct file *file, const st + */ + file->f_version = 0; + +- /* SEQ files support lseek, but not pread/pwrite */ +- file->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); ++ /* ++ * seq_files support lseek() and pread(). They do not implement ++ * write() at all, but we clear FMODE_PWRITE here for historical ++ * reasons. ++ * ++ * If a client of seq_files a) implements file.write() and b) wishes to ++ * support pwrite() then that client will need to implement its own ++ * file.open() which calls seq_open() and then sets FMODE_PWRITE. ++ */ ++ file->f_mode &= ~FMODE_PWRITE; + return 0; + } + EXPORT_SYMBOL(seq_open); +@@ -131,6 +139,22 @@ ssize_t seq_read(struct file *file, char + int err = 0; + + mutex_lock(&m->lock); ++ ++ /* Don't assume *ppos is where we left it */ ++ if (unlikely(*ppos != m->read_pos)) { ++ m->read_pos = *ppos; ++ while ((err = traverse(m, *ppos)) == -EAGAIN) ++ ; ++ if (err) { ++ /* With prejudice... */ ++ m->read_pos = 0; ++ m->version = 0; ++ m->index = 0; ++ m->count = 0; ++ goto Done; ++ } ++ } ++ + /* + * seq_file->op->..m_start/m_stop/m_next may do special actions + * or optimisations based on the file->f_version, so we want to +@@ -230,8 +254,10 @@ Fill: + Done: + if (!copied) + copied = err; +- else ++ else { + *ppos += copied; ++ m->read_pos += copied; ++ } + file->f_version = m->version; + mutex_unlock(&m->lock); + return copied; +@@ -266,16 +292,18 @@ loff_t seq_lseek(struct file *file, loff + if (offset < 0) + break; + retval = offset; +- if (offset != file->f_pos) { ++ if (offset != m->read_pos) { + while ((retval=traverse(m, offset)) == -EAGAIN) + ; + if (retval) { + /* with extreme prejudice... */ + file->f_pos = 0; ++ m->read_pos = 0; + m->version = 0; + m->index = 0; + m->count = 0; + } else { ++ m->read_pos = offset; + retval = file->f_pos = offset; + } + } +--- a/include/linux/seq_file.h ++++ b/include/linux/seq_file.h +@@ -19,6 +19,7 @@ struct seq_file { + size_t from; + size_t count; + loff_t index; ++ loff_t read_pos; + u64 version; + struct mutex lock; + const struct seq_operations *op; diff --git a/queue-2.6.28/series b/queue-2.6.28/series index 30b1a3f12ff..d7c7a552e40 100644 --- a/queue-2.6.28/series +++ b/queue-2.6.28/series @@ -2,3 +2,6 @@ net-amend-the-fix-for-so_bsdcompat-gsopt-infoleak.patch net-kill-skb_truesize_check-it-only-catches-false-positives.patch sparc64-fix-crashes-in-jbusmc_print_dimm.patch sparc64-fix-dax-handling-via-userspace-access-from-kernel.patch +vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags.patch +seq_file-properly-cope-with-pread.patch +vt-declare-pio_cmap-gio_cmap-as-compatbile-ioctls.patch diff --git a/queue-2.6.28/vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags.patch b/queue-2.6.28/vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags.patch new file mode 100644 index 00000000000..c46ae258406 --- /dev/null +++ b/queue-2.6.28/vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags.patch @@ -0,0 +1,71 @@ +From 55ec82176eca52e4e0530a82a0eb59160a1a95a1 Mon Sep 17 00:00:00 2001 +From: Paul Turner +Date: Wed, 18 Feb 2009 14:48:15 -0800 +Subject: vfs: separate FMODE_PREAD/FMODE_PWRITE into separate flags + +From: Paul Turner + +commit 55ec82176eca52e4e0530a82a0eb59160a1a95a1 upstream. + +Separate FMODE_PREAD and FMODE_PWRITE into separate flags to reflect the +reality that the read and write paths may have independent restrictions. + +A git grep verifies that these flags are always cleared together so this +new behavior will only apply to interfaces that change to clear flags +individually. + +This is required for "seq_file: properly cope with pread", a post-2.6.25 +regression fix. + +[akpm@linux-foundation.org: add comment] +Signed-off-by: Paul Turner +Cc: Eric Biederman +Cc: Alexey Dobriyan +Cc: Al Viro +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/fs.h | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +--- a/include/linux/fs.h ++++ b/include/linux/fs.h +@@ -63,24 +63,30 @@ extern int dir_notify_enable; + #define MAY_ACCESS 16 + #define MAY_OPEN 32 + ++/* ++ * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond ++ * to O_WRONLY and O_RDWR via the strange trick in __dentry_open() ++ */ ++ + /* file is open for reading */ + #define FMODE_READ ((__force fmode_t)1) + /* file is open for writing */ + #define FMODE_WRITE ((__force fmode_t)2) + /* file is seekable */ + #define FMODE_LSEEK ((__force fmode_t)4) +-/* file can be accessed using pread/pwrite */ ++/* file can be accessed using pread */ + #define FMODE_PREAD ((__force fmode_t)8) +-#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ ++/* file can be accessed using pwrite */ ++#define FMODE_PWRITE ((__force fmode_t)16) + /* File is opened for execution with sys_execve / sys_uselib */ +-#define FMODE_EXEC ((__force fmode_t)16) ++#define FMODE_EXEC ((__force fmode_t)32) + /* File is opened with O_NDELAY (only set for block devices) */ +-#define FMODE_NDELAY ((__force fmode_t)32) ++#define FMODE_NDELAY ((__force fmode_t)64) + /* File is opened with O_EXCL (only set for block devices) */ +-#define FMODE_EXCL ((__force fmode_t)64) ++#define FMODE_EXCL ((__force fmode_t)128) + /* File is opened using open(.., 3, ..) and is writeable only for ioctls + (specialy hack for floppy.c) */ +-#define FMODE_WRITE_IOCTL ((__force fmode_t)128) ++#define FMODE_WRITE_IOCTL ((__force fmode_t)256) + + #define RW_MASK 1 + #define RWA_MASK 2 diff --git a/queue-2.6.28/vt-declare-pio_cmap-gio_cmap-as-compatbile-ioctls.patch b/queue-2.6.28/vt-declare-pio_cmap-gio_cmap-as-compatbile-ioctls.patch new file mode 100644 index 00000000000..622cb438f53 --- /dev/null +++ b/queue-2.6.28/vt-declare-pio_cmap-gio_cmap-as-compatbile-ioctls.patch @@ -0,0 +1,33 @@ +From 2db69a9340da12a4db44edb7506dd68799aeff55 Mon Sep 17 00:00:00 2001 +From: Bill Nottingham +Date: Wed, 18 Feb 2009 14:48:39 -0800 +Subject: vt: Declare PIO_CMAP/GIO_CMAP as compatbile ioctls. + +From: Bill Nottingham + +commit 2db69a9340da12a4db44edb7506dd68799aeff55 upstream. + +Otherwise, these don't work when called from 32-bit userspace on 64-bit +kernels. + +Cc: Jiri Kosina +Cc: Alan Cox +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + fs/compat_ioctl.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/fs/compat_ioctl.c ++++ b/fs/compat_ioctl.c +@@ -1938,6 +1938,8 @@ ULONG_IOCTL(SET_BITMAP_FILE) + /* Big K */ + COMPATIBLE_IOCTL(PIO_FONT) + COMPATIBLE_IOCTL(GIO_FONT) ++COMPATIBLE_IOCTL(PIO_CMAP) ++COMPATIBLE_IOCTL(GIO_CMAP) + ULONG_IOCTL(KDSIGACCEPT) + COMPATIBLE_IOCTL(KDGETKEYCODE) + COMPATIBLE_IOCTL(KDSETKEYCODE) -- 2.47.3