linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [3.8.y.z extended stable] Linux 3.8.13.17 stable review
@ 2014-01-31 17:32 Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 01/14] vfs: In d_path don't call d_dname on a mount point Kamal Mostafa
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Kamal Mostafa

This is the start of the review cycle for the Linux 3.8.13.17 stable kernel.

This version contains 14 new patches, summarized below.  The new patches are
posted as replies to this message and also available in this git branch:

http://kernel.ubuntu.com/git?p=ubuntu/linux.git;h=linux-3.8.y-review;a=shortlog

git://kernel.ubuntu.com/ubuntu/linux.git  linux-3.8.y-review

The review period for version 3.8.13.17 will be open for the next 24 hours.
To report a problem, please reply to the relevant follow-up patch message.

For more information about the Linux 3.8.y.z extended stable kernel version,
see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .

 -Kamal

--
 arch/x86/kernel/cpu/perf_event_amd_ibs.c        | 53 +++++++++++++++++++++----
 arch/x86/kernel/entry_32.S                      |  4 +-
 arch/x86/kernel/entry_64.S                      |  2 +-
 drivers/gpu/drm/i915/intel_ddi.c                |  8 +++-
 drivers/hwmon/coretemp.c                        |  2 +-
 drivers/md/raid10.c                             | 12 +++---
 drivers/md/raid5.c                              |  4 +-
 drivers/staging/comedi/drivers/8255_pci.c       | 20 ++++++++--
 drivers/staging/comedi/drivers/addi_apci_1032.c |  4 +-
 fs/dcache.c                                     |  7 +++-
 fs/fs-writeback.c                               | 15 ++++---
 fs/nilfs2/segment.c                             | 10 +++--
 net/compat.c                                    |  9 +----
 net/rds/ib_recv.c                               |  7 ++--
 14 files changed, 109 insertions(+), 48 deletions(-)

Andreas Rohner (1):
      nilfs2: fix segctor bug that causes file system corruption

Eric W. Biederman (1):
      vfs: In d_path don't call d_dname on a mount point

Gerald Schaefer (1):
      net: rds: fix per-cpu helper usage

H Hartley Sweeten (1):
      staging: comedi: addi_apci_1032: fix subdevice type/flags bug

Ian Abbott (1):
      staging: comedi: 8255_pci: fix for newer PCI-DIO48H

Jan Kara (1):
      writeback: Fix data corruption on NFS

Jean Delvare (1):
      hwmon: (coretemp) Fix truncated name of alarm attributes

NeilBrown (3):
      md/raid5: Fix possible confusion when multiple write errors occur.
      md/raid10: fix two bugs in handling of known-bad-blocks.
      md/raid10: fix bug when raid10 recovery fails to recover a block.

PaX Team (1):
      x86, x32: Correct invalid use of user timespec in the kernel

Paulo Zanoni (1):
      drm/i915: fix DDI PLLs HW state readout code

Robert Richter (1):
      perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h

Steven Rostedt (1):
      ftrace/x86: Load ftrace_ops in parameter not the variable holding it

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3.8 01/14] vfs: In d_path don't call d_dname on a mount point
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 02/14] writeback: Fix data corruption on NFS Kamal Mostafa
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Eric W. Biederman, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit f48cfddc6729ef133933062320039808bafa6f45 upstream.

Aditya Kali (adityakali@google.com) wrote:
> Commit bf056bfa80596a5d14b26b17276a56a0dcb080e5:
> "proc: Fix the namespace inode permission checks." converted
> the namespace files into symlinks. The same commit changed
> the way namespace bind mounts appear in /proc/mounts:
>   $ mount --bind /proc/self/ns/ipc /mnt/ipc
> Originally:
>   $ cat /proc/mounts | grep ipc
>   proc /mnt/ipc proc rw,nosuid,nodev,noexec 0 0
>
> After commit bf056bfa80596a5d14b26b17276a56a0dcb080e5:
>   $ cat /proc/mounts | grep ipc
>   proc ipc:[4026531839] proc rw,nosuid,nodev,noexec 0 0
>
> This breaks userspace which expects the 2nd field in
> /proc/mounts to be a valid path.

The symlink /proc/<pid>/ns/{ipc,mnt,net,pid,user,uts} point to
dentries allocated with d_alloc_pseudo that we can mount, and
that have interesting names printed out with d_dname.

When these files are bind mounted /proc/mounts is not currently
displaying the mount point correctly because d_dname is called instead
of just displaying the path where the file is mounted.

