]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Dec 2018 12:00:00 +0000 (13:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Dec 2018 12:00:00 +0000 (13:00 +0100)
added patches:
drivers-hv-vmbus-return-einval-for-the-sys-files-for-unopened-channels.patch
gpio-max7301-fix-driver-for-use-with-config_vmap_stack.patch
mmc-core-allow-bkops-and-cache-ctrl-even-if-no-hpi-support.patch
mmc-core-reset-hpi-enabled-state-during-re-init-and-in-case-of-errors.patch
mmc-core-use-a-minimum-1600ms-timeout-when-enabling-cache-ctrl.patch
mmc-omap_hsmmc-fix-dma-api-warning.patch
x86-fpu-disable-bottom-halves-while-loading-fpu-registers.patch
x86-mtrr-don-t-copy-uninitialized-gentry-fields-back-to-userspace.patch

queue-4.9/drivers-hv-vmbus-return-einval-for-the-sys-files-for-unopened-channels.patch [new file with mode: 0644]
queue-4.9/gpio-max7301-fix-driver-for-use-with-config_vmap_stack.patch [new file with mode: 0644]
queue-4.9/mmc-core-allow-bkops-and-cache-ctrl-even-if-no-hpi-support.patch [new file with mode: 0644]
queue-4.9/mmc-core-reset-hpi-enabled-state-during-re-init-and-in-case-of-errors.patch [new file with mode: 0644]
queue-4.9/mmc-core-use-a-minimum-1600ms-timeout-when-enabling-cache-ctrl.patch [new file with mode: 0644]
queue-4.9/mmc-omap_hsmmc-fix-dma-api-warning.patch [new file with mode: 0644]
queue-4.9/series
queue-4.9/x86-fpu-disable-bottom-halves-while-loading-fpu-registers.patch [new file with mode: 0644]
queue-4.9/x86-mtrr-don-t-copy-uninitialized-gentry-fields-back-to-userspace.patch [new file with mode: 0644]

diff --git a/queue-4.9/drivers-hv-vmbus-return-einval-for-the-sys-files-for-unopened-channels.patch b/queue-4.9/drivers-hv-vmbus-return-einval-for-the-sys-files-for-unopened-channels.patch
new file mode 100644 (file)
index 0000000..464a0ce
--- /dev/null
@@ -0,0 +1,119 @@
+From fc96df16a1ce80cbb3c316ab7d4dc8cd5c2852ce Mon Sep 17 00:00:00 2001
+From: Dexuan Cui <decui@microsoft.com>
+Date: Thu, 13 Dec 2018 16:35:43 +0000
+Subject: Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
+
+From: Dexuan Cui <decui@microsoft.com>
+
+commit fc96df16a1ce80cbb3c316ab7d4dc8cd5c2852ce upstream.
+
+Before 98f4c651762c, we returned zeros for unopened channels.
+With 98f4c651762c, we started to return random on-stack values.
+
+We'd better return -EINVAL instead.
+
+Fixes: 98f4c651762c ("hv: move ringbuffer bus attributes to dev_groups")
+Cc: stable@vger.kernel.org
+Cc: K. Y. Srinivasan <kys@microsoft.com>
+Cc: Haiyang Zhang <haiyangz@microsoft.com>
+Cc: Stephen Hemminger <sthemmin@microsoft.com>
+Signed-off-by: Dexuan Cui <decui@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/hv/vmbus_drv.c |   20 ++++++++++++++++++++
+ 1 file changed, 20 insertions(+)
+
+--- a/drivers/hv/vmbus_drv.c
++++ b/drivers/hv/vmbus_drv.c
+@@ -317,6 +317,8 @@ static ssize_t out_intr_mask_show(struct
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+       return sprintf(buf, "%d\n", outbound.current_interrupt_mask);
+ }
+@@ -330,6 +332,8 @@ static ssize_t out_read_index_show(struc
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+       return sprintf(buf, "%d\n", outbound.current_read_index);
+ }
+@@ -344,6 +348,8 @@ static ssize_t out_write_index_show(stru
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+       return sprintf(buf, "%d\n", outbound.current_write_index);
+ }
+@@ -358,6 +364,8 @@ static ssize_t out_read_bytes_avail_show
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+       return sprintf(buf, "%d\n", outbound.bytes_avail_toread);
+ }
+@@ -372,6 +380,8 @@ static ssize_t out_write_bytes_avail_sho
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+       return sprintf(buf, "%d\n", outbound.bytes_avail_towrite);
+ }
+@@ -385,6 +395,8 @@ static ssize_t in_intr_mask_show(struct
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+       return sprintf(buf, "%d\n", inbound.current_interrupt_mask);
+ }
+@@ -398,6 +410,8 @@ static ssize_t in_read_index_show(struct
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+       return sprintf(buf, "%d\n", inbound.current_read_index);
+ }
+@@ -411,6 +425,8 @@ static ssize_t in_write_index_show(struc
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+       return sprintf(buf, "%d\n", inbound.current_write_index);
+ }
+@@ -425,6 +441,8 @@ static ssize_t in_read_bytes_avail_show(
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+       return sprintf(buf, "%d\n", inbound.bytes_avail_toread);
+ }
+@@ -439,6 +457,8 @@ static ssize_t in_write_bytes_avail_show
+       if (!hv_dev->channel)
+               return -ENODEV;
++      if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
++              return -EINVAL;
+       hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+       return sprintf(buf, "%d\n", inbound.bytes_avail_towrite);
+ }
diff --git a/queue-4.9/gpio-max7301-fix-driver-for-use-with-config_vmap_stack.patch b/queue-4.9/gpio-max7301-fix-driver-for-use-with-config_vmap_stack.patch
new file mode 100644 (file)
index 0000000..d859a75
--- /dev/null
@@ -0,0 +1,54 @@
+From abf221d2f51b8ce7b9959a8953f880a8b0a1400d Mon Sep 17 00:00:00 2001
+From: Christophe Leroy <christophe.leroy@c-s.fr>
+Date: Fri, 7 Dec 2018 13:07:55 +0000
+Subject: gpio: max7301: fix driver for use with CONFIG_VMAP_STACK
+
+From: Christophe Leroy <christophe.leroy@c-s.fr>
+
+commit abf221d2f51b8ce7b9959a8953f880a8b0a1400d upstream.
+
+spi_read() and spi_write() require DMA-safe memory. When
+CONFIG_VMAP_STACK is selected, those functions cannot be used
+with buffers on stack.
+
+This patch replaces calls to spi_read() and spi_write() by
+spi_write_then_read() which doesn't require DMA-safe buffers.
+
+Fixes: 0c36ec314735 ("gpio: gpio driver for max7301 SPI GPIO expander")
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpio/gpio-max7301.c |   12 +++---------
+ 1 file changed, 3 insertions(+), 9 deletions(-)
+
+--- a/drivers/gpio/gpio-max7301.c
++++ b/drivers/gpio/gpio-max7301.c
+@@ -25,7 +25,7 @@ static int max7301_spi_write(struct devi
+       struct spi_device *spi = to_spi_device(dev);
+       u16 word = ((reg & 0x7F) << 8) | (val & 0xFF);
+-      return spi_write(spi, (const u8 *)&word, sizeof(word));
++      return spi_write_then_read(spi, &word, sizeof(word), NULL, 0);
+ }
+ /* A read from the MAX7301 means two transfers; here, one message each */
+@@ -37,14 +37,8 @@ static int max7301_spi_read(struct devic
+       struct spi_device *spi = to_spi_device(dev);
+       word = 0x8000 | (reg << 8);
+-      ret = spi_write(spi, (const u8 *)&word, sizeof(word));
+-      if (ret)
+-              return ret;
+-      /*
+-       * This relies on the fact, that a transfer with NULL tx_buf shifts out
+-       * zero bytes (=NOOP for MAX7301)
+-       */
+-      ret = spi_read(spi, (u8 *)&word, sizeof(word));
++      ret = spi_write_then_read(spi, &word, sizeof(word), &word,
++                                sizeof(word));
+       if (ret)
+               return ret;
+       return word & 0xff;
diff --git a/queue-4.9/mmc-core-allow-bkops-and-cache-ctrl-even-if-no-hpi-support.patch b/queue-4.9/mmc-core-allow-bkops-and-cache-ctrl-even-if-no-hpi-support.patch
new file mode 100644 (file)
index 0000000..7372133
--- /dev/null
@@ -0,0 +1,47 @@
+From ba9f39a785a9977e72233000711ef1eb48203551 Mon Sep 17 00:00:00 2001
+From: Ulf Hansson <ulf.hansson@linaro.org>
+Date: Mon, 10 Dec 2018 17:52:37 +0100
+Subject: mmc: core: Allow BKOPS and CACHE ctrl even if no HPI support
+
+From: Ulf Hansson <ulf.hansson@linaro.org>
+
+commit ba9f39a785a9977e72233000711ef1eb48203551 upstream.
+
+In commit 5320226a0512 ("mmc: core: Disable HPI for certain Hynix eMMC
+cards"), then intent was to prevent HPI from being used for some eMMC
+cards, which didn't properly support it. However, that went too far, as
+even BKOPS and CACHE ctrl became prevented. Let's restore those parts and
+allow BKOPS and CACHE ctrl even if HPI isn't supported.
+
+Fixes: 5320226a0512 ("mmc: core: Disable HPI for certain Hynix eMMC cards")
+Cc: Pratibhasagar V <pratibha@codeaurora.org>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mmc/core/mmc.c |    6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+--- a/drivers/mmc/core/mmc.c
++++ b/drivers/mmc/core/mmc.c
+@@ -522,8 +522,7 @@ static int mmc_decode_ext_csd(struct mmc
+                       card->cid.year += 16;
+               /* check whether the eMMC card supports BKOPS */
+-              if (!mmc_card_broken_hpi(card) &&
+-                  ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) {
++              if (ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) {
+                       card->ext_csd.bkops = 1;
+                       card->ext_csd.man_bkops_en =
+                                       (ext_csd[EXT_CSD_BKOPS_EN] &
+@@ -1730,8 +1729,7 @@ static int mmc_init_card(struct mmc_host
+        * If cache size is higher than 0, this indicates
+        * the existence of cache and it can be turned on.
+        */
+-      if (!mmc_card_broken_hpi(card) &&
+-          card->ext_csd.cache_size > 0) {
++      if (card->ext_csd.cache_size > 0) {
+               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+                               EXT_CSD_CACHE_CTRL, 1,
+                               card->ext_csd.generic_cmd6_time);
diff --git a/queue-4.9/mmc-core-reset-hpi-enabled-state-during-re-init-and-in-case-of-errors.patch b/queue-4.9/mmc-core-reset-hpi-enabled-state-during-re-init-and-in-case-of-errors.patch
new file mode 100644 (file)
index 0000000..a693bd1
--- /dev/null
@@ -0,0 +1,38 @@
+From a0741ba40a009f97c019ae7541dc61c1fdf41efb Mon Sep 17 00:00:00 2001
+From: Ulf Hansson <ulf.hansson@linaro.org>
+Date: Mon, 10 Dec 2018 17:52:36 +0100
+Subject: mmc: core: Reset HPI enabled state during re-init and in case of errors
+
+From: Ulf Hansson <ulf.hansson@linaro.org>
+
+commit a0741ba40a009f97c019ae7541dc61c1fdf41efb upstream.
+
+During a re-initialization of the eMMC card, we may fail to re-enable HPI.
+In these cases, that isn't properly reflected in the card->ext_csd.hpi_en
+bit, as it keeps being set. This may cause following attempts to use HPI,
+even if's not enabled. Let's fix this!
+
+Fixes: eb0d8f135b67 ("mmc: core: support HPI send command")
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mmc/core/mmc.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/mmc/core/mmc.c
++++ b/drivers/mmc/core/mmc.c
+@@ -1719,9 +1719,11 @@ static int mmc_init_card(struct mmc_host
+               if (err) {
+                       pr_warn("%s: Enabling HPI failed\n",
+                               mmc_hostname(card->host));
++                      card->ext_csd.hpi_en = 0;
+                       err = 0;
+-              } else
++              } else {
+                       card->ext_csd.hpi_en = 1;
++              }
+       }
+       /*
diff --git a/queue-4.9/mmc-core-use-a-minimum-1600ms-timeout-when-enabling-cache-ctrl.patch b/queue-4.9/mmc-core-use-a-minimum-1600ms-timeout-when-enabling-cache-ctrl.patch
new file mode 100644 (file)
index 0000000..4b9e377
--- /dev/null
@@ -0,0 +1,64 @@
+From e3ae3401aa19432ee4943eb0bbc2ec704d07d793 Mon Sep 17 00:00:00 2001
+From: Ulf Hansson <ulf.hansson@linaro.org>
+Date: Mon, 10 Dec 2018 17:52:38 +0100
+Subject: mmc: core: Use a minimum 1600ms timeout when enabling CACHE ctrl
+
+From: Ulf Hansson <ulf.hansson@linaro.org>
+
+commit e3ae3401aa19432ee4943eb0bbc2ec704d07d793 upstream.
+
+Some eMMCs from Micron have been reported to need ~800 ms timeout, while
+enabling the CACHE ctrl after running sudden power failure tests. The
+needed timeout is greater than what the card specifies as its generic CMD6
+timeout, through the EXT_CSD register, hence the problem.
+
+Normally we would introduce a card quirk to extend the timeout for these
+specific Micron cards. However, due to the rather complicated debug process
+needed to find out the error, let's simply use a minimum timeout of 1600ms,
+the double of what has been reported, for all cards when enabling CACHE
+ctrl.
+
+Reported-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
+Reported-by: Andreas Dannenberg <dannenberg@ti.com>
+Reported-by: Faiz Abbas <faiz_abbas@ti.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mmc/core/mmc.c |   14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+--- a/drivers/mmc/core/mmc.c
++++ b/drivers/mmc/core/mmc.c
+@@ -27,6 +27,7 @@
+ #include "sd_ops.h"
+ #define DEFAULT_CMD6_TIMEOUT_MS       500
++#define MIN_CACHE_EN_TIMEOUT_MS 1600
+ static const unsigned int tran_exp[] = {
+       10000,          100000,         1000000,        10000000,
+@@ -1726,13 +1727,18 @@ static int mmc_init_card(struct mmc_host
+       }
+       /*
+-       * If cache size is higher than 0, this indicates
+-       * the existence of cache and it can be turned on.
++       * If cache size is higher than 0, this indicates the existence of cache
++       * and it can be turned on. Note that some eMMCs from Micron has been
++       * reported to need ~800 ms timeout, while enabling the cache after
++       * sudden power failure tests. Let's extend the timeout to a minimum of
++       * DEFAULT_CACHE_EN_TIMEOUT_MS and do it for all cards.
+        */
+       if (card->ext_csd.cache_size > 0) {
++              unsigned int timeout_ms = MIN_CACHE_EN_TIMEOUT_MS;
++
++              timeout_ms = max(card->ext_csd.generic_cmd6_time, timeout_ms);
+               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+-                              EXT_CSD_CACHE_CTRL, 1,
+-                              card->ext_csd.generic_cmd6_time);
++                              EXT_CSD_CACHE_CTRL, 1, timeout_ms);
+               if (err && err != -EBADMSG)
+                       goto free_card;
diff --git a/queue-4.9/mmc-omap_hsmmc-fix-dma-api-warning.patch b/queue-4.9/mmc-omap_hsmmc-fix-dma-api-warning.patch
new file mode 100644 (file)
index 0000000..705de17
--- /dev/null
@@ -0,0 +1,66 @@
+From 0b479790684192ab7024ce6a621f93f6d0a64d92 Mon Sep 17 00:00:00 2001
+From: Russell King <rmk+kernel@armlinux.org.uk>
+Date: Tue, 11 Dec 2018 14:41:31 +0000
+Subject: mmc: omap_hsmmc: fix DMA API warning
+
+From: Russell King <rmk+kernel@armlinux.org.uk>
+
+commit 0b479790684192ab7024ce6a621f93f6d0a64d92 upstream.
+
+While booting with rootfs on MMC, the following warning is encountered
+on OMAP4430:
+
+omap-dma-engine 4a056000.dma-controller: DMA-API: mapping sg segment longer than device claims to support [len=69632] [max=65536]
+
+This is because the DMA engine has a default maximum segment size of 64K
+but HSMMC sets:
+
+        mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
+        mmc->max_blk_count = 0xFFFF;    /* No. of Blocks is 16 bits */
+        mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
+        mmc->max_seg_size = mmc->max_req_size;
+
+which ends up telling the block layer that we support a maximum segment
+size of 65535*512, which exceeds the advertised DMA engine capabilities.
+
+Fix this by clamping the maximum segment size to the lower of the
+maximum request size and of the DMA engine device used for either DMA
+channel.
+
+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mmc/host/omap_hsmmc.c |   12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+--- a/drivers/mmc/host/omap_hsmmc.c
++++ b/drivers/mmc/host/omap_hsmmc.c
+@@ -2105,7 +2105,6 @@ static int omap_hsmmc_probe(struct platf
+       mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
+       mmc->max_blk_count = 0xFFFF;    /* No. of Blocks is 16 bits */
+       mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
+-      mmc->max_seg_size = mmc->max_req_size;
+       mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
+                    MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE;
+@@ -2135,6 +2134,17 @@ static int omap_hsmmc_probe(struct platf
+               goto err_irq;
+       }
++      /*
++       * Limit the maximum segment size to the lower of the request size
++       * and the DMA engine device segment size limits.  In reality, with
++       * 32-bit transfers, the DMA engine can do longer segments than this
++       * but there is no way to represent that in the DMA model - if we
++       * increase this figure here, we get warnings from the DMA API debug.
++       */
++      mmc->max_seg_size = min3(mmc->max_req_size,
++                      dma_get_max_seg_size(host->rx_chan->device->dev),
++                      dma_get_max_seg_size(host->tx_chan->device->dev));
++
+       /* Request IRQ for MMC operations */
+       ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
+                       mmc_hostname(mmc), host);
index 8aa95da6448419f7eaf5b8df9ef796b44dcf5eee..3e41b23c85b39e3786eab72ed2653e458688fbe2 100644 (file)
@@ -8,3 +8,11 @@ usb-serial-option-add-hp-lt4132.patch
 usb-serial-option-add-simcom-sim7500-sim7600-mbim-mode.patch
 usb-serial-option-add-fibocom-nl668-series.patch
 usb-serial-option-add-telit-ln940-series.patch
+mmc-core-reset-hpi-enabled-state-during-re-init-and-in-case-of-errors.patch
+mmc-core-allow-bkops-and-cache-ctrl-even-if-no-hpi-support.patch
+mmc-core-use-a-minimum-1600ms-timeout-when-enabling-cache-ctrl.patch
+mmc-omap_hsmmc-fix-dma-api-warning.patch
+gpio-max7301-fix-driver-for-use-with-config_vmap_stack.patch
+drivers-hv-vmbus-return-einval-for-the-sys-files-for-unopened-channels.patch
+x86-mtrr-don-t-copy-uninitialized-gentry-fields-back-to-userspace.patch
+x86-fpu-disable-bottom-halves-while-loading-fpu-registers.patch
diff --git a/queue-4.9/x86-fpu-disable-bottom-halves-while-loading-fpu-registers.patch b/queue-4.9/x86-fpu-disable-bottom-halves-while-loading-fpu-registers.patch
new file mode 100644 (file)
index 0000000..258eff3
--- /dev/null
@@ -0,0 +1,84 @@
+From 68239654acafe6aad5a3c1dc7237e60accfebc03 Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Tue, 20 Nov 2018 11:26:35 +0100
+Subject: x86/fpu: Disable bottom halves while loading FPU registers
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+commit 68239654acafe6aad5a3c1dc7237e60accfebc03 upstream.
+
+The sequence
+
+  fpu->initialized = 1;                /* step A */
+  preempt_disable();           /* step B */
+  fpu__restore(fpu);
+  preempt_enable();
+
+in __fpu__restore_sig() is racy in regard to a context switch.
+
+For 32bit frames, __fpu__restore_sig() prepares the FPU state within
+fpu->state. To ensure that a context switch (switch_fpu_prepare() in
+particular) does not modify fpu->state it uses fpu__drop() which sets
+fpu->initialized to 0.
+
+After fpu->initialized is cleared, the CPU's FPU state is not saved
+to fpu->state during a context switch. The new state is loaded via
+fpu__restore(). It gets loaded into fpu->state from userland and
+ensured it is sane. fpu->initialized is then set to 1 in order to avoid
+fpu__initialize() doing anything (overwrite the new state) which is part
+of fpu__restore().
+
+A context switch between step A and B above would save CPU's current FPU
+registers to fpu->state and overwrite the newly prepared state. This
+looks like a tiny race window but the Kernel Test Robot reported this
+back in 2016 while we had lazy FPU support. Borislav Petkov made the
+link between that report and another patch that has been posted. Since
+the removal of the lazy FPU support, this race goes unnoticed because
+the warning has been removed.
+
+Disable bottom halves around the restore sequence to avoid the race. BH
+need to be disabled because BH is allowed to run (even with preemption
+disabled) and might invoke kernel_fpu_begin() by doing IPsec.
+
+ [ bp: massage commit message a bit. ]
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Acked-by: Ingo Molnar <mingo@kernel.org>
+Acked-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Andy Lutomirski <luto@kernel.org>
+Cc: Dave Hansen <dave.hansen@linux.intel.com>
+Cc: "H. Peter Anvin" <hpa@zytor.com>
+Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Cc: kvm ML <kvm@vger.kernel.org>
+Cc: Paolo Bonzini <pbonzini@redhat.com>
+Cc: Radim Krčmář <rkrcmar@redhat.com>
+Cc: Rik van Riel <riel@surriel.com>
+Cc: stable@vger.kernel.org
+Cc: x86-ml <x86@kernel.org>
+Link: http://lkml.kernel.org/r/20181120102635.ddv3fvavxajjlfqk@linutronix.de
+Link: https://lkml.kernel.org/r/20160226074940.GA28911@pd.tnic
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/kernel/fpu/signal.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/x86/kernel/fpu/signal.c
++++ b/arch/x86/kernel/fpu/signal.c
+@@ -342,10 +342,10 @@ static int __fpu__restore_sig(void __use
+                       sanitize_restored_xstate(tsk, &env, xfeatures, fx_only);
+               }
++              local_bh_disable();
+               fpu->fpstate_active = 1;
+-              preempt_disable();
+               fpu__restore(fpu);
+-              preempt_enable();
++              local_bh_enable();
+               return err;
+       } else {
diff --git a/queue-4.9/x86-mtrr-don-t-copy-uninitialized-gentry-fields-back-to-userspace.patch b/queue-4.9/x86-mtrr-don-t-copy-uninitialized-gentry-fields-back-to-userspace.patch
new file mode 100644 (file)
index 0000000..b8fa6e3
--- /dev/null
@@ -0,0 +1,41 @@
+From 32043fa065b51e0b1433e48d118821c71b5cd65d Mon Sep 17 00:00:00 2001
+From: Colin Ian King <colin.king@canonical.com>
+Date: Tue, 18 Dec 2018 17:29:56 +0000
+Subject: x86/mtrr: Don't copy uninitialized gentry fields back to userspace
+
+From: Colin Ian King <colin.king@canonical.com>
+
+commit 32043fa065b51e0b1433e48d118821c71b5cd65d upstream.
+
+Currently the copy_to_user of data in the gentry struct is copying
+uninitiaized data in field _pad from the stack to userspace.
+
+Fix this by explicitly memset'ing gentry to zero, this also will zero any
+compiler added padding fields that may be in struct (currently there are
+none).
+
+Detected by CoverityScan, CID#200783 ("Uninitialized scalar variable")
+
+Fixes: b263b31e8ad6 ("x86, mtrr: Use explicit sizing and padding for the 64-bit ioctls")
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
+Cc: security@kernel.org
+Link: https://lkml.kernel.org/r/20181218172956.1440-1-colin.king@canonical.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kernel/cpu/mtrr/if.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/arch/x86/kernel/cpu/mtrr/if.c
++++ b/arch/x86/kernel/cpu/mtrr/if.c
+@@ -172,6 +172,8 @@ mtrr_ioctl(struct file *file, unsigned i
+       struct mtrr_gentry gentry;
+       void __user *arg = (void __user *) __arg;
++      memset(&gentry, 0, sizeof(gentry));
++
+       switch (cmd) {
+       case MTRRIOC_ADD_ENTRY:
+       case MTRRIOC_SET_ENTRY: