7.2.6-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 632/1815 leds: pca9532: Fix phantom device registration on missing hardware
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmo Chou <[email protected]>
[ Upstream commit 8d6b6c05b8e33d11e3fb3203309385e1a9cceecd ]
The initial PWM and PSC register writes in pca9532_configure() do not check the return values of i2c_smbus_write_byte_data(). If the I2C device is physically absent from the bus, the write fails with -ENXIO. However, the driver ignores this error and allows probe() to complete successfully.
This results in the registration of phantom LED class devices and gpiochips backed by non-existent hardware. Subsequent GPIO reads from these phantom chips return bogus values (due to -ENXIO being truncated to an unsigned char in pca9532_gpio_get_value()), silently corrupting hardware state tracking in userspace.
Propagate the I2C write failures back to probe() so the driver core can gracefully abort binding and release devres-managed resources.
--- drivers/leds/leds-pca9532.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/leds/leds-pca9532.c +8 -4
@@ -397,10 +397,14 @@ static int pca9532_configure(struct i2c_client *client,for (i =0 ; i <2 ; i++) { data->pwm[i] = pdata->pwm[i]; data->psc[i] = pdata->psc[i]; -i2c_smbus_write_byte_data (client,PCA9532_REG_PWM (maxleds, i), - data->pwm[i]); -i2c_smbus_write_byte_data (client,PCA9532_REG_PSC (maxleds, i), - data->psc[i]); + err =i2c_smbus_write_byte_data (client,PCA9532_REG_PWM (maxleds, i), + data->pwm[i]); +if (err <0 ) +return err; + err =i2c_smbus_write_byte_data (client,PCA9532_REG_PSC (maxleds, i), + data->psc[i]); +if (err <0 ) +return err; } data->hw_blink = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 633/1815 clk: sunxi-ng: mux: fix determine helper rate propagation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
[ Upstream commit 4bcba49984ff8c77729f003dd32082b10c02c23b ]
Applying the pre divider on the parent rate is wrong because, while handling rate propagation through determine_rate(), the framework will likely round the parent rate again while cycling through the possibilities, throwing away the prediv applied. This means, the parent rate will then be wrong when the prediv is unapplied from a parent rate on which it was never applied to begin with.
The right way to do it is to unapply the prediv from the requested rate, which is the wanted rate at the input on the clock element, and pass this to framework to do its thing.
Change the determine rate mux helper in this way.
--- drivers/clk/sunxi-ng/ccu_mux.c | 57 +++++++++++++++++----------------- 1 file changed, 28 insertions(+), 29 deletions(-)
drivers/clk/sunxi-ng/ccu_mux.c +28 -29
@@ -93,66 +93,65 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,struct clk_rate_request adj_req = *req; best_parent =clk_hw_get_parent (hw); - best_parent_rate =clk_hw_get_rate (best_parent); - + adj_req.best_parent_rate =clk_hw_get_rate (best_parent); adj_req.best_parent_hw = best_parent; - adj_req.best_parent_rate =ccu_mux_helper_apply_prediv (common, cm,-1 , - best_parent_rate); + +/* +* This effectively treats the predivider as a postdivider. +* It stays mathematically correct and ensures whatever +* round() will do stays correct while walking the tree. +* It may query the parent rate too while handling rate +* propagation. +*/ + adj_req.rate =ccu_mux_helper_unapply_prediv (common, cm,-1 , + req->rate); ret =round (cm, &adj_req, data);if (ret)return ret; - best_rate = adj_req.rate; -/* -* best_parent_rate might have been modified by our clock. -* Unapply the pre-divider if there's one, and give -* the actual frequency the parent needs to run at. +* parent_rate might have been modified by our clock as part +* of the rate propagation mechanism. Same goes below. */ - best_parent_rate =ccu_mux_helper_unapply_prediv (common, cm,-1 , - adj_req.best_parent_rate); + best_parent_rate = adj_req.best_parent_rate; + best_rate =ccu_mux_helper_apply_prediv (common, cm,-1 , + adj_req.rate); goto out; }for (i =0 ; i <clk_hw_get_num_parents (hw); i++) {struct clk_rate_request tmp_req = *req; -unsigned long parent_rate; +unsigned long rate;struct clk_hw *parent; parent =clk_hw_get_parent_by_index (hw, i);if (!parent)continue ; - parent_rate =ccu_mux_helper_apply_prediv (common, cm, i, -clk_hw_get_rate (parent)); - tmp_req.best_parent_hw = parent; - tmp_req.best_parent_rate = parent_rate; + tmp_req.best_parent_rate =clk_hw_get_rate (parent); + tmp_req.rate =ccu_mux_helper_unapply_prediv (common, cm, i, + req->rate); ret =round (cm, &tmp_req, data);if (ret)continue ; -/* -* parent_rate might have been modified by our clock. -* Unapply the pre-divider if there's one, and give -* the actual frequency the parent needs to run at. -*/ - parent_rate =ccu_mux_helper_unapply_prediv (common, cm, i, - tmp_req.best_parent_rate); + rate =ccu_mux_helper_apply_prediv (common, cm, i, + tmp_req.rate); -if (tmp_req.rate == req->rate) { +if (rate == req->rate) { best_parent = parent; - best_parent_rate = parent_rate; - best_rate = tmp_req.rate; + best_parent_rate = tmp_req.best_parent_rate; + best_rate = rate; goto out; } -if (ccu_is_better_rate (common, req->rate, tmp_req.rate, best_rate)) { - best_rate = tmp_req.rate; - best_parent_rate = parent_rate; +if (ccu_is_better_rate (common, req->rate, rate, best_rate)) { + best_rate = rate; + best_parent_rate = tmp_req.best_parent_rate; best_parent = parent; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 634/1815 ASoC: spacemit: rename clock inputs to match binding
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Troy Mitchell <[email protected]>
[ Upstream commit 4c69d04958ec87163ba826e2506babab37192e4b ]
The driver requests the per-controller SSPA bus and functional clocks as "sspa_bus" and "sspa", but the device tree binding (spacemit,k1-i2s) specifies them as "bus" and "func". As a result, any DT written against the published binding fails to probe.
There are currently no in-tree DT users referencing these names, so rename the clock inputs in the driver to match the binding rather than changing the binding. While at it, rename the matching struct member sspa_clk to func_clk for consistency with the new clock-names.
--- sound/soc/spacemit/k1_i2s.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/spacemit/k1_i2s.c +8 -8
@@ -52,7 +52,7 @@ struct spacemit_i2s_dev {struct clk *sysclk;struct clk *bclk; -struct clk *sspa_clk; +struct clk *func_clk;struct clk *sysclk_div;struct clk *c_sysclk;struct clk *c_bclk;
@@ -221,7 +221,7 @@ static int spacemit_i2s_hw_params(struct snd_pcm_substream *substream,if (ret)return ret; -return clk_set_rate (i2s->sspa_clk, bclk_rate); +return clk_set_rate (i2s->func_clk, bclk_rate); } static int spacemit_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id,
@@ -445,14 +445,14 @@ static int spacemit_i2s_probe(struct platform_device *pdev)if (IS_ERR (i2s->bclk))return dev_err_probe (i2s->dev,PTR_ERR (i2s->bclk),"failed to enable bit clock\n" ); - clk =devm_clk_get_enabled (i2s->dev,"sspa_bus" ); + clk =devm_clk_get_enabled (i2s->dev,"bus" );if (IS_ERR (clk)) -return dev_err_probe (i2s->dev,PTR_ERR (clk),"failed to enable sspa_bus clock\n" ); +return dev_err_probe (i2s->dev,PTR_ERR (clk),"failed to enable bus clock\n" ); - i2s->sspa_clk =devm_clk_get_enabled (i2s->dev,"sspa" ); -if (IS_ERR (i2s->sspa_clk)) -return dev_err_probe (i2s->dev,PTR_ERR (i2s->sspa_clk), -"failed to enable sspa clock\n" ); + i2s->func_clk =devm_clk_get_enabled (i2s->dev,"func" ); +if (IS_ERR (i2s->func_clk)) +return dev_err_probe (i2s->dev,PTR_ERR (i2s->func_clk), +"failed to enable func clock\n" ); i2s->sysclk_div =devm_clk_get_optional_enabled (i2s->dev,"sysclk_div" );if (IS_ERR (i2s->sysclk_div))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 635/1815 perf cap: Remove used_root parameter and simplify capability checks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 87ec3437f37b9fe44c524ba967cb12e78de06f15 ]
Refactor perf_cap__capable() to completely remove the used_root out-parameter as requested by the maintainer. Relying on an explicit used_root boolean poisoned sequential capability checks (e.g. failing CAP_SYS_ADMIN checks poisoning the flag for subsequent CAP_PERFMON evaluations for unprivileged users) and created redundant complexity across check_ftrace_capable(), symbol__read_kptr_restrict(), and perf_event_paranoid_check().
Streamline the capability API to perform a pure true/false boolean evaluation. The function checks the Effective set using SYS_capget; if the syscall is missing or fails on legacy kernels, it cleanly falls back to checking EUID == 0. This perfectly preserves modern capability-aware host sessions, guarantees transparent fallback for older kernels, and correctly rejects privileged operations for containerized root processes that have explicitly dropped their capability bounding and permitted sets.
--- tools/perf/builtin-ftrace.c | 13 +++---------- tools/perf/util/bpf-filter.c | 22 +++++++++------------- tools/perf/util/cap.c | 4 +--- tools/perf/util/cap.h | 3 +-- tools/perf/util/symbol.c | 3 +-- tools/perf/util/util.c | 12 +++--------- 6 files changed, 18 insertions(+), 39 deletions(-)
tools/perf/builtin-ftrace.c +3 -10
@@ -72,18 +72,11 @@ static void ftrace__workload_exec_failed_signal(int signo __maybe_unused,static bool check_ftrace_capable (void ) { -bool used_root; - -if (perf_cap__capable (CAP_PERFMON , &used_root)) -return true; - -if (!used_root &&perf_cap__capable (CAP_SYS_ADMIN , &used_root)) +if (perf_cap__capable (CAP_PERFMON ) || +perf_cap__capable (CAP_SYS_ADMIN ))return true; -pr_err ("ftrace only works for %s!\n" , - used_root ?"root" - :"users with the CAP_PERFMON or CAP_SYS_ADMIN capability" - ); +pr_err ("ftrace only works for users with the CAP_PERFMON or CAP_SYS_ADMIN capability!\n" );return false; }
tools/perf/util/bpf-filter.c +9 -13
@@ -629,24 +629,20 @@ struct perf_bpf_filter_expr *perf_bpf_filter_expr__new(enum perf_bpf_filter_termstatic bool check_bpf_filter_capable (void ) { -bool used_root; +int fd; -if (perf_cap__capable (CAP_BPF , &used_root)) +if (perf_cap__capable (CAP_BPF ))return true; -if (!used_root) { -/* Check if root already pinned the filter programs and maps */ -int fd =get_pinned_fd ("filters" ); - -if (fd >=0 ) { -close (fd); -return true; - } +/* Check if root already pinned the filter programs and maps */ + fd =get_pinned_fd ("filters" ); +if (fd >=0 ) { +close (fd); +return true; } -pr_err ("Error: BPF filter only works for %s!\n" -"\tPlease run 'perf record --setup-filter pin' as root first.\n" , - used_root ?"root" :"users with the CAP_BPF capability" ); +pr_err ("Error: BPF filter only works for users with the CAP_BPF capability!\n" +"\tPlease run 'perf record --setup-filter pin' as root first.\n" );return false; }
tools/perf/util/cap.c +1 -3
@@ -12,7 +12,7 @@#define MAX_LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_3 -bool perf_cap__capable (int cap,bool *used_root) +bool perf_cap__capable (int cap) {struct __user_cap_header_struct header = { .version = _LINUX_CAPABILITY_VERSION_3,
@@ -21,7 +21,6 @@ bool perf_cap__capable(int cap, bool *used_root)struct __user_cap_data_struct data[MAX_LINUX_CAPABILITY_U32S ] = {};__u32 cap_val; - *used_root = false;while (syscall (SYS_capget, &header, &data[0 ]) ==-1 ) {/* Retry, first attempt has set the header.version correctly. */ if (errno == EINVAL && header.version != _LINUX_CAPABILITY_VERSION_3 &&
@@ -29,7 +28,6 @@ bool perf_cap__capable(int cap, bool *used_root)continue ;pr_debug2 ("capget syscall failed (%m) fall back on root check\n" ); - *used_root = true;return geteuid () ==0 ; }
tools/perf/util/cap.h +1 -2
@@ -18,7 +18,6 @@#define CAP_BPF 39#endif -/* Query if a capability is supported, used_root is set if the fallback root check was used. */ -bool perf_cap__capable (int cap,bool *used_root); +bool perf_cap__capable (int cap);#endif /* __PERF_CAP_H */
tools/perf/util/symbol.c +1 -2
@@ -2452,8 +2452,7 @@ static bool symbol__read_kptr_restrict(void) {bool value = false;FILE *fp =fopen ("/proc/sys/kernel/kptr_restrict" ,"r" ); -bool used_root; -bool cap_syslog =perf_cap__capable (CAP_SYSLOG , &used_root); +bool cap_syslog =perf_cap__capable (CAP_SYSLOG );if (fp !=NULL ) {char line[8 ];
tools/perf/util/util.c +3 -9
@@ -378,15 +378,9 @@ int perf_event_paranoid(void)bool perf_event_paranoid_check (int max_level) { -bool used_root; - -if (perf_cap__capable (CAP_SYS_ADMIN , &used_root)) -return true; - -if (!used_root &&perf_cap__capable (CAP_PERFMON , &used_root)) -return true; - -return perf_event_paranoid () <= max_level; +return perf_cap__capable (CAP_SYS_ADMIN ) || +perf_cap__capable (CAP_PERFMON ) || +perf_event_paranoid () <= max_level; }int perf_tip (char **strp,const char *dirpath)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 636/1815 perf trace: Correct default cpumask formatting to hexadecimal
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit 89493fe58c81db19efc16ec220e6fce512ec1cf7 ]
Currently, dynamic non-array fields such as 'cpumask_t' are mishandled in 'perf trace', causing the raw length and offset descriptors to be interpreted and displayed as a literal integer (e.g., "cpumask: 524320" instead of the actual mask data).
Correct the parsing of dynamic fields that do not have the TEP_FIELD_IS_ARRAY flag set by introducing helper functions format_field__get_raw_data() and format_field__get_cpumask(). Using these helpers, resolve the pointer to the raw bits within the payload and format the cpumask as a zero-padded hexadecimal string by default.
--- tools/perf/builtin-trace.c | 71 +++++++++++++++++++++++++---- tools/perf/util/evsel.c | 91 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 6 +++ 3 files changed, 159 insertions(+), 9 deletions(-)
tools/perf/builtin-trace.c +62 -9
@@ -3207,6 +3207,22 @@ static void bpf_output__fprintf(struct trace *trace, ++trace->nr_events_printed; } +static unsigned char bitmap_byte (const unsigned long *mask,int byte_idx) +{ +unsigned char b_val =0 ; +int bit_in_byte; + +for (bit_in_byte =0 ; bit_in_byte <8 ; bit_in_byte++) { +int b_idx = byte_idx *8 + bit_in_byte; +int host_w_idx = b_idx /BITS_PER_LONG ; +int host_bit_in_word = b_idx %BITS_PER_LONG ; + +if (mask[host_w_idx] & (1UL << host_bit_in_word)) + b_val |= (1 << bit_in_byte); + } +return b_val; +} +static size_t trace__fprintf_tp_fields (struct trace *trace,struct perf_sample *sample,struct thread *thread,void *augmented_args,int augmented_args_size) {
@@ -3238,17 +3254,54 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample * syscall_arg.len =0 ; syscall_arg.fmt = arg;if (field->flags &TEP_FIELD_IS_ARRAY ) { -int offset = field->offset; - -if (field->flags &TEP_FIELD_IS_DYNAMIC ) { - offset =format_field__intval (field, sample, evsel->needs_swap); - syscall_arg.len = offset >>16 ; - offset &=0xffff ; -if (tep_field_is_relative (field->flags)) - offset += field->offset + field->size; +void *ptr =format_field__get_raw_data (field, sample, + evsel->needs_swap, + &syscall_arg.len); + +if (!ptr) { +pr_err ("Problem processing %s field, skipping...\n" , field->name); +continue ; + } + val = (uintptr_t )ptr; + }else if ((field->flags &TEP_FIELD_IS_DYNAMIC ) && +strstr (field->type,"cpumask" )) { +unsigned long *mask =format_field__get_cpumask (field, sample, + evsel->needs_swap, + &syscall_arg.len); + +if (!mask) { +pr_err ("Problem processing %s field, skipping...\n" , field->name); +continue ; } - val = (uintptr_t )(sample->raw_data + offset); + printed +=scnprintf (bf + printed, size - printed,"%s" , printed ?", " :"" ); +if (trace->show_arg_names) + printed +=scnprintf (bf + printed, size - printed,"%s: " , field->name); + +if (syscall_arg.len ==0 ) { + printed +=scnprintf (bf + printed, size - printed,"0" ); + }else { +int i; +bool skip_zero = true; + + printed +=scnprintf (bf + printed, size - printed,"0x" ); +/* Print bytes from most significant to least significant */ +for (i = syscall_arg.len -1 ; i >=0 ; i--) { +unsigned char b_val =bitmap_byte (mask, i); + +if (skip_zero && b_val ==0 && i >0 ) +continue ; + +if (skip_zero) { + printed +=scnprintf (bf + printed, size - printed,"%x" , b_val); + skip_zero = false; + }else { + printed +=scnprintf (bf + printed, size - printed,"%02x" , b_val); + } + } + } +free (mask); +continue ; }else val =format_field__intval (field, sample, evsel->needs_swap);/*
tools/perf/util/evsel.c +91 -0
106 lines not on this page · raw message
tools/perf/util/evsel.h +6 -0
@@ -401,6 +401,12 @@ static inline char *perf_sample__strval(struct perf_sample *sample, const char *struct tep_format_field ; +void *format_field__get_raw_data (struct tep_format_field *field, +struct perf_sample *sample, +bool needs_swap,u16 *len_out); +unsigned long *format_field__get_cpumask (struct tep_format_field *field, +struct perf_sample *sample, +bool needs_swap,u16 *len_out);u64 format_field__intval (struct tep_format_field *field,struct perf_sample *sample,bool needs_swap);#ifdef HAVE_LIBTRACEEVENT
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 637/1815 drm/tve200: add OF module alias for autoloading
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Peng <[email protected]>
[ Upstream commit b6c3585f2058e0fbfa8cb403458f5cc6cf5c5e06 ]
The TVE200 DRM driver can be built as a module and uses tve200_of_match as its OF match table, but the table is not exported for module alias generation.
Add the MODULE_DEVICE_TABLE(of, ...) entry so modpost can generate OF module aliases for OF based module autoloading.
--- drivers/gpu/drm/tve200/tve200_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/tve200/tve200_drv.c +1 -0
@@ -263,6 +263,7 @@ static const struct of_device_id tve200_of_match[] = { }, {}, }; +MODULE_DEVICE_TABLE (of, tve200_of_match);static struct platform_driver tve200_driver = { .driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 638/1815 netfilter: nf_nat_sip: rewind offset when NAT shrinks the packet
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 16aecbe3036f6097c26b51b12e4c1cf207769690 ]
sashiko says:
If map_addr() changes the packet length, such as when the public NAT IP string is shorter or longer than the internal IP, coff will still point to the offset relative to the pre-mangled packet.
If the packet shrinks, coff could overshoot the correct position, potentially causing the next ct_sip_parse_header_uri() call to silently skip bytes and miss subsequent Contact headers. Could this lead to a failure to NAT those subsequent headers and leak internal network details?
--- net/netfilter/nf_nat_sip.c | 5 +++++ 1 file changed, 5 insertions(+)
net/netfilter/nf_nat_sip.c +5 -0
@@ -273,12 +273,17 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff, SIP_HDR_CONTACT, &in_header, &matchoff, &matchlen, &addr, &port) > 0) { +int old_len = skb->len, delta; +if (!map_addr (skb, protoff, dataoff, dptr, datalen, matchoff, matchlen, &addr, port)) {nf_ct_helper_log (skb, ct,"cannot mangle contact" );return NF_DROP ; } + + delta = (int )skb->len - old_len; + coff += delta; } if (!map_sip_addr(skb, protoff, dataoff, dptr, datalen, SIP_HDR_FROM) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 639/1815 fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Wu <[email protected]>
[ Upstream commit 2064bc663f89e61b8681c1fb9d1ce445de72063d ]
ntfs_reparse_init() and ntfs_objid_init() parse the index root of the $Extend/$Reparse and $Extend/$ObjId metafiles (the INDEX_ROOT attributes named $R and $O). They read its type and rule fields through resident_data(), which does not check that the resident attribute is large enough to hold them.
mi_enum_attr() accepts a resident attribute with data_off == asize and data_size == 0. For such an attribute placed last in its MFT record, resident_data() returns a pointer to the end of the record_size buffer, so reading root->type / root->rule reads past the allocation.
Use resident_data_ex(attr, sizeof(struct INDEX_ROOT)) and bail out when it returns NULL, as ntfs_security_init() already does for $SDH / $SII.
The attribute is only parsed while mounting a crafted image, so this needs CAP_SYS_ADMIN.
BUG: KASAN: slab-out-of-bounds in ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306) Read of size 4 at addr ffff88801219dc00 by task mount ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306) ntfs_fill_super (fs/ntfs3/super.c:1604) get_tree_bdev_flags (fs/super.c:1703) vfs_get_tree (fs/super.c:1758) path_mount (fs/namespace.c:4131) __x64_sys_mount (fs/namespace.c:4360)
--- fs/ntfs3/fsntfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/ntfs3/fsntfs.c +4 -4
@@ -2302,8 +2302,8 @@ int ntfs_reparse_init(struct ntfs_sb_info *sbi) goto out; } - root_r =resident_data (attr); -if (root_r->type !=ATTR_ZERO || + root_r =resident_data_ex (attr,sizeof (struct INDEX_ROOT )); +if (!root_r || root_r->type !=ATTR_ZERO || root_r->rule !=NTFS_COLLATION_TYPE_UINTS ) { err = -EINVAL ; goto out;
@@ -2340,8 +2340,8 @@ int ntfs_objid_init(struct ntfs_sb_info *sbi) goto out; } - root =resident_data (attr); -if (root->type !=ATTR_ZERO || + root =resident_data_ex (attr,sizeof (struct INDEX_ROOT )); +if (!root || root->type !=ATTR_ZERO || root->rule !=NTFS_COLLATION_TYPE_UINTS ) { err = -EINVAL ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 640/1815 drm/panthor: return PTR_ERR() from devm_drm_dev_alloc()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Osama Abdelkader <[email protected]>
[ Upstream commit abc1e559f8e5996eee506dfdc8e3781c2a1e04f9 ]
devm_drm_dev_alloc() returns an ERR_PTR() on failure, but panthor_probe() always converts that failure to -ENOMEM. Preserve the actual error code returned by the DRM core instead.
--- drivers/gpu/drm/panthor/panthor_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_drv.c +1 -1
@@ -1814,7 +1814,7 @@ static int panthor_probe(struct platform_device *pdev) ptdev =devm_drm_dev_alloc (&pdev->dev, &panthor_drm_driver, struct panthor_device, base);if (IS_ERR (ptdev)) -return -ENOMEM ; +return PTR_ERR (ptdev);platform_set_drvdata (pdev, ptdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 641/1815 exfat: fix valid_size extension over a shared writable mapping
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 1135704ed22f54873eb0498a232611d9eca30dd4 ]
When a shared writable mapping has its valid_size extended by a buffered write or a page fault, exfat zeroes the page-cache gap below the new valid_size. A store through the mapping can race with this zeroing and be overwritten.
Fix this by zeroing the gap lazily. Drop ->map_pages so that every first write fault goes through exfat_page_mkwrite(), which advances valid_size to cover the faulting page. With fault-around enabled, a store could install a writable PTE, skip ->page_mkwrite(), and land past valid_size without advancing it. Extending valid_size one faulting page at a time also leaves never-written pages in a large mapping alone.
The gap is filled with block granularity, zeroing only the not-uptodate blocks and preserving blocks that may hold data stored through the mapping. On the buffered-write path the invalidate lock is held and the gap is unmapped before zeroing, so a racing store re-faults and, under the inode lock, completes only after the gap has been zeroed and valid_size covers it.
--- fs/exfat/exfat_fs.h | 2 +- fs/exfat/file.c | 180 +++++++++++++++++++++++++++++++++++--------- fs/exfat/iomap.c | 11 ++- 3 files changed, 153 insertions(+), 40 deletions(-)
fs/exfat/exfat_fs.h +1 -1
@@ -294,7 +294,7 @@ struct exfat_inode_info {/* on-disk position of directory entry or 0 */ loff_t i_pos;loff_t valid_size; -/* page-aligned size that has been zeroed out for mmap */ +/* block-aligned size zeroed in the page cache (>= valid_size) */ loff_t zeroed_size;/* hash by i_location */ struct hlist_node i_hash_fat;
fs/exfat/file.c +143 -37
247 lines not on this page · raw message
fs/exfat/iomap.c +9 -2
@@ -175,11 +175,18 @@ static int exfat_write_iomap_end(struct inode *inode, loff_t pos, loff_t length,if (ei->valid_size < end) { ei->valid_size = end; -if (ei->zeroed_size < end) - ei->zeroed_size = end; dirtied = true; } +/* +* IOMAP_F_ZERO_TAIL zeroes the remainder of the last block. Track that +* block as zeroed so later valid_size extensions do not zero it again. +*/ +if (iomap->flags &IOMAP_F_ZERO_TAIL ) + end =round_up (end,i_blocksize (inode)); +if (ei->zeroed_size < end) + ei->zeroed_size = end; +if (dirtied || iomap->flags &IOMAP_F_SIZE_CHANGED )mark_inode_dirty (inode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 642/1815 arm64: dts: rockchip: Add missing hclk for RK3588 eDP0
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damon Ding <[email protected]>
[ Upstream commit ede2ee37f0a445cacbf24760f53befa10f64994a ]
Add the required HCLK_VO1 bus clock to RK3588 eDP0 node with corresponding clock-name "hclk". This clock is necessary for the eDP controller to access video output GRF and work properly.
Previously the clock was enabled implicitly via GRF phandle reference. Add it explicitly now to align with updated binding.
--- arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +2 -2
@@ -1910,8 +1910,8 @@ hdmi0_out: port@1 { edp0: edp@fdec0000 { compatible = "rockchip,rk3588-edp"; reg = <0x0 0xfdec0000 0x0 0x1000>; - clocks = <&cru CLK_EDP0_24M>, <&cru PCLK_EDP0>; - clock-names = "dp", "pclk"; + clocks = <&cru CLK_EDP0_24M>, <&cru PCLK_EDP0>, <&cru HCLK_VO1>; + clock-names = "dp", "pclk", "hclk"; interrupts = <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH 0>; phys = <&hdptxphy0>; phy-names = "dp";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 643/1815 arm64: dts: rockchip: Add missing hclk for RK3588 eDP1
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damon Ding <[email protected]>
[ Upstream commit 09820811c549ee2c408defe36b210b13c7a85fcf ]
Add the required HCLK_VO1 bus clock to RK3588 eDP1 node with corresponding clock-name "hclk". This clock is necessary for the eDP controller to access video output GRF and work properly.
Previously the clock was enabled implicitly via GRF phandle reference. Add it explicitly now to align with updated binding.
--- arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi +2 -2
@@ -285,8 +285,8 @@ hdmi1_out: port@1 { edp1: edp@fded0000 { compatible = "rockchip,rk3588-edp"; reg = <0x0 0xfded0000 0x0 0x1000>; - clocks = <&cru CLK_EDP1_24M>, <&cru PCLK_EDP1>; - clock-names = "dp", "pclk"; + clocks = <&cru CLK_EDP1_24M>, <&cru PCLK_EDP1>, <&cru HCLK_VO1>; + clock-names = "dp", "pclk", "hclk"; interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH 0>; phys = <&hdptxphy1>; phy-names = "dp";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 644/1815 arm64: dts: rockchip: Fix Gru WLAN sideband interrupt
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit a761818d9ee11183df0aefd16bf9fe46cc1c4c6d ]
The Marvell WLAN host wake interrupt is wired to GPIO0 8 and is not one of the PCI INTx interrupts. The PCI device schema therefore interprets the two-cell GPIO interrupt specifier as an invalid PCI interrupt and reports dtbs_check warnings:
pcie@0,0: wifi@0,0:interrupts:0:0: 8 is not one of [1, 2, 3, 4] pcie@0,0: wifi@0,0:interrupts:0: [8, 8] is too long
Describe the sideband interrupt with interrupts-extended, which explicitly carries the interrupt controller and removes the ambiguity.
--- arch/arm64/boot/dts/rockchip/rk3399-gru-chromebook.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-gru-chromebook.dtsi +1 -2
@@ -505,8 +505,7 @@ &pci_rootport { mvl_wifi: wifi@0,0 { compatible = "pci1b4b,2b42"; reg = <0x0000 0x0 0x0 0x0 0x0>; - interrupt-parent = <&gpio0>; - interrupts = <8 IRQ_TYPE_LEVEL_LOW>; + interrupts-extended = <&gpio0 8 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&wlan_host_wake_l>; wakeup-source;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 645/1815 arm64: dts: rockchip: Fix rk3566-bigtreetech-cb2 touchscreen property
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit 7707e4555cf1d52689621e3206df8ad2debaa0dd ]
The TSC2007 driver uses the ti,max-rt property to specify the maximum touch resistance, but the rk3566-bigtreetech-cb2 device tree uses the undocumented ti,rt-thr property instead.
As a result, the configured value is ignored and the driver falls back to its default maximum resistance value of 4095.
Replace ti,rt-thr with ti,max-rt to preserve the intended resistance threshold of 3000.
--- arch/arm64/boot/dts/rockchip/rk3566-bigtreetech-cb2.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3566-bigtreetech-cb2.dtsi +1 -1
@@ -569,7 +569,7 @@ tft_tp: touchscreen@48 { reg = <0x48>; status = "okay"; ti,x-plate-ohms = <660>; - ti,rt-thr = <3000>; + ti,max-rt = <3000>; ti,fuzzx = <32>; ti,fuzzy = <16>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 646/1815 bpf: Fix CFI mismatch in task work callback
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mykyta Yatsenko <[email protected]>
[ Upstream commit 2805abd089576799b15092949420e3f8ba97fabd ]
BPF subprograms use the bpf_callback_t ABI, but task work invokes the callback through a three-argument function pointer. This trips kCFI.
Store and invoke the callback as bpf_callback_t.
--- kernel/bpf/helpers.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/bpf/helpers.c +5 -4
@@ -4388,7 +4388,7 @@ struct bpf_task_work_ctx {struct bpf_map *map;void *map_val;enum task_work_notify_mode mode; -bpf_task_work_callback_t callback_fn; +bpf_callback_t callback_fn;struct rcu_head rcu; }__aligned(8) ;
@@ -4471,7 +4471,8 @@ static void bpf_task_work_callback(struct callback_head *cb) key = (void *)map_key_from_value (ctx->map, ctx->map_val, &idx);migrate_disable (); - ctx->callback_fn (ctx->map, key, ctx->map_val); + ctx->callback_fn ((u64 )(long )ctx->map, (u64 )(long )key, + (u64 )(long )ctx->map_val,0 ,0 );migrate_enable ();bpf_task_work_ctx_reset (ctx);
@@ -4594,7 +4595,7 @@ static struct bpf_task_work_ctx *bpf_task_work_acquire_ctx(struct bpf_task_work }static int bpf_task_work_schedule (struct task_struct *task,struct bpf_task_work *tw, -struct bpf_map *map,bpf_task_work_callback_t callback_fn, +struct bpf_map *map,void *callback_fn,struct bpf_prog_aux *aux,enum task_work_notify_mode mode) {struct bpf_prog *prog;
@@ -4619,7 +4620,7 @@ static int bpf_task_work_schedule(struct task_struct *task, struct bpf_task_work } ctx->task = task; - ctx->callback_fn = callback_fn; + ctx->callback_fn = (bpf_callback_t )callback_fn; ctx->prog = prog; ctx->mode = mode; ctx->map = map;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 647/1815 ARM: lpc32xx: only run SoC init on LPC32xx hardware
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 717ea4000867e6dffee5e1ed92150a9704ae9f68 ]
lpc32xx_check_uid() and lpc32xx_pm_init() are arch_initcalls that poke LPC32xx-only registers. Since the multiplatform conversion they also run on other ARCH_MULTI_V5 boards where access faults e.g. on versatile:
Unable to handle kernel paging request at virtual address f4004130 PC is at lpc32xx_check_uid+0x2c/0x9c
Drop the arch_initcall() registrations and call both functions directly from lpc3250_machine_init(), the machine's .init_machine hook. The calls are placed in link order (common.c, pm.c, phy3250.c) to keep their previous relative ordering.
--- arch/arm/mach-lpc32xx/common.c | 5 +---- arch/arm/mach-lpc32xx/common.h | 2 ++ arch/arm/mach-lpc32xx/phy3250.c | 2 ++ arch/arm/mach-lpc32xx/pm.c | 5 +---- 4 files changed, 6 insertions(+), 8 deletions(-)
arch/arm/mach-lpc32xx/common.c +1 -4
@@ -106,7 +106,7 @@ void __init lpc32xx_map_io(void)iotable_init (lpc32xx_io_desc,ARRAY_SIZE (lpc32xx_io_desc)); } -static int __init lpc32xx_check_uid (void ) +void __init lpc32xx_check_uid (void ) {u32 uid[4 ];
@@ -119,7 +119,4 @@ static int __init lpc32xx_check_uid(void) system_serial_low = uid[0 ]; system_serial_high = uid[1 ]; } - -return 1 ; } -arch_initcall (lpc32xx_check_uid);
arch/arm/mach-lpc32xx/common.h +2 -0
@@ -16,6 +16,8 @@* Other arch specific structures and functions */ extern void __init lpc32xx_map_io (void ); +extern void __init lpc32xx_check_uid (void ); +extern void __init lpc32xx_pm_init (void );extern void __init lpc32xx_serial_init (void );/*
arch/arm/mach-lpc32xx/phy3250.c +2 -0
@@ -71,6 +71,8 @@ static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {static void __init lpc3250_machine_init (void ) { +lpc32xx_check_uid (); +lpc32xx_pm_init ();lpc32xx_serial_init ();of_platform_default_populate (NULL , lpc32xx_auxdata_lookup,NULL );
arch/arm/mach-lpc32xx/pm.c +1 -4
@@ -120,7 +120,7 @@ static const struct platform_suspend_ops lpc32xx_pm_ops = {#define EMC_DYN_MEM_CTRL_OFS 0x20#define EMC_SRMMC (1 << 3)#define EMC_CTRL_REG io_p2v(LPC32XX_EMC_BASE + EMC_DYN_MEM_CTRL_OFS) -static int __init lpc32xx_pm_init (void ) +void __init lpc32xx_pm_init (void ) {/* * Setup SDRAM self-refresh clock to automatically disable o
@@ -129,7 +129,4 @@ static int __init lpc32xx_pm_init(void)__raw_writel (__raw_readl (EMC_CTRL_REG ) |EMC_SRMMC ,EMC_CTRL_REG );suspend_set_ops (&lpc32xx_pm_ops); - -return 0 ; } -arch_initcall (lpc32xx_pm_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 648/1815 bpf: Fix WARNING in bpf_tracing_link_release
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 61aaa8782bec59ecffd22e030f54ef9351bcabf9 ]
The trampoline could be corrupted by the blindly 'tr->flags = BPF_TRAMP_F_TAIL_CALL_CTX' in verifier.
1. A fexit attached to a tail_call_reachable prog. 'tr->flags' became 'BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_TAIL_CALL_CTX'. And, the trampoline would poke the target prog's nop insn using jmp insn instead of call insn.
2. Another fexit loaded with the same tail_call_reachable prog target. 'tr->flags' became 'BPF_TRAMP_F_TAIL_CALL_CTX'.
3. Close the first fexit link. Due to no BPF_TRAMP_F_CALL_ORIG in 'tr->flags', the trampoline will fail to restore the prog's nop insn using call insn.
[ 3.410719] WARNING: kernel/bpf/syscall.c:3551 at bpf_tracing_link_release+0x53/0x60, CPU#1: test_progs/98 ... [ 3.428793] bpf_link_free+0x58/0x130 [ 3.429293] bpf_link_release+0x23/0x30
Fix the warning by updating 'tr->flags' with '|=' and lock.
--- include/linux/bpf.h | 2 ++ kernel/bpf/trampoline.c | 7 +++++++ kernel/bpf/verifier.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-)
include/linux/bpf.h +2 -0
@@ -1524,6 +1524,7 @@ int bpf_trampoline_multi_attach(struct bpf_prog *prog, u32 *ids, struct bpf_tracing_multi_link *link);int bpf_trampoline_multi_detach (struct bpf_prog *prog,struct bpf_tracing_multi_link *link); +void bpf_trampoline_set_flags (struct bpf_trampoline *tr,u32 flags);/* * When the architecture supports STATIC_CALL replace the bpf_dispatcher_fn
@@ -1647,6 +1648,7 @@ static inline int bpf_trampoline_multi_detach(struct bpf_prog *prog, {return -ENOTSUPP ; } +static inline void bpf_trampoline_set_flags (struct bpf_trampoline *tr,u32 flags) {}#endif struct bpf_func_info_aux {
kernel/bpf/trampoline.c +7 -0
@@ -670,6 +670,13 @@ static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, int size)return ERR_PTR (err); } +void bpf_trampoline_set_flags (struct bpf_trampoline *tr,u32 flags) +{ +trampoline_lock (tr); + tr->flags |= flags; +trampoline_unlock (tr); +} +static int bpf_trampoline_update (struct bpf_trampoline *tr,bool lock_direct_mutex,const struct bpf_trampoline_ops *ops,void *data) {
kernel/bpf/verifier.c +1 -1
@@ -19444,7 +19444,7 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)return -ENOMEM ;if (tgt_prog && tgt_prog->aux->tail_call_reachable) - tr->flags =BPF_TRAMP_F_TAIL_CALL_CTX ; +bpf_trampoline_set_flags (tr,BPF_TRAMP_F_TAIL_CALL_CTX ); prog->aux->dst_trampoline = tr;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 649/1815 selftests/bpf: Fix incorrect error checking for pthread_create
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit b04b8d4e198aefc863e7b702ececb957845b0c25 ]
pthread_create returns 0 on success and a positive error code on failure; it never returns a negative value. The current conditional branch can never be taken. Failures during thread creation are silently ignored, which will lead to invalid memory access when waiting on threads or dereferencing thread handles later.
--- tools/testing/selftests/bpf/test_progs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_progs.c +1 -1
@@ -1741,7 +1741,7 @@ static void server_main(void) data[i].worker_id = i; data[i].sock_fd = env.worker_socks[i]; rc =pthread_create (&dispatcher_threads[i],NULL , dispatch_thread, &data[i]); -if (rc <0 ) { +if (rc) {perror ("Failed to launch dispatcher thread" );exit (EXIT_ERR_SETUP_INFRA ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 650/1815 selftests/bpf: Fix missing allocation null checks in test_progs.c
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit 12b362b2f06b283b7d8a2450f702f9b6a0f94aed ]
Add null checks after memory allocations to prevent potential segmentation faults.
--- tools/testing/selftests/bpf/test_progs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/test_progs.c +9 -2
@@ -730,11 +730,14 @@ int compare_map_keys(int map1_fd, int map2_fd)int compare_stack_ips (int smap_fd,int amap_fd,int stack_trace_len) {__u32 key, next_key, *cur_key_p, *next_key_p; -char *val_buf1, *val_buf2; -int i, err =0 ; +char *val_buf1 =NULL , *val_buf2 =NULL ; +int i, err = -ENOMEM ; val_buf1 =malloc (stack_trace_len); val_buf2 =malloc (stack_trace_len); +if (!val_buf1 || !val_buf2) + goto out; + err =0 ; cur_key_p =NULL ; next_key_p = &key;while (bpf_map_get_next_key (smap_fd, cur_key_p, next_key_p) ==0 ) {
@@ -1514,6 +1517,10 @@ static int dispatch_thread_send_subtests(int sock_fd, struct test_state *state)int subtest_num = state->subtest_num; state->subtest_states =malloc (subtest_num *sizeof (*subtest_state)); +if (!state->subtest_states) { + state->subtest_num =0 ; +return -ENOMEM ; + }for (int i =0 ; i < subtest_num; i++) { subtest_state = &state->subtest_states[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 651/1815 selftests/bpf: Fix memory leak on subtest_states reallocation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit 06efb01c6530e9cfc247178cb96aa8adb3beaf61 ]
Fix memory leak in subtest_states reallocation,
and revert subtest_num if allocation fails.
--- tools/testing/selftests/bpf/test_progs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/test_progs.c +5 -4
@@ -573,18 +573,19 @@ bool test__start_subtest_with_desc(const char *subtest_name, const char *subteststruct subtest_state *subtest_state;const char *subtest_display_name;size_t sub_state_size =sizeof (*subtest_state); +void *tmp;if (env.subtest_state)test__end_subtest (); state->subtest_num++; - state->subtest_states = -realloc (state->subtest_states, - state->subtest_num * sub_state_size); -if (!state->subtest_states) { + tmp =realloc (state->subtest_states, state->subtest_num * sub_state_size); +if (!tmp) { + state->subtest_num--;fprintf (stderr,"Not enough memory to allocate subtest result\n" );return false; } + state->subtest_states = tmp; subtest_state = &state->subtest_states[state->subtest_num -1 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 652/1815 pinctrl: fix unmet dependencies from missing GPIOLIB
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Braha <[email protected]>
[ Upstream commit 46840fa8c9f53b9c90db4b4be2b808bbc626cde2 ]
These 4 options, PINCTRL_PIC32, PINCTRL_PIC32, PINCTRL_IPROC_GPIO, and PINCTRL_NSP_GPIO all select GPIOLIB_IRQCHIP without ensuring GPIOLIB is enabled, causing unmet dependencies, such as:
WARNING: unmet direct dependencies detected for GPIOLIB_IRQCHIP
Depends on [n]: GPIOLIB [=n]
Selected by [y]:
- PINCTRL_PIC32 [=y] && PINCTRL [=y] && OF [=y] && (MACH_PIC32 || COMPILE_TEST [=y])
Similar options in this subsystem select GPIOLIB, so let's do the same here.
These unmet dependency bugs were found by kconfirm, a static analysis tool for Kconfig.
--- drivers/pinctrl/Kconfig | 2 ++ drivers/pinctrl/bcm/Kconfig | 2 ++ 2 files changed, 4 insertions(+)
drivers/pinctrl/Kconfig +2 -0
@@ -488,6 +488,7 @@ config PINCTRL_PIC32 depends on MACH_PIC32 || COMPILE_TEST select PINMUX select GENERIC_PINCONF + select GPIOLIB select GPIOLIB_IRQCHIP help This is the pin controller and gpio driver for Microchip PIC32
@@ -564,6 +565,7 @@ config PINCTRL_STMFX depends on I2C depends on HAS_IOMEM select GENERIC_PINCONF + select GPIOLIB select GPIOLIB_IRQCHIP select MFD_STMFX help
drivers/pinctrl/bcm/Kconfig +2 -0
@@ -121,6 +121,7 @@ source "drivers/pinctrl/bcm/Kconfig.stb" config PINCTRL_IPROC_GPIO bool "Broadcom iProc GPIO (with PINCONF) driver" depends on ARCH_BCM_IPROC || COMPILE_TEST + select GPIOLIB select GPIOLIB_IRQCHIP select PINCONF select GENERIC_PINCONF
@@ -186,6 +187,7 @@ config PINCTRL_NS config PINCTRL_NSP_GPIO bool "Broadcom NSP GPIO (with PINCONF) driver" depends on ARCH_BCM_NSP || COMPILE_TEST + select GPIOLIB select GPIOLIB_IRQCHIP select PINCONF select GENERIC_PINCONF
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 653/1815 cxl/region: Fix use-after-free in find_pos_and_ways() error path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 15da704b732332cc1e8f121f624e5e6c05124c5d ]
The error path releases its reference to a switch decoder before logging an error that includes the decoder name. If the released reference is the last one, the decoder can be freed before the error message accesses its name.
Drop the reference after the error is reported.
--- drivers/cxl/core/region.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/cxl/core/region.c +3 -4
@@ -1939,14 +1939,13 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range,break ; } } -put_device (dev); -if (rc)dev_err (port->uport_dev,"failed to find %s:%s in target list of %s\n" ,dev_name (&port->dev), -dev_name (port->parent_dport->dport_dev), -dev_name (&cxlsd->cxld.dev)); +dev_name (port->parent_dport->dport_dev),dev_name (dev)); + +put_device (dev);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 654/1815 power: reset: reboot-mode: Remove devres based allocations
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivendra Pratap <[email protected]>
[ Upstream commit 42326d59391cf287bf21224f3fdca528be31ece2 ]
Devres APIs are intended for use in drivers, where the managed lifetime of resources is tied directly to the driver attach/detach cycle.
To ensure correct lifetime handling, avoid using devres-based allocations in the reboot-mode and explicitly handle allocation and cleanup of resources.
--- drivers/power/reset/reboot-mode.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
drivers/power/reset/reboot-mode.c +19 -11
@@ -10,6 +10,7 @@#include <linux/list.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/property.h> #include <linux/reboot.h> #include <linux/reboot-mode.h> #include <linux/slab.h>
@@ -168,10 +169,11 @@ static int reboot_mode_create_device(struct reboot_mode_driver *reboot)*/ int reboot_mode_register (struct reboot_mode_driver *reboot) { -struct mode_info *info; +struct mode_info *info =NULL ;struct property *prop;struct device_node *np = reboot->dev->of_node;size_t len =strlen (PREFIX ); +u32 magic;int ret;INIT_LIST_HEAD (&reboot->head);
@@ -180,22 +182,22 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)if (strncmp (prop->name,PREFIX , len))continue ; - info =devm_kzalloc (reboot->dev,sizeof (*info),GFP_KERNEL ); +if (device_property_read_u32 (reboot->dev, prop->name, &magic)) { +dev_dbg (reboot->dev,"reboot mode %s without magic number\n" , + prop->name); +continue ; + } + + info =kzalloc_obj (*info,GFP_KERNEL );if (!info) { ret = -ENOMEM ; goto error; } -if (of_property_read_u32 (np, prop->name, &info->magic)) { -dev_err (reboot->dev,"reboot mode %s without magic number\n" , - info->mode); -devm_kfree (reboot->dev, info); -continue ; - } - + info->magic = magic; info->mode =kstrdup_const (prop->name + len,GFP_KERNEL );if (!info->mode) { - ret = -ENOMEM ; + ret = -ENOMEM ; goto error; }else if (info->mode[0 ] =='\0' ) {kfree_const (info->mode);
@@ -206,6 +208,7 @@ int reboot_mode_register(struct reboot_mode_driver *reboot) }list_add_tail (&info->list, &reboot->head); + info =NULL ; } reboot->reboot_notifier.notifier_call = reboot_mode_notify;
@@ -218,6 +221,7 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)return 0 ; error: +kfree (info);reboot_mode_unregister (reboot);return ret; }
@@ -261,12 +265,16 @@ static inline void reboot_mode_unregister_device(struct reboot_mode_driver *reboint reboot_mode_unregister (struct reboot_mode_driver *reboot) {struct mode_info *info; +struct mode_info *next;unregister_reboot_notifier (&reboot->reboot_notifier);reboot_mode_unregister_device (reboot); -list_for_each_entry (info, &reboot->head, list) +list_for_each_entry_safe (info, next, &reboot->head, list) { +list_del (&info->list);kfree_const (info->mode); +kfree (info); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 655/1815 riscv: dts: spacemit: improve RTL8211F PHY configuration on K3 Pico-ITX board
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aurelien Jarno <[email protected]>
[ Upstream commit e0c1145f4c8ea0515b32e0b9620412528a4312b1 ]
Vendor kernel enabled ALDPS (Advanced Link Down Power Saving) on the RTL8211F PHY to save power when link down.
Vendor kernel also disabled the 125MHz clkout clock signal, and indeed the schematics confirms that it only goes to a test point (TP14), so let's do the same.
Stable-dep-of: a225e19a4cc4 ("riscv: dts: spacemit: Add enough deassert time for the PHY on PICO ITX")
--- arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +2 -0
@@ -196,6 +196,8 @@ phy0: phy@1 { reset-gpios = <&gpio 0 15 GPIO_ACTIVE_LOW>; reset-assert-us = <10000>; reset-deassert-us = <10000>; + realtek,aldps-enable; + realtek,clkout-disable; }; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 656/1815 riscv: dts: spacemit: Add enough deassert time for the PHY on PICO ITX
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit a225e19a4cc4e040ca0389cf0bbe209c23f5c92d ]
RTL8211F require at least 50ms deassert to guarantee the register access, 10ms is only enough for the PHY reset.
--- arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +1 -1
@@ -195,7 +195,7 @@ phy0: phy@1 { reg = <1>; reset-gpios = <&gpio 0 15 GPIO_ACTIVE_LOW>; reset-assert-us = <10000>; - reset-deassert-us = <10000>; + reset-deassert-us = <50000>; realtek,aldps-enable; realtek,clkout-disable; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 657/1815 riscv: dts: spacemit: Add enough deassert time for the PHY on com260 board
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit 12b0d602e8642297ec369eeb99366d37c8a3a120 ]
RTL8211F require at least 50ms deassert to guarantee the register access, 10ms is only enough for the PHY reset.
--- arch/riscv/boot/dts/spacemit/k3-com260.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/spacemit/k3-com260.dtsi +1 -1
@@ -178,7 +178,7 @@ phy1: phy@1 { reg = <1>; reset-gpios = <&gpio 1 5 GPIO_ACTIVE_LOW>; reset-assert-us = <10000>; - reset-deassert-us = <10000>; + reset-deassert-us = <50000>; }; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 658/1815 liveupdate: reject nonzero reserved value for SESSION_FINISH
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jackie Liu <[email protected]>
[ Upstream commit 05cf3d87a0bf23e328a7f7db488860fe14acc335 ]
The UAPI documents liveupdate_session_finish::reserved as requiring zero, but luo_session_finish() currently ignores it and finishes the session. Accepting nonzero values prevents the field from being safely repurposed by a future extension.
Reject nonzero reserved values before changing session state, matching LIVEUPDATE_SESSION_GET_NAME.
--- kernel/liveupdate/luo_session.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/liveupdate/luo_session.c +5 -1
@@ -316,8 +316,12 @@ static int luo_session_finish(struct luo_session *session, struct luo_ucmd *ucmd) {struct liveupdate_session_finish *argp = ucmd->cmd; -int err =luo_session_finish_one (session); +int err; + +if (argp->reserved) +return -EINVAL ; + err =luo_session_finish_one (session);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 659/1815 liveupdate: Reference count outgoing FLB data
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Matlack <[email protected]>
[ Upstream commit 36882f3392395704c8a3fe7fac831fb6f5737e7d ]
Increment the outgoing FLB refcount in liveupdate_flb_get_outgoing() so that the FLB structure cannot be freed while the caller is actively using it. Add an additional liveupdate_flb_put_outgoing() function so the caller can explicitly indicate when it is done using the outgoing FLB.
During a Live Update, the kernel may need to fetch the outgoing FLB outside of the scope of a file handler's preserve() and unpreserve() callbacks. In that situation there is no way for the caller to protect itself against the outgoing FLB from being freed while it is using it. Incrementing the reference count in liveupdate_flb_get_outgoing() ensures it cannot be freed.
This change also aligns the outgoing FLB lifecycle management with the incoming FLB, since the latter uses the same get/put semantics.
--- include/linux/liveupdate.h | 5 +++++ kernel/liveupdate/luo_flb.c | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
include/linux/liveupdate.h +5 -0
@@ -243,6 +243,7 @@ int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp);void liveupdate_flb_put_incoming (struct liveupdate_flb *flb);int liveupdate_flb_get_outgoing (struct liveupdate_flb *flb,void **objp); +void liveupdate_flb_put_outgoing (struct liveupdate_flb *flb);#else /* CONFIG_LIVEUPDATE */
@@ -292,5 +293,9 @@ static inline int liveupdate_flb_get_outgoing(struct liveupdate_flb *flb,return -EOPNOTSUPP ; } +static inline void liveupdate_flb_put_outgoing (struct liveupdate_flb *flb) +{ +} +#endif /* CONFIG_LIVEUPDATE */ #endif /* _LINUX_LIVEUPDATE_H */
kernel/liveupdate/luo_flb.c +7 -3
@@ -133,7 +133,7 @@ static int luo_flb_file_preserve_one(struct liveupdate_flb *flb)return 0 ; } -static void luo_flb_file_unpreserve_one (struct liveupdate_flb *flb) +void liveupdate_flb_put_outgoing (struct liveupdate_flb *flb) {struct luo_flb_private *private =luo_flb_get_private (flb);
@@ -264,7 +264,7 @@ int luo_flb_file_preserve(struct liveupdate_file_handler *fh) exit_err:list_for_each_entry_continue_reverse (iter, flb_list, list) -luo_flb_file_unpreserve_one (iter->flb); +liveupdate_flb_put_outgoing (iter->flb);up_read (&luo_register_rwlock);return err;
@@ -289,7 +289,7 @@ void luo_flb_file_unpreserve(struct liveupdate_file_handler *fh)guard (rwsem_read)(&luo_register_rwlock);list_for_each_entry_reverse (iter, flb_list, list) -luo_flb_file_unpreserve_one (iter->flb); +liveupdate_flb_put_outgoing (iter->flb); }/**
@@ -544,6 +544,10 @@ int liveupdate_flb_get_outgoing(struct liveupdate_flb *flb, void **objp)return -EOPNOTSUPP ;guard (mutex)(&private->outgoing.lock); +if (!private->outgoing.obj) +return -ENOENT ; + +refcount_inc (&private->outgoing.count); *objp = private->outgoing.obj;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 660/1815 liveupdate: Remember FLB retrieve() status
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Matlack <[email protected]>
[ Upstream commit 5c4a03afcb21783987ffc64562b76ddd5a21b12b ]
LUO keeps track of successful retrieve attempts on an FLB. It does so to avoid multiple retrievals of the same FLB. Multiple retrievals cause problems because once the FLB is retrieved, the serialized data structures are likely freed and the FLB is likely in a very different state from what the code expects.
All this works well when retrieve succeeds. When it fails, luo_flb_retrieve_one() returns the error immediately, without ever storing anywhere that a retrieve was attempted or what its error code was. If the user attempts to retrieve another file registered with the same FLB, LUO will attempt to call the FLB's retrieve() callback again.
The retry is problematic for much of the same reasons listed above. The FLB is likely in a very different state than what the retrieve logic normally expects (e.g. some KHO pages may have already been restored and freed).
There is no sane way of attempting the retrieve again. Remember the error retrieve returned and directly return it on a retry.
This is done by changing the retrieved bool to a retrieve_status integer. A value of 0 means retrieve was never attempted, a positive value means it succeeded, and a negative value means it failed and the error code is the value.
This is similar to commit f85b1c6af5bc ("liveupdate: luo_file: remember retrieve() status") which did the same for LUO files.
--- include/linux/liveupdate.h | 6 ++++-- kernel/liveupdate/luo_flb.c | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-)
include/linux/liveupdate.h +4 -2
@@ -173,7 +173,9 @@ struct liveupdate_flb_ops {* @lock: A mutex that protects all fields within this structure, providing * the synchronization service for the FLB's ops. * @finished: True once the FLB's finish() callback has run. -* @retrieved: True once the FLB's retrieve() callback has run. +* @retrieve_status: Status code indicating whether retrieve() has been +* attempted. 0 means not attempted, 1 means successful, +* and negative value means it failed with that error code. */ struct luo_flb_private_state {refcount_t count;
@@ -181,7 +183,7 @@ struct luo_flb_private_state {void *obj;struct mutex lock;bool finished; -bool retrieved; +int retrieve_status; };/*
kernel/liveupdate/luo_flb.c +7 -3
@@ -168,7 +168,10 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb)if (private->incoming.finished)return -ENODATA ; -if (private->incoming.retrieved) +if (private->incoming.retrieve_status <0 ) +return private->incoming.retrieve_status; + +if (private->incoming.retrieve_status >0 )return 0 ;if (!fh->active)
@@ -194,12 +197,13 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb) err = flb->ops->retrieve (&args);if (err) { + private->incoming.retrieve_status = err;module_put (flb->ops->owner);return err; } private->incoming.obj = args.obj; - private->incoming.retrieved = true; + private->incoming.retrieve_status =1 ;return 0 ; }
@@ -213,7 +217,7 @@ void liveupdate_flb_put_incoming(struct liveupdate_flb *flb)if (!refcount_dec_and_test (&private->incoming.count))return ; -if (!private->incoming.retrieved) { +if (private->incoming.retrieve_status <=0 ) {int err =luo_flb_retrieve_one (flb);if (WARN_ON (err))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 661/1815 pinctrl: mediatek: use devm_gpiochip_add_data() for GPIO chip
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Yeh <[email protected]>
[ Upstream commit 9c650317ba553d297f3fc5f0ae40ec53d86f9dab ]
The gpio_chip is allocated with device-managed memory but registered with the non-managed gpiochip_add_data(). This was harmless while the drivers were built-in, but once they can be built as modules and unbound/rmmod'd, devm frees the gpio_chip's memory while it is still registered, causing a use-after-free.
Register it with devm_gpiochip_add_data() so it shares the same device-managed lifecycle, which also lets the manual gpiochip_remove() error paths go away.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 6 ++---- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 14 ++++---------- drivers/pinctrl/mediatek/pinctrl-paris.c | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +2 -4
@@ -594,7 +594,7 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw) chip->base =-1 ; chip->ngpio = hw->soc->npins; - ret =gpiochip_add_data (chip, hw); + ret =devm_gpiochip_add_data (hw->dev, chip, hw);if (ret <0 )return ret;
@@ -608,10 +608,8 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw)if (!of_property_present (hw->dev->of_node,"gpio-ranges" )) { ret =gpiochip_add_pin_range (chip,dev_name (hw->dev),0 ,0 , chip->ngpio); -if (ret <0 ) { -gpiochip_remove (chip); +if (ret <0 )return ret; - } }return 0 ;
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +4 -10
@@ -1130,30 +1130,24 @@ int mtk_pctrl_init(struct platform_device *pdev, pctl->chip->parent = &pdev->dev; pctl->chip->base =-1 ; - ret =gpiochip_add_data (pctl->chip, pctl); + ret =devm_gpiochip_add_data (&pdev->dev, pctl->chip, pctl);if (ret)return -EINVAL ;/* Register the GPIO to pin mappings. */ ret =gpiochip_add_pin_range (pctl->chip,dev_name (&pdev->dev),0 ,0 , pctl->devdata->npins); -if (ret) { - ret = -EINVAL ; - goto chip_error; - } +if (ret) +return -EINVAL ;/* Only initialize EINT if we have EINT pins */ if (data->eint_hw.ap_num >0 ) { ret =mtk_eint_init (pctl, pdev);if (ret) - goto chip_error; +return ret; }return 0 ; - -chip_error: -gpiochip_remove (pctl->chip); -return ret; }int mtk_pctrl_common_probe (struct platform_device *pdev)
drivers/pinctrl/mediatek/pinctrl-paris.c +1 -1
@@ -957,7 +957,7 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw) chip->base =-1 ; chip->ngpio = hw->soc->npins; - ret =gpiochip_add_data (chip, hw); + ret =devm_gpiochip_add_data (hw->dev, chip, hw);if (ret <0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 662/1815 pinctrl: mediatek: free EINT resources on unbind
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Yeh <[email protected]>
[ Upstream commit 88292b7103d260e3e606eb3bb2794060a5fde48e ]
mtk_eint_do_init() creates an IRQ domain, populates it with a mapping for every EINT line and installs a chained handler on the parent interrupt, but none of these are ever released. This was harmless while the drivers were built-in, but now that they can be built as modules and unbound/rmmod'd it leaves behind a dangling IRQ domain, interrupt mappings whose chip data points at freed memory, and a chained handler that keeps firing into that freed data.
The plain allocations in mtk_eint_do_init() already use the device-managed devm_*() helpers, so tear the remaining resources down the same way:
register a devm action that detaches the chained handler, waits for any in-flight handler to finish, disposes of the per-line mappings and removes the IRQ domain. This mirrors the device-managed lifecycle adopted for the GPIO chip and keeps the whole EINT setup self-cleaning on unbind.
--- drivers/pinctrl/mediatek/mtk-eint.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/pinctrl/mediatek/mtk-eint.c +24 -1
@@ -12,8 +12,10 @@*/ #include <linux/delay.h> +#include <linux/device.h> #include <linux/err.h> #include <linux/gpio/driver.h> +#include <linux/interrupt.h> #include <linux/io.h> #include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h>
@@ -509,6 +511,27 @@ int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n) }EXPORT_SYMBOL_GPL (mtk_eint_find_irq); +static void mtk_eint_teardown (void *data) +{ +struct mtk_eint *eint = data; +unsigned int i, virq; + +/* Detach the demux handler so it can no longer reference freed data. */ +irq_set_chained_handler_and_data (eint->irq,NULL ,NULL ); + +/* Wait for any in-flight handler to finish before tearing down. */ +synchronize_irq (eint->irq); + +/* Dispose of all child mappings before the domain is removed. */ +for (i =0 ; i < eint->hw->ap_num; i++) { + virq =irq_find_mapping (eint->domain, i); +if (virq) +irq_dispose_mapping (virq); + } + +irq_domain_remove (eint->domain); +} +int mtk_eint_do_init (struct mtk_eint *eint,struct mtk_eint_pin *eint_pin) {unsigned int size, i, port, virq, inst =0 ;
@@ -601,7 +624,7 @@ int mtk_eint_do_init(struct mtk_eint *eint, struct mtk_eint_pin *eint_pin)irq_set_chained_handler_and_data (eint->irq, mtk_eint_irq_handler, eint); -return 0 ; +return devm_add_action_or_reset (eint->dev, mtk_eint_teardown, eint); err_eint:for (i =0 ; i < eint->nbase; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 663/1815 tools/build: Allow versioning of all LLVM tools defined in Makefile.include
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit d5a1d1270c898057afc5b51fb6d0f2defa89d56d ]
The version of LLVM tools can be given on the build command with LLVM=-15, but this isn't applied to all tools. For example $(CC) gets versioned, but $(CLANG) doesn't. This causes a Perf build with LTO=1 to fail with an error about mixed clang versions:
ld.lld: error: libperf/core.o: Unknown attribute kind (86)
(Producer: 'LLVM18.1.8' Reader: 'LLVM 15.0.7')
This file has two "ifneq ($(LLVM),)" blocks adjacent to each other, so merge these blocks making it obvious that all tools should be versioned consistently and there is nothing special about each block.
This also reveals that ?= and "allow-override" are used inconsistently between the blocks. "allow-override" is technically only required for builtin variables, but isn't only used on them, and doesn't do any harm if used on a non-builtin. Make them all "allow-override" for consistency. The only functional difference this will cause is if there is a file level definition of one of the variables followed by an "#include of Makefile.include" which will now overwrite. But this isn't done and in a later commit some of the duplicate definitions will be removed for good measure.
There are also some other LLVM tools that are not defined here and will be moved in a later commit.
--- tools/scripts/Makefile.include | 37 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-)
tools/scripts/Makefile.include +20 -17
@@ -61,10 +61,18 @@ $(error Invalid value for LLVM, see Documentation/kbuild/llvm.rst) endif $(call allow-override,CC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX)) +$(call allow-override,CLANG,$(LLVM_PREFIX)clang$(LLVM_SUFFIX)) +$(call allow-override,HOSTCC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX)) $(call allow-override,AR,$(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)) +$(call allow-override,HOSTAR,$(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)) $(call allow-override,LD,$(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)) +$(call allow-override,HOSTLD,$(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)) $(call allow-override,CXX,$(LLVM_PREFIX)clang++$(LLVM_SUFFIX)) $(call allow-override,STRIP,$(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)) +$(call allow-override,LLVM_STRIP,$(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)) +$(call allow-override,LLC,$(LLVM_PREFIX)llc$(LLVM_SUFFIX)) +$(call allow-override,LLVM_CONFIG,$(LLVM_PREFIX)llvm-config$(LLVM_SUFFIX)) +$(call allow-override,LLVM_OBJCOPY,$(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)) else # Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix. $(call allow-override,CC,$(CROSS_COMPILE)gcc)
@@ -72,26 +80,21 @@ $(call allow-override,AR,$(CROSS_COMPILE)ar) $(call allow-override,LD,$(CROSS_COMPILE)ld) $(call allow-override,CXX,$(CROSS_COMPILE)g++) $(call allow-override,STRIP,$(CROSS_COMPILE)strip) -endif - -CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) -ifneq ($(LLVM),) -HOSTAR ?= $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX) -HOSTCC ?= $(LLVM_PREFIX)clang$(LLVM_SUFFIX) -HOSTLD ?= $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX) -else -HOSTAR ?= ar -HOSTCC ?= gcc -HOSTLD ?= ld +# Host versions aren't prefixed +$(call allow-override,HOSTAR,ar) +$(call allow-override,HOSTCC,gcc) +$(call allow-override,HOSTLD,ld) + +# Some tools still require Clang, LLC and/or LLVM utils +$(call allow-override,CLANG,clang) +$(call allow-override,LLC,llc) +$(call allow-override,LLVM_CONFIG,llvm-config) +$(call allow-override,LLVM_OBJCOPY,llvm-objcopy) +$(call allow-override,LLVM_STRIP,llvm-strip) endif -# Some tools require Clang, LLC and/or LLVM utils -CLANG ?= clang -LLC ?= llc -LLVM_CONFIG ?= llvm-config -LLVM_OBJCOPY ?= llvm-objcopy -LLVM_STRIP ?= llvm-strip +CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) # Some tools require bpftool SYSTEM_BPFTOOL ?= bpftool
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 664/1815 riscv: dts: spacemit: Fix phy id check for the phy on pico-itx board
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit 6d6536c880febe2340d8d388f42660eccff5aa81 ]
Current phy framework can not re-initialize the phy correctly, as it will assert the phy reset GPIO so the phy id can not be read. Setting the phy id of board pico-itx manually so the phy id detection can be skipped.
--- arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +1 -1
@@ -191,7 +191,7 @@ ð0 { mdio { phy0: phy@1 { - compatible = "ethernet-phy-ieee802.3-c22"; + compatible = "ethernet-phy-id001c.c916"; reg = <1>; reset-gpios = <&gpio 0 15 GPIO_ACTIVE_LOW>; reset-assert-us = <10000>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 665/1815 riscv: dts: spacemit: Fix phy id check for the phy on com260 board
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit 9db839d52ccd9af67d460cb9ac893276a74b88e5 ]
Current phy framework can not re-initialize the phy correctly, as it will assert the phy reset GPIO so the phy id can not be read. Setting the phy id of board com260 manually so the phy id dectection can be skipped.
--- arch/riscv/boot/dts/spacemit/k3-com260.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/spacemit/k3-com260.dtsi +1 -1
@@ -174,7 +174,7 @@ ð1 { mdio { phy1: phy@1 { - compatible = "ethernet-phy-ieee802.3-c22"; + compatible = "ethernet-phy-id001c.c916"; reg = <1>; reset-gpios = <&gpio 1 5 GPIO_ACTIVE_LOW>; reset-assert-us = <10000>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 666/1815 arm64: RSI: fix field-spanning write warning in attestation token init
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit 221049874b6a78c7d87bc826581b0695cd338e2b ]
The challenge is passed in registers a1 through a8. However, copying to ®s.a1 makes FORTIFY treat the destination as the single a1 field, resulting in a field-spanning write warning. [1]
Overlay the SMCCC register structure with an RSI-specific argument layout and copy the challenge into an explicit 64-byte array. This keeps the existing a1-a8 argument encoding while giving the copy a correctly sized destination object.
[1]
memcpy: detected field-spanning write (size 64) of single field "®s.a1" at ./arch/arm64/include/asm/rsi_cmds.h:119 (size 8)
WARNING: ./arch/arm64/include/asm/rsi_cmds.h:119 at rsi_attestation_token_init+0xdc/0xf8 [arm_cca_guest], CPU#0: cat/3314
--- arch/arm64/include/asm/rsi_cmds.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
arch/arm64/include/asm/rsi_cmds.h +19 -8
@@ -88,6 +88,14 @@ static inline long rsi_set_addr_range_state(phys_addr_t start,return res.a0; } +#define RSI_ATTEST_CHALLENGE_MIN_SIZE 32 +#define RSI_ATTEST_CHALLENGE_MAX_SIZE 64 + +struct rsi_attestation_token_init_args { +unsigned long fid; +u8 challenge[RSI_ATTEST_CHALLENGE_MAX_SIZE ]; +}; +/** * rsi_attestation_token_init - Initialise the operation to retrieve an * attestation token.
@@ -109,18 +117,21 @@ static inline long rsi_set_addr_range_state(phys_addr_t start,static inline long rsi_attestation_token_init (const u8 *challenge,unsigned long size) { -struct arm_smccc_1_2_regs regs = {0 }; +union { +struct arm_smccc_1_2_regs regs; +struct rsi_attestation_token_init_args init; + } args = {0 }; -/* The challenge must be at least 32bytes and at most 64bytes */ -if (!challenge || size <32 || size >64 ) +if (!challenge || size <RSI_ATTEST_CHALLENGE_MIN_SIZE || + size >RSI_ATTEST_CHALLENGE_MAX_SIZE )return -EINVAL ; - regs.a0 =SMC_RSI_ATTESTATION_TOKEN_INIT ; -memcpy (®s.a1, challenge, size); -arm_smccc_1_2_smc (®s, ®s); + args.init.fid =SMC_RSI_ATTESTATION_TOKEN_INIT ; +memcpy (args.init.challenge, challenge, size); +arm_smccc_1_2_smc (&args.regs, &args.regs); -if (regs.a0 ==RSI_SUCCESS ) -return regs.a1; +if (args.regs.a0 ==RSI_SUCCESS ) +return args.regs.a1;return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 667/1815 power: supply: sbs-battery: Use a per-device serial number buffer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit 6027892925b8d19d2245c2d077e2ae35b49cc2b1 ]
sbs_get_battery_serial_number() formats the battery serial number into sbs_serial[], a single file-scope buffer shared by every sbs-battery instance, and points val->strval at it.
Nothing restricts this driver to one instance. It binds per I2C client, and sbs-manager registers one muxed I2C channel per supported battery specifically so that the smart battery driver can be bound to each of them, so several sbs-battery instances on one system is a supported configuration.
The power supply core reads strval after the driver's get_property() callback has returned: power_supply_show_property() fills a local union power_supply_propval, then formats it with sysfs_emit(). Two concurrent POWER_SUPPLY_PROP_SERIAL_NUMBER reads on different batteries therefore race for the shared buffer - battery B's sprintf() can land between battery A filling the buffer and the core reading it, and battery A then reports battery B's serial number.
Move the buffer into struct sbs_info so that each battery formats into its own storage. It is deliberately not added to the chip->strings[]
array: those entries hold the cached constant strings that sbs_invalidate_cached_props() clears on presence changes, whereas the serial number is re-read from its word register on every access.
--- drivers/power/supply/sbs-battery.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/supply/sbs-battery.c +4 -3
@@ -217,6 +217,7 @@ struct sbs_info {u32 flags;int technology;char strings[NR_STRING_BUFFERS ][I2C_SMBUS_BLOCK_MAX +1 ]; +char serial[5 ]; }; static char *sbs_get_string_buf(struct sbs_info *chip,
@@ -821,18 +822,18 @@ static int sbs_get_battery_capacity(struct i2c_client *client,return 0 ; } -static char sbs_serial[5 ];static int sbs_get_battery_serial_number (struct i2c_client *client,union power_supply_propval *val) { +struct sbs_info *chip =i2c_get_clientdata (client);int ret; ret =sbs_read_word_data (client, sbs_data[REG_SERIAL_NUMBER ].addr);if (ret <0 )return ret; -sprintf (sbs_serial,"%04x" , ret); - val->strval = sbs_serial; +sprintf (chip->serial,"%04x" , ret); + val->strval = chip->serial;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 668/1815 scsi: ufs: core: Validate string descriptors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Qiang <[email protected]>
[ Upstream commit d96e83d028d7d8762e424e49c671d49ac2ecf14f ]
The string descriptor length includes a two-byte header while the UTF-16 payload starts after it. utf16s_to_utf8s() expects a count of UTF-16 code units, not bytes. Passing the payload byte count can make it read beyond the descriptor buffer.
Validate that the payload has an even byte count, pass a code-unit count to the converter, and allocate sufficient UTF-8 output space.
The raw string buffer starts after the descriptor header but its size is bLength. Copying bLength bytes from that pointer can read beyond the response buffer.
Allocate a zeroed bLength-sized buffer and copy only the UTF-16 payload. This preserves the raw buffer size consumed by the RPMB device-ID ABI while avoiding the overread.
--- drivers/ufs/core/ufshcd.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
drivers/ufs/core/ufshcd.c +19 -5
@@ -3865,7 +3865,7 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, enum u {struct uc_string_id *uc_str;u8 *str; -int ret; +int ret, uc_len;if (!buf)return -EINVAL ;
@@ -3890,11 +3890,19 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, enum u goto out; } + uc_len = uc_str->len -QUERY_DESC_HDR_SIZE ; +if (uc_len %sizeof (*uc_str->uc)) { +dev_err (hba->dev,"String Desc has an odd UTF-16 payload length\n" ); + str =NULL ; + ret = -EINVAL ; + goto out; + } +if (fmt ==SD_ASCII_STD ) {ssize_t ascii_len;int i; -/* remove header and divide by 2 to move from UTF16 to UTF8 */ - ascii_len = (uc_str->len -QUERY_DESC_HDR_SIZE ) /2 +1 ; +/* Allow up to three UTF-8 bytes per UTF-16 code unit plus a NUL. */ + ascii_len = uc_len /sizeof (*uc_str->uc) *3 +1 ; str =kzalloc (ascii_len,GFP_KERNEL );if (!str) { ret = -ENOMEM ;
@@ -3906,7 +3914,7 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, enum u* we need to convert to utf-8 so it can be displayed */ ret =utf16s_to_utf8s (uc_str->uc, - uc_str->len -QUERY_DESC_HDR_SIZE , + uc_len /sizeof (*uc_str->uc),UTF16_BIG_ENDIAN , str, ascii_len -1 );/* replace non-printable or non-ASCII characters with spaces */
@@ -3916,11 +3924,17 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, enum u str[ret++] ='\0' ; }else { - str =kmemdup (uc_str->uc, uc_str->len,GFP_KERNEL ); +/* +* Keep the bLength-sized raw output for the RPMB device ID ABI. +* The two bytes beyond the UTF-16 payload are explicitly zeroed +* instead of being read past the descriptor buffer. +*/ + str =kzalloc (uc_str->len,GFP_KERNEL );if (!str) { ret = -ENOMEM ; goto out; } +memcpy (str, uc_str->uc, uc_len); ret = uc_str->len; } out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 669/1815 scsi: ufs: Avoid NULL CQE dereference when reporting invalid tags
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Qiang <[email protected]>
[ Upstream commit 331bda797e6afc143127ce72b1469d73316f49b4 ]
The single-doorbell completion path can call ufshcd_compl_one_cqe() with a NULL CQE. If no command is associated with the completion tag, the warning message dereferences the CQE while reporting the error. Avoid that dereference and include the invalid tag in the warning.
--- drivers/ufs/core/ufshcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ufs/core/ufshcd.c +2 -2
@@ -5860,8 +5860,8 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,struct ufshcd_lrb *lrbp =scsi_cmd_priv (cmd);enum utp_ocs ocs; -if (WARN_ONCE (!cmd,"cqe->command_desc_base_addr = %#llx\n" , -le64_to_cpu (cqe->command_desc_base_addr))) +if (WARN_ONCE (!cmd,"invalid completion tag %d, cqe->command_desc_base_addr = %#llx\n" , + task_tag, cqe ?le64_to_cpu (cqe->command_desc_base_addr) :0ULL ))return ;if (hba->monitor.enabled) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 670/1815 scsi: ufs: core: Validate connected lane counts
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Qiang <[email protected]>
[ Upstream commit 9e6dd452f1affb5c412ca64bf5809ce9fde3174d ]
The connected lane count is used by TX equalization code to index arrays sized by UFS_MAX_LANES. Reject zero and out-of-range RX or TX lane counts before they can be propagated.
--- drivers/ufs/core/ufshcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +3 -1
@@ -4729,7 +4729,9 @@ static int ufshcd_get_max_pwr_mode(struct ufs_hba *hba)ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDTXDATALANES ), &pwr_info->lane_tx); -if (!pwr_info->lane_rx || !pwr_info->lane_tx) { +if (!pwr_info->lane_rx || !pwr_info->lane_tx || + pwr_info->lane_rx >UFS_MAX_LANES || + pwr_info->lane_tx >UFS_MAX_LANES ) { dev_err(hba->dev, "%s: invalid connected lanes value. rx=%d, tx=%d\n", __func__, pwr_info->lane_rx,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 671/1815 scsi: ufs: rpmb: Validate request frame length before parsing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Qiang <[email protected]>
[ Upstream commit a947b8edbdcec8415a80ca55e9f38801322ffdd3 ]
The RPMB core only verifies that request and response buffers are nonempty. This callback reads req_resp at the end of the first request frame before validating the request length. Require a complete frame before that access.
--- drivers/ufs/core/ufs-rpmb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/ufs/core/ufs-rpmb.c +4 -0
@@ -69,6 +69,10 @@ static int ufs_rpmb_route_frames(struct device *dev, u8 *req, unsigned int req_l hba = ufs_rpmb->hba; +/* req_resp is at the end of an RPMB frame. */ +if (req_len <sizeof (*frm_out)) +return -EINVAL ; + req_type =be16_to_cpu (frm_out->req_resp);switch (req_type) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 672/1815 scsi: ufs: debugfs: Reserve space for a string terminator
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Qiang <[email protected]>
[ Upstream commit abd26e6b53c4169122d61fdd4cabe09bdd916aac ]
ufs_saved_err_write() copies user input into a zero-initialized stack buffer and passes it to kstrtoint(). A write that fills the entire buffer overwrites its only terminator.
Reject an input whose length leaves no room for the trailing NUL.
--- drivers/ufs/core/ufs-debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufs-debugfs.c +1 -1
@@ -165,7 +165,7 @@ static ssize_t ufs_saved_err_write(struct file *file, const char __user *buf,char val_str[16 ] = { };int val, ret; -if (count >sizeof (val_str)) +if (count >=sizeof (val_str))return -EINVAL ;if (copy_from_user (val_str, buf, count))return -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 673/1815 crypto: keembay - Initialize completion before requesting IRQ
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit fce20289dd622cc7ab78d72c8a979a9f8b7cb10e ]
kmb_ocs_aes_probe() requests the device IRQ before initializing irq_completion. Once the handler is registered it can run immediately, and ocs_aes_irq_handler() unconditionally calls complete(). An interrupt in this window would therefore use an uninitialized completion.
Initialize the completion before requesting the IRQ, as the sibling OCS HCU and ECC drivers already do.
--- drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/intel/keembay/keembay-ocs-aes-core.c +2 -2
@@ -1602,6 +1602,8 @@ static int kmb_ocs_aes_probe(struct platform_device *pdev)if (IS_ERR (aes_dev->base_reg))return PTR_ERR (aes_dev->base_reg); +init_completion (&aes_dev->irq_completion); +/* Get and request IRQ */ aes_dev->irq =platform_get_irq (pdev,0 );if (aes_dev->irq <0 )
@@ -1619,8 +1621,6 @@ static int kmb_ocs_aes_probe(struct platform_device *pdev)list_add_tail (&aes_dev->list, &ocs_aes.dev_list);spin_unlock (&ocs_aes.lock); -init_completion (&aes_dev->irq_completion); -/* Initialize crypto engine */ aes_dev->engine =crypto_engine_alloc_init (dev, true);if (!aes_dev->engine) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 674/1815 crypto: keembay - publish OF module alias for OCS AES/SM4
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Peng <[email protected]>
[ Upstream commit 0a94091e29f914e4f233a208599ca4055882c01b ]
The Keem Bay OCS AES/SM4 driver has an OF match table wired to .of_match_table, but does not export the table with MODULE_DEVICE_TABLE().
Although the match table lives in keembay-ocs-aes-core.o, that object is part of the composite keembay-ocs-aes module. Add the missing MODULE_DEVICE_TABLE(of, ...) entry so modpost can generate OF module alias information for OF based module autoloading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the platform driver, and the missing module alias publication.
--- drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/intel/keembay/keembay-ocs-aes-core.c +1 -0
@@ -1561,6 +1561,7 @@ static const struct of_device_id kmb_ocs_aes_of_match[] = { }, {} }; +MODULE_DEVICE_TABLE (of, kmb_ocs_aes_of_match);static void kmb_ocs_aes_remove (struct platform_device *pdev) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 675/1815 RDMA/mlx5: Fix integer overflow of user QP buffer size
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Sanalla <[email protected]>
[ Upstream commit dec47e4b0fe34afdf38caa72b4408ba95502e5de ]
set_user_buf_size() computes the QP buffer size by left-shifting the user-supplied rq.wqe_cnt and rq.wqe_shift values as signed integers. A sufficiently large rq.wqe_cnt causes signed integer overflow, which is undefined behavior, and yields a small or negative buf_size, causing ib_umem_get() to map a buffer smaller than the hardware will actually write into.
Replace the shifts and addition with check_shl_overflow() and check_add_overflow(), rejecting invalid user inputs.
Moreover, guard the identical shift computing qp->sq.offset in _create_user_qp() before set_user_buf_size() is reached.
--- drivers/infiniband/hw/mlx5/qp.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +20 -5
@@ -647,6 +647,7 @@ static int set_user_buf_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr) {int desc_sz =1 << qp->sq.wqe_shift; +int rq_buf_size, sq_buf_size;if (desc_sz >MLX5_CAP_GEN (dev->mdev, max_wqe_sz_sq)) { mlx5_ib_warn(dev, "desc_sz %d, max_sq_desc_sz %d\n",
@@ -671,11 +672,21 @@ static int set_user_buf_size(struct mlx5_ib_dev *dev,if (attr->qp_type ==IB_QPT_RAW_PACKET || qp->flags &IB_QP_CREATE_SOURCE_QPN ) { - base->ubuffer.buf_size = qp->rq.wqe_cnt << qp->rq.wqe_shift; - qp->raw_packet_qp.sq.ubuffer.buf_size = qp->sq.wqe_cnt <<6 ; +if (check_shl_overflow (qp->rq.wqe_cnt, qp->rq.wqe_shift, + &base->ubuffer.buf_size)) +return -EINVAL ; +if (check_shl_overflow (qp->sq.wqe_cnt,6 , + &qp->raw_packet_qp.sq.ubuffer.buf_size)) +return -EINVAL ; }else { - base->ubuffer.buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) + - (qp->sq.wqe_cnt <<6 ); +if (check_shl_overflow (qp->rq.wqe_cnt, qp->rq.wqe_shift, + &rq_buf_size)) +return -EINVAL ; +if (check_shl_overflow (qp->sq.wqe_cnt,6 , &sq_buf_size)) +return -EINVAL ; +if (check_add_overflow (rq_buf_size, sq_buf_size, + &base->ubuffer.buf_size)) +return -EINVAL ; }return 0 ;
@@ -1004,7 +1015,11 @@ static int _create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, qp->rq.offset =0 ; qp->sq.wqe_shift =ilog2 (MLX5_SEND_WQE_BB ); - qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift; +if (check_shl_overflow (qp->rq.wqe_cnt, qp->rq.wqe_shift, + &qp->sq.offset)) { + err = -EINVAL ; + goto err_bfreg; + } err =set_user_buf_size (dev, qp, ucmd, base, attr);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 676/1815 ACPI: bus: Avoid confusing complaints regarding missing _OSC features
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 9bfb23e0661be3d6a72aedde08a9f0fec2e8041a ]
The platform firmware on some platforms sets OSC_CAPABILITIES_MASK_ERROR in _OSC error bits even though it actually acknowledges all of the requested features which after commit e5322888e6bf ("ACPI: bus: Rework the handling of \_SB._OSC platform features") causes the kernel to complain unnecessarily.
Avoid the confusing complaints by explicitly checking for that case in acpi_osc_handshake().
--- drivers/acpi/bus.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/acpi/bus.c +11 -3
@@ -335,7 +335,7 @@ static int acpi_osc_handshake(acpi_handle handle, const char *uuid_str, .length = bufsize * sizeof(u32), };struct acpi_buffer output; -u32 *retbuf, test; +u32 *retbuf, test, errors;guid_t guid;int ret, i;
@@ -395,10 +395,18 @@ static int acpi_osc_handshake(acpi_handle handle, const char *uuid_str,* Clear the feature bits in capbuf[] that have not been acknowledged. * After that, capbuf[] contains the resultant feature mask. */ -for (i =OSC_QUERY_DWORD +1 ; i < bufsize; i++) +for (i =OSC_QUERY_DWORD +1 , test =0 ; i < bufsize; i++) { + test |= capbuf[i] & ~retbuf[i]; capbuf[i] &= retbuf[i]; + } -if (retbuf[OSC_QUERY_DWORD ] &OSC_ERROR_MASK ) { + errors = retbuf[OSC_QUERY_DWORD ] &OSC_ERROR_MASK ; +/* +* Some platforms set OSC_CAPABILITIES_MASK_ERROR even though they +* acknowledge all of the requested features, so avoid complaining in +* those cases unless any other error bits are also set. +*/ +if (errors && (test || errors !=OSC_CAPABILITIES_MASK_ERROR )) {/* * Complain about the unexpected errors and print diagnostic * information related to them.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 677/1815 thermal/drivers/airoha: Fix copy paste error on clamp_t low temp
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit 251621813fb4275e24431f9a0690aec9b15823e7 ]
In airoha_thermal_set_trips, there is a copy paste error on clamping the value for the low trip temp point. Fix it to the correct value and actually clamp for the low variable.
--- drivers/thermal/airoha_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/airoha_thermal.c +1 -1
@@ -273,7 +273,7 @@ static int airoha_thermal_set_trips(struct thermal_zone_device *tz, int low,if (low != -INT_MAX ) {/* Validate low and clamp it to a supported value */ - low =clamp_t (int, high,RAW_TO_TEMP (priv,0 ), + low =clamp_t (int, low,RAW_TO_TEMP (priv,0 ),RAW_TO_TEMP (priv,FIELD_MAX (EN7581_DOUT_TADC_MASK )));/* We offset the low temp of 1°C to trigger correct event */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 678/1815 thermal/drivers/airoha: Fix copy paste error for sen internal
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit 6791265d609549be55bb35b747c9648d0b570c12 ]
In airoha_thermal_setup_monitor there is a copy paste error on configuring the internval for temp monitor. Fix the error and use the correct mask for the sen interval for the EN7581_TEMPMONCTL2 register.
--- drivers/thermal/airoha_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/airoha_thermal.c +1 -1
@@ -403,7 +403,7 @@ static void airoha_thermal_setup_monitor(struct airoha_thermal_priv *priv)* sen interval is 379 * 52.715us = 19.97ms */ writel (FIELD_PREP (EN7581_FILT_INTERVAL ,1 ) | -FIELD_PREP (EN7581_FILT_INTERVAL ,379 ), +FIELD_PREP (EN7581_SEN_INTERVAL ,379 ), priv->base +EN7581_TEMPMONCTL2 );/* AHB poll is set to 146 * 68.64 = 10.02us */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 679/1815 thermal/drivers/qcom-spmi-adc-tm5: Drop IIO_VAL_INT check in adc_tm5_get_temp
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rakesh Kota <[email protected]>
[ Upstream commit 0c569e22020f53ddfac0099b0aa193907bfbcd6f ]
Commit bb21ee31f575 ("iio: Fix iio_multiply_value use in iio_read_channel_processed_scale") fixed the iio_read_channel_processed_scale to return 0 on success instead of IIO_VAL_INT (1). The existing check in adc_tm5_get_temp() treated a successful return as an error because it expected IIO_VAL_INT. Drop the redundant ret != IIO_VAL_INT condition and rely solely on the negative error check.
--- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 3 --- 1 file changed, 3 deletions(-)
drivers/thermal/qcom/qcom-spmi-adc-tm5.c +0 -3
@@ -369,9 +369,6 @@ static int adc_tm5_get_temp(struct thermal_zone_device *tz, int *temp)if (ret <0 )return ret; -if (ret !=IIO_VAL_INT ) -return -EINVAL ; -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 680/1815 powercap: intel_rapl_tpmi: Handle PMU registration failure during probe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumeet Pawnikar <[email protected]>
[ Upstream commit 9229916d59918ec9d3639e7263e1e97be638e361 ]
intel_rapl_tpmi_probe() invokes rapl_package_add_pmu() but ignores its return value, so a PMU registration failure would leave the driver reporting probe success despite the PMU being absent, with no log trace.
Since PMU registration is an optional auxiliary feature for perf energy counters, its failure should not break the primary powercap functionality. Check the return value and log a warning to ensure graceful degradation.
--- drivers/powercap/intel_rapl_tpmi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/powercap/intel_rapl_tpmi.c +4 -1
@@ -414,7 +414,10 @@ static int intel_rapl_tpmi_probe(struct auxiliary_device *auxdev, goto err; } -rapl_package_add_pmu (trp->rp); + ret =rapl_package_add_pmu (trp->rp); +if (ret) +dev_info (&auxdev->dev,"Failed to add RAPL PMU for Package%d, %d\n" , + info->package_id, ret);auxiliary_set_drvdata (auxdev, trp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 681/1815 isofs: release zisofs block pointer buffer head
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 2f7dd9b86fe4076059e6a4a2a2c5d565afd76b9e ]
zisofs_fill_pages() reads the compressed block pointer table. The error paths release the current buffer_head, the loop also releases the old buffer_head when it advances. However, the success path leaves the last buffer_head referenced. Release it before returning success.
--- fs/isofs/compress.c | 1 + 1 file changed, 1 insertion(+)
fs/isofs/compress.c +1 -0
@@ -293,6 +293,7 @@ static int zisofs_fill_pages(struct inode *inode, int full_page, int pcount,memzero_page (*pages, poffset,PAGE_SIZE - poffset);SetPageUptodate (*pages); } +brelse (bh);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 682/1815 PCI/pwrctrl: tc9563: Fix parsing the integrated Ethernet MAC Endpoint node
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 6e5e6c2194b2acbded5b12ed80590d215b786d29 ]
DSP3 has an integrated Ethernet MAC Endpoint which has its own set of config registers for configuring settings such as ASPM. The Endpoint device has two physical functions and those two functions share the same settings.
Parse the Endpoint node under DSP3 instead of parsing both functions. The existing parsing logic also has one OOB issue as parsing both functions will result in accessing past the tc9563_pwrctrl->cfg array.
--- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +10 -4
@@ -595,12 +595,18 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) ret =tc9563_pwrctrl_parse_device_dt (tc9563, child, port);if (ret)break ; -/* Embedded ethernet device are under DSP3 */ + +/* +* The integrated Ethernet MAC Endpoint under DSP3 is a single +* device whose functions share the same config registers. +*/ if (port ==TC9563_DSP3 ) { -for_each_child_of_node_scoped (child, child1) { - port++; + struct device_node *eth __free(device_node) = +of_get_next_available_child (child,NULL ); + +if (eth) { ret =tc9563_pwrctrl_parse_device_dt (tc9563, - child1, port); + eth,TC9563_ETHERNET );if (ret)break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 683/1815 PCI/pwrctrl: tc9563: Power off only the external ports in tc9563_pwrctrl_disable_port()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit e41bbfc4c109f2db741eef5cd0ac55600930c449 ]
TC9563 supports powering off only the external facing ports like DSP1 and DSP2. It is not recommended to power off USP and DSP3 as they have fixed ports/endpoint connected.
Fix tc9563_pwrctrl_disable_port() to power off only DSP1 and DSP2.
--- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +8 -2
@@ -240,12 +240,18 @@ static int tc9563_pwrctrl_disable_port(struct tc9563_pwrctrl *tc9563,if (!cfg->disable_port)return 0 ; -if (port ==TC9563_DSP1 ) { +switch (port) { +case TC9563_DSP1 : seq = dsp1_pwroff_seq; len =ARRAY_SIZE (dsp1_pwroff_seq); - }else { +break ; +case TC9563_DSP2 : seq = dsp2_pwroff_seq; len =ARRAY_SIZE (dsp2_pwroff_seq); +break ; +default : +/* Only external downstream ports DSP1/DSP2 can be powered off */ +return 0 ; } ret =tc9563_pwrctrl_i2c_bulk_write (tc9563->client, seq, len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 684/1815 clk: mediatek: mt6735: Unregister PLLs on probe failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 935ad6242c47b37380d0cb7ec366516fe11855b4 ]
mtk_clk_register_plls() registers the apmixedsys PLL clocks manually, while clk_mt6735_apmixed_remove() unregisters them on driver removal.
If devm_of_clk_add_hw_provider() fails after the PLL registration succeeds, probe returns the error directly and the remove callback is not run. This leaves the registered PLL clocks behind on the probe failure path.
Unregister the PLLs in that failure branch before returning the error.
--- drivers/clk/mediatek/clk-mt6735-apmixedsys.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-mt6735-apmixedsys.c +4 -1
@@ -102,9 +102,12 @@ static int clk_mt6735_apmixed_probe(struct platform_device *pdev) ret =devm_of_clk_add_hw_provider (&pdev->dev, of_clk_hw_onecell_get, clk_data); -if (ret) +if (ret) {dev_err (&pdev->dev,"Failed to register clock provider: %d\n" , ret); +mtk_clk_unregister_plls (apmixedsys_plls,ARRAY_SIZE (apmixedsys_plls), + clk_data); + }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 685/1815 spi: oc-tiny: switch to managed controller allocation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit d710f43ce30975d197f73c543bfe47b958d8ba17 ]
The controller is allocated with the non-managed spi_alloc_host() while the interrupt is registered with devm_request_irq(). During removal, spi_bitbang_stop() only unregisters the controller; the subsequent spi_controller_put() then frees the controller together with its embedded driver-private devdata, which is the IRQ handler's dev_id. The devm_request_irq() release action (free_irq()), which drains the handler, does not run until after .remove() returns. A late or latched interrupt can therefore reach tiny_spi_irq() and dereference already-freed memory (e.g. hw->base).
Switch to devm_spi_alloc_host() so that the devres LIFO order releases the controller only after free_irq() has drained the handler, and drop the now-redundant spi_controller_put() from .remove(). The probe error path is simplified to direct returns.
This issue was found by an in-house static analysis tool.
--- drivers/spi/spi-oc-tiny.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
drivers/spi/spi-oc-tiny.c +8 -16
@@ -210,11 +210,11 @@ static int tiny_spi_probe(struct platform_device *pdev)struct tiny_spi_platform_data *platp =dev_get_platdata (&pdev->dev);struct tiny_spi *hw;struct spi_controller *host; -int err = -ENODEV ; +int err; - host =spi_alloc_host (&pdev->dev,sizeof (struct tiny_spi )); + host =devm_spi_alloc_host (&pdev->dev,sizeof (struct tiny_spi ));if (!host) -return err; +return -ENOMEM ;/* setup the host state. */ host->bus_num = pdev->id;
@@ -232,10 +232,8 @@ static int tiny_spi_probe(struct platform_device *pdev)/* find and map our resources */ hw->base =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (hw->base)) { - err =PTR_ERR (hw->base); - goto exit; - } +if (IS_ERR (hw->base)) +return PTR_ERR (hw->base);/* irq is optional */ hw->irq =platform_get_irq (pdev,0 );if (hw->irq >=0 ) {
@@ -243,7 +241,7 @@ static int tiny_spi_probe(struct platform_device *pdev) err =devm_request_irq (&pdev->dev, hw->irq, tiny_spi_irq,0 , pdev->name, hw);if (err) - goto exit; +return err; }/* find platform data */ if (platp) {
@@ -252,29 +250,23 @@ static int tiny_spi_probe(struct platform_device *pdev) }else { err =tiny_spi_of_probe (pdev);if (err) - goto exit; +return err; }/* register our spi controller */ err =spi_bitbang_start (&hw->bitbang);if (err) - goto exit; +return err;dev_info (&pdev->dev,"base %p, irq %d\n" , hw->base, hw->irq);return 0 ; - -exit: -spi_controller_put (host); -return err; }static void tiny_spi_remove (struct platform_device *pdev) {struct tiny_spi *hw =platform_get_drvdata (pdev); -struct spi_controller *host = hw->bitbang.ctlr;spi_bitbang_stop (&hw->bitbang); -spi_controller_put (host); }#ifdef CONFIG_OF
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 686/1815 w1: ds2482: Fix signedness bug in ds2482_w1_triplet()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit 4d3721b204f961e905714954ff95633337b768e3 ]
ds2482_wait_1wire_idle() returns the status register value (0..255) on success, or a negative value on I2C failure: -1 when selecting the status register fails, or a negative errno from i2c_smbus_read_byte().
ds2482_w1_triplet() feeds that result into "return (status >> 5);" without checking for errors, and the function returns u8. For a negative status the arithmetic shift keeps the sign and the u8 truncation fabricates a triplet result whose meaning depends on the errno value: -1 and -EIO happen to become 0xff, whose set low bits make w1_search() abort, but -ETIMEDOUT (-110 >> 5 = -4) becomes 0xfc - "devices responded on both branches, wrote 1" - and -EOPNOTSUPP (-95 >> 5 = -3) becomes 0xfd - "only the zero branch responded". w1_search() then continues the ROM search with a fabricated direction bit instead of aborting, and the corrupted id is either rejected by the ROM CRC (existing device missed) or registers a phantom slave.
The function already defines an in-band error value: status is initialized to (3 << 5), which decodes to 3 (both branch bits set, "no device responded") and makes w1_search() terminate the search when sending the triplet command fails. Decode a negative status to the same value.
Found by smatch:drivers/w1/masters/ds2482.c:314 ds2482_w1_triplet() warn: signedness bug returning '(-67108864)'
--- drivers/w1/masters/ds2482.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/w1/masters/ds2482.c +4 -0
@@ -310,6 +310,10 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit)mutex_unlock (&pdev->access_lock); +/* On bus error, decode to 3 (no device responded) to abort the search */ +if (status <0 ) + status =3 <<5 ; +/* Decode the status */ return (status >>5 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 687/1815 sched_ext: Fix exit_cpu accuracy for lockup paths
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng-Yang Chou <[email protected]>
[ Upstream commit da428d572e07bb9dd2d076297ef5700f6483aafd ]
handle_lockup() uses raw_smp_processor_id() for exit_cpu, which is wrong for two paths:
- scx_hardlockup_irq_workfn() has the hung CPU in a local variable but irq_work may run elsewhere. Pass the local cpu explicitly.
- scx_rcu_cpu_stall() records the detector CPU rather than the stalled one. Pass -1 for now. The next patch fixes this properly.
Stable-dep-of: 3c4b38064937 ("sched_ext: Abort directly from the hardlockup handler")
--- kernel/sched/ext/ext.c | 15 +++++++++------ kernel/sched/ext/internal.h | 2 -- 2 files changed, 9 insertions(+), 8 deletions(-)
kernel/sched/ext/ext.c +9 -6
@@ -5291,6 +5291,7 @@ bool scx_allow_ttwu_queue(const struct task_struct *p)/** * handle_lockup - sched_ext common lockup handler +* @exit_cpu: CPU to record in exit_info. Pass the stalled/hung CPU, not current. * @fmt: format string * * Called on system stall or lockup condition and initiates abort of sched_ext
@@ -5300,7 +5301,7 @@ bool scx_allow_ttwu_queue(const struct task_struct *p)* resolve the lockup. %false if sched_ext is not enabled or abort was already * initiated by someone else. */ -static __printf(1, 2) bool handle_lockup(const char *fmt, ...) +static __printf(2, 3) bool handle_lockup(int exit_cpu, const char *fmt, ...) { struct scx_sched *sch;va_list args;
@@ -5316,7 +5317,7 @@ static __printf(1, 2) bool handle_lockup(const char *fmt, ...)case SCX_ENABLING :case SCX_ENABLED :va_start (args, fmt); - ret =scx_verror (sch, fmt, args); + ret =scx_vexit (sch,SCX_EXIT_ERROR ,0 , exit_cpu, fmt, args);va_end (args);return ret;default :
@@ -5338,7 +5339,7 @@ static __printf(1, 2) bool handle_lockup(const char *fmt, ...)*/ bool scx_rcu_cpu_stall (void ) { -return handle_lockup ("RCU CPU stall detected!" ); +return handle_lockup (-1 ,"RCU CPU stall detected!" ); }/**
@@ -5353,11 +5354,13 @@ bool scx_rcu_cpu_stall(void)*/ void scx_softlockup (u32 dur_s) { -if (!handle_lockup ("soft lockup - CPU %d stuck for %us" ,smp_processor_id (), dur_s)) +int cpu =smp_processor_id (); + +if (!handle_lockup (cpu,"soft lockup - CPU %d stuck for %us" , cpu, dur_s))return ;printk_deferred (KERN_ERR "sched_ext: Soft lockup - CPU %d stuck for %us, disabling BPF scheduler\n" , -smp_processor_id (), dur_s); + cpu, dur_s); }/*
@@ -5372,7 +5375,7 @@ static void scx_hardlockup_irq_workfn(struct irq_work *work) {int cpu =atomic_xchg (&scx_hardlockup_cpu,-1 ); -if (cpu >=0 &&handle_lockup ("hard lockup - CPU %d" , cpu)) +if (cpu >=0 &&handle_lockup (cpu,"hard lockup - CPU %d" , cpu))printk_deferred (KERN_ERR "sched_ext: Hard lockup - CPU %d, disabling BPF scheduler\n" , cpu); }
kernel/sched/ext/internal.h +0 -2
@@ -1544,8 +1544,6 @@ __printf(5, 6) bool __scx_exit(struct scx_sched *sch, enum scx_exit_kind kind, __scx_exit(sch, kind, exit_code, raw_smp_processor_id(), fmt, ##args) #define scx_error(sch, fmt, args...) \ scx_exit((sch), SCX_EXIT_ERROR, 0, fmt, ##args) -#define scx_verror(sch, fmt, args) \ - scx_vexit((sch), SCX_EXIT_ERROR, 0, raw_smp_processor_id(), fmt, args)/* * Return the rq currently locked from an scx callback, or NULL if no rq is
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 688/1815 sched_ext: Abort directly from the hardlockup handler
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
[ Upstream commit 3c4b38064937a761ebbf85b1649e812db85eb59e ]
scx_hardlockup() defers the abort to an irq_work because exit claiming used to take scx_sched_lock and couldn't run from NMI. The deferral is now unnecessary - claiming is NMI-safe and asserting ->aborting is exactly what breaks the live-locks that hard-lock CPUs. Call handle_lockup() directly and drop the irq_work. This also makes the self-detected case recoverable: the perf watchdog fires on the hard-locked CPU itself, where a queued irq_work never runs with IRQs off.
Also fix the return value: %true used to be returned whenever sched_ext was loaded, suppressing the kernel's hardlockup report even when the abort was refused. Return %true only when this call initiated the abort.
--- kernel/sched/ext/ext.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-)
kernel/sched/ext/ext.c +9 -26
@@ -5363,25 +5363,6 @@ void scx_softlockup(u32 dur_s) cpu, dur_s); } -/* -* scx_hardlockup() runs from NMI and eventually calls scx_claim_exit(), -* which takes scx_sched_lock. scx_sched_lock isn't NMI-safe and grabbing -* it from NMI context can lead to deadlocks. Defer via irq_work; the -* disable path runs off irq_work anyway. -*/ -static atomic_t scx_hardlockup_cpu =ATOMIC_INIT (-1 ); - -static void scx_hardlockup_irq_workfn (struct irq_work *work) -{ -int cpu =atomic_xchg (&scx_hardlockup_cpu,-1 ); - -if (cpu >=0 &&handle_lockup (cpu,"hard lockup - CPU %d" , cpu)) -printk_deferred (KERN_ERR "sched_ext: Hard lockup - CPU %d, disabling BPF scheduler\n" , - cpu); -} - -static DEFINE_IRQ_WORK(scx_hardlockup_irq_work, scx_hardlockup_irq_workfn); -/** * scx_hardlockup - sched_ext hardlockup handler *
@@ -5390,19 +5371,21 @@ static DEFINE_IRQ_WORK(scx_hardlockup_irq_work, scx_hardlockup_irq_workfn);* Try kicking out the current scheduler in an attempt to recover the system to * a good state before taking more drastic actions. * -* Queues an irq_work; the handle_lockup() call happens in IRQ context (see -* scx_hardlockup_irq_workfn). +* Called from NMI. Aborting the scheduler sets ->aborting throughout the +* hierarchy before returning, which is what breaks the dispatch-path live-locks +* that can hard-lock CPUs. * -* Returns %true if sched_ext is enabled and the work was queued, %false -* otherwise. +* Returns %true if sched_ext is enabled and abort was initiated, which may +* resolve the lockup. %false if sched_ext is not enabled or abort was already +* initiated by someone else. */ bool scx_hardlockup (int cpu) { -if (!rcu_access_pointer (scx_root)) +if (!handle_lockup (cpu,"hard lockup - CPU %d" , cpu))return false; -atomic_cmpxchg (&scx_hardlockup_cpu,-1 , cpu); -irq_work_queue (&scx_hardlockup_irq_work); +printk_deferred (KERN_ERR "sched_ext: Hard lockup - CPU %d, disabling BPF scheduler\n" , + cpu);return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 689/1815 gpu: nova-core: build SetRegistry entries dynamically
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhi Wang <[email protected]>
[ Upstream commit d85845b64c0020b2812243a22fa79d57cc1c1e38 ]
The GSP SetRegistry command currently stores its registry entries in a fixed-size array. That makes every additional runtime-dependent registry object require reshaping the command data structure at the same time as the feature that needs the new entry.
Keep the existing registry contents unchanged, but store them in a KVec so SetRegistry can be constructed dynamically. The constructor now returns a Result to propagate allocation failures while the command payload layout is still computed from the final entry list.
Stable-dep-of: 93b9511a3bba ("gpu: nova-core: fix packed registry table size")
--- drivers/gpu/nova-core/gsp/boot.rs | 2 +- drivers/gpu/nova-core/gsp/commands.rs | 76 +++++++++++++++------------ 2 files changed, 44 insertions(+), 34 deletions(-)
drivers/gpu/nova-core/gsp/boot.rs +1 -1
@@ -146,7 +146,7 @@ impl super::Gsp { self.cmdq .send_command_no_wait (bar, commands::SetSystemInfo ::new (pdev, chipset))?; self.cmdq - .send_command_no_wait (bar, commands::SetRegistry ::new ())?; + .send_command_no_wait (bar, commands::SetRegistry ::new ()?)?; hal.post_boot (&self, dev, bar, &gsp_fw, gsp_falcon, sec2_falcon)?;
drivers/gpu/nova-core/gsp/commands.rs +43 -33
107 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 690/1815 gpu: nova-core: fix packed registry table size
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Courbot <[email protected]>
[ Upstream commit 93b9511a3bba7f31d95502e5f912f0a476b0cf4a ]
PACKED_REGISTRY_TABLE::size describes the entire table, including its fixed-size header. SetRegistry currently initializes it with only the variable payload length, omitting the 8 bytes header.
Fix this by using CommandToGsp::size to obtain the actual command size, including its header.
--- drivers/gpu/nova-core/gsp/commands.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/nova-core/gsp/commands.rs +1 -4
@@ -114,10 +114,7 @@ impl CommandToGsp for SetRegistry {type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > { -Self ::Command ::init ( - self.entries.len ()as u32 , - self.variable_payload_len ()as u32 , - ) +Self ::Command ::init (self.entries.len ()as u32 , self.size ()as u32 ) }fn variable_payload_len (&self) ->usize {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 691/1815 perf ui hists: In report UI ensure thread is set with reference counting
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit ae89153d5e50d22e04a084829f74dc5a9ae6eb6d ]
Populates the map_symbol thread in the UI code to fix the e_machine lookup for cross-platform disassembly when using the annotate action. At the same time, refactor the UI options and actions generation to comply with the perf subsystem's strict reference counting abstraction requirements for 'struct map_symbol' and 'struct thread'. Introduce explicit reference acquiring via map_symbol__copy() and thread__get() for menu items, safely clean them up between menu iterations using a new free_popup_actions() helper, and utilize insulated temporary action variables for direct hotkey handler execution.
--- tools/perf/ui/browsers/hists.c | 135 +++++++++++++++++++++------------ 1 file changed, 87 insertions(+), 48 deletions(-)
tools/perf/ui/browsers/hists.c +87 -48
@@ -2356,6 +2356,16 @@ static int hists_browser__scnprintf_title(struct hist_browser *browser, char *bfreturn printed; } +struct popup_action { +unsigned long time; +struct thread *thread; +int (*fn)(struct hist_browser *browser,struct popup_action *act); +struct map_symbol ms; +int socket; +enum rstype rstype; + +}; +static inline void free_popup_options (char **options,int n) {int i;
@@ -2364,6 +2374,16 @@ static inline void free_popup_options(char **options, int n)zfree (&options[i]); } +static inline void free_popup_actions (struct popup_action *actions,int n) +{ +int i; + +for (i =0 ; i < n; ++i) { +map_symbol__exit (&actions[i].ms); +memset (&actions[i],0 ,sizeof (struct popup_action )); + } +} +/* * Only runtime switching of perf data file will make "input_name" point * to a malloced buffer. So add "is_input_name_malloced" flag to decide
@@ -2453,16 +2473,6 @@ static int switch_data_file(void)return ret; } -struct popup_action { -unsigned long time; -struct thread *thread; -int (*fn)(struct hist_browser *browser,struct popup_action *act); -struct map_symbol ms; -int socket; -enum rstype rstype; - -}; -static int do_annotate (struct hist_browser *browser,struct popup_action *act) {
@@ -2540,7 +2550,7 @@ add_annotate_opt(struct popup_action *act, char **optstr,if (asprintf (optstr,"Annotate %s" , ms->sym->name) <0 )return 0 ; - act->ms = *ms; +map_symbol__copy (&act->ms, ms); act->fn = do_annotate;return 1 ; }
@@ -2572,7 +2582,7 @@ add_annotate_type_opt(struct popup_action *act, char **optstr,static int do_zoom_thread (struct hist_browser *browser,struct popup_action *act) { -struct thread *thread = act->thread; +struct thread *thread = act->ms.thread;if ((!hists__has (browser->hists, thread) && !hists__has (browser->hists, comm)) || thread ==NULL )
@@ -2627,7 +2637,7 @@ add_thread_opt(struct hist_browser *browser, struct popup_action *act,if (ret <0 )return 0 ; - act->thread = thread; + act->ms.thread =thread__get (thread); act->fn = do_zoom_thread;return 1 ; }
@@ -2674,7 +2684,7 @@ add_dso_opt(struct hist_browser *browser, struct popup_action *act, __map__is_kernel(map) ? "the Kernel" : dso__short_name(map__dso(map))) < 0)return 0 ; - act->ms.map = map; + act->ms.map =map__get (map); act->fn = do_zoom_dso;return 1 ; }
@@ -2719,7 +2729,7 @@ add_map_opt(struct hist_browser *browser,if (asprintf (optstr,"Browse map details" ) <0 )return 0 ; - act->ms.map = map; + act->ms.map =map__get (map); act->fn = do_browse_map;return 1 ; }
@@ -2733,8 +2743,8 @@ do_run_script(struct hist_browser *browser,int n =0 ; len =100 ; -if (act->thread) - len +=strlen (thread__comm_str (act->thread)); +if (act->ms.thread) + len +=strlen (thread__comm_str (act->ms.thread));else if (act->ms.sym) len +=strlen (act->ms.sym->name); script_opt =malloc (len);
@@ -2742,9 +2752,9 @@ do_run_script(struct hist_browser *browser,return -1 ; script_opt[0 ] =0 ; -if (act->thread) { +if (act->ms.thread) { n =scnprintf (script_opt, len," -c %s " , -thread__comm_str (act->thread)); +thread__comm_str (act->ms.thread)); }else if (act->ms.sym) { n =scnprintf (script_opt, len," -S %s " , act->ms.sym->name);
@@ -2799,7 +2809,7 @@ add_script_opt_2(struct popup_action *act, char **optstr,return 0 ; } - act->thread = thread; + act->ms.thread =thread__get (thread); act->ms.sym = sym; act->fn = do_run_script;return 1 ;
@@ -3087,6 +3097,8 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h key =0 ;// reset key do_hotkey:// key came straight from options ui__popup_menu() +free_popup_options (options,MAX_OPTIONS ); +free_popup_actions (actions,MAX_OPTIONS ); choice = nr_options =0 ; key =hist_browser__run (browser, helpline, warn_lost_event, key);
@@ -3146,24 +3158,40 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h }if (!browser->selection->sym) { +struct map_symbol source_ms; +if (!browser->he_selection)continue ; +memset (&source_ms,0 ,sizeof (source_ms)); +if (sort__mode ==SORT_MODE__BRANCH ) { bi = browser->he_selection->branch_info;if (!bi || !bi->to.ms.map)continue ; - actions->ms.sym =symbol__new_unresolved (bi->to.al_addr, bi->to.ms.map); - actions->ms.map = bi->to.ms.map; + source_ms.sym = +symbol__new_unresolved ( + bi->to.al_addr, + bi->to.ms.map); + source_ms.thread = bi->to.ms.thread; + source_ms.map = bi->to.ms.map; }else { - actions->ms.sym =symbol__new_unresolved (browser->he_selection->ip, - browser->selection->map); - actions->ms.map = browser->selection->map; + source_ms.sym = +symbol__new_unresolved ( + browser->he_selection->ip, + browser->selection->map); + source_ms.thread = browser->selection->thread; + source_ms.map = browser->selection->map; } -if (!actions->ms.sym) +if (!source_ms.sym)continue ; + +memset (&hotkey_act,0 ,sizeof (hotkey_act)); +map_symbol__copy (&hotkey_act.ms, &source_ms); +do_annotate (browser, &hotkey_act); +map_symbol__exit (&hotkey_act.ms); }else {if (symbol__annotation (browser->selection->sym)->src ==NULL ) { ui_browser__warning(&browser->b, delay_secs * 2,
@@ -3173,18 +3201,20 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *hcontinue ; } - actions->ms.map = browser->selection->map; - actions->ms.sym = browser->selection->sym; +memset (&hotkey_act,0 ,sizeof (hotkey_act)); +map_symbol__copy (&hotkey_act.ms, browser->selection); +do_annotate (browser, &hotkey_act); +map_symbol__exit (&hotkey_act.ms); } - -do_annotate (browser, actions);continue ;case 'P' :hist_browser__dump (browser);continue ;case 'd' : - actions->ms.map = map; -do_zoom_dso (browser, actions); +memset (&hotkey_act,0 ,sizeof (hotkey_act)); + hotkey_act.ms.map =map__get (map); +do_zoom_dso (browser, &hotkey_act); +map_symbol__exit (&hotkey_act.ms);continue ;case 'k' :if (browser->selection !=NULL )
@@ -3199,12 +3229,16 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h verbose);continue ;case 't' : - actions->thread = thread; -do_zoom_thread (browser, actions); +memset (&hotkey_act,0 ,sizeof (hotkey_act)); + hotkey_act.ms.thread =thread__get (thread); +do_zoom_thread (browser, &hotkey_act); +map_symbol__exit (&hotkey_act.ms);continue ;case 'S' : - actions->socket = socked_id; -do_zoom_socket (browser, actions); +memset (&hotkey_act,0 ,sizeof (hotkey_act)); + hotkey_act.socket = socked_id; +do_zoom_socket (browser, &hotkey_act); +map_symbol__exit (&hotkey_act.ms);continue ;case '/' : if (ui_browser__input_window("Symbol to show",
@@ -3219,9 +3253,11 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *hcontinue ;case 'r' :if (is_report_browser (hbt)) { - actions->thread =NULL ; - actions->ms.sym =NULL ; -do_run_script (browser, actions); +memset (&hotkey_act,0 ,sizeof (hotkey_act)); + hotkey_act.ms.thread =NULL ; + hotkey_act.ms.sym =NULL ; +do_run_script (browser, &hotkey_act); +map_symbol__exit (&hotkey_act.ms); }continue ;case 's' :
@@ -3293,20 +3329,19 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *hcontinue ; } - actions->ms.map = map; +memset (&hotkey_act,0 ,sizeof (hotkey_act)); top =pstack__peek (browser->pstack);if (top == &browser->hists->dso_filter) { -/* -* No need to set actions->dso here since -* it's just to remove the current filter. -*/ -do_zoom_dso (browser, actions); + hotkey_act.ms.map =map__get (map); +do_zoom_dso (browser, &hotkey_act); }else if (top == &browser->hists->thread_filter) { - actions->thread = thread; -do_zoom_thread (browser, actions); + hotkey_act.ms.thread =thread__get (thread); +do_zoom_thread (browser, &hotkey_act); }else if (top == &browser->hists->socket_filter) { -do_zoom_socket (browser, actions); + hotkey_act.socket = socked_id; +do_zoom_socket (browser, &hotkey_act); } +map_symbol__exit (&hotkey_act.ms);continue ; }case 'q' :
@@ -3443,9 +3478,13 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *hif (key ==K_SWITCH_INPUT_DATA )break ; + +free_popup_options (options,MAX_OPTIONS ); +free_popup_actions (actions,MAX_OPTIONS ); } out_free_stack:pstack__delete (browser->pstack); +free_popup_actions (actions,MAX_OPTIONS ); out:hist_browser__delete (browser);free_popup_options (options,MAX_OPTIONS );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 692/1815 perf annotate: Be robust to annotating without a thread
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit b84e081e071da548a531875258fa4b513d786331 ]
If a thread isn't given to map_symbol__get_arch(), try harder to determine the arch for disassembly. Do this by utilizing fallback paths such as reading the e_machine from a map's DSO ELF header for user-space libraries. Additionally, rely on map__kmaps() and maps__machine() to reliably extract the recorded machine environment and e_machine for kernel and kallsyms maps, perfectly preventing silent, incorrect host fallbacks to uname() during cross-platform Capstone annotation sessions.
At the same time, ensure all remaining uses of a map_symbol's thread pointer do not assume it is non-NULL to eliminate UI segmentation faults, and remove the fragile, redundant thread__get_arch() function to streamline the annotate and disassembly subsystem architecture.
--- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 51 ++++++++++++++++++++++--------- tools/perf/util/annotate.h | 3 +- tools/perf/util/capstone.c | 42 ++++++++++++++++++++----- 4 files changed, 74 insertions(+), 24 deletions(-)
tools/perf/ui/browsers/annotate.c +1 -1
@@ -1201,7 +1201,7 @@ int __hist_entry__tui_annotate(struct hist_entry *he, struct map_symbol *ms,ui__warning ("Annotation has no source code." ); } }else { - err =thread__get_arch (ms->thread, &browser.arch); + err =map_symbol__get_arch (ms, &browser.arch);if (err) {annotate_browser__symbol_annotate_error (&browser, err);return -1 ;
tools/perf/util/annotate.c +37 -14
88 lines not on this page · raw message
tools/perf/util/annotate.h +2 -1
@@ -584,5 +584,6 @@ int annotation_br_cntr_entry(char **str, int br_cntr_nr, u64 *br_cntr, int num_aggr, struct evsel *evsel);int annotation_br_cntr_abbr_list (char **str,struct evsel *evsel,bool header); -int thread__get_arch (struct thread *thread,const struct arch **parch); + +int map_symbol__get_arch (struct map_symbol *ms,const struct arch **parch);#endif /* __PERF_ANNOTATE_H */
tools/perf/util/capstone.c +34 -8
66 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 693/1815 cpufreq/amd-pstate: Set min_limit_freq based on bios_min_perf
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit 5c3ecf36d2918facff40548ee6ae28eef0865266 ]
amd_pstate_update_min_max_limit() sets the min_limit_perf to the nominal_perf to avoid frequency throttling when the system is idling.
This was found to be an ideal default but is suboptimal for users who have profiled their workload at different operating frequencies and have configured the optimal idling frequency via bios_min_perf.
Use the bios_min_perf (if configured) as the min_limit_perf when running with performance governor. In absence of bios_min_perf, continue using nominal_perf as the default min_limit_perf to avoid throttling.
--- drivers/cpufreq/amd-pstate.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/cpufreq/amd-pstate.c +16 -6
@@ -699,9 +699,12 @@ static void amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)WRITE_ONCE (cpudata->max_limit_freq, policy->max);if (cpudata->policy ==CPUFREQ_POLICY_PERFORMANCE ) { +u8 min_limit_perf = perf.bios_min_perf ?: perf.nominal_perf; +u32 min_limit_freq; +/* -* For performance policy, set MinPerf to nominal_perf rather than -* highest_perf or lowest_nonlinear_perf. +* For performance policy, set MinPerf to nominal_perf / bios_min_perf +* rather than highest_perf or lowest_nonlinear_perf. * * Per commit 0c411b39e4f4c, using highest_perf was observed * to cause frequency throttling on power-limited platforms, leading to
@@ -709,11 +712,18 @@ static void amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)* performance too much for HPC workloads requiring high frequency * operation and minimal wakeup latency from idle states. * -* nominal_perf therefore provides a balance by avoiding throttling -* while still maintaining enough performance for HPC workloads. +* nominal_perf therefore provides a balanced default by avoiding +* throttling while still maintaining enough performance for HPC +* workloads when bios_min_perf is not available. +* +* When bios_min_perf is available, users have profiled their workloads +* to understand the best idling frequency. Use that instead. */ - perf.min_limit_perf =min (perf.nominal_perf, perf.max_limit_perf); -WRITE_ONCE (cpudata->min_limit_freq,min (cpudata->nominal_freq, cpudata->max_limit_freq)); + min_limit_perf =min (min_limit_perf, perf.max_limit_perf); + min_limit_freq =perf_to_freq (perf, cpudata->nominal_freq, min_limit_perf); + perf.min_limit_perf = min_limit_perf; + +WRITE_ONCE (cpudata->min_limit_freq,min (min_limit_freq, cpudata->max_limit_freq)); }else { perf.min_limit_perf =freq_to_perf (perf, cpudata->nominal_freq, policy->min);WRITE_ONCE (cpudata->min_limit_freq, policy->min);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 694/1815 remoteproc: Allow shutdown of crashed processors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
[ Upstream commit 2482ca875ef5993df8daee563033d70e2523a25f ]
rproc_shutdown() rejects a remoteproc in RPROC_CRASHED state, and rproc_del() ignores that error. The result of these two decisions is that a user cannot stop a remoteproc that with recovery disabled that has entered a crash state, and removal of an associated remoteproc driver will release resources without first stopping the remoteproc.
Allow rproc_shutdown() to stop crashed processors. Propagate the crash state to subdevice teardown, to allow subdevices to dismantle things appropriately.
--- drivers/remoteproc/remoteproc_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/remoteproc/remoteproc_core.c +5 -2
@@ -1979,6 +1979,7 @@ EXPORT_SYMBOL(rproc_boot);int rproc_shutdown (struct rproc *rproc) {struct device *dev = &rproc->dev; +bool crashed;int ret; ret =mutex_lock_interruptible (&rproc->lock);
@@ -1988,16 +1989,18 @@ int rproc_shutdown(struct rproc *rproc) }if (rproc->state !=RPROC_RUNNING && - rproc->state !=RPROC_ATTACHED ) { + rproc->state !=RPROC_ATTACHED && + rproc->state !=RPROC_CRASHED ) { ret = -EINVAL ; goto out; } + crashed = rproc->state ==RPROC_CRASHED ;/* if the remote proc is still needed, bail out */ if (!atomic_dec_and_test (&rproc->power)) goto out; - ret =rproc_stop (rproc, false); + ret =rproc_stop (rproc, crashed);if (ret) {atomic_inc (&rproc->power); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 695/1815 remoteproc: core: Attach rproc asynchronously in rproc_add() path via schedule_work()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingyi Wang <[email protected]>
[ Upstream commit 026a3fada43261e403c6c4d9bda9501547e3f108 ]
Unlike the remoteproc firmware load path where rproc_add() call rproc_auto_boot_callback() asynchronously and ignores the return value of rproc_boot(), the attach path calls rproc_boot() synchronously and propagates its return value back to rproc_add(). This means a failure during rproc_attach() causes rproc_add() to fail and triggers resource release, removing the remoteproc from sysfs and making it unavailable for recovery or further boot attempts.
Align the remoteproc attach path with the firmware load path by introducing attach_work and scheduling rproc_boot() asynchronously via schedule_work(). This keeps the remoteproc registered and available in sysfs even if the initial attach attempt fails, and avoids blocking rproc_add() on the attach result.
Stable-dep-of: 74ee3b2f5767 ("remoteproc: Prevent crash handling to race with rproc_del()")
--- drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++-------- include/linux/remoteproc.h | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +12 -8
@@ -1668,18 +1668,21 @@ static void rproc_auto_boot_callback(const struct firmware *fw, void *context)release_firmware (fw); } +static void rproc_attach_work (struct work_struct *work) +{ + struct rproc *rproc = container_of(work, struct rproc, attach_work); + +rproc_boot (rproc); +} +static int rproc_trigger_auto_boot (struct rproc *rproc) {int ret; -/* -* Since the remote processor is in a detached state, it has already -* been booted by another entity. As such there is no point in waiting -* for a firmware image to be loaded, we can simply initiate the process -* of attaching to it immediately. -*/ -if (rproc->state ==RPROC_DETACHED ) -return rproc_boot (rproc); +if (rproc->state ==RPROC_DETACHED ) { +schedule_work (&rproc->attach_work); +return 0 ; + }/* * We're initiating an asynchronous firmware loading, so we can
@@ -2510,6 +2513,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,INIT_LIST_HEAD (&rproc->dump_segments);INIT_WORK (&rproc->crash_handler, rproc_crash_handler_work); +INIT_WORK (&rproc->attach_work, rproc_attach_work); rproc->state =RPROC_OFFLINE ;
include/linux/remoteproc.h +2 -0
@@ -259,6 +259,7 @@ enum rproc_features {* @subdevs: list of subdevices, to following the running state * @notifyids: idr for dynamically assigning rproc-wide unique notify ids * @index: index of this rproc device +* @attach_work: workqueue for attaching rproc * @crash_handler: workqueue for handling a crash * @crash_cnt: crash counter * @recovery_disabled: flag that state if recovery was disabled
@@ -301,6 +302,7 @@ struct rproc {struct list_head subdevs;struct idr notifyids;int index; +struct work_struct attach_work;struct work_struct crash_handler;unsigned int crash_cnt;bool recovery_disabled;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 696/1815 remoteproc: Prevent crash handling to race with rproc_del()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
[ Upstream commit 74ee3b2f5767447c57959994341e5b95f1079977 ]
There's no synchronization between rproc_crash_handler_work() and rproc_del(), as such it's possible for a driver to be removed while crash-handler work is scheduled, or even executing - resulting in use-after-free issues.
To avoid this the scheduled work need to be cancelled and synchronized against before the removal proceeds.
In order to ensure that this doesn't race with the reporting, and thereby scheduling new work, a "deleting" flag is introduced. This is similar to the RPROC_DELETE state that was introduced to ensure that "start" didn't race with rproc_del(), but the existing mechanism can not be used as it's valid to call rproc_report_crash() in atomic context - and the "state" is protected by a mutex.
In the event that work is cancelled the pm_stay_awake() is left unbalanced and need to be unrolled.
The blocking and cancelling of crash-handler work prior to the actual rproc_shutdown() call does have the explicit side-effect that crashes resulting from the shutdown process will not enter the crash-handling path, and as such will not generate devcoredumps etc. Due to the existing mutual exclusion between these code paths there's no concrete reduction in functionality, but further work would be needed to handle this case.
--- drivers/remoteproc/remoteproc_core.c | 42 +++++++++++++++++++++------ drivers/remoteproc/remoteproc_sysfs.c | 1 - include/linux/remoteproc.h | 13 +++++---- 3 files changed, 41 insertions(+), 15 deletions(-)
drivers/remoteproc/remoteproc_core.c +33 -9
@@ -1831,6 +1831,11 @@ int rproc_trigger_recovery(struct rproc *rproc)if (ret)return ret; +if (READ_ONCE (rproc->deleting)) { + ret = -ENODEV ; + goto unlock_mutex; + } +/* State could have changed before we got the mutex */ if (rproc->state !=RPROC_CRASHED ) goto unlock_mutex;
@@ -1863,6 +1868,11 @@ static void rproc_crash_handler_work(struct work_struct *work)mutex_lock (&rproc->lock); +if (READ_ONCE (rproc->deleting)) { +mutex_unlock (&rproc->lock); + goto out; + } +if (rproc->state ==RPROC_CRASHED ) {/* handle only the first crash detected */ mutex_unlock (&rproc->lock);
@@ -1918,9 +1928,9 @@ int rproc_boot(struct rproc *rproc)return ret; } -if (rproc->state ==RPROC_DELETED ) { +if (READ_ONCE (rproc->deleting)) { ret = -ENODEV ; -dev_err (dev,"can't boot deleted rproc %s\n" , rproc->name); +dev_err (dev,"can't boot deleting rproc %s\n" , rproc->name); goto unlock_mutex; }
@@ -2512,8 +2522,9 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,INIT_LIST_HEAD (&rproc->subdevs);INIT_LIST_HEAD (&rproc->dump_segments); -INIT_WORK (&rproc->crash_handler, rproc_crash_handler_work);INIT_WORK (&rproc->attach_work, rproc_attach_work); +INIT_WORK (&rproc->crash_handler, rproc_crash_handler_work); +spin_lock_init (&rproc->crash_handler_lock); rproc->state =RPROC_OFFLINE ;
@@ -2577,16 +2588,21 @@ EXPORT_SYMBOL(rproc_put);*/ int rproc_del (struct rproc *rproc) { +unsigned long flags; +if (!rproc)return -EINVAL ; +spin_lock_irqsave (&rproc->crash_handler_lock, flags); +WRITE_ONCE (rproc->deleting, true); +spin_unlock_irqrestore (&rproc->crash_handler_lock, flags); + +if (cancel_work_sync (&rproc->crash_handler)) +pm_relax (rproc->dev.parent); +/* TODO: make sure this works with rproc->power > 1 */ rproc_shutdown (rproc); -mutex_lock (&rproc->lock); - rproc->state =RPROC_DELETED ; -mutex_unlock (&rproc->lock); -rproc_delete_debug_dir (rproc);/* the rproc is downref'ed as soon as it's removed from the klist */
@@ -2698,18 +2714,26 @@ EXPORT_SYMBOL(rproc_get_by_child);*/ void rproc_report_crash (struct rproc *rproc,enum rproc_crash_type type) { +unsigned long flags; +if (!rproc) {pr_err ("NULL rproc pointer\n" );return ; } +spin_lock_irqsave (&rproc->crash_handler_lock, flags); +if (READ_ONCE (rproc->deleting)) { +spin_unlock_irqrestore (&rproc->crash_handler_lock, flags); +return ; + } +/* Prevent suspend while the remoteproc is being recovered */ pm_stay_awake (rproc->dev.parent); +queue_work (rproc_recovery_wq, &rproc->crash_handler); +spin_unlock_irqrestore (&rproc->crash_handler_lock, flags);dev_err (&rproc->dev,"crash detected in %s: type %s\n" , rproc->name,rproc_crash_to_string (type)); - -queue_work (rproc_recovery_wq, &rproc->crash_handler); }EXPORT_SYMBOL (rproc_report_crash);
drivers/remoteproc/remoteproc_sysfs.c +0 -1
@@ -168,7 +168,6 @@ static const char * const rproc_state_string[] = { [RPROC_SUSPENDED] = "suspended", [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", - [RPROC_DELETED] = "deleted", [RPROC_ATTACHED] = "attached", [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid",
include/linux/remoteproc.h +8 -5
@@ -37,6 +37,7 @@#include <linux/types.h> #include <linux/mutex.h> +#include <linux/spinlock.h> #include <linux/virtio.h> #include <linux/cdev.h> #include <linux/completion.h>
@@ -145,7 +146,6 @@ struct rproc_ops {* a message. * @RPROC_RUNNING: device is up and running * @RPROC_CRASHED: device has crashed; need to start recovery -* @RPROC_DELETED: device is deleted * @RPROC_ATTACHED: device has been booted by another entity and the core * has attached to it * @RPROC_DETACHED: device has been booted by another entity and waiting
@@ -163,10 +163,9 @@ enum rproc_state {RPROC_SUSPENDED =1 ,RPROC_RUNNING =2 ,RPROC_CRASHED =3 , -RPROC_DELETED =4 , -RPROC_ATTACHED =5 , -RPROC_DETACHED =6 , - RPROC_LAST = 7, +RPROC_ATTACHED =4 , +RPROC_DETACHED =5 , + RPROC_LAST = 6, };/**
@@ -261,6 +260,8 @@ enum rproc_features {* @index: index of this rproc device * @attach_work: workqueue for attaching rproc * @crash_handler: workqueue for handling a crash +* @crash_handler_lock: serializes crash handler queueing and deletion +* @deleting: remoteproc deletion has begun * @crash_cnt: crash counter * @recovery_disabled: flag that state if recovery was disabled * @max_notifyid: largest allocated notify id.
@@ -304,6 +305,8 @@ struct rproc {int index;struct work_struct attach_work;struct work_struct crash_handler; +spinlock_t crash_handler_lock; +bool deleting;unsigned int crash_cnt;bool recovery_disabled;int max_notifyid;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 697/1815 remoteproc: qcom: pas: Add late attach support for subsystems
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingyi Wang <[email protected]>
[ Upstream commit 16472c99f4699cb28f2f5f946400ead02f58a15e ]
Subsystems can be brought out of reset by entities such as bootloaders. As the irq enablement could be later than subsystem bring up, the state of subsystem should be checked by reading SMP2P bits.
A new qcom_pas_attach() function is introduced. if crash state is detected for the subsystem, rproc_report_crash() is called. If the ready state is detected meanwhile stop state is not detected, it will be marked as "attached", otherwise it could be the early boot feature is not supported by other entities or it has already been stopped. In above cases, the state will be marked as RPROC_OFFLINE so that the PAS driver can load the firmware and start the remoteproc.
Stable-dep-of: 0ea50486978f ("remoteproc: qcom: q6v5: Request shutdown if crash is triggered host-side")
--- drivers/remoteproc/qcom_common.h | 6 +++ drivers/remoteproc/qcom_q6v5.c | 3 +- drivers/remoteproc/qcom_q6v5_pas.c | 68 ++++++++++++++++++++++++++++++ drivers/remoteproc/qcom_sysmon.c | 19 +++++++++ 4 files changed, 95 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_common.h +6 -0
@@ -68,6 +68,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, int ssctl_instance);void qcom_remove_sysmon_subdev (struct qcom_sysmon *sysmon);bool qcom_sysmon_shutdown_acked (struct qcom_sysmon *sysmon); +bool qcom_sysmon_shutdown_irq_state (struct qcom_sysmon *sysmon);#else static inline struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, const char *name,
@@ -84,6 +85,11 @@ static inline bool qcom_sysmon_shutdown_acked(struct qcom_sysmon *sysmon) {return false; } + +static inline bool qcom_sysmon_shutdown_irq_state (struct qcom_sysmon *sysmon) +{ +return false; +}#endif #endif
drivers/remoteproc/qcom_q6v5.c +2 -1
@@ -202,7 +202,8 @@ int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5, struct qcom_sysmon *sysmon) q6v5->running = false;/* Don't perform SMP2P dance if remote isn't running */ -if (q6v5->rproc->state !=RPROC_RUNNING ||qcom_sysmon_shutdown_acked (sysmon)) +if ((q6v5->rproc->state !=RPROC_RUNNING && q6v5->rproc->state !=RPROC_ATTACHED ) || +qcom_sysmon_shutdown_acked (sysmon))return 0 ; qcom_smem_state_update_bits(q6v5->state,
drivers/remoteproc/qcom_q6v5_pas.c +68 -0
98 lines not on this page · raw message
drivers/remoteproc/qcom_sysmon.c +19 -0
@@ -736,6 +736,25 @@ bool qcom_sysmon_shutdown_acked(struct qcom_sysmon *sysmon) }EXPORT_SYMBOL_GPL (qcom_sysmon_shutdown_acked); +bool qcom_sysmon_shutdown_irq_state (struct qcom_sysmon *sysmon) +{ +bool shutdown_state; +int ret; + +if (!sysmon) +return false; + + ret =irq_get_irqchip_state (sysmon->shutdown_irq, +IRQCHIP_STATE_LINE_LEVEL , &shutdown_state); +if (ret) { +dev_warn (sysmon->dev,"failed to get shutdown_state: %d\n" , ret); +return false; + } + +return shutdown_state; +} +EXPORT_SYMBOL_GPL (qcom_sysmon_shutdown_irq_state); +/** * sysmon_probe() - probe sys_mon channel * @rpdev: rpmsg device handle
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 698/1815 remoteproc: qcom: q6v5: Request shutdown if crash is triggered host-side
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
[ Upstream commit 0ea50486978f109e6d4c32267fab01ed654a2160 ]
rpmsg client drivers are allowed to invoke rproc_report_crash() on their grandparent when they determine that the otherwise seemingly healthy remoteproc has entered a functionally broken state.
In the crash handling path qcom_q6v5_request_stop() is invoked, which is based on the current rproc state whether to request a graceful shutdown.
But the current rproc state will be RPROC_CRASHED regardless of where the crash handler was initiated from, and empirical data shows that unless the firmware is taking part of the shutdown the system state is often left such that it's not possible to start the subsystem again.
Use the running state in the q6v5 driver to make the decision instead, as this does represent the actual state of the firmware.
This makes it possible to reliably trigger a restart from client drivers.
--- drivers/remoteproc/qcom_q6v5.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/remoteproc/qcom_q6v5.c +3 -3
@@ -197,13 +197,13 @@ static irqreturn_t q6v5_stop_interrupt(int irq, void *data)*/ int qcom_q6v5_request_stop (struct qcom_q6v5 *q6v5,struct qcom_sysmon *sysmon) { +bool was_running = q6v5->running;int ret; q6v5->running = false; -/* Don't perform SMP2P dance if remote isn't running */ -if ((q6v5->rproc->state !=RPROC_RUNNING && q6v5->rproc->state !=RPROC_ATTACHED ) || -qcom_sysmon_shutdown_acked (sysmon)) +/* A watchdog/fatal IRQ clears running; logical crashes still need a stop. */ +if (!was_running ||qcom_sysmon_shutdown_acked (sysmon))return 0 ; qcom_smem_state_update_bits(q6v5->state,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 699/1815 arm64: dts: qcom: glymur: fix SoCCP memory mappings
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ananthu C V <[email protected]>
[ Upstream commit 61e5b39e96aadeafa884ab96c1477b781dccf145 ]
The currently listed SoCCP and SoCCP DTB reserved memory regions don't align with the memory requested by the SoCCP Firmware. Fix this by updating the SoCCP/SoCCP DTB memory regions to reflect the memory region requirements of the SoCCP firmware, as described in the Glymur v21 memory map release.
--- arch/arm64/boot/dts/qcom/glymur.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/glymur.dtsi +4 -4
@@ -602,13 +602,13 @@ spss_region_mem: spss@88a00000 { no-map; }; - soccpdtb_mem: soccpdtb@892e0000 { - reg = <0x0 0x892e0000 0x0 0x20000>; + soccp_mem: soccp@88e00000 { + reg = <0x0 0x88e00000 0x0 0x400000>; no-map; }; - soccp_mem: soccp@89300000 { - reg = <0x0 0x89300000 0x0 0x400000>; + soccpdtb_mem: soccpdtb@89200000 { + reg = <0x0 0x89200000 0x0 0x20000>; no-map; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 700/1815 staging: rtl8723bs: use kfree_sensitive() for key material
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivy Lopez <[email protected]>
[ Upstream commit d205dfa8cb825f1954ca1cfa474fc50bf06ee4aa ]
The set_stakey_parm struct contains a 16-byte encryption key. Use kfree_sensitive() instead of kfree() to ensure the key material is zeroed before the memory is freed, preventing potential information leaks.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +4 -4
@@ -899,7 +899,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_if (enqueue) { ph2c =kzalloc_obj (*ph2c);if (!ph2c) { -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); res = _FAIL; goto exit; }
@@ -907,7 +907,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ psetstakey_rsp =kzalloc_obj (*psetstakey_rsp);if (!psetstakey_rsp) {kfree (ph2c); -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); res = _FAIL; goto exit; }
@@ -918,7 +918,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ res =rtw_enqueue_cmd (pcmdpriv, ph2c); }else {set_stakey_hdl (padapter, (u8 *)psetstakey_para); -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); } exit:return res;
@@ -958,7 +958,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu psetstakey_rsp =kzalloc_obj (*psetstakey_rsp);if (!psetstakey_rsp) {kfree (ph2c); -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); res = _FAIL; goto exit; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 701/1815 fs/ntfs3: reject restart table growth beyond U16_MAX entries
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 111f8d74a19d85942ecbb3aba78f6f3c88e59391 ]
During $LogFile replay, log_replay() indexes the transaction table by the transact_id taken from the log record header. check_log_rec() only verifies that transact_id is non-zero and properly aligned, not its magnitude, so a crafted image can request an arbitrarily large index.
alloc_rsttbl_from_idx() grows the table to cover that index via extend_rsttbl(), which passes the new entry count to init_rsttbl():
rt = init_rsttbl(esize, used + add);
used + add is computed as u32 but init_rsttbl() takes a u16, and the count is stored in struct RESTART_TABLE as a __le16. When used + add exceeds U16_MAX it is truncated, init_rsttbl() allocates a table far smaller than the index requires, and alloc_rsttbl_from_idx() then dereferences and writes at the original, untruncated offset -- an out-of-bounds access past the allocation, reachable by mounting a crafted NTFS image.
BUG: KASAN: use-after-free in alloc_rsttbl_from_idx (fs/ntfs3/fslog.c:950) Read of size 4 at addr ffff8880327ffff8 by task exploit alloc_rsttbl_from_idx (fs/ntfs3/fslog.c:950) log_replay (fs/ntfs3/fslog.c:4562) ntfs_loadlog_and_replay (fs/ntfs3/fsntfs.c:324) ntfs_fill_super (fs/ntfs3/super.c:1393) get_tree_bdev_flags vfs_get_tree path_mount __x64_sys_mount
A restart table is limited to U16_MAX entries by its __le16 count, so a larger growth request is invalid input. Reject it in extend_rsttbl(); all callers already handle a NULL return.
--- fs/ntfs3/fslog.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/fslog.c +3 -0
@@ -875,6 +875,9 @@ static inline struct RESTART_TABLE *extend_rsttbl(struct RESTART_TABLE *tbl,u32 used =le16_to_cpu (tbl->used);struct RESTART_TABLE *rt; +if (used + add >U16_MAX ) +return NULL ; + rt =init_rsttbl (esize, used + add);if (!rt)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 702/1815 iommu/tegra241-cmdqv: Publish an LVCMDQ only after it is fully initialized
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit cbc41aacd49e695338940196e7084770365e1b68 ]
tegra241_vintf_init_lvcmdq() stores the freshly allocated vcmdq pointer to the vintf->lvcmdqs[] array, before tegra241_vcmdq_alloc_smmu_cmdq() builds the vcmdq->cmdq. The error ISR dereferences that cmdq, so a latched LVCMDQ error (e.g. one inherited across a kexec) firing in this window would make tegra241_vintf0_handle_error() pass the still-zeroed arm_smmu_cmdq down to __arm_smmu_cmdq_skip_err(), dereferencing NULL queue register pointers.
Drop the store from tegra241_vintf_init_lvcmdq() and publish the vcmdq at the end of the allocation instead, with an smp_store_release() that pairs with an smp_load_acquire() in the ISR, which can see a fully built LVCMDQ or NULL.
The user-owned LVCMDQ allocation moves accordingly, publishing the vcmdq once tegra241_vcmdq_hw_init_user() succeeds, using a plain store since a user VINTF's lvcmdqs[] has no lockless reader -- the error ISR only walks the VINTF0 array.
--- .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +17 -8
@@ -320,12 +320,19 @@ static void tegra241_vintf0_handle_error(struct tegra241_vintf *vintf)while (map) {unsigned long lidx =__ffs64 (map); -struct tegra241_vcmdq *vcmdq = vintf->lvcmdqs[lidx]; -u32 gerror =readl_relaxed (REG_VCMDQ_PAGE0 (vcmdq,GERROR )); +struct tegra241_vcmdq *vcmdq; +u32 gerror; + map &= ~BIT_ULL (lidx); + +/* Pairs with smp_store_release() publishing it */ + vcmdq =smp_load_acquire (&vintf->lvcmdqs[lidx]); +if (!vcmdq) +continue ; + + gerror =readl_relaxed (REG_VCMDQ_PAGE0 (vcmdq,GERROR ));__arm_smmu_cmdq_skip_err (&vintf->cmdqv->smmu, &vcmdq->cmdq);writel (gerror,REG_VCMDQ_PAGE0 (vcmdq,GERRORN )); - map &= ~BIT_ULL (lidx); } } }
@@ -668,7 +675,6 @@ static int tegra241_vintf_init_lvcmdq(struct tegra241_vintf *vintf, u16 lidx, vcmdq->page0 = cmdqv->base +TEGRA241_VINTFi_LVCMDQ_PAGE0 (idx, lidx); vcmdq->page1 = cmdqv->base +TEGRA241_VINTFi_LVCMDQ_PAGE1 (idx, lidx); - vintf->lvcmdqs[lidx] = vcmdq;return 0 ; }
@@ -707,14 +713,15 @@ tegra241_vintf_alloc_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)/* Build an arm_smmu_cmdq for each LVCMDQ */ ret =tegra241_vcmdq_alloc_smmu_cmdq (vcmdq);if (ret) - goto deinit_lvcmdq; + goto free_vcmdq; + +/* Pairs with the smp_load_acquire() in the error ISR */ +smp_store_release (&vintf->lvcmdqs[lidx], vcmdq);dev_dbg (cmdqv->dev,"%sallocated\n" ,lvcmdq_error_header (vcmdq, header,64 ));return vcmdq; -deinit_lvcmdq: -tegra241_vintf_deinit_lvcmdq (vintf, lidx); free_vcmdq:kfree (vcmdq);return ERR_PTR (ret);
@@ -1142,13 +1149,15 @@ static int tegra241_vintf_alloc_lvcmdq_user(struct iommufd_hw_queue *hw_queue,if (ret) goto unmap_lvcmdq; +/* No lockless reader of a user VINTF's lvcmdqs[]; mutex-serialized */ + vintf->lvcmdqs[lidx] = vcmdq; + hw_queue->destroy = &tegra241_vintf_destroy_lvcmdq_user;mutex_unlock (&vintf->lvcmdq_mutex);return 0 ; unmap_lvcmdq:tegra241_vcmdq_unmap_lvcmdq (vcmdq); -tegra241_vintf_deinit_lvcmdq (vintf, lidx); undepend_vcmdq:if (vcmdq->prev)iommufd_hw_queue_undepend (vcmdq, vcmdq->prev, core);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 703/1815 iommu/tegra241-cmdqv: Synchronize the error ISR against VINTF (de)init
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit a491be376abd1c80a314cdd658632c85cd660b73 ]
A user VINTF is torn down by tegra241_cmdqv_deinit_vintf(), which runs from the destroy callback and from the init-failure unwind in the alloc handler. It clears the cmdqv->vintfs[] slot and lets the iommufd core free it, but nothing serializes that against the error interrupt: tegra241_cmdqv_isr() reads cmdqv->vintfs[idx] and dereferences the vintf. A concurrent error can make the ISR read a slot mid-clear (a NULL deref) or use a vintf which is about to be freed (a use-after-free).
deinit_vintf() also returns idx to the IDA before clearing the slot, so a concurrent create that reuses idx can publish its new vintf into the slot, only for this teardown to erase it again with the stale NULL store.
On the other end, tegra241_cmdqv_init_vintf() publishes a new vintf with a plain store to the cmdqv->vintfs[] slot, and the ISR dereferences fields of a published vintf such as vintf->base. A plain store gives no ordering on a weakly-ordered CPU, and a stale VINTF_ERR_MAP bit on a reused idx can make the ISR pick a vintf the moment it is published, before its fields are set or tegra241_vintf_hw_init() runs.
The cmdqv->vintfs[0] slot stays NULL until tegra241_cmdqv_init_structures() first creates VINTF0, so the slot 0 read needs the same NULL check.
Publish every slot with an smp_store_release(), and read each slot in the ISR with an smp_load_acquire() under a NULL check, so the ISR always sees a fully built vintf or NULL. Also make deinit_vintf() clear the slot, and synchronize_irq() prior to returning idx to the IDA, so no vintf is freed under a running handler and no reused idx is clobbered.
--- .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +33 -4
@@ -337,6 +337,13 @@ static void tegra241_vintf0_handle_error(struct tegra241_vintf *vintf) } } +/* +* The CMDQV error interrupt is edge-triggered, so a pending VINTF error fires +* this ISR once and does not re-assert. An unacked guest therefore cannot +* storm the host. The HW latches and forwards each new error event on its +* own, so an already-set ERR_MAP bit does not suppress the interrupt for a +* new error. +*/ static irqreturn_t tegra241_cmdqv_isr (int irq,void *devid) {struct tegra241_cmdqv *cmdqv = (struct tegra241_cmdqv *)devid;
@@ -359,16 +366,27 @@ static irqreturn_t tegra241_cmdqv_isr(int irq, void *devid)/* Handle VINTF0 and its LVCMDQs */ if (vintf_map &BIT_ULL (0 )) { -tegra241_vintf0_handle_error (cmdqv->vintfs[0 ]); +struct tegra241_vintf *vintf0; + vintf_map &= ~BIT_ULL (0 ); + +/* NULL until tegra241_cmdqv_init_structures() publishes it */ + vintf0 =smp_load_acquire (&cmdqv->vintfs[0 ]); +if (vintf0) +tegra241_vintf0_handle_error (vintf0); }/* Handle other user VINTFs and their LVCMDQs */ while (vintf_map) {unsigned long idx =__ffs64 (vintf_map); +struct tegra241_vintf *vintf; -tegra241_vintf_user_handle_error (cmdqv->vintfs[idx]); vintf_map &= ~BIT_ULL (idx); + +/* The slot may be published or torn down (NULL'd) concurrently */ + vintf =smp_load_acquire (&cmdqv->vintfs[idx]); +if (vintf) +tegra241_vintf_user_handle_error (vintf); }return IRQ_HANDLED ;
@@ -732,8 +750,18 @@ tegra241_vintf_alloc_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)static void tegra241_cmdqv_deinit_vintf (struct tegra241_cmdqv *cmdqv,u16 idx) {kfree (cmdqv->vintfs[idx]->lvcmdqs); +/* +* Clear the slot and drain any in-flight ISR before returning idx to +* the IDA, so a concurrent create that reuses idx cannot have its +* freshly published VINTF erased here. A plain WRITE_ONCE() suffices +* since clearing the slot publishes no data. This also covers the +* init-failure unwind, which reaches deinit_vintf() without the +* destroy callback. +*/ +WRITE_ONCE (cmdqv->vintfs[idx],NULL ); +if (cmdqv->irq >0 ) +synchronize_irq (cmdqv->irq);ida_free (&cmdqv->vintf_ids, idx); - cmdqv->vintfs[idx] =NULL ; } static int tegra241_cmdqv_init_vintf(struct tegra241_cmdqv *cmdqv, u16 max_idx,
@@ -759,7 +787,8 @@ static int tegra241_cmdqv_init_vintf(struct tegra241_cmdqv *cmdqv, u16 max_idx,return -ENOMEM ; } - cmdqv->vintfs[idx] = vintf; +/* Pairs with the smp_load_acquire() in tegra241_cmdqv_isr() */ +smp_store_release (&cmdqv->vintfs[idx], vintf);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 704/1815 iommu/tegra241-cmdqv: Dont run the error ISR before probe sets up vintfs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit 5acd67ceb38debe2fbf70ea35e2dec9f7ab01bbd ]
__tegra241_cmdqv_probe() requests the error IRQ before it has allocated the cmdqv->vintfs array and set cmdqv->num_vintfs. A CMDQV left enabled with a latched error across a kexec fires the IRQ as soon as it is requested, and tegra241_cmdqv_isr() then walks the uninitialized cmdqv->vintfs array.
Request the IRQ only after cmdqv->vintfs is allocated and zeroed, so that a latched interrupt firing early runs the ISR against a valid array of NULL slots that it safely skips.
--- .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +19 -15
@@ -977,17 +977,6 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res, cmdqv->dev = smmu->impl_dev; cmdqv->base_phys = res->start; -if (cmdqv->irq >0 ) { - ret =request_threaded_irq (irq,NULL , tegra241_cmdqv_isr, -IRQF_ONESHOT ,"tegra241-cmdqv" , - cmdqv); -if (ret) { -dev_err (cmdqv->dev,"failed to request irq (%d): %d\n" , - cmdqv->irq, ret); - goto iounmap; - } - } - regval =readl_relaxed (REG_CMDQV (cmdqv,PARAM )); cmdqv->num_vintfs =1 <<FIELD_GET (CMDQV_NUM_VINTF_LOG2 , regval); cmdqv->num_vcmdqs =1 <<FIELD_GET (CMDQV_NUM_VCMDQ_LOG2 , regval);
@@ -998,10 +987,25 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res, cmdqv->vintfs =kzalloc_objs (*cmdqv->vintfs, cmdqv->num_vintfs);if (!cmdqv->vintfs) - goto free_irq; + goto iounmap;ida_init (&cmdqv->vintf_ids); +/* +* Request the IRQ only after cmdqv->vintfs is allocated and zeroed, so +* the ISR would not walk an uninitialized array. +*/ +if (cmdqv->irq >0 ) { + ret =request_threaded_irq (irq,NULL , tegra241_cmdqv_isr, +IRQF_ONESHOT ,"tegra241-cmdqv" , + cmdqv); +if (ret) { +dev_err (cmdqv->dev,"failed to request irq (%d): %d\n" , + cmdqv->irq, ret); + goto free_vintfs; + } + } +#ifdef CONFIG_IOMMU_DEBUGFS if (!cmdqv_debugfs_dir) { cmdqv_debugfs_dir =
@@ -1016,9 +1020,9 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res,return new_smmu; -free_irq: -if (cmdqv->irq >0 ) -free_irq (cmdqv->irq, cmdqv); +free_vintfs: +ida_destroy (&cmdqv->vintf_ids); +kfree (cmdqv->vintfs); iounmap:iounmap (base);return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 705/1815 iommu/tegra241-cmdqv: Dont fall back to a freed smmu after devm_krealloc()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit d4d05f55e9da646ec03adfa77260eb46f4163749 ]
__tegra241_cmdqv_probe() uses devm_krealloc() to grow @smmu into the larger tegra241_cmdqv, which frees the original @smmu once it relocates. A failure after that returned NULL, and the caller then dereferenced the freed @smmu on its fallback path.
Return an int and take @smmu by reference instead, then update *smmu to the reallocated pointer after devm_krealloc() succeeds, so the caller and its fallback path both use the live @smmu rather than the freed original.
--- .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +32 -22
@@ -938,16 +938,22 @@ static int tegra241_cmdqv_init_structures(struct arm_smmu_device *smmu)static struct dentry *cmdqv_debugfs_dir;#endif -static struct arm_smmu_device * -__tegra241_cmdqv_probe (struct arm_smmu_device *smmu,struct resource *res, -int irq) +/* +* Probe the CMDQV and reallocate @smmu into the larger cmdqv->smmu. +* +* devm_krealloc() may relocate and free the original @smmu, so update *smmu to +* the new pointer once it succeeds. The error paths after it do the same, so a +* caller falling back keeps a live @smmu instead of the freed original. +*/ +static int __tegra241_cmdqv_probe (struct arm_smmu_device **smmu, +struct resource *res,int irq) {static const struct arm_smmu_impl_ops init_ops = { .init_structures = tegra241_cmdqv_init_structures, .device_remove = tegra241_cmdqv_remove, }; -struct tegra241_cmdqv *cmdqv =NULL ; -struct arm_smmu_device *new_smmu; +struct device *dev = (*smmu)->dev; +struct tegra241_cmdqv *cmdqv;void __iomem *base;u32 regval;int ret;
@@ -956,25 +962,28 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res, base =ioremap (res->start,resource_size (res));if (!base) { -dev_err (smmu->dev,"failed to ioremap\n" ); -return NULL ; +dev_err (dev,"failed to ioremap\n" ); +return -ENOMEM ; } regval =readl (base +TEGRA241_CMDQV_CONFIG );if (disable_cmdqv) { -dev_info (smmu->dev,"Detected disable_cmdqv=true\n" ); +dev_info (dev,"Detected disable_cmdqv=true\n" );writel (regval & ~CMDQV_EN , base +TEGRA241_CMDQV_CONFIG ); + ret = -ENODEV ; goto iounmap; } - cmdqv =devm_krealloc (smmu->dev, smmu,sizeof (*cmdqv),GFP_KERNEL ); -if (!cmdqv) + cmdqv =devm_krealloc (dev, *smmu,sizeof (*cmdqv),GFP_KERNEL ); +if (!cmdqv) { + ret = -ENOMEM ; goto iounmap; - new_smmu = &cmdqv->smmu; + } + *smmu = &cmdqv->smmu; cmdqv->irq = irq; cmdqv->base = base; - cmdqv->dev = smmu->impl_dev; + cmdqv->dev = (*smmu)->impl_dev; cmdqv->base_phys = res->start; regval =readl_relaxed (REG_CMDQV (cmdqv,PARAM ));
@@ -986,8 +995,10 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res, cmdqv->vintfs =kzalloc_objs (*cmdqv->vintfs, cmdqv->num_vintfs); -if (!cmdqv->vintfs) +if (!cmdqv->vintfs) { + ret = -ENOMEM ; goto iounmap; + }ida_init (&cmdqv->vintf_ids);
@@ -1016,24 +1027,23 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res,#endif /* Provide init-level ops only, until tegra241_cmdqv_init_structures */ - new_smmu->impl_ops = &init_ops; + cmdqv->smmu.impl_ops = &init_ops; -return new_smmu; +return 0 ; free_vintfs:ida_destroy (&cmdqv->vintf_ids);kfree (cmdqv->vintfs); iounmap:iounmap (base); -return NULL ; +return ret; }struct arm_smmu_device *tegra241_cmdqv_probe (struct arm_smmu_device *smmu) {struct platform_device *pdev =to_platform_device (smmu->impl_dev); -struct arm_smmu_device *new_smmu;struct resource *res; -int irq; +int irq, ret; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!res) {
@@ -1046,15 +1056,15 @@ struct arm_smmu_device *tegra241_cmdqv_probe(struct arm_smmu_device *smmu)dev_warn (&pdev->dev,"no interrupt. errors will not be reported\n" ); - new_smmu =__tegra241_cmdqv_probe (smmu, res, irq); -if (new_smmu) -return new_smmu; + ret =__tegra241_cmdqv_probe (&smmu, res, irq); +if (!ret) +return smmu; out_fallback:dev_info (smmu->impl_dev,"Falling back to standard SMMU CMDQ\n" ); smmu->options &= ~ARM_SMMU_OPT_TEGRA241_CMDQV ;put_device (smmu->impl_dev); -return ERR_PTR (-ENODEV ); +return smmu; }/* User space VINTF and VCMDQ Functions */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 706/1815 iommu/tegra241-cmdqv: Free the error IRQ before tearing down VINTFs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit 61f0d437988e5730b04442f6a7d30a9907339f2a ]
tegra241_cmdqv_remove() tears each VINTF down first, then calls free_irq(). Tearing a VINTF down frees vintf0 and clears cmdqv->vintfs[0]. An error in that window makes tegra241_cmdqv_isr() read the stale slot and hand it to tegra241_vintf0_handle_error(), which dereferences a NULL or freed pointer.
Free the IRQ before tearing the VINTFs down. free_irq() waits for in-flight handlers to finish and blocks new ones, so no ISR can observe a VINTF as it is torn down.
Note: a user-owned VINTF (viommu) could outlive this teardown, which unmaps cmdqv->base and frees cmdqv->vintfs, so a later viommu close then touches freed memory. This is neither introduced nor fixed here: a physical IOMMU is not a pluggable device, so iommufd by design holds no reference on the one behind a viommu, and this teardown is not expected while that viommu is still alive.
--- drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +8 -2
@@ -832,6 +832,14 @@ static void tegra241_cmdqv_remove(struct arm_smmu_device *smmu) container_of(smmu, struct tegra241_cmdqv, smmu);u16 idx; +/* +* Free the IRQ before tearing down the VINTFs. free_irq() waits for any +* in-flight tegra241_cmdqv_isr() to finish and blocks new ones, so the +* ISR cannot dereference a VINTF that is freed by the loop below. +*/ +if (cmdqv->irq >0 ) +free_irq (cmdqv->irq, cmdqv); +/* Remove VINTF resources */ for (idx =0 ; idx < cmdqv->num_vintfs; idx++) {if (cmdqv->vintfs[idx]) {
@@ -844,8 +852,6 @@ static void tegra241_cmdqv_remove(struct arm_smmu_device *smmu)/* Remove cmdqv resources */ ida_destroy (&cmdqv->vintf_ids); -if (cmdqv->irq >0 ) -free_irq (cmdqv->irq, cmdqv);iounmap (cmdqv->base);kfree (cmdqv->vintfs);put_device (cmdqv->dev);/* smmu->impl_dev */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 707/1815 iommu/tegra241-cmdqv: Require exactly one Stream ID for a vSID
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit fb292bfc9be936dade7eef7ec5762de1201983d8 ]
tegra241_vintf_init_vsid() maps a guest vSID to a single physical Stream ID taken from master->streams[0], and only warns when the device does not have exactly one stream. A device with several streams gets only its first one mapped, so a guest vSID invalidation cannot reach the others' ATC and IOTLB entries; a device with none makes master->streams a ZERO_SIZE_PTR, read out of bounds.
Reject the mapping with -EOPNOTSUPP if master->num_streams is not one.
--- drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +2 -1
@@ -1252,7 +1252,8 @@ static int tegra241_vintf_init_vsid(struct iommufd_vdevice *vdev)if (virt_sid >FIELD_MAX (VINTF_SID_MATCH_VIRT_SID ))return -EINVAL ; -WARN_ON_ONCE (master->num_streams !=1 ); +if (master->num_streams !=1 ) +return -EOPNOTSUPP ;/* Find an empty pair of SID_REPLACE and SID_MATCH */ sidx = ida_alloc_max(&vintf->sids, vintf->cmdqv->num_sids_per_vintf - 1,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 708/1815 iommu/tegra241-cmdqv: Fix VINTF0 leak on the init-failure path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit f40f3144477314b489e4bc209c06cb51679fe82b ]
tegra241_cmdqv_init_structures() allocates VINTF0 with kzalloc_obj(), inits it, and preallocates its logical VCMDQs. Two of its error paths leak.
When tegra241_cmdqv_init_vintf() fails it returns before VINTF0 reaches the cmdqv->vintfs[] array, so the devres unwind on probe failure cannot reach it; free it directly there.
A later VCMDQ preallocation failure instead leaves VINTF0 published, and so this time the unwind does reach tegra241_cmdqv_remove_vintf(), which then frees it from vintf->hyp_own. But tegra241_vintf_hw_init() sets that flag only afterward, from a HW read-back, so the still-uninited VINTF0 reads as guest-owned and leaks, with mutex_destroy() and ida_destroy() run on fields it never set up.
Decide ownership from vintf->idx instead, the index assigned when its id is
allocated: idx 0 is the kernel-owned VINTF0, while idx >= 1 marks a guest VINTF. So the in-kernel free decision in tegra241_cmdqv_remove_vintf() and tegra241_vintf_free_lvcmdq() now keys on idx too, and hyp_own stays a pure HW-readback state.
--- drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +8 -2
@@ -708,7 +708,7 @@ static void tegra241_vintf_free_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)dev_dbg (vintf->cmdqv->dev,"%sdeallocated\n" ,lvcmdq_error_header (vcmdq, header,64 ));/* Guest-owned VCMDQ is free-ed with hw_queue by iommufd core */ -if (vcmdq->vintf->hyp_own) +if (!vcmdq->vintf->idx)kfree (vcmdq); }
@@ -806,7 +806,7 @@ static void tegra241_cmdqv_remove_vintf(struct tegra241_cmdqv *cmdqv, u16 idx)dev_dbg (cmdqv->dev,"VINTF%u: deallocated\n" , vintf->idx);tegra241_cmdqv_deinit_vintf (cmdqv, idx); -if (!vintf->hyp_own) { +if (vintf->idx) {mutex_destroy (&vintf->lvcmdq_mutex);ida_destroy (&vintf->sids);/* Guest-owned VINTF is free-ed with viommu by iommufd core */
@@ -923,6 +923,12 @@ static int tegra241_cmdqv_init_structures(struct arm_smmu_device *smmu) ret =tegra241_cmdqv_init_vintf (cmdqv,0 , vintf);if (ret) {dev_err (cmdqv->dev,"failed to init vintf0: %d\n" , ret); +/* +* tegra241_cmdqv_init_vintf() failed to publish the vintf0 to +* cmdqv->vintfs[], so the probe unwind path that goes through +* cmdqv->vintfs[] would miss it. Free it here. +*/ +kfree (vintf);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 709/1815 RDMA/rxe: Fix UAF in ODP init error-handling path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peiyang He <[email protected]>
[ Upstream commit 51f2c8d2c99fc1f452f7113c08a35edcc4bf8732 ]
rxe_odp_mr_init_user() stores &umem_odp->umem in mr->umem before calling rxe_odp_init_pages(). If rxe_odp_init_pages() fails, rxe_odp_mr_init_user() releases umem_odp and returns an error.
rxe_reg_user_mr() then unwinds the error through rxe_cleanup(), rxe_mr_cleanup(), ib_umem_release(mr->umem). There is an IS_ERR_OR_NULL(umem) check at the start of ib_umem_release(). But since mr->umem is NOT reset to NULL in the error handling path of rxe_odp_mr_init_user(), the check passes and it reads already-freed fields like umem->is_dmabuf, causing UAF.
Fix the UAF by clearing mr->umem after releasing the failed ODP umem so the MR cleanup path does not release it again.
--- drivers/infiniband/sw/rxe/rxe_odp.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/sw/rxe/rxe_odp.c +1 -0
@@ -114,6 +114,7 @@ int rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, err =rxe_odp_init_pages (mr);if (err) {ib_umem_odp_release (umem_odp); + mr->umem =NULL ;return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 710/1815 RDMA/efa: Fix PBL chunk length computation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonatan Nachum <[email protected]>
[ Upstream commit 229b42d7450c1cf96f45ec39ebb69211b06bc036 ]
On register MR, when creating the PBL, if it's an indirect PBL we create a chunk list to hold the PBL pages pointers. Each chunk is 4KB in size and can hold 510 addresses (EFA_PTRS_PER_CHUNK) and has a 12-byte control buffer at the end of it holding the next chunk's pointer and its length.
If the PBL number of pages is a multiple of EFA_PTRS_PER_CHUNK, the calculated last chunk length is wrongly computed as 0, even though that chunk is fully populated with 510 real page pointers. This wrong length is used both to DMA map the chunk and is propagated to the device, causing the device to see the chunk as empty and reject the memory registration.
Fix the calculation so it will be performed only if the number of pages isn't a multiple of EFA_PTRS_PER_CHUNK, if it is, its already handled in the above loop correctly.
Also prevent out-of-bounds reach in the chunks array in such scenario.
--- drivers/infiniband/hw/efa/efa_verbs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/infiniband/hw/efa/efa_verbs.c +9 -4
@@ -1345,9 +1345,11 @@ static int pbl_chunk_list_create(struct efa_dev *dev, struct pbl_context *pbl) chunk_list->chunks[i].length =EFA_CHUNK_USED_SIZE ; } - chunk_list->chunks[chunk_list_size -1 ].length = - ((page_cnt %EFA_PTRS_PER_CHUNK ) *EFA_CHUNK_PAYLOAD_PTR_SIZE ) + -EFA_CHUNK_PTR_SIZE ; + +if (page_cnt %EFA_PTRS_PER_CHUNK !=0 ) + chunk_list->chunks[chunk_list_size -1 ].length = + ((page_cnt %EFA_PTRS_PER_CHUNK ) *EFA_CHUNK_PAYLOAD_PTR_SIZE ) + +EFA_CHUNK_PTR_SIZE ;/* fill the dma addresses of sg list pages to chunks: */ chunk_idx =0 ;
@@ -1359,9 +1361,12 @@ static int pbl_chunk_list_create(struct efa_dev *dev, struct pbl_context *pbl)rdma_block_iter_dma_address (&biter);if (payload_idx ==EFA_PTRS_PER_CHUNK ) { + payload_idx =0 ; chunk_idx++; +if (chunk_idx >= chunk_list_size) +break ; + cur_chunk_buf = chunk_list->chunks[chunk_idx].buf; - payload_idx =0 ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 711/1815 media: stm32: dcmi: fix error handling on MDMA pool alloc failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
[ Upstream commit 1bc5946763067d5b8dde2e5c11d7a7ddb89c8937 ]
Properly return an error if of_gen_pool_get or gen_pool_dma_zalloc fails during the chained DMA probing.
--- drivers/media/platform/st/stm32/stm32-dcmi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/st/stm32/stm32-dcmi.c +2 -0
@@ -2050,6 +2050,7 @@ static int dcmi_probe(struct platform_device *pdev) dcmi->sram_pool =of_gen_pool_get (pdev->dev.of_node,"sram" ,0 );if (!dcmi->sram_pool) {dev_info (&pdev->dev,"No SRAM pool, can't use MDMA chaining\n" ); + ret = -ENOMEM ; goto err_dma_slave_config; }
@@ -2061,6 +2062,7 @@ static int dcmi_probe(struct platform_device *pdev) &dcmi->sram_dma_buf);if (!dcmi->sram_buf) {dev_err (dcmi->dev,"Failed to allocate from SRAM\n" ); + ret = -ENOMEM ; goto err_dma_slave_config; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 712/1815 wifi: mac80211: fix per-STA profile length in cross-link CSA parsing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit 4a0bd262df757b25fc4e2a53c947317c119ced4e ]
ieee80211_mgd_check_cross_link_csa() starts parsing elements after the fixed per-STA profile header and the STA Info field, but subtracts only the STA Info length from the profile length. As a result, ieee802_11_parse_elems() is given sizeof(*prof) == 3 bytes beyond the current profile's element area, and data following the profile may be interpreted as belonging to it.
Subtract the fixed profile header as well. The preceding ieee80211_mle_basic_sta_prof_size_ok() check guarantees that the corrected calculation cannot underflow, and ieee80211_rx_uhr_link_reconfig_req() uses the same calculation.
The call site currently states that cross-link CSA parsing has no effect because the broader parsing is still incorrect. This patch does not address that broader problem; it only makes the per-STA profile parser stop at the end of that profile. No production allocation over-read or user-visible failure has been demonstrated.
--- net/mac80211/mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mlme.c +1 -1
@@ -7977,7 +7977,7 @@ ieee80211_mgd_check_cross_link_csa(struct ieee80211_sub_if_data *sdata, prof = (void *)sta_profiles[link_id]; prof_elems = ieee802_11_parse_elems(prof->variable + (prof->sta_info_len - 1), - len - + len - sizeof(*prof) - (prof->sta_info_len - 1), IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 713/1815 arm64: dts: allwinner: sun50i-a64-pinephone: Fix mpu6050 mount matrix
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Jirman <[email protected]>
[ Upstream commit dfc735fd93e4814e65894916ec5f807f25a391d1 ]
The current mount matrix for mpu6050 is wrong. The mount matrix is a simple transform from the sensor coordinate space to the device coordinate space described in DT, where, looking at the screen, X points to the right, Y to the top, and Z towards the user.
The mpu6050 is mounted like this (looking at the screen from the front; the sensor is on the near side of the PCB, so its Z axis points towards the user; o marks the pin 1 corner):
+Xs
^
|
+------+
+Ys <--| |
| o |
+------+so this gives:
Xd = -Ys [0, -1, 0] Yd = Xs [1, 0, 0] Zd = Zs [0, 0, 1]
--- arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +2 -2
@@ -230,8 +230,8 @@ accelerometer@68 { interrupts = <7 5 IRQ_TYPE_EDGE_RISING>; /* PH5 */ vdd-supply = <®_dldo1>; vddio-supply = <®_dldo1>; - mount-matrix = "0", "1", "0", - "-1", "0", "0", + mount-matrix = "0", "-1", "0", + "1", "0", "0", "0", "0", "1"; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 714/1815 clk: tegra: tegra124-emc: put EMC node on register failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit f726279f5eab813f9a8b6f38ddf2a4b062d038ff ]
tegra124_clk_register_emc() stores a device node reference returned by of_parse_phandle() in tegra->emc_node.
If clk_register() fails, the function returns an error before that reference can be consumed and released by the normal runtime path. The tegra_clk_emc object is freed on this failure path, but freeing the object does not drop the OF node reference stored in it.
Drop the EMC node reference before freeing the tegra_clk_emc object. of_node_put() is safe for a NULL node, so this also covers the case where the phandle is absent.
--- drivers/clk/tegra/clk-tegra124-emc.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/tegra/clk-tegra124-emc.c +1 -0
@@ -537,6 +537,7 @@ struct clk *tegra124_clk_register_emc(void __iomem *base, struct device_node *np clk =clk_register (NULL , &tegra->hw);if (IS_ERR (clk)) { +of_node_put (tegra->emc_node);kfree (tegra);return clk; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 715/1815 clk: mediatek: pllfh: Fix IO remapping leak in register_pllfhs error path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis-Alexis Eyraud <[email protected]>
[ Upstream commit 540d91480bcb1b28a62d7023aa70947ea44c55b9 ]
When mtk_clk_register_pllfhs function fails to register a PLL, it unregisters all PLLs and cleans up itself in its error path before returning, so the function callers don't need to do it.
But contrary to mtk_clk_unregister_pllfhs function, that does almost the same sequence, it does not free the IO memory mapped on fhctl node, leading to a leak.
Fix this leak by factorizing the cleanup sequence in a new private function and use it both mtk_clk_register_pllfhs and mtk_clk_unregister_pllfhs functions.
Also, change the loop index start value to avoid the -1 operation on index at each loop.
--- drivers/clk/mediatek/clk-pllfh.c | 98 ++++++++++++++++---------------- 1 file changed, 49 insertions(+), 49 deletions(-)
drivers/clk/mediatek/clk-pllfh.c +49 -49
@@ -197,12 +197,56 @@ static void mtk_clk_unregister_pllfh(struct clk_hw *hw)kfree (fh); } +static void mtk_clk_cleanup_pllfhs (void __iomem *iomem_base, +const struct mtk_pll_data *plls,int num_plls, +void __iomem *iomem_fhctl_base, +struct mtk_pllfh_data *pllfhs,int num_fhs, +struct clk_hw_onecell_data *clk_data) +{ +void __iomem *base = iomem_base; +void __iomem *fhctl_base = iomem_fhctl_base; +int i; + +for (i = num_plls -1 ; i >=0 ; i--) { +const struct mtk_pll_data *pll = &plls[i]; +struct mtk_pllfh_data *pllfh; +bool use_fhctl; + +if (IS_ERR_OR_NULL (clk_data->hws[pll->id])) +continue ; + + pllfh =get_pllfh_by_id (pllfhs, num_fhs, pll->id); + use_fhctl =fhctl_is_supported_and_enabled (pllfh); + +if (!base) + base =mtk_clk_pll_get_base (clk_data->hws[pll->id], + pll); + +if (use_fhctl) { +if (!fhctl_base) + fhctl_base = pllfh->state.base; +mtk_clk_unregister_pllfh (clk_data->hws[pll->id]); + }else { +mtk_clk_unregister_pll (clk_data->hws[pll->id]); + } + + clk_data->hws[pll->id] =ERR_PTR (-ENOENT ); + } + +if (fhctl_base) +iounmap (fhctl_base); + +if (base) +iounmap (base); +} + +int mtk_clk_register_pllfhs (struct device *dev,const struct mtk_pll_data *plls,int num_plls,struct mtk_pllfh_data *pllfhs,int num_fhs,struct clk_hw_onecell_data *clk_data) { -void __iomem *base; +void __iomem *base, *fhctl_base =NULL ;int i;struct clk_hw *hw;
@@ -238,24 +282,8 @@ int mtk_clk_register_pllfhs(struct device *dev,return 0 ; err: -while (--i >=0 ) { -const struct mtk_pll_data *pll = &plls[i]; -struct mtk_pllfh_data *pllfh; -bool use_fhctl; - - pllfh =get_pllfh_by_id (pllfhs, num_fhs, pll->id); - use_fhctl =fhctl_is_supported_and_enabled (pllfh); - -if (use_fhctl) -mtk_clk_unregister_pllfh (clk_data->hws[pll->id]); -else -mtk_clk_unregister_pll (clk_data->hws[pll->id]); - - clk_data->hws[pll->id] =ERR_PTR (-ENOENT ); - } - -iounmap (base); - +mtk_clk_cleanup_pllfhs (base, plls, i, fhctl_base, pllfhs, num_fhs, + clk_data);return PTR_ERR (hw); }EXPORT_SYMBOL_GPL (mtk_clk_register_pllfhs);
@@ -264,38 +292,10 @@ void mtk_clk_unregister_pllfhs(const struct mtk_pll_data *plls, int num_plls, struct mtk_pllfh_data *pllfhs, int num_fhs, struct clk_hw_onecell_data *clk_data) { - void __iomem *base = NULL, *fhctl_base = NULL; -int i; - if (!clk_data) return; -for (i = num_plls; i >0 ; i--) { -const struct mtk_pll_data *pll = &plls[i -1 ]; -struct mtk_pllfh_data *pllfh; -bool use_fhctl; - -if (IS_ERR_OR_NULL (clk_data->hws[pll->id])) -continue ; - - pllfh =get_pllfh_by_id (pllfhs, num_fhs, pll->id); - use_fhctl =fhctl_is_supported_and_enabled (pllfh); - -if (use_fhctl) { - fhctl_base = pllfh->state.base; -mtk_clk_unregister_pllfh (clk_data->hws[pll->id]); - }else { - base =mtk_clk_pll_get_base (clk_data->hws[pll->id], - pll); -mtk_clk_unregister_pll (clk_data->hws[pll->id]); - } - - clk_data->hws[pll->id] =ERR_PTR (-ENOENT ); - } - -if (fhctl_base) -iounmap (fhctl_base); - -iounmap (base); +mtk_clk_cleanup_pllfhs (NULL ,plls ,num_plls ,NULL ,pllfhs , +num_fhs ,clk_data ); }EXPORT_SYMBOL_GPL (mtk_clk_unregister_pllfhs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 716/1815 clk: eswin: Zero-initialize stack-allocated clk_init_data
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kostas Damaskinakis <[email protected]>
[ Upstream commit 011d8de504bc84402aabc1dda1cf0552fe9a5af2 ]
eswin_clk_register_pll() and eswin_register_clkdiv() declare a struct clk_init_data on the stack and only initialize some of its fields (parent_data respectively parent_hws). clk_core_populate_parent_map() checks parent_names first and parent_data second before falling back to parent_hws, so leftover stack garbage in the uninitialized fields hijacks parent resolution and the clk core dereferences a bogus pointer:
Unable to handle kernel NULL pointer dereference at virtual address 000000000000000c Oops [#1] epc : __clk_register+0x31a/0x7f0 [<ffffffff805dc774>] __clk_register+0x31a/0x7f0 [<ffffffff805dcd76>] devm_clk_hw_register+0x2a/0x94 [<ffffffff805e319a>] eswin_register_clkdiv+0x80/0xd0 [<ffffffff805e34a0>] eswin_clk_register_clks+0x162/0x1a0 [<ffffffff805e3736>] eic7700_clk_probe+0x146/0x180 [<ffffffff8065d23c>] platform_probe+0x3c/0x7a
Observed on EIC7700 hardware (with the driver backported to a 6.17 tree); whether the bug triggers depends entirely on what the stack happens to contain when the registration helpers run.
Zero-initialize both structures.
--- drivers/clk/eswin/clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/eswin/clk.c +2 -2
@@ -204,7 +204,7 @@ int eswin_clk_register_pll(struct device *dev, struct eswin_pll_clock *clks, int nums, struct eswin_clock_data *data) { struct eswin_clk_pll *p_clk = NULL; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_hw *clk_hw;int i, ret;
@@ -419,7 +419,7 @@ struct clk_hw *eswin_register_clkdiv(struct device *dev, unsigned int id, unsigned long priv_flag, spinlock_t *lock) { struct eswin_divider_clock *dclk; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_hw *clk_hw;int ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 717/1815 clk: palmas: Manage external-control prepare with devm
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit ccda84fcbf3a972973f772384935928f41817b3a ]
palmas_clks_init_configure() prepares the clock when an external control pin is configured. The current driver only drops that prepare reference when external control configuration fails.
If provider registration fails after that point, or if the driver is later removed, the prepare reference remains held.
Register a device-managed action after clk_prepare() succeeds. This balances the prepare reference on subsequent probe failure and driver removal.
--- drivers/clk/clk-palmas.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/clk/clk-palmas.c +13 -1
@@ -194,6 +194,13 @@ static void palmas_clks_get_clk_data(struct platform_device *pdev, cinfo->ext_control_pin = prop; } +static void palmas_clks_unprepare_ext_control (void *data) +{ +struct palmas_clock_info *cinfo = data; + +clk_unprepare (cinfo->hw.clk); +} +static int palmas_clks_init_configure (struct palmas_clock_info *cinfo) {int ret;
@@ -214,13 +221,18 @@ static int palmas_clks_init_configure(struct palmas_clock_info *cinfo)return ret; } + ret =devm_add_action_or_reset (cinfo->dev, + palmas_clks_unprepare_ext_control, + cinfo); +if (ret) +return ret; + ret =palmas_ext_control_req_config (cinfo->palmas, cinfo->clk_desc->sleep_reqstr_id, cinfo->ext_control_pin, true);if (ret <0 ) {dev_err (cinfo->dev,"Ext config for %s failed, %d\n" , cinfo->clk_desc->clk_name, ret); -clk_unprepare (cinfo->hw.clk);return ret; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 718/1815 clk/x86: pmc_atom: add kasprintf return value check
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: longlong yan <[email protected]>
[ Upstream commit 18e9d14cbac33db1c1fb933c26a736eef53dd538 ]
The kasprintf() function returns NULL on memory allocation failure, but the code in plt_clk_register() was not checking this return value. If kasprintf fails, init.name would be NULL and could cause NULL pointer dereference when clkdev_hw_create() uses it.
Add proper error checking for the kasprintf() return value and return ERR_PTR(-ENOMEM) on failure.
--- drivers/clk/x86/clk-pmc-atom.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/x86/clk-pmc-atom.c +3 -0
@@ -160,6 +160,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,return ERR_PTR (-ENOMEM ); init.name =kasprintf (GFP_KERNEL ,"%s_%d" ,PLT_CLK_NAME_BASE , id); +if (!init.name) +return ERR_PTR (-ENOMEM ); + init.ops = &plt_clk_ops; init.flags =0 ; init.parent_names = parent_names;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 719/1815 clk: mediatek: mt8135: Fix inverted gate control for devapc_ck
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akari Tsuyukusa <[email protected]>
[ Upstream commit fd0e3e4edea6a3e4da91be608ca2fb9b348f9e32 ]
The devapc_ck (CLK_INFRA_DEVAPC) on MT8135 is currently using "mtk_clk_gate_ops_setclr". However, checking the downstream kernel reveals that this clock is configured with set:enable and clr:disable making "mtk_clk_gate_ops_setclr_inv" the appropriate choice.
But, it is strange that some downstream kernels are not like that.
Amazon: INV
ChromiumOS (early): not INV
ChromiumOS 3.16 to 3.18-revew-v2: INV
ChromiumOS 3.18-review-v3 and later (sent to kernel.org): not INV
--- drivers/clk/mediatek/clk-mt8135.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-mt8135.c +4 -1
@@ -409,6 +409,9 @@ static const struct mtk_gate_regs infra_cg_regs = {GATE_MTK_FLAGS (_id, _name, _parent, &infra_cg_regs, _shift, \ &mtk_clk_gate_ops_setclr, CLK_IS_CRITICAL) +#define GATE_ICG_INV (_id, _name, _parent, _shift) \ + GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) +static const struct mtk_gate infra_clks[] = {GATE_DUMMY (CLK_DUMMY ,"infra_dummy" ),GATE_ICG (CLK_INFRA_PMIC_WRAP ,"pmic_wrap_ck" ,"axi_sel" ,23 ),
@@ -419,7 +422,7 @@ static const struct mtk_gate infra_clks[] = {GATE_ICG (CLK_INFRA_CPUM ,"cpum_ck" ,"cpum_tck_in" ,15 ),GATE_ICG_AO (CLK_INFRA_M4U ,"m4u_ck" ,"mem_sel" ,8 ),GATE_ICG (CLK_INFRA_MFGAXI ,"mfgaxi_ck" ,"axi_sel" ,7 ), -GATE_ICG (CLK_INFRA_DEVAPC ,"devapc_ck" ,"axi_sel" ,6 ), +GATE_ICG_INV (CLK_INFRA_DEVAPC ,"devapc_ck" ,"axi_sel" ,6 ),GATE_ICG (CLK_INFRA_AUDIO ,"audio_ck" ,"aud_intbus_sel" ,5 ),GATE_ICG (CLK_INFRA_MFG_BUS ,"mfg_bus_ck" ,"axi_sel" ,2 ), GATE_ICG(CLK_INFRA_SMI, "smi_ck", "smi_sel", 1),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 720/1815 PCI: Make pci_match_one_device() match on ID instead of device
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit c967b365d7b51c2297d9be5df39ac3e20638faf4 ]
PCI dynamic ID needs to match IDs against a new ID to see if it already exists. Existing APIs can only match IDs against devices, so the dynamic ID insertion code creates a temporary device only for matching purposes. Rename pci_match_one_device() to pci_match_one_id() so it can be used for this purpose instead; add a pci_id_from_device() helper to make it easy to convert users.
Similarly, convert pci_match_id() to do_pci_match_id(). But keep the existing API because there are many users.
Stable-dep-of: 04fde70f782b ("PCI: Fix dyn_id add TOCTOU")
--- drivers/pci/pci-driver.c | 38 +++++++++++++++++++++++++---------- drivers/pci/pci.h | 43 +++++++++++++++++++++++++++++----------- drivers/pci/search.c | 8 +++++--- 3 files changed, 64 insertions(+), 25 deletions(-)
drivers/pci/pci-driver.c +28 -10
@@ -90,6 +90,27 @@ static void pci_free_dynids(struct pci_driver *drv)spin_unlock (&drv->dynids.lock); } +/** +* do_pci_match_id - See if a PCI ID matches a given pci_id table +* @ids: array of PCI device ID structures to search in +* @dev_id: the actual PCI device ID structure to match against. +* +* Return: the matching pci_device_id structure or %NULL if there is no match. +*/ +static const struct pci_device_id * +do_pci_match_id (const struct pci_device_id *ids, +const struct pci_device_id *dev_id) +{ +if (ids) { +while (ids->vendor || ids->subvendor || ids->class_mask) { +if (pci_match_one_id (ids, dev_id)) +return ids; + ids++; + } + } +return NULL ; +} +/** * pci_match_id - See if a PCI device matches a given pci_id table * @ids: array of PCI device ID structures to search in
@@ -105,14 +126,9 @@ static void pci_free_dynids(struct pci_driver *drv)const struct pci_device_id *pci_match_id (const struct pci_device_id *ids,struct pci_dev *dev) { -if (ids) { -while (ids->vendor || ids->subvendor || ids->class_mask) { -if (pci_match_one_device (ids, dev)) -return ids; - ids++; - } - } -return NULL ; +struct pci_device_id dev_id =pci_id_from_device (dev); + +return do_pci_match_id (ids, &dev_id); }EXPORT_SYMBOL (pci_match_id);
@@ -138,6 +154,7 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv, {struct pci_dynid *dynid;const struct pci_device_id *found_id =NULL , *ids; +struct pci_device_id dev_id;int ret;/* When driver_override is set, only bind to the matching driver */
@@ -145,10 +162,11 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,if (ret ==0 )return NULL ; + dev_id =pci_id_from_device (dev);/* Look at the dynamic ids first, before the static ones */ spin_lock (&drv->dynids.lock);list_for_each_entry (dynid, &drv->dynids.list, node) { -if (pci_match_one_device (&dynid->id, dev)) { +if (pci_match_one_id (&dynid->id, &dev_id)) { found_id = &dynid->id;break ; }
@@ -158,7 +176,7 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,if (found_id)return found_id; -for (ids = drv->id_table; (found_id =pci_match_id (ids, dev)); +for (ids = drv->id_table; (found_id =do_pci_match_id (ids, &dev_id)); ids = found_id +1 ) {/* * The match table is split based on driver_override.
drivers/pci/pci.h +31 -12
52 lines not on this page · raw message
drivers/pci/search.c +5 -3
@@ -245,8 +245,10 @@ static int match_pci_dev_by_id(struct device *dev, const void *data) {struct pci_dev *pdev =to_pci_dev (dev);const struct pci_device_id *id = data; +struct pci_device_id dev_id; -if (pci_match_one_device (id, pdev)) + dev_id =pci_id_from_device (pdev); +if (pci_match_one_id (id, &dev_id))return 1 ;return 0 ; }
@@ -416,9 +418,9 @@ EXPORT_SYMBOL(pci_get_class);* @class: search for a PCI device with this base class code * @from: Previous PCI device found in search, or %NULL for new search. * -* Iterates through the list of known PCI devices. If a PCI device is found +* Iterate through the list of known PCI devices. If a PCI device is found * with a matching base class code, the reference count to the device is -* incremented. See pci_match_one_device() to figure out how does this works. +* incremented. See pci_match_one_id() to figure out how this works. * A new search is initiated by passing %NULL as the @from argument. * Otherwise if @from is not %NULL, searches continue from next device on the * global list. The reference count for @from is always decremented if it is
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 721/1815 PCI: Fix dyn_id add TOCTOU
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit 04fde70f782b6ce984f9f80c2023786caea28287 ]
Currently there is a TOCTOU issue in new_id_store() as the dyn ID insertion in pci_add_dynid() and the pci_match_device() are in separate critical sections.
Fix this by moving the existing ID check to inside pci_add_dynid() and only check against the static ID table outside the critical section.
--- drivers/pci/pci-driver.c | 140 ++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 68 deletions(-)
drivers/pci/pci-driver.c +72 -68
@@ -29,6 +29,47 @@ struct pci_dynid {struct pci_device_id id; }; +/** +* do_pci_add_dynid - Add a new PCI device ID to this driver and re-probe +* @drv: target PCI driver +* @id: ID to be added +* @check_dup: whether to check if matching ID is already present +* +* Add a new dynamic PCI device ID to this driver and causes the driver to +* probe for all devices again. @drv must have been registered prior to calling +* this function. +* +* Context: Does GFP_KERNEL allocation. +* +* Return: 0 on success, -errno on failure. +*/ +static int do_pci_add_dynid (struct pci_driver *drv, +const struct pci_device_id *id, +bool check_dup) +{ +struct pci_dynid *dynid, *existing_dynid; + + dynid =kzalloc_obj (*dynid); +if (!dynid) +return -ENOMEM ; + + dynid->id = *id; + + scoped_guard(spinlock, &drv->dynids.lock) { +if (check_dup) { +list_for_each_entry (existing_dynid, &drv->dynids.list, node) { +if (pci_match_one_id (&existing_dynid->id, id)) { +kfree (dynid); +return -EEXIST ; + } + } + } +list_add_tail (&dynid->node, &drv->dynids.list); + } + +return driver_attach (&drv->driver); +} +/** * pci_add_dynid - add a new PCI device ID to this driver and re-probe devices * @drv: target pci driver
@@ -56,25 +97,17 @@ int pci_add_dynid(struct pci_driver *drv, unsigned int class, unsigned int class_mask, unsigned long driver_data) { - struct pci_dynid *dynid; - - dynid =kzalloc_obj (*dynid); -if (!dynid) -return -ENOMEM ; + struct pci_device_id id = { + .vendor = vendor, + .device = device, + .subvendor = subvendor, + .subdevice = subdevice, + .class = class, + .class_mask = class_mask, + .driver_data = driver_data, + }; - dynid->id.vendor = vendor; - dynid->id.device = device; - dynid->id.subvendor = subvendor; - dynid->id.subdevice = subdevice; - dynid->id.class = class; - dynid->id.class_mask = class_mask; - dynid->id.driver_data = driver_data; - -spin_lock (&drv->dynids.lock); -list_add_tail (&dynid->node, &drv->dynids.list); -spin_unlock (&drv->dynids.lock); - -return driver_attach (&drv->driver); +return do_pci_add_dynid (drv, &id, false); }EXPORT_SYMBOL_GPL (pci_add_dynid);
@@ -94,16 +127,20 @@ static void pci_free_dynids(struct pci_driver *drv)* do_pci_match_id - See if a PCI ID matches a given pci_id table * @ids: array of PCI device ID structures to search in * @dev_id: the actual PCI device ID structure to match against. +* @include_override_only: also match against device ID entries marked as +* override only. * * Return: the matching pci_device_id structure or %NULL if there is no match. */ static const struct pci_device_id *do_pci_match_id (const struct pci_device_id *ids, -const struct pci_device_id *dev_id) +const struct pci_device_id *dev_id, +bool include_override_only) {if (ids) {while (ids->vendor || ids->subvendor || ids->class_mask) { -if (pci_match_one_id (ids, dev_id)) +if ((!ids->override_only || include_override_only) && +pci_match_one_id (ids, dev_id))return ids; ids++; }
@@ -128,7 +165,7 @@ const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, {struct pci_device_id dev_id =pci_id_from_device (dev); -return do_pci_match_id (ids, &dev_id); +return do_pci_match_id (ids, &dev_id, true); }EXPORT_SYMBOL (pci_match_id);
@@ -153,7 +190,7 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv, struct pci_dev *dev) {struct pci_dynid *dynid; -const struct pci_device_id *found_id =NULL , *ids; +const struct pci_device_id *found_id =NULL ;struct pci_device_id dev_id;int ret;
@@ -176,20 +213,9 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,if (found_id)return found_id; -for (ids = drv->id_table; (found_id =do_pci_match_id (ids, &dev_id)); - ids = found_id +1 ) { -/* -* The match table is split based on driver_override. -* In case override_only was set, enforce driver_override -* matching. -*/ -if (found_id->override_only) { -if (ret >0 ) -return found_id; - }else { -return found_id; - } - } + found_id =do_pci_match_id (drv->id_table, &dev_id, ret >0 ); +if (found_id) +return found_id;/* driver_override will always match, send a dummy id */ if (ret >0 )
@@ -197,11 +223,6 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,return NULL ; } -static void _pci_free_device (struct device *dev) -{ -kfree (to_pci_dev (dev)); -} -/** * new_id_store - sysfs frontend to pci_add_dynid() * @driver: target device driver
@@ -215,38 +236,22 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf, {struct pci_driver *pdrv =to_pci_driver (driver);const struct pci_device_id *ids = pdrv->id_table; -u32 vendor, device, subvendor =PCI_ANY_ID , - subdevice =PCI_ANY_ID , class =0 , class_mask =0 ; -unsigned long driver_data =0 ; +struct pci_device_id id = { + .subvendor =PCI_ANY_ID , + .subdevice =PCI_ANY_ID + };int fields;int retval =0 ; fields =sscanf (buf,"%x %x %x %x %x %x %lx" , - &vendor, &device, &subvendor, &subdevice, - &class, &class_mask, &driver_data); + &id.vendor, &id.device, &id.subvendor, &id.subdevice, + &id.class, &id.class_mask, &id.driver_data);if (fields <2 )return -EINVAL ;if (fields !=7 ) { -struct pci_dev *pdev =kzalloc_obj (*pdev); -if (!pdev) -return -ENOMEM ; - - pdev->vendor = vendor; - pdev->device = device; - pdev->subsystem_vendor = subvendor; - pdev->subsystem_device = subdevice; - pdev->class = class; - pdev->dev.release = _pci_free_device; - -device_initialize (&pdev->dev); -if (pci_match_device (pdrv, pdev)) - retval = -EEXIST ; - -put_device (&pdev->dev); - -if (retval) -return retval; +if (do_pci_match_id (pdrv->id_table, &id, false)) +return -EEXIST ; }/* Only accept driver_data values that match an existing id_table
@@ -254,7 +259,7 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf,if (ids) { retval = -EINVAL ;while (ids->vendor || ids->subvendor || ids->class_mask) { -if (driver_data == ids->driver_data) { +if (id.driver_data == ids->driver_data) { retval =0 ;break ; }
@@ -264,8 +269,7 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf,return retval; } - retval =pci_add_dynid (pdrv, vendor, device, subvendor, subdevice, - class, class_mask, driver_data); + retval =do_pci_add_dynid (pdrv, &id, fields !=7 );if (retval)return retval;return count;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 722/1815 PCI: Fix UAF when probe runs concurrent to dyn ID removal
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit 3ffc4c9690c33ee28cdb3d0182b12f9c623e3acc ]
Dynamic IDs are only guaranteed to be valid when dynids.lock is held, as remove_id_store() can free the node. Thus, make a copy in pci_match_device(). Also, clarify that the id parameter is only valid during probe.
--- drivers/pci/pci-driver.c | 28 +++++++++++++++------------- include/linux/pci.h | 1 + 2 files changed, 16 insertions(+), 13 deletions(-)
drivers/pci/pci-driver.c +15 -13
@@ -180,6 +180,7 @@ static const struct pci_device_id pci_device_id_any = {* pci_match_device - See if a device matches a driver's list of IDs * @drv: the PCI driver to match against * @dev: the PCI device structure to match against +* @id_copy: place to store copy of pci_device_id for dynamic ID * * Used by a driver to check whether a PCI device is in its list of * supported devices or in the dynids list, which may have been augmented
@@ -187,9 +188,9 @@ static const struct pci_device_id pci_device_id_any = {* structure or %NULL if there is no match. */ static const struct pci_device_id *pci_match_device (struct pci_driver *drv, -struct pci_dev *dev) +struct pci_dev *dev, +struct pci_device_id *id_copy) { -struct pci_dynid *dynid;const struct pci_device_id *found_id =NULL ;struct pci_device_id dev_id;int ret;
@@ -201,17 +202,16 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv, dev_id =pci_id_from_device (dev);/* Look at the dynamic ids first, before the static ones */ -spin_lock (&drv->dynids.lock); -list_for_each_entry (dynid, &drv->dynids.list, node) { -if (pci_match_one_id (&dynid->id, &dev_id)) { - found_id = &dynid->id; -break ; + scoped_guard(spinlock, &drv->dynids.lock) { +struct pci_dynid *dynid; + +list_for_each_entry (dynid, &drv->dynids.list, node) { +if (pci_match_one_id (&dynid->id, &dev_id)) { + *id_copy = dynid->id; +return id_copy; + } } } -spin_unlock (&drv->dynids.lock); - -if (found_id) -return found_id; found_id =do_pci_match_id (drv->id_table, &dev_id, ret >0 );if (found_id)
@@ -467,12 +467,13 @@ void pci_probe_flush_workqueue(void)static int __pci_device_probe (struct pci_driver *drv,struct pci_dev *pci_dev) {const struct pci_device_id *id; +struct pci_device_id id_copy;int error =0 ;if (drv->probe) { error = -ENODEV ; - id =pci_match_device (drv, pci_dev); + id =pci_match_device (drv, pci_dev, &id_copy);if (id) error =pci_call_probe (drv, pci_dev, id); }
@@ -1560,12 +1561,13 @@ static int pci_bus_match(struct device *dev, const struct device_driver *drv)struct pci_dev *pci_dev =to_pci_dev (dev);struct pci_driver *pci_drv;const struct pci_device_id *found_id; +struct pci_device_id id_copy;if (pci_dev_binding_disallowed (pci_dev))return 0 ; pci_drv = (struct pci_driver *)to_pci_driver (drv); - found_id =pci_match_device (pci_drv, pci_dev); + found_id =pci_match_device (pci_drv, pci_dev, &id_copy);if (found_id)return 1 ;
include/linux/pci.h +1 -0
@@ -983,6 +983,7 @@ struct module;* function returns zero when the driver chooses to * take "ownership" of the device or an error code * (negative number) otherwise. +* The pci_device_id parameter is only valid during probe. * The probe function always gets called from process * context, so it can sleep. * @remove: The remove() function gets called whenever a device
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 723/1815 clk: rockchip: Fix the fractional part denominator on RK3588/RK3576 PLLs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Charkov <[email protected]>
[ Upstream commit 52aef653c3d0c24013dfa9eccf692594eacdbe17 ]
According to the TRM, the fractional PLL coefficient should be divided by 65536 rather than 65535 to obtain the output rate.
Fix the denominator and add a comment with the TRM provided clock formulae for future reference.
See RK3576 TRM Part 1 V1.2 section 2.13.1.4 Setting Guide on P, M, S and K or equivalently RK3588 TRM part 1 V1.0 section 2.17.1.4 Setting Guide on P, M, S and K.
Fractional PLL rates don't seem to be used by any current mainline consumers, so this is purely a correctness fix. It will also be important to properly support DisplayPort output going forward, as the video output controller derives its pixel clock from system PLLs with no dedicated PHY PLL option for DP unlike HDMI, and some display modes are only achievable with fractional PLL rates.
--- drivers/clk/rockchip/clk-pll.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clk/rockchip/clk-pll.c +8 -1
@@ -900,6 +900,13 @@ static void rockchip_rk3588_pll_get_params(struct rockchip_clk_pll *pll, rate->k = ((pllcon >>RK3588_PLLCON2_K_SHIFT ) &RK3588_PLLCON2_K_MASK ); } +/* +* 2250 MHz <= Fvco <= 4500 MHz +* For Fvco > 3 GHz: period jitter +-1% frac PLL, +-0.75% int PLL +* For Fvco < 3 GHz: period jitter +-2% frac PLL, +-1.50% int PLL +* Fvco = ((m + k / 65536) * Fin) / p +* Fout = ((m + k / 65536) * Fin) / (p * 2^s) +*/ static unsigned long rockchip_rk3588_pll_recalc_rate (struct clk_hw *hw,unsigned long prate) {struct rockchip_clk_pll *pll =to_rockchip_clk_pll (hw);
@@ -915,7 +922,7 @@ static unsigned long rockchip_rk3588_pll_recalc_rate(struct clk_hw *hw, unsigned/* fractional mode */ u64 frac_rate64 = prate * cur.k; - postdiv = cur.p *65535 ; + postdiv = cur.p *65536 ;do_div (frac_rate64, postdiv); rate64 += frac_rate64; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 724/1815 clk: rockchip: Fractional PLL coefficient on RK3588/RK3576 is twos complement
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Charkov <[email protected]>
[ Upstream commit 5814788834774ed6ad1a27ae91b44eeca80cd27f ]
When the PLL rates table was first committed for RK3588 (and later reused for RK3576), the fractional PLL coefficient was defined as an unsigned value, while the TRM clearly states that it is a two's complement 16-bit value.
Treating the fractional PLL coefficient as unsigned in rate recalculation results in a kernel-visible rate which deviates from what the hardware actually generates by Fin / (p * 2^s), or 2 MHz for the two affected table entries.
Rockchip's downstream kernel later revised the fractional PLL code [1] to account for the two's complement nature of the coefficient, but that change wasn't upstreamed.
Change the PLL table definition to use two's complement for the fractional coefficient and update its users accordingly.
Note that a negative fractional coefficient is meant to be subtracted from the next larger integer multiplier, so the m values in the table are also adjusted accordingly for the two negative-k entries.
Rockchip's downstream commit introducing the two's complement logic for k also does unrelated tweaks to the PLL parameters which are not explained by the switch to the two's complement, so they are not replicated here. If any of the parameters prove to need further tweaks (e.g. for precision or jitter) that would better be done in targeted follow-up commits.
Fractional PLL rates don't seem to be used by any current mainline consumers, so this is purely a correctness fix. It will also be important to properly support DisplayPort output going forward, as the video output controller derives its pixel clock from system PLLs with no dedicated PHY PLL option for DP unlike HDMI, and some display modes are only achievable using fractional PLL rates.
--- drivers/clk/rockchip/clk-pll.c | 7 ++++--- drivers/clk/rockchip/clk-rk3576.c | 4 ++-- drivers/clk/rockchip/clk-rk3588.c | 4 ++-- drivers/clk/rockchip/clk.h | 8 ++++---- 4 files changed, 12 insertions(+), 11 deletions(-)
drivers/clk/rockchip/clk-pll.c +4 -3
@@ -13,6 +13,7 @@#include <linux/delay.h> #include <linux/clk-provider.h> #include <linux/iopoll.h> +#include <linux/math64.h> #include <linux/regmap.h> #include <linux/clk.h> #include "clk.h"
@@ -906,6 +907,7 @@ static void rockchip_rk3588_pll_get_params(struct rockchip_clk_pll *pll,* For Fvco < 3 GHz: period jitter +-2% frac PLL, +-1.50% int PLL * Fvco = ((m + k / 65536) * Fin) / p * Fout = ((m + k / 65536) * Fin) / (p * 2^s) +* -32768 <= k <= 32767 (only available in frac PLLs, not int PLLs) */ static unsigned long rockchip_rk3588_pll_recalc_rate (struct clk_hw *hw,unsigned long prate) {
@@ -920,11 +922,10 @@ static unsigned long rockchip_rk3588_pll_recalc_rate(struct clk_hw *hw, unsignedif (cur.k) {/* fractional mode */ -u64 frac_rate64 = prate * cur.k; +s64 frac_rate64 = (s64 )prate * cur.k; postdiv = cur.p *65536 ; -do_div (frac_rate64, postdiv); - rate64 += frac_rate64; + rate64 +=div_s64 (frac_rate64, postdiv); } rate64 = rate64 >> cur.s;
drivers/clk/rockchip/clk-rk3576.c +2 -2
@@ -79,13 +79,13 @@ static struct rockchip_pll_rate_table rk3576_pll_rates[] = {RK3588_PLL_RATE (1008000000 ,2 ,336 ,2 ,0 ),RK3588_PLL_RATE (1000000000 ,3 ,500 ,2 ,0 ),RK3588_PLL_RATE (983040000 ,4 ,655 ,2 ,23592 ), -RK3588_PLL_RATE (955520000 ,3 ,477 ,2 ,49806 ), +RK3588_PLL_RATE (955520000 ,3 ,478 ,2 ,-15730 ),RK3588_PLL_RATE (903168000 ,6 ,903 ,2 ,11009 ),RK3588_PLL_RATE (900000000 ,2 ,300 ,2 ,0 ),RK3588_PLL_RATE (816000000 ,2 ,272 ,2 ,0 ),RK3588_PLL_RATE (786432000 ,2 ,262 ,2 ,9437 ),RK3588_PLL_RATE (786000000 ,1 ,131 ,2 ,0 ), -RK3588_PLL_RATE (785560000 ,3 ,392 ,2 ,51117 ), +RK3588_PLL_RATE (785560000 ,3 ,393 ,2 ,-14419 ),RK3588_PLL_RATE (722534400 ,8 ,963 ,2 ,24850 ),RK3588_PLL_RATE (600000000 ,2 ,200 ,2 ,0 ), RK3588_PLL_RATE(594000000, 2, 198, 2, 0),
drivers/clk/rockchip/clk-rk3588.c +2 -2
@@ -79,14 +79,14 @@ static struct rockchip_pll_rate_table rk3588_pll_rates[] = {RK3588_PLL_RATE (1008000000 ,2 ,336 ,2 ,0 ),RK3588_PLL_RATE (1000000000 ,3 ,500 ,2 ,0 ),RK3588_PLL_RATE (983040000 ,4 ,655 ,2 ,23592 ), -RK3588_PLL_RATE (955520000 ,3 ,477 ,2 ,49806 ), +RK3588_PLL_RATE (955520000 ,3 ,478 ,2 ,-15730 ),RK3588_PLL_RATE (903168000 ,6 ,903 ,2 ,11009 ),RK3588_PLL_RATE (900000000 ,2 ,300 ,2 ,0 ),RK3588_PLL_RATE (850000000 ,3 ,425 ,2 ,0 ),RK3588_PLL_RATE (816000000 ,2 ,272 ,2 ,0 ),RK3588_PLL_RATE (786432000 ,2 ,262 ,2 ,9437 ),RK3588_PLL_RATE (786000000 ,1 ,131 ,2 ,0 ), -RK3588_PLL_RATE (785560000 ,3 ,392 ,2 ,51117 ), +RK3588_PLL_RATE (785560000 ,3 ,393 ,2 ,-14419 ),RK3588_PLL_RATE (722534400 ,8 ,963 ,2 ,24850 ),RK3588_PLL_RATE (600000000 ,2 ,200 ,2 ,0 ), RK3588_PLL_RATE(594000000, 2, 198, 2, 0),
drivers/clk/rockchip/clk.h +4 -4
@@ -635,10 +635,10 @@ struct rockchip_pll_rate_table { };struct {/* for RK3588 */ -unsigned int m; -unsigned int p; -unsigned int s; -unsigned int k; +unsigned int m;/* main divider, 10 bit unsigned */ +unsigned int p;/* pre-divider, 6 bit unsigned */ +unsigned int s;/* scaler, 3 bit unsigned */ +s16 k;/* fractional part, 16 bit two's complement */ }; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 725/1815 nilfs2: fix infinite loop in nilfs_clean_segments()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Crofts <[email protected]>
[ Upstream commit ce5a5ad1a8330a2fcfdd9ec2ab341be739e89a18 ]
syzbot reported a hung task in nilfs_transaction_begin(). This occurs because the cleaner ioctl falls into an infinite loop if nilfs_segctor_construct() repeatedly returns -EROFS (e.g. the device is remounted as read-only after an I/O error).
Currently in nilfs_clean_segments(), if err is non-zero, it logs the error and sleeps but doesn't abort when it encounters a terminal error like -EROFS. This causes the thread to loop forever.
Fix this by breaking out of the loop if nilfs_segctor_construct() returns -EROFS. This matches the behaviour in nilfs_segctor_write_out(), which also handles -EROFS.
--- fs/nilfs2/segment.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nilfs2/segment.c +4 -0
@@ -2561,6 +2561,10 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,break ;nilfs_warn (sb,"error %d cleaning segments" , err); + +if (unlikely (err == -EROFS )) + goto out_unlock; +set_current_state (TASK_INTERRUPTIBLE );schedule_timeout (sci->sc_interval); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 726/1815 nilfs2: prevent out-of-bounds read in super root block parsing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit 7cb2f76a6a2ba2130b577cb8ac13e1e46c4fc689 ]
super-root inode metadata size is trusted before nilfs_read_inode_common().
Reject super-root inode sizes whose computed on-disk footprint exceeds the filesystem block size. This prevents malformed filesystem images from making nilfs_read_inode_common() read past the end of the super-root block.
[ryusuke: clarify the commit title]
--- fs/nilfs2/the_nilfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/nilfs2/the_nilfs.c +6 -0
@@ -461,6 +461,12 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs, nilfs->ns_inode_size);return -EINVAL ; } +if (NILFS_SR_BYTES (nilfs->ns_inode_size) > nilfs->ns_blocksize) { +nilfs_err (nilfs->ns_sb, +"too large inode size for super root: %d bytes" , + nilfs->ns_inode_size); +return -EINVAL ; + } nilfs->ns_first_ino =le32_to_cpu (sbp->s_first_ino);if (nilfs->ns_first_ino <NILFS_USER_INO ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 727/1815 nilfs2: fix BUG in nilfs_copy_dirty_pages() on dirty state mismatch
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 66f4ad3ce158902e5f98afea93189972ed8750c2 ]
Syzbot reported a kernel BUG triggered within nilfs_copy_dirty_pages(), which copies dirty DAT file folios/pages to its shadow page cache. The BUG occurs when a retrieved dirty folio/page unexpectedly loses its 'dirty' status.
This issue arises because, since the commit referenced below, the 'dirty' flag of a folio/page can be cleared asynchronously after the filesystem detects metadata corruption and transitions to read-only mode.
Resolve the issue by returning an -EROFS error if the filesystem has transitioned to read-only mode. Also change the behavior to issue a kernel warning only once instead of triggering a kernel BUG when this unexpected 'dirty' state is detected while the filesystem is not in read-only mode.
--- fs/nilfs2/page.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
fs/nilfs2/page.c +15 -2
@@ -243,6 +243,7 @@ static void nilfs_copy_folio(struct folio *dst, struct folio *src,int nilfs_copy_dirty_pages (struct address_space *dmap,struct address_space *smap) { +struct inode *smap_inode = smap->host;struct folio_batch fbatch;unsigned int i;pgoff_t index =0 ;
@@ -258,8 +259,19 @@ int nilfs_copy_dirty_pages(struct address_space *dmap,struct folio *folio = fbatch.folios[i], *dfolio;folio_lock (folio); -if (unlikely (!folio_test_dirty (folio))) -NILFS_FOLIO_BUG (folio,"inconsistent dirty state" ); +if (unlikely (!folio_test_dirty (folio))) { +if (WARN_ONCE (!sb_rdonly (smap_inode->i_sb), +"inconsistent dirty state\n" )) + goto unlock_folio; + +/* +* If the filesystem has been forced to read-only +* due to metadata corruption. +*/ +folio_unlock (folio); + err = -EROFS ; +break ; + } dfolio =filemap_grab_folio (dmap, folio->index);if (IS_ERR (dfolio)) {
@@ -277,6 +289,7 @@ int nilfs_copy_dirty_pages(struct address_space *dmap,folio_unlock (dfolio);folio_put (dfolio); +unlock_folio:folio_unlock (folio); }folio_batch_release (&fbatch);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 728/1815 scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Strahan <[email protected]>
[ Upstream commit 225548863f0a2350c6f34231ca56710c3dd1a5d5 ]
On recent Linux kernels the driver can enter a retry loop on the AIO fast path when a request is retried, looping until timeout. A diagnostic path that takes a physical drive offline on AIO-bypass failure is also never entered on affected kernels.
Register a per-command initialization callback with the SCSI core. Its presence causes the core to skip the per-dispatch clear, so the retry marker now survives across the requeue and the AIO-to-RAID fallback proceeds as intended. The driver takes over the marker's lifetime: it is zeroed at tag allocation, preserved across the retry requeue so the error path can act on it, and cleared on terminal completion so the tag starts clean on its next use.
--- drivers/scsi/smartpqi/smartpqi_init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +18 -0
@@ -66,6 +66,12 @@ static struct pqi_cmd_priv *pqi_cmd_priv(struct scsi_cmnd *cmd)return scsi_cmd_priv (cmd); } +static int pqi_init_cmd_priv (struct Scsi_Host *shost,struct scsi_cmnd *cmd) +{ +memset (pqi_cmd_priv (cmd),0 ,sizeof (struct pqi_cmd_priv )); +return 0 ; +} +static void pqi_verify_structures (void );static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info,enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);
@@ -5958,6 +5964,17 @@ void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd)struct pqi_scsi_dev *device;struct completion *wait; +/* +* Clear the AIO-retry marker on final completion so the tag +* starts clean on its next dispatch. On DID_IMM_RETRY leave +* it intact: pqi_aio_io_complete() sets DID_IMM_RETRY and +* bumps the marker to steer the requeue onto the RAID path, +* and pqi_process_raid_io_error() consumes the non-zero +* marker to offline a misbehaving drive. +*/ +if (host_byte (scmd->result) !=DID_IMM_RETRY ) +pqi_cmd_priv (scmd)->this_residual =0 ; +if (!scmd->device) {set_host_byte (scmd,DID_NO_CONNECT );return ;
@@ -7612,6 +7629,7 @@ static const struct scsi_host_template pqi_driver_template = { .sdev_groups = pqi_sdev_groups, .shost_groups = pqi_shost_groups, .cmd_size = sizeof(struct pqi_cmd_priv), + .init_cmd_priv = pqi_init_cmd_priv, };static int pqi_register_scsi (struct pqi_ctrl_info *ctrl_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 729/1815 clk: spacemit: k3: fix missing /2 factor in i2s sysclk dividers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Troy Mitchell <[email protected]>
[ Upstream commit 8a7d4b1924d2a424b1a6fe69de4f9464ee1fb485 ]
The i2s{0,2,3,4,5}_sysclk_div DDNs have an additional fixed 1/2 divider in the hardware IP after the configurable divider, so the real output rate is:
rate = parent_rate * den / (num * 2)
Set pre_div to 2 to account for it.
--- drivers/clk/spacemit/ccu-k3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clk/spacemit/ccu-k3.c +5 -5
@@ -236,11 +236,11 @@ CCU_MUX_DEFINE(i2s3_sysclk_sel, i2s_sysclk_parents, MPMU_I2S_SYSCLK_CTRL, 12, 2,CCU_MUX_DEFINE (i2s4_sysclk_sel, i2s_sysclk_parents,MPMU_I2S_SYSCLK_CTRL ,16 ,2 ,0 );CCU_MUX_DEFINE (i2s5_sysclk_sel, i2s_sysclk_parents,MPMU_I2S_SYSCLK_CTRL ,20 ,2 ,0 ); -CCU_DDN_DEFINE (i2s0_sysclk_div, i2s0_sysclk_sel,MPMU_I2S0_SYSCLK ,0 ,16 ,16 ,16 ,1 ,0 ); -CCU_DDN_DEFINE (i2s2_sysclk_div, i2s2_sysclk_sel,MPMU_I2S2_SYSCLK ,0 ,16 ,16 ,16 ,1 ,0 ); -CCU_DDN_DEFINE (i2s3_sysclk_div, i2s3_sysclk_sel,MPMU_I2S3_SYSCLK ,0 ,16 ,16 ,16 ,1 ,0 ); -CCU_DDN_DEFINE (i2s4_sysclk_div, i2s4_sysclk_sel,MPMU_I2S4_SYSCLK ,0 ,16 ,16 ,16 ,1 ,0 ); -CCU_DDN_DEFINE (i2s5_sysclk_div, i2s5_sysclk_sel,MPMU_I2S5_SYSCLK ,0 ,16 ,16 ,16 ,1 ,0 ); +CCU_DDN_DEFINE (i2s0_sysclk_div, i2s0_sysclk_sel,MPMU_I2S0_SYSCLK ,0 ,16 ,16 ,16 ,2 ,0 ); +CCU_DDN_DEFINE (i2s2_sysclk_div, i2s2_sysclk_sel,MPMU_I2S2_SYSCLK ,0 ,16 ,16 ,16 ,2 ,0 ); +CCU_DDN_DEFINE (i2s3_sysclk_div, i2s3_sysclk_sel,MPMU_I2S3_SYSCLK ,0 ,16 ,16 ,16 ,2 ,0 ); +CCU_DDN_DEFINE (i2s4_sysclk_div, i2s4_sysclk_sel,MPMU_I2S4_SYSCLK ,0 ,16 ,16 ,16 ,2 ,0 ); +CCU_DDN_DEFINE (i2s5_sysclk_div, i2s5_sysclk_sel,MPMU_I2S5_SYSCLK ,0 ,16 ,16 ,16 ,2 ,0 );static const struct clk_parent_data i2s2_sysclk_parents[] = {CCU_PARENT_HW (i2s1_sysclk),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 730/1815 riscv: dts: spacemit: Make dtschema recognize the etherent PHY correctly on K3 pico-itx board
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit 9b371a8b13fd0e8e6f3b12f4ef7e58927d6f62ee ]
Since the previous commit does not change the phy node name, the dtschema can not recognize the type of the ethernet phy, so the following error is produced:
/arch/riscv/boot/dts/spacemit/k3-pico-itx.dtb: phy@1 (ethernet-phy-id001c.c916): $nodename:0: 'phy@1' does not match '^ethernet-phy(@[a-f0-9]+)?$'
from schema $id: http://devicetree.org/schemas/net/realtek,rtl82xx.yaml
/arch/riscv/boot/dts/spacemit/k3-pico-itx.dtb: phy@1 (ethernet-phy-id001c.c916): Unevaluated properties are not allowed ('reg', 'reset-assert-us', 're set-deassert-us', 'reset-gpios' were unexpected)
from schema $id: http://devicetree.org/schemas/net/realtek,rtl82xx.yaml
Change the nodename to make the dtschema can recognize the right PHY type.
--- arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +1 -1
@@ -190,7 +190,7 @@ ð0 { status = "okay"; mdio { - phy0: phy@1 { + phy0: ethernet-phy@1 { compatible = "ethernet-phy-id001c.c916"; reg = <1>; reset-gpios = <&gpio 0 15 GPIO_ACTIVE_LOW>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 731/1815 riscv: dts: spacemit: Make dtschema recognize the etherent PHY correctly on K3 com260 board
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit bff5af3c934740481a316c5ae1cd4a09a43134d0 ]
Since the previous commit does not change the phy node name, the dtschema can not recognize the type of the ethernet phy, so the following error is produced:
/arch/riscv/boot/dts/spacemit/k3-com260-ifx.dtb: phy@1 (ethernet-phy-id001c.c916): $nodename:0: 'phy@1' does not match '^ethernet-phy(@[a-f0-9]+)?$'
from schema $id: http://devicetree.org/schemas/net/realtek,rtl82xx.yaml
/arch/riscv/boot/dts/spacemit/k3-com260-ifx.dtb: phy@1 (ethernet-phy-id001c.c916): Unevaluated properties are not allowed ('reg', 'reset-assert-us', ' reset-deassert-us', 'reset-gpios' were unexpected)
from schema $id: http://devicetree.org/schemas/net/realtek,rtl82xx.yaml
Change the nodename to make the dtschema can recognize the right PHY type.
--- arch/riscv/boot/dts/spacemit/k3-com260.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/spacemit/k3-com260.dtsi +1 -1
@@ -173,7 +173,7 @@ ð1 { status = "okay"; mdio { - phy1: phy@1 { + phy1: ethernet-phy@1 { compatible = "ethernet-phy-id001c.c916"; reg = <1>; reset-gpios = <&gpio 1 5 GPIO_ACTIVE_LOW>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 732/1815 RDMA/cxgb4: Fix dereg_skb leak and double free in write_tpt_entry()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 373f3716a2de7adc739269ebb4d87e5bf4dc180c ]
When the device is in the fatal error state, write_tpt_entry() returns -EIO before handing the caller's preallocated skb to the transmit path; its allocation-failure returns do the same. c4iw_dereg_mr() ignores the error and frees mhp, leaking mhp->dereg_skb. c4iw_get_dma_mr() instead frees the skb a second time after dereg_mem() already consumed it, a double free.
Make write_tpt_entry() the sole owner of a non-NULL skb, freeing it on every return preceding handoff to c4iw_ofld_send(): fatal error, tpt and stag allocation failure. c4iw_ofld_send() consumes the skb on success and error alike, so drop the redundant kfree_skb() in c4iw_get_dma_mr() after dereg_mem().
--- drivers/infiniband/hw/cxgb4/mem.c | 46 ++++++++++++------------------- 1 file changed, 17 insertions(+), 29 deletions(-)
drivers/infiniband/hw/cxgb4/mem.c +17 -29
@@ -199,7 +199,8 @@ static int _c4iw_write_mem_dma(struct c4iw_rdev *rdev, u32 addr, u32 len, daddr =dma_map_single (&rdev->lldi.pdev->dev, data, len,DMA_TO_DEVICE );if (dma_mapping_error (&rdev->lldi.pdev->dev, daddr)) -return -1 ; +return _c4iw_write_mem_inline (rdev, addr, len, data, skb, + wr_waitp); save = daddr;while (remain > inline_threshold) {
@@ -235,30 +236,12 @@ static int write_adapter_mem(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data, struct sk_buff *skb, struct c4iw_wr_wait *wr_waitp) { - int ret; - -if (!rdev->lldi.ulptx_memwrite_dsgl || !use_dsgl) { - ret =_c4iw_write_mem_inline (rdev, addr, len, data, skb, - wr_waitp); - goto out; - } - -if (len <= inline_threshold) { - ret =_c4iw_write_mem_inline (rdev, addr, len, data, skb, + if (!rdev->lldi.ulptx_memwrite_dsgl || !use_dsgl || + len <= inline_threshold) + return _c4iw_write_mem_inline(rdev, addr, len, data, skb, wr_waitp); - goto out; - } - - ret =_c4iw_write_mem_dma (rdev, addr, len, data, skb, wr_waitp); -if (ret) { -pr_warn_ratelimited ("%s: dma map failure (non fatal)\n" , -pci_name (rdev->lldi.pdev)); - ret =_c4iw_write_mem_inline (rdev, addr, len, data, skb, - wr_waitp); - } -out: -return ret; + return _c4iw_write_mem_dma(rdev, addr, len, data, skb, wr_waitp); }/*
@@ -279,12 +262,16 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,u32 stag_idx;static atomic_t key; -if (c4iw_fatal_error (rdev)) +if (c4iw_fatal_error (rdev)) { +kfree_skb (skb);return -EIO ; + } tpt =kmalloc_obj (*tpt); -if (!tpt) +if (!tpt) { +kfree_skb (skb);return -ENOMEM ; + } stag_state = stag_state >0 ; stag_idx = (*stag) >>8 ;
@@ -296,6 +283,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry, rdev->stats.stag.fail++;mutex_unlock (&rdev->stats.lock);kfree (tpt); +kfree_skb (skb);return -ENOMEM ; }mutex_lock (&rdev->stats.lock);
@@ -469,8 +457,10 @@ struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc)FW_RI_STAG_NSMR , mhp->attr.perms, mhp->attr.mw_bind_enable,0 ,0 , ~0ULL ,0 ,0 ,0 , NULL, mhp->wr_waitp); -if (ret) - goto err_free_skb; +if (ret) { +kfree_skb (mhp->dereg_skb); + goto err_free_wr_wait; + } ret =finish_mem_reg (mhp, stag);if (ret)
@@ -479,8 +469,6 @@ struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc) err_dereg_mem:dereg_mem (&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size, mhp->attr.pbl_addr, mhp->dereg_skb, mhp->wr_waitp); -err_free_skb: -kfree_skb (mhp->dereg_skb); err_free_wr_wait:c4iw_put_wr_wait (mhp->wr_waitp); err_free_mhp:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 733/1815 RDMA/mlx5: Fix stack out-of-bounds read in cc_params debugfs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 03826bc1fa6c90405bf05831f2b501a8368dcd27 ]
get_param() reads a congestion parameter as a u32 but formats it with the signed "%d" into an 11-byte stack buffer. A value with bit 31 set, such as 0x80000000, renders as "-2147483648\n" whose full length is 12. snprintf() stores only 11 bytes yet returns 12, so simple_read_from_buffer() treats 12 bytes as valid and reads one byte past lbuf[].
Size the buffer for the widest unsigned decimal, format with "%u" to match the u32, and use scnprintf() so the length passed to simple_read_from_buffer() reflects the bytes actually stored.
--- drivers/infiniband/hw/mlx5/cong.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/cong.c +2 -4
@@ -399,15 +399,13 @@ static ssize_t get_param(struct file *filp, char __user *buf, size_t count,int offset = param->offset;u32 var =0 ;int ret; -char lbuf[11 ]; +char lbuf[12 ]; ret =mlx5_ib_get_cc_params (param->dev, param->port_num, offset, &var);if (ret)return ret; - ret =snprintf (lbuf,sizeof (lbuf),"%d\n" , var); -if (ret <0 ) -return ret; + ret =scnprintf (lbuf,sizeof (lbuf),"%u\n" , var);return simple_read_from_buffer (buf, count, pos, lbuf, ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 734/1815 RDMA/mlx5: Send cong param changes to the resolved port mdev
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 033a79e308e4fe832b0924347eda8c4364055174 ]
mlx5_ib_set_cc_params() resolves the port-specific mlx5_core_dev via mlx5_ib_get_native_port_mdev() but issued MLX5_CMD_OP_MODIFY_CONG_PARAMS through dev->mdev. On an affiliated secondary RoCE port those pointers refer to different devices, so a write to the secondary port's cc_params debugfs file either altered the master port or failed with a master-side command error, while the read path already used the resolved mdev and returned the unchanged secondary value.
Issue the command to the resolved mdev, the same device whose capabilities were checked when its debugfs directory was created. It is already referenced by the get/put pair, so its lifetime is safe.
--- drivers/infiniband/hw/mlx5/cong.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/cong.c +1 -1
@@ -361,7 +361,7 @@ static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, u32 port_num,MLX5_SET (field_select_r_roce_rp, field, field_select_r_roce_rp, attr_mask); - err =mlx5_cmd_exec_in (dev->mdev, modify_cong_params, in); + err =mlx5_cmd_exec_in (mdev, modify_cong_params, in);kvfree (in); alloc_err:mlx5_ib_put_native_port_mdev (dev, port_num +1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 735/1815 RDMA/cxgb4: free STAG index when TPT entry write fails
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit fdfb5cea4bf070cdb31d997efd87bb684df041fd ]
write_tpt_entry() allocates a new STAG index with c4iw_get_resource() and bumps stats.stag.cur before programming the entry. When write_adapter_mem() fails, it returns the error without releasing the index or reversing the statistic. No MR is inserted into rhp->mrs, so deregistration never reclaims it, leaking the index until device teardown.
Record whether this call allocated the index and, on a failed write, return it to tpt_table and decrement stats.stag.cur. Key the rollback on both the write error and that flag, not the error alone: a non-reset update carries a caller-owned STAG that this call did not allocate and must not free.
--- drivers/infiniband/hw/cxgb4/mem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/mem.c +3 -1
@@ -260,6 +260,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,int err;struct fw_ri_tpte *tpt;u32 stag_idx; +bool stag_idx_allocated = false;static atomic_t key;if (c4iw_fatal_error (rdev)) {
@@ -287,6 +288,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,return -ENOMEM ; }mutex_lock (&rdev->stats.lock); + stag_idx_allocated = true; rdev->stats.stag.cur +=32 ;if (rdev->stats.stag.cur > rdev->stats.stag.max) rdev->stats.stag.max = rdev->stats.stag.cur;
@@ -321,7 +323,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry, (rdev->lldi.vr->stag.start >>5 ), sizeof(*tpt), tpt, skb, wr_waitp); -if (reset_tpt_entry) { +if (reset_tpt_entry || (err && stag_idx_allocated)) {c4iw_put_resource (&rdev->resource.tpt_table, stag_idx);mutex_lock (&rdev->stats.lock); rdev->stats.stag.cur -=32 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 736/1815 media: staging/ipu7: fix async notifier leak on init error
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit 11ccf31a657f9f95260a22848b7d324d3c6cf113 ]
isys_notifier_init() initialises a v4l2 async notifier and then, for each CSI-2 port, adds a remote sensor subdev to the notifier's waiting_list via v4l2_async_nf_add_fwnode_remote(), which allocates a sensor_async_sd descriptor and takes a fwnode reference.
If parsing or adding a later port fails, the code jumps to the "err_parse" label, which only drops the current endpoint fwnode reference and returns, without calling v4l2_async_nf_cleanup(). Any descriptors already added to the notifier for earlier ports are therefore leaked, and the caller's error path does not clean up the notifier either.
Call v4l2_async_nf_cleanup() on the error path, matching the cleanup already performed when v4l2_async_nf_register() fails. This is safe as the notifier is always initialised before the loop is entered.
--- drivers/staging/media/ipu7/ipu7-isys.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/ipu7/ipu7-isys.c +1 -0
@@ -233,6 +233,7 @@ static int isys_notifier_init(struct ipu7_isys *isys) err_parse:fwnode_handle_put (ep); +v4l2_async_nf_cleanup (&isys->notifier);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 737/1815 IB/isert: reject PDUs declaring more data than was received
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 957f92ea4022fb6af4618271615a2a21a7b5bef9 ]
isert_recv_done() hands each received PDU to the opcode handlers without ever looking at wc->byte_len, the number of bytes the HCA actually placed in the receive descriptor. The handlers then copy that many bytes - the data-segment length the initiator declared in the BHS (ntoh24(hdr->dlength), via the derived unsol_data_len / imm_data_len) - out of the fixed-size descriptor:
isert_handle_iscsi_dataout():
sg_copy_from_buffer(sg_start, sg_nents, isert_get_data(rx_desc),
unsol_data_len);
isert_handle_scsi_cmd():
sg_copy_from_buffer(cmd->se_cmd.t_data_sg, sg_nents,
isert_get_data(rx_desc), imm_data_len);Because the declared length is never checked against wc->byte_len, an initiator can declare a data segment larger than the bytes it actually sent (and larger than the descriptor) and cause an out-of-bounds read of the receive buffer.
Nothing upstream of isert closes this door:
- __iscsit_check_dataout_hdr() bounds the inbound payload against conn_ops->MaxXmitDataSegmentLength (MXDSL) - a transmit parameter, used here for the inbound check.
- iscsi_set_connection_parameters() sets ops->MaxXmitDataSegmentLength = ops->TargetRecvDataSegmentLength; and TARGETRECVDATASEGMENTLENGTH is absent from the min()-clamp list in iscsi_check_acceptor_state(), so the value the initiator declares is adopted verbatim (type range 512..16777215). The initiator effectively raises its own ceiling.
- isert never clamps the negotiated value to its own fixed receive descriptor (ISER_RX_SIZE, 9216 bytes), so the target core's bound and the descriptor size are unrelated.
The imm_data_len == data_len path is more than an over-read: it aliases the receive descriptor via sg_set_buf() and passes it to the backend as the data source for the SCSI WRITE, so an over-declared length causes heap contents past the descriptor to be written through the backend to the backing store. The backend is the victim of the oversized scatterlist isert hands it, not the cause; no read-back of the written bytes was demonstrated.
Trigger: after login completes (full feature phase), an initiator that has declared a large TargetRecvDataSegmentLength and a FirstBurstLength that permits unsolicited/immediate data sends a PDU whose declared data-segment length exceeds what was received. With KASAN:
BUG: KASAN: slab-out-of-bounds in sg_copy_buffer+0x150/0x1c0 Read of size 4096 at addr ffff888109720800 by task kworker/1:0H/25 Workqueue: ib-comp-wq ib_cq_poll_work Call Trace: sg_copy_buffer+0x150/0x1c0 isert_recv_done+0xba6/0x2390 __ib_process_cq+0xe1/0x390 ib_cq_poll_work+0x46/0x150
isert_recv_done+0xba6 resolves to isert_handle_iscsi_dataout() (ib_isert.c:1160), inlined through isert_rx_opcode().
Validate wc->byte_len against the framing in isert_recv_done() before the PDU reaches any handler, and reinstate the connection if it is short. Because the test compares without subtracting the header length, it also rejects PDUs shorter than the iSER and iSCSI headers, which would otherwise be parsed out of stale descriptor contents. The login handler rejects PDUs shorter than ISER_HEADERS_LEN (commit 29e7b925ae6d ("IB/isert: Reject login PDUs shorter than ISER_HEADERS_LEN")) but does not bound the declared length either; that is fixed in the next patch. The data handlers had no length check at all.
isert reads the data segment from a fixed offset: isert_get_data() returns the iSER header plus ISER_HEADERS_LEN and makes no adjustment for an AHS. The bytes the handlers touch are therefore exactly [ISER_HEADERS_LEN, ISER_HEADERS_LEN + dlength), and comparing that sum against wc->byte_len bounds precisely the region that is read. An AHS term would only make the test stricter without bounding anything further, and cannot cause a false reject: a PDU carrying an AHS is longer, not shorter.
This is a memory-safety fix that verifies the bytes that were actually received; it does not touch RFC 7145 length negotiation and is not the MaxXmitDataSegmentLength negotiation redesign raised in the 2017 "[Query]
iSER-Target: QP errors observed on increasing MaxXmitDataSegmentLength" discussion. That redesign is explicitly out of scope here.
The patched kernel rejects the malformed DataOut PDU and both immediate-data variants with "PDU declares ... bytes were received" and continues to pass normal traffic with no regression.
Reproduced with soft-RoCE (rdma_rxe) and a raw rdma_cm/ibv initiator; no kernel-side test hooks were needed.
--- drivers/infiniband/ulp/isert/ib_isert.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/infiniband/ulp/isert/ib_isert.c +15 -0
@@ -1333,6 +1333,21 @@ isert_recv_done(struct ib_cq *cq, struct ib_wc *wc)ib_dma_sync_single_for_cpu (ib_dev, rx_desc->dma_addr,ISER_RX_SIZE ,DMA_FROM_DEVICE ); +/* +* The data segment length declared in the BHS is attacker controlled +* and is used further down to read that many bytes out of the fixed +* size receive descriptor, so it has to be checked against the number +* of bytes that were actually received. Comparing without subtracting +* also rejects PDUs shorter than the iSER and iSCSI headers, which +* would otherwise be parsed out of stale descriptor contents. +*/ +if (unlikely (wc->byte_len <ISER_HEADERS_LEN +ntoh24 (hdr->dlength))) { +isert_err ("PDU declares %u data bytes but only %u bytes were received\n" , +ntoh24 (hdr->dlength), wc->byte_len); +iscsit_cause_connection_reinstatement (isert_conn->conn,0 ); +return ; + } +isert_dbg ("DMA: 0x%llx, iSCSI opcode: 0x%02x, ITT: 0x%08x, flags: 0x%02x dlen: %d\n" , rx_desc->dma_addr, hdr->opcode, hdr->itt, hdr->flags, (int )(wc->byte_len -ISER_HEADERS_LEN ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 738/1815 IB/isert: reject login PDUs declaring more data than was received
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 2488b5b4827e5415768afc8daf097e8eb83c98df ]
isert_login_recv_done() records how many bytes the HCA actually placed in the login buffer, but nothing compares that against the length the login PDU's BHS declares. isert_rx_login_req() copies min(login_req_len, MAX_KEY_VALUE_PAIRS) bytes into login->req_buf, and the login code then reads the declared length back out of that buffer - for the first PDU in iscsi_target_locate_portal(),
payload_length = ntoh24(login_req->dlength); tmpbuf = kmemdup_nul(login->req_buf, payload_length, GFP_KERNEL);
and for the ones after it in iscsi_decode_text_input(), reached from iscsi_target_do_login().
login->req_buf is a fixed MAX_KEY_VALUE_PAIRS (8192) byte allocation, so an initiator that declares more than it sends reads off the end of it, before authentication and with the length under its control:
BUG: KASAN: slab-out-of-bounds in kmemdup_nul+0x43/0x80 Read of size 8193 at addr ffff8881056a8000 by task iscsi_np/167 __asan_memcpy+0x23/0x60 kmemdup_nul+0x43/0x80 iscsi_target_locate_portal+0x48d/0x1180 iscsi_target_login_thread+0x19a9/0x3350 Allocated by task 167: __kmalloc_cache_noprof+0x158/0x370 iscsi_target_login_thread+0x971/0x3350 which belongs to the cache kmalloc-8k of size 8192 allocated 8192-byte region
Falsifying the second login PDU instead reaches the other reader, on the same buffer:
BUG: KASAN: slab-out-of-bounds in kmemdup_nul+0x43/0x80 Read of size 8193 at addr ffff888104d10000 by task kworker/1:1/50 Workqueue: isert_login_wq iscsi_target_do_login_rx __asan_memcpy+0x23/0x60 kmemdup_nul+0x43/0x80 iscsi_decode_text_input+0xc6/0x11c0 iscsi_target_do_login+0x261/0x1470 iscsi_target_do_login_rx+0x51d/0x7d0
iscsit over TCP is not exposed: iscsit_get_login_rx() validates the declared length with iscsi_target_check_login_request() and then reads exactly that many bytes off the socket, so the declared length governs how much arrives rather than how much is copied out of an already-filled buffer. isert does not call iscsi_target_check_login_request() at all.
Reject a login PDU whose declared DataSegmentLength exceeds what was received, in both paths that reach isert_rx_login_req():isert_get_login_rx() for the first login PDU and isert_login_recv_done() for the ones after it. dlength <= login_req_len is allowed because the received count can include up to three bytes of iSCSI padding.
Once the check is in place the copy out can no longer exceed the copy in:
the posted login SGE is ISER_RX_PAYLOAD_SIZE, so login_req_len cannot exceed MAX_KEY_VALUE_PAIRS and the min() in isert_rx_login_req() is login_req_len.
Like the existing short-PDU check added by 29e7b925ae6d, the reject in isert_login_recv_done() returns without completing login_req_comp, so a malformed subsequent PDU leaves the login to be torn down by the login timer rather than failing immediately. The first-PDU path returns an error and fails straight away.
Reproduced on 7.2.0-rc4 with soft-RoCE (rdma_rxe) under KASAN, using an initiator that sends the real key=value payload while declaring 8193 in the BHS, on the first login PDU and on the second in separate runs. The reported read size tracks the declared value exactly; 16384 and 61440 behave the same. Unpatched 3 of 3 runs report on each of the two paths, patched 0 of 3 on both, run alternately in a single session, and a normal login still completes on the patched build.
--- drivers/infiniband/ulp/isert/ib_isert.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/isert/ib_isert.c +24 -1
@@ -971,6 +971,21 @@ isert_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login,return 0 ; } +static int +isert_check_login_req (struct isert_conn *isert_conn) +{ +struct iscsi_hdr *hdr =isert_get_iscsi_hdr (isert_conn->login_desc); +u32 dlength =ntoh24 (hdr->dlength); + +if (unlikely (dlength > (u32 )isert_conn->login_req_len)) { +isert_dbg ("login PDU declares %u data bytes but only %d were received\n" , + dlength, isert_conn->login_req_len); +return -EINVAL ; + } + +return 0 ; +} +static void isert_rx_login_req (struct isert_conn *isert_conn) {
@@ -1409,8 +1424,12 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc)if (isert_conn->conn) {struct iscsi_login *login = isert_conn->conn->conn_login; -if (login && !login->first_request) +if (login && !login->first_request) { +if (isert_check_login_req (isert_conn)) +return ; +isert_rx_login_req (isert_conn); + } }mutex_lock (&isert_conn->mutex);
@@ -2375,6 +2394,10 @@ isert_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login)if (!login->first_request)return 0 ; + ret =isert_check_login_req (isert_conn); +if (ret) +return ret; +isert_rx_login_req (isert_conn);isert_info ("before login_comp conn: %p\n" , conn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 739/1815 nvmet: fix return status of RMI log page on allocation failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 581d8bb556dd3e5567bcf322aa5e3e4b6a200c08 ]
nvmet_execute_get_log_page_rmi() leaves 'status' holding NVME_SC_SUCCESS (set by the successful nvmet_req_find_ns() call) when the kzalloc() for the log buffer fails. It then jumps to the out label and completes the request with a success status, so the host is told the command succeeded while no data was transferred.
Initialize 'status' to NVME_SC_INTERNAL, matching the smart log handler, so an allocation failure is reported as an internal error.
--- drivers/nvme/target/admin-cmd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +3 -1
@@ -309,8 +309,10 @@ static void nvmet_execute_get_log_page_rmi(struct nvmet_req *req) } log =kzalloc_obj (*log); -if (!log) +if (!log) { + status =NVME_SC_INTERNAL ; goto out; + } log->endgid = req->cmd->get_log_page.lsi; disk = req->ns->bdev->bd_disk;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 740/1815 nvme-fc: unmap cmd_iu DMA on rsp_iu mapping failure in init_request
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit f49d0c3a8d56a7cda1628ae17341a4a42063563c ]
__nvme_fc_init_request() maps cmd_iu and then rsp_iu for DMA. If the rsp_iu mapping fails, the original code only recorded the error and fell
through: it left the already-mapped cmd_iu unmapped and still marked the op as FCPOP_STATE_IDLE before returning. Since blk-mq does not call .exit_request() when .init_request() fails, the cmd_iu mapping is leaked for every op whose rsp_iu mapping fails.
Jump to an error path on rsp_iu mapping failure that unmaps cmd_iu and returns the error without marking the op idle, so it stays in the FCPOP_STATE_UNINIT state set by the initial memset().
--- drivers/nvme/host/fc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/host/fc.c +6 -0
@@ -2100,9 +2100,15 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,dev_err (ctrl->dev,"FCP Op failed - rspiu dma mapping failed.\n" ); ret = -EFAULT ; + goto out_unmap; }atomic_set (&op->state,FCPOP_STATE_IDLE ); +return 0 ; + +out_unmap: +fc_dma_unmap_single (ctrl->lport->dev, op->fcp_req.cmddma, +sizeof (op->cmd_iu),DMA_TO_DEVICE ); out_on_error:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 741/1815 nvme-pci: return error when parsing a quirk string fails
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit df74eaad001cf669c332dc67ef91996532e6b52c ]
quirks_param_set() reuses 'err', which param_set_copystring() left as 0, as the return value of the whole function. When nvme_parse_quirk_entry() fails to parse a field, the code jumps to out_free_qlist and returns that stale 0, so a malformed quirks= parameter is silently accepted as valid.
Set err to -EINVAL before jumping out on a parse failure.
--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
@@ -213,6 +213,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)if (nvme_parse_quirk_entry (field, &qlist[i])) {pr_err ("nvme: failed to parse quirk string %s\n" , value); + err = -EINVAL ; goto out_free_qlist; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 742/1815 nvmet: reject out-of-range mdts values in configfs store
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit bf881dd20062db5e951a0d0703cb476df8c9fdee ]
nvmet_param_mdts_store() accepts any integer that kstrtoint() can parse and stores it directly into port->mdts. The value is only range-checked later, when the port is enabled: nvmet_enable_port() silently resets port->mdts to 0 if it is negative or greater than NVMET_MAX_MDTS.
As a result, writing e.g. "mdts=1000" succeeds and reading the attribute back returns 1000, yet enabling the port quietly turns it into 0. This is confusing and hides the invalid input from the user.
Validate the value against [0, NVMET_MAX_MDTS] in the store handler and reject anything out of range with -EINVAL, so the error is reported at write time and port->mdts never holds a value the port cannot use.
--- drivers/nvme/target/configfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/nvme/target/configfs.c +6 -4
@@ -312,15 +312,17 @@ static ssize_t nvmet_param_mdts_store(struct config_item *item, const char *page, size_t count) {struct nvmet_port *port =to_nvmet_port (item); -int ret; +int ret, mdts;if (nvmet_is_port_enabled (port, __func__))return -EACCES ; - ret =kstrtoint (page,0 , &port->mdts); -if (ret) { -pr_err ("Invalid value '%s' for mdts\n" , page); + ret =kstrtoint (page,0 , &mdts); +if (ret || mdts <0 || mdts >NVMET_MAX_MDTS ) { +pr_err ("Invalid value '%s' for mdts, should be 0-%d\n" , + page,NVMET_MAX_MDTS );return -EINVAL ; } + port->mdts = mdts;return count; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 743/1815 spi: davinci: switch to managed controller allocation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit ea408a05dc8f18b4a184b88d6e19d2fd1acc1527 ]
The controller is allocated with the non-managed spi_alloc_host() while the interrupt is registered with devm_request_threaded_irq(). During removal, spi_bitbang_stop() only unregisters the controller; the subsequent spi_controller_put() then frees the controller together with its embedded davinci_spi devdata, which is the IRQ handler's dev_id. The devm_request_threaded_irq() release action (free_irq()), which drains the handler, does not run until after .remove() returns. A late or latched interrupt can therefore reach davinci_spi_irq() and dereference already-freed memory.
Switch to devm_spi_alloc_host() so that the devres LIFO order releases the controller only after free_irq() has drained the handler, and drop the now-redundant spi_controller_put() from .remove(). The probe error path is simplified to direct returns.
The clock is acquired with devm_clk_get_enabled(), which is registered after the IRQ and thus released before it by the devres LIFO order. Drain the interrupt explicitly with devm_free_irq() before disabling the controller so that a late interrupt cannot access the registers of a clock-gated controller.
This issue was found by an in-house static analysis tool.
--- drivers/spi/spi-davinci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/spi/spi-davinci.c +3 -4
@@ -928,7 +928,7 @@ static int davinci_spi_probe(struct platform_device *pdev)int ret =0 ;u32 spipc0; - host =spi_alloc_host (&pdev->dev,sizeof (struct davinci_spi )); + host =devm_spi_alloc_host (&pdev->dev,sizeof (struct davinci_spi ));if (host ==NULL ) { ret = -ENOMEM ; goto err;
@@ -1057,7 +1057,6 @@ static int davinci_spi_probe(struct platform_device *pdev)dma_release_channel (dspi->dma_tx); } free_host: -spi_controller_put (host); err:return ret; }
@@ -1081,6 +1080,8 @@ static void davinci_spi_remove(struct platform_device *pdev)spi_bitbang_stop (&dspi->bitbang); +devm_free_irq (&pdev->dev, dspi->irq, dspi); +/* This bit needs to be cleared to disable dpsi->clk */ clear_io_bits (dspi->base +SPIGCR1 ,SPIGCR1_POWERDOWN_MASK );
@@ -1088,8 +1089,6 @@ static void davinci_spi_remove(struct platform_device *pdev)dma_release_channel (dspi->dma_rx);dma_release_channel (dspi->dma_tx); } - -spi_controller_put (host); }static struct platform_driver davinci_spi_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 744/1815 drm/panthor: Add vm_bind region with kbo range overlap check
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrián Larumbe <[email protected]>
[ Upstream commit 985f5e12f3cdf43030e13c2bbd154913133b5c3f ]
When a VM is created, caller has to specify the range of the address space carve-out set aside for mapping kernel BO's. That means vm_bind mappings of UM-exposed BO's should not intersect with that region, but at the moment we're not checking this.
At first, I thought of giving these values to drm_gpuvm_init() through its reserve_{offset, range} arguments, but it turns out that is meant for VM address spans that are not managed through the usual drm_gpuvm split/merge circuit, so storing the end of the user VA range at VM creation time and doing a quick check in the vm_bind ioctl path was the simplest workaround.
The new check also makes sure vm_bind range doesn't overflow the size of a 64-bit unsigned integer. That was already being done further down the call stack inside drm_gpuvm_sm_map -> drm_gpuvm_range_valid, but it's best to fail early in the driver before GPUVM functions are invoked so that we won't waste time allocating vm_bind context resources.
--- drivers/gpu/drm/panthor/panthor_mmu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/panthor/panthor_mmu.c +9 -0
@@ -318,6 +318,9 @@ struct panthor_vm {u64 end; } kernel_auto_va; +/** @user_va_range: Upper boundary of VAs VM users can map objects against. */ +u64 user_va_range; +/** @as: Address space related fields. */ struct {/**
@@ -2901,6 +2904,8 @@ panthor_vm_create(struct panthor_device *ptdev, bool for_mcu, va_range = full_va_range; } + vm->user_va_range = kernel_va_start; +mutex_init (&vm->mm_lock);drm_mm_init (&vm->mm, kernel_va_start, kernel_va_size); vm->kernel_auto_va.start = auto_kernel_va_start;
@@ -2989,6 +2994,10 @@ panthor_vm_bind_prepare_op_ctx(struct drm_file *file,if (!IS_ALIGNED (op->va | op->size | op->bo_offset, vm_pgsz))return -EINVAL ; +/* We don't allow mappings that overlap with kbo's reserved range */ +if (range_overflows (op->va, op->size, vm->user_va_range)) +return -EINVAL ; +switch (op->flags &DRM_PANTHOR_VM_BIND_OP_TYPE_MASK ) {case DRM_PANTHOR_VM_BIND_OP_TYPE_MAP :if (!(op->flags &DRM_PANTHOR_VM_BIND_OP_MAP_SPARSE )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 745/1815 wifi: ath12k: fix overreads in ath12k_wmi_process_csa_switch_count_event()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 878654eb78c6aa0ff585baf1376567c775ca28ec ]
There is no policy entry for WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT, so the parse infrastructure does not enforce a minimum length for the event struct. Additionally, the num_vdevs field is taken directly from firmware and used as a loop bound over the vdev_ids array without checking that it fits within the TLV payload. Either condition can cause an out-of-bounds read.
Add a TLV policy entry for WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT so the parse infrastructure enforces a minimum length for the fixed-size event struct. Add a helper ath12k_wmi_tlv_data_len() to recover the payload length of a parsed TLV from the header preceding its data pointer. Use it in ath12k_wmi_process_csa_switch_count_event() to bound num_vdevs before the loop.
Compile tested only.
--- drivers/net/wireless/ath/ath12k/wmi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/net/wireless/ath/ath12k/wmi.c +16 -0
@@ -207,6 +207,8 @@ static const struct ath12k_wmi_tlv_policy ath12k_wmi_tlv_policies[] = { .min_len = sizeof(struct wmi_per_chain_rssi_stat_params) }, [WMI_TAG_OBSS_COLOR_COLLISION_EVT] = { .min_len = sizeof(struct wmi_obss_color_collision_event) }, + [WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT] = { + .min_len = sizeof(struct ath12k_wmi_pdev_csa_event) }, };__le32 ath12k_wmi_tlv_hdr (u32 cmd,u32 len)
@@ -374,6 +376,13 @@ ath12k_wmi_tlv_parse(struct ath12k_base *ab, struct sk_buff *skb)return tb; } +static u32 ath12k_wmi_tlv_data_len (const void *data) +{ +const struct wmi_tlv *tlv = (const struct wmi_tlv *)data -1 ; + +return le32_get_bits (tlv->header,WMI_TLV_LEN ); +} +static int ath12k_wmi_cmd_send_nowait (struct ath12k_wmi_pdev *wmi,struct sk_buff *skb,u32 cmd_id) {
@@ -9056,12 +9065,19 @@ ath12k_wmi_process_csa_switch_count_event(struct ath12k_base *ab, const u32 *vdev_ids) {u32 current_switch_count =le32_to_cpu (ev->current_switch_count); +u32 vdev_ids_len =ath12k_wmi_tlv_data_len (vdev_ids);u32 num_vdevs =le32_to_cpu (ev->num_vdevs);struct ieee80211_bss_conf *conf;struct ath12k_link_vif *arvif;struct ath12k_vif *ahvif;int i; +if (num_vdevs > vdev_ids_len /sizeof (*vdev_ids)) { +ath12k_warn (ab,"csa switch count num_vdevs %u exceeds tlv array length %u\n" , + num_vdevs, vdev_ids_len); +return ; + } +rcu_read_lock ();for (i =0 ; i < num_vdevs; i++) { arvif =ath12k_mac_get_arvif_by_vdev_id (ab, vdev_ids[i]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 746/1815 wifi: ath11k: fix overreads in ath11k_wmi_process_csa_switch_count_event()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 208d7fdb85976a737a715b81d54efaff6703880c ]
There is no policy entry for WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT, so the parse infrastructure does not enforce a minimum length for the event struct. Additionally, the num_vdevs field is taken directly from firmware and used as a loop bound over the vdev_ids array without checking that it fits within the TLV payload. Either condition can cause an out-of-bounds read.
Add a TLV policy entry for WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT so the parse infrastructure enforces a minimum length for the fixed-size event struct. Add a helper ath11k_wmi_tlv_data_len() to recover the payload length of a parsed TLV from the header preceding its data pointer. Use it in ath11k_wmi_process_csa_switch_count_event() to bound num_vdevs before the loop.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +19 -2
@@ -159,6 +159,8 @@ static const struct wmi_tlv_policy wmi_tlv_policies[] = { .min_len = sizeof(struct ath11k_wmi_p2p_noa_info) }, [WMI_TAG_P2P_NOA_EVENT] = { .min_len = sizeof(struct wmi_p2p_noa_event) }, + [WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT] = { + .min_len = sizeof(struct wmi_pdev_csa_switch_ev) }, };#define PRIMAP (_hw_mode_) \
@@ -262,6 +264,13 @@ const void **ath11k_wmi_tlv_parse_alloc(struct ath11k_base *ab,return tb; } +static u32 ath11k_wmi_tlv_data_len (const void *data) +{ +const struct wmi_tlv *tlv = (const struct wmi_tlv *)data -1 ; + +return FIELD_GET (WMI_TLV_LEN , tlv->header); +} +static int ath11k_wmi_cmd_send_nowait (struct ath11k_pdev_wmi *wmi,struct sk_buff *skb,u32 cmd_id) {
@@ -8353,15 +8362,23 @@ ath11k_wmi_process_csa_switch_count_event(struct ath11k_base *ab,const struct wmi_pdev_csa_switch_ev *ev, const u32 *vdev_ids) { - int i; + u32 vdev_ids_len = ath11k_wmi_tlv_data_len(vdev_ids); +u32 num_vdevs = ev->num_vdevs;struct ath11k_vif *arvif; +int i;/* Finish CSA once the switch count becomes NULL */ if (ev->current_switch_count)return ; +if (num_vdevs > vdev_ids_len /sizeof (*vdev_ids)) { +ath11k_warn (ab,"csa switch count num_vdevs %u exceeds tlv array length %u\n" , + num_vdevs, vdev_ids_len); +return ; + } +rcu_read_lock (); -for (i =0 ; i < ev->num_vdevs; i++) { +for (i =0 ; i < num_vdevs; i++) { arvif =ath11k_mac_get_arvif_by_vdev_id (ab, vdev_ids[i]);if (!arvif) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 747/1815 wifi: ath12k: validate TLV length in process_tpc_stats()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 8e415b8068480d51a057197ded974e2637e8c42b ]
The outer skb->len guard only confirms the SKB is large enough to hold the full fixed_param struct, but the TLV's own WMI_TLV_LEN field is never checked. Firmware advertising a TLV length shorter than sizeof(*fixed_param) causes reads of pdev_id and event_count beyond the declared TLV payload.
Add a check that the TLV length is at least sizeof(*fixed_param) before casting and dereferencing the pointer.
--- drivers/net/wireless/ath/ath12k/wmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/wireless/ath/ath12k/wmi.c +8 -0
@@ -9967,6 +9967,7 @@ static void ath12k_wmi_process_tpc_stats(struct ath12k_base *ab,void *ptr = skb->data;struct ath12k *ar;u16 tlv_tag; +u16 tlv_len;u32 event_count;int ret;
@@ -9982,6 +9983,7 @@ static void ath12k_wmi_process_tpc_stats(struct ath12k_base *ab, tlv = (struct wmi_tlv *)ptr; tlv_tag =le32_get_bits (tlv->header,WMI_TLV_TAG ); + tlv_len =le32_get_bits (tlv->header,WMI_TLV_LEN ); ptr +=sizeof (*tlv);if (tlv_tag !=WMI_TAG_HALPHY_CTRL_PATH_EVENT_FIXED_PARAM ) {
@@ -9989,6 +9991,12 @@ static void ath12k_wmi_process_tpc_stats(struct ath12k_base *ab,return ; } +if (tlv_len <sizeof (*fixed_param)) { +ath12k_warn (ab,"TPC stats fixed param tlv len %u too short\n" , + tlv_len); +return ; + } + fixed_param = (struct ath12k_wmi_pdev_tpc_stats_event_fixed_params *)ptr;rcu_read_lock (); ar =ath12k_mac_get_ar_by_pdev_id (ab,le32_to_cpu (fixed_param->pdev_id) +1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 748/1815 PCI: starfive: Fix Runtime PM handling and teardown ordering
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Tariq <[email protected]>
[ Upstream commit fb9f7973473fc30d62e0f5f90d59df8ef5223777 ]
The starfive_pcie_remove() path incorrectly disabled runtime PM before executing plda_pcie_host_deinit(), which can cause unmanaged hardware register access in plda_pcie_host_deinit() while power domains or clocks are disabled.
Fix this by restructuring starfive_pcie_remove() to deinitialize the host controller first while runtime PM is active, followed by a synchronous pm_runtime_put_sync() and pm_runtime_disable().
This bug was found in automated AI review by sashiko-bot.
--- drivers/pci/controller/plda/pcie-starfive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/plda/pcie-starfive.c +2 -2
@@ -445,9 +445,9 @@ static void starfive_pcie_remove(struct platform_device *pdev) {struct starfive_jh7110_pcie *pcie =platform_get_drvdata (pdev); -pm_runtime_put (&pdev->dev); -pm_runtime_disable (&pdev->dev);plda_pcie_host_deinit (&pcie->plda); +pm_runtime_put_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev);platform_set_drvdata (pdev,NULL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 749/1815 PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Tariq <[email protected]>
[ Upstream commit aaae917990623a6ca6b638557056606a1ae4a8d6 ]
pm_runtime_get_sync() is called in starfive_pcie_probe() without checking its return value. If runtime resume fails, the driver proceeds to configure PCIe hardware through regmap_update_bits(), enable clocks and resets, and power on the PHY, even though the device may not actually be powered.
pm_runtime_get_sync() also increments the usage counter even when resume fails, which would leave the counter unbalanced if this error path were later handled without additional cleanup.
Switch to pm_runtime_resume_and_get(), which balances the usage counter internally on failure, and bail out of probe before any hardware is touched if resume does not succeed.
Tested on StarFive VisionFive 2 v1.2A board.
--- drivers/pci/controller/plda/pcie-starfive.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/controller/plda/pcie-starfive.c +5 -1
@@ -419,7 +419,11 @@ static int starfive_pcie_probe(struct platform_device *pdev)return ret;pm_runtime_enable (&pdev->dev); -pm_runtime_get_sync (&pdev->dev); + ret =pm_runtime_resume_and_get (&pdev->dev); +if (ret <0 ) { +pm_runtime_disable (&pdev->dev); +return dev_err_probe (dev, ret,"failed to resume device\n" ); + } plda->host_ops = &sf_host_ops; plda->num_events =PLDA_MAX_EVENT_NUM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 750/1815 drm/msm: remove objects from evit list after pinning them
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Maniscalco <[email protected]>
[ Upstream commit 83723f32cb3de23d45c1ac09241b5e0cfb32cc9b ]
Once objects are pinned they should not be kept in the evict list as that will cause drm_gpuvm_validate to keep ieterating a growing list of objects needlessly.
Once an object is pinned remove it from the list.
Patchwork: https://patchwork.freedesktop.org/patch/742166/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/msm_gem_vma.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/msm_gem_vma.c +2 -0
@@ -458,6 +458,8 @@ msm_gem_vm_bo_validate(struct drm_gpuvm_bo *vm_bo, struct drm_exec *exec)return ret; } +drm_gpuvm_bo_evict (vm_bo, false); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 751/1815 media: qcom: iris: Fix bitmask test in iris_allow_cmd()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dikshita Agarwal <[email protected]>
[ Upstream commit 0ac05c4d9f1fa25d0692fb154de36bd3baf2e7ce ]
iris_allow_cmd() incorrectly checks a sub‑state flag using a logical equality comparison. Since sub_state is a bitmask, this allows STOP to pass when IRIS_INST_SUB_DRAIN is set alongside other bits, violating the intended drain semantics. Fix this by using a proper bitmask test.
--- drivers/media/platform/qcom/iris/iris_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_state.c +1 -1
@@ -269,7 +269,7 @@ bool iris_allow_cmd(struct iris_inst *inst, u32 cmd)return true; }else if (cmd ==V4L2_DEC_CMD_STOP || cmd ==V4L2_ENC_CMD_STOP ) {if (vb2_is_streaming (src_q)) -if (inst->sub_state !=IRIS_INST_SUB_DRAIN ) +if (!(inst->sub_state &IRIS_INST_SUB_DRAIN ))return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 752/1815 media: qcom: iris: Remove duplicate HFI_PROP_OPB_ENABLE entry
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dikshita Agarwal <[email protected]>
[ Upstream commit 727a87c71b4ef794cdf552dae585d6f67be690ee ]
HFI_PROP_OPB_ENABLE/iris_hfi_gen2_set_opb_enable appeared twice in the dispatch table, causing the property to be sent to firmware twice on every config-params call.
--- drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +0 -1
@@ -692,7 +692,6 @@ static int iris_hfi_gen2_session_set_config_params(struct iris_inst *inst, u32 p {HFI_PROP_FRAME_RATE, iris_hfi_gen2_set_frame_rate }, {HFI_PROP_AV1_FILM_GRAIN_PRESENT, iris_hfi_gen2_set_film_grain }, {HFI_PROP_AV1_SUPER_BLOCK_ENABLED, iris_hfi_gen2_set_super_block }, - {HFI_PROP_OPB_ENABLE, iris_hfi_gen2_set_opb_enable }, };if (inst->domain ==DECODER ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 753/1815 media: qcom: iris: handle runtime PM resume failure in core deinit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 75d79879ec3cbfd288144b0ae4c3e3fa7700c5fc ]
Check the return value of pm_runtime_resume_and_get() in iris_core_deinit().
If runtime PM resume fails, skip hardware power-off operations but still perform software teardown and state transition. Also skip the corresponding pm_runtime_put_sync() call to avoid unbalanced runtime PM references.
--- drivers/media/platform/qcom/iris/iris_core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_core.c +9 -3
@@ -12,18 +12,24 @@void iris_core_deinit (struct iris_core *core) { -pm_runtime_resume_and_get (core->dev); +int ret; + + ret =pm_runtime_resume_and_get (core->dev);mutex_lock (&core->lock);if (core->state !=IRIS_CORE_DEINIT ) {iris_fw_unload (core); -iris_vpu_power_off (core); + +if (!ret) +iris_vpu_power_off (core); +iris_hfi_queues_deinit (core); core->state =IRIS_CORE_DEINIT ; }mutex_unlock (&core->lock); -pm_runtime_put_sync (core->dev); +if (!ret) +pm_runtime_put_sync (core->dev); }static int iris_wait_for_system_response (struct iris_core *core)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 754/1815 media: stm32: dcmi: fix some error handling bugs in probe()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit f1d1ed39ced825615aeac61f0b6a322178756632 ]
There are a few issues here:
1) After we assign:
chan = dma_request_chan(&pdev->dev, "tx");
Then the error paths need to clean up before returning. The first error path does a direct return.
2) The error paths check "dcmi->mdma_chan" but that is not assigned until later so it results in memory leaks. Test "mdma_chan" instead.
3) The error handling calls dma_release_channel(dcmi->dma_chan) before "dcmi->dma_chan" has been assigned which leads to a NULL pointer dereference. Use the "chan" variable instead.
I also moved the call to dma_release_channel() after the call to dma_release_channel() so it mirrors the allocation code better.
--- drivers/media/platform/st/stm32/stm32-dcmi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/media/platform/st/stm32/stm32-dcmi.c +8 -5
@@ -2024,8 +2024,10 @@ static int dcmi_probe(struct platform_device *pdev) mdma_chan =dma_request_chan (&pdev->dev,"mdma_tx" );if (IS_ERR (mdma_chan)) { ret =PTR_ERR (mdma_chan); -if (ret != -ENODEV ) -return dev_err_probe (&pdev->dev, ret,"Failed to request MDMA channel\n" ); +if (ret != -ENODEV ) { +dev_err_probe (&pdev->dev, ret,"Failed to request MDMA channel\n" ); + goto err_release_chan; + } mdma_chan =NULL ; }
@@ -2208,12 +2210,13 @@ static int dcmi_probe(struct platform_device *pdev) err_media_device_cleanup:media_device_cleanup (&dcmi->mdev); err_mdma_slave_config: -if (dcmi->mdma_chan) +if (mdma_chan)gen_pool_free (dcmi->sram_pool, (unsigned long )dcmi->sram_buf, dcmi->sram_buf_size); err_dma_slave_config: -dma_release_channel (dcmi->dma_chan); -if (dcmi->mdma_chan) +if (mdma_chan)dma_release_channel (mdma_chan); +err_release_chan: +dma_release_channel (chan);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 755/1815 s390/vdso: Pass --eh-frame-hdr to the linker
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Remus <[email protected]>
[ Upstream commit dc161efb6df8518b3cfa7f0a5efdc16a1aee815b ]
Commit 2b2a25845d53 ("s390/vdso: Use $(LD) instead of $(CC) to link vDSO") accidentally broke the GNU_EH_FRAME program table entry in the vDSO, causing it to be empty:
$ readelf --program-headers arch/s390/kernel/vdso/vdso.so
...
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
...
GNU_EH_FRAME 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x8
...Originally, the compiler would implicitly add --eh-frame-hdr when invoking the linker, but when this Makefile was converted from invoking the linker via the compiler, to invoking it directly, the option was missed.
This is the s390 variant of x86 commit cd01544a268a ("x86/vdso: Pass --eh-frame-hdr to the linker").
--- arch/s390/kernel/vdso/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kernel/vdso/Makefile +2 -1
@@ -30,7 +30,8 @@ KBUILD_CFLAGS_VDSO := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLA KBUILD_CFLAGS_VDSO += -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables KBUILD_CFLAGS_VDSO += -fno-stack-protector $(DISABLE_KSTACK_ERASE) ldflags-y := -shared -soname=linux-vdso.so.1 \ - --hash-style=both --build-id=sha1 -T + --hash-style=both --build-id=sha1 \ + $(call ld-option, --eh-frame-hdr) -T $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_VDSO) $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_VDSO)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 756/1815 regulator: tps65185: handle gpiod_get_value_cansleep() error returns
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Surendra Singh Chouhan <[email protected]>
[ Upstream commit 623d9a55685c52b10b995d8dbde9da6283170220 ]
tps65185_vposneg_enable() evaluated:
if (gpiod_get_value_cansleep(data->pgood_gpio) != 1)
return -ETIMEDOUT;
gpiod_get_value_cansleep() returns 1 if active, 0 if inactive, and a negative error code (e.g. -EIO or -EINVAL) on failure. Evaluating != 1 treats a negative error code as non-equal, swallowing GPIO read errors and masking them as -ETIMEDOUT.
Fix this by capturing the return value of gpiod_get_value_cansleep(). If it returns a negative error code, propagate that error immediately; if it returns 0 (inactive), return -ETIMEDOUT.
--- drivers/regulator/tps65185.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/regulator/tps65185.c +4 -1
@@ -183,7 +183,10 @@ static int tps65185_vposneg_enable(struct regulator_dev *rdev)wait_for_completion_timeout (&data->pgood_completion,msecs_to_jiffies (PGOOD_TIMEOUT_MSECS ));dev_dbg (data->dev,"turned on" ); -if (gpiod_get_value_cansleep (data->pgood_gpio) !=1 ) + ret =gpiod_get_value_cansleep (data->pgood_gpio); +if (ret <0 ) +return ret; +if (!ret)return -ETIMEDOUT ;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 757/1815 platform/chrome: cros_ec_debugfs: Clean up console log on probe failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit 5d187600c4603b8f7812b12ce359a11ad7a7fd3a ]
Add a dedicated error label for failures after successful console log setup.
--- drivers/platform/chrome/cros_ec_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_debugfs.c +3 -1
@@ -512,7 +512,7 @@ static int cros_ec_debugfs_probe(struct platform_device *pd) ret =blocking_notifier_chain_register (&ec->ec_dev->panic_notifier, &debug_info->notifier_panic);if (ret) - goto remove_debugfs; + goto cleanup_console_log; ec->debug_info = debug_info;
@@ -520,6 +520,8 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)return 0 ; +cleanup_console_log: +cros_ec_cleanup_console_log (debug_info); remove_debugfs:debugfs_remove_recursive (debug_info->dir);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 758/1815 platform/chrome: cros_ec_debugfs: Unregister panic notifier
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit e5954d3031fb55dd31aa59bae477d63c68e941c0 ]
cros_ec_debugfs_probe() registers notifier_panic with the EC panic notifier chain. The remove path tears down debugfs and the console log, but leaves the notifier registered. A later panic notification can call back into the removed instance and queue work that accesses released data.
Unregister the panic notifier before tearing down the debugfs and console log state.
This issue was found by a static analysis tool.
--- drivers/platform/chrome/cros_ec_debugfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/chrome/cros_ec_debugfs.c +2 -0
@@ -531,6 +531,8 @@ static void cros_ec_debugfs_remove(struct platform_device *pd) {struct cros_ec_dev *ec =dev_get_drvdata (pd->dev.parent); +blocking_notifier_chain_unregister (&ec->ec_dev->panic_notifier, + &ec->debug_info->notifier_panic);debugfs_remove_recursive (ec->debug_info->dir);cros_ec_cleanup_console_log (ec->debug_info); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 759/1815 wifi: rtlwifi: pci: fix error path in rtl_pci_probe()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit 3c2999d13eeb222ae56631aeb7ca248090f2b210 ]
In the last error path in rtl_pci_probe(), the cleanup functions are skipped due to a wrong goto label. Moreover, the successful call to rtl_init_rfkill(), ieee80211_register_hw(), rtl_debug_add_one() have to be reverted. Fix this issue by updating the labels and adding the relevant cleanup functions to the last error path.
--- drivers/net/wireless/realtek/rtlwifi/pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +5 -1
@@ -2227,13 +2227,17 @@ int rtl_pci_probe(struct pci_dev *pdev,rtl_dbg (rtlpriv,COMP_INIT ,DBG_DMESG ,"%s: failed to register IRQ handler\n" ,wiphy_name (hw->wiphy)); - goto fail3; + goto fail6; } rtlpci->irq_alloc =1 ;set_bit (RTL_STATUS_INTERFACE_START , &rtlpriv->status);return 0 ; +fail6: +rtl_deinit_rfkill (hw); +rtl_debug_remove_one (hw); +ieee80211_unregister_hw (hw); fail5:rtl_pci_deinit (hw); fail4:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 760/1815 bus: mhi: host: Flush the posted write after writing to MHI_SOC_RESET_REQ_OFFSET
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 24f4423cbc89548def2b05ae86de6175086dbf94 ]
mhi_soc_reset() tries to reset the device by writing to the MHI_SOC_RESET_REQ_OFFSET register. But it doesn't do a read-back to ensure that the write gets flushed to the device before returning to the caller.
This may lead to the delay (if implemented) on the caller to be insufficient, if the posted write doesn't reach the device before the delay.
So add a read-back after writing to the MHI_SOC_RESET_REQ_OFFSET register.
--- drivers/bus/mhi/host/main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/bus/mhi/host/main.c +6 -0
@@ -170,6 +170,9 @@ EXPORT_SYMBOL_GPL(mhi_get_mhi_state);void mhi_soc_reset (struct mhi_controller *mhi_cntrl) { +int __maybe_unused ret; +u32 tmp; +if (mhi_cntrl->reset) { mhi_cntrl->reset (mhi_cntrl);return ;
@@ -178,6 +181,9 @@ void mhi_soc_reset(struct mhi_controller *mhi_cntrl)/* Generic MHI SoC reset */ mhi_write_reg (mhi_cntrl, mhi_cntrl->regs,MHI_SOC_RESET_REQ_OFFSET ,MHI_SOC_RESET_REQ ); +/* Flush the posted write to the device (ignore return value) */ + ret =mhi_read_reg (mhi_cntrl, mhi_cntrl->regs,MHI_SOC_RESET_REQ_OFFSET , + &tmp); }EXPORT_SYMBOL_GPL (mhi_soc_reset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 761/1815 bus: mhi: host: Fix controller cleanup on EDL sysfs failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 0d5b9e66591d4e2a4376ac82c8cda889a29ba3ee ]
mhi_register_controller() adds the controller device before creating the optional trigger_edl sysfs file. If sysfs_create_file() fails, the error path only drops the device reference and leaves the device registered.
Hence, call device_del() in the error path before put_device().
--- drivers/bus/mhi/host/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bus/mhi/host/init.c +3 -1
@@ -1029,7 +1029,7 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,if (mhi_cntrl->edl_trigger) { ret =sysfs_create_file (&mhi_dev->dev.kobj, &dev_attr_trigger_edl.attr);if (ret) - goto err_release_dev; + goto err_del_dev; } mhi_cntrl->mhi_dev = mhi_dev;
@@ -1038,6 +1038,8 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,return 0 ; +err_del_dev: +device_del (&mhi_dev->dev); err_release_dev:put_device (&mhi_dev->dev); error_setup_irq:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 762/1815 md/raid5: protect bitmap batch counters aka seq_flush/seq_write consistency
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Cheng <[email protected]>
[ Upstream commit f565925810cb8bc799421485770e15d922ef766a ]
kcsan detect race :
- raid5d() closes the current bitmap batch by updating
conf->seq_flush under conf->device_lock. - __add_stripe_bio() read conf->seq_flush without that lock when assigning sh->bm_seq.
so, protect seq_flush/seq_write consistency for multiple CPUs by READ_ONCE()/WRITE_ONCE() under the path without held device_lock.
re-explain the stripe batch sequence number update flow:
1. sh->bm_seq declare which batch number the stripe belongs to when perform bitmap-related write.
==> bm_seq = seq_flush+1
2. stripe be handled,
* if sh->bm_seq - conf->seq_write > 0, means the batch stripes **newer than** the last written batch, it cannot proceed yet, queued on bitmap_list.
* otherwise , has already proceed.
3. raid5d() ++seq_flush to closes the current batch, means
* no more stripes join that old batch
* just-closed batch ready to write-out to disk
4. raid5d() calls bitmap hooks unplug() or writeout, then, ++seq_write to the same as bm_seq.
- seq_flush - for producer, to close batches.
- seq_write - for consumer, the checkpoint number.
the report:
====================================
BUG: KCSAN: data-race in __add_stripe_bio / raid5d
write to 0xffff88ba5625d470 of 4 bytes by task 82401 on cpu 0:
raid5d+0x1d9/0xba0 [.....]
read to 0xffff88ba5625d470 of 4 bytes by task 82421 on cpu 8:
__add_stripe_bio+0x332/0x400 raid5_make_request+0x6ac/0x2930 md_handle_request+0x4a2/0xa40 md_submit_bio+0x109/0x1a0 __submit_bio+0x2ec/0x390 [.....]
v1 -> v2:
- remove WRITE_ONCE(conf->seq_write) in held device_lock path.
- remove READ_ONCE(conf->seq_flush) in held device_lock path.
--- drivers/md/raid5.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/md/raid5.c +6 -4
@@ -3553,7 +3553,7 @@ static void __add_stripe_bio(struct stripe_head *sh, struct bio *bi, sh->dev[dd_idx].sector);if (conf->mddev->bitmap && firstwrite && !sh->batch_head) { - sh->bm_seq = conf->seq_flush+1 ; + sh->bm_seq =READ_ONCE (conf->seq_flush) +1 ;set_bit (STRIPE_BIT_DELAY , &sh->state); } }
@@ -5799,7 +5799,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi) }spin_unlock_irq (&sh->stripe_lock);if (conf->mddev->bitmap) { - sh->bm_seq = conf->seq_flush +1 ; + sh->bm_seq =READ_ONCE (conf->seq_flush) +1 ;set_bit (STRIPE_BIT_DELAY , &sh->state); }
@@ -6849,12 +6849,14 @@ static void raid5d(struct md_thread *thread)if ( !list_empty (&conf->bitmap_list)) {/* Now is a good time to flush some bitmap updates */ - conf->seq_flush++; +int seq = conf->seq_flush +1 ; + +WRITE_ONCE (conf->seq_flush, seq);spin_unlock_irq (&conf->device_lock);if (md_bitmap_enabled (mddev, true)) mddev->bitmap_ops->unplug (mddev, true);spin_lock_irq (&conf->device_lock); - conf->seq_write = conf->seq_flush; + conf->seq_write = seq;activate_bit_delay (conf, conf->temp_inactive_list); }raid5_activate_delayed (conf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 763/1815 md/raid5-ppl: fix use-after-free in ppl_do_flush()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sajal Gupta <[email protected]>
[ Upstream commit 371f7a1b392edc8b7cf449cc7713179b588f2d0e ]
The loop in ppl_do_flush() continues iterating after calling ppl_io_unit_finished(), touching io->pending_flushes and leading to a use-after-free.
Add a break statement to stop the loop once io is freed.
--- drivers/md/raid5-ppl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid5-ppl.c +3 -1
@@ -643,8 +643,10 @@ static void ppl_do_flush(struct ppl_io_unit *io) log->disk_flush_bitmap =0 ;for (i = flushed_disks ; i < raid_disks; i++) { -if (atomic_dec_and_test (&io->pending_flushes)) +if (atomic_dec_and_test (&io->pending_flushes)) {ppl_io_unit_finished (io); +break ; + } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 764/1815 md/raid5: fix lockless max_nr_stripes reads
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Cheng <[email protected]>
[ Upstream commit 6cb6ab75bdf2f49c0adb0fd6971886b082932eaa ]
max_nr_stripes is updated under cache_size_mutex in the stripe cache grow/shrink paths, while is_inactive_blocked() and raid5_end_read_request() read it without that lock.
Use READ_ONCE() for those reads in lockless path to match the WRITE_ONCE() updates and avoid KCSAN data race reports.
A similar issue was previously fixed in commit-id:
dfd2bf436709b2bccb78c2dda550dde93700efa7.
KCSAN report:
=================
BUG: KCSAN: data-race in grow_one_stripe / is_inactive_blocked
write (marked) to 0xffff8f01f0b5a268 of 4 bytes by task 12616 on cpu 9:
grow_one_stripe+0x2d8/0x320 raid5d+0xb57/0xba0 md_thread+0x15a/0x2d0 [..........]
read to 0xffff8f01f0b5a268 of 4 bytes by task 12670 on cpu 11:
is_inactive_blocked+0x97/0xc0 raid5_get_active_stripe+0x2fd/0xa70 raid5_make_request+0x4aa/0x2940 [..........]
value changed: 0x000003b9 -> 0x000003ba
--- drivers/md/raid5.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/md/raid5.c +4 -4
@@ -801,7 +801,7 @@ static bool is_inactive_blocked(struct r5conf *conf, int hash)return true;return (atomic_read (&conf->active_stripes) < - (conf->max_nr_stripes *3 /4 )); + (READ_ONCE (conf->max_nr_stripes) *3 /4 )); } struct stripe_head *raid5_get_active_stripe(struct r5conf *conf,
@@ -2785,6 +2785,7 @@ static void raid5_end_read_request(struct bio * bi) }else {int retry =0 ;int set_bad =0 ; +int max_nr_stripes =READ_ONCE (conf->max_nr_stripes);clear_bit (R5_UPTODATE , &sh->dev[i].flags);if (!(bi->bi_status ==BLK_STS_PROTECTION ))
@@ -2810,13 +2811,12 @@ static void raid5_end_read_request(struct bio * bi)mdname (conf->mddev), (unsigned long long )s, rdev->bdev); - }else if (atomic_read (&rdev->read_errors) - > conf->max_nr_stripes) { + }else if (atomic_read (&rdev->read_errors) > max_nr_stripes) {if (!test_bit (Faulty, &rdev->flags)) {pr_warn ("md/raid:%s: %d read_errors > %d stripes\n" ,mdname (conf->mddev),atomic_read (&rdev->read_errors), - conf->max_nr_stripes); + max_nr_stripes);pr_warn ("md/raid:%s: Too many read errors, failing device %pg.\n" ,mdname (conf->mddev), rdev->bdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 765/1815 net: airoha: fix ETS QoS stats counter underflow and cross-channel corruption
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 8b9a508819880c0c41d70f5b655bbd0baa231395 ]
airoha_qdma_get_tx_ets_stats() has two bugs:
- The hardware counters read via airoha_qdma_rr() are 32-bit values but are stored in u64 locals and subtracted from u64 baselines. When a 32-bit hardware counter wraps around, the subtraction produces a large underflow value passed to _bstats_update().
- The baseline counters (cpu_tx_packets, fwd_tx_packets) are stored as single per-device fields, but airoha_qdma_get_tx_ets_stats() is called with different channel values (0-3). Each call reads a different channel's hardware counter but overwrites the same baseline, corrupting the delta computation for other channels.
Fix both by:
- Narrowing the counter locals and baselines to u32 so that 32-bit unsigned subtraction handles wrap-around naturally.
- Grouping the baselines into a per-channel qos_stats array so each channel tracks its own previous counter value independently.
- Splitting the delta addition into two statements so the first u32 delta is widened to u64 on assignment and the second is added in u64 arithmetic, preventing overflow when both deltas are large.
--- drivers/net/ethernet/airoha/airoha_eth.c | 18 +++++++++++------- drivers/net/ethernet/airoha/airoha_eth.h | 7 ++++--- 2 files changed, 15 insertions(+), 10 deletions(-)
drivers/net/ethernet/airoha/airoha_eth.c +11 -7
@@ -2521,16 +2521,20 @@ static int airoha_qdma_get_tx_ets_stats(struct net_device *netdev, int channel, {struct airoha_gdm_dev *dev =netdev_priv (netdev);struct airoha_qdma *qdma = dev->qdma; +u32 cpu_tx_packets, fwd_tx_packets; +u64 tx_packets; -u64 cpu_tx_packets =airoha_qdma_rr (qdma,REG_CNTR_VAL (channel <<1 )); -u64 fwd_tx_packets =airoha_qdma_rr (qdma, -REG_CNTR_VAL ((channel <<1 ) +1 )); -u64 tx_packets = (cpu_tx_packets - dev->cpu_tx_packets) + - (fwd_tx_packets - dev->fwd_tx_packets); + cpu_tx_packets =airoha_qdma_rr (qdma,REG_CNTR_VAL (channel <<1 )); + fwd_tx_packets =airoha_qdma_rr (qdma, +REG_CNTR_VAL ((channel <<1 ) +1 )); + tx_packets = (u32)(cpu_tx_packets - + dev->qos_stats[channel].cpu_tx_packets); + tx_packets += (u32)(fwd_tx_packets - + dev->qos_stats[channel].fwd_tx_packets);_bstats_update (opt->stats.bstats,0 , tx_packets); - dev->cpu_tx_packets = cpu_tx_packets; - dev->fwd_tx_packets = fwd_tx_packets; + dev->qos_stats[channel].cpu_tx_packets = cpu_tx_packets; + dev->qos_stats[channel].fwd_tx_packets = fwd_tx_packets;return 0 ; }
drivers/net/ethernet/airoha/airoha_eth.h +4 -3
@@ -580,9 +580,10 @@ struct airoha_gdm_dev {struct airoha_eth *eth;DECLARE_BITMAP (qos_sq_bmap,AIROHA_NUM_QOS_CHANNELS ); -/* qos stats counters */ -u64 cpu_tx_packets; -u64 fwd_tx_packets; +struct { +u32 cpu_tx_packets; +u32 fwd_tx_packets; + } qos_stats[AIROHA_NUM_QOS_CHANNELS ];u32 flags;int nbq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 766/1815 md/raid5: protect lockless recovery_offset accesses during reshape
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Cheng <[email protected]>
[ Upstream commit a47431dfb3538a1485f65b68a0605a05307b5b2d ]
During reshape:
- reshape_request() advances rdev->recovery_offset for non-In_sync devices locklessly.
- analyse_stripe() reads rdev->recovery_offset locklessly to decide:
a. use a replacement device to read ?
b. a device can already be treated as in-sync for the current
stripe ?
one possible scenario is:
CPU1 CPU2reshape_request()
-> mddev->curr_resync_completed = sector_nr
-> if (!mddev->reshape_backwards)
-> rdev->recovery_offset = sector_nr
analyse_stripe(sh)
-> rdev = conf->disks[i].replacement
-> if (rdev->recovery_offset >=
sh->sector + stripe_sectors)
set_bit(R5_ReadRepl)
-> or
-> if (sh->sector + stripe_sectors <=
rdev->recovery_offset)
set_bit(R5_Insync)And it could be:
- reading from a replacement before it is recovered far enough; or
- treating a not-yet-recovered device as in-sync for the current stripe.
The race report:
==================================================================
BUG: KCSAN: data-race in ops_run_io / reshape_request
write to 0xffff8bdee168b270 of 8 bytes by task 1704 on cpu 10:
reshape_request+0x1292/0x17b0 raid5_sync_request+0x815/0xa00 md_do_sync.cold+0xf8d/0x1516 [......]
read to 0xffff8bdee168b270 of 8 bytes by task 1696 on cpu 9:
ops_run_io+0xc25/0x1960 handle_stripe+0x2273/0x4570 handle_active_stripes.isra.0+0x6e0/0xa50 raid5d+0x7d5/0xb90 [......]
value changed: 0x0000000000091a00 -> 0x0000000000091b00
==================================================================
--- drivers/md/raid5.c | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-)
drivers/md/raid5.c +25 -25
@@ -3751,11 +3751,10 @@ static int want_replace(struct stripe_head *sh, int disk_idx)int rv =0 ; rdev = sh->raid_conf->disks[disk_idx].replacement; -if (rdev - && !test_bit (Faulty, &rdev->flags) - && !test_bit (In_sync, &rdev->flags) - && (rdev->recovery_offset <= sh->sector - || rdev->mddev->resync_offset <= sh->sector)) +if (rdev && !test_bit (Faulty, &rdev->flags) && + !test_bit (In_sync, &rdev->flags) && + (READ_ONCE (rdev->recovery_offset) <= sh->sector || + rdev->mddev->resync_offset <= sh->sector)) rv =1 ;return rv; }
@@ -4672,7 +4671,8 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)*/ rdev = conf->disks[i].replacement;if (rdev && !test_bit (Faulty, &rdev->flags) && - rdev->recovery_offset >= sh->sector +RAID5_STRIPE_SECTORS (conf) && +READ_ONCE (rdev->recovery_offset) >= + sh->sector +RAID5_STRIPE_SECTORS (conf) && !rdev_has_badblock (rdev, sh->sector,RAID5_STRIPE_SECTORS (conf)))set_bit (R5_ReadRepl, &dev->flags);
@@ -4714,7 +4714,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s) }else if (test_bit (In_sync, &rdev->flags))set_bit (R5_Insync, &dev->flags);else if (sh->sector +RAID5_STRIPE_SECTORS (conf) <= - rdev->recovery_offset) { +READ_ONCE (rdev->recovery_offset)) {/* * in sync if: * - normal IO, or
@@ -5458,13 +5458,13 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio) rdev = conf->disks[dd_idx].replacement;if (!rdev ||test_bit (Faulty, &rdev->flags) || - rdev->recovery_offset < end_sector) { +READ_ONCE (rdev->recovery_offset) < end_sector) { rdev = conf->disks[dd_idx].rdev;if (!rdev)return 0 ;if (test_bit (Faulty, &rdev->flags) || !(test_bit (In_sync, &rdev->flags) || - rdev->recovery_offset >= end_sector)) +READ_ONCE (rdev->recovery_offset) >= end_sector))return 0 ; }
@@ -6427,8 +6427,8 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, int *skif (rdev->raid_disk >=0 && !test_bit (Journal, &rdev->flags) && !test_bit (In_sync, &rdev->flags) && - rdev->recovery_offset < sector_nr) - rdev->recovery_offset = sector_nr; +READ_ONCE (rdev->recovery_offset) < sector_nr) +WRITE_ONCE (rdev->recovery_offset, sector_nr); conf->reshape_checkpoint = jiffies;set_bit (MD_SB_CHANGE_DEVS , &mddev->sb_flags);
@@ -6536,8 +6536,8 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, int *skif (rdev->raid_disk >=0 && !test_bit (Journal, &rdev->flags) && !test_bit (In_sync, &rdev->flags) && - rdev->recovery_offset < sector_nr) - rdev->recovery_offset = sector_nr; +READ_ONCE (rdev->recovery_offset) < sector_nr) +WRITE_ONCE (rdev->recovery_offset, sector_nr); conf->reshape_checkpoint = jiffies;set_bit (MD_SB_CHANGE_DEVS , &mddev->sb_flags);md_wakeup_thread (mddev->thread);
@@ -8058,9 +8058,9 @@ static int raid5_run(struct mddev *mddev)/* Hack because v0.91 doesn't store recovery_offset properly. */ if (mddev->major_version ==0 && mddev->minor_version >90 ) - rdev->recovery_offset = reshape_offset; +WRITE_ONCE (rdev->recovery_offset, reshape_offset); - if (rdev->recovery_offset < reshape_offset) { + if (READ_ONCE(rdev->recovery_offset) < reshape_offset) { /* We need to check old and new layout */ if (!only_parity(rdev->raid_disk, conf->algorithm,
@@ -8215,10 +8215,10 @@ static int raid5_spare_active(struct mddev *mddev)for (i =0 ; i < conf->raid_disks; i++) { rdev = conf->disks[i].rdev; replacement = conf->disks[i].replacement; -if (replacement - && replacement->recovery_offset == MaxSector - && !test_bit (Faulty, &replacement->flags) - && !test_and_set_bit (In_sync, &replacement->flags)) { +if (replacement && +READ_ONCE (replacement->recovery_offset) == MaxSector && + !test_bit (Faulty, &replacement->flags) && + !test_and_set_bit (In_sync, &replacement->flags)) {/* Replacement has just become active. */ if (!rdev || !test_and_clear_bit (In_sync, &rdev->flags))
@@ -8233,10 +8233,10 @@ static int raid5_spare_active(struct mddev *mddev) rdev->sysfs_state); }sysfs_notify_dirent_safe (replacement->sysfs_state); - }else if (rdev - && rdev->recovery_offset == MaxSector - && !test_bit (Faulty, &rdev->flags) - && !test_and_set_bit (In_sync, &rdev->flags)) { + }else if (rdev && +READ_ONCE (rdev->recovery_offset) == MaxSector && + !test_bit (Faulty, &rdev->flags) && + !test_and_set_bit (In_sync, &rdev->flags)) { count++;sysfs_notify_dirent_safe (rdev->sysfs_state); }
@@ -8605,7 +8605,7 @@ static int raid5_start_reshape(struct mddev *mddev) >= conf->previous_raid_disks)set_bit (In_sync, &rdev->flags); else - rdev->recovery_offset = 0; + WRITE_ONCE(rdev->recovery_offset, 0);/* Failure here is OK */ sysfs_link_rdev (mddev, rdev);
@@ -8657,7 +8657,7 @@ static void end_reshape(struct r5conf *conf)if (rdev->raid_disk >=0 && !test_bit (Journal, &rdev->flags) && !test_bit (In_sync, &rdev->flags)) - rdev->recovery_offset = MaxSector; +WRITE_ONCE (rdev->recovery_offset, MaxSector);spin_unlock_irq (&conf->device_lock);wake_up (&conf->wait_for_reshape);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 767/1815 fanotify: stop permission watchdog when timeout is zero
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 17463fe751309330b74618560f181426f643aa3d ]
The fanotify permission watchdog can be disabled by writing zero to fs/fanotify/watchdog_timeout. fanotify_perm_watchdog_group_add() already checks for a zero timeout before scheduling the watchdog.
However, once the watchdog work has been scheduled, perm_group_watchdog() unconditionally schedules itself again with the current timeout. If the sysctl is changed to zero while the work is active, secs_to_jiffies(0) causes the work to be rescheduled immediately, resulting in a kworker busy loop.
Read the timeout once in perm_group_watchdog_schedule() and do not schedule the work when it is zero. This lets a running watchdog stop after the next execution when the sysctl is set to zero.
--- fs/notify/fanotify/fanotify_user.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/notify/fanotify/fanotify_user.c +6 -1
@@ -112,7 +112,12 @@ static DECLARE_DELAYED_WORK(perm_group_work, perm_group_watchdog);static void perm_group_watchdog_schedule (void ) { -schedule_delayed_work (&perm_group_work,secs_to_jiffies (perm_group_timeout)); +int timeout =READ_ONCE (perm_group_timeout); + +if (!timeout) +return ; + +schedule_delayed_work (&perm_group_work,secs_to_jiffies (timeout)); }static void perm_group_watchdog (struct work_struct *work)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 768/1815 tools/nolibc/powerpc: mark ctr and xer as clobbered by system call
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit b9fc5a1742b0c8fb7edf066cc17fa0b18b7be623 ]
The system call can clobber the ctr and xer registers.
Make sure the compiler takes this into account.
The missing clobbers only seem to be an issue with newer compilers.
--- tools/include/nolibc/arch-powerpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/nolibc/arch-powerpc.h +1 -1
@@ -26,7 +26,7 @@*/ #define _NOLIBC_SYSCALL_CLOBBERLIST \ - "memory", "cr0", "r12", "r11", "r10", "r9" + "memory", "cr0", "ctr", "xer", "r12", "r11", "r10", "r9"#define __nolibc_syscall0 (num) \ ({ \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 769/1815 md: remove REQ_NOWAIT support from raid1/10/456
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit 3fe5b7c9fb72ccc29bfd0f955b124892af7e3674 ]
REQ_NOWAIT support in md personalities that can block internally is fundamentally incomplete. While reads can avoid some blocking paths, write requests can still encounter cases where one mirror succeeds while another returns -EAGAIN. At that point md cannot distinguish queue pressure from a real device failure, so it can neither record a bad block nor safely retry the write without REQ_NOWAIT, leaving mirrors with divergent data.
Rather than continue advertising REQ_NOWAIT support for personalities that cannot implement it correctly, remove it from raid1, raid10 and raid456. Keep REQ_NOWAIT for linear and raid0, which only remap bios to their underlying devices; stacked limits will still clear the feature if any component device lacks REQ_NOWAIT support.
--- drivers/md/md-bitmap.c | 9 +--- drivers/md/md-bitmap.h | 2 +- drivers/md/md-linear.c | 1 + drivers/md/md-llbitmap.c | 10 +--- drivers/md/md.c | 6 +-- drivers/md/raid0.c | 1 + drivers/md/raid1-10.c | 8 ++-- drivers/md/raid1.c | 97 +++++++++------------------------------ drivers/md/raid10.c | 98 +++++++++++----------------------------- drivers/md/raid5.c | 13 ------ 10 files changed, 60 insertions(+), 185 deletions(-)
drivers/md/md-bitmap.c +2 -7
@@ -2064,23 +2064,18 @@ static void bitmap_end_behind_write(struct mddev *mddev) bitmap->mddev->bitmap_info.max_write_behind); } -static bool bitmap_wait_behind_writes (struct mddev *mddev,bool nowait) +static void bitmap_wait_behind_writes (struct mddev *mddev) {struct bitmap *bitmap = mddev->bitmap;/* wait for behind writes to complete */ if (bitmap &&atomic_read (&bitmap->behind_writes) >0 ) { -if (nowait) -return false; -pr_debug ("md:%s: behind writes in progress - waiting to stop.\n" ,mdname (mddev));/* need to kick something here to make sure I/O goes? */ wait_event (bitmap->behind_wait,atomic_read (&bitmap->behind_writes) ==0 ); } - -return true; }static void bitmap_destroy (struct mddev *mddev)
@@ -2090,7 +2085,7 @@ static void bitmap_destroy(struct mddev *mddev)if (!bitmap)/* there was no bitmap */ return ; -bitmap_wait_behind_writes (mddev, false); +bitmap_wait_behind_writes (mddev);if (!test_bit (MD_SERIALIZE_POLICY , &mddev->flags))mddev_destroy_serial_pool (mddev,NULL );
drivers/md/md-bitmap.h +1 -1
@@ -98,7 +98,7 @@ struct bitmap_operations {void (*start_behind_write)(struct mddev *mddev);void (*end_behind_write)(struct mddev *mddev); -bool (*wait_behind_writes)(struct mddev *mddev,bool nowait); +void (*wait_behind_writes)(struct mddev *mddev);md_bitmap_fn *start_write;md_bitmap_fn *end_write;
drivers/md/md-linear.c +1 -0
@@ -71,6 +71,7 @@ static int linear_set_limits(struct mddev *mddev)int err;md_init_stacking_limits (&lim); + lim.features |=BLK_FEAT_NOWAIT ; lim.max_hw_sectors = mddev->chunk_sectors; lim.logical_block_size = mddev->logical_block_size; lim.max_write_zeroes_sectors = mddev->chunk_sectors;
drivers/md/md-llbitmap.c +2 -8
@@ -1574,19 +1574,13 @@ static void llbitmap_end_behind_write(struct mddev *mddev)wake_up (&llbitmap->behind_wait); } -static bool llbitmap_wait_behind_writes (struct mddev *mddev,bool nowait) +static void llbitmap_wait_behind_writes (struct mddev *mddev) {struct llbitmap *llbitmap = mddev->bitmap; -if (llbitmap &&atomic_read (&llbitmap->behind_writes) >0 ) { -if (nowait) -return false; - +if (llbitmap &&atomic_read (&llbitmap->behind_writes) >0 )wait_event (llbitmap->behind_wait,atomic_read (&llbitmap->behind_writes) ==0 ); - } - -return true; }static ssize_t bits_show (struct mddev *mddev,char *page)
drivers/md/md.c +2 -4
@@ -6290,7 +6290,7 @@ void md_init_stacking_limits(struct queue_limits *lim) {blk_set_stacking_limits (lim); lim->features =BLK_FEAT_WRITE_CACHE |BLK_FEAT_FUA | -BLK_FEAT_IO_STAT |BLK_FEAT_NOWAIT ; +BLK_FEAT_IO_STAT ; }EXPORT_SYMBOL_GPL (md_init_stacking_limits);
@@ -6638,7 +6638,6 @@ int md_run(struct mddev *mddev)int err;struct md_rdev *rdev;struct md_personality *pers; -bool nowait = true;if (list_empty (&mddev->disks))/* cannot run an array with no devices.. */
@@ -6709,7 +6708,6 @@ int md_run(struct mddev *mddev) } }sysfs_notify_dirent_safe (rdev->sysfs_state); - nowait = nowait &&bdev_nowait (rdev->bdev); } pers =get_pers (mddev->level, mddev->clevel);
@@ -7057,7 +7055,7 @@ EXPORT_SYMBOL_GPL(md_stop_writes);static void mddev_detach (struct mddev *mddev) {if (md_bitmap_enabled (mddev, false)) - mddev->bitmap_ops->wait_behind_writes (mddev, false); + mddev->bitmap_ops->wait_behind_writes (mddev);if (mddev->pers && mddev->pers->quiesce && !is_md_suspended (mddev)) { mddev->pers->quiesce (mddev,1 ); mddev->pers->quiesce (mddev,0 );
drivers/md/raid0.c +1 -0
@@ -385,6 +385,7 @@ static int raid0_set_limits(struct mddev *mddev)int err;md_init_stacking_limits (&lim); + lim.features |=BLK_FEAT_NOWAIT ; lim.max_hw_sectors = mddev->chunk_sectors; lim.max_write_zeroes_sectors = mddev->chunk_sectors; lim.max_hw_wzeroes_unmap_sectors = mddev->chunk_sectors;
drivers/md/raid1-10.c +3 -5
@@ -290,9 +290,8 @@ static inline bool raid1_should_read_first(struct mddev *mddev, }/* -* bio with REQ_RAHEAD or REQ_NOWAIT can fail at anytime, before such IO is -* submitted to the underlying disks, hence don't record badblocks or retry -* in this case. +* bio with REQ_RAHEAD can fail at anytime, before such IO is submitted to the +* underlying disks, hence don't record badblocks or retry in this case. * * BLK_STS_INVAL means the bio was not valid for the underlying device. This * is a user error, not a device failure, so retrying or recording bad blocks
@@ -300,6 +299,5 @@ static inline bool raid1_should_read_first(struct mddev *mddev,*/ static inline bool raid1_should_handle_error (struct bio *bio) { -return !(bio->bi_opf & (REQ_RAHEAD |REQ_NOWAIT )) && - bio->bi_status !=BLK_STS_INVAL ; +return !(bio->bi_opf &REQ_RAHEAD ) && bio->bi_status !=BLK_STS_INVAL ; }
drivers/md/raid1.c +22 -75
222 lines not on this page · raw message
drivers/md/raid10.c +26 -72
218 lines not on this page · raw message
drivers/md/raid5.c +0 -13
@@ -5718,10 +5718,6 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)struct bio *orig_bi = bi;int stripe_sectors; -/* We need to handle this when io_uring supports discard/trim */ -if (WARN_ON_ONCE (bi->bi_opf &REQ_NOWAIT )) -return ; -if (mddev->reshape_position != MaxSector)/* Skip discard while reshape is happening */ return ;
@@ -6191,15 +6187,6 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)pr_debug ("raid456: %s, logical %llu to %llu\n" , __func__, bi->bi_iter.bi_sector, ctx->last_sector); -/* Bail out if conflicts with reshape and REQ_NOWAIT is set */ -if ((bi->bi_opf &REQ_NOWAIT ) && -get_reshape_loc (mddev, conf, logical_sector) ==LOC_INSIDE_RESHAPE ) { -bio_wouldblock_error (bi); -if (rw ==WRITE ) -md_write_end (mddev); -mempool_free (ctx, conf->ctx_pool); -return true; - }md_account_bio (mddev, &bi);/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 770/1815 md: recheck spare changes before starting sync
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit c7d34d17ea43ebc86b45d439ebb435e11ca44bca ]
remove_spares() and remove_and_add_spares() modify the array's rdev configuration. These operations are only safe after the array has been suspended.
md_start_sync() checks whether spare configuration changes are needed before taking reconfig_mutex. However, the rdev state can change before the mutex is acquired, so the initial check can become stale. In that case, md_choose_sync_action() may remove or replace rdevs while normal I/O is still accessing them.
The race can occur as follows:
raid10d Worker Normal IO ____________ _______________________ ______________________
raid10_write_request()
wait_blocked_dev()set Blocked
set Faulty
Skip Faulty rdev rrdev->nr_pending++ .repl_bio = bio
removeable_rdev = false .
array not suspended .
lock mddev goto err_handle
lock mddev (wait)
.
update sb .
clear Blocked .
.
unlock mddev .
lock mddev (acquires)
remove_spares()
removeable_rdev = true
raid10_remove_disk()
rdev = replacement
replacement = NULL
rdev_dec_pending(NULL)
unlock mddev (NULL)->nr_pending--
In this case, rdev_dec_pending() is called with a NULL pointer, resulting in a NULL pointer dereference when attempting to decrement nr_pending.
Fix this by suspending the array when spare configuration changes are needed, including for non-read-write arrays, and checking again after taking reconfig_mutex. If the array was not already suspended and a change is now needed, release the mutex, suspend the array, and reacquire the mutex before continuing.
--- drivers/md/md.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/md/md.c +13 -1
@@ -10186,13 +10186,25 @@ static void md_start_sync(struct work_struct *ws)* If reshape is still in progress, spares won't be added or removed * from conf until reshape is done. */ -if (mddev->reshape_position == MaxSector && +if ((mddev->reshape_position == MaxSector || !md_is_rdwr (mddev)) &&md_spares_need_change (mddev)) { suspend = true;mddev_suspend (mddev, false); }mddev_lock_nointr (mddev); + +/* +* The spare configuration can change before reconfig_mutex is acquired. +* Recheck while holding the lock and suspend if needed. +*/ +if (!suspend && (mddev->reshape_position == MaxSector || !md_is_rdwr (mddev)) && +md_spares_need_change (mddev)) { +mddev_unlock (mddev); +mddev_suspend_and_lock_nointr (mddev); + suspend = true; + } +if (!md_is_rdwr (mddev)) {/* * On a read-only array we can:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 771/1815 selftests/zram: fix kernel_gte() for POSIX sh
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng-Han Wu <[email protected]>
[ Upstream commit 649ba27dfac784427a01f9c95c09ecbcb88900d8 ]
Commit fc4eb486a59d ("selftests/zram: Skip max_comp_streams interface on newer kernel") added kernel_gte() to zram_lib.sh. The function uses the bash-specific [[ ... ]] conditional, but zram selftests source this file while running under /bin/sh.
On systems where /bin/sh is dash, such as Debian, the following test fails:
dash -c '
kernel_major=6; kernel_minor=1; major=6; minor=0
if [ $kernel_major -gt $major ]; then
echo ok
elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then
echo ok
fi'with:
dash: 5: [[: not found
Use separate POSIX test expressions joined by && instead.
--- tools/testing/selftests/zram/zram_lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/zram/zram_lib.sh +1 -1
@@ -37,7 +37,7 @@ kernel_gte() if [ $kernel_major -gt $major ]; then return 0 - elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then + elif [ $kernel_major -eq $major ] && [ $kernel_minor -ge $minor ]; then return 0 fi
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 772/1815 Revert "serial: 8250: Clear CON_PRINTBUFFER on port re-registration"
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fushuai Wang <[email protected]>
[ Upstream commit 57c0741b8c15b93ba4aa92c6618cde6f3f4115b2 ]
This reverts commit d338ab1d90603f875c4f7ed223406535378173a5.
uart_console() only indicates that the port is selected as the console. It does not mean that the console has already been registered or has printed the buffered messages.
On platforms where an initial 8250 port is replaced when the real UART device is registered, clearing CON_PRINTBUFFER causes the console to start at the end of the printk ring buffer. Without earlycon, all messages logged before UART registration are therefore lost.
--- drivers/tty/serial/8250/8250_core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/tty/serial/8250/8250_core.c +1 -5
@@ -720,12 +720,8 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)/* Preserve specified console flow control. */ cons_flow =uart_cons_flow_enabled (&uart->port); -if (uart->port.dev) { -if (uart_console (&uart->port)) - uart->port.cons->flags &= ~CON_PRINTBUFFER ; - +if (uart->port.dev)uart_remove_one_port (&serial8250_reg, &uart->port); - } uart->port.ctrl_id = up->port.ctrl_id; uart->port.port_id = up->port.port_id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 773/1815 wifi: ath12k: fix stride mismatch in mac_phy_caps_parse()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 4c6eb712a91fa079be6f9f1419c96e0ad2227081 ]
Currently, in ath12k_wmi_mac_phy_caps_parse(), kzalloc() sizes the mac_phy_caps buffer as tot_phy_id * len, where len is clamped to min(firmware_len, sizeof(struct ath12k_wmi_mac_phy_caps_params)). The subsequent memcpy() destination advances by sizeof(full struct) per slot via C pointer arithmetic, not by the clamped len. When firmware sends short TLVs, the second and later slots are written past the end of the allocation.
The reader in ath12k_pull_mac_phy_cap_svc_ready_ext() also indexes the buffer with full-struct pointer arithmetic, so the allocation must match that stride.
Fix by using kzalloc_objs(), which derives the element size from the pointer type, making allocation size and pointer stride provably consistent regardless of what len the firmware provides.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
--- drivers/net/wireless/ath/ath12k/wmi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +5 -3
@@ -4770,14 +4770,16 @@ static int ath12k_wmi_mac_phy_caps_parse(struct ath12k_base *soc,if (svc_rdy_ext->n_mac_phy_caps >= svc_rdy_ext->tot_phy_id)return -ENOBUFS ; - len =min_t (u16, len,sizeof (struct ath12k_wmi_mac_phy_caps_params ));if (!svc_rdy_ext->n_mac_phy_caps) { - svc_rdy_ext->mac_phy_caps =kzalloc ((svc_rdy_ext->tot_phy_id) * len, -GFP_ATOMIC ); + svc_rdy_ext->mac_phy_caps = +kzalloc_objs (*svc_rdy_ext->mac_phy_caps, + svc_rdy_ext->tot_phy_id, +GFP_ATOMIC );if (!svc_rdy_ext->mac_phy_caps)return -ENOMEM ; } + len =min_t (u16, len,sizeof (struct ath12k_wmi_mac_phy_caps_params ));memcpy (svc_rdy_ext->mac_phy_caps + svc_rdy_ext->n_mac_phy_caps, ptr, len); svc_rdy_ext->n_mac_phy_caps++;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 774/1815 wifi: ath11k: fix stride mismatch in mac_phy_caps_parse()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 7a246c72132eb943b5844ba79dad597b47429dba ]
Currently, in ath11k_wmi_tlv_mac_phy_caps_parse(), kcalloc() sizes the mac_phy_caps buffer as tot_phy_id * len, where len is clamped to min(firmware_len, sizeof(struct wmi_mac_phy_capabilities)). The subsequent memcpy() destination advances by sizeof(full struct) per slot via C pointer arithmetic, not by the clamped len. When firmware sends short TLVs, the second and later slots are written past the end of the allocation.
The reader in ath11k_pull_mac_phy_cap_svc_ready_ext() also indexes the buffer with full-struct pointer arithmetic, so the allocation must match that stride.
Fix by using kzalloc_objs(), which derives the element size from the pointer type, making allocation size and pointer stride provably consistent regardless of what len the firmware provides.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +5 -3
@@ -4809,14 +4809,16 @@ static int ath11k_wmi_tlv_mac_phy_caps_parse(struct ath11k_base *soc,if (svc_rdy_ext->n_mac_phy_caps >= svc_rdy_ext->tot_phy_id)return -ENOBUFS ; - len =min_t (u16, len,sizeof (struct wmi_mac_phy_capabilities ));if (!svc_rdy_ext->n_mac_phy_caps) { - svc_rdy_ext->mac_phy_caps =kcalloc (svc_rdy_ext->tot_phy_id, - len,GFP_ATOMIC ); + svc_rdy_ext->mac_phy_caps = +kzalloc_objs (*svc_rdy_ext->mac_phy_caps, + svc_rdy_ext->tot_phy_id, +GFP_ATOMIC );if (!svc_rdy_ext->mac_phy_caps)return -ENOMEM ; } + len =min_t (u16, len,sizeof (struct wmi_mac_phy_capabilities ));memcpy (svc_rdy_ext->mac_phy_caps + svc_rdy_ext->n_mac_phy_caps, ptr, len); svc_rdy_ext->n_mac_phy_caps++;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 775/1815 md/raid1: restrict atomic write limits and handle runtime constraints
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit 86d801e895b853667a886918998e1628fcc3174e ]
Restrict the RAID1 atomic write limits by setting chunk_sectors to BARRIER_UNIT_SECTOR_SIZE so that atomic writes never straddle a barrier unit.
A bio that passes block-layer validation may still become unserviceable within RAID1 due to bad blocks or write-behind constraints. In the former case, complete the bio with EIO. In the latter case, disable write-behind rather than failing the bio with EIO.
--- drivers/md/raid1.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/md/raid1.c +9 -13
@@ -1483,6 +1483,7 @@ static bool raid1_write_request(struct mddev *mddev, struct bio *bio,unsigned long flags;int first_clone;bool write_behind = false; +bool atomic = bio->bi_opf &REQ_ATOMIC ;bool is_discard =op_is_discard (bio->bi_opf);sector_t sector = bio->bi_iter.bi_sector;
@@ -1529,6 +1530,8 @@ static bool raid1_write_request(struct mddev *mddev, struct bio *bio,*/ if (!is_discard && rdev &&test_bit (WriteMostly, &rdev->flags)) write_behind = true; +if (atomic && max_sectors >BIO_MAX_VECS * (PAGE_SIZE >>9 )) + write_behind = false; r1_bio->bios[i] =NULL ;if (!rdev ||test_bit (Faulty, &rdev->flags))
@@ -1554,19 +1557,6 @@ static bool raid1_write_request(struct mddev *mddev, struct bio *bio,if (is_bad) {int good_sectors; -/* -* We cannot atomically write this, so just -* error in that case. It could be possible to -* atomically write other mirrors, but the -* complexity of supporting that is not worth -* the benefit. -*/ -if (bio->bi_opf &REQ_ATOMIC ) { - bio->bi_status =BLK_STS_NOTSUPP ; -bio_endio (bio); - goto err_dec_pending; - } - good_sectors = first_bad - sector;if (good_sectors < max_sectors) max_sectors = good_sectors;
@@ -1587,6 +1577,11 @@ static bool raid1_write_request(struct mddev *mddev, struct bio *bio, max_sectors =min_t (int, max_sectors,BIO_MAX_VECS * (PAGE_SIZE >>9 ));if (max_sectors <bio_sectors (bio)) { +if (atomic) { +bio_io_error (bio); + goto err_dec_pending; + } + bio =bio_submit_split_bioset (bio, max_sectors, &conf->bio_split);if (!bio)
@@ -3175,6 +3170,7 @@ static int raid1_set_limits(struct mddev *mddev)md_init_stacking_limits (&lim); lim.max_write_zeroes_sectors =0 ; lim.max_hw_wzeroes_unmap_sectors =0 ; + lim.chunk_sectors =BARRIER_UNIT_SECTOR_SIZE ; lim.logical_block_size = mddev->logical_block_size; lim.features |=BLK_FEAT_ATOMIC_WRITES ; lim.features |=BLK_FEAT_PCI_P2PDMA ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 776/1815 md/raid10: consistently fail atomic writes that require splitting
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit 3409bf2f9678d769a4c33bd232a3571c51fac481 ]
RAID10 currently handles one badblock path explicitly by failing atomic writes with EIO. However, another badblock path can also reduce the writable range and force the bio through bio_submit_split_bioset(), which implicitly completes the bio with EINVAL.
Fix this by handling atomic writes in the common split check. If RAID10 determines that an atomic write would require splitting, complete the bio with EIO.
--- drivers/md/raid10.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/md/raid10.c +4 -10
@@ -1333,6 +1333,7 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio,int i, k;sector_t sectors;int max_sectors; +bool atomic = bio->bi_opf &REQ_ATOMIC ; if ((mddev_is_clustered(mddev) && mddev->cluster_ops->area_resyncing(mddev, WRITE,
@@ -1420,16 +1421,6 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio,if (is_bad) {int good_sectors; -/* -* We cannot atomically write this, so just -* error in that case. It could be possible to -* atomically write other mirrors, but the -* complexity of supporting that is not worth -* the benefit. -*/ -if (bio->bi_opf &REQ_ATOMIC ) - goto err_handle; - good_sectors = first_bad - dev_sector;if (good_sectors < max_sectors) max_sectors = good_sectors;
@@ -1449,6 +1440,9 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio, r10_bio->sectors = max_sectors;if (r10_bio->sectors <bio_sectors (bio)) { +if (atomic) + goto err_handle; +allow_barrier (conf); bio =bio_submit_split_bioset (bio, r10_bio->sectors, &conf->bio_split);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 777/1815 PCI: dwc: ep: Clear MSI iATU mapping in dw_pcie_ep_cleanup()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 36637958726a4bbc630c0848eb3eb07cbfae89c2 ]
The MSI iATU mapping is currently only cleared when the endpoint is stopped via configfs or when the host updates the MSI address/size. This avoids redundant iATU reconfiguration every time the endpoint raises an MSI interrupt.
However, a fundamental reset triggered by PERST# assert/deassert resets all iATU inbound/outbound registers without going through the configfs stop path. If the host also retains the same MSI address/size after PERST# deassert, the driver never clears the stale MSI iATU mapping. It then continues using this stale mapping to raise the MSI interrupts, which can cause IOMMU faults and MSI failures on the host.
Fix this by clearing the MSI iATU mapping inside dw_pcie_ep_cleanup(), which is already called as part of the PERST# assert/deassert sequence. This unmaps the MSI iATU region and sets the msi_iatu_mapped flag to false, ensuring that dw_pcie_ep_raise_msi_irq() performs a fresh iATU mapping on its next invocation, regardless of whether the host changed the MSI address/size.
--- drivers/pci/controller/dwc/pcie-designware-ep.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/controller/dwc/pcie-designware-ep.c +5 -0
@@ -1153,6 +1153,11 @@ void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +if (ep->msi_iatu_mapped) { +dw_pcie_ep_unmap_addr (ep->epc,0 ,0 , ep->msi_mem_phys); + ep->msi_iatu_mapped = false; + } +dwc_pcie_debugfs_deinit (pci);dw_pcie_edma_remove (pci); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 778/1815 rcu: Mark accesses to ->rcu_urgent_qs and ->rcu_need_heavy_qs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Itai Handler <[email protected]>
[ Upstream commit 27d73e81195b395270117ff77c47be2ed9b09b12 ]
rcu_all_qs() and rcu_note_context_switch() read/clear the per-CPU ->rcu_urgent_qs and ->rcu_need_heavy_qs flags with plain raw_cpu_read() and this_cpu_write(), while the RCU core clears them with WRITE_ONCE() in rcu_disable_urgency_upon_qs(). KCSAN flags the resulting same-CPU race:
BUG: KCSAN: data-race in rcu_all_qs / rcu_disable_urgency_upon_qs
It is benign -- the flags are advisory and rcu_all_qs() re-reads ->rcu_urgent_qs with smp_load_acquire() before acting on it -- but these are the last unmarked accesses to the two flags; every other access already uses READ_ONCE()/WRITE_ONCE()/smp_*. Mark them to match. No functional change.
Reproduced on a PREEMPT_NONE, CONFIG_KCSAN_INTERRUPT_WATCHER=y kernel with a pthreads program whose threads (two per CPU) loop reading a large file:
for (;;) {
int fd = open("/proc/kallsyms", O_RDONLY);
while (read(fd, buf, sizeof(buf)) > 0)
;
close(fd);
}The read()s drive cond_resched() -> rcu_all_qs() while the busy CPUs keep the grace period urgent, so the RCU core clears the flags concurrently.
--- kernel/rcu/tree_plugin.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/rcu/tree_plugin.h +5 -5
@@ -970,7 +970,7 @@ void rcu_all_qs(void) {unsigned long flags; -if (!raw_cpu_read (rcu_data.rcu_urgent_qs)) +if (!READ_ONCE (*raw_cpu_ptr (&rcu_data.rcu_urgent_qs)))return ;preempt_disable ();// For CONFIG_PREEMPT_COUNT=y kernels /* Load rcu_urgent_qs before other flags. */
@@ -978,8 +978,8 @@ void rcu_all_qs(void)preempt_enable ();return ; } -this_cpu_write (rcu_data.rcu_urgent_qs, false); -if (unlikely (raw_cpu_read (rcu_data.rcu_need_heavy_qs))) { +WRITE_ONCE (*this_cpu_ptr (&rcu_data.rcu_urgent_qs), false); +if (unlikely (READ_ONCE (*this_cpu_ptr (&rcu_data.rcu_need_heavy_qs)))) {local_irq_save (flags);rcu_momentary_eqs ();local_irq_restore (flags);
@@ -999,8 +999,8 @@ void rcu_note_context_switch(bool preempt)/* Load rcu_urgent_qs before other flags. */ if (!smp_load_acquire (this_cpu_ptr (&rcu_data.rcu_urgent_qs))) goto out; -this_cpu_write (rcu_data.rcu_urgent_qs, false); -if (unlikely (raw_cpu_read (rcu_data.rcu_need_heavy_qs))) +WRITE_ONCE (*this_cpu_ptr (&rcu_data.rcu_urgent_qs), false); +if (unlikely (READ_ONCE (*this_cpu_ptr (&rcu_data.rcu_need_heavy_qs))))rcu_momentary_eqs (); out:rcu_tasks_qs (current, preempt);
Signature · 1 line
2.53.0