Solve this by adding an explicit check to distinguish mounted pseudo
inodes and unmounted pseudo inodes.  Unmounted pseudo inodes always
use mount of their filesstem as the mnt_root  in their path making
these two cases easy to distinguish.

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Reported-by: Aditya Kali <adityakali@google.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/dcache.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index de73da2..675e5d3 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2710,8 +2710,13 @@ char *d_path(const struct path *path, char *buf, int buflen)
 	 * thus don't need to be hashed.  They also don't need a name until a
 	 * user wants to identify the object in /proc/pid/fd/.  The little hack
 	 * below allows us to generate a name for these objects on demand:
+	 *
+	 * Some pseudo inodes are mountable.  When they are mounted
+	 * path->dentry == path->mnt->mnt_root.  In that case don't call d_dname
+	 * and instead have d_path return the mounted path.
 	 */
-	if (path->dentry->d_op && path->dentry->d_op->d_dname)
+	if (path->dentry->d_op && path->dentry->d_op->d_dname &&
+	    (!IS_ROOT(path->dentry) || path->dentry != path->mnt->mnt_root))
 		return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
 
 	get_fs_root(current->fs, &root);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 02/14] writeback: Fix data corruption on NFS
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 01/14] vfs: In d_path don't call d_dname on a mount point Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 03/14] drm/i915: fix DDI PLLs HW state readout code Kamal Mostafa
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Jan Kara, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jan Kara <jack@suse.cz>

commit f9b0e058cbd04ada76b13afffa7e1df830543c24 upstream.

Commit 4f8ad655dbc8 "writeback: Refactor writeback_single_inode()" added
a condition to skip clean inode. However this is wrong in WB_SYNC_ALL
mode because there we also want to wait for outstanding writeback on
possibly clean inode. This was causing occasional data corruption issues
on NFS because it uses sync_inode() to make sure all outstanding writes
are flushed to the server before truncating the inode and with
sync_inode() returning prematurely file was sometimes extended back
by an outstanding write after it was truncated.

So modify the test to also check for pages under writeback in
WB_SYNC_ALL mode.

Fixes: 4f8ad655dbc82cf05d2edc11e66b78a42d38bf93
Reported-and-tested-by: Dan Duval <dan.duval@oracle.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/fs-writeback.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 310972b..17eaad5 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -517,13 +517,16 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb,
 	}
 	WARN_ON(inode->i_state & I_SYNC);
 	/*
-	 * Skip inode if it is clean. We don't want to mess with writeback
-	 * lists in this function since flusher thread may be doing for example
-	 * sync in parallel and if we move the inode, it could get skipped. So
-	 * here we make sure inode is on some writeback list and leave it there
-	 * unless we have completely cleaned the inode.
+	 * Skip inode if it is clean and we have no outstanding writeback in
+	 * WB_SYNC_ALL mode. We don't want to mess with writeback lists in this
+	 * function since flusher thread may be doing for example sync in
+	 * parallel and if we move the inode, it could get skipped. So here we
+	 * make sure inode is on some writeback list and leave it there unless
+	 * we have completely cleaned the inode.
 	 */
-	if (!(inode->i_state & I_DIRTY))
+	if (!(inode->i_state & I_DIRTY) &&
+	    (wbc->sync_mode != WB_SYNC_ALL ||
+	     !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK)))
 		goto out;
 	inode->i_state |= I_SYNC;
 	spin_unlock(&inode->i_lock);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 03/14] drm/i915: fix DDI PLLs HW state readout code
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 01/14] vfs: In d_path don't call d_dname on a mount point Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 02/14] writeback: Fix data corruption on NFS Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 04/14] ftrace/x86: Load ftrace_ops in parameter not the variable holding it Kamal Mostafa
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Paulo Zanoni, Daniel Vetter, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

commit 0882dae983707455e97479e5e904e37673517ebc upstream.

Properly zero the refcounts and crtc->ddi_pll_set so the previous HW
state doesn't affect the result of reading the current HW state.

This fixes WARNs about WRPLL refcount if we have an HDMI monitor on
HSW and then suspend/resume.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64379
Tested-by: Qingshuai Tian <qingshuai.tian@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index b8e53d9..6f09de3 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1178,12 +1178,18 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
 	enum pipe pipe;
 	struct intel_crtc *intel_crtc;
 
+	dev_priv->ddi_plls.spll_refcount = 0;
+	dev_priv->ddi_plls.wrpll1_refcount = 0;
+	dev_priv->ddi_plls.wrpll2_refcount = 0;
+
 	for_each_pipe(pipe) {
 		intel_crtc =
 			to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
 
-		if (!intel_crtc->active)
+		if (!intel_crtc->active) {
+			intel_crtc->ddi_pll_sel = PORT_CLK_SEL_NONE;
 			continue;
+		}
 
 		intel_crtc->ddi_pll_sel = intel_ddi_get_crtc_pll(dev_priv,
 								 pipe);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 04/14] ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (2 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 03/14] drm/i915: fix DDI PLLs HW state readout code Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 05/14] md/raid5: Fix possible confusion when multiple write errors occur Kamal Mostafa
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Steven Rostedt, H. Peter Anvin, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Steven Rostedt <rostedt@goodmis.org>

