]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
.28 patches
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 3 Mar 2009 01:34:41 +0000 (17:34 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 3 Mar 2009 01:34:41 +0000 (17:34 -0800)
queue-2.6.28/seq_file-properly-cope-with-pread.patch [new file with mode: 0644]
queue-2.6.28/series
queue-2.6.28/vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags.patch [new file with mode: 0644]
queue-2.6.28/vt-declare-pio_cmap-gio_cmap-as-compatbile-ioctls.patch [new file with mode: 0644]

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 (file)
index 0000000..67798f2
--- /dev/null
@@ -0,0 +1,119 @@
+From 8f19d472935c83d823fa4cf02bcc0a7b9952db30 Mon Sep 17 00:00:00 2001
+From: Eric Biederman <ebiederm@xmission.com>
+Date: Wed, 18 Feb 2009 14:48:16 -0800
+Subject: seq_file: properly cope with pread
+
+From: Eric Biederman <ebiederm@xmission.com>
+
+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 <ebiederm@xmission.com>
+Cc: Alexey Dobriyan <adobriyan@gmail.com>
+Cc: Al Viro <viro@zeniv.linux.org.uk>
+Cc: Paul Turner <pjt@google.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ 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;
index 30b1a3f12ffbdaa2efb1c3c792cc5bb953db2a19..d7c7a552e409c094068daf2f03972c447e07062f 100644 (file)
@@ -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 (file)
index 0000000..c46ae25
--- /dev/null
@@ -0,0 +1,71 @@
+From 55ec82176eca52e4e0530a82a0eb59160a1a95a1 Mon Sep 17 00:00:00 2001
+From: Paul Turner <pjt@google.com>
+Date: Wed, 18 Feb 2009 14:48:15 -0800
+Subject: vfs: separate FMODE_PREAD/FMODE_PWRITE into separate flags
+
+From: Paul Turner <pjt@google.com>
+
+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 <pjt@google.com>
+Cc: Eric Biederman <ebiederm@xmission.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ 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 (file)
index 0000000..622cb43
--- /dev/null
@@ -0,0 +1,33 @@
+From 2db69a9340da12a4db44edb7506dd68799aeff55 Mon Sep 17 00:00:00 2001
+From: Bill Nottingham <notting@redhat.com>
+Date: Wed, 18 Feb 2009 14:48:39 -0800
+Subject: vt: Declare PIO_CMAP/GIO_CMAP as compatbile ioctls.
+
+From: Bill Nottingham <notting@redhat.com>
+
+commit 2db69a9340da12a4db44edb7506dd68799aeff55 upstream.
+
+Otherwise, these don't work when called from 32-bit userspace on 64-bit
+kernels.
+
+Cc: Jiri Kosina <jkosina@suse.cz>
+Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ 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)