6.1.113-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 121/798 drm/mediatek: Use spin_lock_irqsave() for CRTC event lock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fei Shao <[email protected]>
[ Upstream commit be03b30b7aa99aca876fbc7c1c1b73b2d0339321 ]
Use the state-aware spin_lock_irqsave() and spin_unlock_irqrestore() to avoid unconditionally re-enabling the local interrupts.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +3 -2
@@ -444,6 +444,7 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc) {struct drm_device *drm = mtk_crtc->base.dev;struct drm_crtc *crtc = &mtk_crtc->base; +unsigned long flags;int i;for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) {
@@ -470,10 +471,10 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc)pm_runtime_put (drm->dev);if (crtc->state->event && !crtc->state->active) { -spin_lock_irq (&crtc->dev->event_lock); +spin_lock_irqsave (&crtc->dev->event_lock, flags);drm_crtc_send_vblank_event (crtc, crtc->state->event); crtc->state->event =NULL ; -spin_unlock_irq (&crtc->dev->event_lock); +spin_unlock_irqrestore (&crtc->dev->event_lock, flags); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 122/798 powerpc/8xx: Fix initial memory mapping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit f9f2bff64c2f0dbee57be3d8c2741357ad3d05e6 ]
Commit cf209951fa7f ("powerpc/8xx: Map linear memory with huge pages") introduced an initial mapping of kernel TEXT using PAGE_KERNEL_TEXT, but the pages that contain kernel TEXT may also contain kernel RODATA, and depending on selected debug options PAGE_KERNEL_TEXT may be either RWX or ROX. RODATA must be writable during init because it also contains ro_after_init data.
So use PAGE_KERNEL_X instead to be sure it is RWX.
--- arch/powerpc/mm/nohash/8xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/nohash/8xx.c +2 -2
@@ -147,11 +147,11 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)mmu_mapin_immr (); -mmu_mapin_ram_chunk (0 , boundary,PAGE_KERNEL_TEXT , true); +mmu_mapin_ram_chunk (0 , boundary,PAGE_KERNEL_X , true);if (debug_pagealloc_enabled_or_kfence ()) { top = boundary; }else { -mmu_mapin_ram_chunk (boundary, einittext8,PAGE_KERNEL_TEXT , true); +mmu_mapin_ram_chunk (boundary, einittext8,PAGE_KERNEL_X , true);mmu_mapin_ram_chunk (einittext8, top,PAGE_KERNEL , true); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 123/798 powerpc/8xx: Fix kernel vs user address comparison
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 65a82e117ffeeab0baf6f871a1cab11a28ace183 ]
Since commit 9132a2e82adc ("powerpc/8xx: Define a MODULE area below kernel text"), module exec space is below PAGE_OFFSET so not only space above PAGE_OFFSET, but space above TASK_SIZE need to be seen as kernel space.
Until now the problem went undetected because by default TASK_SIZE is 0x8000000 which means address space is determined by just checking upper address bit. But when TASK_SIZE is over 0x80000000, PAGE_OFFSET is used for comparison, leading to thinking module addresses are part of user space.
Fix it by using TASK_SIZE instead of PAGE_OFFSET for address comparison.
--- arch/powerpc/kernel/head_8xx.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kernel/head_8xx.S +3 -3
@@ -40,12 +40,12 @@ #include "head_32.h" .macro compare_to_kernel_boundary scratch, addr -#if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000 +#if CONFIG_TASK_SIZE <= 0x80000000 && MODULES_VADDR >= 0x80000000 /* By simply checking Address >= 0x80000000, we know if its a kernel address */ not. \scratch, \addr #else rlwinm \scratch, \addr, 16, 0xfff8 - cmpli cr0, \scratch, PAGE_OFFSET@h + cmpli cr0, \scratch, TASK_SIZE@h #endif .endm
@@ -403,7 +403,7 @@ FixupDAR:/* Entry point for dcbx workaround. */ mfspr r10, SPRN_SRR0 mtspr SPRN_MD_EPN, r10 rlwinm r11, r10, 16, 0xfff8 - cmpli cr1, r11, PAGE_OFFSET@h + cmpli cr1, r11, TASK_SIZE@h mfspr r11, SPRN_M_TWB /* Get level 1 table */ blt+ cr1, 3f
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 124/798 drm/msm: Fix incorrect file name output in adreno_request_fw()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mishin <[email protected]>
[ Upstream commit e19366911340c2313a1abbb09c54eaf9bdea4f58 ]
In adreno_request_fw() when debugging information is printed to the log after firmware load, an incorrect filename is printed. 'newname' is used instead of 'fwname', so prefix "qcom/" is being added to filename. Looks like "copy-paste" mistake.
Fix this mistake by replacing 'newname' with 'fwname'.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Patchwork: https://patchwork.freedesktop.org/patch/602382/
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
@@ -418,7 +418,7 @@ adreno_request_fw(struct adreno_gpu *adreno_gpu, const char *fwname) ret =request_firmware_direct (&fw, fwname, drm->dev);if (!ret) {DRM_DEV_INFO (drm->dev,"loaded %s from legacy location\n" , - newname); + fwname); adreno_gpu->fwloc =FW_LOCATION_LEGACY ; goto out; }else if (adreno_gpu->fwloc !=FW_LOCATION_UNKNOWN ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 125/798 drm/msm/a5xx: disable preemption in submits by default
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit db9dec2db76146d65e1cfbb6afb2e2bd5dab67f8 ]
Fine grain preemption (switching from/to points within submits) requires extra handling in command stream of those submits, especially when rendering with tiling (using GMEM). However this handling is missing at this point in mesa (and always was). For this reason we get random GPU faults and hangs if more than one priority level is used because local preemption is enabled prior to executing command stream from submit.
With that said it was ahead of time to enable local preemption by default considering the fact that even on downstream kernel it is only enabled if requested via UAPI.
Patchwork: https://patchwork.freedesktop.org/patch/612041/
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +6 -2
@@ -150,9 +150,13 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)OUT_PKT7 (ring,CP_SET_PROTECTED_MODE ,1 );OUT_RING (ring,1 ); -/* Enable local preemption for finegrain preemption */ +/* +* Disable local preemption by default because it requires +* user-space to be aware of it and provide additional handling +* to restore rendering state or do various flushes on switch. +*/ OUT_PKT7 (ring,CP_PREEMPT_ENABLE_LOCAL ,1 ); -OUT_RING (ring,0x1 ); +OUT_RING (ring,0x0 );/* Allow CP_CONTEXT_SWITCH_YIELD packets in the IB2 */ OUT_PKT7 (ring,CP_YIELD_ENABLE ,1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 126/798 drm/msm/a5xx: properly clear preemption records on resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit 64fd6d01a52904bdbda0ce810a45a428c995a4ca ]
Two fields of preempt_record which are used by CP aren't reset on
resume: "data" and "info". This is the reason behind faults which happen when we try to switch to the ring that was active last before suspend. In addition those faults can't be recovered from because we use suspend and resume to do so (keeping values of those fields again).
Patchwork: https://patchwork.freedesktop.org/patch/612043/
--- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +2 -0
@@ -204,6 +204,8 @@ void a5xx_preempt_hw_init(struct msm_gpu *gpu)return ;for (i =0 ; i < gpu->nr_rings; i++) { + a5xx_gpu->preempt[i]->data =0 ; + a5xx_gpu->preempt[i]->info =0 ; a5xx_gpu->preempt[i]->wptr =0 ; a5xx_gpu->preempt[i]->rptr =0 ; a5xx_gpu->preempt[i]->rbase = gpu->rb[i]->iova;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 127/798 drm/msm/a5xx: fix races in preemption evaluation stage
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit ce050f307ad93bcc5958d0dd35fc276fd394d274 ]
On A5XX GPUs when preemption is used it's invietable to enter a soft lock-up state in which GPU is stuck at empty ring-buffer doing nothing. This appears as full UI lockup and not detected as GPU hang (because it's not). This happens due to not triggering preemption when it was needed. Sometimes this state can be recovered by some new submit but generally it won't happen because applications are waiting for old submits to retire.
One of the reasons why this happens is a race between a5xx_submit and a5xx_preempt_trigger called from IRQ during submit retire. Former thread updates ring->cur of previously empty and not current ring right after latter checks it for emptiness. Then both threads can just exit because for first one preempt_state wasn't NONE yet and for second one all rings appeared to be empty.
To prevent such situations from happening we need to establish guarantee for preempt_trigger to make decision after each submit or retire. To implement this we serialize preemption initiation using spinlock. If switch is already in progress we need to re-trigger preemption when it finishes.
Patchwork: https://patchwork.freedesktop.org/patch/612045/
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 24 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -0
@@ -36,6 +36,7 @@ struct a5xx_gpu {uint64_t preempt_iova[MSM_GPU_MAX_RINGS ];atomic_t preempt_state; +spinlock_t preempt_start_lock;struct timer_list preempt_timer;struct drm_gem_object *shadow_bo;
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +22 -2
@@ -97,12 +97,19 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)if (gpu->nr_rings ==1 )return ; +/* +* Serialize preemption start to ensure that we always make +* decision on latest state. Otherwise we can get stuck in +* lower priority or empty ring. +*/ +spin_lock_irqsave (&a5xx_gpu->preempt_start_lock, flags); +/* * Try to start preemption by moving from NONE to START. If * unsuccessful, a preemption is already in flight */ if (!try_preempt_state (a5xx_gpu,PREEMPT_NONE ,PREEMPT_START )) -return ; + goto out;/* Get the next ring to preempt to */ ring =get_next_ring (gpu);
@@ -127,9 +134,11 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)set_preempt_state (a5xx_gpu,PREEMPT_ABORT );update_wptr (gpu, a5xx_gpu->cur_ring);set_preempt_state (a5xx_gpu,PREEMPT_NONE ); -return ; + goto out; } +spin_unlock_irqrestore (&a5xx_gpu->preempt_start_lock, flags); +/* Make sure the wptr doesn't update while we're in motion */ spin_lock_irqsave (&ring->preempt_lock, flags); a5xx_gpu->preempt[ring->id]->wptr =get_wptr (ring);
@@ -152,6 +161,10 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)/* And actually start the preemption */ gpu_write (gpu,REG_A5XX_CP_CONTEXT_SWITCH_CNTL ,1 ); +return ; + +out: +spin_unlock_irqrestore (&a5xx_gpu->preempt_start_lock, flags); }void a5xx_preempt_irq (struct msm_gpu *gpu)
@@ -188,6 +201,12 @@ void a5xx_preempt_irq(struct msm_gpu *gpu)update_wptr (gpu, a5xx_gpu->cur_ring);set_preempt_state (a5xx_gpu,PREEMPT_NONE ); + +/* +* Try to trigger preemption again in case there was a submit or +* retire during ring switch +*/ +a5xx_preempt_trigger (gpu); }void a5xx_preempt_hw_init (struct msm_gpu *gpu)
@@ -300,5 +319,6 @@ void a5xx_preempt_init(struct msm_gpu *gpu) } } +spin_lock_init (&a5xx_gpu->preempt_start_lock);timer_setup (&a5xx_gpu->preempt_timer, a5xx_preempt_timer,0 ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 128/798 drm/msm/a5xx: workaround early ring-buffer emptiness check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit a30f9f65b5ac82d4390548c32ed9c7f05de7ddf5 ]
There is another cause for soft lock-up of GPU in empty ring-buffer:
race between GPU executing last commands and CPU checking ring for emptiness. On GPU side IRQ for retire is triggered by CACHE_FLUSH_TS event and RPTR shadow (which is used to check ring emptiness) is updated a bit later from CP_CONTEXT_SWITCH_YIELD. Thus if GPU is executing its last commands slow enough or we check that ring too fast we will miss a chance to trigger switch to lower priority ring because current ring isn't empty just yet. This can escalate to lock-up situation described in previous patch.
To work-around this issue we keep track of last submit sequence number for each ring and compare it with one written to memptrs from GPU during execution of CACHE_FLUSH_TS event.
Patchwork: https://patchwork.freedesktop.org/patch/612047/
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++++ drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 4 ++++ 3 files changed, 9 insertions(+)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +4 -0
@@ -65,6 +65,8 @@ void a5xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring,static void a5xx_submit_in_rb (struct msm_gpu *gpu,struct msm_gem_submit *submit) { +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a5xx_gpu *a5xx_gpu =to_a5xx_gpu (adreno_gpu);struct msm_ringbuffer *ring = submit->ring;struct msm_gem_object *obj;uint32_t *ptr, dwords;
@@ -109,6 +111,7 @@ static void a5xx_submit_in_rb(struct msm_gpu *gpu, struct msm_gem_submit *submit } } + a5xx_gpu->last_seqno[ring->id] = submit->seqno;a5xx_flush (gpu, ring, true);a5xx_preempt_trigger (gpu);
@@ -210,6 +213,7 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)/* Write the fence to the scratch register */ OUT_PKT4 (ring,REG_A5XX_CP_SCRATCH_REG (2 ),1 );OUT_RING (ring, submit->seqno); + a5xx_gpu->last_seqno[ring->id] = submit->seqno;/* * Execute a CACHE_FLUSH_TS event. This will ensure that the
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -0
@@ -34,6 +34,7 @@ struct a5xx_gpu {struct drm_gem_object *preempt_counters_bo[MSM_GPU_MAX_RINGS ];struct a5xx_preempt_record *preempt[MSM_GPU_MAX_RINGS ];uint64_t preempt_iova[MSM_GPU_MAX_RINGS ]; +uint32_t last_seqno[MSM_GPU_MAX_RINGS ];atomic_t preempt_state;spinlock_t preempt_start_lock;
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +4 -0
@@ -55,6 +55,8 @@ static inline void update_wptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)/* Return the highest priority ringbuffer with something in it */ static struct msm_ringbuffer *get_next_ring (struct msm_gpu *gpu) { +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a5xx_gpu *a5xx_gpu =to_a5xx_gpu (adreno_gpu);unsigned long flags;int i;
@@ -64,6 +66,8 @@ static struct msm_ringbuffer *get_next_ring(struct msm_gpu *gpu)spin_lock_irqsave (&ring->preempt_lock, flags); empty = (get_wptr (ring) == gpu->funcs->get_rptr (gpu, ring)); +if (!empty && ring == a5xx_gpu->cur_ring) + empty = ring->memptrs->fence == a5xx_gpu->last_seqno[i];spin_unlock_irqrestore (&ring->preempt_lock, flags);if (!empty)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 129/798 ipmi: docs: dont advertise deprecated sysfs entries
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 64dce81f8c373c681e62d5ffe0397c45a35d48a2 ]
"i2c-adapter" class entries are deprecated since 2009. Switch to the proper location.
Message-Id: <[email protected]>
--- Documentation/driver-api/ipmi.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/driver-api/ipmi.rst +1 -1
@@ -540,7 +540,7 @@ at module load time (for a module) with:: alerts_broken The addresses are normal I2C addresses. The adapter is the string -name of the adapter, as shown in /sys/class/i2c-adapter/i2c-<n>/name. +name of the adapter, as shown in /sys/bus/i2c/devices/i2c-<n>/name. It is *NOT* i2c-<n> itself. Also, the comparison is done ignoring spaces, so if the name is "This is an I2C chip" you can say adapter_name=ThisisanI2cchip. This is because it's hard to pass in
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 130/798 drm/msm: fix %s null argument error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sherry Yang <[email protected]>
[ Upstream commit 25b85075150fe8adddb096db8a4b950353045ee1 ]
The following build error was triggered because of NULL string argument:
BUILDSTDERR: drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c: In function 'mdp5_smp_dump': BUILDSTDERR: drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c:352:51: error: '%s' directive argument is null [-Werror=format-overflow=] BUILDSTDERR: 352 | drm_printf(p, "%s:%d\t%d\t%s\n", BUILDSTDERR: | ^~ BUILDSTDERR: drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c:352:51: error: '%s' directive argument is null [-Werror=format-overflow=]
This happens from the commit a61ddb4393ad ("drm: enable (most) W=1 warnings by default across the subsystem"). Using "(null)" instead to fix it.
Patchwork: https://patchwork.freedesktop.org/patch/611071/
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c +1 -1
@@ -356,7 +356,7 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p)drm_printf (p,"%s:%d\t%d\t%s\n" ,pipe2name (pipe), j, inuse, - plane ? plane->name :NULL ); + plane ? plane->name :"(null)" ); total += inuse; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 131/798 drivers:drm:exynos_drm_gsc:Fix wrong assignment in gsc_bind()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuesong Li <[email protected]>
[ Upstream commit 94ebc3d3235c5c516f67315059ce657e5090e94b ]
cocci reported a double assignment problem. Upon reviewing previous commits, it appears this may actually be an incorrect assignment.
--- drivers/gpu/drm/exynos/exynos_drm_gsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_gsc.c +1 -1
@@ -1173,7 +1173,7 @@ static int gsc_bind(struct device *dev, struct device *master, void *data)struct exynos_drm_ipp *ipp = &ctx->ipp; ctx->drm_dev = drm_dev; - ctx->drm_dev = drm_dev; + ipp->drm_dev = drm_dev;exynos_drm_register_dma (drm_dev, dev, &ctx->dma_priv); exynos_drm_ipp_register(dev, ipp, &ipp_funcs,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 132/798 xen: use correct end address of kernel for conflict checking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit fac1bceeeb04886fc2ee952672e6e6c85ce41dca ]
When running as a Xen PV dom0 the kernel is loaded by the hypervisor using a different memory map than that of the host. In order to minimize the required changes in the kernel, the kernel adapts its memory map to that of the host. In order to do that it is checking for conflicts of its load address with the host memory map.
Unfortunately the tested memory range does not include the .brk area, which might result in crashes or memory corruption when this area does conflict with the memory map of the host.
Fix the test by using the _end label instead of __bss_stop.
--- arch/x86/xen/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/setup.c +1 -1
@@ -853,7 +853,7 @@ char * __init xen_memory_setup(void)* to relocating (and even reusing) pages with kernel text or data. */ if (xen_is_e820_reserved (__pa_symbol (_text), -__pa_symbol (__bss_stop) -__pa_symbol (_text))) { +__pa_symbol (_end) -__pa_symbol (_text))) {xen_raw_console_write ("Xen hypervisor allocated kernel memory conflicts with E820 map\n" );BUG (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 133/798 HID: wacom: Support sequence numbers smaller than 16-bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gerecke <[email protected]>
[ Upstream commit 359673ea3a203611b4f6d0f28922a4b9d2cfbcc8 ]
The current dropped packet reporting assumes that all sequence numbers are 16 bits in length. This results in misleading "Dropped" messages if the hardware uses fewer bits. For example, if a tablet uses only 8 bits to store its sequence number, once it rolls over from 255 -> 0, the driver will still be expecting a packet "256". This patch adjusts the logic to reset the next expected packet to logical_minimum whenever it overflows beyond logical_maximum.
--- drivers/hid/wacom_wac.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +7 -2
@@ -2489,9 +2489,14 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.barrelswitch3 = value;return ;case WACOM_HID_WD_SEQUENCENUMBER : -if (wacom_wac->hid_data.sequence_number != value) -hid_warn (hdev,"Dropped %hu packets" , (unsigned short )(value - wacom_wac->hid_data.sequence_number)); +if (wacom_wac->hid_data.sequence_number != value) { +int sequence_size = field->logical_maximum - field->logical_minimum +1 ; +int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size; +hid_warn (hdev,"Dropped %d packets" , drop_count); + } wacom_wac->hid_data.sequence_number = value +1 ; +if (wacom_wac->hid_data.sequence_number > field->logical_maximum) + wacom_wac->hid_data.sequence_number = field->logical_minimum;return ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 134/798 HID: wacom: Do not warn about dropped packets for first packet
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gerecke <[email protected]>
[ Upstream commit 84aecf2d251a3359bc78b7c8e58f54b9fc966e89 ]
The driver currently assumes that the first sequence number it will see is going to be 0. This is not a realiable assumption and can break if, for example, the tablet has already been running for some time prior to the kernel driver connecting to the device. This commit initializes the expected sequence number to -1 and will only print the "Dropped" warning the it has been updated to a non-negative value.
--- drivers/hid/wacom_wac.c | 6 +++++- drivers/hid/wacom_wac.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +5 -1
@@ -2365,6 +2365,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,wacom_map_usage (input, usage, field,EV_KEY ,BTN_STYLUS3 ,0 ); features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3 ;break ; +case WACOM_HID_WD_SEQUENCENUMBER : + wacom_wac->hid_data.sequence_number =-1 ; +break ; } }
@@ -2489,7 +2492,8 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.barrelswitch3 = value;return ;case WACOM_HID_WD_SEQUENCENUMBER : -if (wacom_wac->hid_data.sequence_number != value) { +if (wacom_wac->hid_data.sequence_number != value && + wacom_wac->hid_data.sequence_number >=0 ) {int sequence_size = field->logical_maximum - field->logical_minimum +1 ;int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size;hid_warn (hdev,"Dropped %d packets" , drop_count);
drivers/hid/wacom_wac.h +1 -1
@@ -324,7 +324,7 @@ struct hid_data {int bat_connected;int ps_connected;bool pad_input_event_flag; -unsigned short sequence_number; +int sequence_number;ktime_t time_delayed; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 135/798 xen/swiotlb: add alignment check for dma buffers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit 9f40ec84a7976d95c34e7cc070939deb103652b0 ]
When checking a memory buffer to be consecutive in machine memory, the alignment needs to be checked, too. Failing to do so might result in DMA memory not being aligned according to its requested size, leading to error messages like:
4xxx 0000:2b:00.0: enabling device (0140 -> 0142) 4xxx 0000:2b:00.0: Ring address not aligned
4xxx 0000:2b:00.0: Failed to initialise service qat_crypto 4xxx 0000:2b:00.0: Resetting device qat_dev0 4xxx: probe of 0000:2b:00.0 failed with error -14
--- drivers/xen/swiotlb-xen.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/xen/swiotlb-xen.c +6 -0
@@ -78,9 +78,15 @@ static inline int range_straddles_page_boundary(phys_addr_t p, size_t size) {unsigned long next_bfn, xen_pfn =XEN_PFN_DOWN (p);unsigned int i, nr_pages =XEN_PFN_UP (xen_offset_in_page (p) + size); +phys_addr_t algn =1ULL << (get_order (size) +PAGE_SHIFT ); next_bfn =pfn_to_bfn (xen_pfn); +/* If buffer is physically aligned, ensure DMA alignment. */ +if (IS_ALIGNED (p, algn) && + !IS_ALIGNED ((phys_addr_t )next_bfn <<XEN_PAGE_SHIFT , algn)) +return 1 ; +for (i =1 ; i < nr_pages; i++)if (pfn_to_bfn (++xen_pfn) != ++next_bfn)return 1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 136/798 xen/swiotlb: fix allocated size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit c3dea3d54f4d399f8044547f0f1abdccbdfb0fee ]
The allocated size in xen_swiotlb_alloc_coherent() and xen_swiotlb_free_coherent() is calculated wrong for the case of XEN_PAGE_SIZE not matching PAGE_SIZE. Fix that.
--- drivers/xen/swiotlb-xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/swiotlb-xen.c +2 -2
@@ -146,7 +146,7 @@ xen_swiotlb_alloc_coherent(struct device *dev, size_t size,void *ret;/* Align the allocation to the Xen page size */ - size =1UL << (order +XEN_PAGE_SHIFT ); + size =ALIGN (size,XEN_PAGE_SIZE ); ret = (void *)__get_free_pages (flags,get_order (size));if (!ret)
@@ -178,7 +178,7 @@ xen_swiotlb_free_coherent(struct device *dev, size_t size, void *vaddr,int order =get_order (size);/* Convert the size to actually allocated. */ - size =1UL << (order +XEN_PAGE_SHIFT ); + size =ALIGN (size,XEN_PAGE_SIZE );if (WARN_ON_ONCE (dma_handle + size -1 > dev->coherent_dma_mask) ||WARN_ON_ONCE (range_straddles_page_boundary (phys, size)))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 137/798 tpm: Clean up TPM space after command failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan McDowell <[email protected]>
[ Upstream commit e3aaebcbb7c6b403416f442d1de70d437ce313a7 ]
tpm_dev_transmit prepares the TPM space before attempting command transmission. However if the command fails no rollback of this preparation is done. This can result in transient handles being leaked if the device is subsequently closed with no further commands performed.
Fix this by flushing the space in the event of command transmission failure.
--- drivers/char/tpm/tpm-dev-common.c | 2 ++ drivers/char/tpm/tpm2-space.c | 3 +++ 2 files changed, 5 insertions(+)
drivers/char/tpm/tpm-dev-common.c +2 -0
@@ -47,6 +47,8 @@ static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space,if (!ret) ret =tpm2_commit_space (chip, space, buf, &len); +else +tpm2_flush_space (chip); out_rc:return ret ? ret : len;
drivers/char/tpm/tpm2-space.c +3 -0
@@ -166,6 +166,9 @@ void tpm2_flush_space(struct tpm_chip *chip)struct tpm_space *space = &chip->work_space;int i; +if (!space) +return ; +for (i =0 ; i <ARRAY_SIZE (space->context_tbl); i++)if (space->context_tbl[i] && ~space->context_tbl[i])tpm2_flush_context (chip, space->context_tbl[i]);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 138/798 selftests/bpf: Add selftest deny_namespace to s390x deny list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 8206e4e95230daeeba43c59fc7c39656883ecd62 ]
BPF CI reported that selftest deny_namespace failed with s390x.
test_unpriv_userns_create_no_bpf:PASS:no-bpf unpriv new user ns 0 nsec test_deny_namespace:PASS:skel load 0 nsec
libbpf: prog 'test_userns_create': failed to attach: ERROR: strerror_r(-524)=22
libbpf: prog 'test_userns_create': failed to auto-attach: -524 test_deny_namespace:FAIL:attach unexpected error: -524 (errno 524)
#57/1 deny_namespace/unpriv_userns_create_no_bpf:FAIL
#57 deny_namespace:FAIL
BPF program test_userns_create is a BPF LSM type program which is based on trampoline and s390x does not support s390x. Let add the test to x390x deny list to avoid this failure in BPF CI.
Stable-dep-of: aa8ebb270c66 ("selftests/bpf: Workaround strict bpf_lsm return value check.")
--- tools/testing/selftests/bpf/DENYLIST.s390x | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/DENYLIST.s390x +1 -0
@@ -75,3 +75,4 @@ user_ringbuf # failed to find kernel BTF type ID of lookup_key # JIT does not support calling kernel function (kfunc) verify_pkcs7_sig # JIT does not support calling kernel function (kfunc) kfunc_dynptr_param # JIT does not support calling kernel function (kfunc) +deny_namespace # failed to attach: ERROR: strerror_r(-524)=22 (trampoline)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 139/798 selftests/bpf: Add tests for _opts variants of bpf_*_get_fd_by_id()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roberto Sassu <[email protected]>
[ Upstream commit a9c7c18b57594c72a63fad749021b743c65a098b ]
Introduce the data_input map, write-protected with a small eBPF program implementing the lsm/bpf_map hook.
Then, ensure that bpf_map_get_fd_by_id() and bpf_map_get_fd_by_id_opts() with NULL opts don't succeed due to requesting read-write access to the write-protected map. Also, ensure that bpf_map_get_fd_by_id_opts() with open_flags in opts set to BPF_F_RDONLY instead succeeds.
After obtaining a read-only fd, ensure that only map lookup succeeds and not update. Ensure that update works only with the read-write fd obtained at program loading time, when the write protection was not yet enabled.
Finally, ensure that the other _opts variants of bpf_*_get_fd_by_id() don't work if the BPF_F_RDONLY flag is set in opts (due to the kernel not handling the open_flags member of bpf_attr).
Stable-dep-of: aa8ebb270c66 ("selftests/bpf: Workaround strict bpf_lsm return value check.")
--- tools/testing/selftests/bpf/DENYLIST.s390x | 1 + .../bpf/prog_tests/libbpf_get_fd_by_id_opts.c | 87 +++++++++++++++++++ .../bpf/progs/test_libbpf_get_fd_by_id_opts.c | 36 ++++++++ 3 files changed, 124 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/libbpf_get_fd_by_id_opts.c create mode 100644 tools/testing/selftests/bpf/progs/test_libbpf_get_fd_by_id_opts.c
tools/testing/selftests/bpf/DENYLIST.s390x +1 -0
@@ -76,3 +76,4 @@ lookup_key # JIT does not support calling kernel f verify_pkcs7_sig # JIT does not support calling kernel function (kfunc) kfunc_dynptr_param # JIT does not support calling kernel function (kfunc) deny_namespace # failed to attach: ERROR: strerror_r(-524)=22 (trampoline) +libbpf_get_fd_by_id_opts # failed to attach: ERROR: strerror_r(-524)=22 (trampoline)
tools/testing/selftests/bpf/prog_tests/libbpf_get_fd_by_id_opts.c new file +87 -0
87 lines not on this page · raw message
tools/testing/selftests/bpf/progs/test_libbpf_get_fd_by_id_opts.c new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* Copyright (C) 2022 Huawei Technologies Duesseldorf GmbH +* +* Author: Roberto Sassu <[email protected]> +*/ + +#include "vmlinux.h" +#include <errno.h> +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> + +/* From include/linux/mm.h. */ +#define FMODE_WRITE 0x2 + +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 1); + __type(key, __u32); + __type(value, __u32); +} data_input SEC(".maps"); + +char _license[] SEC("license") = "GPL"; + +SEC("lsm/bpf_map") +int BPF_PROG (check_access ,struct bpf_map *map,fmode_t fmode) +{ +if (map != (struct bpf_map *)&data_input) +return 0 ; + +if (fmode &FMODE_WRITE ) +return -EACCES ; + +return 0 ; +}
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 140/798 selftests/bpf: Workaround strict bpf_lsm return value check.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
[ Upstream commit aa8ebb270c66cea1f56a25d0f938036e91ad085a ]
test_progs-no_alu32 -t libbpf_get_fd_by_id_opts is being rejected by the verifier with the following error due to compiler optimization:
6: (67) r0 <<= 62 ; R0_w=scalar(smax=0x4000000000000000,umax=0xc000000000000000,smin32=0,smax32=umax32=0,var_off=(0x0; 0xc000000000000000))
7: (c7) r0 s>>= 63 ; R0_w=scalar(smin=smin32=-1,smax=smax32=0)
; @ test_libbpf_get_fd_by_id_opts.c:0
8: (57) r0 &= -13 ; R0_w=scalar(smax=0x7ffffffffffffff3,umax=0xfffffffffffffff3,smax32=0x7ffffff3,umax32=0xfffffff3,var_off=(0x0; 0xfffffffffffffff3))
; int BPF_PROG(check_access, struct bpf_map *map, fmode_t fmode) @ test_libbpf_get_fd_by_id_opts.c:27 9: (95) exit
At program exit the register R0 has smax=9223372036854775795 should have been in [-4095, 0]
Workaround by adding barrier().
Eventually the verifier will be able to recognize it.
--- .../testing/selftests/bpf/progs/test_libbpf_get_fd_by_id_opts.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/progs/test_libbpf_get_fd_by_id_opts.c +1 -0
@@ -31,6 +31,7 @@ int BPF_PROG(check_access, struct bpf_map *map, fmode_t fmode)if (fmode &FMODE_WRITE )return -EACCES ; +barrier ();return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 141/798 selftests/bpf: Use pid_t consistently in test_progs.c
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit ec4fe2f0fa12fd2d0115df7e58414dc26899cc5e ]
Use pid_t rather than __pid_t when allocating memory for 'worker_pids' in 'struct test_env', as this is its declared type and also avoids compile errors seen building against musl libc on mipsel64:
test_progs.c:1738:49: error: '__pid_t' undeclared (first use in this function); did you mean 'pid_t'?
1738 | env.worker_pids = calloc(sizeof(__pid_t), env.workers);
| ^~~~~~~
| pid_ttest_progs.c:1738:49: note: each undeclared identifier is reported only once for each function it appears in
--- tools/testing/selftests/bpf/test_progs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_progs.c +1 -1
@@ -1639,7 +1639,7 @@ int main(int argc, char **argv)/* launch workers if requested */ env.worker_id =-1 ;/* main process */ if (env.workers) { - env.worker_pids =calloc (sizeof (__pid_t), env.workers); + env.worker_pids =calloc (sizeof (pid_t), env.workers); env.worker_socks =calloc (sizeof (int ), env.workers);if (env.debug)fprintf (stdout,"Launching %d workers.\n" , env.workers);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 142/798 selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit d393f9479d4aaab0fa4c3caf513f28685e831f13 ]
Cast 'rlim_t' argument to match expected type of printf() format and avoid compile errors seen building for mips64el/musl-libc:
In file included from map_tests/sk_storage_map.c:20:
map_tests/sk_storage_map.c: In function 'test_sk_storage_map_stress_free':
map_tests/sk_storage_map.c:414:56: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'rlim_t' {aka 'long long unsigned int'} [-Werror=format=]
414 | CHECK(err, "setrlimit(RLIMIT_NOFILE)", "rlim_new:%lu errno:%d",
| ^~~~~~~~~~~~~~~~~~~~~~~
415 | rlim_new.rlim_cur, errno);
| ~~~~~~~~~~~~~~~~~
| |
| rlim_t {aka long long unsigned int}
./test_maps.h:12:24: note: in definition of macro 'CHECK'
12 | printf(format); \
| ^~~~~~
map_tests/sk_storage_map.c:414:68: note: format string is defined here
414 | CHECK(err, "setrlimit(RLIMIT_NOFILE)", "rlim_new:%lu errno:%d",
| ~~^
| |
| long unsigned int
| %llucc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/map_tests/sk_storage_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/map_tests/sk_storage_map.c +1 -1
@@ -412,7 +412,7 @@ static void test_sk_storage_map_stress_free(void) rlim_new.rlim_max = rlim_new.rlim_cur +128 ; err =setrlimit (RLIMIT_NOFILE , &rlim_new);CHECK (err,"setrlimit(RLIMIT_NOFILE)" ,"rlim_new:%lu errno:%d" , - rlim_new.rlim_cur, errno); + (unsigned long ) rlim_new.rlim_cur, errno); } err =do_sk_storage_map_stress_free ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 143/798 selftests/bpf: Fix error compiling bpf_iter_setsockopt.c with musl libc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 7b10f0c227ce3fa055d601f058dc411092a62a78 ]
Existing code calls getsockname() with a 'struct sockaddr_in6 *' argument where a 'struct sockaddr *' argument is declared, yielding compile errors when building for mips64el/musl-libc:
bpf_iter_setsockopt.c: In function 'get_local_port':
bpf_iter_setsockopt.c:98:30: error: passing argument 2 of 'getsockname' from incompatible pointer type [-Werror=incompatible-pointer-types]
98 | if (!getsockname(fd, &addr, &addrlen))
| ^~~~~
| |
| struct sockaddr_in6 *
In file included from .../netinet/in.h:10,
from .../arpa/inet.h:9,
from ./test_progs.h:17,
from bpf_iter_setsockopt.c:5:
.../sys/socket.h:391:23: note: expected 'struct sockaddr * restrict' but argument is of type 'struct sockaddr_in6 *'
391 | int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
| ^cc1: all warnings being treated as errors
This compiled under glibc only because the argument is declared to be a "funky" transparent union which includes both types above. Explicitly cast the argument to allow compiling for both musl and glibc.
--- tools/testing/selftests/bpf/prog_tests/bpf_iter_setsockopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/bpf_iter_setsockopt.c +1 -1
@@ -95,7 +95,7 @@ static unsigned short get_local_port(int fd)struct sockaddr_in6 addr;socklen_t addrlen =sizeof (addr); -if (!getsockname (fd, &addr, &addrlen)) +if (!getsockname (fd, (struct sockaddr *)&addr, &addrlen))return ntohs (addr.sin6_port);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 144/798 selftests/bpf: Fix missing ARRAY_SIZE() definition in bench.c
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit d44c93fc2f5a0c47b23fa03d374e45259abd92d2 ]
Add a "bpf_util.h" include to avoid the following error seen compiling for mips64el with musl libc:
bench.c: In function 'find_benchmark':
bench.c:590:25: error: implicit declaration of function 'ARRAY_SIZE' [-Werror=implicit-function-declaration]
590 | for (i = 0; i < ARRAY_SIZE(benchs); i++) {
| ^~~~~~~~~~cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/bench.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/bench.c +1 -0
@@ -10,6 +10,7 @@#include <sys/sysinfo.h> #include <signal.h> #include "bench.h" +#include "bpf_util.h" #include "testing_helpers.h" struct env env = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 145/798 selftests/bpf: Fix missing UINT_MAX definitions in benchmarks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit a2c155131b710959beb508ca6a54769b6b1bd488 ]
Include <limits.h> in 'bench.h' to provide a UINT_MAX definition and avoid multiple compile errors against mips64el/musl-libc like:
benchs/bench_local_storage.c: In function 'parse_arg':
benchs/bench_local_storage.c:40:38: error: 'UINT_MAX' undeclared (first use in this function)
40 | if (ret < 1 || ret > UINT_MAX) {
| ^~~~~~~~
benchs/bench_local_storage.c:11:1: note: 'UINT_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'?
10 | #include <test_btf.h>
+++ |+#include <limits.h>
11 |seen with bench_local_storage.c, bench_local_storage_rcu_tasks_trace.c, and bench_bpf_hashmap_lookup.c.
--- tools/testing/selftests/bpf/bench.h | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/bench.h +1 -0
@@ -10,6 +10,7 @@#include <math.h> #include <time.h> #include <sys/syscall.h> +#include <limits.h> struct cpu_set {bool *cpus;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 146/798 selftests/bpf: Fix missing BUILD_BUG_ON() declaration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 6495eb79ca7d15bd87c38d77307e8f9b6b7bf4ef ]
Explicitly include '<linux/build_bug.h>' to fix errors seen compiling with gcc targeting mips64el/musl-libc:
user_ringbuf.c: In function 'test_user_ringbuf_loop':
user_ringbuf.c:426:9: error: implicit declaration of function 'BUILD_BUG_ON' [-Werror=implicit-function-declaration]
426 | BUILD_BUG_ON(total_samples <= c_max_entries);
| ^~~~~~~~~~~~cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +1 -0
@@ -4,6 +4,7 @@#define _GNU_SOURCE#include <linux/compiler.h> #include <linux/ring_buffer.h> +#include <linux/build_bug.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 147/798 selftests/bpf: Replace CHECK with ASSERT_* in ns_current_pid_tgid test
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 84239a24d10174fcfc7d6760cb120435a6ff69af ]
Replace CHECK in selftest ns_current_pid_tgid with recommended ASSERT_* style. I also shortened subtest name as the prefix of subtest name is covered by the test name already.
This patch does fix a testing issue. Currently even if bss->user_{pid,tgid} is not correct, the test still passed since the clone func returns 0. I fixed it to return a non-zero value if bss->user_{pid,tgid} is incorrect.
Stable-dep-of: 21f0b0af9772 ("selftests/bpf: Fix include of <sys/fcntl.h>")
--- .../bpf/prog_tests/ns_current_pid_tgid.c | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-)
tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c +19 -17
@@ -20,19 +20,19 @@ static int test_current_pid_tgid(void *args) {struct test_ns_current_pid_tgid__bss *bss;struct test_ns_current_pid_tgid *skel; -int err =-1 , duration =0 ; +int ret =-1 , err;pid_t tgid, pid;struct stat st; skel =test_ns_current_pid_tgid__open_and_load (); -if (CHECK (!skel,"skel_open_load" ,"failed to load skeleton\n" )) - goto cleanup; +if (!ASSERT_OK_PTR (skel,"test_ns_current_pid_tgid__open_and_load" )) + goto out; pid =syscall (SYS_gettid); tgid =getpid (); err =stat ("/proc/self/ns/pid" , &st); -if (CHECK (err,"stat" ,"failed /proc/self/ns/pid: %d\n" , err)) +if (!ASSERT_OK (err,"stat /proc/self/ns/pid" )) goto cleanup; bss = skel->bss;
@@ -42,24 +42,26 @@ static int test_current_pid_tgid(void *args) bss->user_tgid =0 ; err =test_ns_current_pid_tgid__attach (skel); -if (CHECK (err,"skel_attach" ,"skeleton attach failed: %d\n" , err)) +if (!ASSERT_OK (err,"test_ns_current_pid_tgid__attach" )) goto cleanup;/* trigger tracepoint */ usleep (1 ); -ASSERT_EQ (bss->user_pid, pid,"pid" ); -ASSERT_EQ (bss->user_tgid, tgid,"tgid" ); - err =0 ; +if (!ASSERT_EQ (bss->user_pid, pid,"pid" )) + goto cleanup; +if (!ASSERT_EQ (bss->user_tgid, tgid,"tgid" )) + goto cleanup; + ret =0 ; cleanup: -test_ns_current_pid_tgid__destroy (skel); - -return err; +test_ns_current_pid_tgid__destroy (skel); +out: +return ret; }static void test_ns_current_pid_tgid_new_ns (void ) { -int wstatus, duration =0 ; +int wstatus;pid_t cpid;/* Create a process in a new namespace, this process
@@ -68,21 +70,21 @@ static void test_ns_current_pid_tgid_new_ns(void) cpid =clone (test_current_pid_tgid, child_stack +STACK_SIZE ,CLONE_NEWPID |SIGCHLD ,NULL ); -if (CHECK (cpid ==-1 ,"clone" ,"%s\n" ,strerror (errno))) +if (!ASSERT_NEQ (cpid,-1 ,"clone" ))return ; -if (CHECK (waitpid (cpid, &wstatus,0 ) ==-1 ,"waitpid" ,"%s\n" ,strerror (errno))) +if (!ASSERT_NEQ (waitpid (cpid, &wstatus,0 ),-1 ,"waitpid" ))return ; -if (CHECK (WEXITSTATUS (wstatus) !=0 ,"newns_pidtgid" ,"failed" )) +if (!ASSERT_OK (WEXITSTATUS (wstatus),"newns_pidtgid" ))return ; }/* TODO: use a different tracepoint */ void serial_test_ns_current_pid_tgid (void ) { -if (test__start_subtest ("ns_current_pid_tgid_root_ns" )) +if (test__start_subtest ("root_ns_tp" ))test_current_pid_tgid (NULL ); -if (test__start_subtest ("ns_current_pid_tgid_new_ns" )) +if (test__start_subtest ("new_ns_tp" ))test_ns_current_pid_tgid_new_ns (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 148/798 selftests/bpf: Refactor out some functions in ns_current_pid_tgid test
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 4d4bd29e363c467752536f874a2cba10a5923c59 ]
Refactor some functions in both user space code and bpf program as these functions are used by later cgroup/sk_msg tests. Another change is to mark tp program optional loading as later patches will use optional loading as well since they have quite different attachment and testing logic.
There is no functionality change.
Stable-dep-of: 21f0b0af9772 ("selftests/bpf: Fix include of <sys/fcntl.h>")
--- .../bpf/prog_tests/ns_current_pid_tgid.c | 53 ++++++++++++------- .../bpf/progs/test_ns_current_pid_tgid.c | 10 ++-- 2 files changed, 41 insertions(+), 22 deletions(-)
tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c +34 -19
@@ -16,30 +16,46 @@#define STACK_SIZE (1024 * 1024)static char child_stack[STACK_SIZE ]; -static int test_current_pid_tgid (void *args) +static int get_pid_tgid (pid_t *pid,pid_t *tgid, +struct test_ns_current_pid_tgid__bss *bss) { -struct test_ns_current_pid_tgid__bss *bss; -struct test_ns_current_pid_tgid *skel; -int ret =-1 , err; -pid_t tgid, pid;struct stat st; +int err; - skel =test_ns_current_pid_tgid__open_and_load (); -if (!ASSERT_OK_PTR (skel,"test_ns_current_pid_tgid__open_and_load" )) - goto out; - - pid =syscall (SYS_gettid); - tgid =getpid (); + *pid =syscall (SYS_gettid); + *tgid =getpid (); err =stat ("/proc/self/ns/pid" , &st);if (!ASSERT_OK (err,"stat /proc/self/ns/pid" )) - goto cleanup; +return err; - bss = skel->bss; bss->dev = st.st_dev; bss->ino = st.st_ino; bss->user_pid =0 ; bss->user_tgid =0 ; +return 0 ; +} + +static int test_current_pid_tgid_tp (void *args) +{ +struct test_ns_current_pid_tgid__bss *bss; +struct test_ns_current_pid_tgid *skel; +int ret =-1 , err; +pid_t tgid, pid; + + skel =test_ns_current_pid_tgid__open (); +if (!ASSERT_OK_PTR (skel,"test_ns_current_pid_tgid__open" )) +return ret; + +bpf_program__set_autoload (skel->progs.tp_handler, true); + + err =test_ns_current_pid_tgid__load (skel); +if (!ASSERT_OK (err,"test_ns_current_pid_tgid__load" )) + goto cleanup; + + bss = skel->bss; +if (get_pid_tgid (&pid, &tgid, bss)) + goto cleanup; err =test_ns_current_pid_tgid__attach (skel);if (!ASSERT_OK (err,"test_ns_current_pid_tgid__attach" ))
@@ -55,11 +71,10 @@ static int test_current_pid_tgid(void *args) cleanup:test_ns_current_pid_tgid__destroy (skel); -out:return ret; } -static void test_ns_current_pid_tgid_new_ns (void ) +static void test_ns_current_pid_tgid_new_ns (int (*fn)(void *),void *arg) {int wstatus;pid_t cpid;
@@ -67,8 +82,8 @@ static void test_ns_current_pid_tgid_new_ns(void)/* Create a process in a new namespace, this process * will be the init process of this new namespace hence will be pid 1. */ - cpid =clone (test_current_pid_tgid, child_stack +STACK_SIZE , -CLONE_NEWPID |SIGCHLD ,NULL ); + cpid =clone (fn, child_stack +STACK_SIZE , +CLONE_NEWPID |SIGCHLD , arg);if (!ASSERT_NEQ (cpid,-1 ,"clone" ))return ;
@@ -84,7 +99,7 @@ static void test_ns_current_pid_tgid_new_ns(void)void serial_test_ns_current_pid_tgid (void ) {if (test__start_subtest ("root_ns_tp" )) -test_current_pid_tgid (NULL ); +test_current_pid_tgid_tp (NULL );if (test__start_subtest ("new_ns_tp" )) -test_ns_current_pid_tgid_new_ns (); +test_ns_current_pid_tgid_new_ns (test_current_pid_tgid_tp,NULL ); }
tools/testing/selftests/bpf/progs/test_ns_current_pid_tgid.c +7 -3
@@ -10,17 +10,21 @@ __u64 user_tgid = 0;__u64 dev =0 ;__u64 ino =0 ; -SEC("tracepoint/syscalls/sys_enter_nanosleep") -int handler (const void *ctx) +static void get_pid_tgid (void ) {struct bpf_pidns_info nsdata;if (bpf_get_ns_current_pid_tgid (dev, ino, &nsdata,sizeof (struct bpf_pidns_info ))) -return 0 ; +return ; user_pid = nsdata.pid; user_tgid = nsdata.tgid; +} +SEC("?tracepoint/syscalls/sys_enter_nanosleep") +int tp_handler (const void *ctx) +{ +get_pid_tgid ();return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 149/798 selftests/bpf: Add a cgroup prog bpf_get_ns_current_pid_tgid() test
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 87ade6cd859ea9dbde6e80b3fcf717ed9a73b4a9 ]
Add a cgroup bpf program test where the bpf program is running in a pid namespace. The test is successfully:
#165/3 ns_current_pid_tgid/new_ns_cgrp:OK
Stable-dep-of: 21f0b0af9772 ("selftests/bpf: Fix include of <sys/fcntl.h>")
--- .../bpf/prog_tests/ns_current_pid_tgid.c | 73 +++++++++++++++++++ .../bpf/progs/test_ns_current_pid_tgid.c | 7 ++ 2 files changed, 80 insertions(+)
tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c +73 -0
@@ -12,6 +12,7 @@#include <sys/wait.h> #include <sys/mount.h> #include <sys/fcntl.h> +#include "network_helpers.h" #define STACK_SIZE (1024 * 1024)static char child_stack[STACK_SIZE ];
@@ -74,6 +75,50 @@ static int test_current_pid_tgid_tp(void *args)return ret; } +static int test_current_pid_tgid_cgrp (void *args) +{ +struct test_ns_current_pid_tgid__bss *bss; +struct test_ns_current_pid_tgid *skel; +int server_fd =-1 , ret =-1 , err; +int cgroup_fd = *(int *)args; +pid_t tgid, pid; + + skel =test_ns_current_pid_tgid__open (); +if (!ASSERT_OK_PTR (skel,"test_ns_current_pid_tgid__open" )) +return ret; + +bpf_program__set_autoload (skel->progs.cgroup_bind4, true); + + err =test_ns_current_pid_tgid__load (skel); +if (!ASSERT_OK (err,"test_ns_current_pid_tgid__load" )) + goto cleanup; + + bss = skel->bss; +if (get_pid_tgid (&pid, &tgid, bss)) + goto cleanup; + + skel->links.cgroup_bind4 =bpf_program__attach_cgroup ( + skel->progs.cgroup_bind4, cgroup_fd); +if (!ASSERT_OK_PTR (skel->links.cgroup_bind4,"bpf_program__attach_cgroup" )) + goto cleanup; + + server_fd =start_server (AF_INET ,SOCK_STREAM ,NULL ,0 ,0 ); +if (!ASSERT_GE (server_fd,0 ,"start_server" )) + goto cleanup; + +if (!ASSERT_EQ (bss->user_pid, pid,"pid" )) + goto cleanup; +if (!ASSERT_EQ (bss->user_tgid, tgid,"tgid" )) + goto cleanup; + ret =0 ; + +cleanup: +if (server_fd >=0 ) +close (server_fd); +test_ns_current_pid_tgid__destroy (skel); +return ret; +} +static void test_ns_current_pid_tgid_new_ns (int (*fn)(void *),void *arg) {int wstatus;
@@ -95,6 +140,25 @@ static void test_ns_current_pid_tgid_new_ns(int (*fn)(void *), void *arg)return ; } +static void test_in_netns (int (*fn)(void *),void *arg) +{ +struct nstoken *nstoken =NULL ; + +SYS (cleanup,"ip netns add ns_current_pid_tgid" ); +SYS (cleanup,"ip -net ns_current_pid_tgid link set dev lo up" ); + + nstoken =open_netns ("ns_current_pid_tgid" ); +if (!ASSERT_OK_PTR (nstoken,"open_netns" )) + goto cleanup; + +test_ns_current_pid_tgid_new_ns (fn, arg); + +cleanup: +if (nstoken) +close_netns (nstoken); +SYS_NOFAIL ("ip netns del ns_current_pid_tgid" ); +} +/* TODO: use a different tracepoint */ void serial_test_ns_current_pid_tgid (void ) {
@@ -102,4 +166,13 @@ void serial_test_ns_current_pid_tgid(void)test_current_pid_tgid_tp (NULL );if (test__start_subtest ("new_ns_tp" ))test_ns_current_pid_tgid_new_ns (test_current_pid_tgid_tp,NULL ); +if (test__start_subtest ("new_ns_cgrp" )) { +int cgroup_fd =-1 ; + + cgroup_fd =test__join_cgroup ("/sock_addr" ); +if (ASSERT_GE (cgroup_fd,0 ,"join_cgroup" )) { +test_in_netns (test_current_pid_tgid_cgrp, &cgroup_fd); +close (cgroup_fd); + } + } }
tools/testing/selftests/bpf/progs/test_ns_current_pid_tgid.c +7 -0
@@ -28,4 +28,11 @@ int tp_handler(const void *ctx)return 0 ; } +SEC("?cgroup/bind4") +int cgroup_bind4 (struct bpf_sock_addr *ctx) +{ +get_pid_tgid (); +return 1 ; +} + char _license[] SEC("license") = "GPL";
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 150/798 selftests/bpf: Fix include of <sys/fcntl.h>
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 21f0b0af977203220ad58aff95e372151288ec47 ]
Update ns_current_pid_tgid.c to use '#include <fcntl.h>' and avoid compile error against mips64el/musl libc:
In file included from .../prog_tests/ns_current_pid_tgid.c:14:
.../include/sys/fcntl.h:1:2: error: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Werror=cpp]
1 | #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
| ^~~~~~~
cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c +1 -1
@@ -11,7 +11,7 @@#include <sched.h> #include <sys/wait.h> #include <sys/mount.h> -#include <sys/fcntl.h> +#include <fcntl.h> #include "network_helpers.h" #define STACK_SIZE (1024 * 1024)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 151/798 selftests/bpf: Fix compiling kfree_skb.c with musl-libc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit bae9a5ce7d3a9b3a9e07b31ab9e9c58450e3e9fd ]
The GNU version of 'struct tcphdr' with member 'doff' is not exposed by musl headers unless _GNU_SOURCE is defined. Add this definition to fix errors seen compiling for mips64el/musl-libc:
In file included from kfree_skb.c:2:
kfree_skb.c: In function 'on_sample':
kfree_skb.c:45:30: error: 'struct tcphdr' has no member named 'doff'
45 | if (CHECK(pkt_v6->tcp.doff != 5, "check_tcp",
| ^--- tools/testing/selftests/bpf/prog_tests/kfree_skb.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/kfree_skb.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include <network_helpers.h> #include "kfree_skb.skel.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 152/798 selftests/bpf: Fix compiling flow_dissector.c with musl-libc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 5e4c43bcb85973243d7274e0058b6e8f5810e4f7 ]
The GNU version of 'struct tcphdr' has members 'doff', 'source' and 'dest', which are not exposed by musl libc headers unless _GNU_SOURCE is defined.
Add this definition to fix errors seen compiling for mips64el/musl-libc:
flow_dissector.c:118:30: error: 'struct tcphdr' has no member named 'doff'
118 | .tcp.doff = 5,
| ^~~~
flow_dissector.c:119:30: error: 'struct tcphdr' has no member named 'source'
119 | .tcp.source = 80,
| ^~~~~~
flow_dissector.c:120:30: error: 'struct tcphdr' has no member named 'dest'
120 | .tcp.dest = 8080,
| ^~~~--- tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/flow_dissector.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include <network_helpers.h> #include <error.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 153/798 selftests/bpf: Fix compiling tcp_rtt.c with musl-libc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 18826fb0b79c3c3cd1fe765d85f9c6f1a902c722 ]
The GNU version of 'struct tcp_info' in 'netinet/tcp.h' is not exposed by musl headers unless _GNU_SOURCE is defined.
Add this definition to fix errors seen compiling for mips64el/musl-libc:
tcp_rtt.c: In function 'wait_for_ack':
tcp_rtt.c:24:25: error: storage size of 'info' isn't known
24 | struct tcp_info info;
| ^~~~ tcp_rtt.c:24:25: error: unused variable 'info' [-Werror=unused-variable]
cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/prog_tests/tcp_rtt.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/tcp_rtt.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include "cgroup_helpers.h" #include "network_helpers.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 154/798 selftests/bpf: Fix compiling core_reloc.c with musl-libc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit debfa4f628f271f72933bf38d581cc53cfe1def5 ]
The type 'loff_t' is a GNU extension and not exposed by the musl 'fcntl.h' header unless _GNU_SOURCE is defined. Add this definition to fix errors seen compiling for mips64el/musl-libc:
In file included from tools/testing/selftests/bpf/prog_tests/core_reloc.c:4:
./bpf_testmod/bpf_testmod.h:10:9: error: unknown type name 'loff_t'
10 | loff_t off;
| ^~~~~~
./bpf_testmod/bpf_testmod.h:16:9: error: unknown type name 'loff_t'
16 | loff_t off;
| ^~~~~~--- tools/testing/selftests/bpf/prog_tests/core_reloc.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/core_reloc.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include "progs/core_reloc_types.h" #include "bpf_testmod/bpf_testmod.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 155/798 selftests/bpf: Fix errors compiling cg_storage_multi.h with musl libc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 730561d3c08d4a327cceaabf11365958a1c00cec ]
Remove a redundant include of '<asm/types.h>', whose needed definitions are already included (via '<linux/types.h>') in cg_storage_multi_egress_only.c, cg_storage_multi_isolated.c, and cg_storage_multi_shared.c. This avoids redefinition errors seen compiling for mips64el/musl-libc like:
In file included from progs/cg_storage_multi_egress_only.c:13:
In file included from progs/cg_storage_multi.h:6:
In file included from /usr/mips64el-linux-gnuabi64/include/asm/types.h:23:
/usr/include/asm-generic/int-l64.h:29:25: error: typedef redefinition with different types ('long' vs 'long long')
29 | typedef __signed__ long __s64;
| ^
/usr/include/asm-generic/int-ll64.h:30:44: note: previous definition is here
30 | __extension__ typedef __signed__ long long __s64;
| ^--- tools/testing/selftests/bpf/progs/cg_storage_multi.h | 2 -- 1 file changed, 2 deletions(-)
tools/testing/selftests/bpf/progs/cg_storage_multi.h +0 -2
@@ -3,8 +3,6 @@ #ifndef __PROGS_CG_STORAGE_MULTI_H #define __PROGS_CG_STORAGE_MULTI_H -#include <asm/types.h> - struct cgroup_value { __u32 egress_pkts; __u32 ingress_pkts;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 156/798 selftests/bpf: Fix error compiling test_lru_map.c
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit cacf2a5a78cd1f5f616eae043ebc6f024104b721 ]
Although the post-increment in macro 'CPU_SET(next++, &cpuset)' seems safe, the sequencing can raise compile errors, so move the increment outside the macro. This avoids an error seen using gcc 12.3.0 for mips64el/musl-libc:
In file included from test_lru_map.c:11:
test_lru_map.c: In function 'sched_next_online':
test_lru_map.c:129:29: error: operation on 'next' may be undefined [-Werror=sequence-point]
129 | CPU_SET(next++, &cpuset);
| ^cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/test_lru_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_lru_map.c +2 -1
@@ -126,7 +126,8 @@ static int sched_next_online(int pid, int *next_to_try)while (next < nr_cpus) {CPU_ZERO (&cpuset); -CPU_SET (next++, &cpuset); +CPU_SET (next, &cpuset); + next++;if (!sched_setaffinity (pid,sizeof (cpuset), &cpuset)) { ret =0 ;break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 157/798 selftests/bpf: Fix C++ compile error from missing _Bool type
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit aa95073fd290b5b3e45f067fa22bb25e59e1ff7c ]
While building, bpftool makes a skeleton from test_core_extern.c, which itself includes <stdbool.h> and uses the 'bool' type. However, the skeleton test_core_extern.skel.h generated *does not* include <stdbool.h> or use the 'bool' type, instead using the C-only '_Bool' type. Compiling test_cpp.cpp with g++ 12.3 for mips64el/musl-libc then fails with error:
In file included from test_cpp.cpp:9:
test_core_extern.skel.h:45:17: error: '_Bool' does not name a type
45 | _Bool CONFIG_BOOL;
| ^~~~~This was likely missed previously because glibc uses a GNU extension for <stdbool.h> with C++ (#define _Bool bool), not supported by musl libc.
Normally, a C fragment would include <stdbool.h> and use the 'bool' type, and thus cleanly work after import by C++. The ideal fix would be for 'bpftool gen skeleton' to output the correct type/include supporting C++, but in the meantime add a conditional define as above.
--- tools/testing/selftests/bpf/test_cpp.cpp | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/bpf/test_cpp.cpp +4 -0
@@ -6,6 +6,10 @@ #pragma GCC diagnostic pop #include <bpf/bpf.h> #include <bpf/btf.h> + +#ifndef _Bool +#define _Bool bool +#endif #include "test_core_extern.skel.h" template <typename T>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 158/798 selftests/bpf: Replace extract_build_id with read_build_id
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit dcc46f51d770bde625e4845cac42e808b3302b62 ]
Replacing extract_build_id with read_build_id that parses out build id directly from elf without using readelf tool.
Stable-dep-of: c9a83e76b5a9 ("selftests/bpf: Fix compile if backtrace support missing in libc")
--- .../bpf/prog_tests/stacktrace_build_id.c | 19 ++++++-------- .../bpf/prog_tests/stacktrace_build_id_nmi.c | 17 +++++-------- tools/testing/selftests/bpf/test_progs.c | 25 ------------------- tools/testing/selftests/bpf/test_progs.h | 1 - 4 files changed, 13 insertions(+), 49 deletions(-)
tools/testing/selftests/bpf/prog_tests/stacktrace_build_id.c +7 -12
@@ -7,13 +7,12 @@ void test_stacktrace_build_id(void)int control_map_fd, stackid_hmap_fd, stackmap_fd, stack_amap_fd;struct test_stacktrace_build_id *skel; -int err, stack_trace_len; +int err, stack_trace_len, build_id_size;__u32 key, prev_key, val, duration =0 ; -char buf[256 ]; -int i, j; +char buf[BPF_BUILD_ID_SIZE ];struct bpf_stack_build_id id_offs[PERF_MAX_STACK_DEPTH ];int build_id_matches =0 ; -int retry =1 ; +int i, retry =1 ; retry: skel =test_stacktrace_build_id__open_and_load ();
@@ -52,9 +51,10 @@ void test_stacktrace_build_id(void) "err %d errno %d\n", err, errno)) goto cleanup; - err =extract_build_id (buf,256 ); + build_id_size =read_build_id ("urandom_read" , buf,sizeof (buf)); + err = build_id_size <0 ? build_id_size :0 ; -if (CHECK (err,"get build_id with readelf" , +if (CHECK (err,"read_build_id" ,"err %d errno %d\n" , err, errno)) goto cleanup;
@@ -64,8 +64,6 @@ void test_stacktrace_build_id(void) goto cleanup; do { - char build_id[64]; - err = bpf_map_lookup_elem(stackmap_fd, &key, id_offs); if (CHECK(err, "lookup_elem from stackmap", "err %d, errno %d\n", err, errno))
@@ -73,10 +71,7 @@ void test_stacktrace_build_id(void)for (i =0 ; i <PERF_MAX_STACK_DEPTH ; ++i)if (id_offs[i].status ==BPF_STACK_BUILD_ID_VALID && id_offs[i].offset !=0 ) { -for (j =0 ; j <20 ; ++j) -sprintf (build_id +2 * j,"%02x" , - id_offs[i].build_id[j] &0xff ); -if (strstr (buf, build_id) !=NULL ) +if (memcmp (buf, id_offs[i].build_id, build_id_size) ==0 ) build_id_matches =1 ; } prev_key = key;
tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c +6 -11
@@ -13,11 +13,10 @@ void test_stacktrace_build_id_nmi(void) .config = PERF_COUNT_HW_CPU_CYCLES, };__u32 key, prev_key, val, duration =0 ; -char buf[256 ]; -int i, j; +char buf[BPF_BUILD_ID_SIZE ];struct bpf_stack_build_id id_offs[PERF_MAX_STACK_DEPTH ]; -int build_id_matches =0 ; -int retry =1 ; +int build_id_matches =0 , build_id_size; +int i, retry =1 ; attr.sample_freq =read_perf_max_sample_freq ();
@@ -79,7 +78,8 @@ void test_stacktrace_build_id_nmi(void) "err %d errno %d\n", err, errno)) goto cleanup; - err =extract_build_id (buf,256 ); + build_id_size =read_build_id ("urandom_read" , buf,sizeof (buf)); + err = build_id_size <0 ? build_id_size :0 ;if (CHECK (err,"get build_id with readelf" ,"err %d errno %d\n" , err, errno))
@@ -91,8 +91,6 @@ void test_stacktrace_build_id_nmi(void) goto cleanup; do { - char build_id[64]; - err = bpf_map__lookup_elem(skel->maps.stackmap, &key, sizeof(key), id_offs, sizeof(id_offs), 0); if (CHECK(err, "lookup_elem from stackmap",
@@ -101,10 +99,7 @@ void test_stacktrace_build_id_nmi(void)for (i =0 ; i <PERF_MAX_STACK_DEPTH ; ++i)if (id_offs[i].status ==BPF_STACK_BUILD_ID_VALID && id_offs[i].offset !=0 ) { -for (j =0 ; j <20 ; ++j) -sprintf (build_id +2 * j,"%02x" , - id_offs[i].build_id[j] &0xff ); -if (strstr (buf, build_id) !=NULL ) +if (memcmp (buf, id_offs[i].build_id, build_id_size) ==0 ) build_id_matches =1 ; } prev_key = key;
tools/testing/selftests/bpf/test_progs.c +0 -25
@@ -583,31 +583,6 @@ int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len)return err; } -int extract_build_id (char *build_id,size_t size) -{ -FILE *fp; -char *line =NULL ; -size_t len =0 ; - - fp =popen ("readelf -n ./urandom_read | grep 'Build ID'" ,"r" ); -if (fp ==NULL ) -return -1 ; - -if (getline (&line, &len, fp) ==-1 ) - goto err; -pclose (fp); - -if (len > size) - len = size; -memcpy (build_id, line, len); - build_id[len] ='\0' ; -free (line); -return 0 ; -err: -pclose (fp); -return -1 ; -} -static int finit_module (int fd,const char *param_values,int flags) {return syscall (__NR_finit_module, fd, param_values, flags);
tools/testing/selftests/bpf/test_progs.h +0 -1
@@ -380,7 +380,6 @@ static inline void *u64_to_ptr(__u64 ptr)int bpf_find_map (const char *test,struct bpf_object *obj,const char *name);int compare_map_keys (int map1_fd,int map2_fd);int compare_stack_ips (int smap_fd,int amap_fd,int stack_trace_len); -int extract_build_id (char *build_id,size_t size);int kern_sync_rcu (void );int trigger_module_test_read (int read_sz);int trigger_module_test_write (int write_sz);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 159/798 selftests/bpf: Move test_progs helpers to testing_helpers object
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit 45db310984bfea977177fb5fc0ea23ab430129bd ]
Moving test_progs helpers to testing_helpers object so they can be used from test_verifier in following changes.
Also adding missing ifndef header guard to testing_helpers.h header.
Using stderr instead of env.stderr because un/load_bpf_testmod helpers will be used outside test_progs. Also at the point of calling them in test_progs the std files are not hijacked yet and stderr is the same as env.stderr.
Stable-dep-of: c9a83e76b5a9 ("selftests/bpf: Fix compile if backtrace support missing in libc")
--- tools/testing/selftests/bpf/test_progs.c | 67 +------------------ tools/testing/selftests/bpf/test_progs.h | 1 - tools/testing/selftests/bpf/testing_helpers.c | 63 +++++++++++++++++ tools/testing/selftests/bpf/testing_helpers.h | 9 +++ 4 files changed, 74 insertions(+), 66 deletions(-)
tools/testing/selftests/bpf/test_progs.c +2 -65
@@ -11,7 +11,6 @@#include <signal.h> #include <string.h> #include <execinfo.h> /* backtrace */ -#include <linux/membarrier.h> #include <sys/sysinfo.h> /* get_nprocs */ #include <netinet/in.h> #include <sys/select.h>
@@ -583,68 +582,6 @@ int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len)return err; } -static int finit_module (int fd,const char *param_values,int flags) -{ -return syscall (__NR_finit_module, fd, param_values, flags); -} - -static int delete_module (const char *name,int flags) -{ -return syscall (__NR_delete_module, name, flags); -} - -/* -* Trigger synchronize_rcu() in kernel. -*/ -int kern_sync_rcu (void ) -{ -return syscall (__NR_membarrier,MEMBARRIER_CMD_SHARED ,0 ,0 ); -} - -static void unload_bpf_testmod (void ) -{ -if (kern_sync_rcu ()) -fprintf (env.stderr,"Failed to trigger kernel-side RCU sync!\n" ); -if (delete_module ("bpf_testmod" ,0 )) { -if (errno ==ENOENT ) { -if (verbose ()) -fprintf (stdout,"bpf_testmod.ko is already unloaded.\n" ); -return ; - } -fprintf (env.stderr,"Failed to unload bpf_testmod.ko from kernel: %d\n" , -errno); -return ; - } -if (verbose ()) -fprintf (stdout,"Successfully unloaded bpf_testmod.ko.\n" ); -} - -static int load_bpf_testmod (void ) -{ -int fd; - -/* ensure previous instance of the module is unloaded */ -unload_bpf_testmod (); - -if (verbose ()) -fprintf (stdout,"Loading bpf_testmod.ko...\n" ); - - fd =open ("bpf_testmod.ko" ,O_RDONLY ); -if (fd <0 ) { -fprintf (env.stderr,"Can't find bpf_testmod.ko kernel module: %d\n" , -errno); -return -ENOENT ; - } -if (finit_module (fd,"" ,0 )) { -fprintf (env.stderr,"Failed to load bpf_testmod.ko into the kernel: %d\n" , -errno); -close (fd); -return -EINVAL ; - } -close (fd); - -if (verbose ()) -fprintf (stdout,"Successfully loaded bpf_testmod.ko.\n" ); -return 0 ; -} -/* extern declarations for test funcs */ #define DEFINE_TEST (name) \ extern void test_##name(void) __weak; \
@@ -1586,7 +1523,7 @@ int main(int argc, char **argv) env.stderr = stderr; env.has_testmod = true; -if (!env.list_test_names &&load_bpf_testmod ()) { +if (!env.list_test_names &&load_bpf_testmod (verbose ())) {fprintf (env.stderr,"WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n" ); env.has_testmod = false; }
@@ -1685,7 +1622,7 @@ int main(int argc, char **argv)close (env.saved_netns_fd); out:if (!env.list_test_names && env.has_testmod) -unload_bpf_testmod (); +unload_bpf_testmod (verbose ());free_test_selector (&env.test_selector);free_test_selector (&env.subtest_selector);
tools/testing/selftests/bpf/test_progs.h +0 -1
@@ -380,7 +380,6 @@ static inline void *u64_to_ptr(__u64 ptr)int bpf_find_map (const char *test,struct bpf_object *obj,const char *name);int compare_map_keys (int map1_fd,int map2_fd);int compare_stack_ips (int smap_fd,int amap_fd,int stack_trace_len); -int kern_sync_rcu (void );int trigger_module_test_read (int read_sz);int trigger_module_test_write (int write_sz);int write_sysctl (const char *sysctl,const char *value);
tools/testing/selftests/bpf/testing_helpers.c +63 -0
72 lines not on this page · raw message
tools/testing/selftests/bpf/testing_helpers.h +9 -0
@@ -1,5 +1,9 @@/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ /* Copyright (C) 2020 Facebook, Inc. */ + +#ifndef __TESTING_HELPERS_H +#define __TESTING_HELPERS_H +#include <stdbool.h> #include <bpf/bpf.h> #include <bpf/libbpf.h>
@@ -22,3 +26,8 @@ int parse_test_list(const char *s, bool is_glob_pattern);__u64 read_perf_max_sample_freq (void ); +int load_bpf_testmod (bool verbose); +void unload_bpf_testmod (bool verbose); +int kern_sync_rcu (void ); + +#endif /* __TESTING_HELPERS_H */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 160/798 selftests/bpf: Fix compile if backtrace support missing in libc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit c9a83e76b5a96801a2c7ea0a79ca77c356d8b38d ]
Include GNU <execinfo.h> header only with glibc and provide weak, stubbed backtrace functions as a fallback in test_progs.c. This allows for non-GNU replacements while avoiding compile errors (e.g. with musl libc) like:
test_progs.c:13:10: fatal error: execinfo.h: No such file or directory
13 | #include <execinfo.h> /* backtrace */
| ^~~~~~~~~~~~
test_progs.c: In function 'crash_handler':
test_progs.c:1034:14: error: implicit declaration of function 'backtrace' [-Werror=implicit-function-declaration]
1034 | sz = backtrace(bt, ARRAY_SIZE(bt));
| ^~~~~~~~~
test_progs.c:1045:9: error: implicit declaration of function 'backtrace_symbols_fd' [-Werror=implicit-function-declaration]
1045 | backtrace_symbols_fd(bt, sz, STDERR_FILENO);
| ^~~~~~~~~~~~~~~~~~~~--- tools/testing/selftests/bpf/test_progs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_progs.c +15 -1
@@ -10,13 +10,27 @@#include <sched.h> #include <signal.h> #include <string.h> -#include <execinfo.h> /* backtrace */ #include <sys/sysinfo.h> /* get_nprocs */ #include <netinet/in.h> #include <sys/select.h> #include <sys/socket.h> #include <sys/un.h> +#ifdef __GLIBC__ +#include <execinfo.h> /* backtrace */ +#endif + +/* Default backtrace funcs if missing at link */ +__weak int backtrace (void **buffer,int size) +{ +return 0 ; +} + +__weak void backtrace_symbols_fd (void *const *buffer,int size,int fd) +{ +dprintf (fd,"<backtrace not supported>\n" ); +} +static bool verbose (void ) {return env.verbosity >VERBOSE_NONE ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 161/798 bpf: correctly handle malformed BPF_CORE_TYPE_ID_LOCAL relos
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 3d2786d65aaa954ebd3fcc033ada433e10da21c4 ]
In case of malformed relocation record of kind BPF_CORE_TYPE_ID_LOCAL referencing a non-existing BTF type, function bpf_core_calc_relo_insn would cause a null pointer deference.
Fix this by adding a proper check upper in call stack, as malformed relocation records could be passed from user space.
Simplest reproducer is a program:
r0 = 0
exitWith a single relocation record:
.insn_off = 0, /* patch first instruction */
.type_id = 100500, /* this type id does not exist */
.access_str_off = 6, /* offset of string "0" */ .kind = BPF_CORE_TYPE_ID_LOCAL,
See the link for original reproducer or next commit for a test case.
--- kernel/bpf/btf.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/bpf/btf.c +8 -0
@@ -7973,6 +7973,7 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,struct bpf_core_cand_list cands = {};struct bpf_core_relo_res targ_res;struct bpf_core_spec *specs; +const struct btf_type *type;int err;/* ~4k of temp memory necessary to convert LLVM spec like "0:1:0:5"
@@ -7982,6 +7983,13 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,if (!specs)return -ENOMEM ; + type =btf_type_by_id (ctx->btf, relo->type_id); +if (!type) { +bpf_log (ctx->log,"relo #%u: bad type id %u\n" , + relo_idx, relo->type_id); +return -EINVAL ; + } +if (need_cands) {struct bpf_cand_cache *cc;int i;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 162/798 xz: cleanup CRC32 edits from 2018
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lasse Collin <[email protected]>
[ Upstream commit 2ee96abef214550d9e92f5143ee3ac1fd1323e67 ]
In 2018, a dependency on <linux/crc32poly.h> was added to avoid duplicating the same constant in multiple files. Two months later it was found to be a bad idea and the definition of CRC32_POLY_LE macro was moved into xz_private.h to avoid including <linux/crc32poly.h>.
xz_private.h is a wrong place for it too. Revert back to the upstream version which has the poly in xz_crc32_init() in xz_crc32.c.
--- lib/xz/xz_crc32.c | 2 +- lib/xz/xz_private.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-)
lib/xz/xz_crc32.c +1 -1
@@ -29,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256]; XZ_EXTERN void xz_crc32_init(void) { -const uint32_t poly =CRC32_POLY_LE ; +const uint32_t poly =0xEDB88320 ;uint32_t i;uint32_t j;
lib/xz/xz_private.h +0 -4
@@ -105,10 +105,6 @@# endif #endif -#ifndef CRC32_POLY_LE -#define CRC32_POLY_LE 0xedb88320 -#endif -/* * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used * before calling xz_dec_lzma2_run().
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 163/798 kthread: fix task state in kthread worker if being frozen
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Yu <[email protected]>
[ Upstream commit e16c7b07784f3fb03025939c4590b9a7c64970a7 ]
When analyzing a kernel waring message, Peter pointed out that there is a race condition when the kworker is being frozen and falls into try_to_freeze() with TASK_INTERRUPTIBLE, which could trigger a might_sleep() warning in try_to_freeze(). Although the root cause is not related to freeze()[1], it is still worthy to fix this issue ahead.
One possible race scenario:
CPU 0 CPU 1
----- -----
// kthread_worker_fn
set_current_state(TASK_INTERRUPTIBLE);
suspend_freeze_processes()
freeze_processes
static_branch_inc(&freezer_active);
freeze_kernel_threads
pm_nosig_freezing = true;
if (work) { //false
__set_current_state(TASK_RUNNING);
} else if (!freezing(current)) //false, been frozen
freezing():
if (static_branch_unlikely(&freezer_active))
if (pm_nosig_freezing)
return true;
schedule()
}
// state is still TASK_INTERRUPTIBLE
try_to_freeze()
might_sleep() <--- warningFix this by explicitly set the TASK_RUNNING before entering try_to_freeze().
--- kernel/kthread.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/kthread.c +9 -1
@@ -826,8 +826,16 @@ int kthread_worker_fn(void *worker_ptr)* event only cares about the address. */ trace_sched_kthread_work_execute_end (work, func); - }else if (!freezing (current)) + }else if (!freezing (current)) {schedule (); + }else { +/* +* Handle the case where the current remains +* TASK_INTERRUPTIBLE. try_to_freeze() expects +* the current to be TASK_RUNNING. +*/ +__set_current_state (TASK_RUNNING ); + }try_to_freeze ();cond_resched ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 164/798 ext4: clear EXT4_GROUP_INFO_WAS_TRIMMED_BIT even mount with discard
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: yangerkun <[email protected]>
[ Upstream commit 20cee68f5b44fdc2942d20f3172a262ec247b117 ]
Commit 3d56b8d2c74c ("ext4: Speed up FITRIM by recording flags in ext4_group_info") speed up fstrim by skipping trim trimmed group. We also has the chance to clear trimmed once there exists some block free for this group(mount without discard), and the next trim for this group will work well too.
For mount with discard, we will issue dicard when we free blocks, so leave trimmed flag keep alive to skip useless trim trigger from userspace seems reasonable. But for some case like ext4 build on dm-thinpool(ext4 blocksize 4K, pool blocksize 128K), discard from ext4 maybe unaligned for dm thinpool, and thinpool will just finish this discard(see process_discard_bio when begein equals to end) without actually process discard. For this case, trim from userspace can really help us to free some thinpool block.
So convert to clear trimmed flag for all case no matter mounted with discard or not.
--- fs/ext4/mballoc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/ext4/mballoc.c +4 -6
@@ -3686,11 +3686,8 @@ static void ext4_free_data_in_buddy(struct super_block *sb,/* * Clear the trimmed flag for the group so that the next * ext4_trim_fs can trim it. -* If the volume is mounted with -o discard, online discard -* is supported and the free blocks will be trimmed online. */ -if (!test_opt (sb,DISCARD )) -EXT4_MB_GRP_CLEAR_TRIMMED (db); +EXT4_MB_GRP_CLEAR_TRIMMED (db);if (!db->bb_free_root.rb_node) {/* No more items in the per group rb tree
@@ -6114,8 +6111,9 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode," group:%u block:%d count:%lu failed" " with %d" , block_group, bit, count, err); - }else -EXT4_MB_GRP_CLEAR_TRIMMED (e4b.bd_info); + } + +EXT4_MB_GRP_CLEAR_TRIMMED (e4b.bd_info);ext4_lock_group (sb, block_group);mb_clear_bits (bitmap_bh->b_data, bit, count_clusters);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 165/798 smackfs: Use rcu_assign_pointer() to ensure safe assignment in smk_set_cipso
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawei Ye <[email protected]>
[ Upstream commit 2749749afa071f8a0e405605de9da615e771a7ce ]
In the smk_set_cipso function, the skp->smk_netlabel.attr.mls.cat field is directly assigned to a new value without using the appropriate RCU pointer assignment functions. According to RCU usage rules, this is illegal and can lead to unpredictable behavior, including data inconsistencies and impossible-to-diagnose memory corruption issues.
This possible bug was identified using a static analysis tool developed by myself, specifically designed to detect RCU-related issues.
To address this, the assignment is now done using rcu_assign_pointer(), which ensures that the pointer assignment is done safely, with the necessary memory barriers and synchronization. This change prevents potential RCU dereference issues by ensuring that the cat field is safely updated while still adhering to RCU's requirements.
--- security/smack/smackfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/smack/smackfs.c +1 -1
@@ -921,7 +921,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, rc =smk_netlbl_mls (maplevel, mapcatset, &ncats,SMK_CIPSOLEN );if (rc >=0 ) { old_cat = skp->smk_netlabel.attr.mls.cat; - skp->smk_netlabel.attr.mls.cat = ncats.attr.mls.cat; +rcu_assign_pointer (skp->smk_netlabel.attr.mls.cat, ncats.attr.mls.cat); skp->smk_netlabel.attr.mls.lvl = ncats.attr.mls.lvl;synchronize_rcu ();netlbl_catmap_free (old_cat);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 166/798 ext4: avoid buffer_head leak in ext4_mark_inode_used()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit 5e5b2a56c57def1b41efd49596621504d7bcc61c ]
Release inode_bitmap_bh from ext4_read_inode_bitmap() in ext4_mark_inode_used() to avoid buffer_head leak.
By the way, remove unneeded goto for invalid ino when inode_bitmap_bh is NULL.
--- fs/ext4/ialloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ext4/ialloc.c +3 -2
@@ -755,10 +755,10 @@ int ext4_mark_inode_used(struct super_block *sb, int ino)struct ext4_group_desc *gdp;ext4_group_t group;int bit; -int err = -EFSCORRUPTED ; +int err;if (ino <EXT4_FIRST_INO (sb) || ino > max_ino) - goto out; +return -EFSCORRUPTED ; group = (ino -1 ) /EXT4_INODES_PER_GROUP (sb); bit = (ino -1 ) %EXT4_INODES_PER_GROUP (sb);
@@ -861,6 +861,7 @@ int ext4_mark_inode_used(struct super_block *sb, int ino) err =ext4_handle_dirty_metadata (NULL ,NULL , group_desc_bh);sync_dirty_buffer (group_desc_bh); out: +brelse (inode_bitmap_bh);return err; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 167/798 ext4: avoid potential buffer_head leak in __ext4_new_inode()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit 227d31b9214d1b9513383cf6c7180628d4b3b61f ]
If a group is marked EXT4_GROUP_INFO_IBITMAP_CORRUPT after it's inode bitmap buffer_head was successfully verified, then __ext4_new_inode() will get a valid inode_bitmap_bh of a corrupted group from ext4_read_inode_bitmap() in which case inode_bitmap_bh misses a release. Hnadle "IS_ERR(inode_bitmap_bh)" and group corruption separately like how ext4_free_inode() does to avoid buffer_head leak.
--- fs/ext4/ialloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/ext4/ialloc.c +4 -3
@@ -1055,12 +1055,13 @@ struct inode *__ext4_new_inode(struct user_namespace *mnt_userns,brelse (inode_bitmap_bh); inode_bitmap_bh =ext4_read_inode_bitmap (sb, group);/* Skip groups with suspicious inode tables */ -if (((!(sbi->s_mount_state &EXT4_FC_REPLAY )) - &&EXT4_MB_GRP_IBITMAP_CORRUPT (grp)) || -IS_ERR (inode_bitmap_bh)) { +if (IS_ERR (inode_bitmap_bh)) { inode_bitmap_bh =NULL ; goto next_group; } +if (!(sbi->s_mount_state &EXT4_FC_REPLAY ) && +EXT4_MB_GRP_IBITMAP_CORRUPT (grp)) + goto next_group; repeat_in_this_group: ret2 =find_inode_bit (sb, group, inode_bitmap_bh, &ino);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 168/798 ext4: avoid negative min_clusters in find_group_orlov()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit bb0a12c3439b10d88412fd3102df5b9a6e3cd6dc ]
min_clusters is signed integer and will be converted to unsigned integer when compared with unsigned number stats.free_clusters. If min_clusters is negative, it will be converted to a huge unsigned value in which case all groups may not meet the actual desired free clusters.
Set negative min_clusters to 0 to avoid unexpected behavior.
--- fs/ext4/ialloc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/ialloc.c +2 -0
@@ -514,6 +514,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,if (min_inodes <1 ) min_inodes =1 ; min_clusters = avefreec -EXT4_CLUSTERS_PER_GROUP (sb)*flex_size /4 ; +if (min_clusters <0 ) + min_clusters =0 ;/* * Start looking in the flex group where we last allocated an
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 169/798 ext4: return error on ext4_find_inline_entry
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit 4d231b91a944f3cab355fce65af5871fb5d7735b ]
In case of errors when reading an inode from disk or traversing inline directory entries, return an error-encoded ERR_PTR instead of returning NULL. ext4_find_inline_entry only caller, __ext4_find_entry already returns such encoded errors.
Stable-dep-of: c6b72f5d82b1 ("ext4: avoid OOB when system.data xattr changes underneath the filesystem")
--- fs/ext4/inline.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/ext4/inline.c +7 -3
@@ -1698,8 +1698,9 @@ struct buffer_head *ext4_find_inline_entry(struct inode *dir,void *inline_start;int inline_size; -if (ext4_get_inode_loc (dir, &iloc)) -return NULL ; + ret =ext4_get_inode_loc (dir, &iloc); +if (ret) +return ERR_PTR (ret);down_read (&EXT4_I (dir)->xattr_sem);if (!ext4_has_inline_data (dir)) {
@@ -1730,7 +1731,10 @@ struct buffer_head *ext4_find_inline_entry(struct inode *dir, out:brelse (iloc.bh); - iloc.bh =NULL ; +if (ret <0 ) + iloc.bh =ERR_PTR (ret); +else + iloc.bh =NULL ; out_find:up_read (&EXT4_I (dir)->xattr_sem);return iloc.bh;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 170/798 ext4: avoid OOB when system.data xattr changes underneath the filesystem
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit c6b72f5d82b1017bad80f9ebf502832fc321d796 ]
When looking up for an entry in an inlined directory, if e_value_offs is changed underneath the filesystem by some change in the block device, it will lead to an out-of-bounds access that KASAN detects as an UAF.
EXT4-fs (loop0): mounted filesystem 00000000-0000-0000-0000-000000000000 r/w without journal. Quota mode: none.
loop0: detected capacity change from 2048 to 2047
==================================================================
BUG: KASAN: use-after-free in ext4_search_dir+0xf2/0x1c0 fs/ext4/namei.c:1500 Read of size 1 at addr ffff88803e91130f by task syz-executor269/5103 CPU: 0 UID: 0 PID: 5103 Comm: syz-executor269 Not tainted 6.11.0-rc4-syzkaller #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 ext4_search_dir+0xf2/0x1c0 fs/ext4/namei.c:1500 ext4_find_inline_entry+0x4be/0x5e0 fs/ext4/inline.c:1697 __ext4_find_entry+0x2b4/0x1b30 fs/ext4/namei.c:1573 ext4_lookup_entry fs/ext4/namei.c:1727 [inline] ext4_lookup+0x15f/0x750 fs/ext4/namei.c:1795 lookup_one_qstr_excl+0x11f/0x260 fs/namei.c:1633 filename_create+0x297/0x540 fs/namei.c:3980 do_symlinkat+0xf9/0x3a0 fs/namei.c:4587 __do_sys_symlinkat fs/namei.c:4610 [inline] __se_sys_symlinkat fs/namei.c:4607 [inline] __x64_sys_symlinkat+0x95/0xb0 fs/namei.c:4607 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f3e73ced469 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 21 18 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fff4d40c258 EFLAGS: 00000246 ORIG_RAX: 000000000000010a RAX: ffffffffffffffda RBX: 0032656c69662f2e RCX: 00007f3e73ced469 RDX: 0000000020000200 RSI: 00000000ffffff9c RDI: 00000000200001c0 RBP: 0000000000000000 R08: 00007fff4d40c290 R09: 00007fff4d40c290 R10: 0023706f6f6c2f76 R11: 0000000000000246 R12: 00007fff4d40c27c R13: 0000000000000003 R14: 431bde82d7b634db R15: 00007fff4d40c2b0 </TASK>
Calling ext4_xattr_ibody_find right after reading the inode with ext4_get_inode_loc will lead to a check of the validity of the xattrs, avoiding this problem.
--- fs/ext4/inline.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
fs/ext4/inline.c +21 -10
@@ -1693,25 +1693,36 @@ struct buffer_head *ext4_find_inline_entry(struct inode *dir,struct ext4_dir_entry_2 **res_dir, int *has_inline_data) { + struct ext4_xattr_ibody_find is = { + .s = { .not_found = -ENODATA , }, + }; +struct ext4_xattr_info i = { + .name_index =EXT4_XATTR_INDEX_SYSTEM , + .name =EXT4_XATTR_SYSTEM_DATA , + };int ret; -struct ext4_iloc iloc;void *inline_start;int inline_size; - ret =ext4_get_inode_loc (dir, &iloc); + ret =ext4_get_inode_loc (dir, &is.iloc);if (ret)return ERR_PTR (ret);down_read (&EXT4_I (dir)->xattr_sem); + + ret =ext4_xattr_ibody_find (dir, &i, &is); +if (ret) + goto out; +if (!ext4_has_inline_data (dir)) { *has_inline_data =0 ; goto out; } - inline_start = (void *)ext4_raw_inode (&iloc)->i_block + + inline_start = (void *)ext4_raw_inode (&is.iloc)->i_block +EXT4_INLINE_DOTDOT_SIZE ; inline_size =EXT4_MIN_INLINE_DATA_SIZE -EXT4_INLINE_DOTDOT_SIZE ; - ret =ext4_search_dir (iloc.bh, inline_start, inline_size, + ret =ext4_search_dir (is.iloc.bh, inline_start, inline_size, dir, fname,0 , res_dir);if (ret ==1 ) goto out_find;
@@ -1721,23 +1732,23 @@ struct buffer_head *ext4_find_inline_entry(struct inode *dir,if (ext4_get_inline_size (dir) ==EXT4_MIN_INLINE_DATA_SIZE ) goto out; - inline_start =ext4_get_inline_xattr_pos (dir, &iloc); + inline_start =ext4_get_inline_xattr_pos (dir, &is.iloc); inline_size =ext4_get_inline_size (dir) -EXT4_MIN_INLINE_DATA_SIZE ; - ret =ext4_search_dir (iloc.bh, inline_start, inline_size, + ret =ext4_search_dir (is.iloc.bh, inline_start, inline_size, dir, fname,0 , res_dir);if (ret ==1 ) goto out_find; out: -brelse (iloc.bh); +brelse (is.iloc.bh);if (ret <0 ) - iloc.bh =ERR_PTR (ret); + is.iloc.bh =ERR_PTR (ret);else - iloc.bh =NULL ; + is.iloc.bh =NULL ; out_find:up_read (&EXT4_I (dir)->xattr_sem); -return iloc.bh; +return is.iloc.bh; } int ext4_delete_inline_entry(handle_t *handle,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 171/798 nilfs2: fix potential null-ptr-deref in nilfs_btree_insert()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 9403001ad65ae4f4c5de368bdda3a0636b51d51a ]
Patch series "nilfs2: fix potential issues with empty b-tree nodes".
This series addresses three potential issues with empty b-tree nodes that can occur with corrupted filesystem images, including one recently discovered by syzbot.
This patch (of 3):
If a b-tree is broken on the device, and the b-tree height is greater than 2 (the level of the root node is greater than 1) even if the number of child nodes of the b-tree root is 0, a NULL pointer dereference occurs in nilfs_btree_prepare_insert(), which is called from nilfs_btree_insert().
This is because, when the number of child nodes of the b-tree root is 0, nilfs_btree_do_lookup() does not set the block buffer head in any of path[x].bp_bh, leaving it as the initial value of NULL, but if the level of the b-tree root node is greater than 1, nilfs_btree_get_nonroot_node(), which accesses the buffer memory of path[x].bp_bh, is called.
Fix this issue by adding a check to nilfs_btree_root_broken(), which performs sanity checks when reading the root node from the device, to detect this inconsistency.
Thanks to Lizhi Xu for trying to solve the bug and clarifying the cause early on.
--- fs/nilfs2/btree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nilfs2/btree.c +2 -1
@@ -381,7 +381,8 @@ static int nilfs_btree_root_broken(const struct nilfs_btree_node *node,if (unlikely (level <NILFS_BTREE_LEVEL_NODE_MIN || level >=NILFS_BTREE_LEVEL_MAX || nchildren <0 || - nchildren >NILFS_BTREE_ROOT_NCHILDREN_MAX )) { + nchildren >NILFS_BTREE_ROOT_NCHILDREN_MAX || + (nchildren ==0 && level >NILFS_BTREE_LEVEL_NODE_MIN ))) {nilfs_crit (inode->i_sb,"bad btree root (ino=%lu): level = %d, flags = 0x%x, nchildren = %d" , inode->i_ino, level, flags, nchildren);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 172/798 nilfs2: determine empty node blocks as corrupted
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 111b812d3662f3a1b831d19208f83aa711583fe6 ]
Due to the nature of b-trees, nilfs2 itself and admin tools such as mkfs.nilfs2 will never create an intermediate b-tree node block with 0 child nodes, nor will they delete (key, pointer)-entries that would result in such a state. However, it is possible that a b-tree node block is corrupted on the backing device and is read with 0 child nodes.
Because operation is not guaranteed if the number of child nodes is 0 for intermediate node blocks other than the root node, modify nilfs_btree_node_broken(), which performs sanity checks when reading a b-tree node block, so that such cases will be judged as metadata corruption.
--- fs/nilfs2/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/btree.c +1 -1
@@ -350,7 +350,7 @@ static int nilfs_btree_node_broken(const struct nilfs_btree_node *node,if (unlikely (level <NILFS_BTREE_LEVEL_NODE_MIN || level >=NILFS_BTREE_LEVEL_MAX || (flags &NILFS_BTREE_NODE_ROOT ) || - nchildren <0 || + nchildren <=0 || nchildren >NILFS_BTREE_NODE_NCHILDREN_MAX (size))) { nilfs_crit(inode->i_sb, "bad btree node (ino=%lu, blocknr=%llu): level = %d, flags = 0x%x, nchildren = %d",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 173/798 nilfs2: fix potential oob read in nilfs_btree_check_delete()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit f9c96351aa6718b42a9f42eaf7adce0356bdb5e8 ]
The function nilfs_btree_check_delete(), which checks whether degeneration to direct mapping occurs before deleting a b-tree entry, causes memory access outside the block buffer when retrieving the maximum key if the root node has no entries.
This does not usually happen because b-tree mappings with 0 child nodes are never created by mkfs.nilfs2 or nilfs2 itself. However, it can happen if the b-tree root node read from a device is configured that way, so fix this potential issue by adding a check for that case.
--- fs/nilfs2/btree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/nilfs2/btree.c +5 -2
@@ -1659,13 +1659,16 @@ static int nilfs_btree_check_delete(struct nilfs_bmap *btree, __u64 key)int nchildren, ret; root =nilfs_btree_get_root (btree); + nchildren =nilfs_btree_node_get_nchildren (root); +if (unlikely (nchildren ==0 )) +return 0 ; +switch (nilfs_btree_height (btree)) {case 2 : bh =NULL ; node = root;break ;case 3 : - nchildren =nilfs_btree_node_get_nchildren (root);if (nchildren >1 )return 0 ; ptr = nilfs_btree_node_get_ptr(root, nchildren - 1,
@@ -1674,12 +1677,12 @@ static int nilfs_btree_check_delete(struct nilfs_bmap *btree, __u64 key)if (ret <0 )return ret; node = (struct nilfs_btree_node *)bh->b_data; + nchildren =nilfs_btree_node_get_nchildren (node);break ;default :return 0 ; } - nchildren =nilfs_btree_node_get_nchildren (node); maxkey =nilfs_btree_node_get_key (node, nchildren -1 ); nextmaxkey = (nchildren >1 ) ?nilfs_btree_node_get_key (node, nchildren -2 ) :0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 174/798 bpf: Fix bpf_strtol and bpf_strtoul helpers for 32bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit cfe69c50b05510b24e26ccb427c7cc70beafd6c1 ]
The bpf_strtol() and bpf_strtoul() helpers are currently broken on 32bit:
The argument type ARG_PTR_TO_LONG is BPF-side "long", not kernel-side "long" and therefore always considered fixed 64bit no matter if 64 or 32bit underlying architecture.
This contract breaks in case of the two mentioned helpers since their BPF_CALL definition for the helpers was added with {unsigned,}long *res. Meaning, the transition from BPF-side "long" (BPF program) to kernel-side "long" (BPF helper) breaks here.
Both helpers call __bpf_strtoll() with "long long" correctly, but later assigning the result into 32-bit "*(long *)" on 32bit architectures. From a BPF program point of view, this means upper bits will be seen as uninitialised.
Therefore, fix both BPF_CALL signatures to {s,u}64 types to fix this situation.
Now, changing also uapi/bpf.h helper documentation which generates bpf_helper_defs.h for BPF programs is tricky: Changing signatures there to __{s,u}64 would trigger compiler warnings (incompatible pointer types passing 'long *' to parameter of type '__s64 *' (aka 'long long *')) for existing BPF programs.
Leaving the signatures as-is would be fine as from BPF program point of view it is still BPF-side "long" and thus equivalent to __{s,u}64 on 64 or 32bit underlying architectures.
Note that bpf_strtol() and bpf_strtoul() are the only helpers with this issue.
--- kernel/bpf/helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/helpers.c +2 -2
@@ -509,7 +509,7 @@ static int __bpf_strtoll(const char *buf, size_t buf_len, u64 flags, } BPF_CALL_4(bpf_strtol, const char *, buf, size_t, buf_len, u64, flags, - long *, res) + s64 *, res) {long long _res;int err;
@@ -534,7 +534,7 @@ const struct bpf_func_proto bpf_strtol_proto = { }; BPF_CALL_4(bpf_strtoul, const char *, buf, size_t, buf_len, u64, flags, - unsigned long *, res) + u64 *, res) {unsigned long long _res;bool is_negative;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 175/798 bpf: Improve check_raw_mode_ok test for MEM_UNINIT-tagged types
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 18752d73c1898fd001569195ba4b0b8c43255f4a ]
When checking malformed helper function signatures, also take other argument types into account aside from just ARG_PTR_TO_UNINIT_MEM.
This concerns (formerly) ARG_PTR_TO_{INT,LONG} given uninitialized memory can be passed there, too.
The func proto sanity check goes back to commit 435faee1aae9 ("bpf, verifier:
add ARG_PTR_TO_RAW_STACK type"), and its purpose was to detect wrong func protos which had more than just one MEM_UNINIT-tagged type as arguments.
The reason more than one is currently not supported is as we mark stack slots with STACK_MISC in check_helper_call() in case of raw mode based on meta.access_size to allow uninitialized stack memory to be passed to helpers when they just write into the buffer.
Probing for base type as well as MEM_UNINIT tagging ensures that other types do not get missed (as it used to be the case for ARG_PTR_TO_{INT,LONG}).
--- kernel/bpf/verifier.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
kernel/bpf/verifier.c +11 -5
@@ -5796,6 +5796,12 @@ static bool arg_type_is_mem_size(enum bpf_arg_type type) type ==ARG_CONST_SIZE_OR_ZERO ; } +static bool arg_type_is_raw_mem (enum bpf_arg_type type) +{ +return base_type (type) ==ARG_PTR_TO_MEM && + type &MEM_UNINIT ; +} +static bool arg_type_is_release (enum bpf_arg_type type) {return type &OBJ_RELEASE ;
@@ -6708,15 +6714,15 @@ static bool check_raw_mode_ok(const struct bpf_func_proto *fn) {int count =0 ; -if (fn->arg1_type ==ARG_PTR_TO_UNINIT_MEM ) +if (arg_type_is_raw_mem (fn->arg1_type)) count++; -if (fn->arg2_type ==ARG_PTR_TO_UNINIT_MEM ) +if (arg_type_is_raw_mem (fn->arg2_type)) count++; -if (fn->arg3_type ==ARG_PTR_TO_UNINIT_MEM ) +if (arg_type_is_raw_mem (fn->arg3_type)) count++; -if (fn->arg4_type ==ARG_PTR_TO_UNINIT_MEM ) +if (arg_type_is_raw_mem (fn->arg4_type)) count++; -if (fn->arg5_type ==ARG_PTR_TO_UNINIT_MEM ) +if (arg_type_is_raw_mem (fn->arg5_type)) count++;/* We only support one arg being in raw mode at the moment,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 176/798 bpf: Zero former ARG_PTR_TO_{LONG,INT} args in case of error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 4b3786a6c5397dc220b1483d8e2f4867743e966f ]
For all non-tracing helpers which formerly had ARG_PTR_TO_{LONG,INT} as input arguments, zero the value for the case of an error as otherwise it could leak memory. For tracing, it is not needed given CAP_PERFMON can already read all kernel memory anyway hence bpf_get_func_arg() and bpf_get_func_ret() is skipped in here.
Also, the MTU helpers mtu_len pointer value is being written but also read. Technically, the MEM_UNINIT should not be there in order to always force init. Removing MEM_UNINIT needs more verifier rework though: MEM_UNINIT right now implies two things actually: i) write into memory, ii) memory does not have to be initialized. If we lift MEM_UNINIT, it then becomes: i) read into memory, ii) memory must be initialized. This means that for bpf_*_check_mtu() we're readding the issue we're trying to fix, that is, it would then be able to write back into things like .rodata BPF maps. Follow-up work will rework the MEM_UNINIT semantics such that the intent can be better expressed. For now just clear the *mtu_len on error path which can be lifted later again.
--- kernel/bpf/helpers.c | 2 ++ kernel/bpf/syscall.c | 1 + net/core/filter.c | 44 +++++++++++++++++++++++--------------------- 3 files changed, 26 insertions(+), 21 deletions(-)
kernel/bpf/helpers.c +2 -0
@@ -514,6 +514,7 @@ BPF_CALL_4(bpf_strtol, const char *, buf, size_t, buf_len, u64, flags,long long _res;int err; + *res =0 ; err =__bpf_strtoll (buf, buf_len, flags, &_res);if (err <0 )return err;
@@ -540,6 +541,7 @@ BPF_CALL_4(bpf_strtoul, const char *, buf, size_t, buf_len, u64, flags,bool is_negative;int err; + *res =0 ; err =__bpf_strtoull (buf, buf_len, flags, &_res, &is_negative);if (err <0 )return err;
kernel/bpf/syscall.c +1 -0
@@ -5239,6 +5239,7 @@ static const struct bpf_func_proto bpf_sys_close_proto = { BPF_CALL_4(bpf_kallsyms_lookup_name, const char *, name, int, name_sz, int, flags, u64 *, res) { + *res =0 ;if (flags)return -EINVAL ;
net/core/filter.c +23 -21
87 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 177/798 perf mem: Free the allocated sort string, fixing a leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 3da209bb1177462b6fe8e3021a5527a5a49a9336 ]
The get_sort_order() returns either a new string (from strdup) or NULL but it never gets freed.
--- tools/perf/builtin-mem.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/builtin-mem.c +1 -0
@@ -368,6 +368,7 @@ static int report_events(int argc, const char **argv, struct perf_mem *mem) rep_argv[i] = argv[j]; ret =cmd_report (i, rep_argv); +free (new_sort_order);free (rep_argv);return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 178/798 perf inject: Fix leader sampling inserting additional samples
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 79bcd34e0f3da39fda841406ccc957405e724852 ]
The processing of leader samples would turn an individual sample with a group of read values into multiple samples. 'perf inject' would pass through the additional samples increasing the output data file size:
$ perf record -g -e "{instructions,cycles}:S" -o perf.orig.data true
$ perf script -D -i perf.orig.data | sed -e 's/perf.orig.data/perf.data/g' > orig.txt
$ perf inject -i perf.orig.data -o perf.new.data
$ perf script -D -i perf.new.data | sed -e 's/perf.new.data/perf.data/g' > new.txt
$ diff -u orig.txt new.txt
--- orig.txt 2024-07-29 14:29:40.606576769 -0700
+++ new.txt 2024-07-29 14:30:04.142737434 -0700
...
[email protected] [0x30]: event: 3
[email protected] [0xd0]: event: 9
+.
+. ... raw event: size 208 bytes
+. 0000: 09 00 00 00 01 00 d0 00 fc 72 01 86 ff ff ff ff .........r......
+. 0010: 74 7d 2c 00 74 7d 2c 00 fb c3 79 f9 ba d5 05 00 t},.t},...y.....
+. 0020: e6 cb 1a 00 00 00 00 00 01 00 00 00 00 00 00 00 ................
+. 0030: 02 00 00 00 00 00 00 00 76 01 00 00 00 00 00 00 ........v.......
+. 0040: e6 cb 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+. 0050: 62 18 00 00 00 00 00 00 f6 cb 1a 00 00 00 00 00 b...............
+. 0060: 00 00 00 00 00 00 00 00 0c 00 00 00 00 00 00 00 ................
+. 0070: 80 ff ff ff ff ff ff ff fc 72 01 86 ff ff ff ff .........r......
+. 0080: f3 0e 6e 85 ff ff ff ff 0c cb 7f 85 ff ff ff ff ..n.............
+. 0090: bc f2 87 85 ff ff ff ff 44 af 7f 85 ff ff ff ff ........D.......
+. 00a0: bd be 7f 85 ff ff ff ff 26 d0 7f 85 ff ff ff ff ........&.......
+. 00b0: 6d a4 ff 85 ff ff ff ff ea 00 20 86 ff ff ff ff m......... .....
+. 00c0: 00 fe ff ff ff ff ff ff 57 14 4f 43 fc 7e 00 00 ........W.OC.~..
+
+1642373909693435 0xc550 [0xd0]: PERF_RECORD_SAMPLE(IP, 0x1): 2915700/2915700: 0xffffffff860172fc period: 1 addr: 0
+... FP chain: nr:12
+..... 0: ffffffffffffff80
+..... 1: ffffffff860172fc
+..... 2: ffffffff856e0ef3
+..... 3: ffffffff857fcb0c
+..... 4: ffffffff8587f2bc
+..... 5: ffffffff857faf44
+..... 6: ffffffff857fbebd
+..... 7: ffffffff857fd026
+..... 8: ffffffff85ffa46d
+..... 9: ffffffff862000ea
+..... 10: fffffffffffffe00
+..... 11: 00007efc434f1457
+... sample_read:
+.... group nr 2
+..... id 00000000001acbe6, value 0000000000000176, lost 0
+..... id 00000000001acbf6, value 0000000000001862, lost 0
+
[email protected] [0x30]: event: 3
...This behavior is incorrect as in the case above 'perf inject' should have done nothing. Fix this behavior by disabling separating samples for a tool that requests it. Only request this for perf inject so as to not affect other perf tools. With the patch and the test above there are no differences between the orig.txt and new.txt.
--- tools/perf/builtin-inject.c | 1 + tools/perf/util/session.c | 3 +++ tools/perf/util/tool.h | 1 + 3 files changed, 5 insertions(+)
tools/perf/builtin-inject.c +1 -0
@@ -2173,6 +2173,7 @@ int cmd_inject(int argc, const char **argv) .finished_init = perf_event__repipe_op2_synth, .compressed = perf_event__repipe_op4_synth, .auxtrace = perf_event__repipe_auxtrace, + .dont_split_sample_group = true, }, .input_name = "-", .samples = LIST_HEAD_INIT(inject.samples),
tools/perf/util/session.c +3 -0
@@ -1497,6 +1497,9 @@ static int deliver_sample_group(struct evlist *evlist,int ret = -EINVAL ;struct sample_read_value *v = sample->read.group.values; +if (tool->dont_split_sample_group) +return deliver_sample_value (evlist, tool, event, sample, v, machine); +sample_read_group__for_each (v, sample->read.group.nr, read_format) { ret =deliver_sample_value (evlist, tool, event, sample, v, machine);
tools/perf/util/tool.h +1 -0
@@ -85,6 +85,7 @@ struct perf_tool {bool namespace_events;bool cgroup_events;bool no_warn; +bool dont_split_sample_group;enum show_feature_header show_feat_hdr; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 179/798 perf sched timehist: Fix missing free of session in perf_sched__timehist()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Jihong <[email protected]>
[ Upstream commit 6bdf5168b6fb19541b0c1862bdaa596d116c7bfb ]
When perf_time__parse_str() fails in perf_sched__timehist(), need to free session that was previously created, fix it.
--- tools/perf/builtin-sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +2 -1
@@ -3056,7 +3056,8 @@ static int perf_sched__timehist(struct perf_sched *sched)if (perf_time__parse_str (&sched->ptime, sched->time_str) !=0 ) {pr_err ("Invalid time string\n" ); -return -EINVAL ; + err = -EINVAL ; + goto out; }if (timehist_check_attr (sched, evlist) !=0 )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 180/798 perf stat: Display iostat headers correctly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yicong Yang <[email protected]>
[ Upstream commit 2615639352420e6e3115952c5b8f46846e1c6d0e ]
Currently we'll only print metric headers for metric leader in aggregration mode. This will make perf iostat header not shown since it'll aggregrated globally but don't have metric events:
root@ubuntu204:/home/yang/linux/tools/perf# ./perf stat --iostat --timeout 1000
Performance counter stats for 'system wide':
port
0000:00 0 0 0 0
0000:80 0 0 0 0
[...]Fix this by excluding the iostat in the check of printing metric headers. Then we can see the headers:
root@ubuntu204:/home/yang/linux/tools/perf# ./perf stat --iostat --timeout 1000
Performance counter stats for 'system wide':
port Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB)
0000:00 0 0 0 0
0000:80 0 0 0 0
[...]--- tools/perf/util/stat-display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/stat-display.c +2 -1
@@ -1162,7 +1162,8 @@ static void print_metric_headers(struct perf_stat_config *config,/* Print metrics headers only */ evlist__for_each_entry (evlist, counter) { -if (config->aggr_mode !=AGGR_NONE && counter->metric_leader != counter) +if (!config->iostat_run && + config->aggr_mode !=AGGR_NONE && counter->metric_leader != counter)continue ; os.evsel = counter;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/798 perf sched timehist: Fixed timestamp error when unable to confirm event sched_in time
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Jihong <[email protected]>
[ Upstream commit 39c243411bdb8fb35777adf49ee32549633c4e12 ]
If sched_in event for current task is not recorded, sched_in timestamp will be set to end_time of time window interest, causing an error in timestamp show. In this case, we choose to ignore this event.
Test scenario:
perf[1229608] does not record the first sched_in event, run time and sch delay are both 0
# perf sched timehist
Samples of sched_switch event do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
--------------- ------ ------------------------------ --------- --------- ---------
2090450.763231 [0000] perf[1229608] 0.000 0.000 0.000
2090450.763235 [0000] migration/0[15] 0.000 0.001 0.003
2090450.763263 [0001] perf[1229608] 0.000 0.000 0.000
2090450.763268 [0001] migration/1[21] 0.000 0.001 0.004
2090450.763302 [0002] perf[1229608] 0.000 0.000 0.000
2090450.763309 [0002] migration/2[27] 0.000 0.001 0.007
2090450.763338 [0003] perf[1229608] 0.000 0.000 0.000
2090450.763343 [0003] migration/3[33] 0.000 0.001 0.004Before:
arbitrarily specify a time window of interest, timestamp will be set to an incorrect value
# perf sched timehist --time 100,200
Samples of sched_switch event do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
--------------- ------ ------------------------------ --------- --------- ---------
200.000000 [0000] perf[1229608] 0.000 0.000 0.000
200.000000 [0001] perf[1229608] 0.000 0.000 0.000
200.000000 [0002] perf[1229608] 0.000 0.000 0.000
200.000000 [0003] perf[1229608] 0.000 0.000 0.000
200.000000 [0004] perf[1229608] 0.000 0.000 0.000
200.000000 [0005] perf[1229608] 0.000 0.000 0.000
200.000000 [0006] perf[1229608] 0.000 0.000 0.000
200.000000 [0007] perf[1229608] 0.000 0.000 0.000After:
# perf sched timehist --time 100,200
Samples of sched_switch event do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
--------------- ------ ------------------------------ --------- --------- ------------ tools/perf/builtin-sched.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +4 -1
@@ -2604,9 +2604,12 @@ static int timehist_sched_change_event(struct perf_tool *tool,* - previous sched event is out of window - we are done * - sample time is beyond window user cares about - reset it * to close out stats for time window interest +* - If tprev is 0, that is, sched_in event for current task is +* not recorded, cannot determine whether sched_in event is +* within time window interest - ignore it */ if (ptime->end) { -if (tprev > ptime->end) +if (!tprev || tprev > ptime->end) goto out;if (t > ptime->end)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 182/798 perf time-utils: Fix 32-bit nsec parsing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 38e2648a81204c9fc5b4c87a8ffce93a6ed91b65 ]
The "time utils" test fails in 32-bit builds:
...
parse_nsec_time("18446744073.709551615")
Failed. ptime 4294967295709551615 expected 18446744073709551615
...
Switch strtoul to strtoull as an unsigned long in 32-bit build isn't 64-bits.
--- tools/perf/util/time-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/time-utils.c +2 -2
@@ -20,7 +20,7 @@ int parse_nsec_time(const char *str, u64 *ptime)u64 time_sec, time_nsec;char *end; - time_sec =strtoul (str, &end,10 ); + time_sec =strtoull (str, &end,10 );if (*end !='.' && *end !='\0' )return -1 ;
@@ -38,7 +38,7 @@ int parse_nsec_time(const char *str, u64 *ptime)for (i =strlen (nsec_buf); i <9 ; i++) nsec_buf[i] ='0' ; - time_nsec =strtoul (nsec_buf, &end,10 ); + time_nsec =strtoull (nsec_buf, &end,10 );if (*end !='\0' )return -1 ; }else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 183/798 clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Elfring <[email protected]>
[ Upstream commit fed6bf52c86df27ad4f39a72cdad8c27da9a50ba ]
The function “kfree” was called in up to three cases by the function “__imx8m_clk_hw_composite” during error handling even if the passed variables contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
Stable-dep-of: 8f32e9dd0916 ("clk: imx: composite-8m: Enable gate clk with mcore_booted")
--- drivers/clk/imx/clk-composite-8m.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/clk/imx/clk-composite-8m.c +7 -5
@@ -189,7 +189,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, mux =kzalloc (sizeof (*mux),GFP_KERNEL );if (!mux) - goto fail; +return ERR_CAST (hw); mux_hw = &mux->hw; mux->reg = reg;
@@ -199,7 +199,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, div =kzalloc (sizeof (*div),GFP_KERNEL );if (!div) - goto fail; + goto free_mux; div_hw = &div->hw; div->reg = reg;
@@ -229,7 +229,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,if (!mcore_booted) { gate =kzalloc (sizeof (*gate),GFP_KERNEL );if (!gate) - goto fail; + goto free_div; gate_hw = &gate->hw; gate->reg = reg;
@@ -241,13 +241,15 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, mux_hw, mux_ops, div_hw, divider_ops, gate_hw, &clk_gate_ops, flags);if (IS_ERR (hw)) - goto fail; + goto free_gate;return hw; -fail: +free_gate:kfree (gate); +free_div:kfree (div); +free_mux:kfree (mux);return ERR_CAST (hw); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 184/798 clk: imx: composite-8m: Enable gate clk with mcore_booted
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 8f32e9dd0916eb3fd4bcf550ed1d04542a65cb9e ]
Bootloader might disable some CCM ROOT Slices. So if mcore_booted set with display CCM ROOT disabled by Bootloader, kernel display BLK CTRL driver imx8m_blk_ctrl_driver_init may hang the system because the BUS clk is disabled.
Add back gate ops, but with disable doing nothing, then the CCM ROOT will be enabled when used.
--- drivers/clk/imx/clk-composite-8m.c | 53 +++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 11 deletions(-)
drivers/clk/imx/clk-composite-8m.c +42 -11
@@ -173,6 +173,34 @@ static const struct clk_ops imx8m_clk_composite_mux_ops = { .determine_rate = imx8m_clk_composite_mux_determine_rate, }; +static int imx8m_clk_composite_gate_enable (struct clk_hw *hw) +{ +struct clk_gate *gate =to_clk_gate (hw); +unsigned long flags; +u32 val; + +spin_lock_irqsave (gate->lock, flags); + + val =readl (gate->reg); + val |=BIT (gate->bit_idx); +writel (val, gate->reg); + +spin_unlock_irqrestore (gate->lock, flags); + +return 0 ; +} + +static void imx8m_clk_composite_gate_disable (struct clk_hw *hw) +{ +/* composite clk requires the disable hook */ +} + +static const struct clk_ops imx8m_clk_composite_gate_ops = { + .enable = imx8m_clk_composite_gate_enable, + .disable = imx8m_clk_composite_gate_disable, + .is_enabled = clk_gate_is_enabled, +}; + struct clk_hw *__imx8m_clk_hw_composite(const char *name, const char * const *parent_names, int num_parents, void __iomem *reg,
@@ -186,6 +214,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,struct clk_mux *mux =NULL ;const struct clk_ops *divider_ops;const struct clk_ops *mux_ops; +const struct clk_ops *gate_ops; mux =kzalloc (sizeof (*mux),GFP_KERNEL );if (!mux)
@@ -226,20 +255,22 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, div->flags =CLK_DIVIDER_ROUND_CLOSEST ;/* skip registering the gate ops if M4 is enabled */ -if (!mcore_booted) { - gate =kzalloc (sizeof (*gate),GFP_KERNEL ); -if (!gate) - goto free_div; - - gate_hw = &gate->hw; - gate->reg = reg; - gate->bit_idx =PCG_CGC_SHIFT ; - gate->lock = &imx_ccm_lock; - } + gate =kzalloc (sizeof (*gate),GFP_KERNEL ); +if (!gate) + goto free_div; + + gate_hw = &gate->hw; + gate->reg = reg; + gate->bit_idx =PCG_CGC_SHIFT ; + gate->lock = &imx_ccm_lock; +if (!mcore_booted) + gate_ops = &clk_gate_ops; +else + gate_ops = &imx8m_clk_composite_gate_ops; hw =clk_hw_register_composite (NULL , name, parent_names, num_parents, mux_hw, mux_ops, div_hw, - divider_ops, gate_hw, &clk_gate_ops, flags); + divider_ops, gate_hw, gate_ops, flags);if (IS_ERR (hw)) goto free_gate;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 185/798 clk: imx: composite-7ulp: Check the PCC present bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Li <[email protected]>
[ Upstream commit 4717ccadb51e2630790dddd222830702de17f090 ]
When some module is disabled by fuse, its PCC PR bit is default 0 and PCC is not operational. Any write to this PCC will cause SError.
--- drivers/clk/imx/clk-composite-7ulp.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/clk/imx/clk-composite-7ulp.c +7 -0
@@ -14,6 +14,7 @@#include "../clk-fractional-divider.h" #include "clk.h" +#define PCG_PR_MASK BIT(31)#define PCG_PCS_SHIFT 24#define PCG_PCS_MASK 0x7#define PCG_CGC_SHIFT 30
@@ -80,6 +81,12 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name,struct clk_hw *hw;u32 val; + val =readl (reg); +if (!(val &PCG_PR_MASK )) { +pr_info ("PCC PR is 0 for clk:%s, bypass\n" , name); +return 0 ; + } +if (mux_present) { mux =kzalloc (sizeof (*mux),GFP_KERNEL );if (!mux)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 186/798 clk: imx: fracn-gppll: support integer pll
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 56b8d0bf3ea8b0db8543e04a6b97348a543405ab ]
The fracn gppll could be configured in FRAC or INTEGER mode during hardware design. The current driver only support FRAC mode, while this patch introduces INTEGER support. When the PLL is INTEGER pll, there is no mfn, mfd, the calculation is as below:
Fvco_clk = (Fref / DIV[RDIV] ) * DIV[MFI]
Fclko_odiv = Fvco_clk / DIV[ODIV]
In this patch, we reuse the FRAC pll logic with some condition check to simplify the driver
Stable-dep-of: 7622f888fca1 ("clk: imx: fracn-gppll: fix fractional part of PLL getting lost")
--- drivers/clk/imx/clk-fracn-gppll.c | 68 +++++++++++++++++++++++++++---- drivers/clk/imx/clk.h | 7 ++++ 2 files changed, 68 insertions(+), 7 deletions(-)
drivers/clk/imx/clk-fracn-gppll.c +61 -7
@@ -53,11 +53,22 @@ .odiv = (_odiv), \ } +#define PLL_FRACN_GP_INTEGER (_rate, _mfi, _rdiv, _odiv) \ + { \ + .rate = (_rate), \ + .mfi = (_mfi), \ + .mfn = 0, \ + .mfd = 0, \ + .rdiv = (_rdiv), \ + .odiv = (_odiv), \ + } +struct clk_fracn_gppll {struct clk_hw hw;void __iomem *base;const struct imx_fracn_gppll_rate_table *rate_table;int rate_count; +u32 flags; };/*
@@ -83,6 +94,24 @@ struct imx_fracn_gppll_clk imx_fracn_gppll = { };EXPORT_SYMBOL_GPL (imx_fracn_gppll); +/* +* Fvco = (Fref / rdiv) * MFI +* Fout = Fvco / odiv +* The (Fref / rdiv) should be in range 20MHz to 40MHz +* The Fvco should be in range 2.5Ghz to 5Ghz +*/ +static const struct imx_fracn_gppll_rate_table int_tbl[] = { +PLL_FRACN_GP_INTEGER (1700000000U ,141 ,1 ,2 ), +PLL_FRACN_GP_INTEGER (1400000000U ,175 ,1 ,3 ), +PLL_FRACN_GP_INTEGER (900000000U ,150 ,1 ,4 ), +}; + +struct imx_fracn_gppll_clk imx_fracn_gppll_integer = { + .rate_table = int_tbl, + .rate_count =ARRAY_SIZE (int_tbl), +}; +EXPORT_SYMBOL_GPL (imx_fracn_gppll_integer); +static inline struct clk_fracn_gppll *to_clk_fracn_gppll (struct clk_hw *hw) { return container_of(hw, struct clk_fracn_gppll, hw);
@@ -169,9 +198,15 @@ static unsigned long clk_fracn_gppll_recalc_rate(struct clk_hw *hw, unsigned lonbreak ; } -/* Fvco = Fref * (MFI + MFN / MFD) */ - fvco = fvco * mfi * mfd + fvco * mfn; -do_div (fvco, mfd * rdiv * odiv); +if (pll->flags &CLK_FRACN_GPPLL_INTEGER ) { +/* Fvco = (Fref / rdiv) * MFI */ + fvco = fvco * mfi; +do_div (fvco, rdiv * odiv); + }else { +/* Fvco = (Fref / rdiv) * (MFI + MFN / MFD) */ + fvco = fvco * mfi * mfd + fvco * mfn; +do_div (fvco, mfd * rdiv * odiv); + }return (unsigned long )fvco; }
@@ -215,8 +250,10 @@ static int clk_fracn_gppll_set_rate(struct clk_hw *hw, unsigned long drate, pll_div =FIELD_PREP (PLL_RDIV_MASK , rate->rdiv) | rate->odiv |FIELD_PREP (PLL_MFI_MASK , rate->mfi);writel_relaxed (pll_div, pll->base +PLL_DIV ); -writel_relaxed (rate->mfd, pll->base +PLL_DENOMINATOR ); -writel_relaxed (FIELD_PREP (PLL_MFN_MASK , rate->mfn), pll->base +PLL_NUMERATOR ); +if (pll->flags &CLK_FRACN_GPPLL_FRACN ) { +writel_relaxed (rate->mfd, pll->base +PLL_DENOMINATOR ); +writel_relaxed (FIELD_PREP (PLL_MFN_MASK , rate->mfn), pll->base +PLL_NUMERATOR ); + }/* Wait for 5us according to fracn mode pll doc */ udelay (5 );
@@ -300,8 +337,10 @@ static const struct clk_ops clk_fracn_gppll_ops = { .set_rate = clk_fracn_gppll_set_rate, }; -struct clk_hw *imx_clk_fracn_gppll (const char *name,const char *parent_name,void __iomem *base, -const struct imx_fracn_gppll_clk *pll_clk) +static struct clk_hw *_imx_clk_fracn_gppll (const char *name,const char *parent_name, +void __iomem *base, +const struct imx_fracn_gppll_clk *pll_clk, +u32 pll_flags) {struct clk_fracn_gppll *pll;struct clk_hw *hw;
@@ -322,6 +361,7 @@ struct clk_hw *imx_clk_fracn_gppll(const char *name, const char *parent_name, vo pll->hw.init = &init; pll->rate_table = pll_clk->rate_table; pll->rate_count = pll_clk->rate_count; + pll->flags = pll_flags; hw = &pll->hw;
@@ -334,4 +374,18 @@ struct clk_hw *imx_clk_fracn_gppll(const char *name, const char *parent_name, voreturn hw; } + +struct clk_hw *imx_clk_fracn_gppll (const char *name,const char *parent_name,void __iomem *base, +const struct imx_fracn_gppll_clk *pll_clk) +{ +return _imx_clk_fracn_gppll (name, parent_name, base, pll_clk,CLK_FRACN_GPPLL_FRACN ); +}EXPORT_SYMBOL_GPL (imx_clk_fracn_gppll); + +struct clk_hw *imx_clk_fracn_gppll_integer (const char *name,const char *parent_name, +void __iomem *base, +const struct imx_fracn_gppll_clk *pll_clk) +{ +return _imx_clk_fracn_gppll (name, parent_name, base, pll_clk,CLK_FRACN_GPPLL_INTEGER ); +} +EXPORT_SYMBOL_GPL (imx_clk_fracn_gppll_integer);
drivers/clk/imx/clk.h +7 -0
@@ -74,6 +74,9 @@ extern struct imx_pll14xx_clk imx_1416x_pll;extern struct imx_pll14xx_clk imx_1443x_pll;extern struct imx_pll14xx_clk imx_1443x_dram_pll; +#define CLK_FRACN_GPPLL_INTEGER BIT(0) +#define CLK_FRACN_GPPLL_FRACN BIT(1) +/* NOTE: Rate table should be kept sorted in descending order. */ struct imx_fracn_gppll_rate_table {unsigned int rate;
@@ -92,8 +95,12 @@ struct imx_fracn_gppll_clk {struct clk_hw *imx_clk_fracn_gppll (const char *name,const char *parent_name,void __iomem *base,const struct imx_fracn_gppll_clk *pll_clk); +struct clk_hw *imx_clk_fracn_gppll_integer (const char *name,const char *parent_name, +void __iomem *base, +const struct imx_fracn_gppll_clk *pll_clk);extern struct imx_fracn_gppll_clk imx_fracn_gppll; +extern struct imx_fracn_gppll_clk imx_fracn_gppll_integer;#define imx_clk_cpu (name, parent_name, div, mux, pll, step) \ to_clk(imx_clk_hw_cpu(name, parent_name, div, mux, pll, step))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 187/798 clk: imx: fracn-gppll: fix fractional part of PLL getting lost
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengfei Li <[email protected]>
[ Upstream commit 7622f888fca125ae46f695edf918798ebc0506c5 ]
Fractional part of PLL gets lost after re-enabling the PLL. the MFN can NOT be automatically loaded when doing frac PLL enable/disable, So when re-enable PLL, configure mfn explicitly.
--- drivers/clk/imx/clk-fracn-gppll.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/imx/clk-fracn-gppll.c +4 -0
@@ -289,6 +289,10 @@ static int clk_fracn_gppll_prepare(struct clk_hw *hw)if (val &POWERUP_MASK )return 0 ; +if (pll->flags &CLK_FRACN_GPPLL_FRACN ) +writel_relaxed (readl_relaxed (pll->base +PLL_NUMERATOR ), + pll->base +PLL_NUMERATOR ); + val |=CLKMUX_BYPASS ;writel_relaxed (val, pll->base +PLL_CTRL );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 188/798 clk: imx: imx8mp: fix clock tree update of TF-A managed clocks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhipeng Wang <[email protected]>
[ Upstream commit 3d29036853b9cb07ac49e8261fca82a940be5c41 ]
On the i.MX8M*, the TF-A exposes a SiP (Silicon Provider) service for DDR frequency scaling. The imx8m-ddrc-devfreq driver calls the SiP and then does clk_set_parent on the DDR muxes to synchronize the clock tree.
since commit 936c383673b9 ("clk: imx: fix composite peripheral flags"), these TF-A managed muxes have SET_PARENT_GATE set, which results in imx8m-ddrc-devfreq's clk_set_parent after SiP failing with -EBUSY:
clk_set_parent(dram_apb_src, sys1_pll_40m);(busfreq-imx8mq.c)
commit 926bf91248dd
("clk: imx8m: fix clock tree update of TF-A managed clocks") adds this method and enables 8mm, 8mn and 8mq. i.MX8MP also needs it.
This is safe to do, because updating the Linux clock tree to reflect reality will always be glitch-free.
Another reason to this patch is that powersave image BT music requires dram to be 400MTS, so clk_set_parent(dram_alt_src, sys1_pll_800m); is required. Without this patch, it will not succeed.
--- drivers/clk/imx/clk-imx8mp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/imx/clk-imx8mp.c +2 -2
@@ -550,8 +550,8 @@ static int imx8mp_clocks_probe(struct platform_device *pdev) hws[IMX8MP_CLK_IPG_ROOT ] =imx_clk_hw_divider2 ("ipg_root" ,"ahb_root" , ccm_base +0x9080 ,0 ,1 ); - hws[IMX8MP_CLK_DRAM_ALT ] =imx8m_clk_hw_composite ("dram_alt" , imx8mp_dram_alt_sels, ccm_base +0xa000 ); - hws[IMX8MP_CLK_DRAM_APB ] =imx8m_clk_hw_composite_critical ("dram_apb" , imx8mp_dram_apb_sels, ccm_base +0xa080 ); + hws[IMX8MP_CLK_DRAM_ALT ] =imx8m_clk_hw_fw_managed_composite ("dram_alt" , imx8mp_dram_alt_sels, ccm_base +0xa000 ); + hws[IMX8MP_CLK_DRAM_APB ] =imx8m_clk_hw_fw_managed_composite_critical ("dram_apb" , imx8mp_dram_apb_sels, ccm_base +0xa080 ); hws[IMX8MP_CLK_VPU_G1 ] =imx8m_clk_hw_composite ("vpu_g1" , imx8mp_vpu_g1_sels, ccm_base +0xa100 ); hws[IMX8MP_CLK_VPU_G2 ] =imx8m_clk_hw_composite ("vpu_g2" , imx8mp_vpu_g2_sels, ccm_base +0xa180 ); hws[IMX8MP_CLK_CAN1 ] =imx8m_clk_hw_composite ("can1" , imx8mp_can1_sels, ccm_base +0xa200 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 189/798 clk: imx: imx8qxp: Register dc0_bypass0_clk before disp clk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit e61352d5ecdc0da2e7253121c15d9a3e040f78a1 ]
The initialization order of SCU clocks affects the sequence of SCU clock resume. If there are no other effects, the earlier the initialization, the earlier the resume. During SCU clock resume, the clock rate is restored. As SCFW guidelines, configure the parent clock rate before configuring the child rate.
--- drivers/clk/imx/clk-imx8qxp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/imx/clk-imx8qxp.c +2 -2
@@ -200,11 +200,11 @@ static int imx8qxp_clk_probe(struct platform_device *pdev)imx_clk_scu ("usb3_lpm_div" ,IMX_SC_R_USB_2 ,IMX_SC_PM_CLK_MISC );/* Display controller SS */ -imx_clk_scu2 ("dc0_disp0_clk" , dc0_sels,ARRAY_SIZE (dc0_sels),IMX_SC_R_DC_0 ,IMX_SC_PM_CLK_MISC0 ); -imx_clk_scu2 ("dc0_disp1_clk" , dc0_sels,ARRAY_SIZE (dc0_sels),IMX_SC_R_DC_0 ,IMX_SC_PM_CLK_MISC1 );imx_clk_scu ("dc0_pll0_clk" ,IMX_SC_R_DC_0_PLL_0 ,IMX_SC_PM_CLK_PLL );imx_clk_scu ("dc0_pll1_clk" ,IMX_SC_R_DC_0_PLL_1 ,IMX_SC_PM_CLK_PLL );imx_clk_scu ("dc0_bypass0_clk" ,IMX_SC_R_DC_0_VIDEO0 ,IMX_SC_PM_CLK_BYPASS ); +imx_clk_scu2 ("dc0_disp0_clk" , dc0_sels,ARRAY_SIZE (dc0_sels),IMX_SC_R_DC_0 ,IMX_SC_PM_CLK_MISC0 ); +imx_clk_scu2 ("dc0_disp1_clk" , dc0_sels,ARRAY_SIZE (dc0_sels),IMX_SC_R_DC_0 ,IMX_SC_PM_CLK_MISC1 );imx_clk_scu ("dc0_bypass1_clk" ,IMX_SC_R_DC_0_VIDEO1 ,IMX_SC_PM_CLK_BYPASS );imx_clk_scu2 ("dc1_disp0_clk" , dc1_sels,ARRAY_SIZE (dc1_sels),IMX_SC_R_DC_1 ,IMX_SC_PM_CLK_MISC0 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 190/798 clk: imx: imx8qxp: Parent should be initialized earlier than the clock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 766c386c16c9899461b83573a06380d364c6e261 ]
The initialization order of SCU clocks affects the sequence of SCU clock resume. If there are no other effects, the earlier the initialization, the earlier the resume. During SCU clock resume, the clock rate is restored. As SCFW guidelines, configure the parent clock rate before configuring the child rate.
--- drivers/clk/imx/clk-imx8qxp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/imx/clk-imx8qxp.c +3 -3
@@ -166,8 +166,8 @@ static int imx8qxp_clk_probe(struct platform_device *pdev)imx_clk_scu ("pwm_clk" ,IMX_SC_R_LCD_0_PWM_0 ,IMX_SC_PM_CLK_PER );imx_clk_scu ("elcdif_pll" ,IMX_SC_R_ELCDIF_PLL ,IMX_SC_PM_CLK_PLL );imx_clk_scu2 ("lcd_clk" , lcd_sels,ARRAY_SIZE (lcd_sels),IMX_SC_R_LCD_0 ,IMX_SC_PM_CLK_PER ); -imx_clk_scu2 ("lcd_pxl_clk" , lcd_pxl_sels,ARRAY_SIZE (lcd_pxl_sels),IMX_SC_R_LCD_0 ,IMX_SC_PM_CLK_MISC0 );imx_clk_scu ("lcd_pxl_bypass_div_clk" ,IMX_SC_R_LCD_0 ,IMX_SC_PM_CLK_BYPASS ); +imx_clk_scu2 ("lcd_pxl_clk" , lcd_pxl_sels,ARRAY_SIZE (lcd_pxl_sels),IMX_SC_R_LCD_0 ,IMX_SC_PM_CLK_MISC0 );/* Audio SS */ imx_clk_scu ("audio_pll0_clk" ,IMX_SC_R_AUDIO_PLL_0 ,IMX_SC_PM_CLK_PLL );
@@ -207,11 +207,11 @@ static int imx8qxp_clk_probe(struct platform_device *pdev)imx_clk_scu2 ("dc0_disp1_clk" , dc0_sels,ARRAY_SIZE (dc0_sels),IMX_SC_R_DC_0 ,IMX_SC_PM_CLK_MISC1 );imx_clk_scu ("dc0_bypass1_clk" ,IMX_SC_R_DC_0_VIDEO1 ,IMX_SC_PM_CLK_BYPASS ); -imx_clk_scu2 ("dc1_disp0_clk" , dc1_sels,ARRAY_SIZE (dc1_sels),IMX_SC_R_DC_1 ,IMX_SC_PM_CLK_MISC0 ); -imx_clk_scu2 ("dc1_disp1_clk" , dc1_sels,ARRAY_SIZE (dc1_sels),IMX_SC_R_DC_1 ,IMX_SC_PM_CLK_MISC1 );imx_clk_scu ("dc1_pll0_clk" ,IMX_SC_R_DC_1_PLL_0 ,IMX_SC_PM_CLK_PLL );imx_clk_scu ("dc1_pll1_clk" ,IMX_SC_R_DC_1_PLL_1 ,IMX_SC_PM_CLK_PLL );imx_clk_scu ("dc1_bypass0_clk" ,IMX_SC_R_DC_1_VIDEO0 ,IMX_SC_PM_CLK_BYPASS ); +imx_clk_scu2 ("dc1_disp0_clk" , dc1_sels,ARRAY_SIZE (dc1_sels),IMX_SC_R_DC_1 ,IMX_SC_PM_CLK_MISC0 ); +imx_clk_scu2 ("dc1_disp1_clk" , dc1_sels,ARRAY_SIZE (dc1_sels),IMX_SC_R_DC_1 ,IMX_SC_PM_CLK_MISC1 );imx_clk_scu ("dc1_bypass1_clk" ,IMX_SC_R_DC_1_VIDEO1 ,IMX_SC_PM_CLK_BYPASS );/* MIPI-LVDS SS */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 191/798 remoteproc: imx_rproc: Correct ddr alias for i.MX8M
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit c901f817792822eda9cec23814a4621fa3e66695 ]
The DDR Alias address should be 0x40000000 according to RM, so correct it.
--- drivers/remoteproc/imx_rproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/imx_rproc.c +1 -1
@@ -160,7 +160,7 @@ static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {/* QSPI Code - alias */ { 0x08000000, 0x08000000, 0x08000000, 0 },/* DDR (Code) - alias */ - { 0x10000000, 0x80000000, 0x0FFE0000, 0 }, + { 0x10000000, 0x40000000, 0x0FFE0000, 0 },/* TCML */ { 0x1FFE0000, 0x007E0000, 0x00020000, ATT_OWN | ATT_IOMEM}, /* TCMU */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 192/798 remoteproc: imx_rproc: Initialize workqueue earlier
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 858e57c1d3dd7b92cc0fa692ba130a0a5d57e49d ]
Initialize workqueue before requesting mailbox channel, otherwise if mailbox interrupt comes before workqueue ready, the imx_rproc_rx_callback will trigger issue.
--- drivers/remoteproc/imx_rproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +2 -2
@@ -796,6 +796,8 @@ static int imx_rproc_probe(struct platform_device *pdev) goto err_put_rproc; } +INIT_WORK (&priv->rproc_work, imx_rproc_vq_work); + ret =imx_rproc_xtr_mbox_init (rproc);if (ret) goto err_put_wkq;
@@ -814,8 +816,6 @@ static int imx_rproc_probe(struct platform_device *pdev)if (ret) goto err_put_mbox; -INIT_WORK (&priv->rproc_work, imx_rproc_vq_work); -if (rproc->state !=RPROC_DETACHED ) rproc->auto_boot =of_property_read_bool (np,"fsl,auto-boot" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 193/798 clk: rockchip: Set parent rate for DCLK_VOP clock on RK3228
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Karlman <[email protected]>
[ Upstream commit 1d34b9757523c1ad547bd6d040381f62d74a3189 ]
Similar to DCLK_LCDC on RK3328, the DCLK_VOP on RK3228 is typically parented by the hdmiphy clk and it is expected that the DCLK_VOP and hdmiphy clk rate are kept in sync.
Use CLK_SET_RATE_PARENT and CLK_SET_RATE_NO_REPARENT flags, same as used on RK3328, to make full use of all possible supported display modes.
--- drivers/clk/rockchip/clk-rk3228.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk-rk3228.c +1 -1
@@ -409,7 +409,7 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = { RK2928_CLKSEL_CON(29), 0, 3, DFLAGS),DIV (0 ,"sclk_vop_pre" ,"sclk_vop_src" ,0 ,RK2928_CLKSEL_CON (27 ),8 ,8 ,DFLAGS ), -MUX (DCLK_VOP ,"dclk_vop" , mux_dclk_vop_p,0 , +MUX (DCLK_VOP ,"dclk_vop" , mux_dclk_vop_p,CLK_SET_RATE_PARENT |CLK_SET_RATE_NO_REPARENT ,RK2928_CLKSEL_CON (27 ),1 ,1 ,MFLAGS ), FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 194/798 Input: ilitek_ts_i2c - avoid wrong input subsystem sync
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emanuele Ghidoli <[email protected]>
[ Upstream commit 7d0b18cd5dc7429917812963611d961fd93cb44d ]
For different reasons i2c transaction may fail or report id in the message may be wrong. Avoid closing the frame in this case as it will result in all contacts being dropped, indicating that nothing is touching the screen anymore, while usually it is not the case.
--- drivers/input/touchscreen/ilitek_ts_i2c.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/input/touchscreen/ilitek_ts_i2c.c +5 -6
@@ -160,15 +160,14 @@ static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts) error =ilitek_i2c_write_and_read (ts,NULL ,0 ,0 , buf,64 );if (error) {dev_err (dev,"get touch info failed, err:%d\n" , error); - goto err_sync_frame; +return error; } report_max_point = buf[REPORT_COUNT_ADDRESS ];if (report_max_point > ts->max_tp) {dev_err (dev,"FW report max point:%d > panel info. max:%d\n" , report_max_point, ts->max_tp); - error = -EINVAL ; - goto err_sync_frame; +return -EINVAL ; } count =DIV_ROUND_UP (report_max_point, packet_max_point);
@@ -178,7 +177,7 @@ static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts)if (error) {dev_err (dev,"get touch info. failed, cnt:%d, err:%d\n" , count, error); - goto err_sync_frame; +return error; } }
@@ -203,10 +202,10 @@ static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts)ilitek_touch_down (ts, id, x, y); } -err_sync_frame:input_mt_sync_frame (input);input_sync (input); -return error; + +return 0 ; }/* APIs of cmds for ILITEK Touch IC */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 195/798 Input: ilitek_ts_i2c - add report id message validation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emanuele Ghidoli <[email protected]>
[ Upstream commit 208989744a6f01bed86968473312d4e650e600b3 ]
Ensure that the touchscreen response has correct "report id" byte before processing the touch data and discard other messages.
--- drivers/input/touchscreen/ilitek_ts_i2c.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/touchscreen/ilitek_ts_i2c.c +7 -0
@@ -37,6 +37,8 @@#define ILITEK_TP_CMD_GET_MCU_VER 0x61#define ILITEK_TP_CMD_GET_IC_MODE 0xC0 +#define ILITEK_TP_I2C_REPORT_ID 0x48 +#define REPORT_COUNT_ADDRESS 61#define ILITEK_SUPPORT_MAX_POINT 40
@@ -163,6 +165,11 @@ static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts)return error; } +if (buf[0 ] !=ILITEK_TP_I2C_REPORT_ID ) { +dev_err (dev,"get touch info failed. Wrong id: 0x%02X\n" , buf[0 ]); +return -EINVAL ; + } + report_max_point = buf[REPORT_COUNT_ADDRESS ];if (report_max_point > ts->max_tp) { dev_err(dev, "FW report max point:%d > panel info. max:%d\n",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 196/798 drivers: media: dvb-frontends/rtl2832: fix an out-of-bounds write error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junlin Li <[email protected]>
[ Upstream commit 8ae06f360cfaca2b88b98ca89144548b3186aab1 ]
Ensure index in rtl2832_pid_filter does not exceed 31 to prevent out-of-bounds access.
dev->filters is a 32-bit value, so set_bit and clear_bit functions should only operate on indices from 0 to 31. If index is 32, it will attempt to access a non-existent 33rd bit, leading to out-of-bounds access. Change the boundary check from index > 32 to index >= 32 to resolve this issue.
--- drivers/media/dvb-frontends/rtl2832.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/rtl2832.c +1 -1
@@ -983,7 +983,7 @@ static int rtl2832_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid, index, pid, onoff, dev->slave_ts);/* skip invalid PIDs (0x2000) */ -if (pid >0x1fff || index >32 ) +if (pid >0x1fff || index >=32 )return 0 ;if (onoff)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 197/798 drivers: media: dvb-frontends/rtl2830: fix an out-of-bounds write error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junlin Li <[email protected]>
[ Upstream commit 46d7ebfe6a75a454a5fa28604f0ef1491f9d8d14 ]
Ensure index in rtl2830_pid_filter does not exceed 31 to prevent out-of-bounds access.
dev->filters is a 32-bit value, so set_bit and clear_bit functions should only operate on indices from 0 to 31. If index is 32, it will attempt to access a non-existent 33rd bit, leading to out-of-bounds access. Change the boundary check from index > 32 to index >= 32 to resolve this issue.
--- drivers/media/dvb-frontends/rtl2830.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/rtl2830.c +1 -1
@@ -609,7 +609,7 @@ static int rtl2830_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid, int on index, pid, onoff);/* skip invalid PIDs (0x2000) */ -if (pid >0x1fff || index >32 ) +if (pid >0x1fff || index >=32 )return 0 ;if (onoff)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 198/798 PCI/PM: Increase wait time after resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
[ Upstream commit e8b908146d44310473e43b3382eca126e12d279c ]
PCIe r6.0 sec 6.6.1 prescribes that a device must be able to respond to config requests within 1.0 s (PCI_RESET_WAIT) after exiting conventional reset and this same delay is prescribed when coming out of D3cold (as that involves reset too).
A device that requires more than 1 second to initialize after reset may respond to config requests with Request Retry Status completions (sec 2.3.1), and we accommodate that in Linux with a 60 second cap (PCIE_RESET_READY_POLL_MS).
Previously we waited up to PCIE_RESET_READY_POLL_MS only in the reset code path, not in the resume path. However, a device has surfaced, namely Intel Titan Ridge xHCI, which requires a longer delay also in the resume code path.
Make the resume code path to use this same extended delay as the reset path.
Stable-dep-of: 3e40aa29d47e ("PCI: Wait for Link before restoring Downstream Buses")
--- drivers/pci/pci-driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci-driver.c +2 -1
@@ -579,7 +579,8 @@ static void pci_pm_default_resume_early(struct pci_dev *pci_dev)static void pci_pm_bridge_power_up_actions (struct pci_dev *pci_dev) { -pci_bridge_wait_for_secondary_bus (pci_dev,"resume" ,PCI_RESET_WAIT ); +pci_bridge_wait_for_secondary_bus (pci_dev,"resume" , +PCIE_RESET_READY_POLL_MS );/* * When powering on a bridge from D3cold, the whole hierarchy may be * powered on into D0uninitialized state, resume them to give them a
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 199/798 PCI/PM: Drop pci_bridge_wait_for_secondary_bus() timeout parameter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
[ Upstream commit e74b2b58ff715ca17bb49c3ad89f665a7150e14b ]
All callers of pci_bridge_wait_for_secondary_bus() supply a timeout of PCIE_RESET_READY_POLL_MS, so drop the parameter. Move the definition of PCIE_RESET_READY_POLL_MS into pci.c, the only user.
[bhelgaas: extracted from
https: //lore.kernel.org/r/[email protected]]
Stable-dep-of: 3e40aa29d47e ("PCI: Wait for Link before restoring Downstream Buses")
--- drivers/pci/pci-driver.c | 4 ++-- drivers/pci/pci.c | 18 ++++++++++++------ drivers/pci/pci.h | 9 +-------- drivers/pci/pcie/dpc.c | 3 +-- 4 files changed, 16 insertions(+), 18 deletions(-)
drivers/pci/pci-driver.c +2 -2
@@ -579,8 +579,8 @@ static void pci_pm_default_resume_early(struct pci_dev *pci_dev)static void pci_pm_bridge_power_up_actions (struct pci_dev *pci_dev) { -pci_bridge_wait_for_secondary_bus (pci_dev,"resume" , -PCIE_RESET_READY_POLL_MS ); +pci_bridge_wait_for_secondary_bus (pci_dev,"resume" ); +/* * When powering on a bridge from D3cold, the whole hierarchy may be * powered on into D0uninitialized state, resume them to give them a
drivers/pci/pci.c +12 -6
@@ -64,6 +64,14 @@ struct pci_pme_device {#define PME_TIMEOUT 1000/* How long between PME checks */ +/* +* Devices may extend the 1 sec period through Request Retry Status +* completions (PCIe r6.0 sec 2.3.1). The spec does not provide an upper +* limit, but 60 sec ought to be enough for any device to become +* responsive. +*/ +#define PCIE_RESET_READY_POLL_MS 60000/* msec */ +static void pci_dev_d3_sleep (struct pci_dev *dev) {unsigned int delay_ms =max (dev->d3hot_delay, pci_pm_d3hot_delay);
@@ -4991,7 +4999,6 @@ static int pci_bus_max_d3cold_delay(const struct pci_bus *bus)* pci_bridge_wait_for_secondary_bus - Wait for secondary bus to be accessible * @dev: PCI bridge * @reset_type: reset type in human-readable form -* @timeout: maximum time to wait for devices on secondary bus (milliseconds) * * Handle necessary delays before access to the devices on the secondary * side of the bridge are permitted after D3cold to D0 transition
@@ -5004,8 +5011,7 @@ static int pci_bus_max_d3cold_delay(const struct pci_bus *bus)* Return 0 on success or -ENOTTY if the first device on the secondary bus * failed to become accessible. */ -int pci_bridge_wait_for_secondary_bus (struct pci_dev *dev,char *reset_type, -int timeout) +int pci_bridge_wait_for_secondary_bus (struct pci_dev *dev,char *reset_type) { struct pci_dev *child __free(pci_dev_put) = NULL;int delay;
@@ -5083,7 +5089,8 @@ int pci_bridge_wait_for_secondary_bus(struct pci_dev *dev, char *reset_type, } } -return pci_dev_wait (child, reset_type, timeout - delay); +return pci_dev_wait (child, reset_type, +PCIE_RESET_READY_POLL_MS - delay); }void pci_reset_secondary_bus (struct pci_dev *dev)
@@ -5120,8 +5127,7 @@ int pci_bridge_secondary_bus_reset(struct pci_dev *dev) {pcibios_reset_secondary_bus (dev); -return pci_bridge_wait_for_secondary_bus (dev,"bus reset" , -PCIE_RESET_READY_POLL_MS ); +return pci_bridge_wait_for_secondary_bus (dev,"bus reset" ); }EXPORT_SYMBOL_GPL (pci_bridge_secondary_bus_reset);
drivers/pci/pci.h +1 -8
@@ -69,12 +69,6 @@ struct pci_cap_saved_state *pci_find_saved_ext_cap(struct pci_dev *dev,* Reset (PCIe r6.0 sec 5.8). */ #define PCI_RESET_WAIT 1000/* msec */ -/* -* Devices may extend the 1 sec period through Request Retry Status completions -* (PCIe r6.0 sec 2.3.1). The spec does not provide an upper limit, but 60 sec -* ought to be enough for any device to become responsive. -*/ -#define PCIE_RESET_READY_POLL_MS 60000/* msec */ void pci_update_current_state (struct pci_dev *dev,pci_power_t state);void pci_refresh_power_state (struct pci_dev *dev);
@@ -99,8 +93,7 @@ void pci_msix_init(struct pci_dev *dev);bool pci_bridge_d3_possible (struct pci_dev *dev);void pci_bridge_d3_update (struct pci_dev *dev);void pci_bridge_reconfigure_ltr (struct pci_dev *dev); -int pci_bridge_wait_for_secondary_bus (struct pci_dev *dev,char *reset_type, -int timeout); +int pci_bridge_wait_for_secondary_bus (struct pci_dev *dev,char *reset_type);static inline void pci_wakeup_event (struct pci_dev *dev) {
drivers/pci/pcie/dpc.c +1 -2
@@ -171,8 +171,7 @@ pci_ers_result_t dpc_reset_link(struct pci_dev *pdev)pci_write_config_word (pdev, cap +PCI_EXP_DPC_STATUS ,PCI_EXP_DPC_STATUS_TRIGGER ); -if (pci_bridge_wait_for_secondary_bus (pdev,"DPC" , -PCIE_RESET_READY_POLL_MS )) { +if (pci_bridge_wait_for_secondary_bus (pdev,"DPC" )) {clear_bit (PCI_DPC_RECOVERED , &pdev->priv_flags); ret =PCI_ERS_RESULT_DISCONNECT ; }else {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 200/798 PCI: Wait for Link before restoring Downstream Buses
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 3e40aa29d47e231a54640addf6a09c1f64c5b63f ]
__pci_reset_bus() calls pci_bridge_secondary_bus_reset() to perform the reset and also waits for the Secondary Bus to become again accessible. __pci_reset_bus() then calls pci_bus_restore_locked() that restores the PCI devices connected to the bus, and if necessary, recursively restores also the subordinate buses and their devices.
The logic in pci_bus_restore_locked() does not take into account that after restoring a device on one level, there might be another Link Downstream that can only start to come up after restore has been performed for its Downstream Port device. That is, the Link may require additional wait until it becomes accessible.
Similarly, pci_slot_restore_locked() lacks wait.
Amend pci_bus_restore_locked() and pci_slot_restore_locked() to wait for the Secondary Bus before recursively performing the restore of that bus.
--- drivers/pci/pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pci/pci.c +6 -2
@@ -5747,8 +5747,10 @@ static void pci_bus_restore_locked(struct pci_bus *bus)list_for_each_entry (dev, &bus->devices, bus_list) {pci_dev_restore (dev); -if (dev->subordinate) +if (dev->subordinate) { +pci_bridge_wait_for_secondary_bus (dev,"bus reset" );pci_bus_restore_locked (dev->subordinate); + } } }
@@ -5782,8 +5784,10 @@ static void pci_slot_restore_locked(struct pci_slot *slot)if (!dev->slot || dev->slot != slot)continue ;pci_dev_restore (dev); -if (dev->subordinate) +if (dev->subordinate) { +pci_bridge_wait_for_secondary_bus (dev,"slot reset" );pci_bus_restore_locked (dev->subordinate); + } } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 201/798 PCI: keystone: Fix if-statement expression in ks_pcie_quirk()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 6188a1c762eb9bbd444f47696eda77a5eae6207a ]
This code accidentally uses && where || was intended. It potentially results in a NULL dereference.
Thus, fix the if-statement expression to use the correct condition.
--- drivers/pci/controller/dwc/pci-keystone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-keystone.c +1 -1
@@ -580,7 +580,7 @@ static void ks_pcie_quirk(struct pci_dev *dev)*/ if (pci_match_id (am6_pci_devids, bridge)) { bridge_dev =pci_get_host_bridge_device (dev); -if (!bridge_dev && !bridge_dev->parent) +if (!bridge_dev || !bridge_dev->parent)return ; ks_pcie =dev_get_drvdata (bridge_dev->parent);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 202/798 clk: qcom: dispcc-sm8250: use special function for Lucid 5LPE PLL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 362be5cbaec2a663eb86b7105313368b4a71fc1e ]
According to msm-5.10 the lucid 5lpe PLLs have require slightly different configuration that trion / lucid PLLs, it doesn't set PLL_UPDATE_BYPASS bit. Add corresponding function and use it for the display clock controller on Qualcomm SM8350 platform.
--- drivers/clk/qcom/clk-alpha-pll.c | 52 ++++++++++++++++++++++++++++++++ drivers/clk/qcom/clk-alpha-pll.h | 2 ++ drivers/clk/qcom/dispcc-sm8250.c | 9 ++++-- 3 files changed, 61 insertions(+), 2 deletions(-)
drivers/clk/qcom/clk-alpha-pll.c +52 -0
@@ -1700,6 +1700,58 @@ const struct clk_ops clk_alpha_pll_agera_ops = { };EXPORT_SYMBOL_GPL (clk_alpha_pll_agera_ops); +/** +* clk_lucid_5lpe_pll_configure - configure the lucid 5lpe pll +* +* @pll: clk alpha pll +* @regmap: register map +* @config: configuration to apply for pll +*/ +void clk_lucid_5lpe_pll_configure (struct clk_alpha_pll *pll,struct regmap *regmap, +const struct alpha_pll_config *config) +{ +/* +* If the bootloader left the PLL enabled it's likely that there are +* RCGs that will lock up if we disable the PLL below. +*/ +if (trion_pll_is_enabled (pll, regmap)) { +pr_debug ("Lucid 5LPE PLL is already enabled, skipping configuration\n" ); +return ; + } + +clk_alpha_pll_write_config (regmap,PLL_L_VAL (pll), config->l); +regmap_write (regmap,PLL_CAL_L_VAL (pll),TRION_PLL_CAL_VAL ); +clk_alpha_pll_write_config (regmap,PLL_ALPHA_VAL (pll), config->alpha); +clk_alpha_pll_write_config (regmap,PLL_CONFIG_CTL (pll), + config->config_ctl_val); +clk_alpha_pll_write_config (regmap,PLL_CONFIG_CTL_U (pll), + config->config_ctl_hi_val); +clk_alpha_pll_write_config (regmap,PLL_CONFIG_CTL_U1 (pll), + config->config_ctl_hi1_val); +clk_alpha_pll_write_config (regmap,PLL_USER_CTL (pll), + config->user_ctl_val); +clk_alpha_pll_write_config (regmap,PLL_USER_CTL_U (pll), + config->user_ctl_hi_val); +clk_alpha_pll_write_config (regmap,PLL_USER_CTL_U1 (pll), + config->user_ctl_hi1_val); +clk_alpha_pll_write_config (regmap,PLL_TEST_CTL (pll), + config->test_ctl_val); +clk_alpha_pll_write_config (regmap,PLL_TEST_CTL_U (pll), + config->test_ctl_hi_val); +clk_alpha_pll_write_config (regmap,PLL_TEST_CTL_U1 (pll), + config->test_ctl_hi1_val); + +/* Disable PLL output */ +regmap_update_bits (regmap,PLL_MODE (pll),PLL_OUTCTRL ,0 ); + +/* Set operation mode to OFF */ +regmap_write (regmap,PLL_OPMODE (pll),PLL_STANDBY ); + +/* Place the PLL in STANDBY mode */ +regmap_update_bits (regmap,PLL_MODE (pll),PLL_RESET_N ,PLL_RESET_N ); +} +EXPORT_SYMBOL_GPL (clk_lucid_5lpe_pll_configure); +static int alpha_pll_lucid_5lpe_enable (struct clk_hw *hw) {struct clk_alpha_pll *pll =to_clk_alpha_pll (hw);
drivers/clk/qcom/clk-alpha-pll.h +2 -0
@@ -178,6 +178,8 @@ void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,void clk_zonda_pll_configure (struct clk_alpha_pll *pll,struct regmap *regmap,const struct alpha_pll_config *config); +void clk_lucid_5lpe_pll_configure (struct clk_alpha_pll *pll,struct regmap *regmap, +const struct alpha_pll_config *config);void clk_lucid_evo_pll_configure (struct clk_alpha_pll *pll,struct regmap *regmap,const struct alpha_pll_config *config); void clk_rivian_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
drivers/clk/qcom/dispcc-sm8250.c +7 -2
@@ -1332,8 +1332,13 @@ static int disp_cc_sm8250_probe(struct platform_device *pdev) disp_cc_pll1.vco_table = lucid_5lpe_vco; } -clk_lucid_pll_configure (&disp_cc_pll0, regmap, &disp_cc_pll0_config); -clk_lucid_pll_configure (&disp_cc_pll1, regmap, &disp_cc_pll1_config); +if (of_device_is_compatible (pdev->dev.of_node,"qcom,sm8350-dispcc" )) { +clk_lucid_5lpe_pll_configure (&disp_cc_pll0, regmap, &disp_cc_pll0_config); +clk_lucid_5lpe_pll_configure (&disp_cc_pll1, regmap, &disp_cc_pll1_config); + }else { +clk_lucid_pll_configure (&disp_cc_pll0, regmap, &disp_cc_pll0_config); +clk_lucid_pll_configure (&disp_cc_pll1, regmap, &disp_cc_pll1_config); + }/* Enable clock gating for MDP clocks */ regmap_update_bits (regmap,0x8000 ,0x10 ,0x10 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 203/798 nvdimm: Fix devs leaks in scan_labels()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Zhijian <[email protected]>
[ Upstream commit 62c2aa6b1f565d2fc1ec11a6e9e8336ce37a6426 ]
scan_labels() leaks memory when label scanning fails and it falls back to just creating a default "seed" namespace for userspace to configure. Root can force the kernel to leak memory.
Allocate the minimum resources unconditionally and release them when unneeded to avoid the memory leak.
A kmemleak reports:
unreferenced object 0xffff88800dda1980 (size 16):
comm "kworker/u10:5", pid 69, jiffies 4294671781 hex dump (first 16 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 0):
[<00000000c5dea560>] __kmalloc+0x32c/0x470
[<000000009ed43c83>] nd_region_register_namespaces+0x6fb/0x1120 [libnvdimm]
[<000000000e07a65c>] nd_region_probe+0xfe/0x210 [libnvdimm]
[<000000007b79ce5f>] nvdimm_bus_probe+0x7a/0x1e0 [libnvdimm]
[<00000000a5f3da2e>] really_probe+0xc6/0x390
[<00000000129e2a69>] __driver_probe_device+0x78/0x150
[<000000002dfed28b>] driver_probe_device+0x1e/0x90
[<00000000e7048de2>] __device_attach_driver+0x85/0x110
[<0000000032dca295>] bus_for_each_drv+0x85/0xe0
[<00000000391c5a7d>] __device_attach+0xbe/0x1e0
[<0000000026dabec0>] bus_probe_device+0x94/0xb0
[<00000000c590d936>] device_add+0x656/0x870
[<000000003d69bfaa>] nd_async_device_register+0xe/0x50 [libnvdimm]
[<000000003f4c52a4>] async_run_entry_fn+0x2e/0x110
[<00000000e201f4b0>] process_one_work+0x1ee/0x600
[<000000006d90d5a9>] worker_thread+0x183/0x350--- drivers/nvdimm/namespace_devs.c | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/nvdimm/namespace_devs.c +17 -17
@@ -1926,12 +1926,16 @@ static int cmp_dpa(const void *a, const void *b)static struct device **scan_labels (struct nd_region *nd_region) {int i, count =0 ; -struct device *dev, **devs =NULL ; +struct device *dev, **devs;struct nd_label_ent *label_ent, *e;struct nd_mapping *nd_mapping = &nd_region->mapping[0 ];struct nvdimm_drvdata *ndd =to_ndd (nd_mapping);resource_size_t map_end = nd_mapping->start + nd_mapping->size -1 ; + devs =kcalloc (2 ,sizeof (dev),GFP_KERNEL ); +if (!devs) +return NULL ; +/* "safe" because create_namespace_pmem() might list_move() label_ent */ list_for_each_entry_safe (label_ent, e, &nd_mapping->labels, list) {struct nd_namespace_label *nd_label = label_ent->label;
@@ -1950,12 +1954,14 @@ static struct device **scan_labels(struct nd_region *nd_region) goto err;if (i < count)continue ; - __devs =kcalloc (count +2 ,sizeof (dev),GFP_KERNEL ); -if (!__devs) - goto err; -memcpy (__devs, devs,sizeof (dev) * count); -kfree (devs); - devs = __devs; +if (count) { + __devs =kcalloc (count +2 ,sizeof (dev),GFP_KERNEL ); +if (!__devs) + goto err; +memcpy (__devs, devs,sizeof (dev) * count); +kfree (devs); + devs = __devs; + } dev =create_namespace_pmem (nd_region, nd_mapping, nd_label);if (IS_ERR (dev)) {
@@ -1982,11 +1988,6 @@ static struct device **scan_labels(struct nd_region *nd_region)/* Publish a zero-sized namespace for userspace to configure. */ nd_mapping_free_labels (nd_mapping); - - devs =kcalloc (2 ,sizeof (dev),GFP_KERNEL ); -if (!devs) - goto err; - nspm =kzalloc (sizeof (*nspm),GFP_KERNEL );if (!nspm) goto err;
@@ -2025,11 +2026,10 @@ static struct device **scan_labels(struct nd_region *nd_region)return devs; err: -if (devs) { -for (i =0 ; devs[i]; i++) -namespace_pmem_release (devs[i]); -kfree (devs); - } +for (i =0 ; devs[i]; i++) +namespace_pmem_release (devs[i]); +kfree (devs); +return NULL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 204/798 PCI: xilinx-nwl: Fix register misspelling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit a437027ae1730b8dc379c75fa0dd7d3036917400 ]
MSIC -> MISC
--- drivers/pci/controller/pcie-xilinx-nwl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +6 -6
@@ -81,8 +81,8 @@#define MSGF_MISC_SR_NON_FATAL_DEV BIT(22)#define MSGF_MISC_SR_FATAL_DEV BIT(23)#define MSGF_MISC_SR_LINK_DOWN BIT(24) -#define MSGF_MSIC_SR_LINK_AUTO_BWIDTH BIT(25) -#define MSGF_MSIC_SR_LINK_BWIDTH BIT(26) +#define MSGF_MISC_SR_LINK_AUTO_BWIDTH BIT(25) +#define MSGF_MISC_SR_LINK_BWIDTH BIT(26)#define MSGF_MISC_SR_MASKALL (MSGF_MISC_SR_RXMSG_AVAIL | \ MSGF_MISC_SR_RXMSG_OVER | \
@@ -97,8 +97,8 @@ MSGF_MISC_SR_NON_FATAL_DEV | \ MSGF_MISC_SR_FATAL_DEV | \ MSGF_MISC_SR_LINK_DOWN | \ - MSGF_MSIC_SR_LINK_AUTO_BWIDTH | \ - MSGF_MSIC_SR_LINK_BWIDTH) + MSGF_MISC_SR_LINK_AUTO_BWIDTH | \ + MSGF_MISC_SR_LINK_BWIDTH)/* Legacy interrupt status mask bits */ #define MSGF_LEG_SR_INTA BIT(0)
@@ -302,10 +302,10 @@ static irqreturn_t nwl_pcie_misc_handler(int irq, void *data)if (misc_stat &MSGF_MISC_SR_FATAL_DEV )dev_err (dev,"Fatal Error Detected\n" ); -if (misc_stat &MSGF_MSIC_SR_LINK_AUTO_BWIDTH ) +if (misc_stat &MSGF_MISC_SR_LINK_AUTO_BWIDTH )dev_info (dev,"Link Autonomous Bandwidth Management Status bit set\n" ); -if (misc_stat &MSGF_MSIC_SR_LINK_BWIDTH ) +if (misc_stat &MSGF_MISC_SR_LINK_BWIDTH )dev_info (dev,"Link Bandwidth Management Status bit set\n" );/* Clear misc interrupt status */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 205/798 PCI: xilinx-nwl: Clean up clock on probe failure/removal
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit cfd67903977b13f63340a4eb5a1cc890994f2c62 ]
Make sure we turn off the clock on probe failure and device removal.
--- drivers/pci/controller/pcie-xilinx-nwl.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +19 -4
@@ -792,6 +792,7 @@ static int nwl_pcie_probe(struct platform_device *pdev)return -ENODEV ; pcie =pci_host_bridge_priv (bridge); +platform_set_drvdata (pdev, pcie); pcie->dev = dev; pcie->ecam_value =NWL_ECAM_VALUE_DEFAULT ;
@@ -815,13 +816,13 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_bridge_init (pcie);if (err) {dev_err (dev,"HW Initialization failed\n" ); -return err; + goto err_clk; } err =nwl_pcie_init_irq_domain (pcie);if (err) {dev_err (dev,"Failed creating IRQ Domain\n" ); -return err; + goto err_clk; } bridge->sysdata = pcie;
@@ -831,11 +832,24 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); -return err; + goto err_clk; } } -return pci_host_probe (bridge); + err =pci_host_probe (bridge); +if (!err) +return 0 ; + +err_clk: +clk_disable_unprepare (pcie->clk); +return err; +} + +static void nwl_pcie_remove (struct platform_device *pdev) +{ +struct nwl_pcie *pcie =platform_get_drvdata (pdev); + +clk_disable_unprepare (pcie->clk); }static struct platform_driver nwl_pcie_driver = {
@@ -845,5 +859,6 @@ static struct platform_driver nwl_pcie_driver = { .of_match_table = nwl_pcie_of_match, }, .probe = nwl_pcie_probe, + .remove_new = nwl_pcie_remove, };builtin_platform_driver (nwl_pcie_driver);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 206/798 RDMA/iwcm: Fix WARNING:at_kernel/workqueue.c:#check_flush_dependency
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Yanjun <[email protected]>
[ Upstream commit 86dfdd8288907f03c18b7fb462e0e232c4f98d89 ]
In the commit aee2424246f9 ("RDMA/iwcm: Fix a use-after-free related to destroying CM IDs"), the function flush_workqueue is invoked to flush the work queue iwcm_wq.
But at that time, the work queue iwcm_wq was created via the function alloc_ordered_workqueue without the flag WQ_MEM_RECLAIM.
Because the current process is trying to flush the whole iwcm_wq, if iwcm_wq doesn't have the flag WQ_MEM_RECLAIM, verify that the current process is not reclaiming memory or running on a workqueue which doesn't have the flag WQ_MEM_RECLAIM as that can break forward-progress guarantee leading to a deadlock.
The call trace is as below:
[ 125.350876][ T1430] Call Trace: [ 125.356281][ T1430] <TASK> [ 125.361285][ T1430] ? __warn (kernel/panic.c:693) [ 125.367640][ T1430] ? check_flush_dependency (kernel/workqueue.c:3706 (discriminator 9)) [ 125.375689][ T1430] ? report_bug (lib/bug.c:180 lib/bug.c:219) [ 125.382505][ T1430] ? handle_bug (arch/x86/kernel/traps.c:239) [ 125.388987][ T1430] ? exc_invalid_op (arch/x86/kernel/traps.c:260 (discriminator 1)) [ 125.395831][ T1430] ? asm_exc_invalid_op (arch/x86/include/asm/idtentry.h:621) [ 125.403125][ T1430] ? check_flush_dependency (kernel/workqueue.c:3706 (discriminator 9)) [ 125.410984][ T1430] ? check_flush_dependency (kernel/workqueue.c:3706 (discriminator 9)) [ 125.418764][ T1430] __flush_workqueue (kernel/workqueue.c:3970) [ 125.426021][ T1430] ? __pfx___might_resched (kernel/sched/core.c:10151) [ 125.433431][ T1430] ? destroy_cm_id (drivers/infiniband/core/iwcm.c:375) iw_cm [ 125.441209][ T1430] ? __pfx___flush_workqueue (kernel/workqueue.c:3910) [ 125.473900][ T1430] ? _raw_spin_lock_irqsave (arch/x86/include/asm/atomic.h:107 include/linux/atomic/atomic-arch-fallback.h:2170 include/linux/atomic/atomic-instrumented.h:1302 include/asm-generic/qspinlock.h:111 include/linux/spinlock.h:187 include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162) [ 125.473909][ T1430] ? __pfx__raw_spin_lock_irqsave (kernel/locking/spinlock.c:161) [ 125.482537][ T1430] _destroy_id (drivers/infiniband/core/cma.c:2044) rdma_cm [ 125.495072][ T1430] nvme_rdma_free_queue (drivers/nvme/host/rdma.c:656 drivers/nvme/host/rdma.c:650) nvme_rdma [ 125.505827][ T1430] nvme_rdma_reset_ctrl_work (drivers/nvme/host/rdma.c:2180) nvme_rdma [ 125.505831][ T1430] process_one_work (kernel/workqueue.c:3231) [ 125.515122][ T1430] worker_thread (kernel/workqueue.c:3306 kernel/workqueue.c:3393) [ 125.515127][ T1430] ? __pfx_worker_thread (kernel/workqueue.c:3339) [ 125.531837][ T1430] kthread (kernel/kthread.c:389) [ 125.539864][ T1430] ? __pfx_kthread (kernel/kthread.c:342) [ 125.550628][ T1430] ret_from_fork (arch/x86/kernel/process.c:147) [ 125.558840][ T1430] ? __pfx_kthread (kernel/kthread.c:342) [ 125.558844][ T1430] ret_from_fork_asm (arch/x86/entry/entry_64.S:257) [ 125.566487][ T1430] </TASK> [ 125.566488][ T1430] ---[ end trace 0000000000000000 ]---
--- drivers/infiniband/core/iwcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/iwcm.c +1 -1
@@ -1191,7 +1191,7 @@ static int __init iw_cm_init(void)if (ret)return ret; - iwcm_wq =alloc_ordered_workqueue ("iw_cm_wq" ,0 ); + iwcm_wq =alloc_ordered_workqueue ("iw_cm_wq" ,WQ_MEM_RECLAIM );if (!iwcm_wq) goto err_alloc;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 207/798 pinctrl: single: fix missing error code in pcs_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Yingliang <[email protected]>
[ Upstream commit cacd8cf79d7823b07619865e994a7916fcc8ae91 ]
If pinctrl_enable() fails in pcs_probe(), it should return the error code.
--- drivers/pinctrl/pinctrl-single.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-single.c +2 -1
@@ -1919,7 +1919,8 @@ static int pcs_probe(struct platform_device *pdev)dev_info (pcs->dev,"%i pins, size %u\n" , pcs->desc.npins, pcs->size); -if (pinctrl_enable (pcs->pctl)) + ret =pinctrl_enable (pcs->pctl); +if (ret) goto free;return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 208/798 RDMA/rtrs: Reset hb_missed_cnt after receiving other traffic from peer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Wang <[email protected]>
[ Upstream commit 3258cbbd86deaa2675e1799bc3d18bd1ef472641 ]
Reset hb_missed_cnt after receiving traffic from other peer, so hb is more robust again high load on host or network.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 3 ++- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +2 -1
@@ -624,6 +624,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc)*/ if (WARN_ON (wc->wr_cqe->done != rtrs_clt_rdma_done))return ; + clt_path->s.hb_missed_cnt =0 ;rtrs_from_imm (be32_to_cpu (wc->ex.imm_data), &imm_type, &imm_payload); if (imm_type == RTRS_IO_RSP_IMM ||
@@ -641,7 +642,6 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc)return rtrs_clt_recv_done (con, wc); }else if (imm_type ==RTRS_HB_ACK_IMM ) {WARN_ON (con->c.cid); - clt_path->s.hb_missed_cnt =0 ; clt_path->s.hb_cur_latency =ktime_sub (ktime_get (), clt_path->s.hb_last_sent);if (clt_path->flags &RTRS_MSG_NEW_RKEY_F )
@@ -668,6 +668,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc)/* * Key invalidations from server side */ + clt_path->s.hb_missed_cnt =0 ;WARN_ON (!(wc->wc_flags &IB_WC_WITH_INVALIDATE || wc->wc_flags &IB_WC_WITH_IMM ));WARN_ON (wc->wr_cqe->done != rtrs_clt_rdma_done);
drivers/infiniband/ulp/rtrs/rtrs-srv.c +1 -0
@@ -1234,6 +1234,7 @@ static void rtrs_srv_rdma_done(struct ib_cq *cq, struct ib_wc *wc)*/ if (WARN_ON (wc->wr_cqe != &io_comp_cqe))return ; + srv_path->s.hb_missed_cnt =0 ; err =rtrs_post_recv_empty (&con->c, &io_comp_cqe);if (err) {rtrs_err (s,"rtrs_post_recv(), err: %d\n" , err);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 209/798 RDMA/rtrs-clt: Reset cid to con_num - 1 to stay in bounds
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Md Haris Iqbal <[email protected]>
[ Upstream commit 3e4289b29e216a55d08a89e126bc0b37cbad9f38 ]
In the function init_conns(), after the create_con() and create_cm() for loop if something fails. In the cleanup for loop after the destroy tag, we access out of bound memory because cid is set to clt_path->s.con_num.
This commits resets the cid to clt_path->s.con_num - 1, to stay in bounds in the cleanup loop later.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +6 -0
@@ -2343,6 +2343,12 @@ static int init_conns(struct rtrs_clt_path *clt_path)if (err) goto destroy; } + +/* +* Set the cid to con_num - 1, since if we fail later, we want to stay in bounds. +*/ + cid = clt_path->s.con_num -1 ; + err =alloc_path_reqs (clt_path);if (err) goto destroy;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 210/798 clk: ti: dra7-atl: Fix leak of of_nodes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lechner <[email protected]>
[ Upstream commit 9d6e9f10e2e031fb7bfb3030a7d1afc561a28fea ]
This fix leaking the of_node references in of_dra7_atl_clk_probe().
The docs for of_parse_phandle_with_args() say that the caller must call of_node_put() on the returned node. This adds the missing of_node_put() to fix the leak.
--- drivers/clk/ti/clk-dra7-atl.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/ti/clk-dra7-atl.c +1 -0
@@ -250,6 +250,7 @@ static int of_dra7_atl_clk_probe(struct platform_device *pdev) } clk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (clk)) {pr_err ("%s: failed to get atl clock %d from provider\n" , __func__, i);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 211/798 nfsd: remove unneeded EEXIST error check in nfsd_do_file_acquire
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit 81a95c2b1d605743220f28db04b8da13a65c4059 ]
Given that we do the search and insertion while holding the i_lock, I don't think it's possible for us to get EEXIST here. Remove this case.
--- fs/nfsd/filecache.c | 2 -- 1 file changed, 2 deletions(-)
fs/nfsd/filecache.c +0 -2
@@ -1041,8 +1041,6 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,if (likely (ret ==0 )) goto open_file; -if (ret == -EEXIST ) - goto retry;trace_nfsd_file_insert_err (rqstp, inode, may_flags, ret); status = nfserr_jukebox; goto construction_err;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 212/798 nfsd: fix refcount leak when file is unhashed after being found
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit 8a7926176378460e0d91e02b03f0ff20a8709a60 ]
If we wait_for_construction and find that the file is no longer hashed, and we're going to retry the open, the old nfsd_file reference is currently leaked. Put the reference before retrying.
--- fs/nfsd/filecache.c | 1 + 1 file changed, 1 insertion(+)
fs/nfsd/filecache.c +1 -0
@@ -1055,6 +1055,7 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, status = nfserr_jukebox; goto construction_err; } +nfsd_file_put (nf); open_retry = false; goto retry; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 213/798 pinctrl: mvebu: Use devm_platform_get_and_ioremap_resource()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yangtao Li <[email protected]>
[ Upstream commit 2d357f25663ddfef47ffe26da21155302153d168 ]
Convert platform_get_resource(), devm_ioremap_resource() to a single call to devm_platform_get_and_ioremap_resource(), as this is exactly what this function does.
Stable-dep-of: c25478419f6f ("pinctrl: mvebu: Fix devinit_dove_pinctrl_probe function")
--- drivers/pinctrl/mvebu/pinctrl-dove.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pinctrl/mvebu/pinctrl-dove.c +1 -2
@@ -784,8 +784,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev) }clk_prepare_enable (clk); - mpp_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - base =devm_ioremap_resource (&pdev->dev, mpp_res); + base =devm_platform_get_and_ioremap_resource (pdev,0 , &mpp_res);if (IS_ERR (base))return PTR_ERR (base);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 214/798 pinctrl: mvebu: Fix devinit_dove_pinctrl_probe function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Jianzheng <[email protected]>
[ Upstream commit c25478419f6fd3f74c324a21ec007cf14f2688d7 ]
When an error occurs during the execution of the function __devinit_dove_pinctrl_probe, the clk is not properly disabled.
Fix this by calling clk_disable_unprepare before return.
--- drivers/pinctrl/mvebu/pinctrl-dove.c | 42 +++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-)
drivers/pinctrl/mvebu/pinctrl-dove.c +29 -13
@@ -769,7 +769,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev)of_match_device (dove_pinctrl_of_match, &pdev->dev);struct mvebu_mpp_ctrl_data *mpp_data;void __iomem *base; -int i; +int i, ret; pdev->dev.platform_data = (void *)match->data;
@@ -785,13 +785,17 @@ static int dove_pinctrl_probe(struct platform_device *pdev)clk_prepare_enable (clk); base =devm_platform_get_and_ioremap_resource (pdev,0 , &mpp_res); -if (IS_ERR (base)) -return PTR_ERR (base); +if (IS_ERR (base)) { + ret =PTR_ERR (base); + goto err_probe; + } mpp_data =devm_kcalloc (&pdev->dev, dove_pinctrl_info.ncontrols,sizeof (*mpp_data),GFP_KERNEL ); -if (!mpp_data) -return -ENOMEM ; +if (!mpp_data) { + ret = -ENOMEM ; + goto err_probe; + } dove_pinctrl_info.control_data = mpp_data;for (i =0 ; i <ARRAY_SIZE (dove_mpp_controls); i++)
@@ -810,8 +814,10 @@ static int dove_pinctrl_probe(struct platform_device *pdev) } mpp4_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (mpp4_base)) -return PTR_ERR (mpp4_base); +if (IS_ERR (mpp4_base)) { + ret =PTR_ERR (mpp4_base); + goto err_probe; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,2 );if (!res) {
@@ -822,8 +828,10 @@ static int dove_pinctrl_probe(struct platform_device *pdev) } pmu_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (pmu_base)) -return PTR_ERR (pmu_base); +if (IS_ERR (pmu_base)) { + ret =PTR_ERR (pmu_base); + goto err_probe; + } gconfmap =syscon_regmap_lookup_by_compatible ("marvell,dove-global-config" );if (IS_ERR (gconfmap)) {
@@ -833,12 +841,17 @@ static int dove_pinctrl_probe(struct platform_device *pdev)adjust_resource (&fb_res, (mpp_res->start &INT_REGS_MASK ) +GC_REGS_OFFS ,0x14 ); gc_base =devm_ioremap_resource (&pdev->dev, &fb_res); -if (IS_ERR (gc_base)) -return PTR_ERR (gc_base); +if (IS_ERR (gc_base)) { + ret =PTR_ERR (gc_base); + goto err_probe; + } + gconfmap =devm_regmap_init_mmio (&pdev->dev, gc_base, &gc_regmap_config); -if (IS_ERR (gconfmap)) -return PTR_ERR (gconfmap); +if (IS_ERR (gconfmap)) { + ret =PTR_ERR (gconfmap); + goto err_probe; + } }/* Warn on any missing DT resource */
@@ -846,6 +859,9 @@ static int dove_pinctrl_probe(struct platform_device *pdev)dev_warn (&pdev->dev,FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n" );return mvebu_pinctrl_probe (pdev); +err_probe: +clk_disable_unprepare (clk); +return ret; }static struct platform_driver dove_pinctrl_driver = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 215/798 IB/core: Fix ib_cache_setup_one error flow cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 1403c8b14765eab805377dd3b75e96ace8747aed ]
When ib_cache_update return an error, we exit ib_cache_setup_one instantly with no proper cleanup, even though before this we had already successfully done gid_table_setup_one, that results in the kernel WARN below.
Do proper cleanup using gid_table_cleanup_one before returning the err in order to fix the issue.
WARNING: CPU: 4 PID: 922 at drivers/infiniband/core/cache.c:806 gid_table_release_one+0x181/0x1a0 Modules linked in: CPU: 4 UID: 0 PID: 922 Comm: c_repro Not tainted 6.11.0-rc1+ #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:gid_table_release_one+0x181/0x1a0 Code: 44 8b 38 75 0c e8 2f cb 34 ff 4d 8b b5 28 05 00 00 e8 23 cb 34 ff 44 89 f9 89 da 4c 89 f6 48 c7 c7 d0 58 14 83 e8 4f de 21 ff <0f> 0b 4c 8b 75 30 e9 54 ff ff ff 48 8 3 c4 10 5b 5d 41 5c 41 5d 41 RSP: 0018:ffffc90002b835b0 EFLAGS: 00010286 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff811c8527 RDX: 0000000000000000 RSI: ffffffff811c8534 RDI: 0000000000000001 RBP: ffff8881011b3d00 R08: ffff88810b3abe00 R09: 205d303839303631 R10: 666572207972746e R11: 72746e6520444947 R12: 0000000000000001 R13: ffff888106390000 R14: ffff8881011f2110 R15: 0000000000000001 FS: 00007fecc3b70800(0000) GS:ffff88813bd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000340 CR3: 000000010435a001 CR4: 00000000003706b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> ? show_regs+0x94/0xa0 ? __warn+0x9e/0x1c0 ? gid_table_release_one+0x181/0x1a0 ? report_bug+0x1f9/0x340 ? gid_table_release_one+0x181/0x1a0 ? handle_bug+0xa2/0x110 ? exc_invalid_op+0x31/0xa0 ? asm_exc_invalid_op+0x16/0x20 ? __warn_printk+0xc7/0x180 ? __warn_printk+0xd4/0x180 ? gid_table_release_one+0x181/0x1a0 ib_device_release+0x71/0xe0 ? __pfx_ib_device_release+0x10/0x10 device_release+0x44/0xd0 kobject_put+0x135/0x3d0 put_device+0x20/0x30 rxe_net_add+0x7d/0xa0 rxe_newlink+0xd7/0x190 nldev_newlink+0x1b0/0x2a0 ? __pfx_nldev_newlink+0x10/0x10 rdma_nl_rcv_msg+0x1ad/0x2e0 rdma_nl_rcv_skb.constprop.0+0x176/0x210 netlink_unicast+0x2de/0x400 netlink_sendmsg+0x306/0x660 __sock_sendmsg+0x110/0x120 ____sys_sendmsg+0x30e/0x390 ___sys_sendmsg+0x9b/0xf0 ? kstrtouint+0x6e/0xa0 ? kstrtouint_from_user+0x7c/0xb0 ? get_pid_task+0xb0/0xd0 ? proc_fail_nth_write+0x5b/0x140 ? __fget_light+0x9a/0x200 ? preempt_count_add+0x47/0xa0 __sys_sendmsg+0x61/0xd0 do_syscall_64+0x50/0x110 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- drivers/infiniband/core/cache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/core/cache.c +3 -1
@@ -1629,8 +1629,10 @@ int ib_cache_setup_one(struct ib_device *device) rdma_for_each_port (device, p) { err =ib_cache_update (device, p, true, true, true); -if (err) +if (err) { +gid_table_cleanup_one (device);return err; + } }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 216/798 PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandra Diupina <[email protected]>
[ Upstream commit c500a86693a126c9393e602741e348f80f1b0fc5 ]
Within kirin_pcie_parse_port(), the pcie->num_slots is compared to pcie->gpio_id_reset size (MAX_PCI_SLOTS) which is correct and would lead to an overflow.
Thus, fix condition to pcie->num_slots + 1 >= MAX_PCI_SLOTS and move pcie->num_slots increment below the if-statement to avoid out-of-bounds array access.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/pci/controller/dwc/pcie-kirin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-kirin.c +2 -2
@@ -416,12 +416,12 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,if (pcie->gpio_id_reset[i] <0 )continue ; - pcie->num_slots++; -if (pcie->num_slots >MAX_PCI_SLOTS ) { +if (pcie->num_slots +1 >=MAX_PCI_SLOTS ) {dev_err (dev,"Too many PCI slots!\n" ); ret = -EINVAL ; goto put_node; } + pcie->num_slots++; ret =of_pci_get_devfn (child);if (ret <0 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 217/798 RDMA/erdma: Return QP state in erdma_query_qp
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng Xu <[email protected]>
[ Upstream commit e77127ff6416b17e0b3e630ac46ee5c9a6570f57 ]
Fix qp_state and cur_qp_state to return correct values in struct ib_qp_attr.
--- drivers/infiniband/hw/erdma/erdma_verbs.c | 25 ++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/infiniband/hw/erdma/erdma_verbs.c +24 -1
@@ -1292,11 +1292,31 @@ int erdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,return ret; } +static enum ib_qp_state query_qp_state (struct erdma_qp *qp) +{ +switch (qp->attrs.state) { +case ERDMA_QP_STATE_IDLE : +return IB_QPS_INIT ; +case ERDMA_QP_STATE_RTR : +return IB_QPS_RTR ; +case ERDMA_QP_STATE_RTS : +return IB_QPS_RTS ; +case ERDMA_QP_STATE_CLOSING : +return IB_QPS_ERR ; +case ERDMA_QP_STATE_TERMINATE : +return IB_QPS_ERR ; +case ERDMA_QP_STATE_ERROR : +return IB_QPS_ERR ; +default : +return IB_QPS_ERR ; + } +} +int erdma_query_qp (struct ib_qp *ibqp,struct ib_qp_attr *qp_attr,int qp_attr_mask,struct ib_qp_init_attr *qp_init_attr) { -struct erdma_qp *qp;struct erdma_dev *dev; +struct erdma_qp *qp;if (ibqp && qp_attr && qp_init_attr) { qp =to_eqp (ibqp);
@@ -1323,6 +1343,9 @@ int erdma_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, qp_init_attr->cap = qp_attr->cap; + qp_attr->qp_state =query_qp_state (qp); + qp_attr->cur_qp_state =query_qp_state (qp); +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 218/798 watchdog: imx_sc_wdt: Dont disable WDT in suspend
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Blixt <[email protected]>
[ Upstream commit 2d9d6d300fb0a4ae4431bb308027ac9385746d42 ]
Parts of the suspend and resume chain is left unprotected if we disable the WDT here.
Quoted 1 line
From experiments we can see that the SCU disables and re-enables the WDT
when we enter and leave suspend to ram. By not touching the WDT here we are protected by the WDT all the way to the SCU.
--- drivers/watchdog/imx_sc_wdt.c | 24 ------------------------ 1 file changed, 24 deletions(-)
drivers/watchdog/imx_sc_wdt.c +0 -24
@@ -213,29 +213,6 @@ static int imx_sc_wdt_probe(struct platform_device *pdev)return devm_watchdog_register_device (dev, wdog); } -static int __maybe_unused imx_sc_wdt_suspend (struct device *dev) -{ -struct imx_sc_wdt_device *imx_sc_wdd =dev_get_drvdata (dev); - -if (watchdog_active (&imx_sc_wdd->wdd)) -imx_sc_wdt_stop (&imx_sc_wdd->wdd); - -return 0 ; -} - -static int __maybe_unused imx_sc_wdt_resume (struct device *dev) -{ -struct imx_sc_wdt_device *imx_sc_wdd =dev_get_drvdata (dev); - -if (watchdog_active (&imx_sc_wdd->wdd)) -imx_sc_wdt_start (&imx_sc_wdd->wdd); - -return 0 ; -} - -static SIMPLE_DEV_PM_OPS(imx_sc_wdt_pm_ops, - imx_sc_wdt_suspend, imx_sc_wdt_resume); -static const struct of_device_id imx_sc_wdt_dt_ids[] = { { .compatible ="fsl,imx-sc-wdt" , }, {/* sentinel */ }
@@ -247,7 +224,6 @@ static struct platform_driver imx_sc_wdt_driver = { .driver = { .name = "imx-sc-wdt", .of_match_table = imx_sc_wdt_dt_ids, - .pm = &imx_sc_wdt_pm_ops, }, };module_platform_driver (imx_sc_wdt_driver);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 219/798 RDMA/hns: Dont modify rq next block addr in HIP09 QPC
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 6928d264e328e0cb5ee7663003a6e46e4cba0a7e ]
The field 'rq next block addr' in QPC can be updated by driver only on HIP08. On HIP09 HW updates this field while driver is not allowed.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +8 -6
@@ -4572,12 +4572,14 @@ static int config_qp_rq_buf(struct hns_roce_dev *hr_dev, upper_32_bits(to_hr_hw_page_addr(mtts[0])));hr_reg_clear (qpc_mask,QPC_RQ_CUR_BLK_ADDR_H ); - context->rq_nxt_blk_addr =cpu_to_le32 (to_hr_hw_page_addr (mtts[1 ])); - qpc_mask->rq_nxt_blk_addr =0 ; - -hr_reg_write (context,QPC_RQ_NXT_BLK_ADDR_H , -upper_32_bits (to_hr_hw_page_addr (mtts[1 ]))); -hr_reg_clear (qpc_mask,QPC_RQ_NXT_BLK_ADDR_H ); +if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08 ) { + context->rq_nxt_blk_addr = +cpu_to_le32 (to_hr_hw_page_addr (mtts[1 ])); + qpc_mask->rq_nxt_blk_addr =0 ; +hr_reg_write (context,QPC_RQ_NXT_BLK_ADDR_H , +upper_32_bits (to_hr_hw_page_addr (mtts[1 ]))); +hr_reg_clear (qpc_mask,QPC_RQ_NXT_BLK_ADDR_H ); + }return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 220/798 RDMA/hns: Fix Use-After-Free of rsv_qp on HIP08
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: wenglianfa <[email protected]>
[ Upstream commit fd8489294dd2beefb70f12ec4f6132aeec61a4d0 ]
Currently rsv_qp is freed before ib_unregister_device() is called on HIP08. During the time interval, users can still dereg MR and rsv_qp will be used in this process, leading to a UAF. Move the release of rsv_qp after calling ib_unregister_device() to fix it.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -3
@@ -3058,6 +3058,9 @@ static int hns_roce_v2_init(struct hns_roce_dev *hr_dev)static void hns_roce_v2_exit (struct hns_roce_dev *hr_dev) { +if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08 ) +free_mr_exit (hr_dev); +hns_roce_function_clear (hr_dev);if (!hr_dev->is_vf)
@@ -6935,9 +6938,6 @@ static void __hns_roce_hw_v2_uninit_instance(struct hnae3_handle *handle, hr_dev->state =HNS_ROCE_DEVICE_STATE_UNINIT ;hns_roce_handle_device_err (hr_dev); -if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08 ) -free_mr_exit (hr_dev); -hns_roce_exit (hr_dev);kfree (hr_dev->priv);ib_dealloc_device (&hr_dev->ib_dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 221/798 RDMA/hns: Fix the overflow risk of hem_list_calc_ba_range()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: wenglianfa <[email protected]>
[ Upstream commit d586628b169d14bbf36be64d2b3ec9d9d2fe0432 ]
The max value of 'unit' and 'hop_num' is 2^24 and 2, so the value of 'step' may exceed the range of u32. Change the type of 'step' to u64.
--- drivers/infiniband/hw/hns/hns_roce_hem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hem.c +6 -6
@@ -1082,9 +1082,9 @@ static bool hem_list_is_bottom_bt(int hopnum, int bt_level)* @bt_level: base address table level * @unit: ba entries per bt page */ -static u32 hem_list_calc_ba_range (int hopnum,int bt_level,int unit) +static u64 hem_list_calc_ba_range (int hopnum,int bt_level,int unit) { -u32 step; +u64 step;int max;int i;
@@ -1120,7 +1120,7 @@ int hns_roce_hem_list_calc_root_ba(const struct hns_roce_buf_region *regions, {struct hns_roce_buf_region *r;int total =0 ; -int step; +u64 step;int i;for (i =0 ; i < region_cnt; i++) {
@@ -1151,7 +1151,7 @@ static int hem_list_alloc_mid_bt(struct hns_roce_dev *hr_dev,int ret =0 ;int max_ofs;int level; -u32 step; +u64 step;int end;if (hopnum <=1 )
@@ -1188,7 +1188,7 @@ static int hem_list_alloc_mid_bt(struct hns_roce_dev *hr_dev, } start_aligned = (distance / step) * step + r->offset; - end =min_t (int, start_aligned + step -1 , max_ofs); + end =min_t (u64, start_aligned + step -1 , max_ofs); cur =hem_list_alloc_item (hr_dev, start_aligned, end, unit, true);if (!cur) {
@@ -1277,7 +1277,7 @@ static int setup_middle_bt(struct hns_roce_dev *hr_dev, void *cpu_base,struct hns_roce_hem_item *hem, *temp_hem;int total =0 ;int offset; -int step; +u64 step; step =hem_list_calc_ba_range (r->hopnum,1 , unit);if (step <1 )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 222/798 RDMA/hns: Fix spin_unlock_irqrestore() called with IRQs enabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengchang Tang <[email protected]>
[ Upstream commit 74d315b5af180220d561684d15897730135733a6 ]
Fix missuse of spin_lock_irq()/spin_unlock_irq() when spin_lock_irqsave()/spin_lock_irqrestore() was hold.
This was discovered through the lock debugging, and the corresponding log is as follows:
raw_local_irq_restore() called with IRQs enabled
WARNING: CPU: 96 PID: 2074 at kernel/locking/irqflag-debug.c:10 warn_bogus_irq_restore+0x30/0x40 ... Call trace: warn_bogus_irq_restore+0x30/0x40 _raw_spin_unlock_irqrestore+0x84/0xc8 add_qp_to_list+0x11c/0x148 [hns_roce_hw_v2] hns_roce_create_qp_common.constprop.0+0x240/0x780 [hns_roce_hw_v2] hns_roce_create_qp+0x98/0x160 [hns_roce_hw_v2] create_qp+0x138/0x258 ib_create_qp_kernel+0x50/0xe8 create_mad_qp+0xa8/0x128 ib_mad_port_open+0x218/0x448 ib_mad_init_device+0x70/0x1f8 add_client_context+0xfc/0x220 enable_device_and_get+0xd0/0x140 ib_register_device.part.0+0xf4/0x1c8 ib_register_device+0x34/0x50 hns_roce_register_device+0x174/0x3d0 [hns_roce_hw_v2] hns_roce_init+0xfc/0x2c0 [hns_roce_hw_v2] __hns_roce_hw_v2_init_instance+0x7c/0x1d0 [hns_roce_hw_v2] hns_roce_hw_v2_init_instance+0x9c/0x180 [hns_roce_hw_v2]
--- drivers/infiniband/hw/hns/hns_roce_qp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +8 -8
@@ -1443,19 +1443,19 @@ void hns_roce_lock_cqs(struct hns_roce_cq *send_cq, struct hns_roce_cq *recv_cq)__acquire (&send_cq->lock);__acquire (&recv_cq->lock); }else if (unlikely (send_cq !=NULL && recv_cq ==NULL )) { -spin_lock_irq (&send_cq->lock); +spin_lock (&send_cq->lock);__acquire (&recv_cq->lock); }else if (unlikely (send_cq ==NULL && recv_cq !=NULL )) { -spin_lock_irq (&recv_cq->lock); +spin_lock (&recv_cq->lock);__acquire (&send_cq->lock); }else if (send_cq == recv_cq) { -spin_lock_irq (&send_cq->lock); +spin_lock (&send_cq->lock);__acquire (&recv_cq->lock); }else if (send_cq->cqn < recv_cq->cqn) { -spin_lock_irq (&send_cq->lock); +spin_lock (&send_cq->lock);spin_lock_nested (&recv_cq->lock,SINGLE_DEPTH_NESTING ); }else { -spin_lock_irq (&recv_cq->lock); +spin_lock (&recv_cq->lock);spin_lock_nested (&send_cq->lock,SINGLE_DEPTH_NESTING ); } }
@@ -1475,13 +1475,13 @@ void hns_roce_unlock_cqs(struct hns_roce_cq *send_cq,spin_unlock (&recv_cq->lock); }else if (send_cq == recv_cq) {__release (&recv_cq->lock); -spin_unlock_irq (&send_cq->lock); +spin_unlock (&send_cq->lock); }else if (send_cq->cqn < recv_cq->cqn) {spin_unlock (&recv_cq->lock); -spin_unlock_irq (&send_cq->lock); +spin_unlock (&send_cq->lock); }else {spin_unlock (&send_cq->lock); -spin_unlock_irq (&recv_cq->lock); +spin_unlock (&recv_cq->lock); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 223/798 RDMA/hns: Fix VF triggering PF reset in abnormal interrupt handler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 4321feefa5501a746ebf6a7d8b59e6b955ae1860 ]
In abnormal interrupt handler, a PF reset will be triggered even if the device is a VF. It should be a VF reset.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +5 -2
@@ -6227,6 +6227,7 @@ static irqreturn_t abnormal_interrupt_basic(struct hns_roce_dev *hr_dev,struct pci_dev *pdev = hr_dev->pci_dev;struct hnae3_ae_dev *ae_dev =pci_get_drvdata (pdev);const struct hnae3_ae_ops *ops = ae_dev->ops; +enum hnae3_reset_type reset_type;irqreturn_t int_work =IRQ_NONE ;u32 int_en;
@@ -6238,10 +6239,12 @@ static irqreturn_t abnormal_interrupt_basic(struct hns_roce_dev *hr_dev,roce_write (hr_dev,ROCEE_VF_ABN_INT_ST_REG ,1 <<HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S ); + reset_type = hr_dev->is_vf ? +HNAE3_VF_FUNC_RESET :HNAE3_FUNC_RESET ; +/* Set reset level for reset_event() */ if (ops->set_default_reset_request) - ops->set_default_reset_request (ae_dev, -HNAE3_FUNC_RESET ); + ops->set_default_reset_request (ae_dev, reset_type);if (ops->reset_event) ops->reset_event (pdev,NULL );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 224/798 RDMA/hns: Fix 1bit-ECC recovery address in non-4K OS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengchang Tang <[email protected]>
[ Upstream commit ce196f6297c7f3ab7780795e40efd6c521f60c8b ]
The 1bit-ECC recovery address read from HW only contain bits 64:12, so it should be fixed left-shifted 12 bits when used.
Currently, the driver will shift the address left by PAGE_SHIFT when used, which is wrong in non-4K OS.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -1
@@ -6314,7 +6314,7 @@ static u64 fmea_get_ram_res_addr(u32 res_type, __le64 *data) res_type == ECC_RESOURCE_SCCC)return le64_to_cpu (*data); -return le64_to_cpu (*data) <<PAGE_SHIFT ; +return le64_to_cpu (*data) <<HNS_HW_PAGE_SHIFT ; } static int fmea_recover_others(struct hns_roce_dev *hr_dev, u32 res_type,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 225/798 RDMA/hns: Optimize hem allocation performance
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit fe51f6254d81f5a69c31df16353d6539b2b51630 ]
When allocating MTT hem, for each hop level of each hem that is being allocated, the driver iterates the hem list to find out whether the bt page has been allocated in this hop level. If not, allocate a new one and splice it to the list. The time complexity is O(n^2) in worst cases.
Currently the allocation for-loop uses 'unit' as the step size. This actually has taken into account the reuse of last-hop-level MTT bt pages by multiple buffer pages. Thus pages of last hop level will never have been allocated, so there is no need to iterate the hem list in last hop level.
Removing this unnecessary iteration can reduce the time complexity to O(n).
--- drivers/infiniband/hw/hns/hns_roce_hem.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hem.c +6 -4
@@ -1175,10 +1175,12 @@ static int hem_list_alloc_mid_bt(struct hns_roce_dev *hr_dev,/* config L1 bt to last bt and link them to corresponding parent */ for (level =1 ; level < hopnum; level++) { - cur =hem_list_search_item (&mid_bt[level], offset); -if (cur) { - hem_ptrs[level] = cur; -continue ; +if (!hem_list_is_bottom_bt (hopnum, level)) { + cur =hem_list_search_item (&mid_bt[level], offset); +if (cur) { + hem_ptrs[level] = cur; +continue ; + } } step =hem_list_calc_ba_range (hopnum, level, unit);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 226/798 riscv: Fix fp alignment bug in perf_callchain_user()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 22ab08955ea13be04a8efd20cc30890e0afaa49c ]
The standard RISC-V calling convention said:
"The stack grows downward and the stack pointer is always kept 16-byte aligned".
So perf_callchain_user() should check whether 16-byte aligned for fp.
--- arch/riscv/kernel/perf_callchain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/perf_callchain.c +1 -1
@@ -62,7 +62,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,perf_callchain_store (entry, regs->epc); fp =user_backtrace (entry, fp, regs->ra); -while (fp && !(fp &0x3 ) && entry->nr < entry->max_stack) +while (fp && !(fp &0x7 ) && entry->nr < entry->max_stack) fp =user_backtrace (entry, fp,0 ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 227/798 RDMA/cxgb4: Added NULL check for lookup_atid
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Lobanov <[email protected]>
[ Upstream commit e766e6a92410ca269161de059fff0843b8ddd65f ]
The lookup_atid() function can return NULL if the ATID is invalid or does not exist in the identifier table, which could lead to dereferencing a null pointer without a check in the act_establish() and act_open_rpl() functions. Add a NULL check to prevent null pointer dereferencing.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/hw/cxgb4/cm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/hw/cxgb4/cm.c +5 -0
@@ -1222,6 +1222,8 @@ static int act_establish(struct c4iw_dev *dev, struct sk_buff *skb)int ret; ep =lookup_atid (t, atid); +if (!ep) +return -EINVAL ;pr_debug ("ep %p tid %u snd_isn %u rcv_isn %u\n" , ep, tid,be32_to_cpu (req->snd_isn),be32_to_cpu (req->rcv_isn));
@@ -2279,6 +2281,9 @@ static int act_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)int ret =0 ; ep =lookup_atid (t, atid); +if (!ep) +return -EINVAL ; + la = (struct sockaddr_in *)&ep->com.local_addr; ra = (struct sockaddr_in *)&ep->com.remote_addr; la6 = (struct sockaddr_in6 *)&ep->com.local_addr;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 228/798 RDMA/irdma: fix error message in irdma_modify_qp_roce()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaliy Shevtsov <[email protected]>
[ Upstream commit 9f0eafe86ea0a589676209d0cff1a1ed49a037d3 ]
Use a correct field max_dest_rd_atomic instead of max_rd_atomic for the error output.
Found by Linux Verification Center (linuxtesting.org) with Svace.
--- drivers/infiniband/hw/irdma/verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +1 -1
@@ -1324,7 +1324,7 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,if (attr->max_dest_rd_atomic > dev->hw_attrs.max_hw_ird) {ibdev_err (&iwdev->ibdev,"rd_atomic = %d, above max_hw_ird=%d\n" , - attr->max_rd_atomic, + attr->max_dest_rd_atomic, dev->hw_attrs.max_hw_ird);return -EINVAL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 229/798 ntb: intel: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit e229897d373a87ee09ec5cc4ecd4bb2f895fc16b ]
The debugfs_create_dir() function returns error pointers. It never returns NULL. So use IS_ERR() to check it.
--- drivers/ntb/hw/intel/ntb_hw_gen1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/hw/intel/ntb_hw_gen1.c +1 -1
@@ -778,7 +778,7 @@ static void ndev_init_debugfs(struct intel_ntb_dev *ndev) ndev->debugfs_dir =debugfs_create_dir (pci_name (ndev->ntb.pdev), debugfs_dir); -if (!ndev->debugfs_dir) +if (IS_ERR (ndev->debugfs_dir)) ndev->debugfs_info =NULL ;else ndev->debugfs_info =
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 230/798 ntb_perf: Fix printk format
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Hawking <[email protected]>
[ Upstream commit 1501ae7479c8d0f66efdbfdc9ae8d6136cefbd37 ]
The correct printk format is %pa or %pap, but not %pa[p].
--- drivers/ntb/test/ntb_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/test/ntb_perf.c +1 -1
@@ -1227,7 +1227,7 @@ static ssize_t perf_dbgfs_read_info(struct file *filep, char __user *ubuf, "\tOut buffer addr 0x%pK\n", peer->outbuf); pos +=scnprintf (buf + pos, buf_size - pos, -"\tOut buff phys addr %pa[p]\n" , &peer->out_phys_addr); +"\tOut buff phys addr %pap\n" , &peer->out_phys_addr); pos +=scnprintf (buf + pos, buf_size - pos,"\tOut buffer size %pa\n" , &peer->outbuf_size);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 231/798 ntb: Force physically contiguous allocation of rx ring buffers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 061a785a114f159e990ea8ed8d1b7dca4b41120f ]
Physical addresses under IOVA on x86 platform are mapped contiguously as a side effect before the patch that removed CONFIG_DMA_REMAP. The NTB rx buffer ring is a single chunk DMA buffer that is allocated against the NTB PCI device. If the receive side is using a DMA device, then the buffers are remapped against the DMA device before being submitted via the dmaengine API. This scheme becomes a problem when the physical memory is discontiguous. When dma_map_page() is called on the kernel virtual address from the dma_alloc_coherent() call, the new IOVA mapping no longer points to all the physical memory allocated due to being discontiguous. Change dma_alloc_coherent() to dma_alloc_attrs() in order to force DMA_ATTR_FORCE_CONTIGUOUS attribute. This is the best fix for the circumstance. A potential future solution may be having the DMA mapping API providing a way to alias an existing IOVA mapping to a new device perhaps.
This fix is not to fix the patch pointed to by the fixes tag, but to fix the issue arised in the ntb_transport driver on x86 platforms after the said patch is applied.
--- drivers/ntb/ntb_transport.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/ntb/ntb_transport.c +18 -5
@@ -807,16 +807,29 @@ static void ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw) }static int ntb_alloc_mw_buffer (struct ntb_transport_mw *mw, -struct device *dma_dev,size_t align) +struct device *ntb_dev,size_t align) {dma_addr_t dma_addr;void *alloc_addr, *virt_addr;int rc; - alloc_addr =dma_alloc_coherent (dma_dev, mw->alloc_size, - &dma_addr,GFP_KERNEL ); +/* +* The buffer here is allocated against the NTB device. The reason to +* use dma_alloc_*() call is to allocate a large IOVA contiguous buffer +* backing the NTB BAR for the remote host to write to. During receive +* processing, the data is being copied out of the receive buffer to +* the kernel skbuff. When a DMA device is being used, dma_map_page() +* is called on the kvaddr of the receive buffer (from dma_alloc_*()) +* and remapped against the DMA device. It appears to be a double +* DMA mapping of buffers, but first is mapped to the NTB device and +* second is to the DMA device. DMA_ATTR_FORCE_CONTIGUOUS is necessary +* in order for the later dma_map_page() to not fail. +*/ + alloc_addr =dma_alloc_attrs (ntb_dev, mw->alloc_size, + &dma_addr,GFP_KERNEL , +DMA_ATTR_FORCE_CONTIGUOUS );if (!alloc_addr) { -dev_err (dma_dev,"Unable to alloc MW buff of size %zu\n" , +dev_err (ntb_dev,"Unable to alloc MW buff of size %zu\n" , mw->alloc_size);return -ENOMEM ; }
@@ -845,7 +858,7 @@ static int ntb_alloc_mw_buffer(struct ntb_transport_mw *mw,return 0 ; err: -dma_free_coherent (dma_dev, mw->alloc_size, alloc_addr, dma_addr); +dma_free_coherent (ntb_dev, mw->alloc_size, alloc_addr, dma_addr);return rc; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 232/798 nfsd: call cache_put if xdr_reserve_space returns NULL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guoqing Jiang <[email protected]>
[ Upstream commit d078cbf5c38de83bc31f83c47dcd2184c04a50c7 ]
If not enough buffer space available, but idmap_lookup has triggered lookup_fn which calls cache_get and returns successfully. Then we missed to call cache_put here which pairs with cache_get.
--- fs/nfsd/nfs4idmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
fs/nfsd/nfs4idmap.c +9 -4
@@ -581,6 +581,7 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr, .id = id, .type = type, }; +__be32 status = nfs_ok;__be32 *p;int ret;struct nfsd_net *nn =net_generic (SVC_NET (rqstp), nfsd_net_id);
@@ -593,12 +594,16 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr,return nfserrno (ret); ret =strlen (item->name);WARN_ON_ONCE (ret >IDMAP_NAMESZ ); + p =xdr_reserve_space (xdr, ret +4 ); -if (!p) -return nfserr_resource; - p =xdr_encode_opaque (p, item->name, ret); +if (unlikely (!p)) { + status = nfserr_resource; + goto out_put; + } +xdr_encode_opaque (p, item->name, ret); +out_put:cache_put (&item->h, nn->idtoname_cache); -return 0 ; +return status; } static bool
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 233/798 nfsd: return -EINVAL when namelen is 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Lingfeng <[email protected]>
[ Upstream commit 22451a16b7ab7debefce660672566be887db1637 ]
When we have a corrupted main.sqlite in /var/lib/nfs/nfsdcld/, it may result in namelen being 0, which will cause memdup_user() to return ZERO_SIZE_PTR.
When we access the name.data that has been assigned the value of ZERO_SIZE_PTR in nfs4_client_to_reclaim(), null pointer dereference is triggered.
[ T1205] ==================================================================
[ T1205] BUG: KASAN: null-ptr-deref in nfs4_client_to_reclaim+0xe9/0x260
[ T1205] Read of size 1 at addr 0000000000000010 by task nfsdcld/1205
[ T1205]
[ T1205] CPU: 11 PID: 1205 Comm: nfsdcld Not tainted 5.10.0-00003-g2c1423731b8d #406
[ T1205] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014 [ T1205] Call Trace:
[ T1205] dump_stack+0x9a/0xd0 [ T1205] ? nfs4_client_to_reclaim+0xe9/0x260 [ T1205] __kasan_report.cold+0x34/0x84 [ T1205] ? nfs4_client_to_reclaim+0xe9/0x260 [ T1205] kasan_report+0x3a/0x50 [ T1205] nfs4_client_to_reclaim+0xe9/0x260 [ T1205] ? nfsd4_release_lockowner+0x410/0x410 [ T1205] cld_pipe_downcall+0x5ca/0x760 [ T1205] ? nfsd4_cld_tracking_exit+0x1d0/0x1d0 [ T1205] ? down_write_killable_nested+0x170/0x170 [ T1205] ? avc_policy_seqno+0x28/0x40 [ T1205] ? selinux_file_permission+0x1b4/0x1e0 [ T1205] rpc_pipe_write+0x84/0xb0 [ T1205] vfs_write+0x143/0x520 [ T1205] ksys_write+0xc9/0x170 [ T1205] ? __ia32_sys_read+0x50/0x50 [ T1205] ? ktime_get_coarse_real_ts64+0xfe/0x110 [ T1205] ? ktime_get_coarse_real_ts64+0xa2/0x110 [ T1205] do_syscall_64+0x33/0x40 [ T1205] entry_SYSCALL_64_after_hwframe+0x67/0xd1
[ T1205] RIP: 0033:0x7fdbdb761bc7
[ T1205] Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 514 [ T1205] RSP: 002b:00007fff8c4b7248 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ T1205] RAX: ffffffffffffffda RBX: 000000000000042b RCX: 00007fdbdb761bc7
[ T1205] RDX: 000000000000042b RSI: 00007fff8c4b75f0 RDI: 0000000000000008
[ T1205] RBP: 00007fdbdb761bb0 R08: 0000000000000000 R09: 0000000000000001
[ T1205] R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000042b
[ T1205] R13: 0000000000000008 R14: 00007fff8c4b75f0 R15: 0000000000000000
[ T1205] ==================================================================
Fix it by checking namelen.
--- fs/nfsd/nfs4recover.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/nfsd/nfs4recover.c +8 -0
@@ -806,6 +806,10 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, ci = &cmsg->cm_u.cm_clntinfo;if (get_user (namelen, &ci->cc_name.cn_len))return -EFAULT ; +if (!namelen) { +dprintk ("%s: namelen should not be zero" , __func__); +return -EINVAL ; + } name.data =memdup_user (&ci->cc_name.cn_id, namelen);if (IS_ERR (name.data))return PTR_ERR (name.data);
@@ -828,6 +832,10 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, cnm = &cmsg->cm_u.cm_name;if (get_user (namelen, &cnm->cn_len))return -EFAULT ; +if (!namelen) { +dprintk ("%s: namelen should not be zero" , __func__); +return -EINVAL ; + } name.data =memdup_user (&cnm->cn_id, namelen);if (IS_ERR (name.data))return PTR_ERR (name.data);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 234/798 f2fs: fix to update i_ctime in __f2fs_setxattr()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 8874ad7dae8d91d24cc87c545c0073b3b2da5688 ]
generic/728 - output mismatch (see /media/fstests/results//generic/728.out.bad)
--- tests/generic/728.out 2023-07-19 07:10:48.362711407 +0000
+++ /media/fstests/results//generic/728.out.bad 2023-07-19 08:39:57.000000000 +0000
QA output created by 728
+Expected ctime to change after setxattr.
+Expected ctime to change after removexattr.
Silence is golden
...
(Run 'diff -u /media/fstests/tests/generic/728.out /media/fstests/results//generic/728.out.bad' to see the entire diff)
generic/729 1s
It needs to update i_ctime after {set,remove}xattr, fix it.
Stable-dep-of: aaf8c0b9ae04 ("f2fs: reduce expensive checkpoint trigger frequency")
--- fs/f2fs/xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/xattr.c +2 -2
@@ -772,17 +772,17 @@ static int __f2fs_setxattr(struct inode *inode, int index,if (index ==F2FS_XATTR_INDEX_ENCRYPTION && !strcmp (name,F2FS_XATTR_NAME_ENCRYPTION_CONTEXT ))f2fs_set_encrypted_inode (inode); -f2fs_mark_inode_dirty_sync (inode, true);if (!error &&S_ISDIR (inode->i_mode))set_sbi_flag (F2FS_I_SB (inode),SBI_NEED_CP ); same:if (is_inode_flag_set (inode,FI_ACL_MODE )) { inode->i_mode =F2FS_I (inode)->i_acl_mode; - inode->i_ctime =current_time (inode);clear_inode_flag (inode,FI_ACL_MODE ); } + inode->i_ctime =current_time (inode); +f2fs_mark_inode_dirty_sync (inode, true); exit:kfree (base_addr);return error;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 235/798 f2fs: remove unneeded check condition in __f2fs_setxattr()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit bc3994ffa4cf23f55171943c713366132c3ff45d ]
It has checked return value of write_all_xattrs(), remove unneeded following check condition.
Stable-dep-of: aaf8c0b9ae04 ("f2fs: reduce expensive checkpoint trigger frequency")
--- fs/f2fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/xattr.c +1 -1
@@ -772,7 +772,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,if (index ==F2FS_XATTR_INDEX_ENCRYPTION && !strcmp (name,F2FS_XATTR_NAME_ENCRYPTION_CONTEXT ))f2fs_set_encrypted_inode (inode); -if (!error &&S_ISDIR (inode->i_mode)) +if (S_ISDIR (inode->i_mode))set_sbi_flag (F2FS_I_SB (inode),SBI_NEED_CP ); same:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 236/798 f2fs: reduce expensive checkpoint trigger frequency
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit aaf8c0b9ae042494cb4585883b15c1332de77840 ]
We may trigger high frequent checkpoint for below case:
1. mkdir /mnt/dir1; set dir1 encrypted
2. touch /mnt/file1; fsync /mnt/file1
3. mkdir /mnt/dir2; set dir2 encrypted
4. touch /mnt/file2; fsync /mnt/file2
...
Although, newly created dir and file are not related, due to commit bbf156f7afa7 ("f2fs: fix lost xattrs of directories"), we will trigger checkpoint whenever fsync() comes after a new encrypted dir created.
In order to avoid such performance regression issue, let's record an entry including directory's ino in global cache whenever we update directory's xattr data, and then triggerring checkpoint() only if xattr metadata of target file's parent was updated.
This patch updates to cover below no encryption case as well:
1) parent is checkpointed
2) set_xattr(dir) w/ new xnid
3) create(file)
4) fsync(file)
--- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/file.c | 3 +++ fs/f2fs/xattr.c | 14 ++++++++++++-- include/trace/events/f2fs.h | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-)
fs/f2fs/f2fs.h +2 -0
@@ -284,6 +284,7 @@ enum {APPEND_INO ,/* for append ino list */ UPDATE_INO ,/* for update ino list */ TRANS_DIR_INO ,/* for transactions dir ino list */ +XATTR_DIR_INO ,/* for xattr updated dir ino list */ FLUSH_INO ,/* for multiple device flushing */ MAX_INO_ENTRY, /* max. list */ };
@@ -1137,6 +1138,7 @@ enum cp_reason_type {CP_FASTBOOT_MODE ,CP_SPEC_LOG_NUM ,CP_RECOVER_DIR , + CP_XATTR_DIR, }; enum iostat_type {
fs/f2fs/file.c +3 -0
@@ -217,6 +217,9 @@ static inline enum cp_reason_type need_do_checkpoint(struct inode *inode) f2fs_exist_written_data(sbi, F2FS_I(inode)->i_pino, TRANS_DIR_INO)) cp_reason =CP_RECOVER_DIR ; + else if (f2fs_exist_written_data(sbi, F2FS_I(inode)->i_pino, +XATTR_DIR_INO )) + cp_reason =CP_XATTR_DIR ;return cp_reason; }
fs/f2fs/xattr.c +12 -2
@@ -629,6 +629,7 @@ static int __f2fs_setxattr(struct inode *inode, int index, const char *name, const void *value, size_t size, struct page *ipage, int flags) { + struct f2fs_sb_info *sbi = F2FS_I_SB(inode);struct f2fs_xattr_entry *here, *last;void *base_addr, *last_base_addr;int found, newsize;
@@ -772,9 +773,18 @@ static int __f2fs_setxattr(struct inode *inode, int index,if (index ==F2FS_XATTR_INDEX_ENCRYPTION && !strcmp (name,F2FS_XATTR_NAME_ENCRYPTION_CONTEXT ))f2fs_set_encrypted_inode (inode); -if (S_ISDIR (inode->i_mode)) -set_sbi_flag (F2FS_I_SB (inode),SBI_NEED_CP ); +if (!S_ISDIR (inode->i_mode)) + goto same; +/* +* In restrict mode, fsync() always try to trigger checkpoint for all +* metadata consistency, in other mode, it triggers checkpoint when +* parent's xattr metadata was updated. +*/ +if (F2FS_OPTION (sbi).fsync_mode ==FSYNC_MODE_STRICT ) +set_sbi_flag (sbi,SBI_NEED_CP ); +else +f2fs_add_ino_entry (sbi, inode->i_ino,XATTR_DIR_INO ); same:if (is_inode_flag_set (inode,FI_ACL_MODE )) { inode->i_mode =F2FS_I (inode)->i_acl_mode;
include/trace/events/f2fs.h +2 -1
@@ -138,7 +138,8 @@ TRACE_DEFINE_ENUM(EX_READ); { CP_NODE_NEED_CP, "node needs cp" }, \ { CP_FASTBOOT_MODE, "fastboot mode" }, \ { CP_SPEC_LOG_NUM, "log type is 2" }, \ - { CP_RECOVER_DIR, "dir needs recovery" }) + { CP_RECOVER_DIR, "dir needs recovery" }, \ + { CP_XATTR_DIR, "dir's xattr updated" }) #define show_shutdown_mode(type) \ __print_symbolic(type, \
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 237/798 f2fs: factor the read/write tracing logic into a helper
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit a28bca0f47feb5cdfc22be0e563bd4da2aed74f7 ]
Factor the logic to log a path for reads and writs into a helper shared between the read_iter and write_iter methods.
Stable-dep-of: 0cac51185e65 ("f2fs: fix to avoid racing in between read and OPU dio write")
--- fs/f2fs/file.c | 61 +++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 35 deletions(-)
fs/f2fs/file.c +26 -35
@@ -4457,6 +4457,27 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)return ret; } +static void f2fs_trace_rw_file_path (struct kiocb *iocb,size_t count,int rw) +{ +struct inode *inode =file_inode (iocb->ki_filp); +char *buf, *path; + + buf =f2fs_kmalloc (F2FS_I_SB (inode),PATH_MAX ,GFP_KERNEL ); +if (!buf) +return ; + path =dentry_path_raw (file_dentry (iocb->ki_filp), buf,PATH_MAX ); +if (IS_ERR (path)) + goto free_buf; +if (rw ==WRITE ) +trace_f2fs_datawrite_start (inode, iocb->ki_pos, count, + current->pid, path, current->comm); +else +trace_f2fs_dataread_start (inode, iocb->ki_pos, count, + current->pid, path, current->comm); +free_buf: +kfree (buf); +} +static ssize_t f2fs_file_read_iter (struct kiocb *iocb,struct iov_iter *to) {struct inode *inode =file_inode (iocb->ki_filp);
@@ -4466,24 +4487,9 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)if (!f2fs_is_compress_backend_ready (inode))return -EOPNOTSUPP ; -if (trace_f2fs_dataread_start_enabled ()) { -char *p =f2fs_kmalloc (F2FS_I_SB (inode),PATH_MAX ,GFP_KERNEL ); -char *path; - -if (!p) - goto skip_read_trace; +if (trace_f2fs_dataread_start_enabled ()) +f2fs_trace_rw_file_path (iocb,iov_iter_count (to),READ ); - path =dentry_path_raw (file_dentry (iocb->ki_filp), p,PATH_MAX ); -if (IS_ERR (path)) { -kfree (p); - goto skip_read_trace; - } - -trace_f2fs_dataread_start (inode, pos,iov_iter_count (to), - current->pid, path, current->comm); -kfree (p); - } -skip_read_trace:if (f2fs_should_use_dio (inode, iocb, to)) { ret =f2fs_dio_read_iter (iocb, to); }else {
@@ -4789,24 +4795,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)if (preallocated <0 ) { ret = preallocated; }else { -if (trace_f2fs_datawrite_start_enabled ()) { -char *p =f2fs_kmalloc (F2FS_I_SB (inode), -PATH_MAX ,GFP_KERNEL ); -char *path; - -if (!p) - goto skip_write_trace; - path =dentry_path_raw (file_dentry (iocb->ki_filp), - p,PATH_MAX ); -if (IS_ERR (path)) { -kfree (p); - goto skip_write_trace; - } -trace_f2fs_datawrite_start (inode, orig_pos, orig_count, - current->pid, path, current->comm); -kfree (p); - } -skip_write_trace: +if (trace_f2fs_datawrite_start_enabled ()) +f2fs_trace_rw_file_path (iocb, orig_count,WRITE ); +/* Do the actual write. */ ret = dio ? f2fs_dio_write_iter(iocb, from, &may_need_sync) :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 238/798 f2fs: fix to avoid racing in between read and OPU dio write
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 0cac51185e65dc2a20686184e02f3cafc99eb202 ]
If lfs mode is on, buffered read may race w/ OPU dio write as below, it may cause buffered read hits unwritten data unexpectly, and for dio read, the race condition exists as well.
Thread A Thread B
- f2fs_file_write_iter
- f2fs_dio_write_iter
- __iomap_dio_rw
- f2fs_iomap_begin
- f2fs_map_blocks
- __allocate_data_block
- allocated blkaddr #x
- iomap_dio_submit_bio
- f2fs_file_read_iter
- filemap_read
- f2fs_read_data_folio
- f2fs_mpage_readpages
- f2fs_map_blocks
: get blkaddr #x
- f2fs_submit_read_bio
IRQ
- f2fs_read_end_io
: read IO on blkaddr #x complete
IRQ
- iomap_dio_bio_end_io
: direct write IO on blkaddr #x complete
In LFS mode, if there is inflight dio, let's wait for its completion, this policy won't cover all race cases, however it is a tradeoff which avoids abusing lock around IO paths.
--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/f2fs/file.c +4 -0
@@ -4490,6 +4490,10 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)if (trace_f2fs_dataread_start_enabled ())f2fs_trace_rw_file_path (iocb,iov_iter_count (to),READ ); +/* In LFS mode, if there is inflight dio, wait for its completion */ +if (f2fs_lfs_mode (F2FS_I_SB (inode))) +inode_dio_wait (inode); +if (f2fs_should_use_dio (inode, iocb, to)) { ret =f2fs_dio_read_iter (iocb, to); }else {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 239/798 f2fs: fix to wait page writeback before setting gcing flag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit a4d7f2b3238fd5f76b9e6434a0bd5d2e29049cff ]
Soft IRQ Thread
- f2fs_write_end_io
- f2fs_defragment_range
- set_page_private_gcing
- type = WB_DATA_TYPE(page, false);
: assign type w/ F2FS_WB_CP_DATA
due to page_private_gcing() is true
- dec_page_count() w/ wrong type
- end_page_writeback()
Value of F2FS_WB_CP_DATA reference count may become negative under above race condition, the root cause is we missed to wait page writeback before setting gcing page private flag, let's fix it.
--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/f2fs/file.c +4 -0
@@ -2749,6 +2749,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, goto clear_out; } +f2fs_wait_on_page_writeback (page,DATA , true, true); +set_page_dirty (page);set_page_private_gcing (page);f2fs_put_page (page,1 );
@@ -4108,6 +4110,8 @@ static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len)/* It will never fail, when page has pinned above */ f2fs_bug_on (F2FS_I_SB (inode), !page); +f2fs_wait_on_page_writeback (page,DATA , true, true); +set_page_dirty (page);set_page_private_gcing (page);f2fs_put_page (page,1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 240/798 f2fs: atomic: fix to truncate pagecache before on-disk metadata truncation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit ebd3309aec6271c4616573b0cb83ea25e623070a ]
We should always truncate pagecache while truncating on-disk data.
--- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/f2fs/file.c +4 -0
@@ -2171,6 +2171,10 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)clear_inode_flag (fi->cow_inode,FI_INLINE_DATA ); }else {/* Reuse the already created COW inode */ +f2fs_bug_on (sbi,get_dirty_pages (fi->cow_inode)); + +invalidate_mapping_pages (fi->cow_inode->i_mapping,0 ,-1 ); + ret =f2fs_do_truncate_blocks (fi->cow_inode,0 , true);if (ret) {f2fs_up_write (&fi->i_gc_rwsem[WRITE ]);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 241/798 f2fs: clean up w/ dotdot_name
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit ff6584ac2c4b4ee8e1fca20bffaaa387d8fe2974 ]
Just cleanup, no logic changes.
Stable-dep-of: 884ee6dc85b9 ("f2fs: get rid of online repaire on corrupted directory")
--- fs/f2fs/namei.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/f2fs/namei.c +2 -3
@@ -449,7 +449,6 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct qstr dot =QSTR_INIT ("." ,1 ); -struct qstr dotdot =QSTR_INIT (".." ,2 );struct f2fs_dir_entry *de;struct page *page;int err =0 ;
@@ -487,13 +486,13 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino) goto out; } - de =f2fs_find_entry (dir, &dotdot, &page); + de =f2fs_find_entry (dir, &dotdot_name, &page);if (de)f2fs_put_page (page,0 );else if (IS_ERR (page)) err =PTR_ERR (page);else - err =f2fs_do_add_link (dir, &dotdot,NULL , pino,S_IFDIR ); + err =f2fs_do_add_link (dir, &dotdot_name,NULL , pino,S_IFDIR ); out:if (!err)clear_inode_flag (dir,FI_INLINE_DOTS );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 242/798 f2fs: get rid of online repaire on corrupted directory
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 884ee6dc85b959bc152f15bca80c30f06069e6c4 ]
syzbot reports a f2fs bug as below:
kernel BUG at fs/f2fs/inode.c:896!
RIP: 0010:f2fs_evict_inode+0x1598/0x15c0 fs/f2fs/inode.c:896 Call Trace: evict+0x532/0x950 fs/inode.c:704 dispose_list fs/inode.c:747 [inline] evict_inodes+0x5f9/0x690 fs/inode.c:797 generic_shutdown_super+0x9d/0x2d0 fs/super.c:627 kill_block_super+0x44/0x90 fs/super.c:1696 kill_f2fs_super+0x344/0x690 fs/f2fs/super.c:4898 deactivate_locked_super+0xc4/0x130 fs/super.c:473 cleanup_mnt+0x41f/0x4b0 fs/namespace.c:1373 task_work_run+0x24f/0x310 kernel/task_work.c:228 ptrace_notify+0x2d2/0x380 kernel/signal.c:2402 ptrace_report_syscall include/linux/ptrace.h:415 [inline] ptrace_report_syscall_exit include/linux/ptrace.h:477 [inline] syscall_exit_work+0xc6/0x190 kernel/entry/common.c:173 syscall_exit_to_user_mode_prepare kernel/entry/common.c:200 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:205 [inline] syscall_exit_to_user_mode+0x279/0x370 kernel/entry/common.c:218 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0010:f2fs_evict_inode+0x1598/0x15c0 fs/f2fs/inode.c:896
Online repaire on corrupted directory in f2fs_lookup() can generate dirty data/meta while racing w/ readonly remount, it may leave dirty inode after filesystem becomes readonly, however, checkpoint() will skips flushing dirty inode in a state of readonly mode, result in above panic.
Let's get rid of online repaire in f2fs_lookup(), and leave the work to fsck.f2fs.
--- fs/f2fs/f2fs.h | 11 ------- fs/f2fs/namei.c | 68 ----------------------------------------- include/linux/f2fs_fs.h | 2 +- 3 files changed, 1 insertion(+), 80 deletions(-)
fs/f2fs/f2fs.h +0 -11
@@ -771,7 +771,6 @@ enum {FI_NEED_IPU ,/* used for ipu per file */ FI_ATOMIC_FILE ,/* indicate atomic file */ FI_DATA_EXIST ,/* indicate data exists */ -FI_INLINE_DOTS ,/* indicate inline dot dentries */ FI_SKIP_WRITES ,/* should skip data page writeback */ FI_OPU_WRITE ,/* used for opu per file */ FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */
@@ -3000,7 +2999,6 @@ static inline void __mark_inode_dirty_flag(struct inode *inode,return ; fallthrough;case FI_DATA_EXIST : -case FI_INLINE_DOTS :case FI_PIN_FILE :case FI_COMPRESS_RELEASED :case FI_ATOMIC_COMMITTED :
@@ -3125,8 +3123,6 @@ static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri)set_bit (FI_INLINE_DENTRY , fi->flags);if (ri->i_inline &F2FS_DATA_EXIST )set_bit (FI_DATA_EXIST , fi->flags); -if (ri->i_inline &F2FS_INLINE_DOTS ) -set_bit (FI_INLINE_DOTS , fi->flags);if (ri->i_inline &F2FS_EXTRA_ATTR )set_bit (FI_EXTRA_ATTR , fi->flags);if (ri->i_inline &F2FS_PIN_FILE )
@@ -3147,8 +3143,6 @@ static inline void set_raw_inline(struct inode *inode, struct f2fs_inode *ri) ri->i_inline |=F2FS_INLINE_DENTRY ;if (is_inode_flag_set (inode,FI_DATA_EXIST )) ri->i_inline |=F2FS_DATA_EXIST ; -if (is_inode_flag_set (inode,FI_INLINE_DOTS )) - ri->i_inline |=F2FS_INLINE_DOTS ;if (is_inode_flag_set (inode,FI_EXTRA_ATTR )) ri->i_inline |=F2FS_EXTRA_ATTR ;if (is_inode_flag_set (inode,FI_PIN_FILE ))
@@ -3235,11 +3229,6 @@ static inline int f2fs_exist_data(struct inode *inode)return is_inode_flag_set (inode,FI_DATA_EXIST ); } -static inline int f2fs_has_inline_dots (struct inode *inode) -{ -return is_inode_flag_set (inode,FI_INLINE_DOTS ); -} -static inline int f2fs_is_mmap_file (struct inode *inode) {return is_inode_flag_set (inode,FI_MMAP_FILE );
fs/f2fs/namei.c +0 -68
86 lines not on this page · raw message
include/linux/f2fs_fs.h +1 -1
@@ -264,7 +264,7 @@ struct f2fs_extent {#define F2FS_INLINE_DATA 0x02/* file inline data flag */ #define F2FS_INLINE_DENTRY 0x04/* file inline dentry flag */ #define F2FS_DATA_EXIST 0x08/* file inline data exist flag */ -#define F2FS_INLINE_DOTS 0x10/* file having implicit dot dentries */ +#define F2FS_INLINE_DOTS 0x10/* file having implicit dot dentries (obsolete) */ #define F2FS_EXTRA_ATTR 0x20/* file having extra attribute */ #define F2FS_PIN_FILE 0x40/* file should not be gced */ #define F2FS_COMPRESS_RELEASED 0x80/* file released compressed blocks */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 243/798 spi: atmel-quadspi: Undo runtime PM changes at driver exit time
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 438efb23f9581659495b85f1f6c7d5946200660c ]
It's important to undo pm_runtime_use_autosuspend() with pm_runtime_dont_use_autosuspend() at driver exit time unless driver initially enabled pm_runtime with devm_pm_runtime_enable() (which handles it for you).
Hence, call pm_runtime_dont_use_autosuspend() at driver exit time to fix it.
--- drivers/spi/atmel-quadspi.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/atmel-quadspi.c +1 -0
@@ -692,6 +692,7 @@ static int atmel_qspi_remove(struct platform_device *pdev)clk_unprepare (aq->pclk);pm_runtime_disable (&pdev->dev); +pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 244/798 spi: spi-fsl-lpspi: Undo runtime PM changes at driver exit time
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 3b577de206d52dbde9428664b6d823d35a803d75 ]
It's important to undo pm_runtime_use_autosuspend() with pm_runtime_dont_use_autosuspend() at driver exit time unless driver initially enabled pm_runtime with devm_pm_runtime_enable() (which handles it for you).
Hence, call pm_runtime_dont_use_autosuspend() at driver exit time to fix it.
--- drivers/spi/spi-fsl-lpspi.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-fsl-lpspi.c +1 -0
@@ -947,6 +947,7 @@ static int fsl_lpspi_remove(struct platform_device *pdev)fsl_lpspi_dma_exit (controller); +pm_runtime_dont_use_autosuspend (fsl_lpspi->dev);pm_runtime_disable (fsl_lpspi->dev);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 245/798 lib/sbitmap: define swap_lock as raw_spinlock_t
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit 65f666c6203600053478ce8e34a1db269a8701c9 ]
When called from sbitmap_queue_get(), sbitmap_deferred_clear() may be run with preempt disabled. In RT kernel, spin_lock() can sleep, then warning of "BUG: sleeping function called from invalid context" can be triggered.
Fix it by replacing it with raw_spin_lock.
--- include/linux/sbitmap.h | 2 +- lib/sbitmap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/sbitmap.h +1 -1
@@ -40,7 +40,7 @@ struct sbitmap_word {/** * @swap_lock: serializes simultaneous updates of ->word and ->cleared */ -spinlock_t swap_lock; +raw_spinlock_t swap_lock; }____cacheline_aligned_in_smp ;/**
lib/sbitmap.c +2 -2
@@ -65,7 +65,7 @@ static inline bool sbitmap_deferred_clear(struct sbitmap_word *map, {unsigned long mask, word_mask; -guard (spinlock_irqsave)(&map->swap_lock); +guard (raw_spinlock_irqsave)(&map->swap_lock);if (!map->cleared) {if (depth ==0 )
@@ -136,7 +136,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, }for (i =0 ; i < sb->map_nr; i++) -spin_lock_init (&sb->map[i].swap_lock); +raw_spin_lock_init (&sb->map[i].swap_lock);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 246/798 nvme-multipath: system fails to create generic nvme device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 63bcf9014e95a7d279d10d8e2caa5d88db2b1855 ]
NVME_NSHEAD_DISK_LIVE is a flag for struct nvme_ns_head, not nvme_ns. The current code has a typo causing NVME_NSHEAD_DISK_LIVE never to be cleared once device_add_disk_fails, causing the system never to create the 'generic' character device. Even several rescan attempts will change the situation and the system has to be rebooted to fix the issue.
--- drivers/nvme/host/multipath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/multipath.c +1 -1
@@ -548,7 +548,7 @@ static void nvme_mpath_set_live(struct nvme_ns *ns) rc =device_add_disk (&head->subsys->dev, head->disk, nvme_ns_id_attr_groups);if (rc) { -clear_bit (NVME_NSHEAD_DISK_LIVE , &ns->flags); +clear_bit (NVME_NSHEAD_DISK_LIVE , &head->flags);return ; }nvme_add_ns_head_cdev (head);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 247/798 iio: adc: ad7606: fix oversampling gpio array
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Stols <[email protected]>
[ Upstream commit 8dc4594b54dbaaba40dc8884ad3d42083de39434 ]
gpiod_set_array_value was misused here: the implementation relied on the assumption that an unsigned long was required for each gpio, while the function expects a bit array stored in "as much unsigned long as needed for storing one bit per GPIO", i.e it is using a bit field.
This leaded to incorrect parameter passed to gpiod_set_array_value, that would set 1 value instead of 3.
It also prevents to select the software mode correctly for the AD7606B.
--- drivers/iio/adc/ad7606.c | 4 ++-- drivers/iio/adc/ad7606_spi.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/iio/adc/ad7606.c +2 -2
@@ -215,9 +215,9 @@ static int ad7606_write_os_hw(struct iio_dev *indio_dev, int val)struct ad7606_state *st =iio_priv (indio_dev);DECLARE_BITMAP (values,3 ); - values[0 ] = val; + values[0 ] = val &GENMASK (2 ,0 ); -gpiod_set_array_value (ARRAY_SIZE (values), st->gpio_os->desc, +gpiod_set_array_value (st->gpio_os->ndescs, st->gpio_os->desc, st->gpio_os->info, values);/* AD7616 requires a reset to update value */
drivers/iio/adc/ad7606_spi.c +3 -2
@@ -249,8 +249,9 @@ static int ad7616_sw_mode_config(struct iio_dev *indio_dev)static int ad7606B_sw_mode_config (struct iio_dev *indio_dev) {struct ad7606_state *st =iio_priv (indio_dev); -unsigned long os[3 ] = {1 }; +DECLARE_BITMAP (os,3 ); +bitmap_fill (os,3 );/* * Software mode is enabled when all three oversampling * pins are set to high. If oversampling gpios are defined
@@ -258,7 +259,7 @@ static int ad7606B_sw_mode_config(struct iio_dev *indio_dev)* otherwise, they must be hardwired to VDD */ if (st->gpio_os) { -gpiod_set_array_value (ARRAY_SIZE (os), +gpiod_set_array_value (st->gpio_os->ndescs, st->gpio_os->desc, st->gpio_os->info, os); }/* OS of 128 and 256 are available only in software mode */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 248/798 iio: adc: ad7606: fix standby gpio state to match the documentation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Stols <[email protected]>
[ Upstream commit 059fe4f8bbdf5cad212e1aeeb3e8968c80b9ff3b ]
The binding's documentation specifies that "As the line is active low, it should be marked GPIO_ACTIVE_LOW". However, in the driver, it was handled the opposite way. This commit sets the driver's behaviour in sync with the documentation
--- drivers/iio/adc/ad7606.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7606.c +2 -2
@@ -422,7 +422,7 @@ static int ad7606_request_gpios(struct ad7606_state *st)return PTR_ERR (st->gpio_range); st->gpio_standby =devm_gpiod_get_optional (dev,"standby" , -GPIOD_OUT_HIGH ); +GPIOD_OUT_LOW );if (IS_ERR (st->gpio_standby))return PTR_ERR (st->gpio_standby);
@@ -681,7 +681,7 @@ static int ad7606_suspend(struct device *dev)if (st->gpio_standby) {gpiod_set_value (st->gpio_range,1 ); -gpiod_set_value (st->gpio_standby,0 ); +gpiod_set_value (st->gpio_standby,1 ); }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 249/798 ABI: testing: fix admv8818 attr description
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
[ Upstream commit 7d34b4ad8cd2867b130b5b8d7d76d0d6092bd019 ]
Fix description of the filter_mode_available attribute by pointing to the correct name of the attribute that can be written with valid values.
--- Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 +1 -1
@@ -3,7 +3,7 @@ KernelVersion: Contact: [email protected] Description: Reading this returns the valid values that can be written to the - on_altvoltage0_mode attribute: + filter_mode attribute: - auto -> Adjust bandpass filter to track changes in input clock rate. - manual -> disable/unregister the clock rate notifier / input clock tracking.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 250/798 iio: chemical: bme680: Fix read/write ops to device by adding mutexes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasileios Amoiridis <[email protected]>
[ Upstream commit 77641e5a477d428335cd094b88ac54e09ccb70f4 ]
Add mutexes in the {read/write}_raw() functions of the device to guard the read/write of data from/to the device. This is necessary because for any operation other than temperature, multiple reads need to take place from the device. Even though regmap has a locking by itself, it won't protect us from multiple applications trying to read at the same time temperature and pressure since the pressure reading includes an internal temperature reading and there is nothing to ensure that this temperature+pressure reading will happen sequentially without any other operation interfering in the meantime.
--- drivers/iio/chemical/bme680_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iio/chemical/bme680_core.c +7 -0
@@ -10,6 +10,7 @@*/ #include <linux/acpi.h> #include <linux/bitfield.h> +#include <linux/cleanup.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/module.h>
@@ -52,6 +53,7 @@ struct bme680_calib {struct bme680_data {struct regmap *regmap;struct bme680_calib bme680; +struct mutex lock;/* Protect multiple serial R/W ops to device. */ u8 oversampling_temp;u8 oversampling_press;u8 oversampling_humid;
@@ -827,6 +829,8 @@ static int bme680_read_raw(struct iio_dev *indio_dev, {struct bme680_data *data =iio_priv (indio_dev); +guard (mutex)(&data->lock); +switch (mask) {case IIO_CHAN_INFO_PROCESSED :switch (chan->type) {
@@ -871,6 +875,8 @@ static int bme680_write_raw(struct iio_dev *indio_dev, {struct bme680_data *data =iio_priv (indio_dev); +guard (mutex)(&data->lock); +if (val2 !=0 )return -EINVAL ;
@@ -967,6 +973,7 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap, name =bme680_match_acpi_device (dev); data =iio_priv (indio_dev); +mutex_init (&data->lock);dev_set_drvdata (dev, indio_dev); data->regmap = regmap; indio_dev->name = name;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 251/798 iio: magnetometer: ak8975: Convert enum->pointer for data in the match tables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 4f9ea93afde190a0f906ee624fc9a45cf784551b ]
Convert enum->pointer for data in the match tables to simplify the probe() by replacing device_get_match_data() and i2c_client_get_device_id by i2c_get_match_data() as we have similar I2C, ACPI and DT matching table.
Stable-dep-of: da6e3160df23 ("iio: magnetometer: ak8975: drop incorrect AK09116 compatible")
--- drivers/iio/magnetometer/ak8975.c | 75 +++++++++++++------------------ 1 file changed, 30 insertions(+), 45 deletions(-)
drivers/iio/magnetometer/ak8975.c +30 -45
@@ -813,13 +813,13 @@ static const struct iio_info ak8975_info = { };static const struct acpi_device_id ak_acpi_match[] = { - {"AK8975" ,AK8975 }, - {"AK8963" ,AK8963 }, - {"INVN6500" ,AK8963 }, - {"AK009911" ,AK09911 }, - {"AK09911" ,AK09911 }, - {"AKM9911" ,AK09911 }, - {"AK09912" ,AK09912 }, + {"AK8975" , (kernel_ulong_t)&ak_def_array[AK8975 ] }, + {"AK8963" , (kernel_ulong_t)&ak_def_array[AK8963 ] }, + {"INVN6500" , (kernel_ulong_t)&ak_def_array[AK8963 ] }, + {"AK009911" , (kernel_ulong_t)&ak_def_array[AK09911 ] }, + {"AK09911" , (kernel_ulong_t)&ak_def_array[AK09911 ] }, + {"AKM9911" , (kernel_ulong_t)&ak_def_array[AK09911 ] }, + {"AK09912" , (kernel_ulong_t)&ak_def_array[AK09912 ] }, { } };MODULE_DEVICE_TABLE (acpi, ak_acpi_match);
@@ -883,10 +883,7 @@ static int ak8975_probe(struct i2c_client *client,struct iio_dev *indio_dev;struct gpio_desc *eoc_gpiod;struct gpio_desc *reset_gpiod; -const void *match; -unsigned int i;int err; -enum asahi_compass_chipset chipset;const char *name =NULL ;/*
@@ -928,27 +925,15 @@ static int ak8975_probe(struct i2c_client *client,return err;/* id will be NULL when enumerated via ACPI */ - match =device_get_match_data (&client->dev); -if (match) { - chipset = (uintptr_t )match; - name =dev_name (&client->dev); - }else if (id) { - chipset = (enum asahi_compass_chipset )(id->driver_data); - name = id->name; - }else -return -ENOSYS ; - -for (i =0 ; i <ARRAY_SIZE (ak_def_array); i++) -if (ak_def_array[i].type == chipset) -break ; - -if (i ==ARRAY_SIZE (ak_def_array)) { -dev_err (&client->dev,"AKM device type unsupported: %d\n" , - chipset); + data->def =i2c_get_match_data (client); +if (!data->def)return -ENODEV ; - } - data->def = &ak_def_array[i]; +/* If enumerated via firmware node, fix the ABI */ +if (dev_fwnode (&client->dev)) + name =dev_name (&client->dev); +else + name = id->name;/* Fetch the regulators */ data->vdd =devm_regulator_get (&client->dev,"vdd" );
@@ -1077,28 +1062,28 @@ static DEFINE_RUNTIME_DEV_PM_OPS(ak8975_dev_pm_ops, ak8975_runtime_suspend, ak8975_runtime_resume, NULL);static const struct i2c_device_id ak8975_id[] = { - {"ak8975" ,AK8975 }, - {"ak8963" ,AK8963 }, - {"AK8963" ,AK8963 }, - {"ak09911" ,AK09911 }, - {"ak09912" ,AK09912 }, - {"ak09916" ,AK09916 }, + {"ak8975" , (kernel_ulong_t)&ak_def_array[AK8975 ] }, + {"ak8963" , (kernel_ulong_t)&ak_def_array[AK8963 ] }, + {"AK8963" , (kernel_ulong_t)&ak_def_array[AK8963 ] }, + {"ak09911" , (kernel_ulong_t)&ak_def_array[AK09911 ] }, + {"ak09912" , (kernel_ulong_t)&ak_def_array[AK09912 ] }, + {"ak09916" , (kernel_ulong_t)&ak_def_array[AK09916 ] }, {} };MODULE_DEVICE_TABLE (i2c, ak8975_id);static const struct of_device_id ak8975_of_match[] = { - { .compatible ="asahi-kasei,ak8975" , }, - { .compatible ="ak8975" , }, - { .compatible ="asahi-kasei,ak8963" , }, - { .compatible ="ak8963" , }, - { .compatible ="asahi-kasei,ak09911" , }, - { .compatible ="ak09911" , }, - { .compatible ="asahi-kasei,ak09912" , }, - { .compatible ="ak09912" , }, - { .compatible ="asahi-kasei,ak09916" , }, - { .compatible ="ak09916" , }, + { .compatible ="asahi-kasei,ak8975" , .data = &ak_def_array[AK8975 ] }, + { .compatible ="ak8975" , .data = &ak_def_array[AK8975 ] }, + { .compatible ="asahi-kasei,ak8963" , .data = &ak_def_array[AK8963 ] }, + { .compatible ="ak8963" , .data = &ak_def_array[AK8963 ] }, + { .compatible ="asahi-kasei,ak09911" , .data = &ak_def_array[AK09911 ] }, + { .compatible ="ak09911" , .data = &ak_def_array[AK09911 ] }, + { .compatible ="asahi-kasei,ak09912" , .data = &ak_def_array[AK09912 ] }, + { .compatible ="ak09912" , .data = &ak_def_array[AK09912 ] }, + { .compatible ="asahi-kasei,ak09916" , .data = &ak_def_array[AK09916 ] }, + { .compatible ="ak09916" , .data = &ak_def_array[AK09916 ] }, {} };MODULE_DEVICE_TABLE (of, ak8975_of_match);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 252/798 iio: magnetometer: ak8975: drop incorrect AK09116 compatible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit da6e3160df230692bbd48a6d52318035f19595e2 ]
All compatibles in this binding without prefixes were deprecated, so adding a new deprecated one after some time is not allowed, because it defies the core logic of deprecating things.
Drop the AK09916 vendorless compatible.
--- drivers/iio/magnetometer/ak8975.c | 1 - 1 file changed, 1 deletion(-)
drivers/iio/magnetometer/ak8975.c +0 -1
@@ -1083,7 +1083,6 @@ static const struct of_device_id ak8975_of_match[] = { { .compatible = "asahi-kasei,ak09912", .data = &ak_def_array[AK09912] }, { .compatible = "ak09912", .data = &ak_def_array[AK09912] }, { .compatible = "asahi-kasei,ak09916", .data = &ak_def_array[AK09916] }, - { .compatible = "ak09916", .data = &ak_def_array[AK09916] }, {} };MODULE_DEVICE_TABLE (of, ak8975_of_match);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 253/798 dt-bindings: iio: asahi-kasei,ak8975: drop incorrect AK09116 compatible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit c7668ac67bc21aebdd8e2d7f839bfffba31b7713 ]
All compatibles in this binding without prefixes were deprecated, so adding a new deprecated one after some time is not allowed, because it defies the core logic of deprecating things.
Drop the AK09916 vendorless compatible.
--- .../devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml | 1 - 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml +0 -1
@@ -23,7 +23,6 @@ properties: - ak8963 - ak09911 - ak09912 - - ak09916 deprecated: true reg:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 254/798 coresight: tmc: sg: Do not leak sg_table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suzuki K Poulose <[email protected]>
[ Upstream commit c58dc5a1f886f2fcc1133746d0cbaa1fe7fd44ff ]
Running perf with cs_etm on Juno triggers the following kmemleak warning !
:~# cat /sys/kernel/debug/kmemleak unreferenced object 0xffffff8806b6d720 (size 96): comm "perf", pid 562, jiffies 4297810960 hex dump (first 32 bytes): 38 d8 13 07 88 ff ff ff 00 d0 9e 85 c0 ff ff ff 8............... 00 10 00 88 c0 ff ff ff 00 f0 ff f7 ff 00 00 00 ................ backtrace (crc 1dbf6e00): [<ffffffc08107381c>] kmemleak_alloc+0xbc/0xd8 [<ffffffc0802f9798>] kmalloc_trace_noprof+0x220/0x2e8 [<ffffffc07bb71948>] tmc_alloc_sg_table+0x48/0x208 [coresight_tmc] [<ffffffc07bb71cbc>] tmc_etr_alloc_sg_buf+0xac/0x240 [coresight_tmc] [<ffffffc07bb72538>] tmc_alloc_etr_buf.constprop.0+0x1f0/0x260 [coresight_tmc] [<ffffffc07bb7280c>] alloc_etr_buf.constprop.0.isra.0+0x74/0xa8 [coresight_tmc] [<ffffffc07bb72950>] tmc_alloc_etr_buffer+0x110/0x260 [coresight_tmc] [<ffffffc07bb38afc>] etm_setup_aux+0x204/0x3b0 [coresight] [<ffffffc08025837c>] rb_alloc_aux+0x20c/0x318 [<ffffffc08024dd84>] perf_mmap+0x2e4/0x7a0 [<ffffffc0802cceb0>] mmap_region+0x3b0/0xa08 [<ffffffc0802cd8a8>] do_mmap+0x3a0/0x500 [<ffffffc080295328>] vm_mmap_pgoff+0x100/0x1d0 [<ffffffc0802cadf8>] ksys_mmap_pgoff+0xb8/0x110 [<ffffffc080020688>] __arm64_sys_mmap+0x38/0x58 [<ffffffc080028fc0>] invoke_syscall.constprop.0+0x58/0x100
This due to the fact that we do not free the "sg_table" itself while freeing up the SG table and data pages. Fix this by freeing the sg_table in tmc_free_sg_table().
--- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-tmc-etr.c +1 -1
@@ -255,6 +255,7 @@ void tmc_free_sg_table(struct tmc_sg_table *sg_table) {tmc_free_table_pages (sg_table);tmc_free_data_pages (sg_table); +kfree (sg_table); }EXPORT_SYMBOL_GPL (tmc_free_sg_table);
@@ -336,7 +337,6 @@ struct tmc_sg_table *tmc_alloc_sg_table(struct device *dev, rc =tmc_alloc_table_pages (sg_table);if (rc) {tmc_free_sg_table (sg_table); -kfree (sg_table);return ERR_PTR (rc); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 255/798 cxl/pci: Break out range register decoding from cxl_hdm_decode_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 1acba6e9206c655f8eb6736c7cafbf022492f36d ]
There are 2 scenarios that requires additional handling. 1. A device that has active ranges in DVSEC range registers (RR) but no HDM decoder register block. 2. A device that has both RR active and HDM, but the HDM decoders are not programmed. The goal is to create emulated decoder software structs based on the RR.
Move the CXL DVSEC range register decoding code block from cxl_hdm_decode_init() to its own function. Refactor code in preparation for the HDM decoder emulation. There is no functionality change to the code. Name the new function to cxl_dvsec_rr_decode().
The only change is to set range->start and range->end to CXL_RESOURCE_NONE and skipping the reading of base registers if the range size is 0, which equates to range not active.
Stable-dep-of: 55e268694e8b ("cxl/pci: Fix to record only non-zero ranges")
--- drivers/cxl/core/pci.c | 64 ++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 24 deletions(-)
drivers/cxl/core/pci.c +40 -24
@@ -211,11 +211,10 @@ int cxl_await_media_ready(struct cxl_dev_state *cxlds) }EXPORT_SYMBOL_NS_GPL (cxl_await_media_ready,CXL ); -static int wait_for_valid (struct cxl_dev_state *cxlds) +static int wait_for_valid (struct pci_dev *pdev,int d) { -struct pci_dev *pdev =to_pci_dev (cxlds->dev); -int d = cxlds->cxl_dvsec, rc;u32 val; +int rc;/* * Memory_Info_Valid: When set, indicates that the CXL Range 1 Size high
@@ -404,20 +403,11 @@ static bool __cxl_hdm_decode_init(struct cxl_dev_state *cxlds,return true; } -/** -* cxl_hdm_decode_init() - Setup HDM decoding for the endpoint -* @cxlds: Device state -* @cxlhdm: Mapped HDM decoder Capability -* -* Try to enable the endpoint's HDM Decoder Capability -*/ -int cxl_hdm_decode_init (struct cxl_dev_state *cxlds,struct cxl_hdm *cxlhdm) +static int cxl_dvsec_rr_decode (struct device *dev,int d, +struct cxl_endpoint_dvsec_info *info) { -struct pci_dev *pdev =to_pci_dev (cxlds->dev); -struct cxl_endpoint_dvsec_info info = {0 }; +struct pci_dev *pdev =to_pci_dev (dev);int hdm_count, rc, i, ranges =0 ; -struct device *dev = &pdev->dev; -int d = cxlds->cxl_dvsec;u16 cap, ctrl;if (!d) {
@@ -448,7 +438,7 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm)if (!hdm_count || hdm_count >2 )return -EINVAL ; - rc =wait_for_valid (cxlds); + rc =wait_for_valid (pdev, d);if (rc) {dev_dbg (dev,"Failure awaiting MEM_INFO_VALID (%d)\n" , rc);return rc;
@@ -459,9 +449,9 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm)* disabled, and they will remain moot after the HDM Decoder * capability is enabled. */ - info.mem_enabled =FIELD_GET (CXL_DVSEC_MEM_ENABLE , ctrl); -if (!info.mem_enabled) - goto hdm_init; + info->mem_enabled =FIELD_GET (CXL_DVSEC_MEM_ENABLE , ctrl); +if (!info->mem_enabled) +return 0 ;for (i =0 ; i < hdm_count; i++) {u64 base, size;
@@ -480,6 +470,13 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm)return rc; size |= temp &CXL_DVSEC_MEM_SIZE_LOW_MASK ; +if (!size) { + info->dvsec_range[i] = (struct range ) { + .start =0 , + .end =CXL_RESOURCE_NONE , + }; +continue ; + } rc =pci_read_config_dword ( pdev, d +CXL_DVSEC_RANGE_BASE_HIGH (i), &temp);
@@ -495,22 +492,41 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm) base |= temp &CXL_DVSEC_MEM_BASE_LOW_MASK ; - info.dvsec_range[i] = (struct range ) { + info->dvsec_range[i] = (struct range ) { .start = base, .end = base + size -1 }; -if (size) - ranges++; + ranges++; } - info.ranges = ranges; + info->ranges = ranges; + +return 0 ; +} + +/** +* cxl_hdm_decode_init() - Setup HDM decoding for the endpoint +* @cxlds: Device state +* @cxlhdm: Mapped HDM decoder Capability +* +* Try to enable the endpoint's HDM Decoder Capability +*/ +int cxl_hdm_decode_init (struct cxl_dev_state *cxlds,struct cxl_hdm *cxlhdm) +{ +struct cxl_endpoint_dvsec_info info = {0 }; +struct device *dev = cxlds->dev; +int d = cxlds->cxl_dvsec; +int rc; + + rc =cxl_dvsec_rr_decode (dev, d, &info); +if (rc <0 ) +return rc;/* * If DVSEC ranges are being used instead of HDM decoder registers there * is no use in trying to manage those. */ -hdm_init:if (!__cxl_hdm_decode_init (cxlds, cxlhdm, &info)) {dev_err (dev,"Legacy range registers configuration prevents HDM operation.\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 256/798 cxl/pci: Fix to record only non-zero ranges
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yanfei Xu <[email protected]>
[ Upstream commit 55e268694e8b07026c88191f9b6949b6887d9ce3 ]
The function cxl_dvsec_rr_decode() retrieves and records DVSEC ranges into info->dvsec_range[], regardless of whether it is non-zero range, and the variable info->ranges indicates the number of non-zero ranges. However, in cxl_hdm_decode_init(), the validation for info->dvsec_range[] occurs in a for loop that iterates based on info->ranges. It may result in zero range to be validated but non-zero range not be validated, in turn, the number of allowed ranges is to be
0. Address it by only record non-zero ranges.
This fix is not urgent as it requires a configuration that zeroes out the first dvsec range while populating the second. This has not been observed, but it is theoretically possible. If this gets picked up for -stable, no harm done, but there is no urgency to backport.
--- drivers/cxl/core/pci.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/cxl/core/pci.c +1 -7
@@ -471,10 +471,6 @@ static int cxl_dvsec_rr_decode(struct device *dev, int d, size |= temp &CXL_DVSEC_MEM_SIZE_LOW_MASK ;if (!size) { - info->dvsec_range[i] = (struct range ) { - .start =0 , - .end =CXL_RESOURCE_NONE , - };continue ; }
@@ -492,12 +488,10 @@ static int cxl_dvsec_rr_decode(struct device *dev, int d, base |= temp &CXL_DVSEC_MEM_BASE_LOW_MASK ; - info->dvsec_range[i] = (struct range ) { + info->dvsec_range[ranges++] = (struct range ) { .start = base, .end = base + size -1 }; - - ranges++; } info->ranges = ranges;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 257/798 vdpa: Add eventfd for the vdpa callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xie Yongji <[email protected]>
[ Upstream commit 5e68470f4e80a4120e9ecec408f6ab4ad386bd4a ]
Add eventfd for the vdpa callback so that user
can signal it directly instead of triggering the
callback. It will be used for vhost-vdpa case.
Message-Id: <[email protected]>
Stable-dep-of: 02e9e9366fef ("vhost_vdpa: assign irq bypass producer token correctly")
--- drivers/vhost/vdpa.c | 2 ++ drivers/virtio/virtio_vdpa.c | 1 + include/linux/vdpa.h | 6 ++++++ 3 files changed, 9 insertions(+)
drivers/vhost/vdpa.c +2 -0
@@ -602,9 +602,11 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,if (vq->call_ctx.ctx) { cb.callback = vhost_vdpa_virtqueue_cb; cb.private = vq; + cb.trigger = vq->call_ctx.ctx; }else { cb.callback =NULL ; cb.private =NULL ; + cb.trigger =NULL ; } ops->set_vq_cb (vdpa, idx, &cb);vhost_vdpa_setup_vq_irq (v, idx);
drivers/virtio/virtio_vdpa.c +1 -0
@@ -188,6 +188,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,/* Setup virtqueue callback */ cb.callback = callback ? virtio_vdpa_virtqueue_cb :NULL ; cb.private = info; + cb.trigger =NULL ; ops->set_vq_cb (vdpa, index, &cb); ops->set_vq_num (vdpa, index,virtqueue_get_vring_size (vq));
include/linux/vdpa.h +6 -0
@@ -13,10 +13,16 @@* struct vdpa_calllback - vDPA callback definition. * @callback: interrupt callback function * @private: the data passed to the callback function +* @trigger: the eventfd for the callback (Optional). +* When it is set, the vDPA driver must guarantee that +* signaling it is functional equivalent to triggering +* the callback. Then vDPA parent can signal it directly +* instead of triggering the callback. */ struct vdpa_callback {irqreturn_t (*callback)(void *data);void *private; +struct eventfd_ctx *trigger; };/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 258/798 vhost_vdpa: assign irq bypass producer token correctly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Wang <[email protected]>
[ Upstream commit 02e9e9366fefe461719da5d173385b6685f70319 ]
We used to call irq_bypass_unregister_producer() in vhost_vdpa_setup_vq_irq() which is problematic as we don't know if the token pointer is still valid or not.
Actually, we use the eventfd_ctx as the token so the life cycle of the token should be bound to the VHOST_SET_VRING_CALL instead of vhost_vdpa_setup_vq_irq() which could be called by set_status().
Fixing this by setting up irq bypass producer's token when handling VHOST_SET_VRING_CALL and un-registering the producer before calling vhost_vring_ioctl() to prevent a possible use after free as eventfd could have been released in vhost_vring_ioctl(). And such registering and unregistering will only be done if DRIVER_OK is set.
Message-Id: <[email protected]>
--- drivers/vhost/vdpa.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/vhost/vdpa.c +13 -3
@@ -191,11 +191,9 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)if (irq <0 )return ; -irq_bypass_unregister_producer (&vq->call_ctx.producer);if (!vq->call_ctx.ctx)return ; - vq->call_ctx.producer.token = vq->call_ctx.ctx; vq->call_ctx.producer.irq = irq; ret =irq_bypass_register_producer (&vq->call_ctx.producer);if (unlikely (ret))
@@ -571,6 +569,14 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, vq->last_avail_idx = vq_state.split.avail_index; }break ; +case VHOST_SET_VRING_CALL : +if (vq->call_ctx.ctx) { +if (ops->get_status (vdpa) & +VIRTIO_CONFIG_S_DRIVER_OK ) +vhost_vdpa_unsetup_vq_irq (v, idx); + vq->call_ctx.producer.token =NULL ; + } +break ; } r =vhost_vring_ioctl (&v->vdev, cmd, argp);
@@ -603,13 +609,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, cb.callback = vhost_vdpa_virtqueue_cb; cb.private = vq; cb.trigger = vq->call_ctx.ctx; + vq->call_ctx.producer.token = vq->call_ctx.ctx; +if (ops->get_status (vdpa) & +VIRTIO_CONFIG_S_DRIVER_OK ) +vhost_vdpa_setup_vq_irq (v, idx); }else { cb.callback =NULL ; cb.private =NULL ; cb.trigger =NULL ; } ops->set_vq_cb (vdpa, idx, &cb); -vhost_vdpa_setup_vq_irq (v, idx);break ;case VHOST_SET_VRING_NUM :
@@ -1235,6 +1244,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)for (i =0 ; i < nvqs; i++) { vqs[i] = &v->vqs[i]; vqs[i]->handle_kick = handle_vq_kick; + vqs[i]->call_ctx.ctx =NULL ; }vhost_dev_init (dev, vqs, nvqs,0 ,0 ,0 , false, vhost_vdpa_process_iotlb_msg);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 259/798 ep93xx: clock: Fix off by one in ep93xx_div_recalc_rate()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit c7f06284a6427475e3df742215535ec3f6cd9662 ]
The psc->div[] array has psc->num_div elements. These values come from when we call clk_hw_register_div(). It's adc_divisors and ARRAY_SIZE(adc_divisors)) and so on. So this condition needs to be >= instead of > to prevent an out of bounds read.
--- arch/arm/mach-ep93xx/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-ep93xx/clock.c +1 -1
@@ -359,7 +359,7 @@ static unsigned long ep93xx_div_recalc_rate(struct clk_hw *hw,u32 val =__raw_readl (psc->reg);u8 index = (val & psc->mask) >> psc->shift; -if (index > psc->num_div) +if (index >= psc->num_div)return 0 ;return DIV_ROUND_UP_ULL (parent_rate, psc->div[index]);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 260/798 Revert "dm: requeue IO if mapping table not yet available"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit c8691cd0fc11197515ed148de0780d927bfca38b ]
This reverts commit fa247089de9936a46e290d4724cb5f0b845600f5.
The following sequence of commands causes a livelock - there will be workqueue process looping and consuming 100% CPU:
dmsetup create --notable test
truncate -s 1MiB testdata
losetup /dev/loop0 testdata
dmsetup load test --table '0 2048 linear /dev/loop0 0' dd if=/dev/zero of=/dev/dm-0 bs=16k count=1 conv=fdatasync
The livelock is caused by the commit fa247089de99. The commit claims that it fixes a race condition, however, it is unknown what the actual race condition is and what program is involved in the race condition.
When the inactive table is loaded, the nodes /dev/dm-0 and /sys/block/dm-0 are created. /dev/dm-0 has zero size at this point. When the device is suspended and resumed, the nodes /dev/mapper/test and /dev/disk/* are created.
If some program opens a block device before it is created by dmsetup or lvm, the program is buggy, so dm could just report an error as it used to do before.
--- drivers/md/dm-rq.c | 4 +++- drivers/md/dm.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/md/dm-rq.c +3 -1
@@ -493,8 +493,10 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx, map =dm_get_live_table (md, &srcu_idx);if (unlikely (!map)) { +DMERR_LIMIT ("%s: mapping table unavailable, erroring io" , +dm_device_name (md));dm_put_live_table (md, srcu_idx); -return BLK_STS_RESOURCE ; +return BLK_STS_IOERR ; } ti =dm_table_find_target (map,0 );dm_put_live_table (md, srcu_idx);
drivers/md/dm.c +8 -3
@@ -1789,10 +1789,15 @@ static void dm_submit_bio(struct bio *bio)struct dm_table *map; map =dm_get_live_table (md, &srcu_idx); +if (unlikely (!map)) { +DMERR_LIMIT ("%s: mapping table unavailable, erroring io" , +dm_device_name (md)); +bio_io_error (bio); + goto out; + } -/* If suspended, or map not yet available, queue this IO for later */ -if (unlikely (test_bit (DMF_BLOCK_IO_FOR_SUSPEND , &md->flags)) || -unlikely (!map)) { +/* If suspended, queue this IO for later */ +if (unlikely (test_bit (DMF_BLOCK_IO_FOR_SUSPEND , &md->flags))) {if (bio->bi_opf &REQ_NOWAIT )bio_wouldblock_error (bio);else if (bio->bi_opf &REQ_RAHEAD )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 261/798 net: xilinx: axienet: Schedule NAPI in two steps
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit ba0da2dc934ec5ac32bbeecbd0670da16ba03565 ]
As advised by Documentation/networking/napi.rst, masking IRQs after calling napi_schedule can be racy. Avoid this by only masking/scheduling if napi_schedule_prep returns true.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8 -6
@@ -1041,9 +1041,10 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)u32 cr = lp->tx_dma_cr; cr &= ~(XAXIDMA_IRQ_IOC_MASK |XAXIDMA_IRQ_DELAY_MASK ); -axienet_dma_out32 (lp,XAXIDMA_TX_CR_OFFSET , cr); - -napi_schedule (&lp->napi_tx); +if (napi_schedule_prep (&lp->napi_tx)) { +axienet_dma_out32 (lp,XAXIDMA_TX_CR_OFFSET , cr); +__napi_schedule (&lp->napi_tx); + } }return IRQ_HANDLED ;
@@ -1085,9 +1086,10 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)u32 cr = lp->rx_dma_cr; cr &= ~(XAXIDMA_IRQ_IOC_MASK |XAXIDMA_IRQ_DELAY_MASK ); -axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); - -napi_schedule (&lp->napi_rx); +if (napi_schedule_prep (&lp->napi_rx)) { +axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); +__napi_schedule (&lp->napi_rx); + } }return IRQ_HANDLED ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 262/798 net: xilinx: axienet: Fix packet counting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit 5a6caa2cfabb559309b5ce29ee7c8e9ce1a9a9df ]
axienet_free_tx_chain returns the number of DMA descriptors it's handled. However, axienet_tx_poll treats the return as the number of packets. When scatter-gather SKBs are enabled, a single packet may use multiple DMA descriptors, which causes incorrect packet counts. Fix this by explicitly keepting track of the number of packets processed as separate from the DMA descriptors.
Budget does not affect the number of Tx completions we can process for NAPI, so we use the ring size as the limit instead of budget. As we no longer return the number of descriptors processed to axienet_tx_poll, we now update tx_bd_ci in axienet_free_tx_chain.
--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +14 -9
@@ -651,15 +651,15 @@ static int axienet_device_reset(struct net_device *ndev)* * Would either be called after a successful transmit operation, or after * there was an error when setting up the chain. -* Returns the number of descriptors handled. +* Returns the number of packets handled. */ static int axienet_free_tx_chain (struct axienet_local *lp,u32 first_bd,int nr_bds,bool force,u32 *sizep,int budget) {struct axidma_bd *cur_p;unsigned int status; +int i, packets =0 ;dma_addr_t phys; -int i;for (i =0 ; i < nr_bds; i++) { cur_p = &lp->tx_bd_v[(first_bd + i) % lp->tx_bd_num];
@@ -678,8 +678,10 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ), DMA_TO_DEVICE); -if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) +if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) {napi_consume_skb (cur_p->skb, budget); + packets++; + } cur_p->app0 =0 ; cur_p->app1 =0 ;
@@ -695,7 +697,13 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, *sizep += status &XAXIDMA_BD_STS_ACTUAL_LEN_MASK ; } -return i; +if (!force) { + lp->tx_bd_ci += i; +if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci %= lp->tx_bd_num; + } + +return packets; }/**
@@ -746,13 +754,10 @@ static int axienet_tx_poll(struct napi_struct *napi, int budget)u32 size =0 ;int packets; - packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, budget, false, &size, budget); + packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, lp->tx_bd_num, false, + &size, budget);if (packets) { - lp->tx_bd_ci += packets; -if (lp->tx_bd_ci >= lp->tx_bd_num) - lp->tx_bd_ci %= lp->tx_bd_num; -u64_stats_update_begin (&lp->tx_stat_sync);u64_stats_add (&lp->tx_packets, packets);u64_stats_add (&lp->tx_bytes, size);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 263/798 netfilter: nf_reject_ipv6: fix nf_reject_ip6_tcphdr_put()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9c778fe48d20ef362047e3376dee56d77f8500d4 ]
syzbot reported that nf_reject_ip6_tcphdr_put() was possibly sending garbage on the four reserved tcp bits (th->res1)
Use skb_put_zero() to clear the whole TCP header,
as done in nf_reject_ip_tcphdr_put()
BUG: KMSAN: uninit-value in nf_reject_ip6_tcphdr_put+0x688/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:255 nf_reject_ip6_tcphdr_put+0x688/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:255 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588 do_softirq+0x9a/0x100 kernel/softirq.c:455 __local_bh_enable_ip+0x9f/0xb0 kernel/softirq.c:382 local_bh_enable include/linux/bottom_half.h:33 [inline] rcu_read_unlock_bh include/linux/rcupdate.h:908 [inline] __dev_queue_xmit+0x2692/0x5610 net/core/dev.c:4450 dev_queue_xmit include/linux/netdevice.h:3105 [inline] neigh_resolve_output+0x9ca/0xae0 net/core/neighbour.c:1565 neigh_output include/net/neighbour.h:542 [inline] ip6_finish_output2+0x2347/0x2ba0 net/ipv6/ip6_output.c:141 __ip6_finish_output net/ipv6/ip6_output.c:215 [inline] ip6_finish_output+0xbb8/0x14b0 net/ipv6/ip6_output.c:226 NF_HOOK_COND include/linux/netfilter.h:303 [inline] ip6_output+0x356/0x620 net/ipv6/ip6_output.c:247 dst_output include/net/dst.h:450 [inline] NF_HOOK include/linux/netfilter.h:314 [inline] ip6_xmit+0x1ba6/0x25d0 net/ipv6/ip6_output.c:366 inet6_csk_xmit+0x442/0x530 net/ipv6/inet6_connection_sock.c:135 __tcp_transmit_skb+0x3b07/0x4880 net/ipv4/tcp_output.c:1466 tcp_transmit_skb net/ipv4/tcp_output.c:1484 [inline] tcp_connect+0x35b6/0x7130 net/ipv4/tcp_output.c:4143 tcp_v6_connect+0x1bcc/0x1e40 net/ipv6/tcp_ipv6.c:333 __inet_stream_connect+0x2ef/0x1730 net/ipv4/af_inet.c:679 inet_stream_connect+0x6a/0xd0 net/ipv4/af_inet.c:750 __sys_connect_file net/socket.c:2061 [inline] __sys_connect+0x606/0x690 net/socket.c:2078 __do_sys_connect net/socket.c:2088 [inline] __se_sys_connect net/socket.c:2085 [inline] __x64_sys_connect+0x91/0xe0 net/socket.c:2085 x64_sys_call+0x27a5/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:43 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
nf_reject_ip6_tcphdr_put+0x60c/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:249 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588
Uninit was stored to memory at:
nf_reject_ip6_tcphdr_put+0x2ca/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:231 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588
Uninit was created at:
slab_post_alloc_hook mm/slub.c:3998 [inline] slab_alloc_node mm/slub.c:4041 [inline] kmem_cache_alloc_node_noprof+0x6bf/0xb80 mm/slub.c:4084 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:583 __alloc_skb+0x363/0x7b0 net/core/skbuff.c:674 alloc_skb include/linux/skbuff.h:1320 [inline] nf_send_reset6+0x98d/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:327 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588
--- net/ipv6/netfilter/nf_reject_ipv6.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
net/ipv6/netfilter/nf_reject_ipv6.c +2 -12
@@ -223,33 +223,23 @@ void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb, const struct tcphdr *oth, unsigned int otcplen) { struct tcphdr *tcph; -int needs_ack;skb_reset_transport_header (nskb); - tcph =skb_put (nskb,sizeof (struct tcphdr )); + tcph =skb_put_zero (nskb,sizeof (struct tcphdr ));/* Truncate to length (no data) */ tcph->doff =sizeof (struct tcphdr )/4 ; tcph->source = oth->dest; tcph->dest = oth->source;if (oth->ack) { - needs_ack =0 ; tcph->seq = oth->ack_seq; - tcph->ack_seq =0 ; }else { - needs_ack =1 ; tcph->ack_seq =htonl (ntohl (oth->seq) + oth->syn + oth->fin + otcplen - (oth->doff<<2 )); - tcph->seq =0 ; + tcph->ack =1 ; } -/* Reset flags */ - ((u_int8_t *)tcph)[13 ] =0 ; tcph->rst =1 ; - tcph->ack = needs_ack; - tcph->window =0 ; - tcph->urg_ptr =0 ; - tcph->check =0 ;/* Adjust TCP checksum */ tcph->check = csum_ipv6_magic(&ipv6_hdr(nskb)->saddr,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 264/798 net: seeq: Fix use after free vulnerability in ether3 Driver Due to Race Condition
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixin Wang <[email protected]>
[ Upstream commit b5109b60ee4fcb2f2bb24f589575e10cc5283ad4 ]
In the ether3_probe function, a timer is initialized with a callback function ether3_ledoff, bound to &prev(dev)->timer. Once the timer is started, there is a risk of a race condition if the module or device is removed, triggering the ether3_remove function to perform cleanup. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| ether3_ledoff
ether3_remove |
free_netdev(dev); |
put_devic |
kfree(dev); |
| ether3_outw(priv(dev)->regs.config2 |= CFG2_CTRLO, REG_CONFIG2);
| // use devFix it by ensuring that the timer is canceled before proceeding with the cleanup in ether3_remove.
--- drivers/net/ethernet/seeq/ether3.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/seeq/ether3.c +2 -0
@@ -847,9 +847,11 @@ static void ether3_remove(struct expansion_card *ec) {struct net_device *dev =ecard_get_drvdata (ec); +ether3_outw (priv (dev)->regs.config2 |=CFG2_CTRLO ,REG_CONFIG2 );ecard_set_drvdata (ec,NULL );unregister_netdev (dev); +del_timer_sync (&priv (dev)->timer);free_netdev (dev);ecard_release_resources (ec); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 265/798 net: ipv6: select DST_CACHE from IPV6_RPL_LWTUNNEL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 93c21077bb9ba08807c459982d440dbbee4c7af3 ]
The rpl sr tunnel code contains calls to dst_cache_*() which are only present when the dst cache is built.
Select DST_CACHE to build the dst cache, similar to other kconfig options in the same file.
Compiling the rpl sr tunnel without DST_CACHE will lead to linker errors.
--- net/ipv6/Kconfig | 1 + 1 file changed, 1 insertion(+)
net/ipv6/Kconfig +1 -0
@@ -323,6 +323,7 @@ config IPV6_RPL_LWTUNNEL bool "IPv6: RPL Source Routing Header support" depends on IPV6 select LWTUNNEL + select DST_CACHE help Support for RFC6554 RPL Source Routing Header using the lightweight tunnels mechanism.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/798 tcp: check skb is non-NULL in tcp_rto_delta_us()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Hunt <[email protected]>
[ Upstream commit c8770db2d54437a5f49417ae7b46f7de23d14db6 ]
We have some machines running stock Ubuntu 20.04.6 which is their 5.4.0-174-generic kernel that are running ceph and recently hit a null ptr dereference in tcp_rearm_rto(). Initially hitting it from the TLP path, but then later we also saw it getting hit from the RACK case as well. Here are examples of the oops messages we saw in each of those cases:
Jul 26 15:05:02 rx [11061395.780353] BUG: kernel NULL pointer dereference, address: 0000000000000020 Jul 26 15:05:02 rx [11061395.787572] #PF: supervisor read access in kernel mode Jul 26 15:05:02 rx [11061395.792971] #PF: error_code(0x0000) - not-present page Jul 26 15:05:02 rx [11061395.798362] PGD 0 P4D 0 Jul 26 15:05:02 rx [11061395.801164] Oops: 0000 [#1] SMP NOPTI Jul 26 15:05:02 rx [11061395.805091] CPU: 0 PID: 9180 Comm: msgr-worker-1 Tainted: G W 5.4.0-174-generic #193-Ubuntu Jul 26 15:05:02 rx [11061395.814996] Hardware name: Supermicro SMC 2x26 os-gen8 64C NVME-Y 256G/H12SSW-NTR, BIOS 2.5.V1.2U.NVMe.UEFI 05/09/2023 Jul 26 15:05:02 rx [11061395.825952] RIP: 0010:tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061395.830656] Code: 87 ca 04 00 00 00 5b 41 5c 41 5d 5d c3 c3 49 8b bc 24 40 06 00 00 eb 8d 48 bb cf f7 53 e3 a5 9b c4 20 4c 89 ef e8 0c fe 0e 00 <48> 8b 78 20 48 c1 ef 03 48 89 f8 41 8b bc 24 80 04 00 00 48 f7 e3 Jul 26 15:05:02 rx [11061395.849665] RSP: 0018:ffffb75d40003e08 EFLAGS: 00010246 Jul 26 15:05:02 rx [11061395.855149] RAX: 0000000000000000 RBX: 20c49ba5e353f7cf RCX: 0000000000000000 Jul 26 15:05:02 rx [11061395.862542] RDX: 0000000062177c30 RSI: 000000000000231c RDI: ffff9874ad283a60 Jul 26 15:05:02 rx [11061395.869933] RBP: ffffb75d40003e20 R08: 0000000000000000 R09: ffff987605e20aa8 Jul 26 15:05:02 rx [11061395.877318] R10: ffffb75d40003f00 R11: ffffb75d4460f740 R12: ffff9874ad283900 Jul 26 15:05:02 rx [11061395.884710] R13: ffff9874ad283a60 R14: ffff9874ad283980 R15: ffff9874ad283d30 Jul 26 15:05:02 rx [11061395.892095] FS: 00007f1ef4a2e700(0000) GS:ffff987605e00000(0000) knlGS:0000000000000000 Jul 26 15:05:02 rx [11061395.900438] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 26 15:05:02 rx [11061395.906435] CR2: 0000000000000020 CR3: 0000003e450ba003 CR4: 0000000000760ef0 Jul 26 15:05:02 rx [11061395.913822] PKRU: 55555554 Jul 26 15:05:02 rx [11061395.916786] Call Trace: Jul 26 15:05:02 rx [11061395.919488] Jul 26 15:05:02 rx [11061395.921765] ? show_regs.cold+0x1a/0x1f Jul 26 15:05:02 rx [11061395.925859] ? __die+0x90/0xd9 Jul 26 15:05:02 rx [11061395.929169] ? no_context+0x196/0x380 Jul 26 15:05:02 rx [11061395.933088] ? ip6_protocol_deliver_rcu+0x4e0/0x4e0 Jul 26 15:05:02 rx [11061395.938216] ? ip6_sublist_rcv_finish+0x3d/0x50 Jul 26 15:05:02 rx [11061395.943000] ? __bad_area_nosemaphore+0x50/0x1a0 Jul 26 15:05:02 rx [11061395.947873] ? bad_area_nosemaphore+0x16/0x20 Jul 26 15:05:02 rx [11061395.952486] ? do_user_addr_fault+0x267/0x450 Jul 26 15:05:02 rx [11061395.957104] ? ipv6_list_rcv+0x112/0x140 Jul 26 15:05:02 rx [11061395.961279] ? __do_page_fault+0x58/0x90 Jul 26 15:05:02 rx [11061395.965458] ? do_page_fault+0x2c/0xe0 Jul 26 15:05:02 rx [11061395.969465] ? page_fault+0x34/0x40 Jul 26 15:05:02 rx [11061395.973217] ? tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061395.977313] ? tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061395.981408] tcp_send_loss_probe+0x10b/0x220 Jul 26 15:05:02 rx [11061395.985937] tcp_write_timer_handler+0x1b4/0x240 Jul 26 15:05:02 rx [11061395.990809] tcp_write_timer+0x9e/0xe0 Jul 26 15:05:02 rx [11061395.994814] ? tcp_write_timer_handler+0x240/0x240 Jul 26 15:05:02 rx [11061395.999866] call_timer_fn+0x32/0x130 Jul 26 15:05:02 rx [11061396.003782] __run_timers.part.0+0x180/0x280 Jul 26 15:05:02 rx [11061396.008309] ? recalibrate_cpu_khz+0x10/0x10 Jul 26 15:05:02 rx [11061396.012841] ? native_x2apic_icr_write+0x30/0x30 Jul 26 15:05:02 rx [11061396.017718] ? lapic_next_event+0x21/0x30 Jul 26 15:05:02 rx [11061396.021984] ? clockevents_program_event+0x8f/0xe0 Jul 26 15:05:02 rx [11061396.027035] run_timer_softirq+0x2a/0x50 Jul 26 15:05:02 rx [11061396.031212] __do_softirq+0xd1/0x2c1 Jul 26 15:05:02 rx [11061396.035044] do_softirq_own_stack+0x2a/0x40 Jul 26 15:05:02 rx [11061396.039480] Jul 26 15:05:02 rx [11061396.041840] do_softirq.part.0+0x46/0x50 Jul 26 15:05:02 rx [11061396.046022] __local_bh_enable_ip+0x50/0x60 Jul 26 15:05:02 rx [11061396.050460] _raw_spin_unlock_bh+0x1e/0x20 Jul 26 15:05:02 rx [11061396.054817] nf_conntrack_tcp_packet+0x29e/0xbe0 [nf_conntrack] Jul 26 15:05:02 rx [11061396.060994] ? get_l4proto+0xe7/0x190 [nf_conntrack] Jul 26 15:05:02 rx [11061396.066220] nf_conntrack_in+0xe9/0x670 [nf_conntrack] Jul 26 15:05:02 rx [11061396.071618] ipv6_conntrack_local+0x14/0x20 [nf_conntrack] Jul 26 15:05:02 rx [11061396.077356] nf_hook_slow+0x45/0xb0 Jul 26 15:05:02 rx [11061396.081098] ip6_xmit+0x3f0/0x5d0 Jul 26 15:05:02 rx [11061396.084670] ? ipv6_anycast_cleanup+0x50/0x50 Jul 26 15:05:02 rx [11061396.089282] ? __sk_dst_check+0x38/0x70 Jul 26 15:05:02 rx [11061396.093381] ? inet6_csk_route_socket+0x13b/0x200 Jul 26 15:05:02 rx [11061396.098346] inet6_csk_xmit+0xa7/0xf0 Jul 26 15:05:02 rx [11061396.102263] __tcp_transmit_skb+0x550/0xb30 Jul 26 15:05:02 rx [11061396.106701] tcp_write_xmit+0x3c6/0xc20 Jul 26 15:05:02 rx [11061396.110792] ? __alloc_skb+0x98/0x1d0 Jul 26 15:05:02 rx [11061396.114708] __tcp_push_pending_frames+0x37/0x100 Jul 26 15:05:02 rx [11061396.119667] tcp_push+0xfd/0x100 Jul 26 15:05:02 rx [11061396.123150] tcp_sendmsg_locked+0xc70/0xdd0 Jul 26 15:05:02 rx [11061396.127588] tcp_sendmsg+0x2d/0x50 Jul 26 15:05:02 rx [11061396.131245] inet6_sendmsg+0x43/0x70 Jul 26 15:05:02 rx [11061396.135075] __sock_sendmsg+0x48/0x70 Jul 26 15:05:02 rx [11061396.138994] ____sys_sendmsg+0x212/0x280 Jul 26 15:05:02 rx [11061396.143172] ___sys_sendmsg+0x88/0xd0 Jul 26 15:05:02 rx [11061396.147098] ? __seccomp_filter+0x7e/0x6b0 Jul 26 15:05:02 rx [11061396.151446] ? __switch_to+0x39c/0x460 Jul 26 15:05:02 rx [11061396.155453] ? __switch_to_asm+0x42/0x80 Jul 26 15:05:02 rx [11061396.159636] ? __switch_to_asm+0x5a/0x80 Jul 26 15:05:02 rx [11061396.163816] __sys_sendmsg+0x5c/0xa0 Jul 26 15:05:02 rx [11061396.167647] __x64_sys_sendmsg+0x1f/0x30 Jul 26 15:05:02 rx [11061396.171832] do_syscall_64+0x57/0x190 Jul 26 15:05:02 rx [11061396.175748] entry_SYSCALL_64_after_hwframe+0x5c/0xc1 Jul 26 15:05:02 rx [11061396.181055] RIP: 0033:0x7f1ef692618d Jul 26 15:05:02 rx [11061396.184893] Code: 28 89 54 24 1c 48 89 74 24 10 89 7c 24 08 e8 ca ee ff ff 8b 54 24 1c 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 2f 44 89 c7 48 89 44 24 08 e8 fe ee ff ff 48 Jul 26 15:05:02 rx [11061396.203889] RSP: 002b:00007f1ef4a26aa0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e Jul 26 15:05:02 rx [11061396.211708] RAX: ffffffffffffffda RBX: 000000000000084b RCX: 00007f1ef692618d Jul 26 15:05:02 rx [11061396.219091] RDX: 0000000000004000 RSI: 00007f1ef4a26b10 RDI: 0000000000000275 Jul 26 15:05:02 rx [11061396.226475] RBP: 0000000000004000 R08: 0000000000000000 R09: 0000000000000020 Jul 26 15:05:02 rx [11061396.233859] R10: 0000000000000000 R11: 0000000000000293 R12: 000000000000084b Jul 26 15:05:02 rx [11061396.241243] R13: 00007f1ef4a26b10 R14: 0000000000000275 R15: 000055592030f1e8 Jul 26 15:05:02 rx [11061396.248628] Modules linked in: vrf bridge stp llc vxlan ip6_udp_tunnel udp_tunnel nls_iso8859_1 amd64_edac_mod edac_mce_amd kvm_amd kvm crct10dif_pclmul ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper wmi_bmof ipmi_ssif input_leds joydev rndis_host cdc_ether usbnet mii ast drm_vram_helper ttm drm_kms_helper i2c_algo_bit fb_sys_fops syscopyarea sysfillrect sysimgblt ccp mac_hid ipmi_si ipmi_devintf ipmi_msghandler nft_ct sch_fq_codel nf_tables_set nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink ramoops reed_solomon efi_pstore drm ip_tables x_tables autofs4 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid0 multipath linear mlx5_ib ib_uverbs ib_core raid1 mlx5_core hid_generic pci_hyperv_intf crc32_pclmul tls usbhid ahci mlxfw bnxt_en libahci hid nvme i2c_piix4 nvme_core wmi Jul 26 15:05:02 rx [11061396.324334] CR2: 0000000000000020 Jul 26 15:05:02 rx [11061396.327944] ---[ end trace 68a2b679d1cfb4f1 ]--- Jul 26 15:05:02 rx [11061396.433435] RIP: 0010:tcp_rearm_rto+0xe4/0x160 Jul 26 15:05:02 rx [11061396.438137] Code: 87 ca 04 00 00 00 5b 41 5c 41 5d 5d c3 c3 49 8b bc 24 40 06 00 00 eb 8d 48 bb cf f7 53 e3 a5 9b c4 20 4c 89 ef e8 0c fe 0e 00 <48> 8b 78 20 48 c1 ef 03 48 89 f8 41 8b bc 24 80 04 00 00 48 f7 e3 Jul 26 15:05:02 rx [11061396.457144] RSP: 0018:ffffb75d40003e08 EFLAGS: 00010246 Jul 26 15:05:02 rx [11061396.462629] RAX: 0000000000000000 RBX: 20c49ba5e353f7cf RCX: 0000000000000000 Jul 26 15:05:02 rx [11061396.470012] RDX: 0000000062177c30 RSI: 000000000000231c RDI: ffff9874ad283a60 Jul 26 15:05:02 rx [11061396.477396] RBP: ffffb75d40003e20 R08: 0000000000000000 R09: ffff987605e20aa8 Jul 26 15:05:02 rx [11061396.484779] R10: ffffb75d40003f00 R11: ffffb75d4460f740 R12: ffff9874ad283900 Jul 26 15:05:02 rx [11061396.492164] R13: ffff9874ad283a60 R14: ffff9874ad283980 R15: ffff9874ad283d30 Jul 26 15:05:02 rx [11061396.499547] FS: 00007f1ef4a2e700(0000) GS:ffff987605e00000(0000) knlGS:0000000000000000 Jul 26 15:05:02 rx [11061396.507886] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 26 15:05:02 rx [11061396.513884] CR2: 0000000000000020 CR3: 0000003e450ba003 CR4: 0000000000760ef0 Jul 26 15:05:02 rx [11061396.521267] PKRU: 55555554 Jul 26 15:05:02 rx [11061396.524230] Kernel panic - not syncing: Fatal exception in interrupt Jul 26 15:05:02 rx [11061396.530885] Kernel Offset: 0x1b200000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) Jul 26 15:05:03 rx [11061396.660181] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
After we hit this we disabled TLP by setting tcp_early_retrans to 0 and then hit the crash in the RACK case:
Aug 7 07:26:16 rx [1006006.265582] BUG: kernel NULL pointer dereference, address: 0000000000000020
Aug 7 07:26:16 rx [1006006.272719] #PF: supervisor read access in kernel mode
Aug 7 07:26:16 rx [1006006.278030] #PF: error_code(0x0000) - not-present page
Aug 7 07:26:16 rx [1006006.283343] PGD 0 P4D 0
Aug 7 07:26:16 rx [1006006.286057] Oops: 0000 [#1] SMP NOPTI
Aug 7 07:26:16 rx [1006006.289896] CPU: 5 PID: 0 Comm: swapper/5 Tainted: G W 5.4.0-174-generic #193-Ubuntu
Aug 7 07:26:16 rx [1006006.299107] Hardware name: Supermicro SMC 2x26 os-gen8 64C NVME-Y 256G/H12SSW-NTR, BIOS 2.5.V1.2U.NVMe.UEFI 05/09/2023
Aug 7 07:26:16 rx [1006006.309970] RIP: 0010:tcp_rearm_rto+0xe4/0x160
Aug 7 07:26:16 rx [1006006.314584] Code: 87 ca 04 00 00 00 5b 41 5c 41 5d 5d c3 c3 49 8b bc 24 40 06 00 00 eb 8d 48 bb cf f7 53 e3 a5 9b c4 20 4c 89 ef e8 0c fe 0e 00 <48> 8b 78 20 48 c1 ef 03 48 89 f8 41 8b bc 24 80 04 00 00 48 f7 e3
Aug 7 07:26:16 rx [1006006.333499] RSP: 0018:ffffb42600a50960 EFLAGS: 00010246
Aug 7 07:26:16 rx [1006006.338895] RAX: 0000000000000000 RBX: 20c49ba5e353f7cf RCX: 0000000000000000
Aug 7 07:26:16 rx [1006006.346193] RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff92d687ed8160
Aug 7 07:26:16 rx [1006006.353489] RBP: ffffb42600a50978 R08: 0000000000000000 R09: 00000000cd896dcc
Aug 7 07:26:16 rx [1006006.360786] R10: ffff92dc3404f400 R11: 0000000000000001 R12: ffff92d687ed8000
Aug 7 07:26:16 rx [1006006.368084] R13: ffff92d687ed8160 R14: 00000000cd896dcc R15: 00000000cd8fca81
Aug 7 07:26:16 rx [1006006.375381] FS: 0000000000000000(0000) GS:ffff93158ad40000(0000) knlGS:0000000000000000
Aug 7 07:26:16 rx [1006006.383632] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Aug 7 07:26:16 rx [1006006.389544] CR2: 0000000000000020 CR3: 0000003e775ce006 CR4: 0000000000760ee0
Aug 7 07:26:16 rx [1006006.396839] PKRU: 55555554
Aug 7 07:26:16 rx [1006006.399717] Call Trace:
Aug 7 07:26:16 rx [1006006.402335]
Aug 7 07:26:16 rx [1006006.404525] ? show_regs.cold+0x1a/0x1f
Aug 7 07:26:16 rx [1006006.408532] ? __die+0x90/0xd9
Aug 7 07:26:16 rx [1006006.411760] ? no_context+0x196/0x380
Aug 7 07:26:16 rx [1006006.415599] ? __bad_area_nosemaphore+0x50/0x1a0
Aug 7 07:26:16 rx [1006006.420392] ? _raw_spin_lock+0x1e/0x30
Aug 7 07:26:16 rx [1006006.424401] ? bad_area_nosemaphore+0x16/0x20
Aug 7 07:26:16 rx [1006006.428927] ? do_user_addr_fault+0x267/0x450
Aug 7 07:26:16 rx [1006006.433450] ? __do_page_fault+0x58/0x90
Aug 7 07:26:16 rx [1006006.437542] ? do_page_fault+0x2c/0xe0
Aug 7 07:26:16 rx [1006006.441470] ? page_fault+0x34/0x40
Aug 7 07:26:16 rx [1006006.445134] ? tcp_rearm_rto+0xe4/0x160
Aug 7 07:26:16 rx [1006006.449145] tcp_ack+0xa32/0xb30
Aug 7 07:26:16 rx [1006006.452542] tcp_rcv_established+0x13c/0x670
Aug 7 07:26:16 rx [1006006.456981] ? sk_filter_trim_cap+0x48/0x220
Aug 7 07:26:16 rx [1006006.461419] tcp_v6_do_rcv+0xdb/0x450
Aug 7 07:26:16 rx [1006006.465257] tcp_v6_rcv+0xc2b/0xd10
Aug 7 07:26:16 rx [1006006.468918] ip6_protocol_deliver_rcu+0xd3/0x4e0
Aug 7 07:26:16 rx [1006006.473706] ip6_input_finish+0x15/0x20
Aug 7 07:26:16 rx [1006006.477710] ip6_input+0xa2/0xb0
Aug 7 07:26:16 rx [1006006.481109] ? ip6_protocol_deliver_rcu+0x4e0/0x4e0
Aug 7 07:26:16 rx [1006006.486151] ip6_sublist_rcv_finish+0x3d/0x50
Aug 7 07:26:16 rx [1006006.490679] ip6_sublist_rcv+0x1aa/0x250
Aug 7 07:26:16 rx [1006006.494779] ? ip6_rcv_finish_core.isra.0+0xa0/0xa0
Aug 7 07:26:16 rx [1006006.499828] ipv6_list_rcv+0x112/0x140
Aug 7 07:26:16 rx [1006006.503748] __netif_receive_skb_list_core+0x1a4/0x250
Aug 7 07:26:16 rx [1006006.509057] netif_receive_skb_list_internal+0x1a1/0x2b0
Aug 7 07:26:16 rx [1006006.514538] gro_normal_list.part.0+0x1e/0x40
Aug 7 07:26:16 rx [1006006.519068] napi_complete_done+0x91/0x130
Aug 7 07:26:16 rx [1006006.523352] mlx5e_napi_poll+0x18e/0x610 [mlx5_core]
Aug 7 07:26:16 rx [1006006.528481] net_rx_action+0x142/0x390
Aug 7 07:26:16 rx [1006006.532398] __do_softirq+0xd1/0x2c1
Aug 7 07:26:16 rx [1006006.536142] irq_exit+0xae/0xb0
Aug 7 07:26:16 rx [1006006.539452] do_IRQ+0x5a/0xf0
Aug 7 07:26:16 rx [1006006.542590] common_interrupt+0xf/0xf
Aug 7 07:26:16 rx [1006006.546421]
Aug 7 07:26:16 rx [1006006.548695] RIP: 0010:native_safe_halt+0xe/0x10
Aug 7 07:26:16 rx [1006006.553399] Code: 7b ff ff ff eb bd 90 90 90 90 90 90 e9 07 00 00 00 0f 00 2d 36 2c 50 00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d 26 2c 50 00 fb f4 90 0f 1f 44 00 00 55 48 89 e5 41 55 41 54 53 e8 dd 5e 61 ff 65
Aug 7 07:26:16 rx [1006006.572309] RSP: 0018:ffffb42600177e70 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffc2
Aug 7 07:26:16 rx [1006006.580040] RAX: ffffffff8ed08b20 RBX: 0000000000000005 RCX: 0000000000000001
Aug 7 07:26:16 rx [1006006.587337] RDX: 00000000f48eeca2 RSI: 0000000000000082 RDI: 0000000000000082
Aug 7 07:26:16 rx [1006006.594635] RBP: ffffb42600177e90 R08: 0000000000000000 R09: 000000000000020f
Aug 7 07:26:16 rx [1006006.601931] R10: 0000000000100000 R11: 0000000000000000 R12: 0000000000000005
Aug 7 07:26:16 rx [1006006.609229] R13: ffff93157deb5f00 R14: 0000000000000000 R15: 0000000000000000
Aug 7 07:26:16 rx [1006006.616530] ? __cpuidle_text_start+0x8/0x8
Aug 7 07:26:16 rx [1006006.620886] ? default_idle+0x20/0x140
Aug 7 07:26:16 rx [1006006.624804] arch_cpu_idle+0x15/0x20
Aug 7 07:26:16 rx [1006006.628545] default_idle_call+0x23/0x30
Aug 7 07:26:16 rx [1006006.632640] do_idle+0x1fb/0x270
Aug 7 07:26:16 rx [1006006.636035] cpu_startup_entry+0x20/0x30
Aug 7 07:26:16 rx [1006006.640126] start_secondary+0x178/0x1d0
Aug 7 07:26:16 rx [1006006.644218] secondary_startup_64+0xa4/0xb0
Aug 7 07:26:17 rx [1006006.648568] Modules linked in: vrf bridge stp llc vxlan ip6_udp_tunnel udp_tunnel nls_iso8859_1 nft_ct amd64_edac_mod edac_mce_amd kvm_amd kvm crct10dif_pclmul ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper wmi_bmof ipmi_ssif input_leds joydev rndis_host cdc_ether usbnet ast mii drm_vram_helper ttm drm_kms_helper i2c_algo_bit fb_sys_fops syscopyarea sysfillrect sysimgblt ccp mac_hid ipmi_si ipmi_devintf ipmi_msghandler sch_fq_codel nf_tables_set nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink ramoops reed_solomon efi_pstore drm ip_tables x_tables autofs4 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid0 multipath linear mlx5_ib ib_uverbs ib_core raid1 hid_generic mlx5_core pci_hyperv_intf crc32_pclmul usbhid ahci tls mlxfw bnxt_en hid libahci nvme i2c_piix4 nvme_core wmi [last unloaded: cpuid] Aug 7 07:26:17 rx [1006006.726180] CR2: 0000000000000020
Aug 7 07:26:17 rx [1006006.729718] ---[ end trace e0e2e37e4e612984 ]---
Prior to seeing the first crash and on other machines we also see the warning in tcp_send_loss_probe() where packets_out is non-zero, but both transmit and retrans queues are empty so we know the box is seeing some accounting issue in this area:
Jul 26 09:15:27 kernel: ------------[ cut here ]------------ Jul 26 09:15:27 kernel: invalid inflight: 2 state 1 cwnd 68 mss 8988 Jul 26 09:15:27 kernel: WARNING: CPU: 16 PID: 0 at net/ipv4/tcp_output.c:2605 tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: Modules linked in: vrf bridge stp llc vxlan ip6_udp_tunnel udp_tunnel nls_iso8859_1 nft_ct amd64_edac_mod edac_mce_amd kvm_amd kvm crct10dif_pclmul ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper wmi_bmof ipmi_ssif joydev input_leds rndis_host cdc_ether usbnet mii ast drm_vram_helper ttm drm_kms_he> Jul 26 09:15:27 kernel: CPU: 16 PID: 0 Comm: swapper/16 Not tainted 5.4.0-174-generic #193-Ubuntu Jul 26 09:15:27 kernel: Hardware name: Supermicro SMC 2x26 os-gen8 64C NVME-Y 256G/H12SSW-NTR, BIOS 2.5.V1.2U.NVMe.UEFI 05/09/2023 Jul 26 09:15:27 kernel: RIP: 0010:tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: Code: 08 26 01 00 75 e2 41 0f b6 54 24 12 41 8b 8c 24 c0 06 00 00 45 89 f0 48 c7 c7 e0 b4 20 a7 c6 05 8d 08 26 01 01 e8 4a c0 0f 00 <0f> 0b eb ba 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 41 Jul 26 09:15:27 kernel: RSP: 0018:ffffb7838088ce00 EFLAGS: 00010286 Jul 26 09:15:27 kernel: RAX: 0000000000000000 RBX: ffff9b84b5630430 RCX: 0000000000000006 Jul 26 09:15:27 kernel: RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff9b8e4621c8c0 Jul 26 09:15:27 kernel: RBP: ffffb7838088ce18 R08: 0000000000000927 R09: 0000000000000004 Jul 26 09:15:27 kernel: R10: 0000000000000000 R11: 0000000000000001 R12: ffff9b84b5630000 Jul 26 09:15:27 kernel: R13: 0000000000000000 R14: 000000000000231c R15: ffff9b84b5630430 Jul 26 09:15:27 kernel: FS: 0000000000000000(0000) GS:ffff9b8e46200000(0000) knlGS:0000000000000000 Jul 26 09:15:27 kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 26 09:15:27 kernel: CR2: 000056238cec2380 CR3: 0000003e49ede005 CR4: 0000000000760ee0 Jul 26 09:15:27 kernel: PKRU: 55555554 Jul 26 09:15:27 kernel: Call Trace: Jul 26 09:15:27 kernel: <IRQ> Jul 26 09:15:27 kernel: ? show_regs.cold+0x1a/0x1f Jul 26 09:15:27 kernel: ? __warn+0x98/0xe0 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: ? report_bug+0xd1/0x100 Jul 26 09:15:27 kernel: ? do_error_trap+0x9b/0xc0 Jul 26 09:15:27 kernel: ? do_invalid_op+0x3c/0x50 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: ? invalid_op+0x1e/0x30 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: tcp_write_timer_handler+0x1b4/0x240 Jul 26 09:15:27 kernel: tcp_write_timer+0x9e/0xe0 Jul 26 09:15:27 kernel: ? tcp_write_timer_handler+0x240/0x240 Jul 26 09:15:27 kernel: call_timer_fn+0x32/0x130 Jul 26 09:15:27 kernel: __run_timers.part.0+0x180/0x280 Jul 26 09:15:27 kernel: ? timerqueue_add+0x9b/0xb0 Jul 26 09:15:27 kernel: ? enqueue_hrtimer+0x3d/0x90 Jul 26 09:15:27 kernel: ? do_error_trap+0x9b/0xc0 Jul 26 09:15:27 kernel: ? do_invalid_op+0x3c/0x50 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: ? invalid_op+0x1e/0x30 Jul 26 09:15:27 kernel: ? tcp_send_loss_probe+0x214/0x220 Jul 26 09:15:27 kernel: tcp_write_timer_handler+0x1b4/0x240 Jul 26 09:15:27 kernel: tcp_write_timer+0x9e/0xe0 Jul 26 09:15:27 kernel: ? tcp_write_timer_handler+0x240/0x240 Jul 26 09:15:27 kernel: call_timer_fn+0x32/0x130 Jul 26 09:15:27 kernel: __run_timers.part.0+0x180/0x280 Jul 26 09:15:27 kernel: ? timerqueue_add+0x9b/0xb0 Jul 26 09:15:27 kernel: ? enqueue_hrtimer+0x3d/0x90 Jul 26 09:15:27 kernel: ? recalibrate_cpu_khz+0x10/0x10 Jul 26 09:15:27 kernel: ? ktime_get+0x3e/0xa0 Jul 26 09:15:27 kernel: ? native_x2apic_icr_write+0x30/0x30 Jul 26 09:15:27 kernel: run_timer_softirq+0x2a/0x50 Jul 26 09:15:27 kernel: __do_softirq+0xd1/0x2c1 Jul 26 09:15:27 kernel: irq_exit+0xae/0xb0 Jul 26 09:15:27 kernel: smp_apic_timer_interrupt+0x7b/0x140 Jul 26 09:15:27 kernel: apic_timer_interrupt+0xf/0x20 Jul 26 09:15:27 kernel: </IRQ> Jul 26 09:15:27 kernel: RIP: 0010:native_safe_halt+0xe/0x10 Jul 26 09:15:27 kernel: Code: 7b ff ff ff eb bd 90 90 90 90 90 90 e9 07 00 00 00 0f 00 2d 36 2c 50 00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d 26 2c 50 00 fb f4 <c3> 90 0f 1f 44 00 00 55 48 89 e5 41 55 41 54 53 e8 dd 5e 61 ff 65 Jul 26 09:15:27 kernel: RSP: 0018:ffffb783801cfe70 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13 Jul 26 09:15:27 kernel: RAX: ffffffffa6908b20 RBX: 0000000000000010 RCX: 0000000000000001 Jul 26 09:15:27 kernel: RDX: 000000006fc0c97e RSI: 0000000000000082 RDI: 0000000000000082 Jul 26 09:15:27 kernel: RBP: ffffb783801cfe90 R08: 0000000000000000 R09: 0000000000000225 Jul 26 09:15:27 kernel: R10: 0000000000100000 R11: 0000000000000000 R12: 0000000000000010 Jul 26 09:15:27 kernel: R13: ffff9b8e390b0000 R14: 0000000000000000 R15: 0000000000000000 Jul 26 09:15:27 kernel: ? __cpuidle_text_start+0x8/0x8 Jul 26 09:15:27 kernel: ? default_idle+0x20/0x140 Jul 26 09:15:27 kernel: arch_cpu_idle+0x15/0x20 Jul 26 09:15:27 kernel: default_idle_call+0x23/0x30 Jul 26 09:15:27 kernel: do_idle+0x1fb/0x270 Jul 26 09:15:27 kernel: cpu_startup_entry+0x20/0x30 Jul 26 09:15:27 kernel: start_secondary+0x178/0x1d0 Jul 26 09:15:27 kernel: secondary_startup_64+0xa4/0xb0 Jul 26 09:15:27 kernel: ---[ end trace e7ac822987e33be1 ]---
The NULL ptr deref is coming from tcp_rto_delta_us() attempting to pull an skb off the head of the retransmit queue and then dereferencing that skb to get the skb_mstamp_ns value via tcp_skb_timestamp_us(skb).
The crash is the same one that was reported a # of years ago here:
https://lore.kernel.org/netdev/[email protected]/T/#t
and the kernel we're running has the fix which was added to resolve this issue.
Unfortunately we've been unsuccessful so far in reproducing this problem in the lab and do not have the luxury of pushing out a new kernel to try and test if newer kernels resolve this issue at the moment. I realize this is a report against both an Ubuntu kernel and also an older 5.4 kernel. I have reported this issue to Ubuntu here: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2077657
however I feel like since this issue has possibly cropped up again it makes sense to build in some protection in this path (even on the latest kernel versions) since the code in question just blindly assumes there's a valid skb without testing if it's NULL b/f it looks at the timestamp.
Given we have seen crashes in this path before and now this case it seems like we should protect ourselves for when packets_out accounting is incorrect. While we should fix that root cause we should also just make sure the skb is not NULL before dereferencing it. Also add a warn once here to capture some information if/when the problem case is hit again.
--- include/net/tcp.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
include/net/tcp.h +19 -2
@@ -2176,9 +2176,26 @@ static inline s64 tcp_rto_delta_us(const struct sock *sk) {const struct sk_buff *skb =tcp_rtx_queue_head (sk);u32 rto =inet_csk (sk)->icsk_rto; -u64 rto_time_stamp_us =tcp_skb_timestamp_us (skb) +jiffies_to_usecs (rto); -return rto_time_stamp_us -tcp_sk (sk)->tcp_mstamp; +if (likely (skb)) { +u64 rto_time_stamp_us =tcp_skb_timestamp_us (skb) +jiffies_to_usecs (rto); + +return rto_time_stamp_us -tcp_sk (sk)->tcp_mstamp; + }else { +WARN_ONCE (1 , +"rtx queue emtpy: " +"out:%u sacked:%u lost:%u retrans:%u " +"tlp_high_seq:%u sk_state:%u ca_state:%u " +"advmss:%u mss_cache:%u pmtu:%u\n" , +tcp_sk (sk)->packets_out,tcp_sk (sk)->sacked_out, +tcp_sk (sk)->lost_out,tcp_sk (sk)->retrans_out, +tcp_sk (sk)->tlp_high_seq, sk->sk_state, +inet_csk (sk)->icsk_ca_state, +tcp_sk (sk)->advmss,tcp_sk (sk)->mss_cache, +inet_csk (sk)->icsk_pmtu_cookie); +return jiffies_to_usecs (rto); + } + }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/798 net: qrtr: Update packets cloning when broadcasting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youssef Samir <[email protected]>
[ Upstream commit f011b313e8ebd5b7abd8521b5119aecef403de45 ]
When broadcasting data to multiple nodes via MHI, using skb_clone() causes all nodes to receive the same header data. This can result in packets being discarded by endpoints, leading to lost data.
This issue occurs when a socket is closed, and a QRTR_TYPE_DEL_CLIENT packet is broadcasted. All nodes receive the same destination node ID, causing the node connected to the client to discard the packet and remain unaware of the client's deletion.
Replace skb_clone() with pskb_copy(), to create a separate copy of the header for each sk_buff.
--- net/qrtr/af_qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/qrtr/af_qrtr.c +1 -1
@@ -879,7 +879,7 @@ static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb,mutex_lock (&qrtr_node_lock);list_for_each_entry (node, &qrtr_all_nodes, item) { - skbn =skb_clone (skb,GFP_KERNEL ); + skbn =pskb_copy (skb,GFP_KERNEL );if (!skbn)break ;skb_set_owner_w (skbn, skb->sk);
Signature · 1 line
2.43.0