commit 1739f09e33d8f66bf48ddbc3eca615574da6c4f6 upstream.

Function tracing callbacks expect to have the ftrace_ops that registered it
passed to them, not the address of the variable that holds the ftrace_ops
that registered it.

Use a mov instead of a lea to store the ftrace_ops into the parameter
of the function tracing callback.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Link: http://lkml.kernel.org/r/20131113152004.459787f9@gandalf.local.home
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/x86/kernel/entry_32.S | 4 ++--
 arch/x86/kernel/entry_64.S | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 6ed91d9..1d7fdbe 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1113,7 +1113,7 @@ ENTRY(ftrace_caller)
 	pushl $0	/* Pass NULL as regs pointer */
 	movl 4*4(%esp), %eax
 	movl 0x4(%ebp), %edx
-	leal function_trace_op, %ecx
+	movl function_trace_op, %ecx
 	subl $MCOUNT_INSN_SIZE, %eax
 
 .globl ftrace_call
@@ -1171,7 +1171,7 @@ ENTRY(ftrace_regs_caller)
 	movl 12*4(%esp), %eax	/* Load ip (1st parameter) */
 	subl $MCOUNT_INSN_SIZE, %eax	/* Adjust ip */
 	movl 0x4(%ebp), %edx	/* Load parent ip (2nd parameter) */
-	leal function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
+	movl function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
 	pushl %esp		/* Save pt_regs as 4th parameter */
 
 GLOBAL(ftrace_regs_call)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index cb3c591..310b270 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -88,7 +88,7 @@ END(function_hook)
 	MCOUNT_SAVE_FRAME \skip
 
 	/* Load the ftrace_ops into the 3rd parameter */
-	leaq function_trace_op, %rdx
+	movq function_trace_op(%rip), %rdx
 
 	/* Load ip into the first parameter */
 	movq RIP(%rsp), %rdi
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 05/14] md/raid5: Fix possible confusion when multiple write errors occur.
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (3 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 04/14] ftrace/x86: Load ftrace_ops in parameter not the variable holding it Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 06/14] md/raid10: fix two bugs in handling of known-bad-blocks Kamal Mostafa
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: NeilBrown, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: NeilBrown <neilb@suse.de>

commit 1cc03eb93245e63b0b7a7832165efdc52e25b4e6 upstream.

commit 5d8c71f9e5fbdd95650be00294d238e27a363b5c
    md: raid5 crash during degradation

Fixed a crash in an overly simplistic way which could leave
R5_WriteError or R5_MadeGood set in the stripe cache for devices
for which it is no longer relevant.
When those devices are removed and spares added the flags are still
set and can cause incorrect behaviour.

commit 14a75d3e07c784c004b4b44b34af996b8e4ac453
    md/raid5: preferentially read from replacement device if possible.

Fixed the same bug if a more effective way, so we can now revert
the original commit.

Reported-and-tested-by: Alexander Lyakas <alex.bolshoy@gmail.com>
Fixes: 5d8c71f9e5fbdd95650be00294d238e27a363b5c
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/md/raid5.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 51887b3..2ffa02c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3420,7 +3420,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
 			 */
 			set_bit(R5_Insync, &dev->flags);
 
