xfrm: Zero padding when dumping algos and encap
Subsystems (10)
Sasha Levin
maintainerPATCH 16/34 drm/amdkfd: Fix BO offset for multi-VMA page migration
In reply to Sasha LevinFrom: Xiaogang Chen <[email protected]>
[ Upstream commit b4ee9606378bb9520c94d8b96f0305c3696f5c29 ]
svm_migrate_ram_to_vram migrates a prange from sys ram to vram. The prange may cross multiple vma. Need remember current dst vram offset in the TTM resource for each migration.
v2: squash in warning fix (Alex)
--- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +10 -7
@@ -295,7 +295,7 @@ static unsigned long svm_migrate_unsuccessful_pages(struct migrate_vma *migrate)static int svm_migrate_copy_to_vram (struct amdgpu_device *adev,struct svm_range *prange,struct migrate_vma *migrate,struct dma_fence **mfence, -dma_addr_t *scratch) +dma_addr_t *scratch,uint64_t ttm_res_offset) {uint64_t npages = migrate->npages;struct device *dev = adev->dev;
@@ -305,8 +305,8 @@ svm_migrate_copy_to_vram(struct amdgpu_device *adev, struct svm_range *prange,uint64_t i, j;int r; -pr_debug ("svms 0x%p [0x%lx 0x%lx]\n" , prange->svms, prange->start, - prange->last); +pr_debug ("svms 0x%p [0x%lx 0x%lx 0x%llx]\n" , prange->svms, prange->start, + prange->last, ttm_res_offset); src = scratch; dst = (uint64_t *)(scratch + npages);
@@ -317,7 +317,7 @@ svm_migrate_copy_to_vram(struct amdgpu_device *adev, struct svm_range *prange, goto out; } -amdgpu_res_first (prange->ttm_res, prange->offset <<PAGE_SHIFT , +amdgpu_res_first (prange->ttm_res, ttm_res_offset, npages <<PAGE_SHIFT , &cursor);for (i = j =0 ; i < npages; i++) {struct page *spage;
@@ -404,7 +404,7 @@ svm_migrate_copy_to_vram(struct amdgpu_device *adev, struct svm_range *prange,static long svm_migrate_vma_to_vram (struct amdgpu_device *adev,struct svm_range *prange,struct vm_area_struct *vma,uint64_t start, -uint64_t end,uint32_t trigger) +uint64_t end,uint32_t trigger,uint64_t ttm_res_offset) { struct kfd_process *p = container_of(prange->svms, struct kfd_process, svms);uint64_t npages = (end - start) >>PAGE_SHIFT ;
@@ -457,7 +457,7 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange,else pr_debug ("0x%lx pages migrated\n" , cpages); - r =svm_migrate_copy_to_vram (adev, prange, &migrate, &mfence, scratch); + r =svm_migrate_copy_to_vram (adev, prange, &migrate, &mfence, scratch, ttm_res_offset);migrate_vma_pages (&migrate); pr_debug("successful/cpages/npages 0x%lx/0x%lx/0x%lx\n",
@@ -505,6 +505,7 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,unsigned long addr, start, end;struct vm_area_struct *vma;struct amdgpu_device *adev; +uint64_t ttm_res_offset;unsigned long cpages =0 ;long r =0 ;
@@ -525,6 +526,7 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc, start = prange->start <<PAGE_SHIFT ; end = (prange->last +1 ) <<PAGE_SHIFT ; + ttm_res_offset = prange->offset <<PAGE_SHIFT ;for (addr = start; addr < end;) {unsigned long next;
@@ -534,13 +536,14 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,break ; next =min (vma->vm_end, end); - r =svm_migrate_vma_to_vram (adev, prange, vma, addr, next, trigger); + r =svm_migrate_vma_to_vram (adev, prange, vma, addr, next, trigger, ttm_res_offset);if (r <0 ) {pr_debug ("failed %ld to migrate\n" , r);break ; }else { cpages += r; } + ttm_res_offset += next - addr; addr = next; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 17/34 drm/amdkfd: fix a potential double free in pqm_create_queue
In reply to Sasha LevinFrom: Chia-I Wu <[email protected]>
[ Upstream commit b2ca5c5d416b4e72d1e9d0293fc720e2d525fd42 ]
Set *q to NULL on errors, otherwise pqm_create_queue would free it again.
--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +2 -2
@@ -218,8 +218,8 @@ static int init_user_queue(struct process_queue_manager *pqm,return 0 ; cleanup: -if (dev->shared_resources.enable_mes) -uninit_queue (*q); +uninit_queue (*q); + *q =NULL ;return retval; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 18/34 drm/amdkfd: fix potential kgd_mem UAFs
In reply to Sasha LevinFrom: Chia-I Wu <[email protected]>
[ Upstream commit 9da050b0d9e04439d225a2ec3044af70cdfb3933 ]
kgd_mem pointers returned by kfd_process_device_translate_handle are only guaranteed to be valid while p->mutex is held. As soon as the mutex is unlocked, another thread can free the BO.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +10 -6
@@ -1298,14 +1298,14 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, args->n_success = i+1 ; } -mutex_unlock (&p->mutex); - err =amdgpu_amdkfd_gpuvm_sync_memory (dev->adev, (struct kgd_mem *) mem, true);if (err) {pr_debug ("Sync memory failed, wait interrupted by user signal\n" ); goto sync_memory_failed; } +mutex_unlock (&p->mutex); +/* Flush TLBs after waiting for the page table updates to complete */ for (i =0 ; i < args->n_devices; i++) { peer_pdd =kfd_process_device_data_by_id (p, devices_arr[i]);
@@ -1321,9 +1321,9 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, bind_process_to_device_failed: get_mem_obj_from_handle_failed: map_memory_to_gpu_failed: +sync_memory_failed:mutex_unlock (&p->mutex); copy_from_user_failed: -sync_memory_failed:kfree (devices_arr);return err;
@@ -1337,6 +1337,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,void *mem;long err =0 ;uint32_t *devices_arr =NULL , i; +bool flush_tlb;if (!args->n_devices) {pr_debug ("Device IDs array empty\n" );
@@ -1389,16 +1390,19 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, } args->n_success = i+1 ; } -mutex_unlock (&p->mutex); -if (kfd_flush_tlb_after_unmap (pdd->dev)) { + flush_tlb =kfd_flush_tlb_after_unmap (pdd->dev); +if (flush_tlb) { err =amdgpu_amdkfd_gpuvm_sync_memory (pdd->dev->adev, (struct kgd_mem *) mem, true);if (err) {pr_debug ("Sync memory failed, wait interrupted by user signal\n" ); goto sync_memory_failed; } + } +mutex_unlock (&p->mutex); +if (flush_tlb) {/* Flush TLBs after waiting for the page table updates to complete */ for (i =0 ; i < args->n_devices; i++) { peer_pdd =kfd_process_device_data_by_id (p, devices_arr[i]);
@@ -1414,9 +1418,9 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, bind_process_to_device_failed: get_mem_obj_from_handle_failed: unmap_memory_from_gpu_failed: +sync_memory_failed:mutex_unlock (&p->mutex); copy_from_user_failed: -sync_memory_failed:kfree (devices_arr);return err; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 15/34 x86/PVH: obtain VGA console info in Dom0
In reply to Sasha LevinFrom: Jan Beulich <[email protected]>
[ Upstream commit 934ef33ee75c3846f605f18b65048acd147e3918 ]
A new platform-op was added to Xen to allow obtaining the same VGA console information PV Dom0 is handed. Invoke the new function and have the output data processed by xen_init_vga().
--- arch/x86/xen/Makefile | 2 +- arch/x86/xen/enlighten_pv.c | 3 ++- arch/x86/xen/enlighten_pvh.c | 13 +++++++++++++ arch/x86/xen/vga.c | 5 ++--- arch/x86/xen/xen-ops.h | 7 ++++--- include/xen/interface/platform.h | 3 +++ 6 files changed, 25 insertions(+), 8 deletions(-)
arch/x86/xen/Makefile +1 -1
@@ -45,6 +45,6 @@ obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o -obj-$(CONFIG_XEN_PV_DOM0) += vga.o +obj-$(CONFIG_XEN_DOM0) += vga.o obj-$(CONFIG_XEN_EFI) += efi.o
arch/x86/xen/enlighten_pv.c +2 -1
@@ -1389,7 +1389,8 @@ asmlinkage __visible void __init xen_start_kernel(struct start_info *si) x86_platform.set_legacy_features = xen_dom0_set_legacy_features; -xen_init_vga (info, xen_start_info->console.dom0.info_size); +xen_init_vga (info, xen_start_info->console.dom0.info_size, + &boot_params.screen_info); xen_start_info->console.domU.mfn =0 ; xen_start_info->console.domU.evtchn =0 ;
arch/x86/xen/enlighten_pvh.c +13 -0
@@ -43,6 +43,19 @@ void __init xen_pvh_init(struct boot_params *boot_params) x86_init.oem.banner = xen_banner;xen_efi_init (boot_params); + +if (xen_initial_domain ()) { +struct xen_platform_op op = { + .cmd = XENPF_get_dom0_console, + }; +long ret =HYPERVISOR_platform_op (&op); + +if (ret >0 ) +xen_init_vga (&op.u.dom0_console, +min (ret *sizeof (char ), +sizeof (op.u.dom0_console)), + &boot_params->screen_info); + } }void __init mem_map_via_hcall (struct boot_params *boot_params_p)
arch/x86/xen/vga.c +2 -3
@@ -9,10 +9,9 @@#include "xen-ops.h" -void __init xen_init_vga (const struct dom0_vga_console_info *info,size_t size) +void __init xen_init_vga (const struct dom0_vga_console_info *info,size_t size, +struct screen_info *screen_info) { -struct screen_info *screen_info = &boot_params.screen_info; -/* This is drawn from a dump from vgacon:startup in * standard Linux. */ screen_info->orig_video_mode =3 ;
arch/x86/xen/xen-ops.h +4 -3
@@ -108,11 +108,12 @@ static inline void xen_uninit_lock_cpu(int cpu)struct dom0_vga_console_info ; -#ifdef CONFIG_XEN_PV_DOM0 -void __init xen_init_vga (const struct dom0_vga_console_info *,size_t size); +#ifdef CONFIG_XEN_DOM0 +void __init xen_init_vga (const struct dom0_vga_console_info *,size_t size, +struct screen_info *);#else static inline void __init xen_init_vga (const struct dom0_vga_console_info *info, -size_t size) +size_t size,struct screen_info *si) { }#endif
include/xen/interface/platform.h +3 -0
@@ -483,6 +483,8 @@ struct xenpf_symdata { };DEFINE_GUEST_HANDLE_STRUCT (xenpf_symdata); +#define XENPF_get_dom0_console 64 +struct xen_platform_op {uint32_t cmd;uint32_t interface_version;/* XENPF_INTERFACE_VERSION */
@@ -506,6 +508,7 @@ struct xen_platform_op {struct xenpf_mem_hotadd mem_add;struct xenpf_core_parking core_parking;struct xenpf_symdata symdata; +struct dom0_vga_console_info dom0_console;uint8_t pad[128 ]; } u; };
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 22/34 fbdev: tgafb: Fix potential divide by zero
In reply to Sasha LevinFrom: Wei Chen <[email protected]>
[ Upstream commit f90bd245de82c095187d8c2cabb8b488a39eaecc ]
fb_set_var would by called when user invokes ioctl with cmd FBIOPUT_VSCREENINFO. User-provided data would finally reach tgafb_check_var. In case var->pixclock is assigned to zero, divide by zero would occur when checking whether reciprocal of var->pixclock is too high.
Similar crashes have happened in other fbdev drivers. There is no check and modification on var->pixclock along the call chain to tgafb_check_var. We believe it could also be triggered in driver tgafb from user site.
--- drivers/video/fbdev/tgafb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/tgafb.c +3 -0
@@ -173,6 +173,9 @@ tgafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) {struct tga_par *par = (struct tga_par *)info->par; +if (!var->pixclock) +return -EINVAL ; +if (par->tga_type ==TGA_TYPE_8PLANE ) {if (var->bits_per_pixel !=8 )return -EINVAL ;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 26/34 drm/amdkfd: Fixed kfd_process cleanup on module exit.
In reply to Sasha LevinFrom: David Belanger <[email protected]>
[ Upstream commit 20bc9f76b6a2455c6b54b91ae7634f147f64987f ]
Handle case when module is unloaded (kfd_exit) before a process space (mm_struct) is released.
v2: Fixed potential race conditions by removing all kfd_process from the process table first, then working on releasing the resources.
v3: Fixed loop element access / synchronization. Fixed extra empty lines.
--- drivers/gpu/drm/amd/amdkfd/kfd_module.c | 1 + drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 67 +++++++++++++++++++++--- 3 files changed, 62 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_module.c +1 -0
@@ -77,6 +77,7 @@ static int kfd_init(void)static void kfd_exit (void ) { +kfd_cleanup_processes ();kfd_debugfs_fini ();kfd_process_destroy_wq ();kfd_procfs_shutdown ();
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -0
@@ -928,6 +928,7 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev);int kfd_process_create_wq (void );void kfd_process_destroy_wq (void ); +void kfd_cleanup_processes (void );struct kfd_process *kfd_create_process (struct file *filep);struct kfd_process *kfd_get_process (const struct task_struct *task);struct kfd_process *kfd_lookup_process_by_pasid (u32 pasid);
drivers/gpu/drm/amd/amdkfd/kfd_process.c +60 -7
89 lines not on this page · raw message
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 25/34 nvme-pci: add NVME_QUIRK_BOGUS_NID for Lexar NM620
In reply to Sasha LevinFrom: Philipp Geulen <[email protected]>
[ Upstream commit b65d44fa0fe072c91bf41cd8756baa2b4c77eff2 ]
Added a quirk to fix Lexar NM620 1TB SSD reporting duplicate NGUIDs.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -3545,6 +3545,8 @@ static const struct pci_device_id nvme_id_table[] = { .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x1d97, 0x2263), /* Lexar NM610 */ .driver_data = NVME_QUIRK_BOGUS_NID, }, + { PCI_DEVICE(0x1d97, 0x1d97), /* Lexar NM620 */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x1d97, 0x2269), /* Lexar NM760 */ .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0061),
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 28/34 fbdev: nvidia: Fix potential divide by zero
In reply to Sasha LevinFrom: Wei Chen <[email protected]>
[ Upstream commit 92e2a00f2987483e1f9253625828622edd442e61 ]
variable var->pixclock can be set by user. In case it equals to zero, divide by zero would occur in nvidiafb_set_par.
Similar crashes have happened in other fbdev drivers. There is no check and modification on var->pixclock along the call chain to nvidia_check_var and nvidiafb_set_par. We believe it could also be triggered in driver nvidia from user site.
--- drivers/video/fbdev/nvidia/nvidia.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/nvidia/nvidia.c +2 -0
@@ -764,6 +764,8 @@ static int nvidiafb_check_var(struct fb_var_screeninfo *var,int pitch, err =0 ;NVTRACE_ENTER (); +if (!var->pixclock) +return -EINVAL ; var->transp.offset =0 ; var->transp.length =0 ;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 29/34 fbdev: intelfb: Fix potential divide by zero
In reply to Sasha LevinFrom: Wei Chen <[email protected]>
[ Upstream commit d823685486a3446d061fed7c7d2f80af984f119a ]
Variable var->pixclock is controlled by user and can be assigned to zero. Without proper check, divide by zero would occur in intelfbhw_validate_mode and intelfbhw_mode_to_hw.
Error out if var->pixclock is zero.
--- drivers/video/fbdev/intelfb/intelfbdrv.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/intelfb/intelfbdrv.c +3 -0
@@ -1219,6 +1219,9 @@ static int intelfb_check_var(struct fb_var_screeninfo *var, dinfo =GET_DINFO (info); +if (!var->pixclock) +return -EINVAL ; +/* update the pitch */ if (intelfbhw_validate_mode (dinfo, var) !=0 )return -EINVAL ;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 30/34 fbdev: lxfb: Fix potential divide by zero
In reply to Sasha LevinFrom: Wei Chen <[email protected]>
[ Upstream commit 61ac4b86a4c047c20d5cb423ddd87496f14d9868 ]
var->pixclock can be assigned to zero by user. Without proper check, divide by zero would occur in lx_set_clock.
Error out if var->pixclock is zero.
--- drivers/video/fbdev/geode/lxfb_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/geode/lxfb_core.c +3 -0
@@ -235,6 +235,9 @@ static void get_modedb(struct fb_videomode **modedb, unsigned int *size)static int lxfb_check_var (struct fb_var_screeninfo *var,struct fb_info *info) { +if (!var->pixclock) +return -EINVAL ; +if (var->xres >1920 || var->yres >1440 )return -EINVAL ;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 31/34 fbdev: au1200fb: Fix potential divide by zero
In reply to Sasha LevinFrom: Wei Chen <[email protected]>
[ Upstream commit 44a3b36b42acfc433aaaf526191dd12fbb919fdb ]
var->pixclock can be assigned to zero by user. Without proper check, divide by zero would occur when invoking macro PICOS2KHZ in au1200fb_fb_check_var.
Error out if var->pixclock is zero.
--- drivers/video/fbdev/au1200fb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/au1200fb.c +3 -0
@@ -1040,6 +1040,9 @@ static int au1200fb_fb_check_var(struct fb_var_screeninfo *var,u32 pixclock;int screen_size, plane; +if (!var->pixclock) +return -EINVAL ; + plane = fbdev->plane;/* Make sure that the mode respect all LCD controller and
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 2/34 ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
In reply to Sasha LevinFrom: Ravulapati Vishnu Vardhan Rao <[email protected]>
[ Upstream commit e5e7e398f6bb7918dab0612eb6991f7bae95520d ]
When we run syzkaller we get below Out of Bound.
"KASAN: slab-out-of-bounds Read in regcache_flat_read"
Below is the backtrace of the issue:
dump_backtrace+0x0/0x4c8
show_stack+0x34/0x44
dump_stack_lvl+0xd8/0x118
print_address_description+0x30/0x2d8
kasan_report+0x158/0x198
__asan_report_load4_noabort+0x44/0x50
regcache_flat_read+0x10c/0x110
regcache_read+0xf4/0x180
_regmap_read+0xc4/0x278
_regmap_update_bits+0x130/0x290
regmap_update_bits_base+0xc0/0x15c
snd_soc_component_update_bits+0xa8/0x22c
snd_soc_component_write_field+0x68/0xd4
tx_macro_digital_mute+0xec/0x140
Actually There is no need to have decimator with 32 bits.
By limiting the variable with short type u8 issue is resolved.--- sound/soc/codecs/lpass-tx-macro.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
sound/soc/codecs/lpass-tx-macro.c +6 -5
@@ -241,7 +241,7 @@ enum {struct tx_mute_work {struct tx_macro *tx; -u32 decimator; +u8 decimator;struct delayed_work dwork; };
@@ -634,7 +634,7 @@ static int tx_macro_mclk_enable(struct tx_macro *tx,return 0 ; } -static bool is_amic_enabled (struct snd_soc_component *component,int decimator) +static bool is_amic_enabled (struct snd_soc_component *component,u8 decimator) {u16 adc_mux_reg, adc_reg, adc_n;
@@ -845,7 +845,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm); -unsigned int decimator; +u8 decimator;u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg, tx_gain_ctl_reg;u8 hpf_cut_off_freq;int hpf_delay =TX_MACRO_DMIC_HPF_DELAY_MS ;
@@ -1060,7 +1060,8 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct snd_soc_component *component = dai->component; -u32 decimator, sample_rate; +u32 sample_rate; +u8 decimator;int tx_fs_rate;struct tx_macro *tx =snd_soc_component_get_drvdata (component);
@@ -1124,7 +1125,7 @@ static int tx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream) {struct snd_soc_component *component = dai->component;struct tx_macro *tx =snd_soc_component_get_drvdata (component); -u16 decimator; +u8 decimator;/* active decimator not set yet */ if (tx->active_decimator[dai->id] ==-1 )
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 3/34 ASoC: Intel: avs: max98357a: Explicitly define codec format
In reply to Sasha LevinFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit d16c893425d07ada1fdd817ec06d322efcf69480 ]
max98357a is speaker codec configured in 48000/2/S16_LE format regardless of front end format, so force it to be so.
--- sound/soc/intel/avs/boards/max98357a.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
sound/soc/intel/avs/boards/max98357a.c +22 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-acpi.h> #include <sound/soc-dapm.h>
@@ -24,6 +25,26 @@ static const struct snd_soc_dapm_route card_base_routes[] = { { "Spk", NULL, "Speaker" }, }; +static int +avs_max98357a_be_fixup (struct snd_soc_pcm_runtime *runrime,struct snd_pcm_hw_params *params) +{ +struct snd_interval *rate, *channels; +struct snd_mask *fmt; + + rate =hw_param_interval (params,SNDRV_PCM_HW_PARAM_RATE ); + channels =hw_param_interval (params,SNDRV_PCM_HW_PARAM_CHANNELS ); + fmt =hw_param_mask (params,SNDRV_PCM_HW_PARAM_FORMAT ); + +/* The ADSP will convert the FE rate to 48k, stereo */ + rate->min = rate->max =48000 ; + channels->min = channels->max =2 ; + +/* set SSP0 to 16 bit */ +snd_mask_none (fmt); +snd_mask_set_format (fmt,SNDRV_PCM_FORMAT_S16_LE ); +return 0 ; +} +static int avs_create_dai_link (struct device *dev,const char *platform_name,int ssp_port,struct snd_soc_dai_link **dai_link) {
@@ -55,6 +76,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in dl->num_platforms =1 ; dl->id =0 ; dl->dai_fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; + dl->be_hw_params_fixup = avs_max98357a_be_fixup; dl->nonatomic =1 ; dl->no_pcm =1 ; dl->dpcm_playback =1 ;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 4/34 ASoC: Intel: avs: da7219: Explicitly define codec format
In reply to Sasha LevinFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit 61f368624fe4d0c25c6e9c917574b8ace51d776e ]
da7219 is headset codec configured in 48000/2/S24_LE format regardless of front end format, so force it to be so.
--- sound/soc/intel/avs/boards/da7219.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
sound/soc/intel/avs/boards/da7219.c +21 -0
@@ -111,6 +111,26 @@ static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime)return 0 ; } +static int +avs_da7219_be_fixup (struct snd_soc_pcm_runtime *runrime,struct snd_pcm_hw_params *params) +{ +struct snd_interval *rate, *channels; +struct snd_mask *fmt; + + rate =hw_param_interval (params,SNDRV_PCM_HW_PARAM_RATE ); + channels =hw_param_interval (params,SNDRV_PCM_HW_PARAM_CHANNELS ); + fmt =hw_param_mask (params,SNDRV_PCM_HW_PARAM_FORMAT ); + +/* The ADSP will convert the FE rate to 48k, stereo */ + rate->min = rate->max =48000 ; + channels->min = channels->max =2 ; + +/* set SSP0 to 24 bit */ +snd_mask_none (fmt); +snd_mask_set_format (fmt,SNDRV_PCM_FORMAT_S24_LE ); +return 0 ; +} +static int avs_create_dai_link (struct device *dev,const char *platform_name,int ssp_port,struct snd_soc_dai_link **dai_link) {
@@ -142,6 +162,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in dl->num_platforms =1 ; dl->id =0 ; dl->dai_fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; + dl->be_hw_params_fixup = avs_da7219_be_fixup; dl->init = avs_da7219_codec_init; dl->nonatomic =1 ; dl->no_pcm =1 ;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 5/34 ASoC: Intel: avs: ssm4567: Remove nau8825 bits
In reply to Sasha LevinFrom: Cezary Rojewski <[email protected]>
[ Upstream commit 933de2d127281731166cf2880fa1e23c5a0f7faa ]
Some of the nau8825 clock control got into the ssm4567, remove it.
--- sound/soc/intel/avs/boards/ssm4567.c | 31 ---------------------------- 1 file changed, 31 deletions(-)
sound/soc/intel/avs/boards/ssm4567.c +0 -31
@@ -15,7 +15,6 @@#include <sound/soc-acpi.h> #include "../../../codecs/nau8825.h" -#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"#define SKL_SSM_CODEC_DAI "ssm4567-hifi"static struct snd_soc_codec_conf card_codec_conf[] = {
@@ -34,41 +33,11 @@ static const struct snd_kcontrol_new card_controls[] = { SOC_DAPM_PIN_SWITCH("Right Speaker"), }; -static int -platform_clock_control (struct snd_soc_dapm_widget *w,struct snd_kcontrol *control,int event) -{ -struct snd_soc_dapm_context *dapm = w->dapm; -struct snd_soc_card *card = dapm->card; -struct snd_soc_dai *codec_dai; -int ret; - - codec_dai =snd_soc_card_get_codec_dai (card,SKL_NUVOTON_CODEC_DAI ); -if (!codec_dai) { -dev_err (card->dev,"Codec dai not found\n" ); -return -EINVAL ; - } - -if (SND_SOC_DAPM_EVENT_ON (event)) { - ret =snd_soc_dai_set_sysclk (codec_dai,NAU8825_CLK_MCLK ,24000000 , -SND_SOC_CLOCK_IN ); -if (ret <0 ) -dev_err (card->dev,"set sysclk err = %d\n" , ret); - }else { - ret =snd_soc_dai_set_sysclk (codec_dai,NAU8825_CLK_INTERNAL ,0 ,SND_SOC_CLOCK_IN ); -if (ret <0 ) -dev_err (card->dev,"set sysclk err = %d\n" , ret); - } - -return ret; -} -static const struct snd_soc_dapm_widget card_widgets[] = {SND_SOC_DAPM_SPK ("Left Speaker" ,NULL ),SND_SOC_DAPM_SPK ("Right Speaker" ,NULL ),SND_SOC_DAPM_SPK ("DP1" ,NULL ),SND_SOC_DAPM_SPK ("DP2" ,NULL ), -SND_SOC_DAPM_SUPPLY ("Platform Clock" ,SND_SOC_NOPM ,0 ,0 , platform_clock_control, -SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ), };static const struct snd_soc_dapm_route card_base_routes[] = {
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 6/34 ASoC: Intel: avs: nau8825: Adjust clock control
In reply to Sasha LevinFrom: Cezary Rojewski <[email protected]>
[ Upstream commit 6206b2e787da2ed567922c37bb588a44f6fb6705 ]
Internal clock shall be adjusted also in cases when DAPM event other than 'ON' is triggered.
--- sound/soc/intel/avs/boards/nau8825.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/intel/avs/boards/nau8825.c +7 -7
@@ -33,15 +33,15 @@ avs_nau8825_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *coreturn -EINVAL ; } -if (!SND_SOC_DAPM_EVENT_ON (event)) { +if (SND_SOC_DAPM_EVENT_ON (event)) + ret =snd_soc_dai_set_sysclk (codec_dai,NAU8825_CLK_MCLK ,24000000 , +SND_SOC_CLOCK_IN ); +else ret =snd_soc_dai_set_sysclk (codec_dai,NAU8825_CLK_INTERNAL ,0 ,SND_SOC_CLOCK_IN ); -if (ret <0 ) { -dev_err (card->dev,"set sysclk err = %d\n" , ret); -return ret; - } - } +if (ret <0 ) +dev_err (card->dev,"Set sysclk failed: %d\n" , ret); -return 0 ; +return ret; }static const struct snd_kcontrol_new card_controls[] = {
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 10/34 ASoC: SOF: ipc3: Check for upper size limit for the received message
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 989a3e4479177d0f4afab8be1960731bc0ffbbd0 ]
The sof_ipc3_rx_msg() checks for minimum size of a new rx message but it is missing the check for upper limit.
Corrupted or compromised firmware might be able to take advantage of this to cause out of bounds reads outside of the message area.
--- sound/soc/sof/ipc3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/sof/ipc3.c +3 -2
@@ -970,8 +970,9 @@ static void sof_ipc3_rx_msg(struct snd_sof_dev *sdev)return ; } -if (hdr.size <sizeof (hdr)) { -dev_err (sdev->dev,"The received message size is invalid\n" ); +if (hdr.size <sizeof (hdr) || hdr.size >SOF_IPC_MSG_MAX_SIZE ) { +dev_err (sdev->dev,"The received message size is invalid: %u\n" , + hdr.size);return ; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 11/34 ASoC: SOF: ipc4-topology: Fix incorrect sample rate print unit
In reply to Sasha LevinFrom: Seppo Ingalsuo <[email protected]>
[ Upstream commit 9e269e3aa9006440de639597079ee7140ef5b5f3 ]
This patch fixes the sample rate print unit from KHz to Hz. E.g. 48000KHz becomes 48000Hz.
--- sound/soc/sof/ipc4-topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/ipc4-topology.c +1 -1
@@ -154,7 +154,7 @@ static void sof_ipc4_dbg_audio_format(struct device *dev,for (i =0 ; i < num_format; i++, ptr = (u8 *)ptr + object_size) { fmt = ptr;dev_dbg (dev, -" #%d: %uKHz, %ubit (ch_map %#x ch_cfg %u interleaving_style %u fmt_cfg %#x)\n" , +" #%d: %uHz, %ubit (ch_map %#x ch_cfg %u interleaving_style %u fmt_cfg %#x)\n" , i, fmt->sampling_frequency, fmt->bit_depth, fmt->ch_map, fmt->ch_cfg, fmt->interleaving_style, fmt->fmt_cfg); }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 12/34 ASoC: SOF: Intel: pci-tng: revert invalid bar size setting
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit ca09e2a351fbc7836ba9418304ff0c3e72addfe0 ]
The logic for the ioremap is to find the resource index 3 (IRAM) and infer the BAR address by subtracting the IRAM offset. The BAR size defined in hardware specifications is 2MB.
The commit 5947b2726beb6 ("ASoC: SOF: Intel: Check the bar size before remapping") tried to find the BAR size by querying the resource length instead of a pre-canned value, but by requesting the size for index 3 it only gets the size of the IRAM. That's obviously wrong and prevents the probe from proceeding.
This commit attempted to fix an issue in a fuzzing/simulated environment but created another on actual devices, so the best course of action is to revert that change.
--- sound/soc/sof/intel/pci-tng.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
sound/soc/sof/intel/pci-tng.c +1 -5
@@ -75,11 +75,7 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)/* LPE base */ base =pci_resource_start (pci, desc->resindex_lpe_base) -IRAM_OFFSET ; - size =pci_resource_len (pci, desc->resindex_lpe_base); -if (size <PCI_BAR_SIZE ) { -dev_err (sdev->dev,"error: I/O region is too small.\n" ); -return -ENODEV ; - } + size =PCI_BAR_SIZE ;dev_dbg (sdev->dev,"LPE PHY base at 0x%x size 0x%x" , base, size); sdev->bar[DSP_BAR ] =devm_ioremap (sdev->dev, base, size);
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 13/34 ASoC: SOF: IPC4: update gain ipc msg definition to align with fw
In reply to Sasha LevinFrom: Rander Wang <[email protected]>
[ Upstream commit e45cd86c3a78bfb9875a5eb8ab5dab459b59bbe2 ]
Recent firmware changes modified the curve duration from 32 to 64 bits, which breaks volume ramps. A simple solution would be to change the definition, but unfortunately the ASoC topology framework only supports up to 32 bit tokens.
This patch suggests breaking the 64 bit value in low and high parts, with only the low-part extracted from topology and high-part only zeroes. Since the curve duration is represented in hundred of nanoseconds, we can still represent a 400s ramp, which is just fine. The defacto ABI change has no effect on existing users since the IPC4 firmware has not been released just yet.
--- sound/soc/sof/ipc4-control.c | 3 ++- sound/soc/sof/ipc4-topology.c | 4 ++-- sound/soc/sof/ipc4-topology.h | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-)
sound/soc/sof/ipc4-control.c +2 -1
@@ -84,7 +84,8 @@ sof_ipc4_set_volume_data(struct snd_sof_dev *sdev, struct snd_sof_widget *swidge }/* set curve type and duration from topology */ - data.curve_duration = gain->data.curve_duration; + data.curve_duration_l = gain->data.curve_duration_l; + data.curve_duration_h = gain->data.curve_duration_h; data.curve_type = gain->data.curve_type; msg->data_ptr = &data;
sound/soc/sof/ipc4-topology.c +2 -2
@@ -106,7 +106,7 @@ static const struct sof_topology_token gain_tokens[] = { get_token_u32, offsetof(struct sof_ipc4_gain_data, curve_type)}, {SOF_TKN_GAIN_RAMP_DURATION,SND_SOC_TPLG_TUPLE_TYPE_WORD , get_token_u32, - offsetof(struct sof_ipc4_gain_data, curve_duration)}, + offsetof(struct sof_ipc4_gain_data, curve_duration_l)}, {SOF_TKN_GAIN_VAL, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, offsetof(struct sof_ipc4_gain_data, init_val)}, };
@@ -682,7 +682,7 @@ static int sof_ipc4_widget_setup_comp_pga(struct snd_sof_widget *swidget)dev_dbg (scomp->dev,"pga widget %s: ramp type: %d, ramp duration %d, initial gain value: %#x, cpc %d\n" , - swidget->widget->name, gain->data.curve_type, gain->data.curve_duration, + swidget->widget->name, gain->data.curve_type, gain->data.curve_duration_l, gain->data.init_val, gain->base_config.cpc); ret =sof_ipc4_widget_setup_msg (swidget, &gain->msg);
sound/soc/sof/ipc4-topology.h +4 -2
@@ -217,14 +217,16 @@ struct sof_ipc4_control_data {* @init_val: Initial value * @curve_type: Curve type * @reserved: reserved for future use -* @curve_duration: Curve duration +* @curve_duration_l: Curve duration low part +* @curve_duration_h: Curve duration high part */ struct sof_ipc4_gain_data {uint32_t channels;uint32_t init_val;uint32_t curve_type;uint32_t reserved; -uint32_t curve_duration; +uint32_t curve_duration_l; +uint32_t curve_duration_h; }__aligned(8) ;/**
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 1/34 xfrm: Zero padding when dumping algos and encap
From: Herbert Xu <[email protected]>
[ Upstream commit 8222d5910dae08213b6d9d4bc9a7f8502855e624 ]
When copying data to user-space we should ensure that only valid data is copied over. Padding in structures may be filled with random (possibly sensitve) data and should never be given directly to user-space.
This patch fixes the copying of xfrm algorithms and the encap template in xfrm_user so that padding is zeroed.
--- net/xfrm/xfrm_user.c | 45 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-)
net/xfrm/xfrm_user.c +41 -4
@@ -997,7 +997,9 @@ static int copy_to_user_aead(struct xfrm_algo_aead *aead, struct sk_buff *skb)return -EMSGSIZE ; ap =nla_data (nla); -memcpy (ap, aead,sizeof (*aead)); +strscpy_pad (ap->alg_name, aead->alg_name,sizeof (ap->alg_name)); + ap->alg_key_len = aead->alg_key_len; + ap->alg_icv_len = aead->alg_icv_len;if (redact_secret && aead->alg_key_len)memset (ap->alg_key,0 , (aead->alg_key_len +7 ) /8 );
@@ -1017,7 +1019,8 @@ static int copy_to_user_ealg(struct xfrm_algo *ealg, struct sk_buff *skb)return -EMSGSIZE ; ap =nla_data (nla); -memcpy (ap, ealg,sizeof (*ealg)); +strscpy_pad (ap->alg_name, ealg->alg_name,sizeof (ap->alg_name)); + ap->alg_key_len = ealg->alg_key_len;if (redact_secret && ealg->alg_key_len)memset (ap->alg_key,0 , (ealg->alg_key_len +7 ) /8 );
@@ -1028,6 +1031,40 @@ static int copy_to_user_ealg(struct xfrm_algo *ealg, struct sk_buff *skb)return 0 ; } +static int copy_to_user_calg (struct xfrm_algo *calg,struct sk_buff *skb) +{ +struct nlattr *nla =nla_reserve (skb,XFRMA_ALG_COMP ,sizeof (*calg)); +struct xfrm_algo *ap; + +if (!nla) +return -EMSGSIZE ; + + ap =nla_data (nla); +strscpy_pad (ap->alg_name, calg->alg_name,sizeof (ap->alg_name)); + ap->alg_key_len =0 ; + +return 0 ; +} + +static int copy_to_user_encap (struct xfrm_encap_tmpl *ep,struct sk_buff *skb) +{ +struct nlattr *nla =nla_reserve (skb,XFRMA_ENCAP ,sizeof (*ep)); +struct xfrm_encap_tmpl *uep; + +if (!nla) +return -EMSGSIZE ; + + uep =nla_data (nla); +memset (uep,0 ,sizeof (*uep)); + + uep->encap_type = ep->encap_type; + uep->encap_sport = ep->encap_sport; + uep->encap_dport = ep->encap_dport; + uep->encap_oa = ep->encap_oa; + +return 0 ; +} +static int xfrm_smark_put (struct sk_buff *skb,struct xfrm_mark *m) {int ret =0 ;
@@ -1083,12 +1120,12 @@ static int copy_to_user_state_extra(struct xfrm_state *x, goto out; }if (x->calg) { - ret =nla_put (skb,XFRMA_ALG_COMP ,sizeof (*(x->calg)), x->calg); + ret =copy_to_user_calg (x->calg, skb);if (ret) goto out; }if (x->encap) { - ret =nla_put (skb,XFRMA_ENCAP ,sizeof (*x->encap), x->encap); + ret =copy_to_user_encap (x->encap, skb);if (ret) goto out; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 20/34 ALSA: asihpi: check pao in control_message()
From: Kuninori Morimoto <[email protected]>
[ Upstream commit 9026c0bf233db53b86f74f4c620715e94eb32a09 ]
control_message() might be called with pao = NULL. Here indicates control_message() as sample.
(B) static void control_message(struct hpi_adapter_obj *pao, ...)
{ ^^^
struct hpi_hw_obj *phw = pao->priv;
... ^^^
}(A) void _HPI_6205(struct hpi_adapter_obj *pao, ...)
{ ^^^
...
case HPI_OBJ_CONTROL:
(B) control_message(pao, phm, phr);
break; ^^^
...
}
void HPI_6205(...)
{
...
(A) _HPI_6205(NULL, phm, phr);
... ^^^^
}Therefore, We will get too many warning via cppcheck, like below
sound/pci/asihpi/hpi6205.c:238:27: warning: Possible null pointer dereference: pao [nullPointer] struct hpi_hw_obj *phw = pao->priv; ^ sound/pci/asihpi/hpi6205.c:433:13: note: Calling function '_HPI_6205', 1st argument 'NULL' value is 0 _HPI_6205(NULL, phm, phr); ^ sound/pci/asihpi/hpi6205.c:401:20: note: Calling function 'control_message', 1st argument 'pao' value is 0 control_message(pao, phm, phr); ^
Set phr->error like many functions doing, and don't call _HPI_6205() with NULL.
--- sound/pci/asihpi/hpi6205.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/asihpi/hpi6205.c +1 -1
@@ -430,7 +430,7 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) pao =hpi_find_adapter (phm->adapter_index); }else {/* subsys messages don't address an adapter */ -_HPI_6205 (NULL , phm, phr); + phr->error =HPI_ERROR_INVALID_OBJ_INDEX ;return ; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 21/34 ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set()
In reply to Sasha LevinFrom: Kuninori Morimoto <[email protected]>
[ Upstream commit 98e5eb110095ec77cb6d775051d181edbf9cd3cf ]
tuning_ctl_set() might have buffer overrun at (X) if it didn't break from loop by matching (A).
static int tuning_ctl_set(...)
{
for (i = 0; i < TUNING_CTLS_COUNT; i++)
(A) if (nid == ca0132_tuning_ctls[i].nid)
break;
snd_hda_power_up(...);
(X) dspio_set_param(..., ca0132_tuning_ctls[i].mid, ...);
snd_hda_power_down(...); ^
return 1;
}We will get below error by cppcheck
sound/pci/hda/patch_ca0132.c:4229:2: note: After for loop, i has value 12 for (i = 0; i < TUNING_CTLS_COUNT; i++) ^ sound/pci/hda/patch_ca0132.c:4234:43: note: Array index out of bounds dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20, ^
This patch cares non match case.
--- sound/pci/hda/patch_ca0132.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/pci/hda/patch_ca0132.c +3 -1
@@ -4228,8 +4228,10 @@ static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid,for (i =0 ; i <TUNING_CTLS_COUNT ; i++)if (nid == ca0132_tuning_ctls[i].nid) -break ; + goto found; +return -EINVAL ; +found:snd_hda_power_up (codec); dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20, ca0132_tuning_ctls[i].req,
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 7/34 zstd: Fix definition of assert()
In reply to Sasha LevinFrom: Jonathan Neuschäfer <[email protected]>
[ Upstream commit 6906598f1ce93761716d780b6e3f171e13f0f4ce ]
assert(x) should emit a warning if x is false. WARN_ON(x) emits a warning if x is true. Thus, assert(x) should be defined as WARN_ON(!x) rather than WARN_ON(x).
--- lib/zstd/common/zstd_deps.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/zstd/common/zstd_deps.h +1 -1
@@ -84,7 +84,7 @@ static uint64_t ZSTD_div64(uint64_t dividend, uint32_t divisor) {#include <linux/kernel.h> -#define assert (x) WARN_ON((x)) +#define assert (x) WARN_ON(!(x))#endif /* ZSTD_DEPS_ASSERT */ #endif /* ZSTD_DEPS_NEED_ASSERT */
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 14/34 md: avoid signed overflow in slot_store()
In reply to Sasha LevinFrom: NeilBrown <[email protected]>
[ Upstream commit 3bc57292278a0b6ac4656cad94c14f2453344b57 ]
slot_store() uses kstrtouint() to get a slot number, but stores the result in an "int" variable (by casting a pointer).
This can result in a negative slot number if the unsigned int value is very large.
A negative number means that the slot is empty, but setting a negative slot number this way will not remove the device from the array. I don't think this is a serious problem, but it could cause confusion and it is best to fix it.
--- drivers/md/md.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/md/md.c +3 -0
@@ -3152,6 +3152,9 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len) err =kstrtouint (buf,10 , (unsigned int *)&slot);if (err <0 )return err; +if (slot <0 ) +/* overflow */ +return -ENOSPC ; }if (rdev->mddev->pers && slot ==-1 ) {/* Setting 'slot' on an active array requires also
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 19/34 net: hsr: Don't log netdev_err message on unknown prp dst node
In reply to Sasha LevinFrom: Kristian Overskeid <[email protected]>
[ Upstream commit 28e8cabe80f3e6e3c98121576eda898eeb20f1b1 ]
If no frames has been exchanged with a node for HSR_NODE_FORGET_TIME, the node will be deleted from the node_db list. If a frame is sent to the node after it is deleted, a netdev_err message for each slave interface is produced. This should not happen with dan nodes because of supervision frames, but can happen often with san nodes, which clutters the kernel log. Since the hsr protocol does not support sans, this is only relevant for the prp protocol.
--- net/hsr/hsr_framereg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/hsr/hsr_framereg.c +1 -1
@@ -422,7 +422,7 @@ void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb, node_dst =find_node_by_addr_A (&port->hsr->node_db,eth_hdr (skb)->h_dest);if (!node_dst) { -if (net_ratelimit ()) +if (net_ratelimit () && port->hsr->prot_version !=PRP_V1 )netdev_err (skb->dev,"%s: Unknown node\n" , __func__);return ; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 8/34 ACPI: video: Add backlight=native DMI quirk for Dell Vostro 15 3535
In reply to Sasha LevinFrom: "Chia-Lin Kao (AceLan)" <[email protected]>
[ Upstream commit 89b0411481967a2e8c91190a211a359966cfcf4b ]
Sometimes the system boots up with a acpi_video0 backlight interface which doesn't work. So add Dell Vostro 15 3535 into the video_detect_dmi_table to set it to native explicitly.
--- drivers/acpi/video_detect.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/video_detect.c +7 -0
@@ -714,6 +714,13 @@ static const struct dmi_system_id video_detect_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"), }, }, + { + .callback = video_detect_force_native, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 15 3535"), + }, + },/* * Desktops which falsely report a backlight and which our heuristics
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 9/34 ACPI: x86: Add skip i2c clients quirk for Lenovo Yoga Book X90
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 1a1e7540cf501dd5c8b57a577a155cdd13c7e202 ]
The Lenovo Yoga Book X90 is a x86 tablet which ships with Android x86 as factory OS. The Android x86 kernel fork ignores I2C devices described in the DSDT, except for the PMIC and Audio codecs.
As usual the Lenovo Yoga Book X90's DSDT contains a bunch of extra I2C devices which are not actually there, causing various resource conflicts. Add an ACPI_QUIRK_SKIP_I2C_CLIENTS quirk for the Lenovo Yoga Book X90 to the acpi_quirk_skip_dmi_ids table to woraround this.
The DSDT also contains broken ACPI GPIO event handlers, disable those too.
--- drivers/acpi/x86/utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/acpi/x86/utils.c +11 -0
@@ -299,6 +299,17 @@ static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = {ACPI_QUIRK_UART1_TTY_UART2_SKIP | ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), }, + { +/* Lenovo Yoga Book X90F/L */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"Intel Corporation" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"CHERRYVIEW D1 PLATFORM" ), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"), + }, + .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | +ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | + ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), + }, { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 23/34 ACPI: tools: pfrut: Check if the input of level and type is in the right numeric range
In reply to Sasha LevinFrom: Chen Yu <[email protected]>
[ Upstream commit 0bc23d8b2237a104d7f8379d687aa4cb82e2968b ]
The user provides arbitrary non-numeic value to level and type, which could bring unexpected behavior. In this case the expected behavior would be to throw an error.
pfrut -h
usage: pfrut [OPTIONS]
code injection:
-l, --load
-s, --stage
-a, --activate
-u, --update [stage and activate]
-q, --query
-d, --revid
update telemetry:
-G, --getloginfo
-T, --type(0:execution, 1:history)
-L, --level(0, 1, 2, 4)
-R, --read
-D, --revid log
pfrut -T A
pfrut -G
log_level:0
log_type:0
log_revid:2
max_data_size:65536
chunk1_size:0
chunk2_size:1530
rollover_cnt:0
reset_cnt:17
Fix this by restricting the input to be in the expected range.
--- tools/power/acpi/tools/pfrut/pfrut.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
tools/power/acpi/tools/pfrut/pfrut.c +15 -3
@@ -97,7 +97,7 @@ static struct option long_options[] = {static void parse_options (int argc,char **argv) {int option_index =0 ; -char *pathname; +char *pathname, *endptr;int opt; pathname =strdup (argv[0 ]);
@@ -125,11 +125,23 @@ static void parse_options(int argc, char **argv) log_getinfo =1 ;break ;case 'T' : - log_type =atoi (optarg); + log_type =strtol (optarg, &endptr,0 ); +if (*endptr || (log_type !=0 && log_type !=1 )) { +printf ("Number expected: type(0:execution, 1:history) - Quit.\n" ); +exit (1 ); + } + set_log_type =1 ;break ;case 'L' : - log_level =atoi (optarg); + log_level =strtol (optarg, &endptr,0 ); +if (*endptr || + (log_level !=0 && log_level !=1 && + log_level !=2 && log_level !=4 )) { +printf ("Number expected: level(0, 1, 2, 4) - Quit.\n" ); +exit (1 ); + } + set_log_level =1 ;break ;case 'R' :
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 24/34 sched_getaffinity: don't assume 'cpumask_size()' is fully initialized
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
[ Upstream commit 6015b1aca1a233379625385feb01dd014aca60b5 ]
The getaffinity() system call uses 'cpumask_size()' to decide how big the CPU mask is - so far so good. It is indeed the allocation size of a cpumask.
But the code also assumes that the whole allocation is initialized without actually doing so itself. That's wrong, because we might have fixed-size allocations (making copying and clearing more efficient), but not all of it is then necessarily used if 'nr_cpu_ids' is smaller.
Having checked other users of 'cpumask_size()', they all seem to be ok, either using it purely for the allocation size, or explicitly zeroing the cpumask before using the size in bytes to copy it.
See for example the ublk_ctrl_get_queue_affinity() function that uses the proper 'zalloc_cpumask_var()' to make sure that the whole mask is cleared, whether the storage is on the stack or if it was an external allocation.
Fix this by just zeroing the allocation before using it. Do the same for the compat version of sched_getaffinity(), which had the same logic.
Also, for consistency, make sched_getaffinity() use 'cpumask_bits()' to access the bits. For a cpumask_var_t, it ends up being a pointer to the same data either way, but it's just a good idea to treat it like you would a 'cpumask_t'. The compat case already did that.
--- kernel/compat.c | 2 +- kernel/sched/core.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
kernel/compat.c +1 -1
@@ -152,7 +152,7 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len,if (len & (sizeof (compat_ulong_t)-1 ))return -EINVAL ; -if (!alloc_cpumask_var (&mask,GFP_KERNEL )) +if (!zalloc_cpumask_var (&mask,GFP_KERNEL ))return -ENOMEM ; ret =sched_getaffinity (pid, mask);
kernel/sched/core.c +2 -2
@@ -8301,14 +8301,14 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,if (len & (sizeof (unsigned long )-1 ))return -EINVAL ; -if (!alloc_cpumask_var (&mask,GFP_KERNEL )) +if (!zalloc_cpumask_var (&mask,GFP_KERNEL ))return -ENOMEM ; ret =sched_getaffinity (pid, mask);if (ret ==0 ) {unsigned int retlen =min (len,cpumask_size ()); -if (copy_to_user (user_mask_ptr, mask, retlen)) +if (copy_to_user (user_mask_ptr,cpumask_bits (mask), retlen)) ret = -EFAULT ;else ret = retlen;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 34/34 tracing: Fix wrong return in kprobe_event_gen_test.c
In reply to Sasha LevinFrom: Anton Gusev <[email protected]>
[ Upstream commit bc4f359b3b607daac0290d0038561237a86b38cb ]
Overwriting the error code with the deletion result may cause the function to return 0 despite encountering an error. Commit b111545d26c0 ("tracing: Remove the useless value assignment in test_create_synth_event()") solves a similar issue by returning the original error code, so this patch does the same.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- kernel/trace/kprobe_event_gen_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/kprobe_event_gen_test.c +2 -2
@@ -146,7 +146,7 @@ static int __init test_gen_kprobe_cmd(void)if (trace_event_file_is_valid (gen_kprobe_test)) gen_kprobe_test =NULL ;/* We got an error after creating the event, delete it */ - ret =kprobe_event_delete ("gen_kprobe_test" ); +kprobe_event_delete ("gen_kprobe_test" ); goto out; }
@@ -211,7 +211,7 @@ static int __init test_gen_kretprobe_cmd(void)if (trace_event_file_is_valid (gen_kretprobe_test)) gen_kretprobe_test =NULL ;/* We got an error after creating the event, delete it */ - ret =kprobe_event_delete ("gen_kretprobe_test" ); +kprobe_event_delete ("gen_kretprobe_test" ); goto out; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 27/34 net/mlx5e: Lower maximum allowed MTU in XSK to match XDP prerequisites
In reply to Sasha LevinFrom: Adham Faris <[email protected]>
[ Upstream commit 78dee7befd56987283c13877b834c0aa97ad51b9 ]
XSK redirecting XDP programs require linearity, hence applies restrictions on the MTU. For PAGE_SIZE=4K, MTU shouldn't exceed 3498.
Features that contradict with XDP such HW-LRO and HW-GRO are enforced by the driver in advance, during XSK params validation, except for MTU, which was not enforced before this patch.
This has been spotted during test scenario described below:
Attaching xdpsock program (PAGE_SIZE=4K), with MTU < 3498, detaching XDP program, changing the MTU to arbitrary value in the range [3499, 3754], attaching XDP program again, which ended up with failure since MTU is > 3498.
This commit lowers the XSK MTU limitation to be aligned with XDP MTU limitation, since XSK socket is meaningless without XDP program.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +7 -3
@@ -4100,13 +4100,17 @@ static bool mlx5e_xsk_validate_mtu(struct net_device *netdev,struct xsk_buff_pool *xsk_pool =mlx5e_xsk_get_pool (&chs->params, chs->params.xsk, ix);struct mlx5e_xsk_param xsk; +int max_xdp_mtu;if (!xsk_pool)continue ;mlx5e_build_xsk_param (xsk_pool, &xsk); + max_xdp_mtu =mlx5e_xdp_max_mtu (new_params, &xsk); -if (!mlx5e_validate_xsk_param (new_params, &xsk, mdev)) { +/* Validate XSK params and XDP MTU in advance */ +if (!mlx5e_validate_xsk_param (new_params, &xsk, mdev) || + new_params->sw_mtu > max_xdp_mtu) {u32 hr =mlx5e_get_linear_rq_headroom (new_params, &xsk);int max_mtu_frame, max_mtu_page, max_mtu;
@@ -4116,9 +4120,9 @@ static bool mlx5e_xsk_validate_mtu(struct net_device *netdev,*/ max_mtu_frame =MLX5E_HW2SW_MTU (new_params, xsk.chunk_size - hr); max_mtu_page =MLX5E_HW2SW_MTU (new_params,SKB_MAX_HEAD (0 )); - max_mtu =min (max_mtu_frame, max_mtu_page); + max_mtu =min3 (max_mtu_frame, max_mtu_page, max_xdp_mtu); -netdev_err (netdev,"MTU %d is too big for an XSK running on channel %u. Try MTU <= %d\n" , +netdev_err (netdev,"MTU %d is too big for an XSK running on channel %u or its redirection XDP program. Try MTU <= %d\n" , new_params->sw_mtu, ix, max_mtu);return false; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 33/34 tools/power turbostat: fix decoding of HWP_STATUS
In reply to Sasha LevinFrom: Antti Laakso <[email protected]>
[ Upstream commit 92c25393586ac799b9b7d9e50434f3c44a7622c4 ]
The "excursion to minimum" information is in bit2
in HWP_STATUS MSR. Fix the bitmask used for
decoding the register.
--- tools/power/x86/turbostat/turbostat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +1 -1
@@ -4426,7 +4426,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p)fprintf (outf,"cpu%d: MSR_HWP_STATUS: 0x%08llx " "(%sGuaranteed_Perf_Change, %sExcursion_Min)\n" , - cpu, msr, ((msr) &0x1 ) ?"" :"No-" , ((msr) &0x2 ) ?"" :"No-" ); + cpu, msr, ((msr) &0x1 ) ?"" :"No-" , ((msr) &0x4 ) ?"" :"No-" );return 0 ; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 32/34 tools/power turbostat: Fix /dev/cpu_dma_latency warnings
In reply to Sasha LevinFrom: Prarit Bhargava <[email protected]>
[ Upstream commit 40aafc7d58d3544f152a863a0e9863014b6d5d8c ]
When running as non-root the following error is seen in turbostat:
turbostat: fopen /dev/cpu_dma_latency
: Permission denied
turbostat and the man page have information on how to avoid other permission errors, so these can be fixed the same way.
Provide better /dev/cpu_dma_latency warnings that provide instructions on how to avoid the error, and update the man page.
--- tools/power/x86/turbostat/turbostat.8 | 2 ++ tools/power/x86/turbostat/turbostat.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.8 +2 -0
@@ -344,6 +344,8 @@ Alternatively, non-root users can be enabled to run turbostat this way: # chmod +r /dev/cpu/*/msr +# chmod +r /dev/cpu_dma_latency + .B "turbostat " reads hardware counters, but doesn't write them. So it will not interfere with the OS or other programs, including
tools/power/x86/turbostat/turbostat.c +1 -1
@@ -5482,7 +5482,7 @@ void print_dev_latency(void) retval =read (fd, (void *)&value,sizeof (int ));if (retval !=sizeof (int )) { -warn ("read %s\n" , path); +warn ("read failed %s\n" , path);close (fd);return ; }
Signature · 1 line
2.39.2