6.6.59-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 1/208 iio: accel: bma400: Fix uninitialized variable field_value in tap event handling.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Lobanov <[email protected]>
[ Upstream commit db9795a43dc944f048a37b65e06707f60f713e34 ]
In the current implementation, the local variable field_value is used without prior initialization, which may lead to reading uninitialized memory. Specifically, in the macro set_mask_bits, the initial (potentially uninitialized) value of the buffer is copied into old__, and a mask is applied to calculate new__. A similar issue was resolved in commit 6ee2a7058fea ("iio: accel: bma400: Fix smatch warning based on use of unintialized value.").
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/iio/accel/bma400_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/accel/bma400_core.c +2 -1
@@ -1219,7 +1219,8 @@ static int bma400_activity_event_en(struct bma400_data *data,static int bma400_tap_event_en (struct bma400_data *data,enum iio_event_direction dir,int state) { -unsigned int mask, field_value; +unsigned int mask; +unsigned int field_value =0 ;int ret;/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 10/208 RDMA/core: Fix ENODEV error for iWARP test over vlan
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anumula Murali Mohan Reddy <[email protected]>
[ Upstream commit 5069d7e202f640a36cf213a432296c85113a52f7 ]
If traffic is over vlan, cma_validate_port() fails to match vlan net_device ifindex with bound_if_index and results in ENODEV error. It is because rdma_copy_src_l2_addr() always assigns bound_if_index with real net_device ifindex.
This patch fixes the issue by assigning bound_if_index with vlan net_device index if traffic is over vlan.
--- drivers/infiniband/core/addr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/core/addr.c +2 -0
@@ -269,6 +269,8 @@ rdma_find_ndev_for_src_ip_rcu(struct net *net, const struct sockaddr *src_in)break ;#endif } +if (!ret && dev &&is_vlan_dev (dev)) + dev =vlan_dev_real_dev (dev);return ret ?ERR_PTR (ret) : dev; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 11/208 x86/resctrl: Avoid overflow in MB settings in bw_validate()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kletzander <[email protected]>
[ Upstream commit 2b5648416e47933939dc310c4ea1e29404f35630 ]
The resctrl schemata file supports specifying memory bandwidth associated with the Memory Bandwidth Allocation (MBA) feature via a percentage (this is the default) or bandwidth in MiBps (when resctrl is mounted with the "mba_MBps" option).
The allowed range for the bandwidth percentage is from /sys/fs/resctrl/info/MB/min_bandwidth to 100, using a granularity of /sys/fs/resctrl/info/MB/bandwidth_gran. The supported range for the MiBps bandwidth is 0 to U32_MAX.
There are two issues with parsing of MiBps memory bandwidth:
* The user provided MiBps is mistakenly rounded up to the granularity that is unique to percentage input.
* The user provided MiBps is parsed using unsigned long (thus accepting values up to ULONG_MAX), and then assigned to u32 that could result in overflow.
Do not round up the MiBps value and parse user provided bandwidth as the u32 it is intended to be. Use the appropriate kstrtou32() that can detect out of range values.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +14 -9
@@ -27,10 +27,10 @@* hardware. The allocated bandwidth percentage is rounded to the next * control step available on the hardware. */ -static bool bw_validate (char *buf,unsigned long *data,struct rdt_resource *r) +static bool bw_validate (char *buf,u32 *data,struct rdt_resource *r) { -unsigned long bw;int ret; +u32 bw;/* * Only linear delay values is supported for current Intel SKUs.
@@ -40,16 +40,21 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)return false; } - ret =kstrtoul (buf,10 , &bw); + ret =kstrtou32 (buf,10 , &bw);if (ret) { -rdt_last_cmd_printf ("Non-decimal digit in MB value %s\n" , buf); +rdt_last_cmd_printf ("Invalid MB value %s\n" , buf);return false; } -if ((bw < r->membw.min_bw || bw > r->default_ctrl) && - !is_mba_sc (r)) { -rdt_last_cmd_printf ("MB value %ld out of range [%d,%d]\n" , bw, - r->membw.min_bw, r->default_ctrl); +/* Nothing else to do if software controller is enabled. */ +if (is_mba_sc (r)) { + *data = bw; +return true; + } + +if (bw < r->membw.min_bw || bw > r->default_ctrl) { +rdt_last_cmd_printf ("MB value %u out of range [%d,%d]\n" , + bw, r->membw.min_bw, r->default_ctrl);return false; }
@@ -63,7 +68,7 @@ int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,struct resctrl_staged_config *cfg;u32 closid = data->rdtgrp->closid;struct rdt_resource *r = s->res; -unsigned long bw_val; +u32 bw_val; cfg = &d->staged_config[s->conf_type];if (cfg->have_new_ctrl) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 12/208 ARM: dts: bcm2837-rpi-cm3-io3: Fix HDMI hpd-gpio pin
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Klink <[email protected]>
[ Upstream commit dc7785e4723510616d776862ddb4c08857a1bdb2 ]
HDMI_HPD_N_1V8 is connected to GPIO pin 0, not 1.
This fixes HDMI hotplug/output detection.
See https://datasheets.raspberrypi.com/cm/cm3-schematics.pdf
--- arch/arm/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dts +1 -1
@@ -77,7 +77,7 @@ }; &hdmi { - hpd-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>; + hpd-gpios = <&expgpio 0 GPIO_ACTIVE_LOW>; power-domains = <&power RPI_POWER_DOMAIN_HDMI>; status = "okay"; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 13/208 bpf: Add missed value to kprobe perf link info
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit 3acf8ace68230e9558cf916847f1cc9f208abdf1 ]
Add missed value to kprobe attached through perf link info to hold the stats of missed kprobe handler execution.
The kprobe's missed counter gets incremented when kprobe handler is not executed due to another kprobe running on the same cpu.
Stable-dep-of: 4deecdd29cf2 ("bpf: fix unpopulated name_len field in perf_event link info")
--- include/linux/trace_events.h | 6 ++++-- include/uapi/linux/bpf.h | 1 + kernel/bpf/syscall.c | 14 ++++++++------ kernel/trace/bpf_trace.c | 5 +++-- kernel/trace/trace_kprobe.c | 14 +++++++++++--- tools/include/uapi/linux/bpf.h | 1 + 6 files changed, 28 insertions(+), 13 deletions(-)
include/linux/trace_events.h +4 -2
@@ -765,7 +765,8 @@ struct bpf_raw_event_map *bpf_get_raw_tracepoint(const char *name);void bpf_put_raw_tracepoint (struct bpf_raw_event_map *btp);int bpf_get_perf_event_info (const struct perf_event *event,u32 *prog_id,u32 *fd_type,const char **buf, -u64 *probe_offset,u64 *probe_addr); +u64 *probe_offset,u64 *probe_addr, +unsigned long *missed);int bpf_kprobe_multi_link_attach (const union bpf_attr *attr,struct bpf_prog *prog);int bpf_uprobe_multi_link_attach (const union bpf_attr *attr,struct bpf_prog *prog);#else
@@ -805,7 +806,7 @@ static inline void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp)static inline int bpf_get_perf_event_info (const struct perf_event *event,u32 *prog_id,u32 *fd_type,const char **buf,u64 *probe_offset, -u64 *probe_addr) +u64 *probe_addr,unsigned long *missed) {return -EOPNOTSUPP ; }
@@ -880,6 +881,7 @@ extern void perf_kprobe_destroy(struct perf_event *event);extern int bpf_get_kprobe_info (const struct perf_event *event,u32 *fd_type,const char **symbol,u64 *probe_offset,u64 *probe_addr, +unsigned long *missed,bool perf_type_tracepoint);#endif #ifdef CONFIG_UPROBE_EVENTS
include/uapi/linux/bpf.h +1 -0
@@ -6562,6 +6562,7 @@ struct bpf_link_info {__u32 name_len;__u32 offset;/* offset from func_name */ __u64 addr; +__u64 missed; } kprobe;/* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ struct {__aligned_u64 tp_name;/* in/out */
kernel/bpf/syscall.c +8 -6
@@ -3444,7 +3444,7 @@ static void bpf_perf_link_dealloc(struct bpf_link *link)static int bpf_perf_link_fill_common (const struct perf_event *event,char __user *uname,u32 ulen,u64 *probe_offset,u64 *probe_addr, -u32 *fd_type) +u32 *fd_type,unsigned long *missed) {const char *buf;u32 prog_id;
@@ -3455,7 +3455,7 @@ static int bpf_perf_link_fill_common(const struct perf_event *event,return -EINVAL ; err =bpf_get_perf_event_info (event, &prog_id, fd_type, &buf, - probe_offset, probe_addr); + probe_offset, probe_addr, missed);if (err)return err;if (!uname)
@@ -3478,6 +3478,7 @@ static int bpf_perf_link_fill_common(const struct perf_event *event,static int bpf_perf_link_fill_kprobe (const struct perf_event *event,struct bpf_link_info *info) { +unsigned long missed;char __user *uname;u64 addr, offset;u32 ulen, type;
@@ -3486,7 +3487,7 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event, uname =u64_to_user_ptr (info->perf_event.kprobe.func_name); ulen = info->perf_event.kprobe.name_len; err =bpf_perf_link_fill_common (event, uname, ulen, &offset, &addr, - &type); + &type, &missed);if (err)return err;if (type ==BPF_FD_TYPE_KRETPROBE )
@@ -3495,6 +3496,7 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event, info->perf_event.type =BPF_PERF_EVENT_KPROBE ; info->perf_event.kprobe.offset = offset; + info->perf_event.kprobe.missed = missed;if (!kallsyms_show_value (current_cred ())) addr =0 ; info->perf_event.kprobe.addr = addr;
@@ -3514,7 +3516,7 @@ static int bpf_perf_link_fill_uprobe(const struct perf_event *event, uname =u64_to_user_ptr (info->perf_event.uprobe.file_name); ulen = info->perf_event.uprobe.name_len; err =bpf_perf_link_fill_common (event, uname, ulen, &offset, &addr, - &type); + &type,NULL );if (err)return err;
@@ -3550,7 +3552,7 @@ static int bpf_perf_link_fill_tracepoint(const struct perf_event *event, uname =u64_to_user_ptr (info->perf_event.tracepoint.tp_name); ulen = info->perf_event.tracepoint.name_len; info->perf_event.type =BPF_PERF_EVENT_TRACEPOINT ; -return bpf_perf_link_fill_common (event, uname, ulen,NULL ,NULL ,NULL ); +return bpf_perf_link_fill_common (event, uname, ulen,NULL ,NULL ,NULL ,NULL ); } static int bpf_perf_link_fill_perf_event(const struct perf_event *event,
@@ -4897,7 +4899,7 @@ static int bpf_task_fd_query(const union bpf_attr *attr, err =bpf_get_perf_event_info (event, &prog_id, &fd_type, &buf, &probe_offset, - &probe_addr); + &probe_addr,NULL );if (!err) err = bpf_task_fd_query_copy(attr, uattr, prog_id, fd_type, buf,
kernel/trace/bpf_trace.c +3 -2
@@ -2389,7 +2389,8 @@ int bpf_probe_unregister(struct bpf_raw_event_map *btp, struct bpf_prog *prog)int bpf_get_perf_event_info (const struct perf_event *event,u32 *prog_id,u32 *fd_type,const char **buf, -u64 *probe_offset,u64 *probe_addr) +u64 *probe_offset,u64 *probe_addr, +unsigned long *missed) {bool is_tracepoint, is_syscall_tp;struct bpf_prog *prog;
@@ -2424,7 +2425,7 @@ int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,#ifdef CONFIG_KPROBE_EVENTS if (flags &TRACE_EVENT_FL_KPROBE ) err =bpf_get_kprobe_info (event, fd_type, buf, - probe_offset, probe_addr, + probe_offset, probe_addr, missed, event->attr.type ==PERF_TYPE_TRACEPOINT );#endif #ifdef CONFIG_UPROBE_EVENTS
kernel/trace/trace_kprobe.c +11 -3
@@ -1249,6 +1249,12 @@ static const struct file_operations kprobe_events_ops = { .write = probes_write, }; +static unsigned long trace_kprobe_missed (struct trace_kprobe *tk) +{ +return trace_kprobe_is_return (tk) ? + tk->rp.kp.nmissed + tk->rp.nmissed : tk->rp.kp.nmissed; +} +/* Probes profiling interfaces */ static int probes_profile_seq_show (struct seq_file *m,void *v) {
@@ -1260,8 +1266,7 @@ static int probes_profile_seq_show(struct seq_file *m, void *v)return 0 ; tk =to_trace_kprobe (ev); - nmissed =trace_kprobe_is_return (tk) ? - tk->rp.kp.nmissed + tk->rp.nmissed : tk->rp.kp.nmissed; + nmissed =trace_kprobe_missed (tk); seq_printf(m, " %-44s %15lu %15lu\n", trace_probe_name(&tk->tp), trace_kprobe_nhit(tk),
@@ -1607,7 +1612,8 @@ NOKPROBE_SYMBOL(kretprobe_perf_func);int bpf_get_kprobe_info (const struct perf_event *event,u32 *fd_type,const char **symbol,u64 *probe_offset, -u64 *probe_addr,bool perf_type_tracepoint) +u64 *probe_addr,unsigned long *missed, +bool perf_type_tracepoint) {const char *pevent =trace_event_name (event->tp_event);const char *group = event->tp_event->class->system;
@@ -1626,6 +1632,8 @@ int bpf_get_kprobe_info(const struct perf_event *event, u32 *fd_type, *probe_addr =kallsyms_show_value (current_cred ()) ? (unsigned long )tk->rp.kp.addr :0 ; *symbol = tk->symbol; +if (missed) + *missed =trace_kprobe_missed (tk); return 0; }#endif /* CONFIG_PERF_EVENTS */
tools/include/uapi/linux/bpf.h +1 -0
@@ -6565,6 +6565,7 @@ struct bpf_link_info {__u32 name_len;__u32 offset;/* offset from func_name */ __u64 addr; +__u64 missed; } kprobe;/* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ struct {__aligned_u64 tp_name;/* in/out */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 14/208 bpf: Add cookie to perf_event bpf_link_info records
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit d5c16492c66fbfca85f36e42363d32212df5927b ]
At the moment we don't store cookie for perf_event probes, while we do that for the rest of the probes.
Adding cookie fields to struct bpf_link_info perf event probe records:
perf_event.uprobe
perf_event.kprobe
perf_event.tracepoint
perf_event.perf_event
And the code to store that in bpf_link_info struct.
Stable-dep-of: 4deecdd29cf2 ("bpf: fix unpopulated name_len field in perf_event link info")
--- include/uapi/linux/bpf.h | 6 ++++++ kernel/bpf/syscall.c | 4 ++++ tools/include/uapi/linux/bpf.h | 6 ++++++ 3 files changed, 16 insertions(+)
include/uapi/linux/bpf.h +6 -0
@@ -6556,6 +6556,7 @@ struct bpf_link_info {__aligned_u64 file_name;/* in/out */ __u32 name_len;__u32 offset;/* offset from file_name */ +__u64 cookie; } uprobe;/* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */ struct {__aligned_u64 func_name;/* in/out */
@@ -6563,14 +6564,19 @@ struct bpf_link_info {__u32 offset;/* offset from func_name */ __u64 addr;__u64 missed; +__u64 cookie; } kprobe;/* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ struct {__aligned_u64 tp_name;/* in/out */ __u32 name_len; + __u32 :32; +__u64 cookie; } tracepoint;/* BPF_PERF_EVENT_TRACEPOINT */ struct {__u64 config;__u32 type; + __u32 :32; +__u64 cookie; } event;/* BPF_PERF_EVENT_EVENT */ }; } perf_event;
kernel/bpf/syscall.c +4 -0
@@ -3500,6 +3500,7 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event,if (!kallsyms_show_value (current_cred ())) addr =0 ; info->perf_event.kprobe.addr = addr; + info->perf_event.kprobe.cookie = event->bpf_cookie; return 0; }#endif
@@ -3525,6 +3526,7 @@ static int bpf_perf_link_fill_uprobe(const struct perf_event *event, else info->perf_event.type = BPF_PERF_EVENT_UPROBE; info->perf_event.uprobe.offset = offset; + info->perf_event.uprobe.cookie = event->bpf_cookie; return 0; }#endif
@@ -3552,6 +3554,7 @@ static int bpf_perf_link_fill_tracepoint(const struct perf_event *event, uname =u64_to_user_ptr (info->perf_event.tracepoint.tp_name); ulen = info->perf_event.tracepoint.name_len; info->perf_event.type =BPF_PERF_EVENT_TRACEPOINT ; + info->perf_event.tracepoint.cookie = event->bpf_cookie;return bpf_perf_link_fill_common (event, uname, ulen,NULL ,NULL ,NULL ,NULL ); }
@@ -3560,6 +3563,7 @@ static int bpf_perf_link_fill_perf_event(const struct perf_event *event, { info->perf_event.event.type = event->attr.type; info->perf_event.event.config = event->attr.config; + info->perf_event.event.cookie = event->bpf_cookie; info->perf_event.type =BPF_PERF_EVENT_EVENT ;return 0 ; }
tools/include/uapi/linux/bpf.h +6 -0
@@ -6559,6 +6559,7 @@ struct bpf_link_info {__aligned_u64 file_name;/* in/out */ __u32 name_len;__u32 offset;/* offset from file_name */ +__u64 cookie; } uprobe;/* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */ struct {__aligned_u64 func_name;/* in/out */
@@ -6566,14 +6567,19 @@ struct bpf_link_info {__u32 offset;/* offset from func_name */ __u64 addr;__u64 missed; +__u64 cookie; } kprobe;/* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ struct {__aligned_u64 tp_name;/* in/out */ __u32 name_len; + __u32 :32; +__u64 cookie; } tracepoint;/* BPF_PERF_EVENT_TRACEPOINT */ struct {__u64 config;__u32 type; + __u32 :32; +__u64 cookie; } event;/* BPF_PERF_EVENT_EVENT */ }; } perf_event;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 15/208 bpf: fix unpopulated name_len field in perf_event link info
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyrone Wu <[email protected]>
[ Upstream commit 4deecdd29cf29844c7bd164d72dc38d2e672f64e ]
Previously when retrieving bpf_link_info.perf_event for kprobe/uprobe/tracepoint, the name_len field was not populated by the kernel, leaving it to reflect the value initially set by the user. This behavior was inconsistent with how other input/output string buffer fields function (e.g. raw_tracepoint.tp_name_len).
This patch fills name_len with the actual size of the string name.
--- kernel/bpf/syscall.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
kernel/bpf/syscall.c +22 -7
@@ -3442,15 +3442,16 @@ static void bpf_perf_link_dealloc(struct bpf_link *link) }static int bpf_perf_link_fill_common (const struct perf_event *event, -char __user *uname,u32 ulen, +char __user *uname,u32 *ulenp,u64 *probe_offset,u64 *probe_addr,u32 *fd_type,unsigned long *missed) {const char *buf; -u32 prog_id; +u32 prog_id, ulen;size_t len;int err; + ulen = *ulenp;if (!ulen ^ !uname)return -EINVAL ;
@@ -3458,10 +3459,17 @@ static int bpf_perf_link_fill_common(const struct perf_event *event, probe_offset, probe_addr, missed);if (err)return err; + +if (buf) { + len =strlen (buf); + *ulenp = len +1 ; + }else { + *ulenp =1 ; + }if (!uname)return 0 ; +if (buf) { - len =strlen (buf); err =bpf_copy_to_user (uname, buf, ulen, len);if (err)return err;
@@ -3486,7 +3494,7 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event, uname =u64_to_user_ptr (info->perf_event.kprobe.func_name); ulen = info->perf_event.kprobe.name_len; - err =bpf_perf_link_fill_common (event, uname, ulen, &offset, &addr, + err =bpf_perf_link_fill_common (event, uname, &ulen, &offset, &addr, &type, &missed);if (err)return err;
@@ -3494,7 +3502,7 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event, info->perf_event.type =BPF_PERF_EVENT_KRETPROBE ; else info->perf_event.type = BPF_PERF_EVENT_KPROBE; - + info->perf_event.kprobe.name_len = ulen; info->perf_event.kprobe.offset = offset; info->perf_event.kprobe.missed = missed;if (!kallsyms_show_value (current_cred ()))
@@ -3516,7 +3524,7 @@ static int bpf_perf_link_fill_uprobe(const struct perf_event *event, uname =u64_to_user_ptr (info->perf_event.uprobe.file_name); ulen = info->perf_event.uprobe.name_len; - err =bpf_perf_link_fill_common (event, uname, ulen, &offset, &addr, + err =bpf_perf_link_fill_common (event, uname, &ulen, &offset, &addr, &type,NULL );if (err)return err;
@@ -3525,6 +3533,7 @@ static int bpf_perf_link_fill_uprobe(const struct perf_event *event, info->perf_event.type =BPF_PERF_EVENT_URETPROBE ; else info->perf_event.type = BPF_PERF_EVENT_UPROBE; + info->perf_event.uprobe.name_len = ulen; info->perf_event.uprobe.offset = offset; info->perf_event.uprobe.cookie = event->bpf_cookie;return 0 ;
@@ -3550,12 +3559,18 @@ static int bpf_perf_link_fill_tracepoint(const struct perf_event *event, {char __user *uname;u32 ulen; +int err; uname =u64_to_user_ptr (info->perf_event.tracepoint.tp_name); ulen = info->perf_event.tracepoint.name_len; + err =bpf_perf_link_fill_common (event, uname, &ulen,NULL ,NULL ,NULL ,NULL ); +if (err) +return err; + info->perf_event.type =BPF_PERF_EVENT_TRACEPOINT ; + info->perf_event.tracepoint.name_len = ulen; info->perf_event.tracepoint.cookie = event->bpf_cookie; -return bpf_perf_link_fill_common (event, uname, ulen,NULL ,NULL ,NULL ,NULL ); +return 0 ; } static int bpf_perf_link_fill_perf_event(const struct perf_event *event,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 16/208 selftests/bpf: Use bpf_link__destroy in fill_link_info tests
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit 1703612885723869064f18e8816c6f3f87987748 ]
The fill_link_info test keeps skeleton open and just creates various links. We are wrongly calling bpf_link__detach after each test to close them, we need to call bpf_link__destroy.
Stable-dep-of: 4538a38f654a ("selftests/bpf: fix perf_event link info name_len assertion")
--- .../selftests/bpf/prog_tests/fill_link_info.c | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-)
tools/testing/selftests/bpf/prog_tests/fill_link_info.c +23 -21
@@ -140,14 +140,14 @@ static void test_kprobe_fill_link_info(struct test_fill_link_info *skel, .retprobe = type == BPF_PERF_EVENT_KRETPROBE, );ssize_t entry_offset =0 ; +struct bpf_link *link;int link_fd, err; - skel->links.kprobe_run =bpf_program__attach_kprobe_opts (skel->progs.kprobe_run, -KPROBE_FUNC , &opts); -if (!ASSERT_OK_PTR (skel->links.kprobe_run,"attach_kprobe" )) + link =bpf_program__attach_kprobe_opts (skel->progs.kprobe_run,KPROBE_FUNC , &opts); +if (!ASSERT_OK_PTR (link,"attach_kprobe" ))return ; - link_fd =bpf_link__fd (skel->links.kprobe_run); + link_fd =bpf_link__fd (link);if (!invalid) {/* See also arch_adjust_kprobe_addr(). */ if (skel->kconfig->CONFIG_X86_KERNEL_IBT)
@@ -157,39 +157,41 @@ static void test_kprobe_fill_link_info(struct test_fill_link_info *skel, }else {kprobe_fill_invalid_user_buffer (link_fd); } -bpf_link__detach (skel->links.kprobe_run); +bpf_link__destroy (link); }static void test_tp_fill_link_info (struct test_fill_link_info *skel) { +struct bpf_link *link;int link_fd, err; - skel->links.tp_run =bpf_program__attach_tracepoint (skel->progs.tp_run,TP_CAT ,TP_NAME ); -if (!ASSERT_OK_PTR (skel->links.tp_run,"attach_tp" )) + link =bpf_program__attach_tracepoint (skel->progs.tp_run,TP_CAT ,TP_NAME ); +if (!ASSERT_OK_PTR (link,"attach_tp" ))return ; - link_fd =bpf_link__fd (skel->links.tp_run); + link_fd =bpf_link__fd (link); err =verify_perf_link_info (link_fd,BPF_PERF_EVENT_TRACEPOINT ,0 ,0 ,0 );ASSERT_OK (err,"verify_perf_link_info" ); -bpf_link__detach (skel->links.tp_run); +bpf_link__destroy (link); }static void test_uprobe_fill_link_info (struct test_fill_link_info *skel,enum bpf_perf_event_type type) { +struct bpf_link *link;int link_fd, err; - skel->links.uprobe_run =bpf_program__attach_uprobe (skel->progs.uprobe_run, - type ==BPF_PERF_EVENT_URETPROBE , -0 ,/* self pid */ -UPROBE_FILE , uprobe_offset); -if (!ASSERT_OK_PTR (skel->links.uprobe_run,"attach_uprobe" )) + link =bpf_program__attach_uprobe (skel->progs.uprobe_run, + type ==BPF_PERF_EVENT_URETPROBE , +0 ,/* self pid */ +UPROBE_FILE , uprobe_offset); +if (!ASSERT_OK_PTR (link,"attach_uprobe" ))return ; - link_fd =bpf_link__fd (skel->links.uprobe_run); + link_fd =bpf_link__fd (link); err =verify_perf_link_info (link_fd, type,0 , uprobe_offset,0 );ASSERT_OK (err,"verify_perf_link_info" ); -bpf_link__detach (skel->links.uprobe_run); +bpf_link__destroy (link); }static int verify_kmulti_link_info (int fd,bool retprobe)
@@ -278,24 +280,24 @@ static void test_kprobe_multi_fill_link_info(struct test_fill_link_info *skel, bool retprobe, bool invalid) {LIBBPF_OPTS (bpf_kprobe_multi_opts ,opts ); +struct bpf_link *link;int link_fd, err; opts.syms = kmulti_syms; opts.cnt =KMULTI_CNT ; opts.retprobe = retprobe; - skel->links.kmulti_run =bpf_program__attach_kprobe_multi_opts (skel->progs.kmulti_run, -NULL , &opts); -if (!ASSERT_OK_PTR (skel->links.kmulti_run,"attach_kprobe_multi" )) + link =bpf_program__attach_kprobe_multi_opts (skel->progs.kmulti_run,NULL , &opts); +if (!ASSERT_OK_PTR (link,"attach_kprobe_multi" ))return ; - link_fd =bpf_link__fd (skel->links.kmulti_run); + link_fd =bpf_link__fd (link);if (!invalid) { err =verify_kmulti_link_info (link_fd, retprobe);ASSERT_OK (err,"verify_kmulti_link_info" ); }else {verify_kmulti_invalid_user_buffer (link_fd); } -bpf_link__detach (skel->links.kmulti_run); +bpf_link__destroy (link); }void test_fill_link_info (void )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 17/208 selftests/bpf: Add cookies check for perf_event fill_link_info test
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit d74179708473c649c653f1db280e29875a532e99 ]
Now that we get cookies for perf_event probes, adding tests for cookie for kprobe/uprobe/tracepoint.
The perf_event test needs to be added completely and is coming in following change.
Stable-dep-of: 4538a38f654a ("selftests/bpf: fix perf_event link info name_len assertion")
--- .../selftests/bpf/prog_tests/fill_link_info.c | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/prog_tests/fill_link_info.c +21 -5
@@ -30,6 +30,8 @@ static noinline void uprobe_func(void) asmvolatile ("" ); } +#define PERF_EVENT_COOKIE 0xdeadbeef +static int verify_perf_link_info (int fd,enum bpf_perf_event_type type,long addr,ssize_t offset,ssize_t entry_offset) {
@@ -61,6 +63,8 @@ static int verify_perf_link_info(int fd, enum bpf_perf_event_type type, long addASSERT_EQ (info.perf_event.kprobe.addr, addr + entry_offset,"kprobe_addr" ); +ASSERT_EQ (info.perf_event.kprobe.cookie,PERF_EVENT_COOKIE ,"kprobe_cookie" ); +if (!info.perf_event.kprobe.func_name) {ASSERT_EQ (info.perf_event.kprobe.name_len,0 ,"name_len" ); info.perf_event.kprobe.func_name =ptr_to_u64 (&buf);
@@ -80,6 +84,8 @@ static int verify_perf_link_info(int fd, enum bpf_perf_event_type type, long add goto again; } +ASSERT_EQ (info.perf_event.tracepoint.cookie,PERF_EVENT_COOKIE ,"tracepoint_cookie" ); + err =strncmp (u64_to_ptr (info.perf_event.tracepoint.tp_name),TP_NAME ,strlen (TP_NAME ));ASSERT_EQ (err,0 ,"cmp_tp_name" );
@@ -95,6 +101,8 @@ static int verify_perf_link_info(int fd, enum bpf_perf_event_type type, long add goto again; } +ASSERT_EQ (info.perf_event.uprobe.cookie,PERF_EVENT_COOKIE ,"uprobe_cookie" ); + err =strncmp (u64_to_ptr (info.perf_event.uprobe.file_name),UPROBE_FILE ,strlen (UPROBE_FILE ));ASSERT_EQ (err,0 ,"cmp_file_name" );
@@ -138,6 +146,7 @@ static void test_kprobe_fill_link_info(struct test_fill_link_info *skel,DECLARE_LIBBPF_OPTS (bpf_kprobe_opts, opts, .attach_mode = PROBE_ATTACH_MODE_LINK, .retprobe = type == BPF_PERF_EVENT_KRETPROBE, + .bpf_cookie = PERF_EVENT_COOKIE, );ssize_t entry_offset =0 ;struct bpf_link *link;
@@ -162,10 +171,13 @@ static void test_kprobe_fill_link_info(struct test_fill_link_info *skel,static void test_tp_fill_link_info (struct test_fill_link_info *skel) { +DECLARE_LIBBPF_OPTS (bpf_tracepoint_opts, opts, + .bpf_cookie = PERF_EVENT_COOKIE, + );struct bpf_link *link;int link_fd, err; - link =bpf_program__attach_tracepoint (skel->progs.tp_run,TP_CAT ,TP_NAME ); + link =bpf_program__attach_tracepoint_opts (skel->progs.tp_run,TP_CAT ,TP_NAME , &opts);if (!ASSERT_OK_PTR (link,"attach_tp" ))return ;
@@ -178,13 +190,17 @@ static void test_tp_fill_link_info(struct test_fill_link_info *skel)static void test_uprobe_fill_link_info (struct test_fill_link_info *skel,enum bpf_perf_event_type type) { +DECLARE_LIBBPF_OPTS (bpf_uprobe_opts, opts, + .retprobe = type == BPF_PERF_EVENT_URETPROBE, + .bpf_cookie = PERF_EVENT_COOKIE, + );struct bpf_link *link;int link_fd, err; - link =bpf_program__attach_uprobe (skel->progs.uprobe_run, - type ==BPF_PERF_EVENT_URETPROBE , -0 ,/* self pid */ -UPROBE_FILE , uprobe_offset); + link =bpf_program__attach_uprobe_opts (skel->progs.uprobe_run, +0 ,/* self pid */ +UPROBE_FILE , uprobe_offset, + &opts);if (!ASSERT_OK_PTR (link,"attach_uprobe" ))return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 18/208 selftests/bpf: fix perf_event link info name_len assertion
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyrone Wu <[email protected]>
[ Upstream commit 4538a38f654a1c292fe489a9b66179262bfed088 ]
Fix name_len field assertions in bpf_link_info.perf_event for kprobe/uprobe/tracepoint to validate correct name size instead of 0.
--- tools/testing/selftests/bpf/prog_tests/fill_link_info.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/fill_link_info.c +6 -3
@@ -65,8 +65,9 @@ static int verify_perf_link_info(int fd, enum bpf_perf_event_type type, long addASSERT_EQ (info.perf_event.kprobe.cookie,PERF_EVENT_COOKIE ,"kprobe_cookie" ); +ASSERT_EQ (info.perf_event.kprobe.name_len,strlen (KPROBE_FUNC ) +1 , +"name_len" );if (!info.perf_event.kprobe.func_name) { -ASSERT_EQ (info.perf_event.kprobe.name_len,0 ,"name_len" ); info.perf_event.kprobe.func_name =ptr_to_u64 (&buf); info.perf_event.kprobe.name_len =sizeof (buf); goto again;
@@ -77,8 +78,9 @@ static int verify_perf_link_info(int fd, enum bpf_perf_event_type type, long addASSERT_EQ (err,0 ,"cmp_kprobe_func_name" );break ;case BPF_PERF_EVENT_TRACEPOINT : +ASSERT_EQ (info.perf_event.tracepoint.name_len,strlen (TP_NAME ) +1 , +"name_len" );if (!info.perf_event.tracepoint.tp_name) { -ASSERT_EQ (info.perf_event.tracepoint.name_len,0 ,"name_len" ); info.perf_event.tracepoint.tp_name =ptr_to_u64 (&buf); info.perf_event.tracepoint.name_len =sizeof (buf); goto again;
@@ -94,8 +96,9 @@ static int verify_perf_link_info(int fd, enum bpf_perf_event_type type, long addcase BPF_PERF_EVENT_URETPROBE :ASSERT_EQ (info.perf_event.uprobe.offset, offset,"uprobe_offset" ); +ASSERT_EQ (info.perf_event.uprobe.name_len,strlen (UPROBE_FILE ) +1 , +"name_len" );if (!info.perf_event.uprobe.file_name) { -ASSERT_EQ (info.perf_event.uprobe.name_len,0 ,"name_len" ); info.perf_event.uprobe.file_name =ptr_to_u64 (&buf); info.perf_event.uprobe.name_len =sizeof (buf); goto again;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 19/208 s390/pci: Handle PCI error codes other than 0x3a
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Schnelle <[email protected]>
[ Upstream commit 3cd03ea57e8e16cc78cc357d5e9f26078426f236 ]
The Linux implementation of PCI error recovery for s390 was based on the understanding that firmware error recovery is a two step process with an optional initial error event to indicate the cause of the error if known followed by either error event 0x3A (Success) or 0x3B (Failure) to indicate whether firmware was able to recover. While this has been the case in testing and the error cases seen in the wild it turns out this is not correct. Instead firmware only generates 0x3A for some error and service scenarios and expects the OS to perform recovery for all PCI events codes except for those indicating permanent error (0x3B, 0x40) and those indicating errors on the function measurement block (0x2A, 0x2B, 0x2C). Align Linux behavior with these expectations.
--- arch/s390/pci/pci_event.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
arch/s390/pci/pci_event.c +9 -8
@@ -272,18 +272,19 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf) goto no_pdev;switch (ccdf->pec) { -case 0x003a :/* Service Action or Error Recovery Successful */ +case 0x002a :/* Error event concerns FMB */ +case 0x002b : +case 0x002c : +break ; +case 0x0040 :/* Service Action or Error Recovery Failed */ +case 0x003b : +zpci_event_io_failure (pdev, pci_channel_io_perm_failure); +break ; +default :/* PCI function left in the error state attempt to recover */ ers_res =zpci_event_attempt_error_recovery (pdev);if (ers_res !=PCI_ERS_RESULT_RECOVERED )zpci_event_io_failure (pdev, pci_channel_io_perm_failure);break ; -default : -/* -* Mark as frozen not permanently failed because the device -* could be subsequently recovered by the platform. -*/ -zpci_event_io_failure (pdev, pci_channel_io_frozen); -break ; }pci_dev_put (pdev); no_pdev:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 2/208 bpf: Make sure internal and UAPI bpf_redirect flags dont overlap
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 09d88791c7cd888d5195c84733caf9183dcfbd16 ]
The bpf_redirect_info is shared between the SKB and XDP redirect paths, and the two paths use the same numeric flag values in the ri->flags field (specifically, BPF_F_BROADCAST == BPF_F_NEXTHOP). This means that if skb bpf_redirect_neigh() is used with a non-NULL params argument and, subsequently, an XDP redirect is performed using the same bpf_redirect_info struct, the XDP path will get confused and end up crashing, which syzbot managed to trigger.
With the stack-allocated bpf_redirect_info, the structure is no longer shared between the SKB and XDP paths, so the crash doesn't happen anymore. However, different code paths using identically-numbered flag values in the same struct field still seems like a bit of a mess, so this patch cleans that up by moving the flag definitions together and redefining the three flags in BPF_F_REDIRECT_INTERNAL to not overlap with the flags used for XDP. It also adds a BUILD_BUG_ON() check to make sure the overlap is not re-introduced by mistake.
--- include/uapi/linux/bpf.h | 13 +++++-------- net/core/filter.c | 8 +++++--- 2 files changed, 10 insertions(+), 11 deletions(-)
include/uapi/linux/bpf.h +5 -8
@@ -5921,11 +5921,6 @@ enum { BPF_F_MARK_ENFORCE = (1ULL << 6), }; -/* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */ -enum { -BPF_F_INGRESS = (1ULL <<0 ), -}; -/* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ enum {BPF_F_TUNINFO_IPV6 = (1ULL <<0 ),
@@ -6072,10 +6067,12 @@ enum { BPF_F_BPRM_SECUREEXEC = (1ULL << 0), }; -/* Flags for bpf_redirect_map helper */ +/* Flags for bpf_redirect and bpf_redirect_map helpers */ enum { -BPF_F_BROADCAST = (1ULL <<3 ), -BPF_F_EXCLUDE_INGRESS = (1ULL <<4 ), +BPF_F_INGRESS = (1ULL <<0 ),/* used for skb path */ +BPF_F_BROADCAST = (1ULL <<3 ),/* used for XDP path */ +BPF_F_EXCLUDE_INGRESS = (1ULL <<4 ),/* used for XDP path */ +#define BPF_F_REDIRECT_FLAGS (BPF_F_INGRESS | BPF_F_BROADCAST | BPF_F_EXCLUDE_INGRESS) };#define __bpf_md_ptr (type, name) \
net/core/filter.c +5 -3
@@ -2423,9 +2423,9 @@ static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev,/* Internal, non-exposed redirect flags. */ enum { -BPF_F_NEIGH = (1ULL <<1 ), -BPF_F_PEER = (1ULL <<2 ), -BPF_F_NEXTHOP = (1ULL <<3 ), +BPF_F_NEIGH = (1ULL <<16 ), +BPF_F_PEER = (1ULL <<17 ), +BPF_F_NEXTHOP = (1ULL <<18 ),#define BPF_F_REDIRECT_INTERNAL (BPF_F_NEIGH | BPF_F_PEER | BPF_F_NEXTHOP) };
@@ -2435,6 +2435,8 @@ BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags)struct sk_buff *clone;int ret; +BUILD_BUG_ON (BPF_F_REDIRECT_INTERNAL &BPF_F_REDIRECT_FLAGS ); +if (unlikely (flags & (~(BPF_F_INGRESS ) |BPF_F_REDIRECT_INTERNAL )))return -EINVAL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 20/208 bpf: fix kfunc btf caching for modules
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 6cb86a0fdece87e126323ec1bb19deb16a52aedf ]
The verifier contains a cache for looking up module BTF objects when calling kfuncs defined in modules. This cache uses a 'struct bpf_kfunc_btf_tab', which contains a sorted list of BTF objects that were already seen in the current verifier run, and the BTF objects are looked up by the offset stored in the relocated call instruction using bsearch().
The first time a given offset is seen, the module BTF is loaded from the file descriptor passed in by libbpf, and stored into the cache. However, there's a bug in the code storing the new entry: it stores a pointer to the new cache entry, then calls sort() to keep the cache sorted for the next lookup using bsearch(), and then returns the entry that was just stored through the stored pointer. However, because sort() modifies the list of entries in place *by value*, the stored pointer may no longer point to the right entry, in which case the wrong BTF object will be returned.
The end result of this is an intermittent bug where, if a BPF program calls two functions with the same signature in two different modules, the function from the wrong module may sometimes end up being called. Whether this happens depends on the order of the calls in the BPF program (as that affects whether sort() reorders the array of BTF objects), making it especially hard to track down. Simon, credited as reporter below, spent significant effort analysing and creating a reproducer for this issue. The reproducer is added as a selftest in a subsequent patch.
The fix is straight forward: simply don't use the stored pointer after calling sort(). Since we already have an on-stack pointer to the BTF object itself at the point where the function return, just use that, and populate it from the cache entry in the branch where the lookup succeeds.
--- kernel/bpf/verifier.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +7 -1
@@ -2799,10 +2799,16 @@ static struct btf *__find_kfunc_desc_btf(struct bpf_verifier_env *env, b->module = mod; b->offset = offset; +/* sort() reorders entries by value, so b may no longer point +* to the right entry after this +*/ sort (tab->descs, tab->nr_descs,sizeof (tab->descs[0 ]), kfunc_btf_cmp_by_off,NULL ); + }else { + btf = b->btf; } -return b->btf; + +return btf; }void bpf_free_kfunc_btf_tab (struct bpf_kfunc_btf_tab *tab)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 3/208 bpf: devmap: provide rxq after redirect
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Kauer <[email protected]>
[ Upstream commit ca9984c5f0ab3690d98b13937b2485a978c8dd73 ]
rxq contains a pointer to the device from where the redirect happened. Currently, the BPF program that was executed after a redirect via BPF_MAP_TYPE_DEVMAP* does not have it set.
This is particularly bad since accessing ingress_ifindex, e.g.
SEC("xdp")
int prog(struct xdp_md *pkt)
{
return bpf_redirect_map(&dev_redirect_map, 0, 0);
}SEC("xdp/devmap")
int prog_after_redirect(struct xdp_md *pkt)
{
bpf_printk("ifindex %i", pkt->ingress_ifindex);
return XDP_PASS;
}depends on access to rxq, so a NULL pointer gets dereferenced:
<1>[ 574.475170] BUG: kernel NULL pointer dereference, address: 0000000000000000 <1>[ 574.475188] #PF: supervisor read access in kernel mode <1>[ 574.475194] #PF: error_code(0x0000) - not-present page <6>[ 574.475199] PGD 0 P4D 0 <4>[ 574.475207] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI <4>[ 574.475217] CPU: 4 UID: 0 PID: 217 Comm: kworker/4:1 Not tainted 6.11.0-rc5-reduced-00859-g780801200300 #23 <4>[ 574.475226] Hardware name: Intel(R) Client Systems NUC13ANHi7/NUC13ANBi7, BIOS ANRPL357.0026.2023.0314.1458 03/14/2023 <4>[ 574.475231] Workqueue: mld mld_ifc_work <4>[ 574.475247] RIP: 0010:bpf_prog_5e13354d9cf5018a_prog_after_redirect+0x17/0x3c <4>[ 574.475257] Code: cc cc cc cc cc cc cc 80 00 00 00 cc cc cc cc cc cc cc cc f3 0f 1e fa 0f 1f 44 00 00 66 90 55 48 89 e5 f3 0f 1e fa 48 8b 57 20 <48> 8b 52 00 8b 92 e0 00 00 00 48 bf f8 a6 d5 c4 5d a0 ff ff be 0b <4>[ 574.475263] RSP: 0018:ffffa62440280c98 EFLAGS: 00010206 <4>[ 574.475269] RAX: ffffa62440280cd8 RBX: 0000000000000001 RCX: 0000000000000000 <4>[ 574.475274] RDX: 0000000000000000 RSI: ffffa62440549048 RDI: ffffa62440280ce0 <4>[ 574.475278] RBP: ffffa62440280c98 R08: 0000000000000002 R09: 0000000000000001 <4>[ 574.475281] R10: ffffa05dc8b98000 R11: ffffa05f577fca40 R12: ffffa05dcab24000 <4>[ 574.475285] R13: ffffa62440280ce0 R14: ffffa62440549048 R15: ffffa62440549000 <4>[ 574.475289] FS: 0000000000000000(0000) GS:ffffa05f4f700000(0000) knlGS:0000000000000000 <4>[ 574.475294] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 <4>[ 574.475298] CR2: 0000000000000000 CR3: 000000025522e000 CR4: 0000000000f50ef0 <4>[ 574.475303] PKRU: 55555554 <4>[ 574.475306] Call Trace: <4>[ 574.475313] <IRQ> <4>[ 574.475318] ? __die+0x23/0x70 <4>[ 574.475329] ? page_fault_oops+0x180/0x4c0 <4>[ 574.475339] ? skb_pp_cow_data+0x34c/0x490 <4>[ 574.475346] ? kmem_cache_free+0x257/0x280 <4>[ 574.475357] ? exc_page_fault+0x67/0x150 <4>[ 574.475368] ? asm_exc_page_fault+0x26/0x30 <4>[ 574.475381] ? bpf_prog_5e13354d9cf5018a_prog_after_redirect+0x17/0x3c <4>[ 574.475386] bq_xmit_all+0x158/0x420 <4>[ 574.475397] __dev_flush+0x30/0x90 <4>[ 574.475407] veth_poll+0x216/0x250 [veth] <4>[ 574.475421] __napi_poll+0x28/0x1c0 <4>[ 574.475430] net_rx_action+0x32d/0x3a0 <4>[ 574.475441] handle_softirqs+0xcb/0x2c0 <4>[ 574.475451] do_softirq+0x40/0x60 <4>[ 574.475458] </IRQ> <4>[ 574.475461] <TASK> <4>[ 574.475464] __local_bh_enable_ip+0x66/0x70 <4>[ 574.475471] __dev_queue_xmit+0x268/0xe40 <4>[ 574.475480] ? selinux_ip_postroute+0x213/0x420 <4>[ 574.475491] ? alloc_skb_with_frags+0x4a/0x1d0 <4>[ 574.475502] ip6_finish_output2+0x2be/0x640 <4>[ 574.475512] ? nf_hook_slow+0x42/0xf0 <4>[ 574.475521] ip6_finish_output+0x194/0x300 <4>[ 574.475529] ? __pfx_ip6_finish_output+0x10/0x10 <4>[ 574.475538] mld_sendpack+0x17c/0x240 <4>[ 574.475548] mld_ifc_work+0x192/0x410 <4>[ 574.475557] process_one_work+0x15d/0x380 <4>[ 574.475566] worker_thread+0x29d/0x3a0 <4>[ 574.475573] ? __pfx_worker_thread+0x10/0x10 <4>[ 574.475580] ? __pfx_worker_thread+0x10/0x10 <4>[ 574.475587] kthread+0xcd/0x100 <4>[ 574.475597] ? __pfx_kthread+0x10/0x10 <4>[ 574.475606] ret_from_fork+0x31/0x50 <4>[ 574.475615] ? __pfx_kthread+0x10/0x10 <4>[ 574.475623] ret_from_fork_asm+0x1a/0x30 <4>[ 574.475635] </TASK> <4>[ 574.475637] Modules linked in: veth br_netfilter bridge stp llc iwlmvm x86_pkg_temp_thermal iwlwifi efivarfs nvme nvme_core <4>[ 574.475662] CR2: 0000000000000000 <4>[ 574.475668] ---[ end trace 0000000000000000 ]---
Therefore, provide it to the program by setting rxq properly.
--- kernel/bpf/devmap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/bpf/devmap.c +7 -4
@@ -322,9 +322,11 @@ static int dev_map_hash_get_next_key(struct bpf_map *map, void *key,static int dev_map_bpf_prog_run (struct bpf_prog *xdp_prog,struct xdp_frame **frames,int n, -struct net_device *dev) +struct net_device *tx_dev, +struct net_device *rx_dev) { -struct xdp_txq_info txq = { .dev = dev }; +struct xdp_txq_info txq = { .dev = tx_dev }; +struct xdp_rxq_info rxq = { .dev = rx_dev };struct xdp_buff xdp;int i, nframes =0 ;
@@ -335,6 +337,7 @@ static int dev_map_bpf_prog_run(struct bpf_prog *xdp_prog,xdp_convert_frame_to_buff (xdpf, &xdp); xdp.txq = &txq; + xdp.rxq = &rxq; act =bpf_prog_run_xdp (xdp_prog, &xdp);switch (act) {
@@ -349,7 +352,7 @@ static int dev_map_bpf_prog_run(struct bpf_prog *xdp_prog,bpf_warn_invalid_xdp_action (NULL , xdp_prog, act); fallthrough;case XDP_ABORTED : -trace_xdp_exception (dev, xdp_prog, act); +trace_xdp_exception (tx_dev, xdp_prog, act); fallthrough;case XDP_DROP :xdp_return_frame_rx_napi (xdpf);
@@ -377,7 +380,7 @@ static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags) }if (bq->xdp_prog) { - to_send =dev_map_bpf_prog_run (bq->xdp_prog, bq->q, cnt, dev); + to_send =dev_map_bpf_prog_run (bq->xdp_prog, bq->q, cnt, dev, bq->dev_rx);if (!to_send) goto out; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 4/208 cpufreq/amd-pstate: Fix amd_pstate mode switch on shared memory systems
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dhananjay Ugwekar <[email protected]>
[ Upstream commit c10e50a469b5ec91eabf653526a22bdce03a9bca ]
While switching the driver mode between active and passive, Collaborative Processor Performance Control (CPPC) is disabled in amd_pstate_unregister_driver(). But, it is not enabled back while registering the new driver (passive or active). This leads to the new driver mode not working correctly, so enable it back in amd_pstate_register_driver().
--- drivers/cpufreq/amd-pstate.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/cpufreq/amd-pstate.c +10 -0
@@ -1061,11 +1061,21 @@ static int amd_pstate_register_driver(int mode)return -EINVAL ; cppc_state = mode; + + ret =amd_pstate_enable (true); +if (ret) { +pr_err ("failed to enable cppc during amd-pstate driver registration, return %d\n" , + ret); +amd_pstate_driver_cleanup (); +return ret; + } + ret =cpufreq_register_driver (current_pstate_driver);if (ret) {amd_pstate_driver_cleanup ();return ret; } +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 5/208 lib/Kconfig.debug: fix grammar in RUST_BUILD_ASSERT_ALLOW
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timo Grautstueck <[email protected]>
[ Upstream commit ab8851431bef5cc44f0f3f0da112e883fd4d0df5 ]
Just a grammar fix in lib/Kconfig.debug, under the config option RUST_BUILD_ASSERT_ALLOW.
--- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
@@ -2999,7 +2999,7 @@ config RUST_BUILD_ASSERT_ALLOW bool "Allow unoptimized build-time assertions" depends on RUST help - Controls how are `build_error!` and `build_assert!` handled during build. + Controls how `build_error!` and `build_assert!` are handled during the build. If calls to them exist in the binary, it may indicate a violated invariant or that the optimizer failed to verify the invariant during compilation.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 6/208 bpf: Fix memory leak in bpf_core_apply
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit 45126b155e3b5201179cdc038504bf93a8ccd921 ]
We need to free specs properly.
--- kernel/bpf/btf.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/btf.c +1 -0
@@ -8435,6 +8435,7 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,if (!type) {bpf_log (ctx->log,"relo #%u: bad type id %u\n" , relo_idx, relo->type_id); +kfree (specs);return -EINVAL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 7/208 RDMA/bnxt_re: Fix a possible memory leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit 3fc5410f225d1651580a4aeb7c72f55e28673b53 ]
In bnxt_re_setup_chip_ctx() when bnxt_qplib_map_db_bar() fails driver is not freeing the memory allocated for "rdev->chip_ctx".
--- drivers/infiniband/hw/bnxt_re/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/main.c +4 -1
@@ -176,8 +176,11 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode)bnxt_re_set_db_offset (rdev); rc =bnxt_qplib_map_db_bar (&rdev->qplib_res); -if (rc) +if (rc) { +kfree (rdev->chip_ctx); + rdev->chip_ctx =NULL ;return rc; + }if (bnxt_qplib_determine_atomics (en_dev->pdev)) ibdev_info(&rdev->ibdev,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 8/208 RDMA/bnxt_re: Fix incorrect AVID type in WQE structure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravanan Vajravel <[email protected]>
[ Upstream commit 9ab20f76ae9fad55ebaf36bdff04aea1c2552374 ]
Driver uses internal data structure to construct WQE frame. It used avid type as u16 which can accommodate up to 64K AVs. When outstanding AVID crosses 64K, driver truncates AVID and hence it uses incorrect AVID to WR. This leads to WR failure due to invalid AV ID and QP is moved to error state with reason set to 19 (INVALID AVID). When RDMA CM path is used, this issue hits QP1 and it is moved to error state
--- drivers/infiniband/hw/bnxt_re/qplib_fp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_fp.h +1 -1
@@ -169,7 +169,7 @@ struct bnxt_qplib_swqe { };u32 q_key;u32 dst_qp; -u16 avid; +u32 avid; } send;/* Send Raw Ethernet and QP1 */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 9/208 RDMA/bnxt_re: Add a check for memory allocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit c5c1ae73b7741fa3b58e6e001b407825bb971225 ]
__alloc_pbl() can return error when memory allocation fails. Driver is not checking the status on one of the instances.
--- drivers/infiniband/hw/bnxt_re/qplib_res.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/bnxt_re/qplib_res.c +2 -0
@@ -244,6 +244,8 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq, sginfo.pgsize = npde * pg_size; sginfo.npages =1 ; rc =__alloc_pbl (res, &hwq->pbl[PBL_LVL_0 ], &sginfo); +if (rc) + goto fail;/* Alloc PBL pages */ sginfo.npages = npbl;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainercover 6.6.59-rc1 review
This is the start of the stable review cycle for the 6.6.59 release. There are 208 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 30 Oct 2024 06:22:39 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.59-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.6.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 6.6.59-rc1
Linus Torvalds <[email protected]>
task_work: make TWA_NMI_CURRENT handling conditional on IRQ_WORK
Masami Hiramatsu (Google) <[email protected]>
tracing: probes: Fix to zero initialize a local variable
Kalesh AP <[email protected]>
RDMA/bnxt_re: Fix unconditional fence for newer adapters
Kalesh AP <[email protected]>
RDMA/bnxt_re: Avoid creating fence MR for newer adapters
Selvin Xavier <[email protected]>
RDMA/bnxt_re: Fix the offset for GenP7 adapters for user applications
Dan Carpenter <[email protected]>
ACPI: PRM: Clean up guid type in struct prm_handler_info
Armin Wolf <[email protected]>
platform/x86: dell-wmi: Ignore suspend notifications
Zichen Xie <[email protected]>
ASoC: qcom: Fix NULL Dereference in asoc_qcom_lpass_cpu_platform_probe()
Niklas Cassel <[email protected]>
ata: libata: Set DID_TIME_OUT for commands that actually timed out
Xinyu Zhang <[email protected]>
block: fix sanity checks in blk_rq_map_user_bvec
Michel Alex <[email protected]>
net: phy: dp83822: Fix reset pin definitions
Paul Moore <[email protected]>
selinux: improve error checking in sel_write_load()
Mario Limonciello <[email protected]>
drm/amd/display: Disable PSR-SU on Parade 08-01 TCON too
Haiyang Zhang <[email protected]>
hv_netvsc: Fix VF namespace also in synthetic NIC NETDEV_REGISTER event
Petr Vaganov <[email protected]>
xfrm: fix one more kernel-infoleak in algo dumping
Huacai Chen <[email protected]>
LoongArch: Make KASAN usable for variable cpu_vabits
Huacai Chen <[email protected]>
LoongArch: Enable IRQ if do_ale() triggered in irq-enabled context
Huacai Chen <[email protected]>
LoongArch: Get correct cores_per_package for SMT systems
José Relvas <[email protected]>
ALSA: hda/realtek: Add subwoofer quirk for Acer Predator G9-593
Eric Biggers <[email protected]>
ALSA: hda/tas2781: select CRC32 instead of CRC32_SARWATE
Pawan Gupta <[email protected]>
x86/lam: Disable ADDRESS_MASKING in most cases
Marc Zyngier <[email protected]>
KVM: arm64: Don't eagerly teardown the vgic on init error
Ilkka Koskinen <[email protected]>
KVM: arm64: Fix shift-out-of-bounds bug
Sean Christopherson <[email protected]>
KVM: nSVM: Ignore nCR3[4:0] when loading PDPTEs from memory
Aleksa Sarai <[email protected]>
openat2: explicitly return -E2BIG for (usize > PAGE_SIZE)
Ryusuke Konishi <[email protected]>
nilfs2: fix kernel bug due to missing clearing of buffer delay flag
Shubham Panwar <[email protected]>
ACPI: button: Add DMI quirk for Samsung Galaxy Book2 to fix initial lid detection issue
Koba Ko <[email protected]>
ACPI: PRM: Find EFI_MEMORY_RUNTIME block for PRM handler and context
Christian Heusel <[email protected]>
ACPI: resource: Add LG 16T90SP to irq1_level_low_skip_override[]
Mario Limonciello <[email protected]>
drm/amd: Guard against bad data for ATIF ACPI method
Naohiro Aota <[email protected]>
btrfs: zoned: fix zone unusable accounting for freed reserved extent
Yue Haibing <[email protected]>
btrfs: fix passing 0 to ERR_PTR in btrfs_search_dir_index_item()
liwei <[email protected]>
cpufreq: CPPC: fix perf_to_khz/khz_to_perf conversion exception
Vincent Guittot <[email protected]>
cpufreq/cppc: Move and rename cppc_cpufreq_{perf_to_khz|khz_to_perf}()
Henrique Carvalho <[email protected]>
smb: client: Handle kstrdup failures for passwords
Kailang Yang <[email protected]>
ALSA: hda/realtek: Update default depop procedure
Yang Erkun <[email protected]>
nfsd: cancel nfsd_shrinker_work using sync mode in nfs4_state_shutdown_net
Yuan Can <[email protected]>
powercap: dtpm_devfreq: Fix error check against dev_pm_qos_add_request()
Andrey Shumilin <[email protected]>
ALSA: firewire-lib: Avoid division by zero in apply_constraint_to_size()
Chancel Liu <[email protected]>
ASoC: fsl_micfil: Add a flag to distinguish with different volume control types
Lad Prabhakar <[email protected]>
ASoC: rsnd: Fix probe failure on HiHope boards due to endpoint parsing
Colin Ian King <[email protected]>
ASoC: max98388: Fix missing increment of variable slot_found
Binbin Zhou <[email protected]>
ASoC: loongson: Fix component check failed on FDT systems
Miquel Raynal <[email protected]>
ASoC: dt-bindings: davinci-mcasp: Fix interrupt properties
Miquel Raynal <[email protected]>
ASoC: dt-bindings: davinci-mcasp: Fix interrupts property
Shenghao Yang <[email protected]>
net: dsa: mv88e6xxx: support 4000ps cycle counter period
Shenghao Yang <[email protected]>
net: dsa: mv88e6xxx: read cycle counter period from hardware
Shenghao Yang <[email protected]>
net: dsa: mv88e6xxx: group cycle counter coefficients
Jiri Olsa <[email protected]>
bpf,perf: Fix perf_event_detach_bpf_prog error handling
Luiz Augusto von Dentz <[email protected]>
Bluetooth: ISO: Fix UAF on iso_sock_timeout
Luiz Augusto von Dentz <[email protected]>
Bluetooth: SCO: Fix UAF on sco_sock_timeout
Jinjie Ruan <[email protected]>
posix-clock: posix-clock: Fix unbalanced locking in pc_clock_settime()
Heiner Kallweit <[email protected]>
r8169: avoid unsolicited interrupts
Dmitry Antipov <[email protected]>
net: sched: use RCU read-side critical section in taprio_dump()
Dmitry Antipov <[email protected]>
net: sched: fix use-after-free in taprio_change()
Vladimir Oltean <[email protected]>
net/sched: act_api: deny mismatched skip_sw/skip_hw flags for actions created by classifiers
Daniel Borkmann <[email protected]>
bpf: Remove MEM_UNINIT from skb/xdp MTU helpers
Daniel Borkmann <[email protected]>
bpf: Fix overloading of MEM_UNINIT's meaning
Daniel Borkmann <[email protected]>
bpf: Add MEM_WRITE attribute
Andrei Matei <[email protected]>
bpf: Simplify checking size of helper accesses
Oliver Neukum <[email protected]>
net: usb: usbnet: fix name regression
Eric Dumazet <[email protected]>
net: fix races in netdev_tx_sent_queue()/dev_watchdog()
Praveen Kumar Kannoju <[email protected]>
net/sched: adjust device watchdog timer to detect stopped queue at right time
Lin Ma <[email protected]>
net: wwan: fix global oob in wwan_rtnl_policy
Pablo Neira Ayuso <[email protected]>
netfilter: xtables: fix typo causing some targets not to load on IPv6
Aleksandr Mishin <[email protected]>
fsl/fman: Fix refcount handling of fman-related devices
Aleksandr Mishin <[email protected]>
fsl/fman: Save device references taken in mac_probe()
Peter Rashleigh <[email protected]>
net: dsa: mv88e6xxx: Fix error when setting port policy on mv88e6393x
Aleksandr Mishin <[email protected]>
octeon_ep: Add SKB allocation failures handling in __octep_oq_process_rx()
Aleksandr Mishin <[email protected]>
octeon_ep: Implement helper for iterating packets in Rx queue
Jakub Boehm <[email protected]>
net: plip: fix break; causing plip to never transmit
Wang Hai <[email protected]>
be2net: fix potential memory leak in be_xmit()
Wang Hai <[email protected]>
net/sun3_82586: fix potential memory leak in sun3_82586_send_packet()
Florian Westphal <[email protected]>
netfilter: bpf: must hold reference on net namespace
Sabrina Dubroca <[email protected]>
xfrm: validate new SA's prefixlen using SA family when sel.family is unset
Antony Antony <[email protected]>
xfrm: Add Direction to the SA in or out
Eyal Birger <[email protected]>
xfrm: respect ip protocols rules criteria when performing dst lookups
Eyal Birger <[email protected]>
xfrm: extract dst lookup parameters into a struct
Leo Yan <[email protected]>
tracing: Consider the NULL character when validating the event length
Mikel Rychliski <[email protected]>
tracing/probes: Fix MAX_TRACE_ARGS limit handling
Dave Kleikamp <[email protected]>
jfs: Fix sanity check in dbMount
Thomas Weißschuh <[email protected]>
LoongArch: Don't crash in stack_top() for tasks without vDSO
Crag Wang <[email protected]>
platform/x86: dell-sysman: add support for alienware products
Pali Rohár <[email protected]>
cifs: Validate content of NFS reparse point buffer
Alexey Klimov <[email protected]>
ASoC: qcom: sm8250: add qrb4210-rb2-sndcard compatible string
Gianfranco Trad <[email protected]>
udf: fix uninit-value use in udf_get_fileshortad
Zhao Mengmeng <[email protected]>
udf: refactor inode_bmap() to handle error
Zhao Mengmeng <[email protected]>
udf: refactor udf_next_aext() to handle error
Zhao Mengmeng <[email protected]>
udf: refactor udf_current_aext() to handle error
Mark Rutland <[email protected]>
arm64: Force position-independent veneers
Shengjiu Wang <[email protected]>
ASoC: fsl_sai: Enable 'FIFO continue on error' FCONT bit
Alexey Klimov <[email protected]>
ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values
David Lawrence Glanzman <[email protected]>
ASoC: amd: yc: Add quirk for HP Dragonfly pro one
Hans de Goede <[email protected]>
drm/vboxvideo: Replace fake VLA at end of vbva_mouse_pointer_shape with real VLA
Mateusz Guzik <[email protected]>
exec: don't WARN for racy path_noexec check
Qiao Ma <[email protected]>
uprobe: avoid out-of-bounds memory access of fetching args
Andrii Nakryiko <[email protected]>
uprobes: prevent mutex_lock() under rcu_read_lock()
Andrii Nakryiko <[email protected]>
uprobes: prepare uprobe args buffer lazily
Andrii Nakryiko <[email protected]>
uprobes: encapsulate preparation of uprobe args buffer
Masami Hiramatsu (Google) <[email protected]>
tracing/probes: Support $argN in return probe (kprobe and fprobe)
Masami Hiramatsu (Google) <[email protected]>
tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init
Masami Hiramatsu (Google) <[email protected]>
tracing/fprobe-event: cleanup: Fix a wrong comment in fprobe event
Roger Quadros <[email protected]>
usb: dwc3: core: Fix system suspend on TI AM62 platforms
Frank Li <[email protected]>
XHCI: Separate PORT and CAPs macros into dedicated file
Kevin Groeneveld <[email protected]>
usb: gadget: f_uac2: fix return value for UAC2_ATTRIBUTE_STRING store
John Keeping <[email protected]>
usb: gadget: f_uac2: fix non-newline-terminated function name
Lee Jones <[email protected]>
usb: gadget: f_uac2: Replace snprintf() with the safer scnprintf() variant
Mathias Nyman <[email protected]>
xhci: dbc: honor usb transfer size boundaries.
Jiri Slaby (SUSE) <[email protected]>
xhci: dbgtty: use kfifo from tty_port struct
Jiri Slaby (SUSE) <[email protected]>
xhci: dbgtty: remove kfifo_out() wrapper
Javier Carrasco <[email protected]>
iio: adc: ti-lmp92064: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
Yang Shi <[email protected]>
mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point
Matthew Wilcox (Oracle) <[email protected]>
khugepaged: remove hpage from collapse_file()
Matthew Wilcox (Oracle) <[email protected]>
khugepaged: convert alloc_charge_hpage to alloc_charge_folio
Matthew Wilcox (Oracle) <[email protected]>
khugepaged: inline hpage_collapse_alloc_folio()
Matthew Wilcox (Oracle) <[email protected]>
mm/khugepaged: use a folio more in collapse_file()
Matthew Wilcox (Oracle) <[email protected]>
mm: convert collapse_huge_page() to use a folio
Vishal Moola (Oracle) <[email protected]>
mm/khugepaged: convert alloc_charge_hpage() to use folios
Josh Poimboeuf <[email protected]>
cdrom: Avoid barrier_nospec() in cdrom_ioctl_media_changed()
Jordan Rome <[email protected]>
bpf: Fix iter/task tid filtering
Maurizio Lombardi <[email protected]>
nvme-pci: fix race condition between reset and nvme_dev_disable()
William Butler <[email protected]>
nvme-pci: set doorbell config before unquiescing
Andrea Parri <[email protected]>
riscv, bpf: Make BPF_CMPXCHG fully ordered
Michal Luczaj <[email protected]>
bpf, vsock: Drop static vsock_bpf_prot initialization
Michal Luczaj <[email protected]>
vsock: Update msg_count on read_skb()
Michal Luczaj <[email protected]>
vsock: Update rx_bytes on read_skb()
Michal Luczaj <[email protected]>
bpf, sockmap: SK_DROP on attempted redirects of unsupported af_vsock
Cosmin Ratiu <[email protected]>
net/mlx5: Unregister notifier on eswitch init failure
Shay Drory <[email protected]>
net/mlx5: Fix command bitmask initialization
Maher Sanalla <[email protected]>
net/mlx5: Check for invalid vector index on EQ creation
Daniel Borkmann <[email protected]>
vmxnet3: Fix packet corruption in vmxnet3_xdp_xmit_frame
Ye Bin <[email protected]>
Bluetooth: bnep: fix wild-memory-access in proto_unregister
Tyrone Wu <[email protected]>
bpf: Fix link info netfilter flags to populate defrag flag
Heiko Carstens <[email protected]>
s390: Initialize psw mask in perf_arch_fetch_caller_regs()
Thadeu Lima de Souza Cascardo <[email protected]>
usb: typec: altmode should keep reference to parent
Paulo Alcantara <[email protected]>
smb: client: fix OOBs when building SMB2_IOCTL request
Su Hui <[email protected]>
smb: client: fix possible double free in smb2_set_ea()
Wang Hai <[email protected]>
scsi: target: core: Fix null-ptr-deref in target_alloc_device()
Niklas Söderlund <[email protected]>
net: ravb: Only advertise Rx/Tx timestamps if hardware supports it
Gal Pressman <[email protected]>
ravb: Remove setting of RX software timestamp
Eric Dumazet <[email protected]>
genetlink: hold RCU in genlmsg_mcast()
Peter Rashleigh <[email protected]>
net: dsa: mv88e6xxx: Fix the max_vid definition for the MV88E6361
Kuniyuki Iwashima <[email protected]>
tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink().
Wang Hai <[email protected]>
net: bcmasp: fix potential memory leak in bcmasp_xmit()
Jessica Zhang <[email protected]>
drm/msm/dpu: don't always program merge_3d block
Fabrizio Castro <[email protected]>
irqchip/renesas-rzg2l: Fix missing put_device
Claudiu Beznea <[email protected]>
irqchip/renesas-rzg2l: Add support for suspend to RAM
Claudiu Beznea <[email protected]>
irqchip/renesas-rzg2l: Document structure members
Claudiu Beznea <[email protected]>
irqchip/renesas-rzg2l: Align struct member names to tabs
Wang Hai <[email protected]>
net: systemport: fix potential memory leak in bcm_sysport_xmit()
Dimitar Kanaliev <[email protected]>
bpf: Fix truncation bug in coerce_reg_to_size_sx()
Wang Hai <[email protected]>
net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()
Li RongQing <[email protected]>
net/smc: Fix searching in list of known pnetids in smc_pnet_add_pnetid
Wang Hai <[email protected]>
net: ethernet: aeroflex: fix potential memory leak in greth_start_xmit_gbit()
Eric Dumazet <[email protected]>
netdevsim: use cond_resched() in nsim_dev_trap_report_work()
Sabrina Dubroca <[email protected]>
macsec: don't increment counters for an unrelated SA
Srinivasan Shanmugam <[email protected]>
drm/amd/amdgpu: Fix double unlock in amdgpu_mes_add_ring
Colin Ian King <[email protected]>
octeontx2-af: Fix potential integer overflows on integer shifts
Paritosh Dixit <[email protected]>
net: stmmac: dwmac-tegra: Fix link bring-up sequence
Oliver Neukum <[email protected]>
net: usb: usbnet: fix race in probe failure
Kai Shen <[email protected]>
net/smc: Fix memory leak when using percpu refs
Justin Chen <[email protected]>
firmware: arm_scmi: Queue in scmi layer for mailbox implementation
Douglas Anderson <[email protected]>
drm/msm: Allocate memory for disp snapshot with kvzalloc()
Douglas Anderson <[email protected]>
drm/msm: Avoid NULL dereference in msm_disp_state_print_regs()
Jonathan Marek <[email protected]>
drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation
Jonathan Marek <[email protected]>
drm/msm/dsi: improve/fix dsc pclk calculation
Dmitry Baryshkov <[email protected]>
drm/msm/dpu: check for overflow in _dpu_crtc_setup_lm_bounds()
Dmitry Baryshkov <[email protected]>
drm/msm/dpu: make sure phys resources are properly initialized
Pranjal Ramajor Asha Kanojiya <[email protected]>
accel/qaic: Fix the for loop used to walk SG table
Kalesh AP <[email protected]>
RDMA/bnxt_re: Fix the GID table length
Selvin Xavier <[email protected]>
RDMA/bnxt_re: Update the BAR offsets
Bhargava Chenna Marreddy <[email protected]>
RDMA/bnxt_re: Fix a bug while setting up Level-2 PBL pages
Kalesh AP <[email protected]>
RDMA/bnxt_re: Return more meaningful error
Kalesh AP <[email protected]>
RDMA/bnxt_re: Fix out of bound check
Abhishek Mohapatra <[email protected]>
RDMA/bnxt_re: Fix the max CQ WQEs for older adapters
Selvin Xavier <[email protected]>
RDMA/bnxt_re: Support new 5760X P7 devices
Xin Long <[email protected]>
ipv4: give an IPv4 dev to blackhole_netdev
Bart Van Assche <[email protected]>
RDMA/srpt: Make slab cache names unique
Alexander Zubkov <[email protected]>
RDMA/irdma: Fix misspelling of "accept*"
Anumula Murali Mohan Reddy <[email protected]>
RDMA/cxgb4: Fix RDMA_CM_EVENT_UNREACHABLE error for iWARP
Su Hui <[email protected]>
firmware: arm_scmi: Fix the double free in scmi_debugfs_common_setup()
Murad Masimov <[email protected]>
ALSA: hda/cs8409: Fix possible NULL dereference
Waiman Long <[email protected]>
sched/core: Disable page allocation in task_tick_mm_cid()
Sebastian Andrzej Siewior <[email protected]>
task_work: Add TWA_NMI_CURRENT as an additional notify mode.
Tony Ambardar <[email protected]>
selftests/bpf: Fix cross-compiling urandom_read
Ian Forbes <[email protected]>
drm/vmwgfx: Handle possible ENOMEM in vmw_stdu_connector_atomic_check
Javier Carrasco <[email protected]>
iio: frequency: admv4420: fix missing select REMAP_SPI in Kconfig
Javier Carrasco <[email protected]>
iio: frequency: {admv4420,adrf6780}: format Kconfig entries
Toke Høiland-Jørgensen <[email protected]>
bpf: fix kfunc btf caching for modules
Niklas Schnelle <[email protected]>
s390/pci: Handle PCI error codes other than 0x3a
Tyrone Wu <[email protected]>
selftests/bpf: fix perf_event link info name_len assertion
Jiri Olsa <[email protected]>
selftests/bpf: Add cookies check for perf_event fill_link_info test
Jiri Olsa <[email protected]>
selftests/bpf: Use bpf_link__destroy in fill_link_info tests
Tyrone Wu <[email protected]>
bpf: fix unpopulated name_len field in perf_event link info
Jiri Olsa <[email protected]>
bpf: Add cookie to perf_event bpf_link_info records
Jiri Olsa <[email protected]>
bpf: Add missed value to kprobe perf link info
Florian Klink <[email protected]>
ARM: dts: bcm2837-rpi-cm3-io3: Fix HDMI hpd-gpio pin
Martin Kletzander <[email protected]>
x86/resctrl: Avoid overflow in MB settings in bw_validate()
Anumula Murali Mohan Reddy <[email protected]>
RDMA/core: Fix ENODEV error for iWARP test over vlan
Kalesh AP <[email protected]>
RDMA/bnxt_re: Add a check for memory allocation
Saravanan Vajravel <[email protected]>
RDMA/bnxt_re: Fix incorrect AVID type in WQE structure
Kalesh AP <[email protected]>
RDMA/bnxt_re: Fix a possible memory leak
Jiri Olsa <[email protected]>
bpf: Fix memory leak in bpf_core_apply
Timo Grautstueck <[email protected]>
lib/Kconfig.debug: fix grammar in RUST_BUILD_ASSERT_ALLOW
Dhananjay Ugwekar <[email protected]>
cpufreq/amd-pstate: Fix amd_pstate mode switch on shared memory systems
Florian Kauer <[email protected]>
bpf: devmap: provide rxq after redirect
Toke Høiland-Jørgensen <[email protected]>
bpf: Make sure internal and UAPI bpf_redirect flags don't overlap
Mikhail Lobanov <[email protected]>
iio: accel: bma400: Fix uninitialized variable field_value in tap event handling.
-------------
Diffstat:
.../bindings/sound/davinci-mcasp-audio.yaml | 18 +- Makefile | 4 +- arch/arm/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dts | 2 +- arch/arm64/Makefile | 2 +- arch/arm64/kvm/arm.c | 3 + arch/arm64/kvm/sys_regs.c | 2 +- arch/arm64/kvm/vgic/vgic-init.c | 6 +- arch/loongarch/include/asm/bootinfo.h | 4 + arch/loongarch/include/asm/kasan.h | 2 +- arch/loongarch/kernel/process.c | 14 +- arch/loongarch/kernel/setup.c | 3 +- arch/loongarch/kernel/traps.c | 5 + arch/riscv/net/bpf_jit_comp64.c | 4 +- arch/s390/include/asm/perf_event.h | 1 + arch/s390/pci/pci_event.c | 17 +- arch/x86/Kconfig | 1 + arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 23 +- arch/x86/kvm/svm/nested.c | 6 +- block/blk-map.c | 4 +- drivers/accel/qaic/qaic_control.c | 2 +- drivers/accel/qaic/qaic_data.c | 6 +- drivers/acpi/button.c | 11 + drivers/acpi/cppc_acpi.c | 116 +++++++++ drivers/acpi/prmt.c | 29 ++- drivers/acpi/resource.c | 7 + drivers/ata/libata-eh.c | 1 + drivers/cdrom/cdrom.c | 2 +- drivers/cpufreq/amd-pstate.c | 10 + drivers/cpufreq/cppc_cpufreq.c | 139 ++--------- drivers/firmware/arm_scmi/driver.c | 4 +- drivers/firmware/arm_scmi/mailbox.c | 32 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 15 +- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 5 +- .../drm/amd/display/modules/power/power_helpers.c | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 17 +- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 9 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 19 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 4 +- drivers/gpu/drm/vboxvideo/hgsmi_base.c | 10 +- drivers/gpu/drm/vboxvideo/vboxvideo.h | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 4 + drivers/iio/accel/bma400_core.c | 3 +- drivers/iio/adc/Kconfig | 2 + drivers/iio/frequency/Kconfig | 31 +-- drivers/infiniband/core/addr.c | 2 + drivers/infiniband/hw/bnxt_re/hw_counters.c | 6 +- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 48 ++-- drivers/infiniband/hw/bnxt_re/main.c | 42 ++-- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 4 +- drivers/infiniband/hw/bnxt_re/qplib_fp.h | 2 +- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 4 +- drivers/infiniband/hw/bnxt_re/qplib_res.c | 23 +- drivers/infiniband/hw/bnxt_re/qplib_res.h | 20 +- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 22 +- drivers/infiniband/hw/bnxt_re/qplib_sp.h | 1 + drivers/infiniband/hw/cxgb4/cm.c | 9 +- drivers/infiniband/hw/irdma/cm.c | 2 +- drivers/infiniband/ulp/srpt/ib_srpt.c | 80 ++++++- drivers/irqchip/irq-renesas-rzg2l.c | 94 ++++++-- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- drivers/net/dsa/mv88e6xxx/chip.h | 6 +- drivers/net/dsa/mv88e6xxx/port.c | 1 + drivers/net/dsa/mv88e6xxx/ptp.c | 108 ++++++--- drivers/net/ethernet/aeroflex/greth.c | 3 +- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 + drivers/net/ethernet/broadcom/bcmsysport.c | 1 + drivers/net/ethernet/emulex/benet/be_main.c | 10 +- drivers/net/ethernet/freescale/fman/mac.c | 68 ++++-- drivers/net/ethernet/freescale/fman/mac.h | 6 +- drivers/net/ethernet/i825xx/sun3_82586.c | 1 + drivers/net/ethernet/marvell/octeon_ep/octep_rx.c | 82 +++++-- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 +- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 6 + drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 5 +- drivers/net/ethernet/realtek/r8169_main.c | 4 +- drivers/net/ethernet/renesas/ravb_main.c | 25 +- drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c | 18 +- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 + drivers/net/hyperv/netvsc_drv.c | 30 +++ drivers/net/macsec.c | 18 -- drivers/net/netdevsim/dev.c | 15 +- drivers/net/phy/dp83822.c | 4 +- drivers/net/plip/plip.c | 2 +- drivers/net/usb/usbnet.c | 4 +- drivers/net/vmxnet3/vmxnet3_xdp.c | 2 +- drivers/net/wwan/wwan_core.c | 2 +- drivers/nvme/host/pci.c | 21 +- drivers/platform/x86/dell/dell-wmi-base.c | 9 + drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 1 + drivers/powercap/dtpm_devfreq.c | 2 +- drivers/target/target_core_device.c | 2 +- drivers/target/target_core_user.c | 2 +- drivers/usb/dwc3/core.c | 19 ++ drivers/usb/dwc3/core.h | 3 + drivers/usb/gadget/function/f_uac2.c | 13 +- drivers/usb/host/xhci-caps.h | 85 +++++++ drivers/usb/host/xhci-dbgcap.h | 2 +- drivers/usb/host/xhci-dbgtty.c | 71 ++++-- drivers/usb/host/xhci-port.h | 176 ++++++++++++++ drivers/usb/host/xhci.h | 262 +-------------------- drivers/usb/typec/class.c | 3 + fs/btrfs/block-group.c | 2 + fs/btrfs/dir-item.c | 4 +- fs/btrfs/inode.c | 7 +- fs/exec.c | 21 +- fs/jfs/jfs_dmap.c | 2 +- fs/nfsd/nfs4state.c | 2 +- fs/nilfs2/page.c | 6 +- fs/open.c | 2 + fs/smb/client/fs_context.c | 7 + fs/smb/client/reparse.c | 23 ++ fs/smb/client/smb2ops.c | 3 +- fs/smb/client/smb2pdu.c | 9 + fs/udf/balloc.c | 38 ++- fs/udf/directory.c | 23 +- fs/udf/inode.c | 202 ++++++++++------ fs/udf/partition.c | 6 +- fs/udf/super.c | 3 +- fs/udf/truncate.c | 43 +++- fs/udf/udfdecl.h | 15 +- include/acpi/cppc_acpi.h | 2 + include/linux/bpf.h | 14 +- include/linux/memcontrol.h | 14 -- include/linux/netdevice.h | 12 + include/linux/task_work.h | 6 +- include/linux/trace_events.h | 6 +- include/net/bluetooth/bluetooth.h | 1 + include/net/genetlink.h | 3 +- include/net/sock.h | 5 + include/net/xfrm.h | 29 ++- include/trace/events/huge_memory.h | 10 +- include/uapi/linux/bpf.h | 20 +- include/uapi/linux/xfrm.h | 6 + kernel/bpf/btf.c | 1 + kernel/bpf/devmap.c | 11 +- kernel/bpf/helpers.c | 10 +- kernel/bpf/ringbuf.c | 2 +- kernel/bpf/syscall.c | 49 ++-- kernel/bpf/task_iter.c | 2 +- kernel/bpf/verifier.c | 99 ++++---- kernel/sched/core.c | 4 +- kernel/task_work.c | 41 +++- kernel/time/posix-clock.c | 6 +- kernel/trace/bpf_trace.c | 11 +- kernel/trace/trace.c | 1 + kernel/trace/trace_eprobe.c | 15 +- kernel/trace/trace_fprobe.c | 65 +++-- kernel/trace/trace_kprobe.c | 78 ++++-- kernel/trace/trace_probe.c | 189 +++++++++++++-- kernel/trace/trace_probe.h | 30 ++- kernel/trace/trace_probe_tmpl.h | 10 +- kernel/trace/trace_uprobe.c | 114 +++++---- lib/Kconfig.debug | 2 +- mm/khugepaged.c | 127 +++++----- net/bluetooth/af_bluetooth.c | 22 ++ net/bluetooth/bnep/core.c | 3 +- net/bluetooth/iso.c | 18 +- net/bluetooth/sco.c | 18 +- net/core/filter.c | 50 ++-- net/core/sock_map.c | 8 + net/ipv4/devinet.c | 35 ++- net/ipv4/inet_connection_sock.c | 21 +- net/ipv4/xfrm4_policy.c | 38 ++- net/ipv6/xfrm6_policy.c | 31 +-- net/l2tp/l2tp_netlink.c | 4 +- net/netfilter/nf_bpf_link.c | 7 +- net/netfilter/xt_NFLOG.c | 2 +- net/netfilter/xt_TRACE.c | 1 + net/netfilter/xt_mark.c | 2 +- net/netlink/genetlink.c | 28 +-- net/sched/act_api.c | 23 +- net/sched/sch_generic.c | 17 +- net/sched/sch_taprio.c | 21 +- net/smc/smc_pnet.c | 2 +- net/smc/smc_wr.c | 6 +- net/vmw_vsock/virtio_transport_common.c | 14 +- net/vmw_vsock/vsock_bpf.c | 8 - net/wireless/nl80211.c | 8 +- net/xfrm/xfrm_compat.c | 7 +- net/xfrm/xfrm_device.c | 17 +- net/xfrm/xfrm_policy.c | 50 +++- net/xfrm/xfrm_replay.c | 3 +- net/xfrm/xfrm_state.c | 8 + net/xfrm/xfrm_user.c | 148 +++++++++++- security/selinux/selinuxfs.c | 30 +-- sound/firewire/amdtp-stream.c | 3 + sound/pci/hda/Kconfig | 2 +- sound/pci/hda/patch_cs8409.c | 5 +- sound/pci/hda/patch_realtek.c | 48 ++-- sound/soc/amd/yc/acp6x-mach.c | 7 + sound/soc/codecs/lpass-rx-macro.c | 2 +- sound/soc/codecs/max98388.c | 1 + sound/soc/fsl/fsl_micfil.c | 43 +++- sound/soc/fsl/fsl_sai.c | 5 +- sound/soc/fsl/fsl_sai.h | 1 + sound/soc/loongson/loongson_card.c | 1 + sound/soc/qcom/lpass-cpu.c | 2 + sound/soc/qcom/sm8250.c | 1 + sound/soc/sh/rcar/core.c | 7 +- tools/include/uapi/linux/bpf.h | 7 + tools/testing/selftests/bpf/Makefile | 2 +- .../selftests/bpf/prog_tests/fill_link_info.c | 69 ++++-- .../bpf/progs/verifier_helper_value_access.c | 8 +- .../selftests/bpf/progs/verifier_raw_stack.c | 2 +- .../ftrace/test.d/dynevent/fprobe_syntax_errors.tc | 4 + .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc | 2 + 208 files changed, 2889 insertions(+), 1471 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 22/208 iio: frequency: admv4420: fix missing select REMAP_SPI in Kconfig
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
[ Upstream commit 6b8e9dbfaed471627f7b863633b9937717df1d4d ]
This driver makes use of regmap_spi, but does not select the required module.
Add the missing 'select REGMAP_SPI'.
--- drivers/iio/frequency/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/iio/frequency/Kconfig +1 -0
@@ -84,6 +84,7 @@ config ADMV1014 config ADMV4420 tristate "Analog Devices ADMV4420 K Band Downconverter" depends on SPI + select REGMAP_SPI help Say yes here to build support for Analog Devices K Band Downconverter with integrated Fractional-N PLL and VCO.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 31/208 RDMA/srpt: Make slab cache names unique
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 4d784c042d164f10fc809e2338457036cd7c653d ]
Since commit 4c39529663b9 ("slab: Warn on duplicate cache names when DEBUG_VM=y"), slab complains about duplicate cache names. Hence this patch. The approach is as follows:
- Maintain an xarray with the slab size as index and a reference count and a kmem_cache pointer as contents. Use srpt-${slab_size} as kmem cache name.
- Use 512-byte alignment for all slabs instead of only for some of the slabs.
- Increment the reference count instead of calling kmem_cache_create().
- Decrement the reference count instead of calling kmem_cache_destroy().
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 80 +++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 12 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +68 -12
@@ -68,6 +68,8 @@ MODULE_LICENSE("Dual BSD/GPL");static u64 srpt_service_guid;static DEFINE_SPINLOCK (srpt_dev_lock);/* Protects srpt_dev_list. */ static LIST_HEAD (srpt_dev_list);/* List of srpt_device structures. */ +static DEFINE_MUTEX (srpt_mc_mutex);/* Protects srpt_memory_caches. */ +static DEFINE_XARRAY (srpt_memory_caches);/* See also srpt_memory_cache_entry */ static unsigned srp_max_req_size =DEFAULT_MAX_REQ_SIZE ;module_param (srp_max_req_size, int,0444 );
@@ -105,6 +107,63 @@ static void srpt_recv_done(struct ib_cq *cq, struct ib_wc *wc);static void srpt_send_done (struct ib_cq *cq,struct ib_wc *wc);static void srpt_process_wait_list (struct srpt_rdma_ch *ch); +/* Type of the entries in srpt_memory_caches. */ +struct srpt_memory_cache_entry { +refcount_t ref; +struct kmem_cache *c; +}; + +static struct kmem_cache *srpt_cache_get (unsigned int object_size) +{ +struct srpt_memory_cache_entry *e; +char name[32 ]; +void *res; + +guard (mutex)(&srpt_mc_mutex); + e =xa_load (&srpt_memory_caches, object_size); +if (e) { +refcount_inc (&e->ref); +return e->c; + } +snprintf (name,sizeof (name),"srpt-%u" , object_size); + e =kmalloc (sizeof (*e),GFP_KERNEL ); +if (!e) +return NULL ; +refcount_set (&e->ref,1 ); + e->c =kmem_cache_create (name, object_size,/*align=*/ 512 ,0 ,NULL ); +if (!e->c) + goto free_entry; + res =xa_store (&srpt_memory_caches, object_size, e,GFP_KERNEL ); +if (xa_is_err (res)) + goto destroy_cache; +return e->c; + +destroy_cache: +kmem_cache_destroy (e->c); + +free_entry: +kfree (e); +return NULL ; +} + +static void srpt_cache_put (struct kmem_cache *c) +{ +struct srpt_memory_cache_entry *e =NULL ; +unsigned long object_size; + +guard (mutex)(&srpt_mc_mutex); +xa_for_each (&srpt_memory_caches, object_size, e) +if (e->c == c) +break ; +if (WARN_ON_ONCE (!e)) +return ; +if (!refcount_dec_and_test (&e->ref)) +return ; +WARN_ON_ONCE (xa_erase (&srpt_memory_caches, object_size) != e); +kmem_cache_destroy (e->c); +kfree (e); +} +/* * The only allowed channel state changes are those that change the channel * state into a state with a higher numerical value. Hence the new > prev test.
@@ -2119,13 +2178,13 @@ static void srpt_release_channel_work(struct work_struct *w) ch->sport->sdev, ch->rq_size, ch->rsp_buf_cache, DMA_TO_DEVICE); -kmem_cache_destroy (ch->rsp_buf_cache); +srpt_cache_put (ch->rsp_buf_cache);srpt_free_ioctx_ring ((struct srpt_ioctx **)ch->ioctx_recv_ring, sdev, ch->rq_size, ch->req_buf_cache,DMA_FROM_DEVICE ); -kmem_cache_destroy (ch->req_buf_cache); +srpt_cache_put (ch->req_buf_cache);kref_put (&ch->kref, srpt_free_ch); }
@@ -2245,8 +2304,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,INIT_LIST_HEAD (&ch->cmd_wait_list); ch->max_rsp_size = ch->sport->port_attrib.srp_max_rsp_size; - ch->rsp_buf_cache =kmem_cache_create ("srpt-rsp-buf" , ch->max_rsp_size, -512 ,0 ,NULL ); + ch->rsp_buf_cache =srpt_cache_get (ch->max_rsp_size);if (!ch->rsp_buf_cache) goto free_ch;
@@ -2280,8 +2338,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, alignment_offset =round_up (imm_data_offset,512 ) - imm_data_offset; req_sz = alignment_offset + imm_data_offset + srp_max_req_size; - ch->req_buf_cache =kmem_cache_create ("srpt-req-buf" , req_sz, -512 ,0 ,NULL ); + ch->req_buf_cache =srpt_cache_get (req_sz);if (!ch->req_buf_cache) goto free_rsp_ring;
@@ -2478,7 +2535,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, ch->req_buf_cache, DMA_FROM_DEVICE); free_recv_cache: -kmem_cache_destroy (ch->req_buf_cache); +srpt_cache_put (ch->req_buf_cache); free_rsp_ring: srpt_free_ioctx_ring((struct srpt_ioctx **)ch->ioctx_ring,
@@ -2486,7 +2543,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, ch->rsp_buf_cache, DMA_TO_DEVICE); free_rsp_cache: -kmem_cache_destroy (ch->rsp_buf_cache); +srpt_cache_put (ch->rsp_buf_cache); free_ch:if (rdma_cm_id)
@@ -3055,7 +3112,7 @@ static void srpt_free_srq(struct srpt_device *sdev)srpt_free_ioctx_ring ((struct srpt_ioctx **)sdev->ioctx_ring, sdev, sdev->srq_size, sdev->req_buf_cache,DMA_FROM_DEVICE ); -kmem_cache_destroy (sdev->req_buf_cache); +srpt_cache_put (sdev->req_buf_cache); sdev->srq =NULL ; }
@@ -3082,8 +3139,7 @@ static int srpt_alloc_srq(struct srpt_device *sdev)pr_debug ("create SRQ #wr= %d max_allow=%d dev= %s\n" , sdev->srq_size, sdev->device->attrs.max_srq_wr,dev_name (&device->dev)); - sdev->req_buf_cache =kmem_cache_create ("srpt-srq-req-buf" , - srp_max_req_size,0 ,0 ,NULL ); + sdev->req_buf_cache =srpt_cache_get (srp_max_req_size);if (!sdev->req_buf_cache) goto free_srq;
@@ -3105,7 +3161,7 @@ static int srpt_alloc_srq(struct srpt_device *sdev)return 0 ; free_cache: -kmem_cache_destroy (sdev->req_buf_cache); +srpt_cache_put (sdev->req_buf_cache); free_srq:ib_destroy_srq (srq);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 32/208 ipv4: give an IPv4 dev to blackhole_netdev
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 22600596b6756b166fd052d5facb66287e6f0bad ]
After commit 8d7017fd621d ("blackhole_netdev: use blackhole_netdev to invalidate dst entries"), blackhole_netdev was introduced to invalidate dst cache entries on the TX path whenever the cache times out or is flushed.
When two UDP sockets (sk1 and sk2) send messages to the same destination simultaneously, they are using the same dst cache. If the dst cache is invalidated on one path (sk2) while the other (sk1) is still transmitting, sk1 may try to use the invalid dst entry.
CPU1 CPU2
udp_sendmsg(sk1) udp_sendmsg(sk2)
udp_send_skb()
ip_output()
<--- dst timeout or flushed
dst_dev_put()
ip_finish_output2()
ip_neigh_for_gw()This results in a scenario where ip_neigh_for_gw() returns -EINVAL because blackhole_dev lacks an in_dev, which is needed to initialize the neigh in arp_constructor(). This error is then propagated back to userspace, breaking the UDP application.
The patch fixes this issue by assigning an in_dev to blackhole_dev for IPv4, similar to what was done for IPv6 in commit e5f80fcf869a ("ipv6:
give an IPv6 dev to blackhole_netdev"). This ensures that even when the dst entry is invalidated with blackhole_dev, it will not fail to create the neigh entry.
As devinet_init() is called ealier than blackhole_netdev_init() in system booting, it can not assign the in_dev to blackhole_dev in devinet_init(). As Paolo suggested, add a separate late_initcall() in devinet.c to ensure inet_blackhole_dev_init() is called after blackhole_netdev_init().
--- net/ipv4/devinet.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
net/ipv4/devinet.c +25 -10
@@ -283,17 +283,19 @@ static struct in_device *inetdev_init(struct net_device *dev)/* Account for reference dev->ip_ptr (below) */ refcount_set (&in_dev->refcnt,1 ); - err =devinet_sysctl_register (in_dev); -if (err) { - in_dev->dead =1 ; -neigh_parms_release (&arp_tbl, in_dev->arp_parms); -in_dev_put (in_dev); - in_dev =NULL ; - goto out; +if (dev != blackhole_netdev) { + err =devinet_sysctl_register (in_dev); +if (err) { + in_dev->dead =1 ; +neigh_parms_release (&arp_tbl, in_dev->arp_parms); +in_dev_put (in_dev); + in_dev =NULL ; + goto out; + } +ip_mc_init_dev (in_dev); +if (dev->flags &IFF_UP ) +ip_mc_up (in_dev); } -ip_mc_init_dev (in_dev); -if (dev->flags &IFF_UP ) -ip_mc_up (in_dev);/* we can receive as soon as ip_ptr is set -- do this last */ rcu_assign_pointer (dev->ip_ptr, in_dev);
@@ -332,6 +334,19 @@ static void inetdev_destroy(struct in_device *in_dev)in_dev_put (in_dev); } +static int __init inet_blackhole_dev_init (void ) +{ +int err =0 ; + +rtnl_lock (); +if (!inetdev_init (blackhole_netdev)) + err = -ENOMEM ; +rtnl_unlock (); + +return err; +} +late_initcall (inet_blackhole_dev_init); +int inet_addr_onlink (struct in_device *in_dev,__be32 a,__be32 b) {const struct in_ifaddr *ifa;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 33/208 RDMA/bnxt_re: Support new 5760X P7 devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 1801d87b3598b173bce3fbf15c5517796f38db96 ]
Add basic support for 5760X P7 devices. Add new chip revisions. The first version support is similar to the existing P5 adapters. Extend the current support for P5 adapters to P7 also.
Stable-dep-of: ac6df53738b4 ("RDMA/bnxt_re: Fix the max CQ WQEs for older adapters")
--- drivers/infiniband/hw/bnxt_re/hw_counters.c | 4 ++-- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 10 +++++----- drivers/infiniband/hw/bnxt_re/main.c | 14 +++++++------- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 4 ++-- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 2 +- drivers/infiniband/hw/bnxt_re/qplib_res.c | 2 +- drivers/infiniband/hw/bnxt_re/qplib_res.h | 20 +++++++++++++++++--- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 6 +++--- 8 files changed, 38 insertions(+), 24 deletions(-)
drivers/infiniband/hw/bnxt_re/hw_counters.c +2 -2
@@ -371,7 +371,7 @@ int bnxt_re_ib_get_hw_stats(struct ib_device *ibdev, } done: -return bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx) ? +return bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ?BNXT_RE_NUM_EXT_COUNTERS :BNXT_RE_NUM_STD_COUNTERS ; }
@@ -381,7 +381,7 @@ struct rdma_hw_stats *bnxt_re_ib_alloc_hw_port_stats(struct ib_device *ibdev,struct bnxt_re_dev *rdev =to_bnxt_re_dev (ibdev, ibdev);int num_counters =0 ; -if (bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx)) +if (bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx)) num_counters =BNXT_RE_NUM_EXT_COUNTERS ;else num_counters =BNXT_RE_NUM_STD_COUNTERS ;
drivers/infiniband/hw/bnxt_re/ib_verbs.c +5 -5
@@ -1023,7 +1023,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd, bytes = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size);/* Consider mapping PSN search memory only for RC QPs. */ if (qplib_qp->type ==CMDQ_CREATE_QP_TYPE_RC ) { - psn_sz =bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx) ? + psn_sz =bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ?sizeof (struct sq_psn_search_ext ) :sizeof (struct sq_psn_search ); psn_nume = (qplib_qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
@@ -1234,7 +1234,7 @@ static void bnxt_re_adjust_gsi_rq_attr(struct bnxt_re_qp *qp) qplqp = &qp->qplib_qp; dev_attr = &rdev->dev_attr; -if (!bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx)) { +if (!bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx)) { qplqp->rq.max_sge = dev_attr->max_qp_sges;if (qplqp->rq.max_sge > dev_attr->max_qp_sges) qplqp->rq.max_sge = dev_attr->max_qp_sges;
@@ -1301,7 +1301,7 @@ static void bnxt_re_adjust_gsi_sq_attr(struct bnxt_re_qp *qp, qplqp = &qp->qplib_qp; dev_attr = &rdev->dev_attr; -if (!bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx)) { +if (!bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx)) { entries =bnxt_re_init_depth (init_attr->cap.max_send_wr +1 , uctx); qplqp->sq.max_wqe =min_t (u32, entries, dev_attr->max_qp_wqes +1 );
@@ -1328,7 +1328,7 @@ static int bnxt_re_init_qp_type(struct bnxt_re_dev *rdev, goto out; } -if (bnxt_qplib_is_chip_gen_p5 (chip_ctx) && +if (bnxt_qplib_is_chip_gen_p5_p7 (chip_ctx) && init_attr->qp_type ==IB_QPT_GSI ) qptype =CMDQ_CREATE_QP_TYPE_GSI ; out:
@@ -1527,7 +1527,7 @@ int bnxt_re_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *qp_init_attr, goto fail;if (qp_init_attr->qp_type ==IB_QPT_GSI && - !(bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx))) { + !(bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx))) { rc =bnxt_re_create_gsi_qp (qp, pd, qp_init_attr);if (rc == -ENODEV ) goto qp_destroy;
drivers/infiniband/hw/bnxt_re/main.c +7 -7
@@ -128,7 +128,7 @@ static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)struct bnxt_qplib_chip_ctx *cctx; cctx = rdev->chip_ctx; - cctx->modes.wqe_mode =bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx) ? + cctx->modes.wqe_mode =bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ? mode :BNXT_QPLIB_WQE_MODE_STATIC ;if (bnxt_re_hwrm_qcaps (rdev)) dev_err(rdev_to_dev(rdev),
@@ -218,7 +218,7 @@ static void bnxt_re_limit_pf_res(struct bnxt_re_dev *rdev) ctx->srqc_count =min_t (u32,BNXT_RE_MAX_SRQC_COUNT , attr->max_srq); ctx->cq_count =min_t (u32,BNXT_RE_MAX_CQ_COUNT , attr->max_cq); -if (!bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx)) +if (!bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx))for (i =0 ; i <MAX_TQM_ALLOC_REQ ; i++) rdev->qplib_ctx.tqm_ctx.qcount[i] = rdev->dev_attr.tqm_alloc_reqs[i];
@@ -267,7 +267,7 @@ static void bnxt_re_set_resource_limits(struct bnxt_re_dev *rdev)memset (&rdev->qplib_ctx.vf_res,0 ,sizeof (struct bnxt_qplib_vf_res ));bnxt_re_limit_pf_res (rdev); - num_vfs =bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx) ? + num_vfs =bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ?BNXT_RE_GEN_P5_MAX_VF : rdev->num_vfs;if (num_vfs)bnxt_re_limit_vf_res (&rdev->qplib_ctx, num_vfs);
@@ -279,7 +279,7 @@ static void bnxt_re_vf_res_config(struct bnxt_re_dev *rdev)if (test_bit (BNXT_RE_FLAG_ERR_DEVICE_DETACHED , &rdev->flags))return ; rdev->num_vfs =pci_sriov_get_totalvfs (rdev->en_dev->pdev); -if (!bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx)) { +if (!bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx)) {bnxt_re_set_resource_limits (rdev);bnxt_qplib_set_func_resources (&rdev->qplib_res, &rdev->rcfw, &rdev->qplib_ctx);
@@ -1074,7 +1074,7 @@ static int bnxt_re_cqn_handler(struct bnxt_qplib_nq *nq,#define BNXT_RE_GEN_P5_VF_NQ_DB 0x4000static u32 bnxt_re_get_nqdb_offset (struct bnxt_re_dev *rdev,u16 indx) { -return bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx) ? +return bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ? (rdev->is_virtfn ?BNXT_RE_GEN_P5_VF_NQ_DB :BNXT_RE_GEN_P5_PF_NQ_DB ) : rdev->en_dev->msix_entries[indx].db_offset;
@@ -1539,7 +1539,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 wqe_mode)bnxt_re_set_resource_limits (rdev); rc =bnxt_qplib_alloc_ctx (&rdev->qplib_res, &rdev->qplib_ctx,0 , -bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx)); +bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx));if (rc) {ibdev_err (&rdev->ibdev,"Failed to allocate QPLIB context: %#x\n" , rc);
@@ -1662,7 +1662,7 @@ static void bnxt_re_setup_cc(struct bnxt_re_dev *rdev, bool enable)return ;/* Currently enabling only for GenP5 adapters */ -if (!bnxt_qplib_is_chip_gen_p5 (rdev->chip_ctx)) +if (!bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx))return ;if (enable) {
drivers/infiniband/hw/bnxt_re/qplib_fp.c +2 -2
@@ -995,7 +995,7 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)/* SQ */ if (qp->type ==CMDQ_CREATE_QP_TYPE_RC ) { - psn_sz =bnxt_qplib_is_chip_gen_p5 (res->cctx) ? + psn_sz =bnxt_qplib_is_chip_gen_p5_p7 (res->cctx) ?sizeof (struct sq_psn_search_ext ) :sizeof (struct sq_psn_search );
@@ -1649,7 +1649,7 @@ static void bnxt_qplib_fill_psn_search(struct bnxt_qplib_qp *qp, flg_npsn = ((swq->next_psn <<SQ_PSN_SEARCH_NEXT_PSN_SFT ) &SQ_PSN_SEARCH_NEXT_PSN_MASK ); -if (bnxt_qplib_is_chip_gen_p5 (qp->cctx)) { +if (bnxt_qplib_is_chip_gen_p5_p7 (qp->cctx)) { psns_ext->opcode_start_psn =cpu_to_le32 (op_spsn); psns_ext->flags_next_psn =cpu_to_le32 (flg_npsn); psns_ext->start_slot_idx =cpu_to_le16 (swq->slot_idx);
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +1 -1
@@ -852,7 +852,7 @@ int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw,*/ if (is_virtfn) goto skip_ctx_setup; -if (bnxt_qplib_is_chip_gen_p5 (rcfw->res->cctx)) +if (bnxt_qplib_is_chip_gen_p5_p7 (rcfw->res->cctx)) goto config_vf_res; lvl = ctx->qpc_tbl.level;
drivers/infiniband/hw/bnxt_re/qplib_res.c +1 -1
@@ -807,7 +807,7 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res, dpit = &res->dpi_tbl; reg = &dpit->wcreg; -if (!bnxt_qplib_is_chip_gen_p5 (res->cctx)) { +if (!bnxt_qplib_is_chip_gen_p5_p7 (res->cctx)) {/* Offest should come from L2 driver */ dbr_offset = dev_attr->l2_db_size; dpit->ucreg.offset = dbr_offset;
drivers/infiniband/hw/bnxt_re/qplib_res.h +17 -3
@@ -44,6 +44,9 @@ extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero;#define CHIP_NUM_57508 0x1750#define CHIP_NUM_57504 0x1751#define CHIP_NUM_57502 0x1752 +#define CHIP_NUM_58818 0xd818 +#define CHIP_NUM_57608 0x1760 +struct bnxt_qplib_drv_modes {u8 wqe_mode;
@@ -296,6 +299,12 @@ struct bnxt_qplib_res {struct bnxt_qplib_db_pacing_data *pacing_data; }; +static inline bool bnxt_qplib_is_chip_gen_p7 (struct bnxt_qplib_chip_ctx *cctx) +{ +return (cctx->chip_num ==CHIP_NUM_58818 || + cctx->chip_num ==CHIP_NUM_57608 ); +} +static inline bool bnxt_qplib_is_chip_gen_p5 (struct bnxt_qplib_chip_ctx *cctx) { return (cctx->chip_num == CHIP_NUM_57508 ||
@@ -303,15 +312,20 @@ static inline bool bnxt_qplib_is_chip_gen_p5(struct bnxt_qplib_chip_ctx *cctx) cctx->chip_num == CHIP_NUM_57502); } +static inline bool bnxt_qplib_is_chip_gen_p5_p7 (struct bnxt_qplib_chip_ctx *cctx) +{ +return bnxt_qplib_is_chip_gen_p5 (cctx) ||bnxt_qplib_is_chip_gen_p7 (cctx); +} +static inline u8 bnxt_qplib_get_hwq_type (struct bnxt_qplib_res *res) { -return bnxt_qplib_is_chip_gen_p5 (res->cctx) ? +return bnxt_qplib_is_chip_gen_p5_p7 (res->cctx) ?HWQ_TYPE_QUEUE :HWQ_TYPE_L2_CMPL ; }static inline u8 bnxt_qplib_get_ring_type (struct bnxt_qplib_chip_ctx *cctx) { -return bnxt_qplib_is_chip_gen_p5 (cctx) ? +return bnxt_qplib_is_chip_gen_p5_p7 (cctx) ?RING_ALLOC_REQ_RING_TYPE_NQ :RING_ALLOC_REQ_RING_TYPE_ROCE_CMPL ; }
@@ -488,7 +502,7 @@ static inline void bnxt_qplib_ring_nq_db(struct bnxt_qplib_db_info *info,u32 type; type = arm ?DBC_DBC_TYPE_NQ_ARM :DBC_DBC_TYPE_NQ ; -if (bnxt_qplib_is_chip_gen_p5 (cctx)) +if (bnxt_qplib_is_chip_gen_p5_p7 (cctx))bnxt_qplib_ring_db (info, type);else bnxt_qplib_ring_db32 (info, arm);
drivers/infiniband/hw/bnxt_re/qplib_sp.c +3 -3
@@ -59,7 +59,7 @@ static bool bnxt_qplib_is_atomic_cap(struct bnxt_qplib_rcfw *rcfw) {u16 pcie_ctl2 =0 ; -if (!bnxt_qplib_is_chip_gen_p5 (rcfw->res->cctx)) +if (!bnxt_qplib_is_chip_gen_p5_p7 (rcfw->res->cctx))return false;pcie_capability_read_word (rcfw->pdev,PCI_EXP_DEVCTL2 , &pcie_ctl2);
@@ -133,7 +133,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,* reporting the max number */ attr->max_qp_wqes -=BNXT_QPLIB_RESERVED_QP_WRS +1 ; - attr->max_qp_sges =bnxt_qplib_is_chip_gen_p5 (rcfw->res->cctx) ? + attr->max_qp_sges =bnxt_qplib_is_chip_gen_p5_p7 (rcfw->res->cctx) ?6 : sb->max_sge; attr->max_cq =le32_to_cpu (sb->max_cq); attr->max_cq_wqes =le32_to_cpu (sb->max_cqe);
@@ -934,7 +934,7 @@ int bnxt_qplib_modify_cc(struct bnxt_qplib_res *res, req->inactivity_th =cpu_to_le16 (cc_param->inact_th);/* For chip gen P5 onwards fill extended cmd and header */ -if (bnxt_qplib_is_chip_gen_p5 (res->cctx)) { +if (bnxt_qplib_is_chip_gen_p5_p7 (res->cctx)) {struct roce_tlv *hdr;u32 payload;u32 chunks;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 34/208 RDMA/bnxt_re: Fix the max CQ WQEs for older adapters
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Mohapatra <[email protected]>
[ Upstream commit ac6df53738b465053d38d491fff87bd7d37fdc07 ]
Older adapters doesn't support the MAX CQ WQEs reported by older FW. So restrict the value reported to 1M always for older adapters.
--- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 2 ++ drivers/infiniband/hw/bnxt_re/qplib_sp.h | 1 + 2 files changed, 3 insertions(+)
drivers/infiniband/hw/bnxt_re/qplib_sp.c +2 -0
@@ -137,6 +137,8 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw, 6 : sb->max_sge; attr->max_cq =le32_to_cpu (sb->max_cq); attr->max_cq_wqes =le32_to_cpu (sb->max_cqe); +if (!bnxt_qplib_is_chip_gen_p7 (rcfw->res->cctx)) + attr->max_cq_wqes =min_t (u32,BNXT_QPLIB_MAX_CQ_WQES , attr->max_cq_wqes); attr->max_cq_sges = attr->max_qp_sges; attr->max_mr =le32_to_cpu (sb->max_mr); attr->max_mw =le32_to_cpu (sb->max_mw);
drivers/infiniband/hw/bnxt_re/qplib_sp.h +1 -0
@@ -55,6 +55,7 @@ struct bnxt_qplib_dev_attr {u32 max_qp_wqes;u32 max_qp_sges;u32 max_cq; +#define BNXT_QPLIB_MAX_CQ_WQES 0xfffffu32 max_cq_wqes;u32 max_cq_sges;u32 max_mr;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 35/208 RDMA/bnxt_re: Fix out of bound check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit a9e6e7443922ac0a48243c35d03834c96926bff1 ]
Driver exports pacing stats only on GenP5 and P7 adapters. But while parsing the pacing stats, driver has a check for "rdev->dbr_pacing". This caused a trace when KASAN is enabled.
BUG: KASAN: slab-out-of-bounds in bnxt_re_get_hw_stats+0x2b6a/0x2e00 [bnxt_re] Write of size 8 at addr ffff8885942a6340 by task modprobe/4809
--- drivers/infiniband/hw/bnxt_re/hw_counters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/hw_counters.c +1 -1
@@ -366,7 +366,7 @@ int bnxt_re_ib_get_hw_stats(struct ib_device *ibdev, goto done; } } -if (rdev->pacing.dbr_pacing) +if (rdev->pacing.dbr_pacing &&bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx))bnxt_re_copy_db_pacing_stats (rdev, stats); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 36/208 RDMA/bnxt_re: Return more meaningful error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit 98647df0178df215b8239c5c365537283b2852a6 ]
When the HWRM command fails, driver currently returns -EFAULT(Bad address). This does not look correct.
Modified to return -EIO(I/O error).
--- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +1 -1
@@ -525,7 +525,7 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,/* failed with status */ dev_err (&rcfw->pdev->dev,"cmdq[%#x]=%#x status %#x\n" , cookie, opcode, evnt->status); - rc = -EFAULT ; + rc = -EIO ; }return rc;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 37/208 RDMA/bnxt_re: Fix a bug while setting up Level-2 PBL pages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bhargava Chenna Marreddy <[email protected]>
[ Upstream commit 7988bdbbb85ac85a847baf09879edcd0f70521dc ]
Avoid memory corruption while setting up Level-2 PBL pages for the non MR resources when num_pages > 256K.
There will be a single PDE page address (contiguous pages in the case of > PAGE_SIZE), but, current logic assumes multiple pages, leading to invalid memory access after 256K PBL entries in the PDE.
--- drivers/infiniband/hw/bnxt_re/qplib_res.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +3 -16
@@ -257,22 +257,9 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq, dst_virt_ptr = (dma_addr_t **)hwq->pbl[PBL_LVL_0 ].pg_arr; src_phys_ptr = hwq->pbl[PBL_LVL_1 ].pg_map_arr; -if (hwq_attr->type ==HWQ_TYPE_MR ) { -/* For MR it is expected that we supply only 1 contigous -* page i.e only 1 entry in the PDL that will contain -* all the PBLs for the user supplied memory region -*/ -for (i =0 ; i < hwq->pbl[PBL_LVL_1 ].pg_count; - i++) - dst_virt_ptr[0 ][i] = src_phys_ptr[i] | - flag; - }else { -for (i =0 ; i < hwq->pbl[PBL_LVL_1 ].pg_count; - i++) - dst_virt_ptr[PTR_PG (i)][PTR_IDX (i)] = - src_phys_ptr[i] | -PTU_PDE_VALID ; - } +for (i =0 ; i < hwq->pbl[PBL_LVL_1 ].pg_count; i++) + dst_virt_ptr[0 ][i] = src_phys_ptr[i] | flag; +/* Alloc or init PTEs */ rc =__alloc_pbl (res, &hwq->pbl[PBL_LVL_2 ], hwq_attr->sginfo);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 38/208 RDMA/bnxt_re: Update the BAR offsets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit a62d685814416647fbb28b3eb2617744adef2d4f ]
Update the BAR offsets for handling GenP7 adapters. Use the values populated by L2 driver for getting the Doorbell offsets.
Stable-dep-of: dc5006cfcf62 ("RDMA/bnxt_re: Fix the GID table length")
--- drivers/infiniband/hw/bnxt_re/main.c | 21 +++++++-------------- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 5 +++-- 2 files changed, 10 insertions(+), 16 deletions(-)
drivers/infiniband/hw/bnxt_re/main.c +7 -14
@@ -107,8 +107,11 @@ static void bnxt_re_set_db_offset(struct bnxt_re_dev *rdev)dev_info (rdev_to_dev (rdev),"Couldn't get DB bar size, Low latency framework is disabled\n" );/* set register offsets for both UC and WC */ - res->dpi_tbl.ucreg.offset = res->is_vf ?BNXT_QPLIB_DBR_VF_DB_OFFSET : -BNXT_QPLIB_DBR_PF_DB_OFFSET ; +if (bnxt_qplib_is_chip_gen_p7 (cctx)) + res->dpi_tbl.ucreg.offset = offset; +else + res->dpi_tbl.ucreg.offset = res->is_vf ?BNXT_QPLIB_DBR_VF_DB_OFFSET : +BNXT_QPLIB_DBR_PF_DB_OFFSET ; res->dpi_tbl.wcreg.offset = res->dpi_tbl.ucreg.offset;/* If WC mapping is disabled by L2 driver then en_dev->l2_db_size
@@ -1070,16 +1073,6 @@ static int bnxt_re_cqn_handler(struct bnxt_qplib_nq *nq,return 0 ; } -#define BNXT_RE_GEN_P5_PF_NQ_DB 0x10000 -#define BNXT_RE_GEN_P5_VF_NQ_DB 0x4000 -static u32 bnxt_re_get_nqdb_offset (struct bnxt_re_dev *rdev,u16 indx) -{ -return bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ? - (rdev->is_virtfn ?BNXT_RE_GEN_P5_VF_NQ_DB : -BNXT_RE_GEN_P5_PF_NQ_DB ) : - rdev->en_dev->msix_entries[indx].db_offset; -} -static void bnxt_re_cleanup_res (struct bnxt_re_dev *rdev) {int i;
@@ -1100,7 +1093,7 @@ static int bnxt_re_init_res(struct bnxt_re_dev *rdev)bnxt_qplib_init_res (&rdev->qplib_res);for (i =1 ; i < rdev->num_msix ; i++) { - db_offt =bnxt_re_get_nqdb_offset (rdev, i); + db_offt = rdev->en_dev->msix_entries[i].db_offset; rc = bnxt_qplib_enable_nq(rdev->en_dev->pdev, &rdev->nq[i - 1], i - 1, rdev->en_dev->msix_entries[i].vector, db_offt, &bnxt_re_cqn_handler,
@@ -1511,7 +1504,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 wqe_mode)ibdev_err (&rdev->ibdev,"Failed to allocate CREQ: %#x\n" , rc); goto free_rcfw; } - db_offt =bnxt_re_get_nqdb_offset (rdev,BNXT_RE_AEQ_IDX ); + db_offt = rdev->en_dev->msix_entries[BNXT_RE_AEQ_IDX ].db_offset; vid = rdev->en_dev->msix_entries[BNXT_RE_AEQ_IDX ].vector; rc = bnxt_qplib_enable_rcfw_channel(&rdev->rcfw, vid, db_offt,
drivers/infiniband/hw/bnxt_re/qplib_sp.c +3 -2
@@ -153,8 +153,9 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw, attr->max_srq_sges = sb->max_srq_sge; attr->max_pkey =1 ; attr->max_inline_data =le32_to_cpu (sb->max_inline_data); - attr->l2_db_size = (sb->l2_db_space_size +1 ) * - (0x01 <<RCFW_DBR_BASE_PAGE_SHIFT ); +if (!bnxt_qplib_is_chip_gen_p7 (rcfw->res->cctx)) + attr->l2_db_size = (sb->l2_db_space_size +1 ) * + (0x01 <<RCFW_DBR_BASE_PAGE_SHIFT ); attr->max_sgid =BNXT_QPLIB_NUM_GIDS_SUPPORTED ; attr->dev_cap_flags =le16_to_cpu (sb->dev_cap_flags);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 39/208 RDMA/bnxt_re: Fix the GID table length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit dc5006cfcf62bea88076a587344ba5e00e66d1c6 ]
GID table length is reported by FW. The gid index which is passed to the driver during modify_qp/create_ah is restricted by the sgid_index field of struct ib_global_route. sgid_index is u8 and the max sgid possible is 256.
Each GID entry in HW will have 2 GID entries in the kernel gid table. So we can support twice the gid table size reported by FW. Also, restrict the max GID to 256 also.
--- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_sp.c +8 -1
@@ -156,7 +156,14 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,if (!bnxt_qplib_is_chip_gen_p7 (rcfw->res->cctx)) attr->l2_db_size = (sb->l2_db_space_size +1 ) * (0x01 <<RCFW_DBR_BASE_PAGE_SHIFT ); - attr->max_sgid =BNXT_QPLIB_NUM_GIDS_SUPPORTED ; +/* +* Read the max gid supported by HW. +* For each entry in HW GID in HW table, we consume 2 +* GID entries in the kernel GID table. So max_gid reported +* to stack can be up to twice the value reported by the HW, up to 256 gids. +*/ + attr->max_sgid =le32_to_cpu (sb->max_gid); + attr->max_sgid =min_t (u32,BNXT_QPLIB_NUM_GIDS_SUPPORTED ,2 * attr->max_sgid); attr->dev_cap_flags =le16_to_cpu (sb->dev_cap_flags);bnxt_qplib_query_version (rcfw, attr->fw_ver);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 40/208 accel/qaic: Fix the for loop used to walk SG table
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pranjal Ramajor Asha Kanojiya <[email protected]>
[ Upstream commit c5e8e93897b7bb0a336bf3332f82f8d9f2b33f14 ]
Only for_each_sgtable_dma_sg() should be used to walk through a SG table to grab correct bus address and length pair after calling DMA MAP API on a SG table as DMA MAP APIs updates the SG table and for_each_sgtable_sg() walks through the original SG table.
--- drivers/accel/qaic/qaic_control.c | 2 +- drivers/accel/qaic/qaic_data.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/accel/qaic/qaic_control.c +1 -1
@@ -496,7 +496,7 @@ static int encode_addr_size_pairs(struct dma_xfer *xfer, struct wrapper_list *wr nents = sgt->nents; nents_dma = nents; *size =QAIC_MANAGE_EXT_MSG_LENGTH - msg_hdr_len -sizeof (**out_trans); -for_each_sgtable_sg (sgt, sg, i) { +for_each_sgtable_dma_sg (sgt, sg, i) { *size -=sizeof (*asp);/* Save 1K for possible follow-up transactions. */ if (*size <SZ_1K ) {
drivers/accel/qaic/qaic_data.c +3 -3
@@ -177,7 +177,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl nents =0 ; size = size ? size :PAGE_SIZE ; -for (sg = sgt_in->sgl; sg; sg =sg_next (sg)) { +for_each_sgtable_dma_sg (sgt_in, sg, j) { len =sg_dma_len (sg);if (!len)
@@ -214,7 +214,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl/* copy relevant sg node and fix page and length */ sgn = sgf; -for_each_sgtable_sg (sgt, sg, j) { +for_each_sgtable_dma_sg (sgt, sg, j) {memcpy (sg, sgn,sizeof (*sg));if (sgn == sgf) {sg_dma_address (sg) += offf;
@@ -294,7 +294,7 @@ static int encode_reqs(struct qaic_device *qdev, struct bo_slice *slice,* fence. */ dev_addr = req->dev_addr; -for_each_sgtable_sg (slice->sgt, sg, i) { +for_each_sgtable_dma_sg (slice->sgt, sg, i) { slice->reqs[i].cmd = cmd; slice->reqs[i].src_addr =cpu_to_le64 (slice->dir ==DMA_TO_DEVICE ?sg_dma_address (sg) : dev_addr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 23/208 drm/vmwgfx: Handle possible ENOMEM in vmw_stdu_connector_atomic_check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Forbes <[email protected]>
[ Upstream commit 4809a017a2bc42ff239d53ade4b2e70f2fe81348 ]
Handle unlikely ENOMEN condition and other errors in vmw_stdu_connector_atomic_check.
--- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +4 -0
@@ -881,6 +881,10 @@ static int vmw_stdu_connector_atomic_check(struct drm_connector *conn,struct drm_crtc_state *new_crtc_state; conn_state =drm_atomic_get_connector_state (state, conn); + +if (IS_ERR (conn_state)) +return PTR_ERR (conn_state); + du =vmw_connector_to_stdu (conn);if (!conn_state->crtc)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 41/208 drm/msm/dpu: make sure phys resources are properly initialized
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit bfecbc2cfba9b06d67d9d249c33d92e570e2fa70 ]
The commit b954fa6baaca ("drm/msm/dpu: Refactor rm iterator") removed zero-init of the hw_ctl array, but didn't change the error condition, that checked for hw_ctl[i] being NULL. At the same time because of the early returns in case of an error dpu_encoder_phys might be left with the resources assigned in the previous state. Rework assigning of hw_pp / hw_ctl to the dpu_encoder_phys in order to make sure they are always set correctly.
Patchwork: https://patchwork.freedesktop.org/patch/612233/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +4 -5
@@ -1122,21 +1122,20 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,for (i =0 ; i < dpu_enc->num_phys_encs; i++) {struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; -if (!dpu_enc->hw_pp[i]) { + phys->hw_pp = dpu_enc->hw_pp[i]; +if (!phys->hw_pp) {DPU_ERROR_ENC (dpu_enc,"no pp block assigned at idx: %d\n" , i);return ; } -if (!hw_ctl[i]) { + phys->hw_ctl = i < num_ctl ?to_dpu_hw_ctl (hw_ctl[i]) :NULL ; +if (!phys->hw_ctl) {DPU_ERROR_ENC (dpu_enc,"no ctl block assigned at idx: %d\n" , i);return ; } - phys->hw_pp = dpu_enc->hw_pp[i]; - phys->hw_ctl =to_dpu_hw_ctl (hw_ctl[i]); - phys->cached_mode = crtc_state->adjusted_mode;if (phys->ops.atomic_mode_set) phys->ops.atomic_mode_set (phys, crtc_state, conn_state);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 42/208 drm/msm/dpu: check for overflow in _dpu_crtc_setup_lm_bounds()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 3a0851b442d1f63ba42ecfa2506d3176cfabf9d4 ]
Make _dpu_crtc_setup_lm_bounds() check that CRTC width is not overflowing LM requirements. Rename the function accordingly.
Patchwork: https://patchwork.freedesktop.org/patch/612237/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +13 -4
@@ -722,12 +722,13 @@ void dpu_crtc_complete_commit(struct drm_crtc *crtc)_dpu_crtc_complete_flip (crtc); } -static void _dpu_crtc_setup_lm_bounds (struct drm_crtc *crtc, +static int _dpu_crtc_check_and_setup_lm_bounds (struct drm_crtc *crtc,struct drm_crtc_state *state) {struct dpu_crtc_state *cstate =to_dpu_crtc_state (state);struct drm_display_mode *adj_mode = &state->adjusted_mode;u32 crtc_split_width = adj_mode->hdisplay / cstate->num_mixers; +struct dpu_kms *dpu_kms =_dpu_crtc_get_kms (crtc);int i;for (i =0 ; i < cstate->num_mixers; i++) {
@@ -738,7 +739,12 @@ static void _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc, r->y2 = adj_mode->vdisplay;trace_dpu_crtc_setup_lm_bounds (DRMID (crtc), i, r); + +if (drm_rect_width (r) > dpu_kms->catalog->caps->max_mixer_width) +return -E2BIG ; } + +return 0 ; } static void _dpu_crtc_get_pcc_coeff(struct drm_crtc_state *state,
@@ -814,7 +820,7 @@ static void dpu_crtc_atomic_begin(struct drm_crtc *crtc,DRM_DEBUG_ATOMIC ("crtc%d\n" , crtc->base.id); -_dpu_crtc_setup_lm_bounds (crtc, crtc->state); +_dpu_crtc_check_and_setup_lm_bounds (crtc, crtc->state);/* encoder will trigger pending mask now */ drm_for_each_encoder_mask (encoder, crtc->dev, crtc->state->encoder_mask)
@@ -1208,8 +1214,11 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,if (crtc_state->active_changed) crtc_state->mode_changed = true; -if (cstate->num_mixers) -_dpu_crtc_setup_lm_bounds (crtc, crtc_state); +if (cstate->num_mixers) { + rc =_dpu_crtc_check_and_setup_lm_bounds (crtc, crtc_state); +if (rc) +return rc; + }/* FIXME: move this to dpu_plane_atomic_check? */ drm_atomic_crtc_state_for_each_plane_state (plane, pstate, crtc_state) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 43/208 drm/msm/dsi: improve/fix dsc pclk calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Marek <[email protected]>
[ Upstream commit 24436a540d16ca6a523b8e5441180001c31b6b35 ]
drm_mode_vrefresh() can introduce a large rounding error, avoid it.
Patchwork: https://patchwork.freedesktop.org/patch/618432/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +1 -1
@@ -537,7 +537,7 @@ static unsigned long dsi_adjust_pclk_for_compression(const struct drm_display_moint new_htotal = mode->htotal - mode->hdisplay + new_hdisplay; -return new_htotal * mode->vtotal *drm_mode_vrefresh (mode); +return mult_frac (mode->clock *1000u , new_htotal, mode->htotal); } static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 44/208 drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Marek <[email protected]>
[ Upstream commit 358b762400bd94db2a14a72dfcef74c7da6bd845 ]
When (mode->clock * 1000) is larger than (1<<31), int to unsigned long conversion will sign extend the int to 64 bits and the pclk_rate value will be incorrect.
Fix this by making the result of the multiplication unsigned.
Note that above (1<<32) would still be broken and require more changes, but its unlikely anyone will need that anytime soon.
Patchwork: https://patchwork.freedesktop.org/patch/618434/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +1 -1
@@ -545,7 +545,7 @@ static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode, {unsigned long pclk_rate; - pclk_rate = mode->clock *1000 ; + pclk_rate = mode->clock *1000u ;if (dsc) pclk_rate =dsi_adjust_pclk_for_compression (mode, dsc);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 45/208 drm/msm: Avoid NULL dereference in msm_disp_state_print_regs()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
[ Upstream commit 293f53263266bc4340d777268ab4328a97f041fa ]
If the allocation in msm_disp_state_dump_regs() failed then block->state can be NULL. The msm_disp_state_print_regs() function _does_ have code to try to handle it with:
if (*reg)
dump_addr = *reg;...but since "dump_addr" is initialized to NULL the above is actually a noop. The code then goes on to dereference dump_addr.
Make the function print "Registers not stored" when it sees a NULL to solve this. Since we're touching the code, fix msm_disp_state_print_regs() not to pointlessly take a double-pointer and properly mark the pointer as const.
Patchwork: https://patchwork.freedesktop.org/patch/619657/
--- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +8 -7
@@ -48,20 +48,21 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b } } -static void msm_disp_state_print_regs (u32 **reg,u32 len,void __iomem *base_addr, -struct drm_printer *p) +static void msm_disp_state_print_regs (const u32 *dump_addr,u32 len, +void __iomem *base_addr,struct drm_printer *p) {int i; -u32 *dump_addr =NULL ;void __iomem *addr;u32 num_rows; +if (!dump_addr) { +drm_printf (p,"Registers not stored\n" ); +return ; + } + addr = base_addr; num_rows = len /REG_DUMP_ALIGN ; -if (*reg) - dump_addr = *reg; -for (i =0 ; i < num_rows; i++) { drm_printf(p, "0x%lx : %08x %08x %08x %08x\n", (unsigned long)(addr - base_addr),
@@ -89,7 +90,7 @@ void msm_disp_state_print(struct msm_disp_state *state, struct drm_printer *p)list_for_each_entry_safe (block, tmp, &state->blocks, node) {drm_printf (p,"====================%s================\n" , block->name); -msm_disp_state_print_regs (&block->state, block->size, block->base_addr, p); +msm_disp_state_print_regs (block->state, block->size, block->base_addr, p); }drm_printf (p,"===================dpu drm state================\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 46/208 drm/msm: Allocate memory for disp snapshot with kvzalloc()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
[ Upstream commit e4a45582db1b792c57bdb52c45958264f7fcfbdc ]
With the "drm/msm: add a display mmu fault handler" series [1] we saw issues in the field where memory allocation was failing when allocating space for registers in msm_disp_state_dump_regs(). Specifically we were seeing an order 5 allocation fail. It's not surprising that order 5 allocations will sometimes fail after the system has been up and running for a while.
There's no need here for contiguous memory. Change the allocation to kvzalloc() which should make it much less likely to fail.
[1] https://lore.kernel.org/r/[email protected]/
Patchwork: https://patchwork.freedesktop.org/patch/619658/
--- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2 -2
@@ -26,7 +26,7 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b end_addr = base_addr + aligned_len;if (!(*reg)) - *reg =kzalloc (len_padded,GFP_KERNEL ); + *reg =kvzalloc (len_padded,GFP_KERNEL );if (*reg) dump_addr = *reg;
@@ -162,7 +162,7 @@ void msm_disp_state_free(void *data)list_for_each_entry_safe (block, tmp, &disp_state->blocks, node) {list_del (&block->node); -kfree (block->state); +kvfree (block->state);kfree (block); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 47/208 firmware: arm_scmi: Queue in scmi layer for mailbox implementation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
[ Upstream commit da1642bc97c4ef67f347edcd493bd0a52f88777b ]
send_message() does not block in the MBOX implementation. This is because the mailbox layer has its own queue. However, this confuses the per xfer timeouts as they all start their timeout ticks in parallel.
Consider a case where the xfer timeout is 30ms and a SCMI transaction takes 25ms:
| 0ms: Message #0 is queued in mailbox layer and sent out, then sits | at scmi_wait_for_message_response() with a timeout of 30ms | 1ms: Message #1 is queued in mailbox layer but not sent out yet. | Since send_message() doesn't block, it also sits at | scmi_wait_for_message_response() with a timeout of 30ms | ... | 25ms: Message #0 is completed, txdone is called and message #1 is sent | 31ms: Message #1 times out since the count started at 1ms. Even though | it has only been inflight for 6ms.
Message-Id: <[email protected]>
--- drivers/firmware/arm_scmi/mailbox.c | 32 +++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/firmware/arm_scmi/mailbox.c +21 -11
@@ -23,6 +23,7 @@* @chan_receiver: Optional Receiver mailbox unidirectional channel * @cinfo: SCMI channel info * @shmem: Transmit/Receive shared memory area +* @chan_lock: Lock that prevents multiple xfers from being queued */ struct scmi_mailbox {struct mbox_client cl;
@@ -30,6 +31,7 @@ struct scmi_mailbox {struct mbox_chan *chan_receiver;struct scmi_chan_info *cinfo;struct scmi_shared_mem __iomem *shmem; +struct mutex chan_lock; };#define client_to_scmi_mailbox (c) container_of(c, struct scmi_mailbox, cl)
@@ -228,6 +230,7 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, cinfo->transport_info = smbox; smbox->cinfo = cinfo; +mutex_init (&smbox->chan_lock);return 0 ; }
@@ -255,13 +258,23 @@ static int mailbox_send_message(struct scmi_chan_info *cinfo,struct scmi_mailbox *smbox = cinfo->transport_info;int ret; - ret =mbox_send_message (smbox->chan, xfer); +/* +* The mailbox layer has its own queue. However the mailbox queue +* confuses the per message SCMI timeouts since the clock starts when +* the message is submitted into the mailbox queue. So when multiple +* messages are queued up the clock starts on all messages instead of +* only the one inflight. +*/ +mutex_lock (&smbox->chan_lock); -/* mbox_send_message returns non-negative value on success, so reset */ -if (ret >0 ) - ret =0 ; + ret =mbox_send_message (smbox->chan, xfer); +/* mbox_send_message returns non-negative value on success */ +if (ret <0 ) { +mutex_unlock (&smbox->chan_lock); +return ret; + } -return ret; +return 0 ; } static void mailbox_mark_txdone(struct scmi_chan_info *cinfo, int ret,
@@ -269,13 +282,10 @@ static void mailbox_mark_txdone(struct scmi_chan_info *cinfo, int ret, {struct scmi_mailbox *smbox = cinfo->transport_info; -/* -* NOTE: we might prefer not to need the mailbox ticker to manage the -* transfer queueing since the protocol layer queues things by itself. -* Unfortunately, we have to kick the mailbox framework after we have -* received our message. -*/ mbox_client_txdone (smbox->chan, ret); + +/* Release channel */ +mutex_unlock (&smbox->chan_lock); } static void mailbox_fetch_response(struct scmi_chan_info *cinfo,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 48/208 net/smc: Fix memory leak when using percpu refs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Shen <[email protected]>
[ Upstream commit 25c12b459db8365fee84b63f3dd7910f70627f29 ]
This patch adds missing percpu_ref_exit when releasing percpu refs. When releasing percpu refs, percpu_ref_exit should be called. Otherwise, memory leak happens.
--- net/smc/smc_wr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/smc/smc_wr.c +5 -1
@@ -648,8 +648,10 @@ void smc_wr_free_link(struct smc_link *lnk)smc_wr_tx_wait_no_pending_sends (lnk);percpu_ref_kill (&lnk->wr_reg_refs);wait_for_completion (&lnk->reg_ref_comp); +percpu_ref_exit (&lnk->wr_reg_refs);percpu_ref_kill (&lnk->wr_tx_refs);wait_for_completion (&lnk->tx_ref_comp); +percpu_ref_exit (&lnk->wr_tx_refs);if (lnk->wr_rx_dma_addr) { ib_dma_unmap_single(ibdev, lnk->wr_rx_dma_addr,
@@ -912,11 +914,13 @@ int smc_wr_create_link(struct smc_link *lnk)init_waitqueue_head (&lnk->wr_reg_wait); rc =percpu_ref_init (&lnk->wr_reg_refs, smcr_wr_reg_refs_free,0 ,GFP_KERNEL );if (rc) - goto dma_unmap; + goto cancel_ref;init_completion (&lnk->reg_ref_comp);init_waitqueue_head (&lnk->wr_rx_empty_wait);return rc; +cancel_ref: +percpu_ref_exit (&lnk->wr_tx_refs); dma_unmap:if (lnk->wr_rx_v2_dma_addr) { ib_dma_unmap_single(ibdev, lnk->wr_rx_v2_dma_addr,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 49/208 net: usb: usbnet: fix race in probe failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit b62f4c186c70aa235fef2da68d07325d85ca3ade ]
The same bug as in the disconnect code path also exists in the case of a failure late during the probe process. The flag must also be set.
--- drivers/net/usb/usbnet.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/usbnet.c +1 -0
@@ -1874,6 +1874,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)* may trigger an error resubmitting itself and, worse, * schedule a timer. So we kill it all just in case. */ +usbnet_mark_going_away (dev);cancel_work_sync (&dev->kevent);del_timer_sync (&dev->delay);free_percpu (net->tstats);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 50/208 net: stmmac: dwmac-tegra: Fix link bring-up sequence
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paritosh Dixit <[email protected]>
[ Upstream commit 1cff6ff302f5703a627f9ee1d99131161ea2683e ]
The Tegra MGBE driver sometimes fails to initialize, reporting the following error, and as a result, it is unable to acquire an IP address with DHCP:
tegra-mgbe 6800000.ethernet: timeout waiting for link to become ready
As per the recommendation from the Tegra hardware design team, fix this issue by:
- clearing the PHY_RDY bit before setting the CDR_RESET bit and then setting PHY_RDY bit before clearing CDR_RESET bit. This ensures valid data is present at UPHY RX inputs before starting the CDR lock.
- adding the required delays when bringing up the UPHY lane. Note we need to use delays here because there is no alternative, such as polling, for these cases. Using the usleep_range() instead of ndelay() as sleeping is preferred over busy wait loop.
Without this change we would see link failures on boot sometimes as often as 1 in 5 boots. With this fix we have not observed any failures in over 1000 boots.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c +12 -2
@@ -127,10 +127,12 @@ static int mgbe_uphy_lane_bringup_serdes_up(struct net_device *ndev, void *mgbe_ value &= ~XPCS_WRAP_UPHY_RX_CONTROL_AUX_RX_IDDQ ;writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); +usleep_range (10 ,20 );/* 50ns min delay needed as per HW design */ value =readl (mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_SLEEP ;writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); +usleep_range (10 ,20 );/* 500ns min delay needed as per HW design */ value =readl (mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); value |=XPCS_WRAP_UPHY_RX_CONTROL_RX_CAL_EN ;writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL );
@@ -143,22 +145,30 @@ static int mgbe_uphy_lane_bringup_serdes_up(struct net_device *ndev, void *mgbe_return err; } +usleep_range (10 ,20 );/* 50ns min delay needed as per HW design */ value =readl (mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); value |=XPCS_WRAP_UPHY_RX_CONTROL_RX_DATA_EN ;writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); value =readl (mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); - value |=XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET ; + value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_PCS_PHY_RDY ;writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); +usleep_range (10 ,20 );/* 50ns min delay needed as per HW design */ value =readl (mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); - value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET ; + value |=XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET ;writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); +usleep_range (10 ,20 );/* 50ns min delay needed as per HW design */ value =readl (mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); value |=XPCS_WRAP_UPHY_RX_CONTROL_RX_PCS_PHY_RDY ;writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); +msleep (30 );/* 30ms delay needed as per HW design */ + value =readl (mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); + value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET ; +writel (value, mgbe->xpcs +XPCS_WRAP_UPHY_RX_CONTROL ); + err =readl_poll_timeout (mgbe->xpcs +XPCS_WRAP_IRQ_STATUS , value, value &XPCS_WRAP_IRQ_STATUS_PCS_LINK_STS ,500 ,500 *2000 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 24/208 selftests/bpf: Fix cross-compiling urandom_read
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit fd526e121c4d6f71aed82d21a8b8277b03e60b43 ]
Linking of urandom_read and liburandom_read.so prefers LLVM's 'ld.lld' but falls back to using 'ld' if unsupported. However, this fallback discards any existing makefile macro for LD and can break cross-compilation.
Fix by changing the fallback to use the target linker $(LD), passed via '-fuse-ld=' using an absolute path rather than a linker "flavour".
--- tools/testing/selftests/bpf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
@@ -200,7 +200,7 @@ $(OUTPUT)/%:%.c ifeq ($(SRCARCH),x86) LLD := lld else -LLD := ld +LLD := $(shell command -v $(LD)) endif # Filter out -static for liburandom_read.so and its dependent targets so that static builds
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 51/208 octeontx2-af: Fix potential integer overflows on integer shifts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
[ Upstream commit 637c4f6fe40befa04f19c38b5d15429cbb9191d9 ]
The left shift int 32 bit integer constants 1 is evaluated using 32 bit arithmetic and then assigned to a 64 bit unsigned integer. In the case where the shift is 32 or more this can lead to an overflow. Avoid this by shifting using the BIT_ULL macro instead.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +2 -2
@@ -2298,7 +2298,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr, NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));if (!(cfg &BIT_ULL (12 )))continue ; - bmap |= (1 << i); + bmap |=BIT_ULL (i); cfg &= ~BIT_ULL (12 );rvu_write64 (rvu, blkaddr,NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link), cfg);
@@ -2319,7 +2319,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,/* Set NIX_AF_TL3_TL2_LINKX_CFG[ENA] for the TL3/TL2 queue */ for (i =0 ; i < (rvu->hw->cgx_links + rvu->hw->lbk_links); i++) { -if (!(bmap & (1 << i))) +if (!(bmap &BIT_ULL (i)))continue ; cfg =rvu_read64 (rvu, blkaddr,NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 52/208 drm/amd/amdgpu: Fix double unlock in amdgpu_mes_add_ring
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit e7457532cb7167516263150ceae86f36d6ef9683 ]
This patch addresses a double unlock issue in the amdgpu_mes_add_ring function. The mutex was being unlocked twice under certain error conditions, which could lead to undefined behavior.
The fix ensures that the mutex is unlocked only once before jumping to the clean_up_memory label. The unlock operation is moved to just before the goto statement within the conditional block that checks the return value of amdgpu_ring_init. This prevents the second unlock attempt after the clean_up_memory label, which is no longer necessary as the mutex is already unlocked by this point in the code flow.
This change resolves the potential double unlock and maintains the correct mutex handling throughout the function.
Fixes below:
Commit d0c423b64765 ("drm/amdgpu/mes: use ring for kernel queue submission"), leads to the following Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1240 amdgpu_mes_add_ring() warn: double unlock '&adev->mes.mutex_hidden' (orig line 1213)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
1143 int amdgpu_mes_add_ring(struct amdgpu_device *adev, int gang_id,
1144 int queue_type, int idx,
1145 struct amdgpu_mes_ctx_data *ctx_data,
1146 struct amdgpu_ring **out)
1147 {
1148 struct amdgpu_ring *ring;
1149 struct amdgpu_mes_gang *gang;
1150 struct amdgpu_mes_queue_properties qprops = {0};
1151 int r, queue_id, pasid;
1152
1153 /*
1154 * Avoid taking any other locks under MES lock to avoid circular
1155 * lock dependencies.
1156 */
1157 amdgpu_mes_lock(&adev->mes);
1158 gang = idr_find(&adev->mes.gang_id_idr, gang_id);
1159 if (!gang) {
1160 DRM_ERROR("gang id %d doesn't exist\n", gang_id);
1161 amdgpu_mes_unlock(&adev->mes);
1162 return -EINVAL;
1163 }
1164 pasid = gang->process->pasid;
1165
1166 ring = kzalloc(sizeof(struct amdgpu_ring), GFP_KERNEL);
1167 if (!ring) {
1168 amdgpu_mes_unlock(&adev->mes);
1169 return -ENOMEM;
1170 }
1171
1172 ring->ring_obj = NULL;
1173 ring->use_doorbell = true;
1174 ring->is_mes_queue = true;
1175 ring->mes_ctx = ctx_data;
1176 ring->idx = idx;
1177 ring->no_scheduler = true;
1178
1179 if (queue_type == AMDGPU_RING_TYPE_COMPUTE) {
1180 int offset = offsetof(struct amdgpu_mes_ctx_meta_data,
1181 compute[ring->idx].mec_hpd);
1182 ring->eop_gpu_addr =
1183 amdgpu_mes_ctx_get_offs_gpu_addr(ring, offset);
1184 }
1185
1186 switch (queue_type) {
1187 case AMDGPU_RING_TYPE_GFX:
1188 ring->funcs = adev->gfx.gfx_ring[0].funcs;
1189 ring->me = adev->gfx.gfx_ring[0].me;
1190 ring->pipe = adev->gfx.gfx_ring[0].pipe;
1191 break;
1192 case AMDGPU_RING_TYPE_COMPUTE:
1193 ring->funcs = adev->gfx.compute_ring[0].funcs;
1194 ring->me = adev->gfx.compute_ring[0].me;
1195 ring->pipe = adev->gfx.compute_ring[0].pipe;
1196 break;
1197 case AMDGPU_RING_TYPE_SDMA:
1198 ring->funcs = adev->sdma.instance[0].ring.funcs;
1199 break;
1200 default:
1201 BUG();
1202 }
1203
1204 r = amdgpu_ring_init(adev, ring, 1024, NULL, 0,
1205 AMDGPU_RING_PRIO_DEFAULT, NULL);
1206 if (r)
1207 goto clean_up_memory;
1208
1209 amdgpu_mes_ring_to_queue_props(adev, ring, &qprops);
1210
1211 dma_fence_wait(gang->process->vm->last_update, false);
1212 dma_fence_wait(ctx_data->meta_data_va->last_pt_update, false);
1213 amdgpu_mes_unlock(&adev->mes);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1214
1215 r = amdgpu_mes_add_hw_queue(adev, gang_id, &qprops, &queue_id);
1216 if (r)
1217 goto clean_up_ring;
^^^^^^^^^^^^^^^^^^
1218
1219 ring->hw_queue_id = queue_id;
1220 ring->doorbell_index = qprops.doorbell_off;
1221
1222 if (queue_type == AMDGPU_RING_TYPE_GFX)
1223 sprintf(ring->name, "gfx_%d.%d.%d", pasid, gang_id, queue_id);
1224 else if (queue_type == AMDGPU_RING_TYPE_COMPUTE)
1225 sprintf(ring->name, "compute_%d.%d.%d", pasid, gang_id,
1226 queue_id);
1227 else if (queue_type == AMDGPU_RING_TYPE_SDMA)
1228 sprintf(ring->name, "sdma_%d.%d.%d", pasid, gang_id,
1229 queue_id);
1230 else
1231 BUG();
1232
1233 *out = ring;
1234 return 0;
1235
1236 clean_up_ring:
1237 amdgpu_ring_fini(ring);
1238 clean_up_memory:
1239 kfree(ring);
--> 1240 amdgpu_mes_unlock(&adev->mes);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1241 return r;
1242 }Reported by: Dan Carpenter <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -2
@@ -1053,8 +1053,10 @@ int amdgpu_mes_add_ring(struct amdgpu_device *adev, int gang_id, r =amdgpu_ring_init (adev, ring,1024 ,NULL ,0 ,AMDGPU_RING_PRIO_DEFAULT ,NULL ); -if (r) +if (r) { +amdgpu_mes_unlock (&adev->mes); goto clean_up_memory; + }amdgpu_mes_ring_to_queue_props (adev, ring, &qprops);
@@ -1087,7 +1089,6 @@ int amdgpu_mes_add_ring(struct amdgpu_device *adev, int gang_id,amdgpu_ring_fini (ring); clean_up_memory:kfree (ring); -amdgpu_mes_unlock (&adev->mes);return r; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 53/208 macsec: dont increment counters for an unrelated SA
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit cf58aefb1332db322060cad4a330d5f9292b0f41 ]
On RX, we shouldn't be incrementing the stats for an arbitrary SA in case the actual SA hasn't been set up. Those counters are intended to track packets for their respective AN when the SA isn't currently configured. Due to the way MACsec is implemented, we don't keep counters unless the SA is configured, so we can't track those packets, and those counters will remain at 0.
The RXSC's stats keeps track of those packets without telling us which AN they belonged to. We could add counters for non-existent SAs, and then find a way to integrate them in the dump to userspace, but I don't think it's worth the effort.
--- drivers/net/macsec.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/net/macsec.c +0 -18
@@ -151,19 +151,6 @@ static struct macsec_rx_sa *macsec_rxsa_get(struct macsec_rx_sa __rcu *ptr)return sa; } -static struct macsec_rx_sa *macsec_active_rxsa_get (struct macsec_rx_sc *rx_sc) -{ -struct macsec_rx_sa *sa =NULL ; -int an; - -for (an =0 ; an <MACSEC_NUM_AN ; an++) { - sa =macsec_rxsa_get (rx_sc->sa[an]); -if (sa) -break ; - } -return sa; -} -static void free_rx_sc_rcu (struct rcu_head *head) { struct macsec_rx_sc *rx_sc = container_of(head, struct macsec_rx_sc, rcu_head);
@@ -1205,15 +1192,12 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)/* If validateFrames is Strict or the C bit in the * SecTAG is set, discard */ -struct macsec_rx_sa *active_rx_sa =macsec_active_rxsa_get (rx_sc);if (hdr->tci_an &MACSEC_TCI_C || secy->validate_frames ==MACSEC_VALIDATE_STRICT ) {u64_stats_update_begin (&rxsc_stats->syncp); rxsc_stats->stats.InPktsNotUsingSA++;u64_stats_update_end (&rxsc_stats->syncp);DEV_STATS_INC (secy->netdev, rx_errors); -if (active_rx_sa) -this_cpu_inc (active_rx_sa->stats->InPktsNotUsingSA); goto drop_nosa; }
@@ -1223,8 +1207,6 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)u64_stats_update_begin (&rxsc_stats->syncp); rxsc_stats->stats.InPktsUnusedSA++;u64_stats_update_end (&rxsc_stats->syncp); -if (active_rx_sa) -this_cpu_inc (active_rx_sa->stats->InPktsUnusedSA); goto deliver; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 54/208 netdevsim: use cond_resched() in nsim_dev_trap_report_work()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit a1494d532e28598bde7a5544892ef9c7dbfafa93 ]
I am still seeing many syzbot reports hinting that syzbot might fool nsim_dev_trap_report_work() with hundreds of ports [1]
Lets use cond_resched(), and system_unbound_wq
instead of implicit system_wq.
[1]
INFO: task syz-executor:20633 blocked for more than 143 seconds.
Not tainted 6.12.0-rc2-syzkaller-00205-g1d227fcc7222 #0"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor state:D stack:25856 pid:20633 tgid:20633 ppid:1 flags:0x00004006
...
NMI backtrace for cpu 1
CPU: 1 UID: 0 PID: 16760 Comm: kworker/1:0 Not tainted 6.12.0-rc2-syzkaller-00205-g1d227fcc7222 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Workqueue: events nsim_dev_trap_report_work RIP: 0010:__sanitizer_cov_trace_pc+0x0/0x70 kernel/kcov.c:210 Code: 89 fb e8 23 00 00 00 48 8b 3d 04 fb 9c 0c 48 89 de 5b e9 c3 c7 5d 00 0f 1f 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 <f3> 0f 1e fa 48 8b 04 24 65 48 8b 0c 25 c0 d7 03 00 65 8b 15 60 f0 RSP: 0018:ffffc90000a187e8 EFLAGS: 00000246 RAX: 0000000000000100 RBX: ffffc90000a188e0 RCX: ffff888027d3bc00 RDX: ffff888027d3bc00 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffff88804a2e6000 R08: ffffffff8a4bc495 R09: ffffffff89da3577 R10: 0000000000000004 R11: ffffffff8a4bc2b0 R12: dffffc0000000000 R13: ffff88806573b503 R14: dffffc0000000000 R15: ffff8880663cca00 FS: 0000000000000000(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fc90a747f98 CR3: 000000000e734000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 000000000000002b DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Call Trace: <NMI> </NMI> <TASK> __local_bh_enable_ip+0x1bb/0x200 kernel/softirq.c:382 spin_unlock_bh include/linux/spinlock.h:396 [inline] nsim_dev_trap_report drivers/net/netdevsim/dev.c:820 [inline] nsim_dev_trap_report_work+0x75d/0xaa0 drivers/net/netdevsim/dev.c:850 process_one_work kernel/workqueue.c:3229 [inline] process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310 worker_thread+0x870/0xd30 kernel/workqueue.c:3391 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK>
--- drivers/net/netdevsim/dev.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/netdevsim/dev.c +9 -6
@@ -836,7 +836,8 @@ static void nsim_dev_trap_report_work(struct work_struct *work) nsim_dev = nsim_trap_data->nsim_dev;if (!devl_trylock (priv_to_devlink (nsim_dev))) { -schedule_delayed_work (&nsim_dev->trap_data->trap_report_dw,1 ); +queue_delayed_work (system_unbound_wq, + &nsim_dev->trap_data->trap_report_dw,1 );return ; }
@@ -848,11 +849,12 @@ static void nsim_dev_trap_report_work(struct work_struct *work)continue ;nsim_dev_trap_report (nsim_dev_port); +cond_resched (); }devl_unlock (priv_to_devlink (nsim_dev)); - -schedule_delayed_work (&nsim_dev->trap_data->trap_report_dw, -msecs_to_jiffies (NSIM_TRAP_REPORT_INTERVAL_MS )); +queue_delayed_work (system_unbound_wq, + &nsim_dev->trap_data->trap_report_dw, +msecs_to_jiffies (NSIM_TRAP_REPORT_INTERVAL_MS )); }static int nsim_dev_traps_init (struct devlink *devlink)
@@ -907,8 +909,9 @@ static int nsim_dev_traps_init(struct devlink *devlink)INIT_DELAYED_WORK (&nsim_dev->trap_data->trap_report_dw, nsim_dev_trap_report_work); -schedule_delayed_work (&nsim_dev->trap_data->trap_report_dw, -msecs_to_jiffies (NSIM_TRAP_REPORT_INTERVAL_MS )); +queue_delayed_work (system_unbound_wq, + &nsim_dev->trap_data->trap_report_dw, +msecs_to_jiffies (NSIM_TRAP_REPORT_INTERVAL_MS ));return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 55/208 net: ethernet: aeroflex: fix potential memory leak in greth_start_xmit_gbit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Hai <[email protected]>
[ Upstream commit cf57b5d7a2aad456719152ecd12007fe031628a3 ]
The greth_start_xmit_gbit() returns NETDEV_TX_OK without freeing skb in case of skb->len being too long, add dev_kfree_skb() to fix it.
--- drivers/net/ethernet/aeroflex/greth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/aeroflex/greth.c +2 -1
@@ -484,7 +484,7 @@ greth_start_xmit_gbit(struct sk_buff *skb, struct net_device *dev)if (unlikely (skb->len >MAX_FRAME_SIZE )) { dev->stats.tx_errors++; - goto out; + goto len_error; }/* Save skb pointer. */
@@ -575,6 +575,7 @@ greth_start_xmit_gbit(struct sk_buff *skb, struct net_device *dev) map_error:if (net_ratelimit ())dev_warn (greth->dev,"Could not create TX DMA mapping\n" ); +len_error:dev_kfree_skb (skb); out:return err;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 56/208 net/smc: Fix searching in list of known pnetids in smc_pnet_add_pnetid
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 82ac39ebd6db0c9f7a97a934bda1e3e101a9d201 ]
pnetid of pi (not newly allocated pe) should be compared
--- net/smc/smc_pnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_pnet.c +1 -1
@@ -753,7 +753,7 @@ static int smc_pnet_add_pnetid(struct net *net, u8 *pnetid)write_lock (&sn->pnetids_ndev.lock);list_for_each_entry (pi, &sn->pnetids_ndev.list, list) { -if (smc_pnet_match (pnetid, pe->pnetid)) { +if (smc_pnet_match (pnetid, pi->pnetid)) {refcount_inc (&pi->refcnt);kfree (pe); goto unlock;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 57/208 net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Hai <[email protected]>
[ Upstream commit 99714e37e8333bbc22496fe80f241d5b35380e83 ]
The axienet_start_xmit() returns NETDEV_TX_OK without freeing skb in case of dma_map_single() fails, add dev_kfree_skb_any() to fix it.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -0
@@ -845,6 +845,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)if (net_ratelimit ())netdev_err (ndev,"TX DMA mapping error\n" ); ndev->stats.tx_dropped++; +dev_kfree_skb_any (skb);return NETDEV_TX_OK ; }desc_set_phys_addr (lp, phys, cur_p);
@@ -865,6 +866,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) ndev->stats.tx_dropped++;axienet_free_tx_chain (lp, orig_tail_ptr, ii +1 , true,NULL ,0 ); +dev_kfree_skb_any (skb);return NETDEV_TX_OK ; }desc_set_phys_addr (lp, phys, cur_p);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 58/208 bpf: Fix truncation bug in coerce_reg_to_size_sx()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dimitar Kanaliev <[email protected]>
[ Upstream commit ae67b9fb8c4e981e929a665dcaa070f4b05ebdb4 ]
coerce_reg_to_size_sx() updates the register state after a sign-extension operation. However, there's a bug in the assignment order of the unsigned min/max values, leading to incorrect truncation:
0: (85) call bpf_get_prandom_u32#7 ; R0_w=scalar() 1: (57) r0 &= 1 ; R0_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=1,var_off=(0x0; 0x1)) 2: (07) r0 += 254 ; R0_w=scalar(smin=umin=smin32=umin32=254,smax=umax=smax32=umax32=255,var_off=(0xfe; 0x1)) 3: (bf) r0 = (s8)r0 ; R0_w=scalar(smin=smin32=-2,smax=smax32=-1,umin=umin32=0xfffffffe,umax=0xffffffff,var_off=(0xfffffffffffffffe; 0x1))
In the current implementation, the unsigned 32-bit min/max values (u32_min_value and u32_max_value) are assigned directly from the 64-bit signed min/max values (s64_min and s64_max):
reg->umin_value = reg->u32_min_value = s64_min; reg->umax_value = reg->u32_max_value = s64_max;
Due to the chain assigmnent, this is equivalent to:
reg->u32_min_value = s64_min; // Unintended truncation reg->umin_value = reg->u32_min_value; reg->u32_max_value = s64_max; // Unintended truncation reg->umax_value = reg->u32_max_value;
--- kernel/bpf/verifier.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/bpf/verifier.c +4 -4
@@ -6143,10 +6143,10 @@ static void coerce_reg_to_size_sx(struct bpf_reg_state *reg, int size)/* both of s64_max/s64_min positive or negative */ if ((s64_max >=0 ) == (s64_min >=0 )) { - reg->smin_value = reg->s32_min_value = s64_min; - reg->smax_value = reg->s32_max_value = s64_max; - reg->umin_value = reg->u32_min_value = s64_min; - reg->umax_value = reg->u32_max_value = s64_max; + reg->s32_min_value = reg->smin_value = s64_min; + reg->s32_max_value = reg->smax_value = s64_max; + reg->u32_min_value = reg->umin_value = s64_min; + reg->u32_max_value = reg->umax_value = s64_max; reg->var_off =tnum_range (s64_min, s64_max);return ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 59/208 net: systemport: fix potential memory leak in bcm_sysport_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Hai <[email protected]>
[ Upstream commit c401ed1c709948e57945485088413e1bb5e94bd1 ]
The bcm_sysport_xmit() returns NETDEV_TX_OK without freeing skb in case of dma_map_single() fails, add dev_kfree_skb() to fix it.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bcmsysport.c +1 -0
@@ -1359,6 +1359,7 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,netif_err (priv, tx_err, dev,"DMA map failed at %p (len=%d)\n" , skb->data, skb_len); ret =NETDEV_TX_OK ; +dev_kfree_skb_any (skb); goto out; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 25/208 task_work: Add TWA_NMI_CURRENT as an additional notify mode.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 466e4d801cd438a1ab2c8a2cce1bef6b65c31bbb ]
Adding task_work from NMI context requires the following:
- The kasan_record_aux_stack() is not NMU safe and must be avoided.
- Using TWA_RESUME is NMI safe. If the NMI occurs while the CPU is in userland then it will continue in userland and not invoke the `work' callback.
Add TWA_NMI_CURRENT as an additional notify mode. In this mode skip kasan and use irq_work in hardirq-mode to for needed interrupt. Set TIF_NOTIFY_RESUME within the irq_work callback due to k[ac]san instrumentation in test_and_set_bit() which does not look NMI safe in case of a report.
Stable-dep-of: 73ab05aa46b0 ("sched/core: Disable page allocation in task_tick_mm_cid()")
--- include/linux/task_work.h | 1 + kernel/task_work.c | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-)
include/linux/task_work.h +1 -0
@@ -18,6 +18,7 @@ enum task_work_notify_mode {TWA_RESUME ,TWA_SIGNAL ,TWA_SIGNAL_NO_IPI , + TWA_NMI_CURRENT, };static inline bool task_work_pending (struct task_struct *task)
kernel/task_work.c +21 -3
@@ -1,10 +1,18 @@// SPDX-License-Identifier: GPL-2.0 +#include <linux/irq_work.h> #include <linux/spinlock.h> #include <linux/task_work.h> #include <linux/resume_user_mode.h> static struct callback_head work_exited;/* all we need is ->next == NULL */ +static void task_work_set_notify_irq (struct irq_work *entry) +{ +test_and_set_tsk_thread_flag (current,TIF_NOTIFY_RESUME ); +} +static DEFINE_PER_CPU(struct irq_work, irq_work_NMI_resume) = +IRQ_WORK_INIT_HARD (task_work_set_notify_irq); +/** * task_work_add - ask the @task to execute @work->func() * @task: the task which should run the callback
@@ -12,7 +20,7 @@ static struct callback_head work_exited; /* all we need is ->next == NULL */* @notify: how to notify the targeted task * * Queue @work for task_work_run() below and notify the @task if @notify -* is @TWA_RESUME, @TWA_SIGNAL, or @TWA_SIGNAL_NO_IPI. +* is @TWA_RESUME, @TWA_SIGNAL, @TWA_SIGNAL_NO_IPI or @TWA_NMI_CURRENT. * * @TWA_SIGNAL works like signals, in that the it will interrupt the targeted * task and run the task_work, regardless of whether the task is currently
@@ -24,6 +32,8 @@ static struct callback_head work_exited; /* all we need is ->next == NULL */* kernel anyway. * @TWA_RESUME work is run only when the task exits the kernel and returns to * user mode, or before entering guest mode. +* @TWA_NMI_CURRENT works like @TWA_RESUME, except it can only be used for the +* current @task and if the current context is NMI. * * Fails if the @task is exiting/exited and thus it can't process this @work. * Otherwise @work->func() will be called when the @task goes through one of
@@ -44,8 +54,13 @@ int task_work_add(struct task_struct *task, struct callback_head *work, {struct callback_head *head; -/* record the work call stack in order to print it in KASAN reports */ -kasan_record_aux_stack (work); +if (notify ==TWA_NMI_CURRENT ) { +if (WARN_ON_ONCE (task != current)) +return -EINVAL ; + }else { +/* record the work call stack in order to print it in KASAN reports */ +kasan_record_aux_stack (work); + } head =READ_ONCE (task->task_works); do {
@@ -66,6 +81,9 @@ int task_work_add(struct task_struct *task, struct callback_head *work,case TWA_SIGNAL_NO_IPI :__set_notify_signal (task);break ; +case TWA_NMI_CURRENT : +irq_work_queue (this_cpu_ptr (&irq_work_NMI_resume)); +break ;default :WARN_ON_ONCE (1 );break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 26/208 sched/core: Disable page allocation in task_tick_mm_cid()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit 73ab05aa46b02d96509cb029a8d04fca7bbde8c7 ]
With KASAN and PREEMPT_RT enabled, calling task_work_add() in task_tick_mm_cid() may cause the following splat.
[ 63.696416] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 [ 63.696416] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 610, name: modprobe [ 63.696416] preempt_count: 10001, expected: 0 [ 63.696416] RCU nest depth: 1, expected: 1
This problem is caused by the following call trace.
sched_tick() [ acquire rq->__lock ]
-> task_tick_mm_cid()
-> task_work_add()
-> __kasan_record_aux_stack()
-> kasan_save_stack()
-> stack_depot_save_flags()
-> alloc_pages_mpol_noprof()
-> __alloc_pages_noprof()
-> get_page_from_freelist()
-> rmqueue()
-> rmqueue_pcplist()
-> __rmqueue_pcplist()
-> rmqueue_bulk()
-> rt_spin_lock()The rq lock is a raw_spinlock_t. We can't sleep while holding it. IOW, we can't call alloc_pages() in stack_depot_save_flags().
The task_tick_mm_cid() function with its task_work_add() call was introduced by commit 223baf9d17f2 ("sched: Fix performance regression introduced by mm_cid") in v6.4 kernel.
Fortunately, there is a kasan_record_aux_stack_noalloc() variant that calls stack_depot_save_flags() while not allowing it to allocate new pages. To allow task_tick_mm_cid() to use task_work without page allocation, a new TWAF_NO_ALLOC flag is added to enable calling kasan_record_aux_stack_noalloc() instead of kasan_record_aux_stack() if set. The task_tick_mm_cid() function is modified to add this new flag.
The possible downside is the missing stack trace in a KASAN report due to new page allocation required when task_work_add_noallloc() is called which should be rare.
--- include/linux/task_work.h | 5 ++++- kernel/sched/core.c | 4 +++- kernel/task_work.c | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-)
include/linux/task_work.h +4 -1
@@ -14,11 +14,14 @@ init_task_work(struct callback_head *twork, task_work_func_t func) }enum task_work_notify_mode { -TWA_NONE , +TWA_NONE =0 ,TWA_RESUME ,TWA_SIGNAL ,TWA_SIGNAL_NO_IPI ,TWA_NMI_CURRENT , + +TWA_FLAGS =0xff00 , +TWAF_NO_ALLOC =0x0100 , };static inline bool task_work_pending (struct task_struct *task)
kernel/sched/core.c +3 -1
@@ -12050,7 +12050,9 @@ void task_tick_mm_cid(struct rq *rq, struct task_struct *curr)return ;if (time_before (now,READ_ONCE (curr->mm->mm_cid_next_scan)))return ; -task_work_add (curr, work,TWA_RESUME ); + +/* No page allocation under rq lock */ +task_work_add (curr, work,TWA_RESUME |TWAF_NO_ALLOC ); }void sched_mm_cid_exit_signals (struct task_struct *t)
kernel/task_work.c +13 -2
@@ -53,13 +53,24 @@ int task_work_add(struct task_struct *task, struct callback_head *work, enum task_work_notify_mode notify) {struct callback_head *head; +int flags = notify &TWA_FLAGS ; + notify &= ~TWA_FLAGS ;if (notify ==TWA_NMI_CURRENT ) {if (WARN_ON_ONCE (task != current))return -EINVAL ; }else { -/* record the work call stack in order to print it in KASAN reports */ -kasan_record_aux_stack (work); +/* +* Record the work call stack in order to print it in KASAN +* reports. +* +* Note that stack allocation can fail if TWAF_NO_ALLOC flag +* is set and new page is needed to expand the stack buffer. +*/ +if (flags &TWAF_NO_ALLOC ) +kasan_record_aux_stack_noalloc (work); +else +kasan_record_aux_stack (work); } head =READ_ONCE (task->task_works);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 27/208 ALSA: hda/cs8409: Fix possible NULL dereference
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
[ Upstream commit c9bd4a82b4ed32c6d1c90500a52063e6e341517f ]
If snd_hda_gen_add_kctl fails to allocate memory and returns NULL, then NULL pointer dereference will occur in the next line.
Since dolphin_fixups function is a hda_fixup function which is not supposed to return any errors, add simple check before dereference, ignore the fail.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- sound/pci/hda/patch_cs8409.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/pci/hda/patch_cs8409.c +3 -2
@@ -1411,8 +1411,9 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac kctrl =snd_hda_gen_add_kctl (&spec->gen,"Line Out Playback Volume" , &cs42l42_dac_volume_mixer);/* Update Line Out kcontrol template */ - kctrl->private_value =HDA_COMPOSE_AMP_VAL_OFS (DOLPHIN_HP_PIN_NID ,3 ,CS8409_CODEC1 , -HDA_OUTPUT ,CS42L42_VOL_DAC ) |HDA_AMP_VAL_MIN_MUTE ; +if (kctrl) + kctrl->private_value =HDA_COMPOSE_AMP_VAL_OFS (DOLPHIN_HP_PIN_NID ,3 ,CS8409_CODEC1 , +HDA_OUTPUT ,CS42L42_VOL_DAC ) |HDA_AMP_VAL_MIN_MUTE ;cs8409_enable_ur (codec,0 );snd_hda_codec_set_name (codec,"CS8409/CS42L42" );break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 28/208 firmware: arm_scmi: Fix the double free in scmi_debugfs_common_setup()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
[ Upstream commit 39b13dce1a91cdfc3bec9238f9e89094551bd428 ]
Clang static checker(scan-build) throws below warning:
| drivers/firmware/arm_scmi/driver.c:line 2915, column 2
| Attempt to free released memory.
When devm_add_action_or_reset() fails, scmi_debugfs_common_cleanup() will run twice which causes double free of 'dbg->name'.
Remove the redundant scmi_debugfs_common_cleanup() to fix this problem.
Message-Id: <[email protected]>
--- drivers/firmware/arm_scmi/driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/driver.c +1 -3
@@ -2603,10 +2603,8 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info) dbg->top_dentry = top_dentry;if (devm_add_action_or_reset (info->dev, - scmi_debugfs_common_cleanup, dbg)) { -scmi_debugfs_common_cleanup (dbg); + scmi_debugfs_common_cleanup, dbg))return NULL ; - }return dbg; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 29/208 RDMA/cxgb4: Fix RDMA_CM_EVENT_UNREACHABLE error for iWARP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anumula Murali Mohan Reddy <[email protected]>
[ Upstream commit c659b405b82ead335bee6eb33f9691bf718e21e8 ]
ip_dev_find() always returns real net_device address, whether traffic is running on a vlan or real device, if traffic is over vlan, filling endpoint struture with real ndev and an attempt to send a connect request will results in RDMA_CM_EVENT_UNREACHABLE error. This patch fixes the issue by using vlan_dev_real_dev().
--- drivers/infiniband/hw/cxgb4/cm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/infiniband/hw/cxgb4/cm.c +4 -5
@@ -2086,7 +2086,7 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, err = -ENOMEM ;if (n->dev->flags &IFF_LOOPBACK ) {if (iptype ==4 ) - pdev =ip_dev_find (&init_net, *(__be32 *)peer_ip); + pdev =__ip_dev_find (&init_net, *(__be32 *)peer_ip, false);else if (IS_ENABLED (CONFIG_IPV6 ))for_each_netdev (&init_net, pdev) { if (ipv6_chk_addr(&init_net,
@@ -2101,12 +2101,12 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, err = -ENODEV ; goto out; } +if (is_vlan_dev (pdev)) + pdev =vlan_dev_real_dev (pdev); ep->l2t =cxgb4_l2t_get (cdev->rdev.lldi.l2t, n, pdev,rt_tos2priority (tos)); -if (!ep->l2t) { -dev_put (pdev); +if (!ep->l2t) goto out; - } ep->mtu = pdev->mtu; ep->tx_chan =cxgb4_port_chan (pdev); ep->smac_idx = ((struct port_info *)netdev_priv (pdev))->smt_idx;
@@ -2119,7 +2119,6 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, ep->rss_qid = cdev->rdev.lldi.rxq_ids[cxgb4_port_idx (pdev) * step];set_tcp_window (ep, (struct port_info *)netdev_priv (pdev)); -dev_put (pdev); }else { pdev =get_real_dev (n->dev); ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 30/208 RDMA/irdma: Fix misspelling of "accept*"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Zubkov <[email protected]>
[ Upstream commit 8cddfa535c931b8d8110c73bfed7354a94cbf891 ]
There is "accept*" misspelled as "accpet*" in the comments. Fix the spelling.
--- drivers/infiniband/hw/irdma/cm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/cm.c +1 -1
@@ -3630,7 +3630,7 @@ void irdma_free_lsmm_rsrc(struct irdma_qp *iwqp)/** * irdma_accept - registered call for connection to be accepted * @cm_id: cm information for passive connection -* @conn_param: accpet parameters +* @conn_param: accept parameters */ int irdma_accept (struct iw_cm_id *cm_id,struct iw_cm_conn_param *conn_param) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 21/208 iio: frequency: {admv4420,adrf6780}: format Kconfig entries
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
[ Upstream commit 5c9644a683e1690387a476a4f5f6bd5cf9a1d695 ]
Format the entries of these drivers in the Kconfig, where spaces instead of tabs were used.
Stable-dep-of: 6b8e9dbfaed4 ("iio: frequency: admv4420: fix missing select REMAP_SPI in Kconfig")
--- drivers/iio/frequency/Kconfig | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/iio/frequency/Kconfig +16 -16
@@ -82,25 +82,25 @@ config ADMV1014 module will be called admv1014. config ADMV4420 - tristate "Analog Devices ADMV4420 K Band Downconverter" - depends on SPI - help - Say yes here to build support for Analog Devices K Band - Downconverter with integrated Fractional-N PLL and VCO. + tristate "Analog Devices ADMV4420 K Band Downconverter" + depends on SPI + help + Say yes here to build support for Analog Devices K Band + Downconverter with integrated Fractional-N PLL and VCO. - To compile this driver as a module, choose M here: the - module will be called admv4420. + To compile this driver as a module, choose M here: the + module will be called admv4420. config ADRF6780 - tristate "Analog Devices ADRF6780 Microwave Upconverter" - depends on SPI - depends on COMMON_CLK - help - Say yes here to build support for Analog Devices ADRF6780 - 5.9 GHz to 23.6 GHz, Wideband, Microwave Upconverter. - - To compile this driver as a module, choose M here: the - module will be called adrf6780. + tristate "Analog Devices ADRF6780 Microwave Upconverter" + depends on SPI + depends on COMMON_CLK + help + Say yes here to build support for Analog Devices ADRF6780 + 5.9 GHz to 23.6 GHz, Wideband, Microwave Upconverter. + + To compile this driver as a module, choose M here: the + module will be called adrf6780. endmenu endmenu
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 61/208 irqchip/renesas-rzg2l: Document structure members
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit b94f455372ad6e6b4da8e8ed9864d9c7daaf54b8 ]
Document structure members to follow the requirements specified in maintainer-tip, section 4.3.7. Struct declarations and initializers.
Stable-dep-of: d038109ac1c6 ("irqchip/renesas-rzg2l: Fix missing put_device")
--- drivers/irqchip/irq-renesas-rzg2l.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/irqchip/irq-renesas-rzg2l.c +6 -0
@@ -55,6 +55,12 @@#define TINT_EXTRACT_HWIRQ (x) FIELD_GET(GENMASK(15, 0), (x))#define TINT_EXTRACT_GPIOINT (x) FIELD_GET(GENMASK(31, 16), (x)) +/** +* struct rzg2l_irqc_priv - IRQ controller private data structure +* @base: Controller's base address +* @fwspec: IRQ firmware specific data +* @lock: Lock to serialize access to hardware registers +*/ struct rzg2l_irqc_priv {void __iomem *base;struct irq_fwspec fwspec[IRQC_NUM_IRQ ];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 70/208 net: ravb: Only advertise Rx/Tx timestamps if hardware supports it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Söderlund <[email protected]>
[ Upstream commit 126e799602f45e9ce1ded03ee9eadda68bf470e0 ]
Recent work moving the reporting of Rx software timestamps to the core
[1] highlighted an issue where hardware time stamping was advertised for the platforms where it is not supported.
Fix this by covering advertising support for hardware timestamps only if the hardware supports it. Due to the Tx implementation in RAVB software Tx timestamping is also only considered if the hardware supports hardware timestamps. This should be addressed in future, but this fix only reflects what the driver currently implements.
1. Commit 277901ee3a26 ("ravb: Remove setting of RX software timestamp")
--- drivers/net/ethernet/renesas/ravb_main.c | 25 ++++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +12 -13
@@ -1673,20 +1673,19 @@ static int ravb_get_ts_info(struct net_device *ndev,struct ravb_private *priv =netdev_priv (ndev);const struct ravb_hw_info *hw_info = priv->info; - info->so_timestamping = -SOF_TIMESTAMPING_TX_SOFTWARE | -SOF_TIMESTAMPING_TX_HARDWARE | -SOF_TIMESTAMPING_RX_HARDWARE | -SOF_TIMESTAMPING_RAW_HARDWARE ; - info->tx_types = (1 <<HWTSTAMP_TX_OFF ) | (1 <<HWTSTAMP_TX_ON ); - info->rx_filters = - (1 <<HWTSTAMP_FILTER_NONE ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_L2_EVENT ) | - (1 <<HWTSTAMP_FILTER_ALL ); -if (hw_info->gptp || hw_info->ccc_gac) +if (hw_info->gptp || hw_info->ccc_gac) { + info->so_timestamping = +SOF_TIMESTAMPING_TX_SOFTWARE | +SOF_TIMESTAMPING_TX_HARDWARE | +SOF_TIMESTAMPING_RX_HARDWARE | +SOF_TIMESTAMPING_RAW_HARDWARE ; + info->tx_types = (1 <<HWTSTAMP_TX_OFF ) | (1 <<HWTSTAMP_TX_ON ); + info->rx_filters = + (1 <<HWTSTAMP_FILTER_NONE ) | + (1 <<HWTSTAMP_FILTER_PTP_V2_L2_EVENT ) | + (1 <<HWTSTAMP_FILTER_ALL ); info->phc_index =ptp_clock_index (priv->ptp.clock); -else - info->phc_index =0 ; + }return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 71/208 scsi: target: core: Fix null-ptr-deref in target_alloc_device()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Hai <[email protected]>
[ Upstream commit fca6caeb4a61d240f031914413fcc69534f6dc03 ]
There is a null-ptr-deref issue reported by KASAN:
BUG: KASAN: null-ptr-deref in target_alloc_device+0xbc4/0xbe0 [target_core_mod] ... kasan_report+0xb9/0xf0 target_alloc_device+0xbc4/0xbe0 [target_core_mod] core_dev_setup_virtual_lun0+0xef/0x1f0 [target_core_mod] target_core_init_configfs+0x205/0x420 [target_core_mod] do_one_initcall+0xdd/0x4e0
...
entry_SYSCALL_64_after_hwframe+0x76/0x7e
In target_alloc_device(), if allocing memory for dev queues fails, then dev will be freed by dev->transport->free_device(), but dev->transport is not initialized at that time, which will lead to a null pointer reference problem.
Fixing this bug by freeing dev with hba->backend->ops->free_device().
--- drivers/target/target_core_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_device.c +1 -1
@@ -692,7 +692,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) dev->queues =kcalloc (nr_cpu_ids,sizeof (*dev->queues),GFP_KERNEL );if (!dev->queues) { - dev->transport->free_device (dev); + hba->backend->ops->free_device (dev);return NULL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 72/208 smb: client: fix possible double free in smb2_set_ea()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
[ Upstream commit 19ebc1e6cab334a8193398d4152deb76019b5d34 ]
Clang static checker(scan-build) warning: fs/smb/client/smb2ops.c:1304:2: Attempt to free released memory.
1304 | kfree(ea);
| ^~~~~~~~~There is a double free in such case:
'ea is initialized to NULL' -> 'first successful memory allocation for ea' -> 'something failed, goto sea_exit' -> 'first memory release for ea' -> 'goto replay_again' -> 'second goto sea_exit before allocate memory for ea' -> 'second memory release for ea resulted in double free'.
Re-initialie 'ea' to NULL near to the replay_again label, it can fix this double free problem.
--- fs/smb/client/smb2ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/client/smb2ops.c +2 -1
@@ -1122,7 +1122,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,struct cifs_fid fid;unsigned int size[1 ];void *data[1 ]; -struct smb2_file_full_ea_info *ea =NULL ; +struct smb2_file_full_ea_info *ea;struct smb2_query_info_rsp *rsp;int rc, used_len =0 ;int retries =0 , cur_sleep =1 ;
@@ -1143,6 +1143,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,if (!utf16_path)return -ENOMEM ; + ea =NULL ; resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ; vars =kzalloc (sizeof (*vars),GFP_KERNEL );if (!vars) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 73/208 smb: client: fix OOBs when building SMB2_IOCTL request
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
[ Upstream commit 1ab60323c5201bef25f2a3dc0ccc404d9aca77f1 ]
When using encryption, either enforced by the server or when using 'seal' mount option, the client will squash all compound request buffers down for encryption into a single iov in smb2_set_next_command().
SMB2_ioctl_init() allocates a small buffer (448 bytes) to hold the SMB2_IOCTL request in the first iov, and if the user passes an input buffer that is greater than 328 bytes, smb2_set_next_command() will end up writing off the end of @rqst->iov[0].iov_base as shown below:
mount.cifs //srv/share /mnt -o ...,seal
ln -s $(perl -e "print('a')for 1..1024") /mnt/linkBUG: KASAN: slab-out-of-bounds in smb2_set_next_command.cold+0x1d6/0x24c [cifs] Write of size 4116 at addr ffff8881148fcab8 by task ln/859 CPU: 1 UID: 0 PID: 859 Comm: ln Not tainted 6.12.0-rc3 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-2.fc40 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 ? smb2_set_next_command.cold+0x1d6/0x24c [cifs] print_report+0x156/0x4d9 ? smb2_set_next_command.cold+0x1d6/0x24c [cifs] ? __virt_addr_valid+0x145/0x310 ? __phys_addr+0x46/0x90 ? smb2_set_next_command.cold+0x1d6/0x24c [cifs] kasan_report+0xda/0x110 ? smb2_set_next_command.cold+0x1d6/0x24c [cifs] kasan_check_range+0x10f/0x1f0 __asan_memcpy+0x3c/0x60 smb2_set_next_command.cold+0x1d6/0x24c [cifs] smb2_compound_op+0x238c/0x3840 [cifs] ? kasan_save_track+0x14/0x30 ? kasan_save_free_info+0x3b/0x70 ? vfs_symlink+0x1a1/0x2c0 ? do_symlinkat+0x108/0x1c0 ? __pfx_smb2_compound_op+0x10/0x10 [cifs] ? kmem_cache_free+0x118/0x3e0 ? cifs_get_writable_path+0xeb/0x1a0 [cifs] smb2_get_reparse_inode+0x423/0x540 [cifs] ? __pfx_smb2_get_reparse_inode+0x10/0x10 [cifs] ? rcu_is_watching+0x20/0x50 ? __kmalloc_noprof+0x37c/0x480 ? smb2_create_reparse_symlink+0x257/0x490 [cifs] ? smb2_create_reparse_symlink+0x38f/0x490 [cifs] smb2_create_reparse_symlink+0x38f/0x490 [cifs] ? __pfx_smb2_create_reparse_symlink+0x10/0x10 [cifs] ? find_held_lock+0x8a/0xa0 ? hlock_class+0x32/0xb0 ? __build_path_from_dentry_optional_prefix+0x19d/0x2e0 [cifs] cifs_symlink+0x24f/0x960 [cifs] ? __pfx_make_vfsuid+0x10/0x10 ? __pfx_cifs_symlink+0x10/0x10 [cifs] ? make_vfsgid+0x6b/0xc0 ? generic_permission+0x96/0x2d0 vfs_symlink+0x1a1/0x2c0 do_symlinkat+0x108/0x1c0 ? __pfx_do_symlinkat+0x10/0x10 ? strncpy_from_user+0xaa/0x160 __x64_sys_symlinkat+0xb9/0xf0 do_syscall_64+0xbb/0x1d0 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f08d75c13bb
--- fs/smb/client/smb2pdu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/smb/client/smb2pdu.c +9 -0
@@ -3300,6 +3300,15 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,return rc;if (indatalen) { +unsigned int len; + +if (WARN_ON_ONCE (smb3_encryption_required (tcon) && + (check_add_overflow (total_len -1 , +ALIGN (indatalen,8 ), &len) || + len >MAX_CIFS_SMALL_BUFFER_SIZE ))) { +cifs_small_buf_release (req); +return -EIO ; + }/* * indatalen is usually small at a couple of bytes max, so * just allocate through generic pool
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 74/208 usb: typec: altmode should keep reference to parent
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit befab3a278c59db0cc88c8799638064f6d3fd6f8 ]
The altmode device release refers to its parent device, but without keeping a reference to it.
When registering the altmode, get a reference to the parent and put it in the release function.
Before this fix, when using CONFIG_DEBUG_KOBJECT_RELEASE, we see issues like this:
[ 43.572860] kobject: 'port0.0' (ffff8880057ba008): kobject_release, parent 0000000000000000 (delayed 3000) [ 43.573532] kobject: 'port0.1' (ffff8880057bd008): kobject_release, parent 0000000000000000 (delayed 1000) [ 43.574407] kobject: 'port0' (ffff8880057b9008): kobject_release, parent 0000000000000000 (delayed 3000) [ 43.575059] kobject: 'port1.0' (ffff8880057ca008): kobject_release, parent 0000000000000000 (delayed 4000) [ 43.575908] kobject: 'port1.1' (ffff8880057c9008): kobject_release, parent 0000000000000000 (delayed 4000) [ 43.576908] kobject: 'typec' (ffff8880062dbc00): kobject_release, parent 0000000000000000 (delayed 4000) [ 43.577769] kobject: 'port1' (ffff8880057bf008): kobject_release, parent 0000000000000000 (delayed 3000) [ 46.612867] ================================================================== [ 46.613402] BUG: KASAN: slab-use-after-free in typec_altmode_release+0x38/0x129 [ 46.614003] Read of size 8 at addr ffff8880057b9118 by task kworker/2:1/48 [ 46.614538] [ 46.614668] CPU: 2 UID: 0 PID: 48 Comm: kworker/2:1 Not tainted 6.12.0-rc1-00138-gedbae730ad31 #535 [ 46.615391] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 [ 46.616042] Workqueue: events kobject_delayed_cleanup [ 46.616446] Call Trace: [ 46.616648] <TASK> [ 46.616820] dump_stack_lvl+0x5b/0x7c [ 46.617112] ? typec_altmode_release+0x38/0x129 [ 46.617470] print_report+0x14c/0x49e [ 46.617769] ? rcu_read_unlock_sched+0x56/0x69 [ 46.618117] ? __virt_addr_valid+0x19a/0x1ab [ 46.618456] ? kmem_cache_debug_flags+0xc/0x1d [ 46.618807] ? typec_altmode_release+0x38/0x129 [ 46.619161] kasan_report+0x8d/0xb4 [ 46.619447] ? typec_altmode_release+0x38/0x129 [ 46.619809] ? process_scheduled_works+0x3cb/0x85f [ 46.620185] typec_altmode_release+0x38/0x129 [ 46.620537] ? process_scheduled_works+0x3cb/0x85f [ 46.620907] device_release+0xaf/0xf2 [ 46.621206] kobject_delayed_cleanup+0x13b/0x17a [ 46.621584] process_scheduled_works+0x4f6/0x85f [ 46.621955] ? __pfx_process_scheduled_works+0x10/0x10 [ 46.622353] ? hlock_class+0x31/0x9a [ 46.622647] ? lock_acquired+0x361/0x3c3 [ 46.622956] ? move_linked_works+0x46/0x7d [ 46.623277] worker_thread+0x1ce/0x291 [ 46.623582] ? __kthread_parkme+0xc8/0xdf [ 46.623900] ? __pfx_worker_thread+0x10/0x10 [ 46.624236] kthread+0x17e/0x190 [ 46.624501] ? kthread+0xfb/0x190 [ 46.624756] ? __pfx_kthread+0x10/0x10 [ 46.625015] ret_from_fork+0x20/0x40 [ 46.625268] ? __pfx_kthread+0x10/0x10 [ 46.625532] ret_from_fork_asm+0x1a/0x30 [ 46.625805] </TASK> [ 46.625953] [ 46.626056] Allocated by task 678: [ 46.626287] kasan_save_stack+0x24/0x44 [ 46.626555] kasan_save_track+0x14/0x2d [ 46.626811] __kasan_kmalloc+0x3f/0x4d [ 46.627049] __kmalloc_noprof+0x1bf/0x1f0 [ 46.627362] typec_register_port+0x23/0x491 [ 46.627698] cros_typec_probe+0x634/0xbb6 [ 46.628026] platform_probe+0x47/0x8c [ 46.628311] really_probe+0x20a/0x47d [ 46.628605] device_driver_attach+0x39/0x72 [ 46.628940] bind_store+0x87/0xd7 [ 46.629213] kernfs_fop_write_iter+0x1aa/0x218 [ 46.629574] vfs_write+0x1d6/0x29b [ 46.629856] ksys_write+0xcd/0x13b [ 46.630128] do_syscall_64+0xd4/0x139 [ 46.630420] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 46.630820] [ 46.630946] Freed by task 48: [ 46.631182] kasan_save_stack+0x24/0x44 [ 46.631493] kasan_save_track+0x14/0x2d [ 46.631799] kasan_save_free_info+0x3f/0x4d [ 46.632144] __kasan_slab_free+0x37/0x45 [ 46.632474] kfree+0x1d4/0x252 [ 46.632725] device_release+0xaf/0xf2 [ 46.633017] kobject_delayed_cleanup+0x13b/0x17a [ 46.633388] process_scheduled_works+0x4f6/0x85f [ 46.633764] worker_thread+0x1ce/0x291 [ 46.634065] kthread+0x17e/0x190 [ 46.634324] ret_from_fork+0x20/0x40 [ 46.634621] ret_from_fork_asm+0x1a/0x30
--- drivers/usb/typec/class.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/typec/class.c +3 -0
@@ -502,6 +502,7 @@ static void typec_altmode_release(struct device *dev)typec_altmode_put_partner (alt);altmode_id_remove (alt->adev.dev.parent, alt->id); +put_device (alt->adev.dev.parent);kfree (alt); }
@@ -551,6 +552,8 @@ typec_register_altmode(struct device *parent, alt->adev.dev.type = &typec_altmode_dev_type;dev_set_name (&alt->adev.dev,"%s.%u" ,dev_name (parent), id); +get_device (alt->adev.dev.parent); +/* Link partners and plugs with the ports */ if (!is_port)typec_altmode_set_partner (alt);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 75/208 s390: Initialize psw mask in perf_arch_fetch_caller_regs()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 223e7fb979fa06934f1595b6ad0ae1d4ead1147f ]
Also initialize regs->psw.mask in perf_arch_fetch_caller_regs(). This way user_mode(regs) will return false, like it should.
It looks like all current users initialize regs to zero, so that this doesn't fix a bug currently. However it is better to not rely on callers to do this.
--- arch/s390/include/asm/perf_event.h | 1 + 1 file changed, 1 insertion(+)
arch/s390/include/asm/perf_event.h +1 -0
@@ -73,6 +73,7 @@ struct perf_sf_sde_regs {#define SAMPLE_FREQ_MODE (hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FREQ_MODE)#define perf_arch_fetch_caller_regs (regs, __ip) do { \ + (regs)->psw.mask = 0; \ (regs)->psw.addr = (__ip); \ (regs)->gprs[15] = (unsigned long)__builtin_frame_address(0) - \ offsetof(struct stack_frame, back_chain); \
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 76/208 bpf: Fix link info netfilter flags to populate defrag flag
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyrone Wu <[email protected]>
[ Upstream commit 92f3715e1eba1d41e55be06159dc3d856b18326d ]
This fix correctly populates the bpf_link_info.netfilter.flags field when user passes the BPF_F_NETFILTER_IP_DEFRAG flag.
--- net/netfilter/nf_bpf_link.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_bpf_link.c +2 -1
@@ -150,11 +150,12 @@ static int bpf_nf_link_fill_link_info(const struct bpf_link *link, struct bpf_link_info *info) { struct bpf_nf_link *nf_link = container_of(link, struct bpf_nf_link, link); +const struct nf_defrag_hook *hook = nf_link->defrag_hook; info->netfilter.pf = nf_link->hook_ops.pf; info->netfilter.hooknum = nf_link->hook_ops.hooknum; info->netfilter.priority = nf_link->hook_ops.priority; - info->netfilter.flags =0 ; + info->netfilter.flags = hook ?BPF_F_NETFILTER_IP_DEFRAG :0 ;return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 77/208 Bluetooth: bnep: fix wild-memory-access in proto_unregister
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit 64a90991ba8d4e32e3173ddd83d0b24167a5668c ]
There's issue as follows:
KASAN: maybe wild-memory-access in range [0xdead...108-0xdead...10f] CPU: 3 UID: 0 PID: 2805 Comm: rmmod Tainted: G W RIP: 0010:proto_unregister+0xee/0x400 Call Trace: <TASK> __do_sys_delete_module+0x318/0x580 do_syscall_64+0xc1/0x1d0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
As bnep_init() ignore bnep_sock_init()'s return value, and bnep_sock_init() will cleanup all resource. Then when remove bnep module will call bnep_sock_cleanup() to cleanup sock's resource.
To solve above issue just return bnep_sock_init()'s return value in bnep_exit().
--- net/bluetooth/bnep/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/bluetooth/bnep/core.c +1 -2
@@ -745,8 +745,7 @@ static int __init bnep_init(void)if (flt[0 ])BT_INFO ("BNEP filters: %s" , flt); -bnep_sock_init (); -return 0 ; +return bnep_sock_init (); } static void __exit bnep_exit(void)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 78/208 vmxnet3: Fix packet corruption in vmxnet3_xdp_xmit_frame
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 4678adf94da4a9e9683817b246b58ce15fb81782 ]
Andrew and Nikolay reported connectivity issues with Cilium's service load-balancing in case of vmxnet3.
If a BPF program for native XDP adds an encapsulation header such as IPIP and transmits the packet out the same interface, then in case of vmxnet3 a corrupted packet is being sent and subsequently dropped on the path.
vmxnet3_xdp_xmit_frame() which is called e.g. via vmxnet3_run_xdp() through vmxnet3_xdp_xmit_back() calculates an incorrect DMA address:
page = virt_to_page(xdpf->data);
tbi->dma_addr = page_pool_get_dma_addr(page) +
VMXNET3_XDP_HEADROOM;
dma_sync_single_for_device(&adapter->pdev->dev,
tbi->dma_addr, buf_size,
DMA_TO_DEVICE);The above assumes a fixed offset (VMXNET3_XDP_HEADROOM), but the XDP BPF program could have moved xdp->data. While the passed buf_size is correct (xdpf->len), the dma_addr needs to have a dynamic offset which can be calculated as xdpf->data - (void *)xdpf, that is, xdp->data - xdp->data_hard_start.
--- drivers/net/vmxnet3/vmxnet3_xdp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vmxnet3/vmxnet3_xdp.c +1 -1
@@ -148,7 +148,7 @@ vmxnet3_xdp_xmit_frame(struct vmxnet3_adapter *adapter, }else {/* XDP buffer from page pool */ page =virt_to_page (xdpf->data); tbi->dma_addr =page_pool_get_dma_addr (page) + -VMXNET3_XDP_HEADROOM ; + (xdpf->data - (void *)xdpf);dma_sync_single_for_device (&adapter->pdev->dev, tbi->dma_addr, buf_size,DMA_TO_DEVICE );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 79/208 net/mlx5: Check for invalid vector index on EQ creation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Sanalla <[email protected]>
[ Upstream commit d4f25be27e3ef7e23998fbd3dd4bff0602de7ae5 ]
Currently, mlx5 driver does not enforce vector index to be lower than the maximum number of supported completion vectors when requesting a new completion EQ. Thus, mlx5_comp_eqn_get() fails when trying to acquire an IRQ with an improper vector index.
To prevent the case above, enforce that vector index value is valid and lower than maximum in mlx5_comp_eqn_get() before handling the request.
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +6 -0
@@ -1073,6 +1073,12 @@ int mlx5_comp_eqn_get(struct mlx5_core_dev *dev, u16 vecidx, int *eqn)struct mlx5_eq_comp *eq;int ret =0 ; +if (vecidx >= table->max_comp_eqs) { +mlx5_core_dbg (dev,"Requested vector index %u should be less than %u" , + vecidx, table->max_comp_eqs); +return -EINVAL ; + } +mutex_lock (&table->comp_lock); eq =xa_load (&table->comp_eqs, vecidx);if (eq) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 62/208 irqchip/renesas-rzg2l: Add support for suspend to RAM
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 74d2ef5f6f4b2437e6292ab2502400e8048db4aa ]
The irqchip-renesas-rzg2l driver is used on RZ/G3S SoC. RZ/G3S can go into deep sleep states where power to different SoC's parts is cut off and RAM is switched to self-refresh. The resume from these states is done with the help of the bootloader.
The IA55 IRQ controller needs to be reconfigured when resuming from deep sleep state. For this the IA55 registers are cached in suspend and restored in resume.
The IA55 IRQ controller is connected to GPIO controller and GIC as follows:
┌──────────┐ ┌──────────┐
│ │ SPIX │ │
│ ├─────────►│ │
│ │ │ │
│ │ │ │
┌────────┐IRQ0-7 │ IA55 │ │ GIC │
Pin0 ───────►│ ├─────────────►│ │ │ │
│ │ │ │ PPIY │ │
... │ GPIO │ │ ├─────────►│ │
│ │GPIOINT0-127 │ │ │ │
PinN ───────►│ ├─────────────►│ │ │ │
└────────┘ └──────────┘ └──────────┘where:
- Pin0 is the first GPIO controller pin
- PinN is the last GPIO controller pin
- SPIX is the SPI interrupt with identifier X
- PPIY is the PPI interrupt with identifier Y
Implement suspend/resume functionality with syscore_ops to be able to cache/restore the registers after/before the GPIO controller suspend/resume functions are invoked.
As the syscore_ops suspend/resume functions do not take any argument make the driver private data static so it can be accessed from the suspend/resume functions.
The IA55 interrupt controller is resumed before the GPIO controller. As GPIO pins could be in an a state which causes spurious interrupts, the reconfiguration of the interrupt controller is restricted to restore the interrupt type and leave them disabled.
An eventually required interrupt enable operation will be done as part of the GPIO controller resume function after restoring the GPIO state.
[ tglx: Massaged changelog ]
Stable-dep-of: d038109ac1c6 ("irqchip/renesas-rzg2l: Fix missing put_device")
--- drivers/irqchip/irq-renesas-rzg2l.c | 68 ++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 11 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +57 -11
@@ -18,6 +18,7 @@#include <linux/pm_runtime.h> #include <linux/reset.h> #include <linux/spinlock.h> +#include <linux/syscore_ops.h> #define IRQC_IRQ_START 1#define IRQC_IRQ_COUNT 8
@@ -55,17 +56,29 @@#define TINT_EXTRACT_HWIRQ (x) FIELD_GET(GENMASK(15, 0), (x))#define TINT_EXTRACT_GPIOINT (x) FIELD_GET(GENMASK(31, 16), (x)) +/** +* struct rzg2l_irqc_reg_cache - registers cache (necessary for suspend/resume) +* @iitsr: IITSR register +* @titsr: TITSR registers +*/ +struct rzg2l_irqc_reg_cache { +u32 iitsr; +u32 titsr[2 ]; +}; +/** * struct rzg2l_irqc_priv - IRQ controller private data structure * @base: Controller's base address * @fwspec: IRQ firmware specific data * @lock: Lock to serialize access to hardware registers +* @cache: Registers cache for suspend/resume */ -struct rzg2l_irqc_priv { +static struct rzg2l_irqc_priv {void __iomem *base;struct irq_fwspec fwspec[IRQC_NUM_IRQ ];raw_spinlock_t lock; -}; +struct rzg2l_irqc_reg_cache cache; +} *rzg2l_irqc_data;static struct rzg2l_irqc_priv *irq_data_to_priv (struct irq_data *data) {
@@ -282,6 +295,38 @@ static int rzg2l_irqc_set_type(struct irq_data *d, unsigned int type)return irq_chip_set_type_parent (d,IRQ_TYPE_LEVEL_HIGH ); } +static int rzg2l_irqc_irq_suspend (void ) +{ +struct rzg2l_irqc_reg_cache *cache = &rzg2l_irqc_data->cache; +void __iomem *base = rzg2l_irqc_data->base; + + cache->iitsr =readl_relaxed (base +IITSR ); +for (u8 i =0 ; i <2 ; i++) + cache->titsr[i] =readl_relaxed (base +TITSR (i)); + +return 0 ; +} + +static void rzg2l_irqc_irq_resume (void ) +{ +struct rzg2l_irqc_reg_cache *cache = &rzg2l_irqc_data->cache; +void __iomem *base = rzg2l_irqc_data->base; + +/* +* Restore only interrupt type. TSSRx will be restored at the +* request of pin controller to avoid spurious interrupts due +* to invalid PIN states. +*/ +for (u8 i =0 ; i <2 ; i++) +writel_relaxed (cache->titsr[i], base +TITSR (i)); +writel_relaxed (cache->iitsr, base +IITSR ); +} + +static struct syscore_ops rzg2l_irqc_syscore_ops = { + .suspend = rzg2l_irqc_irq_suspend, + .resume = rzg2l_irqc_irq_resume, +}; +static const struct irq_chip irqc_chip = { .name ="rzg2l-irqc" , .irq_eoi = rzg2l_irqc_eoi,
@@ -366,7 +411,6 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent)struct irq_domain *irq_domain, *parent_domain;struct platform_device *pdev;struct reset_control *resetn; -struct rzg2l_irqc_priv *priv;int ret; pdev =of_find_device_by_node (node);
@@ -379,15 +423,15 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent)return -ENODEV ; } - priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); -if (!priv) + rzg2l_irqc_data =devm_kzalloc (&pdev->dev,sizeof (*rzg2l_irqc_data),GFP_KERNEL ); +if (!rzg2l_irqc_data)return -ENOMEM ; - priv->base =devm_of_iomap (&pdev->dev, pdev->dev.of_node,0 ,NULL ); -if (IS_ERR (priv->base)) -return PTR_ERR (priv->base); + rzg2l_irqc_data->base =devm_of_iomap (&pdev->dev, pdev->dev.of_node,0 ,NULL ); +if (IS_ERR (rzg2l_irqc_data->base)) +return PTR_ERR (rzg2l_irqc_data->base); - ret =rzg2l_irqc_parse_interrupts (priv, node); + ret =rzg2l_irqc_parse_interrupts (rzg2l_irqc_data, node);if (ret) {dev_err (&pdev->dev,"cannot parse interrupts: %d\n" , ret);return ret;
@@ -410,17 +454,19 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) goto pm_disable; } -raw_spin_lock_init (&priv->lock); +raw_spin_lock_init (&rzg2l_irqc_data->lock); irq_domain =irq_domain_add_hierarchy (parent_domain,0 ,IRQC_NUM_IRQ , node, &rzg2l_irqc_domain_ops, - priv); + rzg2l_irqc_data);if (!irq_domain) {dev_err (&pdev->dev,"failed to add irq domain\n" ); ret = -ENOMEM ; goto pm_put; } +register_syscore_ops (&rzg2l_irqc_syscore_ops); +return 0 ; pm_put:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 80/208 net/mlx5: Fix command bitmask initialization
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shay Drory <[email protected]>
[ Upstream commit d62b14045c6511a7b2d4948d1a83a4e592deeb05 ]
Command bitmask have a dedicated bit for MANAGE_PAGES command, this bit isn't Initialize during command bitmask Initialization, only during MANAGE_PAGES.
In addition, mlx5_cmd_trigger_completions() is trying to trigger completion for MANAGE_PAGES command as well.
Hence, in case health error occurred before any MANAGE_PAGES command have been invoke (for example, during mlx5_enable_hca()), mlx5_cmd_trigger_completions() will try to trigger completion for MANAGE_PAGES command, which will result in null-ptr-deref error.[1]
Fix it by Initialize command bitmask correctly.
While at it, re-write the code for better understanding.
[1]
BUG: KASAN: null-ptr-deref in mlx5_cmd_trigger_completions+0x1db/0x600 [mlx5_core] Write of size 4 at addr 0000000000000214 by task kworker/u96:2/12078 CPU: 10 PID: 12078 Comm: kworker/u96:2 Not tainted 6.9.0-rc2_for_upstream_debug_2024_04_07_19_01 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Workqueue: mlx5_health0000:08:00.0 mlx5_fw_fatal_reporter_err_work [mlx5_core] Call Trace: <TASK> dump_stack_lvl+0x7e/0xc0 kasan_report+0xb9/0xf0 kasan_check_range+0xec/0x190 mlx5_cmd_trigger_completions+0x1db/0x600 [mlx5_core] mlx5_cmd_flush+0x94/0x240 [mlx5_core] enter_error_state+0x6c/0xd0 [mlx5_core] mlx5_fw_fatal_reporter_err_work+0xf3/0x480 [mlx5_core] process_one_work+0x787/0x1490 ? lockdep_hardirqs_on_prepare+0x400/0x400 ? pwq_dec_nr_in_flight+0xda0/0xda0 ? assign_work+0x168/0x240 worker_thread+0x586/0xd30 ? rescuer_thread+0xae0/0xae0 kthread+0x2df/0x3b0 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x2d/0x70 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork_asm+0x11/0x20 </TASK>
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +6 -2
@@ -1758,6 +1758,10 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force } } +#define MLX5_MAX_MANAGE_PAGES_CMD_ENT 1 +#define MLX5_CMD_MASK ((1UL << (cmd->vars.max_reg_cmds + \ + MLX5_MAX_MANAGE_PAGES_CMD_ENT)) - 1) +static void mlx5_cmd_trigger_completions (struct mlx5_core_dev *dev) {struct mlx5_cmd *cmd = &dev->cmd;
@@ -1769,7 +1773,7 @@ static void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev)/* wait for pending handlers to complete */ mlx5_eq_synchronize_cmd_irq (dev);spin_lock_irqsave (&dev->cmd.alloc_lock, flags); - vector = ~dev->cmd.vars.bitmask & ((1ul << (1 << dev->cmd.vars.log_sz)) -1 ); + vector = ~dev->cmd.vars.bitmask &MLX5_CMD_MASK ;if (!vector) goto no_trig;
@@ -2275,7 +2279,7 @@ int mlx5_cmd_enable(struct mlx5_core_dev *dev) cmd->state =MLX5_CMDIF_STATE_DOWN ; cmd->vars.max_reg_cmds = (1 << cmd->vars.log_sz) -1 ; - cmd->vars.bitmask = (1UL << cmd->vars.max_reg_cmds) -1 ; + cmd->vars.bitmask =MLX5_CMD_MASK ;sema_init (&cmd->vars.sem, cmd->vars.max_reg_cmds);sema_init (&cmd->vars.pages_sem,1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 81/208 net/mlx5: Unregister notifier on eswitch init failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Ratiu <[email protected]>
[ Upstream commit 1da9cfd6c41c2e6bbe624d0568644e1521c33e12 ]
It otherwise remains registered and a subsequent attempt at eswitch enabling might trigger warnings of the sort:
[ 682.589148] ------------[ cut here ]------------ [ 682.590204] notifier callback eswitch_vport_event [mlx5_core] already registered [ 682.590256] WARNING: CPU: 13 PID: 2660 at kernel/notifier.c:31 notifier_chain_register+0x3e/0x90 [...snipped] [ 682.610052] Call Trace: [ 682.610369] <TASK> [ 682.610663] ? __warn+0x7c/0x110 [ 682.611050] ? notifier_chain_register+0x3e/0x90 [ 682.611556] ? report_bug+0x148/0x170 [ 682.611977] ? handle_bug+0x36/0x70 [ 682.612384] ? exc_invalid_op+0x13/0x60 [ 682.612817] ? asm_exc_invalid_op+0x16/0x20 [ 682.613284] ? notifier_chain_register+0x3e/0x90 [ 682.613789] atomic_notifier_chain_register+0x25/0x40 [ 682.614322] mlx5_eswitch_enable_locked+0x1d4/0x3b0 [mlx5_core] [ 682.614965] mlx5_eswitch_enable+0xc9/0x100 [mlx5_core] [ 682.615551] mlx5_device_enable_sriov+0x25/0x340 [mlx5_core] [ 682.616170] mlx5_core_sriov_configure+0x50/0x170 [mlx5_core] [ 682.616789] sriov_numvfs_store+0xb0/0x1b0 [ 682.617248] kernfs_fop_write_iter+0x117/0x1a0 [ 682.617734] vfs_write+0x231/0x3f0 [ 682.618138] ksys_write+0x63/0xe0 [ 682.618536] do_syscall_64+0x4c/0x100 [ 682.618958] entry_SYSCALL_64_after_hwframe+0x4b/0x53
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +3 -2
@@ -1489,7 +1489,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs) }if (err) - goto abort; + goto err_esw_enable; esw->fdb_table.flags |=MLX5_ESW_FDB_CREATED ;
@@ -1503,7 +1503,8 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs)return 0 ; -abort: +err_esw_enable: +mlx5_eq_notifier_unregister (esw->dev, &esw->nb);mlx5_esw_acls_ns_cleanup (esw);return err; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 82/208 bpf, sockmap: SK_DROP on attempted redirects of unsupported af_vsock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 9c5bd93edf7b8834aecaa7c340b852d5990d7c78 ]
Don't mislead the callers of bpf_{sk,msg}_redirect_{map,hash}(): make sure to immediately and visibly fail the forwarding of unsupported af_vsock packets.
--- include/net/sock.h | 5 +++++ net/core/sock_map.c | 8 ++++++++ 2 files changed, 13 insertions(+)
include/net/sock.h +5 -0
@@ -2826,6 +2826,11 @@ static inline bool sk_is_stream_unix(const struct sock *sk)return sk->sk_family ==AF_UNIX && sk->sk_type ==SOCK_STREAM ; } +static inline bool sk_is_vsock (const struct sock *sk) +{ +return sk->sk_family ==AF_VSOCK ; +} +/** * sk_eat_skb - Release a skb if it is no longer needed * @sk: socket to eat this skb from
net/core/sock_map.c +8 -0
@@ -644,6 +644,8 @@ BPF_CALL_4(bpf_sk_redirect_map, struct sk_buff *, skb, sk =__sock_map_lookup_elem (map, key);if (unlikely (!sk || !sock_map_redirect_allowed (sk)))return SK_DROP ; +if ((flags &BPF_F_INGRESS ) &&sk_is_vsock (sk)) +return SK_DROP ;skb_bpf_set_redir (skb, sk, flags &BPF_F_INGRESS );return SK_PASS ;
@@ -672,6 +674,8 @@ BPF_CALL_4(bpf_msg_redirect_map, struct sk_msg *, msg,return SK_DROP ;if (!(flags &BPF_F_INGRESS ) && !sk_is_tcp (sk))return SK_DROP ; +if (sk_is_vsock (sk)) +return SK_DROP ; msg->flags = flags; msg->sk_redir = sk;
@@ -1246,6 +1250,8 @@ BPF_CALL_4(bpf_sk_redirect_hash, struct sk_buff *, skb, sk =__sock_hash_lookup_elem (map, key);if (unlikely (!sk || !sock_map_redirect_allowed (sk)))return SK_DROP ; +if ((flags &BPF_F_INGRESS ) &&sk_is_vsock (sk)) +return SK_DROP ;skb_bpf_set_redir (skb, sk, flags &BPF_F_INGRESS );return SK_PASS ;
@@ -1274,6 +1280,8 @@ BPF_CALL_4(bpf_msg_redirect_hash, struct sk_msg *, msg,return SK_DROP ;if (!(flags &BPF_F_INGRESS ) && !sk_is_tcp (sk))return SK_DROP ; +if (sk_is_vsock (sk)) +return SK_DROP ; msg->flags = flags; msg->sk_redir = sk;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 83/208 vsock: Update rx_bytes on read_skb()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 3543152f2d330141d9394d28855cb90b860091d2 ]
Make sure virtio_transport_inc_rx_pkt() and virtio_transport_dec_rx_pkt() calls are balanced (i.e. virtio_vsock_sock::rx_bytes doesn't lie) after vsock_transport::read_skb().
While here, also inform the peer that we've freed up space and it has more credit.
Failing to update rx_bytes after packet is dequeued leads to a warning on SOCK_STREAM recv():
[ 233.396654] rx_queue is empty, but rx_bytes is non-zero [ 233.396702] WARNING: CPU: 11 PID: 40601 at net/vmw_vsock/virtio_transport_common.c:589
--- net/vmw_vsock/virtio_transport_common.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +9 -2
@@ -1508,6 +1508,7 @@ int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t recv_acto {struct virtio_vsock_sock *vvs = vsk->trans;struct sock *sk =sk_vsock (vsk); +struct virtio_vsock_hdr *hdr;struct sk_buff *skb;int off =0 ;int err;
@@ -1517,10 +1518,16 @@ int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t recv_acto* works for types other than dgrams. */ skb =__skb_recv_datagram (sk, &vvs->rx_queue,MSG_DONTWAIT , &off, &err); +if (!skb) { +spin_unlock_bh (&vvs->rx_lock); +return err; + } + + hdr =virtio_vsock_hdr (skb); +virtio_transport_dec_rx_pkt (vvs,le32_to_cpu (hdr->len));spin_unlock_bh (&vvs->rx_lock); -if (!skb) -return err; +virtio_transport_send_credit_update (vsk);return recv_actor (sk, skb); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 84/208 vsock: Update msg_count on read_skb()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 6dafde852df8de3617d4b9f835b629aaeaccd01d ]
Dequeuing via vsock_transport::read_skb() left msg_count outdated, which then confused SOCK_SEQPACKET recv(). Decrease the counter.
--- net/vmw_vsock/virtio_transport_common.c | 3 +++ 1 file changed, 3 insertions(+)
net/vmw_vsock/virtio_transport_common.c +3 -0
@@ -1524,6 +1524,9 @@ int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t recv_acto } hdr =virtio_vsock_hdr (skb); +if (le32_to_cpu (hdr->flags) &VIRTIO_VSOCK_SEQ_EOM ) + vvs->msg_count--; +virtio_transport_dec_rx_pkt (vvs,le32_to_cpu (hdr->len));spin_unlock_bh (&vvs->rx_lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 85/208 bpf, vsock: Drop static vsock_bpf_prot initialization
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 19039f279797efbe044cae41ee216c5fe481fc33 ]
vsock_bpf_prot is set up at runtime. Remove the superfluous init.
No functional change intended.
--- net/vmw_vsock/vsock_bpf.c | 8 -------- 1 file changed, 8 deletions(-)
net/vmw_vsock/vsock_bpf.c +0 -8
@@ -114,14 +114,6 @@ static int vsock_bpf_recvmsg(struct sock *sk, struct msghdr *msg,return copied; } -/* Copy of original proto with updated sock_map methods */ -static struct proto vsock_bpf_prot = { - .close = sock_map_close, - .recvmsg = vsock_bpf_recvmsg, - .sock_is_readable = sk_msg_is_readable, - .unhash = sock_map_unhash, -}; -static void vsock_bpf_rebuild_protos (struct proto *prot,const struct proto *base) { *prot = *base;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 86/208 riscv, bpf: Make BPF_CMPXCHG fully ordered
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit e59db0623f6955986d1be0880b351a1f56e7fd6d ]
According to the prototype formal BPF memory consistency model discussed e.g. in [1] and following the ordering properties of the C/in-kernel macro atomic_cmpxchg(), a BPF atomic operation with the BPF_CMPXCHG modifier is fully ordered. However, the current RISC-V JIT lowerings fail to meet such memory ordering property. This is illustrated by the following litmus test:
BPF BPF__MP+success_cmpxchg+fence
{
0:r1=x; 0:r3=y; 0:r5=1;
1:r2=y; 1:r4=f; 1:r7=x;
}
P0 | P1 ;
*(u64 *)(r1 + 0) = 1 | r1 = *(u64 *)(r2 + 0) ;
r2 = cmpxchg_64 (r3 + 0, r4, r5) | r3 = atomic_fetch_add((u64 *)(r4 + 0), r5) ;
| r6 = *(u64 *)(r7 + 0) ;exists (1:r1=1 /\ 1:r6=0)
whose "exists" clause is not satisfiable according to the BPF memory model. Using the current RISC-V JIT lowerings, the test can be mapped to the following RISC-V litmus test:
RISCV RISCV__MP+success_cmpxchg+fence
{
0:x1=x; 0:x3=y; 0:x5=1;
1:x2=y; 1:x4=f; 1:x7=x;
}
P0 | P1 ; sd x5, 0(x1) | ld x1, 0(x2) ; L00: | amoadd.d.aqrl x3, x5, 0(x4) ; lr.d x2, 0(x3) | ld x6, 0(x7) ; bne x2, x4, L01 | ; sc.d x6, x5, 0(x3) | ; bne x6, x4, L00 | ; fence rw, rw | ; L01: | ;
exists (1:x1=1 /\ 1:x6=0)
where the two stores in P0 can be reordered. Update the RISC-V JIT lowerings/implementation of BPF_CMPXCHG to emit an SC with RELEASE ("rl") annotation in order to meet the expected memory ordering guarantees. The resulting RISC-V JIT lowerings of BPF_CMPXCHG match the RISC-V lowerings of the C atomic_cmpxchg().
Other lowerings were fixed via 20a759df3bba ("riscv, bpf: make some atomic operations fully ordered").
--- arch/riscv/net/bpf_jit_comp64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/net/bpf_jit_comp64.c +2 -2
@@ -555,8 +555,8 @@ static void emit_atomic(u8 rd, u8 rs, s16 off, s32 imm, bool is64, rv_lr_w(r0, 0, rd, 0, 0), ctx); jmp_offset =ninsns_rvoff (8 );emit (rv_bne (RV_REG_T2 , r0, jmp_offset >>1 ), ctx); -emit (is64 ?rv_sc_d (RV_REG_T3 , rs, rd,0 ,0 ) : -rv_sc_w (RV_REG_T3 , rs, rd,0 ,0 ), ctx); +emit (is64 ?rv_sc_d (RV_REG_T3 , rs, rd,0 ,1 ) : +rv_sc_w (RV_REG_T3 , rs, rd,0 ,1 ), ctx); jmp_offset =ninsns_rvoff (-6 );emit (rv_bne (RV_REG_T3 ,0 , jmp_offset >>1 ), ctx);emit (rv_fence (0x3 ,0x3 ), ctx);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 87/208 nvme-pci: set doorbell config before unquiescing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Butler <[email protected]>
[ Upstream commit 06c59d427017fcde3107c236177fcc74c9db7909 ]
During resets, if queues are unquiesced first, then the host can submit IOs to the controller using shadow doorbell logic but the controller won't be aware. This can lead to necessary MMIO doorbells from being not issued, causing requests to be delayed and timed-out.
Stable-dep-of: 26bc0a81f64c ("nvme-pci: fix race condition between reset and nvme_dev_disable()")
--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -2757,10 +2757,10 @@ static void nvme_reset_work(struct work_struct *work)* controller around but remove all namespaces. */ if (dev->online_queues >1 ) { +nvme_dbbuf_set (dev);nvme_unquiesce_io_queues (&dev->ctrl);nvme_wait_freeze (&dev->ctrl);nvme_pci_update_nr_queues (dev); -nvme_dbbuf_set (dev);nvme_unfreeze (&dev->ctrl); }else {dev_warn (dev->ctrl.device,"IO queues lost\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 88/208 nvme-pci: fix race condition between reset and nvme_dev_disable()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit 26bc0a81f64ce00fc4342c38eeb2eddaad084dd2 ]
nvme_dev_disable() modifies the dev->online_queues field, therefore nvme_pci_update_nr_queues() should avoid racing against it, otherwise we could end up passing invalid values to blk_mq_update_nr_hw_queues().
WARNING: CPU: 39 PID: 61303 at drivers/pci/msi/api.c:347
pci_irq_get_affinity+0x187/0x210
Workqueue: nvme-reset-wq nvme_reset_work [nvme]
RIP: 0010:pci_irq_get_affinity+0x187/0x210
Call Trace:
<TASK>
? blk_mq_pci_map_queues+0x87/0x3c0
? pci_irq_get_affinity+0x187/0x210
blk_mq_pci_map_queues+0x87/0x3c0
nvme_pci_map_queues+0x189/0x460 [nvme]
blk_mq_update_nr_hw_queues+0x2a/0x40
nvme_reset_work+0x1be/0x2a0 [nvme]Fix the bug by locking the shutdown_lock mutex before using dev->online_queues. Give up if nvme_dev_disable() is running or if it has been executed already.
--- drivers/nvme/host/pci.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/nvme/host/pci.c +16 -3
@@ -2469,17 +2469,29 @@ static unsigned int nvme_pci_nr_maps(struct nvme_dev *dev)return 1 ; } -static void nvme_pci_update_nr_queues (struct nvme_dev *dev) +static bool nvme_pci_update_nr_queues (struct nvme_dev *dev) {if (!dev->ctrl.tagset) {nvme_alloc_io_tag_set (&dev->ctrl, &dev->tagset, &nvme_mq_ops,nvme_pci_nr_maps (dev),sizeof (struct nvme_iod )); -return ; +return true; + } + +/* Give up if we are racing with nvme_dev_disable() */ +if (!mutex_trylock (&dev->shutdown_lock)) +return false; + +/* Check if nvme_dev_disable() has been executed already */ +if (!dev->online_queues) { +mutex_unlock (&dev->shutdown_lock); +return false; }blk_mq_update_nr_hw_queues (&dev->tagset, dev->online_queues -1 );/* free previously allocated queues that are no longer usable */ nvme_free_queues (dev, dev->online_queues); +mutex_unlock (&dev->shutdown_lock); +return true; }static int nvme_pci_enable (struct nvme_dev *dev)
@@ -2760,7 +2772,8 @@ static void nvme_reset_work(struct work_struct *work)nvme_dbbuf_set (dev);nvme_unquiesce_io_queues (&dev->ctrl);nvme_wait_freeze (&dev->ctrl); -nvme_pci_update_nr_queues (dev); +if (!nvme_pci_update_nr_queues (dev)) + goto out;nvme_unfreeze (&dev->ctrl); }else {dev_warn (dev->ctrl.device,"IO queues lost\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 89/208 bpf: Fix iter/task tid filtering
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jordan Rome <[email protected]>
[ Upstream commit 9495a5b731fcaf580448a3438d63601c88367661 ]
In userspace, you can add a tid filter by setting the "task.tid" field for "bpf_iter_link_info". However, get_pid_task when called for the BPF_TASK_ITER_TID type should have been using PIDTYPE_PID (tid) instead of PIDTYPE_TGID (pid).
--- kernel/bpf/task_iter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/task_iter.c +1 -1
@@ -119,7 +119,7 @@ static struct task_struct *task_seq_get_next(struct bpf_iter_seq_task_common *corcu_read_lock (); pid =find_pid_ns (common->pid, common->ns);if (pid) { - task =get_pid_task (pid,PIDTYPE_TGID ); + task =get_pid_task (pid,PIDTYPE_PID ); *tid = common->pid; }rcu_read_unlock ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 63/208 irqchip/renesas-rzg2l: Fix missing put_device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrizio Castro <[email protected]>
[ Upstream commit d038109ac1c6bf619473dda03a16a6de58170f7f ]
rzg2l_irqc_common_init() calls of_find_device_by_node(), but the corresponding put_device() call is missing. This also gets reported by make coccicheck.
Make use of the cleanup interfaces from cleanup.h to call into __free_put_device(), which in turn calls into put_device when leaving function rzg2l_irqc_common_init() and variable "dev" goes out of scope.
To prevent that the device is put on successful completion, assign NULL to "dev" to prevent __free_put_device() from calling into put_device() within the successful path.
"make coccicheck" will still complain about missing put_device() calls, but those are false positives now.
--- drivers/irqchip/irq-renesas-rzg2l.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +14 -2
@@ -8,6 +8,7 @@*/ #include <linux/bitfield.h> +#include <linux/cleanup.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/io.h>
@@ -408,12 +409,12 @@ static int rzg2l_irqc_parse_interrupts(struct rzg2l_irqc_priv *priv,static int rzg2l_irqc_init (struct device_node *node,struct device_node *parent) { +struct platform_device *pdev =of_find_device_by_node (node); + struct device *dev __free(put_device) = pdev ? &pdev->dev : NULL;struct irq_domain *irq_domain, *parent_domain; -struct platform_device *pdev;struct reset_control *resetn;int ret; - pdev =of_find_device_by_node (node);if (!pdev)return -ENODEV ;
@@ -467,6 +468,17 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent)register_syscore_ops (&rzg2l_irqc_syscore_ops); +/* +* Prevent the cleanup function from invoking put_device by assigning +* NULL to dev. +* +* make coccicheck will complain about missing put_device calls, but +* those are false positives, as dev will be automatically "put" via +* __free_put_device on the failing path. +* On the successful path we don't actually want to "put" dev. +*/ + dev =NULL ; +return 0 ; pm_put:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 90/208 cdrom: Avoid barrier_nospec() in cdrom_ioctl_media_changed()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit b0bf1afde7c34698cf61422fa8ee60e690dc25c3 ]
The barrier_nospec() after the array bounds check is overkill and painfully slow for arches which implement it.
Furthermore, most arches don't implement it, so they remain exposed to Spectre v1 (which can affect pretty much any CPU with branch prediction).
Instead, clamp the user pointer to a valid range so it's guaranteed to be a valid array index even when the bounds check mispredicts.
--- drivers/cdrom/cdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cdrom/cdrom.c +1 -1
@@ -2313,7 +2313,7 @@ static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi,return -EINVAL ;/* Prevent arg from speculatively bypassing the length check */ -barrier_nospec (); + arg =array_index_nospec (arg, cdi->capacity); info =kmalloc (sizeof (*info),GFP_KERNEL );if (!info)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 91/208 mm/khugepaged: convert alloc_charge_hpage() to use folios
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Moola (Oracle) <[email protected]>
[ Upstream commit b455f39d228935f88eebcd1f7c1a6981093c6a3b ]
Also remove count_memcg_page_event now that its last caller no longer uses it and reword hpage_collapse_alloc_page() to hpage_collapse_alloc_folio().
This removes 1 call to compound_head() and helps convert khugepaged to use folios throughout.
Stable-dep-of: 37f0b47c5143 ("mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point")
--- include/linux/memcontrol.h | 14 -------------- mm/khugepaged.c | 17 ++++++++++------- 2 files changed, 10 insertions(+), 21 deletions(-)
include/linux/memcontrol.h +0 -14
@@ -1080,15 +1080,6 @@ static inline void count_memcg_events(struct mem_cgroup *memcg,local_irq_restore (flags); } -static inline void count_memcg_page_event (struct page *page, -enum vm_event_item idx) -{ -struct mem_cgroup *memcg =page_memcg (page); - -if (memcg) -count_memcg_events (memcg, idx,1 ); -} -static inline void count_memcg_folio_events (struct folio *folio,enum vm_event_item idx,unsigned long nr) {
@@ -1565,11 +1556,6 @@ static inline void __count_memcg_events(struct mem_cgroup *memcg, { } -static inline void count_memcg_page_event (struct page *page, -int idx) -{ -} -static inline void count_memcg_folio_events (struct folio *folio,enum vm_event_item idx,unsigned long nr) {
mm/khugepaged.c +10 -7
@@ -887,16 +887,16 @@ static int hpage_collapse_find_target_node(struct collapse_control *cc) }#endif -static bool hpage_collapse_alloc_page (struct page **hpage,gfp_t gfp,int node, +static bool hpage_collapse_alloc_folio (struct folio **folio,gfp_t gfp,int node,nodemask_t *nmask) { - *hpage =__alloc_pages (gfp,HPAGE_PMD_ORDER , node, nmask); -if (unlikely (!*hpage)) { + *folio =__folio_alloc (gfp,HPAGE_PMD_ORDER , node, nmask); + +if (unlikely (!*folio)) {count_vm_event (THP_COLLAPSE_ALLOC_FAILED );return false; } -folio_prep_large_rmappable ((struct folio *)*hpage);count_vm_event (THP_COLLAPSE_ALLOC );return true; }
@@ -1063,17 +1063,20 @@ static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm,int node =hpage_collapse_find_target_node (cc);struct folio *folio; -if (!hpage_collapse_alloc_page (hpage, gfp, node, &cc->alloc_nmask)) +if (!hpage_collapse_alloc_folio (&folio, gfp, node, &cc->alloc_nmask)) { + *hpage =NULL ;return SCAN_ALLOC_HUGE_PAGE_FAIL ; + } - folio =page_folio (*hpage);if (unlikely (mem_cgroup_charge (folio, mm, gfp))) {folio_put (folio); *hpage =NULL ;return SCAN_CGROUP_CHARGE_FAIL ; } -count_memcg_page_event (*hpage,THP_COLLAPSE_ALLOC ); +count_memcg_folio_events (folio,THP_COLLAPSE_ALLOC ,1 ); + + *hpage =folio_page (folio,0 );return SCAN_SUCCEED ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 92/208 mm: convert collapse_huge_page() to use a folio
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 5432726848bb27a01badcbc93b596f39ee6c5ffb ]
Replace three calls to compound_head() with one.
Stable-dep-of: 37f0b47c5143 ("mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point")
--- mm/khugepaged.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
mm/khugepaged.c +8 -7
@@ -1088,6 +1088,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,pmd_t *pmd, _pmd;pte_t *pte;pgtable_t pgtable; +struct folio *folio;struct page *hpage;spinlock_t *pmd_ptl, *pte_ptl;int result =SCAN_FAIL ;
@@ -1207,13 +1208,13 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,if (unlikely (result !=SCAN_SUCCEED )) goto out_up_write; + folio =page_folio (hpage);/* -* spin_lock() below is not the equivalent of smp_wmb(), but -* the smp_wmb() inside __SetPageUptodate() can be reused to -* avoid the copy_huge_page writes to become visible after -* the set_pmd_at() write. +* The smp_wmb() inside __folio_mark_uptodate() ensures the +* copy_huge_page writes become visible before the set_pmd_at() +* write. */ -__SetPageUptodate (hpage); +__folio_mark_uptodate (folio); pgtable =pmd_pgtable (_pmd); _pmd =mk_huge_pmd (hpage, vma->vm_page_prot);
@@ -1221,8 +1222,8 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,spin_lock (pmd_ptl);BUG_ON (!pmd_none (*pmd)); -page_add_new_anon_rmap (hpage, vma, address); -lru_cache_add_inactive_or_unevictable (hpage, vma); +folio_add_new_anon_rmap (folio, vma, address); +folio_add_lru_vma (folio, vma);pgtable_trans_huge_deposit (mm, pmd, pgtable);set_pmd_at (mm, address, pmd, _pmd);update_mmu_cache_pmd (vma, address, pmd);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 93/208 mm/khugepaged: use a folio more in collapse_file()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit b54d60b18e850561e8bdb4264ae740676c3b7658 ]
This function is not yet fully converted to the folio API, but this removes a few uses of old APIs.
Stable-dep-of: 37f0b47c5143 ("mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point")
--- mm/khugepaged.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
mm/khugepaged.c +8 -8
@@ -2124,23 +2124,23 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,xas_lock_irq (&xas); } - nr =thp_nr_pages (hpage); + folio =page_folio (hpage); + nr =folio_nr_pages (folio);if (is_shmem) -__mod_lruvec_page_state (hpage,NR_SHMEM_THPS , nr); +__lruvec_stat_mod_folio (folio,NR_SHMEM_THPS , nr);else -__mod_lruvec_page_state (hpage,NR_FILE_THPS , nr); +__lruvec_stat_mod_folio (folio,NR_FILE_THPS , nr);if (nr_none) { -__mod_lruvec_page_state (hpage,NR_FILE_PAGES , nr_none); +__lruvec_stat_mod_folio (folio,NR_FILE_PAGES , nr_none);/* nr_none is always 0 for non-shmem. */ -__mod_lruvec_page_state (hpage,NR_SHMEM , nr_none); +__lruvec_stat_mod_folio (folio,NR_SHMEM , nr_none); }/* * Mark hpage as uptodate before inserting it into the page cache so * that it isn't mistaken for an fallocated but unwritten page. */ - folio =page_folio (hpage);folio_mark_uptodate (folio);folio_ref_add (folio,HPAGE_PMD_NR -1 );
@@ -2150,7 +2150,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,/* Join all the small entries into a single multi-index entry. */ xas_set_order (&xas, start,HPAGE_PMD_ORDER ); -xas_store (&xas, hpage); +xas_store (&xas, folio);WARN_ON_ONCE (xas_error (&xas));xas_unlock_irq (&xas);
@@ -2161,7 +2161,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,retract_page_tables (mapping, start);if (cc && !cc->is_khugepaged) result =SCAN_PTE_MAPPED_HUGEPAGE ; -unlock_page (hpage); +folio_unlock (folio);/* * The collapse has succeeded, so free the old pages.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 94/208 khugepaged: inline hpage_collapse_alloc_folio()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 4746f5ce0fa52e21b5fe432970fe9516d1a45ebc ]
Patch series "khugepaged folio conversions".
We've been kind of hacking piecemeal at converting khugepaged to use folios instead of compound pages, and so this patchset is a little larger than it should be as I undo some of our wrong moves in the past. In particular, collapse_file() now consistently uses 'new_folio' for the freshly allocated folio and 'folio' for the one that's currently in use.
This patch (of 7):
This function has one caller, and the combined function is simpler to read, reason about and modify.
Stable-dep-of: 37f0b47c5143 ("mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point")
--- mm/khugepaged.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
mm/khugepaged.c +4 -15
@@ -887,20 +887,6 @@ static int hpage_collapse_find_target_node(struct collapse_control *cc) }#endif -static bool hpage_collapse_alloc_folio (struct folio **folio,gfp_t gfp,int node, -nodemask_t *nmask) -{ - *folio =__folio_alloc (gfp,HPAGE_PMD_ORDER , node, nmask); - -if (unlikely (!*folio)) { -count_vm_event (THP_COLLAPSE_ALLOC_FAILED ); -return false; - } - -count_vm_event (THP_COLLAPSE_ALLOC ); -return true; -} -/* * If mmap_lock temporarily dropped, revalidate vma * before taking mmap_lock.
@@ -1063,11 +1049,14 @@ static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm,int node =hpage_collapse_find_target_node (cc);struct folio *folio; -if (!hpage_collapse_alloc_folio (&folio, gfp, node, &cc->alloc_nmask)) { + folio =__folio_alloc (gfp,HPAGE_PMD_ORDER , node, &cc->alloc_nmask); +if (!folio) { *hpage =NULL ; +count_vm_event (THP_COLLAPSE_ALLOC_FAILED );return SCAN_ALLOC_HUGE_PAGE_FAIL ; } +count_vm_event (THP_COLLAPSE_ALLOC );if (unlikely (mem_cgroup_charge (folio, mm, gfp))) {folio_put (folio); *hpage =NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 95/208 khugepaged: convert alloc_charge_hpage to alloc_charge_folio
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit d5ab50b9412c0bba750eef5a34fd2937de1aee55 ]
Both callers want to deal with a folio, so return a folio from this function.
Stable-dep-of: 37f0b47c5143 ("mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point")
--- mm/khugepaged.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
mm/khugepaged.c +9 -8
@@ -1041,7 +1041,7 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm,return result; } -static int alloc_charge_hpage (struct page **hpage,struct mm_struct *mm, +static int alloc_charge_folio (struct folio **foliop,struct mm_struct *mm,struct collapse_control *cc) { gfp_t gfp = (cc->is_khugepaged ? alloc_hugepage_khugepaged_gfpmask() :
@@ -1051,7 +1051,7 @@ static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm, folio =__folio_alloc (gfp,HPAGE_PMD_ORDER , node, &cc->alloc_nmask);if (!folio) { - *hpage =NULL ; + *foliop =NULL ;count_vm_event (THP_COLLAPSE_ALLOC_FAILED );return SCAN_ALLOC_HUGE_PAGE_FAIL ; }
@@ -1059,13 +1059,13 @@ static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm,count_vm_event (THP_COLLAPSE_ALLOC );if (unlikely (mem_cgroup_charge (folio, mm, gfp))) {folio_put (folio); - *hpage =NULL ; + *foliop =NULL ;return SCAN_CGROUP_CHARGE_FAIL ; }count_memcg_folio_events (folio,THP_COLLAPSE_ALLOC ,1 ); - *hpage =folio_page (folio,0 ); + *foliop = folio;return SCAN_SUCCEED ; }
@@ -1094,7 +1094,8 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,*/ mmap_read_unlock (mm); - result =alloc_charge_hpage (&hpage, mm, cc); + result =alloc_charge_folio (&folio, mm, cc); + hpage = &folio->page;if (result !=SCAN_SUCCEED ) goto out_nolock;
@@ -1197,7 +1198,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,if (unlikely (result !=SCAN_SUCCEED )) goto out_up_write; - folio =page_folio (hpage);/* * The smp_wmb() inside __folio_mark_uptodate() ensures the * copy_huge_page writes become visible before the set_pmd_at()
@@ -1786,7 +1786,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,struct page *hpage;struct page *page;struct page *tmp; -struct folio *folio; +struct folio *folio, *new_folio;pgoff_t index =0 , end = start +HPAGE_PMD_NR ;LIST_HEAD (pagelist);XA_STATE_ORDER (xas, &mapping->i_pages, start,HPAGE_PMD_ORDER );
@@ -1797,7 +1797,8 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,VM_BUG_ON (!IS_ENABLED (CONFIG_READ_ONLY_THP_FOR_FS ) && !is_shmem);VM_BUG_ON (start & (HPAGE_PMD_NR -1 )); - result =alloc_charge_hpage (&hpage, mm, cc); + result =alloc_charge_folio (&new_folio, mm, cc); + hpage = &new_folio->page;if (result !=SCAN_SUCCEED ) goto out;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 96/208 khugepaged: remove hpage from collapse_file()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 610ff817b981921213ae51e5c5f38c76c6f0405e ]
Use new_folio throughout where we had been using hpage.
Stable-dep-of: 37f0b47c5143 ("mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point")
--- include/trace/events/huge_memory.h | 6 +-- mm/khugepaged.c | 77 +++++++++++++++--------------- 2 files changed, 42 insertions(+), 41 deletions(-)
include/trace/events/huge_memory.h +3 -3
@@ -207,10 +207,10 @@ TRACE_EVENT(mm_khugepaged_scan_file, ); TRACE_EVENT(mm_khugepaged_collapse_file, - TP_PROTO(struct mm_struct *mm, struct page *hpage, pgoff_t index, + TP_PROTO(struct mm_struct *mm, struct folio *new_folio, pgoff_t index, bool is_shmem, unsigned long addr, struct file *file, int nr, int result), - TP_ARGS(mm, hpage, index, addr, is_shmem, file, nr, result), + TP_ARGS(mm, new_folio, index, addr, is_shmem, file, nr, result), TP_STRUCT__entry( __field(struct mm_struct *, mm) __field(unsigned long, hpfn)
@@ -224,7 +224,7 @@ TRACE_EVENT(mm_khugepaged_collapse_file,TP_fast_assign ( __entry->mm = mm; - __entry->hpfn = hpage ?page_to_pfn (hpage) :-1 ; + __entry->hpfn = new_folio ?folio_pfn (new_folio) :-1 ; __entry->index = index; __entry->addr = addr; __entry->is_shmem = is_shmem;
mm/khugepaged.c +39 -38
158 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 97/208 mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Shi <[email protected]>
[ Upstream commit 37f0b47c5143c2957909ced44fc09ffb118c99f7 ]
The "addr" and "is_shmem" arguments have different order in TP_PROTO and TP_ARGS. This resulted in the incorrect trace result:
text-hugepage-644429 [276] 392092.878683: mm_khugepaged_collapse_file:
mm=0xffff20025d52c440, hpage_pfn=0x200678c00, index=512, addr=1, is_shmem=0, filename=text-hugepage, nr=512, result=failed
The value of "addr" is wrong because it was treated as bool value, the type of is_shmem.
Fix the order in TP_PROTO to keep "addr" is before "is_shmem" since the original patch review suggested this order to achieve best packing.
And use "lx" for "addr" instead of "ld" in TP_printk because address is typically shown in hex.
After the fix, the trace result looks correct:
text-hugepage-7291 [004] 128.627251: mm_khugepaged_collapse_file:
mm=0xffff0001328f9500, hpage_pfn=0x20016ea00, index=512, addr=0x400000, is_shmem=0, filename=text-hugepage, nr=512, result=failed
--- include/trace/events/huge_memory.h | 4 ++-- mm/khugepaged.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/trace/events/huge_memory.h +2 -2
@@ -208,7 +208,7 @@ TRACE_EVENT(mm_khugepaged_scan_file, TRACE_EVENT(mm_khugepaged_collapse_file, TP_PROTO(struct mm_struct *mm, struct folio *new_folio, pgoff_t index, - bool is_shmem, unsigned long addr, struct file *file, + unsigned long addr, bool is_shmem, struct file *file, int nr, int result), TP_ARGS(mm, new_folio, index, addr, is_shmem, file, nr, result), TP_STRUCT__entry(
@@ -233,7 +233,7 @@ TRACE_EVENT(mm_khugepaged_collapse_file, __entry->result = result; ), - TP_printk("mm=%p, hpage_pfn=0x%lx, index=%ld, addr=%ld, is_shmem=%d, filename=%s, nr=%d, result=%s", + TP_printk("mm=%p, hpage_pfn=0x%lx, index=%ld, addr=%lx, is_shmem=%d, filename=%s, nr=%d, result=%s", __entry->mm, __entry->hpfn, __entry->index,
mm/khugepaged.c +1 -1
@@ -2203,7 +2203,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,folio_put (new_folio); out:VM_BUG_ON (!list_empty (&pagelist)); -trace_mm_khugepaged_collapse_file (mm, new_folio, index, is_shmem, addr, file,HPAGE_PMD_NR , result); +trace_mm_khugepaged_collapse_file (mm, new_folio, index, addr, is_shmem, file,HPAGE_PMD_NR , result);return result; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 98/208 iio: adc: ti-lmp92064: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
[ Upstream commit a985576af824426e33100554a5958a6beda60a13 ]
This driver makes use of triggered buffers, but does not select the required modules.
Add the missing 'select IIO_BUFFER' and 'select IIO_TRIGGERED_BUFFER'.
--- drivers/iio/adc/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/adc/Kconfig +2 -0
@@ -1335,6 +1335,8 @@ config TI_LMP92064 tristate "Texas Instruments LMP92064 ADC driver" depends on SPI select REGMAP_SPI + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER help Say yes here to build support for the LMP92064 Precision Current and Voltage sensor.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 64/208 drm/msm/dpu: dont always program merge_3d block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jessica Zhang <[email protected]>
[ Upstream commit f87f3b80abaf7949e638dd17dfdc267066eb52d5 ]
Only program the merge_3d block for the video phys encoder when the 3d blend mode is not NONE
Patchwork: https://patchwork.freedesktop.org/patch/619095/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +1 -1
@@ -280,7 +280,7 @@ static void dpu_encoder_phys_vid_setup_timing_engine( intf_cfg.stream_sel =0 ;/* Don't care value for video mode */ intf_cfg.mode_3d =dpu_encoder_helper_get_3d_blend_mode (phys_enc); intf_cfg.dsc =dpu_encoder_helper_get_dsc (phys_enc); -if (phys_enc->hw_pp->merge_3d) +if (intf_cfg.mode_3d && phys_enc->hw_pp->merge_3d) intf_cfg.merge_3d = phys_enc->hw_pp->merge_3d->idx;spin_lock_irqsave (phys_enc->enc_spinlock, lock_flags);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 65/208 net: bcmasp: fix potential memory leak in bcmasp_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Hai <[email protected]>
[ Upstream commit fed07d3eb8a8d9fcc0e455175a89bc6445d6faed ]
The bcmasp_xmit() returns NETDEV_TX_OK without freeing skb in case of mapping fails, add dev_kfree_skb() to fix it.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1 -0
@@ -322,6 +322,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) }/* Rewind so we do not have a hole */ spb_index = intf->tx_spb_index; +dev_kfree_skb (skb);return NETDEV_TX_OK ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 66/208 tcp/dccp: Dont use timer_pending() in reqsk_queue_unlink().
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit e8c526f2bdf1845bedaf6a478816a3d06fa78b8f ]
Martin KaFai Lau reported use-after-free [0] in reqsk_timer_handler().
"""
We are seeing a use-after-free from a bpf prog attached to trace_tcp_retransmit_synack. The program passes the req->sk to the bpf_sk_storage_get_tracing kernel helper which does check for null before using it.
"""
The commit 83fccfc3940c ("inet: fix potential deadlock in reqsk_queue_unlink()") added timer_pending() in reqsk_queue_unlink() not to call del_timer_sync() from reqsk_timer_handler(), but it introduced a small race window.
Before the timer is called, expire_timers() calls detach_timer(timer, true) to clear timer->entry.pprev and marks it as not pending.
If reqsk_queue_unlink() checks timer_pending() just after expire_timers() calls detach_timer(), TCP will miss del_timer_sync(); the reqsk timer will continue running and send multiple SYN+ACKs until it expires.
The reported UAF could happen if req->sk is close()d earlier than the timer expiration, which is 63s by default.
The scenario would be
1. inet_csk_complete_hashdance() calls inet_csk_reqsk_queue_drop(), but del_timer_sync() is missed
2. reqsk timer is executed and scheduled again
3. req->sk is accept()ed and reqsk_put() decrements rsk_refcnt, but reqsk timer still has another one, and inet_csk_accept() does not clear req->sk for non-TFO sockets
4. sk is close()d
5. reqsk timer is executed again, and BPF touches req->sk
Let's not use timer_pending() by passing the caller context to __inet_csk_reqsk_queue_drop().
Note that reqsk timer is pinned, so the issue does not happen in most use cases. [1]
[0]
BUG: KFENCE: use-after-free read in bpf_sk_storage_get_tracing+0x2e/0x1b0
Use-after-free read at 0x00000000a891fb3a (in kfence-#1):
bpf_sk_storage_get_tracing+0x2e/0x1b0 bpf_prog_5ea3e95db6da0438_tcp_retransmit_synack+0x1d20/0x1dda bpf_trace_run2+0x4c/0xc0 tcp_rtx_synack+0xf9/0x100 reqsk_timer_handler+0xda/0x3d0 run_timer_softirq+0x292/0x8a0 irq_exit_rcu+0xf5/0x320 sysvec_apic_timer_interrupt+0x6d/0x80 asm_sysvec_apic_timer_interrupt+0x16/0x20 intel_idle_irq+0x5a/0xa0 cpuidle_enter_state+0x94/0x273 cpu_startup_entry+0x15e/0x260 start_secondary+0x8a/0x90 secondary_startup_64_no_verify+0xfa/0xfb
kfence-#1: 0x00000000a72cc7b6-0x00000000d97616d9, size=2376, cache=TCPv6
allocated by task 0 on cpu 9 at 260507.901592s:
sk_prot_alloc+0x35/0x140 sk_clone_lock+0x1f/0x3f0 inet_csk_clone_lock+0x15/0x160 tcp_create_openreq_child+0x1f/0x410 tcp_v6_syn_recv_sock+0x1da/0x700 tcp_check_req+0x1fb/0x510 tcp_v6_rcv+0x98b/0x1420 ipv6_list_rcv+0x2258/0x26e0 napi_complete_done+0x5b1/0x2990 mlx5e_napi_poll+0x2ae/0x8d0 net_rx_action+0x13e/0x590 irq_exit_rcu+0xf5/0x320 common_interrupt+0x80/0x90 asm_common_interrupt+0x22/0x40 cpuidle_enter_state+0xfb/0x273 cpu_startup_entry+0x15e/0x260 start_secondary+0x8a/0x90 secondary_startup_64_no_verify+0xfa/0xfb
freed by task 0 on cpu 9 at 260507.927527s:
rcu_core_si+0x4ff/0xf10 irq_exit_rcu+0xf5/0x320 sysvec_apic_timer_interrupt+0x6d/0x80 asm_sysvec_apic_timer_interrupt+0x16/0x20 cpuidle_enter_state+0xfb/0x273 cpu_startup_entry+0x15e/0x260 start_secondary+0x8a/0x90 secondary_startup_64_no_verify+0xfa/0xfb
--- net/ipv4/inet_connection_sock.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
net/ipv4/inet_connection_sock.c +16 -5
@@ -980,21 +980,31 @@ static bool reqsk_queue_unlink(struct request_sock *req) found =__sk_nulls_del_node_init_rcu (sk);spin_unlock (lock); } -if (timer_pending (&req->rsk_timer) &&del_timer_sync (&req->rsk_timer)) -reqsk_put (req); +return found; } -bool inet_csk_reqsk_queue_drop (struct sock *sk,struct request_sock *req) +static bool __inet_csk_reqsk_queue_drop (struct sock *sk, +struct request_sock *req, +bool from_timer) {bool unlinked =reqsk_queue_unlink (req); +if (!from_timer &&timer_delete_sync (&req->rsk_timer)) +reqsk_put (req); +if (unlinked) {reqsk_queue_removed (&inet_csk (sk)->icsk_accept_queue, req);reqsk_put (req); } +return unlinked; } + +bool inet_csk_reqsk_queue_drop (struct sock *sk,struct request_sock *req) +{ +return __inet_csk_reqsk_queue_drop (sk, req, false); +}EXPORT_SYMBOL (inet_csk_reqsk_queue_drop);void inet_csk_reqsk_queue_drop_and_put (struct sock *sk,struct request_sock *req)
@@ -1087,7 +1097,7 @@ static void reqsk_timer_handler(struct timer_list *t)if (!inet_ehash_insert (req_to_sk (nreq),req_to_sk (oreq),NULL )) {/* delete timer */ -inet_csk_reqsk_queue_drop (sk_listener, nreq); +__inet_csk_reqsk_queue_drop (sk_listener, nreq, true); goto no_ownership; }
@@ -1113,7 +1123,8 @@ static void reqsk_timer_handler(struct timer_list *t) } drop: -inet_csk_reqsk_queue_drop_and_put (oreq->rsk_listener, oreq); +__inet_csk_reqsk_queue_drop (sk_listener, oreq, true); +reqsk_put (req); } static bool reqsk_queue_hash_req(struct request_sock *req,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 67/208 net: dsa: mv88e6xxx: Fix the max_vid definition for the MV88E6361
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Rashleigh <[email protected]>
[ Upstream commit 1833d8a26f057128fd63e126b4428203ece84684 ]
According to the Marvell datasheet the 88E6361 has two VTU pages (4k VIDs per page) so the max_vid should be 8191, not 4095.
In the current implementation mv88e6xxx_vtu_walk() gives unexpected results because of this error. I verified that mv88e6xxx_vtu_walk() works correctly on the MV88E6361 with this patch in place.
--- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +1 -1
@@ -6208,7 +6208,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .invalid_port_mask = BIT(1) | BIT(2) | BIT(8), .num_internal_phys = 5, .internal_phys_offset = 3, - .max_vid = 4095, + .max_vid = 8191, .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 68/208 genetlink: hold RCU in genlmsg_mcast()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 56440d7ec28d60f8da3bfa09062b3368ff9b16db ]
While running net selftests with CONFIG_PROVE_RCU_LIST=y I saw one lockdep splat [1].
genlmsg_mcast() uses for_each_net_rcu(), and must therefore hold RCU.
Instead of letting all callers guard genlmsg_multicast_allns() with a rcu_read_lock()/rcu_read_unlock() pair, do it in genlmsg_mcast().
This also means the @flags parameter is useless, we need to always use GFP_ATOMIC.
[1]
[10882.424136] ============================= [10882.424166] WARNING: suspicious RCU usage [10882.424309] 6.12.0-rc2-virtme #1156 Not tainted [10882.424400] ----------------------------- [10882.424423] net/netlink/genetlink.c:1940 RCU-list traversed in non-reader section!! [10882.424469]
other info that might help us debug this:
[10882.424500]
rcu_scheduler_active = 2, debug_locks = 1
[10882.424744] 2 locks held by ip/15677:
[10882.424791] #0: ffffffffb6b491b0 (cb_lock){++++}-{3:3}, at: genl_rcv (net/netlink/genetlink.c:1219)
[10882.426334] #1: ffffffffb6b49248 (genl_mutex){+.+.}-{3:3}, at: genl_rcv_msg (net/netlink/genetlink.c:61 net/netlink/genetlink.c:57 net/netlink/genetlink.c:1209)
[10882.426465]
stack backtrace:
[10882.426805] CPU: 14 UID: 0 PID: 15677 Comm: ip Not tainted 6.12.0-rc2-virtme #1156
[10882.426919] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[10882.427046] Call Trace:
[10882.427131] <TASK>
[10882.427244] dump_stack_lvl (lib/dump_stack.c:123)
[10882.427335] lockdep_rcu_suspicious (kernel/locking/lockdep.c:6822)
[10882.427387] genlmsg_multicast_allns (net/netlink/genetlink.c:1940 (discriminator 7) net/netlink/genetlink.c:1977 (discriminator 7))
[10882.427436] l2tp_tunnel_notify.constprop.0 (net/l2tp/l2tp_netlink.c:119) l2tp_netlink
[10882.427683] l2tp_nl_cmd_tunnel_create (net/l2tp/l2tp_netlink.c:253) l2tp_netlink
[10882.427748] genl_family_rcv_msg_doit (net/netlink/genetlink.c:1115)
[10882.427834] genl_rcv_msg (net/netlink/genetlink.c:1195 net/netlink/genetlink.c:1210)
[10882.427877] ? __pfx_l2tp_nl_cmd_tunnel_create (net/l2tp/l2tp_netlink.c:186) l2tp_netlink
[10882.427927] ? __pfx_genl_rcv_msg (net/netlink/genetlink.c:1201)
[10882.427959] netlink_rcv_skb (net/netlink/af_netlink.c:2551)
[10882.428069] genl_rcv (net/netlink/genetlink.c:1220)
[10882.428095] netlink_unicast (net/netlink/af_netlink.c:1332 net/netlink/af_netlink.c:1357)
[10882.428140] netlink_sendmsg (net/netlink/af_netlink.c:1901)
[10882.428210] ____sys_sendmsg (net/socket.c:729 (discriminator 1) net/socket.c:744 (discriminator 1) net/socket.c:2607 (discriminator 1))--- drivers/target/target_core_user.c | 2 +- include/net/genetlink.h | 3 +-- net/l2tp/l2tp_netlink.c | 4 ++-- net/netlink/genetlink.c | 28 ++++++++++++++-------------- net/wireless/nl80211.c | 8 ++------ 5 files changed, 20 insertions(+), 25 deletions(-)
drivers/target/target_core_user.c +1 -1
@@ -2130,7 +2130,7 @@ static int tcmu_netlink_event_send(struct tcmu_dev *udev, } ret =genlmsg_multicast_allns (&tcmu_genl_family, skb,0 , -TCMU_MCGRP_CONFIG ,GFP_KERNEL ); +TCMU_MCGRP_CONFIG );/* Wait during an add as the listener may not be up yet */ if (ret == 0 ||
include/net/genetlink.h +1 -2
@@ -478,13 +478,12 @@ static inline int genlmsg_multicast(const struct genl_family *family,* @skb: netlink message as socket buffer * @portid: own netlink portid to avoid sending to yourself * @group: offset of multicast group in groups array -* @flags: allocation flags * * This function must hold the RTNL or rcu_read_lock(). */ int genlmsg_multicast_allns (const struct genl_family *family,struct sk_buff *skb,u32 portid, -unsigned int group,gfp_t flags); +unsigned int group);/** * genlmsg_unicast - unicast a netlink message
net/l2tp/l2tp_netlink.c +2 -2
@@ -115,7 +115,7 @@ static int l2tp_tunnel_notify(struct genl_family *family, NLM_F_ACK, tunnel, cmd);if (ret >=0 ) { - ret =genlmsg_multicast_allns (family, msg,0 ,0 ,GFP_ATOMIC ); + ret =genlmsg_multicast_allns (family, msg,0 ,0 );/* We don't care if no one is listening */ if (ret == -ESRCH ) ret =0 ;
@@ -143,7 +143,7 @@ static int l2tp_session_notify(struct genl_family *family, NLM_F_ACK, session, cmd);if (ret >=0 ) { - ret =genlmsg_multicast_allns (family, msg,0 ,0 ,GFP_ATOMIC ); + ret =genlmsg_multicast_allns (family, msg,0 ,0 );/* We don't care if no one is listening */ if (ret == -ESRCH ) ret =0 ;
net/netlink/genetlink.c +14 -14
@@ -1355,15 +1355,11 @@ static int genl_ctrl_event(int event, const struct genl_family *family,if (IS_ERR (msg))return PTR_ERR (msg); -if (!family->netnsok) { +if (!family->netnsok)genlmsg_multicast_netns (&genl_ctrl, &init_net, msg,0 ,0 ,GFP_KERNEL ); - }else { -rcu_read_lock (); -genlmsg_multicast_allns (&genl_ctrl, msg,0 , -0 ,GFP_ATOMIC ); -rcu_read_unlock (); - } +else +genlmsg_multicast_allns (&genl_ctrl, msg,0 ,0 );return 0 ; }
@@ -1752,23 +1748,23 @@ static int __init genl_init(void)core_initcall (genl_init); -static int genlmsg_mcast (struct sk_buff *skb,u32 portid,unsigned long group, -gfp_t flags) +static int genlmsg_mcast (struct sk_buff *skb,u32 portid,unsigned long group) {struct sk_buff *tmp;struct net *net, *prev =NULL ;bool delivered = false;int err; +rcu_read_lock ();for_each_net_rcu (net) {if (prev) { - tmp =skb_clone (skb, flags); + tmp =skb_clone (skb,GFP_ATOMIC );if (!tmp) { err = -ENOMEM ; goto error; } err =nlmsg_multicast (prev->genl_sock, tmp, - portid, group, flags); + portid, group,GFP_ATOMIC );if (!err) delivered = true;else if (err != -ESRCH )
@@ -1777,27 +1773,31 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group, prev = net; } + err =nlmsg_multicast (prev->genl_sock, skb, portid, group,GFP_ATOMIC ); + +rcu_read_unlock (); - err =nlmsg_multicast (prev->genl_sock, skb, portid, group, flags);if (!err) delivered = true;else if (err != -ESRCH )return err;return delivered ?0 : -ESRCH ; error: +rcu_read_unlock (); +kfree_skb (skb);return err; }int genlmsg_multicast_allns (const struct genl_family *family,struct sk_buff *skb,u32 portid, -unsigned int group,gfp_t flags) +unsigned int group) {if (WARN_ON_ONCE (group >= family->n_mcgrps))return -EINVAL ; group = family->mcgrp_offset + group; -return genlmsg_mcast (skb, portid, group, flags); +return genlmsg_mcast (skb, portid, group); }EXPORT_SYMBOL (genlmsg_multicast_allns);
net/wireless/nl80211.c +2 -6
@@ -17905,10 +17905,8 @@ void nl80211_common_reg_change_event(enum nl80211_commands cmd_id,genlmsg_end (msg, hdr); -rcu_read_lock ();genlmsg_multicast_allns (&nl80211_fam, msg,0 , -NL80211_MCGRP_REGULATORY ,GFP_ATOMIC ); -rcu_read_unlock (); +NL80211_MCGRP_REGULATORY );return ;
@@ -18605,10 +18603,8 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy,genlmsg_end (msg, hdr); -rcu_read_lock ();genlmsg_multicast_allns (&nl80211_fam, msg,0 , -NL80211_MCGRP_REGULATORY ,GFP_ATOMIC ); -rcu_read_unlock (); +NL80211_MCGRP_REGULATORY );return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 69/208 ravb: Remove setting of RX software timestamp
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 277901ee3a2620679e2c8797377d2a72f4358068 ]
The responsibility for reporting of RX software timestamp has moved to the core layer (see __ethtool_get_ts_info()), remove usage from the device drivers.
Stable-dep-of: 126e799602f4 ("net: ravb: Only advertise Rx/Tx timestamps if hardware supports it")
--- drivers/net/ethernet/renesas/ravb_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +2 -2
@@ -1675,8 +1675,6 @@ static int ravb_get_ts_info(struct net_device *ndev, info->so_timestamping =SOF_TIMESTAMPING_TX_SOFTWARE | -SOF_TIMESTAMPING_RX_SOFTWARE | -SOF_TIMESTAMPING_SOFTWARE |SOF_TIMESTAMPING_TX_HARDWARE |SOF_TIMESTAMPING_RX_HARDWARE |SOF_TIMESTAMPING_RAW_HARDWARE ;
@@ -1687,6 +1685,8 @@ static int ravb_get_ts_info(struct net_device *ndev, (1 <<HWTSTAMP_FILTER_ALL );if (hw_info->gptp || hw_info->ccc_gac) info->phc_index =ptp_clock_index (priv->ptp.clock); +else + info->phc_index =0 ;return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 60/208 irqchip/renesas-rzg2l: Align struct member names to tabs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 02f6507640173addeeb3af035d2c6f0b3cff1567 ]
Align struct member names to tabs to follow the requirements from maintainer-tip file. 3 tabs were used at the moment as the next commits will add a new member which requires 3 tabs for a better view.
Stable-dep-of: d038109ac1c6 ("irqchip/renesas-rzg2l: Fix missing put_device")
--- drivers/irqchip/irq-renesas-rzg2l.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -3
@@ -56,9 +56,9 @@#define TINT_EXTRACT_GPIOINT (x) FIELD_GET(GENMASK(31, 16), (x))struct rzg2l_irqc_priv { -void __iomem *base; -struct irq_fwspec fwspec[IRQC_NUM_IRQ ]; -raw_spinlock_t lock; +void __iomem *base; +struct irq_fwspec fwspec[IRQC_NUM_IRQ ]; +raw_spinlock_t lock; };static struct rzg2l_irqc_priv *irq_data_to_priv (struct irq_data *data)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 100/208 xhci: dbgtty: use kfifo from tty_port struct
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
[ Upstream commit 866025f0237609532bc8e4af5ef4d7252d3b55b6 ]
There is no need to define one in a custom structure. The tty_port one is free to use.
Stable-dep-of: 30c9ae5ece8e ("xhci: dbc: honor usb transfer size boundaries.")
--- drivers/usb/host/xhci-dbgcap.h | 1 - drivers/usb/host/xhci-dbgtty.c | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/usb/host/xhci-dbgcap.h +0 -1
@@ -108,7 +108,6 @@ struct dbc_port {struct tasklet_struct push;struct list_head write_pool; -struct kfifo write_fifo;bool registered; };
drivers/usb/host/xhci-dbgtty.c +9 -8
@@ -36,7 +36,7 @@ static int dbc_start_tx(struct dbc_port *port)while (!list_empty (pool)) { req = list_entry(pool->next, struct dbc_request, list_pool); - len =kfifo_out (&port->write_fifo, req->buf,DBC_MAX_PACKET ); + len =kfifo_out (&port->port.xmit_fifo, req->buf,DBC_MAX_PACKET );if (len ==0 )break ; do_tty_wake = true;
@@ -203,7 +203,7 @@ static ssize_t dbc_tty_write(struct tty_struct *tty, const u8 *buf,spin_lock_irqsave (&port->port_lock, flags);if (count) - count =kfifo_in (&port->write_fifo, buf, count); + count =kfifo_in (&port->port.xmit_fifo, buf, count);dbc_start_tx (port);spin_unlock_irqrestore (&port->port_lock, flags);
@@ -217,7 +217,7 @@ static int dbc_tty_put_char(struct tty_struct *tty, u8 ch)int status;spin_lock_irqsave (&port->port_lock, flags); - status =kfifo_put (&port->write_fifo, ch); + status =kfifo_put (&port->port.xmit_fifo, ch);spin_unlock_irqrestore (&port->port_lock, flags);return status;
@@ -240,7 +240,7 @@ static unsigned int dbc_tty_write_room(struct tty_struct *tty)unsigned int room;spin_lock_irqsave (&port->port_lock, flags); - room =kfifo_avail (&port->write_fifo); + room =kfifo_avail (&port->port.xmit_fifo);spin_unlock_irqrestore (&port->port_lock, flags);return room;
@@ -253,7 +253,7 @@ static unsigned int dbc_tty_chars_in_buffer(struct tty_struct *tty)unsigned int chars;spin_lock_irqsave (&port->port_lock, flags); - chars =kfifo_len (&port->write_fifo); + chars =kfifo_len (&port->port.xmit_fifo);spin_unlock_irqrestore (&port->port_lock, flags);return chars;
@@ -411,7 +411,8 @@ static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) goto err_idr; } - ret =kfifo_alloc (&port->write_fifo,DBC_WRITE_BUF_SIZE ,GFP_KERNEL ); + ret =kfifo_alloc (&port->port.xmit_fifo,DBC_WRITE_BUF_SIZE , +GFP_KERNEL );if (ret) goto err_exit_port;
@@ -440,7 +441,7 @@ static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc)xhci_dbc_free_requests (&port->read_pool);xhci_dbc_free_requests (&port->write_pool); err_free_fifo: -kfifo_free (&port->write_fifo); +kfifo_free (&port->port.xmit_fifo); err_exit_port:idr_remove (&dbc_tty_minors, port->minor); err_idr:
@@ -465,7 +466,7 @@ static void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc)idr_remove (&dbc_tty_minors, port->minor);mutex_unlock (&dbc_tty_minors_lock); -kfifo_free (&port->write_fifo); +kfifo_free (&port->port.xmit_fifo);xhci_dbc_free_requests (&port->read_pool);xhci_dbc_free_requests (&port->read_queue);xhci_dbc_free_requests (&port->write_pool);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 109/208 tracing/probes: Support $argN in return probe (kprobe and fprobe)
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 25f00e40ce7953db197af3a59233711d154c9d80 ]
Support accessing $argN in the return probe events. This will help users to record entry data in function return (exit) event for simplfing the function entry/exit information in one event, and record the result values (e.g. allocated object/initialized object) at function exit.
For example, if we have a function int init_foo(struct foo *obj, int param) sometimes we want to check how obj is initialized. In such case, we can define a new return event like below;
# echo 'r init_foo retval=$retval param=$arg2 field1=+0($arg1)' >> kprobe_events
Thus it records the function parameter param and its result obj->field1 (the dereference will be done in the function exit timing) value at once.
This also support fprobe, BTF args and'$arg*'. So if CONFIG_DEBUG_INFO_BTF is enabled, we can trace both function parameters and the return value by following command.
# echo 'f target_function%return $arg* $retval' >> dynamic_events
Stable-dep-of: 373b9338c972 ("uprobe: avoid out-of-bounds memory access of fetching args")
--- kernel/trace/trace.c | 1 + kernel/trace/trace_eprobe.c | 6 +- kernel/trace/trace_fprobe.c | 55 ++++-- kernel/trace/trace_kprobe.c | 56 +++++- kernel/trace/trace_probe.c | 177 +++++++++++++++--- kernel/trace/trace_probe.h | 28 ++- kernel/trace/trace_probe_tmpl.h | 10 +- kernel/trace/trace_uprobe.c | 12 +- .../test.d/dynevent/fprobe_syntax_errors.tc | 4 + .../test.d/kprobe/kprobe_syntax_errors.tc | 2 + 10 files changed, 289 insertions(+), 62 deletions(-)
kernel/trace/trace.c +1 -0
@@ -5757,6 +5757,7 @@ static const char readme_msg[] = "\t $stack<index>, $stack, $retval, $comm,\n"#endif "\t +|-[u]<offset>(<fetcharg>), \\imm-value, \\\"imm-string\"\n" +"\t kernel return probes support: $retval, $arg<N>, $comm\n" "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, char, string, symbol,\n" "\t b<bit-width>@<bit-offset>/<container-size>, ustring,\n" "\t symstr, <type>\\[<array-size>\\]\n"
kernel/trace/trace_eprobe.c +3 -3
@@ -390,8 +390,8 @@ static int get_eprobe_size(struct trace_probe *tp, void *rec)/* Note that we don't verify it, since the code does not come from user space */ static int -process_fetch_insn (struct fetch_insn *code,void *rec,void *dest, -void *base) +process_fetch_insn (struct fetch_insn *code,void *rec,void *edata, +void *dest,void *base) {unsigned long val;int ret;
@@ -438,7 +438,7 @@ __eprobe_trace_func(struct eprobe_data *edata, void *rec)return ; entry = fbuffer.entry =ring_buffer_event_data (fbuffer.event); -store_trace_args (&entry[1 ], &edata->ep->tp, rec,sizeof (*entry), dsize); +store_trace_args (&entry[1 ], &edata->ep->tp, rec,NULL ,sizeof (*entry), dsize);trace_event_buffer_commit (&fbuffer); }
kernel/trace/trace_fprobe.c +39 -16
160 lines not on this page · raw message
kernel/trace/trace_kprobe.c +46 -10
134 lines not on this page · raw message
kernel/trace/trace_probe.c +156 -21
238 lines not on this page · raw message
kernel/trace/trace_probe.h +27 -1
@@ -92,6 +92,7 @@ enum fetch_op {FETCH_OP_ARG ,/* Function argument : .param */ FETCH_OP_FOFFS ,/* File offset: .immediate */ FETCH_OP_DATA ,/* Allocated data: .data */ +FETCH_OP_EDATA ,/* Entry data: .offset */ // Stage 2 (dereference) op FETCH_OP_DEREF ,/* Dereference: .offset */ FETCH_OP_UDEREF, /* User-space Dereference: .offset */
@@ -102,6 +103,7 @@ enum fetch_op {FETCH_OP_ST_STRING ,/* String: .offset, .size */ FETCH_OP_ST_USTRING ,/* User String: .offset, .size */ FETCH_OP_ST_SYMSTR ,/* Kernel Symbol String: .offset, .size */ +FETCH_OP_ST_EDATA ,/* Store Entry Data: .offset */ // Stage 4 (modify) op FETCH_OP_MOD_BF, /* Bitfield: .basesize, .lshift, .rshift */// Stage 5 (loop) op
@@ -232,6 +234,11 @@ struct probe_arg {const struct fetch_type *type;/* Type of this argument */ }; +struct probe_entry_arg { +struct fetch_insn *code; +unsigned int size;/* The entry data size */ +}; +struct trace_uprobe_filter {rwlock_t rwlock;int nr_systemwide;
@@ -253,6 +260,7 @@ struct trace_probe {struct trace_probe_event *event;ssize_t size;/* trace entry size */ unsigned int nr_args; +struct probe_entry_arg *entry_arg;/* This is only for return probe */ struct probe_arg args[]; };
@@ -355,6 +363,18 @@ int trace_probe_create(const char *raw_command, int (*createfn)(int, const charint trace_probe_print_args (struct trace_seq *s,struct probe_arg *args,int nr_args,u8 *data,void *field); +#ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API +int traceprobe_get_entry_data_size (struct trace_probe *tp); +/* This is a runtime function to store entry data */ +void store_trace_entry_data (void *edata,struct trace_probe *tp,struct pt_regs *regs); +#else /* !CONFIG_HAVE_FUNCTION_ARG_ACCESS_API */ +static inline int traceprobe_get_entry_data_size (struct trace_probe *tp) +{ +return 0 ; +} +#define store_trace_entry_data (edata, tp, regs) do { } while (0) +#endif +#define trace_probe_for_each_link (pos, tp) \ list_for_each_entry(pos, &(tp)->event->files, list)#define trace_probe_for_each_link_rcu (pos, tp) \
@@ -381,6 +401,11 @@ static inline bool tparg_is_function_entry(unsigned int flags)return (flags &TPARG_FL_LOC_MASK ) == (TPARG_FL_KERNEL |TPARG_FL_FENTRY ); } +static inline bool tparg_is_function_return (unsigned int flags) +{ +return (flags &TPARG_FL_LOC_MASK ) == (TPARG_FL_KERNEL |TPARG_FL_RETURN ); +} +struct traceprobe_parse_context {struct trace_event_call *event;/* BTF related parameters */
@@ -392,6 +417,7 @@ struct traceprobe_parse_context {const struct btf_type *last_type;/* Saved type */ u32 last_bitoffs;/* Saved bitoffs */ u32 last_bitsize;/* Saved bitsize */ +struct trace_probe *tp;unsigned int flags;int offset; };
@@ -506,7 +532,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,C (NO_BTFARG ,"This variable is not found at this probe point" ),\C (NO_BTF_ENTRY ,"No BTF entry for this probe point" ), \C (BAD_VAR_ARGS ,"$arg* must be an independent parameter without name etc." ),\ -C (NOFENTRY_ARGS ,"$arg* can be used only on function entry" ), \ +C (NOFENTRY_ARGS ,"$arg* can be used only on function entry or exit" ), \C (DOUBLE_ARGS ,"$arg* can be used only once in the parameters" ), \C (ARGS_2LONG ,"$arg* failed because the argument list is too long" ), \ C(ARGIDX_2BIG, "$argN index is too big"), \
kernel/trace/trace_probe_tmpl.h +5 -5
@@ -54,7 +54,7 @@ fetch_apply_bitfield(struct fetch_insn *code, void *buf)* If dest is NULL, don't store result and return required dynamic data size. */ static int -process_fetch_insn (struct fetch_insn *code,void *rec, +process_fetch_insn (struct fetch_insn *code,void *rec,void *edata,void *dest,void *base); static nokprobe_inline int fetch_store_strlen(unsigned long addr);static nokprobe_inline int
@@ -232,7 +232,7 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,/* Sum up total data length for dynamic arrays (strings) */ static nokprobe_inline int -__get_data_size (struct trace_probe *tp,struct pt_regs *regs) +__get_data_size (struct trace_probe *tp,struct pt_regs *regs,void *edata) {struct probe_arg *arg;int i, len, ret =0 ;
@@ -240,7 +240,7 @@ __get_data_size(struct trace_probe *tp, struct pt_regs *regs)for (i =0 ; i < tp->nr_args; i++) { arg = tp->args + i;if (unlikely (arg->dynamic)) { - len =process_fetch_insn (arg->code, regs,NULL ,NULL ); + len =process_fetch_insn (arg->code, regs, edata,NULL ,NULL );if (len >0 ) ret += len; }
@@ -251,7 +251,7 @@ __get_data_size(struct trace_probe *tp, struct pt_regs *regs)/* Store the value of each argument */ static nokprobe_inline void -store_trace_args (void *data,struct trace_probe *tp,void *rec, +store_trace_args (void *data,struct trace_probe *tp,void *rec,void *edata,int header_size,int maxlen) {struct probe_arg *arg;
@@ -266,7 +266,7 @@ store_trace_args(void *data, struct trace_probe *tp, void *rec,/* Point the dynamic data area if needed */ if (unlikely (arg->dynamic)) *dl =make_data_loc (maxlen, dyndata - base); - ret =process_fetch_insn (arg->code, rec, dl, base); + ret =process_fetch_insn (arg->code, rec, edata, dl, base);if (arg->dynamic &&likely (ret >0 )) { dyndata += ret; maxlen -= ret;
kernel/trace/trace_uprobe.c +6 -6
@@ -211,8 +211,8 @@ static unsigned long translate_user_vaddr(unsigned long file_offset)/* Note that we don't verify it, since the code does not come from user space */ static int -process_fetch_insn (struct fetch_insn *code,void *rec,void *dest, -void *base) +process_fetch_insn (struct fetch_insn *code,void *rec,void *edata, +void *dest,void *base) {struct pt_regs *regs = rec;unsigned long val;
@@ -1490,11 +1490,11 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)if (WARN_ON_ONCE (!uprobe_cpu_buffer))return 0 ; - dsize =__get_data_size (&tu->tp, regs); + dsize =__get_data_size (&tu->tp, regs,NULL ); esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); ucb =uprobe_buffer_get (); -store_trace_args (ucb->buf, &tu->tp, regs, esize, dsize); +store_trace_args (ucb->buf, &tu->tp, regs,NULL , esize, dsize);if (trace_probe_test_flag (&tu->tp,TP_FLAG_TRACE )) ret |=uprobe_trace_func (tu, regs, ucb, dsize);
@@ -1525,11 +1525,11 @@ static int uretprobe_dispatcher(struct uprobe_consumer *con,if (WARN_ON_ONCE (!uprobe_cpu_buffer))return 0 ; - dsize =__get_data_size (&tu->tp, regs); + dsize =__get_data_size (&tu->tp, regs,NULL ); esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); ucb =uprobe_buffer_get (); -store_trace_args (ucb->buf, &tu->tp, regs, esize, dsize); +store_trace_args (ucb->buf, &tu->tp, regs,NULL , esize, dsize);if (trace_probe_test_flag (&tu->tp,TP_FLAG_TRACE ))uretprobe_trace_func (tu, func, regs, ucb, dsize);
tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc +4 -0
@@ -34,7 +34,9 @@ check_error 'f vfs_read ^$stack10000' # BAD_STACK_NUM check_error 'f vfs_read ^$arg10000' # BAD_ARG_NUM +if !grep -q 'kernel return probes support:' README; then check_error 'f vfs_read $retval ^$arg1' # BAD_VAR +fi check_error 'f vfs_read ^$none_var' # BAD_VAR check_error 'f vfs_read ^'$REG # BAD_VAR
@@ -99,7 +101,9 @@ if grep -q "<argname>" README; then check_error 'f vfs_read args=^$arg*' # BAD_VAR_ARGS check_error 'f vfs_read +0(^$arg*)' # BAD_VAR_ARGS check_error 'f vfs_read $arg* ^$arg*' # DOUBLE_ARGS +if !grep -q 'kernel return probes support:' README; then check_error 'f vfs_read%return ^$arg*' # NOFENTRY_ARGS +fi check_error 'f vfs_read ^hoge' # NO_BTFARG check_error 'f kfree ^$arg10' # NO_BTFARG (exceed the number of parameters) check_error 'f kfree%return ^$retval' # NO_RETVAL
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +2 -0
@@ -108,7 +108,9 @@ if grep -q "<argname>" README; then check_error 'p vfs_read args=^$arg*' # BAD_VAR_ARGS check_error 'p vfs_read +0(^$arg*)' # BAD_VAR_ARGS check_error 'p vfs_read $arg* ^$arg*' # DOUBLE_ARGS +if !grep -q 'kernel return probes support:' README; then check_error 'r vfs_read ^$arg*' # NOFENTRY_ARGS +fi check_error 'p vfs_read+8 ^$arg*' # NOFENTRY_ARGS check_error 'p vfs_read ^hoge' # NO_BTFARG check_error 'p kfree ^$arg10' # NO_BTFARG (exceed the number of parameters)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 110/208 uprobes: encapsulate preparation of uprobe args buffer
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
[ Upstream commit 3eaea21b4d27cff0017c20549aeb53034c58fc23 ]
Move the logic of fetching temporary per-CPU uprobe buffer and storing uprobes args into it to a new helper function. Store data size as part of this buffer, simplifying interfaces a bit, as now we only pass single uprobe_cpu_buffer reference around, instead of pointer + dsize.
This logic was duplicated across uprobe_dispatcher and uretprobe_dispatcher, and now will be centralized. All this is also in preparation to make this uprobe_cpu_buffer handling logic optional in the next patch.
Stable-dep-of: 373b9338c972 ("uprobe: avoid out-of-bounds memory access of fetching args")
--- kernel/trace/trace_uprobe.c | 78 +++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 37 deletions(-)
kernel/trace/trace_uprobe.c +41 -37
@@ -854,6 +854,7 @@ static const struct file_operations uprobe_profile_ops = {struct uprobe_cpu_buffer {struct mutex mutex;void *buf; +int dsize; };static struct uprobe_cpu_buffer __percpu *uprobe_cpu_buffer;static int uprobe_buffer_refcnt;
@@ -943,9 +944,26 @@ static void uprobe_buffer_put(struct uprobe_cpu_buffer *ucb)mutex_unlock (&ucb->mutex); } +static struct uprobe_cpu_buffer *prepare_uprobe_buffer (struct trace_uprobe *tu, +struct pt_regs *regs) +{ +struct uprobe_cpu_buffer *ucb; +int dsize, esize; + + esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); + dsize =__get_data_size (&tu->tp, regs,NULL ); + + ucb =uprobe_buffer_get (); + ucb->dsize = tu->tp.size + dsize; + +store_trace_args (ucb->buf, &tu->tp, regs,NULL , esize, dsize); + +return ucb; +} +static void __uprobe_trace_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb,int dsize, +struct uprobe_cpu_buffer *ucb,struct trace_event_file *trace_file) {struct uprobe_trace_entry_head *entry;
@@ -956,14 +974,14 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,WARN_ON (call != trace_file->event_call); -if (WARN_ON_ONCE (tu->tp.size + dsize >PAGE_SIZE )) +if (WARN_ON_ONCE (ucb->dsize >PAGE_SIZE ))return ;if (trace_trigger_soft_disabled (trace_file))return ; esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); - size = esize + tu->tp.size + dsize; + size = esize + ucb->dsize; entry =trace_event_buffer_reserve (&fbuffer, trace_file, size);if (!entry)return ;
@@ -977,14 +995,14 @@ static void __uprobe_trace_func(struct trace_uprobe *tu, data =DATAOF_TRACE_ENTRY (entry, false); } -memcpy (data, ucb->buf, tu->tp.size + dsize); +memcpy (data, ucb->buf, ucb->dsize);trace_event_buffer_commit (&fbuffer); }/* uprobe handler */ static int uprobe_trace_func (struct trace_uprobe *tu,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb,int dsize) +struct uprobe_cpu_buffer *ucb) {struct event_file_link *link;
@@ -993,7 +1011,7 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs,rcu_read_lock ();trace_probe_for_each_link_rcu (link, &tu->tp) -__uprobe_trace_func (tu,0 , regs, ucb, dsize, link->file); +__uprobe_trace_func (tu,0 , regs, ucb, link->file);rcu_read_unlock ();return 0 ;
@@ -1001,13 +1019,13 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs,static void uretprobe_trace_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb,int dsize) +struct uprobe_cpu_buffer *ucb) {struct event_file_link *link;rcu_read_lock ();trace_probe_for_each_link_rcu (link, &tu->tp) -__uprobe_trace_func (tu, func, regs, ucb, dsize, link->file); +__uprobe_trace_func (tu, func, regs, ucb, link->file);rcu_read_unlock (); }
@@ -1335,7 +1353,7 @@ static bool uprobe_perf_filter(struct uprobe_consumer *uc,static void __uprobe_perf_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb,int dsize) +struct uprobe_cpu_buffer *ucb) {struct trace_event_call *call =trace_probe_event_call (&tu->tp);struct uprobe_trace_entry_head *entry;
@@ -1356,7 +1374,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu, esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); - size = esize + tu->tp.size + dsize; + size = esize + ucb->dsize; size =ALIGN (size +sizeof (u32),sizeof (u64)) -sizeof (u32);if (WARN_ONCE (size >PERF_MAX_TRACE_SIZE ,"profile buffer not large enough" ))return ;
@@ -1379,13 +1397,10 @@ static void __uprobe_perf_func(struct trace_uprobe *tu, data =DATAOF_TRACE_ENTRY (entry, false); } -memcpy (data, ucb->buf, tu->tp.size + dsize); +memcpy (data, ucb->buf, ucb->dsize); -if (size - esize > tu->tp.size + dsize) { -int len = tu->tp.size + dsize; - -memset (data + len,0 , size - esize - len); - } +if (size - esize > ucb->dsize) +memset (data + ucb->dsize,0 , size - esize - ucb->dsize);perf_trace_buf_submit (entry, size, rctx, call->event.type,1 , regs, head,NULL );
@@ -1395,21 +1410,21 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,/* uprobe profile handler */ static int uprobe_perf_func (struct trace_uprobe *tu,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb,int dsize) +struct uprobe_cpu_buffer *ucb) {if (!uprobe_perf_filter (&tu->consumer,0 , current->mm))return UPROBE_HANDLER_REMOVE ;if (!is_ret_probe (tu)) -__uprobe_perf_func (tu,0 , regs, ucb, dsize); +__uprobe_perf_func (tu,0 , regs, ucb);return 0 ; }static void uretprobe_perf_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb,int dsize) +struct uprobe_cpu_buffer *ucb) { -__uprobe_perf_func (tu, func, regs, ucb, dsize); +__uprobe_perf_func (tu, func, regs, ucb); } int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,
@@ -1475,10 +1490,8 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)struct trace_uprobe *tu;struct uprobe_dispatch_data udd;struct uprobe_cpu_buffer *ucb; -int dsize, esize;int ret =0 ; - tu = container_of(con, struct trace_uprobe, consumer); tu->nhit++;
@@ -1490,18 +1503,14 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)if (WARN_ON_ONCE (!uprobe_cpu_buffer))return 0 ; - dsize =__get_data_size (&tu->tp, regs,NULL ); - esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); - - ucb =uprobe_buffer_get (); -store_trace_args (ucb->buf, &tu->tp, regs,NULL , esize, dsize); + ucb =prepare_uprobe_buffer (tu, regs);if (trace_probe_test_flag (&tu->tp,TP_FLAG_TRACE )) - ret |=uprobe_trace_func (tu, regs, ucb, dsize); + ret |=uprobe_trace_func (tu, regs, ucb);#ifdef CONFIG_PERF_EVENTS if (trace_probe_test_flag (&tu->tp,TP_FLAG_PROFILE )) - ret |=uprobe_perf_func (tu, regs, ucb, dsize); + ret |=uprobe_perf_func (tu, regs, ucb);#endif uprobe_buffer_put (ucb);return ret;
@@ -1513,7 +1522,6 @@ static int uretprobe_dispatcher(struct uprobe_consumer *con,struct trace_uprobe *tu;struct uprobe_dispatch_data udd;struct uprobe_cpu_buffer *ucb; -int dsize, esize; tu = container_of(con, struct trace_uprobe, consumer);
@@ -1525,18 +1533,14 @@ static int uretprobe_dispatcher(struct uprobe_consumer *con,if (WARN_ON_ONCE (!uprobe_cpu_buffer))return 0 ; - dsize =__get_data_size (&tu->tp, regs,NULL ); - esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); - - ucb =uprobe_buffer_get (); -store_trace_args (ucb->buf, &tu->tp, regs,NULL , esize, dsize); + ucb =prepare_uprobe_buffer (tu, regs);if (trace_probe_test_flag (&tu->tp,TP_FLAG_TRACE )) -uretprobe_trace_func (tu, func, regs, ucb, dsize); +uretprobe_trace_func (tu, func, regs, ucb);#ifdef CONFIG_PERF_EVENTS if (trace_probe_test_flag (&tu->tp,TP_FLAG_PROFILE )) -uretprobe_perf_func (tu, func, regs, ucb, dsize); +uretprobe_perf_func (tu, func, regs, ucb);#endif uprobe_buffer_put (ucb);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 111/208 uprobes: prepare uprobe args buffer lazily
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
[ Upstream commit 1b8f85defbc82e2eb8f27c5f6060ea507ad4d5a3 ]
uprobe_cpu_buffer and corresponding logic to store uprobe args into it are used for uprobes/uretprobes that are created through tracefs or perf events.
BPF is yet another user of uprobe/uretprobe infrastructure, but doesn't need uprobe_cpu_buffer and associated data. For BPF-only use cases this buffer handling and preparation is a pure overhead. At the same time, BPF-only uprobe/uretprobe usage is very common in practice. Also, for a lot of cases applications are very senstivie to performance overheads, as they might be tracing a very high frequency functions like malloc()/free(), so every bit of performance improvement matters.
All that is to say that this uprobe_cpu_buffer preparation is an unnecessary overhead that each BPF user of uprobes/uretprobe has to pay. This patch is changing this by making uprobe_cpu_buffer preparation optional. It will happen only if either tracefs-based or perf event-based uprobe/uretprobe consumer is registered for given uprobe/uretprobe. For BPF-only use cases this step will be skipped.
We used uprobe/uretprobe benchmark which is part of BPF selftests (see [0]) to estimate the improvements. We have 3 uprobe and 3 uretprobe scenarios, which vary an instruction that is replaced by uprobe: nop (fastest uprobe case), push rbp (typical case), and non-simulated ret instruction (slowest case). Benchmark thread is constantly calling user space function in a tight loop. User space function has attached BPF uprobe or uretprobe program doing nothing but atomic counter increments to count number of triggering calls. Benchmark emits throughput in millions of executions per second.
BEFORE these changes
====================
uprobe-nop : 2.657 ± 0.024M/s uprobe-push : 2.499 ± 0.018M/s uprobe-ret : 1.100 ± 0.006M/s uretprobe-nop : 1.356 ± 0.004M/s uretprobe-push : 1.317 ± 0.019M/s uretprobe-ret : 0.785 ± 0.007M/s
AFTER these changes
===================
uprobe-nop : 2.732 ± 0.022M/s (+2.8%) uprobe-push : 2.621 ± 0.016M/s (+4.9%) uprobe-ret : 1.105 ± 0.007M/s (+0.5%) uretprobe-nop : 1.396 ± 0.007M/s (+2.9%) uretprobe-push : 1.347 ± 0.008M/s (+2.3%) uretprobe-ret : 0.800 ± 0.006M/s (+1.9)
So the improvements on this particular machine seems to be between 2% and 5%.
[0] https://github.com/torvalds/linux/blob/master/tools/testing/selftests/bpf/benchs/bench_trigger.c
Stable-dep-of: 373b9338c972 ("uprobe: avoid out-of-bounds memory access of fetching args")
--- kernel/trace/trace_uprobe.c | 49 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-)
kernel/trace/trace_uprobe.c +28 -21
@@ -941,15 +941,21 @@ static struct uprobe_cpu_buffer *uprobe_buffer_get(void)static void uprobe_buffer_put (struct uprobe_cpu_buffer *ucb) { +if (!ucb) +return ;mutex_unlock (&ucb->mutex); }static struct uprobe_cpu_buffer *prepare_uprobe_buffer (struct trace_uprobe *tu, -struct pt_regs *regs) +struct pt_regs *regs, +struct uprobe_cpu_buffer **ucbp) {struct uprobe_cpu_buffer *ucb;int dsize, esize; +if (*ucbp) +return *ucbp; + esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); dsize =__get_data_size (&tu->tp, regs,NULL );
@@ -958,22 +964,25 @@ static struct uprobe_cpu_buffer *prepare_uprobe_buffer(struct trace_uprobe *tu,store_trace_args (ucb->buf, &tu->tp, regs,NULL , esize, dsize); + *ucbp = ucb;return ucb; }static void __uprobe_trace_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb, +struct uprobe_cpu_buffer **ucbp,struct trace_event_file *trace_file) {struct uprobe_trace_entry_head *entry;struct trace_event_buffer fbuffer; +struct uprobe_cpu_buffer *ucb;void *data;int size, esize;struct trace_event_call *call =trace_probe_event_call (&tu->tp);WARN_ON (call != trace_file->event_call); + ucb =prepare_uprobe_buffer (tu, regs, ucbp);if (WARN_ON_ONCE (ucb->dsize >PAGE_SIZE ))return ;
@@ -1002,7 +1011,7 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,/* uprobe handler */ static int uprobe_trace_func (struct trace_uprobe *tu,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb) +struct uprobe_cpu_buffer **ucbp) {struct event_file_link *link;
@@ -1011,7 +1020,7 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs,rcu_read_lock ();trace_probe_for_each_link_rcu (link, &tu->tp) -__uprobe_trace_func (tu,0 , regs, ucb, link->file); +__uprobe_trace_func (tu,0 , regs, ucbp, link->file);rcu_read_unlock ();return 0 ;
@@ -1019,13 +1028,13 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs,static void uretprobe_trace_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb) +struct uprobe_cpu_buffer **ucbp) {struct event_file_link *link;rcu_read_lock ();trace_probe_for_each_link_rcu (link, &tu->tp) -__uprobe_trace_func (tu, func, regs, ucb, link->file); +__uprobe_trace_func (tu, func, regs, ucbp, link->file);rcu_read_unlock (); }
@@ -1353,10 +1362,11 @@ static bool uprobe_perf_filter(struct uprobe_consumer *uc,static void __uprobe_perf_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb) +struct uprobe_cpu_buffer **ucbp) {struct trace_event_call *call =trace_probe_event_call (&tu->tp);struct uprobe_trace_entry_head *entry; +struct uprobe_cpu_buffer *ucb;struct hlist_head *head;void *data;int size, esize;
@@ -1374,6 +1384,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu, esize =SIZEOF_TRACE_ENTRY (is_ret_probe (tu)); + ucb =prepare_uprobe_buffer (tu, regs, ucbp); size = esize + ucb->dsize; size =ALIGN (size +sizeof (u32),sizeof (u64)) -sizeof (u32);if (WARN_ONCE (size >PERF_MAX_TRACE_SIZE ,"profile buffer not large enough" ))
@@ -1410,21 +1421,21 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,/* uprobe profile handler */ static int uprobe_perf_func (struct trace_uprobe *tu,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb) +struct uprobe_cpu_buffer **ucbp) {if (!uprobe_perf_filter (&tu->consumer,0 , current->mm))return UPROBE_HANDLER_REMOVE ;if (!is_ret_probe (tu)) -__uprobe_perf_func (tu,0 , regs, ucb); +__uprobe_perf_func (tu,0 , regs, ucbp);return 0 ; }static void uretprobe_perf_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer *ucb) +struct uprobe_cpu_buffer **ucbp) { -__uprobe_perf_func (tu, func, regs, ucb); +__uprobe_perf_func (tu, func, regs, ucbp); } int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,
@@ -1489,7 +1500,7 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs) {struct trace_uprobe *tu;struct uprobe_dispatch_data udd; -struct uprobe_cpu_buffer *ucb; +struct uprobe_cpu_buffer *ucb =NULL ;int ret =0 ; tu = container_of(con, struct trace_uprobe, consumer);
@@ -1503,14 +1514,12 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)if (WARN_ON_ONCE (!uprobe_cpu_buffer))return 0 ; - ucb =prepare_uprobe_buffer (tu, regs); -if (trace_probe_test_flag (&tu->tp,TP_FLAG_TRACE )) - ret |=uprobe_trace_func (tu, regs, ucb); + ret |=uprobe_trace_func (tu, regs, &ucb);#ifdef CONFIG_PERF_EVENTS if (trace_probe_test_flag (&tu->tp,TP_FLAG_PROFILE )) - ret |=uprobe_perf_func (tu, regs, ucb); + ret |=uprobe_perf_func (tu, regs, &ucb);#endif uprobe_buffer_put (ucb);return ret;
@@ -1521,7 +1530,7 @@ static int uretprobe_dispatcher(struct uprobe_consumer *con, {struct trace_uprobe *tu;struct uprobe_dispatch_data udd; -struct uprobe_cpu_buffer *ucb; +struct uprobe_cpu_buffer *ucb =NULL ; tu = container_of(con, struct trace_uprobe, consumer);
@@ -1533,14 +1542,12 @@ static int uretprobe_dispatcher(struct uprobe_consumer *con,if (WARN_ON_ONCE (!uprobe_cpu_buffer))return 0 ; - ucb =prepare_uprobe_buffer (tu, regs); -if (trace_probe_test_flag (&tu->tp,TP_FLAG_TRACE )) -uretprobe_trace_func (tu, func, regs, ucb); +uretprobe_trace_func (tu, func, regs, &ucb);#ifdef CONFIG_PERF_EVENTS if (trace_probe_test_flag (&tu->tp,TP_FLAG_PROFILE )) -uretprobe_perf_func (tu, func, regs, ucb); +uretprobe_perf_func (tu, func, regs, &ucb);#endif uprobe_buffer_put (ucb);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 112/208 uprobes: prevent mutex_lock() under rcu_read_lock()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
[ Upstream commit 699646734ab51bf5b1cd4a7a30c20074f6e74f6e ]
Recent changes made uprobe_cpu_buffer preparation lazy, and moved it deeper into __uprobe_trace_func(). This is problematic because __uprobe_trace_func() is called inside rcu_read_lock()/rcu_read_unlock() block, which then calls prepare_uprobe_buffer() -> uprobe_buffer_get() -> mutex_lock(&ucb->mutex), leading to a splat about using mutex under non-sleepable RCU:
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:585
in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 98231, name: stress-ng-sigq
preempt_count: 0, expected: 0
RCU nest depth: 1, expected: 0
...
Call Trace:
<TASK>
dump_stack_lvl+0x3d/0xe0
__might_resched+0x24c/0x270
? prepare_uprobe_buffer+0xd5/0x1d0
__mutex_lock+0x41/0x820
? ___perf_sw_event+0x206/0x290
? __perf_event_task_sched_in+0x54/0x660
? __perf_event_task_sched_in+0x54/0x660
prepare_uprobe_buffer+0xd5/0x1d0
__uprobe_trace_func+0x4a/0x140
uprobe_dispatcher+0x135/0x280
? uprobe_dispatcher+0x94/0x280
uprobe_notify_resume+0x650/0xec0
? atomic_notifier_call_chain+0x21/0x110
? atomic_notifier_call_chain+0xf8/0x110
irqentry_exit_to_user_mode+0xe2/0x1e0
asm_exc_int3+0x35/0x40
RIP: 0033:0x7f7e1d4da390
Code: 33 04 00 0f 1f 80 00 00 00 00 f3 0f 1e fa b9 01 00 00 00 e9 b2 fc ff ff 66 90 f3 0f 1e fa 31 c9 e9 a5 fc ff ff 0f 1f 44 00 00 <cc> 0f 1e fa b8 27 00 00 00 0f 05 c3 0f 1f 40 00 f3 0f 1e fa b8 6e
RSP: 002b:00007ffd2abc3608 EFLAGS: 00000246
RAX: 0000000000000000 RBX: 0000000076d325f1 RCX: 0000000000000000
RDX: 0000000076d325f1 RSI: 000000000000000a RDI: 00007ffd2abc3690
RBP: 000000000000000a R08: 00017fb700000000 R09: 00017fb700000000
R10: 00017fb700000000 R11: 0000000000000246 R12: 0000000000017ff2
R13: 00007ffd2abc3610 R14: 0000000000000000 R15: 00007ffd2abc3780
</TASK>Luckily, it's easy to fix by moving prepare_uprobe_buffer() to be called slightly earlier: into uprobe_trace_func() and uretprobe_trace_func(), outside of RCU locked section. This still keeps this buffer preparation lazy and helps avoid the overhead when it's not needed. E.g., if there is only BPF uprobe handler installed on a given uprobe, buffer won't be initialized.
Note, the other user of prepare_uprobe_buffer(), __uprobe_perf_func(), is not affected, as it doesn't prepare buffer under RCU read lock.
Stable-dep-of: 373b9338c972 ("uprobe: avoid out-of-bounds memory access of fetching args")
--- kernel/trace/trace_uprobe.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
kernel/trace/trace_uprobe.c +9 -5
@@ -970,19 +970,17 @@ static struct uprobe_cpu_buffer *prepare_uprobe_buffer(struct trace_uprobe *tu,static void __uprobe_trace_func (struct trace_uprobe *tu,unsigned long func,struct pt_regs *regs, -struct uprobe_cpu_buffer **ucbp, +struct uprobe_cpu_buffer *ucb,struct trace_event_file *trace_file) {struct uprobe_trace_entry_head *entry;struct trace_event_buffer fbuffer; -struct uprobe_cpu_buffer *ucb;void *data;int size, esize;struct trace_event_call *call =trace_probe_event_call (&tu->tp);WARN_ON (call != trace_file->event_call); - ucb =prepare_uprobe_buffer (tu, regs, ucbp);if (WARN_ON_ONCE (ucb->dsize >PAGE_SIZE ))return ;
@@ -1014,13 +1012,16 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs, struct uprobe_cpu_buffer **ucbp) {struct event_file_link *link; +struct uprobe_cpu_buffer *ucb;if (is_ret_probe (tu))return 0 ; + ucb =prepare_uprobe_buffer (tu, regs, ucbp); +rcu_read_lock ();trace_probe_for_each_link_rcu (link, &tu->tp) -__uprobe_trace_func (tu,0 , regs, ucbp, link->file); +__uprobe_trace_func (tu,0 , regs, ucb, link->file);rcu_read_unlock ();return 0 ;
@@ -1031,10 +1032,13 @@ static void uretprobe_trace_func(struct trace_uprobe *tu, unsigned long func, struct uprobe_cpu_buffer **ucbp) {struct event_file_link *link; +struct uprobe_cpu_buffer *ucb; + + ucb =prepare_uprobe_buffer (tu, regs, ucbp);rcu_read_lock ();trace_probe_for_each_link_rcu (link, &tu->tp) -__uprobe_trace_func (tu, func, regs, ucbp, link->file); +__uprobe_trace_func (tu, func, regs, ucb, link->file);rcu_read_unlock (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 113/208 uprobe: avoid out-of-bounds memory access of fetching args
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiao Ma <[email protected]>
[ Upstream commit 373b9338c9722a368925d83bc622c596896b328e ]
Uprobe needs to fetch args into a percpu buffer, and then copy to ring buffer to avoid non-atomic context problem.
Sometimes user-space strings, arrays can be very large, but the size of percpu buffer is only page size. And store_trace_args() won't check whether these data exceeds a single page or not, caused out-of-bounds memory access.
It could be reproduced by following steps:
1. build kernel with CONFIG_KASAN enabled
2. save follow program as test.c
```
\#include <stdio.h>
\#include <stdlib.h>
\#include <string.h>
// If string length large than MAX_STRING_SIZE, the fetch_store_strlen()
// will return 0, cause __get_data_size() return shorter size, and
// store_trace_args() will not trigger out-of-bounds access.
// So make string length less than 4096.
\#define STRLEN 4093
void generate_string(char *str, int n)
{
int i;
for (i = 0; i < n; ++i)
{
char c = i % 26 + 'a';
str[i] = c;
}
str[n-1] = '\0';
}
void print_string(char *str)
{
printf("%s\n", str);
}
int main()
{
char tmp[STRLEN];
generate_string(tmp, STRLEN);
print_string(tmp);
return 0;
}
```3. compile programgcc -o test test.c
4. get the offset of print_string()
``` objdump -t test | grep -w print_string 0000000000401199 g F .text 000000000000001b print_string ```
5. configure uprobe with offset 0x1199
```
off=0x1199
cd /sys/kernel/debug/tracing/
echo "p /root/test:${off} arg1=+0(%di):ustring arg2=\$comm arg3=+0(%di):ustring"
> uprobe_events
echo 1 > events/uprobes/enable
echo 1 > tracing_on
```6. run test, and kasan will report error.
==================================================================
BUG: KASAN: use-after-free in strncpy_from_user+0x1d6/0x1f0 Write of size 8 at addr ffff88812311c004 by task test/499CPU: 0 UID: 0 PID: 499 Comm: test Not tainted 6.12.0-rc3+ #18 Hardware name: Red Hat KVM, BIOS 1.16.0-4.al8 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x55/0x70 print_address_description.constprop.0+0x27/0x310 kasan_report+0x10f/0x120 ? strncpy_from_user+0x1d6/0x1f0 strncpy_from_user+0x1d6/0x1f0 ? rmqueue.constprop.0+0x70d/0x2ad0 process_fetch_insn+0xb26/0x1470 ? __pfx_process_fetch_insn+0x10/0x10 ? _raw_spin_lock+0x85/0xe0 ? __pfx__raw_spin_lock+0x10/0x10 ? __pte_offset_map+0x1f/0x2d0 ? unwind_next_frame+0xc5f/0x1f80 ? arch_stack_walk+0x68/0xf0 ? is_bpf_text_address+0x23/0x30 ? kernel_text_address.part.0+0xbb/0xd0 ? __kernel_text_address+0x66/0xb0 ? unwind_get_return_address+0x5e/0xa0 ? __pfx_stack_trace_consume_entry+0x10/0x10 ? arch_stack_walk+0xa2/0xf0 ? _raw_spin_lock_irqsave+0x8b/0xf0 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? depot_alloc_stack+0x4c/0x1f0 ? _raw_spin_unlock_irqrestore+0xe/0x30 ? stack_depot_save_flags+0x35d/0x4f0 ? kasan_save_stack+0x34/0x50 ? kasan_save_stack+0x24/0x50 ? mutex_lock+0x91/0xe0 ? __pfx_mutex_lock+0x10/0x10 prepare_uprobe_buffer.part.0+0x2cd/0x500 uprobe_dispatcher+0x2c3/0x6a0 ? __pfx_uprobe_dispatcher+0x10/0x10 ? __kasan_slab_alloc+0x4d/0x90 handler_chain+0xdd/0x3e0 handle_swbp+0x26e/0x3d0 ? __pfx_handle_swbp+0x10/0x10 ? uprobe_pre_sstep_notifier+0x151/0x1b0 irqentry_exit_to_user_mode+0xe2/0x1b0 asm_exc_int3+0x39/0x40 RIP: 0033:0x401199 Code: 01 c2 0f b6 45 fb 88 02 83 45 fc 01 8b 45 fc 3b 45 e4 7c b7 8b 45 e4 48 98 48 8d 50 ff 48 8b 45 e8 48 01 d0 ce RSP: 002b:00007ffdf00576a8 EFLAGS: 00000206 RAX: 00007ffdf00576b0 RBX: 0000000000000000 RCX: 0000000000000ff2 RDX: 0000000000000ffc RSI: 0000000000000ffd RDI: 00007ffdf00576b0 RBP: 00007ffdf00586b0 R08: 00007feb2f9c0d20 R09: 00007feb2f9c0d20 R10: 0000000000000001 R11: 0000000000000202 R12: 0000000000401040 R13: 00007ffdf0058780 R14: 0000000000000000 R15: 0000000000000000 </TASK>
This commit enforces the buffer's maxlen less than a page-size to avoid store_trace_args() out-of-memory access.
--- kernel/trace/trace_uprobe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/trace/trace_uprobe.c +6 -3
@@ -858,6 +858,7 @@ struct uprobe_cpu_buffer { };static struct uprobe_cpu_buffer __percpu *uprobe_cpu_buffer;static int uprobe_buffer_refcnt; +#define MAX_UCB_BUFFER_SIZE PAGE_SIZEstatic int uprobe_buffer_init (void ) {
@@ -962,6 +963,11 @@ static struct uprobe_cpu_buffer *prepare_uprobe_buffer(struct trace_uprobe *tu, ucb =uprobe_buffer_get (); ucb->dsize = tu->tp.size + dsize; +if (WARN_ON_ONCE (ucb->dsize >MAX_UCB_BUFFER_SIZE )) { + ucb->dsize =MAX_UCB_BUFFER_SIZE ; + dsize =MAX_UCB_BUFFER_SIZE - tu->tp.size; + } +store_trace_args (ucb->buf, &tu->tp, regs,NULL , esize, dsize); *ucbp = ucb;
@@ -981,9 +987,6 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,WARN_ON (call != trace_file->event_call); -if (WARN_ON_ONCE (ucb->dsize >PAGE_SIZE )) -return ; -if (trace_trigger_soft_disabled (trace_file))return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 114/208 exec: dont WARN for racy path_noexec check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Guzik <[email protected]>
[ Upstream commit 0d196e7589cefe207d5d41f37a0a28a1fdeeb7c6 ]
Both i_mode and noexec checks wrapped in WARN_ON stem from an artifact of the previous implementation. They used to legitimately check for the condition, but that got moved up in two commits:633fb6ac3980 ("exec: move S_ISREG() check earlier") 0fd338b2d2cd ("exec: move path_noexec() check earlier")
Instead of being removed said checks are WARN_ON'ed instead, which has some debug value.
However, the spurious path_noexec check is racy, resulting in unwarranted warnings should someone race with setting the noexec flag.
One can note there is more to perm-checking whether execve is allowed and none of the conditions are guaranteed to still hold after they were tested for.
Additionally this does not validate whether the code path did any perm checking to begin with -- it will pass if the inode happens to be regular.
Keep the redundant path_noexec() check even though it's mindless nonsense checking for guarantee that isn't given so drop the WARN.
Reword the commentary and do small tidy ups while here.
--- fs/exec.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
fs/exec.c +9 -12
@@ -143,13 +143,11 @@ SYSCALL_DEFINE1(uselib, const char __user *, library) goto out;/* -* may_open() has already checked for this, so it should be -* impossible to trip now. But we need to be extra cautious -* and check again at the very end too. +* Check do_open_execat() for an explanation. */ error = -EACCES ; -if (WARN_ON_ONCE (!S_ISREG (file_inode (file)->i_mode) || -path_noexec (&file->f_path))) +if (WARN_ON_ONCE (!S_ISREG (file_inode (file)->i_mode)) || +path_noexec (&file->f_path)) goto exit; error = -ENOEXEC ;
@@ -925,23 +923,22 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags) file =do_filp_open (fd, name, &open_exec_flags);if (IS_ERR (file)) - goto out; +return file;/* -* may_open() has already checked for this, so it should be -* impossible to trip now. But we need to be extra cautious -* and check again at the very end too. +* In the past the regular type check was here. It moved to may_open() in +* 633fb6ac3980 ("exec: move S_ISREG() check earlier"). Since then it is +* an invariant that all non-regular files error out before we get here. */ err = -EACCES ; -if (WARN_ON_ONCE (!S_ISREG (file_inode (file)->i_mode) || -path_noexec (&file->f_path))) +if (WARN_ON_ONCE (!S_ISREG (file_inode (file)->i_mode)) || +path_noexec (&file->f_path)) goto exit; err =deny_write_access (file);if (err) goto exit; -out:return file; exit:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 115/208 drm/vboxvideo: Replace fake VLA at end of vbva_mouse_pointer_shape with real VLA
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit d92b90f9a54d9300a6e883258e79f36dab53bfae ]
Replace the fake VLA at end of the vbva_mouse_pointer_shape shape with a real VLA to fix a "memcpy: detected field-spanning write error" warning:
[ 13.319813] memcpy: detected field-spanning write (size 16896) of single field "p->data" at drivers/gpu/drm/vboxvideo/hgsmi_base.c:154 (size 4) [ 13.319841] WARNING: CPU: 0 PID: 1105 at drivers/gpu/drm/vboxvideo/hgsmi_base.c:154 hgsmi_update_pointer_shape+0x192/0x1c0 [vboxvideo] [ 13.320038] Call Trace: [ 13.320173] hgsmi_update_pointer_shape [vboxvideo] [ 13.320184] vbox_cursor_atomic_update [vboxvideo]
Note as mentioned in the added comment it seems the original length calculation for the allocated and send hgsmi buffer is 4 bytes too large. Changing this is not the goal of this patch, so this behavior is kept.
--- drivers/gpu/drm/vboxvideo/hgsmi_base.c | 10 +++++++++- drivers/gpu/drm/vboxvideo/vboxvideo.h | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/vboxvideo/hgsmi_base.c +9 -1
@@ -139,7 +139,15 @@ int hgsmi_update_pointer_shape(struct gen_pool *ctx, u32 flags, flags |=VBOX_MOUSE_POINTER_VISIBLE ; } - p =hgsmi_buffer_alloc (ctx,sizeof (*p) + pixel_len,HGSMI_CH_VBVA , +/* +* The 4 extra bytes come from switching struct vbva_mouse_pointer_shape +* from having a 4 bytes fixed array at the end to using a proper VLA +* at the end. These 4 extra bytes were not subtracted from sizeof(*p) +* before the switch to the VLA, so this way the behavior is unchanged. +* Chances are these 4 extra bytes are not necessary but they are kept +* to avoid regressions. +*/ + p =hgsmi_buffer_alloc (ctx,sizeof (*p) + pixel_len +4 ,HGSMI_CH_VBVA ,VBVA_MOUSE_POINTER_SHAPE );if (!p)return -ENOMEM ;
drivers/gpu/drm/vboxvideo/vboxvideo.h +1 -3
@@ -351,10 +351,8 @@ struct vbva_mouse_pointer_shape {* Bytes in the gap between the AND and the XOR mask are undefined. * XOR mask scanlines have no gap between them and size of XOR mask is: * xor_len = width * 4 * height. -* -* Preallocate 4 bytes for accessing actual data as p->data. */ -u8 data[4 ]; +u8 data[]; } __packed;/* pointer is visible */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 116/208 ASoC: amd: yc: Add quirk for HP Dragonfly pro one
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lawrence Glanzman <[email protected]>
[ Upstream commit 84e8d59651879b2ff8499bddbbc9549b7f1a646b ]
Adds a quirk entry to enable the mic on HP Dragonfly pro one laptop
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -444,6 +444,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_BOARD_NAME, "8A3E"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"HP" ), + DMI_MATCH(DMI_BOARD_NAME, "8A7F"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 117/208 ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Klimov <[email protected]>
[ Upstream commit e249786b2188107a7c50e7174d35f955a60988a1 ]
CDC_RX_BCL_VBAT_RF_PROC1 is listed twice and its default value is 0x2a which is overwriten by its next occurence in rx_defaults[]. The second one should be missing CDC_RX_BCL_VBAT_RF_PROC2 instead and its default value is expected 0x0.
--- sound/soc/codecs/lpass-rx-macro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/lpass-rx-macro.c +1 -1
@@ -909,7 +909,7 @@ static const struct reg_default rx_defaults[] = { { CDC_RX_BCL_VBAT_PK_EST2, 0x01 }, { CDC_RX_BCL_VBAT_PK_EST3, 0x40 }, { CDC_RX_BCL_VBAT_RF_PROC1, 0x2A }, - { CDC_RX_BCL_VBAT_RF_PROC1, 0x00 }, + { CDC_RX_BCL_VBAT_RF_PROC2, 0x00 }, { CDC_RX_BCL_VBAT_TAC1, 0x00 }, { CDC_RX_BCL_VBAT_TAC2, 0x18 }, { CDC_RX_BCL_VBAT_TAC3, 0x18 },
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 118/208 ASoC: fsl_sai: Enable FIFO continue on error FCONT bit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 72455e33173c1a00c0ce93d2b0198eb45d5f4195 ]
FCONT=1 means On FIFO error, the SAI will continue from the same word that caused the FIFO error to set after the FIFO warning flag has been cleared.
Set FCONT bit in control register to avoid the channel swap issue after SAI xrun.
--- sound/soc/fsl/fsl_sai.c | 5 ++++- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl_sai.c +4 -1
@@ -604,6 +604,9 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, val_cr4 |=FSL_SAI_CR4_FRSZ (slots); +/* Set to avoid channel swap */ + val_cr4 |=FSL_SAI_CR4_FCONT ; +/* Set to output mode to avoid tri-stated data pins */ if (tx) val_cr4 |=FSL_SAI_CR4_CHMOD ;
@@ -690,7 +693,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,regmap_update_bits (sai->regmap,FSL_SAI_xCR4 (tx, ofs),FSL_SAI_CR4_SYWD_MASK |FSL_SAI_CR4_FRSZ_MASK | -FSL_SAI_CR4_CHMOD_MASK , +FSL_SAI_CR4_CHMOD_MASK |FSL_SAI_CR4_FCONT_MASK , val_cr4); regmap_update_bits(sai->regmap, FSL_SAI_xCR5(tx, ofs), FSL_SAI_CR5_WNW_MASK | FSL_SAI_CR5_W0W_MASK |
sound/soc/fsl/fsl_sai.h +1 -0
@@ -137,6 +137,7 @@/* SAI Transmit and Receive Configuration 4 Register */ +#define FSL_SAI_CR4_FCONT_MASK BIT(28)#define FSL_SAI_CR4_FCONT BIT(28)#define FSL_SAI_CR4_FCOMB_SHIFT BIT(26)#define FSL_SAI_CR4_FCOMB_SOFT BIT(27)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 101/208 xhci: dbc: honor usb transfer size boundaries.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
[ Upstream commit 30c9ae5ece8ecd69d36e6912c2c0896418f2468c ]
Treat each completed full size write to /dev/ttyDBC0 as a separate usb transfer. Make sure the size of the TRBs matches the size of the tty write by first queuing as many max packet size TRBs as possible up to the last TRB which will be cut short to match the size of the tty write.
This solves an issue where userspace writes several transfers back to back via /dev/ttyDBC0 into a kfifo before dbgtty can find available request to turn that kfifo data into TRBs on the transfer ring.
The boundary between transfer was lost as xhci-dbgtty then turned everyting in the kfifo into as many 'max packet size' TRBs as possible.
DbC would then send more data to the host than intended for that transfer, causing host to issue a babble error.
Refuse to write more data to kfifo until previous tty write data is turned into properly sized TRBs with data size boundaries matching tty write size
--- drivers/usb/host/xhci-dbgcap.h | 1 + drivers/usb/host/xhci-dbgtty.c | 55 ++++++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 5 deletions(-)
drivers/usb/host/xhci-dbgcap.h +1 -0
@@ -108,6 +108,7 @@ struct dbc_port {struct tasklet_struct push;struct list_head write_pool; +unsigned int tx_boundary;bool registered; };
drivers/usb/host/xhci-dbgtty.c +50 -5
83 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 119/208 arm64: Force position-independent veneers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
[ Upstream commit 9abe390e689f4f5c23c5f507754f8678431b4f72 ]
Certain portions of code always need to be position-independent regardless of CONFIG_RELOCATABLE, including code which is executed in an idmap or which is executed before relocations are applied. In some kernel configurations the LLD linker generates position-dependent veneers for such code, and when executed these result in early boot-time failures.
Marc Zyngier encountered a boot failure resulting from this when building a (particularly cursed) configuration with LLVM, as he reported to the list:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
In Marc's kernel configuration, the .head.text and .rodata.text sections end up more than 128MiB apart, requiring a veneer to branch between the two:
| [mark@lakrids:~/src/linux]% usekorg 14.1.0 aarch64-linux-objdump -t vmlinux | grep -w _text | ffff800080000000 g .head.text 0000000000000000 _text | [mark@lakrids:~/src/linux]% usekorg 14.1.0 aarch64-linux-objdump -t vmlinux | grep -w primary_entry | ffff8000889df0e0 g .rodata.text 000000000000006c primary_entry,
... consequently, LLD inserts a position-dependent veneer for the branch from _stext (in .head.text) to primary_entry (in .rodata.text):
| ffff800080000000 <_text>: | ffff800080000000: fa405a4d ccmp x18, #0x0, #0xd, pl // pl = nfrst | ffff800080000004: 14003fff b ffff800080010000 <__AArch64AbsLongThunk_primary_entry> ... | ffff800080010000 <__AArch64AbsLongThunk_primary_entry>: | ffff800080010000: 58000050 ldr x16, ffff800080010008 <__AArch64AbsLongThunk_primary_entry+0x8> | ffff800080010004: d61f0200 br x16 | ffff800080010008: 889df0e0 .word 0x889df0e0 | ffff80008001000c: ffff8000 .word 0xffff8000
... and as this is executed early in boot before the kernel is mapped in TTBR1 this results in a silent boot failure.
Fix this by passing '--pic-veneer' to the linker, which will cause the linker to use position-independent veneers, e.g.
| ffff800080000000 <_text>: | ffff800080000000: fa405a4d ccmp x18, #0x0, #0xd, pl // pl = nfrst | ffff800080000004: 14003fff b ffff800080010000 <__AArch64ADRPThunk_primary_entry> ... | ffff800080010000 <__AArch64ADRPThunk_primary_entry>: | ffff800080010000: f004e3f0 adrp x16, ffff800089c8f000 <__idmap_text_start> | ffff800080010004: 91038210 add x16, x16, #0xe0 | ffff800080010008: d61f0200 br x16
I've opted to pass '--pic-veneer' unconditionally, as:
* In addition to solving the boot failure, these sequences are generally nicer as they require fewer instructions and don't need to perform data accesses.
* While the position-independent veneer sequences have a limited +/-2GiB range, this is not a new restriction. Even kernels built with CONFIG_RELOCATABLE=n are limited to 2GiB in size as we have several structues using 32-bit relative offsets and PPREL32 relocations, which are similarly limited to +/-2GiB in range. These include extable entries, jump table entries, and alt_instr entries.
* GNU LD defaults to using position-independent veneers, and supports the same '--pic-veneer' option, so this change is not expected to adversely affect GNU LD.
I've tested with GNU LD 2.30 to 2.42 inclusive and LLVM 13.0.1 to 19.1.0 inclusive, using the kernel.org binaries from:
* https://mirrors.edge.kernel.org/pub/tools/crosstool/
* https://mirrors.edge.kernel.org/pub/tools/llvm/
--- arch/arm64/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/Makefile +1 -1
@@ -10,7 +10,7 @@ # # Copyright (C) 1995-2001 by Russell King -LDFLAGS_vmlinux :=--no-undefined -X +LDFLAGS_vmlinux :=--no-undefined -X --pic-veneer ifeq ($(CONFIG_RELOCATABLE), y) # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 120/208 udf: refactor udf_current_aext() to handle error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Mengmeng <[email protected]>
[ Upstream commit ee703a7068f95764cfb62b57db1d36e465cb9b26 ]
As Jan suggested in links below, refactor udf_current_aext() to differentiate between error, hit EOF and success, it now takes pointer to etype to store the extent type, return 1 when getting etype success, return 0 when hitting EOF and return -errno when err.
--- fs/udf/inode.c | 40 ++++++++++++++++++++++++++-------------- fs/udf/truncate.c | 10 ++++++++-- fs/udf/udfdecl.h | 5 +++-- 3 files changed, 37 insertions(+), 18 deletions(-)
fs/udf/inode.c +26 -14
@@ -1953,6 +1953,7 @@ int udf_setup_indirect_aext(struct inode *inode, udf_pblk_t block,struct extent_position nepos;struct kernel_lb_addr neloc;int ver, adsize; +int err =0 ;if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (struct short_ad );
@@ -1997,10 +1998,12 @@ int udf_setup_indirect_aext(struct inode *inode, udf_pblk_t block,if (epos->offset + adsize > sb->s_blocksize) {struct kernel_lb_addr cp_loc;uint32_t cp_len; -int cp_type; +int8_t cp_type; epos->offset -= adsize; - cp_type =udf_current_aext (inode, epos, &cp_loc, &cp_len,0 ); + err =udf_current_aext (inode, epos, &cp_loc, &cp_len, &cp_type,0 ); +if (err <=0 ) + goto err_out; cp_len |= ((uint32_t )cp_type) <<30 ;__udf_add_aext (inode, &nepos, &cp_loc, cp_len,1 );
@@ -2015,6 +2018,9 @@ int udf_setup_indirect_aext(struct inode *inode, udf_pblk_t block, *epos = nepos;return 0 ; +err_out: +brelse (bh); +return err; }/*
@@ -2165,9 +2171,12 @@ int8_t udf_next_aext(struct inode *inode, struct extent_position *epos, {int8_t etype;unsigned int indirections =0 ; +int ret =0 ; -while ((etype =udf_current_aext (inode, epos, eloc, elen, inc)) == - (EXT_NEXT_EXTENT_ALLOCDESCS >>30 )) { +while ((ret =udf_current_aext (inode, epos, eloc, elen, + &etype, inc)) >0 ) { +if (etype != (EXT_NEXT_EXTENT_ALLOCDESCS >>30 )) +break ;udf_pblk_t block;if (++indirections >UDF_MAX_INDIR_EXTS ) {
@@ -2188,14 +2197,17 @@ int8_t udf_next_aext(struct inode *inode, struct extent_position *epos, } } -return etype; +return ret >0 ? etype :-1 ; } -int8_t udf_current_aext (struct inode *inode,struct extent_position *epos, -struct kernel_lb_addr *eloc,uint32_t *elen,int inc) +/* +* Returns 1 on success, -errno on error, 0 on hit EOF. +*/ +int udf_current_aext (struct inode *inode,struct extent_position *epos, +struct kernel_lb_addr *eloc,uint32_t *elen,int8_t *etype, +int inc) {int alen; -int8_t etype;uint8_t *ptr;struct short_ad *sad;struct long_ad *lad;
@@ -2222,8 +2234,8 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,case ICBTAG_FLAG_AD_SHORT : sad =udf_get_fileshortad (ptr, alen, &epos->offset, inc);if (!sad) -return -1 ; - etype =le32_to_cpu (sad->extLength) >>30 ; +return 0 ; + *etype =le32_to_cpu (sad->extLength) >>30 ; eloc->logicalBlockNum =le32_to_cpu (sad->extPosition); eloc->partitionReferenceNum = iinfo->i_location.partitionReferenceNum;
@@ -2232,17 +2244,17 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,case ICBTAG_FLAG_AD_LONG : lad =udf_get_filelongad (ptr, alen, &epos->offset, inc);if (!lad) -return -1 ; - etype =le32_to_cpu (lad->extLength) >>30 ; +return 0 ; + *etype =le32_to_cpu (lad->extLength) >>30 ; *eloc =lelb_to_cpu (lad->extLocation); *elen =le32_to_cpu (lad->extLength) &UDF_EXTENT_LENGTH_MASK ;break ;default :udf_debug ("alloc_type = %u unsupported\n" , iinfo->i_alloc_type); -return -1 ; +return -EINVAL ; } -return etype; +return 1 ; } static int udf_insert_aext(struct inode *inode, struct extent_position epos,
fs/udf/truncate.c +8 -2
@@ -188,6 +188,7 @@ int udf_truncate_extents(struct inode *inode)loff_t byte_offset;int adsize;struct udf_inode_info *iinfo =UDF_I (inode); +int ret =0 ;if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (struct short_ad );
@@ -217,8 +218,8 @@ int udf_truncate_extents(struct inode *inode)else lenalloc -=sizeof (struct allocExtDesc ); -while ((etype =udf_current_aext (inode, &epos, &eloc, - &elen,0 )) !=-1 ) { +while ((ret =udf_current_aext (inode, &epos, &eloc, + &elen, &etype,0 )) >0 ) {if (etype == (EXT_NEXT_EXTENT_ALLOCDESCS >>30 )) {udf_write_aext (inode, &epos, &neloc, nelen,0 );if (indirect_ext_len) {
@@ -253,6 +254,11 @@ int udf_truncate_extents(struct inode *inode) } } +if (ret <0 ) { +brelse (epos.bh); +return ret; + } +if (indirect_ext_len) {BUG_ON (!epos.bh);udf_free_blocks (sb,NULL , &epos.block,0 , indirect_ext_len);
fs/udf/udfdecl.h +3 -2
@@ -171,8 +171,9 @@ extern void udf_write_aext(struct inode *, struct extent_position *,extern int8_t udf_delete_aext (struct inode *,struct extent_position );extern int8_t udf_next_aext (struct inode *,struct extent_position *,struct kernel_lb_addr *,uint32_t *,int ); -extern int8_t udf_current_aext (struct inode *,struct extent_position *, -struct kernel_lb_addr *,uint32_t *,int ); +extern int udf_current_aext (struct inode *inode,struct extent_position *epos, +struct kernel_lb_addr *eloc,uint32_t *elen, +int8_t *etype,int inc);extern void udf_update_extra_perms (struct inode *inode,umode_t mode);/* misc.c */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 121/208 udf: refactor udf_next_aext() to handle error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Mengmeng <[email protected]>
[ Upstream commit b405c1e58b73981da0f8df03b00666b22b9397ae ]
Since udf_current_aext() has error handling, udf_next_aext() should have error handling too. Besides, when too many indirect extents found in one inode, return -EFSCORRUPTED; when reading block failed, return -EIO.
--- fs/udf/balloc.c | 38 +++++++++----- fs/udf/directory.c | 10 +++- fs/udf/inode.c | 125 ++++++++++++++++++++++++++++++--------------- fs/udf/super.c | 3 +- fs/udf/truncate.c | 27 ++++++++-- fs/udf/udfdecl.h | 5 +- 6 files changed, 143 insertions(+), 65 deletions(-)
fs/udf/balloc.c +25 -13
@@ -387,6 +387,7 @@ static void udf_table_free_blocks(struct super_block *sb,struct extent_position oepos, epos;int8_t etype;struct udf_inode_info *iinfo; +int ret =0 ;mutex_lock (&sbi->s_alloc_mutex); iinfo =UDF_I (table);
@@ -400,8 +401,12 @@ static void udf_table_free_blocks(struct super_block *sb, epos.block = oepos.block = iinfo->i_location; epos.bh = oepos.bh =NULL ; -while (count && - (etype =udf_next_aext (table, &epos, &eloc, &elen,1 )) !=-1 ) { +while (count) { + ret =udf_next_aext (table, &epos, &eloc, &elen, &etype,1 ); +if (ret <0 ) + goto error_return; +if (ret ==0 ) +break ;if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == start)) { if ((0x3FFFFFFF - elen) <
@@ -476,11 +481,8 @@ static void udf_table_free_blocks(struct super_block *sb, adsize =sizeof (struct short_ad ); else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) adsize =sizeof (struct long_ad ); - else { -brelse (oepos.bh); -brelse (epos.bh); + else goto error_return; - }if (epos.offset + (2 * adsize) > sb->s_blocksize) {/* Steal a block from the extent being free'd */
@@ -496,10 +498,10 @@ static void udf_table_free_blocks(struct super_block *sb,__udf_add_aext (table, &epos, &eloc, elen,1 ); } +error_return:brelse (epos.bh);brelse (oepos.bh); -error_return:mutex_unlock (&sbi->s_alloc_mutex);return ; }
@@ -515,6 +517,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,struct extent_position epos;int8_t etype =-1 ;struct udf_inode_info *iinfo; +int ret =0 ;if (first_block >= sbi->s_partmaps[partition].s_partition_len)return 0 ;
@@ -533,11 +536,14 @@ static int udf_table_prealloc_blocks(struct super_block *sb, epos.bh =NULL ; eloc.logicalBlockNum =0xFFFFFFFF ; -while (first_block != eloc.logicalBlockNum && - (etype =udf_next_aext (table, &epos, &eloc, &elen,1 )) !=-1 ) { +while (first_block != eloc.logicalBlockNum) { + ret =udf_next_aext (table, &epos, &eloc, &elen, &etype,1 ); +if (ret <0 ) + goto err_out; +if (ret ==0 ) +break ;udf_debug ("eloc=%u, elen=%u, first_block=%u\n" , eloc.logicalBlockNum, elen, first_block); - ;/* empty loop body */ }if (first_block == eloc.logicalBlockNum) {
@@ -556,6 +562,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb, alloc_count =0 ; } +err_out:brelse (epos.bh);if (alloc_count)
@@ -577,6 +584,7 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb,struct extent_position epos, goal_epos;int8_t etype;struct udf_inode_info *iinfo =UDF_I (table); +int ret =0 ; *err = -ENOSPC ;
@@ -600,8 +608,10 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb, epos.block = iinfo->i_location; epos.bh = goal_epos.bh =NULL ; -while (spread && - (etype =udf_next_aext (table, &epos, &eloc, &elen,1 )) !=-1 ) { +while (spread) { + ret =udf_next_aext (table, &epos, &eloc, &elen, &etype,1 ); +if (ret <=0 ) +break ;if (goal >= eloc.logicalBlockNum) {if (goal < eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits))
@@ -629,9 +639,11 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb,brelse (epos.bh); -if (spread ==0xFFFFFFFF ) { +if (ret <0 || spread ==0xFFFFFFFF ) {brelse (goal_epos.bh);mutex_unlock (&sbi->s_alloc_mutex); +if (ret <0 ) + *err = ret;return 0 ; }
fs/udf/directory.c +8 -2
@@ -166,13 +166,19 @@ static struct buffer_head *udf_fiiter_bread_blk(struct udf_fileident_iter *iter)*/ static int udf_fiiter_advance_blk (struct udf_fileident_iter *iter) { +int8_t etype =-1 ; +int err =0 ; + iter->loffset++;if (iter->loffset <DIV_ROUND_UP (iter->elen,1 <<iter->dir->i_blkbits))return 0 ; iter->loffset =0 ; -if (udf_next_aext (iter->dir, &iter->epos, &iter->eloc, &iter->elen,1 ) - != (EXT_RECORDED_ALLOCATED >>30 )) { + err =udf_next_aext (iter->dir, &iter->epos, &iter->eloc, + &iter->elen, &etype,1 ); +if (err <0 ) +return err; +else if (err ==0 || etype != (EXT_RECORDED_ALLOCATED >>30 )) {if (iter->pos == iter->dir->i_size) { iter->elen =0 ;return 0 ;
fs/udf/inode.c +83 -42
277 lines not on this page · raw message
fs/udf/super.c +2 -1
@@ -2454,13 +2454,14 @@ static unsigned int udf_count_free_table(struct super_block *sb,uint32_t elen;struct kernel_lb_addr eloc;struct extent_position epos; +int8_t etype;mutex_lock (&UDF_SB (sb)->s_alloc_mutex); epos.block =UDF_I (table)->i_location; epos.offset =sizeof (struct unallocSpaceEntry ); epos.bh =NULL ; -while (udf_next_aext (table, &epos, &eloc, &elen,1 ) !=-1 ) +while (udf_next_aext (table, &epos, &eloc, &elen, &etype,1 ) >0 ) accum += (elen >> table->i_sb->s_blocksize_bits);brelse (epos.bh);
fs/udf/truncate.c +22 -5
@@ -69,6 +69,7 @@ void udf_truncate_tail_extent(struct inode *inode)int8_t etype =-1 , netype;int adsize;struct udf_inode_info *iinfo =UDF_I (inode); +int ret;if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB || inode->i_size == iinfo->i_lenExtents)
@@ -85,7 +86,10 @@ void udf_truncate_tail_extent(struct inode *inode)BUG ();/* Find the last extent in the file */ -while ((netype =udf_next_aext (inode, &epos, &eloc, &elen,1 )) !=-1 ) { +while (1 ) { + ret =udf_next_aext (inode, &epos, &eloc, &elen, &netype,1 ); +if (ret <=0 ) +break ; etype = netype; lbcount += elen;if (lbcount > inode->i_size) {
@@ -101,7 +105,8 @@ void udf_truncate_tail_extent(struct inode *inode) epos.offset -= adsize;extent_trunc (inode, &epos, &eloc, etype, elen, nelen); epos.offset += adsize; -if (udf_next_aext (inode, &epos, &eloc, &elen,1 ) !=-1 ) +if (udf_next_aext (inode, &epos, &eloc, &elen, + &netype,1 ) >0 )udf_err (inode->i_sb,"Extent after EOF in inode %u\n" , (unsigned )inode->i_ino);
@@ -110,7 +115,8 @@ void udf_truncate_tail_extent(struct inode *inode) }/* This inode entry is in-memory only and thus we don't have to mark * the inode dirty */ - iinfo->i_lenExtents = inode->i_size; +if (ret ==0 ) + iinfo->i_lenExtents = inode->i_size;brelse (epos.bh); }
@@ -124,6 +130,8 @@ void udf_discard_prealloc(struct inode *inode)int8_t etype =-1 ;struct udf_inode_info *iinfo =UDF_I (inode);int bsize =i_blocksize (inode); +int8_t tmpetype =-1 ; +int ret;if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ||ALIGN (inode->i_size, bsize) ==ALIGN (iinfo->i_lenExtents, bsize))
@@ -132,15 +140,23 @@ void udf_discard_prealloc(struct inode *inode) epos.block = iinfo->i_location;/* Find the last extent in the file */ -while (udf_next_aext (inode, &epos, &eloc, &elen,0 ) !=-1 ) { +while (1 ) { + ret =udf_next_aext (inode, &epos, &eloc, &elen, &tmpetype,0 ); +if (ret <0 ) + goto out; +if (ret ==0 ) +break ;brelse (prev_epos.bh); prev_epos = epos;if (prev_epos.bh)get_bh (prev_epos.bh); - etype =udf_next_aext (inode, &epos, &eloc, &elen,1 ); + ret =udf_next_aext (inode, &epos, &eloc, &elen, &etype,1 ); +if (ret <0 ) + goto out; lbcount += elen; } +if (etype == (EXT_NOT_RECORDED_ALLOCATED >>30 )) { lbcount -= elen;udf_delete_aext (inode, prev_epos);
@@ -150,6 +166,7 @@ void udf_discard_prealloc(struct inode *inode)/* This inode entry is in-memory only and thus we don't have to mark * the inode dirty */ iinfo->i_lenExtents = lbcount; +out:brelse (epos.bh);brelse (prev_epos.bh); }
fs/udf/udfdecl.h +3 -2
@@ -169,8 +169,9 @@ extern int udf_add_aext(struct inode *, struct extent_position *,extern void udf_write_aext (struct inode *,struct extent_position *,struct kernel_lb_addr *,uint32_t ,int );extern int8_t udf_delete_aext (struct inode *,struct extent_position ); -extern int8_t udf_next_aext (struct inode *,struct extent_position *, -struct kernel_lb_addr *,uint32_t *,int ); +extern int udf_next_aext (struct inode *inode,struct extent_position *epos, +struct kernel_lb_addr *eloc,uint32_t *elen, +int8_t *etype,int inc);extern int udf_current_aext (struct inode *inode,struct extent_position *epos,struct kernel_lb_addr *eloc,uint32_t *elen,int8_t *etype,int inc);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 122/208 udf: refactor inode_bmap() to handle error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Mengmeng <[email protected]>
[ Upstream commit c226964ec786f3797ed389a16392ce4357697d24 ]
Refactor inode_bmap() to handle error since udf_next_aext() can return error now. On situations like ftruncate, udf_extend_file() can now detect errors and bail out early without resorting to checking for particular offsets and assuming internal behavior of these functions.
--- fs/udf/directory.c | 13 ++++++++----- fs/udf/inode.c | 40 +++++++++++++++++++++++++--------------- fs/udf/partition.c | 6 ++++-- fs/udf/truncate.c | 6 ++++-- fs/udf/udfdecl.h | 5 +++-- 5 files changed, 44 insertions(+), 26 deletions(-)
fs/udf/directory.c +8 -5
@@ -246,6 +246,7 @@ int udf_fiiter_init(struct udf_fileident_iter *iter, struct inode *dir, {struct udf_inode_info *iinfo =UDF_I (dir);int err =0 ; +int8_t etype; iter->dir = dir; iter->bh[0 ] = iter->bh[1 ] =NULL ;
@@ -265,9 +266,9 @@ int udf_fiiter_init(struct udf_fileident_iter *iter, struct inode *dir, goto out; } -if (inode_bmap (dir, iter->pos >> dir->i_blkbits, &iter->epos, - &iter->eloc, &iter->elen, &iter->loffset) != - (EXT_RECORDED_ALLOCATED >>30 )) { + err =inode_bmap (dir, iter->pos >> dir->i_blkbits, &iter->epos, + &iter->eloc, &iter->elen, &iter->loffset, &etype); +if (err <=0 || etype != (EXT_RECORDED_ALLOCATED >>30 )) {if (pos == dir->i_size)return 0 ; udf_err(dir->i_sb,
@@ -463,6 +464,7 @@ int udf_fiiter_append_blk(struct udf_fileident_iter *iter)sector_t block;uint32_t old_elen = iter->elen;int err; +int8_t etype;if (WARN_ON_ONCE (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ))return -EINVAL ;
@@ -477,8 +479,9 @@ int udf_fiiter_append_blk(struct udf_fileident_iter *iter)udf_fiiter_update_elen (iter, old_elen);return err; } -if (inode_bmap (iter->dir, block, &iter->epos, &iter->eloc, &iter->elen, - &iter->loffset) != (EXT_RECORDED_ALLOCATED >>30 )) { + err =inode_bmap (iter->dir, block, &iter->epos, &iter->eloc, &iter->elen, + &iter->loffset, &etype); +if (err <=0 || etype != (EXT_RECORDED_ALLOCATED >>30 )) {udf_err (iter->dir->i_sb,"block %llu not allocated in directory (ino %lu)\n" , (unsigned long long )block, iter->dir->i_ino);
fs/udf/inode.c +25 -15
@@ -408,7 +408,7 @@ struct udf_map_rq {static int udf_map_block (struct inode *inode,struct udf_map_rq *map) { -int err; +int ret;struct udf_inode_info *iinfo =UDF_I (inode);if (WARN_ON_ONCE (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ))
@@ -420,18 +420,24 @@ static int udf_map_block(struct inode *inode, struct udf_map_rq *map)uint32_t elen;sector_t offset;struct extent_position epos = {}; +int8_t etype;down_read (&iinfo->i_data_sem); -if (inode_bmap (inode, map->lblk, &epos, &eloc, &elen, &offset) - == (EXT_RECORDED_ALLOCATED >>30 )) { + ret =inode_bmap (inode, map->lblk, &epos, &eloc, &elen, &offset, + &etype); +if (ret <0 ) + goto out_read; +if (ret >0 && etype == (EXT_RECORDED_ALLOCATED >>30 )) { map->pblk =udf_get_lb_pblock (inode->i_sb, &eloc, offset); map->oflags |=UDF_BLK_MAPPED ; + ret =0 ; } +out_read:up_read (&iinfo->i_data_sem);brelse (epos.bh); -return 0 ; +return ret; }down_write (&iinfo->i_data_sem);
@@ -442,9 +448,9 @@ static int udf_map_block(struct inode *inode, struct udf_map_rq *map)if (((loff_t )map->lblk) << inode->i_blkbits >= iinfo->i_lenExtents)udf_discard_prealloc (inode);udf_clear_extent_cache (inode); - err =inode_getblk (inode, map); + ret =inode_getblk (inode, map);up_write (&iinfo->i_data_sem); -return err; +return ret; } static int __udf_get_block(struct inode *inode, sector_t block,
@@ -666,8 +672,10 @@ static int udf_extend_file(struct inode *inode, loff_t newsize)*/ udf_discard_prealloc (inode); - etype =inode_bmap (inode, first_block, &epos, &eloc, &elen, &offset); - within_last_ext = (etype !=-1 ); + err =inode_bmap (inode, first_block, &epos, &eloc, &elen, &offset, &etype); +if (err <0 ) + goto out; + within_last_ext = (err ==1 );/* We don't expect extents past EOF... */ WARN_ON_ONCE (within_last_ext && elen > ((loff_t )offset +1 ) << inode->i_blkbits);
@@ -2401,13 +2409,15 @@ int8_t udf_delete_aext(struct inode *inode, struct extent_position epos)return (elen >>30 ); } -int8_t inode_bmap (struct inode *inode,sector_t block, -struct extent_position *pos,struct kernel_lb_addr *eloc, -uint32_t *elen,sector_t *offset) +/* +* Returns 1 on success, -errno on error, 0 on hit EOF. +*/ +int inode_bmap (struct inode *inode,sector_t block,struct extent_position *pos, +struct kernel_lb_addr *eloc,uint32_t *elen,sector_t *offset, +int8_t *etype) {unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits;loff_t lbcount =0 , bcount = (loff_t ) block << blocksize_bits; -int8_t etype;struct udf_inode_info *iinfo;int err =0 ;
@@ -2419,13 +2429,13 @@ int8_t inode_bmap(struct inode *inode, sector_t block, } *elen =0 ;do { - err =udf_next_aext (inode, pos, eloc, elen, &etype,1 ); + err =udf_next_aext (inode, pos, eloc, elen, etype,1 );if (err <=0 ) {if (err ==0 ) { *offset = (bcount - lbcount) >> blocksize_bits; iinfo->i_lenExtents = lbcount; } -return -1 ; +return err; } lbcount += *elen; }while (lbcount <= bcount);
@@ -2433,5 +2443,5 @@ int8_t inode_bmap(struct inode *inode, sector_t block,udf_update_extent_cache (inode, lbcount - *elen, pos); *offset = (bcount + *elen - lbcount) >> blocksize_bits; -return etype; +return 1 ; }
fs/udf/partition.c +4 -2
@@ -282,9 +282,11 @@ static uint32_t udf_try_read_meta(struct inode *inode, uint32_t block,sector_t ext_offset;struct extent_position epos = {};uint32_t phyblock; +int8_t etype; +int err =0 ; -if (inode_bmap (inode, block, &epos, &eloc, &elen, &ext_offset) != - (EXT_RECORDED_ALLOCATED >>30 )) + err =inode_bmap (inode, block, &epos, &eloc, &elen, &ext_offset, &etype); +if (err <=0 || etype != (EXT_RECORDED_ALLOCATED >>30 )) phyblock =0xFFFFFFFF ;else { map = &UDF_SB (sb)->s_partmaps[partition];
fs/udf/truncate.c +4 -2
@@ -214,10 +214,12 @@ int udf_truncate_extents(struct inode *inode)else BUG (); - etype =inode_bmap (inode, first_block, &epos, &eloc, &elen, &offset); + ret =inode_bmap (inode, first_block, &epos, &eloc, &elen, &offset, &etype); +if (ret <0 ) +return ret; byte_offset = (offset << sb->s_blocksize_bits) + (inode->i_size & (sb->s_blocksize -1 )); -if (etype ==-1 ) { +if (ret ==0 ) {/* We should extend the file? */ WARN_ON (byte_offset);return 0 ;
fs/udf/udfdecl.h +3 -2
@@ -157,8 +157,9 @@ extern struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block,extern int udf_setsize (struct inode *,loff_t );extern void udf_evict_inode (struct inode *);extern int udf_write_inode (struct inode *,struct writeback_control *wbc); -extern int8_t inode_bmap (struct inode *,sector_t ,struct extent_position *, -struct kernel_lb_addr *,uint32_t *,sector_t *); +extern int inode_bmap (struct inode *inode,sector_t block, +struct extent_position *pos,struct kernel_lb_addr *eloc, +uint32_t *elen,sector_t *offset,int8_t *etype);int udf_get_block (struct inode *,sector_t ,struct buffer_head *,int );extern int udf_setup_indirect_aext (struct inode *inode,udf_pblk_t block,struct extent_position *epos);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 123/208 udf: fix uninit-value use in udf_get_fileshortad
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gianfranco Trad <[email protected]>
[ Upstream commit 264db9d666ad9a35075cc9ed9ec09d021580fbb1 ]
Check for overflow when computing alen in udf_current_aext to mitigate later uninit-value use in udf_get_fileshortad KMSAN bug[1]. After applying the patch reproducer did not trigger any issue[2].
[1] https://syzkaller.appspot.com/bug?extid=8901c4560b7ab5c2f9df
[2] https://syzkaller.appspot.com/x/log.txt?x=10242227980000
--- fs/udf/inode.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/udf/inode.c +6 -3
@@ -2255,12 +2255,15 @@ int udf_current_aext(struct inode *inode, struct extent_position *epos, alen =udf_file_entry_alloc_offset (inode) + iinfo->i_lenAlloc; }else { +struct allocExtDesc *header = + (struct allocExtDesc *)epos->bh->b_data; +if (!epos->offset) epos->offset =sizeof (struct allocExtDesc ); ptr = epos->bh->b_data + epos->offset; - alen =sizeof (struct allocExtDesc ) + -le32_to_cpu (((struct allocExtDesc *)epos->bh->b_data)-> - lengthAllocDescs); +if (check_add_overflow (sizeof (struct allocExtDesc ), +le32_to_cpu (header->lengthAllocDescs), &alen)) +return -1 ; }switch (iinfo->i_alloc_type) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 124/208 ASoC: qcom: sm8250: add qrb4210-rb2-sndcard compatible string
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Klimov <[email protected]>
[ Upstream commit b97bc0656a66f89f78098d4d72dc04fa9518ab11 ]
Add "qcom,qrb4210-rb2-sndcard" to the list of recognizable devices.
--- sound/soc/qcom/sm8250.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/qcom/sm8250.c +1 -0
@@ -153,6 +153,7 @@ static int sm8250_platform_probe(struct platform_device *pdev)static const struct of_device_id snd_sm8250_dt_match[] = { {.compatible ="qcom,sm8250-sndcard" }, + {.compatible ="qcom,qrb4210-rb2-sndcard" }, {.compatible ="qcom,qrb5165-rb5-sndcard" }, {} };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 125/208 cifs: Validate content of NFS reparse point buffer
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pali Rohár <[email protected]>
[ Upstream commit 556ac52bb1e76cc28fd30aa117b42989965b3efd ]
Symlink target location stored in DataBuffer is encoded in UTF-16. So check that symlink DataBuffer length is non-zero and even number. And check that DataBuffer does not contain UTF-16 null codepoint because Linux cannot process symlink with null byte.
DataBuffer for char and block devices is 8 bytes long as it contains two 32-bit numbers (major and minor). Add check for this.
DataBuffer buffer for sockets and fifos zero-length. Add checks for this.
--- fs/smb/client/reparse.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
fs/smb/client/reparse.c +23 -0
@@ -330,6 +330,18 @@ static int parse_reparse_posix(struct reparse_posix_data *buf,switch ((type =le64_to_cpu (buf->InodeType))) {case NFS_SPECFILE_LNK : +if (len ==0 || (len %2 )) { +cifs_dbg (VFS ,"srv returned malformed nfs symlink buffer\n" ); +return -EIO ; + } +/* +* Check that buffer does not contain UTF-16 null codepoint +* because Linux cannot process symlink with null byte. +*/ +if (UniStrnlen ((wchar_t *)buf->DataBuffer, len/2 ) != len/2 ) { +cifs_dbg (VFS ,"srv returned null byte in nfs symlink target location\n" ); +return -EIO ; + } data->symlink_target =cifs_strndup_from_utf16 (buf->DataBuffer, len, true, cifs_sb->local_nls);
@@ -340,8 +352,19 @@ static int parse_reparse_posix(struct reparse_posix_data *buf,break ;case NFS_SPECFILE_CHR :case NFS_SPECFILE_BLK : +/* DataBuffer for block and char devices contains two 32-bit numbers */ +if (len !=8 ) { +cifs_dbg (VFS ,"srv returned malformed nfs buffer for type: 0x%llx\n" , type); +return -EIO ; + } +break ;case NFS_SPECFILE_FIFO :case NFS_SPECFILE_SOCK : +/* DataBuffer for fifos and sockets is empty */ +if (len !=0 ) { +cifs_dbg (VFS ,"srv returned malformed nfs buffer for type: 0x%llx\n" , type); +return -EIO ; + }break ;default : cifs_dbg(VFS, "%s: unhandled inode type: 0x%llx\n",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 126/208 platform/x86: dell-sysman: add support for alienware products
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Crag Wang <[email protected]>
[ Upstream commit a561509b4187a8908eb7fbb2d1bf35bbc20ec74b ]
Alienware supports firmware-attributes and has its own OEM string.
--- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +1 -0
@@ -521,6 +521,7 @@ static int __init sysman_init(void)int ret =0 ;if (!dmi_find_device (DMI_DEV_TYPE_OEM_STRING ,"Dell System" ,NULL ) && + !dmi_find_device (DMI_DEV_TYPE_OEM_STRING ,"Alienware" ,NULL ) && !dmi_find_device (DMI_DEV_TYPE_OEM_STRING ,"www.dell.com" ,NULL )) {pr_err ("Unable to run on non-Dell system\n" );return -ENODEV ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 127/208 LoongArch: Dont crash in stack_top() for tasks without vDSO
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 134475a9ab8487527238d270639a8cb74c10aab2 ]
Not all tasks have a vDSO mapped, for example kthreads never do. If such a task ever ends up calling stack_top(), it will derefence the NULL vdso pointer and crash.
This can for example happen when using kunit:
[<9000000000203874>] stack_top+0x58/0xa8 [<90000000002956cc>] arch_pick_mmap_layout+0x164/0x220 [<90000000003c284c>] kunit_vm_mmap_init+0x108/0x12c [<90000000003c1fbc>] __kunit_add_resource+0x38/0x8c [<90000000003c2704>] kunit_vm_mmap+0x88/0xc8 [<9000000000410b14>] usercopy_test_init+0xbc/0x25c [<90000000003c1db4>] kunit_try_run_case+0x5c/0x184 [<90000000003c3d54>] kunit_generic_run_threadfn_adapter+0x24/0x48 [<900000000022e4bc>] kthread+0xc8/0xd4 [<9000000000200ce8>] ret_from_kernel_thread+0xc/0xa4
--- arch/loongarch/kernel/process.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/loongarch/kernel/process.c +9 -7
@@ -293,13 +293,15 @@ unsigned long stack_top(void) {unsigned long top =TASK_SIZE &PAGE_MASK ; -/* Space for the VDSO & data page */ - top -=PAGE_ALIGN (current->thread.vdso->size); - top -=VVAR_SIZE ; - -/* Space to randomize the VDSO base */ -if (current->flags &PF_RANDOMIZE ) - top -=VDSO_RANDOMIZE_SIZE ; +if (current->thread.vdso) { +/* Space for the VDSO & data page */ + top -=PAGE_ALIGN (current->thread.vdso->size); + top -=VVAR_SIZE ; + +/* Space to randomize the VDSO base */ +if (current->flags &PF_RANDOMIZE ) + top -=VDSO_RANDOMIZE_SIZE ; + }return top; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 128/208 jfs: Fix sanity check in dbMount
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Kleikamp <[email protected]>
[ Upstream commit 67373ca8404fe57eb1bb4b57f314cff77ce54932 ]
MAXAG is a legitimate value for bmp->db_numag
--- fs/jfs/jfs_dmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +1 -1
@@ -187,7 +187,7 @@ int dbMount(struct inode *ipbmap) } bmp->db_numag =le32_to_cpu (dbmp_le->dn_numag); -if (!bmp->db_numag || bmp->db_numag >=MAXAG ) { +if (!bmp->db_numag || bmp->db_numag >MAXAG ) { err = -EINVAL ; goto err_release_metapage; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 102/208 usb: gadget: f_uac2: Replace snprintf() with the safer scnprintf() variant
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit 60034e0aedf507888c4a880f57011bb7f5d7700c ]
There is a general misunderstanding amongst engineers that {v}snprintf() returns the length of the data *actually* encoded into the destination array. However, as per the C99 standard {v}snprintf() really returns the length of the data that *would have been* written if there were enough space for it. This misunderstanding has led to buffer-overruns in the past. It's generally considered safer to use the {v}scnprintf() variants in their place (or even sprintf() in simple cases). So let's do that.
Stable-dep-of: 9499327714de ("usb: gadget: f_uac2: fix return value for UAC2_ATTRIBUTE_STRING store")
--- drivers/usb/gadget/function/f_uac2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/gadget/function/f_uac2.c +3 -3
@@ -2042,7 +2042,7 @@ static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \int result; \ \mutex_lock (&opts->lock); \ - result =snprintf (page,sizeof (opts->name),"%s" , opts->name); \ + result =scnprintf (page,sizeof (opts->name),"%s" , opts->name); \mutex_unlock (&opts->lock); \ \return result; \
@@ -2060,7 +2060,7 @@ static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \ goto end; \ } \ \ - ret =snprintf (opts->name,min (sizeof (opts->name), len), \ + ret =scnprintf (opts->name,min (sizeof (opts->name), len), \"%s" , page); \ \ end: \
@@ -2178,7 +2178,7 @@ static struct usb_function_instance *afunc_alloc_inst(void) opts->req_number =UAC2_DEF_REQ_NUM ; opts->fb_max =FBACK_FAST_MAX ; -snprintf (opts->function_name,sizeof (opts->function_name),"Source/Sink" ); +scnprintf (opts->function_name,sizeof (opts->function_name),"Source/Sink" );return &opts->func_inst; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 129/208 tracing/probes: Fix MAX_TRACE_ARGS limit handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikel Rychliski <[email protected]>
[ Upstream commit 73f35080477e893aa6f4c8d388352b871b288fbc ]
When creating a trace_probe we would set nr_args prior to truncating the arguments to MAX_TRACE_ARGS. However, we would only initialize arguments up to the limit.
This caused invalid memory access when attempting to set up probes with more than 128 fetchargs.
BUG: kernel NULL pointer dereference, address: 0000000000000020 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 UID: 0 PID: 1769 Comm: cat Not tainted 6.11.0-rc7+ #8 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-1.fc39 04/01/2014 RIP: 0010:__set_print_fmt+0x134/0x330
Resolve the issue by applying the MAX_TRACE_ARGS limit earlier. Return an error when there are too many arguments instead of silently truncating.
--- kernel/trace/trace_eprobe.c | 7 ++++++- kernel/trace/trace_fprobe.c | 6 +++++- kernel/trace/trace_kprobe.c | 6 +++++- kernel/trace/trace_uprobe.c | 4 +++- 4 files changed, 19 insertions(+), 4 deletions(-)
kernel/trace/trace_eprobe.c +6 -1
@@ -915,6 +915,11 @@ static int __trace_eprobe_create(int argc, const char *argv[]) } } +if (argc -2 >MAX_TRACE_ARGS ) { + ret = -E2BIG ; + goto error; + } +mutex_lock (&event_mutex); event_call =find_and_get_event (sys_name, sys_event); ep =alloc_event_probe (group, event, event_call, argc -2 );
@@ -940,7 +945,7 @@ static int __trace_eprobe_create(int argc, const char *argv[]) argc -=2 ; argv +=2 ;/* parse arguments */ -for (i =0 ; i < argc && i <MAX_TRACE_ARGS ; i++) { +for (i =0 ; i < argc; i++) {trace_probe_log_set_index (i +2 ); ret =trace_eprobe_tp_update_arg (ep, argv, i);if (ret)
kernel/trace/trace_fprobe.c +5 -1
@@ -1103,6 +1103,10 @@ static int __trace_fprobe_create(int argc, const char *argv[]) argc = new_argc; argv = new_argv; } +if (argc >MAX_TRACE_ARGS ) { + ret = -E2BIG ; + goto out; + }/* setup a probe */ tf = alloc_trace_fprobe(group, event, symbol, tpoint, maxactive,
@@ -1119,7 +1123,7 @@ static int __trace_fprobe_create(int argc, const char *argv[]) (unsigned long)tf->tpoint->probestub);/* parse arguments */ -for (i =0 ; i < argc && i <MAX_TRACE_ARGS ; i++) { +for (i =0 ; i < argc; i++) {trace_probe_log_set_index (i +2 ); ctx.offset =0 ; ret =traceprobe_parse_probe_arg (&tf->tp, i, argv[i], &ctx);
kernel/trace/trace_kprobe.c +5 -1
@@ -932,6 +932,10 @@ static int __trace_kprobe_create(int argc, const char *argv[]) argc = new_argc; argv = new_argv; } +if (argc >MAX_TRACE_ARGS ) { + ret = -E2BIG ; + goto out; + }/* setup a probe */ tk = alloc_trace_kprobe(group, event, addr, symbol, offset, maxactive,
@@ -944,7 +948,7 @@ static int __trace_kprobe_create(int argc, const char *argv[]) }/* parse arguments */ -for (i =0 ; i < argc && i <MAX_TRACE_ARGS ; i++) { +for (i =0 ; i < argc; i++) {trace_probe_log_set_index (i +2 ); ctx.offset =0 ; ret =traceprobe_parse_probe_arg (&tk->tp, i, argv[i], &ctx);
kernel/trace/trace_uprobe.c +3 -1
@@ -556,6 +556,8 @@ static int __trace_uprobe_create(int argc, const char **argv)if (argc <2 )return -ECANCELED ; +if (argc -2 >MAX_TRACE_ARGS ) +return -E2BIG ;if (argv[0 ][1 ] ==':' ) event = &argv[0 ][2 ];
@@ -681,7 +683,7 @@ static int __trace_uprobe_create(int argc, const char **argv) tu->filename = filename;/* parse arguments */ -for (i =0 ; i < argc && i <MAX_TRACE_ARGS ; i++) { +for (i =0 ; i < argc; i++) {struct traceprobe_parse_context ctx = { .flags = (is_return ?TPARG_FL_RETURN :0 ) |TPARG_FL_USER , };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 130/208 tracing: Consider the NULL character when validating the event length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 0b6e2e22cb23105fcb171ab92f0f7516c69c8471 ]
strlen() returns a string length excluding the null byte. If the string length equals to the maximum buffer length, the buffer will have no space for the NULL terminating character.
This commit checks this condition and returns failure for it.
--- kernel/trace/trace_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_probe.c +1 -1
@@ -275,7 +275,7 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup, }trace_probe_log_err (offset,NO_EVENT_NAME );return -EINVAL ; - }else if (len >MAX_EVENT_NAME_LEN ) { + }else if (len >=MAX_EVENT_NAME_LEN ) {trace_probe_log_err (offset,EVENT_TOO_LONG );return -EINVAL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 131/208 xfrm: extract dst lookup parameters into a struct
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eyal Birger <[email protected]>
[ Upstream commit e509996b16728e37d5a909a5c63c1bd64f23b306 ]
Preparation for adding more fields to dst lookup functions without changing their signatures.
Stable-dep-of: b84697210343 ("xfrm: respect ip protocols rules criteria when performing dst lookups")
--- include/net/xfrm.h | 26 +++++++++++++------------- net/ipv4/xfrm4_policy.c | 38 ++++++++++++++++---------------------- net/ipv6/xfrm6_policy.c | 28 +++++++++++++--------------- net/xfrm/xfrm_device.c | 11 ++++++++--- net/xfrm/xfrm_policy.c | 35 +++++++++++++++++++++++------------ 5 files changed, 73 insertions(+), 65 deletions(-)
include/net/xfrm.h +13 -13
@@ -342,20 +342,23 @@ struct xfrm_if_cb {void xfrm_if_register_cb (const struct xfrm_if_cb *ifcb);void xfrm_if_unregister_cb (void ); +struct xfrm_dst_lookup_params { +struct net *net; +int tos; +int oif; +xfrm_address_t *saddr; +xfrm_address_t *daddr; +u32 mark; +}; +struct net_device ;struct xfrm_type ;struct xfrm_dst ;struct xfrm_policy_afinfo {struct dst_ops *dst_ops; -struct dst_entry *(*dst_lookup)(struct net *net, -int tos,int oif, -const xfrm_address_t *saddr, -const xfrm_address_t *daddr, -u32 mark); -int (*get_saddr)(struct net *net,int oif, -xfrm_address_t *saddr, -xfrm_address_t *daddr, -u32 mark); +struct dst_entry *(*dst_lookup)(const struct xfrm_dst_lookup_params *params); +int (*get_saddr)(xfrm_address_t *saddr, +const struct xfrm_dst_lookup_params *params);int (*fill_dst)(struct xfrm_dst *xdst,struct net_device *dev,const struct flowi *fl);
@@ -1728,10 +1731,7 @@ static inline int xfrm_user_policy(struct sock *sk, int optname, }#endif -struct dst_entry *__xfrm_dst_lookup (struct net *net,int tos,int oif, -const xfrm_address_t *saddr, -const xfrm_address_t *daddr, -int family,u32 mark); +struct dst_entry *__xfrm_dst_lookup (int family,const struct xfrm_dst_lookup_params *params);struct xfrm_policy *xfrm_policy_alloc (struct net *net,gfp_t gfp);
net/ipv4/xfrm4_policy.c +16 -22
@@ -17,47 +17,41 @@#include <net/ip.h> #include <net/l3mdev.h> -static struct dst_entry *__xfrm4_dst_lookup (struct net *net,struct flowi4 *fl4, -int tos,int oif, -const xfrm_address_t *saddr, -const xfrm_address_t *daddr, -u32 mark) +static struct dst_entry *__xfrm4_dst_lookup (struct flowi4 *fl4, +const struct xfrm_dst_lookup_params *params) {struct rtable *rt;memset (fl4,0 ,sizeof (*fl4)); - fl4->daddr = daddr->a4; - fl4->flowi4_tos = tos; - fl4->flowi4_l3mdev =l3mdev_master_ifindex_by_index (net, oif); - fl4->flowi4_mark = mark; -if (saddr) - fl4->saddr = saddr->a4; - - rt =__ip_route_output_key (net, fl4); + fl4->daddr = params->daddr->a4; + fl4->flowi4_tos = params->tos; + fl4->flowi4_l3mdev =l3mdev_master_ifindex_by_index (params->net, + params->oif); + fl4->flowi4_mark = params->mark; +if (params->saddr) + fl4->saddr = params->saddr->a4; + + rt =__ip_route_output_key (params->net, fl4);if (!IS_ERR (rt))return &rt->dst;return ERR_CAST (rt); } -static struct dst_entry *xfrm4_dst_lookup (struct net *net,int tos,int oif, -const xfrm_address_t *saddr, -const xfrm_address_t *daddr, -u32 mark) +static struct dst_entry *xfrm4_dst_lookup (const struct xfrm_dst_lookup_params *params) {struct flowi4 fl4; -return __xfrm4_dst_lookup (net, &fl4, tos, oif, saddr, daddr, mark); +return __xfrm4_dst_lookup (&fl4, params); } -static int xfrm4_get_saddr (struct net *net,int oif, -xfrm_address_t *saddr,xfrm_address_t *daddr, -u32 mark) +static int xfrm4_get_saddr (xfrm_address_t *saddr, +const struct xfrm_dst_lookup_params *params) {struct dst_entry *dst;struct flowi4 fl4; - dst =__xfrm4_dst_lookup (net, &fl4,0 , oif,NULL , daddr, mark); + dst =__xfrm4_dst_lookup (&fl4, params);if (IS_ERR (dst))return -EHOSTUNREACH ;
net/ipv6/xfrm6_policy.c +13 -15
@@ -23,23 +23,21 @@#include <net/ip6_route.h> #include <net/l3mdev.h> -static struct dst_entry *xfrm6_dst_lookup (struct net *net,int tos,int oif, -const xfrm_address_t *saddr, -const xfrm_address_t *daddr, -u32 mark) +static struct dst_entry *xfrm6_dst_lookup (const struct xfrm_dst_lookup_params *params) {struct flowi6 fl6;struct dst_entry *dst;int err;memset (&fl6,0 ,sizeof (fl6)); - fl6.flowi6_l3mdev =l3mdev_master_ifindex_by_index (net, oif); - fl6.flowi6_mark = mark; -memcpy (&fl6.daddr, daddr,sizeof (fl6.daddr)); -if (saddr) -memcpy (&fl6.saddr, saddr,sizeof (fl6.saddr)); + fl6.flowi6_l3mdev =l3mdev_master_ifindex_by_index (params->net, + params->oif); + fl6.flowi6_mark = params->mark; +memcpy (&fl6.daddr, params->daddr,sizeof (fl6.daddr)); +if (params->saddr) +memcpy (&fl6.saddr, params->saddr,sizeof (fl6.saddr)); - dst =ip6_route_output (net,NULL , &fl6); + dst =ip6_route_output (params->net,NULL , &fl6); err = dst->error;if (dst->error) {
@@ -50,15 +48,14 @@ static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, int oif,return dst; } -static int xfrm6_get_saddr (struct net *net,int oif, -xfrm_address_t *saddr,xfrm_address_t *daddr, -u32 mark) +static int xfrm6_get_saddr (xfrm_address_t *saddr, +const struct xfrm_dst_lookup_params *params) {struct dst_entry *dst;struct net_device *dev;struct inet6_dev *idev; - dst =xfrm6_dst_lookup (net,0 , oif,NULL , daddr, mark); + dst =xfrm6_dst_lookup (params);if (IS_ERR (dst))return -EHOSTUNREACH ;
@@ -68,7 +65,8 @@ static int xfrm6_get_saddr(struct net *net, int oif,return -EHOSTUNREACH ; } dev = idev->dev; -ipv6_dev_get_saddr (dev_net (dev), dev, &daddr->in6,0 , &saddr->in6); +ipv6_dev_get_saddr (dev_net (dev), dev, ¶ms->daddr->in6,0 , + &saddr->in6);dst_release (dst);return 0 ; }
net/xfrm/xfrm_device.c +8 -3
@@ -263,6 +263,8 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, dev =dev_get_by_index (net, xuo->ifindex);if (!dev) { +struct xfrm_dst_lookup_params params; +if (!(xuo->flags &XFRM_OFFLOAD_INBOUND )) { saddr = &x->props.saddr; daddr = &x->id.daddr;
@@ -271,9 +273,12 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, daddr = &x->props.saddr; } - dst =__xfrm_dst_lookup (net,0 ,0 , saddr, daddr, - x->props.family, -xfrm_smark_get (0 , x)); +memset (¶ms,0 ,sizeof (params)); + params.net = net; + params.saddr = saddr; + params.daddr = daddr; + params.mark =xfrm_smark_get (0 , x); + dst =__xfrm_dst_lookup (x->props.family, ¶ms);if (IS_ERR (dst))return (is_packet_offload) ? -EINVAL :0 ;
net/xfrm/xfrm_policy.c +23 -12
@@ -251,10 +251,8 @@ static const struct xfrm_if_cb *xfrm_if_get_cb(void)return rcu_dereference (xfrm_if_cb); } -struct dst_entry *__xfrm_dst_lookup (struct net *net,int tos,int oif, -const xfrm_address_t *saddr, -const xfrm_address_t *daddr, -int family,u32 mark) +struct dst_entry *__xfrm_dst_lookup (int family, +const struct xfrm_dst_lookup_params *params) {const struct xfrm_policy_afinfo *afinfo;struct dst_entry *dst;
@@ -263,7 +261,7 @@ struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif,if (unlikely (afinfo ==NULL ))return ERR_PTR (-EAFNOSUPPORT ); - dst = afinfo->dst_lookup (net, tos, oif, saddr, daddr, mark); + dst = afinfo->dst_lookup (params);rcu_read_unlock ();
@@ -277,6 +275,7 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,xfrm_address_t *prev_daddr, int family, u32 mark) { + struct xfrm_dst_lookup_params params;struct net *net =xs_net (x);xfrm_address_t *saddr = &x->props.saddr;xfrm_address_t *daddr = &x->id.daddr;
@@ -291,7 +290,14 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x, daddr = x->coaddr; } - dst =__xfrm_dst_lookup (net, tos, oif, saddr, daddr, family, mark); + params.net = net; + params.saddr = saddr; + params.daddr = daddr; + params.tos = tos; + params.oif = oif; + params.mark = mark; + + dst =__xfrm_dst_lookup (family, ¶ms);if (!IS_ERR (dst)) {if (prev_saddr != saddr)
@@ -2424,15 +2430,15 @@ int __xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk) }static int -xfrm_get_saddr (struct net *net,int oif,xfrm_address_t *local, -xfrm_address_t *remote,unsigned short family,u32 mark) +xfrm_get_saddr (unsigned short family,xfrm_address_t *saddr, +const struct xfrm_dst_lookup_params *params) {int err;const struct xfrm_policy_afinfo *afinfo =xfrm_policy_get_afinfo (family);if (unlikely (afinfo ==NULL ))return -EINVAL ; - err = afinfo->get_saddr (net, oif, local, remote, mark); + err = afinfo->get_saddr (saddr, params);rcu_read_unlock ();return err; }
@@ -2461,9 +2467,14 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, const struct flowi *fl, remote = &tmpl->id.daddr; local = &tmpl->saddr;if (xfrm_addr_any (local, tmpl->encap_family)) { - error =xfrm_get_saddr (net, fl->flowi_oif, - &tmp, remote, - tmpl->encap_family,0 ); +struct xfrm_dst_lookup_params params; + +memset (¶ms,0 ,sizeof (params)); + params.net = net; + params.oif = fl->flowi_oif; + params.daddr = remote; + error =xfrm_get_saddr (tmpl->encap_family, &tmp, + ¶ms);if (error) goto fail; local = &tmp;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 132/208 xfrm: respect ip protocols rules criteria when performing dst lookups
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eyal Birger <[email protected]>
[ Upstream commit b8469721034300bbb6dec5b4bf32492c95e16a0c ]
The series in the "fixes" tag added the ability to consider L4 attributes in routing rules.
The dst lookup on the outer packet of encapsulated traffic in the xfrm code was not adapted to this change, thus routing behavior that relies on L4 information is not respected.
Pass the ip protocol information when performing dst lookups.
--- include/net/xfrm.h | 2 ++ net/ipv4/xfrm4_policy.c | 2 ++ net/ipv6/xfrm6_policy.c | 3 +++ net/xfrm/xfrm_policy.c | 15 +++++++++++++++ 4 files changed, 22 insertions(+)
include/net/xfrm.h +2 -0
@@ -349,6 +349,8 @@ struct xfrm_dst_lookup_params {xfrm_address_t *saddr;xfrm_address_t *daddr;u32 mark; +__u8 ipproto; +union flowi_uli uli; };struct net_device ;
net/ipv4/xfrm4_policy.c +2 -0
@@ -30,6 +30,8 @@ static struct dst_entry *__xfrm4_dst_lookup(struct flowi4 *fl4, fl4->flowi4_mark = params->mark;if (params->saddr) fl4->saddr = params->saddr->a4; + fl4->flowi4_proto = params->ipproto; + fl4->uli = params->uli; rt =__ip_route_output_key (params->net, fl4);if (!IS_ERR (rt))
net/ipv6/xfrm6_policy.c +3 -0
@@ -37,6 +37,9 @@ static struct dst_entry *xfrm6_dst_lookup(const struct xfrm_dst_lookup_params *pif (params->saddr)memcpy (&fl6.saddr, params->saddr,sizeof (fl6.saddr)); + fl6.flowi4_proto = params->ipproto; + fl6.uli = params->uli; + dst =ip6_route_output (params->net,NULL , &fl6); err = dst->error;
net/xfrm/xfrm_policy.c +15 -0
@@ -296,6 +296,21 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x, params.tos = tos; params.oif = oif; params.mark = mark; + params.ipproto = x->id.proto; +if (x->encap) { +switch (x->encap->encap_type) { +case UDP_ENCAP_ESPINUDP : + params.ipproto =IPPROTO_UDP ; + params.uli.ports.sport = x->encap->encap_sport; + params.uli.ports.dport = x->encap->encap_dport; +break ; +case TCP_ENCAP_ESPINTCP : + params.ipproto =IPPROTO_TCP ; + params.uli.ports.sport = x->encap->encap_sport; + params.uli.ports.dport = x->encap->encap_dport; +break ; + } + } dst =__xfrm_dst_lookup (family, ¶ms);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 133/208 xfrm: Add Direction to the SA in or out
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antony Antony <[email protected]>
[ Upstream commit a4a87fa4e96c7746e009de06a567688fd9af6013 ]
This patch introduces the 'dir' attribute, 'in' or 'out', to the xfrm_state, SA, enhancing usability by delineating the scope of values based on direction. An input SA will restrict values pertinent to input, effectively segregating them from output-related values.
And an output SA will restrict attributes for output. This change aims to streamline the configuration process and improve the overall consistency of SA attributes during configuration.
This feature sets the groundwork for future patches, including the upcoming IP-TFS patch.
Stable-dep-of: 3f0ab59e6537 ("xfrm: validate new SA's prefixlen using SA family when sel.family is unset")
--- include/net/xfrm.h | 1 + include/uapi/linux/xfrm.h | 6 ++ net/xfrm/xfrm_compat.c | 7 +- net/xfrm/xfrm_device.c | 6 ++ net/xfrm/xfrm_replay.c | 3 +- net/xfrm/xfrm_state.c | 8 +++ net/xfrm/xfrm_user.c | 138 ++++++++++++++++++++++++++++++++++++-- 7 files changed, 160 insertions(+), 9 deletions(-)
include/net/xfrm.h +1 -0
@@ -292,6 +292,7 @@ struct xfrm_state {/* Private data of this transformer, format is opaque, * interpreted by xfrm_type methods. */ void *data; +u8 dir; };static inline struct net *xs_net (struct xfrm_state *x)
include/uapi/linux/xfrm.h +6 -0
@@ -140,6 +140,11 @@ enum {XFRM_POLICY_MAX =3 }; +enum xfrm_sa_dir { +XFRM_SA_DIR_IN =1 , +XFRM_SA_DIR_OUT =2 +}; +enum {XFRM_SHARE_ANY ,/* No limitations */ XFRM_SHARE_SESSION ,/* For this session only */
@@ -314,6 +319,7 @@ enum xfrm_attr_type_t {XFRMA_SET_MARK_MASK ,/* __u32 */ XFRMA_IF_ID ,/* __u32 */ XFRMA_MTIMER_THRESH ,/* __u32 in seconds for input SA */ +XFRMA_SA_DIR ,/* __u8 */ __XFRMA_MAX#define XFRMA_OUTPUT_MARK XFRMA_SET_MARK/* Compatibility */
net/xfrm/xfrm_compat.c +5 -2
@@ -98,6 +98,7 @@ static const int compat_msg_min[XFRM_NR_MSGTYPES] = { };static const struct nla_policy compat_policy[XFRMA_MAX +1 ] = { + [XFRMA_UNSPEC ] = { .strict_start_type =XFRMA_SA_DIR }, [XFRMA_SA ] = { .len =XMSGSIZE (compat_xfrm_usersa_info)}, [XFRMA_POLICY ] = { .len =XMSGSIZE (compat_xfrm_userpolicy_info)}, [XFRMA_LASTUSED ] = { .type =NLA_U64 },
@@ -129,6 +130,7 @@ static const struct nla_policy compat_policy[XFRMA_MAX+1] = { [XFRMA_SET_MARK_MASK] = { .type = NLA_U32 }, [XFRMA_IF_ID] = { .type = NLA_U32 }, [XFRMA_MTIMER_THRESH] = { .type = NLA_U32 }, + [XFRMA_SA_DIR] = NLA_POLICY_RANGE(NLA_U8, XFRM_SA_DIR_IN, XFRM_SA_DIR_OUT), }; static struct nlmsghdr *xfrm_nlmsg_put_compat(struct sk_buff *skb,
@@ -277,9 +279,10 @@ static int xfrm_xlate64_attr(struct sk_buff *dst, const struct nlattr *src)case XFRMA_SET_MARK_MASK :case XFRMA_IF_ID :case XFRMA_MTIMER_THRESH : +case XFRMA_SA_DIR :return xfrm_nla_cpy (dst, src,nla_len (src));default : -BUILD_BUG_ON (XFRMA_MAX !=XFRMA_MTIMER_THRESH ); +BUILD_BUG_ON (XFRMA_MAX !=XFRMA_SA_DIR );pr_warn_once ("unsupported nla_type %d\n" , src->nla_type);return -EOPNOTSUPP ; }
@@ -434,7 +437,7 @@ static int xfrm_xlate32_attr(void *dst, const struct nlattr *nla,int err;if (type >XFRMA_MAX ) { -BUILD_BUG_ON (XFRMA_MAX !=XFRMA_MTIMER_THRESH ); +BUILD_BUG_ON (XFRMA_MAX !=XFRMA_SA_DIR );NL_SET_ERR_MSG (extack,"Bad attribute" );return -EOPNOTSUPP ; }
net/xfrm/xfrm_device.c +6 -0
@@ -253,6 +253,12 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,return -EINVAL ; } +if ((xuo->flags &XFRM_OFFLOAD_INBOUND && x->dir ==XFRM_SA_DIR_OUT ) || + (!(xuo->flags &XFRM_OFFLOAD_INBOUND ) && x->dir ==XFRM_SA_DIR_IN )) { +NL_SET_ERR_MSG (extack,"Mismatched SA and offload direction" ); +return -EINVAL ; + } + is_packet_offload = xuo->flags &XFRM_OFFLOAD_PACKET ;/* We don't yet support UDP encapsulation and TFC padding. */
net/xfrm/xfrm_replay.c +2 -1
@@ -778,7 +778,8 @@ int xfrm_init_replay(struct xfrm_state *x, struct netlink_ext_ack *extack) }if (x->props.flags &XFRM_STATE_ESN ) { -if (replay_esn->replay_window ==0 ) { +if (replay_esn->replay_window ==0 && + (!x->dir || x->dir ==XFRM_SA_DIR_IN )) {NL_SET_ERR_MSG (extack,"ESN replay window must be > 0" );return -EINVAL ; }
net/xfrm/xfrm_state.c +8 -0
@@ -1349,6 +1349,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,if (km_query (x, tmpl, pol) ==0 ) {spin_lock_bh (&net->xfrm.xfrm_state_lock); x->km.state =XFRM_STATE_ACQ ; + x->dir =XFRM_SA_DIR_OUT ;list_add (&x->km.all, &net->xfrm.state_all); XFRM_STATE_INSERT(bydst, &x->bydst, net->xfrm.state_bydst + h,
@@ -1801,6 +1802,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, x->lastused = orig->lastused; x->new_mapping =0 ; x->new_mapping_sport =0 ; + x->dir = orig->dir;return x;
@@ -1921,8 +1923,14 @@ int xfrm_state_update(struct xfrm_state *x) }if (x1->km.state ==XFRM_STATE_ACQ ) { +if (x->dir && x1->dir != x->dir) + goto out; +__xfrm_state_insert (x); x =NULL ; + }else { +if (x1->dir != x->dir) + goto out; } err =0 ;
net/xfrm/xfrm_user.c +132 -6
229 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 134/208 xfrm: validate new SAs prefixlen using SA family when sel.family is unset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 3f0ab59e6537c6a8f9e1b355b48f9c05a76e8563 ]
This expands the validation introduced in commit 07bf7908950a ("xfrm:
Validate address prefix lengths in the xfrm selector.")
syzbot created an SA with
usersa.sel.family = AF_UNSPEC
usersa.sel.prefixlen_s = 128
usersa.family = AF_INET
Because of the AF_UNSPEC selector, verify_newsa_info doesn't put limits on prefixlen_{s,d}. But then copy_from_user_state sets x->sel.family to usersa.family (AF_INET). Do the same conversion in verify_newsa_info before validating prefixlen_{s,d}, since that's how prefixlen is going to be used later on.
--- net/xfrm/xfrm_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +5 -1
@@ -201,6 +201,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, {int err;u8 sa_dir = attrs[XFRMA_SA_DIR ] ?nla_get_u8 (attrs[XFRMA_SA_DIR ]) :0 ; +u16 family = p->sel.family; err = -EINVAL ;switch (p->family) {
@@ -221,7 +222,10 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, goto out; } -switch (p->sel.family) { +if (!family && !(p->flags &XFRM_STATE_AF_UNSPEC )) + family = p->family; + +switch (family) {case AF_UNSPEC :break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 135/208 netfilter: bpf: must hold reference on net namespace
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 1230fe7ad3974f7bf6c78901473e039b34d4fb1f ]
BUG: KASAN: slab-use-after-free in __nf_unregister_net_hook+0x640/0x6b0 Read of size 8 at addr ffff8880106fe400 by task repro/72= bpf_nf_link_release+0xda/0x1e0 bpf_link_free+0x139/0x2d0 bpf_link_release+0x68/0x80 __fput+0x414/0xb60
Eric says:
It seems that bpf was able to defer the __nf_unregister_net_hook() after exit()/close() time.
Perhaps a netns reference is missing, because the netns has been dismantled/freed already.
bpf_nf_link_attach() does :
link->net = net;
But I do not see a reference being taken on net.
Add such a reference and release it after hook unreg. Note that I was unable to get syzbot reproducer to work, so I do not know if this resolves this splat.
--- net/netfilter/nf_bpf_link.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nf_bpf_link.c +4 -0
@@ -23,6 +23,7 @@ static unsigned int nf_hook_run_bpf(void *bpf_prog, struct sk_buff *skb,struct bpf_nf_link {struct bpf_link link;struct nf_hook_ops hook_ops; +netns_tracker ns_tracker;struct net *net;u32 dead;const struct nf_defrag_hook *defrag_hook;
@@ -120,6 +121,7 @@ static void bpf_nf_link_release(struct bpf_link *link)if (!cmpxchg (&nf_link->dead,0 ,1 )) {nf_unregister_net_hook (nf_link->net, &nf_link->hook_ops);bpf_nf_disable_defrag (nf_link); +put_net_track (nf_link->net, &nf_link->ns_tracker); } }
@@ -258,6 +260,8 @@ int bpf_nf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)return err; } +get_net_track (net, &link->ns_tracker,GFP_KERNEL ); +return bpf_link_settle (&link_primer); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 136/208 net/sun3_82586: fix potential memory leak in sun3_82586_send_packet()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Hai <[email protected]>
[ Upstream commit 2cb3f56e827abb22c4168ad0c1bbbf401bb2f3b8 ]
The sun3_82586_send_packet() returns NETDEV_TX_OK without freeing skb in case of skb->len being too long, add dev_kfree_skb() to fix it.
Message-ID: <[email protected]>
--- drivers/net/ethernet/i825xx/sun3_82586.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/i825xx/sun3_82586.c +1 -0
@@ -1012,6 +1012,7 @@ sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)if (skb->len >XMIT_BUFF_SIZE ) {printk ("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n" ,dev->name,XMIT_BUFF_SIZE ,skb->len); +dev_kfree_skb (skb);return NETDEV_TX_OK ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 137/208 be2net: fix potential memory leak in be_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Hai <[email protected]>
[ Upstream commit e4dd8bfe0f6a23acd305f9b892c00899089bd621 ]
The be_xmit() returns NETDEV_TX_OK without freeing skb
in case of be_xmit_enqueue() fails, add dev_kfree_skb_any() to fix it.
Message-ID: <[email protected]>
--- drivers/net/ethernet/emulex/benet/be_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/emulex/benet/be_main.c +5 -5
@@ -1381,10 +1381,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)be_get_wrb_params_from_skb (adapter, skb, &wrb_params); wrb_cnt =be_xmit_enqueue (adapter, txo, skb, &wrb_params); -if (unlikely (!wrb_cnt)) { -dev_kfree_skb_any (skb); - goto drop; - } +if (unlikely (!wrb_cnt)) + goto drop_skb;/* if os2bmc is enabled and if the pkt is destined to bmc, * enqueue the pkt a 2nd time with mgmt bit set.
@@ -1393,7 +1391,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)BE_WRB_F_SET (wrb_params.features,OS2BMC ,1 ); wrb_cnt =be_xmit_enqueue (adapter, txo, skb, &wrb_params);if (unlikely (!wrb_cnt)) - goto drop; + goto drop_skb;else skb_get (skb); }
@@ -1407,6 +1405,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)be_xmit_flush (adapter, txo);return NETDEV_TX_OK ; +drop_skb: +dev_kfree_skb_any (skb); drop:tx_stats (txo)->tx_drv_drops++;/* Flush the already enqueued tx requests */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 138/208 net: plip: fix break; causing plip to never transmit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Boehm <[email protected]>
[ Upstream commit f99cf996ba5a315f8b9f13cc21dff0604a0eb749 ]
Since commit
71ae2cb30531 ("net: plip: Fix fall-through warnings for Clang")
plip was not able to send any packets, this patch replaces one unintended break; with fallthrough; which was originally missed by commit 9525d69a3667 ("net: plip: mark expected switch fall-throughs").
I have verified with a real hardware PLIP connection that everything works once again after applying this patch.
Message-ID: <[email protected]>
--- drivers/net/plip/plip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/plip/plip.c +1 -1
@@ -815,7 +815,7 @@ plip_send_packet(struct net_device *dev, struct net_local *nl,return HS_TIMEOUT ; } } -break ; + fallthrough;case PLIP_PK_LENGTH_LSB : if (plip_send(nibble_timeout, dev,
Signature · 1 line
2.43.0