-		if (rdev && test_bit(R5_WriteError, &dev->flags)) {
+		if (test_bit(R5_WriteError, &dev->flags)) {
 			/* This flag does not apply to '.replacement'
 			 * only to .rdev, so make sure to check that*/
 			struct md_rdev *rdev2 = rcu_dereference(
@@ -3433,7 +3433,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
 			} else
 				clear_bit(R5_WriteError, &dev->flags);
 		}
-		if (rdev && test_bit(R5_MadeGood, &dev->flags)) {
+		if (test_bit(R5_MadeGood, &dev->flags)) {
 			/* This flag does not apply to '.replacement'
 			 * only to .rdev, so make sure to check that*/
 			struct md_rdev *rdev2 = rcu_dereference(
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 06/14] md/raid10: fix two bugs in handling of known-bad-blocks.
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (4 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 05/14] md/raid5: Fix possible confusion when multiple write errors occur Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 07/14] md/raid10: fix bug when raid10 recovery fails to recover a block Kamal Mostafa
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: NeilBrown, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: NeilBrown <neilb@suse.de>

commit b50c259e25d9260b9108dc0c2964c26e5ecbe1c1 upstream.

If we discover a bad block when reading we split the request and
potentially read some of it from a different device.

The code path of this has two bugs in RAID10.
1/ we get a spin_lock with _irq, but unlock without _irq!!
2/ The calculation of 'sectors_handled' is wrong, as can be clearly
   seen by comparison with raid1.c

This leads to at least 2 warnings and a probable crash is a RAID10
ever had known bad blocks.

Fixes: 856e08e23762dfb92ffc68fd0a8d228f9e152160
Reported-by: Damian Nowak <spam@nowaker.net>
URL: https://bugzilla.kernel.org/show_bug.cgi?id=68181
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/md/raid10.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index b8f5688..4b4e094 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1276,7 +1276,7 @@ read_again:
 			/* Could not read all from this device, so we will
 			 * need another r10_bio.
 			 */
-			sectors_handled = (r10_bio->sectors + max_sectors
+			sectors_handled = (r10_bio->sector + max_sectors
 					   - bio->bi_sector);
 			r10_bio->sectors = max_sectors;
 			spin_lock_irq(&conf->device_lock);
@@ -1284,7 +1284,7 @@ read_again:
 				bio->bi_phys_segments = 2;
 			else
 				bio->bi_phys_segments++;
-			spin_unlock(&conf->device_lock);
+			spin_unlock_irq(&conf->device_lock);
 			/* Cannot call generic_make_request directly
 			 * as that will be queued in __generic_make_request
 			 * and subsequent mempool_alloc might block
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 07/14] md/raid10: fix bug when raid10 recovery fails to recover a block.
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (5 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 06/14] md/raid10: fix two bugs in handling of known-bad-blocks Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 08/14] hwmon: (coretemp) Fix truncated name of alarm attributes Kamal Mostafa
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: NeilBrown, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: NeilBrown <neilb@suse.de>

commit e8b849158508565e0cd6bc80061124afc5879160 upstream.

commit e875ecea266a543e643b19e44cf472f1412708f9
    md/raid10 record bad blocks as needed during recovery.

added code to the "cannot recover this block" path to record a bad
block rather than fail the whole recovery.
Unfortunately this new case was placed *after* r10bio was freed rather
than *before*, yet it still uses r10bio.
This is will crash with a null dereference.

So move the freeing of r10bio down where it is safe.

Fixes: e875ecea266a543e643b19e44cf472f1412708f9
Reported-by: Damian Nowak <spam@nowaker.net>
URL: https://bugzilla.kernel.org/show_bug.cgi?id=68181
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/md/raid10.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 4b4e094..dfd6eba 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3153,10 +3153,6 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
 			if (j == conf->copies) {
 				/* Cannot recover, so abort the recovery or
 				 * record a bad block */
-				put_buf(r10_bio);
-				if (rb2)
-					atomic_dec(&rb2->remaining);
-				r10_bio = rb2;
 				if (any_working) {
 					/* problem is that there are bad blocks
 					 * on other device(s)
@@ -3188,6 +3184,10 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
 					mirror->recovery_disabled
 						= mddev->recovery_disabled;
 				}
+				put_buf(r10_bio);
+				if (rb2)
+					atomic_dec(&rb2->remaining);
+				r10_bio = rb2;
 				break;
 			}
 		}
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 08/14] hwmon: (coretemp) Fix truncated name of alarm attributes
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (6 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 07/14] md/raid10: fix bug when raid10 recovery fails to recover a block Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 09/14] nilfs2: fix segctor bug that causes file system corruption Kamal Mostafa
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Jean Delvare, Guenter Roeck, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jean Delvare <khali@linux-fr.org>

commit 3f9aec7610b39521c7c69d754de7265f6994c194 upstream.

When the core number exceeds 9, the size of the buffer storing the
alarm attribute name is insufficient and the attribute name is
truncated. This causes libsensors to skip these attributes as the
truncated name is not recognized.

Reported-by: Andreas Hollmann <hollmann@in.tum.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/hwmon/coretemp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index d64923d..67c05db 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
 
 #define BASE_SYSFS_ATTR_NO	2	/* Sysfs Base attr no for coretemp */
 #define NUM_REAL_CORES		32	/* Number of Real cores per cpu */
-#define CORETEMP_NAME_LENGTH	17	/* String Length of attrs */
+#define CORETEMP_NAME_LENGTH	19	/* String Length of attrs */
 #define MAX_CORE_ATTRS		4	/* Maximum no of basic attrs */
 #define TOTAL_ATTRS		(MAX_CORE_ATTRS + 1)
 #define MAX_CORE_DATA		(NUM_REAL_CORES + BASE_SYSFS_ATTR_NO)
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 09/14] nilfs2: fix segctor bug that causes file system corruption
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (7 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 08/14] hwmon: (coretemp) Fix truncated name of alarm attributes Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 10/14] perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h Kamal Mostafa
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Andreas Rohner, Ryusuke Konishi, Andrew Morton, Linus Torvalds,
	Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andreas Rohner <andreas.rohner@gmx.net>

commit 70f2fe3a26248724d8a5019681a869abdaf3e89a upstream.

There is a bug in the function nilfs_segctor_collect, which results in
active data being written to a segment, that is marked as clean.  It is
possible, that this segment is selected for a later segment
construction, whereby the old data is overwritten.

The problem shows itself with the following kernel log message:

  nilfs_sufile_do_cancel_free: segment 6533 must be clean

Usually a few hours later the file system gets corrupted:

  NILFS: bad btree node (blocknr=8748107): level = 0, flags = 0x0, nchildren = 0
  NILFS error (device sdc1): nilfs_bmap_last_key: broken bmap (inode number=114660)

The issue can be reproduced with a file system that is nearly full and
with the cleaner running, while some IO intensive task is running.
Although it is quite hard to reproduce.

This is what happens:

 1. The cleaner starts the segment construction
 2. nilfs_segctor_collect is called
 3. sc_stage is on NILFS_ST_SUFILE and segments are freed
 4. sc_stage is on NILFS_ST_DAT current segment is full
 5. nilfs_segctor_extend_segments is called, which
    allocates a new segment
 6. The new segment is one of the segments freed in step 3
 7. nilfs_sufile_cancel_freev is called and produces an error message
 8. Loop around and the collection starts again
 9. sc_stage is on NILFS_ST_SUFILE and segments are freed
    including the newly allocated segment, which will contain active
    data and can be allocated at a later time
10. A few hours later another segment construction allocates the
    segment and causes file system corruption

This can be prevented by simply reordering the statements.  If
nilfs_sufile_cancel_freev is called before nilfs_segctor_extend_segments
the freed segments are marked as dirty and cannot be allocated any more.

Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
Reviewed-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Tested-by: Andreas Rohner <andreas.rohner@gmx.net>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/nilfs2/segment.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index cbd6618..958a5b5 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1440,17 +1440,19 @@ static int nilfs_segctor_collect(struct nilfs_sc_info *sci,
 
 		nilfs_clear_logs(&sci->sc_segbufs);
 
-		err = nilfs_segctor_extend_segments(sci, nilfs, nadd);
-		if (unlikely(err))
-			return err;
-
 		if (sci->sc_stage.flags & NILFS_CF_SUFREED) {
 			err = nilfs_sufile_cancel_freev(nilfs->ns_sufile,
 							sci->sc_freesegs,
 							sci->sc_nfreesegs,
 							NULL);
 			WARN_ON(err); /* do not happen */
+			sci->sc_stage.flags &= ~NILFS_CF_SUFREED;
 		}
+
+		err = nilfs_segctor_extend_segments(sci, nilfs, nadd);
+		if (unlikely(err))
+			return err;
+
 		nadd = min_t(int, nadd << 1, SC_MAX_SEGDELTA);
 		sci->sc_stage = prev_stage;
 	}
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 10/14] perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (8 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 09/14] nilfs2: fix segctor bug that causes file system corruption Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 11/14] net: rds: fix per-cpu helper usage Kamal Mostafa
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Robert Richter, Peter Zijlstra, Linus Torvalds, Ingo Molnar,
	Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Robert Richter <rric@kernel.org>

