[PATCH 4.9 085/171] rds: ib: Fix missing call to rds_ib_dev_put in rds_ib_setup_qp

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 91a825290ca4eae88603bc811bf74a45f94a3f46 ]

The function rds_ib_setup_qp is calling rds_ib_get_client_data and
should correspondingly call rds_ib_dev_put. This call was lost in
the non-error path with the introduction of error handling done in
commit 3b12f73a5c29 ("rds: ib: add error handle")

Signed-off-by: Dag Moxnes 
Reviewed-by: Håkon Bugge 
Acked-by: Santosh Shilimkar 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/rds/ib_cm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 169156cfd4c8..96e61eab19bc 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -505,7 +505,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
rdsdebug("conn %p pd %p cq %p %p\n", conn, ic->i_pd,
 ic->i_send_cq, ic->i_recv_cq);
 
-   return ret;
+   goto out;
 
 sends_out:
vfree(ic->i_sends);
@@ -530,6 +530,7 @@ send_cq_out:
ic->i_send_cq = NULL;
 rds_ibdev_out:
rds_ib_remove_conn(rds_ibdev, conn);
+out:
rds_ib_dev_put(rds_ibdev);
 
return ret;
-- 
2.17.1





[PATCH 4.9 083/171] ptr_ring: fix up after recent ptr_ring changes

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 5790eabc6e7c3ce2d6ca2e3bbf4de467ce2b64b3 ]

Add more stubs to make it build.

Fixes: 81fbfe8a ("ptr_ring: use kmalloc_array()")
Signed-off-by: Michael S. Tsirkin 
Signed-off-by: Sasha Levin 
---
 tools/virtio/ringtest/ptr_ring.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c
index 635b07b4fdd3..b4a2e6af515f 100644
--- a/tools/virtio/ringtest/ptr_ring.c
+++ b/tools/virtio/ringtest/ptr_ring.c
@@ -15,24 +15,41 @@
 #define unlikely(x)(__builtin_expect(!!(x), 0))
 #define likely(x)(__builtin_expect(!!(x), 1))
 #define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a))
+#define SIZE_MAX(~(size_t)0)
+
 typedef pthread_spinlock_t  spinlock_t;
 
 typedef int gfp_t;
-static void *kmalloc(unsigned size, gfp_t gfp)
-{
-   return memalign(64, size);
-}
+#define __GFP_ZERO 0x1
 
-static void *kzalloc(unsigned size, gfp_t gfp)
+static void *kmalloc(unsigned size, gfp_t gfp)
 {
void *p = memalign(64, size);
if (!p)
return p;
-   memset(p, 0, size);
 
+   if (gfp & __GFP_ZERO)
+   memset(p, 0, size);
return p;
 }
 
+static inline void *kzalloc(unsigned size, gfp_t flags)
+{
+   return kmalloc(size, flags | __GFP_ZERO);
+}
+
+static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
+{
+   if (size != 0 && n > SIZE_MAX / size)
+   return NULL;
+   return kmalloc(n * size, flags);
+}
+
+static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
+{
+   return kmalloc_array(n, size, flags | __GFP_ZERO);
+}
+
 static void kfree(void *p)
 {
if (p)
-- 
2.17.1





[PATCH 4.9 081/171] usb: dwc3: omap: remove IRQ_NOAUTOEN used with shared irq

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit ee249b4554947de3be77be4e9e6077b20c0fe055 ]

IRQ_NOAUTOEN cannot be used with shared IRQs, since commit 04c848d39879
("genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts") and
kernel now throws a warn dump. But OMAP DWC3 driver uses this flag. As
per commit 12a7f17fac5b ("usb: dwc3: omap: fix race of pm runtime with
irq handler in probe") that introduced this flag, PM runtime can race
with IRQ handler when deferred probing happens due to extcon,
therefore IRQ_NOAUTOEN needs to be set so that irq is not enabled until
extcon is registered.

Remove setting of IRQ_NOAUTOEN and move the registration of
shared irq to a point after dwc3_omap_extcon_register() and
of_platform_populate(). This avoids possibility of probe deferring and
above said race condition.

Reviewed-by: Grygorii Strashko 
Signed-off-by: Vignesh R 
Signed-off-by: Felipe Balbi 
Signed-off-by: Sasha Levin 
---
 drivers/usb/dwc3/dwc3-omap.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index f221cb479e14..8e69150776f5 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -512,15 +512,6 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 
/* check the DMA Status */
reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
-   irq_set_status_flags(omap->irq, IRQ_NOAUTOEN);
-   ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
-   dwc3_omap_interrupt_thread, IRQF_SHARED,
-   "dwc3-omap", omap);
-   if (ret) {
-   dev_err(dev, "failed to request IRQ #%d --> %d\n",
-   omap->irq, ret);
-   goto err1;
-   }
 
ret = dwc3_omap_extcon_register(omap);
if (ret < 0)
@@ -532,8 +523,15 @@ static int dwc3_omap_probe(struct platform_device *pdev)
goto err2;
}
 
+   ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
+   dwc3_omap_interrupt_thread, IRQF_SHARED,
+   "dwc3-omap", omap);
+   if (ret) {
+   dev_err(dev, "failed to request IRQ #%d --> %d\n",
+   omap->irq, ret);
+   goto err1;
+   }
dwc3_omap_enable_irqs(omap);
-   enable_irq(omap->irq);
return 0;
 
 err2:
-- 
2.17.1





[PATCH 4.9 086/171] iio: adc: Revert "axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications"

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 631b010abc5b57009c6a8328f51492665f6ef310 ]

Inheriting the ADC BIAS current settings from the BIOS instead of
hardcoding then causes the AXP288 to disable charging (I think it
mis-detects an overheated battery) on at least one model tablet.

So lets go back to hard coding the values, this reverts
commit fa2849e9649b ("iio: adc: axp288: Drop bogus
AXP288_ADC_TS_PIN_CTRL register modifications"), fixing charging not
working on the model tablet in question.

The exact cause is not fully understood, hence the revert to a known working
state.

Cc: sta...@vger.kernel.org
Reported-by: Umberto Ixxo 
Signed-off-by: Hans de Goede 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/iio/adc/axp288_adc.c | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index 64799ad7ebad..7fd24949c0c1 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -28,6 +28,8 @@
 #include 
 
 #define AXP288_ADC_EN_MASK 0xF1
+#define AXP288_ADC_TS_PIN_GPADC0xF2
+#define AXP288_ADC_TS_PIN_ON   0xF3
 
 enum axp288_adc_id {
AXP288_ADC_TS,
@@ -121,6 +123,16 @@ static int axp288_adc_read_channel(int *val, unsigned long 
address,
return IIO_VAL_INT;
 }
 
+static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode,
+   unsigned long address)
+{
+   /* channels other than GPADC do not need to switch TS pin */
+   if (address != AXP288_GP_ADC_H)
+   return 0;
+
+   return regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode);
+}
+
 static int axp288_adc_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
@@ -131,7 +143,16 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
+   if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC,
+   chan->address)) {
+   dev_err(&indio_dev->dev, "GPADC mode\n");
+   ret = -EINVAL;
+   break;
+   }
ret = axp288_adc_read_channel(val, chan->address, info->regmap);
+   if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON,
+   chan->address))
+   dev_err(&indio_dev->dev, "TS pin restore\n");
break;
default:
ret = -EINVAL;
@@ -141,6 +162,15 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
return ret;
 }
 
+static int axp288_adc_set_state(struct regmap *regmap)
+{
+   /* ADC should be always enabled for internal FG to function */
+   if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON))
+   return -EIO;
+
+   return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
+}
+
 static const struct iio_info axp288_adc_iio_info = {
.read_raw = &axp288_adc_read_raw,
.driver_module = THIS_MODULE,
@@ -169,7 +199,7 @@ static int axp288_adc_probe(struct platform_device *pdev)
 * Set ADC to enabled state at all time, including system suspend.
 * otherwise internal fuel gauge functionality may be affected.
 */
-   ret = regmap_write(info->regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
+   ret = axp288_adc_set_state(axp20x->regmap);
if (ret) {
dev_err(&pdev->dev, "unable to enable ADC device\n");
return ret;
-- 
2.17.1





[PATCH 4.9 126/171] ARM: dts: imx53-qsb: disable 1.2GHz OPP

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit eea96566c189c77e5272585984eb2729881a2f1d ]

The maximum CPU frequency for the i.MX53 QSB is 1GHz, so disable the
1.2GHz OPP. This makes the board work again with configs that have
cpufreq enabled like imx_v6_v7_defconfig on which the board stopped
working with the addition of cpufreq-dt support.

Fixes: 791f416608 ("ARM: dts: imx53: add cpufreq-dt support")

Signed-off-by: Sascha Hauer 
Signed-off-by: Shawn Guo 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/imx53-qsb-common.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi 
b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index c05e7cfd0cbc..c8a6a6868c46 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -130,6 +130,17 @@
};
 };
 
+&cpu0 {
+   /* CPU rated to 1GHz, not 1.2GHz as per the default settings */
+   operating-points = <
+   /* kHz   uV */
+   16  85
+   40  90
+   80  105
+   100 120
+   >;
+};
+
 &esdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
-- 
2.17.1





[PATCH 4.9 121/171] x86/paravirt: Fix some warning messages

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 571d0563c8881595f4ab027aef9ed1c55e3e7b7c ]

The first argument to WARN_ONCE() is a condition.

Fixes: 5800dc5c19f3 ("x86/paravirt: Fix spectre-v2 mitigations for paravirt 
guests")
Signed-off-by: Dan Carpenter 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Juergen Gross 
Cc: Peter Zijlstra 
Cc: Alok Kataria 
Cc: "H. Peter Anvin" 
Cc: virtualizat...@lists.linux-foundation.org
Cc: kernel-janit...@vger.kernel.org
Link: https://lkml.kernel.org/r/20180919103553.GD9238@mwanda
Signed-off-by: Sasha Levin 
---
 arch/x86/kernel/paravirt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 29d465627919..bf9552bebb3c 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -90,7 +90,7 @@ unsigned paravirt_patch_call(void *insnbuf,
 
if (len < 5) {
 #ifdef CONFIG_RETPOLINE
-   WARN_ONCE("Failing to patch indirect CALL in %ps\n", (void 
*)addr);
+   WARN_ONCE(1, "Failing to patch indirect CALL in %ps\n", (void 
*)addr);
 #endif
return len; /* call too long for patch site */
}
@@ -110,7 +110,7 @@ unsigned paravirt_patch_jmp(void *insnbuf, const void 
*target,
 
if (len < 5) {
 #ifdef CONFIG_RETPOLINE
-   WARN_ONCE("Failing to patch indirect JMP in %ps\n", (void 
*)addr);
+   WARN_ONCE(1, "Failing to patch indirect JMP in %ps\n", (void 
*)addr);
 #endif
return len; /* call too long for patch site */
}
-- 
2.17.1





[PATCH 4.9 127/171] rxrpc: Dont check RXRPC_CALL_TX_LAST after calling rxrpc_rotate_tx_window()

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit c479d5f2c2e1ce609da08c075054440d97ddff52 ]

We should only call the function to end a call's Tx phase if we rotated the
marked-last packet out of the transmission buffer.

Make rxrpc_rotate_tx_window() return an indication of whether it just
rotated the packet marked as the last out of the transmit buffer, carrying
the information out of the locked section in that function.

We can then check the return value instead of examining RXRPC_CALL_TX_LAST.

Fixes: 70790dbe3f66 ("rxrpc: Pass the last Tx packet marker in the annotation 
buffer")
Signed-off-by: David Howells 
Signed-off-by: Sasha Levin 
---
 net/rxrpc/input.c | 35 +++
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index f3ac85a285a2..7bfde4737cb3 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -216,10 +216,11 @@ static void rxrpc_send_ping(struct rxrpc_call *call, 
struct sk_buff *skb,
 /*
  * Apply a hard ACK by advancing the Tx window.
  */
-static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
+static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
   struct rxrpc_ack_summary *summary)
 {
struct sk_buff *skb, *list = NULL;
+   bool rot_last = false;
int ix;
u8 annotation;
 
@@ -243,15 +244,17 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call 
*call, rxrpc_seq_t to,
skb->next = list;
list = skb;
 
-   if (annotation & RXRPC_TX_ANNO_LAST)
+   if (annotation & RXRPC_TX_ANNO_LAST) {
set_bit(RXRPC_CALL_TX_LAST, &call->flags);
+   rot_last = true;
+   }
if ((annotation & RXRPC_TX_ANNO_MASK) != RXRPC_TX_ANNO_ACK)
summary->nr_rot_new_acks++;
}
 
spin_unlock(&call->lock);
 
-   trace_rxrpc_transmit(call, (test_bit(RXRPC_CALL_TX_LAST, &call->flags) ?
+   trace_rxrpc_transmit(call, (rot_last ?
rxrpc_transmit_rotate_last :
rxrpc_transmit_rotate));
wake_up(&call->waitq);
@@ -262,6 +265,8 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, 
rxrpc_seq_t to,
skb->next = NULL;
rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
}
+
+   return rot_last;
 }
 
 /*
@@ -332,11 +337,11 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
ktime_get_real());
}
 
-   if (!test_bit(RXRPC_CALL_TX_LAST, &call->flags))
-   rxrpc_rotate_tx_window(call, top, &summary);
if (!test_bit(RXRPC_CALL_TX_LAST, &call->flags)) {
-   rxrpc_proto_abort("TXL", call, top);
-   return false;
+   if (!rxrpc_rotate_tx_window(call, top, &summary)) {
+   rxrpc_proto_abort("TXL", call, top);
+   return false;
+   }
}
if (!rxrpc_end_tx_phase(call, true, "ETD"))
return false;
@@ -839,8 +844,12 @@ static void rxrpc_input_ack(struct rxrpc_call *call, 
struct sk_buff *skb,
if (nr_acks > call->tx_top - hard_ack)
return rxrpc_proto_abort("AKN", call, 0);
 
-   if (after(hard_ack, call->tx_hard_ack))
-   rxrpc_rotate_tx_window(call, hard_ack, &summary);
+   if (after(hard_ack, call->tx_hard_ack)) {
+   if (rxrpc_rotate_tx_window(call, hard_ack, &summary)) {
+   rxrpc_end_tx_phase(call, false, "ETA");
+   return;
+   }
+   }
 
if (nr_acks > 0) {
if (skb_copy_bits(skb, offset, buf.acks, nr_acks) < 0)
@@ -849,11 +858,6 @@ static void rxrpc_input_ack(struct rxrpc_call *call, 
struct sk_buff *skb,
  &summary);
}
 
-   if (test_bit(RXRPC_CALL_TX_LAST, &call->flags)) {
-   rxrpc_end_tx_phase(call, false, "ETA");
-   return;
-   }
-
if (call->rxtx_annotations[call->tx_top & RXRPC_RXTX_BUFF_MASK] &
RXRPC_TX_ANNO_LAST &&
summary.nr_acks == call->tx_top - hard_ack &&
@@ -875,8 +879,7 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, 
struct sk_buff *skb)
 
_proto("Rx ACKALL %%%u", sp->hdr.serial);
 
-   rxrpc_rotate_tx_window(call, call->tx_top, &summary);
-   if (test_bit(RXRPC_CALL_TX_LAST, &call->flags))
+   if (rxrpc_rotate_tx_window(call, call->tx_top, &summary))
rxrpc_end_tx_phase(call, false, "ETL");
 }
 
-- 
2.17.1





[PATCH 4.9 116/171] xen-netfront: Fix mismatched rtnl_unlock

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit cb257783c2927b73614b20f915a91ff78aa6f3e8 ]

Fixes: f599c64fdf7d ("xen-netfront: Fix race between device setup and open")
Reported-by: Ben Hutchings 
Signed-off-by: Ross Lagerwall 
Reviewed-by: Juergen Gross 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/xen-netfront.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index c85edd161a6c..aceae791baf3 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1848,7 +1848,7 @@ static int talk_to_netback(struct xenbus_device *dev,
err = xen_net_read_mac(dev, info->netdev->dev_addr);
if (err) {
xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
-   goto out;
+   goto out_unlocked;
}
 
rtnl_lock();
@@ -1963,6 +1963,7 @@ abort_transaction_no_dev_fatal:
xennet_destroy_queues(info);
  out:
rtnl_unlock();
+out_unlocked:
device_unregister(&dev->dev);
return err;
 }
-- 
2.17.1





[PATCH 4.9 113/171] test_bpf: Fix testing with CONFIG_BPF_JIT_ALWAYS_ON=y on other arches

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 52fda36d63bfc8c8e8ae5eda8eb5ac6f52cd67ed ]

Function bpf_fill_maxinsns11 is designed to not be able to be JITed on
x86_64. So, it fails when CONFIG_BPF_JIT_ALWAYS_ON=y, and
commit 09584b406742 ("bpf: fix selftests/bpf test_kmod.sh failure when
CONFIG_BPF_JIT_ALWAYS_ON=y") makes sure that failure is detected on that
case.

However, it does not fail on other architectures, which have a different
JIT compiler design. So, test_bpf has started to fail to load on those.

After this fix, test_bpf loads fine on both x86_64 and ppc64el.

Fixes: 09584b406742 ("bpf: fix selftests/bpf test_kmod.sh failure when 
CONFIG_BPF_JIT_ALWAYS_ON=y")
Signed-off-by: Thadeu Lima de Souza Cascardo 
Reviewed-by: Yonghong Song 
Signed-off-by: Daniel Borkmann 
Signed-off-by: Sasha Levin 
---
 lib/test_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 1586dfdea809..960d4d627361 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -4874,7 +4874,7 @@ static struct bpf_test tests[] = {
{
"BPF_MAXINSNS: Jump, gap, jump, ...",
{ },
-#ifdef CONFIG_BPF_JIT_ALWAYS_ON
+#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_X86)
CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
 #else
CLASSIC | FLAG_NO_DATA,
-- 
2.17.1





[PATCH 4.9 075/171] net/mlx5: Fix driver load error flow when firmware is stuck

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 8ce59b16b4b6eacedaec1f7b652b4781cdbfe15f ]

When wait for firmware init fails, previous code would mistakenly
return success and cause inconsistency in the driver state.

Fixes: 6c780a0267b8 ("net/mlx5: Wait for FW readiness before initializing 
command interface")
Signed-off-by: Gal Pressman 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 6698a3a07406..d676088512cf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -957,7 +957,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct 
mlx5_priv *priv,
if (err) {
dev_err(&dev->pdev->dev, "Firmware over %d MS in 
pre-initializing state, aborting\n",
FW_PRE_INIT_TIMEOUT_MILI);
-   goto out;
+   goto out_err;
}
 
err = mlx5_cmd_init(dev);
-- 
2.17.1





[PATCH 4.9 115/171] sparc64: Fix regression in pmdp_invalidate().

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit cfb61b5e3e09f8b49bc4d685429df75f45127adc ]

pmdp_invalidate() was changed to update the pmd atomically
(to not lose dirty/access bits) and return the original pmd
value.

However, in doing so, we lost a lot of the essential work that
set_pmd_at() does, namely to update hugepage mapping counts and
queuing up the batched TLB flush entry.

Thus we were not flushing entries out of the TLB when making
such PMD changes.

Fix this by abstracting the accounting work of set_pmd_at() out into a
separate function, and call it from pmdp_establish().

Fixes: a8e654f01cb7 ("sparc64: update pmdp_invalidate() to return old pmd 
value")
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 arch/sparc/mm/tlb.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
index b2722ed31053..349cb83f7b5f 100644
--- a/arch/sparc/mm/tlb.c
+++ b/arch/sparc/mm/tlb.c
@@ -163,13 +163,10 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, 
unsigned long vaddr,
pte_unmap(pte);
 }
 
-void set_pmd_at(struct mm_struct *mm, unsigned long addr,
-   pmd_t *pmdp, pmd_t pmd)
-{
-   pmd_t orig = *pmdp;
-
-   *pmdp = pmd;
 
+static void __set_pmd_acct(struct mm_struct *mm, unsigned long addr,
+  pmd_t orig, pmd_t pmd)
+{
if (mm == &init_mm)
return;
 
@@ -219,6 +216,15 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
}
 }
 
+void set_pmd_at(struct mm_struct *mm, unsigned long addr,
+   pmd_t *pmdp, pmd_t pmd)
+{
+   pmd_t orig = *pmdp;
+
+   *pmdp = pmd;
+   __set_pmd_acct(mm, addr, orig, pmd);
+}
+
 static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
unsigned long address, pmd_t *pmdp, pmd_t pmd)
 {
@@ -227,6 +233,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct 
*vma,
do {
old = *pmdp;
} while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd);
+   __set_pmd_acct(vma->vm_mm, address, old, pmd);
 
return old;
 }
-- 
2.17.1





[PATCH 4.9 077/171] perf probe: Fix probe definition for inlined functions

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 7598f8bc1383ffd77686cb4e92e749bef3c75937 ]

In commit 613f050d68a8 ("perf probe: Fix to probe on gcc generated
functions in modules"), the offset from symbol is, incorrectly, added
to the trace point address. This leads to incorrect probe trace points
for inlined functions and when using relative line number on symbols.

Prior this patch:
  $ perf probe -m nf_nat -D in_range
  p:probe/in_range nf_nat:in_range.isra.9+0
  $ perf probe -m i40e -D i40e_clean_rx_irq
  p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2212
  $ perf probe -m i40e -D i40e_clean_rx_irq:16
  p:probe/i40e_clean_rx_irq i40e:i40e_lan_xmit_frame+626

After:
  $ perf probe -m nf_nat -D in_range
  p:probe/in_range nf_nat:in_range.isra.9+0
  $ perf probe -m i40e -D i40e_clean_rx_irq
  p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+1106
  $ perf probe -m i40e -D i40e_clean_rx_irq:16
  p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2665

Committer testing:

Using 'pfunct', a tool found in the 'dwarves' package [1], one can ask what are
the functions that while not being explicitely marked as inline, were inlined
by the compiler:

  # pfunct --cc_inlined 
/lib/modules/4.12.0-rc4+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko | 
head
  __ew32
  e1000_regdump
  e1000e_dump_ps_pages
  e1000_desc_unused
  e1000e_systim_to_hwtstamp
  e1000e_rx_hwtstamp
  e1000e_update_rdt_wa
  e1000e_update_tdt_wa
  e1000_put_txbuf
  e1000_consume_page

Then ask 'perf probe' to produce the kprobe_tracer probe definitions for two of
them:

  # perf probe -m e1000e -D e1000e_rx_hwtstamp
  p:probe/e1000e_rx_hwtstamp e1000e:e1000_receive_skb+74

  # perf probe -m e1000e -D e1000_consume_page
  p:probe/e1000_consume_page e1000e:e1000_clean_jumbo_rx_irq+876
  p:probe/e1000_consume_page_1 e1000e:e1000_clean_jumbo_rx_irq+1506
  p:probe/e1000_consume_page_2 e1000e:e1000_clean_rx_irq_ps+1074

Now lets concentrate on the 'e1000_consume_page' one, that was inlined twice in
e1000_clean_jumbo_rx_irq(), lets see what readelf says about the DWARF tags for
that function:

  $ readelf -wi 
/lib/modules/4.12.0-rc4+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
  
  <1><13e27b>: Abbrev Number: 121 (DW_TAG_subprogram)
<13e27c>   DW_AT_name: (indirect string, offset: 0xa8945): 
e1000_clean_jumbo_rx_irq
<13e287>   DW_AT_low_pc  : 0x17a30
  <3><13e6ef>: Abbrev Number: 119 (DW_TAG_inlined_subroutine)
<13e6f0>   DW_AT_abstract_origin: <0x13ed2c>
<13e6f4>   DW_AT_low_pc  : 0x17be6
  
  <1><13ed2c>: Abbrev Number: 142 (DW_TAG_subprogram)
 <13ed2e>   DW_AT_name: (indirect string, offset: 0xa54c3): 
e1000_consume_page

So, the first time in e1000_clean_jumbo_rx_irq() where e1000_consume_page() is
inlined is at PC 0x17be6, which subtracted from e1000_clean_jumbo_rx_irq()'s
address, gives us the offset we should use in the probe definition:

  0x17be6 - 0x17a30 = 438

but above we have 876, which is twice as much.

Lets see the second inline expansion of e1000_consume_page() in
e1000_clean_jumbo_rx_irq():

  <3><13e86e>: Abbrev Number: 119 (DW_TAG_inlined_subroutine)
<13e86f>   DW_AT_abstract_origin: <0x13ed2c>
<13e873>   DW_AT_low_pc  : 0x17d21

  0x17d21 - 0x17a30 = 753

So we where adding it at twice the offset from the containing function as we
should.

And then after this patch:

  # perf probe -m e1000e -D e1000e_rx_hwtstamp
  p:probe/e1000e_rx_hwtstamp e1000e:e1000_receive_skb+37

  # perf probe -m e1000e -D e1000_consume_page
  p:probe/e1000_consume_page e1000e:e1000_clean_jumbo_rx_irq+438
  p:probe/e1000_consume_page_1 e1000e:e1000_clean_jumbo_rx_irq+753
  p:probe/e1000_consume_page_2 e1000e:e1000_clean_jumbo_rx_irq+1353
  #

Which matches the two first expansions and shows that because we were
doubling the offset it would spill over the next function:

  readelf -sw 
/lib/modules/4.12.0-rc4+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
   673: 00017a30  1626 FUNCLOCAL  DEFAULT2 
e1000_clean_jumbo_rx_irq
   674: 00018090  2013 FUNCLOCAL  DEFAULT2 e1000_clean_rx_irq_ps

This is the 3rd inline expansion of e1000_consume_page() in
e1000_clean_jumbo_rx_irq():

   <3><13ec77>: Abbrev Number: 119 (DW_TAG_inlined_subroutine)
<13ec78>   DW_AT_abstract_origin: <0x13ed2c>
<13ec7c>   DW_AT_low_pc  : 0x17f79

  0x17f79 - 0x17a30 = 1353

 So:

   0x17a30 + 2 * 1353 = 0x184c2

  And:

   0x184c2 - 0x18090 = 1074

Which explains the bogus third expansion for e1000_consume_page() to end up at:

   p:probe/e1000_consume_page_2 e1000e:e1000_clean_rx_irq_ps+1074

All fixed now :-)

[1] https://git.kernel.org/pub/scm/devel/pahole/pahole.git/

Signed-off-by: Björn Töpel 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Magnus Karlsson 
Acked-by: Masami Hiramatsu 
Cc: sta...@vger.kernel.org
Fixes: 613f050d68a8 ("perf probe: Fix to probe on gcc generated functions in 
modules")
Link: http:/

[PATCH 4.9 152/171] ip6_tunnel: Fix encapsulation layout

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Stefano Brivio 

[ Upstream commit d4d576f5ab7edcb757bb33e6a5600666a0b1232d ]

Commit 058214a4d1df ("ip6_tun: Add infrastructure for doing
encapsulation") added the ip6_tnl_encap() call in ip6_tnl_xmit(), before
the call to ipv6_push_frag_opts() to append the IPv6 Tunnel Encapsulation
Limit option (option 4, RFC 2473, par. 5.1) to the outer IPv6 header.

As long as the option didn't actually end up in generated packets, this
wasn't an issue. Then commit 89a23c8b528b ("ip6_tunnel: Fix missing tunnel
encapsulation limit option") fixed sending of this option, and the
resulting layout, e.g. for FoU, is:

.---..--.---.- - -
| Outer IPv6 Header | UDP header | Option 4 | Inner IPv6 Header | Payload
'---''--'---'- - -

Needless to say, FoU and GUE (at least) won't work over IPv6. The option
is appended by default, and I couldn't find a way to disable it with the
current iproute2.

Turn this into a more reasonable:

.---.--..---.- - -
| Outer IPv6 Header | Option 4 | UDP header | Inner IPv6 Header | Payload
'---'--''---'- - -

With this, and with 84dad55951b0 ("udp6: fix encap return code for
resubmitting"), FoU and GUE work again over IPv6.

Fixes: 058214a4d1df ("ip6_tun: Add infrastructure for doing encapsulation")
Signed-off-by: Stefano Brivio 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/ipv6/ip6_tunnel.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1185,11 +1185,6 @@ route_lookup:
}
skb_dst_set(skb, dst);
 
-   if (encap_limit >= 0) {
-   init_tel_txopt(&opt, encap_limit);
-   ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
-   }
-
/* Calculate max headroom for all the headers and adjust
 * needed_headroom if necessary.
 */
@@ -1202,6 +1197,11 @@ route_lookup:
if (err)
return err;
 
+   if (encap_limit >= 0) {
+   init_tel_txopt(&opt, encap_limit);
+   ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
+   }
+
skb_push(skb, sizeof(struct ipv6hdr));
skb_reset_network_header(skb);
ipv6h = ipv6_hdr(skb);




[PATCH 4.9 141/171] net: socket: fix a missing-check bug

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Wenwen Wang 

[ Upstream commit b6168562c8ce2bd5a30e213021650422e08764dc ]

In ethtool_ioctl(), the ioctl command 'ethcmd' is checked through a switch
statement to see whether it is necessary to pre-process the ethtool
structure, because, as mentioned in the comment, the structure
ethtool_rxnfc is defined with padding. If yes, a user-space buffer 'rxnfc'
is allocated through compat_alloc_user_space(). One thing to note here is
that, if 'ethcmd' is ETHTOOL_GRXCLSRLALL, the size of the buffer 'rxnfc' is
partially determined by 'rule_cnt', which is actually acquired from the
user-space buffer 'compat_rxnfc', i.e., 'compat_rxnfc->rule_cnt', through
get_user(). After 'rxnfc' is allocated, the data in the original user-space
buffer 'compat_rxnfc' is then copied to 'rxnfc' through copy_in_user(),
including the 'rule_cnt' field. However, after this copy, no check is
re-enforced on 'rxnfc->rule_cnt'. So it is possible that a malicious user
race to change the value in the 'compat_rxnfc->rule_cnt' between these two
copies. Through this way, the attacker can bypass the previous check on
'rule_cnt' and inject malicious data. This can cause undefined behavior of
the kernel and introduce potential security risk.

This patch avoids the above issue via copying the value acquired by
get_user() to 'rxnfc->rule_cn', if 'ethcmd' is ETHTOOL_GRXCLSRLALL.

Signed-off-by: Wenwen Wang 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/socket.c |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

--- a/net/socket.c
+++ b/net/socket.c
@@ -2774,9 +2774,14 @@ static int ethtool_ioctl(struct net *net
copy_in_user(&rxnfc->fs.ring_cookie,
 &compat_rxnfc->fs.ring_cookie,
 (void __user *)(&rxnfc->fs.location + 1) -
-(void __user *)&rxnfc->fs.ring_cookie) ||
-   copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
-sizeof(rxnfc->rule_cnt)))
+(void __user *)&rxnfc->fs.ring_cookie))
+   return -EFAULT;
+   if (ethcmd == ETHTOOL_GRXCLSRLALL) {
+   if (put_user(rule_cnt, &rxnfc->rule_cnt))
+   return -EFAULT;
+   } else if (copy_in_user(&rxnfc->rule_cnt,
+   &compat_rxnfc->rule_cnt,
+   sizeof(rxnfc->rule_cnt)))
return -EFAULT;
}
 




