All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3.10 00/16] 3.10.104-stable review
@ 2016-10-19 22:49 Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls" Willy Tarreau
                   ` (15 more replies)
  0 siblings, 16 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Willy Tarreau

This is the start of the stable review cycle for the 3.10.104 release.
All patches will be posted as a response to this one. If anyone has any
issue with these being applied, please let me know. If anyone thinks some
important patches are missing and should be added prior to the release,
please report them quickly with their respective mainline commit IDs.

Responses should be made by Fri Oct 21 21:00:00 CEST 2016.
Anything received after that time might be too late. If someone
wants a bit more time for a deeper review, please let me know.

The whole patch series can be found in one patch at :
   https://kernel.org/pub/linux/kernel/v3.x/stable-review/patch-3.10.104-rc1.gz

The shortlog and diffstat are appended below.

Thanks,
Willy

===============


Andrea Arcangeli (1):
  mm: thp: fix SMP race condition between THP page fault and
    MADV_DONTNEED

Dan Carpenter (2):
  crypto: nx - off by one bug in nx_of_update_msc()
  ACPI / sysfs: fix error code in get_status()

Dave Carroll (1):
  aacraid: Check size values after double-fetch from user

Ian Abbott (1):
  staging: comedi: daqboard2000: bug fix board type matching code

James Hogan (1):
  MIPS: KVM: Check for pfn noslot case

Jann Horn (1):
  security: let security modules use PTRACE_MODE_* with bitmasks

Jason S. McMullan (3):
  PCI: Support PCIe devices with short cfg_size
  PCI: Add Netronome vendor and device IDs
  PCI: Limit config space size for Netronome NFP6000 family

Linus Torvalds (1):
  mm: remove gup_flags FOLL_WRITE games from __get_user_pages()

Simon Horman (2):
  PCI: Add Netronome NFP4000 PF device ID
  PCI: Limit config space size for Netronome NFP4000

Wei Liu (1):
  xen-netback: ref count shared rings

Willy Tarreau (1):
  Revert "powerpc/tm: Always reclaim in start_thread() for exec() class
    syscalls"

Yinghai Lu (1):
  megaraid_sas: Fix probing cards without io port

 arch/mips/kvm/kvm_tlb.c                       |  2 +-
 arch/powerpc/kernel/process.c                 | 10 ----------
 drivers/acpi/sysfs.c                          |  7 +++----
 drivers/crypto/nx/nx.c                        |  2 +-
 drivers/net/xen-netback/common.h              |  4 ++++
 drivers/net/xen-netback/interface.c           | 17 ++++++++++++++--
 drivers/net/xen-netback/netback.c             |  6 ++++++
 drivers/pci/pci-sysfs.c                       | 18 ++++++++---------
 drivers/pci/quirks.c                          | 12 ++++++++++++
 drivers/scsi/aacraid/commctrl.c               | 13 +++++++++++--
 drivers/scsi/megaraid/megaraid_sas_base.c     |  6 +++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c   |  2 +-
 drivers/staging/comedi/drivers/daqboard2000.c |  2 +-
 include/linux/mm.h                            |  1 +
 include/linux/pci_ids.h                       |  7 +++++++
 mm/memory.c                                   | 28 +++++++++++++++++++++++----
 security/yama/yama_lsm.c                      |  4 ++--
 17 files changed, 101 insertions(+), 40 deletions(-)

-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls"
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-20  3:07   ` Guenter Roeck
  2016-10-19 22:49 ` [PATCH 3.10 02/16] PCI: Support PCIe devices with short cfg_size Willy Tarreau
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Willy Tarreau, Guenter Roeck

This reverts commit 8110080dc53335d5dd99b123144a6174f19ffc65.

Guenter noticed that this breaks PPC build when CONFIG_PPC_TRANSACTIONAL_MEM
is set, because this patch was not for 3.10.

Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 arch/powerpc/kernel/process.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index a5e339806..d55357e 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1088,16 +1088,6 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
 		current->thread.regs = regs - 1;
 	}
 
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-	/*
-	 * Clear any transactional state, we're exec()ing. The cause is
-	 * not important as there will never be a recheckpoint so it's not
-	 * user visible.
-	 */
-	if (MSR_TM_SUSPENDED(mfmsr()))
-		tm_reclaim_current(0);
-#endif
-
 	memset(regs->gpr, 0, sizeof(regs->gpr));
 	regs->ctr = 0;
 	regs->link = 0;
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 02/16] PCI: Support PCIe devices with short cfg_size
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls" Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 03/16] PCI: Add Netronome vendor and device IDs Willy Tarreau
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jason S. McMullan, Simon Horman, Bjorn Helgaas, Willy Tarreau

From: "Jason S. McMullan" <jason.mcmullan@netronome.com>

commit c20aecf6963d1273d8f6d61c042b4845441ca592 upstream.

If a device quirk modifies the pci_dev->cfg_size to be less than
PCI_CFG_SPACE_EXP_SIZE (4096), but greater than PCI_CFG_SPACE_SIZE (256),
the PCI sysfs interface truncates the readable size to PCI_CFG_SPACE_SIZE.

Allow sysfs access to config space up to cfg_size, even if the device
doesn't support the entire 4096-byte PCIe config space.

Note that pci_read_config() and pci_write_config() limit access to
dev->cfg_size even though pcie_config_attr contains 4096 (the maximum
size).

Signed-off-by: Jason S. McMullan <jason.mcmullan@netronome.com>
[simon: edited changelog]
Signed-off-by: Simon Horman <simon.horman@netronome.com>
[bhelgaas: more changelog edits]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/pci/pci-sysfs.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 689f3c8..aee15ce 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1308,10 +1308,10 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 	if (!sysfs_initialized)
 		return -EACCES;
 
-	if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
-		retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
-	else
+	if (pdev->cfg_size > PCI_CFG_SPACE_SIZE)
 		retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
+	else
+		retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
 	if (retval)
 		goto err;
 
@@ -1368,10 +1368,10 @@ err_rom_file:
 err_resource_files:
 	pci_remove_resource_files(pdev);
 err_config_file:
-	if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
-		sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
-	else
+	if (pdev->cfg_size > PCI_CFG_SPACE_SIZE)
 		sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
+	else
+		sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
 err:
 	return retval;
 }
@@ -1405,10 +1405,10 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
 
 	pci_remove_capabilities_sysfs(pdev);
 
-	if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
-		sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
-	else
+	if (pdev->cfg_size > PCI_CFG_SPACE_SIZE)
 		sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
+	else
+		sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
 
 	pci_remove_resource_files(pdev);
 
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 03/16] PCI: Add Netronome vendor and device IDs
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls" Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 02/16] PCI: Support PCIe devices with short cfg_size Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 04/16] PCI: Limit config space size for Netronome NFP6000 family Willy Tarreau
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jason S. McMullan, Simon Horman, Bjorn Helgaas, Willy Tarreau

From: "Jason S. McMullan" <jason.mcmullan@netronome.com>

commit a755e169031dac9ebaed03302c4921687c271d62 upstream.

Device IDs for the Netronome NFP3200, NFP3240, NFP6000, and NFP6000 SR-IOV
devices.

Signed-off-by: Jason S. McMullan <jason.mcmullan@netronome.com>
[simon: edited changelog]
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 include/linux/pci_ids.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 6c7bb35..8b24f73 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2472,6 +2472,12 @@
 #define PCI_DEVICE_ID_KORENIX_JETCARDF2	0x1700
 #define PCI_DEVICE_ID_KORENIX_JETCARDF3	0x17ff
 
+#define PCI_VENDOR_ID_NETRONOME		0x19ee
+#define PCI_DEVICE_ID_NETRONOME_NFP3200	0x3200
+#define PCI_DEVICE_ID_NETRONOME_NFP3240	0x3240
+#define PCI_DEVICE_ID_NETRONOME_NFP6000	0x6000
+#define PCI_DEVICE_ID_NETRONOME_NFP6000_VF	0x6003
+
 #define PCI_VENDOR_ID_QMI		0x1a32
 
 #define PCI_VENDOR_ID_AZWAVE		0x1a3b
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 04/16] PCI: Limit config space size for Netronome NFP6000 family
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (2 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 03/16] PCI: Add Netronome vendor and device IDs Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 05/16] PCI: Add Netronome NFP4000 PF device ID Willy Tarreau
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jason S. McMullan, Simon Horman, Bjorn Helgaas, Willy Tarreau

From: "Jason S. McMullan" <jason.mcmullan@netronome.com>

commit 9f33a2ae59f24452c1076749deb615bccd435ca9 upstream.

The NFP6000 has an erratum where reading/writing to PCI config space
addresses above 0x600 can cause the NFP to generate PCIe completion
timeouts.

Limit the NFP6000's config space size to 0x600 bytes.

Signed-off-by: Jason S. McMullan <jason.mcmullan@netronome.com>
[simon: edited changelog]
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/pci/quirks.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 390e409..df1030c 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -292,6 +292,17 @@ static void quirk_citrine(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM,	PCI_DEVICE_ID_IBM_CITRINE,	quirk_citrine);
 
+/*
+ * This chip can cause bus lockups if config addresses above 0x600
+ * are read or written.
+ */
+static void quirk_nfp6000(struct pci_dev *dev)
+{
+	dev->cfg_size = 0x600;
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME,	PCI_DEVICE_ID_NETRONOME_NFP6000,	quirk_nfp6000);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME,	PCI_DEVICE_ID_NETRONOME_NFP6000_VF,	quirk_nfp6000);
+
 /*  On IBM Crocodile ipr SAS adapters, expand BAR to system page size */
 static void quirk_extend_bar_to_page(struct pci_dev *dev)
 {
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 05/16] PCI: Add Netronome NFP4000 PF device ID
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (3 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 04/16] PCI: Limit config space size for Netronome NFP6000 family Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 06/16] PCI: Limit config space size for Netronome NFP4000 Willy Tarreau
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Simon Horman, Bjorn Helgaas, Willy Tarreau

From: Simon Horman <simon.horman@netronome.com>

commit 69874ec233871a62e1bc8c89e643993af93a8630 upstream.

Add the device ID for the PF of the NFP4000.  The device ID for the VF,
0x6003, is already present as PCI_DEVICE_ID_NETRONOME_NFP6000_VF.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 include/linux/pci_ids.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 8b24f73..302182a 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2475,6 +2475,7 @@
 #define PCI_VENDOR_ID_NETRONOME		0x19ee
 #define PCI_DEVICE_ID_NETRONOME_NFP3200	0x3200
 #define PCI_DEVICE_ID_NETRONOME_NFP3240	0x3240
+#define PCI_DEVICE_ID_NETRONOME_NFP4000	0x4000
 #define PCI_DEVICE_ID_NETRONOME_NFP6000	0x6000
 #define PCI_DEVICE_ID_NETRONOME_NFP6000_VF	0x6003
 
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 06/16] PCI: Limit config space size for Netronome NFP4000
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (4 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 05/16] PCI: Add Netronome NFP4000 PF device ID Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 07/16] aacraid: Check size values after double-fetch from user Willy Tarreau
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Simon Horman, Bjorn Helgaas, Willy Tarreau

From: Simon Horman <simon.horman@netronome.com>

commit c2e771b02792d222cbcd9617fe71482a64f52647 upstream.

Like the NFP6000, the NFP4000 as an erratum where reading/writing to PCI
config space addresses above 0x600 can cause the NFP to generate PCIe
completion timeouts.

Limit the NFP4000's PF's config space size to 0x600 bytes as is already
done for the NFP6000.

The NFP4000's VF is 0x6004 (PCI_DEVICE_ID_NETRONOME_NFP6000_VF), the same
device ID as the NFP6000's VF.  Thus, its config space is already limited
by the existing use of quirk_nfp6000().

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/pci/quirks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index df1030c..a663715 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -300,6 +300,7 @@ static void quirk_nfp6000(struct pci_dev *dev)
 {
 	dev->cfg_size = 0x600;
 }
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME,	PCI_DEVICE_ID_NETRONOME_NFP4000,	quirk_nfp6000);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME,	PCI_DEVICE_ID_NETRONOME_NFP6000,	quirk_nfp6000);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME,	PCI_DEVICE_ID_NETRONOME_NFP6000_VF,	quirk_nfp6000);
 
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 07/16] aacraid: Check size values after double-fetch from user
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (5 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 06/16] PCI: Limit config space size for Netronome NFP4000 Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 08/16] megaraid_sas: Fix probing cards without io port Willy Tarreau
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Dave Carroll, Martin K . Petersen, Willy Tarreau

From: Dave Carroll <david.carroll@microsemi.com>

commit fa00c437eef8dc2e7b25f8cd868cfa405fcc2bb3 upstream.

In aacraid's ioctl_send_fib() we do two fetches from userspace, one the
get the fib header's size and one for the fib itself. Later we use the
size field from the second fetch to further process the fib. If for some
reason the size from the second fetch is different than from the first
fix, we may encounter an out-of- bounds access in aac_fib_send(). We
also check the sender size to insure it is not out of bounds. This was
reported in https://bugzilla.kernel.org/show_bug.cgi?id=116751 and was
assigned CVE-2016-6480.

Reported-by: Pengfei Wang <wpengfeinudt@gmail.com>
Fixes: 7c00ffa31 '[SCSI] 2.6 aacraid: Variable FIB size (updated patch)'
Cc: stable@vger.kernel.org
Signed-off-by: Dave Carroll <david.carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/scsi/aacraid/commctrl.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index ee6cadd..d6fcadd 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -63,7 +63,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
 	struct fib *fibptr;
 	struct hw_fib * hw_fib = (struct hw_fib *)0;
 	dma_addr_t hw_fib_pa = (dma_addr_t)0LL;
-	unsigned size;
+	unsigned int size, osize;
 	int retval;
 
 	if (dev->in_reset) {
@@ -87,7 +87,8 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
 	 *	will not overrun the buffer when we copy the memory. Return
 	 *	an error if we would.
 	 */
-	size = le16_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr);
+	osize = size = le16_to_cpu(kfib->header.Size) +
+		sizeof(struct aac_fibhdr);
 	if (size < le16_to_cpu(kfib->header.SenderSize))
 		size = le16_to_cpu(kfib->header.SenderSize);
 	if (size > dev->max_fib_size) {
@@ -118,6 +119,14 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
 		goto cleanup;
 	}
 
+	/* Sanity check the second copy */
+	if ((osize != le16_to_cpu(kfib->header.Size) +
+		sizeof(struct aac_fibhdr))
+		|| (size < le16_to_cpu(kfib->header.SenderSize))) {
+		retval = -EINVAL;
+		goto cleanup;
+	}
+
 	if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {
 		aac_adapter_interrupt(dev);
 		/*
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 08/16] megaraid_sas: Fix probing cards without io port
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (6 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 07/16] aacraid: Check size values after double-fetch from user Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 09/16] crypto: nx - off by one bug in nx_of_update_msc() Willy Tarreau
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Yinghai Lu, Martin K . Petersen, Willy Tarreau

From: Yinghai Lu <yinghai@kernel.org>

commit e7f851684efb3377e9c93aca7fae6e76212e5680 upstream.

Found one megaraid_sas HBA probe fails,

[  187.235190] scsi host2: Avago SAS based MegaRAID driver
[  191.112365] megaraid_sas 0000:89:00.0: BAR 0: can't reserve [io  0x0000-0x00ff]
[  191.120548] megaraid_sas 0000:89:00.0: IO memory region busy!

and the card has resource like,
[  125.097714] pci 0000:89:00.0: [1000:005d] type 00 class 0x010400
[  125.104446] pci 0000:89:00.0: reg 0x10: [io  0x0000-0x00ff]
[  125.110686] pci 0000:89:00.0: reg 0x14: [mem 0xce400000-0xce40ffff 64bit]
[  125.118286] pci 0000:89:00.0: reg 0x1c: [mem 0xce300000-0xce3fffff 64bit]
[  125.125891] pci 0000:89:00.0: reg 0x30: [mem 0xce200000-0xce2fffff pref]

that does not io port resource allocated from BIOS, and kernel can not
assign one as io port shortage.

The driver is only looking for MEM, and should not fail.

It turns out megasas_init_fw() etc are using bar index as mask.  index 1
is used as mask 1, so that pci_request_selected_regions() is trying to
request BAR0 instead of BAR1.

Fix all related reference.

Fixes: b6d5d8808b4c ("megaraid_sas: Use lowest memory bar for SR-IOV VF support")
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 6 +++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index e6dfa81..6ced6a3 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3470,7 +3470,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
 	/* Find first memory bar */
 	bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
 	instance->bar = find_first_bit(&bar_list, sizeof(unsigned long));
-	if (pci_request_selected_regions(instance->pdev, instance->bar,
+	if (pci_request_selected_regions(instance->pdev, 1<<instance->bar,
 					 "megasas: LSI")) {
 		printk(KERN_DEBUG "megasas: IO memory region busy!\n");
 		return -EBUSY;
@@ -3640,7 +3640,7 @@ fail_ready_state:
 	iounmap(instance->reg_set);
 
       fail_ioremap:
-	pci_release_selected_regions(instance->pdev, instance->bar);
+	pci_release_selected_regions(instance->pdev, 1<<instance->bar);
 
 	return -EINVAL;
 }
@@ -3661,7 +3661,7 @@ static void megasas_release_mfi(struct megasas_instance *instance)
 
 	iounmap(instance->reg_set);
 
-	pci_release_selected_regions(instance->pdev, instance->bar);
+	pci_release_selected_regions(instance->pdev, 1<<instance->bar);
 }
 
 /**
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index a7d5668..d478088 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2020,7 +2020,7 @@ megasas_release_fusion(struct megasas_instance *instance)
 
 	iounmap(instance->reg_set);
 
-	pci_release_selected_regions(instance->pdev, instance->bar);
+	pci_release_selected_regions(instance->pdev, 1<<instance->bar);
 }
 
 /**
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 09/16] crypto: nx - off by one bug in nx_of_update_msc()
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (7 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 08/16] megaraid_sas: Fix probing cards without io port Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 10/16] staging: comedi: daqboard2000: bug fix board type matching code Willy Tarreau
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Dan Carpenter, Herbert Xu, Willy Tarreau

From: Dan Carpenter <dan.carpenter@oracle.com>

commit e514cc0a492a3f39ef71b31590a7ef67537ee04b upstream.

The props->ap[] array is defined like this:

	struct alg_props ap[NX_MAX_FC][NX_MAX_MODE][3];

So we can see that if msc->fc and msc->mode are == to NX_MAX_FC or
NX_MAX_MODE then we're off by one.

Fixes: ae0222b7289d ('powerpc/crypto: nx driver code supporting nx encryption')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/crypto/nx/nx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c
index bbdab6e..fe68964 100644
--- a/drivers/crypto/nx/nx.c
+++ b/drivers/crypto/nx/nx.c
@@ -309,7 +309,7 @@ static void nx_of_update_msc(struct device   *dev,
 		     ((bytes_so_far + sizeof(struct msc_triplet)) <= lenp) &&
 		     i < msc->triplets;
 		     i++) {
-			if (msc->fc > NX_MAX_FC || msc->mode > NX_MAX_MODE) {
+			if (msc->fc >= NX_MAX_FC || msc->mode >= NX_MAX_MODE) {
 				dev_err(dev, "unknown function code/mode "
 					"combo: %d/%d (ignored)\n", msc->fc,
 					msc->mode);
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 10/16] staging: comedi: daqboard2000: bug fix board type matching code
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (8 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 09/16] crypto: nx - off by one bug in nx_of_update_msc() Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 11/16] ACPI / sysfs: fix error code in get_status() Willy Tarreau
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Ian Abbott, stable, Greg Kroah-Hartman, Willy Tarreau

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

commit 80e162ee9b31d77d851b10f8c5299132be1e120f upstream.

`daqboard2000_find_boardinfo()` is supposed to check if the
DaqBoard/2000 series model is supported, based on the PCI subvendor and
subdevice ID.  The current code is wrong as it is comparing the PCI
device's subdevice ID to an expected, fixed value for the subvendor ID.
It should be comparing the PCI device's subvendor ID to this fixed
value.  Correct it.

Fixes: 7e8401b23e7f ("staging: comedi: daqboard2000: add back
subsystem_device check")
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 3.7+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/staging/comedi/drivers/daqboard2000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index b87f95c..1465a26 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -678,7 +678,7 @@ static const void *daqboard2000_find_boardinfo(struct comedi_device *dev,
 	const struct daq200_boardtype *board;
 	int i;
 
-	if (pcidev->subsystem_device != PCI_VENDOR_ID_IOTECH)
+	if (pcidev->subsystem_vendor != PCI_VENDOR_ID_IOTECH)
 		return NULL;
 
 	for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 11/16] ACPI / sysfs: fix error code in get_status()
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (9 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 10/16] staging: comedi: daqboard2000: bug fix board type matching code Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 12/16] mm: thp: fix SMP race condition between THP page fault and MADV_DONTNEED Willy Tarreau
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Dan Carpenter, Rafael J . Wysocki, Willy Tarreau

From: Dan Carpenter <dan.carpenter@oracle.com>

commit f18ebc211e259d4f591e39e74b2aa2de226c9a1d upstream.

The problem with ornamental, do-nothing gotos is that they lead to
"forgot to set the error code" bugs.  We should be returning -EINVAL
here but we don't.  It leads to an uninitalized variable in
counter_show():

    drivers/acpi/sysfs.c:603 counter_show()
    error: uninitialized symbol 'status'.

Fixes: 1c8fce27e275 (ACPI: introduce drivers/acpi/sysfs.c)
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/acpi/sysfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index fcae5fa..95b6371 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -492,23 +492,22 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device,
 static int get_status(u32 index, acpi_event_status *status,
 		      acpi_handle *handle)
 {
-	int result = 0;
+	int result;
 
 	if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
-		goto end;
+		return -EINVAL;
 
 	if (index < num_gpes) {
 		result = acpi_get_gpe_device(index, handle);
 		if (result) {
 			ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
 					"Invalid GPE 0x%x", index));
-			goto end;
+			return result;
 		}
 		result = acpi_get_gpe_status(*handle, index, status);
 	} else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
 		result = acpi_get_event_status(index - num_gpes, status);
 
-end:
 	return result;
 }
 
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 12/16] mm: thp: fix SMP race condition between THP page fault and MADV_DONTNEED
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (10 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 11/16] ACPI / sysfs: fix error code in get_status() Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 13/16] MIPS: KVM: Check for pfn noslot case Willy Tarreau
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Andrea Arcangeli, Andrew Morton, Linus Torvalds, Vlastimil Babka,
	Jiri Slaby, Greg Kroah-Hartman, Willy Tarreau

From: Andrea Arcangeli <aarcange@redhat.com>

commit ad33bb04b2a6cee6c1f99fabb15cddbf93ff0433 upstream.

pmd_trans_unstable()/pmd_none_or_trans_huge_or_clear_bad() were
introduced to locklessy (but atomically) detect when a pmd is a regular
(stable) pmd or when the pmd is unstable and can infinitely transition
from pmd_none() and pmd_trans_huge() from under us, while only holding
the mmap_sem for reading (for writing not).

While holding the mmap_sem only for reading, MADV_DONTNEED can run from
under us and so before we can assume the pmd to be a regular stable pmd
we need to compare it against pmd_none() and pmd_trans_huge() in an
atomic way, with pmd_trans_unstable().  The old pmd_trans_huge() left a
tiny window for a race.

Useful applications are unlikely to notice the difference as doing
MADV_DONTNEED concurrently with a page fault would lead to undefined
behavior.

[js] 3.12 backport: no pmd_devmap in 3.12 yet.

[akpm@linux-foundation.org: tidy up comment grammar/layout]
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Reported-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 mm/memory.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 30bf9cc..10cdade 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3834,8 +3834,18 @@ retry:
 	if (unlikely(pmd_none(*pmd)) &&
 	    unlikely(__pte_alloc(mm, vma, pmd, address)))
 		return VM_FAULT_OOM;
-	/* if an huge pmd materialized from under us just retry later */
-	if (unlikely(pmd_trans_huge(*pmd)))
+	/*
+	 * If a huge pmd materialized under us just retry later.  Use
+	 * pmd_trans_unstable() instead of pmd_trans_huge() to ensure the pmd
+	 * didn't become pmd_trans_huge under us and then back to pmd_none, as
+	 * a result of MADV_DONTNEED running immediately after a huge pmd fault
+	 * in a different thread of this mm, in turn leading to a misleading
+	 * pmd_trans_huge() retval.  All we have to ensure is that it is a
+	 * regular pmd that we can walk with pte_offset_map() and we can do that
+	 * through an atomic read in C, which is what pmd_trans_unstable()
+	 * provides.
+	 */
+	if (unlikely(pmd_trans_unstable(pmd)))
 		return 0;
 	/*
 	 * A regular pmd is established and it can't morph into a huge pmd
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 13/16] MIPS: KVM: Check for pfn noslot case
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (11 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 12/16] mm: thp: fix SMP race condition between THP page fault and MADV_DONTNEED Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 14/16] security: let security modules use PTRACE_MODE_* with bitmasks Willy Tarreau
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: James Hogan, Paolo Bonzini, Radim Krčmář,
	Ralf Baechle, linux-mips, kvm, Willy Tarreau

From: James Hogan <james.hogan@imgtec.com>

commit ba913e4f72fc9cfd03dad968dfb110eb49211d80 upstream.

When mapping a page into the guest we error check using is_error_pfn(),
however this doesn't detect a value of KVM_PFN_NOSLOT, indicating an
error HVA for the page. This can only happen on MIPS right now due to
unusual memslot management (e.g. being moved / removed / resized), or
with an Enhanced Virtual Memory (EVA) configuration where the default
KVM_HVA_ERR_* and kvm_is_error_hva() definitions are unsuitable (fixed
in a later patch). This case will be treated as a pfn of zero, mapping
the first page of physical memory into the guest.

It would appear the MIPS KVM port wasn't updated prior to being merged
(in v3.10) to take commit 81c52c56e2b4 ("KVM: do not treat noslot pfn as
a error pfn") into account (merged v3.8), which converted a bunch of
is_error_pfn() calls to is_error_noslot_pfn(). Switch to using
is_error_noslot_pfn() instead to catch this case properly.

Fixes: 858dd5d45733 ("KVM/MIPS32: MMU/TLB operations for the Guest.")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[james.hogan@imgtec.com: Backport to v3.16.y]
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 arch/mips/kvm/kvm_tlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kvm/kvm_tlb.c b/arch/mips/kvm/kvm_tlb.c
index 4bee439..8a47bd9 100644
--- a/arch/mips/kvm/kvm_tlb.c
+++ b/arch/mips/kvm/kvm_tlb.c
@@ -182,7 +182,7 @@ static int kvm_mips_map_page(struct kvm *kvm, gfn_t gfn)
         srcu_idx = srcu_read_lock(&kvm->srcu);
 	pfn = kvm_mips_gfn_to_pfn(kvm, gfn);
 
-	if (kvm_mips_is_error_pfn(pfn)) {
+	if (is_error_noslot_pfn(pfn)) {
 		kvm_err("Couldn't get pfn for gfn %#" PRIx64 "!\n", gfn);
 		err = -EFAULT;
 		goto out;
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 14/16] security: let security modules use PTRACE_MODE_* with bitmasks
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (12 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 13/16] MIPS: KVM: Check for pfn noslot case Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 15/16] xen-netback: ref count shared rings Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 16/16] mm: remove gup_flags FOLL_WRITE games from __get_user_pages() Willy Tarreau
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jann Horn, Oleg Nesterov, Ingo Molnar, James Morris,
	Serge E. Hallyn, Andy Shevchenko, Andy Lutomirski, Al Viro,
	Eric W. Biederman, Willy Tarreau, Andrew Morton, Linus Torvalds

From: Jann Horn <jann@thejh.net>

commit 3dfb7d8cdbc7ea0c2970450e60818bb3eefbad69 upstream.

It looks like smack and yama weren't aware that the ptrace mode
can have flags ORed into it - PTRACE_MODE_NOAUDIT until now, but
only for /proc/$pid/stat, and with the PTRACE_MODE_*CREDS patch,
all modes have flags ORed into them.

Signed-off-by: Jann Horn <jann@thejh.net>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: "Serge E. Hallyn" <serge.hallyn@ubuntu.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[wt: no smk_ptrace_mode() in 3.10]
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 security/yama/yama_lsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index 13c88fbc..0038834 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -292,7 +292,7 @@ int yama_ptrace_access_check(struct task_struct *child,
 		return rc;
 
 	/* require ptrace target be a child of ptracer on attach */
-	if (mode == PTRACE_MODE_ATTACH) {
+	if (mode & PTRACE_MODE_ATTACH) {
 		switch (ptrace_scope) {
 		case YAMA_SCOPE_DISABLED:
 			/* No additional restrictions. */
@@ -318,7 +318,7 @@ int yama_ptrace_access_check(struct task_struct *child,
 		}
 	}
 
-	if (rc) {
+	if (rc && (mode & PTRACE_MODE_NOAUDIT) == 0) {
 		printk_ratelimited(KERN_NOTICE
 			"ptrace of pid %d was attempted by: %s (pid %d)\n",
 			child->pid, current->comm, current->pid);
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 15/16] xen-netback: ref count shared rings
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (13 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 14/16] security: let security modules use PTRACE_MODE_* with bitmasks Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  2016-10-19 22:49 ` [PATCH 3.10 16/16] mm: remove gup_flags FOLL_WRITE games from __get_user_pages() Willy Tarreau
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Wei Liu, Philipp Hahn, David Vrabel, Willy Tarreau