commit bee09ed91cacdbffdbcd3b05de8409c77ec9fcd6 upstream.

On AMD family 10h we see following error messages while waking up from
S3 for all non-boot CPUs leading to a failed IBS initialization:

 Enabling non-boot CPUs ...
 smpboot: Booting Node 0 Processor 1 APIC 0x1
 [Firmware Bug]: cpu 1, try to use APIC500 (LVT offset 0) for vector 0x400, but the register is already in use for vector 0xf9 on another cpu
 perf: IBS APIC setup failed on cpu #1
 process: Switch to broadcast mode on CPU1
 CPU1 is up
 ...
 ACPI: Waking up from system sleep state S3

Reason for this is that during suspend the LVT offset for the IBS
vector gets lost and needs to be reinialized while resuming.

The offset is read from the IBSCTL msr. On family 10h the offset needs
to be 1 as offset 0 is used for the MCE threshold interrupt, but
firmware assings it for IBS to 0 too. The kernel needs to reprogram
the vector. The msr is a readonly node msr, but a new value can be
written via pci config space access. The reinitialization is
implemented for family 10h in setup_ibs_ctl() which is forced during
IBS setup.

This patch fixes IBS setup after waking up from S3 by adding
resume/supend hooks for the boot cpu which does the offset
reinitialization.

