From: Sasha Levin Date: Sun, 30 Jun 2024 02:22:22 +0000 (-0400) Subject: Fixes for 6.1 X-Git-Tag: v4.19.317~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b009b3eb08bb790f83f1062b34bd1264a6616648;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.1 Signed-off-by: Sasha Levin --- diff --git a/queue-6.1/alsa-emux-improve-patch-ioctl-data-validation.patch b/queue-6.1/alsa-emux-improve-patch-ioctl-data-validation.patch new file mode 100644 index 00000000000..7f29b848fb2 --- /dev/null +++ b/queue-6.1/alsa-emux-improve-patch-ioctl-data-validation.patch @@ -0,0 +1,81 @@ +From 0ca11237ceb7521c934c43c2eef2d97a393331a6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 6 Apr 2024 08:48:20 +0200 +Subject: ALSA: emux: improve patch ioctl data validation + +From: Oswald Buddenhagen + +[ Upstream commit 89b32ccb12ae67e630c6453d778ec30a592a212f ] + +In load_data(), make the validation of and skipping over the main info +block match that in load_guspatch(). + +In load_guspatch(), add checking that the specified patch length matches +the actually supplied data, like load_data() already did. + +Signed-off-by: Oswald Buddenhagen +Message-ID: <20240406064830.1029573-8-oswald.buddenhagen@gmx.de> +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/synth/emux/soundfont.c | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c +index 16f00097cb95a..eed47e4830248 100644 +--- a/sound/synth/emux/soundfont.c ++++ b/sound/synth/emux/soundfont.c +@@ -701,7 +701,6 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) + struct snd_soundfont *sf; + struct soundfont_sample_info sample_info; + struct snd_sf_sample *sp; +- long off; + + /* patch must be opened */ + sf = sflist->currsf; +@@ -711,12 +710,16 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) + if (is_special_type(sf->type)) + return -EINVAL; + ++ if (count < (long)sizeof(sample_info)) { ++ return -EINVAL; ++ } + if (copy_from_user(&sample_info, data, sizeof(sample_info))) + return -EFAULT; ++ data += sizeof(sample_info); ++ count -= sizeof(sample_info); + +- off = sizeof(sample_info); +- +- if (sample_info.size != (count-off)/2) ++ // SoundFont uses S16LE samples. ++ if (sample_info.size * 2 != count) + return -EINVAL; + + /* Check for dup */ +@@ -744,7 +747,7 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) + int rc; + rc = sflist->callback.sample_new + (sflist->callback.private_data, sp, sflist->memhdr, +- data + off, count - off); ++ data, count); + if (rc < 0) { + sf_sample_delete(sflist, sf, sp); + return rc; +@@ -957,10 +960,12 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, + } + if (copy_from_user(&patch, data, sizeof(patch))) + return -EFAULT; +- + count -= sizeof(patch); + data += sizeof(patch); + ++ if ((patch.len << (patch.mode & WAVE_16_BITS ? 1 : 0)) != count) ++ return -EINVAL; ++ + sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_GUS|SNDRV_SFNT_PAT_SHARED, NULL); + if (sf == NULL) + return -ENOMEM; +-- +2.43.0 + diff --git a/queue-6.1/bpf-add-a-check-for-struct-bpf_fib_lookup-size.patch b/queue-6.1/bpf-add-a-check-for-struct-bpf_fib_lookup-size.patch new file mode 100644 index 00000000000..291c77c7a9f --- /dev/null +++ b/queue-6.1/bpf-add-a-check-for-struct-bpf_fib_lookup-size.patch @@ -0,0 +1,39 @@ +From b2348b8871f9464865634495c156b4d15b103fca Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 26 Mar 2024 10:17:42 +0000 +Subject: bpf: Add a check for struct bpf_fib_lookup size + +From: Anton Protopopov + +[ Upstream commit 59b418c7063d30e0a3e1f592d47df096db83185c ] + +The struct bpf_fib_lookup should not grow outside of its 64 bytes. +Add a static assert to validate this. + +Suggested-by: David Ahern +Signed-off-by: Anton Protopopov +Signed-off-by: Daniel Borkmann +Link: https://lore.kernel.org/bpf/20240326101742.17421-4-aspsk@isovalent.com +Signed-off-by: Alexei Starovoitov +Signed-off-by: Sasha Levin +--- + net/core/filter.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/net/core/filter.c b/net/core/filter.c +index 7a07413913538..dc89c34247187 100644 +--- a/net/core/filter.c ++++ b/net/core/filter.c +@@ -82,6 +82,9 @@ + #include + #include + ++/* Keep the struct bpf_fib_lookup small so that it fits into a cacheline */ ++static_assert(sizeof(struct bpf_fib_lookup) == 64, "struct bpf_fib_lookup size check"); ++ + static const struct bpf_func_proto * + bpf_sk_base_func_proto(enum bpf_func_id func_id); + +-- +2.43.0 + diff --git a/queue-6.1/bpf-mark-bpf-prog-stack-with-kmsan_unposion_memory-i.patch b/queue-6.1/bpf-mark-bpf-prog-stack-with-kmsan_unposion_memory-i.patch new file mode 100644 index 00000000000..d68d445065e --- /dev/null +++ b/queue-6.1/bpf-mark-bpf-prog-stack-with-kmsan_unposion_memory-i.patch @@ -0,0 +1,91 @@ +From 65eb9ce864fd97d407ea78adbb9e2045f0018a49 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 28 Mar 2024 11:58:01 -0700 +Subject: bpf: Mark bpf prog stack with kmsan_unposion_memory in interpreter + mode + +From: Martin KaFai Lau + +[ Upstream commit e8742081db7d01f980c6161ae1e8a1dbc1e30979 ] + +syzbot reported uninit memory usages during map_{lookup,delete}_elem. + +========== +BUG: KMSAN: uninit-value in __dev_map_lookup_elem kernel/bpf/devmap.c:441 [inline] +BUG: KMSAN: uninit-value in dev_map_lookup_elem+0xf3/0x170 kernel/bpf/devmap.c:796 +__dev_map_lookup_elem kernel/bpf/devmap.c:441 [inline] +dev_map_lookup_elem+0xf3/0x170 kernel/bpf/devmap.c:796 +____bpf_map_lookup_elem kernel/bpf/helpers.c:42 [inline] +bpf_map_lookup_elem+0x5c/0x80 kernel/bpf/helpers.c:38 +___bpf_prog_run+0x13fe/0xe0f0 kernel/bpf/core.c:1997 +__bpf_prog_run256+0xb5/0xe0 kernel/bpf/core.c:2237 +========== + +The reproducer should be in the interpreter mode. + +The C reproducer is trying to run the following bpf prog: + + 0: (18) r0 = 0x0 + 2: (18) r1 = map[id:49] + 4: (b7) r8 = 16777216 + 5: (7b) *(u64 *)(r10 -8) = r8 + 6: (bf) r2 = r10 + 7: (07) r2 += -229 + ^^^^^^^^^^ + + 8: (b7) r3 = 8 + 9: (b7) r4 = 0 + 10: (85) call dev_map_lookup_elem#1543472 + 11: (95) exit + +It is due to the "void *key" (r2) passed to the helper. bpf allows uninit +stack memory access for bpf prog with the right privileges. This patch +uses kmsan_unpoison_memory() to mark the stack as initialized. + +This should address different syzbot reports on the uninit "void *key" +argument during map_{lookup,delete}_elem. + +Reported-by: syzbot+603bcd9b0bf1d94dbb9b@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/bpf/000000000000f9ce6d061494e694@google.com/ +Reported-by: syzbot+eb02dc7f03dce0ef39f3@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/bpf/000000000000a5c69c06147c2238@google.com/ +Reported-by: syzbot+b4e65ca24fd4d0c734c3@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/bpf/000000000000ac56fb06143b6cfa@google.com/ +Reported-by: syzbot+d2b113dc9fea5e1d2848@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/bpf/0000000000000d69b206142d1ff7@google.com/ +Reported-by: syzbot+1a3cf6f08d68868f9db3@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/bpf/0000000000006f876b061478e878@google.com/ +Tested-by: syzbot+1a3cf6f08d68868f9db3@syzkaller.appspotmail.com +Suggested-by: Yonghong Song +Suggested-by: Alexei Starovoitov +Signed-off-by: Martin KaFai Lau +Link: https://lore.kernel.org/r/20240328185801.1843078-1-martin.lau@linux.dev +Signed-off-by: Alexei Starovoitov +Signed-off-by: Sasha Levin +--- + kernel/bpf/core.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c +index 16d15d5d1e197..0ea0d50a7c161 100644 +--- a/kernel/bpf/core.c ++++ b/kernel/bpf/core.c +@@ -2034,6 +2034,7 @@ static unsigned int PROG_NAME(stack_size)(const void *ctx, const struct bpf_insn + u64 stack[stack_size / sizeof(u64)]; \ + u64 regs[MAX_BPF_EXT_REG] = {}; \ + \ ++ kmsan_unpoison_memory(stack, sizeof(stack)); \ + FP = (u64) (unsigned long) &stack[ARRAY_SIZE(stack)]; \ + ARG1 = (u64) (unsigned long) ctx; \ + return ___bpf_prog_run(regs, insn); \ +@@ -2047,6 +2048,7 @@ static u64 PROG_NAME_ARGS(stack_size)(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5, \ + u64 stack[stack_size / sizeof(u64)]; \ + u64 regs[MAX_BPF_EXT_REG]; \ + \ ++ kmsan_unpoison_memory(stack, sizeof(stack)); \ + FP = (u64) (unsigned long) &stack[ARRAY_SIZE(stack)]; \ + BPF_R1 = r1; \ + BPF_R2 = r2; \ +-- +2.43.0 + diff --git a/queue-6.1/bpf-take-return-from-set_memory_ro-into-account-with.patch b/queue-6.1/bpf-take-return-from-set_memory_ro-into-account-with.patch new file mode 100644 index 00000000000..598417c0ef9 --- /dev/null +++ b/queue-6.1/bpf-take-return-from-set_memory_ro-into-account-with.patch @@ -0,0 +1,88 @@ +From 7569175d8eeda363ad7f7f6547dfc449f0f357ef Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 8 Mar 2024 06:38:07 +0100 +Subject: bpf: Take return from set_memory_ro() into account with + bpf_prog_lock_ro() + +From: Christophe Leroy + +[ Upstream commit 7d2cc63eca0c993c99d18893214abf8f85d566d8 ] + +set_memory_ro() can fail, leaving memory unprotected. + +Check its return and take it into account as an error. + +Link: https://github.com/KSPP/linux/issues/7 +Signed-off-by: Christophe Leroy +Cc: linux-hardening@vger.kernel.org +Reviewed-by: Kees Cook +Message-ID: <286def78955e04382b227cb3e4b6ba272a7442e3.1709850515.git.christophe.leroy@csgroup.eu> +Signed-off-by: Alexei Starovoitov +Signed-off-by: Sasha Levin +--- + include/linux/filter.h | 5 +++-- + kernel/bpf/core.c | 4 +++- + kernel/bpf/verifier.c | 8 ++++++-- + 3 files changed, 12 insertions(+), 5 deletions(-) + +diff --git a/include/linux/filter.h b/include/linux/filter.h +index face590b24e17..01f97956572ce 100644 +--- a/include/linux/filter.h ++++ b/include/linux/filter.h +@@ -850,14 +850,15 @@ bpf_ctx_narrow_access_offset(u32 off, u32 size, u32 size_default) + + #define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0])) + +-static inline void bpf_prog_lock_ro(struct bpf_prog *fp) ++static inline int __must_check bpf_prog_lock_ro(struct bpf_prog *fp) + { + #ifndef CONFIG_BPF_JIT_ALWAYS_ON + if (!fp->jited) { + set_vm_flush_reset_perms(fp); +- set_memory_ro((unsigned long)fp, fp->pages); ++ return set_memory_ro((unsigned long)fp, fp->pages); + } + #endif ++ return 0; + } + + static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr) +diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c +index 44abf88e1bb0d..16d15d5d1e197 100644 +--- a/kernel/bpf/core.c ++++ b/kernel/bpf/core.c +@@ -2223,7 +2223,9 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err) + } + + finalize: +- bpf_prog_lock_ro(fp); ++ *err = bpf_prog_lock_ro(fp); ++ if (*err) ++ return fp; + + /* The tail call compatibility check can only be done at + * this late stage as we need to determine, if we deal +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c +index 1d851e2f48590..56a5c8beb553d 100644 +--- a/kernel/bpf/verifier.c ++++ b/kernel/bpf/verifier.c +@@ -14113,10 +14113,14 @@ static int jit_subprogs(struct bpf_verifier_env *env) + * bpf_prog_load will add the kallsyms for the main program. + */ + for (i = 1; i < env->subprog_cnt; i++) { +- bpf_prog_lock_ro(func[i]); +- bpf_prog_kallsyms_add(func[i]); ++ err = bpf_prog_lock_ro(func[i]); ++ if (err) ++ goto out_free; + } + ++ for (i = 1; i < env->subprog_cnt; i++) ++ bpf_prog_kallsyms_add(func[i]); ++ + /* Last step: make now unused interpreter insns from main + * prog consistent for later dump requests, so they can + * later look the same as if they were interpreted only. +-- +2.43.0 + diff --git a/queue-6.1/crypto-ecdh-explicitly-zeroize-private_key.patch b/queue-6.1/crypto-ecdh-explicitly-zeroize-private_key.patch new file mode 100644 index 00000000000..98bba7feac0 --- /dev/null +++ b/queue-6.1/crypto-ecdh-explicitly-zeroize-private_key.patch @@ -0,0 +1,46 @@ +From 962eeb5a151211a163becc3398043871cdd9b51a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 28 Mar 2024 11:24:30 -0500 +Subject: crypto: ecdh - explicitly zeroize private_key + +From: Joachim Vandersmissen + +[ Upstream commit 73e5984e540a76a2ee1868b91590c922da8c24c9 ] + +private_key is overwritten with the key parameter passed in by the +caller (if present), or alternatively a newly generated private key. +However, it is possible that the caller provides a key (or the newly +generated key) which is shorter than the previous key. In that +scenario, some key material from the previous key would not be +overwritten. The easiest solution is to explicitly zeroize the entire +private_key array first. + +Note that this patch slightly changes the behavior of this function: +previously, if the ecc_gen_privkey failed, the old private_key would +remain. Now, the private_key is always zeroized. This behavior is +consistent with the case where params.key is set and ecc_is_key_valid +fails. + +Signed-off-by: Joachim Vandersmissen +Signed-off-by: Herbert Xu +Signed-off-by: Sasha Levin +--- + crypto/ecdh.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/crypto/ecdh.c b/crypto/ecdh.c +index 80afee3234fbe..3049f147e0117 100644 +--- a/crypto/ecdh.c ++++ b/crypto/ecdh.c +@@ -33,6 +33,8 @@ static int ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, + params.key_size > sizeof(u64) * ctx->ndigits) + return -EINVAL; + ++ memset(ctx->private_key, 0, sizeof(ctx->private_key)); ++ + if (!params.key || !params.key_size) + return ecc_gen_privkey(ctx->curve_id, ctx->ndigits, + ctx->private_key); +-- +2.43.0 + diff --git a/queue-6.1/drm-amd-amdgpu-fix-style-errors-in-amdgpu_drv.c-amdg.patch b/queue-6.1/drm-amd-amdgpu-fix-style-errors-in-amdgpu_drv.c-amdg.patch new file mode 100644 index 00000000000..f499e167599 --- /dev/null +++ b/queue-6.1/drm-amd-amdgpu-fix-style-errors-in-amdgpu_drv.c-amdg.patch @@ -0,0 +1,174 @@ +From f399774b38c23a3674b92d77cc297c3ec80a1c1a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 19 Apr 2023 16:12:45 +0530 +Subject: drm/amd/amdgpu: Fix style errors in amdgpu_drv.c & amdgpu_device.c +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Srinivasan Shanmugam + +[ Upstream commit 47fc644f801e4414753a9b7e87ed41f991cd68c3 ] + +Fix following checkpatch style errors in amdgpu_drv.c & +amdgpu_device.c + +ERROR: exactly one space required after that #ifdef +ERROR: spaces required around that '+=' (ctx:WxV) +ERROR: space required before the open brace '{' +ERROR: spaces required around that '||' (ctx:VxE) +ERROR: space prohibited before that close parenthesis ')' +ERROR: space required before the open parenthesis '(' +ERROR: space required before the open brace '{' +ERROR: code indent should use tabs where possible + +Cc: Christian König +Cc: Alex Deucher +Cc: Mario Limonciello +Signed-off-by: Srinivasan Shanmugam +Reviewed-by: Christian König +Signed-off-by: Alex Deucher +Stable-dep-of: 74fa02c4a5ea ("drm/amdgpu: Fix pci state save during mode-1 reset") +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 +++++++++++----------- + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- + 2 files changed, 34 insertions(+), 33 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +index b11690a816e73..985688696202a 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +@@ -980,7 +980,7 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev, + if (array_size % 3) + return; + +- for (i = 0; i < array_size; i +=3) { ++ for (i = 0; i < array_size; i += 3) { + reg = registers[i + 0]; + and_mask = registers[i + 1]; + or_mask = registers[i + 2]; +@@ -1552,7 +1552,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev) + dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n", + amdgpu_sched_jobs); + amdgpu_sched_jobs = 4; +- } else if (!is_power_of_2(amdgpu_sched_jobs)){ ++ } else if (!is_power_of_2(amdgpu_sched_jobs)) { + dev_warn(adev->dev, "sched jobs (%d) must be a power of 2\n", + amdgpu_sched_jobs); + amdgpu_sched_jobs = roundup_pow_of_two(amdgpu_sched_jobs); +@@ -2747,8 +2747,9 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev) + DRM_ERROR("enable mgpu fan boost failed (%d).\n", r); + + /* For passthrough configuration on arcturus and aldebaran, enable special handling SBR */ +- if (amdgpu_passthrough(adev) && ((adev->asic_type == CHIP_ARCTURUS && adev->gmc.xgmi.num_physical_nodes > 1)|| +- adev->asic_type == CHIP_ALDEBARAN )) ++ if (amdgpu_passthrough(adev) && ++ ((adev->asic_type == CHIP_ARCTURUS && adev->gmc.xgmi.num_physical_nodes > 1) || ++ adev->asic_type == CHIP_ALDEBARAN)) + amdgpu_dpm_handle_passthrough_sbr(adev, true); + + if (adev->gmc.xgmi.num_physical_nodes > 1) { +@@ -3077,7 +3078,7 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev) + } + adev->ip_blocks[i].status.hw = false; + /* handle putting the SMC in the appropriate state */ +- if(!amdgpu_sriov_vf(adev)){ ++ if (!amdgpu_sriov_vf(adev)) { + if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) { + r = amdgpu_dpm_set_mp1_state(adev, adev->mp1_state); + if (r) { +@@ -4048,7 +4049,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) + + /* disable all interrupts */ + amdgpu_irq_disable_all(adev); +- if (adev->mode_info.mode_config_initialized){ ++ if (adev->mode_info.mode_config_initialized) { + if (!drm_drv_uses_atomic_modeset(adev_to_drm(adev))) + drm_helper_force_disable_all(adev_to_drm(adev)); + else +@@ -4755,42 +4756,42 @@ bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev) + + int amdgpu_device_mode1_reset(struct amdgpu_device *adev) + { +- u32 i; +- int ret = 0; ++ u32 i; ++ int ret = 0; + +- amdgpu_atombios_scratch_regs_engine_hung(adev, true); ++ amdgpu_atombios_scratch_regs_engine_hung(adev, true); + +- dev_info(adev->dev, "GPU mode1 reset\n"); ++ dev_info(adev->dev, "GPU mode1 reset\n"); + +- /* disable BM */ +- pci_clear_master(adev->pdev); ++ /* disable BM */ ++ pci_clear_master(adev->pdev); + +- amdgpu_device_cache_pci_state(adev->pdev); ++ amdgpu_device_cache_pci_state(adev->pdev); + +- if (amdgpu_dpm_is_mode1_reset_supported(adev)) { +- dev_info(adev->dev, "GPU smu mode1 reset\n"); +- ret = amdgpu_dpm_mode1_reset(adev); +- } else { +- dev_info(adev->dev, "GPU psp mode1 reset\n"); +- ret = psp_gpu_reset(adev); +- } ++ if (amdgpu_dpm_is_mode1_reset_supported(adev)) { ++ dev_info(adev->dev, "GPU smu mode1 reset\n"); ++ ret = amdgpu_dpm_mode1_reset(adev); ++ } else { ++ dev_info(adev->dev, "GPU psp mode1 reset\n"); ++ ret = psp_gpu_reset(adev); ++ } + +- if (ret) +- dev_err(adev->dev, "GPU mode1 reset failed\n"); ++ if (ret) ++ dev_err(adev->dev, "GPU mode1 reset failed\n"); + +- amdgpu_device_load_pci_state(adev->pdev); ++ amdgpu_device_load_pci_state(adev->pdev); + +- /* wait for asic to come out of reset */ +- for (i = 0; i < adev->usec_timeout; i++) { +- u32 memsize = adev->nbio.funcs->get_memsize(adev); ++ /* wait for asic to come out of reset */ ++ for (i = 0; i < adev->usec_timeout; i++) { ++ u32 memsize = adev->nbio.funcs->get_memsize(adev); + +- if (memsize != 0xffffffff) +- break; +- udelay(1); +- } ++ if (memsize != 0xffffffff) ++ break; ++ udelay(1); ++ } + +- amdgpu_atombios_scratch_regs_engine_hung(adev, false); +- return ret; ++ amdgpu_atombios_scratch_regs_engine_hung(adev, false); ++ return ret; + } + + int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +index 9a5416331f02e..238c15c0c7e1e 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +@@ -1662,7 +1662,7 @@ static const u16 amdgpu_unsupported_pciidlist[] = { + }; + + static const struct pci_device_id pciidlist[] = { +-#ifdef CONFIG_DRM_AMDGPU_SI ++#ifdef CONFIG_DRM_AMDGPU_SI + {0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, + {0x1002, 0x6784, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, + {0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, +-- +2.43.0 + diff --git a/queue-6.1/drm-amdgpu-fix-pci-state-save-during-mode-1-reset.patch b/queue-6.1/drm-amdgpu-fix-pci-state-save-during-mode-1-reset.patch new file mode 100644 index 00000000000..dc6e3cf6979 --- /dev/null +++ b/queue-6.1/drm-amdgpu-fix-pci-state-save-during-mode-1-reset.patch @@ -0,0 +1,47 @@ +From 078586c17cea2a74d41032ea1cc19eb5d6d366df Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 18 Jun 2024 14:04:38 +0530 +Subject: drm/amdgpu: Fix pci state save during mode-1 reset + +From: Lijo Lazar + +[ Upstream commit 74fa02c4a5ea1ade5156a6ce494d3ea83881c2d8 ] + +Cache the PCI state before bus master is disabled. The saved state is +later used for other cases like restoring config space after mode-2 +reset. + +Fixes: 5c03e5843e6b ("drm/amdgpu:add smu mode1/2 support for aldebaran") +Signed-off-by: Lijo Lazar +Reviewed-by: Feifei Xu +Reviewed-by: Hawking Zhang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +index 985688696202a..157441dd07041 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +@@ -4763,11 +4763,14 @@ int amdgpu_device_mode1_reset(struct amdgpu_device *adev) + + dev_info(adev->dev, "GPU mode1 reset\n"); + ++ /* Cache the state before bus master disable. The saved config space ++ * values are used in other cases like restore after mode-2 reset. ++ */ ++ amdgpu_device_cache_pci_state(adev->pdev); ++ + /* disable BM */ + pci_clear_master(adev->pdev); + +- amdgpu_device_cache_pci_state(adev->pdev); +- + if (amdgpu_dpm_is_mode1_reset_supported(adev)) { + dev_info(adev->dev, "GPU smu mode1 reset\n"); + ret = amdgpu_dpm_mode1_reset(adev); +-- +2.43.0 + diff --git a/queue-6.1/drm-panel-ilitek-ili9881c-fix-warning-with-gpio-cont.patch b/queue-6.1/drm-panel-ilitek-ili9881c-fix-warning-with-gpio-cont.patch new file mode 100644 index 00000000000..26531dddce3 --- /dev/null +++ b/queue-6.1/drm-panel-ilitek-ili9881c-fix-warning-with-gpio-cont.patch @@ -0,0 +1,54 @@ +From c7391e307a6b8beab19370f1c9f70df176c41461 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 17 Mar 2024 17:48:39 +0200 +Subject: drm/panel: ilitek-ili9881c: Fix warning with GPIO controllers that + sleep + +From: Laurent Pinchart + +[ Upstream commit ee7860cd8b5763017f8dc785c2851fecb7a0c565 ] + +The ilitek-ili9881c controls the reset GPIO using the non-sleeping +gpiod_set_value() function. This complains loudly when the GPIO +controller needs to sleep. As the caller can sleep, use +gpiod_set_value_cansleep() to fix the issue. + +Signed-off-by: Laurent Pinchart +Reviewed-by: Neil Armstrong +Link: https://lore.kernel.org/r/20240317154839.21260-1-laurent.pinchart@ideasonboard.com +Signed-off-by: Neil Armstrong +Link: https://patchwork.freedesktop.org/patch/msgid/20240317154839.21260-1-laurent.pinchart@ideasonboard.com +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +index cbb68caa36f26..4014c537e397d 100644 +--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c ++++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +@@ -716,10 +716,10 @@ static int ili9881c_prepare(struct drm_panel *panel) + msleep(5); + + /* And reset it */ +- gpiod_set_value(ctx->reset, 1); ++ gpiod_set_value_cansleep(ctx->reset, 1); + msleep(20); + +- gpiod_set_value(ctx->reset, 0); ++ gpiod_set_value_cansleep(ctx->reset, 0); + msleep(20); + + for (i = 0; i < ctx->desc->init_length; i++) { +@@ -774,7 +774,7 @@ static int ili9881c_unprepare(struct drm_panel *panel) + + mipi_dsi_dcs_enter_sleep_mode(ctx->dsi); + regulator_disable(ctx->power); +- gpiod_set_value(ctx->reset, 1); ++ gpiod_set_value_cansleep(ctx->reset, 1); + + return 0; + } +-- +2.43.0 + diff --git a/queue-6.1/drm-panel-simple-add-missing-display-timing-flags-fo.patch b/queue-6.1/drm-panel-simple-add-missing-display-timing-flags-fo.patch new file mode 100644 index 00000000000..69e70fa3f0d --- /dev/null +++ b/queue-6.1/drm-panel-simple-add-missing-display-timing-flags-fo.patch @@ -0,0 +1,40 @@ +From 224860e0e5467e051597369a55122128a0bd437d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Jun 2024 09:56:12 +0800 +Subject: drm/panel: simple: Add missing display timing flags for KOE + TX26D202VM0BWA + +From: Liu Ying + +[ Upstream commit 37ce99b77762256ec9fda58d58fd613230151456 ] + +KOE TX26D202VM0BWA panel spec indicates the DE signal is active high in +timing chart, so add DISPLAY_FLAGS_DE_HIGH flag in display timing flags. +This aligns display_timing with panel_desc. + +Fixes: 8a07052440c2 ("drm/panel: simple: Add support for KOE TX26D202VM0BWA panel") +Signed-off-by: Liu Ying +Reviewed-by: Neil Armstrong +Link: https://lore.kernel.org/r/20240624015612.341983-1-victor.liu@nxp.com +Signed-off-by: Neil Armstrong +Link: https://patchwork.freedesktop.org/patch/msgid/20240624015612.341983-1-victor.liu@nxp.com +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/panel/panel-simple.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c +index acb7f5c206d13..b560d62b6e219 100644 +--- a/drivers/gpu/drm/panel/panel-simple.c ++++ b/drivers/gpu/drm/panel/panel-simple.c +@@ -2371,6 +2371,7 @@ static const struct display_timing koe_tx26d202vm0bwa_timing = { + .vfront_porch = { 3, 5, 10 }, + .vback_porch = { 2, 5, 10 }, + .vsync_len = { 5, 5, 5 }, ++ .flags = DISPLAY_FLAGS_DE_HIGH, + }; + + static const struct panel_desc koe_tx26d202vm0bwa = { +-- +2.43.0 + diff --git a/queue-6.1/drm-radeon-radeon_display-decrease-the-size-of-alloc.patch b/queue-6.1/drm-radeon-radeon_display-decrease-the-size-of-alloc.patch new file mode 100644 index 00000000000..deb1ffacf19 --- /dev/null +++ b/queue-6.1/drm-radeon-radeon_display-decrease-the-size-of-alloc.patch @@ -0,0 +1,79 @@ +From 94144f66804b0baa756518d5111d3b6f9daff51c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 30 Mar 2024 17:34:47 +0100 +Subject: drm/radeon/radeon_display: Decrease the size of allocated memory +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Erick Archer + +[ Upstream commit ae6a233092747e9652eb793d92f79d0820e01c6a ] + +This is an effort to get rid of all multiplications from allocation +functions in order to prevent integer overflows [1] [2]. + +In this case, the memory allocated to store RADEONFB_CONN_LIMIT pointers +to "drm_connector" structures can be avoided. This is because this +memory area is never accessed. + +Also, in the kzalloc function, it is preferred to use sizeof(*pointer) +instead of sizeof(type) due to the type of the variable can change and +one needs not change the former (unlike the latter). + +At the same time take advantage to remove the "#if 0" block, the code +where the removed memory area was accessed, and the RADEONFB_CONN_LIMIT +constant due to now is never used. + +Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] +Link: https://github.com/KSPP/linux/issues/160 [2] +Acked-by: Christian König +Signed-off-by: Erick Archer +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/radeon/radeon.h | 1 - + drivers/gpu/drm/radeon/radeon_display.c | 8 +------- + 2 files changed, 1 insertion(+), 8 deletions(-) + +diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h +index 166c18d62f6d7..ec86c04a0d989 100644 +--- a/drivers/gpu/drm/radeon/radeon.h ++++ b/drivers/gpu/drm/radeon/radeon.h +@@ -131,7 +131,6 @@ extern int radeon_cik_support; + /* RADEON_IB_POOL_SIZE must be a power of 2 */ + #define RADEON_IB_POOL_SIZE 16 + #define RADEON_DEBUGFS_MAX_COMPONENTS 32 +-#define RADEONFB_CONN_LIMIT 4 + #define RADEON_BIOS_NUM_SCRATCH 8 + + /* internal ring indices */ +diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c +index 1814bb8e14f10..dbee301b3b2e8 100644 +--- a/drivers/gpu/drm/radeon/radeon_display.c ++++ b/drivers/gpu/drm/radeon/radeon_display.c +@@ -683,7 +683,7 @@ static void radeon_crtc_init(struct drm_device *dev, int index) + struct radeon_device *rdev = dev->dev_private; + struct radeon_crtc *radeon_crtc; + +- radeon_crtc = kzalloc(sizeof(struct radeon_crtc) + (RADEONFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL); ++ radeon_crtc = kzalloc(sizeof(*radeon_crtc), GFP_KERNEL); + if (radeon_crtc == NULL) + return; + +@@ -709,12 +709,6 @@ static void radeon_crtc_init(struct drm_device *dev, int index) + dev->mode_config.cursor_width = radeon_crtc->max_cursor_width; + dev->mode_config.cursor_height = radeon_crtc->max_cursor_height; + +-#if 0 +- radeon_crtc->mode_set.crtc = &radeon_crtc->base; +- radeon_crtc->mode_set.connectors = (struct drm_connector **)(radeon_crtc + 1); +- radeon_crtc->mode_set.num_connectors = 0; +-#endif +- + if (rdev->is_atom_bios && (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom)) + radeon_atombios_init_crtc(dev, radeon_crtc); + else +-- +2.43.0 + diff --git a/queue-6.1/gpio-davinci-validate-the-obtained-number-of-irqs.patch b/queue-6.1/gpio-davinci-validate-the-obtained-number-of-irqs.patch new file mode 100644 index 00000000000..1ae8695d29c --- /dev/null +++ b/queue-6.1/gpio-davinci-validate-the-obtained-number-of-irqs.patch @@ -0,0 +1,47 @@ +From e1a52174b9eb9bc06909814c808b3bf524152bdb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 18 Jun 2024 17:43:44 +0300 +Subject: gpio: davinci: Validate the obtained number of IRQs + +From: Aleksandr Mishin + +[ Upstream commit 7aa9b96e9a73e4ec1771492d0527bd5fc5ef9164 ] + +Value of pdata->gpio_unbanked is taken from Device Tree. In case of broken +DT due to any error this value can be any. Without this value validation +there can be out of chips->irqs array boundaries access in +davinci_gpio_probe(). + +Validate the obtained nirq value so that it won't exceed the maximum +number of IRQs per bank. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Fixes: eb3744a2dd01 ("gpio: davinci: Do not assume continuous IRQ numbering") +Signed-off-by: Aleksandr Mishin +Link: https://lore.kernel.org/r/20240618144344.16943-1-amishin@t-argos.ru +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpio-davinci.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c +index 69f3d864f69d3..206829165fc58 100644 +--- a/drivers/gpio/gpio-davinci.c ++++ b/drivers/gpio/gpio-davinci.c +@@ -230,6 +230,11 @@ static int davinci_gpio_probe(struct platform_device *pdev) + else + nirq = DIV_ROUND_UP(ngpio, 16); + ++ if (nirq > MAX_INT_PER_BANK) { ++ dev_err(dev, "Too many IRQs!\n"); ++ return -EINVAL; ++ } ++ + chips = devm_kzalloc(dev, sizeof(*chips), GFP_KERNEL); + if (!chips) + return -ENOMEM; +-- +2.43.0 + diff --git a/queue-6.1/gpiolib-cdev-disallow-reconfiguration-without-direct.patch b/queue-6.1/gpiolib-cdev-disallow-reconfiguration-without-direct.patch new file mode 100644 index 00000000000..435b0fc5ef8 --- /dev/null +++ b/queue-6.1/gpiolib-cdev-disallow-reconfiguration-without-direct.patch @@ -0,0 +1,88 @@ +From 5d89f524e8d13086e5239cc3380811d016bf8fdd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 26 Jun 2024 13:29:22 +0800 +Subject: gpiolib: cdev: Disallow reconfiguration without direction (uAPI v1) + +From: Kent Gibson + +[ Upstream commit 9919cce62f68e6ab68dc2a975b5dc670f8ca7d40 ] + +linehandle_set_config() behaves badly when direction is not set. +The configuration validation is borrowed from linehandle_create(), where, +to verify the intent of the user, the direction must be set to in order +to effect a change to the electrical configuration of a line. But, when +applied to reconfiguration, that validation does not allow for the unset +direction case, making it possible to clear flags set previously without +specifying the line direction. + +Adding to the inconsistency, those changes are not immediately applied by +linehandle_set_config(), but will take effect when the line value is next +get or set. + +For example, by requesting a configuration with no flags set, an output +line with GPIOHANDLE_REQUEST_ACTIVE_LOW and GPIOHANDLE_REQUEST_OPEN_DRAIN +requested could have those flags cleared, inverting the sense of the line +and changing the line drive to push-pull on the next line value set. + +Ensure the intent of the user by disallowing configurations which do not +have direction set, returning an error to userspace to indicate that the +configuration is invalid. + +And, for clarity, use lflags, a local copy of gcnf.flags, throughout when +dealing with the requested flags, rather than a mixture of both. + +Fixes: e588bb1eae31 ("gpio: add new SET_CONFIG ioctl() to gpio chardev") +Signed-off-by: Kent Gibson +Link: https://lore.kernel.org/r/20240626052925.174272-2-warthog618@gmail.com +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpiolib-cdev.c | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c +index 97e8335716b01..be51bd00d2fd2 100644 +--- a/drivers/gpio/gpiolib-cdev.c ++++ b/drivers/gpio/gpiolib-cdev.c +@@ -132,6 +132,10 @@ struct linehandle_state { + GPIOHANDLE_REQUEST_OPEN_DRAIN | \ + GPIOHANDLE_REQUEST_OPEN_SOURCE) + ++#define GPIOHANDLE_REQUEST_DIRECTION_FLAGS \ ++ (GPIOHANDLE_REQUEST_INPUT | \ ++ GPIOHANDLE_REQUEST_OUTPUT) ++ + static int linehandle_validate_flags(u32 flags) + { + /* Return an error if an unknown flag is set */ +@@ -212,21 +216,21 @@ static long linehandle_set_config(struct linehandle_state *lh, + if (ret) + return ret; + ++ /* Lines must be reconfigured explicitly as input or output. */ ++ if (!(lflags & GPIOHANDLE_REQUEST_DIRECTION_FLAGS)) ++ return -EINVAL; ++ + for (i = 0; i < lh->num_descs; i++) { + desc = lh->descs[i]; +- linehandle_flags_to_desc_flags(gcnf.flags, &desc->flags); ++ linehandle_flags_to_desc_flags(lflags, &desc->flags); + +- /* +- * Lines have to be requested explicitly for input +- * or output, else the line will be treated "as is". +- */ + if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { + int val = !!gcnf.default_values[i]; + + ret = gpiod_direction_output(desc, val); + if (ret) + return ret; +- } else if (lflags & GPIOHANDLE_REQUEST_INPUT) { ++ } else { + ret = gpiod_direction_input(desc); + if (ret) + return ret; +-- +2.43.0 + diff --git a/queue-6.1/md-fix-overflow-in-is_mddev_idle.patch b/queue-6.1/md-fix-overflow-in-is_mddev_idle.patch new file mode 100644 index 00000000000..3d6e81fcc0e --- /dev/null +++ b/queue-6.1/md-fix-overflow-in-is_mddev_idle.patch @@ -0,0 +1,104 @@ +From 6338df4eea90a285832af592547f2b04b667d019 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Jan 2024 11:19:45 +0800 +Subject: md: Fix overflow in is_mddev_idle + +From: Li Nan + +[ Upstream commit 3f9f231236ce7e48780d8a4f1f8cb9fae2df1e4e ] + +UBSAN reports this problem: + + UBSAN: Undefined behaviour in drivers/md/md.c:8175:15 + signed integer overflow: + -2147483291 - 2072033152 cannot be represented in type 'int' + Call trace: + dump_backtrace+0x0/0x310 + show_stack+0x28/0x38 + dump_stack+0xec/0x15c + ubsan_epilogue+0x18/0x84 + handle_overflow+0x14c/0x19c + __ubsan_handle_sub_overflow+0x34/0x44 + is_mddev_idle+0x338/0x3d8 + md_do_sync+0x1bb8/0x1cf8 + md_thread+0x220/0x288 + kthread+0x1d8/0x1e0 + ret_from_fork+0x10/0x18 + +'curr_events' will overflow when stat accum or 'sync_io' is greater than +INT_MAX. + +Fix it by changing sync_io, last_events and curr_events to 64bit. + +Signed-off-by: Li Nan +Reviewed-by: Yu Kuai +Link: https://lore.kernel.org/r/20240117031946.2324519-2-linan666@huaweicloud.com +Signed-off-by: Song Liu +Signed-off-by: Sasha Levin +--- + drivers/md/md.c | 7 ++++--- + drivers/md/md.h | 4 ++-- + include/linux/blkdev.h | 2 +- + 3 files changed, 7 insertions(+), 6 deletions(-) + +diff --git a/drivers/md/md.c b/drivers/md/md.c +index 506c998c0ca59..3d2befb0baf46 100644 +--- a/drivers/md/md.c ++++ b/drivers/md/md.c +@@ -8542,14 +8542,15 @@ static int is_mddev_idle(struct mddev *mddev, int init) + { + struct md_rdev *rdev; + int idle; +- int curr_events; ++ long long curr_events; + + idle = 1; + rcu_read_lock(); + rdev_for_each_rcu(rdev, mddev) { + struct gendisk *disk = rdev->bdev->bd_disk; +- curr_events = (int)part_stat_read_accum(disk->part0, sectors) - +- atomic_read(&disk->sync_io); ++ curr_events = ++ (long long)part_stat_read_accum(disk->part0, sectors) - ++ atomic64_read(&disk->sync_io); + /* sync IO will cause sync_io to increase before the disk_stats + * as sync_io is counted when a request starts, and + * disk_stats is counted when it completes. +diff --git a/drivers/md/md.h b/drivers/md/md.h +index 4f0b480974552..5910527514db2 100644 +--- a/drivers/md/md.h ++++ b/drivers/md/md.h +@@ -50,7 +50,7 @@ struct md_rdev { + + sector_t sectors; /* Device size (in 512bytes sectors) */ + struct mddev *mddev; /* RAID array if running */ +- int last_events; /* IO event timestamp */ ++ long long last_events; /* IO event timestamp */ + + /* + * If meta_bdev is non-NULL, it means that a separate device is +@@ -576,7 +576,7 @@ extern void mddev_unlock(struct mddev *mddev); + + static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors) + { +- atomic_add(nr_sectors, &bdev->bd_disk->sync_io); ++ atomic64_add(nr_sectors, &bdev->bd_disk->sync_io); + } + + static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors) +diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h +index e255674a9ee72..02e55676e0283 100644 +--- a/include/linux/blkdev.h ++++ b/include/linux/blkdev.h +@@ -161,7 +161,7 @@ struct gendisk { + struct list_head slave_bdevs; + #endif + struct timer_rand_state *random; +- atomic_t sync_io; /* RAID */ ++ atomic64_t sync_io; /* RAID */ + struct disk_events *ev; + #ifdef CONFIG_BLK_DEV_INTEGRITY + struct kobject integrity_kobj; +-- +2.43.0 + diff --git a/queue-6.1/media-dvbdev-initialize-sbuf.patch b/queue-6.1/media-dvbdev-initialize-sbuf.patch new file mode 100644 index 00000000000..2a416854c3a --- /dev/null +++ b/queue-6.1/media-dvbdev-initialize-sbuf.patch @@ -0,0 +1,42 @@ +From 7c0d398cf69a526819bcf1e9e773304269b301b8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 25 Mar 2024 14:50:25 +0000 +Subject: media: dvbdev: Initialize sbuf +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ricardo Ribalda + +[ Upstream commit 17d1316de0d7dc1bdc5d6e3ad4efd30a9bf1a381 ] + +Because the size passed to copy_from_user() cannot be known beforehand, +it needs to be checked during runtime with check_object_size. That makes +gcc believe that the content of sbuf can be used before init. + +Fix: +./include/linux/thread_info.h:215:17: warning: ‘sbuf’ may be used uninitialized [-Wmaybe-uninitialized] + +Signed-off-by: Ricardo Ribalda +Signed-off-by: Hans Verkuil +Signed-off-by: Sasha Levin +--- + drivers/media/dvb-core/dvbdev.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c +index aefee2277254d..04b7ce479fc38 100644 +--- a/drivers/media/dvb-core/dvbdev.c ++++ b/drivers/media/dvb-core/dvbdev.c +@@ -964,7 +964,7 @@ int dvb_usercopy(struct file *file, + int (*func)(struct file *file, + unsigned int cmd, void *arg)) + { +- char sbuf[128]; ++ char sbuf[128] = {}; + void *mbuf = NULL; + void *parg = NULL; + int err = -EINVAL; +-- +2.43.0 + diff --git a/queue-6.1/mtd-partitions-redboot-added-conversion-of-operands-.patch b/queue-6.1/mtd-partitions-redboot-added-conversion-of-operands-.patch new file mode 100644 index 00000000000..e842bee4fa0 --- /dev/null +++ b/queue-6.1/mtd-partitions-redboot-added-conversion-of-operands-.patch @@ -0,0 +1,40 @@ +From b7f27a77e0cf7b66ed1e152629430e2b660cd68f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 15 Mar 2024 12:37:58 +0300 +Subject: mtd: partitions: redboot: Added conversion of operands to a larger + type + +From: Denis Arefev + +[ Upstream commit 1162bc2f8f5de7da23d18aa4b7fbd4e93c369c50 ] + +The value of an arithmetic expression directory * master->erasesize is +subject to overflow due to a failure to cast operands to a larger data +type before perfroming arithmetic + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Signed-off-by: Denis Arefev +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20240315093758.20790-1-arefev@swemel.ru +Signed-off-by: Sasha Levin +--- + drivers/mtd/parsers/redboot.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c +index a16b42a885816..3b55b676ca6b9 100644 +--- a/drivers/mtd/parsers/redboot.c ++++ b/drivers/mtd/parsers/redboot.c +@@ -102,7 +102,7 @@ static int parse_redboot_partitions(struct mtd_info *master, + offset -= master->erasesize; + } + } else { +- offset = directory * master->erasesize; ++ offset = (unsigned long) directory * master->erasesize; + while (mtd_block_isbad(master, offset)) { + offset += master->erasesize; + if (offset == master->size) +-- +2.43.0 + diff --git a/queue-6.1/net-dpaa2-avoid-explicit-cpumask-var-allocation-on-s.patch b/queue-6.1/net-dpaa2-avoid-explicit-cpumask-var-allocation-on-s.patch new file mode 100644 index 00000000000..4e5e9a3ab9f --- /dev/null +++ b/queue-6.1/net-dpaa2-avoid-explicit-cpumask-var-allocation-on-s.patch @@ -0,0 +1,72 @@ +From f69a7d56de0f5e531d5c715d1bd06d3beb299e2d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 31 Mar 2024 13:34:41 +0800 +Subject: net/dpaa2: Avoid explicit cpumask var allocation on stack + +From: Dawei Li + +[ Upstream commit d33fe1714a44ff540629b149d8fab4ac6967585c ] + +For CONFIG_CPUMASK_OFFSTACK=y kernel, explicit allocation of cpumask +variable on stack is not recommended since it can cause potential stack +overflow. + +Instead, kernel code should always use *cpumask_var API(s) to allocate +cpumask var in config-neutral way, leaving allocation strategy to +CONFIG_CPUMASK_OFFSTACK. + +Use *cpumask_var API(s) to address it. + +Signed-off-by: Dawei Li +Link: https://lore.kernel.org/r/20240331053441.1276826-3-dawei.li@shingroup.cn +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +index de62eee58a00e..bbbe7c5b5d35a 100644 +--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c ++++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +@@ -2754,11 +2754,14 @@ static int dpaa2_eth_xdp_xmit(struct net_device *net_dev, int n, + static int update_xps(struct dpaa2_eth_priv *priv) + { + struct net_device *net_dev = priv->net_dev; +- struct cpumask xps_mask; +- struct dpaa2_eth_fq *fq; + int i, num_queues, netdev_queues; ++ struct dpaa2_eth_fq *fq; ++ cpumask_var_t xps_mask; + int err = 0; + ++ if (!alloc_cpumask_var(&xps_mask, GFP_KERNEL)) ++ return -ENOMEM; ++ + num_queues = dpaa2_eth_queue_count(priv); + netdev_queues = (net_dev->num_tc ? : 1) * num_queues; + +@@ -2768,16 +2771,17 @@ static int update_xps(struct dpaa2_eth_priv *priv) + for (i = 0; i < netdev_queues; i++) { + fq = &priv->fq[i % num_queues]; + +- cpumask_clear(&xps_mask); +- cpumask_set_cpu(fq->target_cpu, &xps_mask); ++ cpumask_clear(xps_mask); ++ cpumask_set_cpu(fq->target_cpu, xps_mask); + +- err = netif_set_xps_queue(net_dev, &xps_mask, i); ++ err = netif_set_xps_queue(net_dev, xps_mask, i); + if (err) { + netdev_warn_once(net_dev, "Error setting XPS queue\n"); + break; + } + } + ++ free_cpumask_var(xps_mask); + return err; + } + +-- +2.43.0 + diff --git a/queue-6.1/net-iucv-avoid-explicit-cpumask-var-allocation-on-st.patch b/queue-6.1/net-iucv-avoid-explicit-cpumask-var-allocation-on-st.patch new file mode 100644 index 00000000000..0505d4953ee --- /dev/null +++ b/queue-6.1/net-iucv-avoid-explicit-cpumask-var-allocation-on-st.patch @@ -0,0 +1,85 @@ +From 8a213ce9d7a792068582b3edc4b4c5bea7286889 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 31 Mar 2024 13:34:40 +0800 +Subject: net/iucv: Avoid explicit cpumask var allocation on stack + +From: Dawei Li + +[ Upstream commit be4e1304419c99a164b4c0e101c7c2a756b635b9 ] + +For CONFIG_CPUMASK_OFFSTACK=y kernel, explicit allocation of cpumask +variable on stack is not recommended since it can cause potential stack +overflow. + +Instead, kernel code should always use *cpumask_var API(s) to allocate +cpumask var in config-neutral way, leaving allocation strategy to +CONFIG_CPUMASK_OFFSTACK. + +Use *cpumask_var API(s) to address it. + +Signed-off-by: Dawei Li +Reviewed-by: Alexandra Winter +Link: https://lore.kernel.org/r/20240331053441.1276826-2-dawei.li@shingroup.cn +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + net/iucv/iucv.c | 26 ++++++++++++++++++-------- + 1 file changed, 18 insertions(+), 8 deletions(-) + +diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c +index f66b5f74cd83a..db41eb2d977f2 100644 +--- a/net/iucv/iucv.c ++++ b/net/iucv/iucv.c +@@ -519,7 +519,7 @@ static void iucv_setmask_mp(void) + */ + static void iucv_setmask_up(void) + { +- cpumask_t cpumask; ++ static cpumask_t cpumask; + int cpu; + + /* Disable all cpu but the first in cpu_irq_cpumask. */ +@@ -627,23 +627,33 @@ static int iucv_cpu_online(unsigned int cpu) + + static int iucv_cpu_down_prep(unsigned int cpu) + { +- cpumask_t cpumask; ++ cpumask_var_t cpumask; ++ int ret = 0; + + if (!iucv_path_table) + return 0; + +- cpumask_copy(&cpumask, &iucv_buffer_cpumask); +- cpumask_clear_cpu(cpu, &cpumask); +- if (cpumask_empty(&cpumask)) ++ if (!alloc_cpumask_var(&cpumask, GFP_KERNEL)) ++ return -ENOMEM; ++ ++ cpumask_copy(cpumask, &iucv_buffer_cpumask); ++ cpumask_clear_cpu(cpu, cpumask); ++ if (cpumask_empty(cpumask)) { + /* Can't offline last IUCV enabled cpu. */ +- return -EINVAL; ++ ret = -EINVAL; ++ goto __free_cpumask; ++ } + + iucv_retrieve_cpu(NULL); + if (!cpumask_empty(&iucv_irq_cpumask)) +- return 0; ++ goto __free_cpumask; ++ + smp_call_function_single(cpumask_first(&iucv_buffer_cpumask), + iucv_allow_cpu, NULL, 1); +- return 0; ++ ++__free_cpumask: ++ free_cpumask_var(cpumask); ++ return ret; + } + + /** +-- +2.43.0 + diff --git a/queue-6.1/nvme-fixup-comment-for-nvme-rdma-provider-type.patch b/queue-6.1/nvme-fixup-comment-for-nvme-rdma-provider-type.patch new file mode 100644 index 00000000000..ee32cbf2b95 --- /dev/null +++ b/queue-6.1/nvme-fixup-comment-for-nvme-rdma-provider-type.patch @@ -0,0 +1,38 @@ +From a1c49f2931a77b130c6d0349d5ee1e06b1c23882 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 17 Jun 2024 09:27:27 +0200 +Subject: nvme: fixup comment for nvme RDMA Provider Type + +From: Hannes Reinecke + +[ Upstream commit f80a55fa90fa76d01e3fffaa5d0413e522ab9a00 ] + +PRTYPE is the provider type, not the QP service type. + +Fixes: eb793e2c9286 ("nvme.h: add NVMe over Fabrics definitions") +Signed-off-by: Hannes Reinecke +Reviewed-by: Christoph Hellwig +Signed-off-by: Keith Busch +Signed-off-by: Sasha Levin +--- + include/linux/nvme.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/linux/nvme.h b/include/linux/nvme.h +index e6fb36b71b59d..15086715632e0 100644 +--- a/include/linux/nvme.h ++++ b/include/linux/nvme.h +@@ -90,8 +90,8 @@ enum { + NVMF_RDMA_QPTYPE_DATAGRAM = 2, /* Reliable Datagram */ + }; + +-/* RDMA QP Service Type codes for Discovery Log Page entry TSAS +- * RDMA_QPTYPE field ++/* RDMA Provider Type codes for Discovery Log Page entry TSAS ++ * RDMA_PRTYPE field + */ + enum { + NVMF_RDMA_PRTYPE_NOT_SPECIFIED = 1, /* No Provider Specified */ +-- +2.43.0 + diff --git a/queue-6.1/randomize_kstack-remove-non-functional-per-arch-entr.patch b/queue-6.1/randomize_kstack-remove-non-functional-per-arch-entr.patch new file mode 100644 index 00000000000..7a6a2ade08b --- /dev/null +++ b/queue-6.1/randomize_kstack-remove-non-functional-per-arch-entr.patch @@ -0,0 +1,121 @@ +From 1101502fe46e3d0f26063102eeccbc2bc03c6093 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 19 Jun 2024 14:47:15 -0700 +Subject: randomize_kstack: Remove non-functional per-arch entropy filtering + +From: Kees Cook + +[ Upstream commit 6db1208bf95b4c091897b597c415e11edeab2e2d ] + +An unintended consequence of commit 9c573cd31343 ("randomize_kstack: +Improve entropy diffusion") was that the per-architecture entropy size +filtering reduced how many bits were being added to the mix, rather than +how many bits were being used during the offsetting. All architectures +fell back to the existing default of 0x3FF (10 bits), which will consume +at most 1KiB of stack space. It seems that this is working just fine, +so let's avoid the confusion and update everything to use the default. + +The prior intent of the per-architecture limits were: + + arm64: capped at 0x1FF (9 bits), 5 bits effective + powerpc: uncapped (10 bits), 6 or 7 bits effective + riscv: uncapped (10 bits), 6 bits effective + x86: capped at 0xFF (8 bits), 5 (x86_64) or 6 (ia32) bits effective + s390: capped at 0xFF (8 bits), undocumented effective entropy + +Current discussion has led to just dropping the original per-architecture +filters. The additional entropy appears to be safe for arm64, x86, +and s390. Quoting Arnd, "There is no point pretending that 15.75KB is +somehow safe to use while 15.00KB is not." + +Co-developed-by: Yuntao Liu +Signed-off-by: Yuntao Liu +Fixes: 9c573cd31343 ("randomize_kstack: Improve entropy diffusion") +Link: https://lore.kernel.org/r/20240617133721.377540-1-liuyuntao12@huawei.com +Reviewed-by: Arnd Bergmann +Acked-by: Mark Rutland +Acked-by: Heiko Carstens # s390 +Link: https://lore.kernel.org/r/20240619214711.work.953-kees@kernel.org +Signed-off-by: Kees Cook +Signed-off-by: Sasha Levin +--- + arch/arm64/kernel/syscall.c | 16 +++++++--------- + arch/s390/include/asm/entry-common.h | 2 +- + arch/x86/include/asm/entry-common.h | 15 ++++++--------- + 3 files changed, 14 insertions(+), 19 deletions(-) + +diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c +index d72e8f23422da..c771e94568b9b 100644 +--- a/arch/arm64/kernel/syscall.c ++++ b/arch/arm64/kernel/syscall.c +@@ -57,17 +57,15 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno, + syscall_set_return_value(current, regs, 0, ret); + + /* +- * Ultimately, this value will get limited by KSTACK_OFFSET_MAX(), +- * but not enough for arm64 stack utilization comfort. To keep +- * reasonable stack head room, reduce the maximum offset to 9 bits. ++ * This value will get limited by KSTACK_OFFSET_MAX(), which is 10 ++ * bits. The actual entropy will be further reduced by the compiler ++ * when applying stack alignment constraints: the AAPCS mandates a ++ * 16-byte aligned SP at function boundaries, which will remove the ++ * 4 low bits from any entropy chosen here. + * +- * The actual entropy will be further reduced by the compiler when +- * applying stack alignment constraints: the AAPCS mandates a +- * 16-byte (i.e. 4-bit) aligned SP at function boundaries. +- * +- * The resulting 5 bits of entropy is seen in SP[8:4]. ++ * The resulting 6 bits of entropy is seen in SP[9:4]. + */ +- choose_random_kstack_offset(get_random_u16() & 0x1FF); ++ choose_random_kstack_offset(get_random_u16()); + } + + static inline bool has_syscall_work(unsigned long flags) +diff --git a/arch/s390/include/asm/entry-common.h b/arch/s390/include/asm/entry-common.h +index 000de2b1e67a2..74124092b1c7e 100644 +--- a/arch/s390/include/asm/entry-common.h ++++ b/arch/s390/include/asm/entry-common.h +@@ -55,7 +55,7 @@ static __always_inline void arch_exit_to_user_mode(void) + static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, + unsigned long ti_work) + { +- choose_random_kstack_offset(get_tod_clock_fast() & 0xff); ++ choose_random_kstack_offset(get_tod_clock_fast()); + } + + #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare +diff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h +index ffe72790ceafd..ebdf5c97f53a8 100644 +--- a/arch/x86/include/asm/entry-common.h ++++ b/arch/x86/include/asm/entry-common.h +@@ -73,19 +73,16 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, + #endif + + /* +- * Ultimately, this value will get limited by KSTACK_OFFSET_MAX(), +- * but not enough for x86 stack utilization comfort. To keep +- * reasonable stack head room, reduce the maximum offset to 8 bits. +- * +- * The actual entropy will be further reduced by the compiler when +- * applying stack alignment constraints (see cc_stack_align4/8 in ++ * This value will get limited by KSTACK_OFFSET_MAX(), which is 10 ++ * bits. The actual entropy will be further reduced by the compiler ++ * when applying stack alignment constraints (see cc_stack_align4/8 in + * arch/x86/Makefile), which will remove the 3 (x86_64) or 2 (ia32) + * low bits from any entropy chosen here. + * +- * Therefore, final stack offset entropy will be 5 (x86_64) or +- * 6 (ia32) bits. ++ * Therefore, final stack offset entropy will be 7 (x86_64) or ++ * 8 (ia32) bits. + */ +- choose_random_kstack_offset(rdtsc() & 0xFF); ++ choose_random_kstack_offset(rdtsc()); + } + #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare + +-- +2.43.0 + diff --git a/queue-6.1/rdma-restrack-fix-potential-invalid-address-access.patch b/queue-6.1/rdma-restrack-fix-potential-invalid-address-access.patch new file mode 100644 index 00000000000..4d890d8114b --- /dev/null +++ b/queue-6.1/rdma-restrack-fix-potential-invalid-address-access.patch @@ -0,0 +1,104 @@ +From 9fc828060b453c53aa96f98830d501079c4a3bfc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 18 Mar 2024 17:23:20 +0800 +Subject: RDMA/restrack: Fix potential invalid address access + +From: Wenchao Hao + +[ Upstream commit ca537a34775c103f7b14d7bbd976403f1d1525d8 ] + +struct rdma_restrack_entry's kern_name was set to KBUILD_MODNAME +in ib_create_cq(), while if the module exited but forgot del this +rdma_restrack_entry, it would cause a invalid address access in +rdma_restrack_clean() when print the owner of this rdma_restrack_entry. + +These code is used to help find one forgotten PD release in one of the +ULPs. But it is not needed anymore, so delete them. + +Signed-off-by: Wenchao Hao +Link: https://lore.kernel.org/r/20240318092320.1215235-1-haowenchao2@huawei.com +Signed-off-by: Leon Romanovsky +Signed-off-by: Sasha Levin +--- + drivers/infiniband/core/restrack.c | 51 +----------------------------- + 1 file changed, 1 insertion(+), 50 deletions(-) + +diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c +index 01a499a8b88db..438ed35881752 100644 +--- a/drivers/infiniband/core/restrack.c ++++ b/drivers/infiniband/core/restrack.c +@@ -37,22 +37,6 @@ int rdma_restrack_init(struct ib_device *dev) + return 0; + } + +-static const char *type2str(enum rdma_restrack_type type) +-{ +- static const char * const names[RDMA_RESTRACK_MAX] = { +- [RDMA_RESTRACK_PD] = "PD", +- [RDMA_RESTRACK_CQ] = "CQ", +- [RDMA_RESTRACK_QP] = "QP", +- [RDMA_RESTRACK_CM_ID] = "CM_ID", +- [RDMA_RESTRACK_MR] = "MR", +- [RDMA_RESTRACK_CTX] = "CTX", +- [RDMA_RESTRACK_COUNTER] = "COUNTER", +- [RDMA_RESTRACK_SRQ] = "SRQ", +- }; +- +- return names[type]; +-}; +- + /** + * rdma_restrack_clean() - clean resource tracking + * @dev: IB device +@@ -60,47 +44,14 @@ static const char *type2str(enum rdma_restrack_type type) + void rdma_restrack_clean(struct ib_device *dev) + { + struct rdma_restrack_root *rt = dev->res; +- struct rdma_restrack_entry *e; +- char buf[TASK_COMM_LEN]; +- bool found = false; +- const char *owner; + int i; + + for (i = 0 ; i < RDMA_RESTRACK_MAX; i++) { + struct xarray *xa = &dev->res[i].xa; + +- if (!xa_empty(xa)) { +- unsigned long index; +- +- if (!found) { +- pr_err("restrack: %s", CUT_HERE); +- dev_err(&dev->dev, "BUG: RESTRACK detected leak of resources\n"); +- } +- xa_for_each(xa, index, e) { +- if (rdma_is_kernel_res(e)) { +- owner = e->kern_name; +- } else { +- /* +- * There is no need to call get_task_struct here, +- * because we can be here only if there are more +- * get_task_struct() call than put_task_struct(). +- */ +- get_task_comm(buf, e->task); +- owner = buf; +- } +- +- pr_err("restrack: %s %s object allocated by %s is not freed\n", +- rdma_is_kernel_res(e) ? "Kernel" : +- "User", +- type2str(e->type), owner); +- } +- found = true; +- } ++ WARN_ON(!xa_empty(xa)); + xa_destroy(xa); + } +- if (found) +- pr_err("restrack: %s", CUT_HERE); +- + kfree(rt); + } + +-- +2.43.0 + diff --git a/queue-6.1/riscv-stacktrace-convert-arch_stack_walk-to-noinstr.patch b/queue-6.1/riscv-stacktrace-convert-arch_stack_walk-to-noinstr.patch new file mode 100644 index 00000000000..acb96ecb29b --- /dev/null +++ b/queue-6.1/riscv-stacktrace-convert-arch_stack_walk-to-noinstr.patch @@ -0,0 +1,44 @@ +From 2cee351290fc4f17050ad02a3ae0fc49df85f704 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 13 Jun 2024 15:11:06 +0800 +Subject: riscv: stacktrace: convert arch_stack_walk() to noinstr + +From: Andy Chiu + +[ Upstream commit 23b2188920a25e88d447dd7d819a0b0f62fb4455 ] + +arch_stack_walk() is called intensively in function_graph when the +kernel is compiled with CONFIG_TRACE_IRQFLAGS. As a result, the kernel +logs a lot of arch_stack_walk and its sub-functions into the ftrace +buffer. However, these functions should not appear on the trace log +because they are part of the ftrace itself. This patch references what +arm64 does for the smae function. So it further prevent the re-enter +kprobe issue, which is also possible on riscv. + +Related-to: commit 0fbcd8abf337 ("arm64: Prohibit instrumentation on arch_stack_walk()") +Fixes: 680341382da5 ("riscv: add CALLER_ADDRx support") +Signed-off-by: Andy Chiu +Reviewed-by: Alexandre Ghiti +Link: https://lore.kernel.org/r/20240613-dev-andyc-dyn-ftrace-v4-v1-1-1a538e12c01e@sifive.com +Signed-off-by: Palmer Dabbelt +Signed-off-by: Sasha Levin +--- + arch/riscv/kernel/stacktrace.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c +index 528ec7cc9a622..0d3f00eb0baee 100644 +--- a/arch/riscv/kernel/stacktrace.c ++++ b/arch/riscv/kernel/stacktrace.c +@@ -156,7 +156,7 @@ unsigned long __get_wchan(struct task_struct *task) + return pc; + } + +-noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, ++noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, + struct task_struct *task, struct pt_regs *regs) + { + walk_stackframe(task, regs, consume_entry, cookie); +-- +2.43.0 + diff --git a/queue-6.1/series b/queue-6.1/series index 1d92000aeb9..dc5d0a2632a 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -34,3 +34,29 @@ powerpc-restore-some-missing-spu-syscalls.patch tcp-fix-tcp_rcv_fastopen_synack-to-enter-tcp_ca_loss.patch netfilter-nf_tables-fully-validate-nft_data_value-on.patch tracing-net_sched-null-pointer-dereference-in-perf_t.patch +bpf-take-return-from-set_memory_ro-into-account-with.patch +drm-panel-ilitek-ili9881c-fix-warning-with-gpio-cont.patch +vduse-validate-block-features-only-with-block-device.patch +vduse-temporarily-fail-if-control-queue-feature-requ.patch +x86-fpu-fix-amd-x86_bug_fxsave_leak-fixup.patch +mtd-partitions-redboot-added-conversion-of-operands-.patch +wifi-ieee80211-check-for-null-in-ieee80211_mle_size_.patch +bpf-add-a-check-for-struct-bpf_fib_lookup-size.patch +bpf-mark-bpf-prog-stack-with-kmsan_unposion_memory-i.patch +rdma-restrack-fix-potential-invalid-address-access.patch +net-iucv-avoid-explicit-cpumask-var-allocation-on-st.patch +net-dpaa2-avoid-explicit-cpumask-var-allocation-on-s.patch +crypto-ecdh-explicitly-zeroize-private_key.patch +alsa-emux-improve-patch-ioctl-data-validation.patch +media-dvbdev-initialize-sbuf.patch +md-fix-overflow-in-is_mddev_idle.patch +soc-ti-wkup_m3_ipc-send-null-dummy-message-instead-o.patch +drm-radeon-radeon_display-decrease-the-size-of-alloc.patch +nvme-fixup-comment-for-nvme-rdma-provider-type.patch +drm-panel-simple-add-missing-display-timing-flags-fo.patch +gpio-davinci-validate-the-obtained-number-of-irqs.patch +drm-amd-amdgpu-fix-style-errors-in-amdgpu_drv.c-amdg.patch +drm-amdgpu-fix-pci-state-save-during-mode-1-reset.patch +riscv-stacktrace-convert-arch_stack_walk-to-noinstr.patch +gpiolib-cdev-disallow-reconfiguration-without-direct.patch +randomize_kstack-remove-non-functional-per-arch-entr.patch diff --git a/queue-6.1/soc-ti-wkup_m3_ipc-send-null-dummy-message-instead-o.patch b/queue-6.1/soc-ti-wkup_m3_ipc-send-null-dummy-message-instead-o.patch new file mode 100644 index 00000000000..ff941a279f3 --- /dev/null +++ b/queue-6.1/soc-ti-wkup_m3_ipc-send-null-dummy-message-instead-o.patch @@ -0,0 +1,71 @@ +From 5004d4706426e1a61ea570c7e6de97c2146a92be Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 25 Mar 2024 11:55:07 -0500 +Subject: soc: ti: wkup_m3_ipc: Send NULL dummy message instead of pointer + message + +From: Andrew Davis + +[ Upstream commit ddbf3204f600a4d1f153498f618369fca352ae00 ] + +mbox_send_message() sends a u32 bit message, not a pointer to a message. +We only convert to a pointer type as a generic type. If we want to send +a dummy message of 0, then simply send 0 (NULL). + +Signed-off-by: Andrew Davis +Link: https://lore.kernel.org/r/20240325165507.30323-1-afd@ti.com +Signed-off-by: Nishanth Menon +Signed-off-by: Sasha Levin +--- + drivers/soc/ti/wkup_m3_ipc.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c +index 343c58ed58961..103d793bae748 100644 +--- a/drivers/soc/ti/wkup_m3_ipc.c ++++ b/drivers/soc/ti/wkup_m3_ipc.c +@@ -16,7 +16,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -314,7 +313,6 @@ static irqreturn_t wkup_m3_txev_handler(int irq, void *ipc_data) + static int wkup_m3_ping(struct wkup_m3_ipc *m3_ipc) + { + struct device *dev = m3_ipc->dev; +- mbox_msg_t dummy_msg = 0; + int ret; + + if (!m3_ipc->mbox) { +@@ -330,7 +328,7 @@ static int wkup_m3_ping(struct wkup_m3_ipc *m3_ipc) + * the RX callback to avoid multiple interrupts being received + * by the CM3. + */ +- ret = mbox_send_message(m3_ipc->mbox, &dummy_msg); ++ ret = mbox_send_message(m3_ipc->mbox, NULL); + if (ret < 0) { + dev_err(dev, "%s: mbox_send_message() failed: %d\n", + __func__, ret); +@@ -352,7 +350,6 @@ static int wkup_m3_ping(struct wkup_m3_ipc *m3_ipc) + static int wkup_m3_ping_noirq(struct wkup_m3_ipc *m3_ipc) + { + struct device *dev = m3_ipc->dev; +- mbox_msg_t dummy_msg = 0; + int ret; + + if (!m3_ipc->mbox) { +@@ -361,7 +358,7 @@ static int wkup_m3_ping_noirq(struct wkup_m3_ipc *m3_ipc) + return -EIO; + } + +- ret = mbox_send_message(m3_ipc->mbox, &dummy_msg); ++ ret = mbox_send_message(m3_ipc->mbox, NULL); + if (ret < 0) { + dev_err(dev, "%s: mbox_send_message() failed: %d\n", + __func__, ret); +-- +2.43.0 + diff --git a/queue-6.1/vduse-temporarily-fail-if-control-queue-feature-requ.patch b/queue-6.1/vduse-temporarily-fail-if-control-queue-feature-requ.patch new file mode 100644 index 00000000000..b7eaabccba6 --- /dev/null +++ b/queue-6.1/vduse-temporarily-fail-if-control-queue-feature-requ.patch @@ -0,0 +1,66 @@ +From a93275f9bc3e00125dbddcfd991ec795a484b032 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 9 Jan 2024 12:10:24 +0100 +Subject: vduse: Temporarily fail if control queue feature requested +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Maxime Coquelin + +[ Upstream commit 56e71885b0349241c07631a7b979b61e81afab6a ] + +Virtio-net driver control queue implementation is not safe +when used with VDUSE. If the VDUSE application does not +reply to control queue messages, it currently ends up +hanging the kernel thread sending this command. + +Some work is on-going to make the control queue +implementation robust with VDUSE. Until it is completed, +let's fail features check if control-queue feature is +requested. + +Signed-off-by: Maxime Coquelin +Message-Id: <20240109111025.1320976-3-maxime.coquelin@redhat.com> +Signed-off-by: Michael S. Tsirkin +Acked-by: Eugenio Pérez +Reviewed-by: Xie Yongji +Acked-by: Jason Wang +Signed-off-by: Sasha Levin +--- + drivers/vdpa/vdpa_user/vduse_dev.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c +index cb35a76146b39..0ccece3f4f7da 100644 +--- a/drivers/vdpa/vdpa_user/vduse_dev.c ++++ b/drivers/vdpa/vdpa_user/vduse_dev.c +@@ -8,6 +8,7 @@ + * + */ + ++#include "linux/virtio_net.h" + #include + #include + #include +@@ -28,6 +29,7 @@ + #include + #include + #include ++#include + #include + + #include "iova_domain.h" +@@ -1425,6 +1427,9 @@ static bool features_is_valid(struct vduse_dev_config *config) + if ((config->device_id == VIRTIO_ID_BLOCK) && + (config->features & BIT_ULL(VIRTIO_BLK_F_CONFIG_WCE))) + return false; ++ else if ((config->device_id == VIRTIO_ID_NET) && ++ (config->features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))) ++ return false; + + return true; + } +-- +2.43.0 + diff --git a/queue-6.1/vduse-validate-block-features-only-with-block-device.patch b/queue-6.1/vduse-validate-block-features-only-with-block-device.patch new file mode 100644 index 00000000000..a39e4516b4c --- /dev/null +++ b/queue-6.1/vduse-validate-block-features-only-with-block-device.patch @@ -0,0 +1,64 @@ +From b77992401415991d2e68273183e02a6c1df1ad03 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 9 Jan 2024 12:10:23 +0100 +Subject: vduse: validate block features only with block devices +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Maxime Coquelin + +[ Upstream commit a115b5716fc9a64652aa9cb332070087178ffafa ] + +This patch is preliminary work to enable network device +type support to VDUSE. + +As VIRTIO_BLK_F_CONFIG_WCE shares the same value as +VIRTIO_NET_F_HOST_TSO4, we need to restrict its check +to Virtio-blk device type. + +Acked-by: Jason Wang +Reviewed-by: Xie Yongji +Reviewed-by: Eugenio Pérez +Signed-off-by: Maxime Coquelin +Message-Id: <20240109111025.1320976-2-maxime.coquelin@redhat.com> +Signed-off-by: Michael S. Tsirkin +Signed-off-by: Sasha Levin +--- + drivers/vdpa/vdpa_user/vduse_dev.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c +index edcd74cc4c0f7..cb35a76146b39 100644 +--- a/drivers/vdpa/vdpa_user/vduse_dev.c ++++ b/drivers/vdpa/vdpa_user/vduse_dev.c +@@ -1416,13 +1416,14 @@ static bool device_is_allowed(u32 device_id) + return false; + } + +-static bool features_is_valid(u64 features) ++static bool features_is_valid(struct vduse_dev_config *config) + { +- if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) ++ if (!(config->features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM))) + return false; + + /* Now we only support read-only configuration space */ +- if (features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE)) ++ if ((config->device_id == VIRTIO_ID_BLOCK) && ++ (config->features & BIT_ULL(VIRTIO_BLK_F_CONFIG_WCE))) + return false; + + return true; +@@ -1449,7 +1450,7 @@ static bool vduse_validate_config(struct vduse_dev_config *config) + if (!device_is_allowed(config->device_id)) + return false; + +- if (!features_is_valid(config->features)) ++ if (!features_is_valid(config)) + return false; + + return true; +-- +2.43.0 + diff --git a/queue-6.1/wifi-ieee80211-check-for-null-in-ieee80211_mle_size_.patch b/queue-6.1/wifi-ieee80211-check-for-null-in-ieee80211_mle_size_.patch new file mode 100644 index 00000000000..306d2d2b376 --- /dev/null +++ b/queue-6.1/wifi-ieee80211-check-for-null-in-ieee80211_mle_size_.patch @@ -0,0 +1,38 @@ +From ddb7971ba746647b69418f9acc96b1ffe57d5eba Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 18 Mar 2024 18:53:17 +0200 +Subject: wifi: ieee80211: check for NULL in ieee80211_mle_size_ok() + +From: Johannes Berg + +[ Upstream commit b7793a1a2f370c28b17d9554b58e9dc51afcfcbd ] + +For simplicity, we may want to pass a NULL element, and +while we should then pass also a zero length, just be a +bit more careful here. + +Signed-off-by: Johannes Berg +Signed-off-by: Miri Korenblit +Link: https://msgid.link/20240318184907.4d983653cb8d.Ic3ea99b60c61ac2f7d38cb9fd202a03c97a05601@changeid +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + include/linux/ieee80211.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h +index dce105f67b4d8..160230bb1a9ce 100644 +--- a/include/linux/ieee80211.h ++++ b/include/linux/ieee80211.h +@@ -4608,7 +4608,7 @@ static inline bool ieee80211_mle_size_ok(const u8 *data, u8 len) + bool check_common_len = false; + u16 control; + +- if (len < fixed) ++ if (!data || len < fixed) + return false; + + control = le16_to_cpu(mle->control); +-- +2.43.0 + diff --git a/queue-6.1/x86-fpu-fix-amd-x86_bug_fxsave_leak-fixup.patch b/queue-6.1/x86-fpu-fix-amd-x86_bug_fxsave_leak-fixup.patch new file mode 100644 index 00000000000..968a662898a --- /dev/null +++ b/queue-6.1/x86-fpu-fix-amd-x86_bug_fxsave_leak-fixup.patch @@ -0,0 +1,61 @@ +From 18626ca53795349afbf310022fae52b0bd51ae57 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 15 Mar 2024 09:18:23 +0100 +Subject: x86/fpu: Fix AMD X86_BUG_FXSAVE_LEAK fixup + +From: Uros Bizjak + +[ Upstream commit 5d31174f3c8c465d9dbe88f6b9d1fe5716f44981 ] + +The assembly snippet in restore_fpregs_from_fpstate() that implements +X86_BUG_FXSAVE_LEAK fixup loads the value from a random variable, +preferably the one that is already in the L1 cache. + +However, the access to fpinit_state via *fpstate pointer is not +implemented correctly. The "m" asm constraint requires dereferenced +pointer variable, otherwise the compiler just reloads the value +via temporary stack slot. The current asm code reflects this: + + mov %rdi,(%rsp) + ... + fildl (%rsp) + +With dereferenced pointer variable, the code does what the +comment above the asm snippet says: + + fildl (%rdi) + +Also, remove the pointless %P operand modifier. The modifier is +ineffective on non-symbolic references - it was used to prevent +%rip-relative addresses in .altinstr sections, but FILDL in the +.text section can use %rip-relative addresses without problems. + +Signed-off-by: Uros Bizjak +Signed-off-by: Ingo Molnar +Cc: Andy Lutomirski +Cc: H. Peter Anvin +Cc: Linus Torvalds +Link: https://lore.kernel.org/r/20240315081849.5187-1-ubizjak@gmail.com +Signed-off-by: Sasha Levin +--- + arch/x86/kernel/fpu/core.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c +index 1d190761d00fd..f1446f532b17b 100644 +--- a/arch/x86/kernel/fpu/core.c ++++ b/arch/x86/kernel/fpu/core.c +@@ -145,8 +145,8 @@ void restore_fpregs_from_fpstate(struct fpstate *fpstate, u64 mask) + asm volatile( + "fnclex\n\t" + "emms\n\t" +- "fildl %P[addr]" /* set F?P to defined value */ +- : : [addr] "m" (fpstate)); ++ "fildl %[addr]" /* set F?P to defined value */ ++ : : [addr] "m" (*fpstate)); + } + + if (use_xsave()) { +-- +2.43.0 +