[PATCH 4.9 106/171] iio: pressure: zpa2326: Remove always-true check which confuses gcc

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit f61dfff2f5b9fcb087bf5c444bc44b444709588f ]

With gcc 4.1.2:

drivers/iio/pressure/zpa2326.c: In function 
‘zpa2326_wait_oneshot_completion’:
drivers/iio/pressure/zpa2326.c:868: warning: ‘ret’ may be used 
uninitialized in this function

When testing for "timeout < 0", timeout is already guaranteed to be
strict negative, so the branch is always taken, and ret is thus always
initialized.  But (some version of) gcc is not smart enough to notice.

Remove the check to fix this.
As there is no other code in between assigning the error codes and
returning them, the error codes can be returned immediately, and the
intermediate variable can be dropped.
Drop the "else" to please checkpatch.

Fixes: e7215fe4d51e69c9 ("iio: pressure: zpa2326: report interrupted case as 
failure")
Signed-off-by: Geert Uytterhoeven 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/iio/pressure/zpa2326.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
index 2a4a62ebfd8d..cc002b958f7e 100644
--- a/drivers/iio/pressure/zpa2326.c
+++ b/drivers/iio/pressure/zpa2326.c
@@ -869,7 +869,6 @@ complete:
 static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
   struct zpa2326_private *private)
 {
-   int  ret;
unsigned int val;
long timeout;
 
@@ -891,14 +890,11 @@ static int zpa2326_wait_oneshot_completion(const struct 
iio_dev   *indio_dev,
/* Timed out. */
zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
 timeout);
-   ret = -ETIME;
-   } else if (timeout < 0) {
-   zpa2326_warn(indio_dev,
-"wait for one shot interrupt cancelled");
-   ret = -ERESTARTSYS;
+   return -ETIME;
}
 
-   return ret;
+   zpa2326_warn(indio_dev, "wait for one shot interrupt cancelled");
+   return -ERESTARTSYS;
 }
 
 static int zpa2326_init_managed_irq(struct device  *parent,
-- 
2.17.1





[PATCH 4.9 129/171] net: ena: fix NULL dereference due to untimely napi initialization

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 78a55d05def95144ca5fa9a64c49b2a0636a9866 ]

napi poll functions should be initialized before running request_irq(),
to handle a rare condition where there is a pending interrupt, causing
the ISR to fire immediately while the poll function wasn't set yet,
causing a NULL dereference.

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network 
Adapters (ENA)")
Signed-off-by: Arthur Kiyanovski 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c 
b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 1d92e034febc..0c298878bf46 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -1482,8 +1482,6 @@ static int ena_up_complete(struct ena_adapter *adapter)
if (rc)
return rc;
 
-   ena_init_napi(adapter);
-
ena_change_mtu(adapter->netdev, adapter->netdev->mtu);
 
ena_refill_all_rx_bufs(adapter);
@@ -1643,6 +1641,13 @@ static int ena_up(struct ena_adapter *adapter)
 
ena_setup_io_intr(adapter);
 
+   /* napi poll functions should be initialized before running
+* request_irq(), to handle a rare condition where there is a pending
+* interrupt, causing the ISR to fire immediately while the poll
+* function wasn't set yet, causing a null dereference
+*/
+   ena_init_napi(adapter);
+
rc = ena_request_io_irq(adapter);
if (rc)
goto err_req_irq;
-- 
2.17.1





[PATCH 4.9 132/171] Revert "netfilter: ipv6: nf_defrag: drop skb dst before queueing"

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

This reverts commit ad8b1ffc3efae2f65080bdb11145c87d299b8f9a.

>From Florian Westphal :

It causes kernel crash for locally generated ipv6 fragments
when netfilter ipv6 defragmentation is used.

The faulty commit is not essential for -stable, it only
delays netns teardown for longer than needed when that netns
still has ipv6 frags queued.  Much better than crash :-/

Signed-off-by: Sasha Levin 
---
 net/ipv6/netfilter/nf_conntrack_reasm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c 
b/net/ipv6/netfilter/nf_conntrack_reasm.c
index b9147558a8f2..e46185377981 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -597,8 +597,6 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff 
*skb, u32 user)
fq->q.meat == fq->q.len &&
nf_ct_frag6_reasm(fq, skb, dev))
ret = 0;
-   else
-   skb_dst_drop(skb);
 
 out_unlock:
spin_unlock_bh(&fq->q.lock);
-- 
2.17.1





[PATCH 4.9 108/171] macsec: fix memory leaks when skb_to_sgvec fails

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 5aba2ba5030b66a6f8c93049b718556f9aacd7c6 ]

Fixes: cda7ea690350 ("macsec: check return value of skb_to_sgvec always")
Signed-off-by: Sabrina Dubroca 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/macsec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 365a48cfcbbf..653f0b185a68 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -744,6 +744,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
sg_init_table(sg, ret);
ret = skb_to_sgvec(skb, sg, 0, skb->len);
if (unlikely(ret < 0)) {
+   aead_request_free(req);
macsec_txsa_put(tx_sa);
kfree_skb(skb);
return ERR_PTR(ret);
@@ -956,6 +957,7 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
sg_init_table(sg, ret);
ret = skb_to_sgvec(skb, sg, 0, skb->len);
if (unlikely(ret < 0)) {
+   aead_request_free(req);
kfree_skb(skb);
return ERR_PTR(ret);
}
-- 
2.17.1





[PATCH 4.9 104/171] drm/msm: Fix possible null dereference on failure of get_pages()

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 3976626ea3d2011f8fd3f3a47070a8b792018253 ]

Commit 62e3a3e342af changed get_pages() to initialise
msm_gem_object::pages before trying to initialise msm_gem_object::sgt,
so that put_pages() would properly clean up pages in the failure
case.

However, this means that put_pages() now needs to check that
msm_gem_object::sgt is not null before trying to clean it up, and
this check was only applied to part of the cleanup code.  Move
it all into the conditional block.  (Strictly speaking we don't
need to make the kfree() conditional, but since we can't avoid
checking for null ourselves we may as well do so.)

Fixes: 62e3a3e342af ("drm/msm: fix leak in failed get_pages")
Signed-off-by: Ben Hutchings 
Reviewed-by: Jordan Crouse 
Signed-off-by: Rob Clark 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/msm/msm_gem.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 7145127513c4..795660e29b2c 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -118,17 +118,19 @@ static void put_pages(struct drm_gem_object *obj)
struct msm_gem_object *msm_obj = to_msm_bo(obj);
 
if (msm_obj->pages) {
-   /* For non-cached buffers, ensure the new pages are clean
-* because display controller, GPU, etc. are not coherent:
-*/
-   if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED))
-   dma_unmap_sg(obj->dev->dev, msm_obj->sgt->sgl,
-   msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+   if (msm_obj->sgt) {
+   /* For non-cached buffers, ensure the new
+* pages are clean because display controller,
+* GPU, etc. are not coherent:
+*/
+   if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED))
+   dma_unmap_sg(obj->dev->dev, msm_obj->sgt->sgl,
+msm_obj->sgt->nents,
+DMA_BIDIRECTIONAL);
 
-   if (msm_obj->sgt)
sg_free_table(msm_obj->sgt);
-
-   kfree(msm_obj->sgt);
+   kfree(msm_obj->sgt);
+   }
 
if (use_pages(obj))
drm_gem_put_pages(obj, msm_obj->pages, true, false);
-- 
2.17.1





[PATCH 4.14 10/31] xfs: truncate transaction does not modify the inobt

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit a606ebdb859e78beb757dfefa08001df366e2ef5 ]

The truncate transaction does not ever modify the inode btree, but
includes an associated log reservation. Update
xfs_calc_itruncate_reservation() to remove the reservation
associated with inobt updates.

[Amir:  This commit was merged for kernel v4.16 and a twin commit was
merged for xfsprogs v4.16. As a result, a small xfs filesystem
formatted with features -m rmapbt=1,reflink=1 using mkfs.xfs
version >= v4.16 cannot be mounted with kernel < v4.16.

For example, xfstests generic/17{1,2,3} format a small fs and
when trying to mount it, they fail with an assert on this very
demonic line:

 XFS (vdc): Log size 3075 blocks too small, minimum size is 3717 blocks
 XFS (vdc): AAIEEE! Log failed size checks. Abort!
 XFS: Assertion failed: 0, file: src/linux/fs/xfs/xfs_log.c, line: 666

The simple solution for stable kernels is to apply this patch,
because mkfs.xfs v4.16 is already in the wild, so we have to
assume that xfs filesystems with a "too small" log exist.
Regardless, xfsprogs maintainers should also consider reverting
the twin patch to stop creating those filesystems for the sake
of users with unpatched kernels.]

Signed-off-by: Brian Foster 
Reviewed-by: Dave Chinner 
Reviewed-by: Darrick J. Wong 
Signed-off-by: Darrick J. Wong 
Cc:  # v4.9+
Signed-off-by: Amir Goldstein 
Reviewed-by: Darrick J . Wong 
Signed-off-by: Sasha Levin 
---
 fs/xfs/libxfs/xfs_trans_resv.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c
index 6bd916bd35e2..48eff18c5496 100644
--- a/fs/xfs/libxfs/xfs_trans_resv.c
+++ b/fs/xfs/libxfs/xfs_trans_resv.c
@@ -232,8 +232,6 @@ xfs_calc_write_reservation(
  *the super block to reflect the freed blocks: sector size
  *worst case split in allocation btrees per extent assuming 4 extents:
  * 4 exts * 2 trees * (2 * max depth - 1) * block size
- *the inode btree: max depth * blocksize
- *the allocation btrees: 2 trees * (max depth - 1) * block size
  */
 STATIC uint
 xfs_calc_itruncate_reservation(
@@ -245,12 +243,7 @@ xfs_calc_itruncate_reservation(
  XFS_FSB_TO_B(mp, 1))),
(xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 4),
- XFS_FSB_TO_B(mp, 1)) +
-   xfs_calc_buf_res(5, 0) +
-   xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
-XFS_FSB_TO_B(mp, 1)) +
-   xfs_calc_buf_res(2 + mp->m_ialloc_blks +
-mp->m_in_maxlevels, 0)));
+ XFS_FSB_TO_B(mp, 1;
 }
 
 /*
-- 
2.17.1





[PATCH 4.14 01/31] eeprom: at24: Add support for address-width property

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit a2b3bf4846e5eed62ea6abb096af2c950961033c ]

Provide a flexible way to determine the addressing bits of eeprom.
Pass the addressing bits to driver through address-width property.

Signed-off-by: Alan Chiang 
Signed-off-by: Andy Yeh 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Sasha Levin 
---
 drivers/misc/eeprom/at24.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 4cc0b42f2acc..ded48a0c77ee 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -577,6 +577,23 @@ static void at24_get_pdata(struct device *dev, struct 
at24_platform_data *chip)
if (device_property_present(dev, "read-only"))
chip->flags |= AT24_FLAG_READONLY;
 
+   err = device_property_read_u32(dev, "address-width", &val);
+   if (!err) {
+   switch (val) {
+   case 8:
+   if (chip->flags & AT24_FLAG_ADDR16)
+   dev_warn(dev, "Override address width to be 8, 
while default is 16\n");
+   chip->flags &= ~AT24_FLAG_ADDR16;
+   break;
+   case 16:
+   chip->flags |= AT24_FLAG_ADDR16;
+   break;
+   default:
+   dev_warn(dev, "Bad \"address-width\" property: %u\n",
+val);
+   }
+   }
+
err = device_property_read_u32(dev, "pagesize", &val);
if (!err) {
chip->page_size = val;
-- 
2.17.1





[PATCH 4.14 18/31] cdc-acm: do not reset notification buffer index upon urb unlinking

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Tobias Herzog 

commit dae3ddba36f8c337fb59cef07d564da6fc9b7551 upstream.

Resetting the write index of the notification buffer on urb unlink (e.g.
closing a cdc-acm device from userspace) may lead to wrong interpretation
of further received notifications, in case the index is not 0 when urb
unlink happens (i.e. when parts of a notification already have been
transferred). On the device side there is no "reset" of the notification
transimission and thus we would get out of sync with the device.

Signed-off-by: Tobias Herzog 
Acked-by: Oliver Neukum 
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/class/cdc-acm.c |1 -
 1 file changed, 1 deletion(-)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -367,7 +367,6 @@ static void acm_ctrl_irq(struct urb *urb
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
-   acm->nb_index = 0;
dev_dbg(&acm->control->dev,
"%s - urb shutting down with status: %d\n",
__func__, status);




[PATCH 4.9 138/171] llc: set SOCK_RCU_FREE in llc_sap_add_socket()

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Cong Wang 

[ Upstream commit 5a8e7aea953bdb6d4da13aff6f1e7f9c62023499 ]

WHen an llc sock is added into the sk_laddr_hash of an llc_sap,
it is not marked with SOCK_RCU_FREE.

This causes that the sock could be freed while it is still being
read by __llc_lookup_established() with RCU read lock. sock is
refcounted, but with RCU read lock, nothing prevents the readers
getting a zero refcnt.

Fix it by setting SOCK_RCU_FREE in llc_sap_add_socket().

Reported-by: syzbot+11e05f04c15e03be5...@syzkaller.appspotmail.com
Signed-off-by: Cong Wang 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/llc/llc_conn.c |1 +
 1 file changed, 1 insertion(+)

--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -734,6 +734,7 @@ void llc_sap_add_socket(struct llc_sap *
llc_sk(sk)->sap = sap;
 
spin_lock_bh(&sap->sk_lock);
+   sock_set_flag(sk, SOCK_RCU_FREE);
sap->sk_count++;
sk_nulls_add_node_rcu(sk, laddr_hb);
hlist_add_head(&llc->dev_hash_node, dev_hb);




[PATCH 4.14 02/31] vfs: swap names of {do,vfs}_clone_file_range()

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

commit a725356b6659469d182d662f22d770d83d3bc7b5 upstream.

Commit 031a072a0b8a ("vfs: call vfs_clone_file_range() under freeze
protection") created a wrapper do_clone_file_range() around
vfs_clone_file_range() moving the freeze protection to former, so
overlayfs could call the latter.

The more common vfs practice is to call do_xxx helpers from vfs_xxx
helpers, where freeze protecction is taken in the vfs_xxx helper, so
this anomality could be a source of confusion.

It seems that commit 8ede205541ff ("ovl: add reflink/copyfile/dedup
support") may have fallen a victim to this confusion -
ovl_clone_file_range() calls the vfs_clone_file_range() helper in the
hope of getting freeze protection on upper fs, but in fact results in
overlayfs allowing to bypass upper fs freeze protection.

Swap the names of the two helpers to conform to common vfs practice
and call the correct helpers from overlayfs and nfsd.

Signed-off-by: Amir Goldstein 
Signed-off-by: Miklos Szeredi 
Fixes: 031a072a0b8a ("vfs: call vfs_clone_file_range() under freeze...")
Signed-off-by: Amir Goldstein 
Signed-off-by: Sasha Levin 
---
 fs/ioctl.c |  2 +-
 fs/nfsd/vfs.c  |  3 ++-
 fs/overlayfs/copy_up.c |  2 +-
 fs/read_write.c| 17 +++--
 include/linux/fs.h | 17 +++--
 5 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 5ace7efb0d04..9db5ddaf7ef0 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -229,7 +229,7 @@ static long ioctl_file_clone(struct file *dst_file, 
unsigned long srcfd,
ret = -EXDEV;
if (src_file.file->f_path.mnt != dst_file->f_path.mnt)
goto fdput;
-   ret = do_clone_file_range(src_file.file, off, dst_file, destoff, olen);
+   ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen);
 fdput:
fdput(src_file);
return ret;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index a3c9bfa77def..f55527ef21e8 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -541,7 +541,8 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct 
svc_fh *fhp,
 __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst,
u64 dst_pos, u64 count)
 {
-   return nfserrno(do_clone_file_range(src, src_pos, dst, dst_pos, count));
+   return nfserrno(vfs_clone_file_range(src, src_pos, dst, dst_pos,
+count));
 }
 
 ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst,
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index c441f9387a1b..321eae740148 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -157,7 +157,7 @@ static int ovl_copy_up_data(struct path *old, struct path 
*new, loff_t len)
}
 
/* Try to use clone_file_range to clone up within the same fs */
-   error = vfs_clone_file_range(old_file, 0, new_file, 0, len);
+   error = do_clone_file_range(old_file, 0, new_file, 0, len);
if (!error)
goto out;
/* Couldn't clone, so now we try to copy the data */
diff --git a/fs/read_write.c b/fs/read_write.c
index 0046d72efe94..57a00ef895b2 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1812,8 +1812,8 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, 
loff_t pos_in,
 }
 EXPORT_SYMBOL(vfs_clone_file_prep_inodes);
 
-int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
-   struct file *file_out, loff_t pos_out, u64 len)
+int do_clone_file_range(struct file *file_in, loff_t pos_in,
+   struct file *file_out, loff_t pos_out, u64 len)
 {
struct inode *inode_in = file_inode(file_in);
struct inode *inode_out = file_inode(file_out);
@@ -1860,6 +1860,19 @@ int vfs_clone_file_range(struct file *file_in, loff_t 
pos_in,
 
return ret;
 }
+EXPORT_SYMBOL(do_clone_file_range);
+
+int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
+struct file *file_out, loff_t pos_out, u64 len)
+{
+   int ret;
+
+   file_start_write(file_out);
+   ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len);
+   file_end_write(file_out);
+
+   return ret;
+}
 EXPORT_SYMBOL(vfs_clone_file_range);
 
 /*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cc613f20e5a6..7374639f0aa0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1792,8 +1792,10 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t 
, struct file *,
 extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
  struct inode *inode_out, loff_t pos_out,
  u64 *len, bool is_dedupe);
+extern int do_clone_file_range(struct file *file_in, loff_t pos_in,
+  struct file *file_out, loff_t pos_out, u64 len);
 extern int v

[PATCH 4.9 164/171] usb: gadget: storage: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit 9ae24af3669111d418242caec8dd4ebd9ba26860 upstream.

num can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/usb/gadget/function/f_mass_storage.c:3177 fsg_lun_make() warn:
potential spectre issue 'fsg_opts->common->luns' [r] (local cap)

Fix this by sanitizing num before using it to index
fsg_opts->common->luns

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Acked-by: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/gadget/function/f_mass_storage.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -220,6 +220,8 @@
 #include 
 #include 
 
+#include 
+
 #include "configfs.h"
 
 
@@ -3260,6 +3262,7 @@ static struct config_group *fsg_lun_make
fsg_opts = to_fsg_opts(&group->cg_item);
if (num >= FSG_MAX_LUNS)
return ERR_PTR(-ERANGE);
+   num = array_index_nospec(num, FSG_MAX_LUNS);
 
mutex_lock(&fsg_opts->lock);
if (fsg_opts->refcnt || fsg_opts->common->luns[num]) {




[PATCH 4.9 167/171] sched/fair: Fix throttle_list starvation with low CFS quota

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Phil Auld 

commit baa9be4ffb55876923dc9716abc0a448e510ba30 upstream.

With a very low cpu.cfs_quota_us setting, such as the minimum of 1000,
distribute_cfs_runtime may not empty the throttled_list before it runs
out of runtime to distribute. In that case, due to the change from
c06f04c7048 to put throttled entries at the head of the list, later entries
on the list will starve.  Essentially, the same X processes will get pulled
off the list, given CPU time and then, when expired, get put back on the
head of the list where distribute_cfs_runtime will give runtime to the same
set of processes leaving the rest.

Fix the issue by setting a bit in struct cfs_bandwidth when
distribute_cfs_runtime is running, so that the code in throttle_cfs_rq can
decide to put the throttled entry on the tail or the head of the list.  The
bit is set/cleared by the callers of distribute_cfs_runtime while they hold
cfs_bandwidth->lock.

This is easy to reproduce with a handful of CPU consumers. I use 'crash' on
the live system. In some cases you can simply look at the throttled list and
see the later entries are not changing:

  crash> list cfs_rq.throttled_list -H 0x90b54f6ade40 -s 
cfs_rq.runtime_remaining | paste - - | awk '{print $1"  "$4}' | pr -t -n3
1 90b56cb2d200  -976050
2 90b56cb2cc00  -484925
3 90b56cb2bc00  -658814
4 90b56cb2ba00  -275365
5 90b166a45600  -135138
6 90b56cb2da00  -282505
7 90b56cb2e000  -148065
8 90b56cb2fa00  -872591
9 90b56cb2c000  -84687
   10 90b56cb2f000  -87237
   11 90b166a40a00  -164582

  crash> list cfs_rq.throttled_list -H 0x90b54f6ade40 -s 
cfs_rq.runtime_remaining | paste - - | awk '{print $1"  "$4}' | pr -t -n3
1 90b56cb2d200  -994147
2 90b56cb2cc00  -306051
3 90b56cb2bc00  -961321
4 90b56cb2ba00  -24490
5 90b166a45600  -135138
6 90b56cb2da00  -282505
7 90b56cb2e000  -148065
8 90b56cb2fa00  -872591
9 90b56cb2c000  -84687
   10 90b56cb2f000  -87237
   11 90b166a40a00  -164582

Sometimes it is easier to see by finding a process getting starved and looking
at the sched_info:

  crash> task 8eb765994500 sched_info
  PID: 7800   TASK: 8eb765994500  CPU: 16  COMMAND: "cputest"
sched_info = {
  pcount = 8,
  run_delay = 697094208,
  last_arrival = 240260125039,
  last_queued = 240260327513
},
  crash> task 8eb765994500 sched_info
  PID: 7800   TASK: 8eb765994500  CPU: 16  COMMAND: "cputest"
sched_info = {
  pcount = 8,
  run_delay = 697094208,
  last_arrival = 240260125039,
  last_queued = 240260327513
},

Signed-off-by: Phil Auld 
Reviewed-by: Ben Segall 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Fixes: c06f04c70489 ("sched: Fix potential near-infinite 
distribute_cfs_runtime() loop")
Link: http://lkml.kernel.org/r/20181008143639.ga4...@pauld.bos.csb
Signed-off-by: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/sched/fair.c  |   22 +++---
 kernel/sched/sched.h |2 ++
 2 files changed, 21 insertions(+), 3 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3976,9 +3976,13 @@ static void throttle_cfs_rq(struct cfs_r
 
/*
 * Add to the _head_ of the list, so that an already-started
-* distribute_cfs_runtime will not see us
+* distribute_cfs_runtime will not see us. If disribute_cfs_runtime is
+* not running add to the tail so that later runqueues don't get 
starved.
 */
-   list_add_rcu(&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq);
+   if (cfs_b->distribute_running)
+   list_add_rcu(&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq);
+   else
+   list_add_tail_rcu(&cfs_rq->throttled_list, 
&cfs_b->throttled_cfs_rq);
 
/*
 * If we're the first throttled task, make sure the bandwidth
@@ -4121,14 +4125,16 @@ static int do_sched_cfs_period_timer(str
 * in us over-using our runtime if it is all used during this loop, but
 * only by limited amounts in that extreme case.
 */