Marking it as stable to let distros pick up this fix.

Signed-off-by: Robert Richter <rric@kernel.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1389797849-5565-1-git-send-email-rric.net@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/x86/kernel/cpu/perf_event_amd_ibs.c | 53 +++++++++++++++++++++++++++-----
 1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
index 6336bcb..0798e5f 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/ptrace.h>
+#include <linux/syscore_ops.h>
 
 #include <asm/apic.h>
 
@@ -816,6 +817,18 @@ out:
 	return ret;
 }
 
+static void ibs_eilvt_setup(void)
+{
+	/*
+	 * Force LVT offset assignment for family 10h: The offsets are
+	 * not assigned by the BIOS for this family, so the OS is
+	 * responsible for doing it. If the OS assignment fails, fall
+	 * back to BIOS settings and try to setup this.
+	 */
+	if (boot_cpu_data.x86 == 0x10)
+		force_ibs_eilvt_setup();
+}
+
 static inline int get_ibs_lvt_offset(void)
 {
 	u64 val;
@@ -851,6 +864,36 @@ static void clear_APIC_ibs(void *dummy)
 		setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_FIX, 1);
 }
 
+#ifdef CONFIG_PM
+
+static int perf_ibs_suspend(void)
+{
+	clear_APIC_ibs(NULL);
+	return 0;
+}
+
+static void perf_ibs_resume(void)
+{
+	ibs_eilvt_setup();
+	setup_APIC_ibs(NULL);
+}
+
+static struct syscore_ops perf_ibs_syscore_ops = {
+	.resume		= perf_ibs_resume,
+	.suspend	= perf_ibs_suspend,
+};
+
+static void perf_ibs_pm_init(void)
+{
+	register_syscore_ops(&perf_ibs_syscore_ops);
+}
+
+#else
+
+static inline void perf_ibs_pm_init(void) { }
+
+#endif
+
 static int __cpuinit
 perf_ibs_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
 {
@@ -877,18 +920,12 @@ static __init int amd_ibs_init(void)
 	if (!caps)
 		return -ENODEV;	/* ibs not supported by the cpu */
 
-	/*
-	 * Force LVT offset assignment for family 10h: The offsets are
-	 * not assigned by the BIOS for this family, so the OS is
-	 * responsible for doing it. If the OS assignment fails, fall
-	 * back to BIOS settings and try to setup this.
-	 */
-	if (boot_cpu_data.x86 == 0x10)
-		force_ibs_eilvt_setup();
+	ibs_eilvt_setup();
 
 	if (!ibs_eilvt_valid())
 		goto out;
 
+	perf_ibs_pm_init();
 	get_online_cpus();
 	ibs_caps = caps;
 	/* make ibs_caps visible to other cpus: */
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 11/14] net: rds: fix per-cpu helper usage
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (9 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 10/14] perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 12/14] staging: comedi: 8255_pci: fix for newer PCI-DIO48H Kamal Mostafa
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: David S. Miller, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

commit c196403b79aa241c3fefb3ee5bb328aa7c5cc860 upstream.

commit ae4b46e9d "net: rds: use this_cpu_* per-cpu helper" broke per-cpu
handling for rds. chpfirst is the result of __this_cpu_read(), so it is
an absolute pointer and not __percpu. Therefore, __this_cpu_write()
should not operate on chpfirst, but rather on cache->percpu->first, just
like __this_cpu_read() did before.

Signed-off-byd Gerald Schaefer <gerald.schaefer@de.ibm.com>

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/rds/ib_recv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 8eb9501..b7ebe23 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -421,8 +421,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
 				 struct rds_ib_refill_cache *cache)
 {
 	unsigned long flags;
-	struct list_head *old;
-	struct list_head __percpu *chpfirst;
+	struct list_head *old, *chpfirst;
 
 	local_irq_save(flags);
 
@@ -432,7 +431,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
 	else /* put on front */
 		list_add_tail(new_item, chpfirst);
 
-	__this_cpu_write(chpfirst, new_item);
+	__this_cpu_write(cache->percpu->first, new_item);
 	__this_cpu_inc(cache->percpu->count);
 
 	if (__this_cpu_read(cache->percpu->count) < RDS_IB_RECYCLE_BATCH_COUNT)
@@ -452,7 +451,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
 	} while (old);
 
 
