5.14.19-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 265/849 media: usb: dvd-usb: fix uninit-value bug in dibusb_read_eeprom_byte()
In reply to Greg Kroah-HartmanFrom: Anant Thazhemadam <[email protected]>
[ Upstream commit 899a61a3305d49e8a712e9ab20d0db94bde5929f ]
In dibusb_read_eeprom_byte(), if dibusb_i2c_msg() fails, val gets assigned an value that's not properly initialized.
Using kzalloc() in place of kmalloc() for the buffer fixes this issue, as the val can now be set to 0 in the event dibusb_i2c_msg() fails.
--- drivers/media/usb/dvb-usb/dibusb-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/dibusb-common.c +1 -1
@@ -223,7 +223,7 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)u8 *buf;int rc; - buf =kmalloc (2 ,GFP_KERNEL ); + buf =kzalloc (2 ,GFP_KERNEL );if (!buf)return -ENOMEM ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 266/849 net-sysfs: try not to restart the syscall if it will fail eventually
In reply to Greg Kroah-HartmanFrom: Antoine Tenart <[email protected]>
[ Upstream commit 146e5e733310379f51924111068f08a3af0db830 ]
Due to deadlocks in the networking subsystem spotted 12 years ago[1], a workaround was put in place[2] to avoid taking the rtnl lock when it was not available and restarting the syscall (back to VFS, letting userspace spin). The following construction is found a lot in the net sysfs and sysctl code:
if (!rtnl_trylock())
return restart_syscall();This can be problematic when multiple userspace threads use such interfaces in a short period, making them to spin a lot. This happens for example when adding and moving virtual interfaces: userspace programs listening on events, such as systemd-udevd and NetworkManager, do trigger actions reading files in sysfs. It gets worse when a lot of virtual interfaces are created concurrently, say when creating containers at boot time.
Returning early without hitting the above pattern when the syscall will fail eventually does make things better. While it is not a fix for the issue, it does ease things.
[1] https://lore.kernel.org/netdev/[email protected]/
https://lore.kernel.org/netdev/[email protected]/ and https://lore.kernel.org/netdev/20090226084924.16cb3e08@nehalam/
[2] Rightfully, those deadlocks are *hard* to solve.
--- net/core/net-sysfs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
net/core/net-sysfs.c +55 -0
@@ -175,6 +175,14 @@ static int change_carrier(struct net_device *dev, unsigned long new_carrier)static ssize_t carrier_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len) { +struct net_device *netdev =to_net_dev (dev); + +/* The check is also done in change_carrier; this helps returning early +* without hitting the trylock/restart in netdev_store. +*/ +if (!netdev->netdev_ops->ndo_change_carrier) +return -EOPNOTSUPP ; +return netdev_store (dev, attr, buf, len, change_carrier); }
@@ -196,6 +204,12 @@ static ssize_t speed_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);int ret = -EINVAL ; +/* The check is also done in __ethtool_get_link_ksettings; this helps +* returning early without hitting the trylock/restart below. +*/ +if (!netdev->ethtool_ops->get_link_ksettings) +return ret; +if (!rtnl_trylock ())return restart_syscall ();
@@ -216,6 +230,12 @@ static ssize_t duplex_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);int ret = -EINVAL ; +/* The check is also done in __ethtool_get_link_ksettings; this helps +* returning early without hitting the trylock/restart below. +*/ +if (!netdev->ethtool_ops->get_link_ksettings) +return ret; +if (!rtnl_trylock ())return restart_syscall ();
@@ -468,6 +488,14 @@ static ssize_t proto_down_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t len) { + struct net_device *netdev = to_net_dev(dev); + +/* The check is also done in change_proto_down; this helps returning +* early without hitting the trylock/restart in netdev_store. +*/ +if (!netdev->netdev_ops->ndo_change_proto_down) +return -EOPNOTSUPP ; +return netdev_store (dev, attr, buf, len, change_proto_down); }NETDEVICE_SHOW_RW (proto_down, fmt_dec);
@@ -478,6 +506,12 @@ static ssize_t phys_port_id_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);ssize_t ret = -EINVAL ; +/* The check is also done in dev_get_phys_port_id; this helps returning +* early without hitting the trylock/restart below. +*/ +if (!netdev->netdev_ops->ndo_get_phys_port_id) +return -EOPNOTSUPP ; +if (!rtnl_trylock ())return restart_syscall ();
@@ -500,6 +534,13 @@ static ssize_t phys_port_name_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);ssize_t ret = -EINVAL ; +/* The checks are also done in dev_get_phys_port_name; this helps +* returning early without hitting the trylock/restart below. +*/ +if (!netdev->netdev_ops->ndo_get_phys_port_name && + !netdev->netdev_ops->ndo_get_devlink_port) +return -EOPNOTSUPP ; +if (!rtnl_trylock ())return restart_syscall ();
@@ -522,6 +563,14 @@ static ssize_t phys_switch_id_show(struct device *dev,struct net_device *netdev =to_net_dev (dev);ssize_t ret = -EINVAL ; +/* The checks are also done in dev_get_phys_port_name; this helps +* returning early without hitting the trylock/restart below. This works +* because recurse is false when calling dev_get_port_parent_id. +*/ +if (!netdev->netdev_ops->ndo_get_port_parent_id && + !netdev->netdev_ops->ndo_get_devlink_port) +return -EOPNOTSUPP ; +if (!rtnl_trylock ())return restart_syscall ();
@@ -1226,6 +1275,12 @@ static ssize_t tx_maxrate_store(struct netdev_queue *queue,if (!capable (CAP_NET_ADMIN ))return -EPERM ; +/* The check is also done later; this helps returning early without +* hitting the trylock/restart below. +*/ +if (!dev->netdev_ops->ndo_set_tx_maxrate) +return -EOPNOTSUPP ; + err =kstrtou32 (buf,10 , &rate);if (err <0 )return err;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 267/849 drm/amdkfd: rm BO resv on validation to avoid deadlock
In reply to Greg Kroah-HartmanFrom: Alex Sierra <[email protected]>
[ Upstream commit ec6abe831a843208e99a59adf108adba22166b3f ]
This fix the deadlock with the BO reservations during SVM_BO evictions while allocations in VRAM are concurrently performed. More specific, while the ttm waits for the fence to be signaled (ttm_bo_wait), it already has the BO reserved. In parallel, the restore worker might be running, prefetching memory to VRAM. This also requires to reserve the BO, but blocks the mmap semaphore first. The deadlock happens when the SVM_BO eviction worker kicks in and waits for the mmap semaphore held in restore worker. Preventing signal the fence back, causing the deadlock until the ttm times out.
We don't need to hold the BO reservation anymore during validation and mapping. Now the physical addresses are taken from hmm_range_fault. We also take migrate_mutex to prevent range migration while validate_and_map update GPU page table.
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -6
@@ -1303,7 +1303,7 @@ struct svm_validate_context {struct svm_range *prange;bool intr;unsigned long bitmap[MAX_GPU_INSTANCE ]; -struct ttm_validate_buffer tv[MAX_GPU_INSTANCE +1 ]; +struct ttm_validate_buffer tv[MAX_GPU_INSTANCE ];struct list_head validate_list;struct ww_acquire_ctx ticket; };
@@ -1330,11 +1330,6 @@ static int svm_range_reserve_bos(struct svm_validate_context *ctx) ctx->tv[gpuidx].num_shared =4 ;list_add (&ctx->tv[gpuidx].head, &ctx->validate_list); } -if (ctx->prange->svm_bo && ctx->prange->ttm_res) { - ctx->tv[MAX_GPU_INSTANCE ].bo = &ctx->prange->svm_bo->bo->tbo; - ctx->tv[MAX_GPU_INSTANCE ].num_shared =1 ; -list_add (&ctx->tv[MAX_GPU_INSTANCE ].head, &ctx->validate_list); - } r =ttm_eu_reserve_buffers (&ctx->ticket, &ctx->validate_list, ctx->intr,NULL );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 268/849 tracefs: Have tracefs directories not set OTH permission bits by default
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
[ Upstream commit 49d67e445742bbcb03106b735b2ab39f6e5c56bc ]
The tracefs file system is by default mounted such that only root user can access it. But there are legitimate reasons to create a group and allow those added to the group to have access to tracing. By changing the permissions of the tracefs mount point to allow access, it will allow group access to the tracefs directory.
There should not be any real reason to allow all access to the tracefs directory as it contains sensitive information. Have the default permission of directories being created not have any OTH (other) bits set, such that an admin that wants to give permission to a group has to first disable all OTH bits in the file system.
--- fs/tracefs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/tracefs/inode.c +2 -1
@@ -432,7 +432,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,if (unlikely (!inode))return failed_creating (dentry); - inode->i_mode =S_IFDIR |S_IRWXU |S_IRUGO |S_IXUGO ; +/* Do not set bits for OTH */ + inode->i_mode =S_IFDIR |S_IRWXU |S_IRUSR |S_IRGRP |S_IXUSR |S_IXGRP ; inode->i_op = ops; inode->i_fop = &simple_dir_operations;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 269/849 tracing: Disable "other" permission bits in the tracefs files
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
[ Upstream commit 21ccc9cd72116289469e5519b6159c675a2fa58f ]
When building the files in the tracefs file system, do not by default set any permissions for OTH (other). This will make it easier for admins who want to define a group for accessing tracefs and not having to first disable all the permission bits for "other" in the file system.
As tracing can leak sensitive information, it should never by default allowing all users access. An admin can still set the permission bits for others to have access, which may be useful for creating a honeypot and seeing who takes advantage of it and roots the machine.
--- kernel/trace/ftrace.c | 23 +++++---- kernel/trace/trace.c | 73 ++++++++++++++------------- kernel/trace/trace.h | 3 ++ kernel/trace/trace_dynevent.c | 2 +- kernel/trace/trace_events.c | 42 +++++++-------- kernel/trace/trace_events_synth.c | 4 +- kernel/trace/trace_functions_graph.c | 2 +- kernel/trace/trace_hwlat.c | 6 +-- kernel/trace/trace_kprobe.c | 8 +-- kernel/trace/trace_osnoise.c | 14 ++--- kernel/trace/trace_printk.c | 2 +- kernel/trace/trace_recursion_record.c | 4 +- kernel/trace/trace_stack.c | 6 +-- kernel/trace/trace_stat.c | 6 +-- kernel/trace/trace_uprobe.c | 4 +- 15 files changed, 103 insertions(+), 96 deletions(-)
kernel/trace/ftrace.c +12 -11
@@ -988,8 +988,9 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer) } } - entry =tracefs_create_file ("function_profile_enabled" ,0644 , - d_tracer,NULL , &ftrace_profile_fops); + entry =tracefs_create_file ("function_profile_enabled" , +TRACE_MODE_WRITE , d_tracer,NULL , + &ftrace_profile_fops);if (!entry)pr_warn ("Could not create tracefs 'function_profile_enabled' entry\n" ); }
@@ -6109,10 +6110,10 @@ void ftrace_create_filter_files(struct ftrace_ops *ops, struct dentry *parent) { -trace_create_file ("set_ftrace_filter" ,0644 , parent, +trace_create_file ("set_ftrace_filter" ,TRACE_MODE_WRITE , parent, ops, &ftrace_filter_fops); -trace_create_file ("set_ftrace_notrace" ,0644 , parent, +trace_create_file ("set_ftrace_notrace" ,TRACE_MODE_WRITE , parent, ops, &ftrace_notrace_fops); }
@@ -6139,19 +6140,19 @@ void ftrace_destroy_filter_files(struct ftrace_ops *ops)static __init int ftrace_init_dyn_tracefs (struct dentry *d_tracer) { -trace_create_file ("available_filter_functions" ,0444 , +trace_create_file ("available_filter_functions" ,TRACE_MODE_READ , d_tracer,NULL , &ftrace_avail_fops); -trace_create_file ("enabled_functions" ,0444 , +trace_create_file ("enabled_functions" ,TRACE_MODE_READ , d_tracer,NULL , &ftrace_enabled_fops);ftrace_create_filter_files (&global_ops, d_tracer);#ifdef CONFIG_FUNCTION_GRAPH_TRACER -trace_create_file ("set_graph_function" ,0644 , d_tracer, +trace_create_file ("set_graph_function" ,TRACE_MODE_WRITE , d_tracer,NULL , &ftrace_graph_fops); -trace_create_file ("set_graph_notrace" ,0644 , d_tracer, +trace_create_file ("set_graph_notrace" ,TRACE_MODE_WRITE , d_tracer,NULL , &ftrace_graph_notrace_fops);#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
@@ -7494,10 +7495,10 @@ static const struct file_operations ftrace_no_pid_fops = {void ftrace_init_tracefs (struct trace_array *tr,struct dentry *d_tracer) { -trace_create_file ("set_ftrace_pid" ,0644 , d_tracer, +trace_create_file ("set_ftrace_pid" ,TRACE_MODE_WRITE , d_tracer, tr, &ftrace_pid_fops); -trace_create_file ("set_ftrace_notrace_pid" ,0644 , d_tracer, - tr, &ftrace_no_pid_fops); +trace_create_file ("set_ftrace_notrace_pid" ,TRACE_MODE_WRITE , + d_tracer, tr, &ftrace_no_pid_fops); } void __init ftrace_init_tracefs_toplevel(struct trace_array *tr,
kernel/trace/trace.c +37 -36
191 lines not on this page · raw message
kernel/trace/trace.h +3 -0
@@ -27,6 +27,9 @@#include <asm/syscall.h> /* some archs define it here */ #endif +#define TRACE_MODE_WRITE 0640 +#define TRACE_MODE_READ 0440 +enum trace_type { __TRACE_FIRST_TYPE =0 ,
kernel/trace/trace_dynevent.c +1 -1
@@ -224,7 +224,7 @@ static __init int init_dynamic_event(void)if (ret)return 0 ; - entry =tracefs_create_file ("dynamic_events" ,0644 ,NULL , + entry =tracefs_create_file ("dynamic_events" ,TRACE_MODE_WRITE ,NULL ,NULL , &dynamic_events_ops);/* Event list interface */
kernel/trace/trace_events.c +22 -20
116 lines not on this page · raw message
kernel/trace/trace_events_synth.c +2 -2
@@ -2222,8 +2222,8 @@ static __init int trace_events_synth_init(void)if (err) goto err; - entry =tracefs_create_file ("synthetic_events" ,0644 ,NULL , -NULL , &synth_events_fops); + entry =tracefs_create_file ("synthetic_events" ,TRACE_MODE_WRITE , +NULL ,NULL , &synth_events_fops);if (!entry) { err = -ENODEV ; goto err;
kernel/trace/trace_functions_graph.c +1 -1
@@ -1340,7 +1340,7 @@ static __init int init_graph_tracefs(void)if (ret)return 0 ; -trace_create_file ("max_graph_depth" ,0644 ,NULL , +trace_create_file ("max_graph_depth" ,TRACE_MODE_WRITE ,NULL ,NULL , &graph_depth_fops);return 0 ;
kernel/trace/trace_hwlat.c +3 -3
@@ -782,21 +782,21 @@ static int init_tracefs(void)if (!top_dir)return -ENOMEM ; - hwlat_sample_window =tracefs_create_file ("window" ,0640 , + hwlat_sample_window =tracefs_create_file ("window" ,TRACE_MODE_WRITE , top_dir, &hwlat_window, &trace_min_max_fops);if (!hwlat_sample_window) goto err; - hwlat_sample_width =tracefs_create_file ("width" ,0644 , + hwlat_sample_width =tracefs_create_file ("width" ,TRACE_MODE_WRITE , top_dir, &hwlat_width, &trace_min_max_fops);if (!hwlat_sample_width) goto err; - hwlat_thread_mode =trace_create_file ("mode" ,0644 , + hwlat_thread_mode =trace_create_file ("mode" ,TRACE_MODE_WRITE , top_dir,NULL , &thread_mode_fops);
kernel/trace/trace_kprobe.c +4 -4
@@ -1934,16 +1934,16 @@ static __init int init_kprobe_trace(void)if (ret)return 0 ; - entry =tracefs_create_file ("kprobe_events" ,0644 ,NULL , -NULL , &kprobe_events_ops); + entry =tracefs_create_file ("kprobe_events" ,TRACE_MODE_WRITE , +NULL ,NULL , &kprobe_events_ops);/* Event list interface */ if (!entry)pr_warn ("Could not create tracefs 'kprobe_events' entry\n" );/* Profile interface */ - entry =tracefs_create_file ("kprobe_profile" ,0444 ,NULL , -NULL , &kprobe_profile_ops); + entry =tracefs_create_file ("kprobe_profile" ,TRACE_MODE_READ , +NULL ,NULL , &kprobe_profile_ops);if (!entry)pr_warn ("Could not create tracefs 'kprobe_profile' entry\n" );
kernel/trace/trace_osnoise.c +7 -7
@@ -1856,38 +1856,38 @@ static int init_tracefs(void)if (!top_dir)return 0 ; - tmp =tracefs_create_file ("period_us" ,0640 , top_dir, + tmp =tracefs_create_file ("period_us" ,TRACE_MODE_WRITE , top_dir, &osnoise_period, &trace_min_max_fops);if (!tmp) goto err; - tmp =tracefs_create_file ("runtime_us" ,0644 , top_dir, + tmp =tracefs_create_file ("runtime_us" ,TRACE_MODE_WRITE , top_dir, &osnoise_runtime, &trace_min_max_fops);if (!tmp) goto err; - tmp =tracefs_create_file ("stop_tracing_us" ,0640 , top_dir, + tmp =tracefs_create_file ("stop_tracing_us" ,TRACE_MODE_WRITE , top_dir, &osnoise_stop_tracing_in, &trace_min_max_fops);if (!tmp) goto err; - tmp =tracefs_create_file ("stop_tracing_total_us" ,0640 , top_dir, + tmp =tracefs_create_file ("stop_tracing_total_us" ,TRACE_MODE_WRITE , top_dir, &osnoise_stop_tracing_total, &trace_min_max_fops);if (!tmp) goto err; - tmp =trace_create_file ("cpus" ,0644 , top_dir,NULL , &cpus_fops); + tmp =trace_create_file ("cpus" ,TRACE_MODE_WRITE , top_dir,NULL , &cpus_fops);if (!tmp) goto err;#ifdef CONFIG_TIMERLAT_TRACER #ifdef CONFIG_STACKTRACE - tmp =tracefs_create_file ("print_stack" ,0640 , top_dir, + tmp =tracefs_create_file ("print_stack" ,TRACE_MODE_WRITE , top_dir, &osnoise_print_stack, &trace_min_max_fops);if (!tmp) goto err;#endif - tmp =tracefs_create_file ("timerlat_period_us" ,0640 , top_dir, + tmp =tracefs_create_file ("timerlat_period_us" ,TRACE_MODE_WRITE , top_dir, &timerlat_period, &trace_min_max_fops);if (!tmp) goto err;
kernel/trace/trace_printk.c +1 -1
@@ -384,7 +384,7 @@ static __init int init_trace_printk_function_export(void)if (ret)return 0 ; -trace_create_file ("printk_formats" ,0444 ,NULL , +trace_create_file ("printk_formats" ,TRACE_MODE_READ ,NULL ,NULL , &ftrace_formats_fops);return 0 ;
kernel/trace/trace_recursion_record.c +2 -2
@@ -226,8 +226,8 @@ __init static int create_recursed_functions(void) {struct dentry *dentry; - dentry =trace_create_file ("recursed_functions" ,0644 ,NULL ,NULL , - &recursed_functions_fops); + dentry =trace_create_file ("recursed_functions" ,TRACE_MODE_WRITE , +NULL ,NULL , &recursed_functions_fops);if (!dentry)pr_warn ("WARNING: Failed to create recursed_functions\n" );return 0 ;
kernel/trace/trace_stack.c +3 -3
@@ -559,14 +559,14 @@ static __init int stack_trace_init(void)if (ret)return 0 ; -trace_create_file ("stack_max_size" ,0644 ,NULL , +trace_create_file ("stack_max_size" ,TRACE_MODE_WRITE ,NULL , &stack_trace_max_size, &stack_max_size_fops); -trace_create_file ("stack_trace" ,0444 ,NULL , +trace_create_file ("stack_trace" ,TRACE_MODE_READ ,NULL ,NULL , &stack_trace_fops);#ifdef CONFIG_DYNAMIC_FTRACE -trace_create_file ("stack_trace_filter" ,0644 ,NULL , +trace_create_file ("stack_trace_filter" ,TRACE_MODE_WRITE ,NULL , &trace_ops, &stack_trace_filter_fops);#endif
kernel/trace/trace_stat.c +3 -3
@@ -297,9 +297,9 @@ static int init_stat_file(struct stat_session *session)if (!stat_dir && (ret =tracing_stat_init ()))return ret; - session->file =tracefs_create_file (session->ts->name,0644 , - stat_dir, - session, &tracing_stat_fops); + session->file =tracefs_create_file (session->ts->name,TRACE_MODE_WRITE , + stat_dir, session, + &tracing_stat_fops);if (!session->file)return -ENOMEM ;return 0 ;
kernel/trace/trace_uprobe.c +2 -2
@@ -1657,10 +1657,10 @@ static __init int init_uprobe_trace(void)if (ret)return 0 ; -trace_create_file ("uprobe_events" ,0644 ,NULL , +trace_create_file ("uprobe_events" ,TRACE_MODE_WRITE ,NULL ,NULL , &uprobe_events_ops);/* Profile interface */ -trace_create_file ("uprobe_profile" ,0444 ,NULL , +trace_create_file ("uprobe_profile" ,TRACE_MODE_READ ,NULL ,NULL , &uprobe_profile_ops);return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 270/849 ath: dfs_pattern_detector: Fix possible null-pointer dereference in channel_detector_create()
In reply to Greg Kroah-HartmanFrom: Tuo Li <[email protected]>
[ Upstream commit 4b6012a7830b813799a7faf40daa02a837e0fd5b ]
kzalloc() is used to allocate memory for cd->detectors, and if it fails, channel_detector_exit() behind the label fail will be called:
channel_detector_exit(dpd, cd);
In channel_detector_exit(), cd->detectors is dereferenced through:
struct pri_detector *de = cd->detectors[i];
To fix this possible null-pointer dereference, check cd->detectors before the for loop to dereference cd->detectors.
--- drivers/net/wireless/ath/dfs_pattern_detector.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/dfs_pattern_detector.c +6 -4
@@ -183,10 +183,12 @@ static void channel_detector_exit(struct dfs_pattern_detector *dpd,if (cd ==NULL )return ;list_del (&cd->head); -for (i =0 ; i < dpd->num_radar_types; i++) { -struct pri_detector *de = cd->detectors[i]; -if (de !=NULL ) - de->exit (de); +if (cd->detectors) { +for (i =0 ; i < dpd->num_radar_types; i++) { +struct pri_detector *de = cd->detectors[i]; +if (de !=NULL ) + de->exit (de); + } }kfree (cd->detectors);kfree (cd);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 271/849 mmc: moxart: Fix reference count leaks in moxart_probe
In reply to Greg Kroah-HartmanFrom: Xin Xiong <[email protected]>
[ Upstream commit 8105c2abbf36296bf38ca44f55ee45d160db476a ]
The issue happens in several error handling paths on two refcounted object related to the object "host" (dma_chan_rx, dma_chan_tx). In these paths, the function forgets to decrement one or both objects' reference count increased earlier by dma_request_chan(), causing reference count leaks.
Fix it by balancing the refcounts of both objects in some error handling paths. In correspondence with the changes in moxart_probe(), IS_ERR() is replaced with IS_ERR_OR_NULL() in moxart_remove() as well.
--- drivers/mmc/host/moxart-mmc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/mmc/host/moxart-mmc.c +14 -2
@@ -621,6 +621,14 @@ static int moxart_probe(struct platform_device *pdev) ret = -EPROBE_DEFER ; goto out; } +if (!IS_ERR (host->dma_chan_tx)) { +dma_release_channel (host->dma_chan_tx); + host->dma_chan_tx =NULL ; + } +if (!IS_ERR (host->dma_chan_rx)) { +dma_release_channel (host->dma_chan_rx); + host->dma_chan_rx =NULL ; + }dev_dbg (dev,"PIO mode transfer enabled\n" ); host->have_dma = false; }else {
@@ -675,6 +683,10 @@ static int moxart_probe(struct platform_device *pdev)return 0 ; out: +if (!IS_ERR_OR_NULL (host->dma_chan_tx)) +dma_release_channel (host->dma_chan_tx); +if (!IS_ERR_OR_NULL (host->dma_chan_rx)) +dma_release_channel (host->dma_chan_rx);if (mmc)mmc_free_host (mmc);return ret;
@@ -687,9 +699,9 @@ static int moxart_remove(struct platform_device *pdev)dev_set_drvdata (&pdev->dev,NULL ); -if (!IS_ERR (host->dma_chan_tx)) +if (!IS_ERR_OR_NULL (host->dma_chan_tx))dma_release_channel (host->dma_chan_tx); -if (!IS_ERR (host->dma_chan_rx)) +if (!IS_ERR_OR_NULL (host->dma_chan_rx))dma_release_channel (host->dma_chan_rx);mmc_remove_host (mmc);mmc_free_host (mmc);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 272/849 iov_iter: Fix iov_iter_get_pages{,_alloc} page fault return value
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 814a66741b9ffb5e1ba119e368b178edb0b7322d ]
Both iov_iter_get_pages and iov_iter_get_pages_alloc return the number of bytes of the iovec they could get the pages for. When they cannot get any pages, they're supposed to return 0, but when the start of the iovec isn't page aligned, the calculation goes wrong and they return a negative value. Fix both functions.
In addition, change iov_iter_get_pages_alloc to return NULL in that case to prevent resource leaks.
--- lib/iov_iter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/iov_iter.c +3 -2
@@ -1484,7 +1484,7 @@ ssize_t iov_iter_get_pages(struct iov_iter *i, res =get_user_pages_fast (addr, n,iov_iter_rw (i) !=WRITE ?FOLL_WRITE :0 , pages); -if (unlikely (res <0 )) +if (unlikely (res <=0 ))return res;return (res == n ? len : res *PAGE_SIZE ) - *start; }
@@ -1608,8 +1608,9 @@ ssize_t iov_iter_get_pages_alloc(struct iov_iter *i,return -ENOMEM ; res =get_user_pages_fast (addr, n,iov_iter_rw (i) !=WRITE ?FOLL_WRITE :0 , p); -if (unlikely (res <0 )) { +if (unlikely (res <=0 )) {kvfree (p); + *pages =NULL ;return res; } *pages = p;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 273/849 ACPI: battery: Accept charges over the design capacity as full
In reply to Greg Kroah-HartmanFrom: André Almeida <[email protected]>
[ Upstream commit 2835f327bd1240508db2c89fe94a056faa53c49a ]
Some buggy firmware and/or brand new batteries can support a charge that's slightly over the reported design capacity. In such cases, the kernel will report to userspace that the charging state of the battery is "Unknown", when in reality the battery charge is "Full", at least from the design capacity point of view. Make the fallback condition accepts capacities over the designed capacity so userspace knows that is full.
--- drivers/acpi/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/battery.c +1 -1
@@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)return 1 ;/* fallback to using design values for broken batteries */ -if (battery->design_capacity == battery->capacity_now) +if (battery->design_capacity <= battery->capacity_now)return 1 ;/* we don't do any sort of metric based on percentages */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 274/849 ACPI: scan: Release PM resources blocked by unused objects
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit c10383e8ddf4810b9a5c1595404c2724d925a0a6 ]
On some systems the ACPI namespace contains device objects that are not used in certain configurations of the system. If they start off in the D0 power state configuration, they will stay in it until the system reboots, because of the lack of any mechanism possibly causing their configuration to change. If that happens, they may prevent some power resources from being turned off or generally they may prevent the platform from getting into the deepest low-power states thus causing some energy to be wasted.
Address this issue by changing the configuration of unused ACPI device objects to the D3cold power state one after carrying out the ACPI-based enumeration of devices.
--- drivers/acpi/glue.c | 25 +++++++++++++++++++++++++ drivers/acpi/internal.h | 1 + drivers/acpi/scan.c | 6 ++++++ 3 files changed, 32 insertions(+)
drivers/acpi/glue.c +25 -0
@@ -363,3 +363,28 @@ int acpi_platform_notify(struct device *dev, enum kobject_action action) }return 0 ; } + +int acpi_dev_turn_off_if_unused (struct device *dev,void *not_used) +{ +struct acpi_device *adev =to_acpi_device (dev); + +/* +* Skip device objects with device IDs, because they may be in use even +* if they are not companions of any physical device objects. +*/ +if (adev->pnp.type.hardware_id) +return 0 ; + +mutex_lock (&adev->physical_node_lock); + +/* +* Device objects without device IDs are not in use if they have no +* corresponding physical device objects. +*/ +if (list_empty (&adev->physical_node_list)) +acpi_device_set_power (adev,ACPI_STATE_D3_COLD ); + +mutex_unlock (&adev->physical_node_lock); + +return 0 ; +}
drivers/acpi/internal.h +1 -0
@@ -117,6 +117,7 @@ bool acpi_device_is_battery(struct acpi_device *adev);bool acpi_device_is_first_physical_node (struct acpi_device *adev,const struct device *dev);int acpi_bus_register_early_device (int type); +int acpi_dev_turn_off_if_unused (struct device *dev,void *not_used);/* -------------------------------------------------------------------------- Device Matching and Notification
drivers/acpi/scan.c +6 -0
@@ -2560,6 +2560,12 @@ int __init acpi_scan_init(void) } } +/* +* Make sure that power management resources are not blocked by ACPI +* device objects with no users. +*/ +bus_for_each_dev (&acpi_bus_type,NULL ,NULL , acpi_dev_turn_off_if_unused); +acpi_turn_off_unused_power_resources (); acpi_scan_initialized = true;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 275/849 drm/amd/display: fix null pointer deref when plugging in display
In reply to Greg Kroah-HartmanFrom: Aurabindo Pillai <[email protected]>
[ Upstream commit 1f3b22e4eb162e0b1d423106a47484943a22a309 ]
[Why&How]
When system boots in headless mode, connecting a 4k display creates a null pointer dereference due to hubp for a certain plane being null. Add a condition to check for null hubp before dereferencing it.
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +2 -1
@@ -1002,7 +1002,8 @@ void dcn30_set_disp_pattern_generator(const struct dc *dc,/* turning off DPG */ pipe_ctx->plane_res.hubp->funcs->set_blank (pipe_ctx->plane_res.hubp, false);for (mpcc_pipe = pipe_ctx->bottom_pipe; mpcc_pipe; mpcc_pipe = mpcc_pipe->bottom_pipe) - mpcc_pipe->plane_res.hubp->funcs->set_blank (mpcc_pipe->plane_res.hubp, false); +if (mpcc_pipe->plane_res.hubp) + mpcc_pipe->plane_res.hubp->funcs->set_blank (mpcc_pipe->plane_res.hubp, false); stream_res->opp->funcs->opp_set_disp_pattern_generator (stream_res->opp, test_pattern, color_space, color_depth, solid_color, width, height, offset);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 276/849 drm/amdkfd: fix resume error when iommu disabled in Picasso
In reply to Greg Kroah-HartmanFrom: Yifan Zhang <[email protected]>
[ Upstream commit 6f4b590aae217da16cfa44039a2abcfb209137ab ]
When IOMMU disabled in sbios and kfd in iommuv2 path, IOMMU resume failure blocks system resume. Don't allow kfd to use iommu v2 when iommu is disabled.
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +1 -0
@@ -867,6 +867,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,kfd_double_confirm_iommu_support (kfd);if (kfd_iommu_device_init (kfd)) { + kfd->use_iommu_v2 = false;dev_err (kfd_device,"Error initializing iommuv2\n" ); goto device_iommu_error; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 277/849 net: phy: micrel: make *-skew-ps check more lenient
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 67ca5159dbe2edb5dae7544447b8677d2596933a ]
It seems reasonable to fine-tune only some of the skew values when using one of the rgmii-*id PHY modes, and even when all skew values are specified, using the correct ID PHY mode makes sense for documentation purposes. Such a configuration also appears in the binding docs in Documentation/devicetree/bindings/net/micrel-ksz90x1.txt, so the driver should not warn about it.
--- drivers/net/phy/micrel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/micrel.c +2 -2
@@ -863,9 +863,9 @@ static int ksz9031_config_init(struct phy_device *phydev)MII_KSZ9031RN_TX_DATA_PAD_SKEW ,4 , tx_data_skews, 4, &update); -if (update && phydev->interface !=PHY_INTERFACE_MODE_RGMII ) +if (update && !phy_interface_is_rgmii (phydev))phydev_warn (phydev, -"*-skew-ps values should be used only with phy-mode = \"rgmii\"\n" ); +"*-skew-ps values should be used only with RGMII PHY modes\n" );/* Silicon Errata Sheet (DS80000691D or DS80000692D): * When the device links in the 1000BASE-T slave mode only,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 278/849 leaking_addresses: Always print a trailing newline
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit cf2a85efdade117e2169d6e26641016cbbf03ef0 ]
For files that lack trailing newlines and match a leaking address (e.g. wchan[1]), the leaking_addresses.pl report would run together with the next line, making things look corrupted.
Unconditionally remove the newline on input, and write it back out on output.
[1] https://lore.kernel.org/all/20210103142726.GC30643@xsang-OptiPlex-9020/
--- scripts/leaking_addresses.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/leaking_addresses.pl +2 -1
@@ -455,8 +455,9 @@ sub parse_file open my $fh, "<", $file or return; while ( <$fh> ) { + chomp; if (may_leak_address($_)) { - print $file . ': ' . $_; + printf("$file: $_\n"); } } close $fh;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 279/849 thermal/core: Fix null pointer dereference in thermal_release()
In reply to Greg Kroah-HartmanFrom: Yuanzheng Song <[email protected]>
[ Upstream commit 1dd7128b839f631b31a9e9dce3aaf639bef74e9d ]
If both dev_set_name() and device_register() failed, then null pointer dereference occurs in thermal_release() which will use strncmp() to compare the name.
So fix it by adding dev_set_name() return value check.
--- drivers/thermal/thermal_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/thermal/thermal_core.c +8 -2
@@ -902,6 +902,10 @@ __thermal_cooling_device_register(struct device_node *np, goto out_kfree_cdev; cdev->id = ret; + ret =dev_set_name (&cdev->device,"cooling_device%d" , cdev->id); +if (ret) + goto out_ida_remove; + cdev->type =kstrdup (type ? type :"" ,GFP_KERNEL );if (!cdev->type) { ret = -ENOMEM ;
@@ -916,7 +920,6 @@ __thermal_cooling_device_register(struct device_node *np, cdev->device.class = &thermal_class; cdev->devdata = devdata;thermal_cooling_device_setup_sysfs (cdev); -dev_set_name (&cdev->device,"cooling_device%d" , cdev->id); ret =device_register (&cdev->device);if (ret) goto out_kfree_type;
@@ -1227,6 +1230,10 @@ thermal_zone_device_register(const char *type, int trips, int mask, tz->id = id;strlcpy (tz->type, type,sizeof (tz->type)); + result =dev_set_name (&tz->device,"thermal_zone%d" , tz->id); +if (result) + goto remove_id; +if (!ops->critical) ops->critical = thermal_zone_device_critical;
@@ -1248,7 +1255,6 @@ thermal_zone_device_register(const char *type, int trips, int mask,/* A new thermal zone needs to be updated anyway. */ atomic_set (&tz->need_update,1 ); -dev_set_name (&tz->device,"thermal_zone%d" , tz->id); result =device_register (&tz->device);if (result) goto release_device;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 280/849 drm/msm: prevent NULL dereference in msm_gpu_crashstate_capture()
In reply to Greg Kroah-HartmanFrom: Tim Gardner <[email protected]>
[ Upstream commit b220c154832c5cd0df34cbcbcc19d7135c16e823 ]
Coverity complains of a possible NULL dereference:
CID 120718 (#1 of 1): Dereference null return value (NULL_RETURNS)
23. dereference: Dereferencing a pointer that might be NULL state->bos when calling msm_gpu_crashstate_get_bo. [show details]
301 msm_gpu_crashstate_get_bo(state, submit->bos[i].obj,
302 submit->bos[i].iova, submit->bos[i].flags);
Fix this by employing the same state->bos NULL check as is used in the next for loop.
--- drivers/gpu/drm/msm/msm_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gpu.c +1 -1
@@ -404,7 +404,7 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu, state->bos =kcalloc (nr,sizeof (struct msm_gpu_state_bo ),GFP_KERNEL ); -for (i =0 ; i < submit->nr_bos; i++) { +for (i =0 ; state->bos && i < submit->nr_bos; i++) {if (should_dump (submit, i)) {msm_gpu_crashstate_get_bo (state, submit->bos[i].obj, submit->bos[i].iova, submit->bos[i].flags);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 281/849 thermal/drivers/tsens: Add timeout to get_temp_tsens_valid
In reply to Greg Kroah-HartmanFrom: Ansuel Smith <[email protected]>
[ Upstream commit d012f9189fda0f3a1b303780ba0bbc7298d0d349 ]
The function can loop and lock the system if for whatever reason the bit for the target sensor is NEVER valid. This is the case if a sensor is disabled by the factory and the valid bit is never reported as actually valid. Add a timeout check and exit if a timeout occurs. As this is a very rare condition, handle the timeout only if the first read fails. While at it also rework the function to improve readability and convert to poll_timeout generic macro.
--- drivers/thermal/qcom/tsens.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/thermal/qcom/tsens.c +14 -15
@@ -603,22 +603,21 @@ int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp)int ret;/* VER_0 doesn't have VALID bit */ -if (tsens_version (priv) >=VER_0_1 ) { - ret =regmap_field_read (priv->rf[valid_idx], &valid); -if (ret) -return ret; -while (!valid) { -/* Valid bit is 0 for 6 AHB clock cycles. -* At 19.2MHz, 1 AHB clock is ~60ns. -* We should enter this loop very, very rarely. -*/ -ndelay (400 ); - ret =regmap_field_read (priv->rf[valid_idx], &valid); -if (ret) -return ret; - } - } +if (tsens_version (priv) ==VER_0 ) + goto get_temp; + +/* Valid bit is 0 for 6 AHB clock cycles. +* At 19.2MHz, 1 AHB clock is ~60ns. +* We should enter this loop very, very rarely. +* Wait 1 us since it's the min of poll_timeout macro. +* Old value was 400 ns. +*/ + ret =regmap_field_read_poll_timeout (priv->rf[valid_idx], valid, + valid,1 ,20 *USEC_PER_MSEC ); +if (ret) +return ret; +get_temp:/* Valid bit is set, OK to read the temperature */ *temp =tsens_hw_to_mC (s, temp_idx);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 282/849 block: bump max plugged deferred size from 16 to 32
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit ba0ffdd8ce48ad7f7e85191cd29f9674caca3745 ]
Particularly for NVMe with efficient deferred submission for many requests, there are nice benefits to be seen by bumping the default max plug count from 16 to 32. This is especially true for virtualized setups, where the submit part is more expensive. But can be noticed even on native hardware.
Reduce the multiple queue factor from 4 to 2, since we're changing the default size.
While changing it, move the defines into the block layer private header. These aren't values that anyone outside of the block layer uses, or should use.
--- block/blk-mq.c | 4 ++-- block/blk.h | 6 ++++++ include/linux/blkdev.h | 2 -- 3 files changed, 8 insertions(+), 4 deletions(-)
block/blk-mq.c +2 -2
@@ -2141,14 +2141,14 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq) }/* -* Allow 4x BLK_MAX_REQUEST_COUNT requests on plug queue for multiple +* Allow 2x BLK_MAX_REQUEST_COUNT requests on plug queue for multiple * queues. This is important for md arrays to benefit from merging * requests. */ static inline unsigned short blk_plug_max_rq_count (struct blk_plug *plug) {if (plug->multiple_queues) -return BLK_MAX_REQUEST_COUNT *4 ; +return BLK_MAX_REQUEST_COUNT *2 ;return BLK_MAX_REQUEST_COUNT ; }
block/blk.h +6 -0
@@ -181,6 +181,12 @@ bool blk_bio_list_merge(struct request_queue *q, struct list_head *list,void blk_account_io_start (struct request *req);void blk_account_io_done (struct request *req,u64 now); +/* +* Plug flush limits +*/ +#define BLK_MAX_REQUEST_COUNT 32 +#define BLK_PLUG_FLUSH_SIZE (128 * 1024) +/* * Internal elevator interface */
include/linux/blkdev.h +0 -2
@@ -1223,8 +1223,6 @@ struct blk_plug {bool multiple_queues;bool nowait; }; -#define BLK_MAX_REQUEST_COUNT 16 -#define BLK_PLUG_FLUSH_SIZE (128 * 1024)struct blk_plug_cb ;typedef void (*blk_plug_cb_fn )(struct blk_plug_cb *,bool );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 283/849 floppy: fix calling platform_device_unregister() on invalid drives
In reply to Greg Kroah-HartmanFrom: Luis Chamberlain <[email protected]>
[ Upstream commit 662167e59d2f3c15a44a88088fc6c1a67c8a3650 ]
platform_device_unregister() should only be called when a respective platform_device_register() is called. However the floppy driver currently allows failures when registring a drive and a bail out could easily cause an invalid call to platform_device_unregister() where it was not intended.
Fix this by adding a bool to keep track of when the platform device was registered for a drive.
This does not fix any known panic / bug. This issue was found through code inspection while preparing the driver to use the up and coming support for device_add_disk() error handling.
Quoted 1 line
From what I can tell from code inspection, chances of this
ever happening should be insanely small, perhaps OOM.
--- drivers/block/floppy.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/block/floppy.c +7 -2
@@ -4478,6 +4478,7 @@ static const struct blk_mq_ops floppy_mq_ops = { };static struct platform_device floppy_device[N_DRIVE ]; +static bool registered[N_DRIVE ];static bool floppy_available (int drive) {
@@ -4693,6 +4694,8 @@ static int __init do_floppy_init(void)if (err) goto out_remove_drives; + registered[drive] = true; +device_add_disk (&floppy_device[drive].dev, disks[drive][0 ],NULL ); }
@@ -4703,7 +4706,8 @@ out_remove_drives:while (drive--) {if (floppy_available (drive)) {del_gendisk (disks[drive][0 ]); -platform_device_unregister (&floppy_device[drive]); +if (registered[drive]) +platform_device_unregister (&floppy_device[drive]); } } out_release_dma:
@@ -4946,7 +4950,8 @@ static void __exit floppy_module_exit(void)if (disks[drive][i])del_gendisk (disks[drive][i]); } -platform_device_unregister (&floppy_device[drive]); +if (registered[drive]) +platform_device_unregister (&floppy_device[drive]); }for (i =0 ; i <ARRAY_SIZE (floppy_type); i++) {if (disks[drive][i])
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 284/849 md: update superblock after changing rdev flags in state_store
In reply to Greg Kroah-HartmanFrom: Xiao Ni <[email protected]>
[ Upstream commit 8b9e2291e355a0eafdd5b1e21a94a6659f24b351 ]
When the in memory flag is changed, we need to persist the change in the rdev superblock flags. This is needed for "writemostly" and "failfast".
--- drivers/md/md.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/md/md.c +10 -1
@@ -2976,7 +2976,11 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)* -write_error - clears WriteErrorSeen * {,-}failfast - set/clear FailFast */ + +struct mddev *mddev = rdev->mddev;int err = -EINVAL ; +bool need_update_sb = false; +if (cmd_match (buf,"faulty" ) && rdev->mddev->pers) {md_error (rdev->mddev, rdev);if (test_bit (Faulty, &rdev->flags))
@@ -2991,7 +2995,6 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)if (rdev->raid_disk >=0 ) err = -EBUSY ;else { -struct mddev *mddev = rdev->mddev; err =0 ;if (mddev_is_clustered (mddev)) err = md_cluster_ops->remove_disk (mddev, rdev);
@@ -3008,10 +3011,12 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) }else if (cmd_match (buf,"writemostly" )) {set_bit (WriteMostly, &rdev->flags);mddev_create_serial_pool (rdev->mddev, rdev, false); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"-writemostly" )) {mddev_destroy_serial_pool (rdev->mddev, rdev, false);clear_bit (WriteMostly, &rdev->flags); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"blocked" )) {set_bit (Blocked, &rdev->flags);
@@ -3037,9 +3042,11 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) err =0 ; }else if (cmd_match (buf,"failfast" )) {set_bit (FailFast, &rdev->flags); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"-failfast" )) {clear_bit (FailFast, &rdev->flags); + need_update_sb = true; err =0 ; }else if (cmd_match (buf,"-insync" ) && rdev->raid_disk >=0 && !test_bit (Journal, &rdev->flags)) {
@@ -3118,6 +3125,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)clear_bit (ExternalBbl, &rdev->flags); err =0 ; } +if (need_update_sb) +md_update_sb (mddev,1 );if (!err)sysfs_notify_dirent_safe (rdev->sysfs_state);return err ? err : len;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 285/849 memstick: r592: Fix a UAF bug when removing the driver
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 738216c1953e802aa9f930c5d15b8f9092c847ff ]
In r592_remove(), the driver will free dma after freeing the host, which may cause a UAF bug.
The following log reveals it:
[ 45.361796 ] BUG: KASAN: use-after-free in r592_remove+0x269/0x350 [r592] [ 45.364286 ] Call Trace: [ 45.364472 ] dump_stack_lvl+0xa8/0xd1 [ 45.364751 ] print_address_description+0x87/0x3b0 [ 45.365137 ] kasan_report+0x172/0x1c0 [ 45.365415 ] ? r592_remove+0x269/0x350 [r592] [ 45.365834 ] ? r592_remove+0x269/0x350 [r592] [ 45.366168 ] __asan_report_load8_noabort+0x14/0x20 [ 45.366531 ] r592_remove+0x269/0x350 [r592] [ 45.378785 ] [ 45.378903 ] Allocated by task 4674: [ 45.379162 ] ____kasan_kmalloc+0xb5/0xe0 [ 45.379455 ] __kasan_kmalloc+0x9/0x10 [ 45.379730 ] __kmalloc+0x150/0x280 [ 45.379984 ] memstick_alloc_host+0x2a/0x190 [ 45.380664 ] [ 45.380781 ] Freed by task 5509: [ 45.381014 ] kasan_set_track+0x3d/0x70 [ 45.381293 ] kasan_set_free_info+0x23/0x40 [ 45.381635 ] ____kasan_slab_free+0x10b/0x140 [ 45.381950 ] __kasan_slab_free+0x11/0x20 [ 45.382241 ] slab_free_freelist_hook+0x81/0x150 [ 45.382575 ] kfree+0x13e/0x290 [ 45.382805 ] memstick_free+0x1c/0x20 [ 45.383070 ] device_release+0x9c/0x1d0 [ 45.383349 ] kobject_put+0x2ef/0x4c0 [ 45.383616 ] put_device+0x1f/0x30 [ 45.383865 ] memstick_free_host+0x24/0x30 [ 45.384162 ] r592_remove+0x242/0x350 [r592] [ 45.384473 ] pci_device_remove+0xa9/0x250
--- drivers/memstick/host/r592.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/memstick/host/r592.c +4 -4
@@ -839,15 +839,15 @@ static void r592_remove(struct pci_dev *pdev) }memstick_remove_host (dev->host); +if (dev->dummy_dma_page) +dma_free_coherent (&pdev->dev,PAGE_SIZE , dev->dummy_dma_page, + dev->dummy_dma_page_physical_address); +free_irq (dev->irq, dev);iounmap (dev->mmio);pci_release_regions (pdev);pci_disable_device (pdev);memstick_free_host (dev->host); - -if (dev->dummy_dma_page) -dma_free_coherent (&pdev->dev,PAGE_SIZE , dev->dummy_dma_page, - dev->dummy_dma_page_physical_address); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 286/849 locking/rwsem: Disable preemption for spinning region
In reply to Greg Kroah-HartmanFrom: Yanfei Xu <[email protected]>
[ Upstream commit 7cdacc5f52d68a9370f182c844b5b3e6cc975cc1 ]
The spinning region rwsem_spin_on_owner() should not be preempted, however the rwsem_down_write_slowpath() invokes it and don't disable preemption. Fix it by adding a pair of preempt_disable/enable().
--- kernel/locking/rwsem.c | 53 ++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 23 deletions(-)
kernel/locking/rwsem.c +30 -23
@@ -576,6 +576,24 @@ static inline bool rwsem_try_write_lock(struct rw_semaphore *sem,return true; } +/* +* The rwsem_spin_on_owner() function returns the following 4 values +* depending on the lock owner state. +* OWNER_NULL : owner is currently NULL +* OWNER_WRITER: when owner changes and is a writer +* OWNER_READER: when owner changes and the new owner may be a reader. +* OWNER_NONSPINNABLE: +* when optimistic spinning has to stop because either the +* owner stops running, is unknown, or its timeslice has +* been used up. +*/ +enum owner_state { +OWNER_NULL =1 <<0 , +OWNER_WRITER =1 <<1 , +OWNER_READER =1 <<2 , +OWNER_NONSPINNABLE =1 <<3 , +}; +#ifdef CONFIG_RWSEM_SPIN_ON_OWNER /* * Try to acquire write lock before the writer has been put on wait queue.
@@ -631,23 +649,6 @@ static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem)return ret; } -/* -* The rwsem_spin_on_owner() function returns the following 4 values -* depending on the lock owner state. -* OWNER_NULL : owner is currently NULL -* OWNER_WRITER: when owner changes and is a writer -* OWNER_READER: when owner changes and the new owner may be a reader. -* OWNER_NONSPINNABLE: -* when optimistic spinning has to stop because either the -* owner stops running, is unknown, or its timeslice has -* been used up. -*/ -enum owner_state { -OWNER_NULL =1 <<0 , -OWNER_WRITER =1 <<1 , -OWNER_READER =1 <<2 , -OWNER_NONSPINNABLE =1 <<3 , -};#define OWNER_SPINNABLE (OWNER_NULL | OWNER_WRITER | OWNER_READER) static inline enum owner_state
@@ -877,12 +878,11 @@ static inline bool rwsem_optimistic_spin(struct rw_semaphore *sem)static inline void clear_nonspinnable (struct rw_semaphore *sem) { } -static inline int +static inline enum owner_state rwsem_spin_on_owner (struct rw_semaphore *sem) { -return 0 ; +return OWNER_NONSPINNABLE ; } -#define OWNER_NULL 1#endif /*
@@ -1094,9 +1094,16 @@ wait:* In this case, we attempt to acquire the lock again * without sleeping. */ -if (wstate ==WRITER_HANDOFF && -rwsem_spin_on_owner (sem) ==OWNER_NULL ) - goto trylock_again; +if (wstate ==WRITER_HANDOFF ) { +enum owner_state owner_state; + +preempt_disable (); + owner_state =rwsem_spin_on_owner (sem); +preempt_enable (); + +if (owner_state ==OWNER_NULL ) + goto trylock_again; + }/* Block until there are no active lockers. */ for (;;) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 287/849 lib/xz: Avoid overlapping memcpy() with invalid input with in-place decompression
In reply to Greg Kroah-HartmanFrom: Lasse Collin <[email protected]>
[ Upstream commit 83d3c4f22a36d005b55f44628f46cc0d319a75e8 ]
With valid files, the safety margin described in lib/decompress_unxz.c ensures that these buffers cannot overlap. But if the uncompressed size of the input is larger than the caller thought, which is possible when the input file is invalid/corrupt, the buffers can overlap. Obviously the result will then be garbage (and usually the decoder will return an error too) but no other harm will happen when such an over-run occurs.
This change only affects uncompressed LZMA2 chunks and so this should have no effect on performance.
--- lib/decompress_unxz.c | 2 +- lib/xz/xz_dec_lzma2.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-)
lib/decompress_unxz.c +1 -1
@@ -167,7 +167,7 @@* memeq and memzero are not used much and any remotely sane implementation * is fast enough. memcpy/memmove speed matters in multi-call mode, but * the kernel image is decompressed in single-call mode, in which only -* memcpy speed can matter and only if there is a lot of uncompressible data +* memmove speed can matter and only if there is a lot of uncompressible data * (LZMA2 stores uncompressible chunks in uncompressed form). Thus, the * functions below should just be kept small; it's probably not worth * optimizing for speed.
lib/xz/xz_dec_lzma2.c +19 -2
@@ -387,7 +387,14 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b, *left -= copy_size; -memcpy (dict->buf + dict->pos, b->in + b->in_pos, copy_size); +/* +* If doing in-place decompression in single-call mode and the +* uncompressed size of the file is larger than the caller +* thought (i.e. it is invalid input!), the buffers below may +* overlap and cause undefined behavior with memcpy(). +* With valid inputs memcpy() would be fine here. +*/ +memmove (dict->buf + dict->pos, b->in + b->in_pos, copy_size); dict->pos += copy_size;if (dict->full < dict->pos)
@@ -397,7 +404,11 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,if (dict->pos == dict->end) dict->pos =0 ; -memcpy (b->out + b->out_pos, b->in + b->in_pos, +/* +* Like above but for multi-call mode: use memmove() +* to avoid undefined behavior with invalid input. +*/ +memmove (b->out + b->out_pos, b->in + b->in_pos, copy_size); }
@@ -421,6 +432,12 @@ static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)if (dict->pos == dict->end) dict->pos =0 ; +/* +* These buffers cannot overlap even if doing in-place +* decompression because in multi-call mode dict->buf +* has been allocated by us in this file; it's not +* provided by the caller like in single-call mode. +*/ memcpy (b->out + b->out_pos, dict->buf + dict->start, copy_size); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 288/849 lib/xz: Validate the value before assigning it to an enum variable
In reply to Greg Kroah-HartmanFrom: Lasse Collin <[email protected]>
[ Upstream commit 4f8d7abaa413c34da9d751289849dbfb7c977d05 ]
This might matter, for example, if the underlying type of enum xz_check was a signed char. In such a case the validation wouldn't have caught an unsupported header. I don't know if this problem can occur in the kernel on any arch but it's still good to fix it because some people might copy the XZ code to their own projects from Linux instead of the upstream XZ Embedded repository.
This change may increase the code size by a few bytes. An alternative would have been to use an unsigned int instead of enum xz_check but using an enumeration looks cleaner.
--- lib/xz/xz_dec_stream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/xz/xz_dec_stream.c +3 -3
@@ -402,12 +402,12 @@ static enum xz_ret dec_stream_header(struct xz_dec *s)* we will accept other check types too, but then the check won't * be verified and a warning (XZ_UNSUPPORTED_CHECK) will be given. */ +if (s->temp.buf[HEADER_MAGIC_SIZE +1 ] >XZ_CHECK_MAX ) +return XZ_OPTIONS_ERROR ; + s->check_type = s->temp.buf[HEADER_MAGIC_SIZE +1 ];#ifdef XZ_DEC_ANY_CHECK -if (s->check_type >XZ_CHECK_MAX ) -return XZ_OPTIONS_ERROR ; -if (s->check_type >XZ_CHECK_CRC32 )return XZ_UNSUPPORTED_CHECK ;#else
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 289/849 workqueue: make sysfs of unbound kworker cpumask more clever
In reply to Greg Kroah-HartmanFrom: Menglong Dong <[email protected]>
[ Upstream commit d25302e46592c97d29f70ccb1be558df31a9a360 ]
Some unfriendly component, such as dpdk, write the same mask to unbound kworker cpumask again and again. Every time it write to this interface some work is queue to cpu, even though the mask is same with the original mask.
So, fix it by return success and do nothing if the cpumask is equal with the old one.
--- kernel/workqueue.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
kernel/workqueue.c +11 -4
@@ -5340,9 +5340,6 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)int ret = -EINVAL ;cpumask_var_t saved_cpumask; -if (!zalloc_cpumask_var (&saved_cpumask,GFP_KERNEL )) -return -ENOMEM ; -/* * Not excluding isolated cpus on purpose. * If the user wishes to include them, we allow that.
@@ -5350,6 +5347,15 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)cpumask_and (cpumask, cpumask, cpu_possible_mask);if (!cpumask_empty (cpumask)) {apply_wqattrs_lock (); +if (cpumask_equal (cpumask, wq_unbound_cpumask)) { + ret =0 ; + goto out_unlock; + } + +if (!zalloc_cpumask_var (&saved_cpumask,GFP_KERNEL )) { + ret = -ENOMEM ; + goto out_unlock; + }/* save the old wq_unbound_cpumask. */ cpumask_copy (saved_cpumask, wq_unbound_cpumask);
@@ -5362,10 +5368,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)if (ret <0 )cpumask_copy (wq_unbound_cpumask, saved_cpumask); +free_cpumask_var (saved_cpumask); +out_unlock:apply_wqattrs_unlock (); } -free_cpumask_var (saved_cpumask);return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 290/849 tracing/cfi: Fix cmp_entries_* functions signature mismatch
In reply to Greg Kroah-HartmanFrom: Kalesh Singh <[email protected]>
[ Upstream commit 7ce1bb83a14019f8c396d57ec704d19478747716 ]
If CONFIG_CFI_CLANG=y, attempting to read an event histogram will cause the kernel to panic due to failed CFI check.
1. echo 'hist:keys=common_pid' >> events/sched/sched_switch/trigger
2. cat events/sched/sched_switch/hist
3. kernel panics on attempting to read hist
This happens because the sort() function expects a generic int (*)(const void *, const void *) pointer for the compare function. To prevent this CFI failure, change tracing map cmp_entries_* function signatures to match this.
Also, fix the build error reported by the kernel test robot [1].
[1] https://lore.kernel.org/r/[email protected]/
--- kernel/trace/tracing_map.c | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-)
kernel/trace/tracing_map.c +23 -17
@@ -834,29 +834,35 @@ int tracing_map_init(struct tracing_map *map)return err; } -static int cmp_entries_dup (const struct tracing_map_sort_entry **a, -const struct tracing_map_sort_entry **b) +static int cmp_entries_dup (const void *A ,const void *B ) { +const struct tracing_map_sort_entry *a, *b;int ret =0 ; -if (memcmp ((*a)->key, (*b)->key, (*a)->elt->map->key_size)) + a = *(const struct tracing_map_sort_entry **)A ; + b = *(const struct tracing_map_sort_entry **)B ; + +if (memcmp (a->key, b->key, a->elt->map->key_size)) ret =1 ;return ret; } -static int cmp_entries_sum (const struct tracing_map_sort_entry **a, -const struct tracing_map_sort_entry **b) +static int cmp_entries_sum (const void *A ,const void *B ) {const struct tracing_map_elt *elt_a, *elt_b; +const struct tracing_map_sort_entry *a, *b;struct tracing_map_sort_key *sort_key;struct tracing_map_field *field;tracing_map_cmp_fn_t cmp_fn;void *val_a, *val_b;int ret =0 ; - elt_a = (*a)->elt; - elt_b = (*b)->elt; + a = *(const struct tracing_map_sort_entry **)A ; + b = *(const struct tracing_map_sort_entry **)B ; + + elt_a = a->elt; + elt_b = b->elt; sort_key = &elt_a->map->sort_key;
@@ -873,18 +879,21 @@ static int cmp_entries_sum(const struct tracing_map_sort_entry **a,return ret; } -static int cmp_entries_key (const struct tracing_map_sort_entry **a, -const struct tracing_map_sort_entry **b) +static int cmp_entries_key (const void *A ,const void *B ) {const struct tracing_map_elt *elt_a, *elt_b; +const struct tracing_map_sort_entry *a, *b;struct tracing_map_sort_key *sort_key;struct tracing_map_field *field;tracing_map_cmp_fn_t cmp_fn;void *val_a, *val_b;int ret =0 ; - elt_a = (*a)->elt; - elt_b = (*b)->elt; + a = *(const struct tracing_map_sort_entry **)A ; + b = *(const struct tracing_map_sort_entry **)B ; + + elt_a = a->elt; + elt_b = b->elt; sort_key = &elt_a->map->sort_key;
@@ -989,10 +998,8 @@ static void sort_secondary(struct tracing_map *map, struct tracing_map_sort_key *primary_key, struct tracing_map_sort_key *secondary_key) { -int (*primary_fn)(const struct tracing_map_sort_entry **, -const struct tracing_map_sort_entry **); -int (*secondary_fn)(const struct tracing_map_sort_entry **, -const struct tracing_map_sort_entry **); +int (*primary_fn)(const void *,const void *); +int (*secondary_fn)(const void *,const void *);unsigned i, start =0 , n_sub =1 ;if (is_key (map, primary_key->field_idx))
@@ -1061,8 +1068,7 @@ int tracing_map_sort_entries(struct tracing_map *map, unsigned int n_sort_keys, struct tracing_map_sort_entry ***sort_entries) { -int (*cmp_entries_fn)(const struct tracing_map_sort_entry **, -const struct tracing_map_sort_entry **); +int (*cmp_entries_fn)(const void *,const void *);struct tracing_map_sort_entry *sort_entry, **entries;int i, n_entries, ret;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 291/849 mt76: mt7915: fix an off-by-one bound check
In reply to Greg Kroah-HartmanFrom: Ryder Lee <[email protected]>
[ Upstream commit d45dac0732a287fc371a23f257cce04e65627947 ]
The bounds check on datalen is off-by-one, so fix it.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -925,7 +925,7 @@ static void mt7915_check_he_obss_narrow_bw_ru_iter(struct wiphy *wiphy, elem =ieee80211_bss_get_elem (bss,WLAN_EID_EXT_CAPABILITY ); -if (!elem || elem->datalen <10 || +if (!elem || elem->datalen <=10 || !(elem->data[10 ] &WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT )) data->tolerated = false;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 292/849 mwl8k: Fix use-after-free in mwl8k_fw_state_machine()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 257051a235c17e33782b6e24a4b17f2d7915aaec ]
When the driver fails to request the firmware, it calls its error handler. In the error handler, the driver detaches device from driver first before releasing the firmware, which can cause a use-after-free bug.
Fix this by releasing firmware first.
The following log reveals it:
[ 9.007301 ] BUG: KASAN: use-after-free in mwl8k_fw_state_machine+0x320/0xba0 [ 9.010143 ] Workqueue: events request_firmware_work_func [ 9.010830 ] Call Trace: [ 9.010830 ] dump_stack_lvl+0xa8/0xd1 [ 9.010830 ] print_address_description+0x87/0x3b0 [ 9.010830 ] kasan_report+0x172/0x1c0 [ 9.010830 ] ? mutex_unlock+0xd/0x10 [ 9.010830 ] ? mwl8k_fw_state_machine+0x320/0xba0 [ 9.010830 ] ? mwl8k_fw_state_machine+0x320/0xba0 [ 9.010830 ] __asan_report_load8_noabort+0x14/0x20 [ 9.010830 ] mwl8k_fw_state_machine+0x320/0xba0 [ 9.010830 ] ? mwl8k_load_firmware+0x5f0/0x5f0 [ 9.010830 ] request_firmware_work_func+0x172/0x250 [ 9.010830 ] ? read_lock_is_recursive+0x20/0x20 [ 9.010830 ] ? process_one_work+0x7a1/0x1100 [ 9.010830 ] ? request_firmware_nowait+0x460/0x460 [ 9.010830 ] ? __this_cpu_preempt_check+0x13/0x20 [ 9.010830 ] process_one_work+0x9bb/0x1100
--- drivers/net/wireless/marvell/mwl8k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/marvell/mwl8k.c +1 -1
@@ -5800,8 +5800,8 @@ static void mwl8k_fw_state_machine(const struct firmware *fw, void *context) fail: priv->fw_state =FW_STATE_ERROR ;complete (&priv->firmware_loading_complete); -device_release_driver (&priv->pdev->dev);mwl8k_release_firmware (priv); +device_release_driver (&priv->pdev->dev); }#define MAX_RESTART_ATTEMPTS 1
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 293/849 iwlwifi: change all JnP to NO-160 configuration
In reply to Greg Kroah-HartmanFrom: Yaara Baruch <[email protected]>
[ Upstream commit 70382b0897eeecfcd35ba5f6161dbceeb556ea1e ]
JnP should not have the 160 MHz.
--- drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +3 -3
@@ -931,9 +931,9 @@ static const struct iwl_dev_info iwl_dev_info_table[] = { IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_NO_CDB, iwl_qu_b0_hr1_b0, iwl_ax101_name),_IWL_DEV_INFO (IWL_CFG_ANY ,IWL_CFG_ANY , -IWL_CFG_MAC_TYPE_QU ,SILICON_C_STEP , +IWL_CFG_MAC_TYPE_QU ,SILICON_B_STEP ,IWL_CFG_RF_TYPE_HR2 ,IWL_CFG_ANY , -IWL_CFG_ANY ,IWL_CFG_ANY ,IWL_CFG_NO_CDB , +IWL_CFG_NO_160 ,IWL_CFG_ANY ,IWL_CFG_NO_CDB , iwl_qu_b0_hr_b0, iwl_ax203_name),/* Qu C step */
@@ -945,7 +945,7 @@ static const struct iwl_dev_info iwl_dev_info_table[] = {_IWL_DEV_INFO (IWL_CFG_ANY ,IWL_CFG_ANY ,IWL_CFG_MAC_TYPE_QU ,SILICON_C_STEP ,IWL_CFG_RF_TYPE_HR2 ,IWL_CFG_ANY , -IWL_CFG_ANY ,IWL_CFG_ANY ,IWL_CFG_NO_CDB , +IWL_CFG_NO_160 ,IWL_CFG_ANY ,IWL_CFG_NO_CDB , iwl_qu_c0_hr_b0, iwl_ax203_name),/* QuZ */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 294/849 block: remove inaccurate requeue check
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit 037057a5a979c7eeb2ee5d12cf4c24b805192c75 ]
This check is meant to catch cases where a requeue is attempted on a request that is still inserted. It's never really been useful to catch any misuse, and now it's actively wrong. Outside of that, this should not be a BUG_ON() to begin with.
Remove the check as it's now causing active harm, as requeue off the plug path will trigger it even though the request state is just fine.
--- block/blk-mq.c | 1 - 1 file changed, 1 deletion(-)
block/blk-mq.c +0 -1
@@ -756,7 +756,6 @@ void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list)/* this request will be re-inserted to io scheduler queue */ blk_mq_sched_requeue_request (rq); -BUG_ON (!list_empty (&rq->queuelist));blk_mq_add_to_requeue_list (rq, true, kick_requeue_list); }EXPORT_SYMBOL (blk_mq_requeue_request);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 295/849 media: allegro: ignore interrupt if mailbox is not initialized
In reply to Greg Kroah-HartmanFrom: Michael Tretter <[email protected]>
[ Upstream commit 1ecda6393db4be44aba27a243e648dc98c9b92e3 ]
The mailbox is initialized after the interrupt handler is installed. As the firmware is loaded and started even later, it should not happen that the interrupt occurs without the mailbox being initialized.
As the Linux Driver Verification project (linuxtesting.org) keeps reporting this as an error, add a check to ignore interrupts before the mailbox is initialized to fix this potential null pointer dereference.
--- drivers/media/platform/allegro-dvt/allegro-core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/platform/allegro-dvt/allegro-core.c +9 -0
@@ -2185,6 +2185,15 @@ static irqreturn_t allegro_irq_thread(int irq, void *data) {struct allegro_dev *dev = data; +/* +* The firmware is initialized after the mailbox is setup. We further +* check the AL5_ITC_CPU_IRQ_STA register, if the firmware actually +* triggered the interrupt. Although this should not happen, make sure +* that we ignore interrupts, if the mailbox is not initialized. +*/ +if (!dev->mbox_status) +return IRQ_NONE ; +allegro_mbox_notify (dev->mbox_status);return IRQ_HANDLED ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 296/849 drm/amdgpu/pm: properly handle sclk for profiling modes on vangogh
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
[ Upstream commit 68e3871dcd6e547f6c47454492bc452356cb9eac ]
When selecting between levels in the force performance levels interface sclk (gfxclk) was not set correctly for all levels. Select the proper sclk settings for all levels.
--- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 89 ++++++------------- 1 file changed, 29 insertions(+), 60 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +29 -60
@@ -1382,52 +1382,38 @@ static int vangogh_set_performance_level(struct smu_context *smu,uint32_t soc_mask, mclk_mask, fclk_mask;uint32_t vclk_mask =0 , dclk_mask =0 ; + smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; + smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; +switch (level) {case AMD_DPM_FORCED_LEVEL_HIGH : - smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; + smu->gfx_actual_hard_min_freq = smu->gfx_default_soft_max_freq; smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq; - smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; - smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; ret =vangogh_force_dpm_limit_value (smu, true); +if (ret) +return ret;break ;case AMD_DPM_FORCED_LEVEL_LOW : smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; - smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq; - - smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; - smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; + smu->gfx_actual_soft_max_freq = smu->gfx_default_hard_min_freq; ret =vangogh_force_dpm_limit_value (smu, false); +if (ret) +return ret;break ;case AMD_DPM_FORCED_LEVEL_AUTO : smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq; - smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; - smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; - ret =vangogh_unforce_dpm_levels (smu); -break ; -case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD : - smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; - smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq; - - smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; - smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; - - ret =smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_SetHardMinGfxClk, -VANGOGH_UMD_PSTATE_STANDARD_GFXCLK ,NULL ); -if (ret) -return ret; - - ret =smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_SetSoftMaxGfxClk, -VANGOGH_UMD_PSTATE_STANDARD_GFXCLK ,NULL );if (ret)return ret; +break ; +case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD : + smu->gfx_actual_hard_min_freq =VANGOGH_UMD_PSTATE_STANDARD_GFXCLK ; + smu->gfx_actual_soft_max_freq =VANGOGH_UMD_PSTATE_STANDARD_GFXCLK ; ret = vangogh_get_profiling_clk_mask(smu, level, &vclk_mask,
@@ -1442,32 +1428,15 @@ static int vangogh_set_performance_level(struct smu_context *smu,vangogh_force_clk_levels (smu,SMU_SOCCLK ,1 << soc_mask);vangogh_force_clk_levels (smu,SMU_VCLK ,1 << vclk_mask);vangogh_force_clk_levels (smu,SMU_DCLK ,1 << dclk_mask); -break ;case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK : smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; - smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq; - - smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; - smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; - - ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetHardMinVcn, -VANGOGH_UMD_PSTATE_PEAK_DCLK ,NULL ); -if (ret) -return ret; - - ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetSoftMaxVcn, -VANGOGH_UMD_PSTATE_PEAK_DCLK ,NULL ); -if (ret) -return ret; + smu->gfx_actual_soft_max_freq = smu->gfx_default_hard_min_freq;break ;case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK : smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq; - smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; - smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; - ret = vangogh_get_profiling_clk_mask(smu, level, NULL, NULL,
@@ -1480,29 +1449,29 @@ static int vangogh_set_performance_level(struct smu_context *smu,vangogh_force_clk_levels (smu,SMU_FCLK ,1 << fclk_mask);break ;case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK : - smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; - smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq; - - smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; - smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq; - - ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetHardMinGfxClk, -VANGOGH_UMD_PSTATE_PEAK_GFXCLK ,NULL ); -if (ret) -return ret; + smu->gfx_actual_hard_min_freq =VANGOGH_UMD_PSTATE_PEAK_GFXCLK ; + smu->gfx_actual_soft_max_freq =VANGOGH_UMD_PSTATE_PEAK_GFXCLK ; - ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetSoftMaxGfxClk, -VANGOGH_UMD_PSTATE_PEAK_GFXCLK ,NULL ); + ret =vangogh_set_peak_clock_by_device (smu);if (ret)return ret; - - ret =vangogh_set_peak_clock_by_device (smu);break ;case AMD_DPM_FORCED_LEVEL_MANUAL :case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT :default : -break ; +return 0 ; } + + ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetHardMinGfxClk, + smu->gfx_actual_hard_min_freq,NULL ); +if (ret) +return ret; + + ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetSoftMaxGfxClk, + smu->gfx_actual_soft_max_freq,NULL ); +if (ret) +return ret; +return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 297/849 nvmet: fix use-after-free when a port is removed
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit e3e19dcc4c416d65f99f13d55be2b787f8d0050e ]
When a port is removed through configfs, any connected controllers are starting teardown flow asynchronously and can still send commands. This causes a use-after-free bug for any command that dereferences req->port (like in nvmet_parse_io_cmd).
To fix this, wait for all the teardown scheduled works to complete (like release_work at rdma/tcp drivers). This ensures there are no active controllers when the port is eventually removed.
--- drivers/nvme/target/configfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/target/configfs.c +2 -0
@@ -1553,6 +1553,8 @@ static void nvmet_port_release(struct config_item *item) {struct nvmet_port *port =to_nvmet_port (item); +/* Let inflight controllers teardown complete */ +flush_scheduled_work ();list_del (&port->global_entry);kfree (port->ana_state);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 298/849 nvmet-rdma: fix use-after-free when a port is removed
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit fcf73a804c7d6bbf0ea63531c6122aa363852e04 ]
When removing a port, all its controllers are being removed, but there are queues on the port that doesn't belong to any controller (during connection time). This causes a use-after-free bug for any command that dereferences req->port (like in nvmet_alloc_ctrl). Those queues should be destroyed before freeing the port via configfs. Destroy the remaining queues after the RDMA-CM was destroyed guarantees that no new queue will be created.
--- drivers/nvme/target/rdma.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/nvme/target/rdma.c +24 -0
@@ -1818,12 +1818,36 @@ restart:mutex_unlock (&nvmet_rdma_queue_mutex); } +static void nvmet_rdma_destroy_port_queues (struct nvmet_rdma_port *port) +{ +struct nvmet_rdma_queue *queue, *tmp; +struct nvmet_port *nport = port->nport; + +mutex_lock (&nvmet_rdma_queue_mutex); +list_for_each_entry_safe (queue, tmp, &nvmet_rdma_queue_list, + queue_list) { +if (queue->port != nport) +continue ; + +list_del_init (&queue->queue_list); +__nvmet_rdma_queue_disconnect (queue); + } +mutex_unlock (&nvmet_rdma_queue_mutex); +} +static void nvmet_rdma_disable_port (struct nvmet_rdma_port *port) {struct rdma_cm_id *cm_id =xchg (&port->cm_id,NULL );if (cm_id)rdma_destroy_id (cm_id); + +/* +* Destroy the remaining queues, which are not belong to any +* controller yet. Do it here after the RDMA-CM was destroyed +* guarantees that no new queue will be created. +*/ +nvmet_rdma_destroy_port_queues (port); }static int nvmet_rdma_enable_port (struct nvmet_rdma_port *port)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 299/849 nvmet-tcp: fix use-after-free when a port is removed
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit 2351ead99ce9164fb42555aee3f96af84c4839e9 ]
When removing a port, all its controllers are being removed, but there are queues on the port that doesn't belong to any controller (during connection time). This causes a use-after-free bug for any command that dereferences req->port (like in nvmet_alloc_ctrl). Those queues should be destroyed before freeing the port via configfs. Destroy the remaining queues after the accept_work was cancelled guarantees that no new queue will be created.
--- drivers/nvme/target/tcp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/nvme/target/tcp.c +16 -0
@@ -1740,6 +1740,17 @@ err_port:return ret; } +static void nvmet_tcp_destroy_port_queues (struct nvmet_tcp_port *port) +{ +struct nvmet_tcp_queue *queue; + +mutex_lock (&nvmet_tcp_queue_mutex); +list_for_each_entry (queue, &nvmet_tcp_queue_list, queue_list) +if (queue->port == port) +kernel_sock_shutdown (queue->sock,SHUT_RDWR ); +mutex_unlock (&nvmet_tcp_queue_mutex); +} +static void nvmet_tcp_remove_port (struct nvmet_port *nport) {struct nvmet_tcp_port *port = nport->priv;
@@ -1749,6 +1760,11 @@ static void nvmet_tcp_remove_port(struct nvmet_port *nport) port->sock->sk->sk_user_data =NULL ;write_unlock_bh (&port->sock->sk->sk_callback_lock);cancel_work_sync (&port->accept_work); +/* +* Destroy the remaining queues, which are not belong to any +* controller yet. +*/ +nvmet_tcp_destroy_port_queues (port);sock_release (port->sock);kfree (port);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 300/849 nvme: drop scan_lock and always kick requeue list when removing namespaces
In reply to Greg Kroah-HartmanFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 2b81a5f015199f3d585ce710190a9e87714d3c1e ]
When reading the partition table on initial scan hits an I/O error the I/O will hang with the scan_mutex held:
[<0>] do_read_cache_page+0x49b/0x790 [<0>] read_part_sector+0x39/0xe0 [<0>] read_lba+0xf9/0x1d0 [<0>] efi_partition+0xf1/0x7f0 [<0>] bdev_disk_changed+0x1ee/0x550 [<0>] blkdev_get_whole+0x81/0x90 [<0>] blkdev_get_by_dev+0x128/0x2e0 [<0>] device_add_disk+0x377/0x3c0 [<0>] nvme_mpath_set_live+0x130/0x1b0 [nvme_core] [<0>] nvme_mpath_add_disk+0x150/0x160 [nvme_core] [<0>] nvme_alloc_ns+0x417/0x950 [nvme_core] [<0>] nvme_validate_or_alloc_ns+0xe9/0x1e0 [nvme_core] [<0>] nvme_scan_work+0x168/0x310 [nvme_core] [<0>] process_one_work+0x231/0x420
and trying to delete the controller will deadlock as it tries to grab the scan mutex:
[<0>] nvme_mpath_clear_ctrl_paths+0x25/0x80 [nvme_core] [<0>] nvme_remove_namespaces+0x31/0xf0 [nvme_core] [<0>] nvme_do_delete_ctrl+0x4b/0x80 [nvme_core]
As we're now properly ordering the namespace list there is no need to hold the scan_mutex in nvme_mpath_clear_ctrl_paths() anymore. And we always need to kick the requeue list as the path will be marked as unusable and I/O will be requeued _without_ a current path.
--- drivers/nvme/host/multipath.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/nvme/host/multipath.c +4 -5
@@ -138,13 +138,12 @@ void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl) {struct nvme_ns *ns; -mutex_lock (&ctrl->scan_lock);down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) -if (nvme_mpath_clear_current_path (ns)) -kblockd_schedule_work (&ns->head->requeue_work); +list_for_each_entry (ns, &ctrl->namespaces, list) { +nvme_mpath_clear_current_path (ns); +kblockd_schedule_work (&ns->head->requeue_work); + }up_read (&ctrl->namespaces_rwsem); -mutex_unlock (&ctrl->scan_lock); }static bool nvme_path_is_disabled (struct nvme_ns *ns)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 301/849 arm64: vdso32: suppress error message for make mrproper
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
[ Upstream commit 14831fad73f5ac30ac61760487d95a538e6ab3cb ]
When running the following command without arm-linux-gnueabi-gcc in one's $PATH, the following warning is observed:
$ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make -j72 LLVM=1 mrproper make[1]: arm-linux-gnueabi-gcc: No such file or directory
This is because KCONFIG is not run for mrproper, so CONFIG_CC_IS_CLANG is not set, and we end up eagerly evaluating various variables that try to invoke CC_COMPAT.
This is a similar problem to what was observed in
commit dc960bfeedb0 ("h8300: suppress error messages for 'make clean'")
--- arch/arm64/kernel/vdso32/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/kernel/vdso32/Makefile +2 -1
@@ -40,7 +40,8 @@ cc32-as-instr = $(call try-run,\ # As a result we set our own flags here. # KBUILD_CPPFLAGS and NOSTDINC_FLAGS from top-level Makefile -VDSO_CPPFLAGS := -DBUILD_VDSO -D__KERNEL__ -nostdinc -isystem $(shell $(CC_COMPAT) -print-file-name=include) +VDSO_CPPFLAGS := -DBUILD_VDSO -D__KERNEL__ -nostdinc +VDSO_CPPFLAGS += -isystem $(shell $(CC_COMPAT) -print-file-name=include 2>/dev/null) VDSO_CPPFLAGS += $(LINUXINCLUDE) # Common C and assembly flags
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 302/849 PM: hibernate: Get block device exclusively in swsusp_check()
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
[ Upstream commit 39fbef4b0f77f9c89c8f014749ca533643a37c9f ]
The following kernel crash can be triggered:
[ 89.266592] ------------[ cut here ]------------ [ 89.267427] kernel BUG at fs/buffer.c:3020! [ 89.268264] invalid opcode: 0000 [#1] SMP KASAN PTI [ 89.269116] CPU: 7 PID: 1750 Comm: kmmpd-loop0 Not tainted 5.10.0-862.14.0.6.x86_64-08610-gc932cda3cef4-dirty #20 [ 89.273169] RIP: 0010:submit_bh_wbc.isra.0+0x538/0x6d0 [ 89.277157] RSP: 0018:ffff888105ddfd08 EFLAGS: 00010246 [ 89.278093] RAX: 0000000000000005 RBX: ffff888124231498 RCX: ffffffffb2772612 [ 89.279332] RDX: 1ffff11024846293 RSI: 0000000000000008 RDI: ffff888124231498 [ 89.280591] RBP: ffff8881248cc000 R08: 0000000000000001 R09: ffffed1024846294 [ 89.281851] R10: ffff88812423149f R11: ffffed1024846293 R12: 0000000000003800 [ 89.283095] R13: 0000000000000001 R14: 0000000000000000 R15: ffff8881161f7000 [ 89.284342] FS: 0000000000000000(0000) GS:ffff88839b5c0000(0000) knlGS:0000000000000000 [ 89.285711] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 89.286701] CR2: 00007f166ebc01a0 CR3: 0000000435c0e000 CR4: 00000000000006e0 [ 89.287919] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 89.289138] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 89.290368] Call Trace: [ 89.290842] write_mmp_block+0x2ca/0x510 [ 89.292218] kmmpd+0x433/0x9a0 [ 89.294902] kthread+0x2dd/0x3e0 [ 89.296268] ret_from_fork+0x22/0x30 [ 89.296906] Modules linked in:
by running the following commands:
1. mkfs.ext4 -O mmp /dev/sda -b 1024
2. mount /dev/sda /home/test
3. echo "/dev/sda" > /sys/power/resume
That happens because swsusp_check() calls set_blocksize() on the target partition which confuses the file system:
Thread1 Thread2
mount /dev/sda /home/test
get s_mmp_bh --> has mapped flag
start kmmpd thread
echo "/dev/sda" > /sys/power/resume
resume_store
software_resume
swsusp_check
set_blocksize
truncate_inode_pages_range
truncate_cleanup_page
block_invalidatepage
discard_buffer --> clean mapped flag
write_mmp_block
submit_bh
submit_bh_wbc
BUG_ON(!buffer_mapped(bh))To address this issue, modify swsusp_check() to open the target block device with exclusive access.
--- kernel/power/swap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/power/swap.c +3 -2
@@ -1521,9 +1521,10 @@ end:int swsusp_check (void ) {int error; +void *holder; hib_resume_bdev =blkdev_get_by_dev (swsusp_resume_device, -FMODE_READ ,NULL ); +FMODE_READ |FMODE_EXCL , &holder);if (!IS_ERR (hib_resume_bdev)) {set_blocksize (hib_resume_bdev,PAGE_SIZE );clear_page (swsusp_header);
@@ -1545,7 +1546,7 @@ int swsusp_check(void) put:if (error) -blkdev_put (hib_resume_bdev,FMODE_READ ); +blkdev_put (hib_resume_bdev,FMODE_READ |FMODE_EXCL );else pr_debug ("Image signature found, resuming\n" ); }else {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 303/849 selftests: kvm: fix mismatched fclose() after popen()
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit c3867ab5924b7a9a0b4a117902a08669d8be7c21 ]
get_warnings_count() does fclose() using File * returned from popen(). Fix it to call pclose() as it should.
tools/testing/selftests/kvm/x86_64/mmio_warning_testx86_64/mmio_warning_test.c: In function ‘get_warnings_count’:x86_64/mmio_warning_test.c:87:9: warning: ‘fclose’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
87 | fclose(f);
| ^~~~~~~~~
x86_64/mmio_warning_test.c:84:13: note: returned from ‘popen’
84 | f = popen("dmesg | grep \"WARNING:\" | wc -l", "r");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- tools/testing/selftests/kvm/x86_64/mmio_warning_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/x86_64/mmio_warning_test.c +1 -1
@@ -84,7 +84,7 @@ int get_warnings_count(void) f =popen ("dmesg | grep \"WARNING:\" | wc -l" ,"r" );if (fscanf (f,"%d" , &warnings) <1 ) warnings =0 ; -fclose (f); +pclose (f);return warnings; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 304/849 selftests/bpf: Fix perf_buffer test on system with offline cpus
In reply to Greg Kroah-HartmanFrom: Jiri Olsa <[email protected]>
[ Upstream commit d4121376ac7a9c81a696d7558789b2f29ef3574e ]
The perf_buffer fails on system with offline cpus:
# test_progs -t perf_buffer test_perf_buffer:PASS:nr_cpus 0 nsec test_perf_buffer:PASS:nr_on_cpus 0 nsec test_perf_buffer:PASS:skel_load 0 nsec test_perf_buffer:PASS:attach_kprobe 0 nsec test_perf_buffer:PASS:perf_buf__new 0 nsec test_perf_buffer:PASS:epoll_fd 0 nsec skipping offline CPU #24 skipping offline CPU #25 skipping offline CPU #26 skipping offline CPU #27 skipping offline CPU #28 skipping offline CPU #29 skipping offline CPU #30 skipping offline CPU #31 test_perf_buffer:PASS:perf_buffer__poll 0 nsec test_perf_buffer:PASS:seen_cpu_cnt 0 nsec test_perf_buffer:FAIL:buf_cnt got 24, expected 32 Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
Changing the test to check online cpus instead of possible.
--- tools/testing/selftests/bpf/prog_tests/perf_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/perf_buffer.c +2 -2
@@ -107,8 +107,8 @@ void test_perf_buffer(void) "expect %d, seen %d\n", nr_on_cpus, CPU_COUNT(&cpu_seen))) goto out_free_pb; -if (CHECK (perf_buffer__buffer_cnt (pb) != nr_cpus,"buf_cnt" , -"got %zu, expected %d\n" ,perf_buffer__buffer_cnt (pb), nr_cpus)) +if (CHECK (perf_buffer__buffer_cnt (pb) != nr_on_cpus,"buf_cnt" , +"got %zu, expected %d\n" ,perf_buffer__buffer_cnt (pb), nr_on_cpus)) goto out_close;for (i =0 ; i < nr_cpus; i++) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 305/849 iwlwifi: mvm: disable RX-diversity in powersave
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit e5322b9ab5f63536c41301150b7ce64605ce52cc ]
Just like we have default SMPS mode as dynamic in powersave, we should not enable RX-diversity in powersave, to reduce power consumption when connected to a non-MIMO AP.
--- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +3 -0
@@ -405,6 +405,9 @@ bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm,lockdep_assert_held (&mvm->mutex); +if (iwlmvm_mod_params.power_scheme !=IWL_POWER_SCHEME_CAM ) +return false; +if (num_of_ant (iwl_mvm_get_valid_rx_ant (mvm)) ==1 )return false;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 306/849 smackfs: use __GFP_NOFAIL for smk_cipso_doi()
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit f91488ee15bd3cac467e2d6a361fc2d34d1052ae ]
syzbot is reporting kernel panic at smk_cipso_doi() due to memory allocation fault injection [1]. The reason for need to use panic() was not explained. But since no fix was proposed for 18 months, for now let's use __GFP_NOFAIL for utilizing syzbot resource on other bugs.
--- security/smack/smackfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
security/smack/smackfs.c +1 -3
@@ -693,9 +693,7 @@ static void smk_cipso_doi(void)printk (KERN_WARNING "%s:%d remove rc = %d\n" , __func__, __LINE__, rc); - doip =kmalloc (sizeof (struct cipso_v4_doi ),GFP_KERNEL ); -if (doip ==NULL ) -panic ("smack: Failed to initialize cipso DOI.\n" ); + doip =kmalloc (sizeof (struct cipso_v4_doi ),GFP_KERNEL | __GFP_NOFAIL); doip->map.std =NULL ; doip->doi = smk_cipso_doi_value; doip->type =CIPSO_V4_MAP_PASS ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 307/849 ARM: clang: Do not rely on lr register for stacktrace
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit b3ea5d56f212ad81328c82454829a736197ebccc ]
Currently the stacktrace on clang compiled arm kernel uses the 'lr' register to find the first frame address from pt_regs. However, that is wrong after calling another function, because the 'lr' register is used by 'bl' instruction and never be recovered.
As same as gcc arm kernel, directly use the frame pointer (r11) of the pt_regs to find the first frame address.
Note that this fixes kretprobe stacktrace issue only with CONFIG_UNWINDER_FRAME_POINTER=y. For the CONFIG_UNWINDER_ARM, we need another fix.
--- arch/arm/kernel/stacktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/kernel/stacktrace.c +1 -2
@@ -54,8 +54,7 @@ int notrace unwind_frame(struct stackframe *frame) frame->sp = frame->fp; frame->fp = *(unsigned long *)(fp); - frame->pc = frame->lr; - frame->lr = *(unsigned long *)(fp +4 ); + frame->pc = *(unsigned long *)(fp +4 );#else /* check current frame pointer is within bounds */ if (fp < low +12 || fp > high -4 )
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 308/849 gre/sit: Dont generate link-local addr if addr_gen_mode is IN6_ADDR_GEN_MODE_NONE
In reply to Greg Kroah-HartmanFrom: Stephen Suryaputra <[email protected]>
[ Upstream commit 61e18ce7348bfefb5688a8bcd4b4d6b37c0f9b2a ]
When addr_gen_mode is set to IN6_ADDR_GEN_MODE_NONE, the link-local addr should not be generated. But it isn't the case for GRE (as well as GRE6) and SIT tunnels. Make it so that tunnels consider the addr_gen_mode, especially for IN6_ADDR_GEN_MODE_NONE.
Do this in add_v4_addrs() to cover both GRE and SIT only if the addr scope is link.
--- net/ipv6/addrconf.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/addrconf.c +3 -0
@@ -3100,6 +3100,9 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)memcpy (&addr.s6_addr32[3 ], idev->dev->dev_addr,4 );if (idev->dev->flags&IFF_POINTOPOINT ) { +if (idev->cnf.addr_gen_mode ==IN6_ADDR_GEN_MODE_NONE ) +return ; + addr.s6_addr32[0 ] =htonl (0xfe800000 ); scope =IFA_LINK ; plen =64 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 309/849 net: dsa: lantiq_gswip: serialize access to the PCE table
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 49753a75b9a32de4c0393bb8d1e51ea223fda8e4 ]
Looking at the code, the GSWIP switch appears to hold bridging service structures (VLANs, FDBs, forwarding rules) in PCE table entries. Hardware access to the PCE table is non-atomic, and is comprised of several register reads and writes.
These accesses are currently serialized by the rtnl_lock, but DSA is changing its driver API and that lock will no longer be held when calling ->port_fdb_add() and ->port_fdb_del().
So this driver needs to serialize the access to the PCE table using its own locking scheme. This patch adds that.
--- drivers/net/dsa/lantiq_gswip.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
drivers/net/dsa/lantiq_gswip.c +23 -5
@@ -276,6 +276,7 @@ struct gswip_priv {int num_gphy_fw;struct gswip_gphy_fw *gphy_fw;u32 port_vlan_filter; +struct mutex pce_table_lock; };struct gswip_pce_table_entry {
@@ -523,10 +524,14 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv,u16 addr_mode = tbl->key_mode ?GSWIP_PCE_TBL_CTRL_OPMOD_KSRD :GSWIP_PCE_TBL_CTRL_OPMOD_ADRD ; +mutex_lock (&priv->pce_table_lock); + err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL ,GSWIP_PCE_TBL_CTRL_BAS ); -if (err) +if (err) { +mutex_unlock (&priv->pce_table_lock);return err; + }gswip_switch_w (priv, tbl->index,GSWIP_PCE_TBL_ADDR ); gswip_switch_mask(priv, GSWIP_PCE_TBL_CTRL_ADDR_MASK |
@@ -536,8 +541,10 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv, err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL ,GSWIP_PCE_TBL_CTRL_BAS ); -if (err) +if (err) { +mutex_unlock (&priv->pce_table_lock);return err; + }for (i =0 ; i <ARRAY_SIZE (tbl->key); i++) tbl->key[i] =gswip_switch_r (priv,GSWIP_PCE_TBL_KEY (i));
@@ -553,6 +560,8 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv, tbl->valid = !!(crtl &GSWIP_PCE_TBL_CTRL_VLD ); tbl->gmap = (crtl &GSWIP_PCE_TBL_CTRL_GMAP_MASK ) >>7 ; +mutex_unlock (&priv->pce_table_lock); +return 0 ; }
@@ -565,10 +574,14 @@ static int gswip_pce_table_entry_write(struct gswip_priv *priv,u16 addr_mode = tbl->key_mode ?GSWIP_PCE_TBL_CTRL_OPMOD_KSWR :GSWIP_PCE_TBL_CTRL_OPMOD_ADWR ; +mutex_lock (&priv->pce_table_lock); + err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL ,GSWIP_PCE_TBL_CTRL_BAS ); -if (err) +if (err) { +mutex_unlock (&priv->pce_table_lock);return err; + }gswip_switch_w (priv, tbl->index,GSWIP_PCE_TBL_ADDR ); gswip_switch_mask(priv, GSWIP_PCE_TBL_CTRL_ADDR_MASK |
@@ -600,8 +613,12 @@ static int gswip_pce_table_entry_write(struct gswip_priv *priv, crtl |=GSWIP_PCE_TBL_CTRL_BAS ;gswip_switch_w (priv, crtl,GSWIP_PCE_TBL_CTRL ); -return gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL , -GSWIP_PCE_TBL_CTRL_BAS ); + err =gswip_switch_r_timeout (priv,GSWIP_PCE_TBL_CTRL , +GSWIP_PCE_TBL_CTRL_BAS ); + +mutex_unlock (&priv->pce_table_lock); + +return err; }/* Add the LAN port into a bridge with the CPU port by
@@ -2106,6 +2123,7 @@ static int gswip_probe(struct platform_device *pdev) priv->ds->priv = priv; priv->ds->ops = priv->hw_info->ops; priv->dev = dev; +mutex_init (&priv->pce_table_lock); version =gswip_switch_r (priv,GSWIP_VERSION ); np = dev->of_node;
Signature · 1 line
2.33.0
Re: [PATCH 5.14 309/849] net: dsa: lantiq_gswip: serialize access to the PCE table
Quoted 16 lines · Greg Kroah-Hartman
From: Vladimir Oltean <[email protected]>
[ Upstream commit
49753a75b9a32de4c0393bb8d1e51ea223fda8e4]Looking at the code, the GSWIP switch appears to hold bridging service structures (VLANs, FDBs, forwarding rules) in PCE table entries. Hardware access to the PCE table is non-atomic, and is comprised of several register reads and writes.
These accesses are currently serialized by the
rtnl_lock, but DSA is changing its driver API and that lock will no longer be held when calling ->port_fdb_add() and ->port_fdb_del().So this driver needs to serialize the access to the PCE table using its own locking scheme. This patch adds that.
Quoted 8 lines
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Acked-by Hauke Mehrtens <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/net/dsa/lantiq_gswip.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
Hi Greg and Vladimir,
I understood this is only needed when we apply the complete patch series from Vladimir. This would only be needed when we also apply this patch:
Quoted 5 lines
commit
5cdfde49a07f38663c277ddf2e56345ea1706fc2Author: Vladimir Oltean <[email protected]> Date: Fri Oct 22 21:43:10 2021 +0300net: dsa: drop
rtnl_lockfromdsa_slave_switchdev_event_work
This was added in v5.16-rc1.
Without this patch the sections are protected by rtnl_lock().
Hauke
Re: [PATCH 5.14 309/849] net: dsa: lantiq_gswip: serialize access to the PCE table
Quoted 30 lines · Hauke Mehrtens
Quoted 16 lines · Greg Kroah-Hartman
From: Vladimir Oltean <[email protected]>
[ Upstream commit
49753a75b9a32de4c0393bb8d1e51ea223fda8e4]Looking at the code, the GSWIP switch appears to hold bridging service structures (VLANs, FDBs, forwarding rules) in PCE table entries. Hardware access to the PCE table is non-atomic, and is comprised of several register reads and writes.
These accesses are currently serialized by the
rtnl_lock, but DSA is changing its driver API and that lock will no longer be held when calling ->port_fdb_add() and ->port_fdb_del().So this driver needs to serialize the access to the PCE table using its own locking scheme. This patch adds that.
Quoted 8 lines
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Acked-by Hauke Mehrtens <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/net/dsa/lantiq_gswip.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)Hi Greg and Vladimir,
I understood this is only needed when we apply the complete patch series from Vladimir. This would only be needed when we also apply this patch:
Quoted 8 lines
Quoted 5 lines
commit
5cdfde49a07f38663c277ddf2e56345ea1706fc2Author: Vladimir Oltean <[email protected]> Date: Fri Oct 22 21:43:10 2021 +0300net: dsa: drop
rtnl_lockfromdsa_slave_switchdev_event_workThis was added in v5.16-rc1.
Without this patch the sections are protected by
rtnl_lock().
This is correct, this patch does not need to be backported, and unless it is needed for purposes other than fixing a bug, it should be dropped.
Greg Kroah-Hartman
maintainerPATCH 310/849 can: bittiming: can_fixup_bittiming(): change type of tseg1 and alltseg to unsigned int
In reply to Greg Kroah-HartmanFrom: Marc Kleine-Budde <[email protected]>
[ Upstream commit e346290439609a8ac67122418ca2efbad8d0a7e7 ]
All timing calculation is done with unsigned integers, so change type of tseg1 and alltseg to unsigned int, too.
--- drivers/net/can/dev/bittiming.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/dev/bittiming.c +1 -1
@@ -209,7 +209,7 @@ static int can_fixup_bittiming(struct net_device *dev, struct can_bittiming *bt, const struct can_bittiming_const *btc) {struct can_priv *priv =netdev_priv (dev); -int tseg1, alltseg; +unsigned int tseg1, alltseg;u64 brp64; tseg1 = bt->prop_seg + bt->phase_seg1;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 311/849 gfs2: Cancel remote delete work asynchronously
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 486408d690e130c3adacf816754b97558d715f46 ]
In gfs2_inode_lookup and gfs2_create_inode, we're calling gfs2_cancel_delete_work which currently cancels any remote delete work (delete_work_func) synchronously. This means that if the work is currently running, it will wait for it to finish. We're doing this to pevent a previous instance of an inode from having any influence on the next instance.
However, delete_work_func uses gfs2_inode_lookup internally, and we can end up in a deadlock when delete_work_func gets interrupted at the wrong time. For example,
(1) An inode's iopen glock has delete work queued, but the inode itself has been evicted from the inode cache.
(2) The delete work is preempted before reaching gfs2_inode_lookup.
(3) Another process recreates the inode (gfs2_create_inode). It tries to cancel any outstanding delete work, which blocks waiting for the ongoing delete work to finish.
(4) The delete work calls gfs2_inode_lookup, which blocks waiting for gfs2_create_inode to instantiate and unlock the new inode => deadlock.
It turns out that when the delete work notices that its inode has been re-instantiated, it will do nothing. This means that it's safe to cancel the delete work asynchronously. This prevents the kind of deadlock described above.
--- fs/gfs2/glock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/glock.c +1 -1
@@ -1920,7 +1920,7 @@ bool gfs2_queue_delete_work(struct gfs2_glock *gl, unsigned long delay)void gfs2_cancel_delete_work (struct gfs2_glock *gl) { -if (cancel_delayed_work_sync (&gl->gl_delete)) { +if (cancel_delayed_work (&gl->gl_delete)) {clear_bit (GLF_PENDING_DELETE , &gl->gl_flags);gfs2_glock_put (gl); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 312/849 gfs2: Fix glock_hash_walk bugs
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 7427f3bb49d81525b7dd1d0f7c5f6bbc752e6f0e ]
So far, glock_hash_walk took a reference on each glock it iterated over, and it was the examiner's responsibility to drop those references. Dropping the final reference to a glock can sleep and the examiners are called in a RCU critical section with spin locks held, so examiners that didn't need the extra reference had to drop it asynchronously via gfs2_glock_queue_put or similar. This wasn't done correctly in thaw_glock which did call gfs2_glock_put, and not at all in dump_glock_func.
Change glock_hash_walk to not take glock references at all. That way, the examiners that don't need them won't have to bother with slow asynchronous puts, and the examiners that do need references can take them themselves.
--- fs/gfs2/glock.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
fs/gfs2/glock.c +12 -10
@@ -1894,10 +1894,10 @@ static void glock_hash_walk(glock_examiner examiner, const struct gfs2_sbd *sdp)do {rhashtable_walk_start (&iter); -while ((gl =rhashtable_walk_next (&iter)) && !IS_ERR (gl)) -if (gl->gl_name.ln_sbd == sdp && -lockref_get_not_dead (&gl->gl_lockref)) +while ((gl =rhashtable_walk_next (&iter)) && !IS_ERR (gl)) { +if (gl->gl_name.ln_sbd == sdp)examiner (gl); + }rhashtable_walk_stop (&iter); }while (cond_resched (), gl ==ERR_PTR (-EAGAIN ));
@@ -1939,7 +1939,6 @@ static void flush_delete_work(struct gfs2_glock *gl) &gl->gl_delete, 0); } } -gfs2_glock_queue_work (gl,0 ); }void gfs2_flush_delete_work (struct gfs2_sbd *sdp)
@@ -1956,10 +1955,10 @@ void gfs2_flush_delete_work(struct gfs2_sbd *sdp)static void thaw_glock (struct gfs2_glock *gl) { -if (!test_and_clear_bit (GLF_FROZEN , &gl->gl_flags)) { -gfs2_glock_put (gl); +if (!test_and_clear_bit (GLF_FROZEN , &gl->gl_flags)) +return ; +if (!lockref_get_not_dead (&gl->gl_lockref))return ; - }set_bit (GLF_REPLY_PENDING , &gl->gl_flags);gfs2_glock_queue_work (gl,0 ); }
@@ -1975,9 +1974,12 @@ static void clear_glock(struct gfs2_glock *gl)gfs2_glock_remove_from_lru (gl);spin_lock (&gl->gl_lockref.lock); -if (gl->gl_state !=LM_ST_UNLOCKED ) -handle_callback (gl,LM_ST_UNLOCKED ,0 , false); -__gfs2_glock_queue_work (gl,0 ); +if (!__lockref_is_dead (&gl->gl_lockref)) { + gl->gl_lockref.count++; +if (gl->gl_state !=LM_ST_UNLOCKED ) +handle_callback (gl,LM_ST_UNLOCKED ,0 , false); +__gfs2_glock_queue_work (gl,0 ); + }spin_unlock (&gl->gl_lockref.lock); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 313/849 ARM: 9136/1: ARMv7-M uses BE-8, not BE-32
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 345dac33f58894a56d17b92a41be10e16585ceff ]
When configuring the kernel for big-endian, we set either BE-8 or BE-32 based on the CPU architecture level. Until linux-4.4, we did not have any ARMv7-M platform allowing big-endian builds, but now i.MX/Vybrid is in that category, adn we get a build error because of this:
arch/arm/kernel/module-plts.c: In function 'get_module_plt':arch/arm/kernel/module-plts.c:60:46: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]
This comes down to picking the wrong default, ARMv7-M uses BE8 like ARMv7-A does. Changing the default gets the kernel to compile and presumably works.
https://lore.kernel.org/all/[email protected]/
--- arch/arm/mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mm/Kconfig +1 -1
@@ -750,7 +750,7 @@ config CPU_BIG_ENDIAN config CPU_ENDIAN_BE8 bool depends on CPU_BIG_ENDIAN - default CPU_V6 || CPU_V6K || CPU_V7 + default CPU_V6 || CPU_V6K || CPU_V7 || CPU_V7M help Support for the BE-8 (big-endian) mode on ARMv6 and ARMv7 processors.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 314/849 tools/latency-collector: Use correct size when writing queue_full_warning
In reply to Greg Kroah-HartmanFrom: Viktor Rosendahl <[email protected]>
[ Upstream commit f604de20c0a47e0e9518940a1810193678c92fa8 ]
queue_full_warning is a pointer, so it is wrong to use sizeof to calculate the number of characters of the string it points to. The effect is that we only print out the first few characters of the warning string.
The correct way is to use strlen(). We don't need to add 1 to the strlen() because we don't want to write the terminating null character to stdout.
--- tools/tracing/latency/latency-collector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/latency/latency-collector.c +1 -1
@@ -1538,7 +1538,7 @@ static void tracing_loop(void)mutex_lock (&print_mtx);check_signals ();write_or_die (fd_stdout, queue_full_warning, -sizeof (queue_full_warning)); +strlen (queue_full_warning));mutex_unlock (&print_mtx); } modified--;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 315/849 vrf: run conntrack only in context of lower/physdev for locally generated packets
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 8c9c296adfae9ea05f655d69e9f6e13daa86fb4a ]
The VRF driver invokes netfilter for output+postrouting hooks so that users can create rules that check for 'oif $vrf' rather than lower device name.
This is a problem when NAT rules are configured.
To avoid any conntrack involvement in round 1, tag skbs as 'untracked' to prevent conntrack from picking them up.
This gets cleared before the packet gets handed to the ip stack so conntrack will be active on the second iteration.
One remaining issue is that a rule like
output ... oif $vrfname notrack
won't propagate to the second round because we can't tell 'notrack set via ruleset' and 'notrack set by vrf driver' apart. However, this isn't a regression: the 'notrack' removal happens instead of unconditional nf_reset_ct().
I'd also like to avoid leaking more vrf specific conditionals into the netfilter infra.
For ingress, conntrack has already been done before the packet makes it to the vrf driver, with this patch egress does connection tracking with lower/physical device as well.
--- drivers/net/vrf.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/net/vrf.c +24 -4
@@ -35,6 +35,7 @@#include <net/l3mdev.h> #include <net/fib_rules.h> #include <net/netns/generic.h> +#include <net/netfilter/nf_conntrack.h> #define DRV_NAME "vrf"#define DRV_VERSION "1.1"
@@ -424,12 +425,26 @@ static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev,return NETDEV_TX_OK ; } +static void vrf_nf_set_untracked (struct sk_buff *skb) +{ +if (skb_get_nfct (skb) ==0 ) +nf_ct_set (skb,NULL ,IP_CT_UNTRACKED ); +} + +static void vrf_nf_reset_ct (struct sk_buff *skb) +{ +if (skb_get_nfct (skb) ==IP_CT_UNTRACKED ) +nf_reset_ct (skb); +} +#if IS_ENABLED (CONFIG_IPV6 )static int vrf_ip6_local_out (struct net *net,struct sock *sk,struct sk_buff *skb) {int err; +vrf_nf_reset_ct (skb); + err =nf_hook (NFPROTO_IPV6 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL ,skb_dst (skb)->dev, dst_output);
@@ -508,6 +523,8 @@ static int vrf_ip_local_out(struct net *net, struct sock *sk, {int err; +vrf_nf_reset_ct (skb); + err =nf_hook (NFPROTO_IPV4 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL ,skb_dst (skb)->dev, dst_output);if (likely (err ==1 ))
@@ -626,8 +643,7 @@ static void vrf_finish_direct(struct sk_buff *skb)skb_pull (skb,ETH_HLEN ); } -/* reset skb device */ -nf_reset_ct (skb); +vrf_nf_reset_ct (skb); }#if IS_ENABLED (CONFIG_IPV6 )
@@ -641,7 +657,7 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,struct neighbour *neigh;int ret; -nf_reset_ct (skb); +vrf_nf_reset_ct (skb); skb->protocol =htons (ETH_P_IPV6 ); skb->dev = dev;
@@ -752,6 +768,8 @@ static struct sk_buff *vrf_ip6_out_direct(struct net_device *vrf_dev, skb->dev = vrf_dev; +vrf_nf_set_untracked (skb); + err =nf_hook (NFPROTO_IPV6 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL , vrf_dev, vrf_ip6_out_direct_finish);
@@ -859,7 +877,7 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *sbool is_v6gw = false;int ret = -EINVAL ; -nf_reset_ct (skb); +vrf_nf_reset_ct (skb);/* Be paranoid, rather than too clever. */ if (unlikely (skb_headroom (skb) < hh_len && dev->header_ops)) {
@@ -987,6 +1005,8 @@ static struct sk_buff *vrf_ip_out_direct(struct net_device *vrf_dev, skb->dev = vrf_dev; +vrf_nf_set_untracked (skb); + err =nf_hook (NFPROTO_IPV4 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL , vrf_dev, vrf_ip_out_direct_finish);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 316/849 net: annotate data-race in neigh_output()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit d18785e213866935b4c3dc0c33c3e18801ce0ce8 ]
neigh_output() reads n->nud_state and hh->hh_len locklessly.
This is fine, but we need to add annotations and document this.
We evaluate skip_cache first to avoid reading these fields if the cache has to by bypassed.
syzbot report:
BUG: KCSAN: data-race in __neigh_event_send / ip_finish_output2
write to 0xffff88810798a885 of 1 bytes by interrupt on cpu 1:
__neigh_event_send+0x40d/0xac0 net/core/neighbour.c:1128 neigh_event_send include/net/neighbour.h:444 [inline] neigh_resolve_output+0x104/0x410 net/core/neighbour.c:1476 neigh_output include/net/neighbour.h:510 [inline] ip_finish_output2+0x80a/0xaa0 net/ipv4/ip_output.c:221 ip_finish_output+0x3b5/0x510 net/ipv4/ip_output.c:309 NF_HOOK_COND include/linux/netfilter.h:296 [inline] ip_output+0xf3/0x1a0 net/ipv4/ip_output.c:423 dst_output include/net/dst.h:450 [inline] ip_local_out+0x164/0x220 net/ipv4/ip_output.c:126 __ip_queue_xmit+0x9d3/0xa20 net/ipv4/ip_output.c:525 ip_queue_xmit+0x34/0x40 net/ipv4/ip_output.c:539 __tcp_transmit_skb+0x142a/0x1a00 net/ipv4/tcp_output.c:1405 tcp_transmit_skb net/ipv4/tcp_output.c:1423 [inline] tcp_xmit_probe_skb net/ipv4/tcp_output.c:4011 [inline] tcp_write_wakeup+0x4a9/0x810 net/ipv4/tcp_output.c:4064 tcp_send_probe0+0x2c/0x2b0 net/ipv4/tcp_output.c:4079 tcp_probe_timer net/ipv4/tcp_timer.c:398 [inline] tcp_write_timer_handler+0x394/0x520 net/ipv4/tcp_timer.c:626 tcp_write_timer+0xb9/0x180 net/ipv4/tcp_timer.c:642 call_timer_fn+0x2e/0x1d0 kernel/time/timer.c:1421 expire_timers+0x135/0x240 kernel/time/timer.c:1466 __run_timers+0x368/0x430 kernel/time/timer.c:1734 run_timer_softirq+0x19/0x30 kernel/time/timer.c:1747 __do_softirq+0x12c/0x26e kernel/softirq.c:558 invoke_softirq kernel/softirq.c:432 [inline] __irq_exit_rcu kernel/softirq.c:636 [inline] irq_exit_rcu+0x4e/0xa0 kernel/softirq.c:648 sysvec_apic_timer_interrupt+0x69/0x80 arch/x86/kernel/apic/apic.c:1097 asm_sysvec_apic_timer_interrupt+0x12/0x20 native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline] arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline] acpi_safe_halt drivers/acpi/processor_idle.c:109 [inline] acpi_idle_do_entry drivers/acpi/processor_idle.c:553 [inline] acpi_idle_enter+0x258/0x2e0 drivers/acpi/processor_idle.c:688 cpuidle_enter_state+0x2b4/0x760 drivers/cpuidle/cpuidle.c:237 cpuidle_enter+0x3c/0x60 drivers/cpuidle/cpuidle.c:351 call_cpuidle kernel/sched/idle.c:158 [inline] cpuidle_idle_call kernel/sched/idle.c:239 [inline] do_idle+0x1a3/0x250 kernel/sched/idle.c:306 cpu_startup_entry+0x15/0x20 kernel/sched/idle.c:403 secondary_startup_64_no_verify+0xb1/0xbb
read to 0xffff88810798a885 of 1 bytes by interrupt on cpu 0:
neigh_output include/net/neighbour.h:507 [inline] ip_finish_output2+0x79a/0xaa0 net/ipv4/ip_output.c:221 ip_finish_output+0x3b5/0x510 net/ipv4/ip_output.c:309 NF_HOOK_COND include/linux/netfilter.h:296 [inline] ip_output+0xf3/0x1a0 net/ipv4/ip_output.c:423 dst_output include/net/dst.h:450 [inline] ip_local_out+0x164/0x220 net/ipv4/ip_output.c:126 __ip_queue_xmit+0x9d3/0xa20 net/ipv4/ip_output.c:525 ip_queue_xmit+0x34/0x40 net/ipv4/ip_output.c:539 __tcp_transmit_skb+0x142a/0x1a00 net/ipv4/tcp_output.c:1405 tcp_transmit_skb net/ipv4/tcp_output.c:1423 [inline] tcp_xmit_probe_skb net/ipv4/tcp_output.c:4011 [inline] tcp_write_wakeup+0x4a9/0x810 net/ipv4/tcp_output.c:4064 tcp_send_probe0+0x2c/0x2b0 net/ipv4/tcp_output.c:4079 tcp_probe_timer net/ipv4/tcp_timer.c:398 [inline] tcp_write_timer_handler+0x394/0x520 net/ipv4/tcp_timer.c:626 tcp_write_timer+0xb9/0x180 net/ipv4/tcp_timer.c:642 call_timer_fn+0x2e/0x1d0 kernel/time/timer.c:1421 expire_timers+0x135/0x240 kernel/time/timer.c:1466 __run_timers+0x368/0x430 kernel/time/timer.c:1734 run_timer_softirq+0x19/0x30 kernel/time/timer.c:1747 __do_softirq+0x12c/0x26e kernel/softirq.c:558 invoke_softirq kernel/softirq.c:432 [inline] __irq_exit_rcu kernel/softirq.c:636 [inline] irq_exit_rcu+0x4e/0xa0 kernel/softirq.c:648 sysvec_apic_timer_interrupt+0x69/0x80 arch/x86/kernel/apic/apic.c:1097 asm_sysvec_apic_timer_interrupt+0x12/0x20 native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline] arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline] acpi_safe_halt drivers/acpi/processor_idle.c:109 [inline] acpi_idle_do_entry drivers/acpi/processor_idle.c:553 [inline] acpi_idle_enter+0x258/0x2e0 drivers/acpi/processor_idle.c:688 cpuidle_enter_state+0x2b4/0x760 drivers/cpuidle/cpuidle.c:237 cpuidle_enter+0x3c/0x60 drivers/cpuidle/cpuidle.c:351 call_cpuidle kernel/sched/idle.c:158 [inline] cpuidle_idle_call kernel/sched/idle.c:239 [inline] do_idle+0x1a3/0x250 kernel/sched/idle.c:306 cpu_startup_entry+0x15/0x20 kernel/sched/idle.c:403 rest_init+0xee/0x100 init/main.c:734 arch_call_rest_init+0xa/0xb start_kernel+0x5e4/0x669 init/main.c:1142 secondary_startup_64_no_verify+0xb1/0xbb
value changed: 0x20 -> 0x01
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-rc6-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- include/net/neighbour.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
include/net/neighbour.h +8 -3
@@ -504,10 +504,15 @@ static inline int neigh_output(struct neighbour *n, struct sk_buff *skb, {const struct hh_cache *hh = &n->hh; -if ((n->nud_state &NUD_CONNECTED ) && hh->hh_len && !skip_cache) +/* n->nud_state and hh->hh_len could be changed under us. +* neigh_hh_output() is taking care of the race later. +*/ +if (!skip_cache && + (READ_ONCE (n->nud_state) &NUD_CONNECTED ) && +READ_ONCE (hh->hh_len))return neigh_hh_output (hh, skb); -else -return n->output (n, skb); + +return n->output (n, skb); } static inline struct neighbour *
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 317/849 ACPI: AC: Quirk GK45 to skip reading _PSR
In reply to Greg Kroah-HartmanFrom: Stefan Schaeckeler <[email protected]>
[ Upstream commit 3d730ee686800d71ecc5c3cb8460dcdcdeaf38a3 ]
Let GK45 not go into BIOS for determining the AC power state.
The BIOS wrongly returns 0, so hardcode the power state to 1.
The mini PC GK45 by Besstar Tech Lld. (aka Kodlix) just runs off AC. It does not include any batteries. Nevertheless BIOS reports AC off:
root@kodlix:/usr/src/linux# cat /sys/class/power_supply/ADP1/online 0
root@kodlix:/usr/src/linux# modprobe acpi_dbg root@kodlix:/usr/src/linux# tools/power/acpi/acpidbg
- find _PSR
\_SB.PCI0.SBRG.H_EC.ADP1._PSR Method 000000009283cee8 001 Args 0 Len 001C Aml 00000000f54e5f67
- execute \_SB.PCI0.SBRG.H_EC.ADP1._PSR
Evaluating \_SB.PCI0.SBRG.H_EC.ADP1._PSR
Evaluation of \_SB.PCI0.SBRG.H_EC.ADP1._PSR returned object 00000000dc08c187, external buffer length 18
[Integer] = 0000000000000000
that should be
[Integer] = 0000000000000001
--- drivers/acpi/ac.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/acpi/ac.c +19 -0
@@ -61,6 +61,7 @@ static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);static int ac_sleep_before_get_state_ms;static int ac_check_pmic =1 ; +static int ac_only;static struct acpi_driver acpi_ac_driver = { .name ="ac" ,
@@ -93,6 +94,11 @@ static int acpi_ac_get_state(struct acpi_ac *ac)if (!ac)return -EINVAL ; +if (ac_only) { + ac->state =1 ; +return 0 ; + } + status =acpi_evaluate_integer (ac->device->handle,"_PSR" ,NULL , &ac->state);if (ACPI_FAILURE (status)) {
@@ -200,6 +206,12 @@ static int __init ac_do_not_check_pmic_quirk(const struct dmi_system_id *d)return 0 ; } +static int __init ac_only_quirk (const struct dmi_system_id *d) +{ + ac_only =1 ; +return 0 ; +} +/* Please keep this list alphabetically sorted */ static const struct dmi_system_id ac_dmi_table[]__initconst = { {
@@ -209,6 +221,13 @@ static const struct dmi_system_id ac_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"), }, }, + { +/* Kodlix GK45 returning incorrect state */ + .callback = ac_only_quirk, + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "GK45"), + }, + }, {/* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */ .callback = ac_do_not_check_pmic_quirk,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 318/849 ACPI: resources: Add one more Medion model in IRQ override quirk
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
[ Upstream commit 1b26ae40092b43bb6e9c5df376227382b390b953 ]
The Medion s17 series laptops have the same issue on the keyboard as the s15 series, if skipping to call acpi_get_override_irq(), the keyboard could work well. So put the DMI info of s17 series in the IRQ override quirk table as well.
--- drivers/acpi/resource.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/resource.c +7 -0
@@ -389,6 +389,13 @@ static const struct dmi_system_id medion_laptop[] = { DMI_MATCH(DMI_BOARD_NAME, "M15T"), }, }, + { + .ident = "MEDION S17405", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "MEDION"), + DMI_MATCH(DMI_BOARD_NAME, "M17T"), + }, + }, { } };
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 319/849 btrfs: reflink: initialize return value to 0 in btrfs_extent_same()
In reply to Greg Kroah-HartmanFrom: Sidong Yang <[email protected]>
[ Upstream commit 44bee215f72f13874c0e734a0712c2e3264c0108 ]
Fix a warning reported by smatch that ret could be returned without initialized. The dedupe operations are supposed to to return 0 for a 0 length range but the caller does not pass olen == 0. To keep this behaviour and also fix the warning initialize ret to 0.
--- fs/btrfs/reflink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/reflink.c +1 -1
@@ -649,7 +649,7 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,static int btrfs_extent_same (struct inode *src,u64 loff,u64 olen,struct inode *dst,u64 dst_loff) { -int ret; +int ret =0 ;u64 i, tail_len, chunk_count;struct btrfs_root *root_dst =BTRFS_I (dst)->root;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 320/849 btrfs: do not take the uuid_mutex in btrfs_rm_device
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 8ef9dc0f14ba6124c62547a4fdc59b163d8b864e ]
We got the following lockdep splat while running fstests (specifically btrfs/003 and btrfs/020 in a row) with the new rc. This was uncovered by 87579e9b7d8d ("loop: use worker per cgroup instead of kworker") which converted loop to using workqueues, which comes with lockdep annotations that don't exist with kworkers. The lockdep splat is as follows:
WARNING: possible circular locking dependency detected 5.14.0-rc2-custom+ #34 Not tainted
------------------------------------------------------
losetup/156417 is trying to acquire lock:
ffff9c7645b02d38 ((wq_completion)loop0){+.+.}-{0:0}, at: flush_workqueue+0x84/0x600
but task is already holding lock:
ffff9c7647395468 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0x650 [loop]
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #5 (&lo->lo_mutex){+.+.}-{3:3}:
__mutex_lock+0xba/0x7c0 lo_open+0x28/0x60 [loop] blkdev_get_whole+0x28/0xf0 blkdev_get_by_dev.part.0+0x168/0x3c0 blkdev_open+0xd2/0xe0 do_dentry_open+0x163/0x3a0 path_openat+0x74d/0xa40 do_filp_open+0x9c/0x140 do_sys_openat2+0xb1/0x170 __x64_sys_openat+0x54/0x90 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
-> #4 (&disk->open_mutex){+.+.}-{3:3}:
__mutex_lock+0xba/0x7c0 blkdev_get_by_dev.part.0+0xd1/0x3c0 blkdev_get_by_path+0xc0/0xd0 btrfs_scan_one_device+0x52/0x1f0 [btrfs] btrfs_control_ioctl+0xac/0x170 [btrfs] __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
-> #3 (uuid_mutex){+.+.}-{3:3}:
__mutex_lock+0xba/0x7c0 btrfs_rm_device+0x48/0x6a0 [btrfs] btrfs_ioctl+0x2d1c/0x3110 [btrfs] __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
-> #2 (sb_writers#11){.+.+}-{0:0}:
lo_write_bvec+0x112/0x290 [loop] loop_process_work+0x25f/0xcb0 [loop] process_one_work+0x28f/0x5d0 worker_thread+0x55/0x3c0 kthread+0x140/0x170 ret_from_fork+0x22/0x30
-> #1 ((work_completion)(&lo->rootcg_work)){+.+.}-{0:0}:
process_one_work+0x266/0x5d0 worker_thread+0x55/0x3c0 kthread+0x140/0x170 ret_from_fork+0x22/0x30
-> #0 ((wq_completion)loop0){+.+.}-{0:0}:
__lock_acquire+0x1130/0x1dc0 lock_acquire+0xf5/0x320 flush_workqueue+0xae/0x600 drain_workqueue+0xa0/0x110 destroy_workqueue+0x36/0x250 __loop_clr_fd+0x9a/0x650 [loop] lo_ioctl+0x29d/0x780 [loop] block_ioctl+0x3f/0x50 __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
other info that might help us debug this:
Chain exists of:
(wq_completion)loop0 --> &disk->open_mutex --> &lo->lo_mutex
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&lo->lo_mutex);
lock(&disk->open_mutex);
lock(&lo->lo_mutex);
lock((wq_completion)loop0); *** DEADLOCK ***
1 lock held by losetup/156417:
#0: ffff9c7647395468 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0x650 [loop]
stack backtrace: CPU: 8 PID: 156417 Comm: losetup Not tainted 5.14.0-rc2-custom+ #34 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 Call Trace: dump_stack_lvl+0x57/0x72 check_noncircular+0x10a/0x120 __lock_acquire+0x1130/0x1dc0 lock_acquire+0xf5/0x320 ? flush_workqueue+0x84/0x600 flush_workqueue+0xae/0x600 ? flush_workqueue+0x84/0x600 drain_workqueue+0xa0/0x110 destroy_workqueue+0x36/0x250 __loop_clr_fd+0x9a/0x650 [loop] lo_ioctl+0x29d/0x780 [loop] ? __lock_acquire+0x3a0/0x1dc0 ? update_dl_rq_load_avg+0x152/0x360 ? lock_is_held_type+0xa5/0x120 ? find_held_lock.constprop.0+0x2b/0x80 block_ioctl+0x3f/0x50 __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f645884de6b
Usually the uuid_mutex exists to protect the fs_devices that map together all of the devices that match a specific uuid. In rm_device we're messing with the uuid of a device, so it makes sense to protect that here.
However in doing that it pulls in a whole host of lockdep dependencies, as we call mnt_may_write() on the sb before we grab the uuid_mutex, thus we end up with the dependency chain under the uuid_mutex being added under the normal sb write dependency chain, which causes problems with loop devices.
We don't need the uuid mutex here however. If we call btrfs_scan_one_device() before we scratch the super block we will find the fs_devices and not find the device itself and return EBUSY because the fs_devices is open. If we call it after the scratch happens it will not appear to be a valid btrfs file system.
We do not need to worry about other fs_devices modifying operations here because we're protected by the exclusive operations locking.
So drop the uuid_mutex here in order to fix the lockdep splat.
A more detailed explanation from the discussion:
We are worried about rm and scan racing with each other, before this change we'll zero the device out under the UUID mutex so when scan does run it'll make sure that it can go through the whole device scan thing without rm messing with us.
We aren't worried if the scratch happens first, because the result is we don't think this is a btrfs device and we bail out.
The only case we are concerned with is we scratch _after_ scan is able to read the superblock and gets a seemingly valid super block, so lets consider this case.
Scan will call device_list_add() with the device we're removing. We'll call find_fsid_with_metadata_uuid() and get our fs_devices for this UUID. At this point we lock the fs_devices->device_list_mutex. This is what protects us in this case, but we have two cases here.
1. We aren't to the device removal part of the RM. We found our device, and device name matches our path, we go down and we set total_devices to our super number of devices, which doesn't affect anything because we haven't done the remove yet.
2. We are past the device removal part, which is protected by the device_list_mutex. Scan doesn't find the device, it goes down and does the
if (fs_devices->opened)
return -EBUSY;
check and we bail out.
Nothing about this situation is ideal, but the lockdep splat is real, and the fix is safe, tho admittedly a bit scary looking.
--- fs/btrfs/volumes.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/volumes.c +5 -5
@@ -2146,8 +2146,11 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,u64 num_devices;int ret =0 ; -mutex_lock (&uuid_mutex); - +/* +* The device list in fs_devices is accessed without locks (neither +* uuid_mutex nor device_list_mutex) as it won't change on a mounted +* filesystem and another device rm cannot run. +*/ num_devices =btrfs_num_devices (fs_info); ret =btrfs_check_raid_min_devices (fs_info, num_devices -1 );
@@ -2191,11 +2194,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,mutex_unlock (&fs_info->chunk_mutex); } -mutex_unlock (&uuid_mutex); ret =btrfs_shrink_device (device,0 );if (!ret)btrfs_reada_remove_dev (device); -mutex_lock (&uuid_mutex);if (ret) goto error_undo;
@@ -2282,7 +2283,6 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, } out: -mutex_unlock (&uuid_mutex);return ret; error_undo:
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 321/849 spi: bcm-qspi: Fix missing clk_disable_unprepare() on error in bcm_qspi_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit ca9b8f56ec089d3a436050afefd17b7237301f47 ]
Fix the missing clk_disable_unprepare() before return from bcm_qspi_probe() in the error handling case.
--- drivers/spi/spi-bcm-qspi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-bcm-qspi.c +3 -2
@@ -1460,7 +1460,7 @@ int bcm_qspi_probe(struct platform_device *pdev, &qspi->dev_ids[val]);if (ret <0 ) {dev_err (&pdev->dev,"IRQ %s not found\n" , name); - goto qspi_probe_err; + goto qspi_unprepare_err; } qspi->dev_ids[val].dev = qspi;
@@ -1475,7 +1475,7 @@ int bcm_qspi_probe(struct platform_device *pdev,if (!num_ints) {dev_err (&pdev->dev,"no IRQs registered, cannot init driver\n" ); ret = -EINVAL ; - goto qspi_probe_err; + goto qspi_unprepare_err; }bcm_qspi_hw_init (qspi);
@@ -1499,6 +1499,7 @@ int bcm_qspi_probe(struct platform_device *pdev, qspi_reg_err:bcm_qspi_hw_uninit (qspi); +qspi_unprepare_err:clk_disable_unprepare (qspi->clk); qspi_probe_err:kfree (qspi->dev_ids);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 322/849 wcn36xx: Correct band/freq reporting on RX
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit 8a27ca39478270e07baf9c09aa0c99709769ba03 ]
For packets originating from hardware scan, the channel and band is included in the buffer descriptor (bd->rf_band & bd->rx_ch).
For 2Ghz band the channel value is directly reported in the 4-bit rx_ch field. For 5Ghz band, the rx_ch field contains a mapping index (given the 4-bit limitation).
The reserved0 value field is also used to extend 4-bit mapping to 5-bit mapping to support more than 16 5Ghz channels.
This change adds correct reporting of the frequency/band, that is used in scan mechanism. And is required for 5Ghz hardware scan support.
--- drivers/net/wireless/ath/wcn36xx/txrx.c | 23 +++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/txrx.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/txrx.c +23 -0
@@ -31,6 +31,13 @@ struct wcn36xx_rate {enum rate_info_bw bw; }; +/* Buffer descriptor rx_ch field is limited to 5-bit (4+1), a mapping is used +* for 11A Channels. +*/ +static const u8 ab_rx_ch_map[] = {36 ,40 ,44 ,48 ,52 ,56 ,60 ,64 ,100 ,104 , +108 ,112 ,116 ,120 ,124 ,128 ,132 ,136 ,140 , +149 ,153 ,157 ,161 ,165 ,144 }; +static const struct wcn36xx_rate wcn36xx_rate_table[] = {/* 11b rates */ {10 ,0 ,RX_ENC_LEGACY ,0 ,RATE_INFO_BW_20 },
@@ -291,6 +298,22 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) ieee80211_is_probe_resp(hdr->frame_control)) status.boottime_ns = ktime_get_boottime_ns(); +if (bd->scan_learn) { +/* If packet originates from hardware scanning, extract the +* band/channel from bd descriptor. +*/ +u8 hwch = (bd->reserved0 <<4 ) + bd->rx_ch; + +if (bd->rf_band !=1 && hwch <=sizeof (ab_rx_ch_map) && hwch >=1 ) { + status.band =NL80211_BAND_5GHZ ; + status.freq =ieee80211_channel_to_frequency (ab_rx_ch_map[hwch -1 ], + status.band); + }else { + status.band =NL80211_BAND_2GHZ ; + status.freq =ieee80211_channel_to_frequency (hwch, status.band); + } + } +memcpy (IEEE80211_SKB_RXCB (skb), &status,sizeof (status));if (ieee80211_is_beacon (hdr->frame_control)) {
drivers/net/wireless/ath/wcn36xx/txrx.h +2 -1
@@ -110,7 +110,8 @@ struct wcn36xx_rx_bd {/* 0x44 */ u32 exp_seq_num:12; u32 cur_seq_num:12; - u32 fr_type_subtype:8; + u32 rf_band:2; + u32 fr_type_subtype:6;/* 0x48 */ u32 msdu_size:16;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 323/849 wcn36xx: Fix packet drop on resume
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit df0697801d8aa2eebfe7f0b7388879639f8fe7cc ]
If the system is resumed because of an incoming packet, the wcn36xx RX interrupts is fired before actual resuming of the wireless/mac80211 stack, causing any received packets to be simply dropped. E.g. a ping request causes a system resume, but is dropped and so never forwarded to the IP stack.
This change fixes that, disabling DMA interrupts on suspend to no pass packets until mac80211 is resumed and ready to handle them.
Note that it's not incompatible with RX irq wake.
--- drivers/net/wireless/ath/wcn36xx/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/wireless/ath/wcn36xx/main.c +11 -0
@@ -1115,6 +1115,13 @@ static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) goto out; ret =wcn36xx_smd_wlan_host_suspend_ind (wcn); } + +/* Disable IRQ, we don't want to handle any packet before mac80211 is +* resumed and ready to receive packets. +*/ +disable_irq (wcn->tx_irq); +disable_irq (wcn->rx_irq); + out:mutex_unlock (&wcn->conf_mutex);return ret;
@@ -1137,6 +1144,10 @@ static int wcn36xx_resume(struct ieee80211_hw *hw)wcn36xx_smd_ipv6_ns_offload (wcn, vif, false);wcn36xx_smd_arp_offload (wcn, vif, false); } + +enable_irq (wcn->tx_irq); +enable_irq (wcn->rx_irq); +mutex_unlock (&wcn->conf_mutex);return 0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 324/849 Revert "wcn36xx: Enable firmware link monitoring"
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit 43ea9bd84f27d06482cc823d9749cc9dd2993bc8 ]
Firmware link offload monitoring can be made to work in 3/4 cases by switching on firmware feature bit WLANACTIVE_OFFLOAD
- Secure power-save on
- Secure power-save off
- Open power-save on
However, with an open AP if we switch off power-saving - thus never entering Beacon Mode Power Save - BMPS, firmware never forwards loss of beacon upwards.
We had hoped that WLANACTIVE_OFFLOAD and some fixes for sequence numbers would unblock this but, it hasn't and further investigation is required.
Its possible to have a complete set of Secure power-save on/off and Open power-save on/off provided we use Linux' link monitoring mechanism.
While we debug the Open AP failure we need to fix upstream.
This reverts commit c973fdad79f6eaf247d48b5fc77733e989eb01e1.
--- drivers/net/wireless/ath/wcn36xx/main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/main.c +0 -1
@@ -1341,7 +1341,6 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)ieee80211_hw_set (wcn->hw,HAS_RATE_CONTROL );ieee80211_hw_set (wcn->hw,SINGLE_SCAN_ON_ALL_BANDS );ieee80211_hw_set (wcn->hw,REPORTS_TX_ACK_STATUS ); -ieee80211_hw_set (wcn->hw,CONNECTION_MONITOR ); wcn->hw->wiphy->interface_modes =BIT (NL80211_IFTYPE_STATION ) | BIT(NL80211_IFTYPE_AP) |
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 325/849 ftrace: do CPU checking after preemption disabled
In reply to Greg Kroah-HartmanFrom: 王贇 <[email protected]>
[ Upstream commit d33cc657372366a8959f099c619a208b4c5dc664 ]
With CONFIG_DEBUG_PREEMPT we observed reports like:
BUG: using smp_processor_id() in preemptible caller is perf_ftrace_function_call+0x6f/0x2e0 CPU: 1 PID: 680 Comm: a.out Not tainted Call Trace: <TASK> dump_stack_lvl+0x8d/0xcf check_preemption_disabled+0x104/0x110 ? optimize_nops.isra.7+0x230/0x230 ? text_poke_bp_batch+0x9f/0x310 perf_ftrace_function_call+0x6f/0x2e0 ... __text_poke+0x5/0x620 text_poke_bp_batch+0x9f/0x310
This telling us the CPU could be changed after task is preempted, and the checking on CPU before preemption will be invalid.
Since now ftrace_test_recursion_trylock() will help to disable the preemption, this patch just do the checking after trylock() to address the issue.
--- kernel/trace/trace_event_perf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace_event_perf.c +3 -3
@@ -441,13 +441,13 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,if (!rcu_is_watching ())return ; -if ((unsigned long )ops->private !=smp_processor_id ()) -return ; - bit =ftrace_test_recursion_trylock (ip, parent_ip);if (bit <0 )return ; +if ((unsigned long )ops->private !=smp_processor_id ()) + goto out; + event = container_of(ops, struct perf_event, ftrace_ops);/*
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 326/849 x86/hyperv: Protect set_hv_tscchange_cb() against getting preempted
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
[ Upstream commit 285f68afa8b20f752b0b7194d54980b5e0e27b75 ]
The following issue is observed with CONFIG_DEBUG_PREEMPT when KVM loads:
KVM: vmx: using Hyper-V Enlightened VMCS
BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/488 caller is set_hv_tscchange_cb+0x16/0x80 CPU: 1 PID: 488 Comm: systemd-udevd Not tainted 5.15.0-rc5+ #396 Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.0 12/17/2019 Call Trace: dump_stack_lvl+0x6a/0x9a check_preemption_disabled+0xde/0xe0 ? kvm_gen_update_masterclock+0xd0/0xd0 [kvm] set_hv_tscchange_cb+0x16/0x80 kvm_arch_init+0x23f/0x290 [kvm] kvm_init+0x30/0x310 [kvm] vmx_init+0xaf/0x134 [kvm_intel] ...
set_hv_tscchange_cb() can get preempted in between acquiring smp_processor_id() and writing to HV_X64_MSR_REENLIGHTENMENT_CONTROL. This is not an issue by itself: HV_X64_MSR_REENLIGHTENMENT_CONTROL is a partition-wide MSR and it doesn't matter which particular CPU will be used to receive reenlightenment notifications. The only real problem can (in theory) be observed if the CPU whose id was acquired with smp_processor_id() goes offline before we manage to write to the MSR, the logic in hv_cpu_die() won't be able to reassign it correctly.
--- arch/x86/hyperv/hv_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/hyperv/hv_init.c +4 -1
@@ -160,7 +160,6 @@ void set_hv_tscchange_cb(void (*cb)(void))struct hv_reenlightenment_control re_ctrl = { .vector =HYPERV_REENLIGHTENMENT_VECTOR , .enabled =1 , - .target_vp = hv_vp_index[smp_processor_id ()] };struct hv_tsc_emulation_control emu_ctrl = {.enabled =1 };
@@ -174,8 +173,12 @@ void set_hv_tscchange_cb(void (*cb)(void))/* Make sure callback is registered before we write to MSRs */ wmb (); + re_ctrl.target_vp = hv_vp_index[get_cpu ()]; +wrmsrl (HV_X64_MSR_REENLIGHTENMENT_CONTROL , *((u64 *)&re_ctrl));wrmsrl (HV_X64_MSR_TSC_EMULATION_CONTROL , *((u64 *)&emu_ctrl)); + +put_cpu (); }EXPORT_SYMBOL_GPL (set_hv_tscchange_cb);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 327/849 drm/amd/display: dcn20_resource_construct reduce scope of FPU enabled
In reply to Greg Kroah-HartmanFrom: Anson Jacob <[email protected]>
[ Upstream commit bc39a69a2ac484e6575a958567c162ef56c9f278 ]
Limit when FPU is enabled to only functions that does FPU operations for dcn20_resource_construct, which gets called during driver initialization.
Enabling FPU operation disables preemption. Sleeping functions(mutex (un)lock, memory allocation using GFP_KERNEL, etc.) should not be called when preemption is disabled.
Fixes the following case caught by enablingCONFIG_DEBUG_ATOMIC_SLEEP in kernel config
[ 1.338434] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281 [ 1.347395] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 197, name: systemd-udevd [ 1.356356] CPU: 7 PID: 197 Comm: systemd-udevd Not tainted 5.13.0+ #3 [ 1.356358] Hardware name: System manufacturer System Product Name/PRIME X570-PRO, BIOS 3405 02/01/2021 [ 1.356360] Call Trace: [ 1.356361] dump_stack+0x6b/0x86 [ 1.356366] ___might_sleep.cold+0x87/0x98 [ 1.356370] __might_sleep+0x4b/0x80 [ 1.356372] mutex_lock+0x21/0x50 [ 1.356376] smu_get_uclk_dpm_states+0x3f/0x80 [amdgpu] [ 1.356538] pp_nv_get_uclk_dpm_states+0x35/0x50 [amdgpu] [ 1.356711] init_soc_bounding_box+0xf9/0x210 [amdgpu] [ 1.356892] ? create_object+0x20d/0x340 [ 1.356897] ? dcn20_resource_construct+0x46f/0xd30 [amdgpu] [ 1.357077] dcn20_resource_construct+0x4b1/0xd30 [amdgpu]
...
Tested on: 5700XT (NAVI10 0x1002:0x731F 0x1DA2:0xE410 0xC1)
--- .../drm/amd/display/dc/dcn20/dcn20_resource.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +9 -7
@@ -3701,16 +3701,22 @@ static bool init_soc_bounding_box(struct dc *dc, clock_limits_available = (status ==PP_SMU_RESULT_OK ); } -if (clock_limits_available && uclk_states_available && num_states) +if (clock_limits_available && uclk_states_available && num_states) { +DC_FP_START ();dcn20_update_bounding_box (dc, loaded_bb, &max_clocks, uclk_states, num_states); -else if (clock_limits_available) +DC_FP_END (); + }else if (clock_limits_available) { +DC_FP_START ();dcn20_cap_soc_clocks (loaded_bb, max_clocks); +DC_FP_END (); + } } loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator; loaded_ip->max_num_dpp = pool->base.pipe_count; +DC_FP_START ();dcn20_patch_bounding_box (dc, loaded_bb); - +DC_FP_END ();return true; }
@@ -3730,8 +3736,6 @@ static bool dcn20_resource_construct(enum dml_project dml_project_version =get_dml_project_version (ctx->asic_id.hw_internal_rev); -DC_FP_START (); - ctx->dc_bios->regs = &bios_regs; pool->base.funcs = &dcn20_res_pool_funcs;
@@ -4080,12 +4084,10 @@ static bool dcn20_resource_construct( pool->base.oem_device =NULL ; } -DC_FP_END ();return true; create_fail: -DC_FP_END ();dcn20_resource_destruct (pool);return false;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 328/849 selftests/core: fix conflicting types compile error for close_range()
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit f35dcaa0a8a29188ed61083d153df1454cf89d08 ]
close_range() test type conflicts with close_range() library call in x86_64-linux-gnu/bits/unistd_ext.h. Fix it by changing the name to core_close_range().
gcc -g -I../../../../usr/include/ close_range_test.c -o ../tools/testing/selftests/core/close_range_test
In file included from close_range_test.c:16:
close_range_test.c:57:6: error: conflicting types for ‘close_range’; have ‘void(struct __test_metadata *)’
57 | TEST(close_range)
| ^~~~~~~~~~~
../kselftest_harness.h:181:21: note: in definition of macro ‘__TEST_IMPL’
181 | static void test_name(struct __test_metadata *_metadata); \
| ^~~~~~~~~
close_range_test.c:57:1: note: in expansion of macro ‘TEST’
57 | TEST(close_range)
| ^~~~
In file included from /usr/include/unistd.h:1204,
from close_range_test.c:13:
/usr/include/x86_64-linux-gnu/bits/unistd_ext.h:56:12: note: previous declaration of ‘close_range’ with type ‘int(unsigned int, unsigned int, int)’
56 | extern int close_range (unsigned int __fd, unsigned int __max_fd,
| ^~~~~~~~~~~--- tools/testing/selftests/core/close_range_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/core/close_range_test.c +1 -1
@@ -54,7 +54,7 @@ static inline int sys_close_range(unsigned int fd, unsigned int max_fd,#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))#endif -TEST (close_range) +TEST (core_close_range) {int i, ret;int open_fds[101 ];
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 329/849 perf/x86/intel: Fix ICL/SPR INST_RETIRED.PREC_DIST encodings
In reply to Greg Kroah-HartmanFrom: Stephane Eranian <[email protected]>
[ Upstream commit 2de71ee153efa93099d2ab864acffeec70a8dcd5 ]
This patch fixes the encoding for INST_RETIRED.PREC_DIST as published by Intel (download.01.org/perfmon/) for Icelake. The official encoding
is event code 0x00 umask 0x1, a change from Skylake where it was code 0xc0 umask 0x1.
With this patch applied it is possible to run:
$ perf record -a -e cpu/event=0x00,umask=0x1/pp .....
Whereas before this would fail.
To avoid problems with tools which may use the old code, we maintain the old encoding for Icelake.
--- arch/x86/events/intel/core.c | 5 +++-- arch/x86/events/intel/ds.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/x86/events/intel/core.c +3 -2
@@ -243,7 +243,8 @@ static struct extra_reg intel_skl_extra_regs[] __read_mostly = {static struct event_constraint intel_icl_event_constraints[] = {FIXED_EVENT_CONSTRAINT (0x00c0 ,0 ),/* INST_RETIRED.ANY */ -FIXED_EVENT_CONSTRAINT (0x01c0 ,0 ),/* INST_RETIRED.PREC_DIST */ +FIXED_EVENT_CONSTRAINT (0x01c0 ,0 ),/* old INST_RETIRED.PREC_DIST */ +FIXED_EVENT_CONSTRAINT (0x0100 ,0 ),/* INST_RETIRED.PREC_DIST */ FIXED_EVENT_CONSTRAINT (0x003c ,1 ),/* CPU_CLK_UNHALTED.CORE */ FIXED_EVENT_CONSTRAINT (0x0300 ,2 ),/* CPU_CLK_UNHALTED.REF */ FIXED_EVENT_CONSTRAINT (0x0400 ,3 ),/* SLOTS */
@@ -288,7 +289,7 @@ static struct extra_reg intel_spr_extra_regs[] __read_mostly = {static struct event_constraint intel_spr_event_constraints[] = {FIXED_EVENT_CONSTRAINT (0x00c0 ,0 ),/* INST_RETIRED.ANY */ -FIXED_EVENT_CONSTRAINT (0x01c0 ,0 ),/* INST_RETIRED.PREC_DIST */ +FIXED_EVENT_CONSTRAINT (0x0100 ,0 ),/* INST_RETIRED.PREC_DIST */ FIXED_EVENT_CONSTRAINT (0x003c ,1 ),/* CPU_CLK_UNHALTED.CORE */ FIXED_EVENT_CONSTRAINT (0x0300 ,2 ),/* CPU_CLK_UNHALTED.REF */ FIXED_EVENT_CONSTRAINT (0x0400 ,3 ),/* SLOTS */
arch/x86/events/intel/ds.c +3 -2
@@ -923,7 +923,8 @@ struct event_constraint intel_skl_pebs_event_constraints[] = { };struct event_constraint intel_icl_pebs_event_constraints[] = { -INTEL_FLAGS_UEVENT_CONSTRAINT (0x1c0 ,0x100000000ULL ),/* INST_RETIRED.PREC_DIST */ +INTEL_FLAGS_UEVENT_CONSTRAINT (0x01c0 ,0x100000000ULL ),/* old INST_RETIRED.PREC_DIST */ +INTEL_FLAGS_UEVENT_CONSTRAINT (0x0100 ,0x100000000ULL ),/* INST_RETIRED.PREC_DIST */ INTEL_FLAGS_UEVENT_CONSTRAINT (0x0400 ,0x800000000ULL ),/* SLOTS */ INTEL_PLD_CONSTRAINT (0x1cd ,0xff ),/* MEM_TRANS_RETIRED.LOAD_LATENCY */
@@ -943,7 +944,7 @@ struct event_constraint intel_icl_pebs_event_constraints[] = { };struct event_constraint intel_spr_pebs_event_constraints[] = { -INTEL_FLAGS_UEVENT_CONSTRAINT (0x1c0 ,0x100000000ULL ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x100 ,0x100000000ULL ),/* INST_RETIRED.PREC_DIST */ INTEL_FLAGS_UEVENT_CONSTRAINT (0x0400 ,0x800000000ULL ),INTEL_FLAGS_EVENT_CONSTRAINT (0xc0 ,0xfe ),
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 330/849 parisc: fix warning in flush_tlb_all
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
[ Upstream commit 1030d681319b43869e0d5b568b9d0226652d1a6f ]
I've got the following splat after enabling preemption:
[ 3.724721] BUG: using __this_cpu_add() in preemptible [00000000] code: swapper/0/1 [ 3.734630] caller is __this_cpu_preempt_check+0x38/0x50 [ 3.740635] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.15.0-rc4-64bit+ #324 [ 3.744605] Hardware name: 9000/785/C8000 [ 3.744605] Backtrace: [ 3.744605] [<00000000401d9d58>] show_stack+0x74/0xb0 [ 3.744605] [<0000000040c27bd4>] dump_stack_lvl+0x10c/0x188 [ 3.744605] [<0000000040c27c84>] dump_stack+0x34/0x48 [ 3.744605] [<0000000040c33438>] check_preemption_disabled+0x178/0x1b0 [ 3.744605] [<0000000040c334f8>] __this_cpu_preempt_check+0x38/0x50 [ 3.744605] [<00000000401d632c>] flush_tlb_all+0x58/0x2e0 [ 3.744605] [<00000000401075c0>] 0x401075c0 [ 3.744605] [<000000004010b8fc>] 0x4010b8fc [ 3.744605] [<00000000401080fc>] 0x401080fc [ 3.744605] [<00000000401d5224>] do_one_initcall+0x128/0x378 [ 3.744605] [<0000000040102de8>] 0x40102de8 [ 3.744605] [<0000000040c33864>] kernel_init+0x60/0x3a8 [ 3.744605] [<00000000401d1020>] ret_from_kernel_thread+0x20/0x28 [ 3.744605]
Fix this by moving the __inc_irq_stat() into the locked section.
--- arch/parisc/mm/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/parisc/mm/init.c +2 -2
@@ -842,9 +842,9 @@ void flush_tlb_all(void) {int do_recycle; -__inc_irq_stat (irq_tlb_count); do_recycle =0 ;spin_lock (&sid_lock); +__inc_irq_stat (irq_tlb_count);if (dirty_space_ids >RECYCLE_THRESHOLD ) {BUG_ON (recycle_inuse);/* FIXME: Use a semaphore/wait queue here */ get_dirty_sids (&recycle_ndirty,recycle_dirty_array);
@@ -863,8 +863,8 @@ void flush_tlb_all(void)#else void flush_tlb_all (void ) { -__inc_irq_stat (irq_tlb_count);spin_lock (&sid_lock); +__inc_irq_stat (irq_tlb_count);flush_tlb_all_local (NULL );recycle_sids ();spin_unlock (&sid_lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 331/849 task_stack: Fix end_of_stack() for architectures with upwards-growing stack
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 9cc2fa4f4a92ccc6760d764e7341be46ee8aaaa1 ]
The function end_of_stack() returns a pointer to the last entry of a stack. For architectures like parisc where the stack grows upwards return the pointer to the highest address in the stack.
Without this change I faced a crash on parisc, because the stackleak functionality wrote STACKLEAK_POISON to the lowest address and thus overwrote the first 4 bytes of the task_struct which included the TIF_FLAGS.
--- include/linux/sched/task_stack.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/sched/task_stack.h +4 -0
@@ -25,7 +25,11 @@ static inline void *task_stack_page(const struct task_struct *task)static inline unsigned long *end_of_stack (const struct task_struct *task) { +#ifdef CONFIG_STACK_GROWSUP +return (unsigned long *)((unsigned long )task->stack +THREAD_SIZE ) -1 ; +#else return task->stack; +#endif }#elif !defined(__HAVE_THREAD_FUNCTIONS)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 332/849 erofs: dont trigger WARN() when decompression fails
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit a0961f351d82d43ab0b845304caa235dfe249ae9 ]
syzbot reported a WARNING [1] due to corrupted compressed data.
As Dmitry said, "If this is not a kernel bug, then the code should not use WARN. WARN if for kernel bugs and is recognized as such by all testing systems and humans."
[1] https://lore.kernel.org/r/[email protected]
--- fs/erofs/decompressor.c | 1 - 1 file changed, 1 deletion(-)
fs/erofs/decompressor.c +0 -1
@@ -233,7 +233,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)erofs_err (rq->sb,"failed to decompress %d in[%u, %u] out[%u]" , ret, rq->inputsize, inputmargin, rq->outputsize); -WARN_ON (1 );print_hex_dump (KERN_DEBUG ,"[ in]: " ,DUMP_PREFIX_OFFSET ,16 ,1 , src + inputmargin, rq->inputsize, true); print_hex_dump(KERN_DEBUG, "[out]: ", DUMP_PREFIX_OFFSET,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 333/849 parisc/unwind: fix unwinder when CONFIG_64BIT is enabled
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
[ Upstream commit 8e0ba125c2bf1030af3267058019ba86da96863f ]
With 64 bit kernels unwind_special() is not working because it compares the pc to the address of the function descriptor. Add a helper function that compares pc with the dereferenced address. This fixes all of the backtraces on my c8000. Without this changes, a lot of backtraces are missing in kdb or the show-all-tasks command from /proc/sysrq-trigger.
--- arch/parisc/kernel/unwind.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
arch/parisc/kernel/unwind.c +14 -7
@@ -21,6 +21,8 @@#include <asm/ptrace.h> #include <asm/unwind.h> +#include <asm/switch_to.h> +#include <asm/sections.h> /* #define DEBUG 1 */ #ifdef DEBUG
@@ -203,6 +205,11 @@ int __init unwind_init(void)return 0 ; } +static bool pc_is_kernel_fn (unsigned long pc,void *fn) +{ +return (unsigned long )dereference_kernel_function_descriptor (fn) == pc; +} +static int unwind_special (struct unwind_frame_info *info,unsigned long pc,int frame_size) {/*
@@ -221,7 +228,7 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, intextern void *const _call_on_stack;#endif /* CONFIG_IRQSTACKS */ -if (pc == (unsigned long ) &handle_interruption) { +if (pc_is_kernel_fn (pc, handle_interruption)) {struct pt_regs *regs = (struct pt_regs *)(info->sp - frame_size -PT_SZ_ALGN );dbg ("Unwinding through handle_interruption()\n" ); info->prev_sp = regs->gr[30 ];
@@ -229,13 +236,13 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, intreturn 1 ; } -if (pc == (unsigned long ) &ret_from_kernel_thread || - pc == (unsigned long ) &syscall_exit) { +if (pc_is_kernel_fn (pc, ret_from_kernel_thread) || +pc_is_kernel_fn (pc, syscall_exit)) { info->prev_sp = info->prev_ip =0 ;return 1 ; } -if (pc == (unsigned long ) &intr_return) { +if (pc_is_kernel_fn (pc, intr_return)) {struct pt_regs *regs;dbg ("Found intr_return()\n" );
@@ -246,20 +253,20 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, intreturn 1 ; } -if (pc == (unsigned long ) &_switch_to_ret) { +if (pc_is_kernel_fn (pc, _switch_to) || +pc_is_kernel_fn (pc, _switch_to_ret)) { info->prev_sp = info->sp -CALLEE_SAVE_FRAME_SIZE ; info->prev_ip = *(unsigned long *)(info->prev_sp -RP_OFFSET );return 1 ; }#ifdef CONFIG_IRQSTACKS -if (pc == (unsigned long ) &_call_on_stack) { +if (pc_is_kernel_fn (pc, _call_on_stack)) { info->prev_sp = *(unsigned long *)(info->sp -FRAME_SIZE -REG_SZ ); info->prev_ip = *(unsigned long *)(info->sp -FRAME_SIZE -RP_OFFSET );return 1 ; }#endif -return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 334/849 parisc/kgdb: add kgdb_roundup() to make kgdb work with idle polling
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
[ Upstream commit 66e29fcda1824f0427966fbee2bd2c85bf362c82 ]
With idle polling, IPIs are not sent when a CPU idle, but queued and run later from do_idle(). The default kgdb_call_nmi_hook() implementation gets the pointer to struct pt_regs from get_irq_reqs(), which doesn't work in that case because it was not called from the IPI interrupt handler. Fix it by defining our own kgdb_roundup() function which sents an IPI_ENTER_KGDB. When that IPI is received on the target CPU kgdb_nmicallback() is called.
--- arch/parisc/kernel/smp.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
arch/parisc/kernel/smp.c +17 -2
@@ -29,6 +29,7 @@#include <linux/bitops.h> #include <linux/ftrace.h> #include <linux/cpu.h> +#include <linux/kgdb.h> #include <linux/atomic.h> #include <asm/current.h>
@@ -69,7 +70,10 @@ enum ipi_message_type {IPI_CALL_FUNC ,IPI_CPU_START ,IPI_CPU_STOP , - IPI_CPU_TEST +IPI_CPU_TEST , +#ifdef CONFIG_KGDB + IPI_ENTER_KGDB, +#endif };
@@ -167,7 +171,12 @@ ipi_interrupt(int irq, void *dev_id)case IPI_CPU_TEST :smp_debug (100 ,KERN_DEBUG "CPU%d is alive!\n" , this_cpu);break ; - +#ifdef CONFIG_KGDB +case IPI_ENTER_KGDB : +smp_debug (100 ,KERN_DEBUG "CPU%d ENTER_KGDB\n" , this_cpu); +kgdb_nmicallback (raw_smp_processor_id (),get_irq_regs ()); +break ; +#endif default :printk (KERN_CRIT "Unknown IPI num on CPU%d: %lu\n" , this_cpu, which);
@@ -226,6 +235,12 @@ send_IPI_allbutself(enum ipi_message_type op) } } +#ifdef CONFIG_KGDB +void kgdb_roundup_cpus (void ) +{ +send_IPI_allbutself (IPI_ENTER_KGDB ); +} +#endif inline void smp_send_stop (void ) {send_IPI_allbutself (IPI_CPU_STOP ); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 335/849 netfilter: conntrack: set on IPS_ASSURED if flows enters internal stream state
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b7b1d02fc43925a4d569ec221715db2dfa1ce4f5 ]
The internal stream state sets the timeout to 120 seconds 2 seconds after the creation of the flow, attach this internal stream state to the IPS_ASSURED flag for consistent event reporting.
Before this patch:
[NEW] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 [UNREPLIED] src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] [DESTROY] udp 17 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED]
Note IPS_ASSURED for the flow not yet in the internal stream state.
after this update:
[NEW] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 [UNREPLIED] src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 120 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] [DESTROY] udp 17 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED]
Before this patch, short-lived UDP flows never entered IPS_ASSURED, so they were already candidate flow to be deleted by early_drop under stress.
Before this patch, IPS_ASSURED is set on regardless the internal stream state, attach this internal stream state to IPS_ASSURED.
packet #1 (original direction) enters NEW state
packet #2 (reply direction) enters ESTABLISHED state, sets on IPS_SEEN_REPLY paclet #3 (any direction) sets on IPS_ASSURED (if 2 seconds since the
creation has passed by).
--- net/netfilter/nf_conntrack_proto_udp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_udp.c +5 -2
@@ -104,10 +104,13 @@ int nf_conntrack_udp_packet(struct nf_conn *ct,*/ if (test_bit (IPS_SEEN_REPLY_BIT , &ct->status)) {unsigned long extra = timeouts[UDP_CT_UNREPLIED ]; +bool stream = false;/* Still active after two seconds? Extend timeout. */ -if (time_after (jiffies, ct->proto.udp.stream_ts)) +if (time_after (jiffies, ct->proto.udp.stream_ts)) { extra = timeouts[UDP_CT_REPLIED ]; + stream = true; + }nf_ct_refresh_acct (ct, ctinfo, skb, extra);
@@ -116,7 +119,7 @@ int nf_conntrack_udp_packet(struct nf_conn *ct,return NF_ACCEPT ;/* Also, more likely to be important, and not a probe */ -if (!test_and_set_bit (IPS_ASSURED_BIT , &ct->status)) +if (stream && !test_and_set_bit (IPS_ASSURED_BIT , &ct->status))nf_conntrack_event_cache (IPCT_ASSURED , ct); }else {nf_ct_refresh_acct (ct, ctinfo, skb, timeouts[UDP_CT_UNREPLIED ]);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 336/849 selftests/bpf: Fix strobemeta selftest regression
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 0133c20480b14820d43c37c0e9502da4bffcad3a ]
After most recent nightly Clang update strobemeta selftests started failing with the following error (relevant portion of assembly included):
1624: (85) call bpf_probe_read_user_str#114
1625: (bf) r1 = r0
1626: (18) r2 = 0xfffffffe
1628: (5f) r1 &= r2
1629: (55) if r1 != 0x0 goto pc+7
1630: (07) r9 += 104
1631: (6b) *(u16 *)(r9 +0) = r0
1632: (67) r0 <<= 32
1633: (77) r0 >>= 32
1634: (79) r1 = *(u64 *)(r10 -456)
1635: (0f) r1 += r0
1636: (7b) *(u64 *)(r10 -456) = r1
1637: (79) r1 = *(u64 *)(r10 -368)
1638: (c5) if r1 s< 0x1 goto pc+778
1639: (bf) r6 = r8
1640: (0f) r6 += r7
1641: (b4) w1 = 0
1642: (6b) *(u16 *)(r6 +108) = r1
1643: (79) r3 = *(u64 *)(r10 -352)
1644: (79) r9 = *(u64 *)(r10 -456)
1645: (bf) r1 = r9
1646: (b4) w2 = 1
1647: (85) call bpf_probe_read_user_str#114
R1 unbounded memory access, make sure to bounds check any such access
In the above code r0 and r1 are implicitly related. Clang knows that, but verifier isn't able to infer this relationship.
Yonghong Song narrowed down this "regression" in code generation to a recent Clang optimization change ([0]), which for BPF target generates code pattern that BPF verifier can't handle and loses track of register boundaries.
This patch works around the issue by adding an BPF assembly-based helper that helps to prove to the verifier that upper bound of the register is a given constant by controlling the exact share of generated BPF instruction sequence. This fixes the immediate issue for strobemeta selftest.
[0] https://github.com/llvm/llvm-project/commit/acabad9ff6bf13e00305d9d8621ee8eafc1f8b08
--- tools/testing/selftests/bpf/progs/strobemeta.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/testing/selftests/bpf/progs/strobemeta.h +11 -0
@@ -10,6 +10,14 @@#include <linux/types.h> #include <bpf/bpf_helpers.h> +#define bpf_clamp_umax (VAR ,UMAX ) \ + asm volatile ( \ + "if %0 <= %[max] goto +1\n" \ + "%0 = %[max]\n" \ + : "+r"(VAR) \ + : [max]"i"(UMAX) \ + ) +typedef uint32_t pid_t ;struct task_struct {};
@@ -413,6 +421,7 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg, len =bpf_probe_read_user_str (payload,STROBE_MAX_STR_LEN , map.tag);if (len <=STROBE_MAX_STR_LEN ) { +bpf_clamp_umax (len,STROBE_MAX_STR_LEN ); descr->tag_len = len; payload += len; }
@@ -430,6 +439,7 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg, len =bpf_probe_read_user_str (payload,STROBE_MAX_STR_LEN , map.entries[i].key);if (len <=STROBE_MAX_STR_LEN ) { +bpf_clamp_umax (len,STROBE_MAX_STR_LEN ); descr->key_lens[i] = len; payload += len; }
@@ -437,6 +447,7 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg, len =bpf_probe_read_user_str (payload,STROBE_MAX_STR_LEN , map.entries[i].val);if (len <=STROBE_MAX_STR_LEN ) { +bpf_clamp_umax (len,STROBE_MAX_STR_LEN ); descr->val_lens[i] = len; payload += len; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 337/849 fbdev/efifb: Release PCI devices runtime PM ref during FB destroy
In reply to Greg Kroah-HartmanFrom: Imre Deak <[email protected]>
[ Upstream commit 55285e21f04517939480966164a33898c34b2af2 ]
Atm the EFI FB platform driver gets a runtime PM reference for the associated GFX PCI device during probing the EFI FB platform device and releases it only when the platform device gets unbound.
When fbcon switches to the FB provided by the PCI device's driver (for instance i915/drmfb), the EFI FB will get only unregistered without the EFI FB platform device getting unbound, keeping the runtime PM reference acquired during the platform device probing. This reference will prevent the PCI driver from runtime suspending the device.
Fix this by releasing the RPM reference from the EFI FB's destroy hook, called when the FB gets unregistered.
While at it assert that pm_runtime_get_sync() didn't fail.
v2:
- Move pm_runtime_get_sync() before register_framebuffer() to avoid its race wrt. efifb_destroy()->pm_runtime_put(). (Daniel)
- Assert that pm_runtime_get_sync() didn't fail.
- Clarify commit message wrt. platform/PCI device/driver and driver removal vs. device unbinding.
--- drivers/video/fbdev/efifb.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/video/fbdev/efifb.c +14 -7
@@ -47,6 +47,8 @@ static bool use_bgrt = true;static bool request_mem_succeeded = false;static u64 mem_flags =EFI_MEMORY_WC |EFI_MEMORY_UC ; +static struct pci_dev *efifb_pci_dev;/* dev with BAR covering the efifb */ +static struct fb_var_screeninfo efifb_defined = { .activate =FB_ACTIVATE_NOW , .height =-1 ,
@@ -243,6 +245,9 @@ static inline void efifb_show_boot_graphics(struct fb_info *info) {}static void efifb_destroy (struct fb_info *info) { +if (efifb_pci_dev) +pm_runtime_put (&efifb_pci_dev->dev); +if (info->screen_base) {if (mem_flags & (EFI_MEMORY_UC |EFI_MEMORY_WC ))iounmap (info->screen_base);
@@ -333,7 +338,6 @@ ATTRIBUTE_GROUPS(efifb);static bool pci_dev_disabled;/* FB base matches BAR of a disabled device */ -static struct pci_dev *efifb_pci_dev;/* dev with BAR covering the efifb */ static struct resource *bar_resource;static u64 bar_offset;
@@ -569,17 +573,22 @@ static int efifb_probe(struct platform_device *dev)pr_err ("efifb: cannot allocate colormap\n" ); goto err_groups; } + +if (efifb_pci_dev) +WARN_ON (pm_runtime_get_sync (&efifb_pci_dev->dev) <0 ); + err =register_framebuffer (info);if (err <0 ) {pr_err ("efifb: cannot register framebuffer\n" ); - goto err_fb_dealoc; + goto err_put_rpm_ref; }fb_info (info,"%s frame buffer device\n" , info->fix.id); -if (efifb_pci_dev) -pm_runtime_get_sync (&efifb_pci_dev->dev);return 0 ; -err_fb_dealoc: +err_put_rpm_ref: +if (efifb_pci_dev) +pm_runtime_put (&efifb_pci_dev->dev); +fb_dealloc_cmap (&info->cmap); err_groups:sysfs_remove_groups (&dev->dev.kobj, efifb_groups);
@@ -603,8 +612,6 @@ static int efifb_remove(struct platform_device *pdev)unregister_framebuffer (info);sysfs_remove_groups (&pdev->dev.kobj, efifb_groups);framebuffer_release (info); -if (efifb_pci_dev) -pm_runtime_put (&efifb_pci_dev->dev);return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 338/849 drm/bridge: anx7625: Propagate errors from sp_tx_rst_aux()
In reply to Greg Kroah-HartmanFrom: Robert Foss <[email protected]>
[ Upstream commit 7f16d0f3b8e2d13f940e944cd17044ca8eeb8b32 ]
The return value of sp_tx_rst_aux() is not propagated, which means both compiler warnings and potential errors not being handled.
--- drivers/gpu/drm/bridge/analogix/anx7625.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/analogix/anx7625.c +8 -4
@@ -702,7 +702,7 @@ static int edid_read(struct anx7625_data *ctx, ret =sp_tx_aux_rd (ctx,0xf1 );if (ret) { -sp_tx_rst_aux (ctx); + ret =sp_tx_rst_aux (ctx);DRM_DEV_DEBUG_DRIVER (dev,"edid read fail, reset!\n" ); }else { ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
@@ -717,7 +717,7 @@ static int edid_read(struct anx7625_data *ctx,if (cnt >EDID_TRY_CNT )return -EIO ; -return 0 ; +return ret; } static int segments_edid_read(struct anx7625_data *ctx,
@@ -767,7 +767,7 @@ static int segments_edid_read(struct anx7625_data *ctx,if (cnt >EDID_TRY_CNT )return -EIO ; -return 0 ; +return ret; } static int sp_tx_edid_read(struct anx7625_data *ctx,
@@ -869,7 +869,11 @@ static int sp_tx_edid_read(struct anx7625_data *ctx, }/* Reset aux channel */ -sp_tx_rst_aux (ctx); + ret =sp_tx_rst_aux (ctx); +if (ret <0 ) { +DRM_DEV_ERROR (dev,"Failed to reset aux channel!\n" ); +return ret; + }return (blocks_num +1 ); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 339/849 drm/bridge: it66121: Initialize {device,vendor}_ids
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
[ Upstream commit 3a5f3d61de657bc1c2b53b77d065c5526f982e10 ]
These two arrays are populated with data read from the I2C device through regmap_read(), and the data is then compared with hardcoded vendor/product ID values of supported chips.
However, the return value of regmap_read() was never checked. This is fine, as long as the two arrays are zero-initialized, so that we don't compare the vendor/product IDs against whatever garbage is left on the stack.
Address this issue by zero-initializing these two arrays.
--- drivers/gpu/drm/bridge/ite-it66121.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it66121.c +1 -1
@@ -889,7 +889,7 @@ unlock:static int it66121_probe (struct i2c_client *client,const struct i2c_device_id *id) { -u32 vendor_ids[2 ], device_ids[2 ], revision_id; +u32 revision_id, vendor_ids[2 ] = {0 }, device_ids[2 ] = {0 };struct device_node *ep;int ret;struct it66121_ctx *ctx;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 340/849 drm/bridge: it66121: Wait for next bridge to be probed
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
[ Upstream commit 8b03e3fc79189b17d31a82f5e175698802a11e87 ]
If run before the next bridge is initialized, of_drm_find_bridge() will give us a NULL pointer.
If that's the case, return -EPROBE_DEFER; we may have more luck next time.
--- drivers/gpu/drm/bridge/ite-it66121.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/bridge/ite-it66121.c +3 -0
@@ -924,6 +924,9 @@ static int it66121_probe(struct i2c_client *client, ctx->next_bridge =of_drm_find_bridge (ep);of_node_put (ep); +if (!ctx->next_bridge) +return -EPROBE_DEFER ; +i2c_set_clientdata (client, ctx);mutex_init (&ctx->lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 341/849 Bluetooth: fix init and cleanup of sco_conn.timeout_work
In reply to Greg Kroah-HartmanFrom: Desmond Cheong Zhi Xi <[email protected]>
[ Upstream commit 49d8a5606428ca0962d09050a5af81461ff90fbb ]
Before freeing struct sco_conn, all delayed timeout work should be cancelled. Otherwise, sco_sock_timeout could potentially use the sco_conn after it has been freed.
Additionally, sco_conn.timeout_work should be initialized when the connection is allocated, not when the channel is added. This is because an sco_conn can create channels with multiple sockets over its lifetime, which happens if sockets are released but the connection isn't deleted.
--- net/bluetooth/sco.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/sco.c +4 -5
@@ -134,6 +134,7 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon)return NULL ;spin_lock_init (&conn->lock); +INIT_DELAYED_WORK (&conn->timeout_work, sco_sock_timeout); hcon->sco_data = conn; conn->hcon = hcon;
@@ -197,11 +198,11 @@ static void sco_conn_del(struct hci_conn *hcon, int err)sco_chan_del (sk, err);bh_unlock_sock (sk);sock_put (sk); - -/* Ensure no more work items will run before freeing conn. */ -cancel_delayed_work_sync (&conn->timeout_work); } +/* Ensure no more work items will run before freeing conn. */ +cancel_delayed_work_sync (&conn->timeout_work); + hcon->sco_data =NULL ;kfree (conn); }
@@ -214,8 +215,6 @@ static void __sco_chan_add(struct sco_conn *conn, struct sock *sk,sco_pi (sk)->conn = conn; conn->sk = sk; -INIT_DELAYED_WORK (&conn->timeout_work, sco_sock_timeout); -if (parent)bt_accept_enqueue (parent, sk, true); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 342/849 libbpf: Dont crash on object files with no symbol tables
In reply to Greg Kroah-HartmanFrom: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 03e601f48b2da6fb44d0f7b86957a8f6bacfb347 ]
If libbpf encounters an ELF file that has been stripped of its symbol table, it will crash in bpf_object__add_programs() when trying to dereference the obj->efile.symbols pointer.
Fix this by erroring out of bpf_object__elf_collect() if it is not able able to find the symbol table.
v2:
- Move check into bpf_object__elf_collect() and add nice error message
--- tools/lib/bpf/libbpf.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/lib/bpf/libbpf.c +6 -0
@@ -2990,6 +2990,12 @@ static int bpf_object__elf_collect(struct bpf_object *obj) } } +if (!obj->efile.symbols) { +pr_warn ("elf: couldn't find symbol table in %s, stripped object file?\n" , + obj->path); +return -ENOENT ; + } + scn =NULL ;while ((scn =elf_nextscn (elf, scn)) !=NULL ) { idx++;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 343/849 rcu: Fix existing exp request check in sync_sched_exp_online_cleanup()
In reply to Greg Kroah-HartmanFrom: Neeraj Upadhyay <[email protected]>
[ Upstream commit f0b2b2df5423fb369ac762c77900bc7765496d58 ]
The sync_sched_exp_online_cleanup() checks to see if RCU needs an expedited quiescent state from the incoming CPU, sending it an IPI if so. Before sending IPI, it checks whether expedited qs need has been already requested for the incoming CPU, by checking rcu_data.cpu_no_qs.b.exp for the current cpu, on which sync_sched_exp_online_cleanup() is running. This works for the case where incoming CPU is same as self. However, for the case where incoming CPU is different from self, expedited request won't get marked, which can potentially delay reporting of expedited quiescent state for the incoming CPU.
--- kernel/rcu/tree_exp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree_exp.h +1 -1
@@ -760,7 +760,7 @@ static void sync_sched_exp_online_cleanup(int cpu) my_cpu =get_cpu ();/* Quiescent state either not needed or already requested, leave. */ if (!(READ_ONCE (rnp->expmask) & rdp->grpmask) || -__this_cpu_read (rcu_data.cpu_no_qs.b.exp)) { + rdp->cpu_no_qs.b.exp) {put_cpu ();return ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 344/849 MIPS: lantiq: dma: fix burst length for DEU
In reply to Greg Kroah-HartmanFrom: Aleksander Jan Bajkowski <[email protected]>
[ Upstream commit 5ad74d39c51dd41b3c819f4f5396655f0629b4fd ]
The current definition of 2W burst length is invalid. This patch fixes it. Current downstream DEU driver doesn't use DMA. An incorrect burst length value doesn't cause any errors. This patch also adds other burst length values.
--- arch/mips/lantiq/xway/dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/mips/lantiq/xway/dma.c +7 -2
@@ -41,7 +41,11 @@#define DMA_IRQ_ACK 0x7e/* IRQ status register */ #define DMA_POLL BIT(31)/* turn on channel polling */ #define DMA_CLK_DIV4 BIT(6)/* polling clock divider */ -#define DMA_2W_BURST BIT(1)/* 2 word burst length */ +#define DMA_PCTRL_2W_BURST 0x1/* 2 word burst length */ +#define DMA_PCTRL_4W_BURST 0x2/* 4 word burst length */ +#define DMA_PCTRL_8W_BURST 0x3/* 8 word burst length */ +#define DMA_TX_BURST_SHIFT 4/* tx burst shift */ +#define DMA_RX_BURST_SHIFT 2/* rx burst shift */ #define DMA_ETOP_ENDIANNESS (0xf << 8)/* endianness swap etop channels */ #define DMA_WEIGHT (BIT(17) | BIT(16))/* default channel wheight */
@@ -192,7 +196,8 @@ ltq_dma_init_port(int p)break ;case DMA_PORT_DEU : -ltq_dma_w32 ((DMA_2W_BURST <<4 ) | (DMA_2W_BURST <<2 ), +ltq_dma_w32 ((DMA_PCTRL_2W_BURST <<DMA_TX_BURST_SHIFT ) | + (DMA_PCTRL_2W_BURST <<DMA_RX_BURST_SHIFT ),LTQ_DMA_PCTRL );break ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 345/849 x86/xen: Mark cpu_bringup_and_idle() as dead_end_function
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 9af9dcf11bda3e2c0e24c1acaacb8685ad974e93 ]
The asm_cpu_bringup_and_idle() function is required to push the return value on the stack in order to make ORC happy, but the only reason objtool doesn't complain is because of a happy accident.
The thing is that asm_cpu_bringup_and_idle() doesn't return, so validate_branch() never terminates and falls through to the next function, which in the normal case is the hypercall_page. And that, as it happens, is 4095 NOPs and a RET.
Make asm_cpu_bringup_and_idle() terminate on it's own, by making the function it calls as a dead-end. This way we no longer rely on what code happens to come after.
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
@@ -173,6 +173,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"rewind_stack_do_exit" ,"kunit_try_catch_throw" ,"xen_start_kernel" , + "cpu_bringup_and_idle", };if (!func)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 346/849 objtool: Handle __sanitize_cov*() tail calls
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit f56dae88a81fded66adf2bea9922d1d98d1da14f ]
Turns out the compilers also generate tail calls to __sanitize_cov*(), make sure to also patch those out in noinstr code.
--- tools/objtool/arch/x86/decode.c | 20 ++++ tools/objtool/check.c | 158 ++++++++++++++------------- tools/objtool/include/objtool/arch.h | 1 + 3 files changed, 105 insertions(+), 74 deletions(-)
tools/objtool/arch/x86/decode.c +20 -0
@@ -659,6 +659,26 @@ const char *arch_nop_insn(int len)return nops[len-1 ]; } +#define BYTE_RET 0xC3 + +const char *arch_ret_insn (int len) +{ +static const char ret[5 ][5 ] = { + {BYTE_RET }, + {BYTE_RET ,BYTES_NOP1 }, + {BYTE_RET ,BYTES_NOP2 }, + {BYTE_RET ,BYTES_NOP3 }, + {BYTE_RET ,BYTES_NOP4 }, + }; + +if (len <1 || len >5 ) { +WARN ("invalid RET size: %d\n" , len); +return NULL ; + } + +return ret[len-1 ]; +} +/* asm/alternative.h ? */ #define ALTINSTR_FLAG_INV (1 << 15)
tools/objtool/check.c +84 -74
213 lines not on this page · raw message
tools/objtool/include/objtool/arch.h +1 -0
@@ -82,6 +82,7 @@ unsigned long arch_jump_destination(struct instruction *insn);unsigned long arch_dest_reloc_offset (int addend);const char *arch_nop_insn (int len); +const char *arch_ret_insn (int len);int arch_decode_hint_reg (struct instruction *insn,u8 sp_reg);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 347/849 drm/v3d: fix wait for TMU write combiner flush
In reply to Greg Kroah-HartmanFrom: Iago Toral Quiroga <[email protected]>
[ Upstream commit e4f868191138975f2fdf2f37c11318b47db4acc9 ]
The hardware sets the TMUWCF bit back to 0 when the TMU write combiner flush completes so we should be checking for that instead of the L2TFLS bit.
v2 (Melissa Wen):
- Add Signed-off-by and Fixes tags.
- Change the error message for the timeout to be more clear.
Fixes spurious Vulkan CTS failures in:
dEQP-VK.binding_model.descriptorset_random.*
--- drivers/gpu/drm/v3d/v3d_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/v3d/v3d_gem.c +2 -2
@@ -195,8 +195,8 @@ v3d_clean_caches(struct v3d_dev *v3d)V3D_CORE_WRITE (core,V3D_CTL_L2TCACTL ,V3D_L2TCACTL_TMUWCF );if (wait_for (!(V3D_CORE_READ (core,V3D_CTL_L2TCACTL ) & -V3D_L2TCACTL_L2TFLS ),100 )) { -DRM_ERROR ("Timeout waiting for L1T write combiner flush\n" ); +V3D_L2TCACTL_TMUWCF ),100 )) { +DRM_ERROR ("Timeout waiting for TMU write combiner flush\n" ); }mutex_lock (&v3d->cache_clean_lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 348/849 virtio-gpu: fix possible memory allocation failure
In reply to Greg Kroah-HartmanFrom: liuyuntao <[email protected]>
[ Upstream commit 5bd4f20de8acad37dbb3154feb34dbc36d506c02 ]
When kmem_cache_zalloc in virtio_gpu_get_vbuf fails, it will return an error code. But none of its callers checks this error code, and a core dump will take place.
Considering many of its callers can't handle such error, I add a __GFP_NOFAIL flag when calling kmem_cache_zalloc to make sure it won't fail, and delete those unused error handlings.
--- drivers/gpu/drm/virtio/virtgpu_vq.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +1 -7
@@ -91,9 +91,7 @@ virtio_gpu_get_vbuf(struct virtio_gpu_device *vgdev, {struct virtio_gpu_vbuffer *vbuf; - vbuf =kmem_cache_zalloc (vgdev->vbufs,GFP_KERNEL ); -if (!vbuf) -return ERR_PTR (-ENOMEM ); + vbuf =kmem_cache_zalloc (vgdev->vbufs,GFP_KERNEL | __GFP_NOFAIL);BUG_ON (size >MAX_INLINE_CMD_SIZE || size <sizeof (struct virtio_gpu_ctrl_hdr ));
@@ -147,10 +145,6 @@ static void *virtio_gpu_alloc_cmd_resp(struct virtio_gpu_device *vgdev, vbuf =virtio_gpu_get_vbuf (vgdev, cmd_size, resp_size, resp_buf, cb); -if (IS_ERR (vbuf)) { - *vbuffer_p =NULL ; -return ERR_CAST (vbuf); - } *vbuffer_p = vbuf;return (struct virtio_gpu_command *)vbuf->buf; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 349/849 lockdep: Let lock_is_held_type() detect recursive read as read
In reply to Greg Kroah-HartmanFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 2507003a1d10917c9158077bf6030719d02c941e ]
lock_is_held_type(, 1) detects acquired read locks. It only recognized locks acquired with lock_acquire_shared(). Read locks acquired with lock_acquire_shared_recursive() are not recognized because a `2' is stored as the read value.
Rework the check to additionally recognise lock's read value one and two as a read held lock.
--- kernel/locking/lockdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/lockdep.c +1 -1
@@ -5366,7 +5366,7 @@ int __lock_is_held(const struct lockdep_map *lock, int read)struct held_lock *hlock = curr->held_locks + i;if (match_held_lock (hlock, lock)) { -if (read ==-1 || hlock->read == read) +if (read ==-1 || !!hlock->read == read)return LOCK_STATE_HELD ;return LOCK_STATE_NOT_HELD ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 350/849 net: net_namespace: Fix undefined member in key_remove_domain()
In reply to Greg Kroah-HartmanFrom: Yajun Deng <[email protected]>
[ Upstream commit aed0826b0cf2e488900ab92193893e803d65c070 ]
The key_domain member in struct net only exists if we define CONFIG_KEYS. So we should add the define when we used key_domain.
--- net/core/net_namespace.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/net_namespace.c +4 -0
@@ -477,7 +477,9 @@ struct net *copy_net_ns(unsigned long flags,if (rv <0 ) { put_userns: +#ifdef CONFIG_KEYS key_remove_domain (net->key_domain); +#endif put_user_ns (user_ns);net_drop_ns (net); dec_ucounts:
@@ -609,7 +611,9 @@ static void cleanup_net(struct work_struct *work)list_for_each_entry_safe (net, tmp, &net_exit_list, exit_list) {list_del_init (&net->exit_list);dec_net_namespaces (net->ucounts); +#ifdef CONFIG_KEYS key_remove_domain (net->key_domain); +#endif put_user_ns (net->user_ns);net_drop_ns (net); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 351/849 net: phylink: dont call netif_carrier_off() with NULL netdev
In reply to Greg Kroah-HartmanFrom: Russell King (Oracle) <[email protected]>
[ Upstream commit cbcca2e3961eac736566ac13ef0d0bf6f0b764ec ]
Dan Carpenter points out that we have a code path that permits a NULL netdev pointer to be passed to netif_carrier_off(), which will cause a kernel oops. In any case, we need to set pl->old_link_state to false to have the desired effect when there is no netdev present.
--- drivers/net/phy/phylink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/phy/phylink.c +4 -1
@@ -1332,7 +1332,10 @@ void phylink_suspend(struct phylink *pl, bool mac_wol)* but one would hope all packets have been sent. This * also means phylink_resolve() will do nothing. */ -netif_carrier_off (pl->netdev); +if (pl->netdev) +netif_carrier_off (pl->netdev); +else + pl->old_link_state = false;/* We do not call mac_link_down() here as we want the * link to remain up to receive the WoL packets.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 352/849 drm: bridge: it66121: Fix return value it66121_probe
In reply to Greg Kroah-HartmanFrom: Alex Bee <[email protected]>
[ Upstream commit f3bc07eba481942a246926c5b934199e7ccd567b ]
Currently it66121_probe returns -EPROBE_DEFER if the there is no remote endpoint found in the device tree which doesn't seem helpful, since this is not going to change later and it is never checked if the next bridge has been initialized yet. It will fail in that case later while doing drm_bridge_attach for the next bridge in it66121_bridge_attach.
Since the bindings documentation for it66121 bridge driver states there has to be a remote endpoint defined, its safe to return -EINVAL in that case.
This additonally adds a check, if the remote endpoint is enabled and returns -EPROBE_DEFER, if the remote bridge hasn't been initialized (yet).
--- drivers/gpu/drm/bridge/ite-it66121.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it66121.c +14 -2
@@ -918,11 +918,23 @@ static int it66121_probe(struct i2c_client *client,return -EINVAL ; ep =of_graph_get_remote_node (dev->of_node,1 ,-1 ); -if (!ep) -return -EPROBE_DEFER ; +if (!ep) { +dev_err (ctx->dev,"The endpoint is unconnected\n" ); +return -EINVAL ; + } + +if (!of_device_is_available (ep)) { +of_node_put (ep); +dev_err (ctx->dev,"The remote device is disabled\n" ); +return -ENODEV ; + } ctx->next_bridge =of_drm_find_bridge (ep);of_node_put (ep); +if (!ctx->next_bridge) { +dev_dbg (ctx->dev,"Next bridge not found, deferring probe\n" ); +return -EPROBE_DEFER ; + }if (!ctx->next_bridge)return -EPROBE_DEFER ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 353/849 spi: Fixed division by zero warning
In reply to Greg Kroah-HartmanFrom: Yoshitaka Ikeda <[email protected]>
[ Upstream commit 09134c5322df9f105d9ed324051872d5d0e162aa ]
The reason for dividing by zero is because the dummy bus width is zero, but if the dummy n bytes is zero, it indicates that there is no data transfer, so there is no need for calculation.
--- drivers/spi/atmel-quadspi.c | 2 +- drivers/spi/spi-bcm-qspi.c | 3 ++- drivers/spi/spi-mtk-nor.c | 2 +- drivers/spi/spi-stm32-qspi.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
drivers/spi/atmel-quadspi.c +1 -1
@@ -310,7 +310,7 @@ static int atmel_qspi_set_cfg(struct atmel_qspi *aq,return mode; ifr |= atmel_qspi_modes[mode].config; -if (op->dummy.buswidth && op->dummy.nbytes) +if (op->dummy.nbytes) dummy_cycles = op->dummy.nbytes *8 / op->dummy.buswidth;/*
drivers/spi/spi-bcm-qspi.c +2 -1
@@ -395,7 +395,8 @@ static int bcm_qspi_bspi_set_flex_mode(struct bcm_qspi *qspi,if (addrlen ==BSPI_ADDRLEN_4BYTES ) bpp =BSPI_BPP_ADDR_SELECT_MASK ; - bpp |= (op->dummy.nbytes *8 ) / op->dummy.buswidth; +if (op->dummy.nbytes) + bpp |= (op->dummy.nbytes *8 ) / op->dummy.buswidth;switch (width) {case SPI_NBITS_SINGLE :
drivers/spi/spi-mtk-nor.c +1 -1
@@ -160,7 +160,7 @@ static bool mtk_nor_match_read(const struct spi_mem_op *op) {int dummy =0 ; -if (op->dummy.buswidth) +if (op->dummy.nbytes) dummy = op->dummy.nbytes *BITS_PER_BYTE / op->dummy.buswidth;if ((op->data.buswidth ==2 ) || (op->data.buswidth ==4 )) {
drivers/spi/spi-stm32-qspi.c +1 -1
@@ -397,7 +397,7 @@ static int stm32_qspi_send(struct spi_mem *mem, const struct spi_mem_op *op) ccr |=FIELD_PREP (CCR_ADSIZE_MASK , op->addr.nbytes -1 ); } -if (op->dummy.buswidth && op->dummy.nbytes) +if (op->dummy.nbytes) ccr |=FIELD_PREP (CCR_DCYC_MASK , op->dummy.nbytes *8 / op->dummy.buswidth);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 354/849 cgroup: Make rebind_subsystems() disable v2 controllers all at once
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
[ Upstream commit 7ee285395b211cad474b2b989db52666e0430daf ]
It was found that the following warning was displayed when remounting controllers from cgroup v2 to v1:
[ 8042.997778] WARNING: CPU: 88 PID: 80682 at kernel/cgroup/cgroup.c:3130 cgroup_apply_control_disable+0x158/0x190 : [ 8043.091109] RIP: 0010:cgroup_apply_control_disable+0x158/0x190 [ 8043.096946] Code: ff f6 45 54 01 74 39 48 8d 7d 10 48 c7 c6 e0 46 5a a4 e8 7b 67 33 00 e9 41 ff ff ff 49 8b 84 24 e8 01 00 00 0f b7 40 08 eb 95 <0f> 0b e9 5f ff ff ff 48 83 c4 08 5b 5d 41 5c 41 5d 41 5e 41 5f c3 [ 8043.115692] RSP: 0018:ffffba8a47c23d28 EFLAGS: 00010202 [ 8043.120916] RAX: 0000000000000036 RBX: ffffffffa624ce40 RCX: 000000000000181a [ 8043.128047] RDX: ffffffffa63c43e0 RSI: ffffffffa63c43e0 RDI: ffff9d7284ee1000 [ 8043.135180] RBP: ffff9d72874c5800 R08: ffffffffa624b090 R09: 0000000000000004 [ 8043.142314] R10: ffffffffa624b080 R11: 0000000000002000 R12: ffff9d7284ee1000 [ 8043.149447] R13: ffff9d7284ee1000 R14: ffffffffa624ce70 R15: ffffffffa6269e20 [ 8043.156576] FS: 00007f7747cff740(0000) GS:ffff9d7a5fc00000(0000) knlGS:0000000000000000 [ 8043.164663] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 8043.170409] CR2: 00007f7747e96680 CR3: 0000000887d60001 CR4: 00000000007706e0 [ 8043.177539] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 8043.184673] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 8043.191804] PKRU: 55555554 [ 8043.194517] Call Trace: [ 8043.196970] rebind_subsystems+0x18c/0x470 [ 8043.201070] cgroup_setup_root+0x16c/0x2f0 [ 8043.205177] cgroup1_root_to_use+0x204/0x2a0 [ 8043.209456] cgroup1_get_tree+0x3e/0x120 [ 8043.213384] vfs_get_tree+0x22/0xb0 [ 8043.216883] do_new_mount+0x176/0x2d0 [ 8043.220550] __x64_sys_mount+0x103/0x140 [ 8043.224474] do_syscall_64+0x38/0x90 [ 8043.228063] entry_SYSCALL_64_after_hwframe+0x44/0xae
It was caused by the fact that rebind_subsystem() disables controllers to be rebound one by one. If more than one disabled controllers are originally from the default hierarchy, it means that cgroup_apply_control_disable() will be called multiple times for the same default hierarchy. A controller may be killed by css_kill() in the first round. In the second round, the killed controller may not be completely dead yet leading to the warning.
To avoid this problem, we collect all the ssid's of controllers that needed to be disabled from the default hierarchy and then disable them in one go instead of one by one.
--- kernel/cgroup/cgroup.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
kernel/cgroup/cgroup.c +27 -4
@@ -1726,6 +1726,7 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)struct cgroup *dcgrp = &dst_root->cgrp;struct cgroup_subsys *ss;int ssid, i, ret; +u16 dfl_disable_ss_mask =0 ;lockdep_assert_held (&cgroup_mutex);
@@ -1742,8 +1743,28 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)/* can't move between two non-dummy roots either */ if (ss->root != &cgrp_dfl_root && dst_root != &cgrp_dfl_root)return -EBUSY ; + +/* +* Collect ssid's that need to be disabled from default +* hierarchy. +*/ +if (ss->root == &cgrp_dfl_root) + dfl_disable_ss_mask |=1 << ssid; + }while_each_subsys_mask (); +if (dfl_disable_ss_mask) { +struct cgroup *scgrp = &cgrp_dfl_root.cgrp; + +/* +* Controllers from default hierarchy that need to be rebound +* are all disabled together in one go. +*/ + cgrp_dfl_root.subsys_mask &= ~dfl_disable_ss_mask; +WARN_ON (cgroup_apply_control (scgrp)); +cgroup_finalize_control (scgrp,0 ); + } + do_each_subsys_mask(ss, ssid, ss_mask) {struct cgroup_root *src_root = ss->root;struct cgroup *scgrp = &src_root->cgrp;
@@ -1752,10 +1773,12 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)WARN_ON (!css ||cgroup_css (dcgrp, ss)); -/* disable from the source */ - src_root->subsys_mask &= ~(1 << ssid); -WARN_ON (cgroup_apply_control (scgrp)); -cgroup_finalize_control (scgrp,0 ); +if (src_root != &cgrp_dfl_root) { +/* disable from the source */ + src_root->subsys_mask &= ~(1 << ssid); +WARN_ON (cgroup_apply_control (scgrp)); +cgroup_finalize_control (scgrp,0 ); + }/* rebind */ RCU_INIT_POINTER (scgrp->subsys[ssid],NULL );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 355/849 wcn36xx: Fix Antenna Diversity Switching
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit 701668d3bfa03dabc5095fc383d5315544ee5b31 ]
We have been tracking a strange bug with Antenna Diversity Switching (ADS) on wcn3680b for a while.
ADS is configured like this:
A. Via a firmware configuration table baked into the NV area.
1. Defines if ADS is enabled.
2. Defines which GPIOs are connected to which antenna enable pin.
3. Defines which antenna/GPIO is primary and which is secondary.
B. WCN36XX_CFG_VAL(ANTENNA_DIVERSITY, N)
N is a bitmask of available antenna.
Setting N to 3 indicates a bitmask of enabled antenna (1 | 2).
Obviously then we can set N to 1 or N to 2 to fix to a particular antenna and disable antenna diversity.
C. WCN36XX_CFG_VAL(ASD_PROBE_INTERVAL, XX)
XX is the number of beacons between each antenna RSSI check. Setting this value to 50 means, every 50 received beacons, run the ADS algorithm.
D. WCN36XX_CFG_VAL(ASD_TRIGGER_THRESHOLD, YY)
YY is a two's complement integer which specifies the RSSI decibel threshold below which ADS will run.
We default to -60db here, meaning a measured RSSI <= -60db will trigger an ADS probe.
E. WCN36XX_CFG_VAL(ASD_RTT_RSSI_HYST_THRESHOLD, Z)
Z is a hysteresis value, indicating a delta which the RSSI must exceed for the antenna switch to be valid.
For example if HYST_THRESHOLD == 3 AntennaId1-RSSI == -60db and AntennaId-2-RSSI == -58db then firmware will not switch antenna. The threshold needs to be -57db or better to satisfy the criteria.
F. A firmware feature bit also exists ANTENNA_DIVERSITY_SELECTION.
This feature bit is used by the firmware to report if ANTENNA_DIVERSITY_SELECTION is supported. The host is not required to toggle this bit to enable or disable ADS.
ADS works like this:
A. Every XX beacons the firmware switches to or remains on the primary
antenna.
B. The firmware then sends a Request-To-Send (RTS) packet to the AP.
C. The firmware waits for a Clear-To-Send (CTS) response from the AP.
D. The firmware then notes the received RSSI on the CTS packet.
E. The firmware then repeats steps A-D on the secondary antenna.
F. Subsequently if the RSSI on the measured antenna is better than
ASD_TRIGGER_THRESHOLD + the active antenna's RSSI then the measured antenna becomes the active antenna.
G. If RSSI rises past ASD_TRIGGER_THRESHOLD then ADS doesn't run at
all even if there is a substantially better RSSI on the alternative antenna.
What we have been observing is that the RTS packet is being sent but the MAC address is a byte-swapped version of the target MAC. The ADS/RTS MAC is corrupted only when the link is encrypted, if the AP is open the RTS MAC is correct. Similarly if we configure the firmware to an RTS/CTS sequence for regular data - the transmitted RTS MAC is correctly formatted.
Internally the wcn36xx firmware uses the indexes in the SMD commands to populate and extract data from specific entries in an STA lookup table. The AP's MAC appears a number of times in different indexes within this lookup table, so the MAC address extracted for the data-transmit RTS and the MAC address extracted for the ADS/RTS packet are not the same STA table index.
Our analysis indicates the relevant firmware STA table index is "bssSelfStaIdx".
There is an STA populate function responsible for formatting the MAC address of the bssSelfStaIdx including byte-swapping the MAC address.
Its clear then that the required STA populate command did not run for bssSelfStaIdx.
So taking a look at the sequence of SMD commands sent to the firmware we see the following downstream when moving from an unencrypted to encrypted BSS setup.
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_CONFIG_STA_REQ
- WLAN_HAL_SET_STAKEY_REQ
Upstream in wcn36xx we have
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_SET_STAKEY_REQ
The solution then is to add the missing WLAN_HAL_CONFIG_STA_REQ between WLAN_HAL_CONFIG_BSS_REQ and WLAN_HAL_SET_STAKEY_REQ.
No surprise WLAN_HAL_CONFIG_STA_REQ is the routine responsible for populating the STA lookup table in the firmware and once done the MAC sent by the ADS routine is in the correct byte-order.
This bug is apparent with ADS but it is also the case that any other firmware routine that depends on the "bssSelfStaIdx" would retrieve malformed data on an encrypted link.
--- drivers/net/wireless/ath/wcn36xx/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/main.c +3 -1
@@ -571,12 +571,14 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags) { sta_priv->is_data_encrypted = true;/* Reconfigure bss with encrypt_type */ -if (NL80211_IFTYPE_STATION == vif->type) +if (NL80211_IFTYPE_STATION == vif->type) {wcn36xx_smd_config_bss (wcn, vif, sta, sta->addr, true); +wcn36xx_smd_config_sta (wcn, vif, sta); + } wcn36xx_smd_set_stakey(wcn, vif_priv->encrypt_type,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 356/849 wilc1000: fix possible memory leak in cfg_scan_result()
In reply to Greg Kroah-HartmanFrom: Ajay Singh <[email protected]>
[ Upstream commit 3c719fed0f3a5e95b1d164609ecc81c4191ade70 ]
When the BSS reference holds a valid reference, it is not freed. The 'if' condition is wrong. Instead of the 'if (bss)' check, the 'if (!bss)' check is used.
The issue is solved by removing the unnecessary 'if' check because cfg80211_put_bss() already performs the NULL validation.
--- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/microchip/wilc1000/cfg80211.c +1 -2
@@ -129,8 +129,7 @@ static void cfg_scan_result(enum scan_event scan_event, info->frame_len, (s32 )info->rssi *100 , GFP_KERNEL); -if (!bss) -cfg80211_put_bss (wiphy, bss); +cfg80211_put_bss (wiphy, bss); }else if (scan_event ==SCAN_EVENT_DONE ) {mutex_lock (&priv->scan_req_lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 357/849 Bluetooth: btmtkuart: fix a memleak in mtk_hci_wmt_sync
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 3e5f2d90c28f9454e421108554707620bc23269d ]
bdev->evt_skb will get freed in the normal path and one error path of mtk_hci_wmt_sync, while the other error paths do not free it, which may cause a memleak. This bug is suggested by a static analysis tool, please advise.
--- drivers/bluetooth/btmtkuart.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/bluetooth/btmtkuart.c +8 -5
@@ -158,8 +158,10 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev,int err; hlen =sizeof (*hdr) + wmt_params->dlen; -if (hlen >255 ) -return -EINVAL ; +if (hlen >255 ) { + err = -EINVAL ; + goto err_free_skb; + } hdr = (struct mtk_wmt_hdr *)&wc; hdr->dir =1 ;
@@ -173,7 +175,7 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, err =__hci_cmd_send (hdev,0xfc6f , hlen, &wc);if (err <0 ) {clear_bit (BTMTKUART_TX_WAIT_VND_EVT , &bdev->tx_state); -return err; + goto err_free_skb; }/* The vendor specific WMT commands are all answered by a vendor
@@ -190,13 +192,14 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev,if (err == -EINTR ) {bt_dev_err (hdev,"Execution of wmt command interrupted" );clear_bit (BTMTKUART_TX_WAIT_VND_EVT , &bdev->tx_state); -return err; + goto err_free_skb; }if (err) {bt_dev_err (hdev,"Execution of wmt command timed out" );clear_bit (BTMTKUART_TX_WAIT_VND_EVT , &bdev->tx_state); -return -ETIMEDOUT ; + err = -ETIMEDOUT ; + goto err_free_skb; }/* Parse and handle the return WMT event */
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 358/849 drm/amdgpu: move amdgpu_virt_release_full_gpu to fini_early stage
In reply to Greg Kroah-HartmanFrom: Guchun Chen <[email protected]>
[ Upstream commit 6effad8abe0ba4db3d9c58ed585127858a990f35 ]
adev->rmmio is set to be NULL in amdgpu_device_unmap_mmio to prevent access after pci_remove, however, in SRIOV case, amdgpu_virt_release_full_gpu will still use adev->rmmio for access after amdgpu_device_unmap_mmio. The patch is to move such SRIOV calling earlier to fini_early stage.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -4
@@ -2689,6 +2689,11 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev) adev->ip_blocks[i].status.hw = false; } +if (amdgpu_sriov_vf (adev)) { +if (amdgpu_virt_release_full_gpu (adev, false)) +DRM_ERROR ("failed to release exclusive mode on fini\n" ); + } +return 0 ; }
@@ -2749,10 +2754,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)amdgpu_ras_fini (adev); -if (amdgpu_sriov_vf (adev)) -if (amdgpu_virt_release_full_gpu (adev, false)) -DRM_ERROR ("failed to release exclusive mode on fini\n" ); -return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 359/849 crypto: caam - disable pkc for non-E SoCs
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit f20311cc9c58052e0b215013046cbf390937910c ]
On newer CAAM versions, not all accelerators are disabled if the SoC is a non-E variant. While the driver checks most of the modules for availability, there is one - PKHA - which sticks out. On non-E variants it is still reported as available, that is the number of instances is non-zero, but it has limited functionality. In particular it doesn't support encryption and decryption, but just signing and verifying. This is indicated by a bit in the PKHA_MISC field. Take this bit into account if we are checking for availability.
This will the following error:
[ 8.167817] caam_jr 8020000.jr: 20000b0f: CCB: desc idx 11: : Invalid CHA selected.
Tested on an NXP LS1028A (non-E) SoC.
--- drivers/crypto/caam/caampkc.c | 19 +++++++++++++++---- drivers/crypto/caam/regs.h | 3 +++ 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/crypto/caam/caampkc.c +15 -4
@@ -1153,16 +1153,27 @@ static struct caam_akcipher_alg caam_rsa = {int caam_pkc_init (struct device *ctrldev) {struct caam_drv_private *priv =dev_get_drvdata (ctrldev); -u32 pk_inst; +u32 pk_inst, pkha;int err; init_done = false;/* Determine public key hardware accelerator presence. */ -if (priv->era <10 ) +if (priv->era <10 ) { pk_inst = (rd_reg32 (&priv->ctrl->perfmon.cha_num_ls) &CHA_ID_LS_PK_MASK ) >>CHA_ID_LS_PK_SHIFT ; -else - pk_inst =rd_reg32 (&priv->ctrl->vreg.pkha) &CHA_VER_NUM_MASK ; + }else { + pkha =rd_reg32 (&priv->ctrl->vreg.pkha); + pk_inst = pkha &CHA_VER_NUM_MASK ; + +/* +* Newer CAAMs support partially disabled functionality. If this is the +* case, the number is non-zero, but this bit is set to indicate that +* no encryption or decryption is supported. Only signing and verifying +* is supported. +*/ +if (pkha &CHA_VER_MISC_PKHA_NO_CRYPT ) + pk_inst =0 ; + }/* Do not register algorithms if PKHA is not present. */ if (!pk_inst)
drivers/crypto/caam/regs.h +3 -0
@@ -322,6 +322,9 @@ struct version_regs {/* CHA Miscellaneous Information - AESA_MISC specific */ #define CHA_VER_MISC_AES_GCM BIT(1 + CHA_VER_MISC_SHIFT) +/* CHA Miscellaneous Information - PKHA_MISC specific */ +#define CHA_VER_MISC_PKHA_NO_CRYPT BIT(7 + CHA_VER_MISC_SHIFT) +/* * caam_perfmon - Performance Monitor/Secure Memory Status/ * CAAM Global Status/Component Version IDs
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 360/849 bnxt_en: Check devlink allocation and registration status
In reply to Greg Kroah-HartmanFrom: Leon Romanovsky <[email protected]>
[ Upstream commit e624c70e1131e145bd0510b8a700b5e2d112e377 ]
devlink is a software interface that doesn't depend on any hardware capabilities. The failure in SW means memory issues, wrong parameters, programmer error e.t.c.
Like any other such interface in the kernel, the returned status of devlink APIs should be checked and propagated further and not ignored.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++++- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 13 ++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h | 13 ------------- 3 files changed, 10 insertions(+), 21 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -1
@@ -13359,7 +13359,9 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) }bnxt_inv_fw_health_reg (bp); -bnxt_dl_register (bp); + rc =bnxt_dl_register (bp); +if (rc) + goto init_err_dl; rc =register_netdev (dev);if (rc)
@@ -13379,6 +13381,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) init_err_cleanup:bnxt_dl_unregister (bp); +init_err_dl:bnxt_shutdown_tc (bp);bnxt_clear_int_mode (bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +6 -7
@@ -133,7 +133,7 @@ void bnxt_dl_fw_reporters_create(struct bnxt *bp) {struct bnxt_fw_health *health = bp->fw_health; -if (!bp->dl || !health) +if (!health)return ;if (!(bp->fw_cap &BNXT_FW_CAP_HOT_RESET ) || health->fw_reset_reporter)
@@ -187,7 +187,7 @@ void bnxt_dl_fw_reporters_destroy(struct bnxt *bp, bool all) {struct bnxt_fw_health *health = bp->fw_health; -if (!bp->dl || !health) +if (!health)return ; if ((all || !(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) &&
@@ -744,6 +744,7 @@ static void bnxt_dl_params_unregister(struct bnxt *bp)int bnxt_dl_register (struct bnxt *bp) {struct devlink_port_attrs attrs = {}; +struct bnxt_dl *bp_dl;struct devlink *dl;int rc;
@@ -756,7 +757,9 @@ int bnxt_dl_register(struct bnxt *bp)return -ENOMEM ; } -bnxt_link_bp_to_dl (bp, dl); + bp->dl = dl; + bp_dl =devlink_priv (dl); + bp_dl->bp = bp;/* Add switchdev eswitch mode setting, if SRIOV supported */ if (pci_find_ext_capability(bp->pdev, PCI_EXT_CAP_ID_SRIOV) &&
@@ -794,7 +797,6 @@ err_dl_port_unreg: err_dl_unreg:devlink_unregister (dl); err_dl_free: -bnxt_link_bp_to_dl (bp,NULL );devlink_free (dl);return rc; }
@@ -803,9 +805,6 @@ void bnxt_dl_unregister(struct bnxt *bp) {struct devlink *dl = bp->dl; -if (!dl) -return ; -if (BNXT_PF (bp)) {bnxt_dl_params_unregister (bp);devlink_port_unregister (&bp->dl_port);
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h +0 -13
@@ -20,19 +20,6 @@ static inline struct bnxt *bnxt_get_bp_from_dl(struct devlink *dl)return ((struct bnxt_dl *)devlink_priv (dl))->bp; } -/* To clear devlink pointer from bp, pass NULL dl */ -static inline void bnxt_link_bp_to_dl (struct bnxt *bp,struct devlink *dl) -{ - bp->dl = dl; - -/* add a back pointer in dl to bp */ -if (dl) { -struct bnxt_dl *bp_dl =devlink_priv (dl); - - bp_dl->bp = bp; - } -} -#define NVM_OFF_MSIX_VEC_PER_PF_MAX 108#define NVM_OFF_MSIX_VEC_PER_PF_MIN 114#define NVM_OFF_IGNORE_ARI 164
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 361/849 qed: Dont ignore devlink allocation failures
In reply to Greg Kroah-HartmanFrom: Leon Romanovsky <[email protected]>
[ Upstream commit e6a54d6f221301347aaf9d83bb1f23129325c1c5 ]
devlink is a software interface that doesn't depend on any hardware capabilities. The failure in SW means memory issues, wrong parameters, programmer error e.t.c.
Like any other such interface in the kernel, the returned status of devlink APIs should be checked and propagated further and not ignored.
--- drivers/net/ethernet/qlogic/qede/qede_main.c | 12 +++++------- drivers/scsi/qedf/qedf_main.c | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_main.c +5 -7
@@ -1184,19 +1184,17 @@ static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level, edev->devlink = qed_ops->common->devlink_register (cdev);if (IS_ERR (edev->devlink)) {DP_NOTICE (edev,"Cannot register devlink\n" ); + rc =PTR_ERR (edev->devlink); edev->devlink =NULL ; -/* Go on, we can live without devlink */ + goto err3; } }else {struct net_device *ndev =pci_get_drvdata (pdev); +struct qed_devlink *qdl; edev =netdev_priv (ndev); - -if (edev->devlink) { -struct qed_devlink *qdl =devlink_priv (edev->devlink); - - qdl->cdev = cdev; - } + qdl =devlink_priv (edev->devlink); + qdl->cdev = cdev; edev->cdev = cdev;memset (&edev->stats,0 ,sizeof (edev->stats));memcpy (&edev->dev_info, &dev_info,sizeof (dev_info));
drivers/scsi/qedf/qedf_main.c +2 -0
@@ -3416,7 +3416,9 @@ retry_probe: qedf->devlink = qed_ops->common->devlink_register (qedf->cdev);if (IS_ERR (qedf->devlink)) {QEDF_ERR (&qedf->dbg_ctx,"Cannot register devlink\n" ); + rc =PTR_ERR (qedf->devlink); qedf->devlink =NULL ; + goto err2; } }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 362/849 rxrpc: Fix _usecs_to_jiffies() by using usecs_to_jiffies()
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit acde891c243c1ed85b19d4d5042bdf00914f5739 ]
Directly using _usecs_to_jiffies() might be unsafe, so it's better to use usecs_to_jiffies() instead.
Because we can see that the result of _usecs_to_jiffies() could be larger than MAX_JIFFY_OFFSET values without the check of the input.
--- net/rxrpc/rtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/rtt.c +1 -1
@@ -22,7 +22,7 @@ static u32 rxrpc_rto_min_us(struct rxrpc_peer *peer)static u32 __rxrpc_set_rto (const struct rxrpc_peer *peer) { -return _usecs_to_jiffies ((peer->srtt_us >>3 ) + peer->rttvar_us); +return usecs_to_jiffies ((peer->srtt_us >>3 ) + peer->rttvar_us); }static u32 rxrpc_bound_rto (u32 rto)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 363/849 fortify: Fix dropped strcpy() compile-time write overflow check
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 072af0c638dc8a5c7db2edc4dddbd6d44bee3bdb ]
The implementation for intra-object overflow in str*-family functions accidentally dropped compile-time write overflow checking in strcpy(), leaving it entirely to run-time. Add back the intended check.
--- include/linux/fortify-string.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/fortify-string.h +4 -1
@@ -280,7 +280,10 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q)if (p_size == (size_t )-1 && q_size == (size_t )-1 )return __underlying_strcpy (p, q); size =strlen (q) +1 ; -/* test here to use the more stringent object size */ +/* Compile-time check for const size overflow. */ +if (__builtin_constant_p (size) && p_size < size) +__write_overflow (); +/* Run-time check for dynamic size overflow. */ if (p_size < size)fortify_panic (__func__);memcpy (p, q, size);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 364/849 cfg80211: always free wiphy specific regdomain
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit e53e9828a8d2c6545e01ff9711f1221f2fd199ce ]
In the (somewhat unlikely) event that we allocate a wiphy, then add a regdomain to it, and then fail registration, we leak the regdomain. Fix this by just always freeing it at the end, in the normal cases we'll free (and NULL) it during wiphy_unregister(). This happened when the wiphy settings were bad, and since they can be controlled by userspace with hwsim, syzbot was able to find this issue.
--- net/wireless/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/wireless/core.c +10 -0
@@ -1081,6 +1081,16 @@ void cfg80211_dev_free(struct cfg80211_registered_device *rdev)list_for_each_entry_safe (scan, tmp, &rdev->bss_list, list)cfg80211_put_bss (&rdev->wiphy, &scan->pub);mutex_destroy (&rdev->wiphy.mtx); + +/* +* The 'regd' can only be non-NULL if we never finished +* initializing the wiphy and thus never went through the +* unregister path - e.g. in failure scenarios. Thus, it +* cannot have been visible to anyone if non-NULL, so we +* can just free it here. +*/ +kfree (rcu_dereference_raw (rdev->wiphy.regd)); +kfree (rdev); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 365/849 net: dsa: rtl8366rb: Fix off-by-one bug
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
[ Upstream commit 5f5f12f5d4b108399130bb5c11f07765851d9cdb ]
The max VLAN number with non-4K VLAN activated is 15, and the range is 0..15. Not 16.
The impact should be low since we by default have 4K VLAN and thus have 4095 VLANs to play with in this switch. There will not be a problem unless the code is rewritten to only use 16 VLANs.
--- drivers/net/dsa/rtl8366rb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/rtl8366rb.c +1 -1
@@ -1350,7 +1350,7 @@ static int rtl8366rb_set_mc_index(struct realtek_smi *smi, int port, int index)static bool rtl8366rb_is_vlan_valid (struct realtek_smi *smi,unsigned int vlan) { -unsigned int max =RTL8366RB_NUM_VLANS ; +unsigned int max =RTL8366RB_NUM_VLANS -1 ;if (smi->vlan4k_enabled) max =RTL8366RB_NUM_VIDS -1 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 366/849 net: dsa: rtl8366: Fix a bug in deleting VLANs
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
[ Upstream commit d8251b9db34a2cbc5619b610e7e8aad1d165c531 ]
We were checking that the MC (member config) was != 0 for some reason, all we need to check is that the config has no ports, i.e. no members. Then it can be recycled. This must be some misunderstanding.
--- drivers/net/dsa/rtl8366.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/rtl8366.c +1 -1
@@ -457,7 +457,7 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port,* anymore then clear the whole member * config so it can be reused. */ -if (!vlanmc.member && vlanmc.untag) { +if (!vlanmc.member) { vlanmc.vid =0 ; vlanmc.priority =0 ; vlanmc.fid =0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 367/849 ath11k: fix some sleeping in atomic bugs
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit aadf7c81a0771b8f1c97dabca6a48bae1b387779 ]
The ath11k_dbring_bufs_replenish() and ath11k_dbring_fill_bufs() take a "gfp" parameter but they since they take spinlocks, the allocations they do have to be atomic. This causes a bug because ath11k_dbring_buf_setup passes GFP_KERNEL for the gfp flags.
The fix is to use GFP_ATOMIC and remove the unused parameters.
--- drivers/net/wireless/ath/ath11k/dbring.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/dbring.c +7 -9
@@ -8,8 +8,7 @@static int ath11k_dbring_bufs_replenish (struct ath11k *ar,struct ath11k_dbring *ring, -struct ath11k_dbring_element *buff, -gfp_t gfp) +struct ath11k_dbring_element *buff) {struct ath11k_base *ab = ar->ab;struct hal_srng *srng;
@@ -35,7 +34,7 @@ static int ath11k_dbring_bufs_replenish(struct ath11k *ar, goto err;spin_lock_bh (&ring->idr_lock); - buf_id =idr_alloc (&ring->bufs_idr, buff,0 , ring->bufs_max, gfp); + buf_id =idr_alloc (&ring->bufs_idr, buff,0 , ring->bufs_max,GFP_ATOMIC );spin_unlock_bh (&ring->idr_lock);if (buf_id <0 ) { ret = -ENOBUFS ;
@@ -72,8 +71,7 @@ err: }static int ath11k_dbring_fill_bufs (struct ath11k *ar, -struct ath11k_dbring *ring, -gfp_t gfp) +struct ath11k_dbring *ring) {struct ath11k_dbring_element *buff;struct hal_srng *srng;
@@ -92,11 +90,11 @@ static int ath11k_dbring_fill_bufs(struct ath11k *ar, size =sizeof (*buff) + ring->buf_sz + align -1 ;while (num_remain >0 ) { - buff =kzalloc (size, gfp); + buff =kzalloc (size,GFP_ATOMIC );if (!buff)break ; - ret =ath11k_dbring_bufs_replenish (ar, ring, buff, gfp); + ret =ath11k_dbring_bufs_replenish (ar, ring, buff);if (ret) {ath11k_warn (ar->ab,"failed to replenish db ring num_remain %d req_ent %d\n" , num_remain, req_entries);
@@ -176,7 +174,7 @@ int ath11k_dbring_buf_setup(struct ath11k *ar, ring->hp_addr =ath11k_hal_srng_get_hp_addr (ar->ab, srng); ring->tp_addr =ath11k_hal_srng_get_tp_addr (ar->ab, srng); - ret =ath11k_dbring_fill_bufs (ar, ring,GFP_KERNEL ); + ret =ath11k_dbring_fill_bufs (ar, ring);return ret; }
@@ -322,7 +320,7 @@ int ath11k_dbring_buffer_release_event(struct ath11k_base *ab, }memset (buff,0 , size); -ath11k_dbring_bufs_replenish (ar, ring, buff,GFP_ATOMIC ); +ath11k_dbring_bufs_replenish (ar, ring, buff); }spin_unlock_bh (&srng->lock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 368/849 ath11k: Avoid race during regd updates
In reply to Greg Kroah-HartmanFrom: Sriram R <[email protected]>
[ Upstream commit 1db2b0d0a39102238fcbf9092cefa65a710642e9 ]
Whenever ath11k is bootup with a user country already set, cfg80211 notifies this country info to ath11k soon after registration, where the notification is sent to the firmware for fetching the rules of this user country input.
Multiple race conditions could be seen in this scenario where a new request is either lost as pointed in [1] or a new regd overwrites the default regd provided by the firmware during bootup. Note that, the default regd is used for intersection purpose and hence it should not be overwritten.
The main reason as pointed by [1] is the usage of ATH11K_FLAG_REGISTERED flag which is updated after completion of core registration, whereas the reg notification from cfg80211 and wmi events for the corresponding request can happen much before that. Since the ATH11K_FLAG_REGISTERED is currently used to determine if the event containing reg rules belong to default regd or for user request, there is a possibility of the default regd getting overwritten.
Since the default reg rules will be received only once per pdev on firmware load, the above flag based check can be replaced with a check to see if default_regd is already set, so that we can now always update the new_regd. Also if the new_regd is set, this will be always used to update the reg rules for the registered phy.
[1] https://patchwork.kernel.org/project/linux-wireless/patch/1829665.1PRlr7bOQj@ripper/
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-01460-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/mac.c | 2 +- drivers/net/wireless/ath/ath11k/reg.c | 11 ++++++----- drivers/net/wireless/ath/ath11k/reg.h | 2 +- drivers/net/wireless/ath/ath11k/wmi.c | 16 ++++++---------- 4 files changed, 14 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +1 -1
@@ -6590,7 +6590,7 @@ static int __ath11k_mac_register(struct ath11k *ar) ar->hw->wiphy->interface_modes &= ~BIT (NL80211_IFTYPE_MONITOR );/* Apply the regd received during initialization */ - ret =ath11k_regd_update (ar, true); + ret =ath11k_regd_update (ar);if (ret) {ath11k_err (ar->ab,"ath11k regd update failed: %d\n" , ret); goto err_unregister_hw;
drivers/net/wireless/ath/ath11k/reg.c +6 -5
@@ -198,7 +198,7 @@ static void ath11k_copy_regd(struct ieee80211_regdomain *regd_orig, sizeof(struct ieee80211_reg_rule)); } -int ath11k_regd_update (struct ath11k *ar,bool init) +int ath11k_regd_update (struct ath11k *ar) {struct ieee80211_regdomain *regd, *regd_copy =NULL ;int ret, regd_len, pdev_id;
@@ -209,7 +209,10 @@ int ath11k_regd_update(struct ath11k *ar, bool init)spin_lock_bh (&ab->base_lock); -if (init) { +/* Prefer the latest regd update over default if it's available */ +if (ab->new_regd[pdev_id]) { + regd = ab->new_regd[pdev_id]; + }else {/* Apply the regd received during init through * WMI_REG_CHAN_LIST_CC event. In case of failure to * receive the regd, initialize with a default world
@@ -222,8 +225,6 @@ int ath11k_regd_update(struct ath11k *ar, bool init) "failed to receive default regd during init\n"); regd = (struct ieee80211_regdomain *)&ath11k_world_regd; } - }else { - regd = ab->new_regd[pdev_id]; }if (!regd) {
@@ -683,7 +684,7 @@ void ath11k_regd_update_work(struct work_struct *work) regd_update_work);int ret; - ret =ath11k_regd_update (ar, false); + ret =ath11k_regd_update (ar);if (ret) {/* Firmware has already moved to the new regd. We need * to maintain channel consistency across FW, Host driver
drivers/net/wireless/ath/ath11k/reg.h +1 -1
@@ -31,6 +31,6 @@ void ath11k_regd_update_work(struct work_struct *work);struct ieee80211_regdomain *ath11k_reg_build_regd (struct ath11k_base *ab,struct cur_regulatory_info *reg_info,bool intersect); -int ath11k_regd_update (struct ath11k *ar,bool init); +int ath11k_regd_update (struct ath11k *ar);int ath11k_reg_update_chan_list (struct ath11k *ar);#endif
drivers/net/wireless/ath/ath11k/wmi.c +6 -10
@@ -5841,10 +5841,10 @@ static int ath11k_reg_chan_list_event(struct ath11k_base *ab, struct sk_buff *sk }spin_lock (&ab->base_lock); -if (test_bit (ATH11K_FLAG_REGISTERED , &ab->dev_flags)) { -/* Once mac is registered, ar is valid and all CC events from -* fw is considered to be received due to user requests -* currently. +if (ab->default_regd[pdev_idx]) { +/* The initial rules from FW after WMI Init is to build +* the default regd. From then on, any rules updated for +* the pdev could be due to user reg changes. * Free previously built regd before assigning the newly * generated regd to ar. NULL pointer handling will be * taken care by kfree itself.
@@ -5854,13 +5854,9 @@ static int ath11k_reg_chan_list_event(struct ath11k_base *ab, struct sk_buff *sk ab->new_regd[pdev_idx] = regd;ieee80211_queue_work (ar->hw, &ar->regd_update_work); }else { -/* Multiple events for the same *ar is not expected. But we -* can still clear any previously stored default_regd if we -* are receiving this event for the same radio by mistake. -* NULL pointer handling will be taken care by kfree itself. +/* This regd would be applied during mac registration and is +* held constant throughout for regd intersection purpose */ -kfree (ab->default_regd[pdev_idx]); -/* This regd would be applied during mac registration */ ab->default_regd[pdev_idx] = regd; } ab->dfs_region = reg_info->dfs_region;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 369/849 ath11k: fix packet drops due to incorrect 6 GHz freq value in rx status
In reply to Greg Kroah-HartmanFrom: Pradeep Kumar Chitrapu <[email protected]>
[ Upstream commit 9d6ae1f5cf733c0e8d7f904c501fd015c4b9f0f4 ]
Frequency in rx status is being filled incorrectly in the 6 GHz band as channel number received is invalid in this case which is causing packet drops. So fix that.
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 9 ++++++--- drivers/net/wireless/ath/ath11k/wmi.c | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +6 -3
@@ -2342,8 +2342,10 @@ static void ath11k_dp_rx_h_ppdu(struct ath11k *ar, struct hal_rx_desc *rx_desc, channel_num = meta_data; center_freq = meta_data >>16 ; -if (center_freq >=5935 && center_freq <=7105 ) { +if (center_freq >=ATH11K_MIN_6G_FREQ && + center_freq <=ATH11K_MAX_6G_FREQ ) { rx_status->band =NL80211_BAND_6GHZ ; + rx_status->freq = center_freq; }else if (channel_num >=1 && channel_num <=14 ) { rx_status->band =NL80211_BAND_2GHZ ; }else if (channel_num >=36 && channel_num <=173 ) {
@@ -2361,8 +2363,9 @@ static void ath11k_dp_rx_h_ppdu(struct ath11k *ar, struct hal_rx_desc *rx_desc, rx_desc, sizeof(struct hal_rx_desc)); } - rx_status->freq =ieee80211_channel_to_frequency (channel_num, - rx_status->band); +if (rx_status->band !=NL80211_BAND_6GHZ ) + rx_status->freq =ieee80211_channel_to_frequency (channel_num, + rx_status->band);ath11k_dp_rx_h_rate (ar, rx_desc, rx_status); }
drivers/net/wireless/ath/ath11k/wmi.c +7 -3
@@ -6127,8 +6127,10 @@ static void ath11k_mgmt_rx_event(struct ath11k_base *ab, struct sk_buff *skb)if (rx_ev.status &WMI_RX_STATUS_ERR_MIC ) status->flag |=RX_FLAG_MMIC_ERROR ; -if (rx_ev.chan_freq >=ATH11K_MIN_6G_FREQ ) { +if (rx_ev.chan_freq >=ATH11K_MIN_6G_FREQ && + rx_ev.chan_freq <=ATH11K_MAX_6G_FREQ ) { status->band =NL80211_BAND_6GHZ ; + status->freq = rx_ev.chan_freq; }else if (rx_ev.channel >=1 && rx_ev.channel <=14 ) { status->band =NL80211_BAND_2GHZ ; }else if (rx_ev.channel >=36 && rx_ev.channel <=ATH11K_MAX_5G_CHAN ) {
@@ -6149,8 +6151,10 @@ static void ath11k_mgmt_rx_event(struct ath11k_base *ab, struct sk_buff *skb) sband = &ar->mac.sbands[status->band]; - status->freq =ieee80211_channel_to_frequency (rx_ev.channel, - status->band); +if (status->band !=NL80211_BAND_6GHZ ) + status->freq =ieee80211_channel_to_frequency (rx_ev.channel, + status->band); + status->signal = rx_ev.snr +ATH11K_DEFAULT_NOISE_FLOOR ; status->rate_idx =ath11k_mac_bitrate_to_idx (sband, rx_ev.rate /100 );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 370/849 ath11k: Fix memory leak in ath11k_qmi_driver_event_work
In reply to Greg Kroah-HartmanFrom: Baochen Qiang <[email protected]>
[ Upstream commit 72de799aa9e3e064b35238ef053d2f0a49db055a ]
The buffer pointed to by event is not freed in case ATH11K_FLAG_UNREGISTERING bit is set, resulting in memory leak, so fix it.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
--- drivers/net/wireless/ath/ath11k/qmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/qmi.c +3 -1
@@ -2707,8 +2707,10 @@ static void ath11k_qmi_driver_event_work(struct work_struct *work)list_del (&event->list);spin_unlock (&qmi->event_lock); -if (test_bit (ATH11K_FLAG_UNREGISTERING , &ab->dev_flags)) +if (test_bit (ATH11K_FLAG_UNREGISTERING , &ab->dev_flags)) { +kfree (event);return ; + }switch (event->type) {case ATH11K_QMI_EVENT_SERVER_ARRIVE :
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 371/849 gve: DQO: avoid unused variable warnings
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 1e0083bd0777e4a418a6710d9ee04b979cdbe5cc ]
The use of dma_unmap_addr()/dma_unmap_len() in the driver causes multiple warnings when these macros are defined as empty, e.g. in an ARCH=i386 allmodconfig build:
drivers/net/ethernet/google/gve/gve_tx_dqo.c: In function 'gve_tx_add_skb_no_copy_dqo':drivers/net/ethernet/google/gve/gve_tx_dqo.c:494:40: error: unused variable 'buf' [-Werror=unused-variable]
494 | struct gve_tx_dma_buf *buf =
This is not how the NEED_DMA_MAP_STATE macros are meant to work, as they rely on never using local variables or a temporary structure like gve_tx_dma_buf.
Remote the gve_tx_dma_buf definition and open-code the contents in all places to avoid the warning. This causes some rather long lines but otherwise ends up making the driver slightly smaller.
--- drivers/net/ethernet/google/gve/gve.h | 13 ++- drivers/net/ethernet/google/gve/gve_tx.c | 23 +++--- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 84 +++++++++----------- 3 files changed, 54 insertions(+), 66 deletions(-)
drivers/net/ethernet/google/gve/gve.h +6 -7
@@ -224,11 +224,6 @@ struct gve_tx_iovec {u32 iov_padding;/* padding associated with this segment */ }; -struct gve_tx_dma_buf { -DEFINE_DMA_UNMAP_ADDR (dma); -DEFINE_DMA_UNMAP_LEN (len); -}; -/* Tracks the memory in the fifo occupied by the skb. Mapped 1:1 to a desc * ring entry but only used for a pkt_desc not a seg_desc */
@@ -236,7 +231,10 @@ struct gve_tx_buffer_state {struct sk_buff *skb;/* skb for this pkt */ union {struct gve_tx_iovec iov[GVE_TX_MAX_IOVEC ];/* segments of this pkt */ -struct gve_tx_dma_buf buf; +struct { +DEFINE_DMA_UNMAP_ADDR (dma); +DEFINE_DMA_UNMAP_LEN (len); + }; }; };
@@ -280,7 +278,8 @@ struct gve_tx_pending_packet_dqo {* All others correspond to `skb`'s frags and should be unmapped with * `dma_unmap_page`. */ -struct gve_tx_dma_buf bufs[MAX_SKB_FRAGS +1 ]; +DEFINE_DMA_UNMAP_ADDR (dma[MAX_SKB_FRAGS +1 ]); +DEFINE_DMA_UNMAP_LEN (len[MAX_SKB_FRAGS +1 ]);u16 num_bufs;/* Linked list index to next element in the list, or -1 if none */
drivers/net/ethernet/google/gve/gve_tx.c +10 -13
@@ -303,15 +303,15 @@ static inline int gve_skb_fifo_bytes_required(struct gve_tx_ring *tx,static void gve_tx_unmap_buf (struct device *dev,struct gve_tx_buffer_state *info) {if (info->skb) { -dma_unmap_single (dev,dma_unmap_addr (&info->buf, dma), -dma_unmap_len (&info->buf, len), +dma_unmap_single (dev,dma_unmap_addr (info, dma), +dma_unmap_len (info, len),DMA_TO_DEVICE ); -dma_unmap_len_set (&info->buf, len,0 ); +dma_unmap_len_set (info, len,0 ); }else { -dma_unmap_page (dev,dma_unmap_addr (&info->buf, dma), -dma_unmap_len (&info->buf, len), +dma_unmap_page (dev,dma_unmap_addr (info, dma), +dma_unmap_len (info, len),DMA_TO_DEVICE ); -dma_unmap_len_set (&info->buf, len,0 ); +dma_unmap_len_set (info, len,0 ); } }
@@ -491,7 +491,6 @@ static int gve_tx_add_skb_no_copy(struct gve_priv *priv, struct gve_tx_ring *tx,struct gve_tx_buffer_state *info;bool is_gso =skb_is_gso (skb);u32 idx = tx->req & tx->mask; -struct gve_tx_dma_buf *buf;u64 addr;u32 len;int i;
@@ -515,9 +514,8 @@ static int gve_tx_add_skb_no_copy(struct gve_priv *priv, struct gve_tx_ring *tx, tx->dma_mapping_error++; goto drop; } - buf = &info->buf; -dma_unmap_len_set (buf, len, len); -dma_unmap_addr_set (buf, dma, addr); +dma_unmap_len_set (info, len, len); +dma_unmap_addr_set (info, dma, addr); payload_nfrags = shinfo->nr_frags;if (hlen < len) {
@@ -549,10 +547,9 @@ static int gve_tx_add_skb_no_copy(struct gve_priv *priv, struct gve_tx_ring *tx, tx->dma_mapping_error++; goto unmap_drop; } - buf = &tx->info[idx].buf; tx->info[idx].skb =NULL ; -dma_unmap_len_set (buf, len, len); -dma_unmap_addr_set (buf, dma, addr); +dma_unmap_len_set (&tx->info[idx], len, len); +dma_unmap_addr_set (&tx->info[idx], dma, addr);gve_tx_fill_seg_desc (seg_desc, skb, is_gso, len, addr); }
drivers/net/ethernet/google/gve/gve_tx_dqo.c +38 -46
160 lines not on this page · raw message
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 372/849 ath10k: Fix missing frame timestamp for beacon/probe-resp
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit e6dfbc3ba90cc2b619229be56b485f085a0a8e1c ]
When receiving a beacon or probe response, we should update the boottime_ns field which is the timestamp the frame was received at. (cf mac80211.h)
This fixes a scanning issue with Android since it relies on this timestamp to determine when the AP has been seen for the last time (via the nl80211 BSS_LAST_SEEN_BOOTTIME parameter).
--- drivers/net/wireless/ath/ath10k/wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath10k/wmi.c +4 -0
@@ -2610,6 +2610,10 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)if (ieee80211_is_beacon (hdr->frame_control))ath10k_mac_handle_beacon (ar, skb); +if (ieee80211_is_beacon (hdr->frame_control) || +ieee80211_is_probe_resp (hdr->frame_control)) + status->boottime_ns =ktime_get_boottime_ns (); + ath10k_dbg(ar, ATH10K_DBG_MGMT, "event mgmt rx skb %pK len %d ftype %02x stype %02x\n", skb, skb->len,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 373/849 ath10k: sdio: Add missing BH locking around napi_schdule()
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit 019edd01d174ce4bb2e517dd332922514d176601 ]
On a i.MX-based board with a QCA9377 Wifi chip, the following errors are seen after launching the 'hostapd' application:
hostapd /etc/wifi.conf
Configuration file: /etc/wifi.conf
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! Using interface wlan0 with hwaddr 00:1f:7b:31:04:a0 and ssid "thessid"
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!
...
Fix this problem by adding the BH locking around napi-schedule(), in the same way it was done in commit e63052a5dd3c ("mlx5e: add add missing BH locking around napi_schdule()").
Its commit log provides the following explanation:
"It's not correct to call napi_schedule() in pure process context. Because we use __raise_softirq_irqoff() we require callers to be in a context which will eventually lead to softirq handling (hardirq, bh disabled, etc.).
With code as is users will see:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! "
--- drivers/net/wireless/ath/ath10k/sdio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/sdio.c +4 -1
@@ -1363,8 +1363,11 @@ static void ath10k_rx_indication_async_work(struct work_struct *work) ep->ep_ops.ep_rx_complete (ar, skb); } -if (test_bit (ATH10K_FLAG_CORE_REGISTERED , &ar->dev_flags)) +if (test_bit (ATH10K_FLAG_CORE_REGISTERED , &ar->dev_flags)) { +local_bh_disable ();napi_schedule (&ar->napi); +local_bh_enable (); + } }static int ath10k_sdio_read_rtc_state (struct ath10k_sdio *ar_sdio,unsigned char *state)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 374/849 drm/ttm: stop calling tt_swapin in vm_access
In reply to Greg Kroah-HartmanFrom: Matthew Auld <[email protected]>
[ Upstream commit f5d28856b89baab4232a9f841e565763fcebcdf9 ]
In commit:
commit 09ac4fcb3f255e9225967c75f5893325c116cdbe
Author: Felix Kuehling <[email protected]> Date: Thu Jul 13 17:01:16 2017 -0400
drm/ttm: Implement vm_operations_struct.access v2
we added the vm_access hook, where we also directly call tt_swapin for some reason. If something is swapped-out then the ttm_tt must also be unpopulated, and since access_kmap should also call tt_populate, if needed, then swapping-in will already be handled there.
If anything, calling tt_swapin directly here would likely always fail since the tt->pages won't yet be populated, or worse since the tt->pages array is never actually cleared in unpopulate this might lead to a nasty uaf.
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +0 -5
@@ -519,11 +519,6 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,switch (bo->resource->mem_type) {case TTM_PL_SYSTEM : -if (unlikely (bo->ttm->page_flags &TTM_PAGE_FLAG_SWAPPED )) { - ret =ttm_tt_swapin (bo->ttm); -if (unlikely (ret !=0 )) -return ret; - } fallthrough;case TTM_PL_TT : ret =ttm_bo_vm_access_kmap (bo, offset, buf, len, write);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 375/849 arm64: mm: update max_pfn after memory hotplug
In reply to Greg Kroah-HartmanFrom: Sudarshan Rajagopalan <[email protected]>
[ Upstream commit 8fac67ca236b961b573355e203dbaf62a706a2e5 ]
After new memory blocks have been hotplugged, max_pfn and max_low_pfn needs updating to reflect on new PFNs being hot added to system. Without this patch, debug-related functions that use max_pfn such as get_max_dump_pfn() or read_page_owner() will not work with any page in memory that is hot-added after boot.
--- arch/arm64/mm/mmu.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/mm/mmu.c +5 -0
@@ -1499,6 +1499,11 @@ int arch_add_memory(int nid, u64 start, u64 size,if (ret)__remove_pgd_mapping (swapper_pg_dir,__phys_to_virt (start), size); +else { + max_pfn =PFN_UP (start + size); + max_low_pfn = max_pfn; + } +return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 376/849 drm/amdgpu: fix warning for overflow check
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 335aea75b0d95518951cad7c4c676e6f1c02c150 ]
The overflow check in amdgpu_bo_list_create() causes a warning with clang-14 on 64-bit architectures, since the limit can never be exceeded.
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c:74:18: error: result of comparison of constant 256204778801521549 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (num_entries > (SIZE_MAX - sizeof(struct amdgpu_bo_list))
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The check remains useful for 32-bit architectures, so just avoid the warning by using size_t as the type for the count.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +1 -1
@@ -61,7 +61,7 @@ static void amdgpu_bo_list_free(struct kref *ref)int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info, -unsigned num_entries,struct amdgpu_bo_list **result) +size_t num_entries,struct amdgpu_bo_list **result) {unsigned last_entry =0 , first_userptr = num_entries;struct amdgpu_bo_list_entry *array;
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h +1 -1
@@ -60,7 +60,7 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in,int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info, -unsigned num_entries, +size_t num_entries,struct amdgpu_bo_list **list); static inline struct amdgpu_bo_list_entry *
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 377/849 libbpf: Fix skel_internal.h to set errno on loader retval < 0
In reply to Greg Kroah-HartmanFrom: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit e68ac0082787f4e8ee6ae5b19076ec7709ce715b ]
When the loader indicates an internal error (result of a checked bpf system call), it returns the result in attr.test.retval. However, tests that rely on ASSERT_OK_PTR on NULL (returned from light skeleton) may miss that NULL denotes an error if errno is set to 0. This would result in skel pointer being NULL, while ASSERT_OK_PTR returning 1, leading to a SEGV on dereference of skel, because libbpf_get_error relies on the assumption that errno is always set in case of error for ptr == NULL.
In particular, this was observed for the ksyms_module test. When executed using ./test_progs -t ksyms, prior tests manipulated errno and the test didn't crash when it failed at ksyms_module load, while using ./test_progs -t ksyms_module crashed due to errno being untouched.
--- tools/lib/bpf/skel_internal.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/lib/bpf/skel_internal.h +4 -2
@@ -105,10 +105,12 @@ static inline int bpf_load_and_run(struct bpf_load_and_run_opts *opts) err =skel_sys_bpf (BPF_PROG_RUN , &attr,sizeof (attr));if (err <0 || (int )attr.test.retval <0 ) { opts->errstr ="failed to execute loader prog" ; -if (err <0 ) +if (err <0 ) { err = -errno; -else + }else { err = (int )attr.test.retval; + errno = -err; + } goto out; } err =0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 378/849 media: em28xx: add missing em28xx_close_extension
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit 2c98b8a3458df03abdc6945bbef67ef91d181938 ]
If em28xx dev has ->dev_next pointer, we need to delete ->dev_next list node from em28xx_extension_devlist on disconnect to avoid UAF bugs and corrupted list bugs, since driver frees this pointer on disconnect.
--- drivers/media/usb/em28xx/em28xx-cards.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/usb/em28xx/em28xx-cards.c +4 -1
@@ -4139,8 +4139,11 @@ static void em28xx_usb_disconnect(struct usb_interface *intf)em28xx_close_extension (dev); -if (dev->dev_next) +if (dev->dev_next) { +em28xx_close_extension (dev->dev_next);em28xx_release_resources (dev->dev_next); + } +em28xx_release_resources (dev);if (dev->dev_next) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 379/849 media: meson-ge2d: Fix rotation parameter changes detection in ge2d_s_ctrl()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 4b9e3e8af4b336eefca1f1ee535bc4b6734ed6aa ]
There is likely a typo here. To be consistent, we should compare 'fmt.height' with 'ctx->out.pix_fmt.height', not 'ctx->out.pix_fmt.width'.
Instead of fixing the test, just remove it and copy 'fmt' unconditionally.
--- drivers/media/platform/meson/ge2d/ge2d.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/media/platform/meson/ge2d/ge2d.c +1 -5
@@ -779,11 +779,7 @@ static int ge2d_s_ctrl(struct v4l2_ctrl *ctrl)* If the rotation parameter changes the OUTPUT frames * parameters, take them in account */ -if (fmt.width != ctx->out.pix_fmt.width || - fmt.height != ctx->out.pix_fmt.width || - fmt.bytesperline > ctx->out.pix_fmt.bytesperline || - fmt.sizeimage > ctx->out.pix_fmt.sizeimage) - ctx->out.pix_fmt = fmt; + ctx->out.pix_fmt = fmt;break ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 380/849 media: cxd2880-spi: Fix a null pointer dereference on error handling path
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 11b982e950d2138e90bd120501df10a439006ff8 ]
Currently the null pointer check on dvb_spi->vcc_supply is inverted and this leads to only null values of the dvb_spi->vcc_supply being passed to the call of regulator_disable causing null pointer dereferences. Fix this by only calling regulator_disable if dvb_spi->vcc_supply is not null.
Addresses-Coverity: ("Dereference after null check")
--- drivers/media/spi/cxd2880-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/spi/cxd2880-spi.c +1 -1
@@ -618,7 +618,7 @@ fail_frontend: fail_attach:dvb_unregister_adapter (&dvb_spi->adapter); fail_adapter: -if (!dvb_spi->vcc_supply) +if (dvb_spi->vcc_supply)regulator_disable (dvb_spi->vcc_supply); fail_regulator:kfree (dvb_spi);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 381/849 media: ttusb-dec: avoid release of non-acquired mutex
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit 36b9d695aa6fb8e9a312db21af41f90824d16ab4 ]
ttusb_dec_send_command() invokes mutex_lock_interruptible() that can fail but then it releases the non-acquired mutex. The patch fixes that.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/media/usb/ttusb-dec/ttusb_dec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/usb/ttusb-dec/ttusb_dec.c +5 -5
@@ -327,7 +327,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, result =mutex_lock_interruptible (&dec->usb_mutex);if (result) {printk ("%s: Failed to lock usb mutex.\n" , __func__); - goto err; + goto err_free; } b[0 ] =0xaa ;
@@ -349,7 +349,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,if (result) {printk ("%s: command bulk message failed: error %d\n" , __func__, result); - goto err; + goto err_mutex_unlock; } result = usb_bulk_msg(dec->udev, dec->result_pipe, b,
@@ -358,7 +358,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,if (result) {printk ("%s: result bulk message failed: error %d\n" , __func__, result); - goto err; + goto err_mutex_unlock; }else {if (debug) { printk(KERN_DEBUG "%s: result: %*ph\n",
@@ -371,9 +371,9 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,memcpy (cmd_result, &b[4 ], b[3 ]); } -err: +err_mutex_unlock:mutex_unlock (&dec->usb_mutex); - +err_free:kfree (b);return result; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 382/849 media: dvb-usb: fix ununit-value in az6027_rc_query
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit afae4ef7d5ad913cab1316137854a36bea6268a5 ]
Syzbot reported ununit-value bug in az6027_rc_query(). The problem was in missing state pointer initialization. Since this function does nothing we can simply initialize state to REMOTE_NO_KEY_PRESSED.
--- drivers/media/usb/dvb-usb/az6027.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/dvb-usb/az6027.c +1 -0
@@ -391,6 +391,7 @@ static struct rc_map_table rc_map_az6027_table[] = {/* remote control stuff (does not work with my box) */ static int az6027_rc_query (struct dvb_usb_device *d,u32 *event,int *state) { + *state =REMOTE_NO_KEY_PRESSED ;return 0 ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 383/849 media: imx258: Fix getting clock frequency
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
[ Upstream commit d170b0ea1760989fe8ac053bef83e61f3bf87992 ]
Obtain the clock frequency by reading the clock-frequency property if there's no clock.
--- drivers/media/i2c/imx258.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/i2c/imx258.c +6 -6
@@ -1260,18 +1260,18 @@ static int imx258_probe(struct i2c_client *client)return -ENOMEM ; imx258->clk =devm_clk_get_optional (&client->dev,NULL ); +if (IS_ERR (imx258->clk)) +return dev_err_probe (&client->dev,PTR_ERR (imx258->clk), +"error getting clock\n" );if (!imx258->clk) {dev_dbg (&client->dev,"no clock provided, using clock-frequency property\n" );device_property_read_u32 (&client->dev,"clock-frequency" , &val); -if (val !=IMX258_INPUT_CLOCK_FREQ ) -return -EINVAL ; - }else if (IS_ERR (imx258->clk)) { -return dev_err_probe (&client->dev,PTR_ERR (imx258->clk), -"error getting clock\n" ); + }else { + val =clk_get_rate (imx258->clk); } -if (clk_get_rate (imx258->clk) !=IMX258_INPUT_CLOCK_FREQ ) { +if (val !=IMX258_INPUT_CLOCK_FREQ ) {dev_err (&client->dev,"input clock frequency not supported\n" );return -EINVAL ; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 384/849 media: v4l2-ioctl: S_CTRL output the right value
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit c87ed93574e3cd8346c05bd934c617596c12541b ]
If the driver does not implement s_ctrl, but it does implement s_ext_ctrls, we convert the call.
When that happens we have also to convert back the response from s_ext_ctrls.
Fixes v4l2_compliance:
Control ioctls (Input 0):
fail: v4l2-test-controls.cpp(411): returned control value out of range
fail: v4l2-test-controls.cpp(507): invalid control 00980900
test VIDIOC_G/S_CTRL: FAIL
--- drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +6 -3
@@ -2224,6 +2224,7 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,test_bit (V4L2_FL_USES_V4L2_FH , &vfd->flags) ? fh :NULL ;struct v4l2_ext_controls ctrls;struct v4l2_ext_control ctrl; +int ret;if (vfh && vfh->ctrl_handler)return v4l2_s_ctrl (vfh, vfh->ctrl_handler, p);
@@ -2239,9 +2240,11 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, ctrls.controls = &ctrl; ctrl.id = p->id; ctrl.value = p->value; -if (check_ext_ctrls (&ctrls,VIDIOC_S_CTRL )) -return ops->vidioc_s_ext_ctrls (file, fh, &ctrls); -return -EINVAL ; +if (!check_ext_ctrls (&ctrls,VIDIOC_S_CTRL )) +return -EINVAL ; + ret = ops->vidioc_s_ext_ctrls (file, fh, &ctrls); + p->value = ctrl.value; +return ret; } static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 385/849 media: mtk-vcodec: venc: fix return value when start_streaming fails
In reply to Greg Kroah-HartmanFrom: Dafna Hirschfeld <[email protected]>
[ Upstream commit 065a7c66bd8b21db212fa86187ff12f0cac6ea6d ]
In case vb2ops_venc_start_streaming fails, the error value is overwritten by the ret value of pm_runtime_put which might be 0. Fix it.
--- drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +4 -4
@@ -793,7 +793,7 @@ static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count) {struct mtk_vcodec_ctx *ctx =vb2_get_drv_priv (q);struct venc_enc_param param; -int ret; +int ret, pm_ret;int i;/* Once state turn into MTK_STATE_ABORT, we need stop_streaming
@@ -845,9 +845,9 @@ static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count)return 0 ; err_set_param: - ret =pm_runtime_put (&ctx->dev->plat_dev->dev); -if (ret <0 ) -mtk_v4l2_err ("pm_runtime_put fail %d" , ret); + pm_ret =pm_runtime_put (&ctx->dev->plat_dev->dev); +if (pm_ret <0 ) +mtk_v4l2_err ("pm_runtime_put fail %d" , pm_ret); err_start_stream:for (i =0 ; i < q->num_buffers; ++i) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 386/849 media: TDA1997x: handle short reads of hdmi info frame.
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit 48d219f9cc667bc6fbc3e3af0b1bfd75db94fce4 ]
Static analysis reports this representative problem
tda1997x.c:1939: warning: 7th function call argument is an uninitialized value
The 7th argument is buffer[0], which is set in the earlier call to io_readn(). When io_readn() call to io_read() fails with the first read, buffer[0] is not set and 0 is returned and stored in len.
The later call to hdmi_infoframe_unpack()'s size parameter is the static size of buffer, always 40, so a short read is not caught in hdmi_infoframe_unpacks()'s checking. The variable len should be used instead.
Zero initialize buffer to 0 so it is in a known start state.
--- drivers/media/i2c/tda1997x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/i2c/tda1997x.c +4 -4
@@ -1247,13 +1247,13 @@ tda1997x_parse_infoframe(struct tda1997x_state *state, u16 addr) {struct v4l2_subdev *sd = &state->sd;union hdmi_infoframe frame; -u8 buffer[40 ]; +u8 buffer[40 ] = {0 };u8 reg;int len, err;/* read data */ len =io_readn (sd, addr,sizeof (buffer), buffer); - err =hdmi_infoframe_unpack (&frame, buffer,sizeof (buffer)); + err =hdmi_infoframe_unpack (&frame, buffer, len);if (err) { v4l_err(state->client, "failed parsing %d byte infoframe: 0x%04x/0x%02x\n",
@@ -1927,13 +1927,13 @@ static int tda1997x_log_infoframe(struct v4l2_subdev *sd, int addr) {struct tda1997x_state *state =to_state (sd);union hdmi_infoframe frame; -u8 buffer[40 ]; +u8 buffer[40 ] = {0 };int len, err;/* read data */ len =io_readn (sd, addr,sizeof (buffer), buffer);v4l2_dbg (1 , debug, sd,"infoframe: addr=%d len=%d\n" , addr, len); - err =hdmi_infoframe_unpack (&frame, buffer,sizeof (buffer)); + err =hdmi_infoframe_unpack (&frame, buffer, len);if (err) { v4l_err(state->client, "failed parsing %d byte infoframe: 0x%04x/0x%02x\n",
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 387/849 media: mtk-vpu: Fix a resource leak in the error handling path of mtk_vpu_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 2143ad413c05c7be24c3a92760e367b7f6aaac92 ]
A successful 'clk_prepare()' call should be balanced by a corresponding 'clk_unprepare()' call in the error handling path of the probe, as already done in the remove function.
Update the error handling path accordingly.
--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-vpu/mtk_vpu.c +4 -1
@@ -848,7 +848,8 @@ static int mtk_vpu_probe(struct platform_device *pdev) vpu->wdt.wq =create_singlethread_workqueue ("vpu_wdt" );if (!vpu->wdt.wq) {dev_err (dev,"initialize wdt workqueue failed\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto clk_unprepare; }INIT_WORK (&vpu->wdt.ws, vpu_wdt_reset_func);mutex_init (&vpu->vpu_mutex);
@@ -942,6 +943,8 @@ disable_vpu_clk:vpu_clock_disable (vpu); workqueue_destroy:destroy_workqueue (vpu->wdt.wq); +clk_unprepare: +clk_unprepare (vpu->clk);return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 388/849 media: imx-jpeg: Fix the error handling path of mxc_jpeg_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 5c47dc6657543b3c4dffcbe741fb693b9b96796d ]
A successful 'mxc_jpeg_attach_pm_domains()' call should be balanced by a corresponding 'mxc_jpeg_detach_pm_domains()' call in the error handling path of the probe, as already done in the remove function.
Update the error handling path accordingly.
--- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/imx-jpeg/mxc-jpeg.c +2 -0
@@ -2092,6 +2092,8 @@ err_m2m:v4l2_device_unregister (&jpeg->v4l2_dev); err_register: +mxc_jpeg_detach_pm_domains (jpeg); + err_irq:return ret; }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 389/849 media: i2c: ths8200 needs V4L2_ASYNC
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit e4625044d656f3c33ece0cc9da22577bc10ca5d3 ]
Fix the build errors reported by the kernel test robot by selecting V4L2_ASYNC:
mips-linux-ld: drivers/media/i2c/ths8200.o: in function `ths8200_remove':
ths8200.c:(.text+0x1ec): undefined reference to `v4l2_async_unregister_subdev'
mips-linux-ld: drivers/media/i2c/ths8200.o: in function `ths8200_probe':
ths8200.c:(.text+0x404): undefined reference to `v4l2_async_register_subdev'
--- drivers/media/i2c/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/Kconfig +1 -0
@@ -597,6 +597,7 @@ config VIDEO_AK881X config VIDEO_THS8200 tristate "Texas Instruments THS8200 video encoder" depends on VIDEO_V4L2 && I2C + select V4L2_ASYNC help Support for the Texas Instruments THS8200 video encoder.
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 390/849 media: sun6i-csi: Allow the video device to be open multiple times
In reply to Greg Kroah-HartmanFrom: Ondrej Jirman <[email protected]>
[ Upstream commit 8ed852834683ebe064157e069af8dfb41cad6403 ]
Previously it was possible, but a recent fix for uninitialized ret variable broke this behavior.
v4l2_fh_is_singular_file() check is there just to determine whether the power needs to be enabled, and it's not a failure if it returns false.
--- drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c +2 -4
@@ -467,7 +467,7 @@ static const struct v4l2_ioctl_ops sun6i_video_ioctl_ops = {static int sun6i_video_open (struct file *file) {struct sun6i_video *video =video_drvdata (file); -int ret; +int ret =0 ;if (mutex_lock_interruptible (&video->lock))return -ERESTARTSYS ;
@@ -481,10 +481,8 @@ static int sun6i_video_open(struct file *file) goto fh_release;/* check if already powered */ -if (!v4l2_fh_is_singular_file (file)) { - ret = -EBUSY ; +if (!v4l2_fh_is_singular_file (file)) goto unlock; - } ret =sun6i_csi_set_power (video->csi, true);if (ret <0 )
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 391/849 media: radio-wl1273: Avoid card name truncation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit dfadec236aa99f6086141949c9dc3ec50f3ff20d ]
The "card" string only holds 31 characters (and the terminating NUL). In order to avoid truncation, use a shorter card description instead of the current result, "Texas Instruments Wl1273 FM Rad".
--- drivers/media/radio/radio-wl1273.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/radio-wl1273.c +1 -1
@@ -1279,7 +1279,7 @@ static int wl1273_fm_vidioc_querycap(struct file *file, void *priv,strscpy (capability->driver,WL1273_FM_DRIVER_NAME ,sizeof (capability->driver)); -strscpy (capability->card,"Texas Instruments Wl1273 FM Radio" , +strscpy (capability->card,"TI Wl1273 FM Radio" ,sizeof (capability->card));strscpy (capability->bus_info, radio->bus_type,sizeof (capability->bus_info));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 392/849 media: si470x: Avoid card name truncation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 2908249f3878a591f7918368fdf0b7b0a6c3158c ]
The "card" string only holds 31 characters (and the terminating NUL). In order to avoid truncation, use a shorter card description instead of the current result, "Silicon Labs Si470x FM Radio Re".
--- drivers/media/radio/si470x/radio-si470x-i2c.c | 2 +- drivers/media/radio/si470x/radio-si470x-usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
@@ -11,7 +11,7 @@/* driver definitions */ #define DRIVER_AUTHOR "Joonyoung Shim <[email protected]>"; -#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" +#define DRIVER_CARD "Silicon Labs Si470x FM Radio"#define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"#define DRIVER_VERSION "1.0.2"
drivers/media/radio/si470x/radio-si470x-usb.c +1 -1
@@ -16,7 +16,7 @@/* driver definitions */ #define DRIVER_AUTHOR "Tobias Lorenz <[email protected]>" -#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" +#define DRIVER_CARD "Silicon Labs Si470x FM Radio"#define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers"#define DRIVER_VERSION "1.0.10"
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 393/849 media: tm6000: Avoid card name truncation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 42bb98e420d454fef3614b70ea11cc59068395f6 ]
The "card" string only holds 31 characters (and the terminating NUL). In order to avoid truncation, use a shorter card description instead of the current result, "Trident TVMaster TM5600/6000/60".
--- drivers/media/usb/tm6000/tm6000-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/usb/tm6000/tm6000-video.c +1 -2
@@ -852,8 +852,7 @@ static int vidioc_querycap(struct file *file, void *priv,struct tm6000_core *dev = ((struct tm6000_fh *)priv)->dev;strscpy (cap->driver,"tm6000" ,sizeof (cap->driver)); -strscpy (cap->card,"Trident TVMaster TM5600/6000/6010" , -sizeof (cap->card)); +strscpy (cap->card,"Trident TM5600/6000/6010" ,sizeof (cap->card));usb_make_path (dev->udev, cap->bus_info,sizeof (cap->bus_info)); cap->capabilities =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_READWRITE |V4L2_CAP_DEVICE_CAPS ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 394/849 media: cx23885: Fix snd_card_free call on null card pointer
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 7266dda2f1dfe151b12ef0c14eb4d4e622fb211c ]
Currently a call to snd_card_new that fails will set card with a NULL pointer, this causes a null pointer dereference on the error cleanup path when card it passed to snd_card_free. Fix this by adding a new error exit path that does not call snd_card_free and exiting via this new path.
Addresses-Coverity: ("Explicit null dereference")
--- drivers/media/pci/cx23885/cx23885-alsa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/pci/cx23885/cx23885-alsa.c +2 -1
@@ -550,7 +550,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)SNDRV_DEFAULT_IDX1 ,SNDRV_DEFAULT_STR1 , THIS_MODULE, sizeof(struct cx23885_audio_dev), &card);if (err <0 ) - goto error; + goto error_msg; chip = (struct cx23885_audio_dev *) card->private_data; chip->dev = dev;
@@ -576,6 +576,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev) error:snd_card_free (card); +error_msg:pr_err ("%s(): Failed to register analog audio adapter\n" , __func__);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 395/849 media: atmel: fix the ispck initialization
In reply to Greg Kroah-HartmanFrom: Eugen Hristev <[email protected]>
[ Upstream commit d7f26849ed7cc875d0ff7480c2efebeeccea2bad ]
The runtime enabling of the ISPCK (internally clocks the pipeline inside the ISC) has to be done after the pm_runtime for the ISC dev has been started.
After the commit by Mauro:
the ISC failed to probe with the error:
atmel-sama5d2-isc f0008000.isc: failed to enable ispck: -13
atmel-sama5d2-isc: probe of f0008000.isc failed with error -13
This is because the enabling of the ispck is done too early in the probe, and the PM runtime returns invalid request.
Thus, moved this clock enabling after pm_runtime_idle is called.
The ISPCK is required only for sama5d2 type of ISC.
Thus, add a bool inside the isc struct that is platform dependent. For the sama7g5-isc, the enabling of the ISPCK is wrong and does not make sense. Removed it from the sama7g5 probe. In sama7g5-isc, there is only one clock, the MCK, which also clocks the internal pipeline of the ISC.
Adapted the clk_prepare and clk_unprepare to request the runtime PM for both clocks (MCK and ISPCK) in case of sama5d2-isc, and the single clock (MCK) in case of sama7g5-isc.
--- drivers/media/platform/atmel/atmel-isc-base.c | 25 ++++++------ drivers/media/platform/atmel/atmel-isc.h | 2 + .../media/platform/atmel/atmel-sama5d2-isc.c | 39 ++++++++++--------- .../media/platform/atmel/atmel-sama7g5-isc.c | 22 ++--------- 4 files changed, 38 insertions(+), 50 deletions(-)
drivers/media/platform/atmel/atmel-isc-base.c +11 -14
@@ -123,11 +123,9 @@ static int isc_clk_prepare(struct clk_hw *hw)struct isc_clk *isc_clk =to_isc_clk (hw);int ret; -if (isc_clk->id ==ISC_ISPCK ) { - ret =pm_runtime_resume_and_get (isc_clk->dev); -if (ret <0 ) -return ret; - } + ret =pm_runtime_resume_and_get (isc_clk->dev); +if (ret <0 ) +return ret;return isc_wait_clk_stable (hw); }
@@ -138,8 +136,7 @@ static void isc_clk_unprepare(struct clk_hw *hw)isc_wait_clk_stable (hw); -if (isc_clk->id ==ISC_ISPCK ) -pm_runtime_put_sync (isc_clk->dev); +pm_runtime_put_sync (isc_clk->dev); }static int isc_clk_enable (struct clk_hw *hw)
@@ -186,16 +183,13 @@ static int isc_clk_is_enabled(struct clk_hw *hw)u32 status;int ret; -if (isc_clk->id ==ISC_ISPCK ) { - ret =pm_runtime_resume_and_get (isc_clk->dev); -if (ret <0 ) -return 0 ; - } + ret =pm_runtime_resume_and_get (isc_clk->dev); +if (ret <0 ) +return 0 ;regmap_read (isc_clk->regmap,ISC_CLKSR , &status); -if (isc_clk->id ==ISC_ISPCK ) -pm_runtime_put_sync (isc_clk->dev); +pm_runtime_put_sync (isc_clk->dev);return status &ISC_CLK (isc_clk->id) ?1 :0 ; }
@@ -325,6 +319,9 @@ static int isc_clk_register(struct isc_device *isc, unsigned int id)const char *parent_names[3 ];int num_parents; +if (id ==ISC_ISPCK && !isc->ispck_required) +return 0 ; + num_parents =of_clk_get_parent_count (np);if (num_parents <1 || num_parents >3 )return -EINVAL ;
drivers/media/platform/atmel/atmel-isc.h +2 -0
@@ -178,6 +178,7 @@ struct isc_reg_offsets {* @hclock: Hclock clock input (refer datasheet) * @ispck: iscpck clock (refer datasheet) * @isc_clks: ISC clocks +* @ispck_required: ISC requires ISP Clock initialization * @dcfg: DMA master configuration, architecture dependent * * @dev: Registered device driver
@@ -252,6 +253,7 @@ struct isc_device {struct clk *hclock;struct clk *ispck;struct isc_clk isc_clks[2 ]; +bool ispck_required;u32 dcfg;struct device *dev;
drivers/media/platform/atmel/atmel-sama5d2-isc.c +21 -18
@@ -454,6 +454,9 @@ static int atmel_isc_probe(struct platform_device *pdev)/* sama5d2-isc - 8 bits per beat */ isc->dcfg =ISC_DCFG_YMBSIZE_BEATS8 |ISC_DCFG_CMBSIZE_BEATS8 ; +/* sama5d2-isc : ISPCK is required and mandatory */ + isc->ispck_required = true; + ret =isc_pipeline_init (isc);if (ret)return ret;
@@ -476,22 +479,6 @@ static int atmel_isc_probe(struct platform_device *pdev)dev_err (dev,"failed to init isc clock: %d\n" , ret); goto unprepare_hclk; } - - isc->ispck = isc->isc_clks[ISC_ISPCK ].clk; - - ret =clk_prepare_enable (isc->ispck); -if (ret) { -dev_err (dev,"failed to enable ispck: %d\n" , ret); - goto unprepare_hclk; - } - -/* ispck should be greater or equal to hclock */ - ret =clk_set_rate (isc->ispck,clk_get_rate (isc->hclock)); -if (ret) { -dev_err (dev,"failed to set ispck rate: %d\n" , ret); - goto unprepare_clk; - } - ret =v4l2_device_register (dev, &isc->v4l2_dev);if (ret) {dev_err (dev,"unable to register v4l2 device.\n" );
@@ -545,19 +532,35 @@ static int atmel_isc_probe(struct platform_device *pdev)pm_runtime_enable (dev);pm_request_idle (dev); + isc->ispck = isc->isc_clks[ISC_ISPCK ].clk; + + ret =clk_prepare_enable (isc->ispck); +if (ret) { +dev_err (dev,"failed to enable ispck: %d\n" , ret); + goto cleanup_subdev; + } + +/* ispck should be greater or equal to hclock */ + ret =clk_set_rate (isc->ispck,clk_get_rate (isc->hclock)); +if (ret) { +dev_err (dev,"failed to set ispck rate: %d\n" , ret); + goto unprepare_clk; + } +regmap_read (isc->regmap,ISC_VERSION + isc->offsets.version, &ver);dev_info (dev,"Microchip ISC version %x\n" , ver);return 0 ; +unprepare_clk: +clk_disable_unprepare (isc->ispck); + cleanup_subdev:isc_subdev_cleanup (isc); unregister_v4l2_device:v4l2_device_unregister (&isc->v4l2_dev); -unprepare_clk: -clk_disable_unprepare (isc->ispck); unprepare_hclk:clk_disable_unprepare (isc->hclock);
drivers/media/platform/atmel/atmel-sama7g5-isc.c +4 -18
@@ -447,6 +447,9 @@ static int microchip_xisc_probe(struct platform_device *pdev)/* sama7g5-isc RAM access port is full AXI4 - 32 bits per beat */ isc->dcfg =ISC_DCFG_YMBSIZE_BEATS32 |ISC_DCFG_CMBSIZE_BEATS32 ; +/* sama7g5-isc : ISPCK does not exist, ISC is clocked by MCK */ + isc->ispck_required = false; + ret =isc_pipeline_init (isc);if (ret)return ret;
@@ -470,25 +473,10 @@ static int microchip_xisc_probe(struct platform_device *pdev) goto unprepare_hclk; } - isc->ispck = isc->isc_clks[ISC_ISPCK ].clk; - - ret =clk_prepare_enable (isc->ispck); -if (ret) { -dev_err (dev,"failed to enable ispck: %d\n" , ret); - goto unprepare_hclk; - } - -/* ispck should be greater or equal to hclock */ - ret =clk_set_rate (isc->ispck,clk_get_rate (isc->hclock)); -if (ret) { -dev_err (dev,"failed to set ispck rate: %d\n" , ret); - goto unprepare_clk; - } - ret =v4l2_device_register (dev, &isc->v4l2_dev);if (ret) {dev_err (dev,"unable to register v4l2 device.\n" ); - goto unprepare_clk; + goto unprepare_hclk; } ret =xisc_parse_dt (dev, isc);
@@ -549,8 +537,6 @@ cleanup_subdev: unregister_v4l2_device:v4l2_device_unregister (&isc->v4l2_dev); -unprepare_clk: -clk_disable_unprepare (isc->ispck); unprepare_hclk:clk_disable_unprepare (isc->hclock);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 396/849 scs: Release kasan vmalloc poison in scs_free process
In reply to Greg Kroah-HartmanFrom: Yee Lee <[email protected]>
[ Upstream commit 528a4ab45300fa6283556d9b48e26b45a8aa15c4 ]
Since scs allocation is moved to vmalloc region, the shadow stack is protected by kasan_posion_vmalloc. However, the vfree_atomic operation needs to access its context for scs_free process and causes kasan error as the dump info below.
This patch Adds kasan_unpoison_vmalloc() before vfree_atomic, which aligns to the prior flow as using kmem_cache. The vmalloc region will go back posioned in the following vumap() operations.
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in llist_add_batch+0x60/0xd4
Write of size 8 at addr ffff8000100b9000 by task kthreadd/2
CPU: 0 PID: 2 Comm: kthreadd Not tainted 5.15.0-rc2-11681-g92477dd1faa6-dirty #1
Hardware name: linux,dummy-virt (DT)
Call trace:
dump_backtrace+0x0/0x43c
show_stack+0x1c/0x2c
dump_stack_lvl+0x68/0x84
print_address_description+0x80/0x394
kasan_report+0x180/0x1dc
__asan_report_store8_noabort+0x48/0x58
llist_add_batch+0x60/0xd4
vfree_atomic+0x60/0xe0
scs_free+0x1dc/0x1fc
scs_release+0xa4/0xd4
free_task+0x30/0xe4
__put_task_struct+0x1ec/0x2e0
delayed_put_task_struct+0x5c/0xa0
rcu_do_batch+0x62c/0x8a0
rcu_core+0x60c/0xc14
rcu_core_si+0x14/0x24
__do_softirq+0x19c/0x68c
irq_exit+0x118/0x2dc
handle_domain_irq+0xcc/0x134
gic_handle_irq+0x7c/0x1bc
call_on_irq_stack+0x40/0x70
do_interrupt_handler+0x78/0x9c
el1_interrupt+0x34/0x60
el1h_64_irq_handler+0x1c/0x2c
el1h_64_irq+0x78/0x7c
_raw_spin_unlock_irqrestore+0x40/0xcc
sched_fork+0x4f0/0xb00
copy_process+0xacc/0x3648
kernel_clone+0x168/0x534
kernel_thread+0x13c/0x1b0
kthreadd+0x2bc/0x400
ret_from_fork+0x10/0x20
Memory state around the buggy address:
ffff8000100b8f00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffff8000100b8f80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>ffff8000100b9000: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
ffff8000100b9080: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffff8000100b9100: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================--- kernel/scs.c | 1 + 1 file changed, 1 insertion(+)
kernel/scs.c +1 -0
@@ -78,6 +78,7 @@ void scs_free(void *s)if (this_cpu_cmpxchg (scs_cache[i],0 , s) ==NULL )return ; +kasan_unpoison_vmalloc (s,SCS_SIZE );vfree_atomic (s); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 397/849 kprobes: Do not use local variable when creating debugfs file
In reply to Greg Kroah-HartmanFrom: Punit Agrawal <[email protected]>
[ Upstream commit 8f7262cd66699a4b02eb7549b35c81b2116aad95 ]
debugfs_create_file() takes a pointer argument that can be used during file operation callbacks (accessible via i_private in the inode structure). An obvious requirement is for the pointer to refer to valid memory when used.
When creating the debugfs file to dynamically enable / disable kprobes, a pointer to local variable is passed to debugfs_create_file(); which will go out of scope when the init function returns. The reason this hasn't triggered random memory corruption is because the pointer is not accessed during the debugfs file callbacks.
Since the enabled state is managed by the kprobes_all_disabled global variable, the local variable is not needed. Fix the incorrect (and unnecessary) usage of local variable during debugfs_file_create() by passing NULL instead.
--- kernel/kprobes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/kprobes.c +1 -2
@@ -2809,13 +2809,12 @@ static const struct file_operations fops_kp = {static int __init debugfs_kprobe_init (void ) {struct dentry *dir; -unsigned int value =1 ; dir =debugfs_create_dir ("kprobes" ,NULL );debugfs_create_file ("list" ,0400 , dir,NULL , &kprobes_fops); -debugfs_create_file ("enabled" ,0600 , dir, &value, &fops_kp); +debugfs_create_file ("enabled" ,0600 , dir,NULL , &fops_kp);debugfs_create_file ("blacklist" ,0400 , dir,NULL , &kprobe_blacklist_fops);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 398/849 crypto: ecc - fix CRYPTO_DEFAULT_RNG dependency
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 38aa192a05f22f9778f9420e630f0322525ef12e ]
The ecc.c file started out as part of the ECDH algorithm but got moved out into a standalone module later. It does not build without CRYPTO_DEFAULT_RNG, so now that other modules are using it as well we can run into this link error:
aarch64-linux-ld: ecc.c:(.text+0xfc8): undefined reference to `crypto_default_rng'
aarch64-linux-ld: ecc.c:(.text+0xff4): undefined reference to `crypto_put_default_rng'
Move the 'select CRYPTO_DEFAULT_RNG' statement into the correct symbol.
--- crypto/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/Kconfig +1 -1
@@ -233,12 +233,12 @@ config CRYPTO_DH config CRYPTO_ECC tristate + select CRYPTO_RNG_DEFAULT config CRYPTO_ECDH tristate "ECDH algorithm" select CRYPTO_ECC select CRYPTO_KPP - select CRYPTO_RNG_DEFAULT help Generic implementation of the ECDH algorithm
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 399/849 drm: fb_helper: fix CONFIG_FB dependency
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 606b102876e3741851dfb09d53f3ee57f650a52c ]
With CONFIG_FB=m and CONFIG_DRM=y, we get a link error in the fb helper:
aarch64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_alloc_fbi':
(.text+0x10cc): undefined reference to `framebuffer_alloc'
Tighten the dependency so it is only allowed in the case that DRM can link against FB.
--- drivers/gpu/drm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/Kconfig +1 -1
@@ -98,7 +98,7 @@ config DRM_DEBUG_DP_MST_TOPOLOGY_REFS config DRM_FBDEV_EMULATION bool "Enable legacy fbdev support for your modesetting driver" depends on DRM - depends on FB + depends on FB=y || FB=DRM select DRM_KMS_HELPER select FB_CFB_FILLRECT select FB_CFB_COPYAREA
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 400/849 cpuidle: Fix kobject memory leaks in error paths
In reply to Greg Kroah-HartmanFrom: Anel Orazgaliyeva <[email protected]>
[ Upstream commit e5f5a66c9aa9c331da5527c2e3fd9394e7091e01 ]
Commit c343bf1ba5ef ("cpuidle: Fix three reference count leaks") fixes the cleanup of kobjects; however, it removes kfree() calls altogether, leading to memory leaks.
Fix those and also defer the initialization of dev->kobj_dev until after the error check, so that we do not end up with a dangling pointer.
--- drivers/cpuidle/sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/cpuidle/sysfs.c +4 -1
@@ -488,6 +488,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device) &kdev->kobj, "state%d", i);if (ret) {kobject_put (&kobj->kobj); +kfree (kobj); goto error_state; }cpuidle_add_s2idle_attr_group (kobj);
@@ -619,6 +620,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev) &kdev->kobj, "driver");if (ret) {kobject_put (&kdrv->kobj); +kfree (kdrv);return ret; }
@@ -705,7 +707,6 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)if (!kdev)return -ENOMEM ; kdev->dev = dev; - dev->kobj_dev = kdev;init_completion (&kdev->kobj_unregister);
@@ -713,9 +714,11 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) "cpuidle");if (error) {kobject_put (&kdev->kobj); +kfree (kdev);return error; } + dev->kobj_dev = kdev;kobject_uevent (&kdev->kobj,KOBJ_ADD );return 0 ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 401/849 media: em28xx: Dont use ops->suspend if it is NULL
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 51fa3b70d27342baf1ea8aaab3e96e5f4f26d5b2 ]
The call to ops->suspend for the dev->dev_next case can currently trigger a call on a null function pointer if ops->suspend is null. Skip over the use of function ops->suspend if it is null.
Addresses-Coverity: ("Dereference after null check")
--- drivers/media/usb/em28xx/em28xx-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/usb/em28xx/em28xx-core.c +3 -2
@@ -1154,8 +1154,9 @@ int em28xx_suspend_extension(struct em28xx *dev)dev_info (&dev->intf->dev,"Suspending extensions\n" );mutex_lock (&em28xx_devlist_mutex);list_for_each_entry (ops, &em28xx_extension_devlist, next) { -if (ops->suspend) - ops->suspend (dev); +if (!ops->suspend) +continue ; + ops->suspend (dev);if (dev->dev_next) ops->suspend (dev->dev_next); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 402/849 ath10k: Dont always treat modem stop events as crashes
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
[ Upstream commit 747ff7d3d7424876111b7559b7f6704762f89796 ]
When rebooting on sc7180 Trogdor devices I see the following crash from the wifi driver.
ath10k_snoc 18800000.wifi: firmware crashed! (guid 83493570-29a2-4e98-a83e-70048c47669c)
This is because a modem stop event looks just like a firmware crash to the driver, the qmi connection is closed in both cases. Use the qcom ssr notifier block to stop treating the qmi connection close event as a firmware crash signal when the modem hasn't actually crashed. See ath10k_qmi_event_server_exit() for more details.
This silences the crash message seen during every reboot.
--- drivers/net/wireless/ath/ath10k/qmi.c | 3 +- drivers/net/wireless/ath/ath10k/snoc.c | 77 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/snoc.h | 5 ++ 3 files changed, 84 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/qmi.c +2 -1
@@ -864,7 +864,8 @@ static void ath10k_qmi_event_server_exit(struct ath10k_qmi *qmi)ath10k_qmi_remove_msa_permission (qmi);ath10k_core_free_board_files (ar); -if (!test_bit (ATH10K_SNOC_FLAG_UNREGISTERING , &ar_snoc->flags)) +if (!test_bit (ATH10K_SNOC_FLAG_UNREGISTERING , &ar_snoc->flags) && + !test_bit (ATH10K_SNOC_FLAG_MODEM_STOPPED , &ar_snoc->flags))ath10k_snoc_fw_crashed_dump (ar);ath10k_snoc_fw_indication (ar,ATH10K_QMI_EVENT_FW_DOWN_IND );
drivers/net/wireless/ath/ath10k/snoc.c +77 -0
105 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/snoc.h +5 -0
@@ -6,6 +6,8 @@#ifndef _SNOC_H_#define _SNOC_H_ +#include <linux/notifier.h> +#include "hw.h" #include "ce.h" #include "qmi.h"
@@ -45,6 +47,7 @@ struct ath10k_snoc_ce_irq {enum ath10k_snoc_flags {ATH10K_SNOC_FLAG_REGISTERED ,ATH10K_SNOC_FLAG_UNREGISTERING , +ATH10K_SNOC_FLAG_MODEM_STOPPED ,ATH10K_SNOC_FLAG_RECOVERY ,ATH10K_SNOC_FLAG_8BIT_HOST_CAP_QUIRK , };
@@ -75,6 +78,8 @@ struct ath10k_snoc {struct clk_bulk_data *clks;size_t num_clks;struct ath10k_qmi *qmi; +struct notifier_block nb; +void *notifier;unsigned long flags;bool xo_cal_supported;u32 xo_cal_data;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 403/849 ath9k: Fix potential interrupt storm on queue reset
In reply to Greg Kroah-HartmanFrom: Linus Lüssing <[email protected]>
[ Upstream commit 4925642d541278575ad1948c5924d71ffd57ef14 ]
In tests with two Lima boards from 8devices (QCA4531 based) on OpenWrt 19.07 we could force a silent restart of a device with no serial output when we were sending a high amount of UDP traffic (iperf3 at 80 MBit/s in both directions from external hosts, saturating the wifi and causing a load of about 4.5 to 6) and were then triggering an ath9k_queue_reset().
Further debugging showed that the restart was caused by the ath79 watchdog. With disabled watchdog we could observe that the device was constantly going into ath_isr() interrupt handler and was returning early after the ATH_OP_HW_RESET flag test, without clearing any interrupts. Even though ath9k_queue_reset() calls ath9k_hw_kill_interrupts().
With JTAG we could observe the following race condition:
1) ath9k_queue_reset()
...
-> ath9k_hw_kill_interrupts()
-> set_bit(ATH_OP_HW_RESET, &common->op_flags);
...
<- returns
2) ath9k_tasklet()
...
-> ath9k_hw_resume_interrupts()
...
<- returns
3) loops around:
...
handle_int()
-> ath_isr()
...
-> if (test_bit(ATH_OP_HW_RESET,
&common->op_flags))
return IRQ_HANDLED;
x) ath_reset_internal():
=> never reached <=And in ath_isr() we would typically see the following interrupts / interrupt causes:
* status: 0x00111030 or 0x00110030
* async_cause: 2 (AR_INTR_MAC_IPQ)
* sync_cause: 0
So the ath9k_tasklet() reenables the ath9k interrupts through ath9k_hw_resume_interrupts() which ath9k_queue_reset() had just disabled. And ath_isr() then keeps firing because it returns IRQ_HANDLED without actually clearing the interrupt.
To fix this IRQ storm also clear/disable the interrupts again when we are in reset state.
--- drivers/net/wireless/ath/ath9k/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/main.c +3 -1
@@ -533,8 +533,10 @@ irqreturn_t ath_isr(int irq, void *dev)ath9k_debug_sync_cause (sc, sync_cause); status &= ah->imask;/* discard unasked-for bits */ -if (test_bit (ATH_OP_HW_RESET , &common->op_flags)) +if (test_bit (ATH_OP_HW_RESET , &common->op_flags)) { +ath9k_hw_kill_interrupts (sc->sc_ah);return IRQ_HANDLED ; + }/* * If there are no status bits set, then this interrupt was not
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 404/849 PM: EM: Fix inefficient states detection
In reply to Greg Kroah-HartmanFrom: Vincent Donnefort <[email protected]>
[ Upstream commit aa1a43262ad5df010768f69530fa179ff81651d3 ]
Currently, a debug message is printed if an inefficient state is detected in the Energy Model. Unfortunately, it won't detect if the first state is inefficient or if two successive states are. Fix this behavior.
--- kernel/power/energy_model.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
kernel/power/energy_model.c +8 -15
@@ -107,8 +107,7 @@ static void em_debug_remove_pd(struct device *dev) {}static int em_create_perf_table (struct device *dev,struct em_perf_domain *pd,int nr_states,struct em_data_callback *cb) { -unsigned long opp_eff, prev_opp_eff =ULONG_MAX ; -unsigned long power, freq, prev_freq =0 ; +unsigned long power, freq, prev_freq =0 , prev_cost =ULONG_MAX ;struct em_perf_state *table;int i, ret;u64 fmax;
@@ -153,27 +152,21 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd, table[i].power = power; table[i].frequency = prev_freq = freq; - -/* -* The hertz/watts efficiency ratio should decrease as the -* frequency grows on sane platforms. But this isn't always -* true in practice so warn the user if a higher OPP is more -* power efficient than a lower one. -*/ - opp_eff = freq / power; -if (opp_eff >= prev_opp_eff) -dev_dbg (dev,"EM: hertz/watts ratio non-monotonically decreasing: em_perf_state %d >= em_perf_state%d\n" , - i, i -1 ); - prev_opp_eff = opp_eff; }/* Compute the cost of each performance state. */ fmax = (u64 ) table[nr_states -1 ].frequency; -for (i =0 ; i < nr_states; i++) { +for (i = nr_states -1 ; i >=0 ; i--) {unsigned long power_res =em_scale_power (table[i].power); table[i].cost =div64_u64 (fmax * power_res, table[i].frequency); +if (table[i].cost >= prev_cost) { +dev_dbg (dev,"EM: OPP:%lu is inefficient\n" , + table[i].frequency); + }else { + prev_cost = table[i].cost; + } } pd->table = table;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 405/849 x86/insn: Use get_unaligned() instead of memcpy()
In reply to Greg Kroah-HartmanFrom: Borislav Petkov <[email protected]>
[ Upstream commit f96b4675839b66168f5a07bf964dde6c2f1c4885 ]
Use get_unaligned() instead of memcpy() to access potentially unaligned memory, which, when accessed through a pointer, leads to undefined behavior. get_unaligned() describes much better what is happening there anyway even if memcpy() does the job.
In addition, since perf tool builds with -Werror, it would fire with:
util/intel-pt-decoder/../../../arch/x86/lib/insn.c: In function '__insn_get_emulate_prefix':
tools/include/../include/asm-generic/unaligned.h:10:15: error: packed attribute is unnecessary [-Werror=packed]
10 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \because -Werror=packed would complain if the packed attribute would have no effect on the layout of the structure.
In this case, that is intentional so disable the warning only for that compilation unit.
That part is Reported-by: Stephen Rothwell <[email protected]>
No functional changes.
--- arch/x86/lib/insn.c | 5 +++-- tools/arch/x86/lib/insn.c | 5 +++-- tools/include/asm-generic/unaligned.h | 23 +++++++++++++++++++++++ tools/perf/util/intel-pt-decoder/Build | 2 ++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 tools/include/asm-generic/unaligned.h
arch/x86/lib/insn.c +3 -2
@@ -13,6 +13,7 @@#endif #include <asm/inat.h> /*__ignore_sync_check__ */ #include <asm/insn.h> /* __ignore_sync_check__ */ +#include <asm/unaligned.h> /* __ignore_sync_check__ */ #include <linux/errno.h> #include <linux/kconfig.h>
@@ -37,10 +38,10 @@ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr)#define __get_next (t, insn) \ - ({ t r; memcpy(&r, insn->next_byte, sizeof(t)); insn->next_byte += sizeof(t); leXX_to_cpu(t, r); }) + ({ t r = get_unaligned((t *)(insn)->next_byte); (insn)->next_byte += sizeof(t); leXX_to_cpu(t, r); })#define __peek_nbyte_next (t, insn, n) \ - ({ t r; memcpy(&r, (insn)->next_byte + n, sizeof(t)); leXX_to_cpu(t, r); }) + ({ t r = get_unaligned((t *)(insn)->next_byte + n); leXX_to_cpu(t, r); })#define get_next (t, insn) \ ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); })
tools/arch/x86/lib/insn.c +3 -2
@@ -13,6 +13,7 @@#endif #include "../include/asm/inat.h" /* __ignore_sync_check__ */ #include "../include/asm/insn.h" /* __ignore_sync_check__ */ +#include "../include/asm-generic/unaligned.h" /* __ignore_sync_check__ */ #include <linux/errno.h> #include <linux/kconfig.h>
@@ -37,10 +38,10 @@ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr)#define __get_next (t, insn) \ - ({ t r; memcpy(&r, insn->next_byte, sizeof(t)); insn->next_byte += sizeof(t); leXX_to_cpu(t, r); }) + ({ t r = get_unaligned((t *)(insn)->next_byte); (insn)->next_byte += sizeof(t); leXX_to_cpu(t, r); })#define __peek_nbyte_next (t, insn, n) \ - ({ t r; memcpy(&r, (insn)->next_byte + n, sizeof(t)); leXX_to_cpu(t, r); }) + ({ t r = get_unaligned((t *)(insn)->next_byte + n); leXX_to_cpu(t, r); })#define get_next (t, insn) \ ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); })
tools/include/asm-generic/unaligned.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copied from the kernel sources to tools/perf/: +*/ + +#ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H +#define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H + +#define __get_unaligned_t (type, ptr) ({ \ + const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ + __pptr->x; \ +}) + +#define __put_unaligned_t (type, val, ptr) do { \ + struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ + __pptr->x = (val); \ +} while (0) + +#define get_unaligned (ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) +#define put_unaligned (val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) + +#endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */ +
tools/perf/util/intel-pt-decoder/Build +2 -0
@@ -18,3 +18,5 @@ CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder ifeq ($(CC_NO_CLANG), 1) CFLAGS_intel-pt-insn-decoder.o += -Wno-override-init endif + +CFLAGS_intel-pt-insn-decoder.o += -Wno-packed
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 406/849 EDAC/amd64: Handle three rank interleaving mode
In reply to Greg Kroah-HartmanFrom: Yazen Ghannam <[email protected]>
[ Upstream commit 9f4873fb6af7966de8fcbd95c36b61351c1c4b1f ]
AMD Rome systems and later support interleaving between three identical ranks within a channel.
Check for this mode by counting the number of enabled chip selects and comparing their masks. If there are exactly three enabled chip selects and their masks are identical, then three rank interleaving is enabled.
The size of a rank is determined from its mask value. However, three rank interleaving doesn't follow the method of swapping an interleave bit with the most significant bit. Rather, the interleave bit is flipped and the most significant bit remains the same. There is only a single interleave bit in this case.
Account for this when determining the chip select size by keeping the most significant bit at its original value and ignoring any zero bits. This will return a full bitmask in [MSB:1].
--- drivers/edac/amd64_edac.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/edac/amd64_edac.c +21 -1
@@ -1070,12 +1070,14 @@ static void debug_dump_dramcfg_low(struct amd64_pvt *pvt, u32 dclr, int chan)#define CS_ODD_PRIMARY BIT(1)#define CS_EVEN_SECONDARY BIT(2)#define CS_ODD_SECONDARY BIT(3) +#define CS_3R_INTERLEAVE BIT(4)#define CS_EVEN (CS_EVEN_PRIMARY | CS_EVEN_SECONDARY)#define CS_ODD (CS_ODD_PRIMARY | CS_ODD_SECONDARY)static int f17_get_cs_mode (int dimm,u8 ctrl,struct amd64_pvt *pvt) { +u8 base, count =0 ;int cs_mode =0 ;if (csrow_enabled (2 * dimm, ctrl, pvt))
@@ -1088,6 +1090,20 @@ static int f17_get_cs_mode(int dimm, u8 ctrl, struct amd64_pvt *pvt)if (csrow_sec_enabled (2 * dimm +1 , ctrl, pvt)) cs_mode |=CS_ODD_SECONDARY ; +/* +* 3 Rank inteleaving support. +* There should be only three bases enabled and their two masks should +* be equal. +*/ +for_each_chip_select (base, ctrl, pvt) + count +=csrow_enabled (base, ctrl, pvt); + +if (count ==3 && + pvt->csels[ctrl].csmasks[0 ] == pvt->csels[ctrl].csmasks[1 ]) { +edac_dbg (1 ,"3R interleaving in use.\n" ); + cs_mode |=CS_3R_INTERLEAVE ; + } +return cs_mode; }
@@ -1896,10 +1912,14 @@ static int f17_addr_mask_to_cs_size(struct amd64_pvt *pvt, u8 umc,* * The MSB is the number of bits in the full mask because BIT[0] is * always 0. +* +* In the special 3 Rank interleaving case, a single bit is flipped +* without swapping with the most significant bit. This can be handled +* by keeping the MSB where it is and ignoring the single zero bit. */ msb =fls (addr_mask_orig) -1 ; weight =hweight_long (addr_mask_orig); - num_zero_bits = msb - weight; + num_zero_bits = msb - weight - !!(cs_mode &CS_3R_INTERLEAVE );/* Take the number of zero bits off from the top of the mask. */ addr_mask_deinterleaved =GENMASK_ULL (msb - num_zero_bits,1 );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 407/849 rcu: Always inline rcu_dynticks_task*_{enter,exit}()
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 7663ad9a5dbcc27f3090e6bfd192c7e59222709f ]
RCU managed to grow a few noinstr violations:
vmlinux.o: warning: objtool: rcu_dynticks_eqs_enter()+0x0: call to rcu_dynticks_task_trace_enter() leaves .noinstr.text section vmlinux.o: warning: objtool: rcu_dynticks_eqs_exit()+0xe: call to rcu_dynticks_task_trace_exit() leaves .noinstr.text section
Fix them by adding __always_inline to the relevant trivial functions.
Also replace the noinstr with __always_inline for the existing rcu_dynticks_task_*() functions since noinstr would force noinline them, even when empty, which seems silly.
--- kernel/rcu/tree_plugin.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/tree_plugin.h +4 -4
@@ -2964,7 +2964,7 @@ static void rcu_bind_gp_kthread(void) }/* Record the current task on dyntick-idle entry. */ -static void noinstr rcu_dynticks_task_enter(void) +static __always_inline void rcu_dynticks_task_enter(void) {#if defined(CONFIG_TASKS_RCU ) && defined(CONFIG_NO_HZ_FULL )WRITE_ONCE (current->rcu_tasks_idle_cpu,smp_processor_id ());
@@ -2972,7 +2972,7 @@ static void noinstr rcu_dynticks_task_enter(void) }/* Record no current task on dyntick-idle exit. */ -static void noinstr rcu_dynticks_task_exit(void) +static __always_inline void rcu_dynticks_task_exit(void) {#if defined(CONFIG_TASKS_RCU ) && defined(CONFIG_NO_HZ_FULL )WRITE_ONCE (current->rcu_tasks_idle_cpu,-1 );
@@ -2980,7 +2980,7 @@ static void noinstr rcu_dynticks_task_exit(void) }/* Turn on heavyweight RCU tasks trace readers on idle/user entry. */ -static void rcu_dynticks_task_trace_enter (void ) +static __always_inline void rcu_dynticks_task_trace_enter(void) {#ifdef CONFIG_TASKS_TRACE_RCU if (IS_ENABLED (CONFIG_TASKS_TRACE_RCU_READ_MB ))
@@ -2989,7 +2989,7 @@ static void rcu_dynticks_task_trace_enter(void) }/* Turn off heavyweight RCU tasks trace readers on idle/user exit. */ -static void rcu_dynticks_task_trace_exit (void ) +static __always_inline void rcu_dynticks_task_trace_exit(void) {#ifdef CONFIG_TASKS_TRACE_RCU if (IS_ENABLED (CONFIG_TASKS_TRACE_RCU_READ_MB ))
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 408/849 netfilter: nft_dynset: relax superfluous check on set updates
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 7b1394892de8d95748d05e3ee41e85edb4abbfa1 ]
Relax this condition to make add and update commands idempotent for sets with no timeout. The eval function already checks if the set element timeout is available and updates it if the update command is used.
--- net/netfilter/nft_dynset.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
net/netfilter/nft_dynset.c +1 -10
@@ -198,17 +198,8 @@ static int nft_dynset_init(const struct nft_ctx *ctx,return -EBUSY ; priv->op =ntohl (nla_get_be32 (tb[NFTA_DYNSET_OP ])); -switch (priv->op) { -case NFT_DYNSET_OP_ADD : -case NFT_DYNSET_OP_DELETE : -break ; -case NFT_DYNSET_OP_UPDATE : -if (!(set->flags &NFT_SET_TIMEOUT )) -return -EOPNOTSUPP ; -break ; -default : +if (priv->op >NFT_DYNSET_OP_DELETE )return -EOPNOTSUPP ; - } timeout =0 ;if (tb[NFTA_DYNSET_TIMEOUT ] !=NULL ) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 409/849 media: venus: fix vpp frequency calculation for decoder
In reply to Greg Kroah-HartmanFrom: Mansur Alisha Shaik <[email protected]>
[ Upstream commit 1444232152ea33f5ae41fc14bade3e74d642b634 ]
In existing video driver implementation vpp frequency calculation in calculate_inst_freq() is always zero because the value of vpp_freq_per_mb is always zero for decoder.
Fixed this by correcting the calculating the vpp frequency calculation for decoder.
--- drivers/media/platform/qcom/venus/pm_helpers.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/pm_helpers.c +6 -2
@@ -1085,12 +1085,16 @@ static unsigned long calculate_inst_freq(struct venus_inst *inst,if (inst->state !=INST_START )return 0 ; -if (inst->session_type ==VIDC_SESSION_TYPE_ENC ) +if (inst->session_type ==VIDC_SESSION_TYPE_ENC ) { vpp_freq_per_mb = inst->flags &VENUS_LOW_POWER ? inst->clk_data.low_power_freq : inst->clk_data.vpp_freq; - vpp_freq = mbs_per_sec * vpp_freq_per_mb; + vpp_freq = mbs_per_sec * vpp_freq_per_mb; + }else { + vpp_freq = mbs_per_sec * inst->clk_data.vpp_freq; + } +/* 21 / 20 is overhead factor */ vpp_freq += vpp_freq /20 ; vsp_freq = mbs_per_sec * inst->clk_data.vsp_freq;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 410/849 media: dvb-frontends: mn88443x: Handle errors of clk_prepare_enable()
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit 69a10678e2fba3d182e78ea041f2d1b1a6058764 ]
mn88443x_cmn_power_on() did not handle possible errors of clk_prepare_enable() and always finished successfully so that its caller mn88443x_probe() did not care about failed preparing/enabling of clocks as well.
Add missed error handling in both mn88443x_cmn_power_on() and mn88443x_probe(). This required to change the return value of the former from "void" to "int".
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/media/dvb-frontends/mn88443x.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/media/dvb-frontends/mn88443x.c +15 -3
@@ -204,11 +204,18 @@ struct mn88443x_priv {struct regmap *regmap_t; }; -static void mn88443x_cmn_power_on (struct mn88443x_priv *chip) +static int mn88443x_cmn_power_on (struct mn88443x_priv *chip) { +struct device *dev = &chip->client_s->dev;struct regmap *r_t = chip->regmap_t; +int ret; -clk_prepare_enable (chip->mclk); + ret =clk_prepare_enable (chip->mclk); +if (ret) { +dev_err (dev,"Failed to prepare and enable mclk: %d\n" , + ret); +return ret; + }gpiod_set_value_cansleep (chip->reset_gpio,1 );usleep_range (100 ,1000 );
@@ -222,6 +229,8 @@ static void mn88443x_cmn_power_on(struct mn88443x_priv *chip) }else {regmap_write (r_t,HIZSET3 ,0x8f ); } + +return 0 ; }static void mn88443x_cmn_power_off (struct mn88443x_priv *chip)
@@ -738,7 +747,10 @@ static int mn88443x_probe(struct i2c_client *client, chip->fe.demodulator_priv = chip;i2c_set_clientdata (client, chip); -mn88443x_cmn_power_on (chip); + ret =mn88443x_cmn_power_on (chip); +if (ret) + goto err_i2c_t; +mn88443x_s_sleep (chip);mn88443x_t_sleep (chip);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 411/849 crypto: ccree - avoid out-of-range warnings from clang
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit cfd6fb45cfaf46fa9547421d8da387dc9c7997d4 ]
clang points out inconsistencies in the FIELD_PREP() invocation in this driver that result from the 'mask' being a 32-bit value:
drivers/crypto/ccree/cc_driver.c:117:18: error: result of comparison of constant 18446744073709551615 with expression of type 'u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
cache_params |= FIELD_PREP(mask, val);
^~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:52:28: note: expanded from macro '__BF_FIELD_CHECK'
BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This does not happen in other places that just pass a constant here.
Work around the warnings by widening the type of the temporary variable.
--- drivers/crypto/ccree/cc_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ccree/cc_driver.c +2 -1
@@ -103,7 +103,8 @@ MODULE_DEVICE_TABLE(of, arm_ccree_dev_of_match);static void init_cc_cache_params (struct cc_drvdata *drvdata) {struct device *dev =drvdata_to_dev (drvdata); -u32 cache_params, ace_const, val, mask; +u32 cache_params, ace_const, val; +u64 mask;/* compute CC_AXIM_CACHE_PARAMS */ cache_params =cc_ioread (drvdata,CC_REG (AXIM_CACHE_PARAMS ));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 412/849 crypto: qat - detect PFVF collision after ACK
In reply to Greg Kroah-HartmanFrom: Giovanni Cabiddu <[email protected]>
[ Upstream commit 9b768e8a3909ac1ab39ed44a3933716da7761a6f ]
Detect a PFVF collision between the local and the remote function by checking if the message on the PFVF CSR has been overwritten. This is done after the remote function confirms that the message has been received, by clearing the interrupt bit, or the maximum number of attempts (ADF_IOV_MSG_ACK_MAX_RETRY) to check the CSR has been exceeded.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +7 -0
@@ -150,6 +150,13 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) val =ADF_CSR_RD (pmisc_bar_addr, pf2vf_offset); }while ((val & int_bit) && (count++ <ADF_IOV_MSG_ACK_MAX_RETRY )); +if (val != msg) { +dev_dbg (&GET_DEV (accel_dev), +"Collision - PFVF CSR overwritten by remote function\n" ); + ret = -EIO ; + goto out; + } +if (val & int_bit) {dev_dbg (&GET_DEV (accel_dev),"ACK not received from remote\n" ); val &= ~int_bit;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 413/849 crypto: qat - disregard spurious PFVF interrupts
In reply to Greg Kroah-HartmanFrom: Giovanni Cabiddu <[email protected]>
[ Upstream commit 18fcba469ba5359c1de7e3fb16f7b9e8cd1b8e02 ]
Upon receiving a PFVF message, check if the interrupt bit is set in the message. If it is not, that means that the interrupt was probably triggered by a collision. In this case, disregard the message and re-enable the interrupts.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 6 ++++++ drivers/crypto/qat/qat_common/adf_vf_isr.c | 6 ++++++ 2 files changed, 12 insertions(+)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +6 -0
@@ -205,6 +205,11 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)/* Read message from the VF */ msg =ADF_CSR_RD (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr)); +if (!(msg &ADF_VF2PF_INT )) { +dev_info (&GET_DEV (accel_dev), +"Spurious VF2PF interrupt, msg %X. Ignored\n" , msg); + goto out; + }/* To ACK, clear the VF2PFINT bit */ msg &= ~ADF_VF2PF_INT ;
@@ -288,6 +293,7 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)if (resp &&adf_iov_putmsg (accel_dev, resp, vf_nr))dev_err (&GET_DEV (accel_dev),"Failed to send response to VF\n" ); +out:/* re-enable interrupt on PF from this VF */ adf_enable_vf2pf_interrupts (accel_dev, (1 << vf_nr));return ;
drivers/crypto/qat/qat_common/adf_vf_isr.c +6 -0
@@ -79,6 +79,11 @@ static void adf_pf2vf_bh_handler(void *data)/* Read the message from PF */ msg =ADF_CSR_RD (pmisc_bar_addr, hw_data->get_pf2vf_offset (0 )); +if (!(msg &ADF_PF2VF_INT )) { +dev_info (&GET_DEV (accel_dev), +"Spurious PF2VF interrupt, msg %X. Ignored\n" , msg); + goto out; + }if (!(msg &ADF_PF2VF_MSGORIGIN_SYSTEM ))/* Ignore legacy non-system (non-kernel) PF2VF messages */
@@ -127,6 +132,7 @@ static void adf_pf2vf_bh_handler(void *data) msg &= ~ADF_PF2VF_INT ;ADF_CSR_WR (pmisc_bar_addr, hw_data->get_pf2vf_offset (0 ), msg); +out:/* Re-enable PF2VF interrupts */ adf_enable_pf2vf_interrupts (accel_dev);return ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 414/849 hwrng: mtk - Force runtime pm ops for sleep ops
In reply to Greg Kroah-HartmanFrom: Markus Schneider-Pargmann <[email protected]>
[ Upstream commit b6f5f0c8f72d348b2d07b20d7b680ef13a7ffe98 ]
Currently mtk_rng_runtime_suspend/resume is called for both runtime pm and system sleep operations.
This is wrong as these should only be runtime ops as the name already suggests. Currently freezing the system will lead to a call to mtk_rng_runtime_suspend even if the device currently isn't active. This leads to a clock warning because it is disabled/unprepared although it isn't enabled/prepared currently.
This patch fixes this by only setting the runtime pm ops and forces to call the runtime pm ops from the system sleep ops as well if active but not otherwise.
--- drivers/char/hw_random/mtk-rng.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/char/hw_random/mtk-rng.c +7 -2
@@ -166,8 +166,13 @@ static int mtk_rng_runtime_resume(struct device *dev)return mtk_rng_init (&priv->rng); } -static UNIVERSAL_DEV_PM_OPS(mtk_rng_pm_ops, mtk_rng_runtime_suspend, - mtk_rng_runtime_resume, NULL); +static const struct dev_pm_ops mtk_rng_pm_ops = { + SET_RUNTIME_PM_OPS(mtk_rng_runtime_suspend, + mtk_rng_runtime_resume, NULL) +SET_SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, + pm_runtime_force_resume) +}; +#define MTK_RNG_PM_OPS (&mtk_rng_pm_ops)#else /* CONFIG_PM */ #define MTK_RNG_PM_OPS NULL
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 415/849 IMA: block writes of the security.ima xattr with unsupported algorithms
In reply to Greg Kroah-HartmanFrom: THOBY Simon <[email protected]>
[ Upstream commit 50f742dd91474e7f4954bf88d094eede59783883 ]
By default, writes to the extended attributes security.ima will be allowed even if the hash algorithm used for the xattr is not compiled in the kernel (which does not make sense because the kernel would not be able to appraise that file as it lacks support for validating the hash).
Prevent and audit writes to the security.ima xattr if the hash algorithm used in the new value is not available in the current kernel.
--- security/integrity/ima/ima.h | 2 +- security/integrity/ima/ima_appraise.c | 49 +++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-)
security/integrity/ima/ima.h +1 -1
@@ -319,7 +319,7 @@ int ima_must_appraise(struct user_namespace *mnt_userns, struct inode *inode,void ima_update_xattr (struct integrity_iint_cache *iint,struct file *file);enum integrity_status ima_get_cache_status (struct integrity_iint_cache *iint,enum ima_hooks func); -enum hash_algo ima_get_hash_algo (struct evm_ima_xattr_data *xattr_value, +enum hash_algo ima_get_hash_algo (const struct evm_ima_xattr_data *xattr_value,int xattr_len);int ima_read_xattr (struct dentry *dentry,struct evm_ima_xattr_data **xattr_value);
security/integrity/ima/ima_appraise.c +46 -3
68 lines not on this page · raw message
Signature · 1 line
2.33.0