From: Wei Liu <wei.liu2@citrix.com>

... so that we can make sure the rings are not freed until all SKBs in
internal queues are consumed.

1. The VM is receiving packets through bonding + bridge + netback +
   netfront.
2. For some unknown reason at least one packet remains in the rx queue
   and is not delivered to the domU immediately by netback.
3. The VM finishes shutting down.
4. The shared ring between dom0 and domU is freed.
5. then xen-netback continues processing the pending requests and tries
   to put the packet into the now already released shared ring.

> XXXlan0: port 9(vif26.0) entered disabled state
> BUG: unable to handle kernel paging request at ffffc900108641d8
> IP: [<ffffffffa04147dc>] xen_netbk_rx_action+0x18b/0x6f0 [xen_netback]
> PGD 57e20067 PUD 57e21067 PMD 571a7067 PTE 0
> Oops: 0000 [#1] SMP
> ...
> CPU: 0 PID: 12587 Comm: netback/0 Not tainted 3.10.0-ucs58-amd64 #1 Debian 3.10.11-1.58.201405060908
> Hardware name: FUJITSU PRIMERGY BX620 S6/D3051, BIOS 080015 Rev.3C78.3051 07/22/2011
> task: ffff880004b067c0 ti: ffff8800561ec000 task.ti: ffff8800561ec000
> RIP: e030:[<ffffffffa04147dc>]  [<ffffffffa04147dc>] xen_netbk_rx_action+0x18b/0x6f0 [xen_netback]
> RSP: e02b:ffff8800561edce8  EFLAGS: 00010202
> RAX: ffffc900104adac0 RBX: ffff8800541e95c0 RCX: ffffc90010864000
> RDX: 000000000000003b RSI: 0000000000000000 RDI: ffff880040014380
> RBP: ffff8800570e6800 R08: 0000000000000000 R09: ffff880004799800
> R10: ffffffff813ca115 R11: ffff88005e4fdb08 R12: ffff880054e6f800
> R13: ffff8800561edd58 R14: ffffc900104a1000 R15: 0000000000000000
> FS:  00007f19a54a8700(0000) GS:ffff88005da00000(0000) knlGS:0000000000000000
> CS:  e033 DS: 0000 ES: 0000 CR0: 000000008005003b
> CR2: ffffc900108641d8 CR3: 0000000054cb3000 CR4: 0000000000002660
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
> Stack:
>  ffff880004b06ba0 0000000000000000 ffff88005da13ec0 ffff88005da13ec0
>  0000000004b067c0 ffffc900104a8ac0 ffffc900104a1020 000000005da13ec0
>  0000000000000000 0000000000000001 ffffc900104a8ac0 ffffc900104adac0
> Call Trace:
>  [<ffffffff813ca32d>] ? _raw_spin_lock_irqsave+0x11/0x2f
>  [<ffffffffa0416033>] ? xen_netbk_kthread+0x174/0x841 [xen_netback]
>  [<ffffffff8105d373>] ? wake_up_bit+0x20/0x20
>  [<ffffffffa0415ebf>] ? xen_netbk_tx_build_gops+0xce8/0xce8 [xen_netback]
>  [<ffffffff8105cd73>] ? kthread_freezable_should_stop+0x56/0x56
>  [<ffffffffa0415ebf>] ? xen_netbk_tx_build_gops+0xce8/0xce8 [xen_netback]
>  [<ffffffff8105ce1e>] ? kthread+0xab/0xb3
>  [<ffffffff81003638>] ? xen_end_context_switch+0xe/0x1c
>  [<ffffffff8105cd73>] ? kthread_freezable_should_stop+0x56/0x56
>  [<ffffffff813cfbfc>] ? ret_from_fork+0x7c/0xb0
>  [<ffffffff8105cd73>] ? kthread_freezable_should_stop+0x56/0x56
> Code: 8b b3 d0 00 00 00 48 8b bb d8 00 00 00 0f b7 74 37 02 89 70 08 eb 07 c7 40 08 00 00 00 00 89 d2 c7 40 04 00 00 00 00 48 83 c2 08 <0f> b7 34 d1 89 30 c7 44 24 60 00 00 00 00 8b 44 d1 04 89 44 24
> RIP  [<ffffffffa04147dc>] xen_netbk_rx_action+0x18b/0x6f0 [xen_netback]
>  RSP <ffff8800561edce8>
> CR2: ffffc900108641d8

Track the shared ring buffer being unmapped and drop those packets.

Ref-count the rings as followed:
  map         -> set to 1
   start_xmit -> inc when queueing SKB to internal queue
   rx_action  -> dec after finishing processing a SKB
  unmap       -> dec and wait to be 0

Note that this is different from ref counting the vif structure itself.
Currently only guest Rx path is taken care of because that's where the
bug surfaced.

This bug doesn't exist in kernel >=3.12 as multi-queue support was added
there.

Link: <https://lists.xenproject.org/archives/html/xen-devel/2014-06/msg00818.html>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Philipp Hahn <hahn@univention.de>
Cc: David Vrabel <david.vrabel@citrix.com>
Tested-by: Philipp Hahn <hahn@univention.de>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/net/xen-netback/common.h    |  4 ++++
 drivers/net/xen-netback/interface.c | 17 +++++++++++++++--
 drivers/net/xen-netback/netback.c   |  6 ++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index f2faa77..dd6b7c3 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -66,6 +66,8 @@ struct xenvif {
 	/* The shared rings and indexes. */
 	struct xen_netif_tx_back_ring tx;
 	struct xen_netif_rx_back_ring rx;
+	atomic_t ring_refcnt;
+	wait_queue_head_t waiting_to_unmap;
 
 	/* Frontend feature information. */
 	u8 can_sg:1;
@@ -120,6 +122,8 @@ void xenvif_free(struct xenvif *vif);
 
 void xenvif_get(struct xenvif *vif);
 void xenvif_put(struct xenvif *vif);
+void xenvif_get_rings(struct xenvif *vif);
+void xenvif_put_rings(struct xenvif *vif);
 
 int xenvif_xenbus_init(void);
 
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 540a796..7e3817a 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -44,12 +44,23 @@ void xenvif_get(struct xenvif *vif)
 	atomic_inc(&vif->refcnt);
 }
 
+void xenvif_get_rings(struct xenvif *vif)
+{
+	atomic_inc(&vif->ring_refcnt);
+}
+
 void xenvif_put(struct xenvif *vif)
 {
 	if (atomic_dec_and_test(&vif->refcnt))
 		wake_up(&vif->waiting_to_free);
 }
 
+void xenvif_put_rings(struct xenvif *vif)
+{
+	if (atomic_dec_and_test(&vif->ring_refcnt))
+		wake_up(&vif->waiting_to_unmap);
+}
+
 int xenvif_schedulable(struct xenvif *vif)
 {
 	return netif_running(vif->dev) && netif_carrier_ok(vif->dev);
@@ -91,6 +102,7 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	/* Reserve ring slots for the worst-case number of fragments. */
 	vif->rx_req_cons_peek += xen_netbk_count_skb_slots(vif, skb);
 	xenvif_get(vif);
+	xenvif_get_rings(vif);
 
 	if (vif->can_queue && xen_netbk_must_stop_queue(vif))
 		netif_stop_queue(dev);
@@ -271,6 +283,7 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
 	vif->dev = dev;
 	INIT_LIST_HEAD(&vif->schedule_list);
 	INIT_LIST_HEAD(&vif->notify_list);
+	init_waitqueue_head(&vif->waiting_to_unmap);
 
 	vif->credit_bytes = vif->remaining_credit = ~0UL;
 	vif->credit_usec  = 0UL;
@@ -365,12 +378,12 @@ void xenvif_disconnect(struct xenvif *vif)
 	if (netif_carrier_ok(vif->dev))
 		xenvif_carrier_off(vif);
 
+	disable_irq(vif->irq);
+	xen_netbk_unmap_frontend_rings(vif);
 	if (vif->irq) {
 		unbind_from_irqhandler(vif->irq, vif);
 		vif->irq = 0;
 	}
-
-	xen_netbk_unmap_frontend_rings(vif);
 }
 
 void xenvif_free(struct xenvif *vif)
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 70b830f..1595f81 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -814,6 +814,7 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
 			xenvif_put(vif);
 		npo.meta_cons += sco->meta_slots_used;
 		dev_kfree_skb(skb);
+		xenvif_put_rings(vif);
 	}
 
 	list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