-	__this_cpu_write(chpfirst, NULL);
+	__this_cpu_write(cache->percpu->first, NULL);
 	__this_cpu_write(cache->percpu->count, 0);
 end:
 	local_irq_restore(flags);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 12/14] staging: comedi: 8255_pci: fix for newer PCI-DIO48H
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (10 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 11/14] net: rds: fix per-cpu helper usage Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 13/14] staging: comedi: addi_apci_1032: fix subdevice type/flags bug Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 14/14] x86, x32: Correct invalid use of user timespec in the kernel Kamal Mostafa
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Ian Abbott, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ian Abbott <abbotti@mev.co.uk>

based on
commit 0283f7a100882684ad32b768f9f1ad81658a0b92 upstream.

At some point, Measurement Computing / ComputerBoards redesigned the
PCI-DIO48H to use a PLX PCI interface chip instead of an AMCC chip.
This meant they had to put their hardware registers in the PCI BAR 2
region instead of PCI BAR 1.  Unfortunately, they kept the same PCI
device ID for the new design.  This means the driver recognizes the
newer cards, but doesn't work (and is likely to screw up the local
configuration registers of the PLX chip) because it's using the wrong
region.

Since  the PCI subvendor and subdevice IDs were both zero on the old
design, but are the same as the vendor and device on the new design, we
can tell the old design and new design apart easily enough.  To avoid
adding extra data to `pci_8255_boards[]`, treat the board as a special
case in `pci_8255_auto_attach[]`.  It's safer to use the fact that the
PCI BAR 2 region will have non-zero length only on the newer design, so
use that fact to distinguish them.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: kernel-team@lists.ubuntu.com
[ ian: backport to 3.8 ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/staging/comedi/drivers/8255_pci.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c
index e0a7952..92ee23e 100644
--- a/drivers/staging/comedi/drivers/8255_pci.c
+++ b/drivers/staging/comedi/drivers/8255_pci.c
@@ -122,7 +122,7 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = {
 		.name		= "cb_pci-dio48h",
 		.vendor		= PCI_VENDOR_ID_CB,
 		.device		= PCI_DEVICE_ID_CB_PCIDIO48H,
-		.dio_badr	= 1,
+		.dio_badr	= 1,	/* only for older boards */
 		.n_8255		= 2,
 	}, {
 		.name		= "cb_pci-dio96h",
@@ -224,6 +224,7 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
 	unsigned long len;
 	int ret;
 	int i;
+	int dio_badr;
 
 	board = pci_8255_find_boardinfo(dev, pcidev);
 	if (!board)
@@ -239,8 +240,21 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
 	ret = comedi_pci_enable(pcidev, dev->board_name);
 	if (ret)
 		return ret;
-	iobase = pci_resource_start(pcidev, board->dio_badr);
-	len = pci_resource_len(pcidev, board->dio_badr);
+	dio_badr = board->dio_badr;
+	/*
+	 * For Measurement Computing / ComputerBoards PCI-DIO48H, use the
+	 * PCI BAR 2 region, if non-zero length, else use the PCI BAR 1 region
+	 * from the board entry.  This is because the board was redesigned to
+	 * use a different PCI interface chip, with the user registers in a
+	 * different PCI BAR region.
+	 */
+	if (pcidev->vendor == PCI_VENDOR_ID_CB &&
+	    pcidev->device == PCI_DEVICE_ID_CB_PCIDIO48H &&
+	    pci_resource_len(pcidev, 2))
+		dio_badr = 2;
+
+	iobase = pci_resource_start(pcidev, dio_badr);
+	len = pci_resource_len(pcidev, dio_badr);
 
 	if (board->is_mmio) {
 		devpriv->mmio_base = ioremap(iobase, len);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 13/14] staging: comedi: addi_apci_1032: fix subdevice type/flags bug
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (11 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 12/14] staging: comedi: 8255_pci: fix for newer PCI-DIO48H Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  2014-01-31 17:32 ` [PATCH 3.8 14/14] x86, x32: Correct invalid use of user timespec in the kernel Kamal Mostafa
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: H Hartley Sweeten, Greg Kroah-Hartman, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: H Hartley Sweeten <hsweeten@visionengravers.com>

commit 90daf69a7a3f1d1a41018c799968a0bb896d65e0 upstream

The SDF_CMD_READ should be one of the s->subdev_flags not part of
the s->type.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/staging/comedi/drivers/addi_apci_1032.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c
index 7f94242..97de74e 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1032.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1032.c
@@ -331,8 +331,8 @@ static int apci1032_auto_attach(struct comedi_device *dev,
 	s = &dev->subdevices[1];
 	if (dev->irq) {
 		dev->read_subdev = s;
-		s->type		= COMEDI_SUBD_DI | SDF_CMD_READ;
-		s->subdev_flags	= SDF_READABLE;
+		s->type		= COMEDI_SUBD_DI;
+		s->subdev_flags	= SDF_READABLE | SDF_CMD_READ;
 		s->n_chan	= 1;
 		s->maxdata	= 1;
 		s->range_table	= &range_digital;
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3.8 14/14] x86, x32: Correct invalid use of user timespec in the kernel
  2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
                   ` (12 preceding siblings ...)
  2014-01-31 17:32 ` [PATCH 3.8 13/14] staging: comedi: addi_apci_1032: fix subdevice type/flags bug Kamal Mostafa
@ 2014-01-31 17:32 ` Kamal Mostafa
  13 siblings, 0 replies; 15+ messages in thread
From: Kamal Mostafa @ 2014-01-31 17:32 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: PaX Team, H. Peter Anvin, Linus Torvalds, Kamal Mostafa

3.8.13.17 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: PaX Team <pageexec@freemail.hu>

commit 2def2ef2ae5f3990aabdbe8a755911902707d268 upstream.

The x32 case for the recvmsg() timout handling is broken:

  asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
                                      unsigned int vlen, unsigned int flags,
                                      struct compat_timespec __user *timeout)
  {
          int datagrams;
          struct timespec ktspec;

          if (flags & MSG_CMSG_COMPAT)
                  return -EINVAL;

          if (COMPAT_USE_64BIT_TIME)
                  return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
                                        flags | MSG_CMSG_COMPAT,
                                        (struct timespec *) timeout);
          ...

The timeout pointer parameter is provided by userland (hence the __user
annotation) but for x32 syscalls it's simply cast to a kernel pointer
and is passed to __sys_recvmmsg which will eventually directly
dereference it for both reading and writing.  Other callers to
__sys_recvmmsg properly copy from userland to the kernel first.

The bug was introduced by commit ee4fa23c4bfc ("compat: Use
COMPAT_USE_64BIT_TIME in net/compat.c") and should affect all kernels
since 3.4 (and perhaps vendor kernels if they backported x32 support
along with this code).

Note that CONFIG_X86_X32_ABI gets enabled at build time and only if
CONFIG_X86_X32 is enabled and ld can build x32 executables.

Other uses of COMPAT_USE_64BIT_TIME seem fine.

This addresses CVE-2014-0038.

Signed-off-by: PaX Team <pageexec@freemail.hu>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/compat.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/net/compat.c b/net/compat.c
index dd32e34..f50161f 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -780,21 +780,16 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 	if (flags & MSG_CMSG_COMPAT)
 		return -EINVAL;
 
-	if (COMPAT_USE_64BIT_TIME)
-		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
-				      flags | MSG_CMSG_COMPAT,
-				      (struct timespec *) timeout);
-
 	if (timeout == NULL)
 		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
 				      flags | MSG_CMSG_COMPAT, NULL);
 