-   while (throttled && cfs_b->runtime > 0) {
+   while (throttled && cfs_b->runtime > 0 && !cfs_b->distribute_running) {
runtime = cfs_b->runtime;
+   cfs_b->distribute_running = 1;
raw_spin_unlock(&cfs_b->lock);
/* we can't nest cfs_b->lock while distributing bandwidth */
runtime = distribute_cfs_runtime(cfs_b, runtime,
 runtime_expires);
raw_spin_lock(&cfs_b->lock);
 
+   cfs_b->distribute_running = 0;
throttled = !list_em

[PATCH 4.9 131/171] mtd: spi-nor: Add support for is25wp series chips

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit d616f81cdd2a21edfa90a595a4e9b143f5ba8414 ]

Added support for is25wp032, is25wp064 and is25wp128.

Signed-off-by: Kimmo Rautkoski 
Reviewed-by: Marek Vasut 
Signed-off-by: Boris Brezillon 
[ Adrian Bunk: Trivial adaption to changed context. ]
Signed-off-by: Adrian Bunk 
Signed-off-by: Sasha Levin 
---
 drivers/mtd/spi-nor/spi-nor.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 21dde5249085..c42523b7d5ed 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -858,6 +858,12 @@ static const struct flash_info spi_nor_ids[] = {
 
/* ISSI */
{ "is25cd512", INFO(0x7f9d20, 0, 32 * 1024,   2, SECT_4K) },
+   { "is25wp032", INFO(0x9d7016, 0, 64 * 1024,  64,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+   { "is25wp064", INFO(0x9d7017, 0, 64 * 1024, 128,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+   { "is25wp128", INFO(0x9d7018, 0, 64 * 1024, 256,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 
/* Macronix */
{ "mx25l512e",   INFO(0xc22010, 0, 64 * 1024,   1, SECT_4K) },
-- 
2.17.1





[PATCH 4.14 19/31] cdc-acm: correct counting of UART states in serial state notification

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Tobias Herzog 

commit f976d0e5747ca65ccd0fb2a4118b193d70aa1836 upstream.

The usb standard ("Universal Serial Bus Class Definitions for Communication
Devices") distiguishes between "consistent signals" (DSR, DCD), and
"irregular signals" (break, ring, parity error, framing error, overrun).
The bits of "irregular signals" are set, if this error/event occurred on
the device side and are immeadeatly unset, if the serial state notification
was sent.
Like other drivers of real serial ports do, just the occurence of those
events should be counted in serial_icounter_struct (but no 1->0
transitions).

Signed-off-by: Tobias Herzog 
Acked-by: Oliver Neukum 
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/class/cdc-acm.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -322,17 +322,17 @@ static void acm_process_notification(str
 
if (difference & ACM_CTRL_DSR)
acm->iocount.dsr++;
-   if (difference & ACM_CTRL_BRK)
-   acm->iocount.brk++;
-   if (difference & ACM_CTRL_RI)
-   acm->iocount.rng++;
if (difference & ACM_CTRL_DCD)
acm->iocount.dcd++;
-   if (difference & ACM_CTRL_FRAMING)
+   if (newctrl & ACM_CTRL_BRK)
+   acm->iocount.brk++;
+   if (newctrl & ACM_CTRL_RI)
+   acm->iocount.rng++;
+   if (newctrl & ACM_CTRL_FRAMING)
acm->iocount.frame++;
-   if (difference & ACM_CTRL_PARITY)
+   if (newctrl & ACM_CTRL_PARITY)
acm->iocount.parity++;
-   if (difference & ACM_CTRL_OVERRUN)
+   if (newctrl & ACM_CTRL_OVERRUN)
acm->iocount.overrun++;
spin_unlock(&acm->read_lock);
 




[PATCH 4.9 161/171] RDMA/ucma: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit a3671a4f973ee9d9621d60166cc3b037c397d604 upstream.

hdr.cmd can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/infiniband/core/ucma.c:1686 ucma_write() warn: potential
spectre issue 'ucma_cmd_table' [r] (local cap)

Fix this by sanitizing hdr.cmd before using it to index
ucm_cmd_table.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Signed-off-by: Doug Ledford 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/ucma.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -44,6 +44,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -1637,6 +1639,7 @@ static ssize_t ucma_write(struct file *f
 
if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
return -EINVAL;
+   hdr.cmd = array_index_nospec(hdr.cmd, ARRAY_SIZE(ucma_cmd_table));
 
if (hdr.in + sizeof(hdr) > len)
return -EINVAL;




[PATCH 4.14 15/31] drm: fb-helper: Reject all pixel format changing requests

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Eugeniy Paltsev 

commit db05c481977599236f12a85e55de9f5ab37b0a2c upstream.

drm fbdev emulation doesn't support changing the pixel format at all,
so reject all pixel format changing requests.

Cc: sta...@vger.kernel.org
Signed-off-by: Eugeniy Paltsev 
Reviewed-by: Ville Syrjälä 
Signed-off-by: Daniel Vetter 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20181003164538.5534-1-eugeniy.palt...@synopsys.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_fb_helper.c |   91 +++-
 1 file changed, 26 insertions(+), 65 deletions(-)

--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1490,6 +1490,25 @@ unlock:
 }
 EXPORT_SYMBOL(drm_fb_helper_ioctl);
 
+static bool drm_fb_pixel_format_equal(const struct fb_var_screeninfo *var_1,
+ const struct fb_var_screeninfo *var_2)
+{
+   return var_1->bits_per_pixel == var_2->bits_per_pixel &&
+  var_1->grayscale == var_2->grayscale &&
+  var_1->red.offset == var_2->red.offset &&
+  var_1->red.length == var_2->red.length &&
+  var_1->red.msb_right == var_2->red.msb_right &&
+  var_1->green.offset == var_2->green.offset &&
+  var_1->green.length == var_2->green.length &&
+  var_1->green.msb_right == var_2->green.msb_right &&
+  var_1->blue.offset == var_2->blue.offset &&
+  var_1->blue.length == var_2->blue.length &&
+  var_1->blue.msb_right == var_2->blue.msb_right &&
+  var_1->transp.offset == var_2->transp.offset &&
+  var_1->transp.length == var_2->transp.length &&
+  var_1->transp.msb_right == var_2->transp.msb_right;
+}
+
 /**
  * drm_fb_helper_check_var - implementation for &fb_ops.fb_check_var
  * @var: screeninfo to check
@@ -1500,7 +1519,6 @@ int drm_fb_helper_check_var(struct fb_va
 {
struct drm_fb_helper *fb_helper = info->par;
struct drm_framebuffer *fb = fb_helper->fb;
-   int depth;
 
if (var->pixclock != 0 || in_dbg_master())
return -EINVAL;
@@ -1520,72 +1538,15 @@ int drm_fb_helper_check_var(struct fb_va
return -EINVAL;
}
 
-   switch (var->bits_per_pixel) {
-   case 16:
-   depth = (var->green.length == 6) ? 16 : 15;
-   break;
-   case 32:
-   depth = (var->transp.length > 0) ? 32 : 24;
-   break;
-   default:
-   depth = var->bits_per_pixel;
-   break;
-   }
-
-   switch (depth) {
-   case 8:
-   var->red.offset = 0;
-   var->green.offset = 0;
-   var->blue.offset = 0;
-   var->red.length = 8;
-   var->green.length = 8;
-   var->blue.length = 8;
-   var->transp.length = 0;
-   var->transp.offset = 0;
-   break;
-   case 15:
-   var->red.offset = 10;
-   var->green.offset = 5;
-   var->blue.offset = 0;
-   var->red.length = 5;
-   var->green.length = 5;
-   var->blue.length = 5;
-   var->transp.length = 1;
-   var->transp.offset = 15;
-   break;
-   case 16:
-   var->red.offset = 11;
-   var->green.offset = 5;
-   var->blue.offset = 0;
-   var->red.length = 5;
-   var->green.length = 6;
-   var->blue.length = 5;
-   var->transp.length = 0;
-   var->transp.offset = 0;
-   break;
-   case 24:
-   var->red.offset = 16;
-   var->green.offset = 8;
-   var->blue.offset = 0;
-   var->red.length = 8;
-   var->green.length = 8;
-   var->blue.length = 8;
-   var->transp.length = 0;
-   var->transp.offset = 0;
-   break;
-   case 32:
-   var->red.offset = 16;
-   var->green.offset = 8;
-   var->blue.offset = 0;
-   var->red.length = 8;
-   var->green.length = 8;
-   var->blue.length = 8;
-   var->transp.length = 8;
-   var->transp.offset = 24;
-   break;
-   default:
+   /*
+* drm fbdev emulation doesn't support changing the pixel format at all,
+* so reject all pixel format changing requests.
+*/
+   if (!drm_fb_pixel_format_equal(var, &info->var)) {
+   DRM_DEBUG("fbdev emulation doesn't support changing the pixel 
format\n");
return -EINVAL;
}
+
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_check_var);




[PATCH 4.9 155/171] ahci: dont ignore result code of ahci_reset_controller()

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit d312fefea8387503375f728855c9a62de20c9665 ]

ahci_pci_reset_controller() calls ahci_reset_controller(), which may
fail, but ignores the result code and always returns success. This
may result in failures like below

  ahci :02:00.0: version 3.0
  ahci :02:00.0: enabling device ( -> 0003)
  ahci :02:00.0: SSS flag set, parallel bus scan disabled
  ahci :02:00.0: controller reset failed (0x)
  ahci :02:00.0: failed to stop engine (-5)
... repeated many times ...
  ahci :02:00.0: failed to stop engine (-5)
  Unable to handle kernel paging request at virtual address 093f9018
...
  PC is at ahci_stop_engine+0x5c/0xd8 [libahci]
  LR is at ahci_deinit_port.constprop.12+0x1c/0xc0 [libahci]
...
  [] ahci_stop_engine+0x5c/0xd8 [libahci]
  [] ahci_deinit_port.constprop.12+0x1c/0xc0 [libahci]
  [] ahci_init_controller+0x80/0x168 [libahci]
  [] ahci_pci_init_controller+0x60/0x68 [ahci]
  [] ahci_init_one+0x75c/0xd88 [ahci]
  [] local_pci_probe+0x3c/0xb8
  [] pci_device_probe+0x138/0x170
  [] driver_probe_device+0x2dc/0x458
  [] __driver_attach+0x114/0x118
  [] bus_for_each_dev+0x60/0xa0
  [] driver_attach+0x20/0x28
  [] bus_add_driver+0x1f0/0x2a8
  [] driver_register+0x60/0xf8
  [] __pci_register_driver+0x3c/0x48
  [] ahci_pci_driver_init+0x1c/0x1000 [ahci]
  [] do_one_initcall+0x38/0x120

where an obvious hardware level failure results in an unnecessary 15 second
delay and a subsequent crash.

So record the result code of ahci_reset_controller() and relay it, rather
than ignoring it.

Signed-off-by: Ard Biesheuvel 
Signed-off-by: Tejun Heo 
Signed-off-by: Sasha Levin 
---
 drivers/ata/ahci.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index faa91f8a17a5..5408a292078b 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -624,8 +624,11 @@ static void ahci_pci_save_initial_config(struct pci_dev 
*pdev,
 static int ahci_pci_reset_controller(struct ata_host *host)
 {
struct pci_dev *pdev = to_pci_dev(host->dev);
+   int rc;
 
-   ahci_reset_controller(host);
+   rc = ahci_reset_controller(host);
+   if (rc)
+   return rc;
 
if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
struct ahci_host_priv *hpriv = host->private_data;
-- 
2.17.1





[PATCH 4.9 137/171] ipv6/ndisc: Preserve IPv6 control buffer if protocol error handlers are called

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Stefano Brivio 

[ Upstream commit ee1abcf689353f36d9322231b4320926096bdee0 ]

Commit a61bbcf28a8c ("[NET]: Store skb->timestamp as offset to a base
timestamp") introduces a neighbour control buffer and zeroes it out in
ndisc_rcv(), as ndisc_recv_ns() uses it.

Commit f2776ff04722 ("[IPV6]: Fix address/interface handling in UDP and
DCCP, according to the scoping architecture.") introduces the usage of the
IPv6 control buffer in protocol error handlers (e.g. inet6_iif() in
present-day __udp6_lib_err()).

Now, with commit b94f1c0904da ("ipv6: Use icmpv6_notify() to propagate
redirect, instead of rt6_redirect()."), we call protocol error handlers
from ndisc_redirect_rcv(), after the control buffer is already stolen and
some parts are already zeroed out. This implies that inet6_iif() on this
path will always return zero.

This gives unexpected results on UDP socket lookup in __udp6_lib_err(), as
we might actually need to match sockets for a given interface.

Instead of always claiming the control buffer in ndisc_rcv(), do that only
when needed.

Fixes: b94f1c0904da ("ipv6: Use icmpv6_notify() to propagate redirect, instead 
of rt6_redirect().")
Signed-off-by: Stefano Brivio 
Reviewed-by: Sabrina Dubroca 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/ipv6/ndisc.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1692,10 +1692,9 @@ int ndisc_rcv(struct sk_buff *skb)
return 0;
}
 
-   memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb));
-
switch (msg->icmph.icmp6_type) {
case NDISC_NEIGHBOUR_SOLICITATION:
+   memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb));
ndisc_recv_ns(skb);
break;
 




[PATCH 4.9 165/171] USB: fix the usbfs flag sanitization for control transfers

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Alan Stern 

commit 665c365a77fbfeabe52694aedf3446d5f2f1ce42 upstream.

Commit 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more") checks the
transfer flags for URBs submitted from userspace via usbfs.  However,
the check for whether the USBDEVFS_URB_SHORT_NOT_OK flag should be
allowed for a control transfer was added in the wrong place, before
the code has properly determined the direction of the control
transfer.  (Control transfers are special because for them, the
direction is set by the bRequestType byte of the Setup packet rather
than direction bit of the endpoint address.)

This patch moves code which sets up the allow_short flag for control
transfers down after is_in has been set to the correct value.

Signed-off-by: Alan Stern 
Reported-and-tested-by: syzbot+24a30223a4b609bb8...@syzkaller.appspotmail.com
Fixes: 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more")
CC: Oliver Neukum 
CC: 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/core/devio.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1490,8 +1490,6 @@ static int proc_do_submiturb(struct usb_
u = 0;
switch (uurb->type) {
case USBDEVFS_URB_TYPE_CONTROL:
-   if (is_in)
-   allow_short = true;
if (!usb_endpoint_xfer_control(&ep->desc))
return -EINVAL;
/* min 8 byte setup packet */
@@ -1521,6 +1519,8 @@ static int proc_do_submiturb(struct usb_
is_in = 0;
uurb->endpoint &= ~USB_DIR_IN;
}
+   if (is_in)
+   allow_short = true;
snoop(&ps->dev->dev, "control urb: bRequestType=%02x "
"bRequest=%02x wValue=%04x "
"wIndex=%04x wLength=%04x\n",




[PATCH 4.9 154/171] crypto: shash - Fix a sleep-in-atomic bug in shash_setkey_unaligned

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 9039f3ef446e9ffa200200c934f049add9e58426 ]

The SCTP program may sleep under a spinlock, and the function call path is:
sctp_generate_t3_rtx_event (acquire the spinlock)
  sctp_do_sm
sctp_side_effects
  sctp_cmd_interpreter
sctp_make_init_ack
  sctp_pack_cookie
crypto_shash_setkey
  shash_setkey_unaligned
kmalloc(GFP_KERNEL)

For the same reason, the orinoco driver may sleep in interrupt handler,
and the function call path is:
orinoco_rx_isr_tasklet
  orinoco_rx
orinoco_mic
  crypto_shash_setkey
shash_setkey_unaligned
  kmalloc(GFP_KERNEL)

To fix it, GFP_KERNEL is replaced with GFP_ATOMIC.
This bug is found by my static analysis tool and my code review.

Signed-off-by: Jia-Ju Bai 
Signed-off-by: Herbert Xu 
Signed-off-by: Sasha Levin 
---
 crypto/shash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/shash.c b/crypto/shash.c
index d5bd2f05d036..4f047c7eeca7 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -41,7 +41,7 @@ static int shash_setkey_unaligned(struct crypto_shash *tfm, 
const u8 *key,
int err;
 
absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1));
-   buffer = kmalloc(absize, GFP_KERNEL);
+   buffer = kmalloc(absize, GFP_ATOMIC);
if (!buffer)
return -ENOMEM;
 
-- 
2.17.1





[PATCH 4.14 21/31] usb: usbip: Fix BUG: KASAN: slab-out-of-bounds in vhci_hub_control()

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Shuah Khan (Samsung OSG) 

commit 81f7567c51ad97668d1c3a48e8ecc482e64d4161 upstream.

vhci_hub_control() accesses port_status array with out of bounds port
value. Fix it to reference port_status[] only with a valid rhport value
when invalid_rhport flag is true.

The invalid_rhport flag is set early on after detecting in port value
is within the bounds or not.

The following is used reproduce the problem and verify the fix:
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14ed8ab640

Reported-by: syzbot+bccc1fe10b70fadc7...@syzkaller.appspotmail.com
Cc: stable 
Signed-off-by: Shuah Khan (Samsung OSG) 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/usbip/vhci_hcd.c |   57 +++
 1 file changed, 42 insertions(+), 15 deletions(-)

--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -332,8 +332,9 @@ static int vhci_hub_control(struct usb_h
struct vhci_hcd *vhci_hcd;
struct vhci *vhci;
int retval = 0;
-   int rhport;
+   int rhport = -1;
unsigned long   flags;
+   bool invalid_rhport = false;
 
u32 prev_port_status[VHCI_HC_PORTS];
 
@@ -348,9 +349,19 @@ static int vhci_hub_control(struct usb_h
usbip_dbg_vhci_rh("typeReq %x wValue %x wIndex %x\n", typeReq, wValue,
  wIndex);
 
-   if (wIndex > VHCI_HC_PORTS)
-   pr_err("invalid port number %d\n", wIndex);
-   rhport = wIndex - 1;
+   /*
+* wIndex can be 0 for some request types (typeReq). rhport is
+* in valid range when wIndex >= 1 and < VHCI_HC_PORTS.
+*
+* Reference port_status[] only with valid rhport when
+* invalid_rhport is false.
+*/
+   if (wIndex < 1 || wIndex > VHCI_HC_PORTS) {
+   invalid_rhport = true;
+   if (wIndex > VHCI_HC_PORTS)
+   pr_err("invalid port number %d\n", wIndex);
+   } else
+   rhport = wIndex - 1;
 
vhci_hcd = hcd_to_vhci_hcd(hcd);
vhci = vhci_hcd->vhci;
@@ -359,8 +370,9 @@ static int vhci_hub_control(struct usb_h
 
/* store old status and compare now and old later */
if (usbip_dbg_flag_vhci_rh) {
-   memcpy(prev_port_status, vhci_hcd->port_status,
-   sizeof(prev_port_status));
+   if (!invalid_rhport)
+   memcpy(prev_port_status, vhci_hcd->port_status,
+   sizeof(prev_port_status));
}
 
switch (typeReq) {
@@ -368,8 +380,10 @@ static int vhci_hub_control(struct usb_h
usbip_dbg_vhci_rh(" ClearHubFeature\n");
break;
case ClearPortFeature:
-   if (rhport < 0)
+   if (invalid_rhport) {
+   pr_err("invalid port number %d\n", wIndex);
goto error;
+   }
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
if (hcd->speed == HCD_USB3) {
@@ -429,9 +443,10 @@ static int vhci_hub_control(struct usb_h
break;
case GetPortStatus:
usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
-   if (wIndex < 1) {
+   if (invalid_rhport) {
pr_err("invalid port number %d\n", wIndex);
retval = -EPIPE;
+   goto error;
}
 
/* we do not care about resume. */
@@ -527,16 +542,20 @@ static int vhci_hub_control(struct usb_h
goto error;
}
 
-   if (rhport < 0)
+   if (invalid_rhport) {
+   pr_err("invalid port number %d\n", wIndex);
goto error;
+   }
 
vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND;
break;
case USB_PORT_FEAT_POWER:
usbip_dbg_vhci_rh(
" SetPortFeature: USB_PORT_FEAT_POWER\n");
-   if (rhport < 0)
+   if (invalid_rhport) {
+   pr_err("invalid port number %d\n", wIndex);
goto error;
+   }
if (hcd->speed == HCD_USB3)
vhci_hcd->port_status[rhport] |= 
USB_SS_PORT_STAT_POWER;
else
@@ -545,8 +564,10 @@ static int vhci_hub_control(struct usb_h
case USB_PORT_FEAT_BH_PORT_RESET:
usbip_dbg_vhci_rh(
" SetPortFeature: 
USB_PORT_FEAT_BH_PORT_RESET\n");
-   if (rhport < 0)
+  

[PATCH 4.14 25/31] sched/fair: Fix throttle_list starvation with low CFS quota

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Phil Auld 

commit baa9be4ffb55876923dc9716abc0a448e510ba30 upstream.

With a very low cpu.cfs_quota_us setting, such as the minimum of 1000,
distribute_cfs_runtime may not empty the throttled_list before it runs
out of runtime to distribute. In that case, due to the change from
c06f04c7048 to put throttled entries at the head of the list, later entries
on the list will starve.  Essentially, the same X processes will get pulled
off the list, given CPU time and then, when expired, get put back on the
head of the list where distribute_cfs_runtime will give runtime to the same
set of processes leaving the rest.

Fix the issue by setting a bit in struct cfs_bandwidth when
distribute_cfs_runtime is running, so that the code in throttle_cfs_rq can
decide to put the throttled entry on the tail or the head of the list.  The
bit is set/cleared by the callers of distribute_cfs_runtime while they hold
cfs_bandwidth->lock.

This is easy to reproduce with a handful of CPU consumers. I use 'crash' on
the live system. In some cases you can simply look at the throttled list and
see the later entries are not changing:

  crash> list cfs_rq.throttled_list -H 0x90b54f6ade40 -s 
cfs_rq.runtime_remaining | paste - - | awk '{print $1"  "$4}' | pr -t -n3
1 90b56cb2d200  -976050
2 90b56cb2cc00  -484925
3 90b56cb2bc00  -658814
4 90b56cb2ba00  -275365
5 90b166a45600  -135138
6 90b56cb2da00  -282505
7 90b56cb2e000  -148065
8 90b56cb2fa00  -872591
9 90b56cb2c000  -84687
   10 90b56cb2f000  -87237
   11 90b166a40a00  -164582

  crash> list cfs_rq.throttled_list -H 0x90b54f6ade40 -s 
cfs_rq.runtime_remaining | paste - - | awk '{print $1"  "$4}' | pr -t -n3
1 90b56cb2d200  -994147
2 90b56cb2cc00  -306051
3 90b56cb2bc00  -961321
4 90b56cb2ba00  -24490
5 90b166a45600  -135138
6 90b56cb2da00  -282505
7 90b56cb2e000  -148065
8 90b56cb2fa00  -872591
9 90b56cb2c000  -84687
   10 90b56cb2f000  -87237
   11 90b166a40a00  -164582

Sometimes it is easier to see by finding a process getting starved and looking
at the sched_info:

  crash> task 8eb765994500 sched_info
  PID: 7800   TASK: 8eb765994500  CPU: 16  COMMAND: "cputest"
sched_info = {
  pcount = 8,
  run_delay = 697094208,
  last_arrival = 240260125039,
  last_queued = 240260327513
},
  crash> task 8eb765994500 sched_info
  PID: 7800   TASK: 8eb765994500  CPU: 16  COMMAND: "cputest"
sched_info = {
  pcount = 8,
  run_delay = 697094208,
  last_arrival = 240260125039,
  last_queued = 240260327513
},

Signed-off-by: Phil Auld 
Reviewed-by: Ben Segall 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Fixes: c06f04c70489 ("sched: Fix potential near-infinite 
distribute_cfs_runtime() loop")
Link: http://lkml.kernel.org/r/20181008143639.ga4...@pauld.bos.csb
Signed-off-by: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/sched/fair.c  |   22 +++---
 kernel/sched/sched.h |2 ++
 2 files changed, 21 insertions(+), 3 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4299,9 +4299,13 @@ static void throttle_cfs_rq(struct cfs_r
 
/*
 * Add to the _head_ of the list, so that an already-started
-* distribute_cfs_runtime will not see us
+* distribute_cfs_runtime will not see us. If disribute_cfs_runtime is
+* not running add to the tail so that later runqueues don't get 
starved.
 */
-   list_add_rcu(&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq);
+   if (cfs_b->distribute_running)
+   list_add_rcu(&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq);
+   else
+   list_add_tail_rcu(&cfs_rq->throttled_list, 
&cfs_b->throttled_cfs_rq);
 
/*
 * If we're the first throttled task, make sure the bandwidth
@@ -4445,14 +4449,16 @@ static int do_sched_cfs_period_timer(str
 * in us over-using our runtime if it is all used during this loop, but
 * only by limited amounts in that extreme case.
 */
-   while (throttled && cfs_b->runtime > 0) {
+   while (throttled && cfs_b->runtime > 0 && !cfs_b->distribute_running) {
runtime = cfs_b->runtime;
+   cfs_b->distribute_running = 1;
raw_spin_unlock(&cfs_b->lock);
/* we can't nest cfs_b->lock while distributing bandwidth */
runtime = distribute_cfs_runtime(cfs_b, runtime,
 runtime_expires);
raw_spin_lock(&cfs_b->lock);
 
+   cfs_b->distribute_running = 0;
throttled = !list_e

[PATCH 4.14 04/31] USB: serial: option: add two-endpoints device-id flag

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

commit 35aecc02b5b621782111f64cbb032c7f6a90bb32 upstream

Allow matching on interfaces having two endpoints by adding a new
device-id flag.

This allows for the handling of devices whose interface numbers can
change (e.g. Quectel EP06) to be contained in the device-id table.

The upstream commit removes a variable that is still in use in the 4.14
version of the option-driver, so the removal is undone.

Tested-by: Kristian Evensen 
Cc: stable 
Signed-off-by: Johan Hovold 
Signed-off-by: Kristian Evensen 
Signed-off-by: Sasha Levin 
---
 drivers/usb/serial/option.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index d8d3cb18e9ea..392fddc80c44 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -564,6 +564,9 @@ static void option_instat_callback(struct urb *urb);
 /* Interface is reserved */
 #define RSVD(ifnum)((BIT(ifnum) & 0xff) << 0)
 
+/* Interface must have two endpoints */
+#define NUMEP2 BIT(16)
+
 
 static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
@@ -1085,7 +1088,7 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
  .driver_info = RSVD(4) },
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 
QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
- .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) },
+ .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 
QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
@@ -2012,16 +2015,11 @@ static int option_probe(struct usb_serial *serial,
return -ENODEV;
 
/*
-* Don't bind to the QMI device of the Quectel EP06/EG06/EM06. Class,
-* subclass and protocol is 0xff for both the diagnostic port and the
-* QMI interface, but the diagnostic port only has two endpoints (QMI
-* has three).
+* Allow matching on bNumEndpoints for devices whose interface numbers
+* can change (e.g. Quectel EP06).
 */
-   if (dev_desc->idVendor == cpu_to_le16(QUECTEL_VENDOR_ID) &&
-   dev_desc->idProduct == cpu_to_le16(QUECTEL_PRODUCT_EP06) &&
-   iface_desc->bInterfaceSubClass && iface_desc->bNumEndpoints == 3) {
+   if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
return -ENODEV;
-   }
 
/* Store the device flags so we can use them during attach. */
usb_set_serial_data(serial, (void *)device_flags);
-- 
2.17.1





[PATCH 4.18 12/34] drm: fb-helper: Reject all pixel format changing requests

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Eugeniy Paltsev 

commit db05c481977599236f12a85e55de9f5ab37b0a2c upstream.

drm fbdev emulation doesn't support changing the pixel format at all,
so reject all pixel format changing requests.

Cc: sta...@vger.kernel.org
Signed-off-by: Eugeniy Paltsev 
Reviewed-by: Ville Syrjälä 
Signed-off-by: Daniel Vetter 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20181003164538.5534-1-eugeniy.palt...@synopsys.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_fb_helper.c |   91 +++-
 1 file changed, 26 insertions(+), 65 deletions(-)

--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1561,6 +1561,25 @@ unlock:
 }
 EXPORT_SYMBOL(drm_fb_helper_ioctl);
 
+static bool drm_fb_pixel_format_equal(const struct fb_var_screeninfo *var_1,
+ const struct fb_var_screeninfo *var_2)
+{
+   return var_1->bits_per_pixel == var_2->bits_per_pixel &&
+  var_1->grayscale == var_2->grayscale &&
+  var_1->red.offset == var_2->red.offset &&
+  var_1->red.length == var_2->red.length &&
+  var_1->red.msb_right == var_2->red.msb_right &&
+  var_1->green.offset == var_2->green.offset &&
+  var_1->green.length == var_2->green.length &&
+  var_1->green.msb_right == var_2->green.msb_right &&
+  var_1->blue.offset == var_2->blue.offset &&
+  var_1->blue.length == var_2->blue.length &&
+  var_1->blue.msb_right == var_2->blue.msb_right &&
+  var_1->transp.offset == var_2->transp.offset &&
+  var_1->transp.length == var_2->transp.length &&
+  var_1->transp.msb_right == var_2->transp.msb_right;
+}
+
 /**
  * drm_fb_helper_check_var - implementation for &fb_ops.fb_check_var
  * @var: screeninfo to check
@@ -1571,7 +1590,6 @@ int drm_fb_helper_check_var(struct fb_va
 {
struct drm_fb_helper *fb_helper = info->par;
struct drm_framebuffer *fb = fb_helper->fb;
-   int depth;
 
if (var->pixclock != 0 || in_dbg_master())
return -EINVAL;
@@ -1591,72 +1609,15 @@ int drm_fb_helper_check_var(struct fb_va
return -EINVAL;
}
 
-   switch (var->bits_per_pixel) {
-   case 16:
-   depth = (var->green.length == 6) ? 16 : 15;
-   break;
-   case 32:
-   depth = (var->transp.length > 0) ? 32 : 24;
-   break;
-   default:
-   depth = var->bits_per_pixel;
-   break;
-   }
-
-   switch (depth) {
-   case 8:
-   var->red.offset = 0;
-   var->green.offset = 0;
-   var->blue.offset = 0;
-   var->red.length = 8;
-   var->green.length = 8;
-   var->blue.length = 8;
-   var->transp.length = 0;
-   var->transp.offset = 0;
-   break;
-   case 15:
-   var->red.offset = 10;
-   var->green.offset = 5;
-   var->blue.offset = 0;
-   var->red.length = 5;
-   var->green.length = 5;
-   var->blue.length = 5;
-   var->transp.length = 1;
-   var->transp.offset = 15;
-   break;
-   case 16:
-   var->red.offset = 11;
-   var->green.offset = 5;
-   var->blue.offset = 0;
-   var->red.length = 5;
-   var->green.length = 6;
-   var->blue.length = 5;
-   var->transp.length = 0;
-   var->transp.offset = 0;
-   break;
-   case 24:
-   var->red.offset = 16;
-   var->green.offset = 8;
-   var->blue.offset = 0;
-   var->red.length = 8;
-   var->green.length = 8;
-   var->blue.length = 8;
-   var->transp.length = 0;
-   var->transp.offset = 0;
-   break;
-   case 32:
-   var->red.offset = 16;
-   var->green.offset = 8;
-   var->blue.offset = 0;
-   var->red.length = 8;
-   var->green.length = 8;
-   var->blue.length = 8;
-   var->transp.length = 8;
-   var->transp.offset = 24;
-   break;
-   default:
+   /*
+* drm fbdev emulation doesn't support changing the pixel format at all,
+* so reject all pixel format changing requests.
+*/
+   if (!drm_fb_pixel_format_equal(var, &info->var)) {
+   DRM_DEBUG("fbdev emulation doesn't support changing the pixel 
format\n");
return -EINVAL;
}
+
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_check_var);




[PATCH 4.14 28/31] x86/percpu: Fix this_cpu_read()

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

commit b59167ac7bafd804c91e49ad53c6d33a7394d4c8 upstream.

Eric reported that a sequence count loop using this_cpu_read() got
optimized out. This is wrong, this_cpu_read() must imply READ_ONCE()
because the interface is IRQ-safe, therefore an interrupt can have
changed the per-cpu value.

Fixes: 7c3576d261ce ("[PATCH] i386: Convert PDA into the percpu section")
Reported-by: Eric Dumazet 
Signed-off-by: Peter Zijlstra (Intel) 
Signed-off-by: Thomas Gleixner 
Acked-by: Eric Dumazet 
Cc: h...@zytor.com
Cc: eric.duma...@gmail.com
Cc: b...@alien8.de
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181011104019.748208...@infradead.org
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/include/asm/percpu.h |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -185,22 +185,22 @@ do {  
\
typeof(var) pfo_ret__;  \
switch (sizeof(var)) {  \
case 1: \
-   asm(op "b "__percpu_arg(1)",%0" \
+   asm volatile(op "b "__percpu_arg(1)",%0"\
: "=q" (pfo_ret__)  \
: "m" (var));   \
break;  \
case 2: \
-   asm(op "w "__percpu_arg(1)",%0" \
+   asm volatile(op "w "__percpu_arg(1)",%0"\
: "=r" (pfo_ret__)  \
: "m" (var));   \
break;  \
case 4: \
-   asm(op "l "__percpu_arg(1)",%0" \
+   asm volatile(op "l "__percpu_arg(1)",%0"\
: "=r" (pfo_ret__)  \
: "m" (var));   \
break;  \
case 8: \
-   asm(op "q "__percpu_arg(1)",%0" \
+   asm volatile(op "q "__percpu_arg(1)",%0"\
: "=r" (pfo_ret__)  \
: "m" (var));   \
break;  \




[PATCH 4.14 26/31] x86/tsc: Force inlining of cyc2ns bits

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

commit 4907c68abd3f60f650f98d5a69d4ec77c0bde44f upstream.

Looking at the asm for native_sched_clock() I noticed we don't inline
enough. Mostly caused by sharing code with cyc2ns_read_begin(), which
we didn't used to do. So mark all that __force_inline to make it DTRT.

Fixes: 59eaef78bfea ("x86/tsc: Remodel cyc2ns to use seqcount_latch()")
Reported-by: Eric Dumazet 
Signed-off-by: Peter Zijlstra (Intel) 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Cc: eric.duma...@gmail.com
Cc: b...@alien8.de
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181011104019.695196...@infradead.org
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/tsc.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -60,7 +60,7 @@ struct cyc2ns {
 
 static DEFINE_PER_CPU_ALIGNED(struct cyc2ns, cyc2ns);
 
-void cyc2ns_read_begin(struct cyc2ns_data *data)
+void __always_inline cyc2ns_read_begin(struct cyc2ns_data *data)
 {
int seq, idx;
 
@@ -77,7 +77,7 @@ void cyc2ns_read_begin(struct cyc2ns_dat
} while (unlikely(seq != this_cpu_read(cyc2ns.seq.sequence)));
 }
 
-void cyc2ns_read_end(void)
+void __always_inline cyc2ns_read_end(void)
 {
preempt_enable_notrace();
 }
@@ -123,7 +123,7 @@ static void cyc2ns_init(int cpu)
seqcount_init(&c2n->seq);
 }
 
-static inline unsigned long long cycles_2_ns(unsigned long long cyc)
+static __always_inline unsigned long long cycles_2_ns(unsigned long long cyc)
 {
struct cyc2ns_data data;
unsigned long long ns;




[PATCH 4.14 27/31] x86, hibernate: Fix nosave_regions setup for hibernation

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Zhimin Gu 

commit cc55f7537db6af371e9c1c6a71161ee40f918824 upstream.

On 32bit systems, nosave_regions(non RAM areas) located between
max_low_pfn and max_pfn are not excluded from hibernation snapshot
currently, which may result in a machine check exception when
trying to access these unsafe regions during hibernation:

[  612.800453] Disabling lock debugging due to kernel taint
[  612.805786] mce: [Hardware Error]: CPU 0: Machine Check Exception: 5 Bank 6: 
fe801136
[  612.814344] mce: [Hardware Error]: RIP !INEXACT! 60: 
{swsusp_save+0x436/0x560}
[  612.823167] mce: [Hardware Error]: TSC 1f5939fe276 ADDR dd00 MISC 
30e086
[  612.830677] mce: [Hardware Error]: PROCESSOR 0:306c3 TIME 1529487426 SOCKET 
0 APIC 0 microcode 24
[  612.839581] mce: [Hardware Error]: Run the above through 'mcelog --ascii'
[  612.846394] mce: [Hardware Error]: Machine check: Processor context corrupt
[  612.853380] Kernel panic - not syncing: Fatal machine check
[  612.858978] Kernel Offset: 0x1800 from 0xc100 (relocation range: 
0xc000-0xf7ffdfff)

This is because on 32bit systems, pages above max_low_pfn are regarded
as high memeory, and accessing unsafe pages might cause expected MCE.
On the problematic 32bit system, there are reserved memory above low
memory, which triggered the MCE:

e820 memory mapping:
[0.00] BIOS-e820: [mem 0x-0x0009d7ff] usable
[0.00] BIOS-e820: [mem 0x0009d800-0x0009] reserved
[0.00] BIOS-e820: [mem 0x000e-0x000f] reserved
[0.00] BIOS-e820: [mem 0x0010-0xd160cfff] usable
[0.00] BIOS-e820: [mem 0xd160d000-0xd1613fff] ACPI NVS
[0.00] BIOS-e820: [mem 0xd1614000-0xd1a44fff] usable
[0.00] BIOS-e820: [mem 0xd1a45000-0xd1ec] reserved
[0.00] BIOS-e820: [mem 0xd1ed-0xd7eeafff] usable
[0.00] BIOS-e820: [mem 0xd7eeb000-0xd7ff] reserved
[0.00] BIOS-e820: [mem 0xd800-0xd875] usable
[0.00] BIOS-e820: [mem 0xd876-0xd87f] reserved
[0.00] BIOS-e820: [mem 0xd880-0xd8fadfff] usable
[0.00] BIOS-e820: [mem 0xd8fae000-0xd8ff] ACPI data
[0.00] BIOS-e820: [mem 0xd900-0xda71bfff] usable
[0.00] BIOS-e820: [mem 0xda71c000-0xda7f] ACPI NVS
[0.00] BIOS-e820: [mem 0xda80-0xdbb8bfff] usable
[0.00] BIOS-e820: [mem 0xdbb8c000-0xdbff] reserved
[0.00] BIOS-e820: [mem 0xdd00-0xdf1f] reserved
[0.00] BIOS-e820: [mem 0xf800-0xfbff] reserved
[0.00] BIOS-e820: [mem 0xfec0-0xfec00fff] reserved
[0.00] BIOS-e820: [mem 0xfed0-0xfed03fff] reserved
[0.00] BIOS-e820: [mem 0xfed1c000-0xfed1] reserved
[0.00] BIOS-e820: [mem 0xfee0-0xfee00fff] reserved
[0.00] BIOS-e820: [mem 0xff00-0x] reserved
[0.00] BIOS-e820: [mem 0x0001-0x00041edf] usable

Fix this problem by changing pfn limit from max_low_pfn to max_pfn.
This fix does not impact 64bit system because on 64bit max_low_pfn
is the same as max_pfn.

Signed-off-by: Zhimin Gu 
Acked-by: Pavel Machek 
Signed-off-by: Chen Yu 
Acked-by: Thomas Gleixner 
Cc: All applicable 
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/setup.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1287,7 +1287,7 @@ void __init setup_arch(char **cmdline_p)
kvm_guest_init();
 
e820__reserve_resources();
-   e820__register_nosave_regions(max_low_pfn);
+   e820__register_nosave_regions(max_pfn);
 
x86_init.resources.reserve_resources();
 




[PATCH 4.18 14/34] IB/ucm: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit 0295e39595e1146522f2722715dba7f7fba42217 upstream.

hdr.cmd can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/infiniband/core/ucm.c:1127 ib_ucm_write() warn: potential
spectre issue 'ucm_cmd_table' [r] (local cap)

Fix this by sanitizing hdr.cmd before using it to index
ucm_cmd_table.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Signed-off-by: Doug Ledford 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/ucm.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -46,6 +46,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -1123,6 +1125,7 @@ static ssize_t ib_ucm_write(struct file
 
if (hdr.cmd >= ARRAY_SIZE(ucm_cmd_table))
return -EINVAL;
+   hdr.cmd = array_index_nospec(hdr.cmd, ARRAY_SIZE(ucm_cmd_table));
 
if (hdr.in + sizeof(hdr) > len)
return -EINVAL;




[PATCH 4.18 01/34] eeprom: at24: Add support for address-width property

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit a2b3bf4846e5eed62ea6abb096af2c950961033c ]

Provide a flexible way to determine the addressing bits of eeprom.
Pass the addressing bits to driver through address-width property.

Signed-off-by: Alan Chiang 
Signed-off-by: Andy Yeh 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Sasha Levin 
---
 drivers/misc/eeprom/at24.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index f5cc517d1131..7e50e1d6f58c 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -478,6 +478,23 @@ static void at24_properties_to_pdata(struct device *dev,
if (device_property_present(dev, "no-read-rollover"))
chip->flags |= AT24_FLAG_NO_RDROL;
 
+   err = device_property_read_u32(dev, "address-width", &val);
+   if (!err) {
+   switch (val) {
+   case 8:
+   if (chip->flags & AT24_FLAG_ADDR16)
+   dev_warn(dev, "Override address width to be 8, 
while default is 16\n");
+   chip->flags &= ~AT24_FLAG_ADDR16;
+   break;
+   case 16:
+   chip->flags |= AT24_FLAG_ADDR16;
+   break;
+   default:
+   dev_warn(dev, "Bad \"address-width\" property: %u\n",
+val);
+   }
+   }
+
err = device_property_read_u32(dev, "size", &val);
if (!err)
chip->byte_len = val;
-- 
2.17.1





[PATCH 4.18 16/34] cdc-acm: correct counting of UART states in serial state notification

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Tobias Herzog 

commit f976d0e5747ca65ccd0fb2a4118b193d70aa1836 upstream.

The usb standard ("Universal Serial Bus Class Definitions for Communication
Devices") distiguishes between "consistent signals" (DSR, DCD), and
"irregular signals" (break, ring, parity error, framing error, overrun).
The bits of "irregular signals" are set, if this error/event occurred on
the device side and are immeadeatly unset, if the serial state notification
was sent.
Like other drivers of real serial ports do, just the occurence of those
events should be counted in serial_icounter_struct (but no 1->0
transitions).

Signed-off-by: Tobias Herzog 
Acked-by: Oliver Neukum 
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/class/cdc-acm.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -309,17 +309,17 @@ static void acm_process_notification(str
 
if (difference & ACM_CTRL_DSR)
acm->iocount.dsr++;
-   if (difference & ACM_CTRL_BRK)
-   acm->iocount.brk++;
-   if (difference & ACM_CTRL_RI)
-   acm->iocount.rng++;
if (difference & ACM_CTRL_DCD)
acm->iocount.dcd++;
-   if (difference & ACM_CTRL_FRAMING)
+   if (newctrl & ACM_CTRL_BRK)
+   acm->iocount.brk++;
+   if (newctrl & ACM_CTRL_RI)
+   acm->iocount.rng++;
+   if (newctrl & ACM_CTRL_FRAMING)
acm->iocount.frame++;
-   if (difference & ACM_CTRL_PARITY)
+   if (newctrl & ACM_CTRL_PARITY)
acm->iocount.parity++;
-   if (difference & ACM_CTRL_OVERRUN)
+   if (newctrl & ACM_CTRL_OVERRUN)
acm->iocount.overrun++;
spin_unlock(&acm->read_lock);
 




[PATCH 4.14 20/31] cdc-acm: fix race between reset and control messaging

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Oliver Neukum 

commit 9397940ed812b942c520e0c25ed4b2c64d57e8b9 upstream.

If a device splits up a control message and a reset() happens
between the parts, the message is lost and already recieved parts
must be dropped.

Signed-off-by: Oliver Neukum 
Fixes: 1aba579f3cf51 ("cdc-acm: handle read pipe errors")
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/class/cdc-acm.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1654,6 +1654,7 @@ static int acm_pre_reset(struct usb_inte
struct acm *acm = usb_get_intfdata(intf);
 
clear_bit(EVENT_RX_STALL, &acm->flags);
+   acm->nb_index = 0; /* pending control transfers are lost */
 
return 0;
 }




[PATCH 4.18 19/34] usb: gadget: storage: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit 9ae24af3669111d418242caec8dd4ebd9ba26860 upstream.

num can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/usb/gadget/function/f_mass_storage.c:3177 fsg_lun_make() warn:
potential spectre issue 'fsg_opts->common->luns' [r] (local cap)

Fix this by sanitizing num before using it to index
fsg_opts->common->luns

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Acked-by: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/gadget/function/f_mass_storage.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -222,6 +222,8 @@
 #include 
 #include 
 
+#include 
+
 #include "configfs.h"
 
 
@@ -3171,6 +3173,7 @@ static struct config_group *fsg_lun_make
fsg_opts = to_fsg_opts(&group->cg_item);
if (num >= FSG_MAX_LUNS)
return ERR_PTR(-ERANGE);
+   num = array_index_nospec(num, FSG_MAX_LUNS);
 
mutex_lock(&fsg_opts->lock);
if (fsg_opts->refcnt || fsg_opts->common->luns[num]) {




[PATCH 4.18 02/34] vfs: swap names of {do,vfs}_clone_file_range()

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

commit a725356b6659469d182d662f22d770d83d3bc7b5 upstream.

Commit 031a072a0b8a ("vfs: call vfs_clone_file_range() under freeze
protection") created a wrapper do_clone_file_range() around
vfs_clone_file_range() moving the freeze protection to former, so
overlayfs could call the latter.

The more common vfs practice is to call do_xxx helpers from vfs_xxx
helpers, where freeze protecction is taken in the vfs_xxx helper, so
this anomality could be a source of confusion.

It seems that commit 8ede205541ff ("ovl: add reflink/copyfile/dedup
support") may have fallen a victim to this confusion -
ovl_clone_file_range() calls the vfs_clone_file_range() helper in the
hope of getting freeze protection on upper fs, but in fact results in
overlayfs allowing to bypass upper fs freeze protection.

Swap the names of the two helpers to conform to common vfs practice
and call the correct helpers from overlayfs and nfsd.

Signed-off-by: Amir Goldstein 
Signed-off-by: Miklos Szeredi 
Fixes: 031a072a0b8a ("vfs: call vfs_clone_file_range() under freeze...")
Signed-off-by: Amir Goldstein 
Signed-off-by: Sasha Levin 
---
 fs/ioctl.c |  2 +-
 fs/nfsd/vfs.c  |  3 ++-
 fs/overlayfs/copy_up.c |  2 +-
 fs/read_write.c| 17 +++--
 include/linux/fs.h | 17 +++--
 5 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index b445b13fc59b..5444fec607ce 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -229,7 +229,7 @@ static long ioctl_file_clone(struct file *dst_file, 
unsigned long srcfd,
ret = -EXDEV;
if (src_file.file->f_path.mnt != dst_file->f_path.mnt)
goto fdput;
-   ret = do_clone_file_range(src_file.file, off, dst_file, destoff, olen);
+   ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen);
 fdput:
fdput(src_file);
return ret;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index b0555d7d8200..613d2fe2 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -541,7 +541,8 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct 
svc_fh *fhp,
 __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst,
u64 dst_pos, u64 count)
 {
-   return nfserrno(do_clone_file_range(src, src_pos, dst, dst_pos, count));
+   return nfserrno(vfs_clone_file_range(src, src_pos, dst, dst_pos,
+count));
 }
 
 ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst,
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index ddaddb4ce4c3..26b477f2538d 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -156,7 +156,7 @@ static int ovl_copy_up_data(struct path *old, struct path 
*new, loff_t len)
}
 
/* Try to use clone_file_range to clone up within the same fs */
-   error = vfs_clone_file_range(old_file, 0, new_file, 0, len);
+   error = do_clone_file_range(old_file, 0, new_file, 0, len);
if (!error)
goto out;
/* Couldn't clone, so now we try to copy the data */
diff --git a/fs/read_write.c b/fs/read_write.c
index 153f8f690490..c9d489684335 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1818,8 +1818,8 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, 
loff_t pos_in,
 }
 EXPORT_SYMBOL(vfs_clone_file_prep_inodes);
 
-int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
-   struct file *file_out, loff_t pos_out, u64 len)
+int do_clone_file_range(struct file *file_in, loff_t pos_in,
+   struct file *file_out, loff_t pos_out, u64 len)
 {
struct inode *inode_in = file_inode(file_in);
struct inode *inode_out = file_inode(file_out);
@@ -1866,6 +1866,19 @@ int vfs_clone_file_range(struct file *file_in, loff_t 
pos_in,
 
return ret;
 }
+EXPORT_SYMBOL(do_clone_file_range);
+
+int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
+struct file *file_out, loff_t pos_out, u64 len)
+{
+   int ret;
+
+   file_start_write(file_out);
+   ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len);
+   file_end_write(file_out);
+
+   return ret;
+}
 EXPORT_SYMBOL(vfs_clone_file_range);
 
 /*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a3afa50bb79f..e73363bd8646 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1813,8 +1813,10 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t 
, struct file *,
 extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
  struct inode *inode_out, loff_t pos_out,
  u64 *len, bool is_dedupe);
+extern int do_clone_file_range(struct file *file_in, loff_t pos_in,
+  struct file *file_out, loff_t pos_out, u64 len);
 extern int v

[PATCH 4.18 17/34] cdc-acm: fix race between reset and control messaging

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Oliver Neukum 

commit 9397940ed812b942c520e0c25ed4b2c64d57e8b9 upstream.

If a device splits up a control message and a reset() happens
between the parts, the message is lost and already recieved parts
must be dropped.

Signed-off-by: Oliver Neukum 
Fixes: 1aba579f3cf51 ("cdc-acm: handle read pipe errors")
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/class/cdc-acm.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1641,6 +1641,7 @@ static int acm_pre_reset(struct usb_inte
struct acm *acm = usb_get_intfdata(intf);
 
clear_bit(EVENT_RX_STALL, &acm->flags);
+   acm->nb_index = 0; /* pending control transfers are lost */
 
return 0;
 }




[PATCH 4.18 27/34] drm/sun4i: Fix an ulong overflow in the dotclock driver

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Boris Brezillon 

commit e84cb605e02f1b3d0aee8d7157419cd8aaa06038 upstream.

The calculated ideal rate can easily overflow an unsigned long, thus
making the best div selection buggy as soon as no ideal match is found
before the overflow occurs.

Fixes: 4731a72df273 ("drm/sun4i: request exact rates to our parents")
Cc: 
Signed-off-by: Boris Brezillon 
Acked-by: Maxime Ripard 
Signed-off-by: Maxime Ripard 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20181018100250.12565-1-boris.brezil...@bootlin.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/sun4i/sun4i_dotclock.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c
+++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
@@ -81,9 +81,19 @@ static long sun4i_dclk_round_rate(struct
int i;
 
for (i = tcon->dclk_min_div; i <= tcon->dclk_max_div; i++) {
-   unsigned long ideal = rate * i;
+   u64 ideal = (u64)rate * i;
unsigned long rounded;
 
+   /*
+* ideal has overflowed the max value that can be stored in an
+* unsigned long, and every clk operation we might do on a
+* truncated u64 value will give us incorrect results.
+* Let's just stop there since bigger dividers will result in
+* the same overflow issue.
+*/
+   if (ideal > ULONG_MAX)
+   goto out;
+
rounded = clk_hw_round_rate(clk_hw_get_parent(hw),
ideal);
 




[PATCH 4.18 34/34] x86/fpu: Fix i486 + no387 boot crash by only saving FPU registers on context switch if there is an FPU

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

commit 2224d616528194b02424c91c2ee254b3d29942c3 upstream.

Booting an i486 with "no387 nofxsr" ends with with the following crash:

   math_emulate: 0060:c101987d
   Kernel panic - not syncing: Math emulation needed in kernel

on the first context switch in user land.

The reason is that copy_fpregs_to_fpstate() tries FNSAVE which does not work
as the FPU is turned off.

This bug was introduced in:

  f1c8cd0176078 ("x86/fpu: Change fpu->fpregs_active users to 
fpu->fpstate_active")

Add a check for X86_FEATURE_FPU before trying to save FPU registers (we
have such a check in switch_fpu_finish() already).

Signed-off-by: Sebastian Andrzej Siewior 
Reviewed-by: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Dave Hansen 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Fixes: f1c8cd0176078 ("x86/fpu: Change fpu->fpregs_active users to 
fpu->fpstate_active")
Link: http://lkml.kernel.org/r/20181016202525.29437-4-bige...@linutronix.de
Signed-off-by: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/include/asm/fpu/internal.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -528,7 +528,7 @@ static inline void fpregs_activate(struc
 static inline void
 switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 {
-   if (old_fpu->initialized) {
+   if (static_cpu_has(X86_FEATURE_FPU) && old_fpu->initialized) {
if (!copy_fpregs_to_fpstate(old_fpu))
old_fpu->last_cpu = -1;
else




[PATCH 4.18 04/34] gpio: mxs: Get rid of external API call

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 833eacc7b5913da9896bacd30db7d490aa777868 ]

The MXS driver was calling back into the GPIO API from
its irqchip. This is not very elegant, as we are a driver,
let's just shortcut back into the gpio_chip .get() function
instead.

This is a tricky case since the .get() callback is not in
this file, instead assigned by bgpio_init(). Calling the
function direcly in the gpio_chip is however the lesser
evil.

Cc: Sascha Hauer 
Cc: Janusz Uzycki 
Signed-off-by: Linus Walleij 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpio-mxs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index e2831ee70cdc..deb539b3316b 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -18,8 +18,6 @@
 #include 
 #include 
 #include 
-/* FIXME: for gpio_get_value(), replace this by direct register read */
-#include 
 #include 
 
 #define MXS_SET0x4
@@ -86,7 +84,7 @@ static int mxs_gpio_set_irq_type(struct irq_data *d, unsigned 
int type)
port->both_edges &= ~pin_mask;
switch (type) {
case IRQ_TYPE_EDGE_BOTH:
-   val = gpio_get_value(port->gc.base + d->hwirq);
+   val = port->gc.get(&port->gc, d->hwirq);
if (val)
edge = GPIO_INT_FALL_EDGE;
else
-- 
2.17.1





[PATCH 4.18 18/34] usb: usbip: Fix BUG: KASAN: slab-out-of-bounds in vhci_hub_control()

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Shuah Khan (Samsung OSG) 

commit 81f7567c51ad97668d1c3a48e8ecc482e64d4161 upstream.

vhci_hub_control() accesses port_status array with out of bounds port
value. Fix it to reference port_status[] only with a valid rhport value
when invalid_rhport flag is true.

The invalid_rhport flag is set early on after detecting in port value
is within the bounds or not.

The following is used reproduce the problem and verify the fix:
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14ed8ab640

Reported-by: syzbot+bccc1fe10b70fadc7...@syzkaller.appspotmail.com
Cc: stable 
Signed-off-by: Shuah Khan (Samsung OSG) 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/usbip/vhci_hcd.c |   57 +++
 1 file changed, 42 insertions(+), 15 deletions(-)

--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -318,8 +318,9 @@ static int vhci_hub_control(struct usb_h
struct vhci_hcd *vhci_hcd;
struct vhci *vhci;
int retval = 0;
-   int rhport;
+   int rhport = -1;
unsigned long   flags;
+   bool invalid_rhport = false;
 
u32 prev_port_status[VHCI_HC_PORTS];
 
@@ -334,9 +335,19 @@ static int vhci_hub_control(struct usb_h
usbip_dbg_vhci_rh("typeReq %x wValue %x wIndex %x\n", typeReq, wValue,
  wIndex);
 
-   if (wIndex > VHCI_HC_PORTS)
-   pr_err("invalid port number %d\n", wIndex);
-   rhport = wIndex - 1;
+   /*
+* wIndex can be 0 for some request types (typeReq). rhport is
+* in valid range when wIndex >= 1 and < VHCI_HC_PORTS.
+*
+* Reference port_status[] only with valid rhport when
+* invalid_rhport is false.
+*/
+   if (wIndex < 1 || wIndex > VHCI_HC_PORTS) {
+   invalid_rhport = true;
+   if (wIndex > VHCI_HC_PORTS)
+   pr_err("invalid port number %d\n", wIndex);
+   } else
+   rhport = wIndex - 1;
 
vhci_hcd = hcd_to_vhci_hcd(hcd);
vhci = vhci_hcd->vhci;
@@ -345,8 +356,9 @@ static int vhci_hub_control(struct usb_h
 
/* store old status and compare now and old later */
if (usbip_dbg_flag_vhci_rh) {
-   memcpy(prev_port_status, vhci_hcd->port_status,
-   sizeof(prev_port_status));
+   if (!invalid_rhport)
+   memcpy(prev_port_status, vhci_hcd->port_status,
+   sizeof(prev_port_status));
}
 
switch (typeReq) {
@@ -354,8 +366,10 @@ static int vhci_hub_control(struct usb_h
usbip_dbg_vhci_rh(" ClearHubFeature\n");
break;
case ClearPortFeature:
-   if (rhport < 0)
+   if (invalid_rhport) {
+   pr_err("invalid port number %d\n", wIndex);
goto error;
+   }
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
if (hcd->speed == HCD_USB3) {
@@ -415,9 +429,10 @@ static int vhci_hub_control(struct usb_h
break;
case GetPortStatus:
usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
-   if (wIndex < 1) {
+   if (invalid_rhport) {
pr_err("invalid port number %d\n", wIndex);
retval = -EPIPE;
+   goto error;
}
 
/* we do not care about resume. */
@@ -513,16 +528,20 @@ static int vhci_hub_control(struct usb_h
goto error;
}
 
-   if (rhport < 0)
+   if (invalid_rhport) {
+   pr_err("invalid port number %d\n", wIndex);
goto error;
+   }
 
vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND;
break;
case USB_PORT_FEAT_POWER:
usbip_dbg_vhci_rh(
" SetPortFeature: USB_PORT_FEAT_POWER\n");
-   if (rhport < 0)
+   if (invalid_rhport) {
+   pr_err("invalid port number %d\n", wIndex);
goto error;
+   }
if (hcd->speed == HCD_USB3)
vhci_hcd->port_status[rhport] |= 
USB_SS_PORT_STAT_POWER;
else
@@ -531,8 +550,10 @@ static int vhci_hub_control(struct usb_h
case USB_PORT_FEAT_BH_PORT_RESET:
usbip_dbg_vhci_rh(
" SetPortFeature: 
USB_PORT_FEAT_BH_PORT_RESET\n");
-   if (rhport < 0)
+  

[PATCH 4.18 24/34] tracing: Fix synthetic event to accept unsigned modifier

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Masami Hiramatsu 

commit 282447ba6b00c64678ffdf964f44e5c8b1c68377 upstream.

Fix synthetic event to accept unsigned modifier for its field type
correctly.

Currently, synthetic_events interface returns error for "unsigned"
modifiers as below;

 # echo "myevent unsigned long var" >> synthetic_events
 sh: write error: Invalid argument

This is because argv_split() breaks "unsigned long" into "unsigned"
and "long", but parse_synth_field() doesn't expected it.

With this fix, synthetic_events can handle the "unsigned long"
correctly like as below;

 # echo "myevent unsigned long var" >> synthetic_events
 # cat synthetic_events
 myeventunsigned long var

Link: 
http://lkml.kernel.org/r/153986832571.18251.8448135724590496531.stgit@devbox

Cc: Shuah Khan 
Cc: Tom Zanussi 
Cc: sta...@vger.kernel.org
Fixes: commit 4b147936fa50 ("tracing: Add support for 'synthetic' events")
Signed-off-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt (VMware) 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/trace/trace_events_hist.c |   30 --
 1 file changed, 24 insertions(+), 6 deletions(-)

--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -747,16 +747,30 @@ static void free_synth_field(struct synt
kfree(field);
 }
 
-static struct synth_field *parse_synth_field(char *field_type,
-char *field_name)
+static struct synth_field *parse_synth_field(int argc, char **argv,
+int *consumed)
 {
struct synth_field *field;
+   const char *prefix = NULL;
+   char *field_type = argv[0], *field_name;
int len, ret = 0;
char *array;
 
if (field_type[0] == ';')
field_type++;
 
+   if (!strcmp(field_type, "unsigned")) {
+   if (argc < 3)
+   return ERR_PTR(-EINVAL);
+   prefix = "unsigned ";
+   field_type = argv[1];
+   field_name = argv[2];
+   *consumed = 3;
+   } else {
+   field_name = argv[1];
+   *consumed = 2;
+   }
+
len = strlen(field_name);
if (field_name[len - 1] == ';')
field_name[len - 1] = '\0';
@@ -769,11 +783,15 @@ static struct synth_field *parse_synth_f
array = strchr(field_name, '[');
if (array)
len += strlen(array);
+   if (prefix)
+   len += strlen(prefix);
field->type = kzalloc(len, GFP_KERNEL);
if (!field->type) {
ret = -ENOMEM;
goto free;
}
+   if (prefix)
+   strcat(field->type, prefix);
strcat(field->type, field_type);
if (array) {
strcat(field->type, array);
@@ -1018,7 +1036,7 @@ static int create_synth_event(int argc,
struct synth_field *field, *fields[SYNTH_FIELDS_MAX];
struct synth_event *event = NULL;
bool delete_event = false;
-   int i, n_fields = 0, ret = 0;
+   int i, consumed = 0, n_fields = 0, ret = 0;
char *name;
 
mutex_lock(&synth_event_mutex);
@@ -1070,13 +1088,13 @@ static int create_synth_event(int argc,
goto err;
}
 
-   field = parse_synth_field(argv[i], argv[i + 1]);
+   field = parse_synth_field(argc - i, &argv[i], &consumed);
if (IS_ERR(field)) {
ret = PTR_ERR(field);
goto err;
}
-   fields[n_fields] = field;
-   i++; n_fields++;
+   fields[n_fields++] = field;
+   i += consumed - 1;
}
 
if (i < argc) {




[PATCH 4.18 08/34] fscache: Fix out of bound read in long cookie keys

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Eric Sandeen 

commit fa520c47eaa15b9baa8ad66ac18da4a31679693b upstream.

fscache_set_key() can incur an out-of-bounds read, reported by KASAN:

 BUG: KASAN: slab-out-of-bounds in fscache_alloc_cookie+0x5b3/0x680 [fscache]
 Read of size 4 at addr 88084ff056d4 by task mount.nfs/32615

and also reported by syzbot at https://lkml.org/lkml/2018/7/8/236

  BUG: KASAN: slab-out-of-bounds in fscache_set_key fs/fscache/cookie.c:120 
[inline]
  BUG: KASAN: slab-out-of-bounds in fscache_alloc_cookie+0x7a9/0x880 
fs/fscache/cookie.c:171
  Read of size 4 at addr 8801d3cc8bb4 by task syz-executor907/4466

This happens for any index_key_len which is not divisible by 4 and is
larger than the size of the inline key, because the code allocates exactly
index_key_len for the key buffer, but the hashing loop is stepping through
it 4 bytes (u32) at a time in the buf[] array.

Fix this by calculating how many u32 buffers we'll need by using
DIV_ROUND_UP, and then using kcalloc() to allocate a precleared allocation
buffer to hold the index_key, then using that same count as the hashing
index limit.

Fixes: ec0328e46d6e ("fscache: Maintain a catalogue of allocated cookies")
Reported-by: syzbot+a95b989b2dde8e806...@syzkaller.appspotmail.com
Signed-off-by: Eric Sandeen 
Cc: stable 
Signed-off-by: David Howells 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/fscache/cookie.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -70,7 +70,7 @@ void fscache_free_cookie(struct fscache_
 }
 
 /*
- * Set the index key in a cookie.  The cookie struct has space for a 12-byte
+ * Set the index key in a cookie.  The cookie struct has space for a 16-byte
  * key plus length and hash, but if that's not big enough, it's instead a
  * pointer to a buffer containing 3 bytes of hash, 1 byte of length and then
  * the key data.
@@ -80,10 +80,13 @@ static int fscache_set_key(struct fscach
 {
unsigned long long h;
u32 *buf;
+   int bufs;
int i;
 
+   bufs = DIV_ROUND_UP(index_key_len, sizeof(*buf));
+
if (index_key_len > sizeof(cookie->inline_key)) {
-   buf = kzalloc(index_key_len, GFP_KERNEL);
+   buf = kcalloc(bufs, sizeof(*buf), GFP_KERNEL);
if (!buf)
return -ENOMEM;
cookie->key = buf;
@@ -98,7 +101,8 @@ static int fscache_set_key(struct fscach
 */
h = (unsigned long)cookie->parent;
h += index_key_len + cookie->type;
-   for (i = 0; i < (index_key_len + sizeof(u32) - 1) / sizeof(u32); i++)
+
+   for (i = 0; i < bufs; i++)
h += buf[i];
 
cookie->key_hash = h ^ (h >> 32);




[PATCH 4.18 28/34] sched/fair: Fix throttle_list starvation with low CFS quota

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Phil Auld 

commit baa9be4ffb55876923dc9716abc0a448e510ba30 upstream.

With a very low cpu.cfs_quota_us setting, such as the minimum of 1000,
distribute_cfs_runtime may not empty the throttled_list before it runs
out of runtime to distribute. In that case, due to the change from
c06f04c7048 to put throttled entries at the head of the list, later entries
on the list will starve.  Essentially, the same X processes will get pulled
off the list, given CPU time and then, when expired, get put back on the
head of the list where distribute_cfs_runtime will give runtime to the same
set of processes leaving the rest.

Fix the issue by setting a bit in struct cfs_bandwidth when
distribute_cfs_runtime is running, so that the code in throttle_cfs_rq can
decide to put the throttled entry on the tail or the head of the list.  The
bit is set/cleared by the callers of distribute_cfs_runtime while they hold
cfs_bandwidth->lock.

This is easy to reproduce with a handful of CPU consumers. I use 'crash' on
the live system. In some cases you can simply look at the throttled list and
see the later entries are not changing:

  crash> list cfs_rq.throttled_list -H 0x90b54f6ade40 -s 
cfs_rq.runtime_remaining | paste - - | awk '{print $1"  "$4}' | pr -t -n3
1 90b56cb2d200  -976050
2 90b56cb2cc00  -484925
3 90b56cb2bc00  -658814
4 90b56cb2ba00  -275365
5 90b166a45600  -135138
6 90b56cb2da00  -282505
7 90b56cb2e000  -148065
8 90b56cb2fa00  -872591
9 90b56cb2c000  -84687
   10 90b56cb2f000  -87237
   11 90b166a40a00  -164582

  crash> list cfs_rq.throttled_list -H 0x90b54f6ade40 -s 
cfs_rq.runtime_remaining | paste - - | awk '{print $1"  "$4}' | pr -t -n3
1 90b56cb2d200  -994147
2 90b56cb2cc00  -306051
3 90b56cb2bc00  -961321
4 90b56cb2ba00  -24490
5 90b166a45600  -135138
6 90b56cb2da00  -282505
7 90b56cb2e000  -148065
8 90b56cb2fa00  -872591
9 90b56cb2c000  -84687
   10 90b56cb2f000  -87237
   11 90b166a40a00  -164582

Sometimes it is easier to see by finding a process getting starved and looking
at the sched_info:

  crash> task 8eb765994500 sched_info
  PID: 7800   TASK: 8eb765994500  CPU: 16  COMMAND: "cputest"
sched_info = {
  pcount = 8,
  run_delay = 697094208,
  last_arrival = 240260125039,
  last_queued = 240260327513
},
  crash> task 8eb765994500 sched_info
  PID: 7800   TASK: 8eb765994500  CPU: 16  COMMAND: "cputest"
sched_info = {
  pcount = 8,
  run_delay = 697094208,
  last_arrival = 240260125039,
  last_queued = 240260327513
},

Signed-off-by: Phil Auld 
Reviewed-by: Ben Segall 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Fixes: c06f04c70489 ("sched: Fix potential near-infinite 
distribute_cfs_runtime() loop")
Link: http://lkml.kernel.org/r/20181008143639.ga4...@pauld.bos.csb
Signed-off-by: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/sched/fair.c  |   22 +++---
 kernel/sched/sched.h |2 ++
 2 files changed, 21 insertions(+), 3 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4797,9 +4797,13 @@ static void throttle_cfs_rq(struct cfs_r
 
/*
 * Add to the _head_ of the list, so that an already-started
-* distribute_cfs_runtime will not see us
+* distribute_cfs_runtime will not see us. If disribute_cfs_runtime is
+* not running add to the tail so that later runqueues don't get 
starved.
 */
-   list_add_rcu(&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq);
+   if (cfs_b->distribute_running)
+   list_add_rcu(&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq);
+   else
+   list_add_tail_rcu(&cfs_rq->throttled_list, 
&cfs_b->throttled_cfs_rq);
 
/*
 * If we're the first throttled task, make sure the bandwidth
@@ -4943,14 +4947,16 @@ static int do_sched_cfs_period_timer(str
 * in us over-using our runtime if it is all used during this loop, but
 * only by limited amounts in that extreme case.
 */
-   while (throttled && cfs_b->runtime > 0) {
+   while (throttled && cfs_b->runtime > 0 && !cfs_b->distribute_running) {
runtime = cfs_b->runtime;
+   cfs_b->distribute_running = 1;
raw_spin_unlock(&cfs_b->lock);
/* we can't nest cfs_b->lock while distributing bandwidth */
runtime = distribute_cfs_runtime(cfs_b, runtime,
 runtime_expires);
raw_spin_lock(&cfs_b->lock);
 
+   cfs_b->distribute_running = 0;
throttled = !list_e

[PATCH 4.18 25/34] tracing: Fix synthetic event to allow semicolon at end

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Masami Hiramatsu 

commit a360d9e4016c1fcf41553b37ad496870dc5723d0 upstream.

Fix synthetic event to allow independent semicolon at end.

The synthetic_events interface accepts a semicolon after the
last word if there is no space.

 # echo "myevent u64 var;" >> synthetic_events

But if there is a space, it returns an error.

 # echo "myevent u64 var ;" > synthetic_events
 sh: write error: Invalid argument

This behavior is difficult for users to understand. Let's
allow the last independent semicolon too.

Link: 
http://lkml.kernel.org/r/153986835420.18251.2191216690677025744.stgit@devbox

Cc: Shuah Khan 
Cc: Tom Zanussi 
Cc: sta...@vger.kernel.org
Fixes: commit 4b147936fa50 ("tracing: Add support for 'synthetic' events")
Signed-off-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt (VMware) 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/trace/trace_events_hist.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1097,7 +1097,7 @@ static int create_synth_event(int argc,
i += consumed - 1;
}
 
-   if (i < argc) {
+   if (i < argc && strcmp(argv[i], ";") != 0) {
ret = -EINVAL;
goto err;
}




[PATCH 4.18 00/34] 4.18.18-stable review

2018-11-08 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.18.18 release.
There are 34 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sat Nov 10 21:51:21 UTC 2018.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.18.18-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-4.18.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.18.18-rc1

Sebastian Andrzej Siewior 
x86/fpu: Fix i486 + no387 boot crash by only saving FPU registers on 
context switch if there is an FPU

Christoph Hellwig 
x86/swiotlb: Enable swiotlb for > 4GiG RAM on 32-bit kernels

Nathan Chancellor 
x86/time: Correct the attribute on jiffies' definition

Peter Zijlstra 
x86/percpu: Fix this_cpu_read()

Zhimin Gu 
x86, hibernate: Fix nosave_regions setup for hibernation

Peter Zijlstra 
x86/tsc: Force inlining of cyc2ns bits

Phil Auld 
sched/fair: Fix throttle_list starvation with low CFS quota

Boris Brezillon 
drm/sun4i: Fix an ulong overflow in the dotclock driver

Mikhail Nikiforov 
Input: elan_i2c - add ACPI ID for Lenovo IdeaPad 330-15IGM

Masami Hiramatsu 
tracing: Fix synthetic event to allow semicolon at end

Masami Hiramatsu 
tracing: Fix synthetic event to accept unsigned modifier

Ming Lei 
block: don't deal with discard limit in blkdev_issue_discard()

Alan Stern 
USB: fix the usbfs flag sanitization for control transfers

Heikki Krogerus 
usb: xhci: pci: Enable Intel USB role mux on Apollo Lake platforms

Wan Ahmad Zainie 
usb: roles: intel_xhci: Fix Unbalanced pm_runtime_enable

Gustavo A. R. Silva 
usb: gadget: storage: Fix Spectre v1 vulnerability

Shuah Khan (Samsung OSG) 
usb: usbip: Fix BUG: KASAN: slab-out-of-bounds in vhci_hub_control()

Oliver Neukum 
cdc-acm: fix race between reset and control messaging

Tobias Herzog 
cdc-acm: correct counting of UART states in serial state notification

Tobias Herzog 
cdc-acm: do not reset notification buffer index upon urb unlinking

Gustavo A. R. Silva 
IB/ucm: Fix Spectre v1 vulnerability

Gustavo A. R. Silva 
RDMA/ucma: Fix Spectre v1 vulnerability

Eugeniy Paltsev 
drm: fb-helper: Reject all pixel format changing requests

Clint Taylor 
drm/edid: VSDB yCBCr420 Deep Color mode bit definitions

Kai-Heng Feng 
drm/edid: Add 6 bpc quirk for BOE panel in HP Pavilion 15-n233sl

Gustavo A. R. Silva 
ptp: fix Spectre v1 vulnerability

Eric Sandeen 
fscache: Fix out of bound read in long cookie keys

Al Viro 
cachefiles: fix the race between cachefiles_bury_object() and rmdir(2)

David Howells 
fscache: Fix incomplete initialisation of inline key space

Chen-Yu Tsai 
clk: sunxi-ng: sun4i: Set VCO and PLL bias current to lowest setting

Linus Walleij 
gpio: mxs: Get rid of external API call

Daniel Borkmann 
bpf: fix partial copy of map_ptr when dst is scalar

Amir Goldstein 
vfs: swap names of {do,vfs}_clone_file_range()

Alan Chiang 
eeprom: at24: Add support for address-width property


-

Diffstat:

 Makefile   |  4 +-
 arch/x86/include/asm/fpu/internal.h|  2 +-
 arch/x86/include/asm/percpu.h  |  8 +--
 arch/x86/kernel/pci-swiotlb.c  |  2 -
 arch/x86/kernel/setup.c|  2 +-
 arch/x86/kernel/time.c |  2 +-
 arch/x86/kernel/tsc.c  |  6 +-
 block/blk-lib.c| 28 +---
 drivers/clk/sunxi-ng/ccu-sun4i-a10.c   | 10 ++-
 drivers/gpio/gpio-mxs.c|  4 +-
 drivers/gpu/drm/drm_edid.c |  5 +-
 drivers/gpu/drm/drm_fb_helper.c| 91 --
 drivers/gpu/drm/sun4i/sun4i_dotclock.c | 12 +++-
 drivers/infiniband/core/ucm.c  |  3 +
 drivers/infiniband/core/ucma.c |  3 +
 drivers/input/mouse/elan_i2c_core.c|  1 +
 drivers/misc/eeprom/at24.c | 17 +
 drivers/ptp/ptp_chardev.c  |  4 ++
 drivers/usb/class/cdc-acm.c| 16 ++---
 drivers/usb/core/devio.c   |  4 +-
 drivers/usb/gadget/function/f_mass_storage.c   |  3 +
 drivers/usb/host/xhci-pci.c|  6 +-
 drivers/usb/roles/intel-xhci-usb-role-switch.c |  2 +
 drivers/usb/usbip/vhci_hcd.c   | 57 +++-
 fs/cachefiles/namei.c  |  2 +-
 fs/fscache/cookie.c| 31 +++--
 fs/fscache/internal.h  |  1

[PATCH 4.18 31/34] x86/percpu: Fix this_cpu_read()

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

commit b59167ac7bafd804c91e49ad53c6d33a7394d4c8 upstream.

Eric reported that a sequence count loop using this_cpu_read() got
optimized out. This is wrong, this_cpu_read() must imply READ_ONCE()
because the interface is IRQ-safe, therefore an interrupt can have
changed the per-cpu value.

Fixes: 7c3576d261ce ("[PATCH] i386: Convert PDA into the percpu section")
Reported-by: Eric Dumazet 
Signed-off-by: Peter Zijlstra (Intel) 
Signed-off-by: Thomas Gleixner 
Acked-by: Eric Dumazet 
Cc: h...@zytor.com
Cc: eric.duma...@gmail.com
Cc: b...@alien8.de
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181011104019.748208...@infradead.org
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/include/asm/percpu.h |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -185,22 +185,22 @@ do {  
\
typeof(var) pfo_ret__;  \
switch (sizeof(var)) {  \
case 1: \
-   asm(op "b "__percpu_arg(1)",%0" \
+   asm volatile(op "b "__percpu_arg(1)",%0"\
: "=q" (pfo_ret__)  \
: "m" (var));   \
break;  \
case 2: \
-   asm(op "w "__percpu_arg(1)",%0" \
+   asm volatile(op "w "__percpu_arg(1)",%0"\
: "=r" (pfo_ret__)  \
: "m" (var));   \
break;  \
case 4: \
-   asm(op "l "__percpu_arg(1)",%0" \
+   asm volatile(op "l "__percpu_arg(1)",%0"\
: "=r" (pfo_ret__)  \
: "m" (var));   \
break;  \
case 8: \
-   asm(op "q "__percpu_arg(1)",%0" \
+   asm volatile(op "q "__percpu_arg(1)",%0"\
: "=r" (pfo_ret__)  \
: "m" (var));   \
break;  \




[PATCH 4.18 09/34] ptp: fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit efa61c8cf2950ab5c0e66cff3cabe2a2b24e81ba upstream.

pin_index can be indirectly controlled by user-space, hence leading
to a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/ptp/ptp_chardev.c:253 ptp_ioctl() warn: potential spectre issue
'ops->pin_config' [r] (local cap)

Fix this by sanitizing pin_index before using it to index
ops->pin_config, and before passing it as an argument to
function ptp_set_pinfunc(), in which it is used to index
info->pin_config.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Acked-by: Richard Cochran 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/ptp/ptp_chardev.c |4 
 1 file changed, 4 insertions(+)

--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -24,6 +24,8 @@
 #include 
 #include 
 
+#include 
+
 #include "ptp_private.h"
 
 static int ptp_disable_pinfunc(struct ptp_clock_info *ops,
@@ -248,6 +250,7 @@ long ptp_ioctl(struct posix_clock *pc, u
err = -EINVAL;
break;
}
+   pin_index = array_index_nospec(pin_index, ops->n_pins);
if (mutex_lock_interruptible(&ptp->pincfg_mux))
return -ERESTARTSYS;
pd = ops->pin_config[pin_index];
@@ -266,6 +269,7 @@ long ptp_ioctl(struct posix_clock *pc, u
err = -EINVAL;
break;
}
+   pin_index = array_index_nospec(pin_index, ops->n_pins);
if (mutex_lock_interruptible(&ptp->pincfg_mux))
return -ERESTARTSYS;
err = ptp_set_pinfunc(ptp, pin_index, pd.func, pd.chan);




[PATCH 4.18 26/34] Input: elan_i2c - add ACPI ID for Lenovo IdeaPad 330-15IGM

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Mikhail Nikiforov 

commit 13c1c5e4d7f887cba36c5e3df3faa22071c1469f upstream.

Add ELAN061C to the ACPI table to support Elan touchpad found in Lenovo
IdeaPad 330-15IGM.

Signed-off-by: Mikhail Nikiforov 
Cc: sta...@vger.kernel.org
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/input/mouse/elan_i2c_core.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1346,6 +1346,7 @@ static const struct acpi_device_id elan_
{ "ELAN0611", 0 },
{ "ELAN0612", 0 },
{ "ELAN0618", 0 },
+   { "ELAN061C", 0 },
{ "ELAN061D", 0 },
{ "ELAN0622", 0 },
{ "ELAN1000", 0 },




[PATCH 4.18 33/34] x86/swiotlb: Enable swiotlb for > 4GiG RAM on 32-bit kernels

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Christoph Hellwig 

commit 485734f3fc77c1eb77ffe138c027b9a4bf0178f3 upstream.

We already build the swiotlb code for 32-bit kernels with PAE support,
but the code to actually use swiotlb has only been enabled for 64-bit
kernels for an unknown reason.

Before Linux v4.18 we paper over this fact because the networking code,
the SCSI layer and some random block drivers implemented their own
bounce buffering scheme.

[ mingo: Changelog fixes. ]

Fixes: 21e07dba9fb1 ("scsi: reduce use of block bounce buffers")
Fixes: ab74cfebafa3 ("net: remove the PCI_DMA_BUS_IS_PHYS check in 
illegal_highdma")
Reported-by: Matthew Whitehead 
Signed-off-by: Christoph Hellwig 
Signed-off-by: Thomas Gleixner 
Tested-by: Matthew Whitehead 
Cc: konrad.w...@oracle.com
Cc: io...@lists.linux-foundation.org
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181014075208.2715-1-...@lst.de
Signed-off-by: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/pci-swiotlb.c |2 --
 1 file changed, 2 deletions(-)

--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -42,10 +42,8 @@ IOMMU_INIT_FINISH(pci_swiotlb_detect_ove
 int __init pci_swiotlb_detect_4gb(void)
 {
/* don't initialize swiotlb if iommu=off (no_iommu=1) */
-#ifdef CONFIG_X86_64
if (!no_iommu && max_possible_pfn > MAX_DMA32_PFN)
swiotlb = 1;
-#endif
 
/*
 * If SME is active then swiotlb will be set to 1 so that bounce




[PATCH 4.18 29/34] x86/tsc: Force inlining of cyc2ns bits

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

commit 4907c68abd3f60f650f98d5a69d4ec77c0bde44f upstream.

Looking at the asm for native_sched_clock() I noticed we don't inline
enough. Mostly caused by sharing code with cyc2ns_read_begin(), which
we didn't used to do. So mark all that __force_inline to make it DTRT.

Fixes: 59eaef78bfea ("x86/tsc: Remodel cyc2ns to use seqcount_latch()")
Reported-by: Eric Dumazet 
Signed-off-by: Peter Zijlstra (Intel) 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Cc: eric.duma...@gmail.com
Cc: b...@alien8.de
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181011104019.695196...@infradead.org
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/tsc.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -60,7 +60,7 @@ struct cyc2ns {
 
 static DEFINE_PER_CPU_ALIGNED(struct cyc2ns, cyc2ns);
 
-void cyc2ns_read_begin(struct cyc2ns_data *data)
+void __always_inline cyc2ns_read_begin(struct cyc2ns_data *data)
 {
int seq, idx;
 
@@ -77,7 +77,7 @@ void cyc2ns_read_begin(struct cyc2ns_dat
} while (unlikely(seq != this_cpu_read(cyc2ns.seq.sequence)));
 }
 
-void cyc2ns_read_end(void)
+void __always_inline cyc2ns_read_end(void)
 {
preempt_enable_notrace();
 }
@@ -123,7 +123,7 @@ static void __init cyc2ns_init(int cpu)
seqcount_init(&c2n->seq);
 }
 
-static inline unsigned long long cycles_2_ns(unsigned long long cyc)
+static __always_inline unsigned long long cycles_2_ns(unsigned long long cyc)
 {
struct cyc2ns_data data;
unsigned long long ns;




[PATCH 4.18 30/34] x86, hibernate: Fix nosave_regions setup for hibernation

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Zhimin Gu 

commit cc55f7537db6af371e9c1c6a71161ee40f918824 upstream.

On 32bit systems, nosave_regions(non RAM areas) located between
max_low_pfn and max_pfn are not excluded from hibernation snapshot
currently, which may result in a machine check exception when
trying to access these unsafe regions during hibernation:

[  612.800453] Disabling lock debugging due to kernel taint
[  612.805786] mce: [Hardware Error]: CPU 0: Machine Check Exception: 5 Bank 6: 
fe801136
[  612.814344] mce: [Hardware Error]: RIP !INEXACT! 60: 
{swsusp_save+0x436/0x560}
[  612.823167] mce: [Hardware Error]: TSC 1f5939fe276 ADDR dd00 MISC 
30e086
[  612.830677] mce: [Hardware Error]: PROCESSOR 0:306c3 TIME 1529487426 SOCKET 
0 APIC 0 microcode 24
[  612.839581] mce: [Hardware Error]: Run the above through 'mcelog --ascii'
[  612.846394] mce: [Hardware Error]: Machine check: Processor context corrupt
[  612.853380] Kernel panic - not syncing: Fatal machine check
[  612.858978] Kernel Offset: 0x1800 from 0xc100 (relocation range: 
0xc000-0xf7ffdfff)

This is because on 32bit systems, pages above max_low_pfn are regarded
as high memeory, and accessing unsafe pages might cause expected MCE.
On the problematic 32bit system, there are reserved memory above low
memory, which triggered the MCE:

e820 memory mapping:
[0.00] BIOS-e820: [mem 0x-0x0009d7ff] usable
[0.00] BIOS-e820: [mem 0x0009d800-0x0009] reserved
[0.00] BIOS-e820: [mem 0x000e-0x000f] reserved
[0.00] BIOS-e820: [mem 0x0010-0xd160cfff] usable
[0.00] BIOS-e820: [mem 0xd160d000-0xd1613fff] ACPI NVS
[0.00] BIOS-e820: [mem 0xd1614000-0xd1a44fff] usable
[0.00] BIOS-e820: [mem 0xd1a45000-0xd1ec] reserved
[0.00] BIOS-e820: [mem 0xd1ed-0xd7eeafff] usable
[0.00] BIOS-e820: [mem 0xd7eeb000-0xd7ff] reserved
[0.00] BIOS-e820: [mem 0xd800-0xd875] usable
[0.00] BIOS-e820: [mem 0xd876-0xd87f] reserved
[0.00] BIOS-e820: [mem 0xd880-0xd8fadfff] usable
[0.00] BIOS-e820: [mem 0xd8fae000-0xd8ff] ACPI data
[0.00] BIOS-e820: [mem 0xd900-0xda71bfff] usable
[0.00] BIOS-e820: [mem 0xda71c000-0xda7f] ACPI NVS
[0.00] BIOS-e820: [mem 0xda80-0xdbb8bfff] usable
[0.00] BIOS-e820: [mem 0xdbb8c000-0xdbff] reserved
[0.00] BIOS-e820: [mem 0xdd00-0xdf1f] reserved
[0.00] BIOS-e820: [mem 0xf800-0xfbff] reserved
[0.00] BIOS-e820: [mem 0xfec0-0xfec00fff] reserved
[0.00] BIOS-e820: [mem 0xfed0-0xfed03fff] reserved
[0.00] BIOS-e820: [mem 0xfed1c000-0xfed1] reserved
[0.00] BIOS-e820: [mem 0xfee0-0xfee00fff] reserved
[0.00] BIOS-e820: [mem 0xff00-0x] reserved
[0.00] BIOS-e820: [mem 0x0001-0x00041edf] usable

Fix this problem by changing pfn limit from max_low_pfn to max_pfn.
This fix does not impact 64bit system because on 64bit max_low_pfn
is the same as max_pfn.

Signed-off-by: Zhimin Gu 
Acked-by: Pavel Machek 
Signed-off-by: Chen Yu 
Acked-by: Thomas Gleixner 
Cc: All applicable 
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/setup.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1258,7 +1258,7 @@ void __init setup_arch(char **cmdline_p)
x86_init.hyper.guest_late_init();
 
e820__reserve_resources();
-   e820__register_nosave_regions(max_low_pfn);
+   e820__register_nosave_regions(max_pfn);
 
x86_init.resources.reserve_resources();
 




[PATCH 4.18 32/34] x86/time: Correct the attribute on jiffies definition

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Nathan Chancellor 

commit 53c13ba8ed39e89f21a0b98f4c8a241bb44e483d upstream.

Clang warns that the declaration of jiffies in include/linux/jiffies.h
doesn't match the definition in arch/x86/time/kernel.c:

arch/x86/kernel/time.c:29:42: warning: section does not match previous 
declaration [-Wsection]
__visible volatile unsigned long jiffies __cacheline_aligned = INITIAL_JIFFIES;
 ^
./include/linux/cache.h:49:4: note: expanded from macro '__cacheline_aligned'
 __section__(".data..cacheline_aligned")))
 ^
./include/linux/jiffies.h:81:31: note: previous attribute is here
extern unsigned long volatile __cacheline_aligned_in_smp __jiffy_arch_data 
jiffies;
  ^
./arch/x86/include/asm/cache.h:20:2: note: expanded from macro 
'__cacheline_aligned_in_smp'
__page_aligned_data
^
./include/linux/linkage.h:39:29: note: expanded from macro '__page_aligned_data'
#define __page_aligned_data __section(.data..page_aligned) 
__aligned(PAGE_SIZE)
^
./include/linux/compiler_attributes.h:233:56: note: expanded from macro 
'__section'
#define __section(S)__attribute__((__section__(#S)))
   ^
1 warning generated.

The declaration was changed in commit 7c30f352c852 ("jiffies.h: declare
jiffies and jiffies_64 with cacheline_aligned_in_smp") but wasn't
updated here. Make them match so Clang no longer warns.

Fixes: 7c30f352c852 ("jiffies.h: declare jiffies and jiffies_64 with 
cacheline_aligned_in_smp")
Signed-off-by: Nathan Chancellor 
Signed-off-by: Thomas Gleixner 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Nick Desaulniers 
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181013005311.28617-1-natechancel...@gmail.com
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/time.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -25,7 +25,7 @@
 #include 
 
 #ifdef CONFIG_X86_64
-__visible volatile unsigned long jiffies __cacheline_aligned = INITIAL_JIFFIES;
+__visible volatile unsigned long jiffies __cacheline_aligned_in_smp = 
INITIAL_JIFFIES;
 #endif
 
 unsigned long profile_pc(struct pt_regs *regs)




[PATCH 4.18 07/34] cachefiles: fix the race between cachefiles_bury_object() and rmdir(2)

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Al Viro 

commit 169b803397499be85bdd1e3d07d6f5e3d4bd669e upstream.

the victim might've been rmdir'ed just before the lock_rename();
unlike the normal callers, we do not look the source up after the
parents are locked - we know it beforehand and just recheck that it's
still the child of what used to be its parent.  Unfortunately,
the check is too weak - we don't spot a dead directory since its
->d_parent is unchanged, dentry is positive, etc.  So we sail all
the way to ->rename(), with hosting filesystems _not_ expecting
to be asked renaming an rmdir'ed subdirectory.

The fix is easy, fortunately - the lock on parent is sufficient for
making IS_DEADDIR() on child safe.

Cc: sta...@vger.kernel.org
Fixes: 9ae326a69004 (CacheFiles: A cache that backs onto a mounted filesystem)
Signed-off-by: Al Viro 
Signed-off-by: David Howells 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/cachefiles/namei.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -343,7 +343,7 @@ try_again:
trap = lock_rename(cache->graveyard, dir);
 
/* do some checks before getting the grave dentry */
-   if (rep->d_parent != dir) {
+   if (rep->d_parent != dir || IS_DEADDIR(d_inode(rep))) {
/* the entry was probably culled when we dropped the parent dir
 * lock */
unlock_rename(cache->graveyard, dir);




[PATCH 4.18 06/34] fscache: Fix incomplete initialisation of inline key space

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: David Howells 

commit 1ff22883b0b2f7a73eb2609ffe879c9fd96f6328 upstream.

The inline key in struct rxrpc_cookie is insufficiently initialized,
zeroing only 3 of the 4 slots, therefore an index_key_len between 13 and 15
bytes will end up hashing uninitialized memory because the memcpy only
partially fills the last buf[] element.

Fix this by clearing fscache_cookie objects on allocation rather than using
the slab constructor to initialise them.  We're going to pretty much fill
in the entire struct anyway, so bringing it into our dcache writably
shouldn't incur much overhead.

This removes the need to do clearance in fscache_set_key() (where we aren't
doing it correctly anyway).

Also, we don't need to set cookie->key_len in fscache_set_key() as we
already did it in the only caller, so remove that.

Fixes: ec0328e46d6e ("fscache: Maintain a catalogue of allocated cookies")
Reported-by: syzbot+a95b989b2dde8e806...@syzkaller.appspotmail.com
Reported-by: Eric Sandeen 
Cc: stable 
Signed-off-by: David Howells 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/fscache/cookie.c   |   23 ---
 fs/fscache/internal.h |1 -
 fs/fscache/main.c |4 +---
 3 files changed, 5 insertions(+), 23 deletions(-)

--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -70,19 +70,6 @@ void fscache_free_cookie(struct fscache_
 }
 
 /*
- * initialise an cookie jar slab element prior to any use
- */
-void fscache_cookie_init_once(void *_cookie)
-{
-   struct fscache_cookie *cookie = _cookie;
-
-   memset(cookie, 0, sizeof(*cookie));
-   spin_lock_init(&cookie->lock);
-   spin_lock_init(&cookie->stores_lock);
-   INIT_HLIST_HEAD(&cookie->backing_objects);
-}
-
-/*
  * Set the index key in a cookie.  The cookie struct has space for a 12-byte
  * key plus length and hash, but if that's not big enough, it's instead a
  * pointer to a buffer containing 3 bytes of hash, 1 byte of length and then
@@ -95,8 +82,6 @@ static int fscache_set_key(struct fscach
u32 *buf;
int i;
 
-   cookie->key_len = index_key_len;
-
if (index_key_len > sizeof(cookie->inline_key)) {
buf = kzalloc(index_key_len, GFP_KERNEL);
if (!buf)
@@ -104,9 +89,6 @@ static int fscache_set_key(struct fscach
cookie->key = buf;
} else {
buf = (u32 *)cookie->inline_key;
-   buf[0] = 0;
-   buf[1] = 0;
-   buf[2] = 0;
}
 
memcpy(buf, index_key, index_key_len);
@@ -161,7 +143,7 @@ struct fscache_cookie *fscache_alloc_coo
struct fscache_cookie *cookie;
 
/* allocate and initialise a cookie */
-   cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
+   cookie = kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL);
if (!cookie)
return NULL;
 
@@ -192,6 +174,9 @@ struct fscache_cookie *fscache_alloc_coo
cookie->netfs_data  = netfs_data;
cookie->flags   = (1 << FSCACHE_COOKIE_NO_DATA_YET);
cookie->type= def->type;
+   spin_lock_init(&cookie->lock);
+   spin_lock_init(&cookie->stores_lock);
+   INIT_HLIST_HEAD(&cookie->backing_objects);
 
/* radix tree insertion won't use the preallocation pool unless it's
 * told it may not wait */
--- a/fs/fscache/internal.h
+++ b/fs/fscache/internal.h
@@ -51,7 +51,6 @@ extern struct fscache_cache *fscache_sel
 extern struct kmem_cache *fscache_cookie_jar;
 
 extern void fscache_free_cookie(struct fscache_cookie *);
-extern void fscache_cookie_init_once(void *);
 extern struct fscache_cookie *fscache_alloc_cookie(struct fscache_cookie *,
   const struct 
fscache_cookie_def *,
   const void *, size_t,
--- a/fs/fscache/main.c
+++ b/fs/fscache/main.c
@@ -143,9 +143,7 @@ static int __init fscache_init(void)
 
fscache_cookie_jar = kmem_cache_create("fscache_cookie_jar",
   sizeof(struct fscache_cookie),
-  0,
-  0,
-  fscache_cookie_init_once);
+  0, 0, NULL);
if (!fscache_cookie_jar) {
pr_notice("Failed to allocate a cookie jar\n");
ret = -ENOMEM;




[PATCH 4.18 03/34] bpf: fix partial copy of map_ptr when dst is scalar

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

commit 0962590e553331db2cc0aef2dc35c57f6300dbbe upstream.

ALU operations on pointers such as scalar_reg += map_value_ptr are
handled in adjust_ptr_min_max_vals(). Problem is however that map_ptr
and range in the register state share a union, so transferring state
through dst_reg->range = ptr_reg->range is just buggy as any new
map_ptr in the dst_reg is then truncated (or null) for subsequent
checks. Fix this by adding a raw member and use it for copying state
over to dst_reg.

Fixes: f1174f77b50c ("bpf/verifier: rework value tracking")
Signed-off-by: Daniel Borkmann 
Cc: Edward Cree 
Acked-by: Alexei Starovoitov 
Signed-off-by: Alexei Starovoitov 
Acked-by: Edward Cree 
Signed-off-by: Sasha Levin 
---
 include/linux/bpf_verifier.h |  3 +++
 kernel/bpf/verifier.c| 10 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 38b04f559ad3..1fd6fa822d2c 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -50,6 +50,9 @@ struct bpf_reg_state {
 *   PTR_TO_MAP_VALUE_OR_NULL
 */
struct bpf_map *map_ptr;
+
+   /* Max size from any of the above. */
+   unsigned long raw;
};
/* Fixed part of pointer offset, pointer types only */
s32 off;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 82e8edef6ea0..b000686fa1a1 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2731,7 +2731,7 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
dst_reg->umax_value = umax_ptr;
dst_reg->var_off = ptr_reg->var_off;
dst_reg->off = ptr_reg->off + smin_val;
-   dst_reg->range = ptr_reg->range;
+   dst_reg->raw = ptr_reg->raw;
break;
}
/* A new variable offset is created.  Note that off_reg->off
@@ -2761,10 +2761,11 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
}
dst_reg->var_off = tnum_add(ptr_reg->var_off, off_reg->var_off);
dst_reg->off = ptr_reg->off;
+   dst_reg->raw = ptr_reg->raw;
if (reg_is_pkt_pointer(ptr_reg)) {
dst_reg->id = ++env->id_gen;
/* something was added to pkt_ptr, set range to zero */
-   dst_reg->range = 0;
+   dst_reg->raw = 0;
}
break;
case BPF_SUB:
@@ -2793,7 +2794,7 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
dst_reg->var_off = ptr_reg->var_off;
dst_reg->id = ptr_reg->id;
dst_reg->off = ptr_reg->off - smin_val;
-   dst_reg->range = ptr_reg->range;
+   dst_reg->raw = ptr_reg->raw;
break;
}
/* A new variable offset is created.  If the subtrahend is known
@@ -2819,11 +2820,12 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
}
dst_reg->var_off = tnum_sub(ptr_reg->var_off, off_reg->var_off);
dst_reg->off = ptr_reg->off;
+   dst_reg->raw = ptr_reg->raw;
if (reg_is_pkt_pointer(ptr_reg)) {
dst_reg->id = ++env->id_gen;
/* something was added to pkt_ptr, set range to zero */
if (smin_val < 0)
-   dst_reg->range = 0;
+   dst_reg->raw = 0;
}
break;
case BPF_AND:
-- 
2.17.1





[PATCH 4.18 22/34] USB: fix the usbfs flag sanitization for control transfers

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Alan Stern 

commit 665c365a77fbfeabe52694aedf3446d5f2f1ce42 upstream.

Commit 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more") checks the
transfer flags for URBs submitted from userspace via usbfs.  However,
the check for whether the USBDEVFS_URB_SHORT_NOT_OK flag should be
allowed for a control transfer was added in the wrong place, before
the code has properly determined the direction of the control
transfer.  (Control transfers are special because for them, the
direction is set by the bRequestType byte of the Setup packet rather
than direction bit of the endpoint address.)

This patch moves code which sets up the allow_short flag for control
transfers down after is_in has been set to the correct value.

Signed-off-by: Alan Stern 
Reported-and-tested-by: syzbot+24a30223a4b609bb8...@syzkaller.appspotmail.com
Fixes: 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more")
CC: Oliver Neukum 
CC: 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/core/devio.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1473,8 +1473,6 @@ static int proc_do_submiturb(struct usb_
u = 0;
switch (uurb->type) {
case USBDEVFS_URB_TYPE_CONTROL:
-   if (is_in)
-   allow_short = true;
if (!usb_endpoint_xfer_control(&ep->desc))
return -EINVAL;
/* min 8 byte setup packet */
@@ -1504,6 +1502,8 @@ static int proc_do_submiturb(struct usb_
is_in = 0;
uurb->endpoint &= ~USB_DIR_IN;
}
+   if (is_in)
+   allow_short = true;
snoop(&ps->dev->dev, "control urb: bRequestType=%02x "
"bRequest=%02x wValue=%04x "
"wIndex=%04x wLength=%04x\n",




[PATCH 4.18 23/34] block: dont deal with discard limit in blkdev_issue_discard()

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Ming Lei 

commit 744889b7cbb56a64f957e65ade7cb65fe3f35714 upstream.

blk_queue_split() does respect this limit via bio splitting, so no
need to do that in blkdev_issue_discard(), then we can align to
normal bio submit(bio_add_page() & submit_bio()).

More importantly, this patch fixes one issue introduced in a22c4d7e34402cc
("block: re-add discard_granularity and alignment checks"), in which
zero discard bio may be generated in case of zero alignment.

Fixes: a22c4d7e34402ccdf3 ("block: re-add discard_granularity and alignment 
checks")
Cc: sta...@vger.kernel.org
Cc: Ming Lin 
Cc: Mike Snitzer 
Cc: Christoph Hellwig 
Cc: Xiao Ni 
Tested-by: Mariusz Dabrowski 
Signed-off-by: Ming Lei 
Signed-off-by: Jens Axboe 
Signed-off-by: Greg Kroah-Hartman 

---
 block/blk-lib.c |   28 ++--
 1 file changed, 2 insertions(+), 26 deletions(-)

--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -29,9 +29,7 @@ int __blkdev_issue_discard(struct block_
 {
struct request_queue *q = bdev_get_queue(bdev);
struct bio *bio = *biop;
-   unsigned int granularity;
unsigned int op;
-   int alignment;
sector_t bs_mask;
 
if (!q)
@@ -54,38 +52,16 @@ int __blkdev_issue_discard(struct block_
if ((sector | nr_sects) & bs_mask)
return -EINVAL;
 
-   /* Zero-sector (unknown) and one-sector granularities are the same.  */
-   granularity = max(q->limits.discard_granularity >> 9, 1U);
-   alignment = (bdev_discard_alignment(bdev) >> 9) % granularity;
-
while (nr_sects) {
-   unsigned int req_sects;
-   sector_t end_sect, tmp;
+   unsigned int req_sects = nr_sects;
+   sector_t end_sect;
 
-   /*
-* Issue in chunks of the user defined max discard setting,
-* ensuring that bi_size doesn't overflow
-*/
-   req_sects = min_t(sector_t, nr_sects,
-   q->limits.max_discard_sectors);
if (!req_sects)
goto fail;
if (req_sects > UINT_MAX >> 9)
req_sects = UINT_MAX >> 9;
 
-   /*
-* If splitting a request, and the next starting sector would be
-* misaligned, stop the discard at the previous aligned sector.
-*/
end_sect = sector + req_sects;
-   tmp = end_sect;
-   if (req_sects < nr_sects &&
-   sector_div(tmp, granularity) != alignment) {
-   end_sect = end_sect - alignment;
-   sector_div(end_sect, granularity);
-   end_sect = end_sect * granularity + alignment;
-   req_sects = end_sect - sector;
-   }
 
bio = next_bio(bio, 0, gfp_mask);
bio->bi_iter.bi_sector = sector;




[PATCH 4.18 05/34] clk: sunxi-ng: sun4i: Set VCO and PLL bias current to lowest setting

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Chen-Yu Tsai 

commit 80a6ec7d5e1653208eb53f6738620dab98f6f50e upstream.

The default mid-level PLL bias current setting interferes with sigma
delta modulation. This manifests as decreased audio quality at lower
sampling rates, which sounds like radio broadcast quality, and
distortion noises at sampling rates at 48 kHz or above.

Changing the bias current settings to the lowest gets rid of the
noise.

Fixes: de3448519194 ("clk: sunxi-ng: sun4i: Use sigma-delta modulation
  for audio PLL")
Cc:  # 4.15.x
Signed-off-by: Chen-Yu Tsai 
Signed-off-by: Maxime Ripard 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/clk/sunxi-ng/ccu-sun4i-a10.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
+++ b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
@@ -1434,8 +1434,16 @@ static void __init sun4i_ccu_init(struct
return;
}
 
-   /* Force the PLL-Audio-1x divider to 1 */
val = readl(reg + SUN4I_PLL_AUDIO_REG);
+
+   /*
+* Force VCO and PLL bias current to lowest setting. Higher
+* settings interfere with sigma-delta modulation and result
+* in audible noise and distortions when using SPDIF or I2S.
+*/
+   val &= ~GENMASK(25, 16);
+
+   /* Force the PLL-Audio-1x divider to 1 */
val &= ~GENMASK(29, 26);
writel(val | (1 << 26), reg + SUN4I_PLL_AUDIO_REG);
 




[PATCH 4.18 21/34] usb: xhci: pci: Enable Intel USB role mux on Apollo Lake platforms

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Heikki Krogerus 

commit c02588a352defaf985fc1816eb6232663159e1b8 upstream.

Intel Apollo Lake has the same internal USB role mux as
Intel Cherry Trail.

Cc: 
Signed-off-by: Heikki Krogerus 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/host/xhci-pci.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -179,10 +179,12 @@ static void xhci_pci_quirks(struct devic
xhci->quirks |= XHCI_PME_STUCK_QUIRK;
}
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
-pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
+   pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI)
xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
+   if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
+   (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
+pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI))
xhci->quirks |= XHCI_INTEL_USB_ROLE_SW;
-   }
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
(pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||




[PATCH 4.18 20/34] usb: roles: intel_xhci: Fix Unbalanced pm_runtime_enable

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Wan Ahmad Zainie 

commit 009b1948e153ae448f62f1887e2b58d0e05db51b upstream.

Add missing pm_runtime_disable() to remove(), in order to avoid
an Unbalanced pm_runtime_enable when the module is removed and
re-probed.

Error log:
root@intel-corei7-64:~# modprobe -r intel_xhci_usb_role_switch
root@intel-corei7-64:~# modprobe intel_xhci_usb_role_switch
intel_xhci_usb_sw intel_xhci_usb_sw: Unbalanced pm_runtime_enable!

Fixes: cb2968468605 (usb: roles: intel_xhci: Enable runtime PM)
Cc: 
Reviewed-by: Heikki Krogerus 
Signed-off-by: Wan Ahmad Zainie 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/roles/intel-xhci-usb-role-switch.c |2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/usb/roles/intel-xhci-usb-role-switch.c
+++ b/drivers/usb/roles/intel-xhci-usb-role-switch.c
@@ -161,6 +161,8 @@ static int intel_xhci_usb_remove(struct
 {
struct intel_xhci_usb_data *data = platform_get_drvdata(pdev);
 
+   pm_runtime_disable(&pdev->dev);
+
usb_role_switch_unregister(data->role_sw);
return 0;
 }




[PATCH 4.14 29/31] x86/time: Correct the attribute on jiffies definition

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Nathan Chancellor 

commit 53c13ba8ed39e89f21a0b98f4c8a241bb44e483d upstream.

Clang warns that the declaration of jiffies in include/linux/jiffies.h
doesn't match the definition in arch/x86/time/kernel.c:

arch/x86/kernel/time.c:29:42: warning: section does not match previous 
declaration [-Wsection]
__visible volatile unsigned long jiffies __cacheline_aligned = INITIAL_JIFFIES;
 ^
./include/linux/cache.h:49:4: note: expanded from macro '__cacheline_aligned'
 __section__(".data..cacheline_aligned")))
 ^
./include/linux/jiffies.h:81:31: note: previous attribute is here
extern unsigned long volatile __cacheline_aligned_in_smp __jiffy_arch_data 
jiffies;
  ^
./arch/x86/include/asm/cache.h:20:2: note: expanded from macro 
'__cacheline_aligned_in_smp'
__page_aligned_data
^
./include/linux/linkage.h:39:29: note: expanded from macro '__page_aligned_data'
#define __page_aligned_data __section(.data..page_aligned) 
__aligned(PAGE_SIZE)
^
./include/linux/compiler_attributes.h:233:56: note: expanded from macro 
'__section'
#define __section(S)__attribute__((__section__(#S)))
   ^
1 warning generated.

The declaration was changed in commit 7c30f352c852 ("jiffies.h: declare
jiffies and jiffies_64 with cacheline_aligned_in_smp") but wasn't
updated here. Make them match so Clang no longer warns.

Fixes: 7c30f352c852 ("jiffies.h: declare jiffies and jiffies_64 with 
cacheline_aligned_in_smp")
Signed-off-by: Nathan Chancellor 
Signed-off-by: Thomas Gleixner 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Nick Desaulniers 
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181013005311.28617-1-natechancel...@gmail.com
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/time.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -25,7 +25,7 @@
 #include 
 
 #ifdef CONFIG_X86_64
-__visible volatile unsigned long jiffies __cacheline_aligned = INITIAL_JIFFIES;
+__visible volatile unsigned long jiffies __cacheline_aligned_in_smp = 
INITIAL_JIFFIES;
 #endif
 
 unsigned long profile_pc(struct pt_regs *regs)




[PATCH 4.14 22/31] usb: gadget: storage: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit 9ae24af3669111d418242caec8dd4ebd9ba26860 upstream.

num can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/usb/gadget/function/f_mass_storage.c:3177 fsg_lun_make() warn:
potential spectre issue 'fsg_opts->common->luns' [r] (local cap)

Fix this by sanitizing num before using it to index
fsg_opts->common->luns

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Acked-by: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/gadget/function/f_mass_storage.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -221,6 +221,8 @@
 #include 
 #include 
 
+#include 
+
 #include "configfs.h"
 
 
@@ -3170,6 +3172,7 @@ static struct config_group *fsg_lun_make
fsg_opts = to_fsg_opts(&group->cg_item);
if (num >= FSG_MAX_LUNS)
return ERR_PTR(-ERANGE);
+   num = array_index_nospec(num, FSG_MAX_LUNS);
 
mutex_lock(&fsg_opts->lock);
if (fsg_opts->refcnt || fsg_opts->common->luns[num]) {




[PATCH 4.14 24/31] Input: elan_i2c - add ACPI ID for Lenovo IdeaPad 330-15IGM

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Mikhail Nikiforov 

commit 13c1c5e4d7f887cba36c5e3df3faa22071c1469f upstream.

Add ELAN061C to the ACPI table to support Elan touchpad found in Lenovo
IdeaPad 330-15IGM.

Signed-off-by: Mikhail Nikiforov 
Cc: sta...@vger.kernel.org
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/input/mouse/elan_i2c_core.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1262,6 +1262,7 @@ static const struct acpi_device_id elan_
{ "ELAN0611", 0 },
{ "ELAN0612", 0 },
{ "ELAN0618", 0 },
+   { "ELAN061C", 0 },
{ "ELAN061D", 0 },
{ "ELAN0622", 0 },
{ "ELAN1000", 0 },




[PATCH 4.14 23/31] USB: fix the usbfs flag sanitization for control transfers

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Alan Stern 

commit 665c365a77fbfeabe52694aedf3446d5f2f1ce42 upstream.

Commit 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more") checks the
transfer flags for URBs submitted from userspace via usbfs.  However,
the check for whether the USBDEVFS_URB_SHORT_NOT_OK flag should be
allowed for a control transfer was added in the wrong place, before
the code has properly determined the direction of the control
transfer.  (Control transfers are special because for them, the
direction is set by the bRequestType byte of the Setup packet rather
than direction bit of the endpoint address.)

This patch moves code which sets up the allow_short flag for control
transfers down after is_in has been set to the correct value.

Signed-off-by: Alan Stern 
Reported-and-tested-by: syzbot+24a30223a4b609bb8...@syzkaller.appspotmail.com
Fixes: 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more")
CC: Oliver Neukum 
CC: 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/core/devio.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1491,8 +1491,6 @@ static int proc_do_submiturb(struct usb_
u = 0;
switch (uurb->type) {
case USBDEVFS_URB_TYPE_CONTROL:
-   if (is_in)
-   allow_short = true;
if (!usb_endpoint_xfer_control(&ep->desc))
return -EINVAL;
/* min 8 byte setup packet */
@@ -1522,6 +1520,8 @@ static int proc_do_submiturb(struct usb_
is_in = 0;
uurb->endpoint &= ~USB_DIR_IN;
}
+   if (is_in)
+   allow_short = true;
snoop(&ps->dev->dev, "control urb: bRequestType=%02x "
"bRequest=%02x wValue=%04x "
"wIndex=%04x wLength=%04x\n",




[PATCH 4.18 10/34] drm/edid: Add 6 bpc quirk for BOE panel in HP Pavilion 15-n233sl

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Kai-Heng Feng 

commit 0711a43b6d84ff9189adfbf83c8bbf56eef794bf upstream.

There's another panel that reports "DFP 1.x compliant TMDS" but it
supports 6bpc instead of 8 bpc.

Apply 6 bpc quirk for the panel to fix it.

BugLink: https://bugs.launchpad.net/bugs/1794387
Cc:  # v4.8+
Signed-off-by: Kai-Heng Feng 
Signed-off-by: Daniel Vetter 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20181002152911.4370-1-kai.heng.f...@canonical.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_edid.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -113,6 +113,9 @@ static const struct edid_quirk {
/* AEO model 0 reports 8 bpc, but is a 6 bpc panel */
{ "AEO", 0, EDID_QUIRK_FORCE_6BPC },
 
+   /* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc 
panel */
+   { "BOE", 0x78b, EDID_QUIRK_FORCE_6BPC },
+
/* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */
{ "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC },
 




[PATCH 4.18 15/34] cdc-acm: do not reset notification buffer index upon urb unlinking

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Tobias Herzog 

commit dae3ddba36f8c337fb59cef07d564da6fc9b7551 upstream.

Resetting the write index of the notification buffer on urb unlink (e.g.
closing a cdc-acm device from userspace) may lead to wrong interpretation
of further received notifications, in case the index is not 0 when urb
unlink happens (i.e. when parts of a notification already have been
transferred). On the device side there is no "reset" of the notification
transimission and thus we would get out of sync with the device.

Signed-off-by: Tobias Herzog 
Acked-by: Oliver Neukum 
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/class/cdc-acm.c |1 -
 1 file changed, 1 deletion(-)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -354,7 +354,6 @@ static void acm_ctrl_irq(struct urb *urb
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
-   acm->nb_index = 0;
dev_dbg(&acm->control->dev,
"%s - urb shutting down with status: %d\n",
__func__, status);




[PATCH 4.18 11/34] drm/edid: VSDB yCBCr420 Deep Color mode bit definitions

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Clint Taylor 

commit 9068e02f58740778d8270840657f1e250a2cc60f upstream.

HDMI Forum VSDB YCBCR420 deep color capability bits are 2:0. Correct
definitions in the header for the mask to work correctly.

Fixes: e6a9a2c3dc43 ("drm/edid: parse ycbcr 420 deep color information")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107893
Cc:  # v4.14+
Signed-off-by: Clint Taylor 
Reviewed-by: Jani Nikula 
Reviewed-by: Shashank Sharma 
Signed-off-by: Jani Nikula 
Link: 
https://patchwork.freedesktop.org/patch/msgid/1538776335-12569-1-git-send-email-clinton.a.tay...@intel.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_edid.c |2 +-
 include/drm/drm_edid.h |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4282,7 +4282,7 @@ static void drm_parse_ycbcr420_deep_colo
struct drm_hdmi_info *hdmi = &connector->display_info.hdmi;
 
dc_mask = db[7] & DRM_EDID_YCBCR420_DC_MASK;
-   hdmi->y420_dc_modes |= dc_mask;
+   hdmi->y420_dc_modes = dc_mask;
 }
 
 static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -214,9 +214,9 @@ struct detailed_timing {
 #define DRM_EDID_HDMI_DC_Y444 (1 << 3)
 
 /* YCBCR 420 deep color modes */
-#define DRM_EDID_YCBCR420_DC_48  (1 << 6)
-#define DRM_EDID_YCBCR420_DC_36  (1 << 5)
-#define DRM_EDID_YCBCR420_DC_30  (1 << 4)
+#define DRM_EDID_YCBCR420_DC_48  (1 << 2)
+#define DRM_EDID_YCBCR420_DC_36  (1 << 1)
+#define DRM_EDID_YCBCR420_DC_30  (1 << 0)
 #define DRM_EDID_YCBCR420_DC_MASK (DRM_EDID_YCBCR420_DC_48 | \
DRM_EDID_YCBCR420_DC_36 | \
DRM_EDID_YCBCR420_DC_30)




[PATCH 4.14 31/31] net: fs_enet: do not call phy_stop() in interrupts

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit f8b39039cbf2a15f2b8c9f081e1cbd5dee00aaf5 ]

In case of TX timeout, fs_timeout() calls phy_stop(), which
triggers the following BUG_ON() as we are in interrupt.

[92708.199889] kernel BUG at drivers/net/phy/mdio_bus.c:482!
[92708.204985] Oops: Exception in kernel mode, sig: 5 [#1]
[92708.210119] PREEMPT
[92708.212107] CMPC885
[92708.214216] CPU: 0 PID: 3 Comm: ksoftirqd/0 Tainted: GW   4.9.61 
#39
[92708.223227] task: c60f0a40 task.stack: c6104000
[92708.227697] NIP: c02a84bc LR: c02a947c CTR: c02a93d8
[92708.232614] REGS: c6105c70 TRAP: 0700   Tainted: GW(4.9.61)
[92708.241193] MSR: 00021032 [92708.244818]   CR: 24000822  XER: 
2000
[92708.248767]
GPR00: c02a947c c6105d20 c60f0a40 c62b4c00 0005 001f c069aad8 0001a688
GPR08: 0007 0100 c02a93d8  05fc  c6213240 c06338e4
GPR16: 0001 c06330d4 c0633094  c068 c6104000 c6104000 
GPR24: 0200   0004 0078 9032  c62b4c00
NIP [c02a84bc] mdiobus_read+0x20/0x74
[92708.281517] LR [c02a947c] kszphy_config_intr+0xa4/0xc4
[92708.286547] Call Trace:
[92708.288980] [c6105d20] [c6104000] 0xc6104000 (unreliable)
[92708.294339] [c6105d40] [c02a947c] kszphy_config_intr+0xa4/0xc4
[92708.300098] [c6105d50] [c02a5330] phy_stop+0x60/0x9c
[92708.305007] [c6105d60] [c02c84d0] fs_timeout+0xdc/0x110
[92708.310197] [c6105d80] [c035cd48] dev_watchdog+0x268/0x2a0
[92708.315593] [c6105db0] [c0060288] call_timer_fn+0x34/0x17c
[92708.321014] [c6105dd0] [c00605f0] run_timer_softirq+0x21c/0x2e4
[92708.326887] [c6105e50] [c001e19c] __do_softirq+0xf4/0x2f4
[92708.332207] [c6105eb0] [c001e3c8] run_ksoftirqd+0x2c/0x40
[92708.337560] [c6105ec0] [c003b420] smpboot_thread_fn+0x1f0/0x258
[92708.343405] [c6105ef0] [c003745c] kthread+0xbc/0xd0
[92708.348217] [c6105f40] [c000c400] ret_from_kernel_thread+0x5c/0x64
[92708.354275] Instruction dump:
[92708.357207] 7c0803a6 bbc10018 38210020 4e800020 7c0802a6 9421ffe0 54290024 
bfc10018
[92708.364865] 90010024 7c7f1b78 81290008 552902ee <0f09> 3bc3002c 7fc3f378 
90810008
[92708.372711] ---[ end trace 42b05441616fafd7 ]---

This patch moves fs_timeout() actions into an async worker.

Fixes: commit 48257c4f168e5 ("Add fs_enet ethernet network driver, for several 
embedded platforms")
Signed-off-by: Christophe Leroy 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 .../ethernet/freescale/fs_enet/fs_enet-main.c| 16 +---
 drivers/net/ethernet/freescale/fs_enet/fs_enet.h |  1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c 
b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 753259091b22..28bd4cf61741 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -613,9 +613,11 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct 
net_device *dev)
return NETDEV_TX_OK;
 }
 
-static void fs_timeout(struct net_device *dev)
+static void fs_timeout_work(struct work_struct *work)
 {
-   struct fs_enet_private *fep = netdev_priv(dev);
+   struct fs_enet_private *fep = container_of(work, struct fs_enet_private,
+  timeout_work);
+   struct net_device *dev = fep->ndev;
unsigned long flags;
int wake = 0;
 
@@ -627,7 +629,6 @@ static void fs_timeout(struct net_device *dev)
phy_stop(dev->phydev);
(*fep->ops->stop)(dev);
(*fep->ops->restart)(dev);
-   phy_start(dev->phydev);
}
 
phy_start(dev->phydev);
@@ -639,6 +640,13 @@ static void fs_timeout(struct net_device *dev)
netif_wake_queue(dev);
 }
 
+static void fs_timeout(struct net_device *dev)
+{
+   struct fs_enet_private *fep = netdev_priv(dev);
+
+   schedule_work(&fep->timeout_work);
+}
+
 /*-
  *  generic link-change handler - should be sufficient for most cases
  
*-*/
@@ -759,6 +767,7 @@ static int fs_enet_close(struct net_device *dev)
netif_stop_queue(dev);
netif_carrier_off(dev);
napi_disable(&fep->napi);
+   cancel_work_sync(&fep->timeout_work);
phy_stop(dev->phydev);
 
spin_lock_irqsave(&fep->lock, flags);
@@ -1019,6 +1028,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
 
ndev->netdev_ops = &fs_enet_netdev_ops;
ndev->watchdog_timeo = 2 * HZ;
+   INIT_WORK(&fep->timeout_work, fs_timeout_work);
netif_napi_add(ndev, &fep->napi, fs_enet_napi, fpi->napi_weight);
 
ndev->ethtool_ops = &fs_ethtool_ops;
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet.h 
b/driver

[PATCH 4.18 13/34] RDMA/ucma: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit a3671a4f973ee9d9621d60166cc3b037c397d604 upstream.

hdr.cmd can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/infiniband/core/ucma.c:1686 ucma_write() warn: potential
spectre issue 'ucma_cmd_table' [r] (local cap)

Fix this by sanitizing hdr.cmd before using it to index
ucm_cmd_table.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Signed-off-by: Doug Ledford 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/ucma.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -44,6 +44,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -1676,6 +1678,7 @@ static ssize_t ucma_write(struct file *f
 
if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
return -EINVAL;
+   hdr.cmd = array_index_nospec(hdr.cmd, ARRAY_SIZE(ucma_cmd_table));
 
if (hdr.in + sizeof(hdr) > len)
return -EINVAL;




Re: [PATCH v2] PCI/MSI: Don't touch MSI bits when the PCI device is disconnected

2018-11-08 Thread Greg Kroah-Hartman
On Thu, Nov 08, 2018 at 02:09:17PM -0600, Bjorn Helgaas wrote:
> [+cc Jonathan, Greg, Lukas, Russell, Sam, Oliver for discussion about
> PCI error recovery in general]
> 
> On Wed, Nov 07, 2018 at 05:42:57PM -0600, Bjorn Helgaas wrote:
> > On Tue, Sep 18, 2018 at 05:15:00PM -0500, Alexandru Gagniuc wrote:
> > > When a PCI device is gone, we don't want to send IO to it if we can
> > > avoid it. We expose functionality via the irq_chip structure. As
> > > users of that structure may not know about the underlying PCI device,
> > > it's our responsibility to guard against removed devices.
> > > 
> > > .irq_write_msi_msg() is already guarded inside __pci_write_msi_msg().
> > > .irq_mask/unmask() are not. Guard them for completeness.
> > > 
> > > For example, surprise removal of a PCIe device triggers teardown. This
> > > touches the irq_chips ops some point to disable the interrupts. I/O
> > > generated here can crash the system on firmware-first machines.
> > > Not triggering the IO in the first place greatly reduces the
> > > possibility of the problem occurring.
> > > 
> > > Signed-off-by: Alexandru Gagniuc 
> > 
> > Applied to pci/misc for v4.21, thanks!
> 
> I'm having second thoughts about this.  One thing I'm uncomfortable
> with is that sprinkling pci_dev_is_disconnected() around feels ad hoc
> instead of systematic, in the sense that I don't know how we convince
> ourselves that this (and only this) is the correct place to put it.

I think my stance always has been that this call is not good at all
because once you call it you never really know if it is still true as
the device could have been removed right afterward.

So almost any code that relies on it is broken, there is no locking and
it can and will race and you will loose.

I think your patch suffers from this race:

> +static u32 mmio_readl(struct pci_dev *dev, const volatile void __iomem *addr)
> +{
> + u32 val, id;
> +
> + if (pci_dev_is_disconnected(dev))
> + return ~0;

Great, but what happens if I yank the device out right here?

> + val = readl(addr);

This value could now be all FF, if the device is gone, so what did the
check above help with?

> + /*
> +  * If an MMIO read from the device returns ~0 data, that data may
> +  * be valid, or it may indicate a bus error.  If config space is
> +  * readable, assume it's valid data; otherwise, assume a bus error.
> +  */
> + if (val == ~0) {
> + pci_read_config_dword(dev, PCI_VENDOR_ID, &id);
> + if (id == ~0)
> + pci_dev_set_disconnected(dev, NULL);

So why do the check above for "is disconnected"?  What does this buy us
here, just short-circuiting the readl()?

> + }
> +
> + return val;
> +}
> +
> +static void mmio_writel(struct pci_dev *dev, u32 val,
> + volatile void __iomem *addr)
> +{
> + if (pci_dev_is_disconnected(dev))
> + return;
> +
> + writel(val, addr);

Why even check, what's wrong with always doing the write?

I understand the wish to make this easier, but I think the only way is
that the driver themselves should be checking on their reads.  And they
have to check on all reads, or at least on some subset of reads and be
able to handle 0xff for the other ones without going crazy.

I _think_ the xhci driver does this given that it is hot added/removed
all the time dynamically due to the way that modern laptops are made
where the bios adds/removed the xhci controller when a USB device is
added/removed.

thanks,

greg k-h


[PATCH 4.14 00/31] 4.14.80-stable review

2018-11-08 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.80 release.
There are 31 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sat Nov 10 21:51:09 UTC 2018.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.80-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-4.14.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.14.80-rc1

Christophe Leroy 
net: fs_enet: do not call phy_stop() in interrupts

Sebastian Andrzej Siewior 
x86/fpu: Fix i486 + no387 boot crash by only saving FPU registers on 
context switch if there is an FPU

Nathan Chancellor 
x86/time: Correct the attribute on jiffies' definition

Peter Zijlstra 
x86/percpu: Fix this_cpu_read()

Zhimin Gu 
x86, hibernate: Fix nosave_regions setup for hibernation

Peter Zijlstra 
x86/tsc: Force inlining of cyc2ns bits

Phil Auld 
sched/fair: Fix throttle_list starvation with low CFS quota

Mikhail Nikiforov 
Input: elan_i2c - add ACPI ID for Lenovo IdeaPad 330-15IGM

Alan Stern 
USB: fix the usbfs flag sanitization for control transfers

Gustavo A. R. Silva 
usb: gadget: storage: Fix Spectre v1 vulnerability

Shuah Khan (Samsung OSG) 
usb: usbip: Fix BUG: KASAN: slab-out-of-bounds in vhci_hub_control()

Oliver Neukum 
cdc-acm: fix race between reset and control messaging

Tobias Herzog 
cdc-acm: correct counting of UART states in serial state notification

Tobias Herzog 
cdc-acm: do not reset notification buffer index upon urb unlinking

Gustavo A. R. Silva 
IB/ucm: Fix Spectre v1 vulnerability

Gustavo A. R. Silva 
RDMA/ucma: Fix Spectre v1 vulnerability

Eugeniy Paltsev 
drm: fb-helper: Reject all pixel format changing requests

Clint Taylor 
drm/edid: VSDB yCBCr420 Deep Color mode bit definitions

Kai-Heng Feng 
drm/edid: Add 6 bpc quirk for BOE panel in HP Pavilion 15-n233sl

Gustavo A. R. Silva 
ptp: fix Spectre v1 vulnerability

Al Viro 
cachefiles: fix the race between cachefiles_bury_object() and rmdir(2)

Brian Foster 
xfs: truncate transaction does not modify the inobt

Linus Walleij 
gpio: mxs: Get rid of external API call

Amir Goldstein 
fsnotify: fix ignore mask logic in fsnotify()

Dmitry Osipenko 
clk: tegra: Add quirk for getting CDEV1/2 clocks on Tegra20

Sasha Levin 
Revert "ARM: tegra: Fix ULPI regression on Tegra20"

Daniel Borkmann 
bpf: fix partial copy of map_ptr when dst is scalar

Johan Hovold 
USB: serial: option: add two-endpoints device-id flag

Kristian Evensen 
USB: serial: option: improve Quectel EP06 detection

Amir Goldstein 
vfs: swap names of {do,vfs}_clone_file_range()

Alan Chiang 
eeprom: at24: Add support for address-width property


-

Diffstat:

 Makefile   |  4 +-
 arch/arm/boot/dts/tegra20.dtsi |  2 +-
 arch/x86/include/asm/fpu/internal.h|  2 +-
 arch/x86/include/asm/percpu.h  |  8 +-
 arch/x86/kernel/setup.c|  2 +-
 arch/x86/kernel/time.c |  2 +-
 arch/x86/kernel/tsc.c  |  6 +-
 drivers/clk/tegra/clk-tegra114.c   |  2 +-
 drivers/clk/tegra/clk-tegra124.c   |  2 +-
 drivers/clk/tegra/clk-tegra20.c| 32 +++-
 drivers/clk/tegra/clk-tegra210.c   |  2 +-
 drivers/clk/tegra/clk-tegra30.c|  2 +-
 drivers/clk/tegra/clk.c|  5 +-
 drivers/clk/tegra/clk.h|  2 +-
 drivers/gpio/gpio-mxs.c|  4 +-
 drivers/gpu/drm/drm_edid.c |  5 +-
 drivers/gpu/drm/drm_fb_helper.c| 91 +++---
 drivers/infiniband/core/ucm.c  |  3 +
 drivers/infiniband/core/ucma.c |  3 +
 drivers/input/mouse/elan_i2c_core.c|  1 +
 drivers/misc/eeprom/at24.c | 17 
 .../net/ethernet/freescale/fs_enet/fs_enet-main.c  | 16 +++-
 drivers/net/ethernet/freescale/fs_enet/fs_enet.h   |  1 +
 drivers/ptp/ptp_chardev.c  |  4 +
 drivers/usb/class/cdc-acm.c| 16 ++--
 drivers/usb/core/devio.c   |  4 +-
 drivers/usb/gadget/function/f_mass_storage.c   |  3 +
 drivers/usb/serial/option.c| 15 +++-
 drivers/usb/usbip/vhci_hcd.c   | 57 ++
 fs/cachefiles/namei.c  |  2 +-
 fs/ioctl.c 

[PATCH 4.14 30/31] x86/fpu: Fix i486 + no387 boot crash by only saving FPU registers on context switch if there is an FPU

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

commit 2224d616528194b02424c91c2ee254b3d29942c3 upstream.

Booting an i486 with "no387 nofxsr" ends with with the following crash:

   math_emulate: 0060:c101987d
   Kernel panic - not syncing: Math emulation needed in kernel

on the first context switch in user land.

The reason is that copy_fpregs_to_fpstate() tries FNSAVE which does not work
as the FPU is turned off.

This bug was introduced in:

  f1c8cd0176078 ("x86/fpu: Change fpu->fpregs_active users to 
fpu->fpstate_active")

Add a check for X86_FEATURE_FPU before trying to save FPU registers (we
have such a check in switch_fpu_finish() already).

Signed-off-by: Sebastian Andrzej Siewior 
Reviewed-by: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Dave Hansen 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Fixes: f1c8cd0176078 ("x86/fpu: Change fpu->fpregs_active users to 
fpu->fpstate_active")
Link: http://lkml.kernel.org/r/20181016202525.29437-4-bige...@linutronix.de
Signed-off-by: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/include/asm/fpu/internal.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -528,7 +528,7 @@ static inline void fpregs_activate(struc
 static inline void
 switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 {
-   if (old_fpu->initialized) {
+   if (static_cpu_has(X86_FEATURE_FPU) && old_fpu->initialized) {
if (!copy_fpregs_to_fpstate(old_fpu))
old_fpu->last_cpu = -1;
else




[PATCH 4.14 06/31] Revert "ARM: tegra: Fix ULPI regression on Tegra20"

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

This reverts commit b39ac54215190bc178ae7de799e74d327a3c1a33.

The issue was fixed by upstream commit 5d797111afe1 ("clk:
tegra: Add quirk for getting CDEV1/2 clocks on Tegra20").

Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/tegra20.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 2780e68a853b..914f59166a99 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -706,7 +706,7 @@
phy_type = "ulpi";
clocks = <&tegra_car TEGRA20_CLK_USB2>,
 <&tegra_car TEGRA20_CLK_PLL_U>,
-<&tegra_car TEGRA20_CLK_PLL_P_OUT4>;
+<&tegra_car TEGRA20_CLK_CDEV2>;
clock-names = "reg", "pll_u", "ulpi-link";
resets = <&tegra_car 58>, <&tegra_car 22>;
reset-names = "usb", "utmi-pads";
-- 
2.17.1





[PATCH 4.14 05/31] bpf: fix partial copy of map_ptr when dst is scalar

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

commit 0962590e553331db2cc0aef2dc35c57f6300dbbe upstream.

ALU operations on pointers such as scalar_reg += map_value_ptr are
handled in adjust_ptr_min_max_vals(). Problem is however that map_ptr
and range in the register state share a union, so transferring state
through dst_reg->range = ptr_reg->range is just buggy as any new
map_ptr in the dst_reg is then truncated (or null) for subsequent
checks. Fix this by adding a raw member and use it for copying state
over to dst_reg.

Fixes: f1174f77b50c ("bpf/verifier: rework value tracking")
Signed-off-by: Daniel Borkmann 
Cc: Edward Cree 
Acked-by: Alexei Starovoitov 
Signed-off-by: Alexei Starovoitov 
Acked-by: Edward Cree 
Signed-off-by: Sasha Levin 
---
 include/linux/bpf_verifier.h |  3 +++
 kernel/bpf/verifier.c| 10 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 73bec75b74c8..a004fd2b 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -50,6 +50,9 @@ struct bpf_reg_state {
 *   PTR_TO_MAP_VALUE_OR_NULL
 */
struct bpf_map *map_ptr;
+
+   /* Max size from any of the above. */
+   unsigned long raw;
};
/* Fixed part of pointer offset, pointer types only */
s32 off;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index a0ffc62e7677..013b0cd1958e 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1935,7 +1935,7 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
dst_reg->umax_value = umax_ptr;
dst_reg->var_off = ptr_reg->var_off;
dst_reg->off = ptr_reg->off + smin_val;
-   dst_reg->range = ptr_reg->range;
+   dst_reg->raw = ptr_reg->raw;
break;
}
/* A new variable offset is created.  Note that off_reg->off
@@ -1965,10 +1965,11 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
}
dst_reg->var_off = tnum_add(ptr_reg->var_off, off_reg->var_off);
dst_reg->off = ptr_reg->off;
+   dst_reg->raw = ptr_reg->raw;
if (ptr_reg->type == PTR_TO_PACKET) {
dst_reg->id = ++env->id_gen;
/* something was added to pkt_ptr, set range to zero */
-   dst_reg->range = 0;
+   dst_reg->raw = 0;
}
break;
case BPF_SUB:
@@ -1999,7 +2000,7 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
dst_reg->var_off = ptr_reg->var_off;
dst_reg->id = ptr_reg->id;
dst_reg->off = ptr_reg->off - smin_val;
-   dst_reg->range = ptr_reg->range;
+   dst_reg->raw = ptr_reg->raw;
break;
}
/* A new variable offset is created.  If the subtrahend is known
@@ -2025,11 +2026,12 @@ static int adjust_ptr_min_max_vals(struct 
bpf_verifier_env *env,
}
dst_reg->var_off = tnum_sub(ptr_reg->var_off, off_reg->var_off);
dst_reg->off = ptr_reg->off;
+   dst_reg->raw = ptr_reg->raw;
if (ptr_reg->type == PTR_TO_PACKET) {
dst_reg->id = ++env->id_gen;
/* something was added to pkt_ptr, set range to zero */
if (smin_val < 0)
-   dst_reg->range = 0;
+   dst_reg->raw = 0;
}
break;
case BPF_AND:
-- 
2.17.1





[PATCH 4.14 03/31] USB: serial: option: improve Quectel EP06 detection

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

commit 36cae568404a298a19a6e8a3f18641075d4cab04 upstream

The Quectel EP06 (and EM06/EG06) LTE modem supports updating the USB
configuration, without the VID/PID or configuration number changing.
When the configuration is updated and interfaces are added/removed, the
interface numbers are updated. This causes our current code for matching
EP06 not to work as intended, as the assumption about reserved
interfaces no longer holds. If for example the diagnostic (first)
interface is removed, option will (try to) bind to the QMI interface.

This patch improves EP06 detection by replacing the current match with
two matches, and those matches check class, subclass and protocol as
well as VID and PID. The diag interface exports class, subclass and
protocol as 0xff. For the other serial interfaces, class is 0xff and
subclass and protocol are both 0x0.

The modem can export the following devices and always in this order:
diag, nmea, at, ppp. qmi and adb. This means that diag can only ever be
interface 0, and interface numbers 1-5 should be marked as reserved. The
three other serial devices can have interface numbers 0-3, but I have
not marked any interfaces as reserved. The reason is that the serial
devices are the only interfaces exported by the device where subclass
and protocol is 0x0.

QMI exports the same class, subclass and protocol values as the diag
interface. However, the two interfaces have different number of
endpoints, QMI has three and diag two. I have added a check for number
of interfaces if VID/PID matches the EP06, and we ignore the device if
number of interfaces equals three (and subclass is set).

The upstream commit does not apply cleanly to the 4.14-tree because of
differences in option_probe(). In order to make the commit apply, a
slight reshuffeling of the code was needed.

Signed-off-by: Kristian Evensen 
Acked-by: Dan Williams 
[ johan: drop uneeded RSVD(5) for ADB ]
Cc: stable 
Signed-off-by: Johan Hovold 
Signed-off-by: Kristian Evensen 
Signed-off-by: Sasha Levin 
---
 drivers/usb/serial/option.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 0600dadd6a0c..d8d3cb18e9ea 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1084,8 +1084,9 @@ static const struct usb_device_id option_ids[] = {
  .driver_info = RSVD(4) },
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
  .driver_info = RSVD(4) },
-   { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06),
- .driver_info = RSVD(4) | RSVD(5) },
+   { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 
QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
+ .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) },
+   { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 
QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
@@ -2010,6 +2011,18 @@ static int option_probe(struct usb_serial *serial,
iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
return -ENODEV;
 
+   /*
+* Don't bind to the QMI device of the Quectel EP06/EG06/EM06. Class,
+* subclass and protocol is 0xff for both the diagnostic port and the
+* QMI interface, but the diagnostic port only has two endpoints (QMI
+* has three).
+*/
+   if (dev_desc->idVendor == cpu_to_le16(QUECTEL_VENDOR_ID) &&
+   dev_desc->idProduct == cpu_to_le16(QUECTEL_PRODUCT_EP06) &&
+   iface_desc->bInterfaceSubClass && iface_desc->bNumEndpoints == 3) {
+   return -ENODEV;
+   }
+
/* Store the device flags so we can use them during attach. */
usb_set_serial_data(serial, (void *)device_flags);
 
-- 
2.17.1





[PATCH 4.14 09/31] gpio: mxs: Get rid of external API call

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 833eacc7b5913da9896bacd30db7d490aa777868 ]

The MXS driver was calling back into the GPIO API from
its irqchip. This is not very elegant, as we are a driver,
let's just shortcut back into the gpio_chip .get() function
instead.

This is a tricky case since the .get() callback is not in
this file, instead assigned by bgpio_init(). Calling the
function direcly in the gpio_chip is however the lesser
evil.

Cc: Sascha Hauer 
Cc: Janusz Uzycki 
Signed-off-by: Linus Walleij 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpio-mxs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 435def22445d..f66395524d0e 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -32,8 +32,6 @@
 #include 
 #include 
 #include 
-/* FIXME: for gpio_get_value(), replace this by direct register read */
-#include 
 #include 
 
 #define MXS_SET0x4
@@ -100,7 +98,7 @@ static int mxs_gpio_set_irq_type(struct irq_data *d, 
unsigned int type)
port->both_edges &= ~pin_mask;
switch (type) {
case IRQ_TYPE_EDGE_BOTH:
-   val = gpio_get_value(port->gc.base + d->hwirq);
+   val = port->gc.get(&port->gc, d->hwirq);
if (val)
edge = GPIO_INT_FALL_EDGE;
else
-- 
2.17.1





[PATCH 4.14 08/31] fsnotify: fix ignore mask logic in fsnotify()

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 9bdda4e9cf2dcecb60a0683b10ffb8cd7e5f2f45 ]

Commit 92183a42898d ("fsnotify: fix ignore mask logic in
send_to_group()") acknoledges the use case of ignoring an event on
an inode mark, because of an ignore mask on a mount mark of the same
group (i.e. I want to get all events on this file, except for the events
that came from that mount).

This change depends on correctly merging the inode marks and mount marks
group lists, so that the mount mark ignore mask would be tested in
send_to_group(). Alas, the merging of the lists did not take into
account the case where event in question is not in the mask of any of
the mount marks.

To fix this, completely remove the tests for inode and mount event masks
from the lists merging code.

Fixes: 92183a42898d ("fsnotify: fix ignore mask logic in send_to_group")
Signed-off-by: Amir Goldstein 
Signed-off-by: Jan Kara 
[amir: backport to v4.14.y]
Signed-off-by: Amir Goldstein 
Signed-off-by: Sasha Levin 
---
 fs/notify/fsnotify.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index d76c81323dc1..2bc61e7543dd 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -286,17 +286,13 @@ int fsnotify(struct inode *to_tell, __u32 mask, const 
void *data, int data_is,
 
iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
 
-   if ((mask & FS_MODIFY) ||
-   (test_mask & to_tell->i_fsnotify_mask)) {
-   inode_conn = srcu_dereference(to_tell->i_fsnotify_marks,
+   inode_conn = srcu_dereference(to_tell->i_fsnotify_marks,
+ &fsnotify_mark_srcu);
+   if (inode_conn)
+   inode_node = srcu_dereference(inode_conn->list.first,
  &fsnotify_mark_srcu);
-   if (inode_conn)
-   inode_node = srcu_dereference(inode_conn->list.first,
- &fsnotify_mark_srcu);
-   }
 
-   if (mnt && ((mask & FS_MODIFY) ||
-   (test_mask & mnt->mnt_fsnotify_mask))) {
+   if (mnt) {
inode_conn = srcu_dereference(to_tell->i_fsnotify_marks,
  &fsnotify_mark_srcu);
if (inode_conn)
-- 
2.17.1





[PATCH 4.14 07/31] clk: tegra: Add quirk for getting CDEV1/2 clocks on Tegra20

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 5d797111afe12e488e08432fd9b372fae2cc7e93 ]

CDEV1 and CDEV2 clocks are a bit special case, their parent clock is
created by the pinctrl driver. It should be possible for clk user to
request these clocks before pinctrl driver got probed and hence user will
get an orphaned clock. That might be undesirable because user may expect
parent clock to be enabled by the child, so let's return -EPROBE_DEFER
till parent clock appears.

Signed-off-by: Dmitry Osipenko 
Acked-by: Peter De Schrijver 
Signed-off-by: Thierry Reding 
Signed-off-by: Sasha Levin 
---
 drivers/clk/tegra/clk-tegra114.c |  2 +-
 drivers/clk/tegra/clk-tegra124.c |  2 +-
 drivers/clk/tegra/clk-tegra20.c  | 32 +++-
 drivers/clk/tegra/clk-tegra210.c |  2 +-
 drivers/clk/tegra/clk-tegra30.c  |  2 +-
 drivers/clk/tegra/clk.c  |  5 +++--
 drivers/clk/tegra/clk.h  |  2 +-
 7 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/tegra/clk-tegra114.c b/drivers/clk/tegra/clk-tegra114.c
index fd1a99c05c2d..f94d1c016643 100644
--- a/drivers/clk/tegra/clk-tegra114.c
+++ b/drivers/clk/tegra/clk-tegra114.c
@@ -1369,7 +1369,7 @@ static void __init tegra114_clock_init(struct device_node 
*np)
tegra_super_clk_gen4_init(clk_base, pmc_base, tegra114_clks,
&pll_x_params);
 
-   tegra_add_of_provider(np);
+   tegra_add_of_provider(np, of_clk_src_onecell_get);
tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
 
tegra_clk_apply_init_table = tegra114_clock_apply_init_table;
diff --git a/drivers/clk/tegra/clk-tegra124.c b/drivers/clk/tegra/clk-tegra124.c
index e81ea5b11577..e08df2faafd7 100644
--- a/drivers/clk/tegra/clk-tegra124.c
+++ b/drivers/clk/tegra/clk-tegra124.c
@@ -1480,7 +1480,7 @@ static void __init tegra124_132_clock_init_post(struct 
device_node *np)
  &pll_x_params);
tegra_init_special_resets(1, tegra124_reset_assert,
  tegra124_reset_deassert);
-   tegra_add_of_provider(np);
+   tegra_add_of_provider(np, of_clk_src_onecell_get);
 
clks[TEGRA124_CLK_EMC] = tegra_clk_register_emc(clk_base, np,
&emc_lock);
diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
index 837e5cbd60e9..532322b3d717 100644
--- a/drivers/clk/tegra/clk-tegra20.c
+++ b/drivers/clk/tegra/clk-tegra20.c
@@ -1084,6 +1084,36 @@ static const struct of_device_id pmc_match[] __initconst 
= {
{ },
 };
 
+static struct clk *tegra20_clk_src_onecell_get(struct of_phandle_args *clkspec,
+  void *data)
+{
+   struct clk_hw *parent_hw;
+   struct clk_hw *hw;
+   struct clk *clk;
+
+   clk = of_clk_src_onecell_get(clkspec, data);
+   if (IS_ERR(clk))
+   return clk;
+
+   /*
+* Tegra20 CDEV1 and CDEV2 clocks are a bit special case, their parent
+* clock is created by the pinctrl driver. It is possible for clk user
+* to request these clocks before pinctrl driver got probed and hence
+* user will get an orphaned clock. That might be undesirable because
+* user may expect parent clock to be enabled by the child.
+*/
+   if (clkspec->args[0] == TEGRA20_CLK_CDEV1 ||
+   clkspec->args[0] == TEGRA20_CLK_CDEV2) {
+   hw = __clk_get_hw(clk);
+
+   parent_hw = clk_hw_get_parent(hw);
+   if (!parent_hw)
+   return ERR_PTR(-EPROBE_DEFER);
+   }
+
+   return clk;
+}
+
 static void __init tegra20_clock_init(struct device_node *np)
 {
struct device_node *node;
@@ -1122,7 +1152,7 @@ static void __init tegra20_clock_init(struct device_node 
*np)
 
tegra_init_dup_clks(tegra_clk_duplicates, clks, TEGRA20_CLK_CLK_MAX);
 
-   tegra_add_of_provider(np);
+   tegra_add_of_provider(np, tegra20_clk_src_onecell_get);
tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
 
tegra_clk_apply_init_table = tegra20_clock_apply_init_table;
diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index b92867814e2d..b57193fba643 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -3169,7 +3169,7 @@ static void __init tegra210_clock_init(struct device_node 
*np)
tegra_init_special_resets(2, tegra210_reset_assert,
  tegra210_reset_deassert);
 
-   tegra_add_of_provider(np);
+   tegra_add_of_provider(np, of_clk_src_onecell_get);
tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
 
tegra_cpu_car_ops = &tegra210_cpu_car_ops;
diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
index 07f5203df01c..80748e7925f8 100644
--- a/drivers

linux-next: Signed-off-by missing for commit in the rdma tree

2018-11-08 Thread Stephen Rothwell
Hi all,

Commit

  5736c7c499f1 ("RDMA/rxe: Distinguish between down links and disabled links")

is missing a Signed-off-by from its committer.

-- 
Cheers,
Stephen Rothwell


pgpt_d59gvFav.pgp
Description: OpenPGP digital signature


[PATCH 4.14 14/31] drm/edid: VSDB yCBCr420 Deep Color mode bit definitions

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Clint Taylor 

commit 9068e02f58740778d8270840657f1e250a2cc60f upstream.

HDMI Forum VSDB YCBCR420 deep color capability bits are 2:0. Correct
definitions in the header for the mask to work correctly.

Fixes: e6a9a2c3dc43 ("drm/edid: parse ycbcr 420 deep color information")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107893
Cc:  # v4.14+
Signed-off-by: Clint Taylor 
Reviewed-by: Jani Nikula 
Reviewed-by: Shashank Sharma 
Signed-off-by: Jani Nikula 
Link: 
https://patchwork.freedesktop.org/patch/msgid/1538776335-12569-1-git-send-email-clinton.a.tay...@intel.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_edid.c |2 +-
 include/drm/drm_edid.h |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4223,7 +4223,7 @@ static void drm_parse_ycbcr420_deep_colo
struct drm_hdmi_info *hdmi = &connector->display_info.hdmi;
 
dc_mask = db[7] & DRM_EDID_YCBCR420_DC_MASK;
-   hdmi->y420_dc_modes |= dc_mask;
+   hdmi->y420_dc_modes = dc_mask;
 }
 
 static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -214,9 +214,9 @@ struct detailed_timing {
 #define DRM_EDID_HDMI_DC_Y444 (1 << 3)
 
 /* YCBCR 420 deep color modes */
-#define DRM_EDID_YCBCR420_DC_48  (1 << 6)
-#define DRM_EDID_YCBCR420_DC_36  (1 << 5)
-#define DRM_EDID_YCBCR420_DC_30  (1 << 4)
+#define DRM_EDID_YCBCR420_DC_48  (1 << 2)
+#define DRM_EDID_YCBCR420_DC_36  (1 << 1)
+#define DRM_EDID_YCBCR420_DC_30  (1 << 0)
 #define DRM_EDID_YCBCR420_DC_MASK (DRM_EDID_YCBCR420_DC_48 | \
DRM_EDID_YCBCR420_DC_36 | \
DRM_EDID_YCBCR420_DC_30)




[PATCH 4.14 12/31] ptp: fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit efa61c8cf2950ab5c0e66cff3cabe2a2b24e81ba upstream.

pin_index can be indirectly controlled by user-space, hence leading
to a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/ptp/ptp_chardev.c:253 ptp_ioctl() warn: potential spectre issue
'ops->pin_config' [r] (local cap)

Fix this by sanitizing pin_index before using it to index
ops->pin_config, and before passing it as an argument to
function ptp_set_pinfunc(), in which it is used to index
info->pin_config.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Acked-by: Richard Cochran 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/ptp/ptp_chardev.c |4 
 1 file changed, 4 insertions(+)

--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -24,6 +24,8 @@
 #include 
 #include 
 
+#include 
+
 #include "ptp_private.h"
 
 static int ptp_disable_pinfunc(struct ptp_clock_info *ops,
@@ -248,6 +250,7 @@ long ptp_ioctl(struct posix_clock *pc, u
err = -EINVAL;
break;
}
+   pin_index = array_index_nospec(pin_index, ops->n_pins);
if (mutex_lock_interruptible(&ptp->pincfg_mux))
return -ERESTARTSYS;
pd = ops->pin_config[pin_index];
@@ -266,6 +269,7 @@ long ptp_ioctl(struct posix_clock *pc, u
err = -EINVAL;
break;
}
+   pin_index = array_index_nospec(pin_index, ops->n_pins);
if (mutex_lock_interruptible(&ptp->pincfg_mux))
return -ERESTARTSYS;
err = ptp_set_pinfunc(ptp, pin_index, pd.func, pd.chan);




[PATCH 4.14 16/31] RDMA/ucma: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit a3671a4f973ee9d9621d60166cc3b037c397d604 upstream.

hdr.cmd can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/infiniband/core/ucma.c:1686 ucma_write() warn: potential
spectre issue 'ucma_cmd_table' [r] (local cap)

Fix this by sanitizing hdr.cmd before using it to index
ucm_cmd_table.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Signed-off-by: Doug Ledford 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/ucma.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -44,6 +44,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -1659,6 +1661,7 @@ static ssize_t ucma_write(struct file *f
 
if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
return -EINVAL;
+   hdr.cmd = array_index_nospec(hdr.cmd, ARRAY_SIZE(ucma_cmd_table));
 
if (hdr.in + sizeof(hdr) > len)
return -EINVAL;




[PATCH 4.14 17/31] IB/ucm: Fix Spectre v1 vulnerability

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Gustavo A. R. Silva 

commit 0295e39595e1146522f2722715dba7f7fba42217 upstream.

hdr.cmd can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/infiniband/core/ucm.c:1127 ib_ucm_write() warn: potential
spectre issue 'ucm_cmd_table' [r] (local cap)

Fix this by sanitizing hdr.cmd before using it to index
ucm_cmd_table.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
Signed-off-by: Doug Ledford 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/ucm.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -46,6 +46,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -1118,6 +1120,7 @@ static ssize_t ib_ucm_write(struct file
 
if (hdr.cmd >= ARRAY_SIZE(ucm_cmd_table))
return -EINVAL;
+   hdr.cmd = array_index_nospec(hdr.cmd, ARRAY_SIZE(ucm_cmd_table));
 
if (hdr.in + sizeof(hdr) > len)
return -EINVAL;




[PATCH 4.14 13/31] drm/edid: Add 6 bpc quirk for BOE panel in HP Pavilion 15-n233sl

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Kai-Heng Feng 

commit 0711a43b6d84ff9189adfbf83c8bbf56eef794bf upstream.

There's another panel that reports "DFP 1.x compliant TMDS" but it
supports 6bpc instead of 8 bpc.

Apply 6 bpc quirk for the panel to fix it.

BugLink: https://bugs.launchpad.net/bugs/1794387
Cc:  # v4.8+
Signed-off-by: Kai-Heng Feng 
Signed-off-by: Daniel Vetter 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20181002152911.4370-1-kai.heng.f...@canonical.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_edid.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -111,6 +111,9 @@ static const struct edid_quirk {
/* AEO model 0 reports 8 bpc, but is a 6 bpc panel */
{ "AEO", 0, EDID_QUIRK_FORCE_6BPC },
 
+   /* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc 
panel */
+   { "BOE", 0x78b, EDID_QUIRK_FORCE_6BPC },
+
/* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */
{ "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC },
 




[PATCH 4.9 170/171] net: fs_enet: do not call phy_stop() in interrupts

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit f8b39039cbf2a15f2b8c9f081e1cbd5dee00aaf5 ]

In case of TX timeout, fs_timeout() calls phy_stop(), which
triggers the following BUG_ON() as we are in interrupt.

[92708.199889] kernel BUG at drivers/net/phy/mdio_bus.c:482!
[92708.204985] Oops: Exception in kernel mode, sig: 5 [#1]
[92708.210119] PREEMPT
[92708.212107] CMPC885
[92708.214216] CPU: 0 PID: 3 Comm: ksoftirqd/0 Tainted: GW   4.9.61 
#39
[92708.223227] task: c60f0a40 task.stack: c6104000
[92708.227697] NIP: c02a84bc LR: c02a947c CTR: c02a93d8
[92708.232614] REGS: c6105c70 TRAP: 0700   Tainted: GW(4.9.61)
[92708.241193] MSR: 00021032 [92708.244818]   CR: 24000822  XER: 
2000
[92708.248767]
GPR00: c02a947c c6105d20 c60f0a40 c62b4c00 0005 001f c069aad8 0001a688
GPR08: 0007 0100 c02a93d8  05fc  c6213240 c06338e4
GPR16: 0001 c06330d4 c0633094  c068 c6104000 c6104000 
GPR24: 0200   0004 0078 9032  c62b4c00
NIP [c02a84bc] mdiobus_read+0x20/0x74
[92708.281517] LR [c02a947c] kszphy_config_intr+0xa4/0xc4
[92708.286547] Call Trace:
[92708.288980] [c6105d20] [c6104000] 0xc6104000 (unreliable)
[92708.294339] [c6105d40] [c02a947c] kszphy_config_intr+0xa4/0xc4
[92708.300098] [c6105d50] [c02a5330] phy_stop+0x60/0x9c
[92708.305007] [c6105d60] [c02c84d0] fs_timeout+0xdc/0x110
[92708.310197] [c6105d80] [c035cd48] dev_watchdog+0x268/0x2a0
[92708.315593] [c6105db0] [c0060288] call_timer_fn+0x34/0x17c
[92708.321014] [c6105dd0] [c00605f0] run_timer_softirq+0x21c/0x2e4
[92708.326887] [c6105e50] [c001e19c] __do_softirq+0xf4/0x2f4
[92708.332207] [c6105eb0] [c001e3c8] run_ksoftirqd+0x2c/0x40
[92708.337560] [c6105ec0] [c003b420] smpboot_thread_fn+0x1f0/0x258
[92708.343405] [c6105ef0] [c003745c] kthread+0xbc/0xd0
[92708.348217] [c6105f40] [c000c400] ret_from_kernel_thread+0x5c/0x64
[92708.354275] Instruction dump:
[92708.357207] 7c0803a6 bbc10018 38210020 4e800020 7c0802a6 9421ffe0 54290024 
bfc10018
[92708.364865] 90010024 7c7f1b78 81290008 552902ee <0f09> 3bc3002c 7fc3f378 
90810008
[92708.372711] ---[ end trace 42b05441616fafd7 ]---

This patch moves fs_timeout() actions into an async worker.

Fixes: commit 48257c4f168e5 ("Add fs_enet ethernet network driver, for several 
embedded platforms")
Signed-off-by: Christophe Leroy 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 .../ethernet/freescale/fs_enet/fs_enet-main.c| 16 +---
 drivers/net/ethernet/freescale/fs_enet/fs_enet.h |  1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c 
b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 4b86260584a0..8b66551511f5 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -613,9 +613,11 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct 
net_device *dev)
return NETDEV_TX_OK;
 }
 
-static void fs_timeout(struct net_device *dev)
+static void fs_timeout_work(struct work_struct *work)
 {
-   struct fs_enet_private *fep = netdev_priv(dev);
+   struct fs_enet_private *fep = container_of(work, struct fs_enet_private,
+  timeout_work);
+   struct net_device *dev = fep->ndev;
unsigned long flags;
int wake = 0;
 
@@ -627,7 +629,6 @@ static void fs_timeout(struct net_device *dev)
phy_stop(dev->phydev);
(*fep->ops->stop)(dev);
(*fep->ops->restart)(dev);
-   phy_start(dev->phydev);
}
 
phy_start(dev->phydev);
@@ -639,6 +640,13 @@ static void fs_timeout(struct net_device *dev)
netif_wake_queue(dev);
 }
 
+static void fs_timeout(struct net_device *dev)
+{
+   struct fs_enet_private *fep = netdev_priv(dev);
+
+   schedule_work(&fep->timeout_work);
+}
+
 /*-
  *  generic link-change handler - should be sufficient for most cases
  
*-*/
@@ -759,6 +767,7 @@ static int fs_enet_close(struct net_device *dev)
netif_stop_queue(dev);
netif_carrier_off(dev);
napi_disable(&fep->napi);
+   cancel_work_sync(&fep->timeout_work);
phy_stop(dev->phydev);
 
spin_lock_irqsave(&fep->lock, flags);
@@ -1033,6 +1042,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
 
ndev->netdev_ops = &fs_enet_netdev_ops;
ndev->watchdog_timeo = 2 * HZ;
+   INIT_WORK(&fep->timeout_work, fs_timeout_work);
netif_napi_add(ndev, &fep->napi, fs_enet_napi, fpi->napi_weight);
 
ndev->ethtool_ops = &fs_ethtool_ops;
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet.h 
b/drivers

[PATCH 4.9 163/171] cdc-acm: correct counting of UART states in serial state notification

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Tobias Herzog 

commit f976d0e5747ca65ccd0fb2a4118b193d70aa1836 upstream.

The usb standard ("Universal Serial Bus Class Definitions for Communication
Devices") distiguishes between "consistent signals" (DSR, DCD), and
"irregular signals" (break, ring, parity error, framing error, overrun).
The bits of "irregular signals" are set, if this error/event occurred on
the device side and are immeadeatly unset, if the serial state notification
was sent.
Like other drivers of real serial ports do, just the occurence of those
events should be counted in serial_icounter_struct (but no 1->0
transitions).

Signed-off-by: Tobias Herzog 
Acked-by: Oliver Neukum 
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/class/cdc-acm.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -333,17 +333,17 @@ static void acm_ctrl_irq(struct urb *urb
 
if (difference & ACM_CTRL_DSR)
acm->iocount.dsr++;
-   if (difference & ACM_CTRL_BRK)
-   acm->iocount.brk++;
-   if (difference & ACM_CTRL_RI)
-   acm->iocount.rng++;
if (difference & ACM_CTRL_DCD)
acm->iocount.dcd++;
-   if (difference & ACM_CTRL_FRAMING)
+   if (newctrl & ACM_CTRL_BRK)
+   acm->iocount.brk++;
+   if (newctrl & ACM_CTRL_RI)
+   acm->iocount.rng++;
+   if (newctrl & ACM_CTRL_FRAMING)
acm->iocount.frame++;
-   if (difference & ACM_CTRL_PARITY)
+   if (newctrl & ACM_CTRL_PARITY)
acm->iocount.parity++;
-   if (difference & ACM_CTRL_OVERRUN)
+   if (newctrl & ACM_CTRL_OVERRUN)
acm->iocount.overrun++;
spin_unlock(&acm->read_lock);
 




[PATCH 4.14 11/31] cachefiles: fix the race between cachefiles_bury_object() and rmdir(2)

2018-11-08 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Al Viro 

commit 169b803397499be85bdd1e3d07d6f5e3d4bd669e upstream.

the victim might've been rmdir'ed just before the lock_rename();
unlike the normal callers, we do not look the source up after the
parents are locked - we know it beforehand and just recheck that it's
still the child of what used to be its parent.  Unfortunately,
the check is too weak - we don't spot a dead directory since its
->d_parent is unchanged, dentry is positive, etc.  So we sail all
the way to ->rename(), with hosting filesystems _not_ expecting
to be asked renaming an rmdir'ed subdirectory.

The fix is easy, fortunately - the lock on parent is sufficient for
making IS_DEADDIR() on child safe.

Cc: sta...@vger.kernel.org
Fixes: 9ae326a69004 (CacheFiles: A cache that backs onto a mounted filesystem)
Signed-off-by: Al Viro 
Signed-off-by: David Howells 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/cachefiles/namei.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -340,7 +340,7 @@ try_again:
trap = lock_rename(cache->graveyard, dir);
 
/* do some checks before getting the grave dentry */
-   if (rep->d_parent != dir) {
+   if (rep->d_parent != dir || IS_DEADDIR(d_inode(rep))) {
/* the entry was probably culled when we dropped the parent dir
 * lock */
unlock_rename(cache->graveyard, dir);




[PATCH 4.9 169/171] x86/time: Correct the attribute on jiffies definition

2018-11-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Nathan Chancellor 

commit 53c13ba8ed39e89f21a0b98f4c8a241bb44e483d upstream.

Clang warns that the declaration of jiffies in include/linux/jiffies.h
doesn't match the definition in arch/x86/time/kernel.c:

arch/x86/kernel/time.c:29:42: warning: section does not match previous 
declaration [-Wsection]
__visible volatile unsigned long jiffies __cacheline_aligned = INITIAL_JIFFIES;
 ^
./include/linux/cache.h:49:4: note: expanded from macro '__cacheline_aligned'
 __section__(".data..cacheline_aligned")))
 ^
./include/linux/jiffies.h:81:31: note: previous attribute is here
extern unsigned long volatile __cacheline_aligned_in_smp __jiffy_arch_data 
jiffies;
  ^
./arch/x86/include/asm/cache.h:20:2: note: expanded from macro 
'__cacheline_aligned_in_smp'
__page_aligned_data
^
./include/linux/linkage.h:39:29: note: expanded from macro '__page_aligned_data'
#define __page_aligned_data __section(.data..page_aligned) 
__aligned(PAGE_SIZE)
^
./include/linux/compiler_attributes.h:233:56: note: expanded from macro 
'__section'
#define __section(S)__attribute__((__section__(#S)))
   ^
1 warning generated.

The declaration was changed in commit 7c30f352c852 ("jiffies.h: declare
jiffies and jiffies_64 with cacheline_aligned_in_smp") but wasn't
updated here. Make them match so Clang no longer warns.

Fixes: 7c30f352c852 ("jiffies.h: declare jiffies and jiffies_64 with 
cacheline_aligned_in_smp")
Signed-off-by: Nathan Chancellor 
Signed-off-by: Thomas Gleixner 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Nick Desaulniers 
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20181013005311.28617-1-natechancel...@gmail.com
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/time.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -24,7 +24,7 @@
 #include 
 
 #ifdef CONFIG_X86_64
-__visible volatile unsigned long jiffies __cacheline_aligned = INITIAL_JIFFIES;
+__visible volatile unsigned long jiffies __cacheline_aligned_in_smp = 
INITIAL_JIFFIES;
 #endif
 
 unsigned long profile_pc(struct pt_regs *regs)




  1   2   3   4   5   6   7   8   9   10   >