@@ -1864,6 +1865,9 @@ static int xen_netbk_kthread(void *data)
 
 void xen_netbk_unmap_frontend_rings(struct xenvif *vif)
 {
+	atomic_dec(&vif->ring_refcnt);
+	wait_event(vif->waiting_to_unmap, atomic_read(&vif->ring_refcnt) == 0);
+
 	if (vif->tx.sring)
 		xenbus_unmap_ring_vfree(xenvif_to_xenbus_device(vif),
 					vif->tx.sring);
@@ -1882,6 +1886,8 @@ int xen_netbk_map_frontend_rings(struct xenvif *vif,
 
 	int err = -ENOMEM;
 
+	atomic_set(&vif->ring_refcnt, 1);
+
 	err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
 				     tx_ring_ref, &addr);
 	if (err)
-- 
2.8.0.rc2.1.gbe9624a

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

* [PATCH 3.10 16/16] mm: remove gup_flags FOLL_WRITE games from __get_user_pages()
  2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
                   ` (14 preceding siblings ...)
  2016-10-19 22:49 ` [PATCH 3.10 15/16] xen-netback: ref count shared rings Willy Tarreau
@ 2016-10-19 22:49 ` Willy Tarreau
  15 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-19 22:49 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Linus Torvalds, Andy Lutomirski, Kees Cook, Oleg Nesterov,
	Willy Tarreau, Nick Piggin, Greg Thelen

From: Linus Torvalds <torvalds@linux-foundation.org>

commit 19be0eaffa3ac7d8eb6784ad9bdbc7d67ed8e619 upstream.

This is an ancient bug that was actually attempted to be fixed once
(badly) by me eleven years ago in commit 4ceb5db9757a ("Fix
get_user_pages() race for write access") but that was then undone due to
problems on s390 by commit f33ea7f404e5 ("fix get_user_pages bug").

In the meantime, the s390 situation has long been fixed, and we can now
fix it by checking the pte_dirty() bit properly (and do it better).  The
s390 dirty bit was implemented in abf09bed3cce ("s390/mm: implement
software dirty bits") which made it into v3.9.  Earlier kernels will
have to look at the page state itself.

Also, the VM has become more scalable, and what used a purely
theoretical race back then has become easier to trigger.

To fix it, we introduce a new internal FOLL_COW flag to mark the "yes,
we already did a COW" rather than play racy games with FOLL_WRITE that
is very fundamental, and then use the pte dirty flag to validate that
the FOLL_COW flag is still valid.

Reported-and-tested-by: Phil "not Paul" Oester <kernel@linuxace.com>
Acked-by: Hugh Dickins <hughd@google.com>
Reviewed-by: Michal Hocko <mhocko@suse.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Nick Piggin <npiggin@gmail.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[wt: s/gup.c/memory.c; s/follow_page_pte/follow_page_mask;
     s/faultin_page/__get_user_page]
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 include/linux/mm.h |  1 +
 mm/memory.c        | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 53b0d70..55590f4 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1715,6 +1715,7 @@ static inline struct page *follow_page(struct vm_area_struct *vma,
 #define FOLL_HWPOISON	0x100	/* check page is hwpoisoned */
 #define FOLL_NUMA	0x200	/* force NUMA hinting page fault */
 #define FOLL_MIGRATION	0x400	/* wait for page to replace migration entry */
+#define FOLL_COW	0x4000	/* internal GUP flag */
 
 typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr,
 			void *data);
diff --git a/mm/memory.c b/mm/memory.c
index 10cdade..2ca2ee1 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1462,6 +1462,16 @@ int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
 }
 EXPORT_SYMBOL_GPL(zap_vma_ptes);
 
+/*
+ * FOLL_FORCE can write to even unwritable pte's, but only
+ * after we've gone through a COW cycle and they are dirty.
+ */
+static inline bool can_follow_write_pte(pte_t pte, unsigned int flags)
+{
+	return pte_write(pte) ||
+		((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte));
+}
+
 /**
  * follow_page_mask - look up a page descriptor from a user-virtual address
  * @vma: vm_area_struct mapping @address
@@ -1569,7 +1579,7 @@ split_fallthrough:
 	}
 	if ((flags & FOLL_NUMA) && pte_numa(pte))
 		goto no_page;
-	if ((flags & FOLL_WRITE) && !pte_write(pte))
+	if ((flags & FOLL_WRITE) && !can_follow_write_pte(pte, flags))
 		goto unlock;
 
 	page = vm_normal_page(vma, address, pte);
@@ -1877,7 +1887,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 				 */
 				if ((ret & VM_FAULT_WRITE) &&
 				    !(vma->vm_flags & VM_WRITE))
-					foll_flags &= ~FOLL_WRITE;
+					foll_flags |= FOLL_COW;
 
 				cond_resched();
 			}
-- 
2.8.0.rc2.1.gbe9624a

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

* Re: [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls"
  2016-10-19 22:49 ` [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls" Willy Tarreau
@ 2016-10-20  3:07   ` Guenter Roeck
  2016-10-20  6:12     ` Willy Tarreau
  0 siblings, 1 reply; 19+ messages in thread
From: Guenter Roeck @ 2016-10-20  3:07 UTC (permalink / raw)
  To: Willy Tarreau, linux-kernel, stable

On 10/19/2016 03:49 PM, Willy Tarreau wrote:
> This reverts commit 8110080dc53335d5dd99b123144a6174f19ffc65.
>
> Guenter noticed that this breaks PPC build when CONFIG_PPC_TRANSACTIONAL_MEM
> is set, because this patch was not for 3.10.
>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Willy Tarreau <w@1wt.eu>

I wasn't copied on patch 00/16, so I'll post the test results here:

Build results:
	total: 124 pass: 124 fail: 0
Qemu test results:
	total: 75 pass: 75 fail: 0

Details are available at http://kerneltests.org/builders.

Guenter

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

* Re: [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls"
  2016-10-20  3:07   ` Guenter Roeck
@ 2016-10-20  6:12     ` Willy Tarreau
  0 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2016-10-20  6:12 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-kernel, stable

On Wed, Oct 19, 2016 at 08:07:23PM -0700, Guenter Roeck wrote:
> On 10/19/2016 03:49 PM, Willy Tarreau wrote:
> > This reverts commit 8110080dc53335d5dd99b123144a6174f19ffc65.
> > 
> > Guenter noticed that this breaks PPC build when CONFIG_PPC_TRANSACTIONAL_MEM
> > is set, because this patch was not for 3.10.
> > 
> > Cc: Guenter Roeck <linux@roeck-us.net>
> > Signed-off-by: Willy Tarreau <w@1wt.eu>
> 
> I wasn't copied on patch 00/16,

Ah sorry for this Guenter, I've now updated my build script.

> so I'll post the test results here:
> 
> Build results:
> 	total: 124 pass: 124 fail: 0
> Qemu test results:
> 	total: 75 pass: 75 fail: 0

Marvellous, thank you!

Willy

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

end of thread, other threads:[~2016-10-20  6:12 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-19 22:49 [PATCH 3.10 00/16] 3.10.104-stable review Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 01/16] Revert "powerpc/tm: Always reclaim in start_thread() for exec() class syscalls" Willy Tarreau
2016-10-20  3:07   ` Guenter Roeck
2016-10-20  6:12     ` Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 02/16] PCI: Support PCIe devices with short cfg_size Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 03/16] PCI: Add Netronome vendor and device IDs Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 04/16] PCI: Limit config space size for Netronome NFP6000 family Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 05/16] PCI: Add Netronome NFP4000 PF device ID Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 06/16] PCI: Limit config space size for Netronome NFP4000 Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 07/16] aacraid: Check size values after double-fetch from user Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 08/16] megaraid_sas: Fix probing cards without io port Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 09/16] crypto: nx - off by one bug in nx_of_update_msc() Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 10/16] staging: comedi: daqboard2000: bug fix board type matching code Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 11/16] ACPI / sysfs: fix error code in get_status() Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 12/16] mm: thp: fix SMP race condition between THP page fault and MADV_DONTNEED Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 13/16] MIPS: KVM: Check for pfn noslot case Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 14/16] security: let security modules use PTRACE_MODE_* with bitmasks Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 15/16] xen-netback: ref count shared rings Willy Tarreau
2016-10-19 22:49 ` [PATCH 3.10 16/16] mm: remove gup_flags FOLL_WRITE games from __get_user_pages() Willy Tarreau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.