-	if (get_compat_timespec(&ktspec, timeout))
+	if (compat_get_timespec(&ktspec, timeout))
 		return -EFAULT;
 
 	datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
 				   flags | MSG_CMSG_COMPAT, &ktspec);
-	if (datagrams > 0 && put_compat_timespec(&ktspec, timeout))
+	if (datagrams > 0 && compat_put_timespec(&ktspec, timeout))
 		datagrams = -EFAULT;
 
 	return datagrams;
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-01-31 17:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-31 17:32 [3.8.y.z extended stable] Linux 3.8.13.17 stable review Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 01/14] vfs: In d_path don't call d_dname on a mount point Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 02/14] writeback: Fix data corruption on NFS Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 03/14] drm/i915: fix DDI PLLs HW state readout code Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 04/14] ftrace/x86: Load ftrace_ops in parameter not the variable holding it Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 05/14] md/raid5: Fix possible confusion when multiple write errors occur Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 06/14] md/raid10: fix two bugs in handling of known-bad-blocks Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 07/14] md/raid10: fix bug when raid10 recovery fails to recover a block Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 08/14] hwmon: (coretemp) Fix truncated name of alarm attributes Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 09/14] nilfs2: fix segctor bug that causes file system corruption Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 10/14] perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 11/14] net: rds: fix per-cpu helper usage Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 12/14] staging: comedi: 8255_pci: fix for newer PCI-DIO48H Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 13/14] staging: comedi: addi_apci_1032: fix subdevice type/flags bug Kamal Mostafa
2014-01-31 17:32 ` [PATCH 3.8 14/14] x86, x32: Correct invalid use of user timespec in the kernel Kamal Mostafa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).