* [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file
@ 2019-02-15 2:13 Sasha Levin
2019-02-15 2:13 ` [PATCH AUTOSEL 4.9 02/27] ASoC: Intel: Haswell/Broadwell: fix setting for .dynamic field Sasha Levin
` (25 more replies)
0 siblings, 26 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:13 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Kristian H. Kristensen, Kristian H . Kristensen, Rob Clark,
Sasha Levin, linux-arm-msm, dri-devel, freedreno
From: "Kristian H. Kristensen" <hoegsberg@gmail.com>
[ Upstream commit 99c66bc051e7407fe0bf0607b142ec0be1a1d1dd ]
Prevents deadlock when fifo is full and reader closes file.
Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/msm_rd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c
index 8487f461f05f..4823019eb422 100644
--- a/drivers/gpu/drm/msm/msm_rd.c
+++ b/drivers/gpu/drm/msm/msm_rd.c
@@ -112,7 +112,9 @@ static void rd_write(struct msm_rd_state *rd, const void *buf, int sz)
char *fptr = &fifo->buf[fifo->head];
int n;
- wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0);
+ wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0 || !rd->open);
+ if (!rd->open)
+ return;
n = min(sz, circ_space_to_end(&rd->fifo));
memcpy(fptr, ptr, n);
@@ -202,7 +204,10 @@ static int rd_open(struct inode *inode, struct file *file)
static int rd_release(struct inode *inode, struct file *file)
{
struct msm_rd_state *rd = inode->i_private;
+
rd->open = false;
+ wake_up_all(&rd->fifo_event);
+
return 0;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 02/27] ASoC: Intel: Haswell/Broadwell: fix setting for .dynamic field
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
@ 2019-02-15 2:13 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 03/27] ALSA: compress: prevent potential divide by zero bugs Sasha Levin
` (24 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:13 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Rander Wang, Mark Brown, Sasha Levin
From: Rander Wang <rander.wang@linux.intel.com>
[ Upstream commit 906a9abc5de73c383af518f5a806f4be2993a0c7 ]
For some reason this field was set to zero when all other drivers use
.dynamic = 1 for front-ends. This change was tested on Dell XPS13 and
has no impact with the existing legacy driver. The SOF driver also works
with this change which enables it to override the fixed topology.
Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/intel/boards/broadwell.c | 2 +-
sound/soc/intel/boards/haswell.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c
index 7486a0022fde..993d2c105ae1 100644
--- a/sound/soc/intel/boards/broadwell.c
+++ b/sound/soc/intel/boards/broadwell.c
@@ -191,7 +191,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
.stream_name = "Loopback",
.cpu_dai_name = "Loopback Pin",
.platform_name = "haswell-pcm-audio",
- .dynamic = 0,
+ .dynamic = 1,
.codec_name = "snd-soc-dummy",
.codec_dai_name = "snd-soc-dummy-dai",
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
diff --git a/sound/soc/intel/boards/haswell.c b/sound/soc/intel/boards/haswell.c
index 863f1d5e2a2c..11d0cc2b0e39 100644
--- a/sound/soc/intel/boards/haswell.c
+++ b/sound/soc/intel/boards/haswell.c
@@ -145,7 +145,7 @@ static struct snd_soc_dai_link haswell_rt5640_dais[] = {
.stream_name = "Loopback",
.cpu_dai_name = "Loopback Pin",
.platform_name = "haswell-pcm-audio",
- .dynamic = 0,
+ .dynamic = 1,
.codec_name = "snd-soc-dummy",
.codec_dai_name = "snd-soc-dummy-dai",
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 03/27] ALSA: compress: prevent potential divide by zero bugs
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
2019-02-15 2:13 ` [PATCH AUTOSEL 4.9 02/27] ASoC: Intel: Haswell/Broadwell: fix setting for .dynamic field Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 04/27] thermal: int340x_thermal: Fix a NULL vs IS_ERR() check Sasha Levin
` (23 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Dan Carpenter, Mark Brown, Sasha Levin
From: Dan Carpenter <dan.carpenter@oracle.com>
[ Upstream commit 678e2b44c8e3fec3afc7202f1996a4500a50be93 ]
The problem is seen in the q6asm_dai_compr_set_params() function:
ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys,
(prtd->pcm_size / prtd->periods),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
prtd->periods);
In this code prtd->pcm_size is the buffer_size and prtd->periods comes
from params->buffer.fragments. If we allow the number of fragments to
be zero then it results in a divide by zero bug. One possible fix would
be to use prtd->pcm_count directly instead of using the division to
re-calculate it. But I decided that it doesn't really make sense to
allow zero fragments.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/core/compress_offload.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 4490a699030b..555df64d46ff 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -529,7 +529,8 @@ static int snd_compress_check_input(struct snd_compr_params *params)
{
/* first let's check the buffer parameter's */
if (params->buffer.fragment_size == 0 ||
- params->buffer.fragments > INT_MAX / params->buffer.fragment_size)
+ params->buffer.fragments > INT_MAX / params->buffer.fragment_size ||
+ params->buffer.fragments == 0)
return -EINVAL;
/* now codec parameters */
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 04/27] thermal: int340x_thermal: Fix a NULL vs IS_ERR() check
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
2019-02-15 2:13 ` [PATCH AUTOSEL 4.9 02/27] ASoC: Intel: Haswell/Broadwell: fix setting for .dynamic field Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 03/27] ALSA: compress: prevent potential divide by zero bugs Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 05/27] usb: dwc3: gadget: synchronize_irq dwc irq in suspend Sasha Levin
` (22 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Dan Carpenter, Zhang Rui, Sasha Levin, linux-pm
From: Dan Carpenter <dan.carpenter@oracle.com>
[ Upstream commit 3fe931b31a4078395c1967f0495dcc9e5ec6b5e3 ]
The intel_soc_dts_iosf_init() function doesn't return NULL, it returns
error pointers.
Fixes: 4d0dd6c1576b ("Thermal/int340x/processor_thermal: Enable auxiliary DTS for Braswell")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/thermal/int340x_thermal/processor_thermal_device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/int340x_thermal/processor_thermal_device.c b/drivers/thermal/int340x_thermal/processor_thermal_device.c
index ff3b36f339e3..06d46e2ff337 100644
--- a/drivers/thermal/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/int340x_thermal/processor_thermal_device.c
@@ -416,7 +416,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
proc_priv->soc_dts = intel_soc_dts_iosf_init(
INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0);
- if (proc_priv->soc_dts && pdev->irq) {
+ if (!IS_ERR(proc_priv->soc_dts) && pdev->irq) {
ret = pci_enable_msi(pdev);
if (!ret) {
ret = request_threaded_irq(pdev->irq, NULL,
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 05/27] usb: dwc3: gadget: synchronize_irq dwc irq in suspend
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (2 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 04/27] thermal: int340x_thermal: Fix a NULL vs IS_ERR() check Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 06/27] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts Sasha Levin
` (21 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Bo He, Yu Wang, Felipe Balbi, Sasha Levin, linux-usb
From: Bo He <bo.he@intel.com>
[ Upstream commit 01c10880d24291a96a4ab0da773e3c5ce4d12da8 ]
We see dwc3 endpoint stopped by unwanted irq during
suspend resume test, which is caused dwc3 ep can't be started
with error "No Resource".
Here, add synchronize_irq before suspend to sync the
pending IRQ handlers complete.
Signed-off-by: Bo He <bo.he@intel.com>
Signed-off-by: Yu Wang <yu.y.wang@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/dwc3/gadget.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index ed6b9bfe3759..c481df18a5a1 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -3096,6 +3096,8 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
dwc3_disconnect_gadget(dwc);
__dwc3_gadget_stop(dwc);
+ synchronize_irq(dwc->irq_gadget);
+
return 0;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 06/27] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (3 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 05/27] usb: dwc3: gadget: synchronize_irq dwc irq in suspend Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 07/27] usb: gadget: Potential NULL dereference on allocation error Sasha Levin
` (20 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Zeng Tao, Felipe Balbi, Sasha Levin, linux-usb
From: Zeng Tao <prime.zeng@hisilicon.com>
[ Upstream commit 88b1bb1f3b88e0bf20b05d543a53a5b99bd7ceb6 ]
Currently the link_state is uninitialized and the default value is 0(U0)
before the first time we start the udc, and after we start the udc then
stop the udc, the link_state will be undefined.
We may have the following warnings if we start the udc again with
an undefined link_state:
WARNING: CPU: 0 PID: 327 at drivers/usb/dwc3/gadget.c:294 dwc3_send_gadget_ep_cmd+0x304/0x308
dwc3 100e0000.hidwc3_0: wakeup failed --> -22
[...]
Call Trace:
[<c010f270>] (unwind_backtrace) from [<c010b3d8>] (show_stack+0x10/0x14)
[<c010b3d8>] (show_stack) from [<c034a4dc>] (dump_stack+0x84/0x98)
[<c034a4dc>] (dump_stack) from [<c0118000>] (__warn+0xe8/0x100)
[<c0118000>] (__warn) from [<c0118050>](warn_slowpath_fmt+0x38/0x48)
[<c0118050>] (warn_slowpath_fmt) from [<c0442ec0>](dwc3_send_gadget_ep_cmd+0x304/0x308)
[<c0442ec0>] (dwc3_send_gadget_ep_cmd) from [<c0445e68>](dwc3_ep0_start_trans+0x48/0xf4)
[<c0445e68>] (dwc3_ep0_start_trans) from [<c0446750>](dwc3_ep0_out_start+0x64/0x80)
[<c0446750>] (dwc3_ep0_out_start) from [<c04451c0>](__dwc3_gadget_start+0x1e0/0x278)
[<c04451c0>] (__dwc3_gadget_start) from [<c04452e0>](dwc3_gadget_start+0x88/0x10c)
[<c04452e0>] (dwc3_gadget_start) from [<c045ee54>](udc_bind_to_driver+0x88/0xbc)
[<c045ee54>] (udc_bind_to_driver) from [<c045f29c>](usb_gadget_probe_driver+0xf8/0x140)
[<c045f29c>] (usb_gadget_probe_driver) from [<bf005424>](gadget_dev_desc_UDC_store+0xac/0xc4 [libcomposite])
[<bf005424>] (gadget_dev_desc_UDC_store [libcomposite]) from[<c023d8e0>] (configfs_write_file+0xd4/0x160)
[<c023d8e0>] (configfs_write_file) from [<c01d51e8>] (__vfs_write+0x1c/0x114)
[<c01d51e8>] (__vfs_write) from [<c01d5ff4>] (vfs_write+0xa4/0x168)
[<c01d5ff4>] (vfs_write) from [<c01d6d40>] (SyS_write+0x3c/0x90)
[<c01d6d40>] (SyS_write) from [<c0107400>] (ret_fast_syscall+0x0/0x3c)
Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/dwc3/gadget.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index c481df18a5a1..712bd450f857 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1705,6 +1705,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
/* begin to receive SETUP packets */
dwc->ep0state = EP0_SETUP_PHASE;
+ dwc->link_state = DWC3_LINK_STATE_SS_DIS;
dwc3_ep0_out_start(dwc);
dwc3_gadget_enable_irq(dwc);
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 07/27] usb: gadget: Potential NULL dereference on allocation error
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (4 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 06/27] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 08/27] ASoC: dapm: change snprintf to scnprintf for possible overflow Sasha Levin
` (19 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Dan Carpenter, Felipe Balbi, Sasha Levin, linux-usb
From: Dan Carpenter <dan.carpenter@oracle.com>
[ Upstream commit df28169e1538e4a8bcd8b779b043e5aa6524545c ]
The source_sink_alloc_func() function is supposed to return error
pointers on error. The function is called from usb_get_function() which
doesn't check for NULL returns so it would result in an Oops.
Of course, in the current kernel, small allocations always succeed so
this doesn't affect runtime.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/gadget/function/f_sourcesink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 8784fa12ea2c..6e9d958004a0 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -842,7 +842,7 @@ static struct usb_function *source_sink_alloc_func(
ss = kzalloc(sizeof(*ss), GFP_KERNEL);
if (!ss)
- return NULL;
+ return ERR_PTR(-ENOMEM);
ss_opts = container_of(fi, struct f_ss_opts, func_inst);
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 08/27] ASoC: dapm: change snprintf to scnprintf for possible overflow
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (5 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 07/27] usb: gadget: Potential NULL dereference on allocation error Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 09/27] ASoC: imx-audmux: " Sasha Levin
` (18 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Silvio Cesare, Liam Girdwood, Mark Brown, Dan Carpenter,
Kees Cook, Will Deacon, Greg KH, Willy Tarreau, Sasha Levin
From: Silvio Cesare <silvio.cesare@gmail.com>
[ Upstream commit e581e151e965bf1f2815dd94620b638fec4d0a7e ]
Change snprintf to scnprintf. There are generally two cases where using
snprintf causes problems.
1) Uses of size += snprintf(buf, SIZE - size, fmt, ...)
In this case, if snprintf would have written more characters than what the
buffer size (SIZE) is, then size will end up larger than SIZE. In later
uses of snprintf, SIZE - size will result in a negative number, leading
to problems. Note that size might already be too large by using
size = snprintf before the code reaches a case of size += snprintf.
2) If size is ultimately used as a length parameter for a copy back to user
space, then it will potentially allow for a buffer overflow and information
disclosure when size is greater than SIZE. When the size is used to index
the buffer directly, we can have memory corruption. This also means when
size = snprintf... is used, it may also cause problems since size may become
large. Copying to userspace is mitigated by the HARDENED_USERCOPY kernel
configuration.
The solution to these issues is to use scnprintf which returns the number of
characters actually written to the buffer, so the size variable will never
exceed SIZE.
Signed-off-by: Silvio Cesare <silvio.cesare@gmail.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/soc-dapm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8bfc534e3b34..ab647f1fe11b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1976,19 +1976,19 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
out = is_connected_output_ep(w, NULL, NULL);
}
- ret = snprintf(buf, PAGE_SIZE, "%s: %s%s in %d out %d",
+ ret = scnprintf(buf, PAGE_SIZE, "%s: %s%s in %d out %d",
w->name, w->power ? "On" : "Off",
w->force ? " (forced)" : "", in, out);
if (w->reg >= 0)
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
" - R%d(0x%x) mask 0x%x",
w->reg, w->reg, w->mask << w->shift);
- ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
if (w->sname)
- ret += snprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n",
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n",
w->sname,
w->active ? "active" : "inactive");
@@ -2001,7 +2001,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
if (!p->connect)
continue;
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
" %s \"%s\" \"%s\"\n",
(rdir == SND_SOC_DAPM_DIR_IN) ? "in" : "out",
p->name ? p->name : "static",
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 09/27] ASoC: imx-audmux: change snprintf to scnprintf for possible overflow
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (6 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 08/27] ASoC: dapm: change snprintf to scnprintf for possible overflow Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 10/27] ARC: fix __ffs return value to avoid build warnings Sasha Levin
` (17 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Silvio Cesare, Timur Tabi, Nicolin Chen, Mark Brown, Xiubo Li,
Fabio Estevam, Dan Carpenter, Kees Cook, Will Deacon, Greg KH,
Willy Tarreau, Sasha Levin, linuxppc-dev
From: Silvio Cesare <silvio.cesare@gmail.com>
[ Upstream commit c407cd008fd039320d147088b52d0fa34ed3ddcb ]
Change snprintf to scnprintf. There are generally two cases where using
snprintf causes problems.
1) Uses of size += snprintf(buf, SIZE - size, fmt, ...)
In this case, if snprintf would have written more characters than what the
buffer size (SIZE) is, then size will end up larger than SIZE. In later
uses of snprintf, SIZE - size will result in a negative number, leading
to problems. Note that size might already be too large by using
size = snprintf before the code reaches a case of size += snprintf.
2) If size is ultimately used as a length parameter for a copy back to user
space, then it will potentially allow for a buffer overflow and information
disclosure when size is greater than SIZE. When the size is used to index
the buffer directly, we can have memory corruption. This also means when
size = snprintf... is used, it may also cause problems since size may become
large. Copying to userspace is mitigated by the HARDENED_USERCOPY kernel
configuration.
The solution to these issues is to use scnprintf which returns the number of
characters actually written to the buffer, so the size variable will never
exceed SIZE.
Signed-off-by: Silvio Cesare <silvio.cesare@gmail.com>
Cc: Timur Tabi <timur@kernel.org>
Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/fsl/imx-audmux.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index fc57da341d61..136df38c4536 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -86,49 +86,49 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
if (!buf)
return -ENOMEM;
- ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
+ ret = scnprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
pdcr, ptcr);
if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR)
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"TxFS output from %s, ",
audmux_port_string((ptcr >> 27) & 0x7));
else
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"TxFS input, ");
if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR)
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"TxClk output from %s",
audmux_port_string((ptcr >> 22) & 0x7));
else
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"TxClk input");
- ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) {
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"Port is symmetric");
} else {
if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR)
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"RxFS output from %s, ",
audmux_port_string((ptcr >> 17) & 0x7));
else
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"RxFS input, ");
if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR)
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"RxClk output from %s",
audmux_port_string((ptcr >> 12) & 0x7));
else
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"RxClk input");
}
- ret += snprintf(buf + ret, PAGE_SIZE - ret,
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
"\nData received from %s\n",
audmux_port_string((pdcr >> 13) & 0x7));
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 10/27] ARC: fix __ffs return value to avoid build warnings
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (7 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 09/27] ASoC: imx-audmux: " Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 11/27] drivers: thermal: int340x_thermal: Fix sysfs race condition Sasha Levin
` (16 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Eugeniy Paltsev, Vineet Gupta, Sasha Levin, linux-snps-arc
From: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
[ Upstream commit 4e868f8419cb4cb558c5d428e7ab5629cef864c7 ]
| CC mm/nobootmem.o
|In file included from ./include/asm-generic/bug.h:18:0,
| from ./arch/arc/include/asm/bug.h:32,
| from ./include/linux/bug.h:5,
| from ./include/linux/mmdebug.h:5,
| from ./include/linux/gfp.h:5,
| from ./include/linux/slab.h:15,
| from mm/nobootmem.c:14:
|mm/nobootmem.c: In function '__free_pages_memory':
|./include/linux/kernel.h:845:29: warning: comparison of distinct pointer types lacks a cast
| (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^
|./include/linux/kernel.h:859:4: note: in expansion of macro '__typecheck'
| (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~
|./include/linux/kernel.h:869:24: note: in expansion of macro '__safe_cmp'
| __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
|./include/linux/kernel.h:878:19: note: in expansion of macro '__careful_cmp'
| #define min(x, y) __careful_cmp(x, y, <)
| ^~~~~~~~~~~~~
|mm/nobootmem.c:104:11: note: in expansion of macro 'min'
| order = min(MAX_ORDER - 1UL, __ffs(start));
Change __ffs return value from 'int' to 'unsigned long' as it
is done in other implementations (like asm-generic, x86, etc...)
to avoid build-time warnings in places where type is strictly
checked.
As __ffs may return values in [0-31] interval changing return
type to unsigned is valid.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arc/include/asm/bitops.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
index 8da87feec59a..99e6d8948f4a 100644
--- a/arch/arc/include/asm/bitops.h
+++ b/arch/arc/include/asm/bitops.h
@@ -340,7 +340,7 @@ static inline __attribute__ ((const)) int __fls(unsigned long x)
/*
* __ffs: Similar to ffs, but zero based (0-31)
*/
-static inline __attribute__ ((const)) int __ffs(unsigned long word)
+static inline __attribute__ ((const)) unsigned long __ffs(unsigned long word)
{
if (!word)
return word;
@@ -400,9 +400,9 @@ static inline __attribute__ ((const)) int ffs(unsigned long x)
/*
* __ffs: Similar to ffs, but zero based (0-31)
*/
-static inline __attribute__ ((const)) int __ffs(unsigned long x)
+static inline __attribute__ ((const)) unsigned long __ffs(unsigned long x)
{
- int n;
+ unsigned long n;
asm volatile(
" ffs.f %0, %1 \n" /* 0:31; 31(Z) if src 0 */
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 11/27] drivers: thermal: int340x_thermal: Fix sysfs race condition
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (8 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 10/27] ARC: fix __ffs return value to avoid build warnings Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 12/27] mac80211: fix miscounting of ttl-dropped frames Sasha Levin
` (15 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Aaron Hill, Zhang Rui, Sasha Levin, linux-pm
From: Aaron Hill <aa1ronham@gmail.com>
[ Upstream commit 129699bb8c7572106b5bbb2407c2daee4727ccad ]
Changes since V1:
* Use dev_info instead of printk
* Use dev_warn instead of BUG_ON
Previously, sysfs_create_group was called before all initialization had
fully run - specifically, before pci_set_drvdata was called. Since the
sysctl group is visible to userspace as soon as sysfs_create_group
returns, a small window of time existed during which a process could read
from an uninitialized/partially-initialized device.
This commit moves the creation of the sysctl group to after all
initialized is completed. This ensures that it's impossible for
userspace to read from a sysctl file before initialization has fully
completed.
To catch any future regressions, I've added a check to ensure
that proc_thermal_emum_mode is never PROC_THERMAL_NONE when a process
tries to read from a sysctl file. Previously, the aforementioned race
condition could result in the 'else' branch
running while PROC_THERMAL_NONE was set,
leading to a null pointer deference.
Signed-off-by: Aaron Hill <aa1ronham@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../processor_thermal_device.c | 28 ++++++++++---------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/thermal/int340x_thermal/processor_thermal_device.c b/drivers/thermal/int340x_thermal/processor_thermal_device.c
index 06d46e2ff337..1fdf6fd24cdf 100644
--- a/drivers/thermal/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/int340x_thermal/processor_thermal_device.c
@@ -77,7 +77,12 @@ static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \
struct pci_dev *pci_dev; \
struct platform_device *pdev; \
struct proc_thermal_device *proc_dev; \
-\
+ \
+ if (proc_thermal_emum_mode == PROC_THERMAL_NONE) { \
+ dev_warn(dev, "Attempted to get power limit before device was initialized!\n"); \
+ return 0; \
+ } \
+ \
if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \
pdev = to_platform_device(dev); \
proc_dev = platform_get_drvdata(pdev); \
@@ -291,11 +296,6 @@ static int proc_thermal_add(struct device *dev,
*priv = proc_priv;
ret = proc_thermal_read_ppcc(proc_priv);
- if (!ret) {
- ret = sysfs_create_group(&dev->kobj,
- &power_limit_attribute_group);
-
- }
if (ret)
return ret;
@@ -309,8 +309,7 @@ static int proc_thermal_add(struct device *dev,
proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops);
if (IS_ERR(proc_priv->int340x_zone)) {
- ret = PTR_ERR(proc_priv->int340x_zone);
- goto remove_group;
+ return PTR_ERR(proc_priv->int340x_zone);
} else
ret = 0;
@@ -324,9 +323,6 @@ static int proc_thermal_add(struct device *dev,
remove_zone:
int340x_thermal_zone_remove(proc_priv->int340x_zone);
-remove_group:
- sysfs_remove_group(&proc_priv->dev->kobj,
- &power_limit_attribute_group);
return ret;
}
@@ -357,7 +353,10 @@ static int int3401_add(struct platform_device *pdev)
platform_set_drvdata(pdev, proc_priv);
proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV;
- return 0;
+ dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PLATFORM_DEV\n");
+
+ return sysfs_create_group(&pdev->dev.kobj,
+ &power_limit_attribute_group);
}
static int int3401_remove(struct platform_device *pdev)
@@ -434,7 +433,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
dev_err(&pdev->dev, "No auxiliary DTSs enabled\n");
}
- return 0;
+ dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PCI\n");
+
+ return sysfs_create_group(&pdev->dev.kobj,
+ &power_limit_attribute_group);
}
static void proc_thermal_pci_remove(struct pci_dev *pdev)
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 12/27] mac80211: fix miscounting of ttl-dropped frames
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (9 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 11/27] drivers: thermal: int340x_thermal: Fix sysfs race condition Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 13/27] locking/rwsem: Fix (possible) missed wakeup Sasha Levin
` (14 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Bob Copeland, Bob Copeland, Johannes Berg, Sasha Levin,
linux-wireless, netdev
From: Bob Copeland <me@bobcopeland.com>
[ Upstream commit a0dc02039a2ee54fb4ae400e0b755ed30e73e58c ]
In ieee80211_rx_h_mesh_fwding, we increment the 'dropped_frames_ttl'
counter when we decrement the ttl to zero. For unicast frames
destined for other hosts, we stop processing the frame at that point.
For multicast frames, we do not rebroadcast it in this case, but we
do pass the frame up the stack to process it on this STA. That
doesn't match the usual definition of "dropped," so don't count
those as such.
With this change, something like `ping6 -i0.2 ff02::1%mesh0` from a
peer in a ttl=1 network no longer increments the counter rapidly.
Signed-off-by: Bob Copeland <bobcopeland@fb.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/mac80211/rx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 93c332737e86..fdbfdb04abe8 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2509,7 +2509,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
skb_set_queue_mapping(skb, q);
if (!--mesh_hdr->ttl) {
- IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_ttl);
+ if (!is_multicast_ether_addr(hdr->addr1))
+ IEEE80211_IFSTA_MESH_CTR_INC(ifmsh,
+ dropped_frames_ttl);
goto out;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 13/27] locking/rwsem: Fix (possible) missed wakeup
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (10 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 12/27] mac80211: fix miscounting of ttl-dropped frames Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 14/27] libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive() Sasha Levin
` (13 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Xie Yongji, Zhang Yu, Peter Zijlstra, Linus Torvalds,
Thomas Gleixner, Ingo Molnar, Sasha Levin
From: Xie Yongji <xieyongji@baidu.com>
[ Upstream commit e158488be27b157802753a59b336142dc0eb0380 ]
Because wake_q_add() can imply an immediate wakeup (cmpxchg failure
case), we must not rely on the wakeup being delayed. However, commit:
e38513905eea ("locking/rwsem: Rework zeroing reader waiter->task")
relies on exactly that behaviour in that the wakeup must not happen
until after we clear waiter->task.
[ peterz: Added changelog. ]
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: e38513905eea ("locking/rwsem: Rework zeroing reader waiter->task")
Link: https://lkml.kernel.org/r/1543495830-2644-1-git-send-email-xieyongji@baidu.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/locking/rwsem-xadd.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c
index a4112dfcd0fb..be06c45cbe4f 100644
--- a/kernel/locking/rwsem-xadd.c
+++ b/kernel/locking/rwsem-xadd.c
@@ -195,15 +195,22 @@ static void __rwsem_mark_wake(struct rw_semaphore *sem,
woken++;
tsk = waiter->task;
- wake_q_add(wake_q, tsk);
+ get_task_struct(tsk);
list_del(&waiter->list);
/*
- * Ensure that the last operation is setting the reader
+ * Ensure calling get_task_struct() before setting the reader
* waiter to nil such that rwsem_down_read_failed() cannot
* race with do_exit() by always holding a reference count
* to the task to wakeup.
*/
smp_store_release(&waiter->task, NULL);
+ /*
+ * Ensure issuing the wakeup (either by us or someone else)
+ * after setting the reader waiter to nil.
+ */
+ wake_q_add(wake_q, tsk);
+ /* wake_q_add() already take the task ref */
+ put_task_struct(tsk);
}
adjustment = woken * RWSEM_ACTIVE_READ_BIAS - adjustment;
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 14/27] libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive()
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (11 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 13/27] locking/rwsem: Fix (possible) missed wakeup Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 15/27] serial: fsl_lpuart: fix maximum acceptable baud rate with over-sampling Sasha Levin
` (12 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Ilya Dryomov, Sasha Levin, ceph-devel, netdev
From: Ilya Dryomov <idryomov@gmail.com>
[ Upstream commit 4aac9228d16458cedcfd90c7fb37211cf3653ac3 ]
con_fault() can transition the connection into STANDBY right after
ceph_con_keepalive() clears STANDBY in clear_standby():
libceph user thread ceph-msgr worker
ceph_con_keepalive()
mutex_lock(&con->mutex)
clear_standby(con)
mutex_unlock(&con->mutex)
mutex_lock(&con->mutex)
con_fault()
...
if KEEPALIVE_PENDING isn't set
set state to STANDBY
...
mutex_unlock(&con->mutex)
set KEEPALIVE_PENDING
set WRITE_PENDING
This triggers warnings in clear_standby() when either ceph_con_send()
or ceph_con_keepalive() get to clearing STANDBY next time.
I don't see a reason to condition queue_con() call on the previous
value of KEEPALIVE_PENDING, so move the setting of KEEPALIVE_PENDING
into the critical section -- unlike WRITE_PENDING, KEEPALIVE_PENDING
could have been a non-atomic flag.
Reported-by: syzbot+acdeb633f6211ccdf886@syzkaller.appspotmail.com
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Tested-by: Myungho Jung <mhjungk@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ceph/messenger.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 5a8075d9f2e7..93eb606f7628 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -3186,9 +3186,10 @@ void ceph_con_keepalive(struct ceph_connection *con)
dout("con_keepalive %p\n", con);
mutex_lock(&con->mutex);
clear_standby(con);
+ con_flag_set(con, CON_FLAG_KEEPALIVE_PENDING);
mutex_unlock(&con->mutex);
- if (con_flag_test_and_set(con, CON_FLAG_KEEPALIVE_PENDING) == 0 &&
- con_flag_test_and_set(con, CON_FLAG_WRITE_PENDING) == 0)
+
+ if (con_flag_test_and_set(con, CON_FLAG_WRITE_PENDING) == 0)
queue_con(con);
}
EXPORT_SYMBOL(ceph_con_keepalive);
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 15/27] serial: fsl_lpuart: fix maximum acceptable baud rate with over-sampling
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (12 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 14/27] libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive() Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 16/27] direct-io: allow direct writes to empty inodes Sasha Levin
` (11 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Tomonori Sakita, Atsushi Nemoto, Greg Kroah-Hartman, Sasha Levin,
linux-serial
From: Tomonori Sakita <tomonori.sakita@sord.co.jp>
[ Upstream commit 815d835b7ba46685c316b000013367dacb2b461b ]
Using over-sampling ratio, lpuart can accept baud rate upto uartclk / 4.
Signed-off-by: Tomonori Sakita <tomonori.sakita@sord.co.jp>
Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/tty/serial/fsl_lpuart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index e2ec04904f54..0cf4fe6cb4d1 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1490,7 +1490,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
}
/* ask the core to calculate the divisor */
- baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16);
+ baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 4);
spin_lock_irqsave(&sport->port.lock, flags);
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 16/27] direct-io: allow direct writes to empty inodes
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (13 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 15/27] serial: fsl_lpuart: fix maximum acceptable baud rate with over-sampling Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 17/27] scsi: csiostor: fix NULL pointer dereference in csio_vport_set_state() Sasha Levin
` (10 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Ernesto A. Fernández, Jens Axboe, Sasha Levin, linux-fsdevel
From: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
[ Upstream commit 8b9433eb4de3c26a9226c981c283f9f4896ae030 ]
On a DIO_SKIP_HOLES filesystem, the ->get_block() method is currently
not allowed to create blocks for an empty inode. This confusion comes
from trying to bit shift a negative number, so check the size of the
inode first.
The problem is most visible for hfsplus, because the fallback to
buffered I/O doesn't happen and the write fails with EIO. This is in
part the fault of the module, because it gives a wrong return value on
->get_block(); that will be fixed in a separate patch.
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/direct-io.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 07cc38ec66ca..fc90f0c33cbe 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -616,6 +616,7 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio,
unsigned long fs_count; /* Number of filesystem-sized blocks */
int create;
unsigned int i_blkbits = sdio->blkbits + sdio->blkfactor;
+ loff_t i_size;
/*
* If there was a memory error and we've overwritten all the
@@ -645,8 +646,8 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio,
*/
create = dio->op == REQ_OP_WRITE;
if (dio->flags & DIO_SKIP_HOLES) {
- if (fs_startblk <= ((i_size_read(dio->inode) - 1) >>
- i_blkbits))
+ i_size = i_size_read(dio->inode);
+ if (i_size && fs_startblk <= (i_size - 1) >> i_blkbits)
create = 0;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 17/27] scsi: csiostor: fix NULL pointer dereference in csio_vport_set_state()
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (14 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 16/27] direct-io: allow direct writes to empty inodes Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 18/27] net: altera_tse: fix connect_local_phy error path Sasha Levin
` (9 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Varun Prakash, Martin K . Petersen, Sasha Levin, linux-scsi
From: Varun Prakash <varun@chelsio.com>
[ Upstream commit fe35a40e675473eb65f2f5462b82770f324b5689 ]
Assign fc_vport to ln->fc_vport before calling csio_fcoe_alloc_vnp() to
avoid a NULL pointer dereference in csio_vport_set_state().
ln->fc_vport is dereferenced in csio_vport_set_state().
Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/csiostor/csio_attr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/csiostor/csio_attr.c b/drivers/scsi/csiostor/csio_attr.c
index 2d1c4ebd40f9..6587f20cff1a 100644
--- a/drivers/scsi/csiostor/csio_attr.c
+++ b/drivers/scsi/csiostor/csio_attr.c
@@ -582,12 +582,12 @@ csio_vport_create(struct fc_vport *fc_vport, bool disable)
}
fc_vport_set_state(fc_vport, FC_VPORT_INITIALIZING);
+ ln->fc_vport = fc_vport;
if (csio_fcoe_alloc_vnp(hw, ln))
goto error;
*(struct csio_lnode **)fc_vport->dd_data = ln;
- ln->fc_vport = fc_vport;
if (!fc_vport->node_name)
fc_vport->node_name = wwn_to_u64(csio_ln_wwnn(ln));
if (!fc_vport->port_name)
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 18/27] net: altera_tse: fix connect_local_phy error path
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (15 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 17/27] scsi: csiostor: fix NULL pointer dereference in csio_vport_set_state() Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 19/27] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe Sasha Levin
` (8 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Atsushi Nemoto, David S . Miller, Sasha Levin, netdev
From: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
[ Upstream commit 17b42a20d7ca59377788c6a2409e77569570cc10 ]
The connect_local_phy should return NULL (not negative errno) on
error, since its caller expects it.
Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/altera/altera_tse_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index a0eee7218695..e306342506f1 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -692,8 +692,10 @@ static struct phy_device *connect_local_phy(struct net_device *dev)
phydev = phy_connect(dev, phy_id_fmt, &altera_tse_adjust_link,
priv->phy_iface);
- if (IS_ERR(phydev))
+ if (IS_ERR(phydev)) {
netdev_err(dev, "Could not attach to PHY\n");
+ phydev = NULL;
+ }
} else {
int ret;
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 19/27] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (16 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 18/27] net: altera_tse: fix connect_local_phy error path Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 20/27] ax25: fix possible use-after-free Sasha Levin
` (7 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Edward Cree, David S . Miller, Sasha Levin, netdev
From: Edward Cree <ecree@solarflare.com>
[ Upstream commit 3366463513f544c12c6b88c13da4462ee9e7a1a1 ]
Use a bitmap to keep track of which partition types we've already seen;
for duplicates, return -EEXIST from efx_ef10_mtd_probe_partition() and
thus skip adding that partition.
Duplicate partitions occur because of the A/B backup scheme used by newer
sfc NICs. Prior to this patch they cause sysfs_warn_dup errors because
they have the same name, causing us not to expose any MTDs at all.
Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/sfc/ef10.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 3d5d5d54c103..34e2256c93f4 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -5093,22 +5093,25 @@ static const struct efx_ef10_nvram_type_info efx_ef10_nvram_types[] = {
{ NVRAM_PARTITION_TYPE_LICENSE, 0, 0, "sfc_license" },
{ NVRAM_PARTITION_TYPE_PHY_MIN, 0xff, 0, "sfc_phy_fw" },
};
+#define EF10_NVRAM_PARTITION_COUNT ARRAY_SIZE(efx_ef10_nvram_types)
static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
struct efx_mcdi_mtd_partition *part,
- unsigned int type)
+ unsigned int type,
+ unsigned long *found)
{
MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_METADATA_IN_LEN);
MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_METADATA_OUT_LENMAX);
const struct efx_ef10_nvram_type_info *info;
size_t size, erase_size, outlen;
+ int type_idx = 0;
bool protected;
int rc;
- for (info = efx_ef10_nvram_types; ; info++) {
- if (info ==
- efx_ef10_nvram_types + ARRAY_SIZE(efx_ef10_nvram_types))
+ for (type_idx = 0; ; type_idx++) {
+ if (type_idx == EF10_NVRAM_PARTITION_COUNT)
return -ENODEV;
+ info = efx_ef10_nvram_types + type_idx;
if ((type & ~info->type_mask) == info->type)
break;
}
@@ -5121,6 +5124,13 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
if (protected)
return -ENODEV; /* hide it */
+ /* If we've already exposed a partition of this type, hide this
+ * duplicate. All operations on MTDs are keyed by the type anyway,
+ * so we can't act on the duplicate.
+ */
+ if (__test_and_set_bit(type_idx, found))
+ return -EEXIST;
+
part->nvram_type = type;
MCDI_SET_DWORD(inbuf, NVRAM_METADATA_IN_TYPE, type);
@@ -5149,6 +5159,7 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
static int efx_ef10_mtd_probe(struct efx_nic *efx)
{
MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX);
+ DECLARE_BITMAP(found, EF10_NVRAM_PARTITION_COUNT);
struct efx_mcdi_mtd_partition *parts;
size_t outlen, n_parts_total, i, n_parts;
unsigned int type;
@@ -5177,11 +5188,13 @@ static int efx_ef10_mtd_probe(struct efx_nic *efx)
for (i = 0; i < n_parts_total; i++) {
type = MCDI_ARRAY_DWORD(outbuf, NVRAM_PARTITIONS_OUT_TYPE_ID,
i);
- rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type);
- if (rc == 0)
- n_parts++;
- else if (rc != -ENODEV)
+ rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type,
+ found);
+ if (rc == -EEXIST || rc == -ENODEV)
+ continue;
+ if (rc)
goto fail;
+ n_parts++;
}
rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 20/27] ax25: fix possible use-after-free
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (17 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 19/27] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 21/27] net: usb: asix: ax88772_bind return error when hw_reset fail Sasha Levin
` (6 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Eric Dumazet, Ralf Baechle, David S . Miller, Sasha Levin,
linux-hams, netdev
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit 63530aba7826a0f8e129874df9c4d264f9db3f9e ]
syzbot found that ax25 routes where not properly protected
against concurrent use [1].
In this particular report the bug happened while
copying ax25->digipeat.
Fix this problem by making sure we call ax25_get_route()
while ax25_route_lock is held, so that no modification
could happen while using the route.
The current two ax25_get_route() callers do not sleep,
so this change should be fine.
Once we do that, ax25_get_route() no longer needs to
grab a reference on the found route.
[1]
ax25_connect(): syz-executor0 uses autobind, please contact jreuter@yaina.de
BUG: KASAN: use-after-free in memcpy include/linux/string.h:352 [inline]
BUG: KASAN: use-after-free in kmemdup+0x42/0x60 mm/util.c:113
Read of size 66 at addr ffff888066641a80 by task syz-executor2/531
ax25_connect(): syz-executor0 uses autobind, please contact jreuter@yaina.de
CPU: 1 PID: 531 Comm: syz-executor2 Not tainted 5.0.0-rc2+ #10
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1db/0x2d0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
check_memory_region_inline mm/kasan/generic.c:185 [inline]
check_memory_region+0x123/0x190 mm/kasan/generic.c:191
memcpy+0x24/0x50 mm/kasan/common.c:130
memcpy include/linux/string.h:352 [inline]
kmemdup+0x42/0x60 mm/util.c:113
kmemdup include/linux/string.h:425 [inline]
ax25_rt_autobind+0x25d/0x750 net/ax25/ax25_route.c:424
ax25_connect.cold+0x30/0xa4 net/ax25/af_ax25.c:1224
__sys_connect+0x357/0x490 net/socket.c:1664
__do_sys_connect net/socket.c:1675 [inline]
__se_sys_connect net/socket.c:1672 [inline]
__x64_sys_connect+0x73/0xb0 net/socket.c:1672
do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x458099
Code: 6d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 3b b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f870ee22c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000458099
RDX: 0000000000000048 RSI: 0000000020000080 RDI: 0000000000000005
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
ax25_connect(): syz-executor4 uses autobind, please contact jreuter@yaina.de
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f870ee236d4
R13: 00000000004be48e R14: 00000000004ce9a8 R15: 00000000ffffffff
Allocated by task 526:
save_stack+0x45/0xd0 mm/kasan/common.c:73
set_track mm/kasan/common.c:85 [inline]
__kasan_kmalloc mm/kasan/common.c:496 [inline]
__kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:469
kasan_kmalloc+0x9/0x10 mm/kasan/common.c:504
ax25_connect(): syz-executor5 uses autobind, please contact jreuter@yaina.de
kmem_cache_alloc_trace+0x151/0x760 mm/slab.c:3609
kmalloc include/linux/slab.h:545 [inline]
ax25_rt_add net/ax25/ax25_route.c:95 [inline]
ax25_rt_ioctl+0x3b9/0x1270 net/ax25/ax25_route.c:233
ax25_ioctl+0x322/0x10b0 net/ax25/af_ax25.c:1763
sock_do_ioctl+0xe2/0x400 net/socket.c:950
sock_ioctl+0x32f/0x6c0 net/socket.c:1074
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:509 [inline]
do_vfs_ioctl+0x107b/0x17d0 fs/ioctl.c:696
ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
__do_sys_ioctl fs/ioctl.c:720 [inline]
__se_sys_ioctl fs/ioctl.c:718 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
ax25_connect(): syz-executor5 uses autobind, please contact jreuter@yaina.de
Freed by task 550:
save_stack+0x45/0xd0 mm/kasan/common.c:73
set_track mm/kasan/common.c:85 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/common.c:458
kasan_slab_free+0xe/0x10 mm/kasan/common.c:466
__cache_free mm/slab.c:3487 [inline]
kfree+0xcf/0x230 mm/slab.c:3806
ax25_rt_add net/ax25/ax25_route.c:92 [inline]
ax25_rt_ioctl+0x304/0x1270 net/ax25/ax25_route.c:233
ax25_ioctl+0x322/0x10b0 net/ax25/af_ax25.c:1763
sock_do_ioctl+0xe2/0x400 net/socket.c:950
sock_ioctl+0x32f/0x6c0 net/socket.c:1074
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:509 [inline]
do_vfs_ioctl+0x107b/0x17d0 fs/ioctl.c:696
ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
__do_sys_ioctl fs/ioctl.c:720 [inline]
__se_sys_ioctl fs/ioctl.c:718 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff888066641a80
which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes inside of
96-byte region [ffff888066641a80, ffff888066641ae0)
The buggy address belongs to the page:
page:ffffea0001999040 count:1 mapcount:0 mapping:ffff88812c3f04c0 index:0x0
flags: 0x1fffc0000000200(slab)
ax25_connect(): syz-executor4 uses autobind, please contact jreuter@yaina.de
raw: 01fffc0000000200 ffffea0001817948 ffffea0002341dc8 ffff88812c3f04c0
raw: 0000000000000000 ffff888066641000 0000000100000020 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888066641980: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff888066641a00: 00 00 00 00 00 00 00 00 02 fc fc fc fc fc fc fc
>ffff888066641a80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff888066641b00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff888066641b80: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/net/ax25.h | 12 ++++++++++++
net/ax25/ax25_ip.c | 4 ++--
net/ax25/ax25_route.c | 19 ++++++++-----------
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/include/net/ax25.h b/include/net/ax25.h
index e602f8177ebf..b507ce2b1952 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -199,6 +199,18 @@ static inline void ax25_hold_route(ax25_route *ax25_rt)
void __ax25_put_route(ax25_route *ax25_rt);
+extern rwlock_t ax25_route_lock;
+
+static inline void ax25_route_lock_use(void)
+{
+ read_lock(&ax25_route_lock);
+}
+
+static inline void ax25_route_lock_unuse(void)
+{
+ read_unlock(&ax25_route_lock);
+}
+
static inline void ax25_put_route(ax25_route *ax25_rt)
{
if (atomic_dec_and_test(&ax25_rt->refcount))
diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c
index 2fa3be965101..cd9a24e5b97a 100644
--- a/net/ax25/ax25_ip.c
+++ b/net/ax25/ax25_ip.c
@@ -114,6 +114,7 @@ netdev_tx_t ax25_ip_xmit(struct sk_buff *skb)
dst = (ax25_address *)(bp + 1);
src = (ax25_address *)(bp + 8);
+ ax25_route_lock_use();
route = ax25_get_route(dst, NULL);
if (route) {
digipeat = route->digipeat;
@@ -206,9 +207,8 @@ netdev_tx_t ax25_ip_xmit(struct sk_buff *skb)
ax25_queue_xmit(skb, dev);
put:
- if (route)
- ax25_put_route(route);
+ ax25_route_lock_unuse();
return NETDEV_TX_OK;
}
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index d39097737e38..149f82bd83fd 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -40,7 +40,7 @@
#include <linux/export.h>
static ax25_route *ax25_route_list;
-static DEFINE_RWLOCK(ax25_route_lock);
+DEFINE_RWLOCK(ax25_route_lock);
void ax25_rt_device_down(struct net_device *dev)
{
@@ -349,6 +349,7 @@ const struct file_operations ax25_route_fops = {
* Find AX.25 route
*
* Only routes with a reference count of zero can be destroyed.
+ * Must be called with ax25_route_lock read locked.
*/
ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev)
{
@@ -356,7 +357,6 @@ ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev)
ax25_route *ax25_def_rt = NULL;
ax25_route *ax25_rt;
- read_lock(&ax25_route_lock);
/*
* Bind to the physical interface we heard them on, or the default
* route if none is found;
@@ -379,11 +379,6 @@ ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev)
if (ax25_spe_rt != NULL)
ax25_rt = ax25_spe_rt;
- if (ax25_rt != NULL)
- ax25_hold_route(ax25_rt);
-
- read_unlock(&ax25_route_lock);
-
return ax25_rt;
}
@@ -414,9 +409,12 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr)
ax25_route *ax25_rt;
int err = 0;
- if ((ax25_rt = ax25_get_route(addr, NULL)) == NULL)
+ ax25_route_lock_use();
+ ax25_rt = ax25_get_route(addr, NULL);
+ if (!ax25_rt) {
+ ax25_route_lock_unuse();
return -EHOSTUNREACH;
-
+ }
if ((ax25->ax25_dev = ax25_dev_ax25dev(ax25_rt->dev)) == NULL) {
err = -EHOSTUNREACH;
goto put;
@@ -451,8 +449,7 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr)
}
put:
- ax25_put_route(ax25_rt);
-
+ ax25_route_lock_unuse();
return err;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 21/27] net: usb: asix: ax88772_bind return error when hw_reset fail
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (18 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 20/27] ax25: fix possible use-after-free Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 22/27] ibmveth: Do not process frames after calling napi_reschedule Sasha Levin
` (5 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Zhang Run, David S . Miller, Sasha Levin, linux-usb, netdev
From: Zhang Run <zhang.run@zte.com.cn>
[ Upstream commit 6eea3527e68acc22483f4763c8682f223eb90029 ]
The ax88772_bind() should return error code immediately when the PHY
was not reset properly through ax88772a_hw_reset().
Otherwise, The asix_get_phyid() will block when get the PHY
Identifier from the PHYSID1 MII registers through asix_mdio_read()
due to the PHY isn't ready. Furthermore, it will produce a lot of
error message cause system crash.As follows:
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to write
reg index 0x0000: -71
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to send
software reset: ffffffb9
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to write
reg index 0x0000: -71
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to enable
software MII access
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to read
reg index 0x0000: -71
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to write
reg index 0x0000: -71
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to enable
software MII access
asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to read
reg index 0x0000: -71
...
Signed-off-by: Zhang Run <zhang.run@zte.com.cn>
Reviewed-by: Yang Wei <yang.wei9@zte.com.cn>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/usb/asix_devices.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 5be6b67492d5..393fd3ed6b94 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -729,8 +729,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &chipcode, 0);
chipcode &= AX_CHIPCODE_MASK;
- (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) :
- ax88772a_hw_reset(dev, 0);
+ ret = (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) :
+ ax88772a_hw_reset(dev, 0);
+
+ if (ret < 0) {
+ netdev_dbg(dev->net, "Failed to reset AX88772: %d\n", ret);
+ return ret;
+ }
/* Read PHYID register *AFTER* the PHY was reset properly */
phyid = asix_get_phyid(dev);
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 22/27] ibmveth: Do not process frames after calling napi_reschedule
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (19 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 21/27] net: usb: asix: ax88772_bind return error when hw_reset fail Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 23/27] mac80211: don't initiate TDLS connection if station is not associated to AP Sasha Levin
` (4 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Thomas Falcon, David S . Miller, Sasha Levin, netdev,
linuxppc-dev
From: Thomas Falcon <tlfalcon@linux.ibm.com>
[ Upstream commit e95d22c69b2c130ccce257b84daf283fd82d611e ]
The IBM virtual ethernet driver's polling function continues
to process frames after rescheduling NAPI, resulting in a warning
if it exhausted its budget. Do not restart polling after calling
napi_reschedule. Instead let frames be processed in the following
instance.
Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/ibm/ibmveth.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 4996228fd7e6..955f658f3b65 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1240,7 +1240,6 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
struct iphdr *iph;
u16 mss = 0;
-restart_poll:
while (frames_processed < budget) {
if (!ibmveth_rxq_pending_buffer(adapter))
break;
@@ -1338,7 +1337,6 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
napi_reschedule(napi)) {
lpar_rc = h_vio_signal(adapter->vdev->unit_address,
VIO_IRQ_DISABLE);
- goto restart_poll;
}
}
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 23/27] mac80211: don't initiate TDLS connection if station is not associated to AP
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (20 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 22/27] ibmveth: Do not process frames after calling napi_reschedule Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 24/27] mac80211: Add attribute aligned(2) to struct 'action' Sasha Levin
` (3 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Balaji Pothunoori, Johannes Berg, Sasha Levin, linux-wireless,
netdev
From: Balaji Pothunoori <bpothuno@codeaurora.org>
[ Upstream commit 7ed5285396c257fd4070b1e29e7b2341aae2a1ce ]
Following call trace is observed while adding TDLS peer entry in driver
during TDLS setup.
Call Trace:
[<c1301476>] dump_stack+0x47/0x61
[<c10537d2>] __warn+0xe2/0x100
[<fa22415f>] ? sta_apply_parameters+0x49f/0x550 [mac80211]
[<c1053895>] warn_slowpath_null+0x25/0x30
[<fa22415f>] sta_apply_parameters+0x49f/0x550 [mac80211]
[<fa20ad42>] ? sta_info_alloc+0x1c2/0x450 [mac80211]
[<fa224623>] ieee80211_add_station+0xe3/0x160 [mac80211]
[<c1876fe3>] nl80211_new_station+0x273/0x420
[<c170f6d9>] genl_rcv_msg+0x219/0x3c0
[<c170f4c0>] ? genl_rcv+0x30/0x30
[<c170ee7e>] netlink_rcv_skb+0x8e/0xb0
[<c170f4ac>] genl_rcv+0x1c/0x30
[<c170e8aa>] netlink_unicast+0x13a/0x1d0
[<c170ec18>] netlink_sendmsg+0x2d8/0x390
[<c16c5acd>] sock_sendmsg+0x2d/0x40
[<c16c6369>] ___sys_sendmsg+0x1d9/0x1e0
Fixing this by allowing TDLS setup request only when we have completed
association.
Signed-off-by: Balaji Pothunoori <bpothuno@codeaurora.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/mac80211/cfg.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 6ef9d32c34f1..954315e1661d 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1425,6 +1425,10 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
sta->sta.tdls = true;
+ if (sta->sta.tdls && sdata->vif.type == NL80211_IFTYPE_STATION &&
+ !sdata->u.mgd.associated)
+ return -EINVAL;
+
err = sta_apply_parameters(local, sta, params);
if (err) {
sta_info_free(local, sta);
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 24/27] mac80211: Add attribute aligned(2) to struct 'action'
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (21 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 23/27] mac80211: don't initiate TDLS connection if station is not associated to AP Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 25/27] cfg80211: extend range deviation for DMG Sasha Levin
` (2 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mathieu Malaterre, Johannes Berg, Sasha Levin, linux-wireless,
netdev
From: Mathieu Malaterre <malat@debian.org>
[ Upstream commit 7c53eb5d87bc21464da4268c3c0c47457b6d9c9b ]
During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
follow-MAC mode") a new struct 'action' was declared with packed
attribute as:
struct {
struct ieee80211_hdr_3addr hdr;
u8 category;
u8 action_code;
} __packed action;
But since struct 'ieee80211_hdr_3addr' is declared with an aligned
keyword as:
struct ieee80211_hdr {
__le16 frame_control;
__le16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
__le16 seq_ctrl;
u8 addr4[ETH_ALEN];
} __packed __aligned(2);
Solve the ambiguity of placing aligned structure in a packed one by
adding the aligned(2) attribute to struct 'action'.
This removes the following warning (W=1):
net/mac80211/rx.c:234:2: warning: alignment 1 of 'struct <anonymous>' is less than 2 [-Wpacked-not-aligned]
Cc: Johannes Berg <johannes.berg@intel.com>
Suggested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/mac80211/rx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index fdbfdb04abe8..10e8b85e017f 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -216,7 +216,7 @@ static void ieee80211_handle_mu_mimo_mon(struct ieee80211_sub_if_data *sdata,
struct ieee80211_hdr_3addr hdr;
u8 category;
u8 action_code;
- } __packed action;
+ } __packed __aligned(2) action;
if (!sdata)
return;
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 25/27] cfg80211: extend range deviation for DMG
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (22 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 24/27] mac80211: Add attribute aligned(2) to struct 'action' Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 26/27] svm: Fix AVIC incomplete IPI emulation Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 27/27] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1 Sasha Levin
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Chaitanya Tata, Chaitanya Tata, Johannes Berg, Sasha Levin,
linux-wireless, netdev
From: Chaitanya Tata <chaitanya.tata@bluwirelesstechnology.com>
[ Upstream commit 93183bdbe73bbdd03e9566c8dc37c9d06b0d0db6 ]
Recently, DMG frequency bands have been extended till 71GHz, so extend
the range check till 20GHz (45-71GHZ), else some channels will be marked
as disabled.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@bluwireless.co.uk>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/wireless/reg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 36d1d25082e3..7c19d0d2549b 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -773,7 +773,7 @@ static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range,
* definitions (the "2.4 GHz band", the "5 GHz band" and the "60GHz band"),
* however it is safe for now to assume that a frequency rule should not be
* part of a frequency's band if the start freq or end freq are off by more
- * than 2 GHz for the 2.4 and 5 GHz bands, and by more than 10 GHz for the
+ * than 2 GHz for the 2.4 and 5 GHz bands, and by more than 20 GHz for the
* 60 GHz band.
* This resolution can be lowered and should be considered as we add
* regulatory rule support for other "bands".
@@ -788,7 +788,7 @@ static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range,
* with the Channel starting frequency above 45 GHz.
*/
u32 limit = freq_khz > 45 * ONE_GHZ_IN_KHZ ?
- 10 * ONE_GHZ_IN_KHZ : 2 * ONE_GHZ_IN_KHZ;
+ 20 * ONE_GHZ_IN_KHZ : 2 * ONE_GHZ_IN_KHZ;
if (abs(freq_khz - freq_range->start_freq_khz) <= limit)
return true;
if (abs(freq_khz - freq_range->end_freq_khz) <= limit)
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 26/27] svm: Fix AVIC incomplete IPI emulation
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (23 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 25/27] cfg80211: extend range deviation for DMG Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 27/27] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1 Sasha Levin
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Suravee Suthikulpanit, Paolo Bonzini, Sasha Levin, kvm
From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
[ Upstream commit bb218fbcfaaa3b115d4cd7a43c0ca164f3a96e57 ]
In case of incomplete IPI with invalid interrupt type, the current
SVM driver does not properly emulate the IPI, and fails to boot
FreeBSD guests with multiple vcpus when enabling AVIC.
Fix this by update APIC ICR high/low registers, which also
emulate sending the IPI.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/kvm/svm.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index fa1b0e3c8a06..31df05fcbc61 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3932,25 +3932,14 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm)
kvm_lapic_reg_write(apic, APIC_ICR, icrl);
break;
case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: {
- int i;
- struct kvm_vcpu *vcpu;
- struct kvm *kvm = svm->vcpu.kvm;
struct kvm_lapic *apic = svm->vcpu.arch.apic;
/*
- * At this point, we expect that the AVIC HW has already
- * set the appropriate IRR bits on the valid target
- * vcpus. So, we just need to kick the appropriate vcpu.
+ * Update ICR high and low, then emulate sending IPI,
+ * which is handled when writing APIC_ICR.
*/
- kvm_for_each_vcpu(i, vcpu, kvm) {
- bool m = kvm_apic_match_dest(vcpu, apic,
- icrl & KVM_APIC_SHORT_MASK,
- GET_APIC_DEST_FIELD(icrh),
- icrl & KVM_APIC_DEST_MASK);
-
- if (m && !avic_vcpu_is_running(vcpu))
- kvm_vcpu_wake_up(vcpu);
- }
+ kvm_lapic_reg_write(apic, APIC_ICR2, icrh);
+ kvm_lapic_reg_write(apic, APIC_ICR, icrl);
break;
}
case AVIC_IPI_FAILURE_INVALID_TARGET:
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH AUTOSEL 4.9 27/27] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
` (24 preceding siblings ...)
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 26/27] svm: Fix AVIC incomplete IPI emulation Sasha Levin
@ 2019-02-15 2:14 ` Sasha Levin
25 siblings, 0 replies; 27+ messages in thread
From: Sasha Levin @ 2019-02-15 2:14 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Vitaly Kuznetsov, Paolo Bonzini, Sasha Levin, kvm
From: Vitaly Kuznetsov <vkuznets@redhat.com>
[ Upstream commit 619ad846fc3452adaf71ca246c5aa711e2055398 ]
kvm-unit-tests' eventinj "NMI failing on IDT" test results in NMI being
delivered to the host (L1) when it's running nested. The problem seems to
be: svm_complete_interrupts() raises 'nmi_injected' flag but later we
decide to reflect EXIT_NPF to L1. The flag remains pending and we do NMI
injection upon entry so it got delivered to L1 instead of L2.
It seems that VMX code solves the same issue in prepare_vmcs12(), this was
introduced with code refactoring in commit 5f3d5799974b ("KVM: nVMX: Rework
event injection and recovery").
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/kvm/svm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 31df05fcbc61..49c89436a118 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2862,6 +2862,14 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
kvm_mmu_reset_context(&svm->vcpu);
kvm_mmu_load(&svm->vcpu);
+ /*
+ * Drop what we picked up for L2 via svm_complete_interrupts() so it
+ * doesn't end up in L1.
+ */
+ svm->vcpu.arch.nmi_injected = false;
+ kvm_clear_exception_queue(&svm->vcpu);
+ kvm_clear_interrupt_queue(&svm->vcpu);
+
return 0;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
end of thread, other threads:[~2019-02-15 2:24 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-15 2:13 [PATCH AUTOSEL 4.9 01/27] drm/msm: Unblock writer if reader closes file Sasha Levin
2019-02-15 2:13 ` [PATCH AUTOSEL 4.9 02/27] ASoC: Intel: Haswell/Broadwell: fix setting for .dynamic field Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 03/27] ALSA: compress: prevent potential divide by zero bugs Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 04/27] thermal: int340x_thermal: Fix a NULL vs IS_ERR() check Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 05/27] usb: dwc3: gadget: synchronize_irq dwc irq in suspend Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 06/27] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 07/27] usb: gadget: Potential NULL dereference on allocation error Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 08/27] ASoC: dapm: change snprintf to scnprintf for possible overflow Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 09/27] ASoC: imx-audmux: " Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 10/27] ARC: fix __ffs return value to avoid build warnings Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 11/27] drivers: thermal: int340x_thermal: Fix sysfs race condition Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 12/27] mac80211: fix miscounting of ttl-dropped frames Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 13/27] locking/rwsem: Fix (possible) missed wakeup Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 14/27] libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive() Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 15/27] serial: fsl_lpuart: fix maximum acceptable baud rate with over-sampling Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 16/27] direct-io: allow direct writes to empty inodes Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 17/27] scsi: csiostor: fix NULL pointer dereference in csio_vport_set_state() Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 18/27] net: altera_tse: fix connect_local_phy error path Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 19/27] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 20/27] ax25: fix possible use-after-free Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 21/27] net: usb: asix: ax88772_bind return error when hw_reset fail Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 22/27] ibmveth: Do not process frames after calling napi_reschedule Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 23/27] mac80211: don't initiate TDLS connection if station is not associated to AP Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 24/27] mac80211: Add attribute aligned(2) to struct 'action' Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 25/27] cfg80211: extend range deviation for DMG Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 26/27] svm: Fix AVIC incomplete IPI emulation Sasha Levin
2019-02-15 2:14 ` [PATCH AUTOSEL 4.9 27/27] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1 Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox