4.19.21-stable review
Subsystems (10)
Greg Kroah-Hartman
maintainerPATCH 162/313 i2c: sh_mobile: Add support for r8a774c0 (RZ/G2E)
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 51243b73455f2d12cb82abffa7bc9028aec656e0 ]
Similarly to R-Car E3, RZ/G2E doesn't come with automatic transmission registers, as such it is not considered compatible with the existing fallback bindings.
Add SoC specific binding compatibility to allow for later support for automatic transmission.
--- drivers/i2c/busses/i2c-sh_mobile.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-sh_mobile.c +1 -0
@@ -800,6 +800,7 @@ static const struct sh_mobile_dt_config r8a7740_dt_config = {static const struct of_device_id sh_mobile_i2c_dt_ids[] = { { .compatible ="renesas,iic-r8a73a4" , .data = &fast_clock_dt_config }, { .compatible ="renesas,iic-r8a7740" , .data = &r8a7740_dt_config }, + { .compatible ="renesas,iic-r8a774c0" , .data = &fast_clock_dt_config }, { .compatible ="renesas,iic-r8a7790" , .data = &v2_freq_calc_dt_config }, { .compatible ="renesas,iic-r8a7791" , .data = &fast_clock_dt_config }, { .compatible ="renesas,iic-r8a7792" , .data = &fast_clock_dt_config },
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 163/313 bnxt_en: Disable MSIX before re-reserving NQs/CMPL rings.
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 36d65be9a88052cdfc8524eb591baf0e6c878408 ]
When bringing up a device, the code checks to see if the number of MSIX has changed. pci_disable_msix() should be called first before changing the number of reserved NQs/CMPL rings. This ensures that the MSIX vectors associated with the NQs/CMPL rings are still properly mapped when pci_disable_msix() masks the vectors.
This patch will prevent errors when RDMA support is added for the new 57500 chips. When the RDMA driver shuts down, the number of NQs is decreased and we must use the new sequence to prevent MSIX errors.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +11 -8
@@ -6073,23 +6073,26 @@ static void bnxt_clear_int_mode(struct bnxt *bp)int bnxt_reserve_rings (struct bnxt *bp) {int tcs =netdev_get_num_tc (bp->dev); +bool reinit_irq = false;int rc;if (!bnxt_need_reserve_rings (bp))return 0 ; - rc =__bnxt_reserve_rings (bp); -if (rc) { -netdev_err (bp->dev,"ring reservation failure rc: %d\n" , rc); -return rc; - }if (BNXT_NEW_RM (bp) && (bnxt_get_num_msix (bp) != bp->total_irqs)) {bnxt_ulp_irq_stop (bp);bnxt_clear_int_mode (bp); - rc =bnxt_init_int_mode (bp); + reinit_irq = true; + } + rc =__bnxt_reserve_rings (bp); +if (reinit_irq) { +if (!rc) + rc =bnxt_init_int_mode (bp);bnxt_ulp_irq_restart (bp, rc); -if (rc) -return rc; + } +if (rc) { +netdev_err (bp->dev,"ring reservation/IRQ init failure rc: %d\n" , rc); +return rc; }if (tcs && (bp->tx_nr_rings_per_tc * tcs != bp->tx_nr_rings)) {netdev_err (bp->dev,"tx ring reservation failure\n" );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 164/313 KVM: s390: unregister debug feature on failing arch init
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 308c3e6673b012beecb96ef04cc65f4a0e7cdd99 ]
Make sure the debug feature and its allocated resources get released upon unsuccessful architecture initialization.
A related indication of the issue will be reported as kernel message.
Message-Id: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
arch/s390/kvm/kvm-s390.c +14 -3
@@ -416,19 +416,30 @@ static void kvm_s390_cpu_feat_init(void)int kvm_arch_init (void *opaque) { +int rc; + kvm_s390_dbf =debug_register ("kvm-trace" ,32 ,1 ,7 *sizeof (long ));if (!kvm_s390_dbf)return -ENOMEM ;if (debug_register_view (kvm_s390_dbf, &debug_sprintf_view)) { -debug_unregister (kvm_s390_dbf); -return -ENOMEM ; + rc = -ENOMEM ; + goto out_debug_unreg; }kvm_s390_cpu_feat_init ();/* Register floating interrupt controller interface. */ -return kvm_register_device_ops (&kvm_flic_ops,KVM_DEV_TYPE_FLIC ); + rc =kvm_register_device_ops (&kvm_flic_ops,KVM_DEV_TYPE_FLIC ); +if (rc) { +pr_err ("Failed to register FLIC rc=%d\n" , rc); + goto out_debug_unreg; + } +return 0 ; + +out_debug_unreg: +debug_unregister (kvm_s390_dbf); +return rc; }void kvm_arch_exit (void )
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 165/313 tools/power/x86/intel_pstate_tracer: Fix non root execution for post processing a trace file
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 663546903c835fe46308b1b1e53d32d1f2b33da9 ]
This script is supposed to be allowed to run with regular user privileges if a previously captured trace is being post processed.
Commit fbe313884d7d (tools/power/x86/intel_pstate_tracer: Free the trace buffer memory) introduced a bug that breaks that option.
Commit 35459105deb2 (tools/power/x86/intel_pstate_tracer: Add optional setting of trace buffer memory allocation) moved the code but kept the bug.
This patch fixes the issue.
--- tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py +2 -2
@@ -585,9 +585,9 @@ current_max_cpu = 0 read_trace_data(filename) -clear_trace_file() -# Free the memory if interval: + clear_trace_file() + # Free the memory free_trace_buffer() if graph_data_present == False:
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 166/313 livepatch: check kzalloc return values
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 5f30b2e823484ce6a79f2b59901b6351c15effa6 ]
kzalloc() return should always be checked - notably in example code where this may be seen as reference. On failure of allocation in livepatch_fix1_dummy_alloc() respectively dummy_alloc() previous allocation is freed (thanks to Petr Mladek <[email protected]> for catching this) and NULL returned.
--- samples/livepatch/livepatch-shadow-fix1.c | 5 +++++ samples/livepatch/livepatch-shadow-mod.c | 4 ++++ 2 files changed, 9 insertions(+)
samples/livepatch/livepatch-shadow-fix1.c +5 -0
@@ -89,6 +89,11 @@ struct dummy *livepatch_fix1_dummy_alloc(void)* pointer to handle resource release. */ leak =kzalloc (sizeof (int ),GFP_KERNEL ); +if (!leak) { +kfree (d); +return NULL ; + } +klp_shadow_alloc (d,SV_LEAK ,sizeof (leak),GFP_KERNEL , shadow_leak_ctor, leak);
samples/livepatch/livepatch-shadow-mod.c +4 -0
@@ -118,6 +118,10 @@ noinline struct dummy *dummy_alloc(void)/* Oops, forgot to save leak! */ leak =kzalloc (sizeof (int ),GFP_KERNEL ); +if (!leak) { +kfree (d); +return NULL ; + }pr_info ("%s: dummy @ %p, expires @ %lx\n" , __func__, d, d->jiffies_expire);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 167/313 arm64: KVM: Skip MMIO insn after emulation
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 0d640732dbebed0f10f18526de21652931f0b2f2 ]
When we emulate an MMIO instruction, we advance the CPU state within decode_hsr(), before emulating the instruction effects.
Having this logic in decode_hsr() is opaque, and advancing the state before emulation is problematic. It gets in the way of applying consistent single-step logic, and it prevents us from being able to fail an MMIO instruction with a synchronous exception.
Clean this up by only advancing the CPU state *after* the effects of the instruction are emulated.
--- virt/kvm/arm/mmio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
virt/kvm/arm/mmio.c +6 -5
@@ -117,6 +117,12 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)vcpu_set_reg (vcpu, vcpu->arch.mmio_decode.rt, data); } +/* +* The MMIO instruction is emulated and should not be re-executed +* in the guest. +*/ +kvm_skip_instr (vcpu,kvm_vcpu_trap_il_is32bit (vcpu)); +return 0 ; }
@@ -144,11 +150,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, bool *is_write, int *len) vcpu->arch.mmio_decode.sign_extend = sign_extend; vcpu->arch.mmio_decode.rt = rt; -/* -* The MMIO instruction is emulated and should not be re-executed -* in the guest. -*/ -kvm_skip_instr (vcpu,kvm_vcpu_trap_il_is32bit (vcpu));return 0 ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 168/313 usb: musb: dsps: fix otg state machine
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 6010abf2c2c0e382d7e8ee44bd11f343aae90cce ]
Due to lack of ID pin interrupt event on AM335x devices, the musb dsps driver uses polling to detect usb device attach for dual-role port.
But in the case if a micro-A cable adapter is attached without a USB device attached to the cable, the musb state machine gets stuck in a_wait_vrise state waiting for the MUSB_CONNECT interrupt which won't happen due to the usb device is not attached. The state is stuck in a_wait_vrise even after the micro-A cable is detached, which could cause VBUS retention if then the dual-role port is attached to a host port.
To fix the problem, make a_wait_vrise as a transient state, then move the state to either a_wait_bcon for host port or a_idle state for dual-role port, if no usb device is attached to the port.
--- drivers/usb/musb/musb_dsps.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_dsps.c +7 -2
@@ -227,8 +227,13 @@ static int dsps_check_status(struct musb *musb, void *unused)switch (musb->xceiv->otg->state) {case OTG_STATE_A_WAIT_VRISE : -dsps_mod_timer_optional (glue); -break ; +if (musb->port_mode ==MUSB_HOST ) { + musb->xceiv->otg->state =OTG_STATE_A_WAIT_BCON ; +dsps_mod_timer_optional (glue); +break ; + } +/* fall through */ +case OTG_STATE_A_WAIT_BCON :/* keep VBUS on for host-only mode */ if (musb->port_mode ==MUSB_HOST ) {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 169/313 usb: musb: dsps: fix runtime pm for peripheral mode
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 54578ee883e34d2d1c518d48f1c1e2dd3f387188 ]
Since the runtime PM support was added in musb, dsps relies on the timer calling otg_timer() to activate the usb subsystem. However the driver doesn't enable the timer for peripheral port, then the peripheral port is unable to be enumerated by a host if the other usb port is disabled or in peripheral mode too.
So let's start the timer for peripheral port too.
--- drivers/usb/musb/musb_dsps.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_dsps.c +9 -3
@@ -181,9 +181,11 @@ static void dsps_musb_enable(struct musb *musb)musb_writel (reg_base, wrp->epintr_set, epmask);musb_writel (reg_base, wrp->coreintr_set, coremask); -/* start polling for ID change in dual-role idle mode */ -if (musb->xceiv->otg->state ==OTG_STATE_B_IDLE && - musb->port_mode ==MUSB_OTG ) +/* +* start polling for runtime PM active and idle, +* and for ID change in dual-role idle mode. +*/ +if (musb->xceiv->otg->state ==OTG_STATE_B_IDLE )dsps_mod_timer (glue,-1 ); }
@@ -254,6 +256,10 @@ static int dsps_check_status(struct musb *musb, void *unused) musb->xceiv->otg->state =OTG_STATE_A_IDLE ;MUSB_HST_MODE (musb); } + +if (musb->port_mode ==MUSB_PERIPHERAL ) + skip_session =1 ; +if (!(devctl &MUSB_DEVCTL_SESSION ) && !skip_session)musb_writeb (mregs,MUSB_DEVCTL ,MUSB_DEVCTL_SESSION );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 170/313 perf header: Fix up argument to ctime()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 0afcf29bab35d3785204cd9bd51693b231ad7181 ]
Reducing this noise when cross building to the Android NDK:
util/header.c: In function 'perf_header__fprintf_info':
util/header.c:2710:45: warning: pointer targets in passing argument 1 of 'ctime' differ in signedness [-Wpointer-sign]
fprintf(fp, "# captured on : %s", ctime(&st.st_ctime));
^
In file included from util/../perf.h:5:0,
from util/evlist.h:11,
from util/header.c:22:
/opt/android-ndk-r15c/platforms/android-26/arch-arm/usr/include/time.h:81:14: note: expected 'const time_t *' but argument is of type 'long unsigned int *'
extern char* ctime(const time_t*) __LIBC_ABI_PUBLIC__;
^--- tools/perf/util/header.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/header.c +3 -1
@@ -2636,6 +2636,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)struct perf_header *header = &session->header;int fd =perf_data__fd (session->data);struct stat st; +time_t stctime;int ret, bit; hd.fp = fp;
@@ -2645,7 +2646,8 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)if (ret ==-1 )return -1 ; -fprintf (fp,"# captured on : %s" ,ctime (&st.st_ctime)); + stctime = st.st_ctime; +fprintf (fp,"# captured on : %s" ,ctime (&stctime));fprintf (fp,"# header version : %u\n" , header->version);fprintf (fp,"# data offset : %" PRIu64"\n" , header->data_offset);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 171/313 perf tools: Cast off_t to s64 to avoid warning on bionic libc
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 866053bb644f754d1a93aaa9db9998fecf7a8978 ]
To avoid this warning:
CC /tmp/build/perf/util/s390-cpumsf.o
util/s390-cpumsf.c: In function 's390_cpumsf_samples':
util/s390-cpumsf.c:508:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'off_t' [-Wformat=]
pr_err("[%#08" PRIx64 "] Invalid AUX trailer entry TOD clock base\n",
^
Now the various Android cross toolchains used in the perf tools container test builds are all clean and we can remove this:
export EXTRA_MAKE_ARGS="WERROR=0"
--- tools/perf/util/s390-cpumsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/s390-cpumsf.c +1 -1
@@ -499,7 +499,7 @@ static int s390_cpumsf_samples(struct s390_cpumsf_queue *sfq, u64 *ts) aux_ts =get_trailer_time (buf);if (!aux_ts) {pr_err ("[%#08" PRIx64"] Invalid AUX trailer entry TOD clock base\n" , - sfq->buffer->data_offset); + (s64 )sfq->buffer->data_offset); aux_ts = ~0ULL ; goto out; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 172/313 percpu: convert spin_lock_irq to spin_lock_irqsave.
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 6ab7d47bcbf0144a8cb81536c2cead4cde18acfe ]
Quoted 1 line
From Michael Cree:
"Bisection lead to commit b38d08f3181c ("percpu: restructure
locking") as being the cause of lockups at initial boot on the kernel built for generic Alpha.
On a suggestion by Tejun Heo that:
So, the only thing I can think of is that it's calling spin_unlock_irq() while irq handling isn't set up yet. Can you please try the followings?
1. Convert all spin_[un]lock_irq() to spin_lock_irqsave/unlock_irqrestore()."
--- mm/percpu-km.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/percpu-km.c +3 -2
@@ -50,6 +50,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)const int nr_pages = pcpu_group_sizes[0 ] >>PAGE_SHIFT ;struct pcpu_chunk *chunk;struct page *pages; +unsigned long flags;int i; chunk =pcpu_alloc_chunk (gfp);
@@ -68,9 +69,9 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp) chunk->data = pages; chunk->base_addr =page_address (pages) - pcpu_group_offsets[0 ]; -spin_lock_irq (&pcpu_lock); +spin_lock_irqsave (&pcpu_lock, flags);pcpu_chunk_populated (chunk,0 , nr_pages, false); -spin_unlock_irq (&pcpu_lock); +spin_unlock_irqrestore (&pcpu_lock, flags);pcpu_stats_chunk_alloc ();trace_percpu_create_chunk (chunk->base_addr);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 173/313 net: hns3: fix incomplete uninitialization of IRQ in the hns3_nic_uninit_vector_data()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit ae6017a71115ebc4e5c1a3f0f451319ab3f5c447 ]
In the hns3_nic_uninit_vector_data(), the procedure of uninitializing the tqp_vector's IRQ has not set affinity_notify to NULL and changes its init flag. This patch fixes it. And for simplificaton, local variable tqp_vector is used instead of priv->tqp_vector[i].
--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +6 -6
@@ -2760,12 +2760,12 @@ static int hns3_nic_uninit_vector_data(struct hns3_nic_priv *priv)hns3_free_vector_ring_chain (tqp_vector, &vector_ring_chain); -if (priv->tqp_vector[i].irq_init_flag ==HNS3_VECTOR_INITED ) { - (void )irq_set_affinity_hint ( - priv->tqp_vector[i].vector_irq, -NULL ); -free_irq (priv->tqp_vector[i].vector_irq, - &priv->tqp_vector[i]); +if (tqp_vector->irq_init_flag ==HNS3_VECTOR_INITED ) { +irq_set_affinity_notifier (tqp_vector->vector_irq, +NULL ); +irq_set_affinity_hint (tqp_vector->vector_irq,NULL ); +free_irq (tqp_vector->vector_irq, tqp_vector); + tqp_vector->irq_init_flag =HNS3_VECTOR_NOT_INITED ; } priv->ring_data[i].ring->irq_init_flag =HNS3_VECTOR_NOT_INITED ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 174/313 drm/amd/display: Add retry to read ddc_clock pin
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit bd4905a9583c760da31ded7256dca6f71483c3dc ]
[WHY]
On customer board, there is one pluse (1v , < 1ms) on DDC_CLK pin when plug / unplug DP cable. Driver will read it and config DP to HDMI/DVI dongle.
[HOW]
If there is a real dongle, DDC_CLK should be always pull high. Try to read again to recovery this special case. Retry times = 3. Need additional 3ms to detect DP passive dongle(3 failures)
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +17 -6
@@ -324,7 +324,7 @@ bool dc_link_is_dp_sink_present(struct dc_link *link) {enum gpio_result gpio_result;uint32_t clock_pin =0 ; - +uint8_t retry =0 ;struct ddc *ddc; enum connector_id connector_id =
@@ -353,11 +353,22 @@ bool dc_link_is_dp_sink_present(struct dc_link *link)return present; } -/* Read GPIO: DP sink is present if both clock and data pins are zero */ -/* [anaumov] in DAL2, there was no check for GPIO failure */ - - gpio_result =dal_gpio_get_value (ddc->pin_clock, &clock_pin); -ASSERT (gpio_result ==GPIO_RESULT_OK ); +/* +* Read GPIO: DP sink is present if both clock and data pins are zero +* +* [W/A] plug-unplug DP cable, sometimes customer board has +* one short pulse on clk_pin(1V, < 1ms). DP will be config to HDMI/DVI +* then monitor can't br light up. Add retry 3 times +* But in real passive dongle, it need additional 3ms to detect +*/ +do { + gpio_result =dal_gpio_get_value (ddc->pin_clock, &clock_pin); +ASSERT (gpio_result ==GPIO_RESULT_OK ); +if (clock_pin) +udelay (1000 ); +else +break ; + }while (retry++ <3 ); present = (gpio_result ==GPIO_RESULT_OK ) && !clock_pin;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 175/313 Bluetooth: hci_bcm: Handle deferred probing for the clock supply
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 28ac03b9ac3f784c2f048a910c8d0a7a87483b66 ]
On some systems that actually have the bluetooth controller wired up with an extra clock signal, it's possible the bluetooth controller probes before the clock provider. clk_get would return a defer probe error, which was not handled by this driver.
Handle this properly, so that these systems can work reliably.
--- drivers/bluetooth/hci_bcm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/hci_bcm.c +4 -0
@@ -907,6 +907,10 @@ static int bcm_get_resources(struct bcm_device *dev) dev->clk =devm_clk_get (dev->dev,NULL ); +/* Handle deferred probing */ +if (dev->clk ==ERR_PTR (-EPROBE_DEFER )) +return PTR_ERR (dev->clk); + dev->device_wakeup =devm_gpiod_get_optional (dev->dev,"device-wakeup" ,GPIOD_OUT_LOW );if (IS_ERR (dev->device_wakeup))
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 176/313 drm/amd/display: fix YCbCr420 blank color
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 12750d1647f118496f1da727146f255f5e44d500 ]
[Why]
YCbCr420 packing format uses two chanels for luma, and 1 channel for both chroma component. Our previous implementation did not account for this and results in every other pixel having very high luma value, showing greyish color instead of black.
YCbCr444 = <Y1, Cb1, Cr1>; <Y2, Cb2, Cr2> .....
YCbCr420 = <Y1, Y2, Cb1>; <Y3, Y4, Cr1> .....
[How]
Program the second channel with the black color value for luma as well.
--- .../drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 11 ++++++++++- .../gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +10 -1
@@ -1268,10 +1268,19 @@ static void program_scaler(const struct dc *dc, pipe_ctx->plane_res.scl_data.lb_params.depth, &pipe_ctx->stream->bit_depth_params); -if (pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color) +if (pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color) { +/* +* The way 420 is packed, 2 channels carry Y component, 1 channel +* alternate between Cb and Cr, so both channels need the pixel +* value for Y +*/ +if (pipe_ctx->stream->timing.pixel_encoding ==PIXEL_ENCODING_YCBCR420 ) + color.color_r_cr = color.color_g_y; + pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color ( pipe_ctx->stream_res.tg, &color); + } pipe_ctx->plane_res.xfm->funcs->transform_set_scaler (pipe_ctx->plane_res.xfm, &pipe_ctx->plane_res.scl_data);
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +9 -0
@@ -2121,6 +2121,15 @@ static void dcn10_blank_pixel_data( color_space = stream->output_color_space;color_space_to_black_color (dc, color_space, &black_color); +/* +* The way 420 is packed, 2 channels carry Y component, 1 channel +* alternate between Cb and Cr, so both channels need the pixel +* value for Y +*/ +if (stream->timing.pixel_encoding ==PIXEL_ENCODING_YCBCR420 ) + black_color.color_r_cr = black_color.color_g_y; + +if (stream_res->tg->funcs->set_blank_color) stream_res->tg->funcs->set_blank_color( stream_res->tg,
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 177/313 powerpc/uaccess: fix warning/error with access_ok()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 05a4ab823983d9136a460b7b5e0d49ee709a6f86 ]
With the following piece of code, the following compilation warning is encountered:
if (_IOC_DIR(ioc) != _IOC_NONE) {
int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
if (!access_ok(verify, ioarg, _IOC_SIZE(ioc))) {drivers/platform/test/dev.c: In function 'my_ioctl':drivers/platform/test/dev.c:219:7: warning: unused variable 'verify' [-Wunused-variable]
int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
This patch fixes it by referencing 'type' in the macro allthough doing nothing with it.
--- arch/powerpc/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/uaccess.h +1 -1
@@ -63,7 +63,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size,#endif #define access_ok (type, addr, size) \ - (__chk_user_ptr(addr), \ + (__chk_user_ptr(addr), (void)(type), \ __access_ok((__force unsigned long)(addr), (size), get_fs()))/*
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 178/313 mac80211: fix radiotap vendor presence bitmap handling
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit efc38dd7d5fa5c8cdd0c917c5d00947aa0539443 ]
Due to the alignment handling, it actually matters where in the code we add the 4 bytes for the presence bitmap to the length; the first field is the timestamp with 8 byte alignment so we need to add the space for the extra vendor namespace presence bitmap *before* we do any alignment for the fields.
Move the presence bitmap length accounting to the right place to fix the alignment for the data properly.
--- net/mac80211/rx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/mac80211/rx.c +3 -2
@@ -142,6 +142,9 @@ ieee80211_rx_radiotap_hdrlen(struct ieee80211_local *local,/* allocate extra bitmaps */ if (status->chains) len +=4 *hweight8 (status->chains); +/* vendor presence bitmap */ +if (status->flag &RX_FLAG_RADIOTAP_VENDOR_DATA ) + len +=4 ;if (ieee80211_have_rx_timestamp (status)) { len =ALIGN (len,8 );
@@ -197,8 +200,6 @@ ieee80211_rx_radiotap_hdrlen(struct ieee80211_local *local,if (status->flag &RX_FLAG_RADIOTAP_VENDOR_DATA ) {struct ieee80211_vendor_radiotap *rtap = (void *)skb->data; -/* vendor presence bitmap */ - len +=4 ;/* alignment for fixed 6-byte vendor data header */ len =ALIGN (len,2 );/* vendor data header */
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 179/313 xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit fa89a4593b927b3f59c3b69379f31d3b22272e4e ]
gcc warn this:
net/ipv6/xfrm6_tunnel.c:143 __xfrm6_tunnel_alloc_spi() warn:
always true condition '(spi <= 4294967295) => (0-u32max <= u32max)'
'spi' is u32, which always not greater than XFRM6_TUNNEL_SPI_MAX because of wrap around. So the second forloop will never reach.
--- net/ipv6/xfrm6_tunnel.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/xfrm6_tunnel.c +3 -0
@@ -144,6 +144,9 @@ static u32 __xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr) index =__xfrm6_tunnel_spi_check (net, spi);if (index >=0 ) goto alloc_spi; + +if (spi ==XFRM6_TUNNEL_SPI_MAX ) +break ; }for (spi =XFRM6_TUNNEL_SPI_MIN ; spi < xfrm6_tn->spi; spi++) { index =__xfrm6_tunnel_spi_check (net, spi);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 180/313 mlxsw: spectrum: Properly cleanup LAG uppers when removing port from LAG
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit be2d6f421f680e01d58f7cd452646e0d8586d49b ]
When a LAG device or a VLAN device on top of it is enslaved to a bridge, the driver propagates the CHANGEUPPER event to the LAG's slaves.
This causes each physical port to increase the reference count of the internal representation of the bridge port by calling mlxsw_sp_port_bridge_join().
However, when a port is removed from a LAG, the corresponding leave() function is not called and the reference count is not decremented. This leads to ugly hacks such as mlxsw_sp_bridge_port_should_destroy() that try to understand if the bridge port should be destroyed even when its reference count is not 0.
Instead, make sure that when a port is unlinked from a LAG it would see the same events as if the LAG (or its uppers) were unlinked from a bridge.
The above is achieved by walking the LAG's uppers when a port is unlinked and calling mlxsw_sp_port_bridge_leave() for each upper that is enslaved to a bridge.
--- .../net/ethernet/mellanox/mlxsw/spectrum.c | 23 ++++++++++++++++ .../mellanox/mlxsw/spectrum_switchdev.c | 27 +------------------ 2 files changed, 24 insertions(+), 26 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +23 -0
@@ -4235,6 +4235,25 @@ void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port)dev_put (mlxsw_sp_port->dev); } +static void +mlxsw_sp_port_lag_uppers_cleanup (struct mlxsw_sp_port *mlxsw_sp_port, +struct net_device *lag_dev) +{ +struct net_device *br_dev =netdev_master_upper_dev_get (lag_dev); +struct net_device *upper_dev; +struct list_head *iter; + +if (netif_is_bridge_port (lag_dev)) +mlxsw_sp_port_bridge_leave (mlxsw_sp_port, lag_dev, br_dev); + +netdev_for_each_upper_dev_rcu (lag_dev, upper_dev, iter) { +if (!netif_is_bridge_port (upper_dev)) +continue ; + br_dev =netdev_master_upper_dev_get (upper_dev); +mlxsw_sp_port_bridge_leave (mlxsw_sp_port, upper_dev, br_dev); + } +} +static int mlxsw_sp_lag_create (struct mlxsw_sp *mlxsw_sp,u16 lag_id) {char sldr_pl[MLXSW_REG_SLDR_LEN ];
@@ -4427,6 +4446,10 @@ static void mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port,/* Any VLANs configured on the port are no longer valid */ mlxsw_sp_port_vlan_flush (mlxsw_sp_port); +/* Make the LAG and its directly linked uppers leave bridges they +* are memeber in +*/ +mlxsw_sp_port_lag_uppers_cleanup (mlxsw_sp_port, lag_dev);if (lag->ref_count ==1 )mlxsw_sp_lag_destroy (mlxsw_sp, lag_id);
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1 -26
@@ -282,30 +282,6 @@ mlxsw_sp_bridge_port_destroy(struct mlxsw_sp_bridge_port *bridge_port)kfree (bridge_port); } -static bool -mlxsw_sp_bridge_port_should_destroy (const struct mlxsw_sp_bridge_port * - bridge_port) -{ -struct net_device *dev = bridge_port->dev; -struct mlxsw_sp *mlxsw_sp; - -if (is_vlan_dev (dev)) - mlxsw_sp =mlxsw_sp_lower_get (vlan_dev_real_dev (dev)); -else - mlxsw_sp =mlxsw_sp_lower_get (dev); - -/* In case ports were pulled from out of a bridged LAG, then -* it's possible the reference count isn't zero, yet the bridge -* port should be destroyed, as it's no longer an upper of ours. -*/ -if (!mlxsw_sp &&list_empty (&bridge_port->vlans_list)) -return true; -else if (bridge_port->ref_count ==0 ) -return true; -else -return false; -} -static struct mlxsw_sp_bridge_port *mlxsw_sp_bridge_port_get (struct mlxsw_sp_bridge *bridge,struct net_device *brport_dev)
@@ -343,8 +319,7 @@ static void mlxsw_sp_bridge_port_put(struct mlxsw_sp_bridge *bridge, {struct mlxsw_sp_bridge_device *bridge_device; - bridge_port->ref_count--; -if (!mlxsw_sp_bridge_port_should_destroy (bridge_port)) +if (--bridge_port->ref_count !=0 )return ; bridge_device = bridge_port->bridge_device;mlxsw_sp_bridge_port_destroy (bridge_port);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 181/313 scsi: smartpqi: correct host serial num for ssa
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit b2346b5030cf9458f30a84028d9fe904b8c942a7 ]
--- drivers/scsi/smartpqi/smartpqi_init.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +3 -0
@@ -653,6 +653,7 @@ struct bmic_host_wellness_driver_version {u8 driver_version_tag[2 ];__le16 driver_version_length;char driver_version[32 ]; +u8 dont_write_tag[2 ];u8 end_tag[2 ]; };
@@ -682,6 +683,8 @@ static int pqi_write_driver_version_to_host_wellness(strncpy (buffer->driver_version,"Linux " DRIVER_VERSION ,sizeof (buffer->driver_version) -1 ); buffer->driver_version[sizeof (buffer->driver_version) -1 ] ='\0' ; + buffer->dont_write_tag[0 ] ='D' ; + buffer->dont_write_tag[1 ] ='W' ; buffer->end_tag[0 ] ='Z' ; buffer->end_tag[1 ] ='Z' ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 182/313 scsi: smartpqi: correct volume status
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 7ff44499bafbd376115f0bb6b578d980f56ee13b ]
- fix race condition when a unit is deleted after an RLL, and before we have gotten the LV_STATUS page of the unit.
- In this case we will get a standard inquiry, rather than the desired page. This will result in a unit presented which no longer exists.
- If we ask for LV_STATUS, insure we get LV_STATUS
--- drivers/scsi/smartpqi/smartpqi_init.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +3 -0
@@ -1184,6 +1184,9 @@ static void pqi_get_volume_status(struct pqi_ctrl_info *ctrl_info,if (rc) goto out; +if (vpd->page_code !=CISS_VPD_LV_STATUS ) + goto out; + page_length = offsetof(struct ciss_vpd_logical_volume_status , volume_status) + vpd->page_length;if (page_length <sizeof (*vpd))
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 183/313 scsi: smartpqi: increase fw status register read timeout
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 65111785acccb836ec75263b03b0e33f21e74f47 ]
Problem:
- during the driver initialization, driver will poll fw for KERNEL_UP in a 30 seconds timeout.
- if the firmware is not ready after 30 seconds,
driver will not be loaded.
Fix:
- change timeout from 30 seconds to 3 minutes.
--- drivers/scsi/smartpqi/smartpqi_sis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_sis.c +1 -1
@@ -59,7 +59,7 @@#define SIS_CTRL_KERNEL_UP 0x80#define SIS_CTRL_KERNEL_PANIC 0x100 -#define SIS_CTRL_READY_TIMEOUT_SECS 30 +#define SIS_CTRL_READY_TIMEOUT_SECS 180#define SIS_CTRL_READY_RESUME_TIMEOUT_SECS 90#define SIS_CTRL_READY_POLL_INTERVAL_MSECS 10
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 184/313 cw1200: Fix concurrency use-after-free bugs in cw1200_hw_scan()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 4f68ef64cd7feb1220232bd8f501d8aad340a099 ]
The function cw1200_bss_info_changed() and cw1200_hw_scan() can be concurrently executed.
The two functions both access a possible shared variable "frame.skb".
This shared variable is freed by dev_kfree_skb() in cw1200_upload_beacon(), which is called by cw1200_bss_info_changed(). The free operation is protected by a mutex lock "priv->conf_mutex" in cw1200_bss_info_changed().
In cw1200_hw_scan(), this shared variable is accessed without the protection of the mutex lock "priv->conf_mutex".
Thus, concurrency use-after-free bugs may occur.
To fix these bugs, the original calls to mutex_lock(&priv->conf_mutex) and mutex_unlock(&priv->conf_mutex) are moved to the places, which can protect the accesses to the shared variable.
--- drivers/net/wireless/st/cw1200/scan.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/wireless/st/cw1200/scan.c +6 -7
@@ -78,6 +78,10 @@ int cw1200_hw_scan(struct ieee80211_hw *hw,if (req->n_ssids >WSM_SCAN_MAX_NUM_OF_SSIDS )return -EINVAL ; +/* will be unlocked in cw1200_scan_work() */ +down (&priv->scan.lock); +mutex_lock (&priv->conf_mutex); + frame.skb =ieee80211_probereq_get (hw, priv->vif->addr,NULL ,0 , req->ie_len);if (!frame.skb)
@@ -86,19 +90,15 @@ int cw1200_hw_scan(struct ieee80211_hw *hw,if (req->ie_len)skb_put_data (frame.skb, req->ie, req->ie_len); -/* will be unlocked in cw1200_scan_work() */ -down (&priv->scan.lock); -mutex_lock (&priv->conf_mutex); - ret =wsm_set_template_frame (priv, &frame);if (!ret) {/* Host want to be the probe responder. */ ret =wsm_set_probe_responder (priv, true); }if (ret) { +dev_kfree_skb (frame.skb);mutex_unlock (&priv->conf_mutex);up (&priv->scan.lock); -dev_kfree_skb (frame.skb);return ret; }
@@ -120,10 +120,9 @@ int cw1200_hw_scan(struct ieee80211_hw *hw, ++priv->scan.n_ssids; } -mutex_unlock (&priv->conf_mutex); -if (frame.skb)dev_kfree_skb (frame.skb); +mutex_unlock (&priv->conf_mutex);queue_work (priv->workqueue, &priv->scan.work);return 0 ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 185/313 net: hns3: add max vector number check for pf
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 75edb610860fda65ceedb017fc69afabd2806b8b ]
Each pf supports max 64 vectors and 128 tqps. For 2p/4p core scenario, there may be more than 64 cpus online. So the result of min_t(u16, num_Online_cpus(), tqp_num) may be more than 64. This patch adds check for the vector number.
--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +4 -0
@@ -2691,6 +2691,8 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)static int hns3_nic_alloc_vector_data (struct hns3_nic_priv *priv) { +#define HNS3_VECTOR_PF_MAX_NUM 64 +struct hnae3_handle *h = priv->ae_handle;struct hns3_enet_tqp_vector *tqp_vector;struct hnae3_vector_info *vector;
@@ -2703,6 +2705,8 @@ static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)/* RSS size, cpu online and vector_num should be the same */ /* Should consider 2p/4p later */ vector_num =min_t (u16,num_online_cpus (), tqp_num); + vector_num =min_t (u16, vector_num,HNS3_VECTOR_PF_MAX_NUM ); + vector =devm_kcalloc (&pdev->dev, vector_num,sizeof (*vector),GFP_KERNEL );if (!vector)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 186/313 powerpc/perf: Fix thresholding counter data for unknown type
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 17cfccc91545682513541924245abb876d296063 ]
MMCRA[34:36] and MMCRA[38:44] expose the thresholding counter value. Thresholding counter can be used to count latency cycles such as load miss to reload. But threshold counter value is not relevant when the sampled instruction type is unknown or reserved. Patch to fix the thresholding counter value to zero when sampled instruction type is unknown or reserved.
--- arch/powerpc/perf/isa207-common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/powerpc/perf/isa207-common.c +6 -1
@@ -226,8 +226,13 @@ void isa207_get_mem_weight(u64 *weight)u64 mmcra =mfspr (SPRN_MMCRA );u64 exp =MMCRA_THR_CTR_EXP (mmcra);u64 mantissa =MMCRA_THR_CTR_MANT (mmcra); +u64 sier =mfspr (SPRN_SIER ); +u64 val = (sier &ISA207_SIER_TYPE_MASK ) >>ISA207_SIER_TYPE_SHIFT ; - *weight = mantissa << (2 * exp); +if (val ==0 || val ==7 ) + *weight =0 ; +else + *weight = mantissa << (2 * exp); }int isa207_get_constraint (u64 event,unsigned long *maskp,unsigned long *valp)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 187/313 iwlwifi: mvm: fix setting HE ppe FW config
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 189b8d441b0f7825f0b4278851c52afaa0515ed2 ]
The FW expects to get the ppe value for each NSS-BW pair in the same format as in the he phy capabilities IE, which means that a value of 0 implies ppe should be used for BPSK (mcs 0). If there are no PPE thresholds in the IE, or if for some NSS-RU pair there's no threshold set for it (this could happen because it's a variable-sized field), it means no PPE should not be used for that pair, so the value sent to FW should be 7 which corresponds to "none".
--- drivers/net/wireless/intel/iwlwifi/fw/api/mac.h | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/mac.h +1 -1
@@ -442,7 +442,7 @@ struct iwl_he_backoff_conf {* Support for Nss x BW (or RU) matrix: * (0=SISO, 1=MIMO2) x (0-20MHz, 1-40MHz, 2-80MHz, 3-160MHz) * Each entry contains 2 QAM thresholds for 8us and 16us: -* 0=BPSK, 1=QPSK, 2=16QAM, 3=64QAM, 4=256QAM, 5=1024QAM, 6/7=RES +* 0=BPSK, 1=QPSK, 2=16QAM, 3=64QAM, 4=256QAM, 5=1024QAM, 6=RES, 7=NONE * i.e. QAM_th1 < QAM_th2 such if TX uses QAM_tx: * QAM_tx < QAM_th1 --> PPE=0us * QAM_th1 <= QAM_tx < QAM_th2 --> PPE=8us
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +7 -1
@@ -1997,7 +1997,13 @@ static void iwl_mvm_cfg_he_sta(struct iwl_mvm *mvm,if (sta->he_cap.he_cap_elem.mac_cap_info[4 ] &IEEE80211_HE_MAC_CAP4_BQR ) sta_ctxt_cmd.htc_flags |=cpu_to_le32 (IWL_HE_HTC_BQR_SUPP ); -/* If PPE Thresholds exist, parse them into a FW-familiar format */ +/* +* Initialize the PPE thresholds to "None" (7), as described in Table +* 9-262ac of 80211.ax/D3.0. +*/ +memset (&sta_ctxt_cmd.pkt_ext,7 ,sizeof (sta_ctxt_cmd.pkt_ext)); + +/* If PPE Thresholds exist, parse them into a FW-familiar format. */ if (sta->he_cap.he_cap_elem.phy_cap_info[6 ] &IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT ) { u8 nss = (sta->he_cap.ppe_thres[0] &
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 188/313 powerpc/powernv/ioda: Allocate indirect TCE levels of cached userspace addresses on demand
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit bdbf649efe21173cae63b4b71db84176420f9039 ]
The powernv platform maintains 2 TCE tables for VFIO - a hardware TCE table and a table with userspace addresses; the latter is used for marking pages dirty when corresponging TCEs are unmapped from the hardware table.
a68bd1267b72 ("powerpc/powernv/ioda: Allocate indirect TCE levels on demand") enabled on-demand allocation of the hardware table, however it missed the other table so it has still been fully allocated at the boot time. This fixes the issue by allocating a single level, just like we do for the hardware table.
--- arch/powerpc/platforms/powernv/pci-ioda-tce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/pci-ioda-tce.c +1 -1
@@ -299,7 +299,7 @@ long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,if (alloc_userspace_copy) { offset =0 ; uas =pnv_pci_ioda2_table_do_alloc_pages (nid, level_shift, - levels, tce_table_size, &offset, + tmplevels, tce_table_size, &offset, &total_allocated_uas);if (!uas) goto free_tces_exit;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 189/313 mlx5: update timecounter at least twice per counter overflow
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 5d8678365c90b9ce1fd2243ff5ea562609f6cec1 ]
The timecounter needs to be updated at least once in half of the cyclecounter interval to prevent timecounter_cyc2time() interpreting a new timestamp as an old value and causing a backward jump.
This would be an issue if the timecounter multiplier was so small that the update interval would not be limited by the 64-bit overflow in multiplication.
Shorten the calculated interval to make sure the timecounter is updated in time even when the system clock is slowed down by up to 10%, the multiplier is increased by up to 10%, and the scheduled overflow check is late by 15%.
--- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +2 -2
@@ -511,14 +511,14 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev) ktime_to_ns(ktime_get_real()));/* Calculate period in seconds to call the overflow watchdog - to make -* sure counter is checked at least once every wrap around. +* sure counter is checked at least twice every wrap around. * The period is calculated as the minimum between max HW cycles count * (The clock source mask) and max amount of cycles that can be * multiplied by clock multiplier where the result doesn't exceed * 64bits. */ overflow_cycles =div64_u64 (~0ULL >>1 , clock->cycles.mult); - overflow_cycles =min (overflow_cycles, clock->cycles.mask >>1 ); + overflow_cycles =min (overflow_cycles,div_u64 (clock->cycles.mask,3 )); ns =cyclecounter_cyc2ns (&clock->cycles, overflow_cycles, frac, &frac);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 190/313 drbd: narrow rcu_read_lock in drbd_sync_handshake
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit d29e89e34952a9ad02c77109c71a80043544296e ]
So far there was the possibility that we called genlmsg_new(GFP_NOIO)/mutex_lock() while holding an rcu_read_lock().
This included cases like:
drbd_sync_handshake (acquire the RCU lock)
drbd_asb_recover_1p
drbd_khelper
drbd_bcast_event
genlmsg_new(GFP_NOIO) --> may sleepdrbd_sync_handshake (acquire the RCU lock)
drbd_asb_recover_1p
drbd_khelper
notify_helper
genlmsg_new(GFP_NOIO) --> may sleepdrbd_sync_handshake (acquire the RCU lock)
drbd_asb_recover_1p
drbd_khelper
notify_helper
mutex_lock --> may sleepWhile using GFP_ATOMIC whould have been possible in the first two cases, the real fix is to narrow the rcu_read_lock.
--- drivers/block/drbd/drbd_receiver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/block/drbd/drbd_receiver.c +6 -5
@@ -3364,7 +3364,7 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,enum drbd_conns rv =C_MASK ;enum drbd_disk_state mydisk;struct net_conf *nc; -int hg, rule_nr, rr_conflict, tentative; +int hg, rule_nr, rr_conflict, tentative, always_asbp; mydisk = device->state.disk;if (mydisk ==D_NEGOTIATING )
@@ -3415,8 +3415,12 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,rcu_read_lock (); nc =rcu_dereference (peer_device->connection->net_conf); + always_asbp = nc->always_asbp; + rr_conflict = nc->rr_conflict; + tentative = nc->tentative; +rcu_read_unlock (); -if (hg ==100 || (hg ==-100 && nc->always_asbp)) { +if (hg ==100 || (hg ==-100 && always_asbp)) {int pcount = (device->state.role ==R_PRIMARY ) + (peer_role ==R_PRIMARY );int forced = (hg ==-100 );
@@ -3455,9 +3459,6 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,"Sync from %s node\n" , (hg < 0) ? "peer" : "this"); } - rr_conflict = nc->rr_conflict; - tentative = nc->tentative; -rcu_read_unlock ();if (hg ==-100 ) {/* FIXME this log message is not correct if we end up here
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 191/313 drbd: disconnect, if the wrong UUIDs are attached on a connected peer
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit b17b59602b6dcf8f97a7dc7bc489a48388d7063a ]
With "on-no-data-accessible suspend-io", DRBD requires the next attach or connect to be to the very same data generation uuid tag it lost last.
If we first lost connection to the peer, then later lost connection to our own disk, we would usually refuse to re-connect to the peer, because it presents the wrong data set.
However, if the peer first connects without a disk,
and then attached its disk, we accepted that same wrong data set, which would be "unexpected" by any user of that DRBD and cause "undefined results" (read: very likely data corruption).
The fix is to forcefully disconnect as soon as we notice that the peer attached to the "wrong" dataset.
--- drivers/block/drbd/drbd_receiver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/drbd/drbd_receiver.c +1 -1
@@ -4142,7 +4142,7 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_infokfree (device->p_uuid); device->p_uuid = p_uuid; -if (device->state.conn <C_CONNECTED && +if ((device->state.conn <C_CONNECTED || device->state.pdsk ==D_DISKLESS ) && device->state.disk <D_INCONSISTENT && device->state.role ==R_PRIMARY && (device->ed_uuid & ~((u64 )1 )) != (p_uuid[UI_CURRENT ] & ~((u64 )1 ))) {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 192/313 drbd: skip spurious timeout (ping-timeo) when failing promote
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 9848b6ddd8c92305252f94592c5e278574e7a6ac ]
If you try to promote a Secondary while connected to a Primary and allow-two-primaries is NOT set, we will wait for "ping-timeout" to give this node a chance to detect a dead primary,
in case the cluster manager noticed faster than we did.
But if we then are *still* connected to a Primary, we fail (after an additional timeout of ping-timout).
This change skips the spurious second timeout.
Most people won't notice really,
since "ping-timeout" by default is half a second.
But in some installations, ping-timeout may be 10 or 20 seconds or more, and spuriously delaying the error return becomes annoying.
--- drivers/block/drbd/drbd_nl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/block/drbd/drbd_nl.c +8 -7
@@ -668,14 +668,15 @@ drbd_set_role(struct drbd_device *const device, enum drbd_role new_role, int forif (rv ==SS_TWO_PRIMARIES ) {/* Maybe the peer is detected as dead very soon... retry at most once more in this case. */ -int timeo; -rcu_read_lock (); - nc =rcu_dereference (connection->net_conf); - timeo = nc ? (nc->ping_timeo +1 ) *HZ /10 :1 ; -rcu_read_unlock (); -schedule_timeout_interruptible (timeo); -if (try < max_tries) +if (try < max_tries) { +int timeo; try = max_tries -1 ; +rcu_read_lock (); + nc =rcu_dereference (connection->net_conf); + timeo = nc ? (nc->ping_timeo +1 ) *HZ /10 :1 ; +rcu_read_unlock (); +schedule_timeout_interruptible (timeo); + }continue ; }if (rv <SS_SUCCESS ) {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 193/313 drbd: Avoid Clang warning about pointless switch statment
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit a52c5a16cf19d8a85831bb1b915a221dd4ffae3c ]
There are several warnings from Clang about no case statement matching the constant 0:
In file included from drivers/block/drbd/drbd_receiver.c:48:
In file included from drivers/block/drbd/drbd_int.h:48:
In file included from ./include/linux/drbd_genl_api.h:54:
In file included from ./include/linux/genl_magic_struct.h:236:./include/linux/drbd_genl.h:321:1: warning: no case matching constant switch condition '0'
GENL_struct(DRBD_NLA_HELPER, 24, drbd_helper_info, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/genl_magic_struct.h:220:10: note: expanded from macro 'GENL_struct'
switch (0) {
^Silence this warning by adding a 'case 0:' statement. Additionally, adjust the alignment of the statements in the ct_assert_unique macro to avoid a checkpatch warning.
This solution was originally sent by Arnd Bergmann with a default case
statement: https://lore.kernel.org/patchwork/patch/756723/
--- include/linux/genl_magic_struct.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/genl_magic_struct.h +4 -1
@@ -191,6 +191,7 @@ static inline void ct_assert_unique_operations(void) {switch (0 ) {#include GENL_MAGIC_INCLUDE_FILE +case 0 : ; } }
@@ -209,6 +210,7 @@ static inline void ct_assert_unique_top_level_attributes(void) {switch (0 ) {#include GENL_MAGIC_INCLUDE_FILE +case 0 : ; } }
@@ -218,7 +220,8 @@ static inline void ct_assert_unique_top_level_attributes(void) static inline void ct_assert_unique_ ## s_name ## _attributes(void) \ { \ switch (0) { \ - s_fields \ + s_fields \ + case 0: \ ; \ } \ }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 194/313 drm/amd/display: validate extended dongle caps
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 99b922f9ed6a6313c0d2247cde8aa1e4a0bd67e4 ]
[why]
Some dongle doesn't have a valid extended dongle caps, but we still set the extended dongle caps to be valid. This causes validation fails for all timing.
[how]
If no dp_hdmi_max_pixel_clk is provided,
don't use extended dongle caps.
--- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +2 -1
@@ -2240,7 +2240,8 @@ static void get_active_converter_info(translate_dpcd_max_bpc ( hdmi_color_caps.bits.MAX_BITS_PER_COLOR_COMPONENT); - link->dpcd_caps.dongle_caps.extendedCapValid = true; +if (link->dpcd_caps.dongle_caps.dp_hdmi_max_pixel_clk !=0 ) + link->dpcd_caps.dongle_caps.extendedCapValid = true; }break ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 195/313 video: clps711x-fb: release disp device node in probe()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit fdac751355cd76e049f628afe6acb8ff4b1399f7 ]
clps711x_fb_probe() increments refcnt of disp device node by of_parse_phandle() and leaves it undecremented on both successful and error paths.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/video/fbdev/clps711x-fb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/fbdev/clps711x-fb.c +4 -1
@@ -287,14 +287,17 @@ static int clps711x_fb_probe(struct platform_device *pdev) } ret =of_get_fb_videomode (disp, &cfb->mode,OF_USE_NATIVE_MODE ); -if (ret) +if (ret) { +of_node_put (disp); goto out_fb_release; + }of_property_read_u32 (disp,"ac-prescale" , &cfb->ac_prescale); cfb->cmap_invert =of_property_read_bool (disp,"cmap-invert" ); ret =of_property_read_u32 (disp,"bits-per-pixel" , &info->var.bits_per_pixel); +of_node_put (disp);if (ret) goto out_fb_release;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 196/313 md: fix raid10 hang issue caused by barrier
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit e820d55cb99dd93ac2dc949cf486bb187e5cd70d ]
When both regular IO and resync IO happen at the same time, and if we also need to split regular. Then we can see tasks hang due to barrier.
1. resync thread
[ 1463.757205] INFO: task md1_resync:5215 blocked for more than 480 seconds. [ 1463.757207] Not tainted 4.19.5-1-default #1 [ 1463.757209] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 1463.757212] md1_resync D 0 5215 2 0x80000000 [ 1463.757216] Call Trace: [ 1463.757223] ? __schedule+0x29a/0x880 [ 1463.757231] ? raise_barrier+0x8d/0x140 [raid10] [ 1463.757236] schedule+0x78/0x110 [ 1463.757243] raise_barrier+0x8d/0x140 [raid10] [ 1463.757248] ? wait_woken+0x80/0x80 [ 1463.757257] raid10_sync_request+0x1f6/0x1e30 [raid10] [ 1463.757265] ? _raw_spin_unlock_irq+0x22/0x40 [ 1463.757284] ? is_mddev_idle+0x125/0x137 [md_mod] [ 1463.757302] md_do_sync.cold.78+0x404/0x969 [md_mod] [ 1463.757311] ? wait_woken+0x80/0x80 [ 1463.757336] ? md_rdev_init+0xb0/0xb0 [md_mod] [ 1463.757351] md_thread+0xe9/0x140 [md_mod] [ 1463.757358] ? _raw_spin_unlock_irqrestore+0x2e/0x60 [ 1463.757364] ? __kthread_parkme+0x4c/0x70 [ 1463.757369] kthread+0x112/0x130 [ 1463.757374] ? kthread_create_worker_on_cpu+0x40/0x40 [ 1463.757380] ret_from_fork+0x3a/0x50
2. regular IO
[ 1463.760679] INFO: task kworker/0:8:5367 blocked for more than 480 seconds. [ 1463.760683] Not tainted 4.19.5-1-default #1 [ 1463.760684] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 1463.760687] kworker/0:8 D 0 5367 2 0x80000000 [ 1463.760718] Workqueue: md submit_flushes [md_mod] [ 1463.760721] Call Trace: [ 1463.760731] ? __schedule+0x29a/0x880 [ 1463.760741] ? wait_barrier+0xdd/0x170 [raid10] [ 1463.760746] schedule+0x78/0x110 [ 1463.760753] wait_barrier+0xdd/0x170 [raid10] [ 1463.760761] ? wait_woken+0x80/0x80 [ 1463.760768] raid10_write_request+0xf2/0x900 [raid10] [ 1463.760774] ? wait_woken+0x80/0x80 [ 1463.760778] ? mempool_alloc+0x55/0x160 [ 1463.760795] ? md_write_start+0xa9/0x270 [md_mod] [ 1463.760801] ? try_to_wake_up+0x44/0x470 [ 1463.760810] raid10_make_request+0xc1/0x120 [raid10] [ 1463.760816] ? wait_woken+0x80/0x80 [ 1463.760831] md_handle_request+0x121/0x190 [md_mod] [ 1463.760851] md_make_request+0x78/0x190 [md_mod] [ 1463.760860] generic_make_request+0x1c6/0x470 [ 1463.760870] raid10_write_request+0x77a/0x900 [raid10] [ 1463.760875] ? wait_woken+0x80/0x80 [ 1463.760879] ? mempool_alloc+0x55/0x160 [ 1463.760895] ? md_write_start+0xa9/0x270 [md_mod] [ 1463.760904] raid10_make_request+0xc1/0x120 [raid10] [ 1463.760910] ? wait_woken+0x80/0x80 [ 1463.760926] md_handle_request+0x121/0x190 [md_mod] [ 1463.760931] ? _raw_spin_unlock_irq+0x22/0x40 [ 1463.760936] ? finish_task_switch+0x74/0x260 [ 1463.760954] submit_flushes+0x21/0x40 [md_mod]
So resync io is waiting for regular write io to complete to decrease nr_pending (conf->barrier++ is called before waiting). The regular write io splits another bio after call wait_barrier which call nr_pending++, then the splitted bio would continue with raid10_write_request -> wait_barrier, so the splitted bio has to wait for barrier to be zero, then deadlock happens as follows.
resync io regular io
raise_barrier
wait_barrier generic_make_request wait_barrier
To resolve the issue, we need to call allow_barrier to decrease nr_pending before generic_make_request since regular IO is not issued to underlying devices, and wait_barrier is called again to ensure no internal IO happening.
--- drivers/md/raid10.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/raid10.c +4 -0
@@ -1208,7 +1208,9 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,struct bio *split =bio_split (bio, max_sectors, gfp, &conf->bio_split);bio_chain (split, bio); +allow_barrier (conf);generic_make_request (bio); +wait_barrier (conf); bio = split; r10_bio->master_bio = bio; r10_bio->sectors = max_sectors;
@@ -1513,7 +1515,9 @@ retry_write:struct bio *split =bio_split (bio, r10_bio->sectors,GFP_NOIO , &conf->bio_split);bio_chain (split, bio); +allow_barrier (conf);generic_make_request (bio); +wait_barrier (conf); bio = split; r10_bio->master_bio = bio; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 197/313 fbdev: fbmem: behave better with small rotated displays and many CPUs
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit f75df8d4b4fabfad7e3cba2debfad12741c6fde7 ]
Blitting an image with "negative" offsets is not working since there is no clipping. It hopefully just crashes. For the bootup logo, there is protection so that blitting does not happen as the image is drawn further and further to the right (ROTATE_UR) or further and further down (ROTATE_CW). There is however no protection when drawing in the opposite directions (ROTATE_UD and ROTATE_CCW).
Add back this protection.
The regression is 20-odd years old but the mindless warning-killing mentality displayed in commit 34bdb666f4b2 ("fbdev: fbmem: remove positive test on unsigned values") is also to blame, methinks.
--- drivers/video/fbdev/core/fbmem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/core/fbmem.c +6 -2
@@ -435,7 +435,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image, image->dx += image->width +8 ; } }else if (rotate ==FB_ROTATE_UD ) { -for (x =0 ; x < num; x++) { +u32 dx = image->dx; + +for (x =0 ; x < num && image->dx <= dx; x++) { info->fbops->fb_imageblit (info, image); image->dx -= image->width +8 ; }
@@ -447,7 +449,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image, image->dy += image->height +8 ; } }else if (rotate ==FB_ROTATE_CCW ) { -for (x =0 ; x < num; x++) { +u32 dy = image->dy; + +for (x =0 ; x < num && image->dy <= dy; x++) { info->fbops->fb_imageblit (info, image); image->dy -= image->height +8 ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 198/313 i40e: define proper net_device::neigh_priv_len
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 31389b53b3e0b535867af9090a5d19ec64768d55 ]
Out of bound read reported by KASan.
i40iw_net_event() reads unconditionally 16 bytes from neigh->primary_key while the memory allocated for "neighbour" struct is evaluated in neigh_alloc() as
tbl->entry_size + dev->neigh_priv_len
where "dev" is a net_device.
But the driver does not setup dev->neigh_priv_len and we read beyond the neigh entry allocated memory, so the patch in the next mail fixes this.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -0
@@ -12016,6 +12016,9 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)ether_addr_copy (netdev->dev_addr, mac_addr);ether_addr_copy (netdev->perm_addr, mac_addr); +/* i40iw_net_event() reads 16 bytes from neigh->primary_key */ + netdev->neigh_priv_len =sizeof (u32) *4 ; + netdev->priv_flags |=IFF_UNICAST_FLT ; netdev->priv_flags |=IFF_SUPP_NOFCS ;/* Setup netdev TC information */
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 199/313 ice: Do not enable NAPI on q_vectors that have no rings
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit eec903769b4ea476591ffff73bb7359f14f38c51 ]
If ice driver has q_vectors w/ active NAPI that has no rings, then this will result in a divide by zero error. To correct it I am updating the driver code so that we only support NAPI on q_vectors that have 1 or more rings allocated to them.
See commit 13a8cd191a2b ("i40e: Do not enable NAPI on q_vectors that have no rings") for detail.
--- drivers/net/ethernet/intel/ice/ice_main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +12 -4
@@ -4333,8 +4333,12 @@ static void ice_napi_enable_all(struct ice_vsi *vsi)if (!vsi->netdev)return ; -for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) -napi_enable (&vsi->q_vectors[q_idx]->napi); +for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) { +struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; + +if (q_vector->rx.ring || q_vector->tx.ring) +napi_enable (&q_vector->napi); + } }/**
@@ -4817,8 +4821,12 @@ static void ice_napi_disable_all(struct ice_vsi *vsi)if (!vsi->netdev)return ; -for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) -napi_disable (&vsi->q_vectors[q_idx]->napi); +for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) { +struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; + +if (q_vector->rx.ring || q_vector->tx.ring) +napi_disable (&q_vector->napi); + } }/**
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 200/313 igb: Fix an issue that PME is not enabled during runtime suspend
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 1fb3a7a75e2efcc83ef21f2434069cddd6fae6f5 ]
I210 ethernet card doesn't wakeup when a cable gets plugged. It's because its PME is not set.
Since commit 42eca2302146 ("PCI: Don't touch card regs after runtime suspend D3"), if the PCI state is saved, pci_pm_runtime_suspend() stops calling pci_finish_runtime_suspend(), which enables the PCI PME.
To fix the issue, let's not to save PCI states when it's runtime suspend, to let the PCI subsystem enables PME.
--- drivers/net/ethernet/intel/igb/igb_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +5 -3
@@ -8770,9 +8770,11 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,rtnl_unlock ();#ifdef CONFIG_PM - retval =pci_save_state (pdev); -if (retval) -return retval; +if (!runtime) { + retval =pci_save_state (pdev); +if (retval) +return retval; + }#endif status =rd32 (E1000_STATUS );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 201/313 ACPI/APEI: Clear GHES block_status before panic()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 98cff8b23ed1c763a029ee81ea300df0d153d07d ]
In __ghes_panic() clear the block status in the APEI generic error status block for that generic hardware error source before calling panic() to prevent a second panic() in the crash kernel for exactly the same fatal error.
Otherwise ghes_probe(), running in the crash kernel, would see an unhandled error in the APEI generic error status block and panic again, thereby precluding any crash dump.
--- drivers/acpi/apei/ghes.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/apei/ghes.c +2 -0
@@ -691,6 +691,8 @@ static void __ghes_panic(struct ghes *ghes) {__ghes_print_estatus (KERN_EMERG , ghes->generic, ghes->estatus); +ghes_clear_estatus (ghes); +/* reboot to log the error! */ if (!panic_timeout) panic_timeout = ghes_panic_timeout;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 202/313 fbdev: fbcon: Fix unregister crash when more than one framebuffer
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 2122b40580dd9d0620398739c773d07a7b7939d0 ]
When unregistering fbdev using unregister_framebuffer(), any bound console will unbind automatically. This is working fine if this is the only framebuffer, resulting in a switch to the dummy console. However if there is a fb0 and I unregister fb1 having a bound console, I eventually get a crash. The fastest way for me to trigger the crash is to do a reboot, resulting in this splat:
[ 76.478825] WARNING: CPU: 0 PID: 527 at linux/kernel/workqueue.c:1442 __queue_work+0x2d4/0x41c [ 76.478849] Modules linked in: raspberrypi_hwmon gpio_backlight backlight bcm2835_rng rng_core [last unloaded: tinydrm] [ 76.478916] CPU: 0 PID: 527 Comm: systemd-udevd Not tainted 4.20.0-rc4+ #4 [ 76.478933] Hardware name: BCM2835 [ 76.478949] Backtrace: [ 76.478995] [<c010d388>] (dump_backtrace) from [<c010d670>] (show_stack+0x20/0x24) [ 76.479022] r6:00000000 r5:c0bc73be r4:00000000 r3:6fb5bf81 [ 76.479060] [<c010d650>] (show_stack) from [<c08e82f4>] (dump_stack+0x20/0x28) [ 76.479102] [<c08e82d4>] (dump_stack) from [<c0120070>] (__warn+0xec/0x12c) [ 76.479134] [<c011ff84>] (__warn) from [<c01201e4>] (warn_slowpath_null+0x4c/0x58) [ 76.479165] r9:c0eb6944 r8:00000001 r7:c0e927f8 r6:c0bc73be r5:000005a2 r4:c0139e84 [ 76.479197] [<c0120198>] (warn_slowpath_null) from [<c0139e84>] (__queue_work+0x2d4/0x41c) [ 76.479222] r6:d7666a00 r5:c0e918ee r4:dbc4e700 [ 76.479251] [<c0139bb0>] (__queue_work) from [<c013a02c>] (queue_work_on+0x60/0x88) [ 76.479281] r10:c0496bf8 r9:00000100 r8:c0e92ae0 r7:00000001 r6:d9403700 r5:d7666a00 [ 76.479298] r4:20000113 [ 76.479348] [<c0139fcc>] (queue_work_on) from [<c0496c28>] (cursor_timer_handler+0x30/0x54) [ 76.479374] r7:d8a8fabc r6:c0e08088 r5:d8afdc5c r4:d8a8fabc [ 76.479413] [<c0496bf8>] (cursor_timer_handler) from [<c0178744>] (call_timer_fn+0x100/0x230) [ 76.479435] r4:c0e9192f r3:d758a340 [ 76.479465] [<c0178644>] (call_timer_fn) from [<c0178980>] (expire_timers+0x10c/0x12c) [ 76.479495] r10:40000000 r9:c0e9192f r8:c0e92ae0 r7:d8afdccc r6:c0e19280 r5:c0496bf8 [ 76.479513] r4:d8a8fabc [ 76.479541] [<c0178874>] (expire_timers) from [<c0179630>] (run_timer_softirq+0xa8/0x184) [ 76.479570] r9:00000001 r8:c0e19280 r7:00000000 r6:c0e08088 r5:c0e1a3e0 r4:c0e19280 [ 76.479603] [<c0179588>] (run_timer_softirq) from [<c0102404>] (__do_softirq+0x1ac/0x3fc) [ 76.479632] r10:c0e91680 r9:d8afc020 r8:0000000a r7:00000100 r6:00000001 r5:00000002 [ 76.479650] r4:c0eb65ec [ 76.479686] [<c0102258>] (__do_softirq) from [<c0124d10>] (irq_exit+0xe8/0x168) [ 76.479716] r10:d8d1a9b0 r9:d8afc000 r8:00000001 r7:d949c000 r6:00000000 r5:c0e8b3f0 [ 76.479734] r4:00000000 [ 76.479764] [<c0124c28>] (irq_exit) from [<c016b72c>] (__handle_domain_irq+0x94/0xb0) [ 76.479793] [<c016b698>] (__handle_domain_irq) from [<c01021dc>] (bcm2835_handle_irq+0x3c/0x48) [ 76.479823] r8:d8afdebc r7:d8afddfc r6:ffffffff r5:c0e089f8 r4:d8afddc8 r3:d8afddc8 [ 76.479851] [<c01021a0>] (bcm2835_handle_irq) from [<c01019f0>] (__irq_svc+0x70/0x98)
The problem is in the console rebinding in fbcon_fb_unbind(). It uses the virtual console index as the new framebuffer index to bind the console(s) to. The correct way is to use the con2fb_map lookup table to find the framebuffer index.
--- drivers/video/fbdev/core/fbcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon.c +1 -1
@@ -3066,7 +3066,7 @@ static int fbcon_fb_unbind(int idx)for (i = first_fb_vc; i <= last_fb_vc; i++) {if (con2fb_map[i] != idx && con2fb_map[i] !=-1 ) { - new_idx = i; + new_idx = con2fb_map[i];break ; } }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 203/313 powerpc/mm: Fix reporting of kernel execute faults on the 8xx
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit ffca395b11c4a5a6df6d6345f794b0e3d578e2d0 ]
On the 8xx, no-execute is set via PPP bits in the PTE. Therefore a no-exec fault generates DSISR_PROTFAULT error bits, not DSISR_NOEXEC_OR_G.
This patch adds DSISR_PROTFAULT in the test mask.
--- arch/powerpc/mm/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/mm/fault.c +3 -1
@@ -221,7 +221,9 @@ static int mm_fault_error(struct pt_regs *regs, unsigned long addr,static bool bad_kernel_fault (bool is_exec,unsigned long error_code,unsigned long address) { -if (is_exec && (error_code & (DSISR_NOEXEC_OR_G |DSISR_KEYFAULT ))) { +/* NX faults set DSISR_PROTFAULT on the 8xx, DSISR_NOEXEC_OR_G on others */ +if (is_exec && (error_code & (DSISR_NOEXEC_OR_G |DSISR_KEYFAULT | +DSISR_PROTFAULT ))) { printk_ratelimited(KERN_CRIT "kernel tried to execute" " exec-protected page (%lx) -" "exploit attempt? (uid: %d)\n",
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 204/313 pinctrl: meson: meson8: fix the GPIO function for the GPIOAO pins
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 42f9b48cc5402be11d2364275eb18c257d2a79e8 ]
The GPIOAO pins (as well as the two exotic GPIO_BSD_EN and GPIO_TEST_N) only belong to the pin controller in the AO domain. With the current definition these pins cannot be referred to in .dts files as group (which is possible on GXBB and GXL for example).
Add a separate "gpio_aobus" function to fix the mapping between the pin controller and the GPIO pins in the AO domain. This is similar to how the GXBB and GXL drivers implement this functionality.
--- drivers/pinctrl/meson/pinctrl-meson8.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pinctrl/meson/pinctrl-meson8.c +3 -0
@@ -807,7 +807,9 @@ static const char * const gpio_groups[] = {"BOOT_5" ,"BOOT_6" ,"BOOT_7" ,"BOOT_8" ,"BOOT_9" ,"BOOT_10" ,"BOOT_11" ,"BOOT_12" ,"BOOT_13" ,"BOOT_14" , "BOOT_15", "BOOT_16", "BOOT_17", "BOOT_18", +}; +static const char *const gpio_aobus_groups[] = {"GPIOAO_0" ,"GPIOAO_1" ,"GPIOAO_2" ,"GPIOAO_3" ,"GPIOAO_4" ,"GPIOAO_5" ,"GPIOAO_6" ,"GPIOAO_7" , "GPIOAO_8", "GPIOAO_9", "GPIOAO_10", "GPIOAO_11",
@@ -1030,6 +1032,7 @@ static struct meson_pmx_func meson8_cbus_functions[] = { };static struct meson_pmx_func meson8_aobus_functions[] = { +FUNCTION (gpio_aobus),FUNCTION (uart_ao),FUNCTION (remote),FUNCTION (i2c_slave_ao),
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 205/313 pinctrl: meson: meson8b: fix the GPIO function for the GPIOAO pins
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 2b745ac3cceb8fc1d9985990c8241a821ea97e53 ]
The GPIOAO pins (as well as the two exotic GPIO_BSD_EN and GPIO_TEST_N) only belong to the pin controller in the AO domain. With the current definition these pins cannot be referred to in .dts files as group (which is possible on GXBB and GXL for example).
Add a separate "gpio_aobus" function to fix the mapping between the pin controller and the GPIO pins in the AO domain. This is similar to how the GXBB and GXL drivers implement this functionality.
--- drivers/pinctrl/meson/pinctrl-meson8b.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/pinctrl/meson/pinctrl-meson8b.c +8 -5
@@ -646,16 +646,18 @@ static const char * const gpio_groups[] = {"BOOT_10" ,"BOOT_11" ,"BOOT_12" ,"BOOT_13" ,"BOOT_14" ,"BOOT_15" ,"BOOT_16" ,"BOOT_17" ,"BOOT_18" , -"GPIOAO_0" ,"GPIOAO_1" ,"GPIOAO_2" ,"GPIOAO_3" , -"GPIOAO_4" ,"GPIOAO_5" ,"GPIOAO_6" ,"GPIOAO_7" , -"GPIOAO_8" ,"GPIOAO_9" ,"GPIOAO_10" ,"GPIOAO_11" , -"GPIOAO_12" ,"GPIOAO_13" ,"GPIO_BSD_EN" ,"GPIO_TEST_N" , -"DIF_0_P" ,"DIF_0_N" ,"DIF_1_P" ,"DIF_1_N" ,"DIF_2_P" ,"DIF_2_N" ,"DIF_3_P" ,"DIF_3_N" ,"DIF_4_P" ,"DIF_4_N" }; +static const char *const gpio_aobus_groups[] = { +"GPIOAO_0" ,"GPIOAO_1" ,"GPIOAO_2" ,"GPIOAO_3" , +"GPIOAO_4" ,"GPIOAO_5" ,"GPIOAO_6" ,"GPIOAO_7" , +"GPIOAO_8" ,"GPIOAO_9" ,"GPIOAO_10" ,"GPIOAO_11" , +"GPIOAO_12" ,"GPIOAO_13" ,"GPIO_BSD_EN" ,"GPIO_TEST_N" +}; +static const char *const sd_a_groups[] = {"sd_d0_a" ,"sd_d1_a" ,"sd_d2_a" ,"sd_d3_a" ,"sd_clk_a" , "sd_cmd_a"
@@ -871,6 +873,7 @@ static struct meson_pmx_func meson8b_cbus_functions[] = { };static struct meson_pmx_func meson8b_aobus_functions[] = { +FUNCTION (gpio_aobus),FUNCTION (uart_ao),FUNCTION (uart_ao_b),FUNCTION (i2c_slave_ao),
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 206/313 KVM: x86: svm: report MSR_IA32_MCG_EXT_CTL as unsupported
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit e87555e550cef4941579cd879759a7c0dee24e68 ]
AMD doesn't seem to implement MSR_IA32_MCG_EXT_CTL and svm code in kvm knows nothing about it, however, this MSR is among emulated_msrs and thus returned with KVM_GET_MSR_INDEX_LIST. The consequent KVM_GET_MSRS, of course, fails.
Report the MSR as unsupported to not confuse userspace.
--- arch/x86/kvm/svm.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kvm/svm.c +7 -0
@@ -5837,6 +5837,13 @@ static bool svm_cpu_has_accelerated_tpr(void)static bool svm_has_emulated_msr (int index) { +switch (index) { +case MSR_IA32_MCG_EXT_CTL : +return false; +default : +break ; + } +return true; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 207/313 powerpc/fadump: Do not allow hot-remove memory from fadump reserved area.
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 0db6896ff6332ba694f1e61b93ae3b2640317633 ]
For fadump to work successfully there should not be any holes in reserved memory ranges where kernel has asked firmware to move the content of old kernel memory in event of crash. Now that fadump uses CMA for reserved area, this memory area is now not protected from hot-remove operations unless it is cma allocated. Hence, fadump service can fail to re-register after the hot-remove operation, if hot-removed memory belongs to fadump reserved region. To avoid this make sure that memory from fadump reserved area is not hot-removable if fadump is registered.
However, if user still wants to remove that memory, he can do so by manually stopping fadump service before hot-remove operation.
--- arch/powerpc/include/asm/fadump.h | 2 +- arch/powerpc/kernel/fadump.c | 10 ++++++++-- arch/powerpc/platforms/pseries/hotplug-memory.c | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/fadump.h +1 -1
@@ -200,7 +200,7 @@ struct fad_crash_memory_ranges {unsigned long long size; }; -extern int is_fadump_boot_memory_area (u64 addr,ulong size); +extern int is_fadump_memory_area (u64 addr,ulong size);extern int early_init_dt_scan_fw_dump (unsigned long node,const char *uname,int depth,void *data);extern int fadump_reserve_mem (void );
arch/powerpc/kernel/fadump.c +8 -2
@@ -118,13 +118,19 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,/* * If fadump is registered, check if the memory provided -* falls within boot memory area. +* falls within boot memory area and reserved memory area. */ -int is_fadump_boot_memory_area (u64 addr,ulong size) +int is_fadump_memory_area (u64 addr,ulong size) { +u64 d_start = fw_dump.reserve_dump_area_start; +u64 d_end = d_start + fw_dump.reserve_dump_area_size; +if (!fw_dump.dump_registered)return 0 ; +if (((addr + size) > d_start) && (addr <= d_end)) +return 1 ; +return (addr + size) >RMA_START && addr <= fw_dump.boot_memory_size; }
arch/powerpc/platforms/pseries/hotplug-memory.c +5 -2
@@ -389,8 +389,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb) phys_addr = lmb->base_addr;#ifdef CONFIG_FA_DUMP -/* Don't hot-remove memory that falls in fadump boot memory area */ -if (is_fadump_boot_memory_area (phys_addr, block_sz)) +/* +* Don't hot-remove memory that falls in fadump boot memory area +* and memory that is reserved for capturing old kernel memory. +*/ +if (is_fadump_memory_area (phys_addr, block_sz))return false;#endif
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 208/313 kvm: Change offset in kvm_write_guest_offset_cached to unsigned
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 7a86dab8cf2f0fdf508f3555dddfc236623bff60 ]
Since the offset is added directly to the hva from the gfn_to_hva_cache, a negative offset could result in an out of bounds write. The existing BUG_ON only checks for addresses beyond the end of the gfn_to_hva_cache, not for addresses before the start of the gfn_to_hva_cache.
Note that all current call sites have non-negative offsets.
--- include/linux/kvm_host.h | 3 ++- virt/kvm/kvm_main.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
include/linux/kvm_host.h +2 -1
@@ -694,7 +694,8 @@ int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,int kvm_write_guest_cached (struct kvm *kvm,struct gfn_to_hva_cache *ghc,void *data,unsigned long len);int kvm_write_guest_offset_cached (struct kvm *kvm,struct gfn_to_hva_cache *ghc, -void *data,int offset,unsigned long len); +void *data,unsigned int offset, +unsigned long len);int kvm_gfn_to_hva_cache_init (struct kvm *kvm,struct gfn_to_hva_cache *ghc,gpa_t gpa,unsigned long len);int kvm_clear_guest_page (struct kvm *kvm,gfn_t gfn,int offset,int len);
virt/kvm/kvm_main.c +2 -1
@@ -1959,7 +1959,8 @@ int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,EXPORT_SYMBOL_GPL (kvm_gfn_to_hva_cache_init);int kvm_write_guest_offset_cached (struct kvm *kvm,struct gfn_to_hva_cache *ghc, -void *data,int offset,unsigned long len) +void *data,unsigned int offset, +unsigned long len) {struct kvm_memslots *slots =kvm_memslots (kvm);int r;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 209/313 NFS: nfs_compare_mount_options always compare auth flavors.
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 594d1644cd59447f4fceb592448d5cd09eb09b5e ]
This patch removes the check from nfs_compare_mount_options to see if a `sec' option was passed for the current mount before comparing auth flavors and instead just always compares auth flavors.
Consider the following scenario:
You have a server with the address 192.168.1.1 and two exports /export/a and /export/b. The first export supports sys' and krb5' security, the second just `sys'.
Assume you start with no mounts from the server.
The following results in EIOs being returned as the kernel nfs client incorrectly thinks it can share the underlying `struct nfs_server's:
$ mkdir /tmp/{a,b}
$ sudo mount -t nfs -o vers=3,sec=krb5 192.168.1.1:/export/a /tmp/a
$ sudo mount -t nfs -o vers=3 192.168.1.1:/export/b /tmp/b
$ df >/dev/null
df: ‘/tmp/b’: Input/output error--- fs/nfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfs/super.c +1 -2
@@ -2409,8 +2409,7 @@ static int nfs_compare_mount_options(const struct super_block *s, const struct n goto Ebusy;if (a->acdirmax != b->acdirmax) goto Ebusy; -if (b->auth_info.flavor_len >0 && - clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor) +if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor) goto Ebusy;return 1 ; Ebusy:
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 210/313 perf build: Dont unconditionally link the libbfd feature test to -liberty and -lz
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 14541b1e7e723859ff2c75c6fc10cdbbec6b8c34 ]
Current libbfd feature test unconditionally links against -liberty and -lz. While it's required on some systems (e.g. opensuse), it's completely unnecessary on the others, where only -lbdf is sufficient (debian). This patch streamlines (and renames) the following feature checks:
feature-libbfd - only link against -lbfd (debian),
see commit 2cf9040714f3 ("perf tools: Fix bfd dependency libraries detection")
feature-libbfd-liberty - link against -lbfd and -liberty
feature-libbfd-liberty-z - link against -lbfd, -liberty and -lz (opensuse),
see commit 280e7c48c3b8 ("perf tools: fix BFD detection on opensuse")
(feature-liberty{,-z} were renamed to feature-libbfd-liberty{,z} for clarity)
The main motivation is to fix this feature test for bpftool which is currently broken on debian (libbfd feature shows OFF, but we still unconditionally link against -lbfd and it works).
Tested on debian with only -lbfd installed (without -liberty); I'd appreciate if somebody on the other systems can test this new detection method.
--- tools/build/Makefile.feature | 4 ++-- tools/build/feature/Makefile | 10 ++++---- tools/perf/Makefile.config | 44 +++++++++++++++++++----------------- 3 files changed, 30 insertions(+), 28 deletions(-)
tools/build/Makefile.feature +2 -2
@@ -79,8 +79,8 @@ FEATURE_TESTS_EXTRA := \ cplus-demangle \ hello \ libbabeltrace \ - liberty \ - liberty-z \ + libbfd-liberty \ + libbfd-liberty-z \ libunwind-debug-frame \ libunwind-debug-frame-arm \ libunwind-debug-frame-aarch64 \
tools/build/feature/Makefile +5 -5
@@ -15,8 +15,8 @@ FILES= \ test-libbfd.bin \ test-disassembler-four-args.bin \ test-reallocarray.bin \ - test-liberty.bin \ - test-liberty-z.bin \ + test-libbfd-liberty.bin \ + test-libbfd-liberty-z.bin \ test-cplus-demangle.bin \ test-libelf.bin \ test-libelf-getphdrnum.bin \
@@ -200,7 +200,7 @@ $(OUTPUT)test-libpython-version.bin: $(BUILD) $(OUTPUT)test-libbfd.bin: - $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl + $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl $(OUTPUT)test-disassembler-four-args.bin: $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
@@ -208,10 +208,10 @@ $(OUTPUT)test-disassembler-four-args.bin: $(OUTPUT)test-reallocarray.bin: $(BUILD) -$(OUTPUT)test-liberty.bin: +$(OUTPUT)test-libbfd-liberty.bin: $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -$(OUTPUT)test-liberty-z.bin: +$(OUTPUT)test-libbfd-liberty-z.bin: $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz $(OUTPUT)test-cplus-demangle.bin:
tools/perf/Makefile.config +23 -21
65 lines not on this page · raw message
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 211/313 hwmon: (lm80) fix a missing check of the status of SMBus read
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit c9c63915519b1def7043b184680f33c24cd49d7b ]
If lm80_read_value() fails, it returns a negative number instead of the correct read data. Therefore, we should avoid using the data if it fails.
The fix checks if lm80_read_value() fails, and if so, returns with the error number.
--- drivers/hwmon/lm80.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/hwmon/lm80.c +10 -5
@@ -360,9 +360,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,struct i2c_client *client = data->client;unsigned long min, val;u8 reg; -int err =kstrtoul (buf,10 , &val); -if (err <0 ) -return err; +int rv; + + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv;/* Save fan_min */ mutex_lock (&data->update_lock);
@@ -390,8 +392,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,return -EINVAL ; } - reg = (lm80_read_value (client,LM80_REG_FANDIV ) & - ~(3 << (2 * (nr +1 )))) | (data->fan_div[nr] << (2 * (nr +1 ))); + rv =lm80_read_value (client,LM80_REG_FANDIV ); +if (rv <0 ) +return rv; + reg = (rv & ~(3 << (2 * (nr +1 )))) + | (data->fan_div[nr] << (2 * (nr +1 )));lm80_write_value (client,LM80_REG_FANDIV , reg);/* Restore fan_min */
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 212/313 hwmon: (lm80) fix a missing check of bus read in lm80 probe
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 9aa3aa15f4c2f74f47afd6c5db4b420fadf3f315 ]
In lm80_probe(), if lm80_read_value() fails, it returns a negative error number which is stored to data->fan[f_min] and will be further used. We should avoid using the data if the read fails.
The fix checks if lm80_read_value() fails, and if so, returns with the error number.
--- drivers/hwmon/lm80.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/hwmon/lm80.c +9 -2
@@ -628,6 +628,7 @@ static int lm80_probe(struct i2c_client *client,struct device *dev = &client->dev;struct device *hwmon_dev;struct lm80_data *data; +int rv; data =devm_kzalloc (dev,sizeof (struct lm80_data ),GFP_KERNEL );if (!data)
@@ -640,8 +641,14 @@ static int lm80_probe(struct i2c_client *client,lm80_init_client (client);/* A few vars need to be filled upon startup */ - data->fan[f_min][0 ] =lm80_read_value (client,LM80_REG_FAN_MIN (1 )); - data->fan[f_min][1 ] =lm80_read_value (client,LM80_REG_FAN_MIN (2 )); + rv =lm80_read_value (client,LM80_REG_FAN_MIN (1 )); +if (rv <0 ) +return rv; + data->fan[f_min][0 ] = rv; + rv =lm80_read_value (client,LM80_REG_FAN_MIN (2 )); +if (rv <0 ) +return rv; + data->fan[f_min][1 ] = rv; hwmon_dev =devm_hwmon_device_register_with_groups (dev, client->name, data, lm80_groups);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 213/313 seq_buf: Make seq_buf_puts() null-terminate the buffer
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 0464ed24380905d640030d368cd84a4e4d1e15e2 ]
Currently seq_buf_puts() will happily create a non null-terminated string for you in the buffer. This is particularly dangerous if the buffer is on the stack.
For example:
char buf[8];
char secret = "secret";
struct seq_buf s;
seq_buf_init(&s, buf, sizeof(buf));
seq_buf_puts(&s, "foo");
printk("Message is %s\n", buf);Can result in:
Message is fooªªªªªsecret
We could require all users to memset() their buffer to zero before use. But that seems likely to be forgotten and lead to bugs.
Instead we can change seq_buf_puts() to always leave the buffer in a null-terminated state.
The only downside is that this makes the buffer 1 character smaller for seq_buf_puts(), but that seems like a good trade off.
--- lib/seq_buf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/seq_buf.c +5 -1
@@ -144,9 +144,13 @@ int seq_buf_puts(struct seq_buf *s, const char *str)WARN_ON (s->size ==0 ); +/* Add 1 to len for the trailing null byte which must be there */ + len +=1 ; +if (seq_buf_can_fit (s, len)) {memcpy (s->buffer + s->len, str, len); - s->len += len; +/* Don't count the trailing null byte against the capacity */ + s->len += len -1 ;return 0 ; }seq_buf_set_overflow (s);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 214/313 crypto: ux500 - Use proper enum in cryp_set_dma_transfer
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 9d880c5945c748d8edcac30965f3349a602158c4 ]
Clang warns when one enumerated type is implicitly converted to another:
drivers/crypto/ux500/cryp/cryp_core.c:559:5: warning: implicit conversion from enumeration type 'enum dma_data_direction' to different enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
direction, DMA_CTRL_ACK);
^~~~~~~~~
drivers/crypto/ux500/cryp/cryp_core.c:583:5: warning: implicit
conversion from enumeration type 'enum dma_data_direction' to different
enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
direction,
^~~~~~~~~2 warnings generated.
dmaengine_prep_slave_sg expects an enum from dma_transfer_direction. Because we know the value of the dma_data_direction enum from the switch statement, we can just use the proper value from dma_transfer_direction so there is no more conversion.
DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1DMA_FROM_DEVICE = DMA_DEV_TO_MEM = 2
--- drivers/crypto/ux500/cryp/cryp_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/ux500/cryp/cryp_core.c +2 -2
@@ -556,7 +556,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx, desc =dmaengine_prep_slave_sg (channel, ctx->device->dma.sg_src, ctx->device->dma.sg_src_len, - direction,DMA_CTRL_ACK ); +DMA_MEM_TO_DEV ,DMA_CTRL_ACK );break ;case DMA_FROM_DEVICE :
@@ -580,7 +580,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx, desc =dmaengine_prep_slave_sg (channel, ctx->device->dma.sg_dst, ctx->device->dma.sg_dst_len, - direction, +DMA_DEV_TO_MEM ,DMA_CTRL_ACK |DMA_PREP_INTERRUPT );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 215/313 crypto: ux500 - Use proper enum in hash_set_dma_transfer
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 5ac93f808338f4dd465402e91869702eb87db241 ]
Clang warns when one enumerated type is implicitly converted to another:
drivers/crypto/ux500/hash/hash_core.c:169:4: warning: implicit conversion from enumeration type 'enum dma_data_direction' to different enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
^~~~~~~~~1 warning generated.
dmaengine_prep_slave_sg expects an enum from dma_transfer_direction. We know that the only direction supported by this function is DMA_TO_DEVICE because of the check at the top of this function so we can just use the equivalent value from dma_transfer_direction.
DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1
--- drivers/crypto/ux500/hash/hash_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ux500/hash/hash_core.c +1 -1
@@ -166,7 +166,7 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg, __func__); desc =dmaengine_prep_slave_sg (channel, ctx->device->dma.sg, ctx->device->dma.sg_len, - direction,DMA_CTRL_ACK |DMA_PREP_INTERRUPT ); +DMA_MEM_TO_DEV ,DMA_CTRL_ACK |DMA_PREP_INTERRUPT );if (!desc) {dev_err (ctx->device->dev,"%s: dmaengine_prep_slave_sg() failed!\n" , __func__);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 216/313 MIPS: ralink: Select CONFIG_CPU_MIPSR2_IRQ_VI on MT7620/8
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 0b15394475e3bcaf35ca4bf22fc55d56df67224e ]
Testing has shown, that when using mainline U-Boot on MT7688 based boards, the system may hang or crash while mounting the root-fs. The main issue here is that mainline U-Boot configures EBase to a value near the end of system memory. And with CONFIG_CPU_MIPSR2_IRQ_VI disabled, trap_init() will not allocate a new area to place the exception handler. The original value will be used and the handler will be copied to this location, which might already be used by some userspace application.
The MT7688 supports VI - its config3 register is 0x00002420, so VInt (Bit 5) is set. But without setting CONFIG_CPU_MIPSR2_IRQ_VI this bit will not be evaluated to result in "cpu_has_vi" being set. This patch now selects CONFIG_CPU_MIPSR2_IRQ_VI on MT7620/8 which results trap_init() to allocate some memory for the exception handler.
Please note that this issue was not seen with the Mediatek U-Boot version, as it does not touch EBase (stays at default of 0x8000.0000). This is strictly also not correct as the kernel (_text) resides here.
--- arch/mips/ralink/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/ralink/Kconfig +1 -0
@@ -38,6 +38,7 @@ choice config SOC_MT7620 bool "MT7620/8" + select CPU_MIPSR2_IRQ_VI select HW_HAS_PCI config SOC_MT7621
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 217/313 cifs: check ntwrk_buf_start for NULL before dereferencing it
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 59a63e479ce36a3f24444c3a36efe82b78e4a8e0 ]
RHBZ: 1021460
There is an issue where when multiple threads open/close the same directory ntwrk_buf_start might end up being NULL, causing the call to smbCalcSize later to oops with a NULL deref.
The real bug is why this happens and why this can become NULL for an open cfile, which should not be allowed.
This patch tries to avoid a oops until the time when we fix the underlying issue.
--- fs/cifs/readdir.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/cifs/readdir.c +8 -1
@@ -655,7 +655,14 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,/* scan and find it */ int i;char *cur_ent; -char *end_of_smb = cfile->srch_inf.ntwrk_buf_start + +char *end_of_smb; + +if (cfile->srch_inf.ntwrk_buf_start ==NULL ) { +cifs_dbg (VFS ,"ntwrk_buf_start is NULL during readdir\n" ); +return -EIO ; + } + + end_of_smb = cfile->srch_inf.ntwrk_buf_start + server->ops->calc_smb_size ( cfile->srch_inf.ntwrk_buf_start, server);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 218/313 f2fs: fix use-after-free issue when accessing sbi->stat_info
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 60aa4d5536ab7fe32433ca1173bd9d6633851f27 ]
iput() on sbi->node_inode can update sbi->stat_info in the below context, if the f2fs_write_checkpoint() has failed with error.
f2fs_balance_fs_bg+0x1ac/0x1ec f2fs_write_node_pages+0x4c/0x260 do_writepages+0x80/0xbc __writeback_single_inode+0xdc/0x4ac writeback_single_inode+0x9c/0x144 write_inode_now+0xc4/0xec iput+0x194/0x22c f2fs_put_super+0x11c/0x1e8 generic_shutdown_super+0x70/0xf4 kill_block_super+0x2c/0x5c kill_f2fs_super+0x44/0x50 deactivate_locked_super+0x60/0x8c deactivate_super+0x68/0x74 cleanup_mnt+0x40/0x78
Fix this by moving f2fs_destroy_stats() further below iput() in both f2fs_put_super() and f2fs_fill_super() paths.
--- fs/f2fs/super.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
fs/f2fs/super.c +15 -12
@@ -1039,9 +1039,6 @@ static void f2fs_put_super(struct super_block *sb)f2fs_write_checkpoint (sbi, &cpc); } -/* f2fs_write_checkpoint can update stat informaion */ -f2fs_destroy_stats (sbi); -/* * normally superblock is clean, so we need to release this. * In addition, EIO will skip do checkpoint, we need this as well.
@@ -1061,6 +1058,12 @@ static void f2fs_put_super(struct super_block *sb)iput (sbi->node_inode);iput (sbi->meta_inode); +/* +* iput() can update stat information, if f2fs_write_checkpoint() +* above failed with error. +*/ +f2fs_destroy_stats (sbi); +/* destroy f2fs internal modules */ f2fs_destroy_node_manager (sbi);f2fs_destroy_segment_manager (sbi);
@@ -2980,30 +2983,30 @@ try_onemore:f2fs_build_gc_manager (sbi); + err =f2fs_build_stats (sbi); +if (err) + goto free_nm; +/* get an inode for node space */ sbi->node_inode =f2fs_iget (sb,F2FS_NODE_INO (sbi));if (IS_ERR (sbi->node_inode)) {f2fs_msg (sb,KERN_ERR ,"Failed to read node inode" ); err =PTR_ERR (sbi->node_inode); - goto free_nm; + goto free_stats; } - err =f2fs_build_stats (sbi); -if (err) - goto free_node_inode; -/* read root inode and dentry */ root =f2fs_iget (sb,F2FS_ROOT_INO (sbi));if (IS_ERR (root)) {f2fs_msg (sb,KERN_ERR ,"Failed to read root inode" ); err =PTR_ERR (root); - goto free_stats; + goto free_node_inode; }if (!S_ISDIR (root->i_mode) || !root->i_blocks || !root->i_size || !root->i_nlink) {iput (root); err = -EINVAL ; - goto free_stats; + goto free_node_inode; } sb->s_root =d_make_root (root);/* allocate root dentry */
@@ -3121,12 +3124,12 @@ free_sysfs: free_root_inode:dput (sb->s_root); sb->s_root =NULL ; -free_stats: -f2fs_destroy_stats (sbi); free_node_inode:f2fs_release_ino_entry (sbi, true);truncate_inode_pages_final (NODE_MAPPING (sbi));iput (sbi->node_inode); +free_stats: +f2fs_destroy_stats (sbi); free_nm:f2fs_destroy_node_manager (sbi); free_sm:
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 219/313 um: Avoid marking pages with "changed protection"
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 8892d8545f2d0342b9c550defbfb165db237044b ]
Changing protection is a very high cost operation in UML because in addition to an extra syscall it also interrupts mmap merge sequences generated by the tlb.
While the condition is not particularly common it is worth avoiding.
--- arch/um/include/asm/pgtable.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/um/include/asm/pgtable.h +8 -1
@@ -197,12 +197,17 @@ static inline pte_t pte_mkold(pte_t pte)static inline pte_t pte_wrprotect (pte_t pte) { -pte_clear_bits (pte, _PAGE_RW); +if (likely (pte_get_bits (pte, _PAGE_RW))) +pte_clear_bits (pte, _PAGE_RW); +else +return pte;return (pte_mknewprot (pte)); }static inline pte_t pte_mkread (pte_t pte) { +if (unlikely (pte_get_bits (pte, _PAGE_USER))) +return pte;pte_set_bits (pte, _PAGE_USER);return (pte_mknewprot (pte)); }
@@ -221,6 +226,8 @@ static inline pte_t pte_mkyoung(pte_t pte)static inline pte_t pte_mkwrite (pte_t pte) { +if (unlikely (pte_get_bits (pte, _PAGE_RW))) +return pte;pte_set_bits (pte, _PAGE_RW);return (pte_mknewprot (pte)); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 220/313 niu: fix missing checks of niu_pci_eeprom_read
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 26fd962bde0b15e54234fe762d86bc0349df1de4 ]
niu_pci_eeprom_read() may fail, so we should check its return value before using the read data.
--- drivers/net/ethernet/sun/niu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/sun/niu.c +8 -2
@@ -8100,6 +8100,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end) start +=3 ; prop_len =niu_pci_eeprom_read (np, start +4 ); +if (prop_len <0 ) +return prop_len; err =niu_pci_vpd_get_propname (np, start +5 , namebuf,64 );if (err <0 )return err;
@@ -8144,8 +8146,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)netif_printk (np, probe,KERN_DEBUG , np->dev,"VPD_SCAN: Reading in property [%s] len[%d]\n" , namebuf, prop_len); -for (i =0 ; i < prop_len; i++) - *prop_buf++ =niu_pci_eeprom_read (np, off + i); +for (i =0 ; i < prop_len; i++) { + err =niu_pci_eeprom_read (np, off + i); +if (err >=0 ) + *prop_buf = err; + ++prop_buf; + } } start += len;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 221/313 f2fs: fix sbi->extent_list corruption issue
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit e4589fa545e0020dbbc3c9bde35f35f949901392 ]
When there is a failure in f2fs_fill_super() after/during the recovery of fsync'd nodes, it frees the current sbi and retries again. This time the mount is successful, but the files that got recovered before retry, still holds the extent tree, whose extent nodes list is corrupted since sbi and sbi->extent_list is freed up. The list_del corruption issue is observed when the file system is getting unmounted and when those recoverd files extent node is being freed up in the below context.
list_del corruption. prev->next should be fffffff1e1ef5480, but was (null) <...>
kernel BUG at kernel/msm-4.14/lib/list_debug.c:53!
lr : __list_del_entry_valid+0x94/0xb4 pc : __list_del_entry_valid+0x94/0xb4 <...> Call trace: __list_del_entry_valid+0x94/0xb4 __release_extent_node+0xb0/0x114 __free_extent_tree+0x58/0x7c f2fs_shrink_extent_tree+0xdc/0x3b0 f2fs_leave_shrinker+0x28/0x7c f2fs_put_super+0xfc/0x1e0 generic_shutdown_super+0x70/0xf4 kill_block_super+0x2c/0x5c kill_f2fs_super+0x44/0x50 deactivate_locked_super+0x60/0x8c deactivate_super+0x68/0x74 cleanup_mnt+0x40/0x78 __cleanup_mnt+0x1c/0x28 task_work_run+0x48/0xd0 do_notify_resume+0x678/0xe98 work_pending+0x8/0x14
Fix this by not creating extents for those recovered files if shrinker is not registered yet. Once mount is successful and shrinker is registered, those files can have extents again.
--- fs/f2fs/f2fs.h | 11 ++++++++++- fs/f2fs/shrinker.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-)
fs/f2fs/f2fs.h +10 -1
@@ -2614,10 +2614,19 @@ static inline bool is_dot_dotdot(const struct qstr *str)static inline bool f2fs_may_extent_tree (struct inode *inode) { -if (!test_opt (F2FS_I_SB (inode),EXTENT_CACHE ) || +struct f2fs_sb_info *sbi =F2FS_I_SB (inode); + +if (!test_opt (sbi,EXTENT_CACHE ) ||is_inode_flag_set (inode,FI_NO_EXTENT ))return false; +/* +* for recovered files during mount do not create extents +* if shrinker is not registered. +*/ +if (list_empty (&sbi->s_list)) +return false; +return S_ISREG (inode->i_mode); }
fs/f2fs/shrinker.c +1 -1
@@ -138,6 +138,6 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi)f2fs_shrink_extent_tree (sbi,__count_extent_cache (sbi));spin_lock (&f2fs_list_lock); -list_del (&sbi->s_list); +list_del_init (&sbi->s_list);spin_unlock (&f2fs_list_lock); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 222/313 cgroup: fix parsing empty mount option string
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit e250d91d65750a0c0c62483ac4f9f357e7317617 ]
This fixes the case where all mount options specified are consumed by an LSM and all that's left is an empty string. In this case cgroupfs should accept the string and not fail.
How to reproduce (with SELinux enabled):
# umount /sys/fs/cgroup/unified
# mount -o context=system_u:object_r:cgroup_t:s0 -t cgroup2 cgroup2 /sys/fs/cgroup/unified
mount: /sys/fs/cgroup/unified: wrong fs type, bad option, bad superblock on cgroup2, missing codepage or helper program, or other error.
# dmesg | tail -n 1
[ 31.575952] cgroup: cgroup2: unknown option ""--- kernel/cgroup/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cgroup.c +1 -1
@@ -1743,7 +1743,7 @@ static int parse_cgroup_root_flags(char *data, unsigned int *root_flags) *root_flags =0 ; -if (!data) +if (!data || *data =='\0' )return 0 ;while ((token =strsep (&data,"," )) !=NULL ) {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 223/313 perf python: Do not force closing original perf descriptor in evlist.get_pollfd()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit a389aece97938966616ce0336466b98b0351ef10 ]
Ondřej reported that when compiled with python3, the python extension regresses in evlist.get_pollfd function behaviour.
The evlist.get_pollfd function creates file objects from evlist's fds and returns them in a list. The python3 version also sets them to 'close the original descriptor' when the object dies (is closed), by passing True via the 'closefd' arg in the PyFile_FromFd call.
The python's closefd doc says:
If closefd is False, the underlying file descriptor will be kept open when the file is closed.
That's why the following line in python3 closes all evlist fds:
evlist.get_pollfd()
the returned list is immediately destroyed and that takes down the original events fds.
Passing closefd as False to PyFile_FromFd to fix this.
--- tools/perf/util/python.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/python.c +2 -1
@@ -939,7 +939,8 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist, file =PyFile_FromFile (fp,"perf" ,"r" ,NULL );#else - file =PyFile_FromFd (evlist->pollfd.entries[i].fd,"perf" ,"r" ,-1 ,NULL ,NULL ,NULL ,1 ); + file =PyFile_FromFd (evlist->pollfd.entries[i].fd,"perf" ,"r" ,-1 , +NULL ,NULL ,NULL ,0 );#endif if (file ==NULL ) goto free_list;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 224/313 scripts/decode_stacktrace: only strip base path when a prefix of the path
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 67a28de47faa83585dd644bd4c31e5a1d9346c50 ]
Running something like:
decodecode vmlinux .
leads to interested results where not only the leading "." gets stripped from the displayed paths, but also anywhere in the string, displaying something like:
kvm_vcpu_check_block (arch/arm64/kvm/virt/kvm/kvm_mainc:2141)
which doesn't help further processing.
Fix it by only stripping the base path if it is a prefix of the path.
--- scripts/decode_stacktrace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/decode_stacktrace.sh +1 -1
@@ -78,7 +78,7 @@ parse_symbol() { fi # Strip out the base of the path - code=${code//$basepath/""} + code=${code//^$basepath/""} # In the case of inlines, move everything to same line code=${code//$'\n'/' '}
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 225/313 arch/sh/boards/mach-kfr2r09/setup.c: fix struct mtd_oob_ops build warning
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 440e7b379f91acd245d5c8de94d533f40f5dffb3 ]
arch/sh/boards/mach-kfr2r09/setup.c does not need to #include <mtd/onenand.h>, and doing so causes a build warning, so drop that header file.
In file included from ../arch/sh/boards/mach-kfr2r09/setup.c:28:../include/linux/mtd/onenand.h:225:12: warning: 'struct mtd_oob_ops' declared inside parameter list will not be visible outside of this definition or declaration
struct mtd_oob_ops *ops);
--- arch/sh/boards/mach-kfr2r09/setup.c | 1 - 1 file changed, 1 deletion(-)
arch/sh/boards/mach-kfr2r09/setup.c +0 -1
@@ -25,7 +25,6 @@#include <linux/memblock.h> #include <linux/mfd/tmio.h> #include <linux/mmc/host.h> -#include <linux/mtd/onenand.h> #include <linux/mtd/physmap.h> #include <linux/platform_data/lv5207lp.h> #include <linux/platform_device.h>
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 226/313 ocfs2: dont clear bh uptodate for block read
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 70306d9dce75abde855cefaf32b3f71eed8602a3 ]
For sync io read in ocfs2_read_blocks_sync(), first clear bh uptodate flag and submit the io, second wait io done, last check whether bh uptodate, if not return io error.
If two sync io for the same bh were issued, it could be the first io done and set uptodate flag, but just before check that flag, the second io came in and cleared uptodate, then ocfs2_read_blocks_sync() for the first io will return IO error.
Indeed it's not necessary to clear uptodate flag, as the io end handler end_buffer_read_sync() will set or clear it based on io succeed or failed.
The following message was found from a nfs server but the underlying storage returned no error.
[4106438.567376] (nfsd,7146,3):ocfs2_get_suballoc_slot_bit:2780 ERROR: read block 1238823695 failed -5 [4106438.567569] (nfsd,7146,3):ocfs2_get_suballoc_slot_bit:2812 ERROR: status = -5 [4106438.567611] (nfsd,7146,3):ocfs2_test_inode_bit:2894 ERROR: get alloc slot and bit failed -5 [4106438.567643] (nfsd,7146,3):ocfs2_test_inode_bit:2932 ERROR: status = -5 [4106438.567675] (nfsd,7146,3):ocfs2_get_dentry:94 ERROR: test inode bit failed -5
Same issue in non sync read ocfs2_read_blocks(), fixed it as well.
--- fs/ocfs2/buffer_head_io.c | 2 -- 1 file changed, 2 deletions(-)
fs/ocfs2/buffer_head_io.c +0 -2
@@ -152,7 +152,6 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,#endif } -clear_buffer_uptodate (bh);get_bh (bh);/* for end_buffer_read_sync() */ bh->b_end_io = end_buffer_read_sync;submit_bh (REQ_OP_READ ,0 , bh);
@@ -306,7 +305,6 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,continue ; } -clear_buffer_uptodate (bh);get_bh (bh);/* for end_buffer_read_sync() */ if (validate)set_buffer_needs_validate (bh);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 227/313 ocfs2: improve ocfs2 Makefile
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 9e6aea22802b5684c7e1d69822aeb0844dd01953 ]
Included file path was hard-wired in the ocfs2 makefile, which might causes some confusion when compiling ocfs2 as an external module.
Say if we compile ocfs2 module as following.
cp -r /kernel/tree/fs/ocfs2 /other/dir/ocfs2
cd /other/dir/ocfs2
make -C /path/to/kernel_source M=pwd modules
Acutally, the compiler wil try to find included file in /kernel/tree/fs/ocfs2, rather than the directory /other/dir/ocfs2.
To fix this little bug, we introduce the var $(src) provided by kbuild. $(src) means the absolute path of the running kbuild file.
--- fs/ocfs2/Makefile | 2 +- fs/ocfs2/dlm/Makefile | 2 +- fs/ocfs2/dlmfs/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
fs/ocfs2/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -Ifs/ocfs2 +ccflags-y := -I$(src) obj-$(CONFIG_OCFS2_FS) += \ ocfs2.o \
fs/ocfs2/dlm/Makefile +1 -1
@@ -1,4 +1,4 @@ -ccflags-y := -Ifs/ocfs2 +ccflags-y := -I$(src)/.. obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o
fs/ocfs2/dlmfs/Makefile +1 -1
@@ -1,4 +1,4 @@ -ccflags-y := -Ifs/ocfs2 +ccflags-y := -I$(src)/.. obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 228/313 mm/page_alloc.c: dont call kasan_free_pages() at deferred mem init
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 3c0c12cc8f00ca5f81acb010023b8eb13e9a7004 ]
When CONFIG_KASAN is enabled on large memory SMP systems, the deferrred pages initialization can take a long time. Below were the reported init times on a 8-socket 96-core 4TB IvyBridge system.
1) Non-debug kernel without CONFIG_KASAN
[ 8.764222] node 1 initialised, 132086516 pages in 7027ms
2) Debug kernel with CONFIG_KASAN
[ 146.288115] node 1 initialised, 132075466 pages in 143052ms
So the page init time in a debug kernel was 20X of the non-debug kernel. The long init time can be problematic as the page initialization is done with interrupt disabled. In this particular case, it caused the appearance of following warning messages as well as NMI backtraces of all the cores that were doing the initialization.
[ 68.240049] rcu: INFO: rcu_sched detected stalls on CPUs/tasks: [ 68.241000] rcu: 25-...0: (100 ticks this GP) idle=b72/1/0x4000000000000000 softirq=915/915 fqs=16252 [ 68.241000] rcu: 44-...0: (95 ticks this GP) idle=49a/1/0x4000000000000000 softirq=788/788 fqs=16253 [ 68.241000] rcu: 54-...0: (104 ticks this GP) idle=03a/1/0x4000000000000000 softirq=721/825 fqs=16253 [ 68.241000] rcu: 60-...0: (103 ticks this GP) idle=cbe/1/0x4000000000000000 softirq=637/740 fqs=16253 [ 68.241000] rcu: 72-...0: (105 ticks this GP) idle=786/1/0x4000000000000000 softirq=536/641 fqs=16253 [ 68.241000] rcu: 84-...0: (99 ticks this GP) idle=292/1/0x4000000000000000 softirq=537/537 fqs=16253 [ 68.241000] rcu: 111-...0: (104 ticks this GP) idle=bde/1/0x4000000000000000 softirq=474/476 fqs=16253 [ 68.241000] rcu: (detected by 13, t=65018 jiffies, g=249, q=2)
The long init time was mainly caused by the call to kasan_free_pages() to poison the newly initialized pages. On a 4TB system, we are talking about almost 500GB of memory probably on the same node.
In reality, we may not need to poison the newly initialized pages before they are ever allocated. So KASAN poisoning of freed pages before the completion of deferred memory initialization is now disabled. Those pages will be properly poisoned when they are allocated or freed after deferred pages initialization is done.
With this change, the new page initialization time became:
[ 21.948010] node 1 initialised, 132075466 pages in 18702ms
This was still about double the non-debug kernel time, but was much better than before.
--- mm/page_alloc.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
mm/page_alloc.c +29 -8
@@ -294,6 +294,32 @@ EXPORT_SYMBOL(nr_online_nodes);int page_group_by_mobility_disabled__read_mostly ;#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT +/* +* During boot we initialize deferred pages on-demand, as needed, but once +* page_alloc_init_late() has finished, the deferred pages are all initialized, +* and we can permanently disable that path. +*/ +static DEFINE_STATIC_KEY_TRUE (deferred_pages); + +/* +* Calling kasan_free_pages() only after deferred memory initialization +* has completed. Poisoning pages during deferred memory init will greatly +* lengthen the process and cause problem in large memory systems as the +* deferred pages initialization is done with interrupt disabled. +* +* Assuming that there will be no reference to those newly initialized +* pages before they are ever allocated, this should have no effect on +* KASAN memory tracking as the poison will be properly inserted at page +* allocation time. The only corner case is when pages are allocated by +* on-demand allocation and then freed again before the deferred pages +* initialization is done, but this is not likely to happen. +*/ +static inline void kasan_free_nondeferred_pages (struct page *page,int order) +{ +if (!static_branch_unlikely (&deferred_pages)) +kasan_free_pages (page, order); +} +/* Returns true if the struct page for the pfn is uninitialised */ static inline bool __meminit early_page_uninitialised (unsigned long pfn) {
@@ -326,6 +352,8 @@ static inline bool update_defer_init(pg_data_t *pgdat, return true; }#else +#define kasan_free_nondeferred_pages (p, o) kasan_free_pages(p, o) +static inline bool early_page_uninitialised (unsigned long pfn) {return false;
@@ -1030,7 +1058,7 @@ static __always_inline bool free_pages_prepare(struct page *page,arch_free_page (page, order);kernel_poison_pages (page,1 << order,0 );kernel_map_pages (page,1 << order,0 ); -kasan_free_pages (page, order); +kasan_free_nondeferred_pages (page, order);return true; }
@@ -1593,13 +1621,6 @@ static int __init deferred_init_memmap(void *data)return 0 ; } -/* -* During boot we initialize deferred pages on-demand, as needed, but once -* page_alloc_init_late() has finished, the deferred pages are all initialized, -* and we can permanently disable that path. -*/ -static DEFINE_STATIC_KEY_TRUE (deferred_pages); -/* * If this zone has deferred pages, try to grow it by initializing enough * deferred pages to satisfy the allocation specified by order, rounded up to
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 229/313 zram: fix lockdep warning of free block handling
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 3c9959e025472122a61faebb208525cf26b305d1 ]
Patch series "zram idle page writeback", v3.
Inherently, swap device has many idle pages which are rare touched since it was allocated. It is never problem if we use storage device as swap. However, it's just waste for zram-swap.
This patchset supports zram idle page writeback feature.
* Admin can define what is idle page "no access since X time ago"
* Admin can define when zram should writeback them
* Admin can define when zram should stop writeback to prevent wearout
Details are in each patch's description.
This patch (of 7):
================================
WARNING: inconsistent lock state
4.19.0+ #390 Not tainted
--------------------------------
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
zram_verify/2095 [HC0[0]:SC1[1]:HE1:SE0] takes:
00000000b1828693 (&(&zram->bitmap_lock)->rlock){+.?.}, at: put_entry_bdev+0x1e/0x50 {SOFTIRQ-ON-W} state was registered at:
_raw_spin_lock+0x2c/0x40
zram_make_request+0x755/0xdc9
generic_make_request+0x373/0x6a0
submit_bio+0x6c/0x140
__swap_writepage+0x3a8/0x480
shrink_page_list+0x1102/0x1a60
shrink_inactive_list+0x21b/0x3f0
shrink_node_memcg.constprop.99+0x4f8/0x7e0
shrink_node+0x7d/0x2f0
do_try_to_free_pages+0xe0/0x300
try_to_free_pages+0x116/0x2b0
__alloc_pages_slowpath+0x3f4/0xf80
__alloc_pages_nodemask+0x2a2/0x2f0
__handle_mm_fault+0x42e/0xb50
handle_mm_fault+0x55/0xb0
__do_page_fault+0x235/0x4b0
page_fault+0x1e/0x30
irq event stamp: 228412
hardirqs last enabled at (228412): [<ffffffff98245846>] __slab_free+0x3e6/0x600
hardirqs last disabled at (228411): [<ffffffff98245625>] __slab_free+0x1c5/0x600
softirqs last enabled at (228396): [<ffffffff98e0031e>] __do_softirq+0x31e/0x427
softirqs last disabled at (228403): [<ffffffff98072051>] irq_exit+0xd1/0xe0other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&(&zram->bitmap_lock)->rlock);
<Interrupt>
lock(&(&zram->bitmap_lock)->rlock);*** DEADLOCK ***
no locks held by zram_verify/2095.
stack backtrace: CPU: 5 PID: 2095 Comm: zram_verify Not tainted 4.19.0+ #390 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 Call Trace: <IRQ> dump_stack+0x67/0x9b print_usage_bug+0x1bd/0x1d3 mark_lock+0x4aa/0x540 __lock_acquire+0x51d/0x1300 lock_acquire+0x90/0x180 _raw_spin_lock+0x2c/0x40 put_entry_bdev+0x1e/0x50 zram_free_page+0xf6/0x110 zram_slot_free_notify+0x42/0xa0 end_swap_bio_read+0x5b/0x170 blk_update_request+0x8f/0x340 scsi_end_request+0x2c/0x1e0 scsi_io_completion+0x98/0x650 blk_done_softirq+0x9e/0xd0 __do_softirq+0xcc/0x427 irq_exit+0xd1/0xe0 do_IRQ+0x93/0x120 common_interrupt+0xf/0xf </IRQ>
With writeback feature, zram_slot_free_notify could be called in softirq context by end_swap_bio_read. However, bitmap_lock is not aware of that so lockdep yell out:
get_entry_bdev spin_lock(bitmap->lock); irq softirq end_swap_bio_read zram_slot_free_notify zram_slot_lock <-- deadlock prone zram_free_page put_entry_bdev spin_lock(bitmap->lock); <-- deadlock prone
With akpm's suggestion (i.e. bitmap operation is already atomic), we could remove bitmap lock. It might fail to find a empty slot if serious contention happens. However, it's not severe problem because huge page writeback has already possiblity to fail if there is severe memory pressure. Worst case is just keeping the incompressible in memory, not storage.
The other problem is zram_slot_lock in zram_slot_slot_free_notify. To make it safe is this patch introduces zram_slot_trylock where zram_slot_free_notify uses it. Although it's rare to be contented, this patch adds new debug stat "miss_free" to keep monitoring how often it happens.
--- drivers/block/zram/zram_drv.c | 38 +++++++++++++++++++---------------- drivers/block/zram/zram_drv.h | 2 +- 2 files changed, 22 insertions(+), 18 deletions(-)
drivers/block/zram/zram_drv.c +21 -17
@@ -53,6 +53,11 @@ static size_t huge_class_size;static void zram_free_page (struct zram *zram,size_t index); +static int zram_slot_trylock (struct zram *zram,u32 index) +{ +return bit_spin_trylock (ZRAM_LOCK , &zram->table[index].value); +} +static void zram_slot_lock (struct zram *zram,u32 index) {bit_spin_lock (ZRAM_LOCK , &zram->table[index].value);
@@ -401,7 +406,6 @@ static ssize_t backing_dev_store(struct device *dev, goto out;reset_bdev (zram); -spin_lock_init (&zram->bitmap_lock); zram->old_block_size = old_block_size; zram->bdev = bdev;
@@ -445,29 +449,24 @@ out:static unsigned long get_entry_bdev (struct zram *zram) { -unsigned long entry; - -spin_lock (&zram->bitmap_lock); +unsigned long blk_idx =1 ; +retry:/* skip 0 bit to confuse zram.handle = 0 */ - entry =find_next_zero_bit (zram->bitmap, zram->nr_pages,1 ); -if (entry == zram->nr_pages) { -spin_unlock (&zram->bitmap_lock); + blk_idx =find_next_zero_bit (zram->bitmap, zram->nr_pages, blk_idx); +if (blk_idx == zram->nr_pages)return 0 ; - } -set_bit (entry, zram->bitmap); -spin_unlock (&zram->bitmap_lock); +if (test_and_set_bit (blk_idx, zram->bitmap)) + goto retry; -return entry; +return blk_idx; }static void put_entry_bdev (struct zram *zram,unsigned long entry) {int was_set; -spin_lock (&zram->bitmap_lock); was_set =test_and_clear_bit (entry, zram->bitmap); -spin_unlock (&zram->bitmap_lock);WARN_ON_ONCE (!was_set); }
@@ -888,9 +887,10 @@ static ssize_t debug_stat_show(struct device *dev,down_read (&zram->init_lock); ret =scnprintf (buf,PAGE_SIZE , -"version: %d\n%8llu\n" , +"version: %d\n%8llu %8llu\n" , version, - (u64 )atomic64_read (&zram->stats.writestall)); + (u64 )atomic64_read (&zram->stats.writestall), + (u64 )atomic64_read (&zram->stats.miss_free));up_read (&zram->init_lock);return ret;
@@ -1402,10 +1402,14 @@ static void zram_slot_free_notify(struct block_device *bdev, zram = bdev->bd_disk->private_data; -zram_slot_lock (zram, index); +atomic64_inc (&zram->stats.notify_free); +if (!zram_slot_trylock (zram, index)) { +atomic64_inc (&zram->stats.miss_free); +return ; + } +zram_free_page (zram, index);zram_slot_unlock (zram, index); -atomic64_inc (&zram->stats.notify_free); } static int zram_rw_page(struct block_device *bdev, sector_t sector,
drivers/block/zram/zram_drv.h +1 -1
@@ -79,6 +79,7 @@ struct zram_stats {atomic64_t pages_stored;/* no. of pages currently stored */ atomic_long_t max_used_pages;/* no. of maximum pages stored */ atomic64_t writestall;/* no. of write slow paths */ +atomic64_t miss_free;/* no. of missed free */ };struct zram {
@@ -110,7 +111,6 @@ struct zram {unsigned int old_block_size;unsigned long *bitmap;unsigned long nr_pages; -spinlock_t bitmap_lock;#endif #ifdef CONFIG_ZRAM_MEMORY_TRACKING struct dentry *debugfs_dir;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 230/313 isdn: hisax: hfc_pci: Fix a possible concurrency use-after-free bug in HFCPCI_l1hw()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 7418e6520f22a2e35815122fa5a53d5bbfa2c10f ]
In drivers/isdn/hisax/hfc_pci.c, the functions hfcpci_interrupt() and HFCPCI_l1hw() may be concurrently executed.
HFCPCI_l1hw()
line 1173: if (!cs->tx_skb)
hfcpci_interrupt()
line 942: spin_lock_irqsave();
line 1066: dev_kfree_skb_irq(cs->tx_skb);
Thus, a possible concurrency use-after-free bug may occur in HFCPCI_l1hw().
To fix these bugs, the calls to spin_lock_irqsave() and spin_unlock_irqrestore() are added in HFCPCI_l1hw(), to protect the access to cs->tx_skb.
--- drivers/isdn/hisax/hfc_pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/isdn/hisax/hfc_pci.c +2 -0
@@ -1170,11 +1170,13 @@ HFCPCI_l1hw(struct PStack *st, int pr, void *arg)if (cs->debug &L1_DEB_LAPD )debugl1 (cs,"-> PH_REQUEST_PULL" );#endif +spin_lock_irqsave (&cs->lock, flags);if (!cs->tx_skb) {test_and_clear_bit (FLG_L1_PULL_REQ , &st->l1.Flags); st->l1.l1l2 (st,PH_PULL |CONFIRM ,NULL ); }else test_and_set_bit (FLG_L1_PULL_REQ , &st->l1.Flags); +spin_unlock_irqrestore (&cs->lock, flags);break ;case (HW_RESET |REQUEST ):spin_lock_irqsave (&cs->lock, flags);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 231/313 gdrom: fix a memory leak bug
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 093c48213ee37c3c3ff1cf5ac1aa2a9d8bc66017 ]
In probe_gdrom(), the buffer pointed by 'gd.cd_info' is allocated through kzalloc() and is used to hold the information of the gdrom device. To register and unregister the device, the pointer 'gd.cd_info' is passed to the functions register_cdrom() and unregister_cdrom(), respectively. However, this buffer is not freed after it is used, which can cause a memory leak bug.
This patch simply frees the buffer 'gd.cd_info' in exit_gdrom() to fix the above issue.
--- drivers/cdrom/gdrom.c | 1 + 1 file changed, 1 insertion(+)
drivers/cdrom/gdrom.c +1 -0
@@ -889,6 +889,7 @@ static void __exit exit_gdrom(void)platform_device_unregister (pd);platform_driver_unregister (&gdrom_driver);kfree (gd.toc); +kfree (gd.cd_info); }module_init (init_gdrom);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 232/313 fsl/fman: Use GFP_ATOMIC in {memac,tgec}_add_hash_mac_address()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 0d9c9a238faf925823bde866182c663b6d734f2e ]
These functions are called from atomic context:
[ 9.150239] BUG: sleeping function called from invalid context at /home/scott/git/linux/mm/slab.h:421 [ 9.158159] in_atomic(): 1, irqs_disabled(): 0, pid: 4432, name: ip [ 9.163128] CPU: 8 PID: 4432 Comm: ip Not tainted 4.20.0-rc2-00169-g63d86876f324 #29 [ 9.163130] Call Trace: [ 9.170701] [c0000002e899a980] [c0000000009c1068] .dump_stack+0xa8/0xec (unreliable) [ 9.177140] [c0000002e899aa10] [c00000000007a7b4] .___might_sleep+0x138/0x164 [ 9.184440] [c0000002e899aa80] [c0000000001d5bac] .kmem_cache_alloc_trace+0x238/0x30c [ 9.191216] [c0000002e899ab40] [c00000000065ea1c] .memac_add_hash_mac_address+0x104/0x198 [ 9.199464] [c0000002e899abd0] [c00000000065a788] .set_multi+0x1c8/0x218 [ 9.206242] [c0000002e899ac80] [c0000000006615ec] .dpaa_set_rx_mode+0xdc/0x17c [ 9.213544] [c0000002e899ad00] [c00000000083d2b0] .__dev_set_rx_mode+0x80/0xd4 [ 9.219535] [c0000002e899ad90] [c00000000083d334] .dev_set_rx_mode+0x30/0x54 [ 9.225271] [c0000002e899ae10] [c00000000083d4a0] .__dev_open+0x148/0x1c8 [ 9.230751] [c0000002e899aeb0] [c00000000083d934] .__dev_change_flags+0x19c/0x1e0 [ 9.230755] [c0000002e899af60] [c00000000083d9a4] .dev_change_flags+0x2c/0x80 [ 9.242752] [c0000002e899aff0] [c0000000008554ec] .do_setlink+0x350/0xf08 [ 9.248228] [c0000002e899b170] [c000000000857ad0] .rtnl_newlink+0x588/0x7e0 [ 9.253965] [c0000002e899b740] [c000000000852424] .rtnetlink_rcv_msg+0x3e0/0x498 [ 9.261440] [c0000002e899b820] [c000000000884790] .netlink_rcv_skb+0x134/0x14c [ 9.267607] [c0000002e899b8e0] [c000000000851840] .rtnetlink_rcv+0x18/0x2c [ 9.274558] [c0000002e899b950] [c000000000883c8c] .netlink_unicast+0x214/0x318 [ 9.281163] [c0000002e899ba00] [c000000000884220] .netlink_sendmsg+0x348/0x444 [ 9.287076] [c0000002e899bae0] [c00000000080d13c] .sock_sendmsg+0x2c/0x54 [ 9.287080] [c0000002e899bb50] [c0000000008106c0] .___sys_sendmsg+0x2d0/0x2d8 [ 9.298375] [c0000002e899bd30] [c000000000811a80] .__sys_sendmsg+0x5c/0xb0 [ 9.303939] [c0000002e899be20] [c0000000000006b0] system_call+0x60/0x6c
--- drivers/net/ethernet/freescale/fman/fman_memac.c | 2 +- drivers/net/ethernet/freescale/fman/fman_tgec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/freescale/fman/fman_memac.c +1 -1
@@ -928,7 +928,7 @@ int memac_add_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr) hash =get_mac_addr_hash_code (addr) &HASH_CTRL_ADDR_MASK ;/* Create element to be added to the driver hash table */ - hash_entry =kmalloc (sizeof (*hash_entry),GFP_KERNEL ); + hash_entry =kmalloc (sizeof (*hash_entry),GFP_ATOMIC );if (!hash_entry)return -ENOMEM ; hash_entry->addr = addr;
drivers/net/ethernet/freescale/fman/fman_tgec.c +1 -1
@@ -553,7 +553,7 @@ int tgec_add_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr) hash = (crc >>TGEC_HASH_MCAST_SHIFT ) &TGEC_HASH_ADR_MSK ;/* Create element to be added to the driver hash table */ - hash_entry =kmalloc (sizeof (*hash_entry),GFP_KERNEL ); + hash_entry =kmalloc (sizeof (*hash_entry),GFP_ATOMIC );if (!hash_entry)return -ENOMEM ; hash_entry->addr = addr;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 233/313 block/swim3: Fix -EBUSY error when re-opening device after unmount
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 296dcc40f2f2e402facf7cd26cf3f2c8f4b17d47 ]
When the block device is opened with FMODE_EXCL, ref_count is set to -1. This value doesn't get reset when the device is closed which means the device cannot be opened again. Fix this by checking for refcount <= 0 in the release method.
--- drivers/block/swim3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/block/swim3.c +5 -1
@@ -1026,7 +1026,11 @@ static void floppy_release(struct gendisk *disk, fmode_t mode)struct swim3 __iomem *sw = fs->swim3;mutex_lock (&swim3_mutex); -if (fs->ref_count >0 && --fs->ref_count ==0 ) { +if (fs->ref_count >0 ) + --fs->ref_count; +else if (fs->ref_count ==-1 ) + fs->ref_count =0 ; +if (fs->ref_count ==0 ) {swim3_action (fs,MOTOR_OFF );out_8 (&sw->control_bic,0xff );swim3_select (fs,RELAX );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 234/313 thermal: bcm2835: enable hwmon explicitly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit d56c19d07e0bc3ceff366a49b7d7a2440c967b1b ]
By defaul of-based thermal driver do not enable hwmon. This patch does this explicitly, so that the temperature can be read through the common hwmon sysfs.
--- drivers/thermal/broadcom/bcm2835_thermal.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/thermal/broadcom/bcm2835_thermal.c +11 -0
@@ -27,6 +27,8 @@#include <linux/platform_device.h> #include <linux/thermal.h> +#include "../thermal_hwmon.h" +#define BCM2835_TS_TSENSCTL 0x00#define BCM2835_TS_TSENSSTAT 0x04
@@ -275,6 +277,15 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, tz); +/* +* Thermal_zone doesn't enable hwmon as default, +* enable it here +*/ + tz->tzp->no_hwmon = false; + err =thermal_add_hwmon_sysfs (tz); +if (err) + goto err_tz; +bcm2835_thermal_debugfs (pdev);return 0 ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 235/313 kdb: Dont back trace on a cpu that didnt round up
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 162bc7f5afd75b72acbe3c5f3488ef7e64a3fe36 ]
If you have a CPU that fails to round up and then run 'btc' you'll end up crashing in kdb becaue we dereferenced NULL. Let's add a check. It's wise to also set the task to NULL when leaving the debugger so that if we fail to round up on a later entry into the debugger we won't backtrace a stale task.
--- kernel/debug/debug_core.c | 4 ++++ kernel/debug/kdb/kdb_bt.c | 11 ++++++++++- kernel/debug/kdb/kdb_debugger.c | 7 ------- 3 files changed, 14 insertions(+), 8 deletions(-)
kernel/debug/debug_core.c +4 -0
@@ -535,6 +535,8 @@ return_normal: arch_kgdb_ops.correct_hw_break ();if (trace_on)tracing_on (); + kgdb_info[cpu].debuggerinfo =NULL ; + kgdb_info[cpu].task =NULL ; kgdb_info[cpu].exception_state &= ~(DCPU_WANT_MASTER |DCPU_IS_SLAVE ); kgdb_info[cpu].enter_kgdb--;
@@ -667,6 +669,8 @@ kgdb_restore:if (trace_on)tracing_on (); + kgdb_info[cpu].debuggerinfo =NULL ; + kgdb_info[cpu].task =NULL ; kgdb_info[cpu].exception_state &= ~(DCPU_WANT_MASTER |DCPU_IS_SLAVE ); kgdb_info[cpu].enter_kgdb--;
kernel/debug/kdb/kdb_bt.c +10 -1
@@ -186,7 +186,16 @@ kdb_bt(int argc, const char **argv)kdb_printf ("btc: cpu status: " );kdb_parse ("cpu\n" );for_each_online_cpu (cpu) { -sprintf (buf,"btt 0x%px\n" ,KDB_TSK (cpu)); +void *kdb_tsk =KDB_TSK (cpu); + +/* If a CPU failed to round up we could be here */ +if (!kdb_tsk) { +kdb_printf ("WARNING: no task for cpu %ld\n" , + cpu); +continue ; + } + +sprintf (buf,"btt 0x%px\n" , kdb_tsk);kdb_parse (buf);touch_nmi_watchdog (); }
kernel/debug/kdb/kdb_debugger.c +0 -7
@@ -118,13 +118,6 @@ int kdb_stub(struct kgdb_state *ks)kdb_bp_remove ();KDB_STATE_CLEAR (DOING_SS );KDB_STATE_SET (PAGER ); -/* zero out any offline cpu data */ -for_each_present_cpu (i) { -if (!cpu_online (i)) { - kgdb_info[i].debuggerinfo =NULL ; - kgdb_info[i].task =NULL ; - } - }if (ks->err_code ==DIE_OOPS || reason ==KDB_REASON_OOPS ) { ks->pass_exception =1 ;KDB_FLAG_SET (CATASTROPHIC );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 236/313 PCI: imx: Enable MSI from downstream components
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 75cb8d20c112aba70f23d98e3f8d0a38ace16006 ]
The MSI Enable bit in the MSI Capability (PCIe r4.0, sec 7.7.1.2) controls whether a Function can request service using MSI.
i.MX6 Root Ports implement the MSI Capability and may use MSI to request service for events like PME, hotplug, AER, etc. In addition, on i.MX6, the MSI Enable bit controls delivery of MSI interrupts from components below the Root Port.
Prior to f3fdfc4ac3a2 ("PCI: Remove host driver Kconfig selection of CONFIG_PCIEPORTBUS"), enabling CONFIG_PCI_IMX6 automatically also enabled CONFIG_PCIEPORTBUS, and when portdrv claimed the Root Ports, it set the MSI Enable bit so it could use PME, hotplug, AER, etc. As a side effect, that also enabled delivery of MSI interrupts from downstream components.
The imx6q-pcie driver itself does not depend on portdrv, so set MSI Enable in imx6q-pcie so MSI from downstream components works even if nobody uses MSI for the Root Port events.
--- drivers/pci/controller/dwc/pci-imx6.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pci/controller/dwc/pci-imx6.c +10 -0
@@ -66,6 +66,7 @@ struct imx6_pcie {#define PHY_PLL_LOCK_WAIT_USLEEP_MAX 200/* PCIe Root Complex registers (memory-mapped) */ +#define PCIE_RC_IMX6_MSI_CAP 0x50#define PCIE_RC_LCR 0x7c#define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN1 0x1#define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2 0x2
@@ -682,6 +683,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)struct resource *dbi_base;struct device_node *node = dev->of_node;int ret; +u16 val; imx6_pcie =devm_kzalloc (dev,sizeof (*imx6_pcie),GFP_KERNEL );if (!imx6_pcie)
@@ -816,6 +818,14 @@ static int imx6_pcie_probe(struct platform_device *pdev)if (ret <0 )return ret; +if (pci_msi_enabled ()) { + val =dw_pcie_readw_dbi (pci,PCIE_RC_IMX6_MSI_CAP + +PCI_MSI_FLAGS ); + val |=PCI_MSI_FLAGS_ENABLE ; +dw_pcie_writew_dbi (pci,PCIE_RC_IMX6_MSI_CAP +PCI_MSI_FLAGS , + val); + } +return 0 ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 237/313 thermal: generic-adc: Fix adc to temp interpolation
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 9d216211fded20fff301d0317af3238d8383634c ]
First correct the edge case to return the last element if we're outside the range, rather than at the last element, so that interpolation is not omitted for points between the two last entries in the table.
Then correct the formula to perform linear interpolation based the two points surrounding the read ADC value. The indices for temp are kept as "hi" and "lo" to pair with the adc indices, but there's no requirement that the temperature is provided in descendent order. mult_frac() is used to prevent issues with overflowing the int.
--- drivers/thermal/thermal-generic-adc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/thermal/thermal-generic-adc.c +8 -4
@@ -26,7 +26,7 @@ struct gadc_thermal_info {static int gadc_thermal_adc_to_temp (struct gadc_thermal_info *gti,int val) { -int temp, adc_hi, adc_lo; +int temp, temp_hi, temp_lo, adc_hi, adc_lo;int i;for (i =0 ; i < gti->nlookup_table; i++) {
@@ -36,13 +36,17 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)if (i ==0 ) { temp = gti->lookup_table[0 ]; - }else if (i >= (gti->nlookup_table -1 )) { + }else if (i >= gti->nlookup_table) { temp = gti->lookup_table[2 * (gti->nlookup_table -1 )]; }else { adc_hi = gti->lookup_table[2 * i -1 ]; adc_lo = gti->lookup_table[2 * i +1 ]; - temp = gti->lookup_table[2 * i]; - temp -= ((val - adc_lo) *1000 ) / (adc_hi - adc_lo); + + temp_hi = gti->lookup_table[2 * i -2 ]; + temp_lo = gti->lookup_table[2 * i]; + + temp = temp_hi +mult_frac (temp_lo - temp_hi, val - adc_hi, + adc_lo - adc_hi); }return temp;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 238/313 HID: lenovo: Add checks to fix of_led_classdev_register
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 6ae16dfb61bce538d48b7fe98160fada446056c5 ]
In lenovo_probe_tpkbd(), the function of_led_classdev_register() could return an error value that is unchecked. The fix adds these checks.
--- drivers/hid/hid-lenovo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/hid/hid-lenovo.c +8 -2
@@ -743,7 +743,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev) data_pointer->led_mute.brightness_get = lenovo_led_brightness_get_tpkbd; data_pointer->led_mute.brightness_set = lenovo_led_brightness_set_tpkbd; data_pointer->led_mute.dev = dev; -led_classdev_register (dev, &data_pointer->led_mute); + ret =led_classdev_register (dev, &data_pointer->led_mute); +if (ret <0 ) + goto err; data_pointer->led_micmute.name = name_micmute; data_pointer->led_micmute.brightness_get =
@@ -751,7 +753,11 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev) data_pointer->led_micmute.brightness_set = lenovo_led_brightness_set_tpkbd; data_pointer->led_micmute.dev = dev; -led_classdev_register (dev, &data_pointer->led_micmute); + ret =led_classdev_register (dev, &data_pointer->led_micmute); +if (ret <0 ) { +led_classdev_unregister (&data_pointer->led_mute); + goto err; + }lenovo_features_set_tpkbd (hdev);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 239/313 arm64/sve: ptrace: Fix SVE_PT_REGS_OFFSET definition
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit ee1b465b303591d3a04d403122bbc0d7026520fb ]
SVE_PT_REGS_OFFSET is supposed to indicate the offset for skipping over the ptrace NT_ARM_SVE header (struct user_sve_header) to the start of the SVE register data proper.
However, currently SVE_PT_REGS_OFFSET is defined in terms of struct sve_context, which is wrong: that structure describes the SVE header in the signal frame, not in the ptrace regset.
This patch fixes the definition to use the ptrace header structure struct user_sve_header instead.
By good fortune, the two structures are the same size anyway, so there is no functional or ABI change.
--- arch/arm64/include/uapi/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/uapi/asm/ptrace.h +1 -1
@@ -130,7 +130,7 @@ struct user_sve_header {/* Offset from the start of struct user_sve_header to the register data */ #define SVE_PT_REGS_OFFSET \ - ((sizeof(struct sve_context) + (SVE_VQ_BYTES - 1)) \ + ((sizeof(struct user_sve_header) + (SVE_VQ_BYTES - 1)) \ / SVE_VQ_BYTES * SVE_VQ_BYTES)/*
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 240/313 fs/proc/base.c: use ns_capable instead of capable for timerslack_ns
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 8da0b4f692c6d90b09c91f271517db746a22ff67 ]
Access to timerslack_ns is controlled by a process having CAP_SYS_NICE in its effective capability set, but the current check looks in the root namespace instead of the process' user namespace. Since a process is allowed to do other activities controlled by CAP_SYS_NICE inside a namespace, it should also be able to adjust timerslack_ns.
--- fs/proc/base.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/proc/base.c +9 -3
@@ -2356,10 +2356,13 @@ static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,return -ESRCH ;if (p != current) { -if (!capable (CAP_SYS_NICE )) { +rcu_read_lock (); +if (!ns_capable (__task_cred (p)->user_ns,CAP_SYS_NICE )) { +rcu_read_unlock (); count = -EPERM ; goto out; } +rcu_read_unlock (); err =security_task_setscheduler (p);if (err) {
@@ -2392,11 +2395,14 @@ static int timerslack_ns_show(struct seq_file *m, void *v)return -ESRCH ;if (p != current) { - -if (!capable (CAP_SYS_NICE )) { +rcu_read_lock (); +if (!ns_capable (__task_cred (p)->user_ns,CAP_SYS_NICE )) { +rcu_read_unlock (); err = -EPERM ; goto out; } +rcu_read_unlock (); + err =security_task_getscheduler (p);if (err) goto out;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 241/313 kernel/hung_task.c: break RCU locks based on jiffies
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 304ae42739b108305f8d7b3eb3c1aec7c2b643a9 ]
check_hung_uninterruptible_tasks() is currently calling rcu_lock_break() for every 1024 threads. But check_hung_task() is very slow if printk() was called, and is very fast otherwise.
If many threads within some 1024 threads called printk(), the RCU grace period might be extended enough to trigger RCU stall warnings. Therefore, calling rcu_lock_break() for every some fixed jiffies will be safer.
--- kernel/hung_task.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/hung_task.c +4 -4
@@ -33,7 +33,7 @@ int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;* is disabled during the critical section. It also controls the size of * the RCU grace period. So it needs to be upper-bound. */ -#define HUNG_TASK_BATCHING 1024 +#define HUNG_TASK_LOCK_BREAK (HZ / 10)/* * Zero means infinite timeout - no checking done:
@@ -172,7 +172,7 @@ static bool rcu_lock_break(struct task_struct *g, struct task_struct *t)static void check_hung_uninterruptible_tasks (unsigned long timeout) {int max_count = sysctl_hung_task_check_count; -int batch_count =HUNG_TASK_BATCHING ; +unsigned long last_break = jiffies;struct task_struct *g, *t;/*
@@ -187,10 +187,10 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)for_each_process_thread (g, t) {if (!max_count--) goto unlock; -if (!--batch_count) { - batch_count =HUNG_TASK_BATCHING ; +if (time_after (jiffies, last_break +HUNG_TASK_LOCK_BREAK )) {if (!rcu_lock_break (g, t)) goto unlock; + last_break = jiffies; }/* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */ if (t->state ==TASK_UNINTERRUPTIBLE )
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 242/313 proc/sysctl: fix return error for proc_doulongvec_minmax()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 09be178400829dddc1189b50a7888495dd26aa84 ]
If the number of input parameters is less than the total parameters, an EINVAL error will be returned.
For example, we use proc_doulongvec_minmax to pass up to two parameters with kern_table:
{
.procname = "monitor_signals", .data = &monitor_sigs, .maxlen = 2*sizeof(unsigned long), .mode = 0644, .proc_handler = proc_doulongvec_minmax,
},
Reproduce:
When passing two parameters, it's work normal. But passing only one parameter, an error "Invalid argument"(EINVAL) is returned.
[root@cl150 ~]# echo 1 2 > /proc/sys/kernel/monitor_signals [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
1 2
[root@cl150 ~]# echo 3 > /proc/sys/kernel/monitor_signals -bash: echo: write error: Invalid argument [root@cl150 ~]# echo $?
1
[root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
3 2
[root@cl150 ~]#
The following is the result after apply this patch. No error is returned when the number of input parameters is less than the total parameters.
[root@cl150 ~]# echo 1 2 > /proc/sys/kernel/monitor_signals [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
1 2
[root@cl150 ~]# echo 3 > /proc/sys/kernel/monitor_signals [root@cl150 ~]# echo $?
0
[root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
3 2
[root@cl150 ~]#
There are three processing functions dealing with digital parameters, __do_proc_dointvec/__do_proc_douintvec/__do_proc_doulongvec_minmax.
This patch deals with __do_proc_doulongvec_minmax, just as __do_proc_dointvec does, adding a check for parameters 'left'. In __do_proc_douintvec, its code implementation explicitly does not support multiple inputs.
static int __do_proc_douintvec(...){
...
/*
* Arrays are not supported, keep this simple. *Do not* add
* support for them.
*/
if (vleft != 1) {
*lenp = 0;
return -EINVAL;
}
...
}So, just __do_proc_doulongvec_minmax has the problem. And most use of proc_doulongvec_minmax/proc_doulongvec_ms_jiffies_minmax just have one parameter.
--- kernel/sysctl.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/sysctl.c +2 -0
@@ -2767,6 +2767,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, intbool neg; left -=proc_skip_spaces (&p); +if (!left) +break ; err = proc_get_long(&p, &left, &val, &neg, proc_wspace_sep,
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 243/313 kernel/hung_task.c: force console verbose before panic
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 168e06f7937d96c7222037d8a05565e8a6eb00fe ]
Based on commit 401c636a0eeb ("kernel/hung_task.c: show all hung tasks before panic"), we could get the call stack of hung task.
However, if the console loglevel is not high, we still can not see the useful panic information in practice, and in most cases users don't set console loglevel to high level.
This patch is to force console verbose before system panic, so that the real useful information can be seen in the console, instead of being like the following, which doesn't have hung task information.
INFO: task init:1 blocked for more than 120 seconds.
Tainted: G U W 4.19.0-quilt-2e5dc0ac-g51b6c21d76cc #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Kernel panic - not syncing: hung_task: blocked tasks
CPU: 2 PID: 479 Comm: khungtaskd Tainted: G U W 4.19.0-quilt-2e5dc0ac-g51b6c21d76cc #1
Call Trace:
dump_stack+0x4f/0x65
panic+0xde/0x231
watchdog+0x290/0x410
kthread+0x12c/0x150
ret_from_fork+0x35/0x40
reboot: panic mode set: p,w
Kernel Offset: 0x34000000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)--- kernel/hung_task.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
kernel/hung_task.c +5 -7
@@ -111,8 +111,11 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)trace_sched_process_hang (t); -if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic) -return ; +if (sysctl_hung_task_panic) { +console_verbose (); + hung_task_show_lock = true; + hung_task_call_panic = true; + }/* * Ok, the task did not get scheduled for more than 2 minutes,
@@ -134,11 +137,6 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout) }touch_nmi_watchdog (); - -if (sysctl_hung_task_panic) { - hung_task_show_lock = true; - hung_task_call_panic = true; - } }/*
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 244/313 fs/epoll: drop ovflist branch prediction
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 76699a67f3041ff4c7af6d6ee9be2bfbf1ffb671 ]
The ep->ovflist is a secondary ready-list to temporarily store events that might occur when doing sproc without holding the ep->wq.lock. This accounts for every time we check for ready events and also send events back to userspace; both callbacks, particularly the latter because of copy_to_user, can account for a non-trivial time.
As such, the unlikely() check to see if the pointer is being used, seems both misleading and sub-optimal. In fact, we go to an awful lot of trouble to sync both lists, and populating the ovflist is far from an uncommon scenario.
For example, profiling a concurrent epoll_wait(2) benchmark, with CONFIG_PROFILE_ANNOTATED_BRANCHES shows that for a two threads a 33% incorrect rate was seen; and when incrementally increasing the number of epoll instances (which is used, for example for multiple queuing load balancing models), up to a 90% incorrect rate was seen.
Similarly, by deleting the prediction, 3% throughput boost was seen across incremental threads.
--- fs/eventpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/eventpoll.c +1 -1
@@ -1154,7 +1154,7 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v* semantics). All the events that happen during that period of time are * chained in ep->ovflist and requeued later on. */ -if (unlikely (ep->ovflist !=EP_UNACTIVE_PTR )) { +if (ep->ovflist !=EP_UNACTIVE_PTR ) {if (epi->next ==EP_UNACTIVE_PTR ) { epi->next = ep->ovflist; ep->ovflist = epi;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 245/313 exec: load_script: dont blindly truncate shebang string
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 8099b047ecc431518b9bb6bdbba3549bbecdc343 ]
load_script() simply truncates bprm->buf and this is very wrong if the length of shebang string exceeds BINPRM_BUF_SIZE-2. This can silently truncate i_arg or (worse) we can execute the wrong binary if buf[2:126] happens to be the valid executable path.
Change load_script() to return ENOEXEC if it can't find '\n' or zero in bprm->buf. Note that '\0' can come from either prepare_binprm()->memset() or from kernel_read(), we do not care.
--- fs/binfmt_script.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/binfmt_script.c +7 -3
@@ -42,10 +42,14 @@ static int load_script(struct linux_binprm *bprm)fput (bprm->file); bprm->file =NULL ; - bprm->buf[BINPRM_BUF_SIZE -1 ] ='\0' ; -if ((cp =strchr (bprm->buf,'\n' )) ==NULL ) - cp = bprm->buf+BINPRM_BUF_SIZE -1 ; +for (cp = bprm->buf+2 ;; cp++) { +if (cp >= bprm->buf +BINPRM_BUF_SIZE ) +return -ENOEXEC ; +if (!*cp || (*cp =='\n' )) +break ; + } *cp ='\0' ; +while (cp > bprm->buf) { cp--;if ((*cp ==' ' ) || (*cp =='\t' ))
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 246/313 kernel/kcov.c: mark write_comp_data() as notrace
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 634724431607f6f46c495dfef801a1c8b44a96d9 ]
Since __sanitizer_cov_trace_const_cmp4 is marked as notrace, the function called from __sanitizer_cov_trace_const_cmp4 shouldn't be traceable either. ftrace_graph_caller() gets called every time func write_comp_data() gets called if it isn't marked 'notrace'. This is the backtrace from gdb:
#0 ftrace_graph_caller () at ../arch/arm64/kernel/entry-ftrace.S:179 #1 0xffffff8010201920 in ftrace_caller () at ../arch/arm64/kernel/entry-ftrace.S:151 #2 0xffffff8010439714 in write_comp_data (type=5, arg1=0, arg2=0, ip=18446743524224276596) at ../kernel/kcov.c:116 #3 0xffffff8010439894 in __sanitizer_cov_trace_const_cmp4 (arg1=<optimized out>, arg2=<optimized out>) at ../kernel/kcov.c:188 #4 0xffffff8010201874 in prepare_ftrace_return (self_addr=18446743524226602768, parent=0xffffff801014b918, frame_pointer=18446743524223531344) at ./include/generated/atomic-instrumented.h:27 #5 0xffffff801020194c in ftrace_graph_caller () at ../arch/arm64/kernel/entry-ftrace.S:182
Rework so that write_comp_data() that are called from __sanitizer_cov_trace_*_cmp*() are marked as 'notrace'.
Commit 903e8ff86753 ("kernel/kcov.c: mark funcs in __sanitizer_cov_trace_pc() as notrace") missed to mark write_comp_data() as 'notrace'. When that patch was
created gcc-7 was used. In lib/Kconfig.debug
config KCOV_ENABLE_COMPARISONS
depends on $(cc-option,-fsanitize-coverage=trace-cmp)
That code path isn't hit with gcc-7. However, it were that with gcc-8.
--- kernel/kcov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcov.c +1 -1
@@ -112,7 +112,7 @@ void notrace __sanitizer_cov_trace_pc(void)EXPORT_SYMBOL (__sanitizer_cov_trace_pc);#ifdef CONFIG_KCOV_ENABLE_COMPARISONS -static void write_comp_data (u64 type,u64 arg1,u64 arg2,u64 ip) +static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip) {struct task_struct *t;u64 *area;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 247/313 scripts/gdb: fix lx-version string output
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit b058809bfc8faeb7b7cae047666e23375a060059 ]
A bug is present in GDB which causes early string termination when parsing variables. This has been reported [0], but we should ensure that we can support at least basic printing of the core kernel strings.
For current gdb version (has been tested with 7.3 and 8.1), 'lx-version' only prints one character.
(gdb) lx-version
L(gdb)
This can be fixed by casting 'linux_banner' as (char *).
(gdb) lx-version
Linux version 4.19.0-rc1+ (changbin@acer) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #21 SMP Sat Sep 1 21:43:30 CST 2018
[0] https://sourceware.org/bugzilla/show_bug.cgi?id=20077
--- scripts/gdb/linux/proc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/proc.py +1 -1
@@ -41,7 +41,7 @@ class LxVersion(gdb.Command): def invoke(self, arg, from_tty): # linux_banner should contain a newline - gdb.write(gdb.parse_and_eval("linux_banner").string()) + gdb.write(gdb.parse_and_eval("(char *)linux_banner").string()) LxVersion()
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 248/313 xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit 41657e5507b13e963be906d5d874f4f02374fd5c upstream.
The addition of FIBT, RMAP and REFCOUNT changed the offsets into __xfssats structure.
This caused xqmstat_proc_show() to display garbage data via /proc/fs/xfs/xqmstat, once it relies on the offsets marked via macros.
Fix it.
--- fs/xfs/xfs_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_stats.c +1 -1
@@ -119,7 +119,7 @@ static int xqmstat_proc_show(struct seq_file *m, void *v)int j;seq_printf (m,"qm" ); -for (j =XFSSTAT_END_IBT_V2 ; j <XFSSTAT_END_XQMSTAT ; j++) +for (j =XFSSTAT_END_REFCOUNT ; j <XFSSTAT_END_XQMSTAT ; j++)seq_printf (m," %u" ,counter_val (xfsstats.xs_stats, j));seq_putc (m,'\n' );return 0 ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 249/313 xfs: cancel COW blocks before swapext
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit 96987eea537d6ccd98704a71958f9ba02da80843 upstream.
We need to make sure we have no outstanding COW blocks before we swap extents, as there is nothing preventing us from having preallocated COW delalloc on either inode that swapext is called on. That case can easily be reproduced by running generic/324 in always_cow mode:
[ 620.760572] XFS: Assertion failed: tip->i_delayed_blks == 0, file: fs/xfs/xfs_bmap_util.c, line: 1669 [ 620.761608] ------------[ cut here ]------------ [ 620.762171] kernel BUG at fs/xfs/xfs_message.c:102! [ 620.762732] invalid opcode: 0000 [#1] SMP PTI [ 620.763272] CPU: 0 PID: 24153 Comm: xfs_fsr Tainted: G W 4.19.0-rc1+ #4182 [ 620.764203] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.1-1 04/01/2014 [ 620.765202] RIP: 0010:assfail+0x20/0x28 [ 620.765646] Code: 31 ff e8 83 fc ff ff 0f 0b c3 48 89 f1 41 89 d0 48 c7 c6 48 ca 8d 82 48 89 fa 38 [ 620.767758] RSP: 0018:ffffc9000898bc10 EFLAGS: 00010202 [ 620.768359] RAX: 0000000000000000 RBX: ffff88012f14ba40 RCX: 0000000000000000 [ 620.769174] RDX: 00000000ffffffc0 RSI: 000000000000000a RDI: ffffffff828560d9 [ 620.769982] RBP: ffff88012f14b300 R08: 0000000000000000 R09: 0000000000000000 [ 620.770788] R10: 000000000000000a R11: f000000000000000 R12: ffffc9000898bc98 [ 620.771638] R13: ffffc9000898bc9c R14: ffff880130b5e2b8 R15: ffff88012a1fa2a8 [ 620.772504] FS: 00007fdc36e0fbc0(0000) GS:ffff88013ba00000(0000) knlGS:0000000000000000 [ 620.773475] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 620.774168] CR2: 00007fdc3604d000 CR3: 0000000132afc000 CR4: 00000000000006f0 [ 620.774978] Call Trace: [ 620.775274] xfs_swap_extent_forks+0x2a0/0x2e0 [ 620.775792] xfs_swap_extents+0x38b/0xab0 [ 620.776256] xfs_ioc_swapext+0x121/0x140 [ 620.776709] xfs_file_ioctl+0x328/0xc90 [ 620.777154] ? rcu_read_lock_sched_held+0x50/0x60 [ 620.777694] ? xfs_iunlock+0x233/0x260 [ 620.778127] ? xfs_setattr_nonsize+0x3be/0x6a0 [ 620.778647] do_vfs_ioctl+0x9d/0x680 [ 620.779071] ? ksys_fchown+0x47/0x80 [ 620.779552] ksys_ioctl+0x35/0x70 [ 620.780040] __x64_sys_ioctl+0x11/0x20 [ 620.780530] do_syscall_64+0x4b/0x190 [ 620.780927] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 620.781467] RIP: 0033:0x7fdc364d0f07 [ 620.781900] Code: b3 66 90 48 8b 05 81 5f 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 28 [ 620.784044] RSP: 002b:00007ffe2a766038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 620.784896] RAX: ffffffffffffffda RBX: 0000000000000025 RCX: 00007fdc364d0f07 [ 620.785667] RDX: 0000560296ca2fc0 RSI: 00000000c0c0586d RDI: 0000000000000005 [ 620.786398] RBP: 0000000000000025 R08: 0000000000001200 R09: 0000000000000000 [ 620.787283] R10: 0000000000000432 R11: 0000000000000246 R12: 0000000000000005 [ 620.788051] R13: 0000000000000000 R14: 0000000000001000 R15: 0000000000000006 [ 620.788927] Modules linked in: [ 620.789340] ---[ end trace 9503b7417ffdbdb0 ]--- [ 620.790065] RIP: 0010:assfail+0x20/0x28 [ 620.790642] Code: 31 ff e8 83 fc ff ff 0f 0b c3 48 89 f1 41 89 d0 48 c7 c6 48 ca 8d 82 48 89 fa 38 [ 620.793038] RSP: 0018:ffffc9000898bc10 EFLAGS: 00010202 [ 620.793609] RAX: 0000000000000000 RBX: ffff88012f14ba40 RCX: 0000000000000000 [ 620.794317] RDX: 00000000ffffffc0 RSI: 000000000000000a RDI: ffffffff828560d9 [ 620.795025] RBP: ffff88012f14b300 R08: 0000000000000000 R09: 0000000000000000 [ 620.795778] R10: 000000000000000a R11: f000000000000000 R12: ffffc9000898bc98 [ 620.796675] R13: ffffc9000898bc9c R14: ffff880130b5e2b8 R15: ffff88012a1fa2a8 [ 620.797782] FS: 00007fdc36e0fbc0(0000) GS:ffff88013ba00000(0000) knlGS:0000000000000000 [ 620.798908] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 620.799594] CR2: 00007fdc3604d000 CR3: 0000000132afc000 CR4: 00000000000006f0 [ 620.800424] Kernel panic - not syncing: Fatal exception [ 620.801191] Kernel Offset: disabled [ 620.801597] ---[ end Kernel panic - not syncing: Fatal exception ]---
--- fs/xfs/xfs_bmap_util.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/xfs/xfs_bmap_util.c +6 -0
@@ -1824,6 +1824,12 @@ xfs_swap_extents(if (error) goto out_unlock; +if (xfs_inode_has_cow_data (tip)) { + error =xfs_reflink_cancel_cow_range (tip,0 ,NULLFILEOFF , true); +if (error) +return error; + } +/* * Extent "swapping" with rmap requires a permanent reservation and * a block reservation because it's really just a remap operation
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 250/313 xfs: Fix error code in xfs_ioc_getbmap()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit 132bf6723749f7219c399831eeb286dbbb985429 upstream.
In this function, once 'buf' has been allocated, we unconditionally return 0.
However, 'error' is set to some error codes in several error handling paths.
Before commit 232b51948b99 ("xfs: simplify the xfs_getbmap interface") this was not an issue because all error paths were returning directly, but now that some cleanup at the end may be needed, we must propagate the error code.
--- fs/xfs/xfs_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_ioctl.c +1 -1
@@ -1616,7 +1616,7 @@ xfs_ioc_getbmap( error =0 ; out_free_buf:kmem_free (buf); -return 0 ; +return error; }struct getfsmap_info {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 251/313 xfs: fix overflow in xfs_attr3_leaf_verify
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit 837514f7a4ca4aca06aec5caa5ff56d33ef06976 upstream.
generic/070 on 64k block size filesystems is failing with a verifier corruption on writeback or an attribute leaf block:
[ 94.973083] XFS (pmem0): Metadata corruption detected at xfs_attr3_leaf_verify+0x246/0x260, xfs_attr3_leaf block 0x811480
[ 94.975623] XFS (pmem0): Unmount and run xfs_repair
[ 94.976720] XFS (pmem0): First 128 bytes of corrupted metadata buffer:
[ 94.978270] 000000004b2e7b45: 00 00 00 00 00 00 00 00 3b ee 00 00 00 00 00 00 ........;.......
[ 94.980268] 000000006b1db90b: 00 00 00 00 00 81 14 80 00 00 00 00 00 00 00 00 ................
[ 94.982251] 00000000433f2407: 22 7b 5c 82 2d 5c 47 4c bb 31 1c 37 fa a9 ce d6 "{\.-\GL.1.7....
[ 94.984157] 0000000010dc7dfb: 00 00 00 00 00 81 04 8a 00 0a 18 e8 dd 94 01 00 ................
[ 94.986215] 00000000d5a19229: 00 a0 dc f4 fe 98 01 68 f0 d8 07 e0 00 00 00 00 .......h........
[ 94.988171] 00000000521df36c: 0c 2d 32 e2 fe 20 01 00 0c 2d 58 65 fe 0c 01 00 .-2.. ...-Xe....
[ 94.990162] 000000008477ae06: 0c 2d 5b 66 fe 8c 01 00 0c 2d 71 35 fe 7c 01 00 .-[f.....-q5.|..
[ 94.992139] 00000000a4a6bca6: 0c 2d 72 37 fc d4 01 00 0c 2d d8 b8 f0 90 01 00 .-r7.....-......
[ 94.994789] XFS (pmem0): xfs_do_force_shutdown(0x8) called from line 1453 of file fs/xfs/xfs_buf.c. Return address = ffffffff815365f3This is failing this check:
end = ichdr.freemap[i].base + ichdr.freemap[i].size; if (end < ichdr.freemap[i].base)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
return __this_address;
if (end > mp->m_attr_geo->blksize)
return __this_address;And from the buffer output above, the freemap array is:
freemap[0].base = 0x00a0 freemap[0].size = 0xdcf4 end = 0xdd94 freemap[1].base = 0xfe98 freemap[1].size = 0x0168 end = 0x10000 freemap[2].base = 0xf0d8 freemap[2].size = 0x07e0 end = 0xf8b8
These all look valid - the block size is 0x10000 and so from the last check in the above verifier fragment we know that the end of freemap[1] is valid. The problem is that end is declared as:
uint16_t end;
And (uint16_t)0x10000 = 0. So we have a verifier bug here, not a corruption. Fix the verifier to use uint32_t types for the check and hence avoid the overflow.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +9 -2
@@ -243,7 +243,7 @@ xfs_attr3_leaf_verify(struct xfs_mount *mp = bp->b_target->bt_mount;struct xfs_attr_leafblock *leaf = bp->b_addr;struct xfs_attr_leaf_entry *entries; -uint16_t end; +uint32_t end;/* must be 32bit - see below */ int i;xfs_attr3_leaf_hdr_from_disk (mp->m_attr_geo, &ichdr, leaf);
@@ -293,6 +293,11 @@ xfs_attr3_leaf_verify(/* * Quickly check the freemap information. Attribute data has to be * aligned to 4-byte boundaries, and likewise for the free space. +* +* Note that for 64k block size filesystems, the freemap entries cannot +* overflow as they are only be16 fields. However, when checking end +* pointer of the freemap, we have to be careful to detect overflows and +* so use uint32_t for those checks. */ for (i =0 ; i <XFS_ATTR_LEAF_MAPSIZE ; i++) {if (ichdr.freemap[i].base > mp->m_attr_geo->blksize)
@@ -303,7 +308,9 @@ xfs_attr3_leaf_verify(return __this_address;if (ichdr.freemap[i].size &0x3 )return __this_address; - end = ichdr.freemap[i].base + ichdr.freemap[i].size; + +/* be care of 16 bit overflows here */ + end = (uint32_t )ichdr.freemap[i].base + ichdr.freemap[i].size;if (end < ichdr.freemap[i].base)return __this_address;if (end > mp->m_attr_geo->blksize)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 252/313 xfs: fix shared extent data corruption due to missing cow reservation
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit 59e4293149106fb92530f8e56fa3992d8548c5e6 upstream.
Page writeback indirectly handles shared extents via the existence of overlapping COW fork blocks. If COW fork blocks exist, writeback always performs the associated copy-on-write regardless if the underlying blocks are actually shared. If the blocks are shared, then overlapping COW fork blocks must always exist.
fstests shared/010 reproduces a case where a buffered write occurs over a shared block without performing the requisite COW fork reservation. This ultimately causes writeback to the shared extent and data corruption that is detected across md5 checks of the filesystem across a mount cycle.
The problem occurs when a buffered write lands over a shared extent that crosses an extent size hint boundary and that also happens to have a partial COW reservation that doesn't cover the start and end blocks of the data fork extent.
For example, a buffered write occurs across the file offset (in FSB units) range of [29, 57]. A shared extent exists at blocks [29, 35] and COW reservation already exists at blocks [32, 34]. After accommodating a COW extent size hint of 32 blocks and the existing reservation at offset 32, xfs_reflink_reserve_cow() allocates 32 blocks of reservation at offset 0 and returns with COW reservation across the range of [0, 34]. The associated data fork extent is still [29, 35], however, which isn't fully covered by the COW reservation.
This leads to a buffered write at file offset 35 over a shared extent without associated COW reservation. Writeback eventually kicks in, performs an overwrite of the underlying shared block and causes the associated data corruption.
Update xfs_reflink_reserve_cow() to accommodate the fact that a delalloc allocation request may not fully cover the extent in the data fork. Trim the data fork extent appropriately, just as is done for shared extent boundaries and/or existing COW reservations that happen to overlap the start of the data fork extent. This prevents shared/010 failures due to data corruption on reflink enabled filesystems.
--- fs/xfs/xfs_reflink.c | 1 + 1 file changed, 1 insertion(+)
fs/xfs/xfs_reflink.c +1 -0
@@ -302,6 +302,7 @@ xfs_reflink_reserve_cow(if (error)return error; +xfs_trim_extent (imap, got.br_startoff, got.br_blockcount);trace_xfs_reflink_cow_alloc (ip, &got);return 0 ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 253/313 xfs: fix transient reference count error in xfs_buf_resubmit_failed_buffers
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit d43aaf1685aa471f0593685c9f54d53e3af3cf3f upstream.
When retrying a failed inode or dquot buffer, xfs_buf_resubmit_failed_buffers() clears all the failed flags from the inde/dquot log items. In doing so, it also drops all the reference counts on the buffer that the failed log items hold. This means it can drop all the active references on the buffer and hence free the buffer before it queues it for write again.
Putting the buffer on the delwri queue takes a reference to the buffer (so that it hangs around until it has been written and completed), but this goes bang if the buffer has already been freed.
Hence we need to add the buffer to the delwri queue before we remove the failed flags from the log items attached to the buffer to ensure it always remains referenced during the resubmit process.
--- fs/xfs/xfs_buf_item.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
fs/xfs/xfs_buf_item.c +21 -7
@@ -1233,9 +1233,23 @@ xfs_buf_iodone( }/* -* Requeue a failed buffer for writeback +* Requeue a failed buffer for writeback. * -* Return true if the buffer has been re-queued properly, false otherwise +* We clear the log item failed state here as well, but we have to be careful +* about reference counts because the only active reference counts on the buffer +* may be the failed log items. Hence if we clear the log item failed state +* before queuing the buffer for IO we can release all active references to +* the buffer and free it, leading to use after free problems in +* xfs_buf_delwri_queue. It makes no difference to the buffer or log items which +* order we process them in - the buffer is locked, and we own the buffer list +* so nothing on them is going to change while we are performing this action. +* +* Hence we can safely queue the buffer for IO before we clear the failed log +* item state, therefore always having an active reference to the buffer and +* avoiding the transient zero-reference state that leads to use-after-free. +* +* Return true if the buffer was added to the buffer list, false if it was +* already on the buffer list. */ bool xfs_buf_resubmit_failed_buffers(
@@ -1243,16 +1257,16 @@ xfs_buf_resubmit_failed_buffers( struct list_head *buffer_list) {struct xfs_log_item *lip; +bool ret; + + ret =xfs_buf_delwri_queue (bp, buffer_list);/* -* Clear XFS_LI_FAILED flag from all items before resubmit -* -* XFS_LI_FAILED set/clear is protected by ail_lock, caller this +* XFS_LI_FAILED set/clear is protected by ail_lock, caller of this * function already have it acquired */ list_for_each_entry (lip, &bp->b_li_list, li_bio_list)xfs_clear_li_failed (lip); -/* Add this buffer back to the delayed write list */ -return xfs_buf_delwri_queue (bp, buffer_list); +return ret; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 254/313 xfs: delalloc -> unwritten COW fork allocation can go wrong
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit 9230a0b65b47fe6856c4468ec0175c4987e5bede upstream.
Long saga. There have been days spent following this through dead end after dead end in multi-GB event traces. This morning, after writing a trace-cmd wrapper that enabled me to be more selective about XFS trace points, I discovered that I could get just enough essential tracepoints enabled that there was a 50:50 chance the fsx config would fail at ~115k ops. If it didn't fail at op 115547, I stopped fsx at op 115548 anyway.
That gave me two traces - one where the problem manifested, and one where it didn't. After refining the traces to have the necessary information, I found that in the failing case there was a real extent in the COW fork compared to an unwritten extent in the working case.
Walking back through the two traces to the point where the CWO fork extents actually diverged, I found that the bad case had an extra unwritten extent in it. This is likely because the bug it led me to had triggered multiple times in those 115k ops, leaving stray COW extents around. What I saw was a COW delalloc conversion to an unwritten extent (as they should always be through xfs_iomap_write_allocate()) resulted in a /written extent/:
xfs_writepage: dev 259:0 ino 0x83 pgoff 0x17000 size 0x79a00 offset 0 length 0 xfs_iext_remove: dev 259:0 ino 0x83 state RC|LF|RF|COW cur 0xffff888247b899c0/2 offset 32 block 152 count 20 flag 1 caller xfs_bmap_add_extent_delay_real xfs_bmap_pre_update: dev 259:0 ino 0x83 state RC|LF|RF|COW cur 0xffff888247b899c0/1 offset 1 block 4503599627239429 count 31 flag 0 caller xfs_bmap_add_extent_delay_real xfs_bmap_post_update: dev 259:0 ino 0x83 state RC|LF|RF|COW cur 0xffff888247b899c0/1 offset 1 block 121 count 51 flag 0 caller xfs_bmap_add_ex
Basically, Cow fork before:
0 1 32 52
+H+DDDDDDDDDDDD+UUUUUUUUUUU+
PREV RIGHT
COW delalloc conversion allocates:
1 32 +uuuuuuuuuuuu+ NEW
And the result according to the xfs_bmap_post_update trace was:
0 1 32 52
+H+wwwwwwwwwwwwwwwwwwwwwwww+
PREV
Which is clearly wrong - it should be a merged unwritten extent, not an unwritten extent.
That lead me to look at the LEFT_FILLING|RIGHT_FILLING|RIGHT_CONTIG case in xfs_bmap_add_extent_delay_real(), and sure enough, there's the bug.
It takes the old delalloc extent (PREV) and adds the length of the RIGHT extent to it, takes the start block from NEW, removes the RIGHT extent and then updates PREV with the new extent.
What it fails to do is update PREV.br_state. For delalloc, this is always XFS_EXT_NORM, while in this case we are converting the delayed allocation to unwritten, so it needs to be updated to XFS_EXT_UNWRITTEN. This LF|RF|RC case does not do this, and so the resultant extent is always written.
And that's the bug I've been chasing for a week - a bmap btree bug, not a reflink/dedupe/copy_file_range bug, but a BMBT bug introduced with the recent in core extent tree scalability enhancements.
--- fs/xfs/libxfs/xfs_bmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_bmap.c +4 -1
@@ -1683,10 +1683,13 @@ xfs_bmap_add_extent_delay_real(case BMAP_LEFT_FILLING |BMAP_RIGHT_FILLING |BMAP_RIGHT_CONTIG :/* * Filling in all of a previously delayed allocation extent. -* The right neighbor is contiguous, the left is not. +* The right neighbor is contiguous, the left is not. Take care +* with delay -> unwritten extent allocation here because the +* delalloc record we are overwriting is always written. */ PREV .br_startblock = new->br_startblock;PREV .br_blockcount +=RIGHT .br_blockcount; +PREV .br_state = new->br_state;xfs_iext_next (ifp, &bma->icur);xfs_iext_remove (bma->ip, &bma->icur, state);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 255/313 fs/xfs: fix f_ffree value for statfs when project quota is set
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit de7243057e7cefa923fa5f467c0f1ec24eef41d2 upsream.
When project is set, we should use inode limit minus the used count
--- fs/xfs/xfs_qm_bhv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_qm_bhv.c +1 -1
@@ -40,7 +40,7 @@ xfs_fill_statvfs_from_dquot( statp->f_files = limit; statp->f_ffree = (statp->f_files > dqp->q_res_icount) ? - (statp->f_ffree - dqp->q_res_icount) :0 ; + (statp->f_files - dqp->q_res_icount) :0 ; } }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 256/313 xfs: fix PAGE_MASK usage in xfs_free_file_space
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit a579121f94aba4e8bad1a121a0fad050d6925296 upstream.
In commit e53c4b598, I *tried* to teach xfs to force writeback when we fzero/fpunch right up to EOF so that if EOF is in the middle of a page, the post-EOF part of the page gets zeroed before we return to userspace. Unfortunately, I missed the part where PAGE_MASK is ~(PAGE_SIZE - 1), which means that we totally fail to zero if we're fpunching and EOF is within the first page. Worse yet, the same PAGE_MASK thinko plagues the filemap_write_and_wait_range call, so we'd initiate writeback of the entire file, which (mostly) masked the thinko.
Drop the tricky PAGE_MASK and replace it with correct usage of PAGE_SIZE and the proper rounding macros.
--- fs/xfs/xfs_bmap_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_bmap_util.c +2 -2
@@ -1175,9 +1175,9 @@ xfs_free_file_space(* page could be mmap'd and iomap_zero_range doesn't do that for us. * Writeback of the eof page will do this, albeit clumsily. */ -if (offset + len >=XFS_ISIZE (ip) && ((offset + len) &PAGE_MASK )) { +if (offset + len >=XFS_ISIZE (ip) &&offset_in_page (offset + len) >0 ) { error =filemap_write_and_wait_range (VFS_I (ip)->i_mapping, - (offset + len) & ~PAGE_MASK ,LLONG_MAX ); +round_down (offset + len,PAGE_SIZE ),LLONG_MAX ); }return error;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 257/313 xfs: fix inverted return from xfs_btree_sblock_verify_crc
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
commit 7d048df4e9b05ba89b74d062df59498aa81f3785 upstream.
xfs_btree_sblock_verify_crc is a bool so should not be returning a failaddr_t; worse, if xfs_log_check_lsn fails it returns __this_address which looks like a boolean true (i.e. success) to the caller.
(interestingly xfs_btree_lblock_verify_crc doesn't have the issue)
--- fs/xfs/libxfs/xfs_btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_btree.c +1 -1
@@ -330,7 +330,7 @@ xfs_btree_sblock_verify_crc(if (xfs_sb_version_hascrc (&mp->m_sb)) {if (!xfs_log_check_lsn (mp,be64_to_cpu (block->bb_u.s.bb_lsn))) -return __this_address; +return false;return xfs_buf_verify_cksum (bp,XFS_BTREE_SBLOCK_CRC_OFF ); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 258/313 thermal: hwmon: inline helpers when CONFIG_THERMAL_HWMON is not set
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduardo Valentin <[email protected]>
commit 03334ba8b425b2ad275c8f390cf83c7b081c3095 upstream.
Avoid warnings like this:
thermal_hwmon.h:29:1: warning: ‘thermal_remove_hwmon_sysfs’ defined but not used [-Wunused-function]
thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
--- drivers/thermal/thermal_hwmon.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/thermal_hwmon.h +2 -2
@@ -19,13 +19,13 @@int thermal_add_hwmon_sysfs (struct thermal_zone_device *tz);void thermal_remove_hwmon_sysfs (struct thermal_zone_device *tz);#else -static int +static inline int thermal_add_hwmon_sysfs (struct thermal_zone_device *tz) {return 0 ; } -static void +static inline void thermal_remove_hwmon_sysfs (struct thermal_zone_device *tz) { }
Greg Kroah-Hartman
maintainerPATCH 259/313 dccp: fool proof ccid_hc_[rt]x_parse_options()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9b1f19d810e92d6cdc68455fbc22d9f961a58ce1 ]
Similarly to commit 276bdb82dedb ("dccp: check ccid before dereferencing") it is wise to test for a NULL ccid.
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] PREEMPT SMP KASAN CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 5.0.0-rc3+ #37 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:ccid_hc_tx_parse_options net/dccp/ccid.h:205 [inline] RIP: 0010:dccp_parse_options+0x8d9/0x12b0 net/dccp/options.c:233 Code: c5 0f b6 75 b3 80 38 00 0f 85 d6 08 00 00 48 b9 00 00 00 00 00 fc ff df 48 8b 45 b8 4c 8b b8 f8 07 00 00 4c 89 f8 48 c1 e8 03 <80> 3c 08 00 0f 85 95 08 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b kobject: 'loop5' (0000000080f78fc1): kobject_uevent_env RSP: 0018:ffff8880a94df0b8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff8880858ac723 RCX: dffffc0000000000 RDX: 0000000000000100 RSI: 0000000000000007 RDI: 0000000000000001 RBP: ffff8880a94df140 R08: 0000000000000001 R09: ffff888061b83a80 R10: ffffed100c370752 R11: ffff888061b83a97 R12: 0000000000000026 R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f0defa33518 CR3: 000000008db5e000 CR4: 00000000001406e0 kobject: 'loop5' (0000000080f78fc1): fill_kobj_path: path = '/devices/virtual/block/loop5' DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: dccp_rcv_state_process+0x2b6/0x1af6 net/dccp/input.c:654 dccp_v4_do_rcv+0x100/0x190 net/dccp/ipv4.c:688 sk_backlog_rcv include/net/sock.h:936 [inline] __sk_receive_skb+0x3a9/0xea0 net/core/sock.c:473 dccp_v4_rcv+0x10cb/0x1f80 net/dccp/ipv4.c:880 ip_protocol_deliver_rcu+0xb6/0xa20 net/ipv4/ip_input.c:208 ip_local_deliver_finish+0x23b/0x390 net/ipv4/ip_input.c:234 NF_HOOK include/linux/netfilter.h:289 [inline] NF_HOOK include/linux/netfilter.h:283 [inline] ip_local_deliver+0x1f0/0x740 net/ipv4/ip_input.c:255 dst_input include/net/dst.h:450 [inline] ip_rcv_finish+0x1f4/0x2f0 net/ipv4/ip_input.c:414 NF_HOOK include/linux/netfilter.h:289 [inline] NF_HOOK include/linux/netfilter.h:283 [inline] ip_rcv+0xed/0x620 net/ipv4/ip_input.c:524 __netif_receive_skb_one_core+0x160/0x210 net/core/dev.c:4973 __netif_receive_skb+0x2c/0x1c0 net/core/dev.c:5083 process_backlog+0x206/0x750 net/core/dev.c:5923 napi_poll net/core/dev.c:6346 [inline] net_rx_action+0x76d/0x1930 net/core/dev.c:6412 __do_softirq+0x30b/0xb11 kernel/softirq.c:292 run_ksoftirqd kernel/softirq.c:654 [inline] run_ksoftirqd+0x8e/0x110 kernel/softirq.c:646 smpboot_thread_fn+0x6ab/0xa10 kernel/smpboot.c:164 kthread+0x357/0x430 kernel/kthread.c:246 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352 Modules linked in: ---[ end trace 58a0ba03bea2c376 ]--- RIP: 0010:ccid_hc_tx_parse_options net/dccp/ccid.h:205 [inline] RIP: 0010:dccp_parse_options+0x8d9/0x12b0 net/dccp/options.c:233 Code: c5 0f b6 75 b3 80 38 00 0f 85 d6 08 00 00 48 b9 00 00 00 00 00 fc ff df 48 8b 45 b8 4c 8b b8 f8 07 00 00 4c 89 f8 48 c1 e8 03 <80> 3c 08 00 0f 85 95 08 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b RSP: 0018:ffff8880a94df0b8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff8880858ac723 RCX: dffffc0000000000 RDX: 0000000000000100 RSI: 0000000000000007 RDI: 0000000000000001 RBP: ffff8880a94df140 R08: 0000000000000001 R09: ffff888061b83a80 R10: ffffed100c370752 R11: ffff888061b83a97 R12: 0000000000000026 R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f0defa33518 CR3: 0000000009871000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
--- net/dccp/ccid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dccp/ccid.h +2 -2
@@ -202,7 +202,7 @@ static inline void ccid_hc_tx_packet_recstatic inline int ccid_hc_tx_parse_options (struct ccid *ccid,struct sock *sk,u8 pkt,u8 opt,u8 *val,u8 len) { -if (ccid->ccid_ops->ccid_hc_tx_parse_options ==NULL ) +if (!ccid || !ccid->ccid_ops->ccid_hc_tx_parse_options)return 0 ;return ccid->ccid_ops->ccid_hc_tx_parse_options (sk, pkt, opt, val, len); }
@@ -214,7 +214,7 @@ static inline int ccid_hc_tx_parse_optiostatic inline int ccid_hc_rx_parse_options (struct ccid *ccid,struct sock *sk,u8 pkt,u8 opt,u8 *val,u8 len) { -if (ccid->ccid_ops->ccid_hc_rx_parse_options ==NULL ) +if (!ccid || !ccid->ccid_ops->ccid_hc_rx_parse_options)return 0 ;return ccid->ccid_ops->ccid_hc_rx_parse_options (sk, pkt, opt, val, len); }
Greg Kroah-Hartman
maintainerPATCH 260/313 enic: fix checksum validation for IPv6
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Govindarajulu Varadarajan <[email protected]>
[ Upstream commit 7596175e99b3d4bce28022193efd954c201a782a ]
In case of IPv6 pkts, ipv4_csum_ok is 0. Because of this, driver does not set skb->ip_summed. So IPv6 rx checksum is not offloaded.
--- drivers/net/ethernet/cisco/enic/enic_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/cisco/enic/enic_main.c +2 -1
@@ -1434,7 +1434,8 @@ static void enic_rq_indicate_buf(struct* csum is correct or is zero. */ if ((netdev->features &NETIF_F_RXCSUM ) && !csum_not_calc && - tcp_udp_csum_ok && ipv4_csum_ok && outer_csum_ok) { + tcp_udp_csum_ok && outer_csum_ok && + (ipv4_csum_ok || ipv6)) { skb->ip_summed =CHECKSUM_UNNECESSARY ; skb->csum_level = encap; }
Greg Kroah-Hartman
maintainerPATCH 261/313 lib/test_rhashtable: Make test_insert_dup() allocate its hash table dynamically
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit fc42a689c4c097859e5bd37b5ea11b60dc426df6 ]
The test_insert_dup() function from lib/test_rhashtable.c passes a pointer to a stack object to rhltable_init(). Allocate the hash table dynamically to avoid that the following is reported with object debugging enabled:
ODEBUG: object (ptrval) is on stack (ptrval), but NOT annotated.
WARNING: CPU: 0 PID: 1 at lib/debugobjects.c:368 __debug_object_init+0x312/0x480 Modules linked in: EIP: __debug_object_init+0x312/0x480 Call Trace: ? debug_object_init+0x1a/0x20 ? __init_work+0x16/0x30 ? rhashtable_init+0x1e1/0x460 ? sched_clock_cpu+0x57/0xe0 ? rhltable_init+0xb/0x20 ? test_insert_dup+0x32/0x20f ? trace_hardirqs_on+0x38/0xf0 ? ida_dump+0x10/0x10 ? jhash+0x130/0x130 ? my_hashfn+0x30/0x30 ? test_rht_init+0x6aa/0xab4 ? ida_dump+0x10/0x10 ? test_rhltable+0xc5c/0xc5c ? do_one_initcall+0x67/0x28e ? trace_hardirqs_off+0x22/0xe0 ? restore_all_kernel+0xf/0x70 ? trace_hardirqs_on_thunk+0xc/0x10 ? restore_all_kernel+0xf/0x70 ? kernel_init_freeable+0x142/0x213 ? rest_init+0x230/0x230 ? kernel_init+0x10/0x110 ? schedule_tail_wrapper+0x9/0xc ? ret_from_fork+0x19/0x24
--- lib/test_rhashtable.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
lib/test_rhashtable.c +15 -8
@@ -541,38 +541,45 @@ static unsigned int __init print_ht(strustatic int __init test_insert_dup (struct test_obj_rhl *rhl_test_objects,int cnt,bool slow) { -struct rhltable rhlt; +struct rhltable *rhlt;unsigned int i, ret;const char *key;int err =0 ; - err =rhltable_init (&rhlt, &test_rht_params_dup); -if (WARN_ON (err)) + rhlt =kmalloc (sizeof (*rhlt),GFP_KERNEL ); +if (WARN_ON (!rhlt)) +return -EINVAL ; + + err =rhltable_init (rhlt, &test_rht_params_dup); +if (WARN_ON (err)) { +kfree (rhlt);return err; + }for (i =0 ; i < cnt; i++) { rhl_test_objects[i].value.tid = i; - key =rht_obj (&rhlt.ht, &rhl_test_objects[i].list_node.rhead); + key =rht_obj (&rhlt->ht, &rhl_test_objects[i].list_node.rhead); key += test_rht_params_dup.key_offset;if (slow) { - err =PTR_ERR (rhashtable_insert_slow (&rhlt.ht, key, + err =PTR_ERR (rhashtable_insert_slow (&rhlt->ht, key, &rhl_test_objects[i].list_node.rhead));if (err == -EAGAIN ) err =0 ; }else - err =rhltable_insert (&rhlt, + err =rhltable_insert (rhlt, &rhl_test_objects[i].list_node, test_rht_params_dup);if (WARN (err,"error %d on element %d/%d (%s)\n" , err, i, cnt, slow?"slow" :"fast" )) goto skip_print; } - ret =print_ht (&rhlt); + ret =print_ht (rhlt);WARN (ret != cnt,"missing rhltable elements (%d != %d, %s)\n" , ret, cnt, slow?"slow" :"fast" ); skip_print: -rhltable_destroy (&rhlt); +rhltable_destroy (rhlt); +kfree (rhlt);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 262/313 net: dp83640: expire old TX-skb
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 53bc8d2af08654659abfadfd3e98eb9922ff787c ]
During sendmsg() a cloned skb is saved via dp83640_txtstamp() in ->tx_queue. After the NIC sends this packet, the PHY will reply with a timestamp for that TX packet. If the cable is pulled at the right time I don't see that packet. It might gets flushed as part of queue shutdown on NIC's side.
Once the link is up again then after the next sendmsg() we enqueue another skb in dp83640_txtstamp() and have two on the list. Then the PHY will send a reply and decode_txts() attaches it to the first skb on the list.
No crash occurs since refcounting works but we are one packet behind. linuxptp/ptp4l usually closes the socket and opens a new one (in such a timeout case) so those "stale" replies never get there. However it does not resume normal operation anymore.
Purge old skbs in decode_txts().
--- drivers/net/phy/dp83640.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/phy/dp83640.c +10 -3
@@ -896,14 +896,14 @@ static void decode_txts(struct dp83640_p struct phy_txts *phy_txts) {struct skb_shared_hwtstamps shhwtstamps; +struct dp83640_skb_info *skb_info;struct sk_buff *skb; -u64 ns;u8 overflow; +u64 ns;/* We must already have the skb that triggered this. */ - +again: skb =skb_dequeue (&dp83640->tx_queue); -if (!skb) {pr_debug ("have timestamp but tx_queue empty\n" );return ;
@@ -918,6 +918,11 @@ static void decode_txts(struct dp83640_p }return ; } + skb_info = (struct dp83640_skb_info *)skb->cb; +if (time_after (jiffies, skb_info->tmo)) { +kfree_skb (skb); + goto again; + } ns =phy2txts (phy_txts);memset (&shhwtstamps,0 ,sizeof (shhwtstamps));
@@ -1470,6 +1475,7 @@ static bool dp83640_rxtstamp(struct phy_static void dp83640_txtstamp (struct phy_device *phydev,struct sk_buff *skb,int type) { +struct dp83640_skb_info *skb_info = (struct dp83640_skb_info *)skb->cb;struct dp83640_private *dp83640 = phydev->priv;switch (dp83640->hwts_tx_en) {
@@ -1482,6 +1488,7 @@ static void dp83640_txtstamp(struct phy_/* fall through */ case HWTSTAMP_TX_ON :skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; + skb_info->tmo = jiffies +SKB_TIMESTAMP_TIMEOUT ;skb_queue_tail (&dp83640->tx_queue, skb);break ;
Greg Kroah-Hartman
maintainerPATCH 263/313 net: dsa: Fix lockdep false positive splat
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit c8101f7729daee251f4f6505f9d135ec08e1342f ]
Creating a macvtap on a DSA-backed interface results in the following splat when lockdep is enabled:
[ 19.638080] IPv6: ADDRCONF(NETDEV_CHANGE): lan0: link becomes ready
[ 23.041198] device lan0 entered promiscuous mode
[ 23.043445] device eth0 entered promiscuous mode
[ 23.049255]
[ 23.049557] ============================================
[ 23.055021] WARNING: possible recursive locking detected
[ 23.060490] 5.0.0-rc3-00013-g56c857a1b8d3 #118 Not tainted
[ 23.066132] --------------------------------------------
[ 23.071598] ip/2861 is trying to acquire lock:
[ 23.076171] 00000000f61990cb (_xmit_ETHER){+...}, at: dev_set_rx_mode+0x1c/0x38
[ 23.083693]
[ 23.083693] but task is already holding lock:
[ 23.089696] 00000000ecf0c3b4 (_xmit_ETHER){+...}, at: dev_uc_add+0x24/0x70
[ 23.096774]
[ 23.096774] other info that might help us debug this:
[ 23.103494] Possible unsafe locking scenario:
[ 23.103494]
[ 23.109584] CPU0
[ 23.112093] ----
[ 23.114601] lock(_xmit_ETHER);
[ 23.117917] lock(_xmit_ETHER);
[ 23.121233]
[ 23.121233] *** DEADLOCK ***
[ 23.121233]
[ 23.127325] May be due to missing lock nesting notation
[ 23.127325]
[ 23.134315] 2 locks held by ip/2861:
[ 23.137987] #0: 000000003b766c72 (rtnl_mutex){+.+.}, at: rtnetlink_rcv_msg+0x338/0x4e0
[ 23.146231] #1: 00000000ecf0c3b4 (_xmit_ETHER){+...}, at: dev_uc_add+0x24/0x70
[ 23.153757]
[ 23.153757] stack backtrace:
[ 23.158243] CPU: 0 PID: 2861 Comm: ip Not tainted 5.0.0-rc3-00013-g56c857a1b8d3 #118
[ 23.166212] Hardware name: Globalscale Marvell ESPRESSOBin Board (DT)
[ 23.172843] Call trace:
[ 23.175358] dump_backtrace+0x0/0x188
[ 23.179116] show_stack+0x14/0x20
[ 23.182524] dump_stack+0xb4/0xec
[ 23.185928] __lock_acquire+0x123c/0x1860
[ 23.190048] lock_acquire+0xc8/0x248
[ 23.193724] _raw_spin_lock_bh+0x40/0x58
[ 23.197755] dev_set_rx_mode+0x1c/0x38
[ 23.201607] dev_set_promiscuity+0x3c/0x50
[ 23.205820] dsa_slave_change_rx_flags+0x5c/0x70
[ 23.210567] __dev_set_promiscuity+0x148/0x1e0
[ 23.215136] __dev_set_rx_mode+0x74/0x98
[ 23.219167] dev_uc_add+0x54/0x70
[ 23.222575] macvlan_open+0x170/0x1d0
[ 23.226336] __dev_open+0xe0/0x160
[ 23.229830] __dev_change_flags+0x16c/0x1b8
[ 23.234132] dev_change_flags+0x20/0x60
[ 23.238074] do_setlink+0x2d0/0xc50
[ 23.241658] __rtnl_newlink+0x5f8/0x6e8
[ 23.245601] rtnl_newlink+0x50/0x78
[ 23.249184] rtnetlink_rcv_msg+0x360/0x4e0
[ 23.253397] netlink_rcv_skb+0xe8/0x130
[ 23.257338] rtnetlink_rcv+0x14/0x20
[ 23.261012] netlink_unicast+0x190/0x210
[ 23.265043] netlink_sendmsg+0x288/0x350
[ 23.269075] sock_sendmsg+0x18/0x30
[ 23.272659] ___sys_sendmsg+0x29c/0x2c8
[ 23.276602] __sys_sendmsg+0x60/0xb8
[ 23.280276] __arm64_sys_sendmsg+0x1c/0x28
[ 23.284488] el0_svc_common+0xd8/0x138
[ 23.288340] el0_svc_handler+0x24/0x80
[ 23.292192] el0_svc+0x8/0xcThis looks fairly harmless (no actual deadlock occurs), and is fixed in a similar way to c6894dec8ea9 ("bridge: fix lockdep addr_list_lock false positive splat") by putting the addr_list_lock in its own lockdep class.
--- net/dsa/master.c | 4 ++++ 1 file changed, 4 insertions(+)
net/dsa/master.c +4 -0
@@ -158,6 +158,8 @@ static void dsa_master_ethtool_teardown( cpu_dp->orig_ethtool_ops =NULL ; } +static struct lock_class_key dsa_master_addr_list_lock_key; +int dsa_master_setup (struct net_device *dev,struct dsa_port *cpu_dp) {/* If we use a tagging format that doesn't have an ethertype
@@ -167,6 +169,8 @@ int dsa_master_setup(struct net_device *wmb (); dev->dsa_ptr = cpu_dp; +lockdep_set_class (&dev->addr_list_lock, + &dsa_master_addr_list_lock_key);return dsa_master_ethtool_setup (dev); }
Greg Kroah-Hartman
maintainerPATCH 264/313 net: dsa: Fix NULL checking in dsa_slave_set_eee()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 00670cb8a73b10b10d3c40f045c15411715e4465 ]
This function can't succeed if dp->pl is NULL. It will Oops inside the call to return phylink_ethtool_get_eee(dp->pl, e);
--- net/dsa/slave.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/slave.c +2 -2
@@ -639,7 +639,7 @@ static int dsa_slave_set_eee(struct net_int ret;/* Port's PHY and MAC both need to be EEE capable */ -if (!dev->phydev && !dp->pl) +if (!dev->phydev || !dp->pl)return -ENODEV ;if (!ds->ops->set_mac_eee)
@@ -659,7 +659,7 @@ static int dsa_slave_get_eee(struct net_int ret;/* Port's PHY and MAC both need to be EEE capable */ -if (!dev->phydev && !dp->pl) +if (!dev->phydev || !dp->pl)return -ENODEV ;if (!ds->ops->get_mac_eee)
Greg Kroah-Hartman
maintainerPATCH 265/313 net: dsa: mv88e6xxx: Fix counting of ATU violations
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lunn <[email protected]>
[ Upstream commit 75c05a74e745ae7d663b04d75777af80ada2233c ]
The ATU port vector contains a bit per port of the switch. The code wrongly used it as a port number, and incremented a port counter. This resulted in the wrong interfaces counter being incremented, and potentially going off the end of the array of ports.
Fix this by using the source port ID for the violation, which really is a port number.
--- drivers/net/dsa/mv88e6xxx/global1_atu.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/net/dsa/mv88e6xxx/global1_atu.c +12 -9
@@ -314,6 +314,7 @@ static irqreturn_t mv88e6xxx_g1_atu_prob {struct mv88e6xxx_chip *chip = dev_id;struct mv88e6xxx_atu_entry entry; +int spid;int err;u16 val;
@@ -336,6 +337,8 @@ static irqreturn_t mv88e6xxx_g1_atu_probif (err) goto out; + spid = entry.state; +if (val &MV88E6XXX_G1_ATU_OP_AGE_OUT_VIOLATION ) { dev_err_ratelimited(chip->dev, "ATU age out violation for %pM\n",
@@ -344,23 +347,23 @@ static irqreturn_t mv88e6xxx_g1_atu_probif (val &MV88E6XXX_G1_ATU_OP_MEMBER_VIOLATION ) {dev_err_ratelimited (chip->dev, -"ATU member violation for %pM portvec %x\n" , - entry.mac, entry.portvec); - chip->ports[entry.portvec].atu_member_violation++; +"ATU member violation for %pM portvec %x spid %d\n" , + entry.mac, entry.portvec, spid); + chip->ports[spid].atu_member_violation++; }if (val &MV88E6XXX_G1_ATU_OP_MISS_VIOLATION ) {dev_err_ratelimited (chip->dev, -"ATU miss violation for %pM portvec %x\n" , - entry.mac, entry.portvec); - chip->ports[entry.portvec].atu_miss_violation++; +"ATU miss violation for %pM portvec %x spid %d\n" , + entry.mac, entry.portvec, spid); + chip->ports[spid].atu_miss_violation++; }if (val &MV88E6XXX_G1_ATU_OP_FULL_VIOLATION ) {dev_err_ratelimited (chip->dev, -"ATU full violation for %pM portvec %x\n" , - entry.mac, entry.portvec); - chip->ports[entry.portvec].atu_full_violation++; +"ATU full violation for %pM portvec %x spid %d\n" , + entry.mac, entry.portvec, spid); + chip->ports[spid].atu_full_violation++; }mutex_unlock (&chip->reg_lock);
Greg Kroah-Hartman
maintainerPATCH 266/313 net: dsa: slave: Dont propagate flag changes on down slave interfaces
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rundong Ge <[email protected]>
[ Upstream commit 17ab4f61b8cd6f9c38e9d0b935d86d73b5d0d2b5 ]
The unbalance of master's promiscuity or allmulti will happen after ifdown and ifup a slave interface which is in a bridge.
When we ifdown a slave interface , both the 'dsa_slave_close' and 'dsa_slave_change_rx_flags' will clear the master's flags. The flags of master will be decrease twice.
In the other hand, if we ifup the slave interface again, since the slave's flags were cleared the 'dsa_slave_open' won't set the master's flag, only 'dsa_slave_change_rx_flags' that triggered by 'br_add_if' will set the master's flags. The flags of master is increase once.
Only propagating flag changes when a slave interface is up makes sure this does not happen. The 'vlan_dev_change_rx_flags' had the same problem and was fixed, and changes here follows that fix.
--- net/dsa/slave.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/dsa/slave.c +8 -5
@@ -140,11 +140,14 @@ static int dsa_slave_close(struct net_destatic void dsa_slave_change_rx_flags (struct net_device *dev,int change) {struct net_device *master =dsa_slave_to_master (dev); - -if (change &IFF_ALLMULTI ) -dev_set_allmulti (master, dev->flags &IFF_ALLMULTI ?1 :-1 ); -if (change &IFF_PROMISC ) -dev_set_promiscuity (master, dev->flags &IFF_PROMISC ?1 :-1 ); +if (dev->flags &IFF_UP ) { +if (change &IFF_ALLMULTI ) +dev_set_allmulti (master, + dev->flags &IFF_ALLMULTI ?1 :-1 ); +if (change &IFF_PROMISC ) +dev_set_promiscuity (master, + dev->flags &IFF_PROMISC ?1 :-1 ); + } }static void dsa_slave_set_rx_mode (struct net_device *dev)
Greg Kroah-Hartman
maintainerPATCH 267/313 net/mlx5e: Force CHECKSUM_UNNECESSARY for short ethernet frames
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit e8c8b53ccaff568fef4c13a6ccaf08bf241aa01a ]
When an ethernet frame is padded to meet the minimum ethernet frame size, the padding octets are not covered by the hardware checksum. Fortunately the padding octets are usually zero's, which don't affect checksum. However, we have a switch which pads non-zero octets, this causes kernel hardware checksum fault repeatedly.
Prior to:
commit '88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE ...")' skb checksum was forced to be CHECKSUM_NONE when padding is detected. After it, we need to keep skb->csum updated, like what we do for RXFCS. However, fixing up CHECKSUM_COMPLETE requires to verify and parse IP headers, it is not worthy the effort as the packets are so small that CHECKSUM_COMPLETE can't save anything.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +14 -0
@@ -707,6 +707,8 @@ static u32 mlx5e_get_fcs(const struct skreturn __get_unaligned_cpu32 (fcs_bytes); } +#define short_frame (size) ((size) <= ETH_ZLEN + ETH_FCS_LEN) + static inline void mlx5e_handle_csum(struct net_device *netdev, struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq,
@@ -725,6 +727,17 @@ static inline void mlx5e_handle_csum(strreturn ; } +/* CQE csum doesn't cover padding octets in short ethernet +* frames. And the pad field is appended prior to calculating +* and appending the FCS field. +* +* Detecting these padded frames requires to verify and parse +* IP headers, so we simply force all those small frames to be +* CHECKSUM_UNNECESSARY even if they are not padded. +*/ +if (short_frame (skb->len)) + goto csum_unnecessary; +if (likely (is_last_ethertype_ip (skb, &network_depth))) { skb->ip_summed =CHECKSUM_COMPLETE ; skb->csum =csum_unfold ((__force __sum16 )cqe->check_sum);
@@ -744,6 +757,7 @@ static inline void mlx5e_handle_csum(strreturn ; } +csum_unnecessary:if (likely ((cqe->hds_ip_ext &CQE_L3_OK ) && (cqe->hds_ip_ext &CQE_L4_OK ))) { skb->ip_summed =CHECKSUM_UNNECESSARY ;
Greg Kroah-Hartman
maintainerPATCH 268/313 net: systemport: Fix WoL with password after deep sleep
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 8dfb8d2cceb76b74ad5b58cc65c75994329b4d5e ]
Broadcom STB chips support a deep sleep mode where all register contents are lost. Because we were stashing the MagicPacket password into some of these registers a suspend into that deep sleep then a resumption would not lead to being able to wake-up from MagicPacket with password again.
Fix this by keeping a software copy of the password and program it during suspend.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 25 ++++++++++--------------- drivers/net/ethernet/broadcom/bcmsysport.h | 2 ++ 2 files changed, 12 insertions(+), 15 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +10 -15
@@ -519,7 +519,6 @@ static void bcm_sysport_get_wol(struct n struct ethtool_wolinfo *wol) {struct bcm_sysport_priv *priv =netdev_priv (dev); -u32 reg; wol->supported =WAKE_MAGIC |WAKE_MAGICSECURE |WAKE_FILTER ; wol->wolopts = priv->wolopts;
@@ -527,11 +526,7 @@ static void bcm_sysport_get_wol(struct nif (!(priv->wolopts &WAKE_MAGICSECURE ))return ; -/* Return the programmed SecureOn password */ - reg =umac_readl (priv,UMAC_PSW_MS ); -put_unaligned_be16 (reg, &wol->sopass[0 ]); - reg =umac_readl (priv,UMAC_PSW_LS ); -put_unaligned_be32 (reg, &wol->sopass[2 ]); +memcpy (wol->sopass, priv->sopass,sizeof (priv->sopass)); } static int bcm_sysport_set_wol(struct net_device *dev,
@@ -547,13 +542,8 @@ static int bcm_sysport_set_wol(struct neif (wol->wolopts & ~supported)return -EINVAL ; -/* Program the SecureOn password */ -if (wol->wolopts &WAKE_MAGICSECURE ) { -umac_writel (priv,get_unaligned_be16 (&wol->sopass[0 ]), -UMAC_PSW_MS ); -umac_writel (priv,get_unaligned_be32 (&wol->sopass[2 ]), -UMAC_PSW_LS ); - } +if (wol->wolopts &WAKE_MAGICSECURE ) +memcpy (priv->sopass, wol->sopass,sizeof (priv->sopass));/* Flag the device and relevant IRQ as wakeup capable */ if (wol->wolopts) {
@@ -2588,13 +2578,18 @@ static int bcm_sysport_suspend_to_wol(stunsigned int index, i =0 ;u32 reg; -/* Password has already been programmed */ reg =umac_readl (priv,UMAC_MPD_CTRL );if (priv->wolopts & (WAKE_MAGIC |WAKE_MAGICSECURE )) reg |=MPD_EN ; reg &= ~PSW_EN ; -if (priv->wolopts &WAKE_MAGICSECURE ) +if (priv->wolopts &WAKE_MAGICSECURE ) { +/* Program the SecureOn password */ +umac_writel (priv,get_unaligned_be16 (&priv->sopass[0 ]), +UMAC_PSW_MS ); +umac_writel (priv,get_unaligned_be32 (&priv->sopass[2 ]), +UMAC_PSW_LS ); reg |=PSW_EN ; + }umac_writel (priv, reg,UMAC_MPD_CTRL );if (priv->wolopts &WAKE_FILTER ) {
drivers/net/ethernet/broadcom/bcmsysport.h +2 -0
@@ -12,6 +12,7 @@#define __BCM_SYSPORT_H#include <linux/bitmap.h> +#include <linux/ethtool.h> #include <linux/if_vlan.h> #include <linux/net_dim.h>
@@ -776,6 +777,7 @@ struct bcm_sysport_priv { unsigned int crc_fwd:1;u16 rev;u32 wolopts; +u8 sopass[SOPASS_MAX ]; unsigned int wol_irq_disabled:1;/* MIB related fields */
Greg Kroah-Hartman
maintainerPATCH 269/313 rds: fix refcount bug in rds_sock_addref
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 6fa19f5637a6c22bc0999596bcc83bdcac8a4fa6 ]
syzbot was able to catch a bug in rds [1]
The issue here is that the socket might be found in a hash table but that its refcount has already be set to 0 by another cpu.
We need to use refcount_inc_not_zero() to be safe here.
[1]
refcount_t: increment on 0; use-after-free.
WARNING: CPU: 1 PID: 23129 at lib/refcount.c:153 refcount_inc_checked lib/refcount.c:153 [inline] WARNING: CPU: 1 PID: 23129 at lib/refcount.c:153 refcount_inc_checked+0x61/0x70 lib/refcount.c:151 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 23129 Comm: syz-executor3 Not tainted 5.0.0-rc4+ #53 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 panic+0x2cb/0x65c kernel/panic.c:214 __warn.cold+0x20/0x48 kernel/panic.c:571 report_bug+0x263/0x2b0 lib/bug.c:186 fixup_bug arch/x86/kernel/traps.c:178 [inline] fixup_bug arch/x86/kernel/traps.c:173 [inline] do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:271 do_invalid_op+0x37/0x50 arch/x86/kernel/traps.c:290 invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:973 RIP: 0010:refcount_inc_checked lib/refcount.c:153 [inline] RIP: 0010:refcount_inc_checked+0x61/0x70 lib/refcount.c:151 Code: 1d 51 63 c8 06 31 ff 89 de e8 eb 1b f2 fd 84 db 75 dd e8 a2 1a f2 fd 48 c7 c7 60 9f 81 88 c6 05 31 63 c8 06 01 e8 af 65 bb fd <0f> 0b eb c1 90 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 41 54 49 RSP: 0018:ffff8880a0cbf1e8 EFLAGS: 00010282 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc90006113000 RDX: 000000000001047d RSI: ffffffff81685776 RDI: 0000000000000005 RBP: ffff8880a0cbf1f8 R08: ffff888097c9e100 R09: ffffed1015ce5021 R10: ffffed1015ce5020 R11: ffff8880ae728107 R12: ffff8880723c20c0 R13: ffff8880723c24b0 R14: dffffc0000000000 R15: ffffed1014197e64 sock_hold include/net/sock.h:647 [inline] rds_sock_addref+0x19/0x20 net/rds/af_rds.c:675 rds_find_bound+0x97c/0x1080 net/rds/bind.c:82 rds_recv_incoming+0x3be/0x1430 net/rds/recv.c:362 rds_loop_xmit+0xf3/0x2a0 net/rds/loop.c:96 rds_send_xmit+0x1355/0x2a10 net/rds/send.c:355 rds_sendmsg+0x323c/0x44e0 net/rds/send.c:1368 sock_sendmsg_nosec net/socket.c:621 [inline] sock_sendmsg+0xdd/0x130 net/socket.c:631 __sys_sendto+0x387/0x5f0 net/socket.c:1788 __do_sys_sendto net/socket.c:1800 [inline] __se_sys_sendto net/socket.c:1796 [inline] __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1796 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x458089 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:00007fc266df8c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 0000000000458089 RDX: 0000000000000000 RSI: 00000000204b3fff RDI: 0000000000000005 RBP: 000000000073bf00 R08: 00000000202b4000 R09: 0000000000000010 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fc266df96d4 R13: 00000000004c56e4 R14: 00000000004d94a8 R15: 00000000ffffffff
--- net/rds/bind.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/rds/bind.c +3 -3
@@ -78,10 +78,10 @@ struct rds_sock *rds_find_bound(const st__rds_create_bind_key (key, addr, port, scope_id);rcu_read_lock (); rs =rhashtable_lookup (&bind_hash_table, key, ht_parms); -if (rs && !sock_flag (rds_rs_to_sk (rs),SOCK_DEAD )) -rds_sock_addref (rs); -else +if (rs && (sock_flag (rds_rs_to_sk (rs),SOCK_DEAD ) || + !refcount_inc_not_zero (&rds_rs_to_sk (rs)->sk_refcnt))) rs =NULL ; +rcu_read_unlock (); rdsdebug("returning rs %p for %pI6c:%u\n", rs, addr,
Greg Kroah-Hartman
maintainerPATCH 270/313 Revert "net: phy: marvell: avoid pause mode on SGMII-to-Copper for 88e151x"
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
[ Upstream commit c14f07c6211cc01d52ed92cce1fade5071b8d197 ]
This reverts commit 6623c0fba10ef45b64ca213ad5dec926f37fa9a0.
The original diagnosis was incorrect: it appears that the NIC had PHY polling mode enabled, which meant that it overwrote the PHYs advertisement register during negotiation.
--- drivers/net/phy/marvell.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/net/phy/marvell.c +0 -12
@@ -868,8 +868,6 @@ static int m88e1510_config_init(struct p/* SGMII-to-Copper mode initialization */ if (phydev->interface ==PHY_INTERFACE_MODE_SGMII ) { -u32 pause; -/* Select page 18 */ err =marvell_set_page (phydev,18 );if (err <0 )
@@ -892,16 +890,6 @@ static int m88e1510_config_init(struct p err =marvell_set_page (phydev,MII_MARVELL_COPPER_PAGE );if (err <0 )return err; - -/* There appears to be a bug in the 88e1512 when used in -* SGMII to copper mode, where the AN advertisement register -* clears the pause bits each time a negotiation occurs. -* This means we can never be truely sure what was advertised, -* so disable Pause support. -*/ - pause = SUPPORTED_Pause | SUPPORTED_Asym_Pause; - phydev->supported &= ~pause; - phydev->advertising &= ~pause; }return m88e1318_config_init (phydev);
Greg Kroah-Hartman
maintainerPATCH 271/313 rxrpc: bad unlock balance in rxrpc_recvmsg
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 6dce3c20ac429e7a651d728e375853370c796e8d ]
When either "goto wait_interrupted;" or "goto wait_error;" paths are taken, socket lock has already been released.
This patch fixes following syzbot splat :
WARNING: bad unlock balance detected!
5.0.0-rc4+ #59 Not tainted
-------------------------------------
syz-executor223/8256 is trying to release lock (sk_lock-AF_RXRPC) at:
[<ffffffff86651353>] rxrpc_recvmsg+0x6d3/0x3099 net/rxrpc/recvmsg.c:598 but there are no more locks to release!
other info that might help us debug this:
1 lock held by syz-executor223/8256:
#0: 00000000fa9ed0f4 (slock-AF_RXRPC){+...}, at: spin_lock_bh include/linux/spinlock.h:334 [inline] #0: 00000000fa9ed0f4 (slock-AF_RXRPC){+...}, at: release_sock+0x20/0x1c0 net/core/sock.c:2798
stack backtrace: CPU: 1 PID: 8256 Comm: syz-executor223 Not tainted 5.0.0-rc4+ #59 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+0x172/0x1f0 lib/dump_stack.c:113 print_unlock_imbalance_bug kernel/locking/lockdep.c:3391 [inline] print_unlock_imbalance_bug.cold+0x114/0x123 kernel/locking/lockdep.c:3368 __lock_release kernel/locking/lockdep.c:3601 [inline] lock_release+0x67e/0xa00 kernel/locking/lockdep.c:3860 sock_release_ownership include/net/sock.h:1471 [inline] release_sock+0x183/0x1c0 net/core/sock.c:2808 rxrpc_recvmsg+0x6d3/0x3099 net/rxrpc/recvmsg.c:598 sock_recvmsg_nosec net/socket.c:794 [inline] sock_recvmsg net/socket.c:801 [inline] sock_recvmsg+0xd0/0x110 net/socket.c:797 __sys_recvfrom+0x1ff/0x350 net/socket.c:1845 __do_sys_recvfrom net/socket.c:1863 [inline] __se_sys_recvfrom net/socket.c:1859 [inline] __x64_sys_recvfrom+0xe1/0x1a0 net/socket.c:1859 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x446379 Code: e8 2c b3 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 2b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fe5da89fd98 EFLAGS: 00000246 ORIG_RAX: 000000000000002d RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 0000000000446379 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00000000006dbc20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc2c R13: 0000000000000000 R14: 0000000000000000 R15: 20c49ba5e353f7cf
--- net/rxrpc/recvmsg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/rxrpc/recvmsg.c +2 -1
@@ -596,6 +596,7 @@ error_requeue_call: } error_no_call:release_sock (&rx->sk); +error_trace:trace_rxrpc_recvmsg (call, rxrpc_recvmsg_return,0 ,0 ,0 , ret);return ret;
@@ -604,7 +605,7 @@ wait_interrupted: wait_error:finish_wait (sk_sleep (&rx->sk), &wait); call =NULL ; - goto error_no_call; + goto error_trace; }/**
Greg Kroah-Hartman
maintainerPATCH 272/313 sctp: check and update stream->out_curr when allocating stream_out
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit cfe4bd7a257f6d6f81d3458d8c9d9ec4957539e6 ]
Now when using stream reconfig to add out streams, stream->out will get re-allocated, and all old streams' information will be copied to the new ones and the old ones will be freed.
So without stream->out_curr updated, next time when trying to send from stream->out_curr stream, a panic would be caused.
This patch is to check and update stream->out_curr when allocating stream_out.
v1->v2:
- define fa_index() to get elem index from stream->out_curr.v2->v3:
- repost with no change.
--- net/sctp/stream.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
net/sctp/stream.c +20 -0
@@ -84,6 +84,19 @@ static void fa_zero(struct flex_array *f } } +static size_t fa_index (struct flex_array *fa,void *elem,size_t count) +{ +size_t index =0 ; + +while (count--) { +if (elem ==flex_array_get (fa, index)) +break ; + index++; + } + +return index; +} +/* Migrates chunks from stream queues to new stream queues if needed, * but not across associations. Also, removes those chunks to streams * higher than the new max.
@@ -147,6 +160,13 @@ static int sctp_stream_alloc_out(structif (stream->out) {fa_copy (out, stream->out,0 ,min (outcnt, stream->outcnt)); +if (stream->out_curr) { +size_t index =fa_index (stream->out, stream->out_curr, + stream->outcnt); + +BUG_ON (index == stream->outcnt); + stream->out_curr =flex_array_get (out, index); + }fa_free (stream->out); }
Greg Kroah-Hartman
maintainerPATCH 273/313 sctp: walk the list of asoc safely
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit ba59fb0273076637f0add4311faa990a5eec27c0 ]
In sctp_sendmesg(), when walking the list of endpoint associations, the association can be dropped from the list, making the list corrupt. Properly handle this by using list_for_each_entry_safe()
--- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sctp/socket.c +2 -2
@@ -2045,7 +2045,7 @@ static int sctp_sendmsg(struct sock *sk,struct sctp_endpoint *ep =sctp_sk (sk)->ep;struct sctp_transport *transport =NULL ;struct sctp_sndrcvinfo _sinfo, *sinfo; -struct sctp_association *asoc; +struct sctp_association *asoc, *tmp;struct sctp_cmsgs cmsgs;union sctp_addr *daddr;bool new = false;
@@ -2071,7 +2071,7 @@ static int sctp_sendmsg(struct sock *sk,/* SCTP_SENDALL process */ if ((sflags &SCTP_SENDALL ) &&sctp_style (sk,UDP )) { -list_for_each_entry (asoc, &ep->asocs, asocs) { +list_for_each_entry_safe (asoc, tmp, &ep->asocs, asocs) { err =sctp_sendmsg_check_sflags (asoc, sflags, msg, msg_len);if (err ==0 )
Greg Kroah-Hartman
maintainerPATCH 274/313 skge: potential memory corruption in skge_get_regs()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 294c149a209c6196c2de85f512b52ef50f519949 ]
The "p" buffer is 0x4000 bytes long. B3_RI_WTO_R1 is 0x190. The value of "regs->len" is in the 1-0x4000 range. The bug here is that "regs->len - B3_RI_WTO_R1" can be a negative value which would lead to memory corruption and an abrupt crash.
--- drivers/net/ethernet/marvell/skge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/skge.c +4 -2
@@ -152,8 +152,10 @@ static void skge_get_regs(struct net_devmemset (p,0 , regs->len);memcpy_fromio (p, io,B3_RAM_ADDR ); -memcpy_fromio (p +B3_RI_WTO_R1 , io +B3_RI_WTO_R1 , - regs->len -B3_RI_WTO_R1 ); +if (regs->len >B3_RI_WTO_R1 ) { +memcpy_fromio (p +B3_RI_WTO_R1 , io +B3_RI_WTO_R1 , + regs->len -B3_RI_WTO_R1 ); + } }/* Wake on Lan only supported on Yukon chips with rev 1 or above */
Greg Kroah-Hartman
maintainerPATCH 275/313 virtio_net: Account for tx bytes and packets on sending xdp_frames
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toshiaki Makita <[email protected]>
[ Upstream commit 546f28974d771b124fb0bf7b551b343888cf0419 ]
Previously virtnet_xdp_xmit() did not account for device tx counters, which caused confusions.
To be consistent with SKBs, account them on freeing xdp_frames.
--- drivers/net/virtio_net.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/net/virtio_net.c +16 -4
@@ -502,6 +502,8 @@ static int virtnet_xdp_xmit(struct net_dstruct bpf_prog *xdp_prog;struct send_queue *sq;unsigned int len; +int packets =0 ; +int bytes =0 ;int drops =0 ;int kicks =0 ;int ret, err;
@@ -525,10 +527,18 @@ static int virtnet_xdp_xmit(struct net_d/* Free up any pending old buffers before queueing new ones. */ while ((ptr =virtqueue_get_buf (sq->vq, &len)) !=NULL ) { -if (likely (is_xdp_frame (ptr))) -xdp_return_frame (ptr_to_xdp (ptr)); -else -napi_consume_skb (ptr, false); +if (likely (is_xdp_frame (ptr))) { +struct xdp_frame *frame =ptr_to_xdp (ptr); + + bytes += frame->len; +xdp_return_frame (frame); + }else { +struct sk_buff *skb = ptr; + + bytes += skb->len; +napi_consume_skb (skb, false); + } + packets++; }for (i =0 ; i < n; i++) {
@@ -548,6 +558,8 @@ static int virtnet_xdp_xmit(struct net_d } out:u64_stats_update_begin (&sq->stats.syncp); + sq->stats.bytes += bytes; + sq->stats.packets += packets; sq->stats.xdp_tx += n; sq->stats.xdp_tx_drops += drops; sq->stats.kicks += kicks;
Greg Kroah-Hartman
maintainerPATCH 276/313 net/mlx5e: FPGA, fix Innova IPsec TX offload data path performance
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raed Salem <[email protected]>
[ Upstream commit 82eaa1fa0448da1852d7b80832e67e80a08dcc27 ]
At Innova IPsec TX offload data path a special software parser metadata is used to pass some packet attributes to the hardware, this metadata is passed using the Ethernet control segment of a WQE (a HW descriptor) header.
The cited commit might nullify this header, hence the metadata is lost, this caused a significant performance drop during hw offloading operation.
Fix by restoring the metadata at the Ethernet control segment in case it was nullified.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +6 -0
@@ -387,8 +387,14 @@ netdev_tx_t mlx5e_sq_xmit(struct mlx5e_t num_wqebbs =DIV_ROUND_UP (ds_cnt,MLX5_SEND_WQEBB_NUM_DS ); contig_wqebbs_room =mlx5_wq_cyc_get_contig_wqebbs (wq, pi);if (unlikely (contig_wqebbs_room < num_wqebbs)) { +#ifdef CONFIG_MLX5_EN_IPSEC +struct mlx5_wqe_eth_seg cur_eth = wqe->eth; +#endif mlx5e_fill_sq_frag_edge (sq, wq, pi, contig_wqebbs_room);mlx5e_sq_fetch_wqe (sq, &wqe, &pi); +#ifdef CONFIG_MLX5_EN_IPSEC + wqe->eth = cur_eth; +#endif }/* fill wqe */
Greg Kroah-Hartman
maintainerPATCH 277/313 xfs: eof trim writeback mapping as soon as it is cached
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Foster <[email protected]>
commit aa6ee4ab69293969867ab09b57546d226ace3d7a upstream.
The cached writeback mapping is EOF trimmed to try and avoid races between post-eof block management and writeback that result in sending cached data to a stale location. The cached mapping is currently trimmed on the validation check, which leaves a race window between the time the mapping is cached and when it is trimmed against the current inode size.
For example, if a new mapping is cached by delalloc conversion on a blocksize == page size fs, we could cycle various locks, perform memory allocations, etc. in the writeback codepath before the associated mapping is eventually trimmed to i_size. This leaves enough time for a post-eof truncate and file append before the cached mapping is trimmed. The former event essentially invalidates a range of the cached mapping and the latter bumps the inode size such the trim on the next writepage event won't trim all of the invalid blocks. fstest generic/464 reproduces this scenario occasionally and causes a lost writeback and stale delalloc blocks warning on inode inactivation.
To work around this problem, trim the cached writeback mapping as soon as it is cached in addition to on subsequent validation checks. This is a minor tweak to tighten the race window as much as possible until a proper invalidation mechanism is available.
--- fs/xfs/xfs_aops.c | 2 ++ 1 file changed, 2 insertions(+)
fs/xfs/xfs_aops.c +2 -0
@@ -449,6 +449,7 @@ xfs_map_blocks( } wpc->imap = imap; +xfs_trim_extent_eof (&wpc->imap, ip);trace_xfs_map_blocks_found (ip, offset, count, wpc->io_type, &imap);return 0 ; allocate_blocks:
@@ -459,6 +460,7 @@ allocate_blocks:ASSERT (whichfork ==XFS_COW_FORK || cow_fsb ==NULLFILEOFF || imap.br_startoff + imap.br_blockcount <= cow_fsb); wpc->imap = imap; +xfs_trim_extent_eof (&wpc->imap, ip);trace_xfs_map_blocks_alloc (ip, offset, count, wpc->io_type, &imap);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 278/313 ALSA: compress: Fix stop handling on compressed capture streams
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Keepax <[email protected]>
commit 4f2ab5e1d13d6aa77c55f4914659784efd776eb4 upstream.
It is normal user behaviour to start, stop, then start a stream again without closing it. Currently this works for compressed playback streams but not capture ones.
The states on a compressed capture stream go directly from OPEN to PREPARED, unlike a playback stream which moves to SETUP and waits for a write of data before moving to PREPARED. Currently however, when a stop is sent the state is set to SETUP for both types of streams. This leaves a capture stream in the situation where a new start can't be sent as that requires the state to be PREPARED and a new set_params can't be sent as that requires the state to be OPEN. The only option being to close the stream, and then reopen.
Correct this issues by allowing snd_compr_drain_notify to set the state depending on the stream direction, as we already do in set_params.
--- include/sound/compress_driver.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/sound/compress_driver.h +5 -1
@@ -171,7 +171,11 @@ static inline void snd_compr_drain_notifif (snd_BUG_ON (!stream))return ; - stream->runtime->state =SNDRV_PCM_STATE_SETUP ; +if (stream->direction ==SND_COMPRESS_PLAYBACK ) + stream->runtime->state =SNDRV_PCM_STATE_SETUP ; +else + stream->runtime->state =SNDRV_PCM_STATE_PREPARED ; +wake_up (&stream->runtime->sleep); }
Greg Kroah-Hartman
maintainerPATCH 279/313 ALSA: usb-audio: Add support for new T+A USB DAC
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Udo Eberhardt <[email protected]>
commit 3bff2407fbd28fd55ad5b5cccd98fc0c9598f23b upstream.
This patch adds the T+A VID to the generic check in order to enable native DSD support for T+A devices. This works with the new T+A USB DAC model SD3100HV and will also work with future devices which support the XMOS/Thesycon style DSD format.
--- sound/usb/quirks.c | 1 + 1 file changed, 1 insertion(+)
sound/usb/quirks.c +1 -0
@@ -1448,6 +1448,7 @@ u64 snd_usb_interface_dsd_format_quirks(case 0x20b1 :/* XMOS based devices */ case 0x152a :/* Thesycon devices */ case 0x25ce :/* Mytek devices */ +case 0x2ab6 :/* T+A devices */ if (fp->dsd_raw)return SNDRV_PCM_FMTBIT_DSD_U32_BE ;break ;
Greg Kroah-Hartman
maintainerPATCH 280/313 ALSA: hda - Serialize codec registrations
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 305a0ade180981686eec1f92aa6252a7c6ebb1cf upstream.
In the current code, the codec registration may happen both at the codec bind time and the end of the controller probe time. In a rare occasion, they race with each other, leading to Oops due to the still uninitialized card device.
This patch introduces a simple flag to prevent the codec registration at the codec bind time as long as the controller probe is going on. The controller probe invokes snd_card_register() that does the whole registration task, and we don't need to register each piece beforehand.
--- sound/pci/hda/hda_bind.c | 3 ++- sound/pci/hda/hda_codec.h | 1 + sound/pci/hda/hda_intel.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/hda_bind.c +2 -1
@@ -109,7 +109,8 @@ static int hda_codec_driver_probe(struct err =snd_hda_codec_build_controls (codec);if (err <0 ) goto error_module; -if (codec->card->registered) { +/* only register after the bus probe finished; otherwise it's racy */ +if (!codec->bus->bus_probing && codec->card->registered) { err =snd_card_register (codec->card);if (err <0 ) goto error_module;
sound/pci/hda/hda_codec.h +1 -0
@@ -68,6 +68,7 @@ struct hda_bus { unsigned int response_reset:1; /* controller was reset */ unsigned int in_reset:1; /* during reset operation */ unsigned int no_response_fallback:1; /* don't fallback at RIRB error */ + unsigned int bus_probing :1; /* during probing process */int primary_dig_out_type;/* primary digital out PCM type */ unsigned int mixer_assigned;/* codec addr for mixer name */
sound/pci/hda/hda_intel.c +2 -0
@@ -2315,6 +2315,7 @@ static int azx_probe_continue(struct azxint dev = chip->dev_index;int err; +to_hda_bus (bus)->bus_probing =1 ; hda->probe_continued =1 ;/* bind with i915 if needed */
@@ -2410,6 +2411,7 @@ i915_power_fail:if (err <0 ) hda->init_failed =1 ;complete_all (&hda->probe_wait); +to_hda_bus (bus)->bus_probing =0 ;return err; }
Greg Kroah-Hartman
maintainerPATCH 281/313 ALSA: hda/realtek - Fix lose hp_pins for disable auto mute
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit d561aa0a70bb2e1dd85fde98b6a5561e4175ac3e upstream.
When auto_mute = no or spec->suppress_auto_mute = 1, cfg->hp_pins will lose value.
Add this patch to find hp_pins value.
I add fixed for ALC282 ALC225 ALC256 ALC294 and alc_default_init() alc_default_shutup().
--- sound/pci/hda/patch_realtek.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
sound/pci/hda/patch_realtek.c +45 -0
@@ -2963,6 +2963,11 @@ static void alc282_init(struct hda_codecbool hp_pin_sense;int coef78; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +alc282_restore_default_value (codec);if (!hp_pin)
@@ -3000,6 +3005,11 @@ static void alc282_shutup(struct hda_codbool hp_pin_sense;int coef78; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3159,6 +3169,11 @@ static void alc256_init(struct hda_codechda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ];bool hp_pin_sense; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin)return ;
@@ -3195,6 +3210,11 @@ static void alc256_shutup(struct hda_codhda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ];bool hp_pin_sense; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3231,6 +3251,11 @@ static void alc225_init(struct hda_codechda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ];bool hp1_pin_sense, hp2_pin_sense; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin)return ;
@@ -3274,6 +3299,11 @@ static void alc225_shutup(struct hda_codhda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ];bool hp1_pin_sense, hp2_pin_sense; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3318,6 +3348,11 @@ static void alc_default_init(struct hda_hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ];bool hp_pin_sense; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin)return ;
@@ -3347,6 +3382,11 @@ static void alc_default_shutup(struct hdhda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ];bool hp_pin_sense; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3379,6 +3419,11 @@ static void alc294_hp_init(struct hda_cohda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ];int i, val; +if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) + hp_pin = spec->gen.autocfg.line_out_pins[0 ]; + } +if (!hp_pin)return ;
Greg Kroah-Hartman
maintainerPATCH 282/313 ALSA: hda/realtek - Use a common helper for hp pin reference
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 35a39f98567d8d3f1cea48f0f30de1a7e736b644 upstream.
Replace the open-codes in many places with a new common helper for performing the same thing: referring to the primary headphone pin.
This eventually fixes the potentially missing headphone pin on some weird devices, too.
--- sound/pci/hda/patch_realtek.c | 96 ++++++++++-------------------------------- 1 file changed, 24 insertions(+), 72 deletions(-)
sound/pci/hda/patch_realtek.c +24 -72
@@ -515,6 +515,15 @@ static void alc_auto_init_amp(struct hda } } +/* get a primary headphone pin if available */ +static hda_nid_t alc_get_hp_pin (struct alc_spec *spec) +{ +if (spec->gen.autocfg.hp_pins[0 ]) +return spec->gen.autocfg.hp_pins[0 ]; +if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) +return spec->gen.autocfg.line_out_pins[0 ]; +return 0 ; +}/* * Realtek SSID verification
@@ -725,9 +734,7 @@ do_sku:* 15 : 1 --> enable the function "Mute internal speaker * when the external headphone out jack is plugged" */ -if (!spec->gen.autocfg.hp_pins[0 ] && - !(spec->gen.autocfg.line_out_pins[0 ] && - spec->gen.autocfg.line_out_type ==AUTO_PIN_HP_OUT )) { +if (!alc_get_hp_pin (spec)) {hda_nid_t nid; tmp = (ass >>11 ) &0x3 ;/* HP to chassis */ nid = ports[tmp];
@@ -2959,15 +2966,10 @@ static void alc282_restore_default_valuestatic void alc282_init (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense;int coef78; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -alc282_restore_default_value (codec);if (!hp_pin)
@@ -3001,15 +3003,10 @@ static void alc282_init(struct hda_codecstatic void alc282_shutup (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense;int coef78; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3084,14 +3081,9 @@ static void alc283_restore_default_valuestatic void alc283_init (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense; -if (!spec->gen.autocfg.hp_outs) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -alc283_restore_default_value (codec);if (!hp_pin)
@@ -3125,14 +3117,9 @@ static void alc283_init(struct hda_codecstatic void alc283_shutup (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense; -if (!spec->gen.autocfg.hp_outs) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3166,14 +3153,9 @@ static void alc283_shutup(struct hda_codstatic void alc256_init (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin)return ;
@@ -3207,14 +3189,9 @@ static void alc256_init(struct hda_codecstatic void alc256_shutup (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3248,14 +3225,9 @@ static void alc256_shutup(struct hda_codstatic void alc225_init (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp1_pin_sense, hp2_pin_sense; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin)return ;
@@ -3296,14 +3268,9 @@ static void alc225_init(struct hda_codecstatic void alc225_shutup (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp1_pin_sense, hp2_pin_sense; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3345,14 +3312,9 @@ static void alc225_shutup(struct hda_codstatic void alc_default_init (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin)return ;
@@ -3379,14 +3341,9 @@ static void alc_default_init(struct hda_static void alc_default_shutup (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);bool hp_pin_sense; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin) {alc269_shutup (codec);return ;
@@ -3416,14 +3373,9 @@ static void alc_default_shutup(struct hdstatic void alc294_hp_init (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);int i, val; -if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) { -if (spec->gen.autocfg.line_out_type ==AC_JACK_HP_OUT ) - hp_pin = spec->gen.autocfg.line_out_pins[0 ]; - } -if (!hp_pin)return ;
@@ -4825,7 +4777,7 @@ static void alc_update_headset_mode(strustruct alc_spec *spec = codec->spec;hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0 ]]; -hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0 ]; +hda_nid_t hp_pin =alc_get_hp_pin (spec);int new_headset_mode;
@@ -5104,7 +5056,7 @@ static void alc_fixup_tpt470_dock(structstatic void alc_shutup_dell_xps13 (struct hda_codec *codec) {struct alc_spec *spec = codec->spec; -int hp_pin = spec->gen.autocfg.hp_pins[0 ]; +int hp_pin =alc_get_hp_pin (spec);/* Prevent pop noises when headphones are plugged in */ snd_hda_codec_write(codec, hp_pin, 0,
@@ -5197,7 +5149,7 @@ static void alc271_hp_gate_mic_jack(struif (action ==HDA_FIXUP_ACT_PROBE ) {int mic_pin =find_ext_mic_pin (codec); -int hp_pin = spec->gen.autocfg.hp_pins[0 ]; +int hp_pin =alc_get_hp_pin (spec);if (snd_BUG_ON (!mic_pin || !hp_pin))return ;
Greg Kroah-Hartman
maintainerPATCH 283/313 ALSA: hda/realtek - Headset microphone support for System76 darp5
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Soller <[email protected]>
commit 89e3a5682edaa4e5bb334719afb180256ac7bf78 upstream.
On the System76 Darter Pro (darp5), there is a headset microphone input attached to 0x1a that does not have a jack detect. In order to get it working, the pin configuration needs to be set correctly, and the ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC fixup needs to be applied. This is similar to the MIC_NO_PRESENCE fixups for some Dell laptops, except we have a separate microphone jack that is already configured correctly.
--- sound/pci/hda/patch_realtek.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/pci/hda/patch_realtek.c +11 -0
@@ -5572,6 +5572,7 @@ enum {ALC294_FIXUP_ASUS_MIC ,ALC294_FIXUP_ASUS_HEADSET_MIC ,ALC294_FIXUP_ASUS_SPK , + ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE, }; static const struct hda_fixup alc269_fixups[] = {
@@ -6496,6 +6497,15 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id =ALC294_FIXUP_ASUS_HEADSET_MIC }, + [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x1a ,0x01a1913c },/* use as headset mic, without its own jack detect */ + { } + }, + .chained = true, + .chain_id =ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -6674,6 +6684,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1458 ,0xfa53 ,"Gigabyte BXBT-2807" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1462 ,0xb120 ,"MSI Cubi MS-B120" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1462 ,0xb171 ,"Cubi N 8GL (MS-B171)" ,ALC283_FIXUP_HEADSET_MIC ), +SND_PCI_QUIRK (0x1558 ,0x1325 ,"System76 Darter Pro (darp5)" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x17aa ,0x1036 ,"Lenovo P520" ,ALC233_FIXUP_LENOVO_MULTI_CODECS ),SND_PCI_QUIRK (0x17aa ,0x20f2 ,"Thinkpad SL410/510" ,ALC269_FIXUP_SKU_IGNORE ), SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
Greg Kroah-Hartman
maintainerPATCH 284/313 fuse: call pipe_buf_release() under pipe lock
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 9509941e9c534920ccc4771ae70bd6cbbe79df1c upstream.
Some of the pipe_buf_release() handlers seem to assume that the pipe is locked - in particular, anon_pipe_buf_release() accesses pipe->tmp_page without taking any extra locks. From a glance through the callers of pipe_buf_release(), it looks like FUSE is the only one that calls pipe_buf_release() without having the pipe locked.
This bug should only lead to a memory leak, nothing terrible.
--- fs/fuse/dev.c | 2 ++ 1 file changed, 2 insertions(+)
fs/fuse/dev.c +2 -0
@@ -2032,8 +2032,10 @@ static ssize_t fuse_dev_splice_write(str ret =fuse_dev_do_write (fud, &cs, len); +pipe_lock (pipe);for (idx =0 ; idx < nbuf; idx++)pipe_buf_release (pipe, &bufs[idx]); +pipe_unlock (pipe); out:kvfree (bufs);
Greg Kroah-Hartman
maintainerPATCH 285/313 fuse: decrement NR_WRITEBACK_TEMP on the right page
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit a2ebba824106dabe79937a9f29a875f837e1b6d4 upstream.
NR_WRITEBACK_TEMP is accounted on the temporary page in the request, not the page cache page.
--- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
@@ -1778,7 +1778,7 @@ static bool fuse_writepage_in_flight(strspin_unlock (&fc->lock);dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -dec_node_page_state (page,NR_WRITEBACK_TEMP ); +dec_node_page_state (new_req->pages[0 ],NR_WRITEBACK_TEMP );wb_writeout_inc (&bdi->wb);fuse_writepage_free (fc, new_req);fuse_request_free (new_req);
Greg Kroah-Hartman
maintainerPATCH 286/313 fuse: handle zero sized retrieve correctly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 97e1532ef81acb31c30f9e75bf00306c33a77812 upstream.
Dereferencing req->page_descs[0] will Oops if req->max_pages is zero.
--- fs/fuse/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/dev.c +1 -1
@@ -1698,7 +1698,6 @@ static int fuse_retrieve(struct fuse_con req->in.h.nodeid = outarg->nodeid; req->in.numargs =2 ; req->in.argpages =1 ; - req->page_descs[0 ].offset = offset; req->end = fuse_retrieve_end; index = outarg->offset >>PAGE_SHIFT ;
@@ -1713,6 +1712,7 @@ static int fuse_retrieve(struct fuse_con this_num =min_t (unsigned, num,PAGE_SIZE - offset); req->pages[req->num_pages] = page; + req->page_descs[req->num_pages].offset = offset; req->page_descs[req->num_pages].length = this_num; req->num_pages++;
Greg Kroah-Hartman
maintainerPATCH 287/313 HID: debug: fix the ring buffer implementation
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladis Dronov <[email protected]>
commit 13054abbaa4f1fd4e6f3b4b63439ec033b4c8035 upstream.
Ring buffer implementation in hid_debug_event() and hid_debug_events_read() is strange allowing lost or corrupted data. After commit 717adfdaf147 ("HID: debug: check length before copy_to_user()") it is possible to enter an infinite loop in hid_debug_events_read() by providing 0 as count, this locks up a system. Fix this by rewriting the ring buffer implementation with kfifo and simplify the code.
This fixes CVE-2019-3819.
v2: fix an execution logic and add a comment
v3: use __set_current_state() instead of set_current_state()
--- drivers/hid/hid-debug.c | 120 ++++++++++++++++++---------------------------- include/linux/hid-debug.h | 9 +-- 2 files changed, 51 insertions(+), 78 deletions(-)
drivers/hid/hid-debug.c +47 -73
@@ -30,6 +30,7 @@#include <linux/debugfs.h> #include <linux/seq_file.h> +#include <linux/kfifo.h> #include <linux/sched/signal.h> #include <linux/export.h> #include <linux/slab.h>
@@ -661,17 +662,12 @@ EXPORT_SYMBOL_GPL(hid_dump_device);/* enqueue string to 'events' ring buffer */ void hid_debug_event (struct hid_device *hdev,char *buf) { -unsigned i;struct hid_debug_list *list;unsigned long flags;spin_lock_irqsave (&hdev->debug_list_lock, flags); -list_for_each_entry (list, &hdev->debug_list, node) { -for (i =0 ; buf[i]; i++) - list->hid_debug_buf[(list->tail + i) %HID_DEBUG_BUFSIZE ] = - buf[i]; - list->tail = (list->tail + i) %HID_DEBUG_BUFSIZE ; - } +list_for_each_entry (list, &hdev->debug_list, node) +kfifo_in (&list->hid_debug_fifo, buf,strlen (buf));spin_unlock_irqrestore (&hdev->debug_list_lock, flags);wake_up_interruptible (&hdev->debug_wait);
@@ -722,8 +718,7 @@ void hid_dump_input(struct hid_device *hhid_debug_event (hdev, buf);kfree (buf); -wake_up_interruptible (&hdev->debug_wait); - +wake_up_interruptible (&hdev->debug_wait); }EXPORT_SYMBOL_GPL (hid_dump_input);
@@ -1088,8 +1083,8 @@ static int hid_debug_events_open(struct goto out; } -if (!(list->hid_debug_buf =kzalloc (HID_DEBUG_BUFSIZE ,GFP_KERNEL ))) { - err = -ENOMEM ; + err =kfifo_alloc (&list->hid_debug_fifo,HID_DEBUG_FIFOSIZE ,GFP_KERNEL ); +if (err) {kfree (list); goto out; }
@@ -1109,77 +1104,57 @@ static ssize_t hid_debug_events_read(str size_t count, loff_t *ppos) { struct hid_debug_list *list = file->private_data; -int ret =0 , len; +int ret =0 , copied;DECLARE_WAITQUEUE (wait, current);mutex_lock (&list->read_mutex); -while (ret ==0 ) { -if (list->head == list->tail) { -add_wait_queue (&list->hdev->debug_wait, &wait); -set_current_state (TASK_INTERRUPTIBLE ); - -while (list->head == list->tail) { -if (file->f_flags &O_NONBLOCK ) { - ret = -EAGAIN ; -break ; - } -if (signal_pending (current)) { - ret = -ERESTARTSYS ; -break ; - } - -if (!list->hdev || !list->hdev->debug) { - ret = -EIO ; -set_current_state (TASK_RUNNING ); - goto out; - } - -/* allow O_NONBLOCK from other threads */ -mutex_unlock (&list->read_mutex); -schedule (); -mutex_lock (&list->read_mutex); -set_current_state (TASK_INTERRUPTIBLE ); +if (kfifo_is_empty (&list->hid_debug_fifo)) { +add_wait_queue (&list->hdev->debug_wait, &wait); +set_current_state (TASK_INTERRUPTIBLE ); + +while (kfifo_is_empty (&list->hid_debug_fifo)) { +if (file->f_flags &O_NONBLOCK ) { + ret = -EAGAIN ; +break ; } -set_current_state (TASK_RUNNING ); -remove_wait_queue (&list->hdev->debug_wait, &wait); - } - -if (ret) - goto out; - -/* pass the ringbuffer contents to userspace */ -copy_rest: -if (list->tail == list->head) - goto out; -if (list->tail > list->head) { - len = list->tail - list->head; -if (len > count) - len = count; - -if (copy_to_user (buffer + ret, &list->hid_debug_buf[list->head], len)) { - ret = -EFAULT ; - goto out; +if (signal_pending (current)) { + ret = -ERESTARTSYS ; +break ; } - ret += len; - list->head += len; - }else { - len =HID_DEBUG_BUFSIZE - list->head; -if (len > count) - len = count; -if (copy_to_user (buffer, &list->hid_debug_buf[list->head], len)) { - ret = -EFAULT ; +/* if list->hdev is NULL we cannot remove_wait_queue(). +* if list->hdev->debug is 0 then hid_debug_unregister() +* was already called and list->hdev is being destroyed. +* if we add remove_wait_queue() here we can hit a race. +*/ +if (!list->hdev || !list->hdev->debug) { + ret = -EIO ; +set_current_state (TASK_RUNNING ); goto out; } - list->head =0 ; - ret += len; - count -= len; -if (count >0 ) - goto copy_rest; + +/* allow O_NONBLOCK from other threads */ +mutex_unlock (&list->read_mutex); +schedule (); +mutex_lock (&list->read_mutex); +set_current_state (TASK_INTERRUPTIBLE ); } +__set_current_state (TASK_RUNNING ); +remove_wait_queue (&list->hdev->debug_wait, &wait); + +if (ret) + goto out; } + +/* pass the fifo content to userspace, locking is not needed with only +* one concurrent reader and one concurrent writer +*/ + ret =kfifo_to_user (&list->hid_debug_fifo, buffer, count, &copied); +if (ret) + goto out; + ret = copied; out:mutex_unlock (&list->read_mutex);return ret;
@@ -1190,7 +1165,7 @@ static __poll_t hid_debug_events_poll(ststruct hid_debug_list *list = file->private_data;poll_wait (file, &list->hdev->debug_wait, wait); -if (list->head != list->tail) +if (!kfifo_is_empty (&list->hid_debug_fifo))return EPOLLIN |EPOLLRDNORM ;if (!list->hdev->debug)return EPOLLERR |EPOLLHUP ;
@@ -1205,7 +1180,7 @@ static int hid_debug_events_release(struspin_lock_irqsave (&list->hdev->debug_list_lock, flags);list_del (&list->node);spin_unlock_irqrestore (&list->hdev->debug_list_lock, flags); -kfree (list->hid_debug_buf); +kfifo_free (&list->hid_debug_fifo);kfree (list);return 0 ;
@@ -1256,4 +1231,3 @@ void hid_debug_exit(void) {debugfs_remove_recursive (hid_debug_root); } -
include/linux/hid-debug.h +4 -5
@@ -24,7 +24,10 @@#ifdef CONFIG_DEBUG_FS +#include <linux/kfifo.h> +#define HID_DEBUG_BUFSIZE 512 +#define HID_DEBUG_FIFOSIZE 512void hid_dump_input (struct hid_device *,struct hid_usage *,__s32 );void hid_dump_report (struct hid_device *,int ,u8 *,int );
@@ -37,11 +40,8 @@ void hid_debug_init(void);void hid_debug_exit (void );void hid_debug_event (struct hid_device *,char *); -struct hid_debug_list { -char *hid_debug_buf; -int head; -int tail; + DECLARE_KFIFO_PTR(hid_debug_fifo, char);struct fasync_struct *fasync;struct hid_device *hdev;struct list_head node;
@@ -64,4 +64,3 @@ struct hid_debug_list {#endif #endif -
Greg Kroah-Hartman
maintainerPATCH 288/313 dmaengine: bcm2835: Fix interrupt race on RT
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit f7da7782aba92593f7b82f03d2409a1c5f4db91b upstream.
If IRQ handlers are threaded (either because CONFIG_PREEMPT_RT_BASE is enabled or "threadirqs" was passed on the command line) and if system load is sufficiently high that wakeup latency of IRQ threads degrades, SPI DMA transactions on the BCM2835 occasionally break like this:
ks8851 spi0.0: SPI transfer timed out
bcm2835-dma 3f007000.dma: DMA transfer could not be terminated ks8851 spi0.0 eth2: ks8851_rdfifo: spi_sync() failed
The root cause is an assumption made by the DMA driver which is documented in a code comment in bcm2835_dma_terminate_all():
/*
* Stop DMA activity: we assume the callback will not be called
* after bcm_dma_abort() returns (even if it does, it will see
* c->desc is NULL and exit.)
*/
That assumption falls apart if the IRQ handler bcm2835_dma_callback() is
threaded: A client may terminate a descriptor and issue a new one before the IRQ handler had a chance to run. In fact the IRQ handler may miss an *arbitrary* number of descriptors. The result is the following race condition:
1. A descriptor finishes, its interrupt is deferred to the IRQ thread.
2. A client calls dma_terminate_async() which sets channel->desc = NULL.
3. The client issues a new descriptor. Because channel->desc is NULL, bcm2835_dma_issue_pending() immediately starts the descriptor.
4. Finally the IRQ thread runs and writes BCM2835_DMA_INT to the CS register to acknowledge the interrupt. This clears the ACTIVE flag, so the newly issued descriptor is paused in the middle of the transaction. Because channel->desc is not NULL, the IRQ thread finalizes the descriptor and tries to start the next one.
I see two possible solutions: The first is to call synchronize_irq() in bcm2835_dma_issue_pending() to wait until the IRQ thread has finished before issuing a new descriptor. The downside of this approach is unnecessary latency if clients desire rapidly terminating and re-issuing descriptors and don't have any use for an IRQ callback. (The SPI TX DMA channel is a case in point.)
A better alternative is to make the IRQ thread recognize that it has missed descriptors and avoid finalizing the newly issued descriptor. So first of all, set the ACTIVE flag when acknowledging the interrupt. This keeps a newly issued descriptor running.
If the descriptor was finished, the channel remains idle despite the ACTIVE flag being set. However the ACTIVE flag can then no longer be used to check whether the channel is idle, so instead check whether the register containing the current control block address is zero and finalize the current descriptor only if so.
That way, there is no impact on latency and throughput if the client doesn't care for the interrupt: Only minimal additional overhead is introduced for non-cyclic descriptors as one further MMIO read is necessary per interrupt to check for idleness of the channel. Cyclic descriptors are sped up slightly by removing one MMIO write per interrupt.
--- drivers/dma/bcm2835-dma.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/dma/bcm2835-dma.c +18 -15
@@ -421,7 +421,12 @@ static int bcm2835_dma_abort(void __iomelong int timeout =10000 ; cs =readl (chan_base +BCM2835_DMA_CS ); -if (!(cs &BCM2835_DMA_ACTIVE )) + +/* +* A zero control block address means the channel is idle. +* (The ACTIVE flag in the CS register is not a reliable indicator.) +*/ +if (!readl (chan_base +BCM2835_DMA_ADDR ))return 0 ;/* Write 0 to the active bit - Pause the DMA */
@@ -485,8 +490,15 @@ static irqreturn_t bcm2835_dma_callback(spin_lock_irqsave (&c->vc.lock, flags); -/* Acknowledge interrupt */ -writel (BCM2835_DMA_INT , c->chan_base +BCM2835_DMA_CS ); +/* +* Clear the INT flag to receive further interrupts. Keep the channel +* active in case the descriptor is cyclic or in case the client has +* already terminated the descriptor and issued a new one. (May happen +* if this IRQ handler is threaded.) If the channel is finished, it +* will remain idle despite the ACTIVE flag being set. +*/ +writel (BCM2835_DMA_INT |BCM2835_DMA_ACTIVE , + c->chan_base +BCM2835_DMA_CS ); d = c->desc;
@@ -494,11 +506,7 @@ static irqreturn_t bcm2835_dma_callback(if (d->cyclic) {/* call the cyclic callback */ vchan_cyclic_callback (&d->vd); - -/* Keep the DMA engine running */ -writel (BCM2835_DMA_ACTIVE , - c->chan_base +BCM2835_DMA_CS ); - }else { + }else if (!readl (c->chan_base +BCM2835_DMA_ADDR )) {vchan_cookie_complete (&c->desc->vd);bcm2835_dma_start_desc (c); }
@@ -806,11 +814,7 @@ static int bcm2835_dma_terminate_all(strlist_del_init (&c->node);spin_unlock (&d->lock); -/* -* Stop DMA activity: we assume the callback will not be called -* after bcm_dma_abort() returns (even if it does, it will see -* c->desc is NULL and exit.) -*/ +/* stop DMA activity */ if (c->desc) {vchan_terminate_vdesc (&c->desc->vd); c->desc =NULL ;
@@ -818,8 +822,7 @@ static int bcm2835_dma_terminate_all(str/* Wait for stopping */ while (--timeout) { -if (!(readl (c->chan_base +BCM2835_DMA_CS ) & -BCM2835_DMA_ACTIVE )) +if (!readl (c->chan_base +BCM2835_DMA_ADDR ))break ;cpu_relax ();
Greg Kroah-Hartman
maintainerPATCH 289/313 dmaengine: bcm2835: Fix abort of transactions
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 9e528c799d17a4ac37d788c81440b50377dd592d upstream.
There are multiple issues with bcm2835_dma_abort() (which is called on termination of a transaction):
* The algorithm to abort the transaction first pauses the channel by clearing the ACTIVE flag in the CS register, then waits for the PAUSED flag to clear. Page 49 of the spec documents the latter as follows:
"Indicates if the DMA is currently paused and not transferring data.
This will occur if the active bit has been cleared [...]"
https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
So the function is entering an infinite loop because it is waiting for PAUSED to clear which is always set due to the function having cleared the ACTIVE flag. The only thing that's saving it from itself is the upper bound of 10000 loop iterations.
The code comment says that the intention is to "wait for any current AXI transfer to complete", so the author probably wanted to check the WAITING_FOR_OUTSTANDING_WRITES flag instead. Amend the function accordingly.
* The CS register is only read at the beginning of the function. It needs to be read again after pausing the channel and before checking for outstanding writes, otherwise writes which were issued between the register read at the beginning of the function and pausing the channel may not be waited for.
* The function seeks to abort the transfer by writing 0 to the NEXTCONBK register and setting the ABORT and ACTIVE flags. Thereby, the 0 in NEXTCONBK is sought to be loaded into the CONBLK_AD register. However experimentation has shown this approach to not work: The CONBLK_AD register remains the same as before and the CS register contains 0x00000030 (PAUSED | DREQ_STOPS_DMA). In other words, the control block is not aborted but merely paused and it will be resumed once the next DMA transaction is started. That is absolutely not the desired behavior.
A simpler approach is to set the channel's RESET flag instead. This reliably zeroes the NEXTCONBK as well as the CS register. It requires less code and only a single MMIO write. This is also what popular user space DMA drivers do, e.g.:
https://github.com/metachris/RPIO/blob/master/source/c_pwm/pwm.c
Note that the spec is contradictory whether the NEXTCONBK register is writeable at all. On the one hand, page 41 claims:
"The value loaded into the NEXTCONBK register can be overwritten so that the linked list of Control Block data structures can be dynamically altered. However it is only safe to do this when the DMA is paused."
On the other hand, page 40 specifies:
"Only three registers in each channel's register set are directly writeable (CS, CONBLK_AD and DEBUG). The other registers (TI, SOURCE_AD, DEST_AD, TXFR_LEN, STRIDE & NEXTCONBK), are automatically loaded from a Control Block data structure held in external memory."
--- drivers/dma/bcm2835-dma.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-)
drivers/dma/bcm2835-dma.c +9 -32
@@ -415,13 +415,11 @@ static void bcm2835_dma_fill_cb_chain_wi } } -static int bcm2835_dma_abort (void __iomem *chan_base) +static int bcm2835_dma_abort (struct bcm2835_chan *c) { -unsigned long cs; +void __iomem *chan_base = c->chan_base;long int timeout =10000 ; - cs =readl (chan_base +BCM2835_DMA_CS ); -/* * A zero control block address means the channel is idle. * (The ACTIVE flag in the CS register is not a reliable indicator.)
@@ -433,25 +431,16 @@ static int bcm2835_dma_abort(void __iomewritel (0 , chan_base +BCM2835_DMA_CS );/* Wait for any current AXI transfer to complete */ -while ((cs &BCM2835_DMA_ISPAUSED ) && --timeout) { +while ((readl (chan_base +BCM2835_DMA_CS ) & +BCM2835_DMA_WAITING_FOR_WRITES ) && --timeout)cpu_relax (); - cs =readl (chan_base +BCM2835_DMA_CS ); - } -/* We'll un-pause when we set of our next DMA */ +/* Peripheral might be stuck and fail to signal AXI write responses */ if (!timeout) -return -ETIMEDOUT ; - -if (!(cs &BCM2835_DMA_ACTIVE )) -return 0 ; - -/* Terminate the control block chain */ -writel (0 , chan_base +BCM2835_DMA_NEXTCB ); - -/* Abort the whole DMA */ -writel (BCM2835_DMA_ABORT |BCM2835_DMA_ACTIVE , - chan_base +BCM2835_DMA_CS ); +dev_err (c->vc.chan.device->dev, +"failed to complete outstanding writes\n" ); +writel (BCM2835_DMA_RESET , chan_base +BCM2835_DMA_CS );return 0 ; }
@@ -804,7 +793,6 @@ static int bcm2835_dma_terminate_all(strstruct bcm2835_chan *c =to_bcm2835_dma_chan (chan);struct bcm2835_dmadev *d =to_bcm2835_dma_dev (c->vc.chan.device);unsigned long flags; -int timeout =10000 ;LIST_HEAD (head);spin_lock_irqsave (&c->vc.lock, flags);
@@ -818,18 +806,7 @@ static int bcm2835_dma_terminate_all(strif (c->desc) {vchan_terminate_vdesc (&c->desc->vd); c->desc =NULL ; -bcm2835_dma_abort (c->chan_base); - -/* Wait for stopping */ -while (--timeout) { -if (!readl (c->chan_base +BCM2835_DMA_ADDR )) -break ; - -cpu_relax (); - } - -if (!timeout) -dev_err (d->ddev.dev,"DMA transfer could not be terminated\n" ); +bcm2835_dma_abort (c); }vchan_get_all_descriptors (&c->vc, &head);
Greg Kroah-Hartman
maintainerPATCH 290/313 dmaengine: imx-dma: fix wrong callback invoke
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leonid Iziumtsev <[email protected]>
commit 341198eda723c8c1cddbb006a89ad9e362502ea2 upstream.
Once the "ld_queue" list is not empty, next descriptor will migrate into "ld_active" list. The "desc" variable will be overwritten during that transition. And later the dmaengine_desc_get_callback_invoke() will use it as an argument. As result we invoke wrong callback.
That behaviour was in place since:
commit fcaaba6c7136 ("dmaengine: imx-dma: fix callback path in tasklet"). But after commit 4cd13c21b207 ("softirq: Let ksoftirqd do its job") things got worse, since possible delay between tasklet_schedule() from DMA irq handler and actual tasklet function execution got bigger. And that gave more time for new DMA request to be submitted and to be put into "ld_queue" list.
It has been noticed that DMA issue is causing problems for "mxc-mmc" driver. While stressing the system with heavy network traffic and writing/reading to/from sd card simultaneously the timeout may happen:
10013000.sdhci: mxcmci_watchdog: read time out (status = 0x30004900)
That often lead to file system corruption.
--- drivers/dma/imx-dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/imx-dma.c +4 -4
@@ -617,7 +617,7 @@ static void imxdma_tasklet(unsigned long {struct imxdma_channel *imxdmac = (void *)data;struct imxdma_engine *imxdma = imxdmac->imxdma; -struct imxdma_desc *desc; +struct imxdma_desc *desc, *next_desc;unsigned long flags;spin_lock_irqsave (&imxdma->lock, flags);
@@ -647,10 +647,10 @@ static void imxdma_tasklet(unsigned longlist_move_tail (imxdmac->ld_active.next, &imxdmac->ld_free);if (!list_empty (&imxdmac->ld_queue)) { - desc = list_first_entry(&imxdmac->ld_queue, struct imxdma_desc, - node); + next_desc =list_first_entry (&imxdmac->ld_queue, + struct imxdma_desc, node);list_move_tail (imxdmac->ld_queue.next, &imxdmac->ld_active); -if (imxdma_xfer_desc (desc) <0 ) +if (imxdma_xfer_desc (next_desc) <0 )dev_warn (imxdma->dev,"%s: channel: %d couldn't xfer desc\n" , __func__, imxdmac->channel); }
Greg Kroah-Hartman
maintainerPATCH 291/313 futex: Handle early deadlock return correctly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 1a1fb985f2e2b85ec0d3dc2e519ee48389ec2434 upstream.
commit 56222b212e8e ("futex: Drop hb->lock before enqueueing on the rtmutex") changed the locking rules in the futex code so that the hash bucket lock is not longer held while the waiter is enqueued into the rtmutex wait list. This made the lock and the unlock path symmetric, but unfortunately the possible early exit from __rt_mutex_proxy_start() due to a detected deadlock was not updated accordingly. That allows a concurrent unlocker to observe inconsitent state which triggers the warning in the unlock path.
futex_lock_pi() futex_unlock_pi()
lock(hb->lock)
queue(hb_waiter) lock(hb->lock)
lock(rtmutex->wait_lock)
unlock(hb->lock)
// acquired hb->lock
hb_waiter = futex_top_waiter()
lock(rtmutex->wait_lock)
__rt_mutex_proxy_start()
---> fail
remove(rtmutex_waiter);
---> returns -EDEADLOCK
unlock(rtmutex->wait_lock)
// acquired wait_lock
wake_futex_pi()
rt_mutex_next_owner()
--> returns NULL
--> WARN lock(hb->lock)
unqueue(hb_waiter)
The problem is caused by the remove(rtmutex_waiter) in the failure case of __rt_mutex_proxy_start() as this lets the unlocker observe a waiter in the hash bucket but no waiter on the rtmutex, i.e. inconsistent state.
The original commit handles this correctly for the other early return cases (timeout, signal) by delaying the removal of the rtmutex waiter until the returning task reacquired the hash bucket lock.
Treat the failure case of __rt_mutex_proxy_start() in the same way and let the existing cleanup code handle the eventual handover of the rtmutex gracefully. The regular rt_mutex_proxy_start() gains the rtmutex waiter removal for the failure case, so that the other callsites are still operating correctly.
Add proper comments to the code so all these details are fully documented.
Thanks to Peter for helping with the analysis and writing the really valuable code comments.
--- kernel/futex.c | 28 ++++++++++++++++++---------- kernel/locking/rtmutex.c | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 15 deletions(-)
kernel/futex.c +18 -10
@@ -2850,35 +2850,39 @@ retry_private:* and BUG when futex_unlock_pi() interleaves with this. * * Therefore acquire wait_lock while holding hb->lock, but drop the -* latter before calling rt_mutex_start_proxy_lock(). This still fully -* serializes against futex_unlock_pi() as that does the exact same -* lock handoff sequence. +* latter before calling __rt_mutex_start_proxy_lock(). This +* interleaves with futex_unlock_pi() -- which does a similar lock +* handoff -- such that the latter can observe the futex_q::pi_state +* before __rt_mutex_start_proxy_lock() is done. */ raw_spin_lock_irq (&q.pi_state->pi_mutex.wait_lock);spin_unlock (q.lock_ptr); +/* +* __rt_mutex_start_proxy_lock() unconditionally enqueues the @rt_waiter +* such that futex_unlock_pi() is guaranteed to observe the waiter when +* it sees the futex_q::pi_state. +*/ ret =__rt_mutex_start_proxy_lock (&q.pi_state->pi_mutex, &rt_waiter, current);raw_spin_unlock_irq (&q.pi_state->pi_mutex.wait_lock);if (ret) {if (ret ==1 ) ret =0 ; - -spin_lock (q.lock_ptr); - goto no_block; + goto cleanup; } -if (unlikely (to))hrtimer_start_expires (&to->timer,HRTIMER_MODE_ABS ); ret =rt_mutex_wait_proxy_lock (&q.pi_state->pi_mutex, to, &rt_waiter); +cleanup:spin_lock (q.lock_ptr);/* -* If we failed to acquire the lock (signal/timeout), we must +* If we failed to acquire the lock (deadlock/signal/timeout), we must * first acquire the hb->lock before removing the lock from the -* rt_mutex waitqueue, such that we can keep the hb and rt_mutex -* wait lists consistent. +* rt_mutex waitqueue, such that we can keep the hb and rt_mutex wait +* lists consistent. * * In particular; it is important that futex_unlock_pi() can not * observe this inconsistency.
@@ -3002,6 +3006,10 @@ retry:* there is no point where we hold neither; and therefore * wake_futex_pi() must observe a state consistent with what we * observed. +* +* In particular; this forces __rt_mutex_start_proxy() to +* complete such that we're guaranteed to observe the +* rt_waiter. Also see the WARN in wake_futex_pi(). */ raw_spin_lock_irq (&pi_state->pi_mutex.wait_lock);spin_unlock (&hb->lock);
kernel/locking/rtmutex.c +32 -5
@@ -1726,12 +1726,33 @@ void rt_mutex_proxy_unlock(struct rt_mutrt_mutex_set_owner (lock,NULL ); } +/** +* __rt_mutex_start_proxy_lock() - Start lock acquisition for another task +* @lock: the rt_mutex to take +* @waiter: the pre-initialized rt_mutex_waiter +* @task: the task to prepare +* +* Starts the rt_mutex acquire; it enqueues the @waiter and does deadlock +* detection. It does not wait, see rt_mutex_wait_proxy_lock() for that. +* +* NOTE: does _NOT_ remove the @waiter on failure; must either call +* rt_mutex_wait_proxy_lock() or rt_mutex_cleanup_proxy_lock() after this. +* +* Returns: +* 0 - task blocked on lock +* 1 - acquired the lock for task, caller should wake it up +* <0 - error +* +* Special API call for PI-futex support. +*/ int __rt_mutex_start_proxy_lock (struct rt_mutex *lock,struct rt_mutex_waiter *waiter,struct task_struct *task) {int ret; +lockdep_assert_held (&lock->wait_lock); +if (try_to_take_rt_mutex (lock, task,NULL ))return 1 ;
@@ -1749,9 +1770,6 @@ int __rt_mutex_start_proxy_lock(struct r ret =0 ; } -if (unlikely (ret)) -remove_waiter (lock, waiter); -debug_rt_mutex_print_deadlock (waiter);return ret;
@@ -1763,12 +1781,18 @@ int __rt_mutex_start_proxy_lock(struct r* @waiter: the pre-initialized rt_mutex_waiter * @task: the task to prepare * +* Starts the rt_mutex acquire; it enqueues the @waiter and does deadlock +* detection. It does not wait, see rt_mutex_wait_proxy_lock() for that. +* +* NOTE: unlike __rt_mutex_start_proxy_lock this _DOES_ remove the @waiter +* on failure. +* * Returns: * 0 - task blocked on lock * 1 - acquired the lock for task, caller should wake it up * <0 - error * -* Special API call for FUTEX_REQUEUE_PI support. +* Special API call for PI-futex support. */ int rt_mutex_start_proxy_lock(struct rt_mutex *lock, struct rt_mutex_waiter *waiter,
@@ -1778,6 +1802,8 @@ int rt_mutex_start_proxy_lock(struct rt_raw_spin_lock_irq (&lock->wait_lock); ret =__rt_mutex_start_proxy_lock (lock, waiter, task); +if (unlikely (ret)) +remove_waiter (lock, waiter);raw_spin_unlock_irq (&lock->wait_lock);return ret;
@@ -1845,7 +1871,8 @@ int rt_mutex_wait_proxy_lock(struct rt_m* @lock: the rt_mutex we were woken on * @waiter: the pre-initialized rt_mutex_waiter * -* Attempt to clean up after a failed rt_mutex_wait_proxy_lock(). +* Attempt to clean up after a failed __rt_mutex_start_proxy_lock() or +* rt_mutex_wait_proxy_lock(). * * Unless we acquired the lock; we're still enqueued on the wait-list and can * in fact still be granted ownership until we're removed. Therefore we can
Greg Kroah-Hartman
maintainerPATCH 292/313 irqchip/gic-v3-its: Plug allocation race for devices sharing a DevID
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 9791ec7df0e7b4d80706ccea8f24b6542f6059e9 upstream.
On systems or VMs where multiple devices share a single DevID (because they sit behind a PCI bridge, or because the HW is broken in funky ways), we reuse the save its_device structure in order to reflect this.
It turns out that there is a distinct lack of locking when looking up the its_device, and two device being probed concurrently can result in double allocations. That's obviously not nice.
A solution for this is to have a per-ITS mutex that serializes device allocation.
A similar issue exists on the freeing side, which can run concurrently with the allocation. On top of now taking the appropriate lock, we also make sure that a shared device is never freed, as we have no way to currently track the life cycle of such object.
--- drivers/irqchip/irq-gic-v3-its.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +27 -5
@@ -93,9 +93,14 @@ struct its_device;* The ITS structure - contains most of the infrastructure, with the * top-level MSI domain, the command queue, the collections, and the * list of devices writing to it. +* +* dev_alloc_lock has to be taken for device allocations, while the +* spinlock must be taken to parse data structures such as the device +* list. */ struct its_node {raw_spinlock_t lock; +struct mutex dev_alloc_lock;struct list_head entry;void __iomem *base;phys_addr_t phys_base;
@@ -152,6 +157,7 @@ struct its_device {void *itt;u32 nr_ites;u32 device_id; +bool shared; }; static struct {
@@ -2290,6 +2296,7 @@ static int its_msi_prepare(struct irq_dostruct its_device *its_dev;struct msi_domain_info *msi_info;u32 dev_id; +int err =0 ;/* * We ignore "dev" entierely, and rely on the dev_id that has
@@ -2312,6 +2319,7 @@ static int its_msi_prepare(struct irq_doreturn -EINVAL ; } +mutex_lock (&its->dev_alloc_lock); its_dev =its_find_device (its, dev_id);if (its_dev) {/*
@@ -2319,18 +2327,22 @@ static int its_msi_prepare(struct irq_do* another alias (PCI bridge of some sort). No need to * create the device. */ + its_dev->shared = true;pr_debug ("Reusing ITT for devID %x\n" , dev_id); goto out; } its_dev =its_create_device (its, dev_id, nvec, true); -if (!its_dev) -return -ENOMEM ; +if (!its_dev) { + err = -ENOMEM ; + goto out; + }pr_debug ("ITT %d entries, %d bits\n" , nvec,ilog2 (nvec)); out: +mutex_unlock (&its->dev_alloc_lock); info->scratchpad[0 ].ptr = its_dev; -return 0 ; +return err; }static struct msi_domain_ops its_msi_domain_ops = {
@@ -2434,6 +2446,7 @@ static void its_irq_domain_free(struct i {struct irq_data *d =irq_domain_get_irq_data (domain, virq);struct its_device *its_dev =irq_data_get_irq_chip_data (d); +struct its_node *its = its_dev->its;int i;for (i =0 ; i < nr_irqs; i++) {
@@ -2448,8 +2461,14 @@ static void its_irq_domain_free(struct iirq_domain_reset_irq_data (data); } -/* If all interrupts have been freed, start mopping the floor */ -if (bitmap_empty (its_dev->event_map.lpi_map, +mutex_lock (&its->dev_alloc_lock); + +/* +* If all interrupts have been freed, start mopping the +* floor. This is conditionned on the device not being shared. +*/ +if (!its_dev->shared && +bitmap_empty (its_dev->event_map.lpi_map, its_dev->event_map.nr_lpis)) { its_lpi_free(its_dev->event_map.lpi_map, its_dev->event_map.lpi_base,
@@ -2461,6 +2480,8 @@ static void its_irq_domain_free(struct iits_free_device (its_dev); } +mutex_unlock (&its->dev_alloc_lock); +irq_domain_free_irqs_parent (domain, virq, nr_irqs); }
@@ -3385,6 +3406,7 @@ static int __init its_probe_one(struct r }raw_spin_lock_init (&its->lock); +mutex_init (&its->dev_alloc_lock);INIT_LIST_HEAD (&its->entry);INIT_LIST_HEAD (&its->its_device_list); typer =gic_read_typer (its_base +GITS_TYPER );
Greg Kroah-Hartman
maintainerPATCH 293/313 usb: phy: am335x: fix race condition in _probe
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit a53469a68eb886e84dd8b69a1458a623d3591793 upstream.
power off the phy should be done before populate the phy. Otherwise, am335x_init() could be called by the phy owner to power on the phy first, then am335x_phy_probe() turns off the phy again without the caller knowing it.
--- drivers/usb/phy/phy-am335x.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/usb/phy/phy-am335x.c +1 -4
@@ -61,9 +61,6 @@ static int am335x_phy_probe(struct platfif (ret)return ret; - ret =usb_add_phy_dev (&am_phy->usb_phy_gen.phy); -if (ret) -return ret; am_phy->usb_phy_gen.phy.init = am335x_init; am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown;
@@ -82,7 +79,7 @@ static int am335x_phy_probe(struct platfdevice_set_wakeup_enable (dev, false);phy_ctrl_power (am_phy->phy_ctrl, am_phy->id, am_phy->dr_mode, false); -return 0 ; +return usb_add_phy_dev (&am_phy->usb_phy_gen.phy); }static int am335x_phy_remove (struct platform_device *pdev)
Greg Kroah-Hartman
maintainerPATCH 294/313 usb: dwc3: gadget: Handle 0 xfer length for OUT EP
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejas Joglekar <[email protected]>
commit 1e19cdc8060227b0802bda6bc0bd22b23679ba32 upstream.
For OUT endpoints, zero-length transfers require MaxPacketSize buffer as per the DWC_usb3 programming guide 3.30a section 4.2.3.3.
This patch fixes this by explicitly checking zero length transfer to correctly pad up to MaxPacketSize.
--- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +1 -1
@@ -1110,7 +1110,7 @@ static void dwc3_prepare_one_trb_linear(unsigned int maxp =usb_endpoint_maxp (dep->endpoint.desc);unsigned int rem = length % maxp; -if (rem &&usb_endpoint_dir_out (dep->endpoint.desc)) { +if ((!length || rem) &&usb_endpoint_dir_out (dep->endpoint.desc)) {struct dwc3 *dwc = dep->dwc;struct dwc3_trb *trb;
Greg Kroah-Hartman
maintainerPATCH 295/313 usb: gadget: udc: net2272: Fix bitwise and boolean operations
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit 07c69f1148da7de3978686d3af9263325d9d60bd upstream.
(!x & y) strikes again.
Fix bitwise and boolean operations by enclosing the expression:
intcsr & (1 << NET2272_PCI_IRQ)
in parentheses, before applying the boolean operator '!'.
Notice that this code has been there since 2011. So, it would be helpful if someone can double-check this.
This issue was detected with the help of Coccinelle.
--- drivers/usb/gadget/udc/net2272.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/net2272.c +1 -1
@@ -2083,7 +2083,7 @@ static irqreturn_t net2272_irq(int irq,#if defined(PLX_PCI_RDK2 )/* see if PCI int for us by checking irqstat */ intcsr =readl (dev->rdk2.fpga_base_addr +RDK2_IRQSTAT ); -if (!intcsr & (1 <<NET2272_PCI_IRQ )) { +if (!(intcsr & (1 <<NET2272_PCI_IRQ ))) {spin_unlock (&dev->lock);return IRQ_NONE ; }
Greg Kroah-Hartman
maintainerPATCH 296/313 usb: gadget: musb: fix short isoc packets with inventra dma
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Elder <[email protected]>
commit c418fd6c01fbc5516a2cd1eaf1df1ec86869028a upstream.
Handling short packets (length < max packet size) in the Inventra DMA engine in the MUSB driver causes the MUSB DMA controller to hang. An example of a problem that is caused by this problem is when streaming video out of a UVC gadget, only the first video frame is transferred.
For short packets (mode-0 or mode-1 DMA), MUSB_TXCSR_TXPKTRDY must be set manually by the driver. This was previously done in musb_g_tx (musb_gadget.c), but incorrectly (all csr flags were cleared, and only MUSB_TXCSR_MODE and MUSB_TXCSR_TXPKTRDY were set). Fixing that problem allows some requests to be transferred correctly, but multiple requests were often put together in one USB packet, and caused problems if the packet size was not a multiple of 4. Instead, set MUSB_TXCSR_TXPKTRDY in dma_controller_irq (musbhsdma.c), just like host mode transfers.
This topic was originally tackled by Nicolas Boichat [0] [1] and is discussed further at [2] as part of his GSoC project [3].
[0] https://groups.google.com/forum/?hl=en#!topic/beagleboard-gsoc/k8Azwfp75CU
[1] https://gitorious.org/beagleboard-usbsniffer/beagleboard-usbsniffer-kernel/commit/b0be3b6cc195ba732189b04f1d43ec843c3e54c9?p=beagleboard-usbsniffer:beagleboard-usbsniffer-kernel.git;a=patch;h=b0be3b6cc195ba732189b04f1d43ec843c3e54c9
[2] http://beagleboard-usbsniffer.blogspot.com/2010/07/musb-isochronous-transfers-fixed.html
[3] http://elinux.org/BeagleBoard/GSoC/USBSniffer
--- drivers/usb/musb/musb_gadget.c | 13 +------------ drivers/usb/musb/musbhsdma.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 22 deletions(-)
drivers/usb/musb/musb_gadget.c +1 -12
@@ -452,13 +452,10 @@ void musb_g_tx(struct musb *musb, u8 epn }if (request) { -u8 is_dma =0 ; -bool short_packet = false;trace_musb_req_tx (req);if (dma && (csr &MUSB_TXCSR_DMAENAB )) { - is_dma =1 ; csr |=MUSB_TXCSR_P_WZC_BITS ; csr &= ~(MUSB_TXCSR_DMAENAB |MUSB_TXCSR_P_UNDERRUN |MUSB_TXCSR_TXPKTRDY |MUSB_TXCSR_AUTOSET );
@@ -476,16 +473,8 @@ void musb_g_tx(struct musb *musb, u8 epn*/ if ((request->zero && request->length) && (request->length % musb_ep->packet_sz ==0 ) - && (request->actual == request->length)) - short_packet = true; + && (request->actual == request->length)) { -if ((musb_dma_inventra (musb) ||musb_dma_ux500 (musb)) && - (is_dma && (!dma->desired_mode || - (request->actual & - (musb_ep->packet_sz -1 ))))) - short_packet = true; - -if (short_packet) {/* * On DMA completion, FIFO may not be * available yet...
drivers/usb/musb/musbhsdma.c +11 -10
@@ -346,12 +346,10 @@ static irqreturn_t dma_controller_irq(in channel->status =MUSB_DMA_STATUS_FREE ;/* completed */ -if ((devctl &MUSB_DEVCTL_HM ) - && (musb_channel->transmit) - && ((channel->desired_mode ==0 ) - || (channel->actual_len & - (musb_channel->max_packet_sz -1 ))) - ) { +if (musb_channel->transmit && + (!channel->desired_mode || + (channel->actual_len % + musb_channel->max_packet_sz))) {u8 epnum = musb_channel->epnum;int offset = musb->io.ep_offset (epnum,MUSB_TXCSR );
@@ -363,11 +361,14 @@ static irqreturn_t dma_controller_irq(in*/ musb_ep_select (mbase, epnum); txcsr =musb_readw (mbase, offset); - txcsr &= ~(MUSB_TXCSR_DMAENAB +if (channel->desired_mode ==1 ) { + txcsr &= ~(MUSB_TXCSR_DMAENAB |MUSB_TXCSR_AUTOSET ); -musb_writew (mbase, offset, txcsr); -/* Send out the packet */ - txcsr &= ~MUSB_TXCSR_DMAMODE ; +musb_writew (mbase, offset, txcsr); +/* Send out the packet */ + txcsr &= ~MUSB_TXCSR_DMAMODE ; + txcsr |=MUSB_TXCSR_DMAENAB ; + } txcsr |=MUSB_TXCSR_TXPKTRDY ;musb_writew (mbase, offset, txcsr); }
Greg Kroah-Hartman
maintainerPATCH 297/313 staging: speakup: fix tty-operation NULL derefs
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a1960e0f1639cb1f7a3d94521760fc73091f6640 upstream.
The send_xchar() and tiocmset() tty operations are optional. Add the missing sanity checks to prevent user-space triggerable NULL-pointer dereferences.
--- drivers/staging/speakup/spk_ttyio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/speakup/spk_ttyio.c +4 -2
@@ -265,7 +265,8 @@ static void spk_ttyio_send_xchar(char chreturn ; } - speakup_tty->ops->send_xchar (speakup_tty, ch); +if (speakup_tty->ops->send_xchar) + speakup_tty->ops->send_xchar (speakup_tty, ch);mutex_unlock (&speakup_tty_mutex); }
@@ -277,7 +278,8 @@ static void spk_ttyio_tiocmset(unsignedreturn ; } - speakup_tty->ops->tiocmset (speakup_tty, set, clear); +if (speakup_tty->ops->tiocmset) + speakup_tty->ops->tiocmset (speakup_tty, set, clear);mutex_unlock (&speakup_tty_mutex); }
Greg Kroah-Hartman
maintainerPATCH 298/313 scsi: cxlflash: Prevent deadlock when adapter probe fails
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vaibhav Jain <[email protected]>
commit bb61b843ffd46978d7ca5095453e572714934eeb upstream.
Presently when an error is encountered during probe of the cxlflash adapter, a deadlock is seen with cpu thread stuck inside cxlflash_remove(). Below is the trace of the deadlock as logged by khungtaskd:
cxlflash 0006:00:00.0: cxlflash_probe: init_afu failed rc=-16
INFO: task kworker/80:1:890 blocked for more than 120 seconds.
Not tainted 5.0.0-rc4-capi2-kexec+ #2
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kworker/80:1 D 0 890 2 0x00000808
Workqueue: events work_for_cpu_fn
Call Trace:
0x4d72136320 (unreliable)
__switch_to+0x2cc/0x460
__schedule+0x2bc/0xac0
schedule+0x40/0xb0
cxlflash_remove+0xec/0x640 [cxlflash]
cxlflash_probe+0x370/0x8f0 [cxlflash]
local_pci_probe+0x6c/0x140
work_for_cpu_fn+0x38/0x60
process_one_work+0x260/0x530
worker_thread+0x280/0x5d0
kthread+0x1a8/0x1b0
ret_from_kernel_thread+0x5c/0x80
INFO: task systemd-udevd:5160 blocked for more than 120 seconds.The deadlock occurs as cxlflash_remove() is called from cxlflash_probe() without setting 'cxlflash_cfg->state' to STATE_PROBED and the probe thread starts to wait on 'cxlflash_cfg->reset_waitq'. Since the device was never successfully probed the 'cxlflash_cfg->state' never changes from STATE_PROBING hence the deadlock occurs.
We fix this deadlock by setting the variable 'cxlflash_cfg->state' to STATE_PROBED in case an error occurs during cxlflash_probe() and just before calling cxlflash_remove().
--- drivers/scsi/cxlflash/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/cxlflash/main.c +2 -0
@@ -3694,6 +3694,7 @@ static int cxlflash_probe(struct pci_dev host->max_cmd_len =CXLFLASH_MAX_CDB_LEN ; cfg =shost_priv (host); + cfg->state =STATE_PROBING ; cfg->host = host; rc =alloc_mem (cfg);if (rc) {
@@ -3782,6 +3783,7 @@ out:return rc; out_remove: + cfg->state =STATE_PROBED ;cxlflash_remove (pdev); goto out; }
Greg Kroah-Hartman
maintainerPATCH 299/313 scsi: aic94xx: fix module loading
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Bottomley <[email protected]>
commit 42caa0edabd6a0a392ec36a5f0943924e4954311 upstream.
The aic94xx driver is currently failing to load with errors like
sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/0000:02:00.3/0000:07:02.0/revision'
Because the PCI code had recently added a file named 'revision' to every PCI device. Fix this by renaming the aic94xx revision file to aic_revision. This is safe to do for us because as far as I can tell, there's nothing in userspace relying on the current aic94xx revision file so it can be renamed without breaking anything.
--- drivers/scsi/aic94xx/aic94xx_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/aic94xx/aic94xx_init.c +4 -4
@@ -281,7 +281,7 @@ static ssize_t asd_show_dev_rev(struct dreturn snprintf (buf,PAGE_SIZE ,"%s\n" , asd_dev_rev[asd_ha->revision_id]); } -static DEVICE_ATTR(revision, S_IRUGO, asd_show_dev_rev, NULL); +static DEVICE_ATTR(aic_revision, S_IRUGO, asd_show_dev_rev, NULL);static ssize_t asd_show_dev_bios_build (struct device *dev,struct device_attribute *attr,char *buf)
@@ -478,7 +478,7 @@ static int asd_create_dev_attrs(struct a {int err; - err =device_create_file (&asd_ha->pcidev->dev, &dev_attr_revision); + err =device_create_file (&asd_ha->pcidev->dev, &dev_attr_aic_revision);if (err)return err;
@@ -500,13 +500,13 @@ err_update_bios: err_biosb:device_remove_file (&asd_ha->pcidev->dev, &dev_attr_bios_build); err_rev: -device_remove_file (&asd_ha->pcidev->dev, &dev_attr_revision); +device_remove_file (&asd_ha->pcidev->dev, &dev_attr_aic_revision);return err; }static void asd_remove_dev_attrs (struct asd_ha_struct *asd_ha) { -device_remove_file (&asd_ha->pcidev->dev, &dev_attr_revision); +device_remove_file (&asd_ha->pcidev->dev, &dev_attr_aic_revision);device_remove_file (&asd_ha->pcidev->dev, &dev_attr_bios_build);device_remove_file (&asd_ha->pcidev->dev, &dev_attr_pcba_sn);device_remove_file (&asd_ha->pcidev->dev, &dev_attr_update_bios);
Greg Kroah-Hartman
maintainerPATCH 300/313 KVM: x86: work around leak of uninitialized stack contents (CVE-2019-7222)
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit 353c0956a618a07ba4bbe7ad00ff29fe70e8412a upstream.
Bugzilla: 1671930
Emulation of certain instructions (VMXON, VMCLEAR, VMPTRLD, VMWRITE with memory operand, INVEPT, INVVPID) can incorrectly inject a page fault when passed an operand that points to an MMIO address. The page fault will use uninitialized kernel stack memory as the CR2 and error code.
The right behavior would be to abort the VM with a KVM_EXIT_INTERNAL_ERROR exit to userspace; however, it is not an easy fix, so for now just ensure that the error code and CR2 are zero.
Embargoed until Feb 7th 2019.
--- arch/x86/kvm/x86.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kvm/x86.c +7 -0
@@ -4904,6 +4904,13 @@ int kvm_read_guest_virt(struct kvm_vcpu {u32 access = (kvm_x86_ops->get_cpl (vcpu) ==3 ) ?PFERR_USER_MASK :0 ; +/* +* FIXME: this should call handle_emulation_failure if X86EMUL_IO_NEEDED +* is returned, but our callers are not ready for that and they blindly +* call kvm_inject_page_fault. Ensure that they at least do not leak +* uninitialized kernel stack memory into cr2 and error code. +*/ +memset (exception,0 ,sizeof (*exception));return kvm_read_guest_virt_helper (addr, val, bytes, vcpu, access, exception); }
Greg Kroah-Hartman
maintainerPATCH 301/313 kvm: fix kvm_ioctl_create_device() reference counting (CVE-2019-6974)
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit cfa39381173d5f969daf43582c95ad679189cbc9 upstream.
kvm_ioctl_create_device() does the following:
1. creates a device that holds a reference to the VM object (with a borrowed reference, the VM's refcount has not been bumped yet)
2. initializes the device
3. transfers the reference to the device to the caller's file descriptor table
4. calls kvm_get_kvm() to turn the borrowed reference to the VM into a real reference
The ownership transfer in step 3 must not happen before the reference to the VM becomes a proper, non-borrowed reference, which only happens in step 4. After step 3, an attacker can close the file descriptor and drop the borrowed reference, which can cause the refcount of the kvm object to drop to zero.
This means that we need to grab a reference for the device before anon_inode_getfd(), otherwise the VM can disappear from under us.
--- virt/kvm/kvm_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/kvm_main.c +2 -1
@@ -2913,8 +2913,10 @@ static int kvm_ioctl_create_device(strucif (ops->init) ops->init (dev); +kvm_get_kvm (kvm); ret =anon_inode_getfd (ops->name, &kvm_device_fops, dev,O_RDWR |O_CLOEXEC );if (ret <0 ) { +kvm_put_kvm (kvm);mutex_lock (&kvm->lock);list_del (&dev->vm_node);mutex_unlock (&kvm->lock);
@@ -2922,7 +2924,6 @@ static int kvm_ioctl_create_device(strucreturn ret; } -kvm_get_kvm (kvm); cd->fd = ret;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 302/313 KVM: nVMX: unconditionally cancel preemption timer in free_nested (CVE-2019-7221)
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Shier <[email protected]>
commit ecec76885bcfe3294685dc363fd1273df0d5d65f upstream.
Bugzilla: 1671904
There are multiple code paths where an hrtimer may have been started to emulate an L1 VMX preemption timer that can result in a call to free_nested without an intervening L2 exit where the hrtimer is normally cancelled. Unconditionally cancel in free_nested to cover all cases.
Embargoed until Feb 7th 2019.
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/vmx.c +1 -0
@@ -8469,6 +8469,7 @@ static void free_nested(struct vcpu_vmxif (!vmx->nested.vmxon && !vmx->nested.smm.vmxon)return ; +hrtimer_cancel (&vmx->nested.preemption_timer); vmx->nested.vmxon = false; vmx->nested.smm.vmxon = false;free_vpid (vmx->nested.vpid02);
Greg Kroah-Hartman
maintainerPATCH 303/313 cpu/hotplug: Fix "SMT disabled by BIOS" detection for KVM
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit b284909abad48b07d3071a9fc9b5692b3e64914b upstream.
With the following commit:
73d5e2b47264 ("cpu/hotplug: detect SMT disabled by BIOS")
... the hotplug code attempted to detect when SMT was disabled by BIOS, in which case it reported SMT as permanently disabled. However, that code broke a virt hotplug scenario, where the guest is booted with only primary CPU threads, and a sibling is brought online later.
The problem is that there doesn't seem to be a way to reliably distinguish between the HW "SMT disabled by BIOS" case and the virt "sibling not yet brought online" case. So the above-mentioned commit was a bit misguided, as it permanently disabled SMT for both cases, preventing future virt sibling hotplugs.
Going back and reviewing the original problems which were attempted to be solved by that commit, when SMT was disabled in BIOS:
1) /sys/devices/system/cpu/smt/control showed "on" instead of "notsupported"; and
2) vmx_vm_init() was incorrectly showing the L1TF_MSG_SMT warning.
I'd propose that we instead consider #1 above to not actually be a problem. Because, at least in the virt case, it's possible that SMT wasn't disabled by BIOS and a sibling thread could be brought online later. So it makes sense to just always default the smt control to "on" to allow for that possibility (assuming cpuid indicates that the CPU supports SMT).
The real problem is #2, which has a simple fix: change vmx_vm_init() to query the actual current SMT state -- i.e., whether any siblings are currently online -- instead of looking at the SMT "control" sysfs value.
So fix it by:
a) reverting the original "fix" and its followup fix:
73d5e2b47264 ("cpu/hotplug: detect SMT disabled by BIOS") bc2d8d262cba ("cpu/hotplug: Fix SMT supported evaluation")
and
b) changing vmx_vm_init() to query the actual current SMT state -- instead of the sysfs control value -- to determine whether the L1TF warning is needed. This also requires the 'sched_smt_present' variable to exported, instead of 'cpu_smt_control'.
--- arch/x86/kernel/cpu/bugs.c | 2 +- arch/x86/kvm/vmx.c | 3 ++- include/linux/cpu.h | 2 -- kernel/cpu.c | 33 ++++----------------------------- kernel/sched/fair.c | 1 + kernel/smp.c | 2 -- 6 files changed, 8 insertions(+), 35 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -69,7 +69,7 @@ void __init check_bugs(void)* identify_boot_cpu() initialized SMT support information, let the * core code know. */ -cpu_smt_check_topology_early (); +cpu_smt_check_topology ();if (!IS_ENABLED (CONFIG_SMP )) {pr_info ("CPU: " );
arch/x86/kvm/vmx.c +2 -1
@@ -27,6 +27,7 @@#include <linux/mm.h> #include <linux/highmem.h> #include <linux/sched.h> +#include <linux/sched/smt.h> #include <linux/moduleparam.h> #include <linux/mod_devicetable.h> #include <linux/trace_events.h>
@@ -11129,7 +11130,7 @@ static int vmx_vm_init(struct kvm *kvm)* Warn upon starting the first VM in a potentially * insecure environment. */ -if (cpu_smt_control ==CPU_SMT_ENABLED ) +if (sched_smt_active ())pr_warn_once (L1TF_MSG_SMT );if (l1tf_vmx_mitigation ==VMENTER_L1D_FLUSH_NEVER )pr_warn_once (L1TF_MSG_L1D );
include/linux/cpu.h +0 -2
@@ -180,12 +180,10 @@ enum cpuhp_smt_control {#if defined(CONFIG_SMP ) && defined(CONFIG_HOTPLUG_SMT )extern enum cpuhp_smt_control cpu_smt_control;extern void cpu_smt_disable (bool force); -extern void cpu_smt_check_topology_early (void );extern void cpu_smt_check_topology (void );#else # define cpu_smt_control (CPU_SMT_ENABLED)static inline void cpu_smt_disable (bool force) { } -static inline void cpu_smt_check_topology_early (void ) { }static inline void cpu_smt_check_topology (void ) { }#endif
kernel/cpu.c +4 -29
@@ -355,9 +355,6 @@ void __weak arch_smt_update(void) { }#ifdef CONFIG_HOTPLUG_SMT enum cpuhp_smt_control cpu_smt_control__read_mostly =CPU_SMT_ENABLED ; -EXPORT_SYMBOL_GPL (cpu_smt_control); - -static bool cpu_smt_available__read_mostly ;void __init cpu_smt_disable (bool force) {
@@ -375,25 +372,11 @@ void __init cpu_smt_disable(bool force)/* * The decision whether SMT is supported can only be done after the full -* CPU identification. Called from architecture code before non boot CPUs -* are brought up. -*/ -void __init cpu_smt_check_topology_early (void ) -{ -if (!topology_smt_supported ()) - cpu_smt_control =CPU_SMT_NOT_SUPPORTED ; -} - -/* -* If SMT was disabled by BIOS, detect it here, after the CPUs have been -* brought online. This ensures the smt/l1tf sysfs entries are consistent -* with reality. cpu_smt_available is set to true during the bringup of non -* boot CPUs when a SMT sibling is detected. Note, this may overwrite -* cpu_smt_control's previous setting. +* CPU identification. Called from architecture code. */ void __init cpu_smt_check_topology (void ) { -if (!cpu_smt_available) +if (!topology_smt_supported ()) cpu_smt_control =CPU_SMT_NOT_SUPPORTED ; }
@@ -406,18 +389,10 @@ early_param("nosmt", smt_cmdline_disablestatic inline bool cpu_smt_allowed (unsigned int cpu) { -if (topology_is_primary_thread (cpu)) +if (cpu_smt_control ==CPU_SMT_ENABLED )return true; -/* -* If the CPU is not a 'primary' thread and the booted_once bit is -* set then the processor has SMT support. Store this information -* for the late check of SMT support in cpu_smt_check_topology(). -*/ -if (per_cpu (cpuhp_state, cpu).booted_once) - cpu_smt_available = true; - -if (cpu_smt_control ==CPU_SMT_ENABLED ) +if (topology_is_primary_thread (cpu))return true;/*
kernel/sched/fair.c +1 -0
@@ -5932,6 +5932,7 @@ static inline int find_idlest_cpu(struct#ifdef CONFIG_SCHED_SMT DEFINE_STATIC_KEY_FALSE (sched_smt_present); +EXPORT_SYMBOL_GPL (sched_smt_present);static inline void set_idle_cores (int cpu,int val) {
kernel/smp.c +0 -2
@@ -584,8 +584,6 @@ void __init smp_init(void) num_nodes, (num_nodes >1 ?"s" :"" ), num_cpus, (num_cpus > 1 ? "s" : "")); -/* Final decision about SMT support */ -cpu_smt_check_topology ();/* Any cleanup work */ smp_cpus_done (setup_max_cpus); }
Greg Kroah-Hartman
maintainerPATCH 304/313 perf/x86/intel/uncore: Add Node ID mask
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 9e63a7894fd302082cf3627fe90844421a6cbe7f upstream.
Some PCI uncore PMUs cannot be registered on an 8-socket system (HPE Superdome Flex).
To understand which Socket the PCI uncore PMUs belongs to, perf retrieves the local Node ID of the uncore device from CPUNODEID(0xC0) of the PCI configuration space, and the mapping between Socket ID and Node ID from GIDNIDMAP(0xD4). The Socket ID can be calculated accordingly.
The local Node ID is only available at bit 2:0, but current code doesn't mask it. If a BIOS doesn't clear the rest of the bits, an incorrect Node ID will be fetched.
Filter the Node ID by adding a mask.
--- arch/x86/events/intel/uncore_snbep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/events/intel/uncore_snbep.c +3 -1
@@ -1222,6 +1222,8 @@ static struct pci_driver snbep_uncore_pc .id_table = snbep_uncore_pci_ids, }; +#define NODE_ID_MASK 0x7 +/* * build pci bus to socket mapping */
@@ -1243,7 +1245,7 @@ static int snbep_pci2phy_map_init(int de err =pci_read_config_dword (ubox_dev, nodeid_loc, &config);if (err)break ; - nodeid = config; + nodeid = config &NODE_ID_MASK ;/* get the Node ID mapping */ err =pci_read_config_dword (ubox_dev, idmap_loc, &config);if (err)
Greg Kroah-Hartman
maintainerPATCH 305/313 x86/MCE: Initialize mce.bank in the case of a fatal error in mce_no_way_out()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Luck <[email protected]>
commit d28af26faa0b1daf3c692603d46bc4687c16f19e upstream.
Internal injection testing crashed with a console log that said:
mce: [Hardware Error]: CPU 7: Machine Check Exception: f Bank 0: bd80000000100134
This caused a lot of head scratching because the MCACOD (bits 15:0) of that status is a signature from an L1 data cache error. But Linux says that it found it in "Bank 0", which on this model CPU only reports L1 instruction cache errors.
The answer was that Linux doesn't initialize "m->bank" in the case that it finds a fatal error in the mce_no_way_out() pre-scan of banks. If this was a local machine check, then this partially initialized struct mce is being passed to mce_panic().
Fix is simple: just initialize m->bank in the case of a fatal error.
--- arch/x86/kernel/cpu/mcheck/mce.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/cpu/mcheck/mce.c +1 -0
@@ -783,6 +783,7 @@ static int mce_no_way_out(struct mce *m,quirk_no_way_out (i, m, regs);if (mce_severity (m, mca_cfg.tolerant, &tmp, true) >=MCE_PANIC_SEVERITY ) { + m->bank = i;mce_read_aux (m, i); *msg = tmp;return 1 ;
Greg Kroah-Hartman
maintainerPATCH 306/313 perf/core: Dont WARN() for impossible ring-buffer sizes
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit 9dff0aa95a324e262ffb03f425d00e4751f3294e upstream.
The perf tool uses /proc/sys/kernel/perf_event_mlock_kb to determine how large its ringbuffer mmap should be. This can be configured to arbitrary values, which can be larger than the maximum possible allocation from kmalloc.
When this is configured to a suitably large value (e.g. thanks to the perf fuzzer), attempting to use perf record triggers a WARN_ON_ONCE() in __alloc_pages_nodemask():
WARNING: CPU: 2 PID: 5666 at mm/page_alloc.c:4511 __alloc_pages_nodemask+0x3f8/0xbc8
Let's avoid this by checking that the requested allocation is possible before calling kzalloc.
--- kernel/events/ring_buffer.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/events/ring_buffer.c +3 -0
@@ -724,6 +724,9 @@ struct ring_buffer *rb_alloc(int nr_page size =sizeof (struct ring_buffer ); size += nr_pages *sizeof (void *); +if (order_base_2 (size) >=MAX_ORDER ) + goto fail; + rb =kzalloc (size,GFP_KERNEL );if (!rb) goto fail;
Greg Kroah-Hartman
maintainerPATCH 307/313 perf tests evsel-tp-sched: Fix bitwise operator
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit 489338a717a0dfbbd5a3fabccf172b78f0ac9015 upstream.
Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.
Fix this by using bitwise AND operator '&' instead.
This bug was detected with the help of Coccinelle.
--- tools/perf/tests/evsel-tp-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/evsel-tp-sched.c +1 -1
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(structreturn -1 ; } - is_signed = !!(field->flags |FIELD_IS_SIGNED ); + is_signed = !!(field->flags &FIELD_IS_SIGNED );if (should_be_signed && !is_signed) {pr_debug ("%s: \"%s\" signedness(%d) is wrong, should be %d\n" , evsel->name, name, is_signed, should_be_signed);
Greg Kroah-Hartman
maintainerPATCH 308/313 serial: fix race between flush_to_ldisc and tty_open
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit fedb5760648a291e949f2380d383b5b2d2749b5e upstream.
There still is a race window after the commit b027e2298bd588 ("tty: fix data race between tty_init_dev and flush of buf"), and we encountered this crash issue if receive_buf call comes before tty initialization completes in tty_open and tty->driver_data may be NULL.
CPU0 CPU1
---- ----
tty_open
tty_init_dev
tty_ldisc_unlock
scheduleflush_to_ldisc
receive_buf
tty_port_default_receive_buf
tty_ldisc_receive_buf
n_tty_receive_buf_common
__receive_buf
uart_flush_chars
uart_start
/*tty->driver_data is NULL*/
tty->ops->open
/*init tty->driver_data*/it can be fixed by extending ldisc semaphore lock in tty_init_dev to driver_data initialized completely after tty->ops->open(), but this will lead to get lock on one function and unlock in some other function, and hard to maintain, so fix this race only by checking tty->driver_data when receiving, and return if tty->driver_data is NULL, and n_tty_receive_buf_common maybe calls uart_unthrottle, so add the same check.
Because the tty layer knows nothing about the driver associated with the device, the tty layer can not do anything here, it is up to the tty driver itself to check for this type of race. Fix up the serial driver to correctly check to see if it is finished binding with the device when being called, and if not, abort the tty calls.
[Description and problem report and testing from Li RongQing, I rewrote the patch to be in the serial layer, not in the tty core - gregkh]
--- drivers/tty/serial/serial_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/serial/serial_core.c +6 -0
@@ -130,6 +130,9 @@ static void uart_start(struct tty_structstruct uart_port *port;unsigned long flags; +if (!state) +return ; + port =uart_port_lock (state, flags);__uart_start (tty);uart_port_unlock (port, flags);
@@ -727,6 +730,9 @@ static void uart_unthrottle(struct tty_supstat_t mask =UPSTAT_SYNC_FIFO ;struct uart_port *port; +if (!state) +return ; + port =uart_port_ref (state);if (!port)return ;
Greg Kroah-Hartman
maintainerPATCH 309/313 serial: 8250_pci: Make PCI class test non fatal
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 824d17c57b0abbcb9128fb3f7327fae14761914b upstream.
As has been reported the National Instruments serial cards have broken PCI class.
The commit 7d8905d06405
("serial: 8250_pci: Enable device after we check black list")
made the PCI class check mandatory for the case when device is listed in a quirk list.
Make PCI class test non fatal to allow broken card be enumerated.
--- drivers/tty/serial/8250/8250_pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_pci.c +5 -4
@@ -3420,6 +3420,11 @@ static int serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) { int num_iomem, num_port, first_port = -1, i; +int rc; + + rc =serial_pci_is_class_communication (dev); +if (rc) +return rc;/* * Should we try to make guesses for multiport serial devices later?
@@ -3647,10 +3652,6 @@ pciserial_init_one(struct pci_dev *dev, board = &pci_boards[ent->driver_data]; - rc =serial_pci_is_class_communication (dev); -if (rc) -return rc; - rc =serial_pci_is_blacklisted (dev);if (rc)return rc;
Greg Kroah-Hartman
maintainerPATCH 310/313 serial: sh-sci: Do not free irqs that have already been freed
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Brandt <[email protected]>
commit 4d95987a32db53f3beca76f8c4c8309ef6a5f192 upstream.
Since IRQs might be muxed on some parts, we need to pay attention when we are freeing them.
Otherwise we get the ugly WARNING "Trying to free already-free IRQ 20".
--- drivers/tty/serial/sh-sci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/tty/serial/sh-sci.c +8 -1
@@ -1921,7 +1921,7 @@ out_nomem:static void sci_free_irq (struct sci_port *port) { -int i; +int i, j;/* * Intentionally in reverse order so we iterate over the muxed
@@ -1937,6 +1937,13 @@ static void sci_free_irq(struct sci_portif (unlikely (irq <0 ))continue ; +/* Check if already freed (irq was muxed) */ +for (j =0 ; j < i; j++) +if (port->irqs[j] == irq) + j = i +1 ; +if (j > i) +continue ; +free_irq (port->irqs[i], port);kfree (port->irqstr[i]);
Greg Kroah-Hartman
maintainerPATCH 311/313 cacheinfo: Keep the old value if of_property_read_u32 fails
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit 3a34c986324c07dde32903f7bb262e6138e77c2a upstream.
Commit 448a5a552f336bd7b847b1951 ("drivers: base: cacheinfo: use OF property_read_u32 instead of get_property,read_number") makes cache size and number_of_sets be 0 if DT doesn't provide there values. I think this is unreasonable so make them keep the old values, which is the same as old kernels.
--- drivers/base/cacheinfo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/base/cacheinfo.c +2 -4
@@ -79,8 +79,7 @@ static void cache_size(struct cacheinfo ct_idx =get_cacheinfo_idx (this_leaf->type); propname = cache_type_info[ct_idx].size_prop; -if (of_property_read_u32 (np, propname, &this_leaf->size)) - this_leaf->size =0 ; +of_property_read_u32 (np, propname, &this_leaf->size); }/* not cache_line_size() because that's a macro in include/linux/cache.h */
@@ -114,8 +113,7 @@ static void cache_nr_sets(struct cachein ct_idx =get_cacheinfo_idx (this_leaf->type); propname = cache_type_info[ct_idx].nr_sets_prop; -if (of_property_read_u32 (np, propname, &this_leaf->number_of_sets)) - this_leaf->number_of_sets =0 ; +of_property_read_u32 (np, propname, &this_leaf->number_of_sets); }static void cache_associativity (struct cacheinfo *this_leaf)
Greg Kroah-Hartman
maintainerPATCH 312/313 IB/hfi1: Add limit test for RC/UC send via loopback
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Marciniszyn <[email protected]>
commit 09ce351dff8e7636af0beb72cd4a86c3904a0500 upstream.
Fix potential memory corruption and panic in loopback for IB_WR_SEND variants.
The code blindly assumes the posted length will fit in the fetched rwqe, which is not a valid assumption.
Fix by adding a limit test, and triggering the appropriate send completion and putting the QP in an error state. This mimics the handling for non-loopback QPs.
--- drivers/infiniband/hw/hfi1/ruc.c | 7 ++++++- drivers/infiniband/hw/qib/qib_ruc.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/ruc.c +6 -1
@@ -278,6 +278,8 @@ send: goto op_err;if (!ret) goto rnr_nak; +if (wqe->length > qp->r_len) + goto inv_err;break ;case IB_WR_RDMA_WRITE_WITH_IMM :
@@ -445,7 +447,10 @@ op_err: goto err; inv_err: - send_status =IB_WC_REM_INV_REQ_ERR ; + send_status = + sqp->ibqp.qp_type ==IB_QPT_RC ? +IB_WC_REM_INV_REQ_ERR : +IB_WC_SUCCESS ; wc.status =IB_WC_LOC_QP_OP_ERR ; goto err;
drivers/infiniband/hw/qib/qib_ruc.c +6 -1
@@ -274,6 +274,8 @@ again: goto op_err;if (!ret) goto rnr_nak; +if (wqe->length > qp->r_len) + goto inv_err;break ;case IB_WR_RDMA_WRITE_WITH_IMM :
@@ -434,7 +436,10 @@ op_err: goto err; inv_err: - send_status =IB_WC_REM_INV_REQ_ERR ; + send_status = + sqp->ibqp.qp_type ==IB_QPT_RC ? +IB_WC_REM_INV_REQ_ERR : +IB_WC_SUCCESS ; wc.status =IB_WC_LOC_QP_OP_ERR ; goto err;
Greg Kroah-Hartman
maintainerPATCH 313/313 perf/x86/intel: Delay memory deallocation until x86_pmu_dead_cpu()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 602cae04c4864bb3487dfe4c2126c8d9e7e1614a upstream.
intel_pmu_cpu_prepare() allocated memory for ->shared_regs among other members of struct cpu_hw_events. This memory is released in intel_pmu_cpu_dying() which is wrong. The counterpart of the intel_pmu_cpu_prepare() callback is x86_pmu_dead_cpu().
Otherwise if the CPU fails on the UP path between CPUHP_PERF_X86_PREPARE and CPUHP_AP_PERF_X86_STARTING then it won't release the memory but allocate new memory on the next attempt to online the CPU (leaking the old memory).
Also, if the CPU down path fails between CPUHP_AP_PERF_X86_STARTING and CPUHP_PERF_X86_PREPARE then the CPU will go back online but never allocate the memory that was released in x86_pmu_dying_cpu().
Make the memory allocation/free symmetrical in regard to the CPU hotplug notifier by moving the deallocation to intel_pmu_cpu_dead().
This started in commit:
a7e3ed1e47011 ("perf: Add support for supplementary event registers").
In principle the bug was introduced in v2.6.39 (!), but it will almost certainly not backport cleanly across the big CPU hotplug rewrite between v4.7-v4.15...
[ bigeasy: Added patch description. ]
[ mingo: Added backporting guidance. ]
[ He Zhe: Fixes conflict caused by missing disable_counter_freeze which is
introduced since v4.20 af3bdb991a5cb. ]
--- arch/x86/events/intel/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/events/intel/core.c +8 -2
@@ -3440,6 +3440,11 @@ static void free_excl_cntrs(int cpu)static void intel_pmu_cpu_dying (int cpu) { +fini_debug_store_on_cpu (cpu); +} + +static void intel_pmu_cpu_dead (int cpu) +{struct cpu_hw_events *cpuc = &per_cpu (cpu_hw_events, cpu);struct intel_shared_regs *pc;
@@ -3451,8 +3456,6 @@ static void intel_pmu_cpu_dying(int cpu) }free_excl_cntrs (cpu); - -fini_debug_store_on_cpu (cpu); } static void intel_pmu_sched_task(struct perf_event_context *ctx,
@@ -3541,6 +3544,7 @@ static __initconst const struct x86_pmu .cpu_prepare = intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, .cpu_dying = intel_pmu_cpu_dying, + .cpu_dead = intel_pmu_cpu_dead, };static struct attribute *intel_pmu_attrs[];
@@ -3581,6 +3585,8 @@ static __initconst const struct x86_pmu .cpu_prepare = intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, .cpu_dying = intel_pmu_cpu_dying, + .cpu_dead = intel_pmu_cpu_dead, + .guest_get_msrs = intel_guest_get_msrs, .sched_task = intel_pmu_sched_task, };
stable-rc/linux-4.19.y boot: 113 boots: 0 failed, 112 passed with 1 untried/unknown (v4.19.20-313-g175a7aa1da44)
stable-rc/linux-4.19.y boot: 113 boots: 0 failed, 112 passed with 1 untried/unknown (v4.19.20-313-g175a7aa1da44)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.19.y/kernel/v4.19.20-313-g175a7aa1da44/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.19.y/kernel/v4.19.20-313-g175a7aa1da44/
Tree: stable-rc
Branch: linux-4.19.y
Git Describe: v4.19.20-313-g175a7aa1da44
Git Commit: 175a7aa1da44876d97625a345183b3f885f0b6ea
Git URL: http://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 62 unique boards, 23 SoC families, 12 builds out of 202
---
For more info write to <[email protected]>
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.21 release. There are 313 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 Wed Feb 13 14:17:25 UTC 2019. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.21-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 4.19.21-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.19.y
git commit: 3ddcc8a209d38c7eb6eb5fd9b8bafd859a08fa1f
git describe: v4.19.20-313-g3ddcc8a209d3
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.19-oe/build/v4.19.20-313-g3ddcc8a209d3
No regressions (compared to build v4.19.20)
No fixes (compared to build v4.19.20)
Ran 14561 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- juno-r2 - arm64
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15 - arm
Test Suites
-----------
* boot
* install-android-platform-tools-r2600
* kselftest
* libhugetlbfs
* ltp-cap_bounds-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-timers-tests
* spectre-meltdown-checker-test
* ltp-open-posix-tests
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.21 release. There are 313 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 Wed Feb 13 14:17:25 UTC 2019. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.21-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.21 release. There are 313 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 Wed Feb 13 14:17:25 UTC 2019. Anything received after that time might be too late.
Build results:
total: 156 pass: 156 fail: 0 Qemu test results: total: 343 pass: 343 fail: 0
Guenter