6.4.4-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 85/800 rcu/rcuscale: Move rcu_scale_*() after kfree_scale_cleanup()
In reply to Greg Kroah-HartmanFrom: Qiuxu Zhuo <[email protected]>
[ Upstream commit bf5ddd736509a7d9077c0b6793e6f0852214dbea ]
This code-movement-only commit moves the rcu_scale_cleanup() and rcu_scale_shutdown() functions to follow kfree_scale_cleanup(). This is code movement is in preparation for a bug-fix patch that invokes kfree_scale_cleanup() from rcu_scale_cleanup().
Stable-dep-of: 23fc8df26dea ("rcu/rcuscale: Stop kfree_scale_thread thread(s) after unloading rcuscale")
--- kernel/rcu/rcuscale.c | 194 +++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 97 deletions(-)
kernel/rcu/rcuscale.c +97 -97
@@ -522,89 +522,6 @@ rcu_scale_print_module_parms(struct rcu_scale_ops *cur_ops, const char *tag) scale_type, tag, nrealreaders, nrealwriters, verbose, shutdown); } -static void -rcu_scale_cleanup (void ) -{ -int i; -int j; -int ngps =0 ; -u64 *wdp; -u64 *wdpp; - -/* -* Would like warning at start, but everything is expedited -* during the mid-boot phase, so have to wait till the end. -*/ -if (rcu_gp_is_expedited () && !rcu_gp_is_normal () && !gp_exp) -SCALEOUT_ERRSTRING ("All grace periods expedited, no normal ones to measure!" ); -if (rcu_gp_is_normal () && gp_exp) -SCALEOUT_ERRSTRING ("All grace periods normal, no expedited ones to measure!" ); -if (gp_exp && gp_async) -SCALEOUT_ERRSTRING ("No expedited async GPs, so went with async!" ); - -if (torture_cleanup_begin ()) -return ; -if (!cur_ops) { -torture_cleanup_end (); -return ; - } - -if (reader_tasks) { -for (i =0 ; i < nrealreaders; i++) -torture_stop_kthread (rcu_scale_reader, - reader_tasks[i]); -kfree (reader_tasks); - } - -if (writer_tasks) { -for (i =0 ; i < nrealwriters; i++) { -torture_stop_kthread (rcu_scale_writer, - writer_tasks[i]); -if (!writer_n_durations) -continue ; - j = writer_n_durations[i]; -pr_alert ("%s%s writer %d gps: %d\n" , - scale_type,SCALE_FLAG , i, j); - ngps += j; - } -pr_alert ("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n" , - scale_type,SCALE_FLAG , - t_rcu_scale_writer_started, t_rcu_scale_writer_finished, - t_rcu_scale_writer_finished - - t_rcu_scale_writer_started, - ngps, -rcuscale_seq_diff (b_rcu_gp_test_finished, - b_rcu_gp_test_started)); -for (i =0 ; i < nrealwriters; i++) { -if (!writer_durations) -break ; -if (!writer_n_durations) -continue ; - wdpp = writer_durations[i]; -if (!wdpp) -continue ; -for (j =0 ; j < writer_n_durations[i]; j++) { - wdp = &wdpp[j]; -pr_alert ("%s%s %4d writer-duration: %5d %llu\n" , - scale_type,SCALE_FLAG , - i, j, *wdp); -if (j %100 ==0 ) -schedule_timeout_uninterruptible (1 ); - } -kfree (writer_durations[i]); - } -kfree (writer_tasks); -kfree (writer_durations); -kfree (writer_n_durations); - } - -/* Do torture-type-specific cleanup operations. */ -if (cur_ops->cleanup !=NULL ) - cur_ops->cleanup (); - -torture_cleanup_end (); -} -/* * Return the number if non-negative. If -1, the number of CPUs. * If less than -1, that much less than the number of CPUs, but
@@ -624,20 +541,6 @@ static int compute_real(int n)return nr; } -/* -* RCU scalability shutdown kthread. Just waits to be awakened, then shuts -* down system. -*/ -static int -rcu_scale_shutdown (void *arg) -{ -wait_event_idle (shutdown_wq,atomic_read (&n_rcu_scale_writer_finished) >= nrealwriters); -smp_mb ();/* Wake before output. */ -rcu_scale_cleanup (); -kernel_power_off (); -return -EINVAL ; -} -/* * kfree_rcu() scalability tests: Start a kfree_rcu() loop on all CPUs for number * of iterations and measure total time and number of GP for all iterations to complete.
@@ -874,6 +777,103 @@ kfree_scale_init(void)return firsterr; } +static void +rcu_scale_cleanup (void ) +{ +int i; +int j; +int ngps =0 ; +u64 *wdp; +u64 *wdpp; + +/* +* Would like warning at start, but everything is expedited +* during the mid-boot phase, so have to wait till the end. +*/ +if (rcu_gp_is_expedited () && !rcu_gp_is_normal () && !gp_exp) +SCALEOUT_ERRSTRING ("All grace periods expedited, no normal ones to measure!" ); +if (rcu_gp_is_normal () && gp_exp) +SCALEOUT_ERRSTRING ("All grace periods normal, no expedited ones to measure!" ); +if (gp_exp && gp_async) +SCALEOUT_ERRSTRING ("No expedited async GPs, so went with async!" ); + +if (torture_cleanup_begin ()) +return ; +if (!cur_ops) { +torture_cleanup_end (); +return ; + } + +if (reader_tasks) { +for (i =0 ; i < nrealreaders; i++) +torture_stop_kthread (rcu_scale_reader, + reader_tasks[i]); +kfree (reader_tasks); + } + +if (writer_tasks) { +for (i =0 ; i < nrealwriters; i++) { +torture_stop_kthread (rcu_scale_writer, + writer_tasks[i]); +if (!writer_n_durations) +continue ; + j = writer_n_durations[i]; +pr_alert ("%s%s writer %d gps: %d\n" , + scale_type,SCALE_FLAG , i, j); + ngps += j; + } +pr_alert ("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n" , + scale_type,SCALE_FLAG , + t_rcu_scale_writer_started, t_rcu_scale_writer_finished, + t_rcu_scale_writer_finished - + t_rcu_scale_writer_started, + ngps, +rcuscale_seq_diff (b_rcu_gp_test_finished, + b_rcu_gp_test_started)); +for (i =0 ; i < nrealwriters; i++) { +if (!writer_durations) +break ; +if (!writer_n_durations) +continue ; + wdpp = writer_durations[i]; +if (!wdpp) +continue ; +for (j =0 ; j < writer_n_durations[i]; j++) { + wdp = &wdpp[j]; +pr_alert ("%s%s %4d writer-duration: %5d %llu\n" , + scale_type,SCALE_FLAG , + i, j, *wdp); +if (j %100 ==0 ) +schedule_timeout_uninterruptible (1 ); + } +kfree (writer_durations[i]); + } +kfree (writer_tasks); +kfree (writer_durations); +kfree (writer_n_durations); + } + +/* Do torture-type-specific cleanup operations. */ +if (cur_ops->cleanup !=NULL ) + cur_ops->cleanup (); + +torture_cleanup_end (); +} + +/* +* RCU scalability shutdown kthread. Just waits to be awakened, then shuts +* down system. +*/ +static int +rcu_scale_shutdown (void *arg) +{ +wait_event_idle (shutdown_wq,atomic_read (&n_rcu_scale_writer_finished) >= nrealwriters); +smp_mb ();/* Wake before output. */ +rcu_scale_cleanup (); +kernel_power_off (); +return -EINVAL ; +} +static int __init rcu_scale_init (void ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 86/800 rcu/rcuscale: Stop kfree_scale_thread thread(s) after unloading rcuscale
In reply to Greg Kroah-HartmanFrom: Qiuxu Zhuo <[email protected]>
[ Upstream commit 23fc8df26dead16687ae6eb47b0561a4a832e2f6 ]
Running the 'kfree_rcu_test' test case [1] results in a splat [2]. The root cause is the kfree_scale_thread thread(s) continue running after unloading the rcuscale module. This commit fixes that isue by invoking kfree_scale_cleanup() from rcu_scale_cleanup() when removing the rcuscale module.
[1] modprobe rcuscale kfree_rcu_test=1
// After some time
rmmod rcuscale
rmmod torture[2] BUG: unable to handle page fault for address: ffffffffc0601a87
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 11de4f067 P4D 11de4f067 PUD 11de51067 PMD 112f4d067 PTE 0
Oops: 0010 [#1] PREEMPT SMP NOPTI
CPU: 1 PID: 1798 Comm: kfree_scale_thr Not tainted 6.3.0-rc1-rcu+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
RIP: 0010:0xffffffffc0601a87
Code: Unable to access opcode bytes at 0xffffffffc0601a5d.
RSP: 0018:ffffb25bc2e57e18 EFLAGS: 00010297
RAX: 0000000000000000 RBX: ffffffffc061f0b6 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff962fd0de RDI: ffffffff962fd0de
RBP: ffffb25bc2e57ea8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000
R13: 0000000000000000 R14: 000000000000000a R15: 00000000001c1dbe
FS: 0000000000000000(0000) GS:ffff921fa2200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffc0601a5d CR3: 000000011de4c006 CR4: 0000000000370ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
? kvfree_call_rcu+0xf0/0x3a0
? kthread+0xf3/0x120
? kthread_complete_and_exit+0x20/0x20
? ret_from_fork+0x1f/0x30
</TASK>
Modules linked in: rfkill sunrpc ... [last unloaded: torture]
CR2: ffffffffc0601a87
---[ end trace 0000000000000000 ]------ kernel/rcu/rcuscale.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/rcu/rcuscale.c +5 -0
@@ -797,6 +797,11 @@ rcu_scale_cleanup(void)if (gp_exp && gp_async)SCALEOUT_ERRSTRING ("No expedited async GPs, so went with async!" ); +if (kfree_rcu_test) { +kfree_scale_cleanup (); +return ; + } +if (torture_cleanup_begin ())return ;if (!cur_ops) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 87/800 x86/mtrr: Remove physical address size calculation
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit f6b980646b93a8c585b4ed991b8a34e8fc6ef847 ]
The physical address width calculation in mtrr_bp_init() can easily be replaced with using the already available value x86_phys_bits from struct cpuinfo_x86.
The same information source can be used in mtrr/cleanup.c, removing the need to pass that value on to mtrr_cleanup().
In print_mtrr_state() use x86_phys_bits instead of recalculating it from size_or_mask.
Move setting of size_or_mask and size_and_mask into a dedicated new function in mtrr/generic.c, enabling to make those 2 variables static, as they are used in generic.c only now.
Stable-dep-of: c957f1f3c498 ("x86/hyperv: Set MTRR state when running as SEV-SNP Hyper-V guest")
--- arch/x86/kernel/cpu/mtrr/cleanup.c | 16 ++++---- arch/x86/kernel/cpu/mtrr/generic.c | 12 +++++- arch/x86/kernel/cpu/mtrr/mtrr.c | 61 ++++-------------------------- arch/x86/kernel/cpu/mtrr/mtrr.h | 4 +- 4 files changed, 29 insertions(+), 64 deletions(-)
arch/x86/kernel/cpu/mtrr/cleanup.c +8 -8
@@ -173,7 +173,7 @@ early_param("mtrr_cleanup_debug", mtrr_cleanup_debug_setup);static void __init set_var_mtrr (unsigned int reg,unsigned long basek,unsigned long sizek, -unsigned char type,unsigned int address_bits) +unsigned char type) {u32 base_lo, base_hi, mask_lo, mask_hi;u64 base, mask;
@@ -183,7 +183,7 @@ set_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek,return ; } - mask = (1ULL << address_bits) -1 ; + mask = (1ULL << boot_cpu_data.x86_phys_bits) -1 ; mask &= ~((((u64 )sizek) <<10 ) -1 ); base = ((u64 )basek) <<10 ;
@@ -209,7 +209,7 @@ save_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek, range_state[reg].type = type; } -static void __init set_var_mtrr_all (unsigned int address_bits) +static void __init set_var_mtrr_all (void ) {unsigned long basek, sizek;unsigned char type;
@@ -220,7 +220,7 @@ static void __init set_var_mtrr_all(unsigned int address_bits) sizek = range_state[reg].size_pfn << (PAGE_SHIFT -10 ); type = range_state[reg].type; -set_var_mtrr (reg, basek, sizek, type, address_bits); +set_var_mtrr (reg, basek, sizek, type); } }
@@ -680,7 +680,7 @@ static int __init mtrr_search_optimal_index(void)return index_good; } -int __init mtrr_cleanup (unsigned address_bits) +int __init mtrr_cleanup (void ) {unsigned long x_remove_base, x_remove_size;unsigned long base, size, def, dummy;
@@ -742,7 +742,7 @@ int __init mtrr_cleanup(unsigned address_bits)mtrr_print_out_one_result (i);if (!result[i].bad) { -set_var_mtrr_all (address_bits); +set_var_mtrr_all ();pr_debug ("New variable MTRRs\n" );print_out_mtrr_range_state ();return 1 ;
@@ -786,7 +786,7 @@ int __init mtrr_cleanup(unsigned address_bits) gran_size = result[i].gran_sizek; gran_size <<=10 ;x86_setup_var_mtrrs (range, nr_range, chunk_size, gran_size); -set_var_mtrr_all (address_bits); +set_var_mtrr_all ();pr_debug ("New variable MTRRs\n" );print_out_mtrr_range_state ();return 1 ;
@@ -802,7 +802,7 @@ int __init mtrr_cleanup(unsigned address_bits) return 0; }#else -int __init mtrr_cleanup (unsigned address_bits) +int __init mtrr_cleanup (void ) {return 0 ; }
arch/x86/kernel/cpu/mtrr/generic.c +11 -1
@@ -38,6 +38,16 @@ u64 mtrr_tom2;struct mtrr_state_type mtrr_state;EXPORT_SYMBOL_GPL (mtrr_state); +static u64 size_or_mask, size_and_mask; + +void __init mtrr_set_mask (void ) +{ +unsigned int phys_addr = boot_cpu_data.x86_phys_bits; + + size_or_mask = ~GENMASK_ULL (phys_addr -PAGE_SHIFT -1 ,0 ); + size_and_mask = ~size_or_mask &GENMASK_ULL (39 ,20 ); +} +/* * BIOS is expected to clear MtrrFixDramModEn bit, see for example * "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD
@@ -422,7 +432,7 @@ static void __init print_mtrr_state(void) }pr_debug ("MTRR variable ranges %sabled:\n" , mtrr_state.enabled &MTRR_STATE_MTRR_ENABLED ?"en" :"dis" ); - high_width = (__ffs64 (size_or_mask) - (32 -PAGE_SHIFT ) +3 ) /4 ; + high_width = (boot_cpu_data.x86_phys_bits - (32 -PAGE_SHIFT ) +3 ) /4 ;for (i =0 ; i < num_var_ranges; ++i) {if (mtrr_state.var_ranges[i].mask_lo & (1 <<11 ))
arch/x86/kernel/cpu/mtrr/mtrr.c +8 -53
100 lines not on this page · raw message
arch/x86/kernel/cpu/mtrr/mtrr.h +2 -2
@@ -51,7 +51,6 @@ void fill_mtrr_var_range(unsigned int index, u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi);bool get_mtrr_state (void ); -extern u64 size_or_mask, size_and_mask;extern const struct mtrr_ops *mtrr_if;#define is_cpu (vnd) (mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)
@@ -60,6 +59,7 @@ extern unsigned int num_var_ranges;extern u64 mtrr_tom2;extern struct mtrr_state_type mtrr_state; +void mtrr_set_mask (void );void mtrr_state_warn (void );const char *mtrr_attrib_to_str (int x);void mtrr_wrmsr (unsigned ,unsigned ,unsigned );
@@ -70,4 +70,4 @@ extern const struct mtrr_ops cyrix_mtrr_ops;extern const struct mtrr_ops centaur_mtrr_ops;extern int changed_by_mtrr_cleanup; -extern int mtrr_cleanup (unsigned address_bits); +extern int mtrr_cleanup (void );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 88/800 x86/mtrr: Support setting MTRR state for software defined MTRRs
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit 29055dc74287467bd7a053d60b4afe753832960d ]
When running virtualized, MTRR access can be reduced (e.g. in Xen PV guests or when running as a SEV-SNP guest under Hyper-V). Typically, the hypervisor will not advertize the MTRR feature in CPUID data, resulting in no MTRR memory type information being available for the kernel.
This has turned out to result in problems (Link tags below):
- Hyper-V SEV-SNP guests using uncached mappings where they shouldn't
- Xen PV dom0 mapping memory as WB which should be UC- instead
Solve those problems by allowing an MTRR static state override, overwriting the empty state used today. In case such a state has been set, don't call get_mtrr_state() in mtrr_bp_init().
The set state will only be used by mtrr_type_lookup(), as in all other cases mtrr_enabled() is being checked, which will return false. Accept the overwrite call only for selected cases when running as a guest. Disable X86_FEATURE_MTRR in order to avoid any MTRR modifications by just refusing them.
[ bp: Massage. ]
Stable-dep-of: c957f1f3c498 ("x86/hyperv: Set MTRR state when running as SEV-SNP Hyper-V guest")
--- arch/x86/include/asm/mtrr.h | 8 ++++ arch/x86/kernel/cpu/mtrr/generic.c | 60 +++++++++++++++++++++++++++++- arch/x86/kernel/cpu/mtrr/mtrr.c | 14 ++++++- arch/x86/kernel/setup.c | 2 + 4 files changed, 82 insertions(+), 2 deletions(-)
arch/x86/include/asm/mtrr.h +8 -0
@@ -31,6 +31,8 @@*/ # ifdef CONFIG_MTRR void mtrr_bp_init (void ); +void mtrr_overwrite_state (struct mtrr_var_range *var,unsigned int num_var, +mtrr_type def_type);extern u8 mtrr_type_lookup (u64 addr,u64 end,u8 *uniform);extern void mtrr_save_fixed_ranges (void *);extern void mtrr_save_state (void );
@@ -48,6 +50,12 @@ void mtrr_disable(void);void mtrr_enable (void );void mtrr_generic_set_state (void );# else +static inline void mtrr_overwrite_state (struct mtrr_var_range *var, +unsigned int num_var, +mtrr_type def_type) +{ +} +static inline u8 mtrr_type_lookup (u64 addr,u64 end,u8 *uniform) {/*
arch/x86/kernel/cpu/mtrr/generic.c +59 -1
75 lines not on this page · raw message
arch/x86/kernel/cpu/mtrr/mtrr.c +13 -1
@@ -625,11 +625,23 @@ int __initdata changed_by_mtrr_cleanup;*/ void __init mtrr_bp_init (void ) { +bool generic_mtrrs =cpu_feature_enabled (X86_FEATURE_MTRR );const char *why ="(not available)" ;mtrr_set_mask (); -if (cpu_feature_enabled (X86_FEATURE_MTRR )) { +if (!generic_mtrrs && mtrr_state.enabled) { +/* +* Software overwrite of MTRR state, only for generic case. +* Note that X86_FEATURE_MTRR has been reset in this case. +*/ +init_table (); +pr_info ("MTRRs set to read-only\n" ); + +return ; + } + +if (generic_mtrrs) { mtrr_if = &generic_mtrr_ops; }else {switch (boot_cpu_data.x86_vendor) {
arch/x86/kernel/setup.c +2 -0
@@ -1037,6 +1037,8 @@ void __init setup_arch(char **cmdline_p)/* * VMware detection requires dmi to be available, so this * needs to be done after dmi_setup(), for the boot CPU. +* For some guest types (Xen PV, SEV-SNP, TDX) it is required to be +* called before cache_bp_init() for setting up MTRR state. */ init_hypervisor_platform ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 89/800 x86/hyperv: Set MTRR state when running as SEV-SNP Hyper-V guest
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit c957f1f3c498bcce85c04e92e60afbae1fd10cde ]
In order to avoid mappings using the UC- cache attribute, set the MTRR state to use WB caching as the default.
This is needed in order to cope with the fact that PAT is enabled, while MTRRs are not supported by the hypervisor.
--- arch/x86/hyperv/ivm.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/hyperv/ivm.c +4 -0
@@ -17,6 +17,7 @@#include <asm/mem_encrypt.h> #include <asm/mshyperv.h> #include <asm/hypervisor.h> +#include <asm/mtrr.h> #ifdef CONFIG_AMD_MEM_ENCRYPT
@@ -372,6 +373,9 @@ void __init hv_vtom_init(void) x86_platform.guest.enc_cache_flush_required = hv_vtom_cache_flush_required; x86_platform.guest.enc_tlb_flush_required = hv_vtom_tlb_flush_required; x86_platform.guest.enc_status_change_finish = hv_vtom_set_host_visibility; + +/* Set WB as the default cache mode. */ + mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK); }#endif /* CONFIG_AMD_MEM_ENCRYPT */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 90/800 x86/mtrr: Replace size_or_mask and size_and_mask with a much easier concept
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit d053b481a5f16dbd4f020c6b3ebdf9173fdef0e2 ]
Replace size_or_mask and size_and_mask with the much easier concept of high reserved bits.
While at it, instead of using constants in the MTRR code, use some new
[ bp:
- Drop mtrr_set_mask()
- Unbreak long lines
- Move struct mtrr_state_type out of the uapi header as it doesn't belong there. It also fixes a HDRTEST breakage "unknown type name ‘bool’" as Reported-by: kernel test robot <[email protected]>
- Massage.
]
Stable-dep-of: a153f254e5cd ("x86/xen: Set MTRR state when running as Xen PV initial domain")
--- arch/x86/include/asm/mtrr.h | 32 +++++++++++++- arch/x86/include/uapi/asm/mtrr.h | 8 ---- arch/x86/kernel/cpu/mtrr/cleanup.c | 2 +- arch/x86/kernel/cpu/mtrr/generic.c | 70 +++++++++++++----------------- arch/x86/kernel/cpu/mtrr/mtrr.c | 4 +- arch/x86/kernel/cpu/mtrr/mtrr.h | 2 +- 6 files changed, 65 insertions(+), 53 deletions(-)
arch/x86/include/asm/mtrr.h +30 -2
@@ -23,8 +23,35 @@#ifndef _ASM_X86_MTRR_H#define _ASM_X86_MTRR_H +#include <linux/bits.h> #include <uapi/asm/mtrr.h> +/* Defines for hardware MTRR registers. */ +#define MTRR_CAP_VCNT GENMASK(7, 0) +#define MTRR_CAP_FIX BIT_MASK(8) +#define MTRR_CAP_WC BIT_MASK(10) + +#define MTRR_DEF_TYPE_TYPE GENMASK(7, 0) +#define MTRR_DEF_TYPE_FE BIT_MASK(10) +#define MTRR_DEF_TYPE_E BIT_MASK(11) + +#define MTRR_DEF_TYPE_ENABLE (MTRR_DEF_TYPE_FE | MTRR_DEF_TYPE_E) +#define MTRR_DEF_TYPE_DISABLE ~(MTRR_DEF_TYPE_TYPE | MTRR_DEF_TYPE_ENABLE) + +#define MTRR_PHYSBASE_TYPE GENMASK(7, 0) +#define MTRR_PHYSBASE_RSVD GENMASK(11, 8) + +#define MTRR_PHYSMASK_RSVD GENMASK(10, 0) +#define MTRR_PHYSMASK_V BIT_MASK(11) + +struct mtrr_state_type { +struct mtrr_var_range var_ranges[MTRR_MAX_VAR_RANGES ]; +mtrr_type fixed_ranges[MTRR_NUM_FIXED_RANGES ]; +unsigned char enabled; +bool have_fixed; +mtrr_type def_type; +}; +/* * The following functions are for use by other drivers that cannot use * arch_phys_wc_add and arch_phys_wc_del.
@@ -129,7 +156,8 @@ struct mtrr_gentry32 {#endif /* CONFIG_COMPAT */ /* Bit fields for enabled in struct mtrr_state_type */ -#define MTRR_STATE_MTRR_FIXED_ENABLED 0x01 -#define MTRR_STATE_MTRR_ENABLED 0x02 +#define MTRR_STATE_SHIFT 10 +#define MTRR_STATE_MTRR_FIXED_ENABLED (MTRR_DEF_TYPE_FE >> MTRR_STATE_SHIFT) +#define MTRR_STATE_MTRR_ENABLED (MTRR_DEF_TYPE_E >> MTRR_STATE_SHIFT)#endif /* _ASM_X86_MTRR_H */
arch/x86/include/uapi/asm/mtrr.h +0 -8
@@ -81,14 +81,6 @@ typedef __u8 mtrr_type;#define MTRR_NUM_FIXED_RANGES 88#define MTRR_MAX_VAR_RANGES 256 -struct mtrr_state_type { -struct mtrr_var_range var_ranges[MTRR_MAX_VAR_RANGES ]; -mtrr_type fixed_ranges[MTRR_NUM_FIXED_RANGES ]; -unsigned char enabled; -unsigned char have_fixed; -mtrr_type def_type; -}; -#define MTRRphysBase_MSR (reg) (0x200 + 2 * (reg))#define MTRRphysMask_MSR (reg) (0x200 + 2 * (reg) + 1)
arch/x86/kernel/cpu/mtrr/cleanup.c +1 -1
@@ -890,7 +890,7 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)return 0 ;rdmsr (MSR_MTRRdefType, def, dummy); - def &=0xff ; + def &=MTRR_DEF_TYPE_TYPE ;if (def !=MTRR_TYPE_UNCACHABLE )return 0 ;
arch/x86/kernel/cpu/mtrr/generic.c +31 -39
175 lines not on this page · raw message
arch/x86/kernel/cpu/mtrr/mtrr.c +2 -2
@@ -115,7 +115,7 @@ static void __init set_num_var_ranges(bool use_generic)else if (is_cpu (CYRIX ) ||is_cpu (CENTAUR )) config =8 ; - num_var_ranges = config &0xff ; + num_var_ranges = config &MTRR_CAP_VCNT ; }static void __init init_table (void )
@@ -628,7 +628,7 @@ void __init mtrr_bp_init(void)bool generic_mtrrs =cpu_feature_enabled (X86_FEATURE_MTRR );const char *why ="(not available)" ; -mtrr_set_mask (); + phys_hi_rsvd =GENMASK (31 , boot_cpu_data.x86_phys_bits -32 );if (!generic_mtrrs && mtrr_state.enabled) {/*
arch/x86/kernel/cpu/mtrr/mtrr.h +1 -1
@@ -58,8 +58,8 @@ extern const struct mtrr_ops *mtrr_if;extern unsigned int num_var_ranges;extern u64 mtrr_tom2;extern struct mtrr_state_type mtrr_state; +extern u32 phys_hi_rsvd; -void mtrr_set_mask (void );void mtrr_state_warn (void );const char *mtrr_attrib_to_str (int x);void mtrr_wrmsr (unsigned ,unsigned ,unsigned );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 91/800 x86/xen: Set MTRR state when running as Xen PV initial domain
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit a153f254e5cdf8fa3a1df90a6ffed3063fede154 ]
When running as Xen PV initial domain (aka dom0), MTRRs are disabled by the hypervisor, but the system should nevertheless use correct cache memory types. This has always kind of worked, as disabled MTRRs resulted in disabled PAT, too, so that the kernel avoided code paths resulting in inconsistencies. This bypassed all of the sanity checks the kernel is doing with enabled MTRRs in order to avoid memory mappings with conflicting memory types.
This has been changed recently, leading to PAT being accepted to be enabled, while MTRRs stayed disabled. The result is that mtrr_type_lookup() no longer is accepting all memory type requests, but started to return WB even if UC- was requested. This led to driver failures during initialization of some devices.
In reality MTRRs are still in effect, but they are under complete control of the Xen hypervisor. It is possible, however, to retrieve the MTRR settings from the hypervisor.
In order to fix those problems, overwrite the MTRR state via mtrr_overwrite_state() with the MTRR data from the hypervisor, if the system is running as a Xen dom0.
--- arch/x86/xen/enlighten_pv.c | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
arch/x86/xen/enlighten_pv.c +52 -0
@@ -68,6 +68,7 @@#include <asm/reboot.h> #include <asm/hypervisor.h> #include <asm/mach_traps.h> +#include <asm/mtrr.h> #include <asm/mwait.h> #include <asm/pci_x86.h> #include <asm/cpu.h>
@@ -119,6 +120,54 @@ static int __init parse_xen_msr_safe(char *str) }early_param ("xen_msr_safe" , parse_xen_msr_safe); +/* Get MTRR settings from Xen and put them into mtrr_state. */ +static void __init xen_set_mtrr_data (void ) +{ +#ifdef CONFIG_MTRR +struct xen_platform_op op = { + .cmd = XENPF_read_memtype, + .interface_version =XENPF_INTERFACE_VERSION , + }; +unsigned int reg; +unsigned long mask; +uint32_t eax, width; +static struct mtrr_var_range var[MTRR_MAX_VAR_RANGES ]__initdata ; + +/* Get physical address width (only 64-bit cpus supported). */ + width =36 ; + eax =cpuid_eax (0x80000000 ); +if ((eax >>16 ) ==0x8000 && eax >=0x80000008 ) { + eax =cpuid_eax (0x80000008 ); + width = eax &0xff ; + } + +for (reg =0 ; reg <MTRR_MAX_VAR_RANGES ; reg++) { + op.u.read_memtype.reg = reg; +if (HYPERVISOR_platform_op (&op)) +break ; + +/* +* Only called in dom0, which has all RAM PFNs mapped at +* RAM MFNs, and all PCI space etc. is identity mapped. +* This means we can treat MFN == PFN regarding MTRR settings. +*/ + var[reg].base_lo = op.u.read_memtype.type; + var[reg].base_lo |= op.u.read_memtype.mfn <<PAGE_SHIFT ; + var[reg].base_hi = op.u.read_memtype.mfn >> (32 -PAGE_SHIFT ); + mask = ~((op.u.read_memtype.nr_mfns <<PAGE_SHIFT ) -1 ); + mask &= (1UL << width) -1 ; +if (mask) + mask |=MTRR_PHYSMASK_V ; + var[reg].mask_lo = mask; + var[reg].mask_hi = mask >>32 ; + } + +/* Only overwrite MTRR state if any MTRR could be got from Xen. */ +if (reg) +mtrr_overwrite_state (var, reg,MTRR_TYPE_UNCACHABLE ); +#endif +} +static void __init xen_pv_init_platform (void ) {/* PV guests can't operate virtio devices without grants. */
@@ -135,6 +184,9 @@ static void __init xen_pv_init_platform(void)/* pvclock is in shared info area */ xen_init_time_ops (); + +if (xen_initial_domain ()) +xen_set_mtrr_data (); }static void __init xen_pv_guest_late_init (void )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 82/800 rcu: Make rcu_cpu_starting() rely on interrupts being disabled
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 15d44dfa40305da1648de4bf001e91cc63148725 ]
Currently, rcu_cpu_starting() is written so that it might be invoked with interrupts enabled. However, it is always called when interrupts are disabled, either by rcu_init(), notify_cpu_starting(), or from a call point prior to the call to notify_cpu_starting().
But why bother requiring that interrupts be disabled? The purpose is to allow the rcu_data structure's ->beenonline flag to be set after all early processing has completed for the incoming CPU, thus allowing this flag to be used to determine when workqueues have been set up for the incoming CPU, while still allowing this flag to be used as a diagnostic within rcu_core().
This commit therefore makes rcu_cpu_starting() rely on interrupts being disabled.
Stable-dep-of: 401b0de3ae4f ("rcu-tasks: Stop rcu_tasks_invoke_cbs() from using never-onlined CPUs")
--- kernel/rcu/tree.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
kernel/rcu/tree.c +5 -6
@@ -4368,15 +4368,16 @@ int rcutree_offline_cpu(unsigned int cpu)* Note that this function is special in that it is invoked directly * from the incoming CPU rather than from the cpuhp_step mechanism. * This is because this function must be invoked at a precise location. +* This incoming CPU must not have enabled interrupts yet. */ void rcu_cpu_starting (unsigned int cpu) { -unsigned long flags;unsigned long mask;struct rcu_data *rdp;struct rcu_node *rnp;bool newcpu; +lockdep_assert_irqs_disabled (); rdp =per_cpu_ptr (&rcu_data, cpu);if (rdp->cpu_started)return ;
@@ -4384,7 +4385,6 @@ void rcu_cpu_starting(unsigned int cpu) rnp = rdp->mynode; mask = rdp->grpmask; -local_irq_save (flags);arch_spin_lock (&rcu_state.ofl_lock);rcu_dynticks_eqs_online ();raw_spin_lock (&rcu_state.barrier_lock);
@@ -4403,17 +4403,16 @@ void rcu_cpu_starting(unsigned int cpu)/* An incoming CPU should never be blocking a grace period. */ if (WARN_ON_ONCE (rnp->qsmask & mask)) {/* RCU waiting on incoming CPU? */ /* rcu_report_qs_rnp() *really* wants some flags to restore */ -unsigned long flags2; +unsigned long flags; -local_irq_save (flags2); +local_irq_save (flags);rcu_disable_urgency_upon_qs (rdp);/* Report QS -after- changing ->qsmaskinitnext! */ -rcu_report_qs_rnp (mask, rnp, rnp->gp_seq, flags2); +rcu_report_qs_rnp (mask, rnp, rnp->gp_seq, flags); }else {raw_spin_unlock_rcu_node (rnp); }arch_spin_unlock (&rcu_state.ofl_lock); -local_irq_restore (flags);smp_mb ();/* Ensure RCU read-side usage follows above initialization. */ }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 113/800 samples/bpf: Fix buffer overflow in tcp_basertt
In reply to Greg Kroah-HartmanFrom: Pengcheng Yang <[email protected]>
[ Upstream commit f4dea9689c5fea3d07170c2cb0703e216f1a0922 ]
Using sizeof(nv) or strlen(nv)+1 is correct.
--- samples/bpf/tcp_basertt_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/tcp_basertt_kern.c +1 -1
@@ -47,7 +47,7 @@ int bpf_basertt(struct bpf_sock_ops *skops)case BPF_SOCK_OPS_BASE_RTT : n =bpf_getsockopt (skops,SOL_TCP ,TCP_CONGESTION , cong,sizeof (cong)); -if (!n && !__builtin_memcmp (cong, nv,sizeof (nv)+1 )) { +if (!n && !__builtin_memcmp (cong, nv,sizeof (nv))) {/* Set base_rtt to 80us */ rv =80 ; }else if (n) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 122/800 bpf: Dont EFAULT for {g,s}setsockopt with wrong optlen
In reply to Greg Kroah-HartmanFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 29ebbba7d46136cba324264e513a1e964ca16c0a ]
With the way the hooks implemented right now, we have a special
condition: optval larger than PAGE_SIZE will expose only first 4k into BPF; any modifications to the optval are ignored. If the BPF program doesn't handle this condition by resetting optlen to 0,
the userspace will get EFAULT.
The intention of the EFAULT was to make it apparent to the developers that the program is doing something wrong. However, this inadvertently might affect production workloads with the BPF programs that are not too careful (i.e., returning EFAULT for perfectly valid setsockopt/getsockopt calls).
Let's try to minimize the chance of BPF program screwing up userspace by ignoring the output of those BPF programs (instead of returning EFAULT to the userspace). pr_info_once those cases to
the dmesg to help with figuring out what's going wrong.
--- kernel/bpf/cgroup.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
kernel/bpf/cgroup.c +15 -0
@@ -1826,6 +1826,12 @@ int __cgroup_bpf_run_filter_setsockopt(struct sock *sk, int *level, ret =1 ; }else if (ctx.optlen > max_optlen || ctx.optlen <-1 ) {/* optlen is out of bounds */ +if (*optlen >PAGE_SIZE && ctx.optlen >=0 ) { +pr_info_once ("bpf setsockopt: ignoring program buffer with optlen=%d (max_optlen=%d)\n" , + ctx.optlen, max_optlen); + ret =0 ; + goto out; + } ret = -EFAULT ; }else {/* optlen within bounds, run kernel handler */
@@ -1881,8 +1887,10 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, .optname = optname, .current_task = current, }; +int orig_optlen;int ret; + orig_optlen = max_optlen; ctx.optlen = max_optlen; max_optlen =sockopt_alloc_buf (&ctx, max_optlen, &buf);if (max_optlen <0 )
@@ -1905,6 +1913,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, ret = -EFAULT ; goto out; } + orig_optlen = ctx.optlen;if (copy_from_user (ctx.optval, optval,min (ctx.optlen, max_optlen)) !=0 ) {
@@ -1922,6 +1931,12 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, goto out;if (optval && (ctx.optlen > max_optlen || ctx.optlen <0 )) { +if (orig_optlen >PAGE_SIZE && ctx.optlen >=0 ) { +pr_info_once ("bpf getsockopt: ignoring program buffer with optlen=%d (max_optlen=%d)\n" , + ctx.optlen, max_optlen); + ret = retval; + goto out; + } ret = -EFAULT ; goto out; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 123/800 spi: dw: Round of n_bytes to power of 2
In reply to Greg Kroah-HartmanFrom: Joy Chakraborty <[email protected]>
[ Upstream commit 9f34baf67e4d08908fd94ff29c825bb673295336 ]
n_bytes variable in the driver represents the number of bytes per word that needs to be sent/copied to fifo. Bits/word can be between 8 and 32 bits from the client but in memory they are a power of 2, same is mentioned in spi.h header:
"
* @bits_per_word: Data transfers involve one or more words; word sizes
* like eight or 12 bits are common. In-memory wordsizes are * powers of two bytes (e.g. 20 bit samples use 32 bits). * This may be changed by the device's driver, or left at the * default (0) indicating protocol words are eight bit bytes. * The spi_transfer.bits_per_word can override this for each transfer.
"
Hence, round of n_bytes to a power of 2 to avoid values like 3 which would generate unalligned/odd accesses to memory/fifo.
* tested on Baikal-T1 based system with DW SPI-looped back interface transferring a chunk of data with DFS:8,12,16.
--- drivers/spi/spi-dw-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-dw-core.c +4 -1
@@ -426,7 +426,10 @@ static int dw_spi_transfer_one(struct spi_controller *master,int ret; dws->dma_mapped =0 ; - dws->n_bytes =DIV_ROUND_UP (transfer->bits_per_word,BITS_PER_BYTE ); + dws->n_bytes = +roundup_pow_of_two (DIV_ROUND_UP (transfer->bits_per_word, +BITS_PER_BYTE )); + dws->tx = (void *)transfer->tx_buf; dws->tx_len = transfer->len / dws->n_bytes; dws->rx = transfer->rx_buf;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 124/800 nfc: llcp: fix possible use of uninitialized variable in nfc_llcp_send_connect()
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 0d9b41daa5907756a31772d8af8ac5ff25cf17c1 ]
If sock->service_name is NULL, the local variable service_name_tlv_length will not be assigned by nfc_llcp_build_tlv(), later leading to using value frmo the stack. Smatch warning:
net/nfc/llcp_commands.c:442 nfc_llcp_send_connect() error: uninitialized symbol 'service_name_tlv_length'.
--- net/nfc/llcp_commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/nfc/llcp_commands.c +2 -1
@@ -390,7 +390,8 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)const u8 *service_name_tlv =NULL ;const u8 *miux_tlv =NULL ;const u8 *rw_tlv =NULL ; -u8 service_name_tlv_length, miux_tlv_length, rw_tlv_length, rw; +u8 service_name_tlv_length =0 ; +u8 miux_tlv_length, rw_tlv_length, rw;int err;u16 size =0 ;__be16 miux;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 125/800 bpftool: JIT limited misreported as negative value on aarch64
In reply to Greg Kroah-HartmanFrom: Alan Maguire <[email protected]>
[ Upstream commit 04cb8453a91c7c22f60ddadb6cef0d19abb33bb5 ]
On aarch64, "bpftool feature" reports an incorrect BPF JIT limit:
$ sudo /sbin/bpftool feature Scanning system configuration... bpf() syscall restricted to privileged users JIT compiler is enabled JIT compiler hardening is disabled JIT compiler kallsyms exports are enabled for root skipping kernel config, can't open file: No such file or directory Global memory limit for JIT compiler for unprivileged users is -201326592 bytes
This is because /proc/sys/net/core/bpf_jit_limit reports
$ sudo cat /proc/sys/net/core/bpf_jit_limit 68169519595520
...and an int is assumed in read_procfs(). Change read_procfs() to return a long to avoid negative value reporting.
--- tools/bpf/bpftool/feature.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
tools/bpf/bpftool/feature.c +12 -12
@@ -167,12 +167,12 @@ static int get_vendor_id(int ifindex)return strtol (buf,NULL ,0 ); } -static int read_procfs (const char *path) +static long read_procfs (const char *path) {char *endptr, *line =NULL ;size_t len =0 ;FILE *fd; -int res; +long res; fd =fopen (path,"r" );if (!fd)
@@ -194,7 +194,7 @@ static int read_procfs(const char *path)static void probe_unprivileged_disabled (void ) { -int res; +long res;/* No support for C-style ouptut */
@@ -216,14 +216,14 @@ static void probe_unprivileged_disabled(void)printf ("Unable to retrieve required privileges for bpf() syscall\n" );break ;default : -printf ("bpf() syscall restriction has unknown value %d\n" , res); +printf ("bpf() syscall restriction has unknown value %ld\n" , res); } } }static void probe_jit_enable (void ) { -int res; +long res;/* No support for C-style ouptut */
@@ -245,7 +245,7 @@ static void probe_jit_enable(void)printf ("Unable to retrieve JIT-compiler status\n" );break ;default : -printf ("JIT-compiler status has unknown value %d\n" , +printf ("JIT-compiler status has unknown value %ld\n" , res); } }
@@ -253,7 +253,7 @@ static void probe_jit_enable(void)static void probe_jit_harden (void ) { -int res; +long res;/* No support for C-style ouptut */
@@ -275,7 +275,7 @@ static void probe_jit_harden(void)printf ("Unable to retrieve JIT hardening status\n" );break ;default : -printf ("JIT hardening status has unknown value %d\n" , +printf ("JIT hardening status has unknown value %ld\n" , res); } }
@@ -283,7 +283,7 @@ static void probe_jit_harden(void)static void probe_jit_kallsyms (void ) { -int res; +long res;/* No support for C-style ouptut */
@@ -302,14 +302,14 @@ static void probe_jit_kallsyms(void)printf ("Unable to retrieve JIT kallsyms export status\n" );break ;default : -printf ("JIT kallsyms exports status has unknown value %d\n" , res); +printf ("JIT kallsyms exports status has unknown value %ld\n" , res); } } }static void probe_jit_limit (void ) { -int res; +long res;/* No support for C-style ouptut */
@@ -322,7 +322,7 @@ static void probe_jit_limit(void)printf ("Unable to retrieve global memory limit for JIT compiler for unprivileged users\n" );break ;default : -printf ("Global memory limit for JIT compiler for unprivileged users is %d bytes\n" , res); +printf ("Global memory limit for JIT compiler for unprivileged users is %ld bytes\n" , res); } } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 126/800 bpf: Remove bpf trampoline selector
In reply to Greg Kroah-HartmanFrom: Yafang Shao <[email protected]>
[ Upstream commit 47e79cbeea4b3891ad476047f4c68543eb51c8e0 ]
After commit e21aa341785c ("bpf: Fix fexit trampoline."), the selector is only used to indicate how many times the bpf trampoline image are updated and been displayed in the trampoline ksym name. After the trampoline is freed, the selector will start from 0 again. So the selector is a useless value to the user. We can remove it.
If the user want to check whether the bpf trampoline image has been updated or not, the user can compare the address. Each time the trampoline image is updated, the address will change consequently. Jiri also pointed out another issue that perf is still using the old name "bpf_trampoline_%lu", so this change can fix the issue in perf.
--- include/linux/bpf.h | 1 - kernel/bpf/trampoline.c | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-)
include/linux/bpf.h +0 -1
@@ -1125,7 +1125,6 @@ struct bpf_trampoline {int progs_cnt[BPF_TRAMP_MAX ];/* Executable image of trampoline */ struct bpf_tramp_image *cur_image; -u64 selector;struct module *mod; };
kernel/bpf/trampoline.c +4 -7
@@ -344,7 +344,7 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im)call_rcu_tasks_trace (&im->rcu, __bpf_tramp_image_put_rcu_tasks); } -static struct bpf_tramp_image *bpf_tramp_image_alloc (u64 key,u32 idx) +static struct bpf_tramp_image *bpf_tramp_image_alloc (u64 key) {struct bpf_tramp_image *im;struct bpf_ksym *ksym;
@@ -371,7 +371,7 @@ static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, u32 idx) ksym = &im->ksym;INIT_LIST_HEAD_RCU (&ksym->lnode); -snprintf (ksym->name,KSYM_NAME_LEN ,"bpf_trampoline_%llu_%u" , key, idx); +snprintf (ksym->name,KSYM_NAME_LEN ,"bpf_trampoline_%llu" , key);bpf_image_ksym_add (image, ksym);return im;
@@ -401,11 +401,10 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut err =unregister_fentry (tr, tr->cur_image->image);bpf_tramp_image_put (tr->cur_image); tr->cur_image =NULL ; - tr->selector =0 ; goto out; } - im =bpf_tramp_image_alloc (tr->key, tr->selector); + im =bpf_tramp_image_alloc (tr->key);if (IS_ERR (im)) { err =PTR_ERR (im); goto out;
@@ -442,8 +441,7 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mutset_memory_rox ((long )im->image,1 ); -WARN_ON (tr->cur_image && tr->selector ==0 ); -WARN_ON (!tr->cur_image && tr->selector); +WARN_ON (tr->cur_image && total ==0 );if (tr->cur_image)/* progs already running at this address */ err =modify_fentry (tr, tr->cur_image->image, im->image, lock_direct_mutex);
@@ -473,7 +471,6 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mutif (tr->cur_image)bpf_tramp_image_put (tr->cur_image); tr->cur_image = im; - tr->selector++; out:/* If any error happens, restore previous flags */ if (err)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 127/800 bpf: Fix memleak due to fentry attach failure
In reply to Greg Kroah-HartmanFrom: Yafang Shao <[email protected]>
[ Upstream commit 108598c39eefbedc9882273ac0df96127a629220 ]
If it fails to attach fentry, the allocated bpf trampoline image will be left in the system. That can be verified by checking /proc/kallsyms.
This meamleak can be verified by a simple bpf program as follows:
SEC("fentry/trap_init")
int fentry_run()
{
return 0;
}It will fail to attach trap_init because this function is freed after kernel init, and then we can find the trampoline image is left in the system by checking /proc/kallsyms.
$ tail /proc/kallsyms ffffffffc0613000 t bpf_trampoline_6442453466_1 [bpf] ffffffffc06c3000 t bpf_trampoline_6442453466_1 [bpf]
$ bpftool btf dump file /sys/kernel/btf/vmlinux | grep "FUNC 'trap_init'" [2522] FUNC 'trap_init' type_id=119 linkage=static
$ echo $((6442453466 & 0x7fffffff)) 2522
Note that there are two left bpf trampoline images, that is because the libbpf will fallback to raw tracepoint if -EINVAL is returned.
--- kernel/bpf/trampoline.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
kernel/bpf/trampoline.c +15 -6
@@ -251,11 +251,8 @@ bpf_trampoline_get_progs(const struct bpf_trampoline *tr, int *total, bool *ip_areturn tlinks; } -static void __bpf_tramp_image_put_deferred (struct work_struct *work) +static void bpf_tramp_image_free (struct bpf_tramp_image *im) { -struct bpf_tramp_image *im; - - im = container_of(work, struct bpf_tramp_image, work);bpf_image_ksym_del (&im->ksym);bpf_jit_free_exec (im->image);bpf_jit_uncharge_modmem (PAGE_SIZE );
@@ -263,6 +260,14 @@ static void __bpf_tramp_image_put_deferred(struct work_struct *work)kfree_rcu (im, rcu); } +static void __bpf_tramp_image_put_deferred (struct work_struct *work) +{ +struct bpf_tramp_image *im; + + im = container_of(work, struct bpf_tramp_image, work); +bpf_tramp_image_free (im); +} +/* callback, fexit step 3 or fentry step 2 */ static void __bpf_tramp_image_put_rcu (struct rcu_head *rcu) {
@@ -437,7 +442,7 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut &tr->func.model, tr->flags, tlinks, tr->func.addr);if (err <0 ) - goto out; + goto out_free;set_memory_rox ((long )im->image,1 );
@@ -466,7 +471,7 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut }#endif if (err) - goto out; + goto out_free;if (tr->cur_image)bpf_tramp_image_put (tr->cur_image);
@@ -477,6 +482,10 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut tr->flags = orig_flags;kfree (tlinks);return err; + +out_free: +bpf_tramp_image_free (im); + goto out; }static enum bpf_tramp_prog_type bpf_attach_type_to_tramp (struct bpf_prog *prog)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 128/800 selftests/bpf: Do not use sign-file as testcase
In reply to Greg Kroah-HartmanFrom: Alexey Gladkov <[email protected]>
[ Upstream commit f04a32b2c5b539e3c097cb5c7c1df12a8f4a0cf0 ]
The sign-file utility (from scripts/) is used in prog_tests/verify_pkcs7_sig.c, but the utility should not be called as a test. Executing this utility produces the following error:
selftests: /linux/tools/testing/selftests/bpf: urandom_read ok 16 selftests: /linux/tools/testing/selftests/bpf: urandom_read
selftests: /linux/tools/testing/selftests/bpf: sign-file
not ok 17 selftests: /linux/tools/testing/selftests/bpf: sign-file # exit=2
Also, urandom_read is mistakenly used as a test. It does not lead to an error, but should be moved over to TEST_GEN_FILES as well. The empty TEST_CUSTOM_PROGS can then be removed.
--- tools/testing/selftests/bpf/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/bpf/Makefile +1 -2
@@ -88,8 +88,7 @@ TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \ xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata \ xdp_features -TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read $(OUTPUT)/sign-file -TEST_GEN_FILES += liburandom_read.so +TEST_GEN_FILES += liburandom_read.so urandom_read sign-file # Emit succinct information message describing current building step # $1 - generic step name (e.g., CC, LINK, etc);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 129/800 regulator: rk808: fix asynchronous probing
In reply to Greg Kroah-HartmanFrom: Sebastian Reichel <[email protected]>
[ Upstream commit 1b9e86d445a0f5c6d8dcbaf11508cb5dfb5848a8 ]
If the probe routine fails with -EPROBE_DEFER after taking over the OF node from its parent driver, reprobing triggers pinctrl_bind_pins() and that will fail. Fix this by setting of_node_reused, so that the device does not try to setup pin muxing.
For me this always happens once the driver is marked to prefer async probing and never happens without that flag.
--- drivers/regulator/rk808-regulator.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/rk808-regulator.c +1 -0
@@ -1336,6 +1336,7 @@ static int rk808_regulator_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.dev->of_node = pdev->dev.parent->of_node; + config.dev->of_node_reused = true; config.driver_data = pdata; config.regmap = regmap;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 130/800 regulator: core: Fix more error checking for debugfs_create_dir()
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 2715bb11cfff964aa33946847f9527cfbd4874f5 ]
In case of failure, debugfs_create_dir() does not return NULL, but an error pointer. Most incorrect error checks were fixed, but the one in create_regulator() was forgotten.
Fix the remaining error check.
--- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/core.c +1 -1
@@ -1911,7 +1911,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,if (err != -EEXIST ) regulator->debugfs =debugfs_create_dir (supply_name, rdev->debugfs); -if (!regulator->debugfs) { +if (IS_ERR (regulator->debugfs)) {rdev_dbg (rdev,"Failed to create debugfs directory\n" ); }else { debugfs_create_u32("uA_load", 0444, regulator->debugfs,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 131/800 regulator: core: Streamline debugfs operations
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 08880713ceec023dd94d634f1e8902728c385939 ]
If CONFIG_DEBUG_FS is not set:
regulator: Failed to create debugfs directory
...
regulator-dummy: Failed to create debugfs directory
As per the comments for debugfs_create_dir(), errors returned by this function should be expected, and ignored:
* If debugfs is not enabled in the kernel, the value -%ENODEV will be
* returned.
*
* NOTE: it's expected that most callers should _ignore_ the errors returned
* by this function. Other debugfs functions handle the fact that the "dentry"
* passed to them could be an error and they don't crash in that case.
* Drivers should generally work fine even if debugfs fails to init anyway.
Adhere to the debugfs spirit, and streamline all operations by:
1. Demoting the importance of the printed error messages to debug level, like is already done in create_regulator(),
2. Further ignoring any returned errors, as by design, all debugfs functions are no-ops when passed an error pointer.
--- drivers/regulator/core.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/regulator/core.c +13 -17
@@ -1911,19 +1911,17 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,if (err != -EEXIST ) regulator->debugfs =debugfs_create_dir (supply_name, rdev->debugfs); -if (IS_ERR (regulator->debugfs)) { +if (IS_ERR (regulator->debugfs))rdev_dbg (rdev,"Failed to create debugfs directory\n" ); - }else { -debugfs_create_u32 ("uA_load" ,0444 , regulator->debugfs, - ®ulator->uA_load); -debugfs_create_u32 ("min_uV" ,0444 , regulator->debugfs, - ®ulator->voltage[PM_SUSPEND_ON ].min_uV); -debugfs_create_u32 ("max_uV" ,0444 , regulator->debugfs, - ®ulator->voltage[PM_SUSPEND_ON ].max_uV); -debugfs_create_file ("constraint_flags" ,0444 , - regulator->debugfs, regulator, - &constraint_flags_fops); - } + +debugfs_create_u32 ("uA_load" ,0444 , regulator->debugfs, + ®ulator->uA_load); +debugfs_create_u32 ("min_uV" ,0444 , regulator->debugfs, + ®ulator->voltage[PM_SUSPEND_ON ].min_uV); +debugfs_create_u32 ("max_uV" ,0444 , regulator->debugfs, + ®ulator->voltage[PM_SUSPEND_ON ].max_uV); +debugfs_create_file ("constraint_flags" ,0444 , regulator->debugfs, + regulator, &constraint_flags_fops);/* * Check now if the regulator is an always on regulator - if
@@ -5256,10 +5254,8 @@ static void rdev_init_debugfs(struct regulator_dev *rdev) } rdev->debugfs =debugfs_create_dir (rname, debugfs_root); -if (IS_ERR (rdev->debugfs)) { -rdev_warn (rdev,"Failed to create debugfs directory\n" ); -return ; - } +if (IS_ERR (rdev->debugfs)) +rdev_dbg (rdev,"Failed to create debugfs directory\n" );debugfs_create_u32 ("use_count" ,0444 , rdev->debugfs, &rdev->use_count);
@@ -6179,7 +6175,7 @@ static int __init regulator_init(void) debugfs_root =debugfs_create_dir ("regulator" ,NULL );if (IS_ERR (debugfs_root)) -pr_warn ("regulator: Failed to create debugfs directory\n" ); +pr_debug ("regulator: Failed to create debugfs directory\n" );#ifdef CONFIG_DEBUG_FS debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 114/800 spi: spi-geni-qcom: Correct CS_TOGGLE bit in SPI_TRANS_CFG
In reply to Greg Kroah-HartmanFrom: Vijaya Krishna Nivarthi <[email protected]>
[ Upstream commit 5fd7c99ecf45c8ee8a9b1268f0ffc91cc6271da2 ]
The CS_TOGGLE bit when set is supposed to instruct FW to toggle CS line between words. The driver with intent of disabling this behaviour has been unsetting BIT(0). This has not caused any trouble so far because the original BIT(1) is untouched and BIT(0) likely wasn't being used.
Correct this to prevent a potential future bug.
--- drivers/spi/spi-geni-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-geni-qcom.c +1 -1
@@ -35,7 +35,7 @@#define CS_DEMUX_OUTPUT_SEL GENMASK(3, 0)#define SE_SPI_TRANS_CFG 0x25c -#define CS_TOGGLE BIT(0) +#define CS_TOGGLE BIT(1)#define SE_SPI_WORD_LEN 0x268#define WORD_LEN_MSK GENMASK(9, 0)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 132/800 wifi: orinoco: Fix an error handling path in spectrum_cs_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 925244325159824385209e3e0e3f91fa6bf0646c ]
Should spectrum_cs_config() fail, some resources need to be released as already done in the remove function.
While at it, remove a useless and erroneous comment. The probe is spectrum_cs_probe(), not spectrum_cs_attach().
--- drivers/net/wireless/intersil/orinoco/spectrum_cs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/wireless/intersil/orinoco/spectrum_cs.c +11 -2
@@ -157,6 +157,7 @@ spectrum_cs_probe(struct pcmcia_device *link) {struct orinoco_private *priv;struct orinoco_pccard *card; +int ret; priv = alloc_orinocodev(sizeof(*card), &link->dev, spectrum_cs_hard_reset,
@@ -169,8 +170,16 @@ spectrum_cs_probe(struct pcmcia_device *link) card->p_dev = link; link->priv = priv; -return spectrum_cs_config (link); -}/* spectrum_cs_attach */ + ret =spectrum_cs_config (link); +if (ret) + goto err_free_orinocodev; + +return 0 ; + +err_free_orinocodev: +free_orinocodev (priv); +return ret; +}static void spectrum_cs_detach (struct pcmcia_device *link) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 133/800 wifi: orinoco: Fix an error handling path in orinoco_cs_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 67a81d911c01225f426cc6bee2373df044c1a9b7 ]
Should orinoco_cs_config() fail, some resources need to be released as already done in the remove function.
While at it, remove a useless and erroneous comment. The probe is orinoco_cs_probe(), not orinoco_cs_attach().
--- drivers/net/wireless/intersil/orinoco/orinoco_cs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/wireless/intersil/orinoco/orinoco_cs.c +11 -2
@@ -96,6 +96,7 @@ orinoco_cs_probe(struct pcmcia_device *link) {struct orinoco_private *priv;struct orinoco_pccard *card; +int ret; priv =alloc_orinocodev (sizeof (*card), &link->dev, orinoco_cs_hard_reset,NULL );
@@ -107,8 +108,16 @@ orinoco_cs_probe(struct pcmcia_device *link) card->p_dev = link; link->priv = priv; -return orinoco_cs_config (link); -}/* orinoco_cs_attach */ + ret =orinoco_cs_config (link); +if (ret) + goto err_free_orinocodev; + +return 0 ; + +err_free_orinocodev: +free_orinocodev (priv); +return ret; +}static void orinoco_cs_detach (struct pcmcia_device *link) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 134/800 wifi: atmel: Fix an error handling path in atmel_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 6b92e4351a29af52c285fe235e6e4d1a75de04b2 ]
Should atmel_config() fail, some resources need to be released as already done in the remove function.
While at it, remove a useless and erroneous comment. The probe is atmel_probe(), not atmel_attach().
--- drivers/net/wireless/atmel/atmel_cs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/wireless/atmel/atmel_cs.c +11 -2
@@ -72,6 +72,7 @@ struct local_info {static int atmel_probe (struct pcmcia_device *p_dev) {struct local_info *local; +int ret;dev_dbg (&p_dev->dev,"atmel_attach()\n" );
@@ -82,8 +83,16 @@ static int atmel_probe(struct pcmcia_device *p_dev) p_dev->priv = local; -return atmel_config (p_dev); -}/* atmel_attach */ + ret =atmel_config (p_dev); +if (ret) + goto err_free_priv; + +return 0 ; + +err_free_priv: +kfree (p_dev->priv); +return ret; +}static void atmel_detach (struct pcmcia_device *link) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 135/800 wifi: wl3501_cs: Fix an error handling path in wl3501_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 391af06a02e7642039ac5f6c4b2c034ab0992b5d ]
Should wl3501_config() fail, some resources need to be released as already done in the remove function.
--- drivers/net/wireless/legacy/wl3501_cs.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/legacy/wl3501_cs.c +11 -5
@@ -1862,6 +1862,7 @@ static int wl3501_probe(struct pcmcia_device *p_dev) {struct net_device *dev;struct wl3501_card *this; +int ret;/* The io structure describes IO port mapping */ p_dev->resource[0 ]->end =16 ;
@@ -1873,8 +1874,7 @@ static int wl3501_probe(struct pcmcia_device *p_dev) dev =alloc_etherdev (sizeof (struct wl3501_card ));if (!dev) - goto out_link; - +return -ENOMEM ; dev->netdev_ops = &wl3501_netdev_ops; dev->watchdog_timeo =5 *HZ ;
@@ -1887,9 +1887,15 @@ static int wl3501_probe(struct pcmcia_device *p_dev)netif_stop_queue (dev); p_dev->priv = dev; -return wl3501_config (p_dev); -out_link: -return -ENOMEM ; + ret =wl3501_config (p_dev); +if (ret) + goto out_free_etherdev; + +return 0 ; + +out_free_etherdev: +free_netdev (dev); +return ret; }static int wl3501_config (struct pcmcia_device *link)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 136/800 wifi: ray_cs: Fix an error handling path in ray_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 4f8d66a9fb2edcd05c1e563456a55a08910bfb37 ]
Should ray_config() fail, some resources need to be released as already done in the remove function.
While at it, remove a useless and erroneous comment. The probe is ray_probe(), not ray_attach().
--- drivers/net/wireless/legacy/ray_cs.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/legacy/ray_cs.c +11 -5
@@ -270,13 +270,14 @@ static int ray_probe(struct pcmcia_device *p_dev) {ray_dev_t *local;struct net_device *dev; +int ret;dev_dbg (&p_dev->dev,"ray_attach()\n" );/* Allocate space for private device-specific data */ dev =alloc_etherdev (sizeof (ray_dev_t));if (!dev) - goto fail_alloc_dev; +return -ENOMEM ; local =netdev_priv (dev); local->finder = p_dev;
@@ -313,11 +314,16 @@ static int ray_probe(struct pcmcia_device *p_dev)timer_setup (&local->timer,NULL ,0 ); this_device = p_dev; -return ray_config (p_dev); + ret =ray_config (p_dev); +if (ret) + goto err_free_dev; + +return 0 ; -fail_alloc_dev: -return -ENOMEM ; -}/* ray_attach */ +err_free_dev: +free_netdev (dev); +return ret; +}static void ray_detach (struct pcmcia_device *link) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 137/800 wifi: ath9k: dont allow to overwrite ENDPOINT0 attributes
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit 061b0cb9327b80d7a0f63a33e7c3e2a91a71f142 ]
A bad USB device is able to construct a service connection response message with target endpoint being ENDPOINT0 which is reserved for HTC_CTRL_RSVD_SVC and should not be modified to be used for any other services.
Reject such service connection responses.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/htc_hst.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/htc_hst.c +7 -1
@@ -114,7 +114,13 @@ static void htc_process_conn_rsp(struct htc_target *target,if (svc_rspmsg->status ==HTC_SERVICE_SUCCESS ) { epid = svc_rspmsg->endpoint_id; -if (epid <0 || epid >=ENDPOINT_MAX ) + +/* Check that the received epid for the endpoint to attach +* a new service is valid. ENDPOINT0 can't be used here as it +* is already reserved for HTC_CTRL_RSVD_SVC service and thus +* should not be modified. +*/ +if (epid <=ENDPOINT0 || epid >=ENDPOINT_MAX )return ; service_id =be16_to_cpu (svc_rspmsg->service_id);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 138/800 wifi: rtw88: usb: silence log flooding error message
In reply to Greg Kroah-HartmanFrom: Sascha Hauer <[email protected]>
[ Upstream commit 1f1784a59caf3eefd127908a1a3cf224017ff9c7 ]
When receiving more rx packets than the kernel can handle the driver drops the packets and issues an error message. This is bad for two reasons. The logs are flooded with myriads of messages, but then time consumed for printing messages in that critical code path brings down the device. After some time of excessive rx load the driver responds with:
rtw_8822cu 1-1:1.2: failed to get tx report from firmware rtw_8822cu 1-1:1.2: firmware failed to report density after scan rtw_8822cu 1-1:1.2: firmware failed to report density after scan
The device stops working until being replugged.
Fix this by lowering the priority to debug level and also by ratelimiting it.
--- drivers/net/wireless/realtek/rtw88/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/usb.c +1 -1
@@ -535,7 +535,7 @@ static void rtw_usb_rx_handler(struct work_struct *work) }if (skb_queue_len (&rtwusb->rx_queue) >=RTW_USB_MAX_RXQ_LEN ) { -rtw_err (rtwdev,"failed to get rx_queue, overflow\n" ); +dev_dbg_ratelimited (rtwdev->dev,"failed to get rx_queue, overflow\n" );dev_kfree_skb_any (skb);continue ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 139/800 samples/bpf: xdp1 and xdp2 reduce XDPBUFSIZE to 60
In reply to Greg Kroah-HartmanFrom: Jesper Dangaard Brouer <[email protected]>
[ Upstream commit 60548b825b082cedf89b275c21c28b1e1d030e50 ]
Default samples/pktgen scripts send 60 byte packets as hardware adds 4-bytes FCS checksum, which fulfils minimum Ethernet 64 bytes frame size.
XDP layer will not necessary have access to the 4-bytes FCS checksum.
This leads to bpf_xdp_load_bytes() failing as it tries to copy 64-bytes from an XDP packet that only have 60-bytes available.
--- samples/bpf/xdp1_kern.c | 2 +- samples/bpf/xdp2_kern.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
samples/bpf/xdp1_kern.c +1 -1
@@ -39,7 +39,7 @@ static int parse_ipv6(void *data, u64 nh_off, void *data_end)return ip6h->nexthdr; } -#define XDPBUFSIZE 64 +#define XDPBUFSIZE 60 SEC("xdp.frags")int xdp_prog1 (struct xdp_md *ctx) {
samples/bpf/xdp2_kern.c +1 -1
@@ -55,7 +55,7 @@ static int parse_ipv6(void *data, u64 nh_off, void *data_end)return ip6h->nexthdr; } -#define XDPBUFSIZE 64 +#define XDPBUFSIZE 60 SEC("xdp.frags")int xdp_prog1 (struct xdp_md *ctx) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 140/800 wifi: ath10k: Trigger STA disconnect after reconfig complete on hardware restart
In reply to Greg Kroah-HartmanFrom: Youghandhar Chintala <[email protected]>
[ Upstream commit 75bd32f5ce94bc365ba0b9b68bcf9de84a391d37 ]
Currently, on WCN3990, the station disconnect after hardware recovery is not working as expected. This is because of setting the IEEE80211_SDATA_DISCONNECT_HW_RESTART flag very early in the hardware recovery process even before the driver invokes ieee80211_hw_restart(). On the contrary, mac80211 expects this flag to be set after ieee80211_hw_restart() is invoked for it to trigger station disconnect.
Set the IEEE80211_SDATA_DISCONNECT_HW_RESTART flag in ath10k_reconfig_complete() instead to fix this.
The other targets are not affected by this change, since the hardware params flag is not set.
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1
--- drivers/net/wireless/ath/ath10k/core.c | 9 --------- drivers/net/wireless/ath/ath10k/mac.c | 7 +++++++ 2 files changed, 7 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -9
@@ -2504,7 +2504,6 @@ EXPORT_SYMBOL(ath10k_core_napi_sync_disable);static void ath10k_core_restart (struct work_struct *work) { struct ath10k *ar = container_of(work, struct ath10k, restart_work); -struct ath10k_vif *arvif;int ret;set_bit (ATH10K_FLAG_CRASH_FLUSH , &ar->dev_flags);
@@ -2543,14 +2542,6 @@ static void ath10k_core_restart(struct work_struct *work) ar->state =ATH10K_STATE_RESTARTING ;ath10k_halt (ar);ath10k_scan_finish (ar); -if (ar->hw_params.hw_restart_disconnect) { -list_for_each_entry (arvif, &ar->arvifs, list) { -if (arvif->is_up && - arvif->vdev_type ==WMI_VDEV_TYPE_STA ) -ieee80211_hw_restart_disconnect (arvif->vif); - } - } -ieee80211_restart_hw (ar->hw);break ;case ATH10K_STATE_OFF :
drivers/net/wireless/ath/ath10k/mac.c +7 -0
@@ -8107,6 +8107,7 @@ static void ath10k_reconfig_complete(struct ieee80211_hw *hw, enum ieee80211_reconfig_type reconfig_type) {struct ath10k *ar = hw->priv; +struct ath10k_vif *arvif;if (reconfig_type !=IEEE80211_RECONFIG_TYPE_RESTART )return ;
@@ -8121,6 +8122,12 @@ static void ath10k_reconfig_complete(struct ieee80211_hw *hw, ar->state =ATH10K_STATE_ON ;ieee80211_wake_queues (ar->hw);clear_bit (ATH10K_FLAG_RESTARTING , &ar->dev_flags); +if (ar->hw_params.hw_restart_disconnect) { +list_for_each_entry (arvif, &ar->arvifs, list) { +if (arvif->is_up && arvif->vdev_type ==WMI_VDEV_TYPE_STA ) +ieee80211_hw_restart_disconnect (arvif->vif); + } + } }mutex_unlock (&ar->conf_mutex);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 141/800 bpf: Remove anonymous union in bpf_kfunc_call_arg_meta
In reply to Greg Kroah-HartmanFrom: Dave Marchevsky <[email protected]>
[ Upstream commit 4d585f48ee6b38c54c075b151c5efd2ff65f8ffd ]
For kfuncs like bpf_obj_drop and bpf_refcount_acquire - which take user-defined types as input - the verifier needs to track the specific type passed in when checking a particular kfunc call. This requires tracking (btf, btf_id) tuple. In commit 7c50b1cb76ac
("bpf: Add bpf_refcount_acquire kfunc") I added an anonymous union with inner structs named after the specific kfuncs tracking this information, with the goal of making it more obvious which kfunc this data was being tracked / expected to be tracked on behalf of.
In a recent series adding a new user of this tuple, Alexei mentioned that he didn't like this union usage as it doesn't really help with readability or bug-proofing ([0]). In an offline convo we agreed to have the tuple be fields (arg_btf, arg_btf_id), with comments in bpf_kfunc_call_arg_meta definition enumerating the uses of the fields by kfunc-specific handling logic. Such a pattern is used by struct bpf_reg_state without trouble.
Accordingly, this patch removes the anonymous union in favor of arg_btf and arg_btf_id fields and comment enumerating their current uses. The patch also removes struct btf_and_id, which was only being used by the removed union's inner structs.
This is a mechanical change, existing linked_list and rbtree tests will validate that correct (btf, btf_id) are being passed.
[0]: https://lore.kernel.org/bpf/20230505021707.vlyiwy57vwxglbka@dhcp-172-26-102-232.dhcp.thefacebook.com
Stable-dep-of: 2140a6e3422d ("bpf: Set kptr_struct_meta for node param to list and rbtree insert funcs")
--- kernel/bpf/verifier.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-)
kernel/bpf/verifier.c +22 -19
@@ -273,11 +273,6 @@ struct bpf_call_arg_meta {struct btf_field *kptr_field; }; -struct btf_and_id { -struct btf *btf; -u32 btf_id; -}; -struct bpf_kfunc_call_arg_meta {/* In parameters */ struct btf *btf;
@@ -296,10 +291,18 @@ struct bpf_kfunc_call_arg_meta {u64 value;bool found; } arg_constant; -union { -struct btf_and_id arg_obj_drop; -struct btf_and_id arg_refcount_acquire; - }; + +/* arg_btf and arg_btf_id are used by kfunc-specific handling, +* generally to pass info about user-defined local kptr types to later +* verification logic +* bpf_obj_drop +* Record the local kptr type to be drop'd +* bpf_refcount_acquire (via KF_ARG_PTR_TO_REFCOUNTED_KPTR arg type) +* Record the local kptr type to be refcount_incr'd +*/ +struct btf *arg_btf; +u32 arg_btf_id; +struct {struct btf_field *field; } arg_list_head;
@@ -10493,8 +10496,8 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_kfunc_call_ }if (meta->btf == btf_vmlinux && meta->func_id == special_kfunc_list[KF_bpf_obj_drop_impl]) { - meta->arg_obj_drop.btf = reg->btf; - meta->arg_obj_drop.btf_id = reg->btf_id; + meta->arg_btf = reg->btf; + meta->arg_btf_id = reg->btf_id; }break ;case KF_ARG_PTR_TO_DYNPTR :
@@ -10683,8 +10686,8 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_kfunc_call_verbose (env,"bpf_refcount_acquire calls are disabled for now\n" );return -EINVAL ; } - meta->arg_refcount_acquire.btf = reg->btf; - meta->arg_refcount_acquire.btf_id = reg->btf_id; + meta->arg_btf = reg->btf; + meta->arg_btf_id = reg->btf_id;break ; } }
@@ -10916,12 +10919,12 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn, }else if (meta.func_id == special_kfunc_list[KF_bpf_refcount_acquire_impl]) {mark_reg_known_zero (env, regs,BPF_REG_0 ); regs[BPF_REG_0 ].type =PTR_TO_BTF_ID |MEM_ALLOC ; - regs[BPF_REG_0 ].btf = meta.arg_refcount_acquire.btf; - regs[BPF_REG_0 ].btf_id = meta.arg_refcount_acquire.btf_id; + regs[BPF_REG_0 ].btf = meta.arg_btf; + regs[BPF_REG_0 ].btf_id = meta.arg_btf_id; insn_aux->kptr_struct_meta = -btf_find_struct_meta (meta.arg_refcount_acquire.btf, - meta.arg_refcount_acquire.btf_id); +btf_find_struct_meta (meta.arg_btf, + meta.arg_btf_id); }else if (meta.func_id == special_kfunc_list[KF_bpf_list_pop_front] || meta.func_id == special_kfunc_list[KF_bpf_list_pop_back]) {struct btf_field *field = meta.arg_list_head.field;
@@ -11051,8 +11054,8 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,if (meta.btf == btf_vmlinux &&btf_id_set_contains (&special_kfunc_set, meta.func_id)) {if (meta.func_id == special_kfunc_list[KF_bpf_obj_drop_impl]) { insn_aux->kptr_struct_meta = -btf_find_struct_meta (meta.arg_obj_drop.btf, - meta.arg_obj_drop.btf_id); +btf_find_struct_meta (meta.arg_btf, + meta.arg_btf_id); } } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 115/800 wifi: wilc1000: fix for absent RSN capabilities WFA testcase
In reply to Greg Kroah-HartmanFrom: Amisha Patel <[email protected]>
[ Upstream commit 9ce4bb09123e9754996e358bd808d39f5d112899 ]
Mandatory WFA testcase CT_Security_WPA2Personal_STA_RSNEBoundsVerification-AbsentRSNCap, performs bounds verfication on Beacon and/or Probe response frames. It failed and observed the reason to be absence of cipher suite and AKM suite in RSN information. To fix this, enable the RSN flag before extracting RSN capabilities.
--- drivers/net/wireless/microchip/wilc1000/hif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/microchip/wilc1000/hif.c +4 -4
@@ -485,6 +485,9 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,int rsn_ie_len =sizeof (struct element ) + rsn_ie[1 ];int offset =8 ; + param->mode_802_11i =2 ; + param->rsn_found = true; +/* extract RSN capabilities */ if (offset < rsn_ie_len) {/* skip over pairwise suites */
@@ -494,11 +497,8 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,/* skip over authentication suites */ offset += (rsn_ie[offset] *4 ) +2 ; -if (offset +1 < rsn_ie_len) { - param->mode_802_11i =2 ; - param->rsn_found = true; +if (offset +1 < rsn_ie_len)memcpy (param->rsn_cap, &rsn_ie[offset],2 ); - } } } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 142/800 bpf: Set kptr_struct_meta for node param to list and rbtree insert funcs
In reply to Greg Kroah-HartmanFrom: Dave Marchevsky <[email protected]>
[ Upstream commit 2140a6e3422de22e6ebe77d4d18b6c0c9c425426 ]
In verifier.c, fixup_kfunc_call uses struct bpf_insn_aux_data's kptr_struct_meta field to pass information about local kptr types to various helpers and kfuncs at runtime. The recent bpf_refcount series added a few functions to the set that need this information:
* bpf_refcount_acquire
* Needs to know where the refcount field is in order to increment
* Graph collection insert kfuncs: bpf_rbtree_add, bpf_list_push_{front,back}
* Were migrated to possibly fail by the bpf_refcount series. If insert fails, the input node is bpf_obj_drop'd. bpf_obj_drop needs the kptr_struct_meta in order to decr refcount and properly free special fields.
Unfortunately the verifier handling of collection insert kfuncs was not modified to actually populate kptr_struct_meta. Accordingly, when the node input to those kfuncs is passed to bpf_obj_drop, it is done so without the information necessary to decr refcount.
This patch fixes the issue by populating kptr_struct_meta for those kfuncs.
--- kernel/bpf/verifier.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/bpf/verifier.c +3 -0
@@ -10286,6 +10286,8 @@ __process_kf_arg_ptr_to_graph_node(struct bpf_verifier_env *env, node_off, btf_name_by_offset(reg->btf, t->name_off));return -EINVAL ; } + meta->arg_btf = reg->btf; + meta->arg_btf_id = reg->btf_id;if (node_off != field->graph_root.node_offset) { verbose(env, "arg#1 offset=%d, but expected %s at offset=%d in struct %s\n",
@@ -10833,6 +10835,7 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn, meta.func_id == special_kfunc_list[KF_bpf_rbtree_add_impl]) { release_ref_obj_id = regs[BPF_REG_2 ].ref_obj_id; insn_aux->insert_off = regs[BPF_REG_2 ].off; + insn_aux->kptr_struct_meta =btf_find_struct_meta (meta.arg_btf, meta.arg_btf_id); err =ref_convert_owning_non_owning (env, release_ref_obj_id);if (err) { verbose(env, "kfunc %s#%d conversion of owning ref to non-owning failed\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 143/800 bpf: Fix __bpf_{list,rbtree}_adds beginning-of-node calculation
In reply to Greg Kroah-HartmanFrom: Dave Marchevsky <[email protected]>
[ Upstream commit cc0d76cafebbd3e1ffab9c4252d48ecc9e0737f6 ]
Given the pointer to struct bpf_{rb,list}_node within a local kptr and the byte offset of that field within the kptr struct, the calculation changed by this patch is meant to find the beginning of the kptr so that it can be passed to bpf_obj_drop.
Unfortunately instead of doing
ptr_to_kptr = ptr_to_node_field - offset_bytes
the calculation is erroneously doing
ptr_to_ktpr = ptr_to_node_field - (offset_bytes * sizeof(struct bpf_rb_node))
or the bpf_list_node equivalent.
This patch fixes the calculation.
--- kernel/bpf/helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/helpers.c +2 -2
@@ -1943,7 +1943,7 @@ static int __bpf_list_add(struct bpf_list_node *node, struct bpf_list_head *headINIT_LIST_HEAD (h);if (!list_empty (n)) {/* Only called from BPF prog, no need to migrate_disable */ -__bpf_obj_drop_impl (n - off, rec); +__bpf_obj_drop_impl ((void *)n - off, rec);return -EINVAL ; }
@@ -2025,7 +2025,7 @@ static int __bpf_rbtree_add(struct bpf_rb_root *root, struct bpf_rb_node *node,if (!RB_EMPTY_NODE (n)) {/* Only called from BPF prog, no need to migrate_disable */ -__bpf_obj_drop_impl (n - off, rec); +__bpf_obj_drop_impl ((void *)n - off, rec);return -EINVAL ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 116/800 wifi: rtw88: unlock on error path in rtw_ops_add_interface()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e2ff1181b3d48257aab26bfd2165f3c7d271499f ]
Call mutex_unlock(&rtwdev->mutex); before returning on this error path.
--- drivers/net/wireless/realtek/rtw88/mac80211.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/mac80211.c +3 -1
@@ -164,8 +164,10 @@ static int rtw_ops_add_interface(struct ieee80211_hw *hw,mutex_lock (&rtwdev->mutex); port =find_first_zero_bit (rtwdev->hw_port,RTW_PORT_NUM ); -if (port >=RTW_PORT_NUM ) +if (port >=RTW_PORT_NUM ) { +mutex_unlock (&rtwdev->mutex);return -EINVAL ; + }set_bit (port, rtwdev->hw_port); rtwvif->port = port;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 117/800 wifi: mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit d9aef04fcfa81ee4fb2804a21a3712b7bbd936af ]
The type of "mwifiex_adapter->nd_info" is "struct cfg80211_wowlan_nd_info", not "struct cfg80211_wowlan_nd_match".
Use struct_size() to ease the computation of the needed size.
The current code over-allocates some memory, so is safe. But it wastes 32 bytes.
--- drivers/net/wireless/marvell/mwifiex/scan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/scan.c +3 -3
@@ -2187,9 +2187,9 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,if (nd_config) { adapter->nd_info = -kzalloc (sizeof (struct cfg80211_wowlan_nd_match ) + -sizeof (struct cfg80211_wowlan_nd_match *) * - scan_rsp->number_of_sets,GFP_ATOMIC ); +kzalloc (struct_size (adapter->nd_info, matches, + scan_rsp->number_of_sets), +GFP_ATOMIC );if (adapter->nd_info) adapter->nd_info->n_matches = scan_rsp->number_of_sets;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 118/800 net/handshake: Unpin sock->file if a handshake is cancelled
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit f921bd41001ccff2249f5f443f2917f7ef937daf ]
If user space never calls DONE, sock->file's reference count remains elevated. Enable sock->file to be freed eventually in this case.
--- net/handshake/handshake.h | 1 + net/handshake/request.c | 4 ++++ 2 files changed, 5 insertions(+)
net/handshake/handshake.h +1 -0
@@ -31,6 +31,7 @@ struct handshake_req {struct list_head hr_list;struct rhash_head hr_rhash;unsigned long hr_flags; +struct file *hr_file;const struct handshake_proto *hr_proto;struct sock *hr_sk;void (*hr_odestruct)(struct sock *sk);
net/handshake/request.c +4 -0
@@ -239,6 +239,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req, } req->hr_odestruct = req->hr_sk->sk_destruct; req->hr_sk->sk_destruct = handshake_sk_destruct; + req->hr_file = sock->file; ret = -EOPNOTSUPP ; net =sock_net (req->hr_sk);
@@ -334,6 +335,9 @@ bool handshake_req_cancel(struct sock *sk)return false; } +/* Request accepted and waiting for DONE */ +fput (req->hr_file); + out_true:trace_handshake_cancel (net, req, sk);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 119/800 sctp: add bpf_bypass_getsockopt proto callback
In reply to Greg Kroah-HartmanFrom: Alexander Mikhalitsyn <[email protected]>
[ Upstream commit 2598619e012cee5273a2821441b9a051ad931249 ]
Implement ->bpf_bypass_getsockopt proto callback and filter out SCTP_SOCKOPT_PEELOFF, SCTP_SOCKOPT_PEELOFF_FLAGS and SCTP_SOCKOPT_CONNECTX3 socket options from running eBPF hook on them.
SCTP_SOCKOPT_PEELOFF and SCTP_SOCKOPT_PEELOFF_FLAGS options do fd_install(), and if BPF_CGROUP_RUN_PROG_GETSOCKOPT hook returns an error after success of the original handler sctp_getsockopt(...), userspace will receive an error from getsockopt syscall and will be not aware that fd was successfully installed into a fdtable.
As pointed by Marcelo Ricardo Leitner it seems reasonable to skip bpf getsockopt hook for SCTP_SOCKOPT_CONNECTX3 sockopt too. Because internaly, it triggers connect() and if error is masked then userspace will be confused.
This patch was born as a result of discussion around a new SCM_PIDFD interface:
https://lore.kernel.org/all/[email protected]/
--- net/sctp/socket.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
net/sctp/socket.c +18 -0
@@ -8281,6 +8281,22 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,return retval; } +static bool sctp_bpf_bypass_getsockopt (int level,int optname) +{ +if (level ==SOL_SCTP ) { +switch (optname) { +case SCTP_SOCKOPT_PEELOFF : +case SCTP_SOCKOPT_PEELOFF_FLAGS : +case SCTP_SOCKOPT_CONNECTX3 : +return true; +default : +return false; + } + } + +return false; +} +static int sctp_hash (struct sock *sk) {/* STUB */
@@ -9650,6 +9666,7 @@ struct proto sctp_prot = { .shutdown = sctp_shutdown, .setsockopt = sctp_setsockopt, .getsockopt = sctp_getsockopt, + .bpf_bypass_getsockopt = sctp_bpf_bypass_getsockopt, .sendmsg = sctp_sendmsg, .recvmsg = sctp_recvmsg, .bind = sctp_bind,
@@ -9705,6 +9722,7 @@ struct proto sctpv6_prot = { .shutdown = sctp_shutdown, .setsockopt = sctp_setsockopt, .getsockopt = sctp_getsockopt, + .bpf_bypass_getsockopt = sctp_bpf_bypass_getsockopt, .sendmsg = sctp_sendmsg, .recvmsg = sctp_recvmsg, .bind = sctp_bind,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 120/800 sfc: release encap match in efx_tc_flow_free()
In reply to Greg Kroah-HartmanFrom: Edward Cree <[email protected]>
[ Upstream commit 28fa3ac487c6d30aaa10570481c27b6adfc492b3 ]
When force-freeing leftover entries from our match_action_ht, call
efx_tc_delete_rule(), which releases all the rule's resources, rather than open-coding it. The open-coded version was missing a call to release the rule's encap match (if any).
It probably doesn't matter as everything's being torn down anyway, but
it's cleaner this way and prevents further error messages potentially being logged by efx_tc_encap_match_free() later on.
Move efx_tc_flow_free() further down the file to avoid introducing a
forward declaration of efx_tc_delete_rule().
--- drivers/net/ethernet/sfc/tc.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
drivers/net/ethernet/sfc/tc.c +15 -17
@@ -132,23 +132,6 @@ static void efx_tc_free_action_set_list(struct efx_nic *efx,/* Don't kfree, as acts is embedded inside a struct efx_tc_flow_rule */ } -static void efx_tc_flow_free (void *ptr,void *arg) -{ -struct efx_tc_flow_rule *rule = ptr; -struct efx_nic *efx = arg; - -netif_err (efx, drv, efx->net_dev, -"tc rule %lx still present at teardown, removing\n" , - rule->cookie); - -efx_mae_delete_rule (efx, rule->fw_id); - -/* Release entries in subsidiary tables */ -efx_tc_free_action_set_list (efx, &rule->acts, true); - -kfree (rule); -} -/* Boilerplate for the simple 'copy a field' cases */ #define _MAP_KEY_AND_MASK (_name, _type, _tcget, _tcfield, _field) \ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_##_name)) { \
@@ -1451,6 +1434,21 @@ static void efx_tc_encap_match_free(void *ptr, void *__unused)kfree (encap); } +static void efx_tc_flow_free (void *ptr,void *arg) +{ +struct efx_tc_flow_rule *rule = ptr; +struct efx_nic *efx = arg; + +netif_err (efx, drv, efx->net_dev, +"tc rule %lx still present at teardown, removing\n" , + rule->cookie); + +/* Also releases entries in subsidiary tables */ +efx_tc_delete_rule (efx, rule); + +kfree (rule); +} +int efx_init_struct_tc (struct efx_nic *efx) {int rc;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 121/800 libbpf: fix offsetof() and container_of() to work with CO-RE
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit bdeeed3498c7871c17465bb4f11d1bc67f9098af ]
It seems like __builtin_offset() doesn't preserve CO-RE field relocations properly. So if offsetof() macro is defined through __builtin_offset(), CO-RE-enabled BPF code using container_of() will be subtly and silently broken.
To avoid this problem, redefine offsetof() and container_of() in the form that works with CO-RE relocations more reliably.
--- tools/lib/bpf/bpf_helpers.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
tools/lib/bpf/bpf_helpers.h +10 -5
@@ -77,16 +77,21 @@/* * Helper macros to manipulate data structures */ -#ifndef offsetof -#define offsetof (TYPE ,MEMBER ) ((unsigned long)&((TYPE *)0)->MEMBER) -#endif -#ifndef container_of + +/* offsetof() definition that uses __builtin_offset() might not preserve field +* offset CO-RE relocation properly, so force-redefine offsetof() using +* old-school approach which works with CO-RE correctly +*/ +#undef offsetof +#define offsetof (type, member) ((unsigned long)&((type *)0)->member) + +/* redefined container_of() to ensure we use the above offsetof() macro */ +#undef container_of#define container_of (ptr, type, member) \ ({ \ void *__mptr = (void *)(ptr); \ ((type *)(__mptr - offsetof(type, member))); \ }) -#endif /* * Compiler (optimization) barrier.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 112/800 wifi: rtw89: fix rtw89_read_chip_ver() for RTL8852B and RTL8851B
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 9d4f491b860ea6d04471c3342093b86a46eee63e ]
The if statement is reversed so it will not record the chip version. This was detected using Smatch:
drivers/net/wireless/realtek/rtw89/core.c:3593 rtw89_read_chip_ver()
error: uninitialized symbol 'val'.
--- drivers/net/wireless/realtek/rtw89/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/core.c +1 -1
@@ -3584,7 +3584,7 @@ static void rtw89_read_chip_ver(struct rtw89_dev *rtwdev)if (chip->chip_id ==RTL8852B || chip->chip_id ==RTL8851B ) { ret =rtw89_mac_read_xtal_si (rtwdev,XTAL_SI_CV , &val); -if (!ret) +if (ret)return ; rtwdev->hal.acv =u8_get_bits (val,XTAL_SI_ACV_MASK );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 145/800 tools/resolve_btfids: Fix setting HOSTCFLAGS
In reply to Greg Kroah-HartmanFrom: Viktor Malik <[email protected]>
[ Upstream commit edd75c802855271c8610f58a2fc9e54aefc49ce5 ]
Building BPF selftests with custom HOSTCFLAGS yields an error:
# make HOSTCFLAGS="-O2"
[...]
HOSTCC ./tools/testing/selftests/bpf/tools/build/resolve_btfids/main.o
main.c:73:10: fatal error: linux/rbtree.h: No such file or directory
73 | #include <linux/rbtree.h>
| ^~~~~~~~~~~~~~~~The reason is that tools/bpf/resolve_btfids/Makefile passes header include paths by extending HOSTCFLAGS which is overridden by setting HOSTCFLAGS in the make command (because of Makefile rules [1]).
This patch fixes the above problem by passing the include paths via HOSTCFLAGS_resolve_btfids which is used by tools/build/Build.include and can be combined with overridding HOSTCFLAGS.
[1] https://www.gnu.org/software/make/manual/html_node/Overriding.html
--- tools/bpf/resolve_btfids/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/bpf/resolve_btfids/Makefile +2 -2
@@ -67,7 +67,7 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf) -HOSTCFLAGS += -g \ +HOSTCFLAGS_resolve_btfids += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \
@@ -76,7 +76,7 @@ HOSTCFLAGS += -g \ LIBS = $(LIBELF_LIBS) -lz -export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR +export srctree OUTPUT HOSTCFLAGS_resolve_btfids Q HOSTCC HOSTLD HOSTAR include $(srctree)/tools/build/Makefile.include $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 154/800 selftests: cgroup: fix unexpected failure on test_memcg_low
In reply to Greg Kroah-HartmanFrom: Haifeng Xu <[email protected]>
[ Upstream commit 19ab365762c6cc39dfdee9e13ab0d12fe4b5540d ]
Since commit f079a020ba95 ("selftests: memcg: factor out common parts of memory.{low,min} tests"), the value used in second alloc_anon has changed from 148M to 170M. Because memory.low allows reclaiming page cache in child cgroups, so the memory.current is close to 30M instead of 50M. Therefore, adjust the expected value of parent cgroup.
--- tools/testing/selftests/cgroup/test_memcontrol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/cgroup/test_memcontrol.c +3 -1
@@ -292,6 +292,7 @@ static int test_memcg_protection(const char *root, bool min)char *children[4 ] = {NULL };const char *attribute = min ?"memory.min" :"memory.low" ;long c[4 ]; +long current;int i, attempts;int fd;
@@ -400,7 +401,8 @@ static int test_memcg_protection(const char *root, bool min) goto cleanup; } -if (!values_close (cg_read_long (parent[1 ],"memory.current" ),MB (50 ),3 )) + current = min ?MB (50 ) :MB (30 ); +if (!values_close (cg_read_long (parent[1 ],"memory.current" ), current,3 )) goto cleanup;if (!reclaim_until (children[0 ],MB (10 )))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 155/800 watchdog/perf: define dummy watchdog_update_hrtimer_threshold() on correct config
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 5e008df11c55228a86a1bae692cc2002503572c9 ]
Patch series "watchdog/hardlockup: Add the buddy hardlockup detector", v5.
This patch series adds the "buddy" hardlockup detector. In brief, the buddy hardlockup detector can detect hardlockups without arch-level support by having CPUs checkup on a "buddy" CPU periodically.
Given the new design of this patch series, testing all combinations is fairly difficult. I've attempted to make sure that all combinations of CONFIG_ options are good, but it wouldn't surprise me if I missed something. I apologize in advance and I'll do my best to fix any problems that are found.
This patch (of 18):
The real watchdog_update_hrtimer_threshold() is defined in kernel/watchdog_hld.c. That file is included if CONFIG_HARDLOCKUP_DETECTOR_PERF and the function is defined in that file if CONFIG_HARDLOCKUP_CHECK_TIMESTAMP.
The dummy version of the function in "nmi.h" didn't get that quite right. While this doesn't appear to be a huge deal, it's nice to make it consistent.
It doesn't break builds because CHECK_TIMESTAMP is only defined by x86 so others don't get a double definition, and x86 uses perf lockup detector, so it gets the out of line version.
--- include/linux/nmi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/nmi.h +1 -1
@@ -197,7 +197,7 @@ u64 hw_nmi_get_sample_period(int watchdog_thresh);#endif #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP ) && \ - defined(CONFIG_HARDLOCKUP_DETECTOR ) + defined(CONFIG_HARDLOCKUP_DETECTOR_PERF )void watchdog_update_hrtimer_threshold (u64 period);#else static inline void watchdog_update_hrtimer_threshold (u64 period) { }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 156/800 watchdog/perf: more properly prevent false positives with turbo modes
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 4379e59fe5665cfda737e45b8bf2f05321ef049c ]
Currently, in the watchdog_overflow_callback() we first check to see if the watchdog had been touched and _then_ we handle the workaround for turbo mode. This order should be reversed.
Specifically, "touching" the hardlockup detector's watchdog should avoid lockups being detected for one period that should be roughly the same regardless of whether we're running turbo or not. That means that we should do the extra accounting for turbo _before_ we look at (and clear) the global indicating that we've been touched.
NOTE: this fix is made based on code inspection. I am not aware of any reports where the old code would have generated false positives. That being said, this order seems more correct and also makes it easier down the line to share code with the "buddy" hardlockup detector.
--- kernel/watchdog_hld.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/watchdog_hld.c +3 -3
@@ -114,14 +114,14 @@ static void watchdog_overflow_callback(struct perf_event *event,/* Ensure the watchdog never gets throttled */ event->hw.interrupts =0 ; +if (!watchdog_check_timestamp ()) +return ; +if (__this_cpu_read (watchdog_nmi_touch) == true) {__this_cpu_write (watchdog_nmi_touch, false);return ; } -if (!watchdog_check_timestamp ()) -return ; -/* check for a hardlockup * This is done by making sure our timer interrupt * is incrementing. The timer interrupt should have
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 157/800 kexec: fix a memory leak in crash_shrink_memory()
In reply to Greg Kroah-HartmanFrom: Zhen Lei <[email protected]>
[ Upstream commit 1cba6c4309f03de570202c46f03df3f73a0d4c82 ]
Patch series "kexec: enable kexec_crash_size to support two crash kernel regions".
When crashkernel=X fails to reserve region under 4G, it will fall back to reserve region above 4G and a region of the default size will also be reserved under 4G. Unfortunately, /sys/kernel/kexec_crash_size only supports one crash kernel region now, the user cannot sense the low memory reserved by reading /sys/kernel/kexec_crash_size. Also, low memory cannot be freed by writing this file.
For example:resource_size(crashk_res) = 512Mresource_size(crashk_low_res) = 256M
The result of 'cat /sys/kernel/kexec_crash_size' is 512M, but it should be 768M. When we execute 'echo 0 > /sys/kernel/kexec_crash_size', the size of crashk_res becomes 0 and resource_size(crashk_low_res) is still 256 MB, which is incorrect.
Since crashk_res manages the memory with high address and crashk_low_res manages the memory with low address, crashk_low_res is shrunken only when all crashk_res is shrunken. And because when there is only one crash kernel region, crashk_res is always used. Therefore, if all crashk_res is shrunken and crashk_low_res still exists, swap them.
This patch (of 6):
If the value of parameter 'new_size' is in the semi-open and semi-closed interval (crashk_res.end - KEXEC_CRASH_MEM_ALIGN + 1, crashk_res.end], the calculation result of ram_res is:
ram_res->start = crashk_res.end + 1 ram_res->end = crashk_res.end
The operation of insert_resource() fails, and ram_res is not added to iomem_resource. As a result, the memory of the control block ram_res is leaked.
In fact, on all architectures, the start address and size of crashk_res are already aligned by KEXEC_CRASH_MEM_ALIGN. Therefore, we do not need to round up crashk_res.start again. Instead, we should round up 'new_size' in advance.
--- kernel/kexec_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/kexec_core.c +2 -3
@@ -1122,6 +1122,7 @@ int crash_shrink_memory(unsigned long new_size) start = crashk_res.start; end = crashk_res.end; old_size = (end ==0 ) ?0 : end - start +1 ; + new_size =roundup (new_size,KEXEC_CRASH_MEM_ALIGN );if (new_size >= old_size) { ret = (new_size == old_size) ?0 : -EINVAL ; goto unlock;
@@ -1133,9 +1134,7 @@ int crash_shrink_memory(unsigned long new_size) goto unlock; } - start =roundup (start,KEXEC_CRASH_MEM_ALIGN ); - end =roundup (start + new_size,KEXEC_CRASH_MEM_ALIGN ); - + end = start + new_size;crash_free_reserved_phys_range (end, crashk_res.end);if ((start == end) && (crashk_res.parent !=NULL ))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 158/800 mmc: mediatek: Avoid ugly error message when SDIO wakeup IRQ isnt used
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit a3332b7aad346b14770797e03ddd02ebdb14db41 ]
When I boot a kukui-kodama board, I see an ugly warning in my kernel log:
mtk-msdc 11240000.mmc: error -ENXIO: IRQ sdio_wakeup not found
It's pretty normal not to have an "sdio_wakeup" IRQ defined. In fact, no device trees in mainline seem to have it. Let's use the platform_get_irq_byname_optional() to avoid the error message.
--- drivers/mmc/host/mtk-sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/mtk-sd.c +1 -1
@@ -2707,7 +2707,7 @@ static int msdc_drv_probe(struct platform_device *pdev)/* Support for SDIO eint irq ? */ if ((mmc->pm_caps &MMC_PM_WAKE_SDIO_IRQ ) && (mmc->pm_caps &MMC_PM_KEEP_POWER )) { - host->eint_irq =platform_get_irq_byname (pdev,"sdio_wakeup" ); + host->eint_irq =platform_get_irq_byname_optional (pdev,"sdio_wakeup" );if (host->eint_irq >0 ) { host->pins_eint =pinctrl_lookup_state (host->pinctrl,"state_eint" );if (IS_ERR (host->pins_eint)) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 159/800 memstick r592: make memstick_debug_get_tpc_name() static
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 434587df9f7fd68575f99a889cc5f2efc2eaee5e ]
There are no other files referencing this function, apparently it was left global to avoid an 'unused function' warning when the only caller is left out. With a 'W=1' build, it causes a 'missing prototype' warning though:
drivers/memstick/host/r592.c:47:13: error: no previous prototype for 'memstick_debug_get_tpc_name' [-Werror=missing-prototypes]
Annotate the function as 'static __maybe_unused' to avoid both problems.
--- drivers/memstick/host/r592.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/memstick/host/r592.c +1 -3
@@ -44,12 +44,10 @@ static const char *tpc_names[] = {* memstick_debug_get_tpc_name - debug helper that returns string for * a TPC number */ -const char *memstick_debug_get_tpc_name (int tpc) +static __maybe_unused const char *memstick_debug_get_tpc_name (int tpc) {return tpc_names[tpc-1 ]; } -EXPORT_SYMBOL (memstick_debug_get_tpc_name); -/* Read a register*/ static inline u32 r592_read_reg (struct r592_device *dev,int address)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 160/800 selftests/bpf: Fix invalid pointer check in get_xlated_program()
In reply to Greg Kroah-HartmanFrom: Eduard Zingerman <[email protected]>
[ Upstream commit b23ed4d74c4d583b5f621ee4c776699442833554 ]
Dan Carpenter reported invalid check for calloc() result in test_verifier.c:get_xlated_program():
./tools/testing/selftests/bpf/test_verifier.c:1365 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 1364)
./tools/testing/selftests/bpf/test_verifier.c
1363 *cnt = xlated_prog_len / buf_element_size;
1364 *buf = calloc(*cnt, buf_element_size);
1365 if (!buf) {
This should be if (!*buf) { 1366 perror("can't allocate xlated program buffer");
1367 return -ENOMEM;This commit refactors the get_xlated_program() to avoid using double pointer type.
--- tools/testing/selftests/bpf/test_verifier.c | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-)
tools/testing/selftests/bpf/test_verifier.c +13 -11
@@ -1227,45 +1227,46 @@ static bool cmp_str_seq(const char *log, const char *exp)return true; } -static int get_xlated_program (int fd_prog,struct bpf_insn **buf,int *cnt) +static struct bpf_insn *get_xlated_program (int fd_prog,int *cnt) { +__u32 buf_element_size =sizeof (struct bpf_insn );struct bpf_prog_info info = {};__u32 info_len =sizeof (info);__u32 xlated_prog_len; -__u32 buf_element_size =sizeof (struct bpf_insn ); +struct bpf_insn *buf;if (bpf_prog_get_info_by_fd (fd_prog, &info, &info_len)) {perror ("bpf_prog_get_info_by_fd failed" ); -return -1 ; +return NULL ; } xlated_prog_len = info.xlated_prog_len;if (xlated_prog_len % buf_element_size) {printf ("Program length %d is not multiple of %d\n" , xlated_prog_len, buf_element_size); -return -1 ; +return NULL ; } *cnt = xlated_prog_len / buf_element_size; - *buf =calloc (*cnt, buf_element_size); + buf =calloc (*cnt, buf_element_size);if (!buf) {perror ("can't allocate xlated program buffer" ); -return -ENOMEM ; +return NULL ; }bzero (&info,sizeof (info)); info.xlated_prog_len = xlated_prog_len; - info.xlated_prog_insns = (__u64 )(unsigned long )*buf; + info.xlated_prog_insns = (__u64 )(unsigned long )buf;if (bpf_prog_get_info_by_fd (fd_prog, &info, &info_len)) {perror ("second bpf_prog_get_info_by_fd failed" ); goto out_free_buf; } -return 0 ; +return buf; out_free_buf: -free (*buf); -return -1 ; +free (buf); +return NULL ; }static bool is_null_insn (struct bpf_insn *insn)
@@ -1398,7 +1399,8 @@ static bool check_xlated_program(struct bpf_test *test, int fd_prog)if (!check_expected && !check_unexpected) goto out; -if (get_xlated_program (fd_prog, &buf, &cnt)) { + buf =get_xlated_program (fd_prog, &cnt); +if (!buf) {printf ("FAIL: can't get xlated program\n" ); result = false; goto out;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 161/800 wifi: ath9k: Fix possible stall on ath9k_txq_list_has_key()
In reply to Greg Kroah-HartmanFrom: Remi Pommarel <[email protected]>
[ Upstream commit 75086cc6dee046e3fbb3dba148b376d8802f83bc ]
On EDMA capable hardware, ath9k_txq_list_has_key() can enter infinite loop if it is called while all txq_fifos have packets that use different key that the one we are looking for. Fix it by exiting the loop if all txq_fifos have been checked already.
Because this loop is called under spin_lock_bh() (see ath_txq_lock) it causes the following rcu stall:
rcu: INFO: rcu_sched self-detected stall on CPU
ath10k_pci 0000:01:00.0: failed to read temperature -11
rcu: 1-....: (5254 ticks this GP) idle=189/1/0x4000000000000002 softirq=8442983/8442984 fqs=2579
(t=5257 jiffies g=17983297 q=334)
Task dump for CPU 1:
task:hostapd state:R running task stack: 0 pid: 297 ppid: 289 flags:0x0000000a
Call trace:
dump_backtrace+0x0/0x170
show_stack+0x1c/0x24
sched_show_task+0x140/0x170
dump_cpu_task+0x48/0x54
rcu_dump_cpu_stacks+0xf0/0x134
rcu_sched_clock_irq+0x8d8/0x9fc
update_process_times+0xa0/0xec
tick_sched_timer+0x5c/0xd0
__hrtimer_run_queues+0x154/0x320
hrtimer_interrupt+0x120/0x2f0
arch_timer_handler_virt+0x38/0x44
handle_percpu_devid_irq+0x9c/0x1e0
handle_domain_irq+0x64/0x90
gic_handle_irq+0x78/0xb0
call_on_irq_stack+0x28/0x38
do_interrupt_handler+0x54/0x5c
el1_interrupt+0x2c/0x4c
el1h_64_irq_handler+0x14/0x1c
el1h_64_irq+0x74/0x78
ath9k_txq_has_key+0x1bc/0x250 [ath9k]
ath9k_set_key+0x1cc/0x3dc [ath9k]
drv_set_key+0x78/0x170
ieee80211_key_replace+0x564/0x6cc
ieee80211_key_link+0x174/0x220
ieee80211_add_key+0x11c/0x300
nl80211_new_key+0x12c/0x330
genl_family_rcv_msg_doit+0xbc/0x11c
genl_rcv_msg+0xd8/0x1c4
netlink_rcv_skb+0x40/0x100
genl_rcv+0x3c/0x50
netlink_unicast+0x1ec/0x2c0
netlink_sendmsg+0x198/0x3c0
____sys_sendmsg+0x210/0x250
___sys_sendmsg+0x78/0xc4
__sys_sendmsg+0x4c/0x90
__arm64_sys_sendmsg+0x28/0x30
invoke_syscall.constprop.0+0x60/0x100
do_el0_svc+0x48/0xd0
el0_svc+0x14/0x50
el0t_64_sync_handler+0xa8/0xb0
el0t_64_sync+0x158/0x15cThis rcu stall is hard to reproduce as is, but changing ATH_TXFIFO_DEPTH from 8 to 2 makes it reasonably easy to reproduce.
--- drivers/net/wireless/ath/ath9k/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +4 -3
@@ -850,7 +850,7 @@ static bool ath9k_txq_list_has_key(struct list_head *txq_list, u32 keyix)static bool ath9k_txq_has_key (struct ath_softc *sc,u32 keyix) {struct ath_hw *ah = sc->sc_ah; -int i; +int i, j;struct ath_txq *txq;bool key_in_use = false;
@@ -868,8 +868,9 @@ static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix)if (sc->sc_ah->caps.hw_caps &ATH9K_HW_CAP_EDMA ) {int idx = txq->txq_tailidx; -while (!key_in_use && - !list_empty (&txq->txq_fifo[idx])) { +for (j =0 ; !key_in_use && + !list_empty (&txq->txq_fifo[idx]) && + j <ATH_TXFIFO_DEPTH ; j++) { key_in_use =ath9k_txq_list_has_key ( &txq->txq_fifo[idx], keyix);INCR (idx,ATH_TXFIFO_DEPTH );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 162/800 bpf: Use scalar ids in mark_chain_precision()
In reply to Greg Kroah-HartmanFrom: Eduard Zingerman <[email protected]>
[ Upstream commit 904e6ddf4133c52fdb9654c2cd2ad90f320d48b9 ]
Change mark_chain_precision() to track precision in situations like below:
r2 = unknown value
...
--- state #0 ---
...
r1 = r2 // r1 and r2 now share the same ID
...
--- state #1 {r1.id = A, r2.id = A} ---
...
if (r2 > 10) goto exit; // find_equal_scalars() assigns range to r1
...
--- state #2 {r1.id = A, r2.id = A} ---
r3 = r10
r3 += r1 // need to mark both r1 and r2At the beginning of the processing of each state, ensure that if a register with a scalar ID is marked as precise, all registers sharing this ID are also marked as precise.
This property would be used by a follow-up change in regsafe().
Stable-dep-of: 1ffc85d9298e ("bpf: Verify scalar ids mapping in regsafe() using check_ids()")
--- include/linux/bpf_verifier.h | 10 +- kernel/bpf/verifier.c | 115 ++++++++++++++++++ .../testing/selftests/bpf/verifier/precise.c | 8 +- 3 files changed, 128 insertions(+), 5 deletions(-)
include/linux/bpf_verifier.h +9 -1
@@ -557,6 +557,11 @@ struct backtrack_state {u64 stack_masks[MAX_CALL_FRAMES ]; }; +struct bpf_idset { +u32 count; +u32 ids[BPF_ID_MAP_SIZE ]; +}; +/* single container for all structs * one verifier_env per bpf_check() call */
@@ -588,7 +593,10 @@ struct bpf_verifier_env {const struct bpf_line_info *prev_linfo;struct bpf_verifier_log log;struct bpf_subprog_info subprog_info[BPF_MAX_SUBPROGS +1 ]; -struct bpf_id_pair idmap_scratch[BPF_ID_MAP_SIZE ]; +union { +struct bpf_id_pair idmap_scratch[BPF_ID_MAP_SIZE ]; +struct bpf_idset idset_scratch; + };struct {int *insn_state;int *insn_stack;
kernel/bpf/verifier.c +115 -0
127 lines not on this page · raw message
tools/testing/selftests/bpf/verifier/precise.c +4 -4
@@ -46,7 +46,7 @@ mark_precise: frame0: regs=r2 stack= before 20\ mark_precise: frame0: parent state regs=r2 stack=:\ mark_precise: frame0: last_idx 19 first_idx 10\ - mark_precise: frame0: regs=r2 stack= before 19\ + mark_precise: frame0: regs=r2,r9 stack= before 19\ mark_precise: frame0: regs=r9 stack= before 18\ mark_precise: frame0: regs=r8,r9 stack= before 17\ mark_precise: frame0: regs=r0,r9 stack= before 15\
@@ -106,10 +106,10 @@ mark_precise: frame0: regs=r2 stack= before 22\ mark_precise: frame0: parent state regs=r2 stack=:\ mark_precise: frame0: last_idx 20 first_idx 20\ - mark_precise: frame0: regs=r2 stack= before 20\ - mark_precise: frame0: parent state regs=r2 stack=:\ + mark_precise: frame0: regs=r2,r9 stack= before 20\ + mark_precise: frame0: parent state regs=r2,r9 stack=:\ mark_precise: frame0: last_idx 19 first_idx 17\ - mark_precise: frame0: regs=r2 stack= before 19\ + mark_precise: frame0: regs=r2,r9 stack= before 19\ mark_precise: frame0: regs=r9 stack= before 18\ mark_precise: frame0: regs=r8,r9 stack= before 17\ mark_precise: frame0: parent state regs= stack=:",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 163/800 bpf: Verify scalar ids mapping in regsafe() using check_ids()
In reply to Greg Kroah-HartmanFrom: Eduard Zingerman <[email protected]>
[ Upstream commit 1ffc85d9298e0ca0137ba65c93a786143fe167b8 ]
Make sure that the following unsafe example is rejected by verifier:
1: r9 = ... some pointer with range X ...
2: r6 = ... unbound scalar ID=a ...
3: r7 = ... unbound scalar ID=b ...
4: if (r6 > r7) goto +1
5: r6 = r7
6: if (r6 > X) goto ...
--- checkpoint ---
7: r9 += r7
8: *(u64 *)r9 = Y
This example is unsafe because not all execution paths verify r7 range. Because of the jump at (4) the verifier would arrive at (6) in two states:
I. r6{.id=b}, r7{.id=b} via path 1-6;
II. r6{.id=a}, r7{.id=b} via path 1-4, 6.
Currently regsafe() does not call check_ids() for scalar registers, thus from POV of regsafe() states (I) and (II) are identical. If the path 1-6 is taken by verifier first, and checkpoint is created at (6) the path [1-4, 6] would be considered safe.
Changes in this commit:
- check_ids() is modified to disallow mapping multiple old_id to the same cur_id.
- check_scalar_ids() is added, unlike check_ids() it treats ID zero as a unique scalar ID.
- check_scalar_ids() needs to generate temporary unique IDs, field 'tmp_id_gen' is added to bpf_verifier_env::idmap_scratch to facilitate this.
- regsafe() is updated to:
- use check_scalar_ids() for precise scalar registers.
- compare scalar registers using memcmp only for explore_alu_limits branch. This simplifies control flow for scalar case, and has no measurable performance impact.
- check_alu_op() is updated to avoid generating bpf_reg_state::id for constant scalar values when processing BPF_MOV. ID is needed to propagate range information for identical values, but there is nothing to propagate for constants.
--- include/linux/bpf_verifier.h | 17 ++++--- kernel/bpf/verifier.c | 91 +++++++++++++++++++++++++++--------- 2 files changed, 79 insertions(+), 29 deletions(-)
include/linux/bpf_verifier.h +11 -6
@@ -313,11 +313,6 @@ struct bpf_idx_pair {u32 idx; }; -struct bpf_id_pair { -u32 old; -u32 cur; -}; -#define MAX_CALL_FRAMES 8/* Maximum number of register states that can exist at once */ #define BPF_ID_MAP_SIZE ((MAX_BPF_REG + MAX_BPF_STACK / BPF_REG_SIZE) * MAX_CALL_FRAMES)
@@ -557,6 +552,16 @@ struct backtrack_state {u64 stack_masks[MAX_CALL_FRAMES ]; }; +struct bpf_id_pair { +u32 old; +u32 cur; +}; + +struct bpf_idmap { +u32 tmp_id_gen; +struct bpf_id_pair map[BPF_ID_MAP_SIZE ]; +}; +struct bpf_idset {u32 count;u32 ids[BPF_ID_MAP_SIZE ];
@@ -594,7 +599,7 @@ struct bpf_verifier_env {struct bpf_verifier_log log;struct bpf_subprog_info subprog_info[BPF_MAX_SUBPROGS +1 ];union { -struct bpf_id_pair idmap_scratch[BPF_ID_MAP_SIZE ]; +struct bpf_idmap idmap_scratch;struct bpf_idset idset_scratch; };struct {
kernel/bpf/verifier.c +68 -23
185 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 146/800 wifi: iwlwifi: mvm: send time sync only if needed
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit ead65aa2d5155728baec90f6404cd02618ef29d0 ]
If there's no peer configured then there's no point in sending the command down to the firmware with an invalid peer address.
--- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +5 -3
@@ -1699,9 +1699,11 @@ int iwl_mvm_up(struct iwl_mvm *mvm)if (test_bit (IWL_MVM_STATUS_IN_HW_RESTART , &mvm->status)) {iwl_mvm_send_recovery_cmd (mvm,ERROR_RECOVERY_UPDATE_DB ); -iwl_mvm_time_sync_config (mvm, mvm->time_sync.peer_addr, -IWL_TIME_SYNC_PROTOCOL_TM | -IWL_TIME_SYNC_PROTOCOL_FTM ); + +if (mvm->time_sync.active) +iwl_mvm_time_sync_config (mvm, mvm->time_sync.peer_addr, +IWL_TIME_SYNC_PROTOCOL_TM | +IWL_TIME_SYNC_PROTOCOL_FTM ); }if (!mvm->ptp_data.ptp_clock)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 164/800 wifi: mac80211: Fix permissions for valid_links debugfs entry
In reply to Greg Kroah-HartmanFrom: Ilan Peer <[email protected]>
[ Upstream commit 4cacadc0dbd8013e6161aa8843d8e9d8ad435b47 ]
The entry should be a read only one and not a write only one. Fix it.
--- net/mac80211/debugfs_netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/debugfs_netdev.c +1 -1
@@ -717,7 +717,7 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata)DEBUGFS_ADD_MODE (uapsd_queues,0600 );DEBUGFS_ADD_MODE (uapsd_max_sp_len,0600 );DEBUGFS_ADD_MODE (tdls_wider_bw,0600 ); -DEBUGFS_ADD_MODE (valid_links,0200 ); +DEBUGFS_ADD_MODE (valid_links,0400 );DEBUGFS_ADD_MODE (active_links,0600 ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 165/800 wifi: iwlwifi: mvm: Handle return value for iwl_mvm_sta_init
In reply to Greg Kroah-HartmanFrom: Mukesh Sisodiya <[email protected]>
[ Upstream commit 8d507812cb4bb3c3b05404a7dda70b32a1fc1324 ]
sta_init function can fail and if it returns an error then driver should not send the request to fw to add a station.
--- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/sta.c +2 -0
@@ -1859,6 +1859,8 @@ int iwl_mvm_add_sta(struct iwl_mvm *mvm, ret =iwl_mvm_sta_init (mvm, vif, sta, sta_id, sta->tdls ?IWL_STA_TDLS_LINK :IWL_STA_LINK ); +if (ret) + goto err; update_fw: ret =iwl_mvm_sta_send_to_fw (mvm, sta, sta_update, sta_flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 166/800 wifi: iwlwifi: fw: print PC register value instead of address
In reply to Greg Kroah-HartmanFrom: Mukesh Sisodiya <[email protected]>
[ Upstream commit 2b69d242e29b891b11f1190201f4a08abb0c8342 ]
The program counter address is read from the TLV and PC address is printed in debug messages. Read the value at PC address and print the value instead of the register address.
--- drivers/net/wireless/intel/iwlwifi/fw/dump.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/fw/dump.c +6 -1
@@ -507,11 +507,16 @@ void iwl_fwrt_dump_error_logs(struct iwl_fw_runtime *fwrt)iwl_fwrt_dump_fseq_regs (fwrt);if (fwrt->trans->trans_cfg->device_family >=IWL_DEVICE_FAMILY_22000 ) { pc_data = fwrt->trans->dbg.pc_data; + +if (!iwl_trans_grab_nic_access (fwrt->trans)) +return ;for (count =0 ; count < fwrt->trans->dbg.num_pc; count++, pc_data++)IWL_ERR (fwrt,"%s: 0x%x\n" , pc_data->pc_name, - pc_data->pc_address); +iwl_read_prph_no_grab (fwrt->trans, + pc_data->pc_address)); +iwl_trans_release_nic_access (fwrt->trans); }if (fwrt->trans->trans_cfg->device_family >=IWL_DEVICE_FAMILY_BZ ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 167/800 rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO
In reply to Greg Kroah-HartmanFrom: Edwin Peer <[email protected]>
[ Upstream commit fa0e21fa44438a0e856d42224bfa24641d37b979 ]
This filter already exists for excluding IPv6 SNMP stats. Extend its definition to also exclude IFLA_VF_INFO stats in RTM_GETLINK.
This patch constitutes a partial fix for a netlink attribute nesting overflow bug in IFLA_VFINFO_LIST. By excluding the stats when the requester doesn't need them, the truncation of the VF list is avoided.
While it was technically only the stats added in commit c5a9f6f0ab40 ("net/core: Add drop counters to VF statistics") breaking the camel's back, the appreciable size of the stats data should never have been included without due consideration for the maximum number of VFs supported by PCI.
--- net/core/rtnetlink.c | 96 +++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 45 deletions(-)
net/core/rtnetlink.c +51 -45
@@ -961,24 +961,27 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,nla_total_size (sizeof (struct ifla_vf_rate )) +nla_total_size (sizeof (struct ifla_vf_link_state )) +nla_total_size (sizeof (struct ifla_vf_rss_query_en )) + -nla_total_size (0 ) +/* nest IFLA_VF_STATS */ -/* IFLA_VF_STATS_RX_PACKETS */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_TX_PACKETS */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_RX_BYTES */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_TX_BYTES */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_BROADCAST */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_MULTICAST */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_RX_DROPPED */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_TX_DROPPED */ -nla_total_size_64bit (sizeof (__u64)) + nla_total_size(sizeof(struct ifla_vf_trust))); +if (~ext_filter_mask &RTEXT_FILTER_SKIP_STATS ) { + size += num_vfs * + (nla_total_size (0 ) +/* nest IFLA_VF_STATS */ +/* IFLA_VF_STATS_RX_PACKETS */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_TX_PACKETS */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_RX_BYTES */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_TX_BYTES */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_BROADCAST */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_MULTICAST */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_RX_DROPPED */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_TX_DROPPED */ +nla_total_size_64bit (sizeof (__u64))); + }return size; }else return 0 ;
@@ -1270,7 +1273,8 @@ static noinline_for_stack int rtnl_fill_stats(struct sk_buff *skb, static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,struct net_device *dev,int vfs_num, -struct nlattr *vfinfo) +struct nlattr *vfinfo, +u32 ext_filter_mask) {struct ifla_vf_rss_query_en vf_rss_query_en;struct nlattr *vf, *vfstats, *vfvlanlist;
@@ -1376,33 +1380,35 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, goto nla_put_vf_failure; }nla_nest_end (skb, vfvlanlist); -memset (&vf_stats,0 ,sizeof (vf_stats)); -if (dev->netdev_ops->ndo_get_vf_stats) - dev->netdev_ops->ndo_get_vf_stats (dev, vfs_num, - &vf_stats); - vfstats =nla_nest_start_noflag (skb,IFLA_VF_STATS ); -if (!vfstats) - goto nla_put_vf_failure; -if (nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_PACKETS , - vf_stats.rx_packets,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_PACKETS , - vf_stats.tx_packets,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_BYTES , - vf_stats.rx_bytes,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_BYTES , - vf_stats.tx_bytes,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_BROADCAST , - vf_stats.broadcast,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_MULTICAST , - vf_stats.multicast,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_DROPPED , - vf_stats.rx_dropped,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_DROPPED , - vf_stats.tx_dropped,IFLA_VF_STATS_PAD )) { -nla_nest_cancel (skb, vfstats); - goto nla_put_vf_failure; +if (~ext_filter_mask &RTEXT_FILTER_SKIP_STATS ) { +memset (&vf_stats,0 ,sizeof (vf_stats)); +if (dev->netdev_ops->ndo_get_vf_stats) + dev->netdev_ops->ndo_get_vf_stats (dev, vfs_num, + &vf_stats); + vfstats =nla_nest_start_noflag (skb,IFLA_VF_STATS ); +if (!vfstats) + goto nla_put_vf_failure; +if (nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_PACKETS , + vf_stats.rx_packets,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_PACKETS , + vf_stats.tx_packets,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_BYTES , + vf_stats.rx_bytes,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_BYTES , + vf_stats.tx_bytes,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_BROADCAST , + vf_stats.broadcast,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_MULTICAST , + vf_stats.multicast,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_DROPPED , + vf_stats.rx_dropped,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_DROPPED , + vf_stats.tx_dropped,IFLA_VF_STATS_PAD )) { +nla_nest_cancel (skb, vfstats); + goto nla_put_vf_failure; + } +nla_nest_end (skb, vfstats); } -nla_nest_end (skb, vfstats);nla_nest_end (skb, vf);return 0 ;
@@ -1435,7 +1441,7 @@ static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,return -EMSGSIZE ;for (i =0 ; i < num_vfs; i++) { -if (rtnl_fill_vfinfo (skb, dev, i, vfinfo)) +if (rtnl_fill_vfinfo (skb, dev, i, vfinfo, ext_filter_mask))return -EMSGSIZE ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 168/800 wifi: ath11k: Add missing check for ioremap
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 16e0077e14a73866e9b0f4a6bf4ad3d4a5cb0f2a ]
Add check for ioremap() and return the error if it fails in order to guarantee the success of ioremap(), same as in ath11k_qmi_load_file_target_mem().
--- drivers/net/wireless/ath/ath11k/qmi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath11k/qmi.c +5 -0
@@ -2058,6 +2058,9 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab) ab->qmi.target_mem[idx].iaddr =ioremap (ab->qmi.target_mem[idx].paddr, ab->qmi.target_mem[i].size); +if (!ab->qmi.target_mem[idx].iaddr) +return -EIO ; + ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; host_ddr_sz = ab->qmi.target_mem[i].size; ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type;
@@ -2083,6 +2086,8 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab) ab->qmi.target_mem[idx].iaddr =ioremap (ab->qmi.target_mem[idx].paddr, ab->qmi.target_mem[i].size); +if (!ab->qmi.target_mem[idx].iaddr) +return -EIO ; }else { ab->qmi.target_mem[idx].paddr =ATH11K_QMI_CALDB_ADDRESS ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 169/800 wifi: ath11k: Add missing ops config for IPQ5018 in ath11k_ahb_probe()
In reply to Greg Kroah-HartmanFrom: Ziyang Huang <[email protected]>
[ Upstream commit 469ddb20cae61cad9c4f208a4c8682305905a511 ]
Without this patch, the IPQ5018 WiFi will fail and print the following logs:
[ 11.033179] ath11k c000000.wifi: unsupported device type 7 [ 11.033223] ath11k: probe of c000000.wifi failed with error -95
--- drivers/net/wireless/ath/ath11k/ahb.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/ahb.c +1 -0
@@ -1127,6 +1127,7 @@ static int ath11k_ahb_probe(struct platform_device *pdev)switch (hw_rev) {case ATH11K_HW_IPQ8074 :case ATH11K_HW_IPQ6018_HW10 : +case ATH11K_HW_IPQ5018_HW10 : hif_ops = &ath11k_ahb_hif_ops_ipq8074; pci_ops =NULL ;break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 170/800 wifi: ath11k: Restart firmware after cold boot calibration for IPQ5018
In reply to Greg Kroah-HartmanFrom: Ziyang Huang <[email protected]>
[ Upstream commit 80c5390e1f5e5b16d820512265530ef26073d8e0 ]
Restart is required after cold boot calibration on IPQ5018. Otherwise, we get the following exception:
[ 14.412829] qcom-q6-mpd cd00000.remoteproc: fatal error received: err_smem_ver.2.1: [ 14.412829] QC Image Version : QC_IMAGE_VERSION_STRING=WLAN.HK.2.6.0.1-00974-QCAHKSWPL_SILICONZ-1 [ 14.412829] Image Variant : IMAGE_VARIANT_STRING=5018.wlanfw2.map_spr_spr_evalQ [ 14.412829] DALSysLogEvent.c:174 Assertion 0 failed param0 :zero,param1 :zero,param2 :zero [ 14.412829] Thread ID : 0x00000048 Thread name : WLAN RT0 Process ID : 0x00000001 Process name :wlan0 [ 14.412829] [ 14.412829] Registers: [ 14.412829] SP : 0x4c81c120 [ 14.412829] FP : 0x4c81c138 [ 14.412829] PC : 0xb022c590 [ 14.412829] SSR : 0x00000000 [ 14.412829] BADVA : 0x00000000 [ 14.412829] LR : 0xb0008490 [ 14.412829] [ 14.412829] StackDump [ 14.412829] from:0x4c81c120 [ 14.412829] to: 0x00000000: [ 14.412829] [ 14.463006] remoteproc remoteproc0: crash detected in cd00000.remoteproc: type fatal error
--- drivers/net/wireless/ath/ath11k/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/core.c +1 -0
@@ -664,6 +664,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { .hal_params = &ath11k_hw_hal_params_ipq8074, .single_pdev_only = false, .cold_boot_calib = true, + .cbcal_restart_fw = true, .fix_l1ss = true, .supports_dynamic_smps_6ghz = false, .alloc_cacheable_memory = true,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 171/800 wifi: ath11k: Add missing hw_ops->get_ring_selector() for IPQ5018
In reply to Greg Kroah-HartmanFrom: Ziyang Huang <[email protected]>
[ Upstream commit ce282d8de71f07f0056ea319541141152c65f552 ]
During sending data after clients connected, hw_ops->get_ring_selector() will be called. But for IPQ5018, this member isn't set, and the following NULL pointer exception will be occurred:
[ 38.840478] 8<--- cut here --- [ 38.840517] Unable to handle kernel NULL pointer dereference at virtual address 00000000 ... [ 38.923161] PC is at 0x0 [ 38.927930] LR is at ath11k_dp_tx+0x70/0x730 [ath11k] ... [ 39.063264] Process hostapd (pid: 1034, stack limit = 0x801ceb3d) [ 39.068994] Stack: (0x856a9a68 to 0x856aa000) ... [ 39.438467] [<7f323804>] (ath11k_dp_tx [ath11k]) from [<7f314e6c>] (ath11k_mac_op_tx+0x80/0x190 [ath11k]) [ 39.446607] [<7f314e6c>] (ath11k_mac_op_tx [ath11k]) from [<7f17dbe0>] (ieee80211_handle_wake_tx_queue+0x7c/0xc0 [mac80211]) [ 39.456162] [<7f17dbe0>] (ieee80211_handle_wake_tx_queue [mac80211]) from [<7f174450>] (ieee80211_probereq_get+0x584/0x704 [mac80211]) [ 39.467443] [<7f174450>] (ieee80211_probereq_get [mac80211]) from [<7f178c40>] (ieee80211_tx_prepare_skb+0x1f8/0x248 [mac80211]) [ 39.479334] [<7f178c40>] (ieee80211_tx_prepare_skb [mac80211]) from [<7f179e28>] (__ieee80211_subif_start_xmit+0x32c/0x3d4 [mac80211]) [ 39.491053] [<7f179e28>] (__ieee80211_subif_start_xmit [mac80211]) from [<7f17af08>] (ieee80211_tx_control_port+0x19c/0x288 [mac80211]) [ 39.502946] [<7f17af08>] (ieee80211_tx_control_port [mac80211]) from [<7f0fc704>] (nl80211_tx_control_port+0x174/0x1d4 [cfg80211]) [ 39.515017] [<7f0fc704>] (nl80211_tx_control_port [cfg80211]) from [<808ceac4>] (genl_rcv_msg+0x154/0x340) [ 39.526814] [<808ceac4>] (genl_rcv_msg) from [<808cdb74>] (netlink_rcv_skb+0xb8/0x11c) [ 39.536446] [<808cdb74>] (netlink_rcv_skb) from [<808ce1d0>] (genl_rcv+0x28/0x34) [ 39.544344] [<808ce1d0>] (genl_rcv) from [<808cd234>] (netlink_unicast+0x174/0x274) [ 39.551895] [<808cd234>] (netlink_unicast) from [<808cd510>] (netlink_sendmsg+0x1dc/0x440) [ 39.559362] [<808cd510>] (netlink_sendmsg) from [<808596e0>] (____sys_sendmsg+0x1a8/0x1fc) [ 39.567697] [<808596e0>] (____sys_sendmsg) from [<8085b1a8>] (___sys_sendmsg+0xa4/0xdc) [ 39.575941] [<8085b1a8>] (___sys_sendmsg) from [<8085b310>] (sys_sendmsg+0x44/0x74) [ 39.583841] [<8085b310>] (sys_sendmsg) from [<80300060>] (ret_fast_syscall+0x0/0x40) ... [ 39.620734] Code: bad PC value [ 39.625869] ---[ end trace 8aef983ad3cbc032 ]---
--- drivers/net/wireless/ath/ath11k/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/hw.c +1 -1
@@ -1175,7 +1175,7 @@ const struct ath11k_hw_ops ipq5018_ops = { .mpdu_info_get_peerid = ath11k_hw_ipq8074_mpdu_info_get_peerid, .rx_desc_mac_addr2_valid = ath11k_hw_ipq9074_rx_desc_mac_addr2_valid, .rx_desc_mpdu_start_addr2 = ath11k_hw_ipq9074_rx_desc_mpdu_start_addr2, - + .get_ring_selector = ath11k_hw_ipq8074_get_tcl_ring_selector, };#define ATH11K_TX_RING_MASK_0 BIT(0)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 172/800 wifi: mac80211: add helpers to access sband iftype data
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 1ec7291e247055fab3a088e1a333a31e7c06e2dd ]
There's quite a bit of code accessing sband iftype data (HE, HE 6 GHz, EHT) and we always need to remember to use the ieee80211_vif_type_p2p() helper. Add new helpers to directly get it from the sband/vif rather than having to call ieee80211_vif_type_p2p().
Convert most code with the following spatch:
@@
expression vif, sband;
@@
-ieee80211_get_he_iftype_cap(sband, ieee80211_vif_type_p2p(vif))
+ieee80211_get_he_iftype_cap_vif(sband, vif)
@@
expression vif, sband;
@@
-ieee80211_get_eht_iftype_cap(sband, ieee80211_vif_type_p2p(vif))
+ieee80211_get_eht_iftype_cap_vif(sband, vif)
@@
expression vif, sband;
@@
-ieee80211_get_he_6ghz_capa(sband, ieee80211_vif_type_p2p(vif))
+ieee80211_get_he_6ghz_capa_vif(sband, vif)Stable-dep-of: f91295987576 ("wifi: iwlwifi: mvm: correctly access HE/EHT sband capa")
--- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 6 +-- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 5 +-- .../net/wireless/intel/iwlwifi/mvm/rs-fw.c | 5 +-- include/net/mac80211.h | 44 ++++++++++++++++++- net/mac80211/eht.c | 5 +-- net/mac80211/he.c | 3 +- net/mac80211/mlme.c | 30 +++++-------- net/mac80211/util.c | 11 ++--- 8 files changed, 66 insertions(+), 43 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +2 -4
@@ -2285,8 +2285,7 @@ bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm *mvm, struct ieee80211_vif *vif)* so take it from one of them. */ sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ ]; - own_he_cap =ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (vif)); + own_he_cap =ieee80211_get_he_iftype_cap_vif (sband, vif);return (own_he_cap && (own_he_cap->he_cap_elem.mac_cap_info[2 ] &IEEE80211_HE_MAC_CAP2_ACK_EN ));
@@ -3468,8 +3467,7 @@ static void iwl_mvm_reset_cca_40mhz_workaround(struct iwl_mvm *mvm, sband->ht_cap.cap |=IEEE80211_HT_CAP_SUP_WIDTH_20_40 ; - he_cap =ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (vif)); + he_cap =ieee80211_get_he_iftype_cap_vif (sband, vif);if (he_cap) {/* we know that ours is writable */
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +2 -3
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2012-2014, 2018-2020 Intel Corporation +* Copyright (C) 2012-2014, 2018-2023 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */
@@ -192,8 +192,7 @@ static void iwl_mvm_rx_monitor_notif(struct iwl_mvm *mvm,WARN_ON (!(sband->ht_cap.cap &IEEE80211_HT_CAP_SUP_WIDTH_20_40 )); sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40 ; - he_cap =ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (vif)); + he_cap =ieee80211_get_he_iftype_cap_vif (sband, vif);if (he_cap) {/* we know that ours is writable */
drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c +2 -3
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* * Copyright (C) 2017 Intel Deutschland GmbH -* Copyright (C) 2018-2022 Intel Corporation +* Copyright (C) 2018-2023 Intel Corporation */ #include "rs.h" #include "fw-api.h"
@@ -94,8 +94,7 @@ static u16 rs_fw_get_config_flags(struct iwl_mvm *mvm, IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD)) flags |= IWL_TLC_MNG_CFG_FLAGS_LDPC_MSK; - sband_he_cap =ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (vif)); + sband_he_cap =ieee80211_get_he_iftype_cap_vif (sband, vif);if (sband_he_cap && !(sband_he_cap->he_cap_elem.phy_cap_info[1 ] &IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD ))
include/net/mac80211.h +43 -1
56 lines not on this page · raw message
net/mac80211/eht.c +2 -3
@@ -2,7 +2,7 @@/* * EHT handling * -* Copyright(c) 2021-2022 Intel Corporation +* Copyright(c) 2021-2023 Intel Corporation */ #include "ieee80211_i.h"
@@ -25,8 +25,7 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata,memset (eht_cap,0 ,sizeof (*eht_cap));if (!eht_cap_ie_elem || - !ieee80211_get_eht_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif))) + !ieee80211_get_eht_iftype_cap_vif (sband, &sdata->vif))return ; mcs_nss_size = ieee80211_eht_mcs_nss_size(he_cap_ie_elem,
net/mac80211/he.c +1 -2
@@ -128,8 +128,7 @@ ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,return ; own_he_cap_ptr = -ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); +ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif);if (!own_he_cap_ptr)return ;
net/mac80211/mlme.c +10 -20
@@ -511,16 +511,14 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,/* don't check HE if we associated as non-HE station */ if (link->u.mgd.conn_flags &IEEE80211_CONN_DISABLE_HE || - !ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif))) { + !ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif)) { he_oper =NULL ; eht_oper =NULL ; }/* don't check EHT if we associated as non-EHT station */ if (link->u.mgd.conn_flags &IEEE80211_CONN_DISABLE_EHT || - !ieee80211_get_eht_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif))) + !ieee80211_get_eht_iftype_cap_vif (sband, &sdata->vif)) eht_oper =NULL ;/*
@@ -776,8 +774,7 @@ static void ieee80211_add_he_ie(struct ieee80211_sub_if_data *sdata,const struct ieee80211_sta_he_cap *he_cap;u8 he_cap_size; - he_cap =ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); + he_cap =ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif);if (WARN_ON (!he_cap))return ;
@@ -806,10 +803,8 @@ static void ieee80211_add_eht_ie(struct ieee80211_sub_if_data *sdata,const struct ieee80211_sta_eht_cap *eht_cap;u8 eht_cap_size; - he_cap =ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); - eht_cap =ieee80211_get_eht_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); + he_cap =ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif); + eht_cap =ieee80211_get_eht_iftype_cap_vif (sband, &sdata->vif);/* * EHT capabilities element is only added if the HE capabilities element
@@ -3949,8 +3944,7 @@ static bool ieee80211_twt_req_supported(struct ieee80211_sub_if_data *sdata, const struct ieee802_11_elems *elems) {const struct ieee80211_sta_he_cap *own_he_cap = -ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); +ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif);if (elems->ext_capab_len <10 )return false;
@@ -3986,8 +3980,7 @@ static bool ieee80211_twt_bcast_support(struct ieee80211_sub_if_data *sdata, struct link_sta_info *link_sta) {const struct ieee80211_sta_he_cap *own_he_cap = -ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); +ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif); return bss_conf->he_support && (link_sta->pub->he_cap.he_cap_elem.mac_cap_info[2] &
@@ -4624,8 +4617,7 @@ ieee80211_verify_sta_he_mcs_support(struct ieee80211_sub_if_data *sdata, const struct ieee80211_he_operation *he_op) {const struct ieee80211_sta_he_cap *sta_he_cap = -ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); +ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif);u16 ap_min_req_set;int i;
@@ -4759,15 +4751,13 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata, *conn_flags |=IEEE80211_CONN_DISABLE_EHT ; } -if (!ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif))) { +if (!ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif)) {mlme_dbg (sdata,"HE not supported, disabling HE and EHT\n" ); *conn_flags |=IEEE80211_CONN_DISABLE_HE ; *conn_flags |=IEEE80211_CONN_DISABLE_EHT ; } -if (!ieee80211_get_eht_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif))) { +if (!ieee80211_get_eht_iftype_cap_vif (sband, &sdata->vif)) {mlme_dbg (sdata,"EHT not supported, disabling EHT\n" ); *conn_flags |=IEEE80211_CONN_DISABLE_EHT ; }
net/mac80211/util.c +4 -7
@@ -6,7 +6,7 @@* Copyright 2007 Johannes Berg <[email protected]> * Copyright 2013-2014 Intel Mobile Communications GmbH * Copyright (C) 2015-2017 Intel Deutschland GmbH -* Copyright (C) 2018-2022 Intel Corporation +* Copyright (C) 2018-2023 Intel Corporation * * utilities for mac80211 */
@@ -2121,8 +2121,7 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_sub_if_data *sdata, *offset = noffset; } - he_cap =ieee80211_get_he_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); + he_cap =ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif);if (he_cap &&cfg80211_any_usable_channels (local->hw.wiphy,BIT (sband->band),IEEE80211_CHAN_NO_HE )) {
@@ -2131,8 +2130,7 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_sub_if_data *sdata, goto out_err; } - eht_cap =ieee80211_get_eht_iftype_cap (sband, -ieee80211_vif_type_p2p (&sdata->vif)); + eht_cap =ieee80211_get_eht_iftype_cap_vif (sband, &sdata->vif);if (eht_cap && cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
@@ -2150,8 +2148,7 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_sub_if_data *sdata,struct ieee80211_supported_band *sband6; sband6 = local->hw.wiphy->bands[NL80211_BAND_6GHZ ]; - he_cap =ieee80211_get_he_iftype_cap (sband6, -ieee80211_vif_type_p2p (&sdata->vif)); + he_cap =ieee80211_get_he_iftype_cap_vif (sband6, &sdata->vif);if (he_cap) { enum nl80211_iftype iftype =
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 173/800 wifi: iwlwifi: mvm: add support for Extra EHT LTF
In reply to Greg Kroah-HartmanFrom: Gregory Greenman <[email protected]>
[ Upstream commit 18c0ffb404db2093b6afdc8ae15f18ba3975e1ed ]
Add support for Extra EHT LTF defined in 9.4.2.313 EHT Capabilities element.
Stable-dep-of: f91295987576 ("wifi: iwlwifi: mvm: correctly access HE/EHT sband capa")
--- drivers/net/wireless/intel/iwlwifi/fw/api/rs.h | 2 ++ .../net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 2 ++ drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c | 15 +++++++++++++++ include/linux/ieee80211.h | 1 + 4 files changed, 20 insertions(+)
drivers/net/wireless/intel/iwlwifi/fw/api/rs.h +2 -0
@@ -21,6 +21,7 @@* @IWL_TLC_MNG_CFG_FLAGS_HE_DCM_NSS_2_MSK: enable HE Dual Carrier Modulation * for BPSK (MCS 0) with 2 spatial * streams +* @IWL_TLC_MNG_CFG_FLAGS_EHT_EXTRA_LTF_MSK: enable support for EHT extra LTF */ enum iwl_tlc_mng_cfg_flags {IWL_TLC_MNG_CFG_FLAGS_STBC_MSK =BIT (0 ),
@@ -28,6 +29,7 @@ enum iwl_tlc_mng_cfg_flags {IWL_TLC_MNG_CFG_FLAGS_HE_STBC_160MHZ_MSK =BIT (2 ),IWL_TLC_MNG_CFG_FLAGS_HE_DCM_NSS_1_MSK =BIT (3 ),IWL_TLC_MNG_CFG_FLAGS_HE_DCM_NSS_2_MSK =BIT (4 ), + IWL_TLC_MNG_CFG_FLAGS_EHT_EXTRA_LTF_MSK = BIT(6), };/**
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +2 -0
@@ -975,6 +975,8 @@ iwl_nvm_fixup_sband_iftd(struct iwl_trans *trans, iftype_data->eht_cap.eht_cap_elem.phy_cap_info[6 ] &= ~(IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK |IEEE80211_EHT_PHY_CAP6_EHT_DUP_6GHZ_SUPP ); + iftype_data->eht_cap.eht_cap_elem.phy_cap_info[5 ] |= +IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF ; }if (fw_has_capa (&fw->ucode_capa,IWL_UCODE_TLV_CAPA_BROADCAST_TWT ))
drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c +15 -0
@@ -591,6 +591,21 @@ void iwl_mvm_rs_fw_rate_init(struct iwl_mvm *mvm,int cmd_ver;int ret; +/* Enable external EHT LTF only for GL device and if there's +* mutual support by AP and client +*/ +if (CSR_HW_REV_TYPE (mvm->trans->hw_rev) ==IWL_CFG_MAC_TYPE_GL && + sband->iftype_data->eht_cap.has_eht && + sband->iftype_data->eht_cap.eht_cap_elem.phy_cap_info[5 ] & +IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF && + link_sta->eht_cap.has_eht && + link_sta->eht_cap.eht_cap_elem.phy_cap_info[5 ] & +IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF ) { +IWL_DEBUG_RATE (mvm,"Set support for Extra EHT LTF\n" ); + cfg_cmd.flags |= +cpu_to_le16 (IWL_TLC_MNG_CFG_FLAGS_EHT_EXTRA_LTF_MSK ); + } +rcu_read_lock (); mvm_link_sta =rcu_dereference (mvmsta->link[link_id]);if (WARN_ON_ONCE (!mvm_link_sta)) {
include/linux/ieee80211.h +1 -0
@@ -2856,6 +2856,7 @@ ieee80211_he_spr_size(const u8 *he_spr_ie)/* Maximum number of supported EHT LTF is split */ #define IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK 0xc0 +#define IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF 0x40#define IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK 0x07#define IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK 0x78
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 147/800 wifi: mac80211: recalc min chandef for new STA links
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit ba7af2654e3b7b810c750b3c6106f6f20b81cc88 ]
When adding a new link to a station, this needs to cause a recalculation of the minimum chandef since otherwise we can have a higher bandwidth station connected on that link than the link is operating at. Do the appropriate recalc.
--- net/mac80211/sta_info.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/sta_info.c +2 -0
@@ -2913,6 +2913,8 @@ int ieee80211_sta_activate_link(struct sta_info *sta, unsigned int link_id)if (!test_sta_flag (sta,WLAN_STA_INSERTED )) goto hash; +ieee80211_recalc_min_chandef (sdata, link_id); +/* Ensure the values are updated for the driver, * redone by sta_remove_link on failure. */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 148/800 selftests/bpf: Fix check_mtu using wrong variable type
In reply to Greg Kroah-HartmanFrom: Jesper Dangaard Brouer <[email protected]>
[ Upstream commit 095641817e1bf6aa2560e025e47575188ee3edaf ]
Dan Carpenter found via Smatch static checker, that unsigned 'mtu_lo' is never less than zero.
Variable mtu_lo should have been an 'int', because read_mtu_device_lo() uses minus as error indications.
--- tools/testing/selftests/bpf/prog_tests/check_mtu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/check_mtu.c +1 -1
@@ -183,7 +183,7 @@ static void test_check_mtu_tc(__u32 mtu, __u32 ifindex)void serial_test_check_mtu (void ) { -__u32 mtu_lo; +int mtu_lo;if (test__start_subtest ("bpf_check_mtu XDP-attach" ))test_check_mtu_xdp_attach ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 149/800 soc: qcom: geni-se: Add interfaces geni_se_tx_init_dma() and geni_se_rx_init_dma()
In reply to Greg Kroah-HartmanFrom: Vijaya Krishna Nivarthi <[email protected]>
[ Upstream commit 6d6e57594957ee9131bc3802dfc8657ca6f78fee ]
The geni_se_xx_dma_prep() interfaces necessarily do DMA mapping before initiating DMA transfers. This is not suitable for spi where framework is expected to handle map/unmap.
Expose new interfaces geni_se_xx_init_dma() which do only DMA transfer.
Stable-dep-of: 3a76c7ca9e77 ("spi: spi-geni-qcom: Do not do DMA map/unmap inside driver, use framework instead")
--- drivers/soc/qcom/qcom-geni-se.c | 67 +++++++++++++++++++++++--------- include/linux/soc/qcom/geni-se.h | 4 ++ 2 files changed, 53 insertions(+), 18 deletions(-)
drivers/soc/qcom/qcom-geni-se.c +49 -18
@@ -682,6 +682,30 @@ EXPORT_SYMBOL(geni_se_clk_freq_match);#define GENI_SE_DMA_EOT_EN BIT(1)#define GENI_SE_DMA_AHB_ERR_EN BIT(2)#define GENI_SE_DMA_EOT_BUF BIT(0) + +/** +* geni_se_tx_init_dma() - Initiate TX DMA transfer on the serial engine +* @se: Pointer to the concerned serial engine. +* @iova: Mapped DMA address. +* @len: Length of the TX buffer. +* +* This function is used to initiate DMA TX transfer. +*/ +void geni_se_tx_init_dma (struct geni_se *se,dma_addr_t iova,size_t len) +{ +u32 val; + + val =GENI_SE_DMA_DONE_EN ; + val |=GENI_SE_DMA_EOT_EN ; + val |=GENI_SE_DMA_AHB_ERR_EN ; +writel_relaxed (val, se->base +SE_DMA_TX_IRQ_EN_SET ); +writel_relaxed (lower_32_bits (iova), se->base +SE_DMA_TX_PTR_L ); +writel_relaxed (upper_32_bits (iova), se->base +SE_DMA_TX_PTR_H ); +writel_relaxed (GENI_SE_DMA_EOT_BUF , se->base +SE_DMA_TX_ATTR ); +writel (len, se->base +SE_DMA_TX_LEN ); +} +EXPORT_SYMBOL (geni_se_tx_init_dma); +/** * geni_se_tx_dma_prep() - Prepare the serial engine for TX DMA transfer * @se: Pointer to the concerned serial engine.
@@ -697,7 +721,6 @@ int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len, dma_addr_t *iova) {struct geni_wrapper *wrapper = se->wrapper; -u32 val;if (!wrapper)return -EINVAL ;
@@ -706,17 +729,34 @@ int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len,if (dma_mapping_error (wrapper->dev, *iova))return -EIO ; +geni_se_tx_init_dma (se, *iova, len); +return 0 ; +} +EXPORT_SYMBOL (geni_se_tx_dma_prep); + +/** +* geni_se_rx_init_dma() - Initiate RX DMA transfer on the serial engine +* @se: Pointer to the concerned serial engine. +* @iova: Mapped DMA address. +* @len: Length of the RX buffer. +* +* This function is used to initiate DMA RX transfer. +*/ +void geni_se_rx_init_dma (struct geni_se *se,dma_addr_t iova,size_t len) +{ +u32 val; + val =GENI_SE_DMA_DONE_EN ; val |=GENI_SE_DMA_EOT_EN ; val |=GENI_SE_DMA_AHB_ERR_EN ; -writel_relaxed (val, se->base +SE_DMA_TX_IRQ_EN_SET ); -writel_relaxed (lower_32_bits (*iova), se->base +SE_DMA_TX_PTR_L ); -writel_relaxed (upper_32_bits (*iova), se->base +SE_DMA_TX_PTR_H ); -writel_relaxed (GENI_SE_DMA_EOT_BUF , se->base +SE_DMA_TX_ATTR ); -writel (len, se->base +SE_DMA_TX_LEN ); -return 0 ; +writel_relaxed (val, se->base +SE_DMA_RX_IRQ_EN_SET ); +writel_relaxed (lower_32_bits (iova), se->base +SE_DMA_RX_PTR_L ); +writel_relaxed (upper_32_bits (iova), se->base +SE_DMA_RX_PTR_H ); +/* RX does not have EOT buffer type bit. So just reset RX_ATTR */ +writel_relaxed (0 , se->base +SE_DMA_RX_ATTR ); +writel (len, se->base +SE_DMA_RX_LEN ); } -EXPORT_SYMBOL (geni_se_tx_dma_prep); +EXPORT_SYMBOL (geni_se_rx_init_dma);/** * geni_se_rx_dma_prep() - Prepare the serial engine for RX DMA transfer
@@ -733,7 +773,6 @@ int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len, dma_addr_t *iova) {struct geni_wrapper *wrapper = se->wrapper; -u32 val;if (!wrapper)return -EINVAL ;
@@ -742,15 +781,7 @@ int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len,if (dma_mapping_error (wrapper->dev, *iova))return -EIO ; - val =GENI_SE_DMA_DONE_EN ; - val |=GENI_SE_DMA_EOT_EN ; - val |=GENI_SE_DMA_AHB_ERR_EN ; -writel_relaxed (val, se->base +SE_DMA_RX_IRQ_EN_SET ); -writel_relaxed (lower_32_bits (*iova), se->base +SE_DMA_RX_PTR_L ); -writel_relaxed (upper_32_bits (*iova), se->base +SE_DMA_RX_PTR_H ); -/* RX does not have EOT buffer type bit. So just reset RX_ATTR */ -writel_relaxed (0 , se->base +SE_DMA_RX_ATTR ); -writel (len, se->base +SE_DMA_RX_LEN ); +geni_se_rx_init_dma (se, *iova, len);return 0 ; }EXPORT_SYMBOL (geni_se_rx_dma_prep);
include/linux/soc/qcom/geni-se.h +4 -0
@@ -490,9 +490,13 @@ int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq, unsigned int *index, unsigned long *res_freq, bool exact); +void geni_se_tx_init_dma (struct geni_se *se,dma_addr_t iova,size_t len); +int geni_se_tx_dma_prep (struct geni_se *se,void *buf,size_t len,dma_addr_t *iova); +void geni_se_rx_init_dma (struct geni_se *se,dma_addr_t iova,size_t len); +int geni_se_rx_dma_prep (struct geni_se *se,void *buf,size_t len,dma_addr_t *iova);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 150/800 spi: spi-geni-qcom: Do not do DMA map/unmap inside driver, use framework instead
In reply to Greg Kroah-HartmanFrom: Vijaya Krishna Nivarthi <[email protected]>
[ Upstream commit 3a76c7ca9e77269dd10cf21465a055274cfa40c6 ]
The spi geni driver in SE DMA mode, unlike GSI DMA, is not making use of DMA mapping functionality available in the framework.
The driver does mapping internally which makes dma buffer fields available in spi_transfer struct superfluous while requiring additional members in spi_geni_master struct.
Conform to the design by having framework handle map/unmap and do only DMA transfer in the driver; this also simplifies code a bit.
--- drivers/spi/spi-geni-qcom.c | 103 +++++++++++++++++------------------- 1 file changed, 50 insertions(+), 53 deletions(-)
drivers/spi/spi-geni-qcom.c +50 -53
@@ -97,8 +97,6 @@ struct spi_geni_master {struct dma_chan *tx;struct dma_chan *rx;int cur_xfer_mode; -dma_addr_t tx_se_dma; -dma_addr_t rx_se_dma; }; static int get_spi_clk_cfg(unsigned int speed_hz,
@@ -174,7 +172,7 @@ static void handle_se_timeout(struct spi_master *spi, unmap_if_dma:if (mas->cur_xfer_mode ==GENI_SE_DMA ) {if (xfer) { -if (xfer->tx_buf && mas->tx_se_dma) { +if (xfer->tx_buf) {spin_lock_irq (&mas->lock);reinit_completion (&mas->tx_reset_done);writel (1 , se->base +SE_DMA_TX_FSM_RST );
@@ -182,9 +180,8 @@ static void handle_se_timeout(struct spi_master *spi, time_left =wait_for_completion_timeout (&mas->tx_reset_done,HZ );if (!time_left)dev_err (mas->dev,"DMA TX RESET failed\n" ); -geni_se_tx_dma_unprep (se, mas->tx_se_dma, xfer->len); } -if (xfer->rx_buf && mas->rx_se_dma) { +if (xfer->rx_buf) {spin_lock_irq (&mas->lock);reinit_completion (&mas->rx_reset_done);writel (1 , se->base +SE_DMA_RX_FSM_RST );
@@ -192,7 +189,6 @@ static void handle_se_timeout(struct spi_master *spi, time_left =wait_for_completion_timeout (&mas->rx_reset_done,HZ );if (!time_left)dev_err (mas->dev,"DMA RX RESET failed\n" ); -geni_se_rx_dma_unprep (se, mas->rx_se_dma, xfer->len); } }else {/*
@@ -523,17 +519,36 @@ static int setup_gsi_xfer(struct spi_transfer *xfer, struct spi_geni_master *masreturn 1 ; } +static u32 get_xfer_len_in_words (struct spi_transfer *xfer, +struct spi_geni_master *mas) +{ +u32 len; + +if (!(mas->cur_bits_per_word %MIN_WORD_LEN )) + len = xfer->len *BITS_PER_BYTE / mas->cur_bits_per_word; +else + len = xfer->len / (mas->cur_bits_per_word /BITS_PER_BYTE +1 ); + len &=TRANS_LEN_MSK ; + +return len; +} +static bool geni_can_dma (struct spi_controller *ctlr,struct spi_device *slv,struct spi_transfer *xfer) {struct spi_geni_master *mas =spi_master_get_devdata (slv->master); +u32 len, fifo_size; -/* -* Return true if transfer needs to be mapped prior to -* calling transfer_one which is the case only for GPI_DMA. -* For SE_DMA mode, map/unmap is done in geni_se_*x_dma_prep. -*/ -return mas->cur_xfer_mode ==GENI_GPI_DMA ; +if (mas->cur_xfer_mode ==GENI_GPI_DMA ) +return true; + + len =get_xfer_len_in_words (xfer, mas); + fifo_size = mas->tx_fifo_depth * mas->fifo_width_bits / mas->cur_bits_per_word; + +if (len > fifo_size) +return true; +else +return false; } static int spi_geni_prepare_message(struct spi_master *spi,
@@ -774,7 +789,7 @@ static int setup_se_xfer(struct spi_transfer *xfer, u16 mode, struct spi_master *spi) { u32 m_cmd = 0; -u32 len, fifo_size; +u32 len;struct geni_se *se = &mas->se;int ret;
@@ -806,11 +821,7 @@ static int setup_se_xfer(struct spi_transfer *xfer, mas->tx_rem_bytes =0 ; mas->rx_rem_bytes =0 ; -if (!(mas->cur_bits_per_word %MIN_WORD_LEN )) - len = xfer->len *BITS_PER_BYTE / mas->cur_bits_per_word; -else - len = xfer->len / (mas->cur_bits_per_word /BITS_PER_BYTE +1 ); - len &=TRANS_LEN_MSK ; + len =get_xfer_len_in_words (xfer, mas); mas->cur_xfer = xfer;if (xfer->tx_buf) {
@@ -825,9 +836,20 @@ static int setup_se_xfer(struct spi_transfer *xfer, mas->rx_rem_bytes = xfer->len; } -/* Select transfer mode based on transfer length */ - fifo_size = mas->tx_fifo_depth * mas->fifo_width_bits / mas->cur_bits_per_word; - mas->cur_xfer_mode = (len <= fifo_size) ?GENI_SE_FIFO :GENI_SE_DMA ; +/* +* Select DMA mode if sgt are present; and with only 1 entry +* This is not a serious limitation because the xfer buffers are +* expected to fit into in 1 entry almost always, and if any +* doesn't for any reason we fall back to FIFO mode anyway +*/ +if (!xfer->tx_sg.nents && !xfer->rx_sg.nents) + mas->cur_xfer_mode =GENI_SE_FIFO ; +else if (xfer->tx_sg.nents >1 || xfer->rx_sg.nents >1 ) { +dev_warn_once (mas->dev,"Doing FIFO, cannot handle tx_nents-%d, rx_nents-%d\n" , + xfer->tx_sg.nents, xfer->rx_sg.nents); + mas->cur_xfer_mode =GENI_SE_FIFO ; + }else + mas->cur_xfer_mode =GENI_SE_DMA ;geni_se_select_mode (se, mas->cur_xfer_mode);/*
@@ -838,35 +860,17 @@ static int setup_se_xfer(struct spi_transfer *xfer,geni_se_setup_m_cmd (se, m_cmd,FRAGMENTATION );if (mas->cur_xfer_mode ==GENI_SE_DMA ) { -if (m_cmd &SPI_RX_ONLY ) { - ret =geni_se_rx_dma_prep (se, xfer->rx_buf, - xfer->len, &mas->rx_se_dma); -if (ret) { -dev_err (mas->dev,"Failed to setup Rx dma %d\n" , ret); - mas->rx_se_dma =0 ; - goto unlock_and_return; - } - } -if (m_cmd &SPI_TX_ONLY ) { - ret =geni_se_tx_dma_prep (se, (void *)xfer->tx_buf, - xfer->len, &mas->tx_se_dma); -if (ret) { -dev_err (mas->dev,"Failed to setup Tx dma %d\n" , ret); - mas->tx_se_dma =0 ; -if (m_cmd &SPI_RX_ONLY ) { -/* Unmap rx buffer if duplex transfer */ -geni_se_rx_dma_unprep (se, mas->rx_se_dma, xfer->len); - mas->rx_se_dma =0 ; - } - goto unlock_and_return; - } - } +if (m_cmd &SPI_RX_ONLY ) +geni_se_rx_init_dma (se,sg_dma_address (xfer->rx_sg.sgl), +sg_dma_len (xfer->rx_sg.sgl)); +if (m_cmd &SPI_TX_ONLY ) +geni_se_tx_init_dma (se,sg_dma_address (xfer->tx_sg.sgl), +sg_dma_len (xfer->tx_sg.sgl)); }else if (m_cmd &SPI_TX_ONLY ) {if (geni_spi_handle_tx (mas))writel (mas->tx_wm, se->base +SE_GENI_TX_WATERMARK_REG ); } -unlock_and_return:spin_unlock_irq (&mas->lock);return ret; }
@@ -967,14 +971,6 @@ static irqreturn_t geni_spi_isr(int irq, void *data)if (dma_rx_status &RX_RESET_DONE )complete (&mas->rx_reset_done);if (!mas->tx_rem_bytes && !mas->rx_rem_bytes && xfer) { -if (xfer->tx_buf && mas->tx_se_dma) { -geni_se_tx_dma_unprep (se, mas->tx_se_dma, xfer->len); - mas->tx_se_dma =0 ; - } -if (xfer->rx_buf && mas->rx_se_dma) { -geni_se_rx_dma_unprep (se, mas->rx_se_dma, xfer->len); - mas->rx_se_dma =0 ; - }spi_finalize_current_transfer (spi); mas->cur_xfer =NULL ; }
@@ -1059,6 +1055,7 @@ static int spi_geni_probe(struct platform_device *pdev) spi->bits_per_word_mask =SPI_BPW_RANGE_MASK (4 ,32 ); spi->num_chipselect =4 ; spi->max_speed_hz =50000000 ; + spi->max_dma_len =0xffff0 ;/* 24 bits for tx/rx dma length */ spi->prepare_message = spi_geni_prepare_message; spi->transfer_one = spi_geni_transfer_one; spi->can_dma = geni_can_dma;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 151/800 wifi: rsi: Do not configure WoWlan in shutdown hook if not enabled
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit b241e260820b68c09586e8a0ae0fc23c0e3215bd ]
In case WoWlan was never configured during the operation of the system, the hw->wiphy->wowlan_config will be NULL. rsi_config_wowlan() checks whether wowlan_config is non-NULL and if it is not, then WARNs about it. The warning is valid, as during normal operation the rsi_config_wowlan() should only ever be called with non-NULL wowlan_config. In shutdown this rsi_config_wowlan() should only ever be called if WoWlan was configured before by the user.
Add checks for non-NULL wowlan_config into the shutdown hook. While at it, check whether the wiphy is also non-NULL before accessing wowlan_config . Drop the single-use wowlan_config variable, just inline it into function call.
--- drivers/net/wireless/rsi/rsi_91x_sdio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_sdio.c +2 -4
@@ -1463,10 +1463,8 @@ static void rsi_shutdown(struct device *dev)rsi_dbg (ERR_ZONE ,"SDIO Bus shutdown =====>\n" ); -if (hw) { -struct cfg80211_wowlan *wowlan = hw->wiphy->wowlan_config; - -if (rsi_config_wowlan (adapter, wowlan)) +if (hw && hw->wiphy && hw->wiphy->wowlan_config) { +if (rsi_config_wowlan (adapter, hw->wiphy->wowlan_config))rsi_dbg (ERR_ZONE ,"Failed to configure WoWLAN\n" ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 152/800 wifi: rsi: Do not set MMC_PM_KEEP_POWER in shutdown
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit e74f562328b03fbe9cf438f958464dff3a644dfc ]
It makes no sense to set MMC_PM_KEEP_POWER in shutdown. The flag indicates to the MMC subsystem to keep the slot powered on during suspend, but in shutdown the slot should actually be powered off. Drop this call.
--- drivers/net/wireless/rsi/rsi_91x_sdio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/rsi/rsi_91x_sdio.c +0 -3
@@ -1479,9 +1479,6 @@ static void rsi_shutdown(struct device *dev)if (sdev->write_fail)rsi_dbg (INFO_ZONE ,"###### Device is not ready #######\n" ); -if (rsi_set_sdio_pm_caps (adapter)) -rsi_dbg (INFO_ZONE ,"Setting power management caps failed\n" ); -rsi_dbg (INFO_ZONE ,"***** RSI module shut down *****\n" ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 153/800 ice: handle extts in the miscellaneous interrupt thread
In reply to Greg Kroah-HartmanFrom: Karol Kolacinski <[email protected]>
[ Upstream commit 6e8b2c88fc8cf95ed09de25946b20b7536c88cd5 ]
The ice_ptp_extts_work() and ice_ptp_periodic_work() functions are both scheduled on the same kthread worker, pf.ptp.kworker. The ice_ptp_periodic_work() function sends to the firmware to interact with the PHY, and must block to wait for responses.
This can cause delay in responding to the PFINT_OICR_TSYN_EVNT interrupt cause, ultimately resulting in disruption to processing an input signal of the frequency is high enough. In our testing, even 100 Hz signals get disrupted.
Fix this by instead processing the signal inside the miscellaneous interrupt thread prior to handling Tx timestamps.
Use atomic bits in a new pf->misc_thread bitmap in order to safely communicate which tasks require processing within the ice_misc_intr_thread_fn(). This ensures the communication of desired tasks from the ice_misc_intr() are correctly processed without racing even in the event that the interrupt triggers again before the thread function exits.
--- drivers/net/ethernet/intel/ice/ice.h | 7 ++++++ drivers/net/ethernet/intel/ice/ice_main.c | 29 ++++++++++++++++------- drivers/net/ethernet/intel/ice/ice_ptp.c | 12 +++------- drivers/net/ethernet/intel/ice/ice_ptp.h | 4 ++-- 4 files changed, 33 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +7 -0
@@ -514,6 +514,12 @@ enum ice_pf_flags {ICE_PF_FLAGS_NBITS /* must be last */ }; +enum ice_misc_thread_tasks { +ICE_MISC_THREAD_EXTTS_EVENT , +ICE_MISC_THREAD_TX_TSTAMP , +ICE_MISC_THREAD_NBITS /* must be last */ +}; +struct ice_switchdev_info {struct ice_vsi *control_vsi;struct ice_vsi *uplink_vsi;
@@ -556,6 +562,7 @@ struct ice_pf {DECLARE_BITMAP (features,ICE_F_MAX );DECLARE_BITMAP (state,ICE_STATE_NBITS );DECLARE_BITMAP (flags,ICE_PF_FLAGS_NBITS ); +DECLARE_BITMAP (misc_thread,ICE_MISC_THREAD_NBITS );unsigned long *avail_txqs;/* bitmap to track PF Tx queue usage */ unsigned long *avail_rxqs;/* bitmap to track PF Rx queue usage */ unsigned long serv_tmr_period;
drivers/net/ethernet/intel/ice/ice_main.c +21 -8
@@ -3141,20 +3141,28 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)if (oicr &PFINT_OICR_TSYN_TX_M ) { ena_mask &= ~PFINT_OICR_TSYN_TX_M ; -if (!hw->reset_ongoing) +if (!hw->reset_ongoing) { +set_bit (ICE_MISC_THREAD_TX_TSTAMP , pf->misc_thread); ret =IRQ_WAKE_THREAD ; + } }if (oicr &PFINT_OICR_TSYN_EVNT_M ) {u8 tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned;u32 gltsyn_stat =rd32 (hw,GLTSYN_STAT (tmr_idx)); -/* Save EVENTs from GTSYN register */ - pf->ptp.ext_ts_irq |= gltsyn_stat & (GLTSYN_STAT_EVENT0_M | -GLTSYN_STAT_EVENT1_M | -GLTSYN_STAT_EVENT2_M ); ena_mask &= ~PFINT_OICR_TSYN_EVNT_M ; -kthread_queue_work (pf->ptp.kworker, &pf->ptp.extts_work); + +if (hw->func_caps.ts_func_info.src_tmr_owned) { +/* Save EVENTs from GLTSYN register */ + pf->ptp.ext_ts_irq |= gltsyn_stat & + (GLTSYN_STAT_EVENT0_M | +GLTSYN_STAT_EVENT1_M | +GLTSYN_STAT_EVENT2_M ); + +set_bit (ICE_MISC_THREAD_EXTTS_EVENT , pf->misc_thread); + ret =IRQ_WAKE_THREAD ; + } }#define ICE_AUX_CRIT_ERR (PFINT_OICR_PE_CRITERR_M | PFINT_OICR_HMC_ERR_M | PFINT_OICR_PE_PUSH_M)
@@ -3198,8 +3206,13 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)if (ice_is_reset_in_progress (pf->state))return IRQ_HANDLED ; -while (!ice_ptp_process_ts (pf)) -usleep_range (50 ,100 ); +if (test_and_clear_bit (ICE_MISC_THREAD_EXTTS_EVENT , pf->misc_thread)) +ice_ptp_extts_event (pf); + +if (test_and_clear_bit (ICE_MISC_THREAD_TX_TSTAMP , pf->misc_thread)) { +while (!ice_ptp_process_ts (pf)) +usleep_range (50 ,100 ); + }return IRQ_HANDLED ; }
drivers/net/ethernet/intel/ice/ice_ptp.c +3 -9
@@ -1458,15 +1458,11 @@ static int ice_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm) }/** -* ice_ptp_extts_work - Workqueue task function -* @work: external timestamp work structure -* -* Service for PTP external clock event +* ice_ptp_extts_event - Process PTP external clock event +* @pf: Board private structure */ -static void ice_ptp_extts_work (struct kthread_work *work) +void ice_ptp_extts_event (struct ice_pf *pf) { - struct ice_ptp *ptp = container_of(work, struct ice_ptp, extts_work); - struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp);struct ptp_clock_event event;struct ice_hw *hw = &pf->hw;u8 chan, tmr_idx;
@@ -2558,7 +2554,6 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf)ice_ptp_cfg_timestamp (pf, false);kthread_cancel_delayed_work_sync (&ptp->work); -kthread_cancel_work_sync (&ptp->extts_work);if (test_bit (ICE_PFR_REQ , pf->state))return ;
@@ -2656,7 +2651,6 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp)/* Initialize work functions */ kthread_init_delayed_work (&ptp->work, ice_ptp_periodic_work); -kthread_init_work (&ptp->extts_work, ice_ptp_extts_work);/* Allocate a kworker for handling work required for the ports * connected to the PTP hardware clock.
drivers/net/ethernet/intel/ice/ice_ptp.h +2 -2
@@ -169,7 +169,6 @@ struct ice_ptp_port {* struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK * @port: data for the PHY port initialization procedure * @work: delayed work function for periodic tasks -* @extts_work: work function for handling external Tx timestamps * @cached_phc_time: a cached copy of the PHC time for timestamp extension * @cached_phc_jiffies: jiffies when cached_phc_time was last updated * @ext_ts_chan: the external timestamp channel in use
@@ -190,7 +189,6 @@ struct ice_ptp_port {struct ice_ptp {struct ice_ptp_port port;struct kthread_delayed_work work; -struct kthread_work extts_work;u64 cached_phc_time;unsigned long cached_phc_jiffies;u8 ext_ts_chan;
@@ -256,6 +254,7 @@ int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr);void ice_ptp_cfg_timestamp (struct ice_pf *pf,bool ena);int ice_get_ptp_clock_index (struct ice_pf *pf); +void ice_ptp_extts_event (struct ice_pf *pf);s8 ice_ptp_request_ts (struct ice_ptp_tx *tx,struct sk_buff *skb);bool ice_ptp_process_ts (struct ice_pf *pf);
@@ -284,6 +283,7 @@ static inline int ice_get_ptp_clock_index(struct ice_pf *pf)return -1 ; } +static inline void ice_ptp_extts_event (struct ice_pf *pf) { }static inline s8 ice_ptp_request_ts (struct ice_ptp_tx *tx,struct sk_buff *skb) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 144/800 bpf: Make bpf_refcount_acquire fallible for non-owning refs
In reply to Greg Kroah-HartmanFrom: Dave Marchevsky <[email protected]>
[ Upstream commit 7793fc3babe9fea908e57f7c187ea819f9fd7e95 ]
This patch fixes an incorrect assumption made in the original bpf_refcount series [0], specifically that the BPF program calling bpf_refcount_acquire on some node can always guarantee that the node is alive. In that series, the patch adding failure behavior to rbtree_add and list_push_{front, back} breaks this assumption for non-owning references.
Consider the following program:
n = bpf_kptr_xchg(&mapval, NULL);
/* skip error checking */
bpf_spin_lock(&l);
if(bpf_rbtree_add(&t, &n->rb, less)) {
bpf_refcount_acquire(n);
/* Failed to add, do something else with the node */
}
bpf_spin_unlock(&l);It's incorrect to assume that bpf_refcount_acquire will always succeed in this scenario. bpf_refcount_acquire is being called in a critical section here, but the lock being held is associated with rbtree t, which isn't necessarily the lock associated with the tree that the node is already in. So after bpf_rbtree_add fails to add the node and calls bpf_obj_drop in it, the program has no ownership of the node's lifetime. Therefore the node's refcount can be decr'd to 0 at any time after the failing rbtree_add. If this happens before the refcount_acquire above, the node might be free'd, and regardless refcount_acquire will be incrementing a 0 refcount.
Later patches in the series exercise this scenario, resulting in the expected complaint from the kernel (without this patch's changes):
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 1 PID: 207 at lib/refcount.c:25 refcount_warn_saturate+0xbc/0x110 Modules linked in: bpf_testmod(O) CPU: 1 PID: 207 Comm: test_progs Tainted: G O 6.3.0-rc7-02231-g723de1a718a2-dirty #371 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 RIP: 0010:refcount_warn_saturate+0xbc/0x110 Code: 6f 64 f6 02 01 e8 84 a3 5c ff 0f 0b eb 9d 80 3d 5e 64 f6 02 00 75 94 48 c7 c7 e0 13 d2 82 c6 05 4e 64 f6 02 01 e8 64 a3 5c ff <0f> 0b e9 7a ff ff ff 80 3d 38 64 f6 02 00 0f 85 6d ff ff ff 48 c7 RSP: 0018:ffff88810b9179b0 EFLAGS: 00010082 RAX: 0000000000000000 RBX: 0000000000000002 RCX: 0000000000000000 RDX: 0000000000000202 RSI: 0000000000000008 RDI: ffffffff857c3680 RBP: ffff88810027d3c0 R08: ffffffff8125f2a4 R09: ffff88810b9176e7 R10: ffffed1021722edc R11: 746e756f63666572 R12: ffff88810027d388 R13: ffff88810027d3c0 R14: ffffc900005fe030 R15: ffffc900005fe048 FS: 00007fee0584a700(0000) GS:ffff88811b280000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00005634a96f6c58 CR3: 0000000108ce9002 CR4: 0000000000770ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> bpf_refcount_acquire_impl+0xb5/0xc0
(rest of output snipped)
The patch addresses this by changing bpf_refcount_acquire_impl to use refcount_inc_not_zero instead of refcount_inc and marking bpf_refcount_acquire KF_RET_NULL.
For owning references, though, we know the above scenario is not possible and thus that bpf_refcount_acquire will always succeed. Some verifier bookkeeping is added to track "is input owning ref?" for bpf_refcount_acquire calls and return false from is_kfunc_ret_null for bpf_refcount_acquire on owning refs despite it being marked KF_RET_NULL.
Existing selftests using bpf_refcount_acquire are modified where necessary to NULL-check its return value.
[0]: https://lore.kernel.org/bpf/[email protected]/
--- kernel/bpf/helpers.c | 8 ++++-- kernel/bpf/verifier.c | 26 +++++++++++++------ .../selftests/bpf/progs/refcounted_kptr.c | 2 ++ .../bpf/progs/refcounted_kptr_fail.c | 4 ++- 4 files changed, 29 insertions(+), 11 deletions(-)
kernel/bpf/helpers.c +6 -2
@@ -1926,8 +1926,12 @@ __bpf_kfunc void *bpf_refcount_acquire_impl(void *p__refcounted_kptr, void *meta* bpf_refcount type so that it is emitted in vmlinux BTF */ ref = (struct bpf_refcount *)(p__refcounted_kptr + meta->record->refcount_off); +if (!refcount_inc_not_zero ((refcount_t *)ref)) +return NULL ; -refcount_inc ((refcount_t *)ref); +/* Verifier strips KF_RET_NULL if input is owned ref, see is_kfunc_ret_null +* in verifier.c +*/ return (void *)p__refcounted_kptr; }
@@ -2325,7 +2329,7 @@ BTF_ID_FLAGS(func, crash_kexec, KF_DESTRUCTIVE)#endif BTF_ID_FLAGS(func, bpf_obj_new_impl, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_obj_drop_impl, KF_RELEASE) -BTF_ID_FLAGS(func, bpf_refcount_acquire_impl, KF_ACQUIRE) +BTF_ID_FLAGS(func, bpf_refcount_acquire_impl, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_list_push_front_impl) BTF_ID_FLAGS(func, bpf_list_push_back_impl)BTF_ID_FLAGS (func, bpf_list_pop_front,KF_ACQUIRE |KF_RET_NULL )
kernel/bpf/verifier.c +18 -8
@@ -292,16 +292,19 @@ struct bpf_kfunc_call_arg_meta {bool found; } arg_constant; -/* arg_btf and arg_btf_id are used by kfunc-specific handling, +/* arg_{btf,btf_id,owning_ref} are used by kfunc-specific handling, * generally to pass info about user-defined local kptr types to later * verification logic * bpf_obj_drop * Record the local kptr type to be drop'd * bpf_refcount_acquire (via KF_ARG_PTR_TO_REFCOUNTED_KPTR arg type) -* Record the local kptr type to be refcount_incr'd +* Record the local kptr type to be refcount_incr'd and use +* arg_owning_ref to determine whether refcount_acquire should be +* fallible */ struct btf *arg_btf;u32 arg_btf_id; +bool arg_owning_ref;struct {struct btf_field *field;
@@ -9497,11 +9500,6 @@ static bool is_kfunc_acquire(struct bpf_kfunc_call_arg_meta *meta)return meta->kfunc_flags &KF_ACQUIRE ; } -static bool is_kfunc_ret_null (struct bpf_kfunc_call_arg_meta *meta) -{ -return meta->kfunc_flags &KF_RET_NULL ; -} -static bool is_kfunc_release (struct bpf_kfunc_call_arg_meta *meta) {return meta->kfunc_flags &KF_RELEASE ;
@@ -9809,6 +9807,16 @@ BTF_ID(func, bpf_dynptr_from_xdp) BTF_ID(func, bpf_dynptr_slice) BTF_ID(func, bpf_dynptr_slice_rdwr) +static bool is_kfunc_ret_null (struct bpf_kfunc_call_arg_meta *meta) +{ +if (meta->func_id == special_kfunc_list[KF_bpf_refcount_acquire_impl] && + meta->arg_owning_ref) { +return false; + } + +return meta->kfunc_flags &KF_RET_NULL ; +} +static bool is_kfunc_bpf_rcu_read_lock (struct bpf_kfunc_call_arg_meta *meta) {return meta->func_id == special_kfunc_list[KF_bpf_rcu_read_lock];
@@ -10669,10 +10677,12 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_kfunc_call_ meta->subprogno = reg->subprogno;break ;case KF_ARG_PTR_TO_REFCOUNTED_KPTR : -if (!type_is_ptr_alloc_obj (reg->type) && !type_is_non_owning_ref (reg->type)) { +if (!type_is_ptr_alloc_obj (reg->type)) {verbose (env,"arg#%d is neither owning or non-owning ref\n" , i);return -EINVAL ; } +if (!type_is_non_owning_ref (reg->type)) + meta->arg_owning_ref = true; rec =reg_btf_record (reg);if (!rec) {
tools/testing/selftests/bpf/progs/refcounted_kptr.c +2 -0
@@ -375,6 +375,8 @@ long rbtree_refcounted_node_ref_escapes(void *ctx)bpf_rbtree_add (&aroot, &n->node, less_a); m =bpf_refcount_acquire (n);bpf_spin_unlock (&alock); +if (!m) +return 2 ; m->key =2 ;bpf_obj_drop (m);
tools/testing/selftests/bpf/progs/refcounted_kptr_fail.c +3 -1
@@ -29,7 +29,7 @@ static bool less(struct bpf_rb_node *a, const struct bpf_rb_node *b) } SEC("?tc") -__failure __msg("Unreleased reference id=3 alloc_insn=21") +__failure __msg("Unreleased reference id=4 alloc_insn=21") long rbtree_refcounted_node_ref_escapes(void *ctx) {struct node_acquire *n, *m;
@@ -43,6 +43,8 @@ long rbtree_refcounted_node_ref_escapes(void *ctx)/* m becomes an owning ref but is never drop'd or added to a tree */ m =bpf_refcount_acquire (n);bpf_spin_unlock (&glock); +if (!m) +return 2 ; m->key =2 ;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 175/800 wifi: iwlwifi: pull from TXQs with softirqs disabled
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 96fb6f47db24a712d650b0a9b9074873f273fb0e ]
In mac80211, it's required that we pull from TXQs by calling ieee80211_tx_dequeue() only with softirqs disabled. However, in iwl_mvm_queue_state_change() we're often called with them enabled, e.g. from flush if anything was flushed, triggering a mac80211 warning.
Fix that by disabling the softirqs across the TX call.
--- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +4 -1
@@ -1742,8 +1742,11 @@ static void iwl_mvm_queue_state_change(struct iwl_op_mode *op_mode,else set_bit (IWL_MVM_TXQ_STATE_STOP_FULL , &mvmtxq->state); -if (start && mvmsta->sta_state !=IEEE80211_STA_NOTEXIST ) +if (start && mvmsta->sta_state !=IEEE80211_STA_NOTEXIST ) { +local_bh_disable ();iwl_mvm_mac_itxq_xmit (mvm->hw, txq); +local_bh_enable (); + } } out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 184/800 watchdog/hardlockup: change watchdog_nmi_enable() to void
In reply to Greg Kroah-HartmanFrom: Lecopzer Chen <[email protected]>
[ Upstream commit 730211182ed083898fa5feb4b28459ffac4c9615 ]
Nobody cares about the return value of watchdog_nmi_enable(), changing its prototype to void.
Stable-dep-of: 9ec272c586b0 ("watchdog/hardlockup: keep kernel.nmi_watchdog sysctl as 0444 if probe fails")
--- arch/sparc/kernel/nmi.c | 8 +++----- include/linux/nmi.h | 2 +- kernel/watchdog.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-)
arch/sparc/kernel/nmi.c +3 -5
@@ -282,11 +282,11 @@ __setup("nmi_watchdog=", setup_nmi_watchdog);* sparc specific NMI watchdog enable function. * Enables watchdog if it is not enabled already. */ -int watchdog_nmi_enable (unsigned int cpu) +void watchdog_nmi_enable (unsigned int cpu) {if (atomic_read (&nmi_active) ==-1 ) {pr_warn ("NMI watchdog cannot be enabled or disabled\n" ); -return -1 ; +return ; }/*
@@ -295,11 +295,9 @@ int watchdog_nmi_enable(unsigned int cpu)* process first. */ if (!nmi_init_done) -return 0 ; +return ;smp_call_function_single (cpu, start_nmi_watchdog,NULL ,1 ); - -return 0 ; }/* * sparc specific NMI watchdog disable function.
include/linux/nmi.h +1 -1
@@ -119,7 +119,7 @@ static inline int hardlockup_detector_perf_init(void) { return 0; }void watchdog_nmi_stop (void );void watchdog_nmi_start (void );int watchdog_nmi_probe (void ); -int watchdog_nmi_enable (unsigned int cpu); +void watchdog_nmi_enable (unsigned int cpu);void watchdog_nmi_disable (unsigned int cpu);void lockup_detector_reconfigure (void );
kernel/watchdog.c +1 -2
@@ -93,10 +93,9 @@ __setup("nmi_watchdog=", hardlockup_panic_setup);* softlockup watchdog start and stop. The arch must select the * SOFTLOCKUP_DETECTOR Kconfig. */ -int __weak watchdog_nmi_enable (unsigned int cpu) +void __weak watchdog_nmi_enable (unsigned int cpu) {hardlockup_detector_perf_enable (); -return 0 ; }void __weak watchdog_nmi_disable (unsigned int cpu)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 185/800 watchdog/hardlockup: move perf hardlockup checking/panic to common watchdog.c
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 81972551df9d168a8183b786ff4de06008469c2e ]
The perf hardlockup detector works by looking at interrupt counts and seeing if they change from run to run. The interrupt counts are managed by the common watchdog code via its watchdog_timer_fn().
Currently the API between the perf detector and the common code is a
function: is_hardlockup(). When the hard lockup detector sees that function return true then it handles printing out debug info and inducing a panic if necessary.
Let's change the API a little bit in preparation for the buddy hardlockup detector. The buddy hardlockup detector wants to print nearly the same debug info and have nearly the same panic behavior. That means we want to move all that code to the common file. For now, the code in the common file will only be there if the perf hardlockup detector is enabled, but eventually it will be selected by a common config.
Right now, this _just_ moves the code from the perf detector file to the common file and changes the names. It doesn't make the changes that the buddy hardlockup detector will need and doesn't do any style cleanups. A future patch will do cleanup to make it more obvious what changed.
With the above, we no longer have any callers of is_hardlockup() outside of the "watchdog.c" file, so we can remove it from the header, make it static, and move it to the same "#ifdef" block as our new watchdog_hardlockup_check(). While doing this, it can be noted that even if no hardlockup detectors were configured the existing code used to still have the code for counting/checking "hrtimer_interrupts" even if the perf hardlockup detector wasn't configured. We didn't need to do that, so move all the "hrtimer_interrupts" counting to only be there if the perf hardlockup detector is configured as well.
This change is expected to be a no-op.
Stable-dep-of: 9ec272c586b0 ("watchdog/hardlockup: keep kernel.nmi_watchdog sysctl as 0444 if probe fails")
--- include/linux/nmi.h | 5 ++- kernel/watchdog.c | 93 +++++++++++++++++++++++++++++++++---------- kernel/watchdog_hld.c | 42 +------------------ 3 files changed, 78 insertions(+), 62 deletions(-)
include/linux/nmi.h +4 -1
@@ -15,7 +15,6 @@void lockup_detector_init (void );void lockup_detector_soft_poweroff (void );void lockup_detector_cleanup (void ); -bool is_hardlockup (void );extern int watchdog_user_enabled;extern int nmi_watchdog_user_enabled;
@@ -88,6 +87,10 @@ extern unsigned int hardlockup_panic;static inline void hardlockup_detector_disable (void ) {}#endif +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF ) +void watchdog_hardlockup_check (struct pt_regs *regs); +#endif +#if defined(CONFIG_HAVE_NMI_WATCHDOG ) || defined(CONFIG_HARDLOCKUP_DETECTOR )# define NMI_WATCHDOG_SYSCTL_PERM 0644#else
kernel/watchdog.c +73 -20
117 lines not on this page · raw message
kernel/watchdog_hld.c +1 -41
59 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 186/800 watchdog/hardlockup: rename some "NMI watchdog" constants/function
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit df95d3085caa5b99a60eb033d7ad6c2ff2b43dbf ]
Do a search and replace of:
- NMI_WATCHDOG_ENABLED => WATCHDOG_HARDLOCKUP_ENABLED
- SOFT_WATCHDOG_ENABLED => WATCHDOG_SOFTOCKUP_ENABLED
- watchdog_nmi_ => watchdog_hardlockup_
- nmi_watchdog_available => watchdog_hardlockup_available
- nmi_watchdog_user_enabled => watchdog_hardlockup_user_enabled
- soft_watchdog_user_enabled => watchdog_softlockup_user_enabled
- NMI_WATCHDOG_DEFAULT => WATCHDOG_HARDLOCKUP_DEFAULT
Then update a few comments near where names were changed.
This is specifically to make it less confusing when we want to introduce the buddy hardlockup detector, which isn't using NMIs. As part of this, we sanitized a few names for consistency.
Stable-dep-of: 9ec272c586b0 ("watchdog/hardlockup: keep kernel.nmi_watchdog sysctl as 0444 if probe fails")
--- arch/powerpc/include/asm/nmi.h | 4 +- arch/powerpc/kernel/watchdog.c | 12 +-- arch/powerpc/platforms/pseries/mobility.c | 4 +- arch/sparc/kernel/nmi.c | 4 +- include/linux/nmi.h | 24 +++-- kernel/watchdog.c | 113 +++++++++++----------- kernel/watchdog_hld.c | 2 +- 7 files changed, 81 insertions(+), 82 deletions(-)
arch/powerpc/include/asm/nmi.h +2 -2
@@ -5,10 +5,10 @@#ifdef CONFIG_PPC_WATCHDOG extern void arch_touch_nmi_watchdog (void );long soft_nmi_interrupt (struct pt_regs *regs); -void watchdog_nmi_set_timeout_pct (u64 pct); +void watchdog_hardlockup_set_timeout_pct (u64 pct);#else static inline void arch_touch_nmi_watchdog (void ) {} -static inline void watchdog_nmi_set_timeout_pct (u64 pct) {} +static inline void watchdog_hardlockup_set_timeout_pct (u64 pct) {}#endif #ifdef CONFIG_NMI_IPI
arch/powerpc/kernel/watchdog.c +6 -6
@@ -438,7 +438,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) {int cpu =smp_processor_id (); -if (!(watchdog_enabled &NMI_WATCHDOG_ENABLED )) +if (!(watchdog_enabled &WATCHDOG_HARDLOCKUP_ENABLED ))return HRTIMER_NORESTART ;if (!cpumask_test_cpu (cpu, &watchdog_cpumask))
@@ -479,7 +479,7 @@ static void start_watchdog(void *arg)return ; } -if (!(watchdog_enabled &NMI_WATCHDOG_ENABLED )) +if (!(watchdog_enabled &WATCHDOG_HARDLOCKUP_ENABLED ))return ;if (!cpumask_test_cpu (cpu, &watchdog_cpumask))
@@ -546,7 +546,7 @@ static void watchdog_calc_timeouts(void) wd_timer_period_ms = watchdog_thresh *1000 *2 /5 ; } -void watchdog_nmi_stop (void ) +void watchdog_hardlockup_stop (void ) {int cpu;
@@ -554,7 +554,7 @@ void watchdog_nmi_stop(void)stop_watchdog_on_cpu (cpu); } -void watchdog_nmi_start (void ) +void watchdog_hardlockup_start (void ) {int cpu;
@@ -566,7 +566,7 @@ void watchdog_nmi_start(void)/* * Invoked from core watchdog init. */ -int __init watchdog_nmi_probe (void ) +int __init watchdog_hardlockup_probe (void ) {int err;
@@ -582,7 +582,7 @@ int __init watchdog_nmi_probe(void) }#ifdef CONFIG_PPC_PSERIES -void watchdog_nmi_set_timeout_pct (u64 pct) +void watchdog_hardlockup_set_timeout_pct (u64 pct) {pr_info ("Set the NMI watchdog timeout factor to %llu%%\n" , pct);WRITE_ONCE (wd_timeout_pct, pct);
arch/powerpc/platforms/pseries/mobility.c +2 -2
@@ -750,7 +750,7 @@ static int pseries_migrate_partition(u64 handle) goto out;if (factor) -watchdog_nmi_set_timeout_pct (factor); +watchdog_hardlockup_set_timeout_pct (factor); ret =pseries_suspend (handle);if (ret ==0 ) {
@@ -766,7 +766,7 @@ static int pseries_migrate_partition(u64 handle)pseries_cancel_migration (handle, ret);if (factor) -watchdog_nmi_set_timeout_pct (0 ); +watchdog_hardlockup_set_timeout_pct (0 ); out:vas_migration_handler (VAS_RESUME );
arch/sparc/kernel/nmi.c +2 -2
@@ -282,7 +282,7 @@ __setup("nmi_watchdog=", setup_nmi_watchdog);* sparc specific NMI watchdog enable function. * Enables watchdog if it is not enabled already. */ -void watchdog_nmi_enable (unsigned int cpu) +void watchdog_hardlockup_enable (unsigned int cpu) {if (atomic_read (&nmi_active) ==-1 ) {pr_warn ("NMI watchdog cannot be enabled or disabled\n" );
@@ -303,7 +303,7 @@ void watchdog_nmi_enable(unsigned int cpu)* sparc specific NMI watchdog disable function. * Disables watchdog if it is not disabled already. */ -void watchdog_nmi_disable (unsigned int cpu) +void watchdog_hardlockup_disable (unsigned int cpu) {if (atomic_read (&nmi_active) ==-1 )pr_warn_once ("NMI watchdog cannot be enabled or disabled\n" );
include/linux/nmi.h +11 -13
@@ -17,8 +17,6 @@ void lockup_detector_soft_poweroff(void);void lockup_detector_cleanup (void );extern int watchdog_user_enabled; -extern int nmi_watchdog_user_enabled; -extern int soft_watchdog_user_enabled;extern int watchdog_thresh;extern unsigned long watchdog_enabled;
@@ -68,17 +66,17 @@ static inline void reset_hung_task_detector(void) { }* 'watchdog_enabled' variable. Each lockup detector has its dedicated bit - * bit 0 for the hard lockup detector and bit 1 for the soft lockup detector. * -* 'watchdog_user_enabled', 'nmi_watchdog_user_enabled' and -* 'soft_watchdog_user_enabled' are variables that are only used as an +* 'watchdog_user_enabled', 'watchdog_hardlockup_user_enabled' and +* 'watchdog_softlockup_user_enabled' are variables that are only used as an * 'interface' between the parameters in /proc/sys/kernel and the internal * state bits in 'watchdog_enabled'. The 'watchdog_thresh' variable is * handled differently because its value is not boolean, and the lockup * detectors are 'suspended' while 'watchdog_thresh' is equal zero. */ -#define NMI_WATCHDOG_ENABLED_BIT 0 -#define SOFT_WATCHDOG_ENABLED_BIT 1 -#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT) -#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) +#define WATCHDOG_HARDLOCKUP_ENABLED_BIT 0 +#define WATCHDOG_SOFTOCKUP_ENABLED_BIT 1 +#define WATCHDOG_HARDLOCKUP_ENABLED (1 << WATCHDOG_HARDLOCKUP_ENABLED_BIT) +#define WATCHDOG_SOFTOCKUP_ENABLED (1 << WATCHDOG_SOFTOCKUP_ENABLED_BIT)#if defined(CONFIG_HARDLOCKUP_DETECTOR )extern void hardlockup_detector_disable (void );
@@ -119,11 +117,11 @@ static inline int hardlockup_detector_perf_init(void) { return 0; }# endif #endif -void watchdog_nmi_stop (void ); -void watchdog_nmi_start (void ); -int watchdog_nmi_probe (void ); -void watchdog_nmi_enable (unsigned int cpu); -void watchdog_nmi_disable (unsigned int cpu); +void watchdog_hardlockup_stop (void ); +void watchdog_hardlockup_start (void ); +int watchdog_hardlockup_probe (void ); +void watchdog_hardlockup_enable (unsigned int cpu); +void watchdog_hardlockup_disable (unsigned int cpu);void lockup_detector_reconfigure (void );
kernel/watchdog.c +57 -56
276 lines not on this page · raw message
kernel/watchdog_hld.c +1 -1
@@ -228,7 +228,7 @@ void __init hardlockup_detector_perf_restart(void)lockdep_assert_cpus_held (); -if (!(watchdog_enabled &NMI_WATCHDOG_ENABLED )) +if (!(watchdog_enabled &WATCHDOG_HARDLOCKUP_ENABLED ))return ;for_each_online_cpu (cpu) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 187/800 watchdog/perf: adapt the watchdog_perf interface for async model
In reply to Greg Kroah-HartmanFrom: Lecopzer Chen <[email protected]>
[ Upstream commit 930d8f8dbab97cb05dba30e67a2dfa0c6dbf4bc7 ]
When lockup_detector_init()->watchdog_hardlockup_probe(), PMU may be not ready yet. E.g. on arm64, PMU is not ready until device_initcall(armv8_pmu_driver_init). And it is deeply integrated with the driver model and cpuhp. Hence it is hard to push this initialization before smp_init().
But it is easy to take an opposite approach and try to initialize the watchdog once again later. The delayed probe is called using workqueues. It need to allocate memory and must be proceed in a normal context. The delayed probe is able to use if watchdog_hardlockup_probe() returns non-zero which means the return code returned when PMU is not ready yet.
Provide an API - lockup_detector_retry_init() for anyone who needs to delayed init lockup detector if they had ever failed at lockup_detector_init().
The original assumption is: nobody should use delayed probe after lockup_detector_check() which has __init attribute. That is, anyone uses this API must call between lockup_detector_init() and lockup_detector_check(), and the caller must have __init attribute
Stable-dep-of: 9ec272c586b0 ("watchdog/hardlockup: keep kernel.nmi_watchdog sysctl as 0444 if probe fails")
--- include/linux/nmi.h | 2 ++ kernel/watchdog.c | 67 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-)
include/linux/nmi.h +2 -0
@@ -13,6 +13,7 @@#ifdef CONFIG_LOCKUP_DETECTOR void lockup_detector_init (void ); +void lockup_detector_retry_init (void );void lockup_detector_soft_poweroff (void );void lockup_detector_cleanup (void );
@@ -32,6 +33,7 @@ extern int sysctl_hardlockup_all_cpu_backtrace;#else /* CONFIG_LOCKUP_DETECTOR */ static inline void lockup_detector_init (void ) { } +static inline void lockup_detector_retry_init (void ) { }static inline void lockup_detector_soft_poweroff (void ) { }static inline void lockup_detector_cleanup (void ) { }#endif /* !CONFIG_LOCKUP_DETECTOR */
kernel/watchdog.c +66 -1
85 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 188/800 watchdog/hardlockup: keep kernel.nmi_watchdog sysctl as 0444 if probe fails
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 9ec272c586b07d1abf73438524bd12b1df9c5f9b ]
Patch series "watchdog: Cleanup / fixes after buddy series v5 reviews".
This patch series attempts to finish resolving the feedback received from Petr Mladek on the v5 series I posted.
Probably the only thing that wasn't fully as clean as Petr requested was the Kconfig stuff. I couldn't find a better way to express it without a more major overhaul. In the very least, I renamed "NON_ARCH" to "PERF_OR_BUDDY" in the hopes that will make it marginally better.
Nothing in this series is terribly critical and even the bugfixes are small. However, it does cleanup a few things that were pointed out in review.
This patch (of 10):
The permissions for the kernel.nmi_watchdog sysctl have always been set at compile time despite the fact that a watchdog can fail to probe. Let's fix this and set the permissions based on whether the hardlockup detector actually probed.
--- include/linux/nmi.h | 6 ------ kernel/watchdog.c | 30 ++++++++++++++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-)
include/linux/nmi.h +0 -6
@@ -91,12 +91,6 @@ static inline void hardlockup_detector_disable(void) {}void watchdog_hardlockup_check (struct pt_regs *regs);#endif -#if defined(CONFIG_HAVE_NMI_WATCHDOG ) || defined(CONFIG_HARDLOCKUP_DETECTOR ) -# define NMI_WATCHDOG_SYSCTL_PERM 0644 -#else -# define NMI_WATCHDOG_SYSCTL_PERM 0444 -#endif -#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF )extern void arch_touch_nmi_watchdog (void );extern void hardlockup_detector_perf_stop (void );
kernel/watchdog.c +20 -10
@@ -830,15 +830,6 @@ static struct ctl_table watchdog_sysctls[] = { .extra1 = SYSCTL_ZERO, .extra2 = (void *)&sixty, }, - { - .procname = "nmi_watchdog", - .data = &watchdog_hardlockup_user_enabled, - .maxlen = sizeof(int), - .mode = NMI_WATCHDOG_SYSCTL_PERM, - .proc_handler = proc_nmi_watchdog, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, { .procname = "watchdog_cpumask", .data = &watchdog_cpumask_bits,
@@ -902,10 +893,28 @@ static struct ctl_table watchdog_sysctls[] = { {} }; +static struct ctl_table watchdog_hardlockup_sysctl[] = { + { + .procname ="nmi_watchdog" , + .data = &watchdog_hardlockup_user_enabled, + .maxlen =sizeof (int ), + .mode =0444 , + .proc_handler = proc_nmi_watchdog, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_ONE , + }, + {} +}; +static void __init watchdog_sysctl_init (void ) {register_sysctl_init ("kernel" , watchdog_sysctls); + +if (watchdog_hardlockup_available) + watchdog_hardlockup_sysctl[0 ].mode =0644 ; +register_sysctl_init ("kernel" , watchdog_hardlockup_sysctl); } +#else #define watchdog_sysctl_init () do { } while (0)#endif /* CONFIG_SYSCTL */
@@ -961,6 +970,8 @@ static int __init lockup_detector_check(void)/* Make sure no work is pending. */ flush_work (&detector_work); +watchdog_sysctl_init (); +return 0 ; }
@@ -980,5 +991,4 @@ void __init lockup_detector_init(void) allow_lockup_detector_init_retry = true;lockup_detector_setup (); -watchdog_sysctl_init (); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 189/800 mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit c467c8f081859d4f4ca4eee4fba54bb5d85d6c97 ]
This microSD card never clears Flush Cache bit after cache flush has been started in sd_flush_cache(). This leads e.g. to failure to mount file system. Add a quirk which disables the SD cache for this specific card from specific manufacturing date of 11/2019, since on newer dated cards from 05/2023 the cache flush works correctly.
--- drivers/mmc/core/card.h | 30 +++++++++++++++++++++++------- drivers/mmc/core/quirks.h | 13 +++++++++++++ drivers/mmc/core/sd.c | 2 +- include/linux/mmc/card.h | 1 + 4 files changed, 38 insertions(+), 8 deletions(-)
drivers/mmc/core/card.h +23 -7
@@ -53,6 +53,10 @@ struct mmc_fixup {unsigned int manfid;unsigned short oemid; +/* Manufacturing date */ +unsigned short year; +unsigned char month; +/* SDIO-specific fields. You can use SDIO_ANY_ID here of course */ u16 cis_vendor, cis_device;
@@ -68,6 +72,8 @@ struct mmc_fixup {#define CID_MANFID_ANY (-1u)#define CID_OEMID_ANY ((unsigned short) -1) +#define CID_YEAR_ANY ((unsigned short) -1) +#define CID_MONTH_ANY ((unsigned char) -1)#define CID_NAME_ANY (NULL)#define EXT_CSD_REV_ANY (-1u)
@@ -81,17 +87,21 @@ struct mmc_fixup {#define CID_MANFID_APACER 0x27#define CID_MANFID_KINGSTON 0x70#define CID_MANFID_HYNIX 0x90 +#define CID_MANFID_KINGSTON_SD 0x9F#define CID_MANFID_NUMONYX 0xFE#define END_FIXUP { NULL } -#define _FIXUP_EXT (_name, _manfid, _oemid, _rev_start, _rev_end, \ - _cis_vendor, _cis_device, \ - _fixup, _data, _ext_csd_rev) \ +#define _FIXUP_EXT (_name, _manfid, _oemid, _year, _month, \ + _rev_start, _rev_end, \ + _cis_vendor, _cis_device, \ + _fixup, _data, _ext_csd_rev) \ { \ .name = (_name), \ .manfid = (_manfid), \ .oemid = (_oemid), \ + .year = (_year), \ + .month = (_month), \ .rev_start = (_rev_start), \ .rev_end = (_rev_end), \ .cis_vendor = (_cis_vendor), \
@@ -103,8 +113,8 @@ struct mmc_fixup {#define MMC_FIXUP_REV (_name, _manfid, _oemid, _rev_start, _rev_end, \ _fixup, _data, _ext_csd_rev) \ - _FIXUP_EXT(_name, _manfid, \ - _oemid, _rev_start, _rev_end, \ + _FIXUP_EXT(_name, _manfid, _oemid, CID_YEAR_ANY, CID_MONTH_ANY, \ + _rev_start, _rev_end, \ SDIO_ANY_ID, SDIO_ANY_ID, \ _fixup, _data, _ext_csd_rev) \
@@ -118,8 +128,9 @@ struct mmc_fixup { _ext_csd_rev)#define SDIO_FIXUP (_vendor, _device, _fixup, _data) \ - _FIXUP_EXT(CID_NAME_ANY, CID_MANFID_ANY, \ - CID_OEMID_ANY, 0, -1ull, \ + _FIXUP_EXT(CID_NAME_ANY, CID_MANFID_ANY, CID_OEMID_ANY, \ + CID_YEAR_ANY, CID_MONTH_ANY, \ + 0, -1ull, \ _vendor, _device, \ _fixup, _data, EXT_CSD_REV_ANY) \
@@ -264,4 +275,9 @@ static inline int mmc_card_broken_sd_discard(const struct mmc_card *c) return c->quirks & MMC_QUIRK_BROKEN_SD_DISCARD; } +static inline int mmc_card_broken_sd_cache (const struct mmc_card *c) +{ +return c->quirks &MMC_QUIRK_BROKEN_SD_CACHE ; +} +#endif
drivers/mmc/core/quirks.h +13 -0
@@ -53,6 +53,15 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {MMC_FIXUP ("MMC32G" ,CID_MANFID_TOSHIBA ,CID_OEMID_ANY , add_quirk_mmc,MMC_QUIRK_BLK_NO_CMD23 ), +/* +* Kingston Canvas Go! Plus microSD cards never finish SD cache flush. +* This has so far only been observed on cards from 11/2019, while new +* cards from 2023/05 do not exhibit this behavior. +*/ +_FIXUP_EXT ("SD64G" ,CID_MANFID_KINGSTON_SD ,0x5449 ,2019 ,11 , +0 ,-1ull ,SDIO_ANY_ID ,SDIO_ANY_ID , add_quirk_sd, + MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY), +/* * Some SD cards lockup while using CMD23 multiblock transfers. */
@@ -209,6 +218,10 @@ static inline void mmc_fixup_device(struct mmc_card *card,if (f->of_compatible && !mmc_fixup_of_compatible_match (card, f->of_compatible))continue ; +if (f->year !=CID_YEAR_ANY && f->year != card->cid.year) +continue ; +if (f->month !=CID_MONTH_ANY && f->month != card->cid.month) +continue ;dev_dbg (&card->dev,"calling %ps\n" , f->vendor_fixup); f->vendor_fixup (card, f->data);
drivers/mmc/core/sd.c +1 -1
@@ -1170,7 +1170,7 @@ static int sd_parse_ext_reg_perf(struct mmc_card *card, u8 fno, u8 page, card->ext_perf.feature_support |=SD_EXT_PERF_HOST_MAINT ;/* Cache support at bit 0. */ -if (reg_buf[4 ] &BIT (0 )) +if ((reg_buf[4 ] &BIT (0 )) && !mmc_card_broken_sd_cache (card)) card->ext_perf.feature_support |=SD_EXT_PERF_CACHE ;/* Command queue support indicated via queue depth bits (0 to 4). */
include/linux/mmc/card.h +1 -0
@@ -294,6 +294,7 @@ struct mmc_card {#define MMC_QUIRK_TRIM_BROKEN (1<<12)/* Skip trim */ #define MMC_QUIRK_BROKEN_HPI (1<<13)/* Disable broken HPI support */ #define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14)/* Disable broken SD discard support */ +#define MMC_QUIRK_BROKEN_SD_CACHE (1<<15)/* Disable broken SD cache support */ bool reenable_cmdq;/* Re-enable Command Queue */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 190/800 wifi: iwlwifi: mvm: indicate HW decrypt for beacon protection
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 2db72b8a700943aa54dce0aabe6ff1b72b615162 ]
We've already done the 'decryption' here, so tell
mac80211 it need not do it again.
--- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +6 -3
@@ -279,7 +279,8 @@ static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm,static int iwl_mvm_rx_mgmt_prot (struct ieee80211_sta *sta,struct ieee80211_hdr *hdr,struct iwl_rx_mpdu_desc *desc, -u32 status) +u32 status, +struct ieee80211_rx_status *stats) {struct iwl_mvm_sta *mvmsta;struct iwl_mvm_vif *mvmvif;
@@ -308,8 +309,10 @@ static int iwl_mvm_rx_mgmt_prot(struct ieee80211_sta *sta,/* good cases */ if (likely (status &IWL_RX_MPDU_STATUS_MIC_OK && - !(status &IWL_RX_MPDU_STATUS_REPLAY_ERROR ))) + !(status &IWL_RX_MPDU_STATUS_REPLAY_ERROR ))) { + stats->flag |=RX_FLAG_DECRYPTED ;return 0 ; + }if (!sta)return -1 ;
@@ -378,7 +381,7 @@ static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_sta *sta,if (unlikely (ieee80211_is_mgmt (hdr->frame_control) && !ieee80211_has_protected (hdr->frame_control))) -return iwl_mvm_rx_mgmt_prot (sta, hdr, desc, status); +return iwl_mvm_rx_mgmt_prot (sta, hdr, desc, status, stats);if (!ieee80211_has_protected (hdr->frame_control) || (status & IWL_RX_MPDU_STATUS_SEC_MASK) ==
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 191/800 wifi: iwlwifi: mvm: check only affected links
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit de1076008148460fe273e6d39158faffcc954991 ]
When hostapd starts up, it may start up with only one link while the other is still scanning for overlapping BSSes. A station might start to connect at this point, but we run into this warning instead. Since there's no need to check for _all_ links, restrict the check to just the affected links that the STA will be using.
--- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +2 -1
@@ -3846,6 +3846,7 @@ int iwl_mvm_mac_sta_state_common(struct ieee80211_hw *hw,struct iwl_mvm *mvm =IWL_MAC80211_GET_MVM (hw);struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif);struct iwl_mvm_sta *mvm_sta =iwl_mvm_sta_from_mac80211 (sta); +struct ieee80211_link_sta *link_sta;unsigned int link_id;int ret;
@@ -3887,7 +3888,7 @@ int iwl_mvm_mac_sta_state_common(struct ieee80211_hw *hw,mutex_lock (&mvm->mutex);/* this would be a mac80211 bug ... but don't crash */ -for_each_mvm_vif_valid_link (mvmvif, link_id) { +for_each_sta_active_link (vif, sta, link_sta, link_id) {if (WARN_ON_ONCE (!mvmvif->link[link_id]->phy_ctxt)) {mutex_unlock (&mvm->mutex); return test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 192/800 wifi: ath9k: convert msecs to jiffies where needed
In reply to Greg Kroah-HartmanFrom: Dmitry Antipov <[email protected]>
[ Upstream commit 2aa083acea9f61be3280184384551178f510ff51 ]
Since 'ieee80211_queue_delayed_work()' expects timeout in jiffies and not milliseconds, 'msecs_to_jiffies()' should be used in 'ath_restart_work()' and '__ath9k_flush()'.
--- drivers/net/wireless/ath/ath9k/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +2 -2
@@ -203,7 +203,7 @@ void ath_cancel_work(struct ath_softc *sc)void ath_restart_work (struct ath_softc *sc) {ieee80211_queue_delayed_work (sc->hw, &sc->hw_check_work, -ATH_HW_CHECK_POLL_INT ); +msecs_to_jiffies (ATH_HW_CHECK_POLL_INT ));if (AR_SREV_9340 (sc->sc_ah) ||AR_SREV_9330 (sc->sc_ah)) ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
@@ -2240,7 +2240,7 @@ void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop, }ieee80211_queue_delayed_work (hw, &sc->hw_check_work, -ATH_HW_CHECK_POLL_INT ); +msecs_to_jiffies (ATH_HW_CHECK_POLL_INT )); }static bool ath9k_tx_frames_pending (struct ieee80211_hw *hw)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 193/800 bpf: Factor out socket lookup functions for the TC hookpoint.
In reply to Greg Kroah-HartmanFrom: Gilad Sever <[email protected]>
[ Upstream commit 6e98730bc0b44acaf86eccc75f823128aa9c9e79 ]
Change BPF helper socket lookup functions to use TC specific variants:bpf_tc_sk_lookup_tcp() / bpf_tc_sk_lookup_udp() / bpf_tc_skc_lookup_tcp() instead of sharing implementation with the cg / sk_skb hooking points. This allows introducing a separate logic for the TC flow.
The tc functions are identical to the original code.
Stable-dep-of: 9a5cb79762e0 ("bpf: Fix bpf socket lookup from tc/xdp to respect socket VRF bindings")
--- net/core/filter.c | 63 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-)
net/core/filter.c +60 -3
@@ -6727,6 +6727,63 @@ static const struct bpf_func_proto bpf_sk_lookup_udp_proto = { .arg5_type = ARG_ANYTHING, }; +BPF_CALL_5(bpf_tc_skc_lookup_tcp, struct sk_buff *, skb, + struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) +{ +return (unsigned long )bpf_skc_lookup (skb, tuple, len,IPPROTO_TCP , + netns_id, flags); +} + +static const struct bpf_func_proto bpf_tc_skc_lookup_tcp_proto = { + .func = bpf_tc_skc_lookup_tcp, + .gpl_only = false, + .pkt_access = true, + .ret_type =RET_PTR_TO_SOCK_COMMON_OR_NULL , + .arg1_type =ARG_PTR_TO_CTX , + .arg2_type =ARG_PTR_TO_MEM |MEM_RDONLY , + .arg3_type =ARG_CONST_SIZE , + .arg4_type =ARG_ANYTHING , + .arg5_type =ARG_ANYTHING , +}; + +BPF_CALL_5(bpf_tc_sk_lookup_tcp, struct sk_buff *, skb, + struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) +{ +return (unsigned long )bpf_sk_lookup (skb, tuple, len,IPPROTO_TCP , + netns_id, flags); +} + +static const struct bpf_func_proto bpf_tc_sk_lookup_tcp_proto = { + .func = bpf_tc_sk_lookup_tcp, + .gpl_only = false, + .pkt_access = true, + .ret_type =RET_PTR_TO_SOCKET_OR_NULL , + .arg1_type =ARG_PTR_TO_CTX , + .arg2_type =ARG_PTR_TO_MEM |MEM_RDONLY , + .arg3_type =ARG_CONST_SIZE , + .arg4_type =ARG_ANYTHING , + .arg5_type =ARG_ANYTHING , +}; + +BPF_CALL_5(bpf_tc_sk_lookup_udp, struct sk_buff *, skb, + struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) +{ +return (unsigned long )bpf_sk_lookup (skb, tuple, len,IPPROTO_UDP , + netns_id, flags); +} + +static const struct bpf_func_proto bpf_tc_sk_lookup_udp_proto = { + .func = bpf_tc_sk_lookup_udp, + .gpl_only = false, + .pkt_access = true, + .ret_type =RET_PTR_TO_SOCKET_OR_NULL , + .arg1_type =ARG_PTR_TO_CTX , + .arg2_type =ARG_PTR_TO_MEM |MEM_RDONLY , + .arg3_type =ARG_CONST_SIZE , + .arg4_type =ARG_ANYTHING , + .arg5_type =ARG_ANYTHING , +}; + BPF_CALL_1(bpf_sk_release, struct sock *, sk) {if (sk &&sk_is_refcounted (sk))
@@ -7980,9 +8037,9 @@ tc_cls_act_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)#endif #ifdef CONFIG_INET case BPF_FUNC_sk_lookup_tcp: -return &bpf_sk_lookup_tcp_proto; +return &bpf_tc_sk_lookup_tcp_proto;case BPF_FUNC_sk_lookup_udp: -return &bpf_sk_lookup_udp_proto; +return &bpf_tc_sk_lookup_udp_proto;case BPF_FUNC_sk_release:return &bpf_sk_release_proto;case BPF_FUNC_tcp_sock:
@@ -7990,7 +8047,7 @@ tc_cls_act_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)case BPF_FUNC_get_listener_sock:return &bpf_get_listener_sock_proto;case BPF_FUNC_skc_lookup_tcp: -return &bpf_skc_lookup_tcp_proto; +return &bpf_tc_skc_lookup_tcp_proto;case BPF_FUNC_tcp_check_syncookie:return &bpf_tcp_check_syncookie_proto;case BPF_FUNC_skb_ecn_set_ce:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 176/800 wifi: iwlwifi: pcie: fix NULL pointer dereference in iwl_pcie_irq_rx_msix_handler()
In reply to Greg Kroah-HartmanFrom: Anjaneyulu <[email protected]>
[ Upstream commit 1902f1953b8ba100ee8705cb8a6f1a9795550eca ]
rxq can be NULL only when trans_pcie->rxq is NULL and entry->entry is zero. For the case when entry->entry is not equal to 0, rxq won't be NULL even if trans_pcie->rxq is NULL. Modify checker to check for trans_pcie->rxq.
--- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/rx.c +3 -2
@@ -1636,14 +1636,14 @@ irqreturn_t iwl_pcie_irq_rx_msix_handler(int irq, void *dev_id)struct msix_entry *entry = dev_id;struct iwl_trans_pcie *trans_pcie =iwl_pcie_get_trans_pcie (entry);struct iwl_trans *trans = trans_pcie->trans; -struct iwl_rxq *rxq = &trans_pcie->rxq[entry->entry]; +struct iwl_rxq *rxq;trace_iwlwifi_dev_irq_msix (trans->dev, entry, false,0 ,0 );if (WARN_ON (entry->entry >= trans->num_rx_queues))return IRQ_NONE ; -if (!rxq) { +if (!trans_pcie->rxq) {if (net_ratelimit ()) IWL_ERR(trans, "[%d] Got MSI-X interrupt before we have Rx queues\n",
@@ -1651,6 +1651,7 @@ irqreturn_t iwl_pcie_irq_rx_msix_handler(int irq, void *dev_id)return IRQ_NONE ; } + rxq = &trans_pcie->rxq[entry->entry];lock_map_acquire (&trans->sync_cmd_lockdep_map);IWL_DEBUG_ISR (trans,"[%d] Got interrupt\n" , entry->entry);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 194/800 bpf: Call __bpf_sk_lookup()/__bpf_skc_lookup() directly via TC hookpoint
In reply to Greg Kroah-HartmanFrom: Gilad Sever <[email protected]>
[ Upstream commit 97fbfeb86917bdbe9c41d5143e335a929147f405 ]
skb->dev always exists in the tc flow. There is no need to use bpf_skc_lookup(), bpf_sk_lookup() from this code path.
This change facilitates fixing the tc flow to be VRF aware.
Stable-dep-of: 9a5cb79762e0 ("bpf: Fix bpf socket lookup from tc/xdp to respect socket VRF bindings")
--- net/core/filter.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
net/core/filter.c +18 -6
@@ -6730,8 +6730,12 @@ static const struct bpf_func_proto bpf_sk_lookup_udp_proto = { BPF_CALL_5(bpf_tc_skc_lookup_tcp, struct sk_buff *, skb, struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) { -return (unsigned long )bpf_skc_lookup (skb, tuple, len,IPPROTO_TCP , - netns_id, flags); +struct net *caller_net =dev_net (skb->dev); +int ifindex = skb->dev->ifindex; + +return (unsigned long )__bpf_skc_lookup (skb, tuple, len, caller_net, + ifindex,IPPROTO_TCP , netns_id, + flags); }static const struct bpf_func_proto bpf_tc_skc_lookup_tcp_proto = {
@@ -6749,8 +6753,12 @@ static const struct bpf_func_proto bpf_tc_skc_lookup_tcp_proto = { BPF_CALL_5(bpf_tc_sk_lookup_tcp, struct sk_buff *, skb, struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) { -return (unsigned long )bpf_sk_lookup (skb, tuple, len,IPPROTO_TCP , - netns_id, flags); +struct net *caller_net =dev_net (skb->dev); +int ifindex = skb->dev->ifindex; + +return (unsigned long )__bpf_sk_lookup (skb, tuple, len, caller_net, + ifindex,IPPROTO_TCP , netns_id, + flags); }static const struct bpf_func_proto bpf_tc_sk_lookup_tcp_proto = {
@@ -6768,8 +6776,12 @@ static const struct bpf_func_proto bpf_tc_sk_lookup_tcp_proto = { BPF_CALL_5(bpf_tc_sk_lookup_udp, struct sk_buff *, skb, struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) { -return (unsigned long )bpf_sk_lookup (skb, tuple, len,IPPROTO_UDP , - netns_id, flags); +struct net *caller_net =dev_net (skb->dev); +int ifindex = skb->dev->ifindex; + +return (unsigned long )__bpf_sk_lookup (skb, tuple, len, caller_net, + ifindex,IPPROTO_UDP , netns_id, + flags); }static const struct bpf_func_proto bpf_tc_sk_lookup_udp_proto = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 195/800 bpf: Fix bpf socket lookup from tc/xdp to respect socket VRF bindings
In reply to Greg Kroah-HartmanFrom: Gilad Sever <[email protected]>
[ Upstream commit 9a5cb79762e0eda17ca15c2a6eaca4622383c21c ]
When calling bpf_sk_lookup_tcp(), bpf_sk_lookup_udp() or bpf_skc_lookup_tcp() from tc/xdp ingress, VRF socket bindings aren't respoected, i.e. unbound sockets are returned, and bound sockets aren't found.
VRF binding is determined by the sdif argument to sk_lookup(), however when called from tc the IP SKB control block isn't initialized and thus inet{,6}_sdif() always returns 0.
Fix by calculating sdif for the tc/xdp flows by observing the device's l3 enslaved state.
The cg/sk_skb hooking points which are expected to support inet{,6}_sdif() pass sdif=-1 which makes __bpf_skc_lookup() use the existing logic.
--- include/linux/netdevice.h | 9 +++++ net/core/filter.c | 69 ++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 30 deletions(-)
include/linux/netdevice.h +9 -0
@@ -5093,6 +5093,15 @@ static inline bool netif_is_l3_slave(const struct net_device *dev)return dev->priv_flags &IFF_L3MDEV_SLAVE ; } +static inline int dev_sdif (const struct net_device *dev) +{ +#ifdef CONFIG_NET_L3_MASTER_DEV +if (netif_is_l3_slave (dev)) +return dev->ifindex; +#endif +return 0 ; +} +static inline bool netif_is_bridge_master (const struct net_device *dev) {return dev->priv_flags &IFF_EBRIDGE ;
net/core/filter.c +39 -30
171 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 196/800 can: length: fix bitstuffing count
In reply to Greg Kroah-HartmanFrom: Vincent Mailhol <[email protected]>
[ Upstream commit 9fde4c557f78ee2f3626e92b4089ce9d54a2573a ]
The Stuff Bit Count is always coded on 4 bits [1]. Update the Stuff Bit Count size accordingly.
In addition, the CRC fields of CAN FD Frames contain stuff bits at fixed positions called fixed stuff bits [2]. The CRC field starts with a fixed stuff bit and then has another fixed stuff bit after each fourth bit [2], which allows us to derive this formula:
FSB count = 1 + round_down(len(CRC field)/4)
The length of the CRC field is [1]:
len(CRC field) = len(Stuff Bit Count) + len(CRC)
= 4 + len(CRC)
with len(CRC) either 17 or 21 bits depending of the payload length.
In conclusion, for CRC17:
FSB count = 1 + round_down((4 + 17)/4)
= 6
and for CRC 21:
FSB count = 1 + round_down((4 + 21)/4)
= 7
Add a Fixed Stuff bits (FSB) field with above values and update CANFD_FRAME_OVERHEAD_SFF and CANFD_FRAME_OVERHEAD_EFF accordingly.
[1] ISO 11898-1:2015 section 10.4.2.6 "CRC field":
The CRC field shall contain the CRC sequence followed by a recessive CRC delimiter. For FD Frames, the CRC field shall also contain the stuff count.
Stuff count
If FD Frames, the stuff count shall be at the beginning of the CRC field. It shall consist of the stuff bit count modulo 8 in a 3-bit gray code followed by a parity bit [...]
[2] ISO 11898-1:2015 paragraph 10.5 "Frame coding":
In the CRC field of FD Frames, the stuff bits shall be inserted at fixed positions; they are called fixed stuff bits. There shall be a fixed stuff bit before the first bit of the stuff count, even if the last bits of the preceding field are a sequence of five consecutive bits of identical value, there shall be only the fixed stuff bit, there shall not be two consecutive stuff bits. A further fixed stuff bit shall be inserted after each fourth bit of the CRC field [...]
--- include/linux/can/length.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
include/linux/can/length.h +8 -6
@@ -69,17 +69,18 @@* Error Status Indicator (ESI) 1 * Data length code (DLC) 4 * Data field 0...512 -* Stuff Bit Count (SBC) 0...16: 4 20...64:5 +* Stuff Bit Count (SBC) 4 * CRC 0...16: 17 20...64:21 * CRC delimiter (CD) 1 +* Fixed Stuff bits (FSB) 0...16: 6 20...64:7 * ACK slot (AS) 1 * ACK delimiter (AD) 1 * End-of-frame (EOF) 7 * Inter frame spacing 3 * -* assuming CRC21, rounded up and ignoring bitstuffing +* assuming CRC21, rounded up and ignoring dynamic bitstuffing */ -#define CANFD_FRAME_OVERHEAD_SFF DIV_ROUND_UP(61, 8) +#define CANFD_FRAME_OVERHEAD_SFF DIV_ROUND_UP(67, 8)/* * Size of a CAN-FD Extended Frame
@@ -98,17 +99,18 @@* Error Status Indicator (ESI) 1 * Data length code (DLC) 4 * Data field 0...512 -* Stuff Bit Count (SBC) 0...16: 4 20...64:5 +* Stuff Bit Count (SBC) 4 * CRC 0...16: 17 20...64:21 * CRC delimiter (CD) 1 +* Fixed Stuff bits (FSB) 0...16: 6 20...64:7 * ACK slot (AS) 1 * ACK delimiter (AD) 1 * End-of-frame (EOF) 7 * Inter frame spacing 3 * -* assuming CRC21, rounded up and ignoring bitstuffing +* assuming CRC21, rounded up and ignoring dynamic bitstuffing */ -#define CANFD_FRAME_OVERHEAD_EFF DIV_ROUND_UP(80, 8) +#define CANFD_FRAME_OVERHEAD_EFF DIV_ROUND_UP(86, 8)/* * Maximum size of a Classical CAN frame
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 197/800 can: kvaser_pciefd: Add function to set skb hwtstamps
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 2d55e9f9b4427e1ad59b974f2267767aac3788d3 ]
Add new function, kvaser_pciefd_set_skb_timestamp(), to set skb hwtstamps.
Stable-dep-of: ec681b91befa ("can: kvaser_pciefd: Set hardware timestamp on transmitted packets")
--- drivers/net/can/kvaser_pciefd.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-)
drivers/net/can/kvaser_pciefd.c +10 -17
@@ -538,6 +538,13 @@ static int kvaser_pciefd_set_tx_irq(struct kvaser_pciefd_can *can)return 0 ; } +static inline void kvaser_pciefd_set_skb_timestamp (const struct kvaser_pciefd *pcie, +struct sk_buff *skb,u64 timestamp) +{ +skb_hwtstamps (skb)->hwtstamp = +ns_to_ktime (div_u64 (timestamp *1000 , pcie->freq_to_ticks_div)); +} +static void kvaser_pciefd_setup_controller (struct kvaser_pciefd_can *can) {u32 mode;
@@ -1171,7 +1178,6 @@ static int kvaser_pciefd_handle_data_packet(struct kvaser_pciefd *pcie,struct canfd_frame *cf;struct can_priv *priv;struct net_device_stats *stats; -struct skb_shared_hwtstamps *shhwtstamps;u8 ch_id = (p->header[1 ] >>KVASER_PCIEFD_PACKET_CHID_SHIFT ) &0x7 ;if (ch_id >= pcie->nr_channels)
@@ -1214,12 +1220,7 @@ static int kvaser_pciefd_handle_data_packet(struct kvaser_pciefd *pcie, stats->rx_bytes += cf->len; } stats->rx_packets++; - - shhwtstamps =skb_hwtstamps (skb); - - shhwtstamps->hwtstamp = -ns_to_ktime (div_u64 (p->timestamp *1000 , - pcie->freq_to_ticks_div)); +kvaser_pciefd_set_skb_timestamp (pcie, skb, p->timestamp);return netif_rx (skb); }
@@ -1282,7 +1283,6 @@ static int kvaser_pciefd_rx_error_frame(struct kvaser_pciefd_can *can,struct net_device *ndev = can->can.dev;struct sk_buff *skb;struct can_frame *cf =NULL ; -struct skb_shared_hwtstamps *shhwtstamps;struct net_device_stats *stats = &ndev->stats; old_state = can->can.state;
@@ -1323,10 +1323,7 @@ static int kvaser_pciefd_rx_error_frame(struct kvaser_pciefd_can *can,return -ENOMEM ; } - shhwtstamps =skb_hwtstamps (skb); - shhwtstamps->hwtstamp = -ns_to_ktime (div_u64 (p->timestamp *1000 , - can->kv_pcie->freq_to_ticks_div)); +kvaser_pciefd_set_skb_timestamp (can->kv_pcie, skb, p->timestamp); cf->can_id |=CAN_ERR_BUSERROR |CAN_ERR_CNT ; cf->data[6 ] = bec.txerr;
@@ -1374,7 +1371,6 @@ static int kvaser_pciefd_handle_status_resp(struct kvaser_pciefd_can *can,struct net_device *ndev = can->can.dev;struct sk_buff *skb;struct can_frame *cf; -struct skb_shared_hwtstamps *shhwtstamps; skb =alloc_can_err_skb (ndev, &cf);if (!skb) {
@@ -1394,10 +1390,7 @@ static int kvaser_pciefd_handle_status_resp(struct kvaser_pciefd_can *can, cf->can_id |=CAN_ERR_RESTARTED ; } - shhwtstamps =skb_hwtstamps (skb); - shhwtstamps->hwtstamp = -ns_to_ktime (div_u64 (p->timestamp *1000 , - can->kv_pcie->freq_to_ticks_div)); +kvaser_pciefd_set_skb_timestamp (can->kv_pcie, skb, p->timestamp); cf->data[6 ] = bec.txerr; cf->data[7 ] = bec.rxerr;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 198/800 can: kvaser_pciefd: Set hardware timestamp on transmitted packets
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit ec681b91befa982477e24a150dd6452427fe6473 ]
Set hardware timestamp on transmitted packets.
--- drivers/net/can/kvaser_pciefd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/can/kvaser_pciefd.c +10 -2
@@ -1519,6 +1519,7 @@ static void kvaser_pciefd_handle_nack_packet(struct kvaser_pciefd_can *can,if (skb) { cf->can_id |=CAN_ERR_BUSERROR ; +kvaser_pciefd_set_skb_timestamp (can->kv_pcie, skb, p->timestamp);netif_rx (skb); }else { stats->rx_dropped++;
@@ -1550,8 +1551,15 @@ static int kvaser_pciefd_handle_ack_packet(struct kvaser_pciefd *pcie,netdev_dbg (can->can.dev,"Packet was flushed\n" ); }else {int echo_idx = p->header[0 ] &KVASER_PCIEFD_PACKET_SEQ_MSK ; -int dlc =can_get_echo_skb (can->can.dev, echo_idx,NULL ); -u8 count =ioread32 (can->reg_base + +int dlc; +u8 count; +struct sk_buff *skb; + + skb = can->can.echo_skb[echo_idx]; +if (skb) +kvaser_pciefd_set_skb_timestamp (pcie, skb, p->timestamp); + dlc =can_get_echo_skb (can->can.dev, echo_idx,NULL ); + count =ioread32 (can->reg_base +KVASER_PCIEFD_KCAN_TX_NPACKETS_REG ) &0xff ; if (count < KVASER_PCIEFD_CAN_TX_MAX_COUNT &&
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 199/800 igc: Fix race condition in PTP tx code
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 9c50e2b150c8ee0eee5f8154e2ad168cdd748877 ]
Currently, the igc driver supports timestamping only one tx packet at a time. During the transmission flow, the skb that requires hardware timestamping is saved in adapter->ptp_tx_skb. Once hardware has the timestamp, an interrupt is delivered, and adapter->ptp_tx_work is scheduled. In igc_ptp_tx_work(), we read the timestamp register, update adapter->ptp_tx_skb, and notify the network stack.
While the thread executing the transmission flow (the user process running in kernel mode) and the thread executing ptp_tx_work don't access adapter->ptp_tx_skb concurrently, there are two other places where adapter->ptp_tx_skb is accessed: igc_ptp_tx_hang() and igc_ptp_suspend().
igc_ptp_tx_hang() is executed by the adapter->watchdog_task worker thread which runs periodically so it is possible we have two threads accessing ptp_tx_skb at the same time. Consider the following scenario:
right after __IGC_PTP_TX_IN_PROGRESS is set in igc_xmit_frame_ring(), igc_ptp_tx_hang() is executed. Since adapter->ptp_tx_start hasn't been written yet, this is considered a timeout and adapter->ptp_tx_skb is cleaned up.
This patch fixes the issue described above by adding the ptp_tx_lock to protect access to ptp_tx_skb and ptp_tx_start fields from igc_adapter. Since igc_xmit_frame_ring() called in atomic context by the networking stack, ptp_tx_lock is defined as a spinlock, and the irq safe variants of lock/unlock are used.
With the introduction of the ptp_tx_lock, the __IGC_PTP_TX_IN_PROGRESS flag doesn't provide much of a use anymore so this patch gets rid of it.
--- drivers/net/ethernet/intel/igc/igc.h | 5 +- drivers/net/ethernet/intel/igc/igc_main.c | 9 ++-- drivers/net/ethernet/intel/igc/igc_ptp.c | 57 ++++++++++++----------- 3 files changed, 41 insertions(+), 30 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +4 -1
@@ -230,6 +230,10 @@ struct igc_adapter {struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_caps;struct work_struct ptp_tx_work; +/* Access to ptp_tx_skb and ptp_tx_start are protected by the +* ptp_tx_lock. +*/ +spinlock_t ptp_tx_lock;struct sk_buff *ptp_tx_skb;struct hwtstamp_config tstamp_config;unsigned long ptp_tx_start;
@@ -429,7 +433,6 @@ enum igc_state_t { __IGC_TESTING, __IGC_RESETTING, __IGC_DOWN, - __IGC_PTP_TX_IN_PROGRESS, }; enum igc_tx_flags {
drivers/net/ethernet/intel/igc/igc_main.c +6 -3
@@ -1590,9 +1590,10 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb,* the other timer registers before skipping the * timestamping request. */ -if (adapter->tstamp_config.tx_type ==HWTSTAMP_TX_ON && - !test_and_set_bit_lock (__IGC_PTP_TX_IN_PROGRESS, - &adapter->state)) { +unsigned long flags; + +spin_lock_irqsave (&adapter->ptp_tx_lock, flags); +if (adapter->tstamp_config.tx_type ==HWTSTAMP_TX_ON && !adapter->ptp_tx_skb) {skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; tx_flags |=IGC_TX_FLAGS_TSTAMP ;
@@ -1601,6 +1602,8 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, }else { adapter->tx_hwtstamp_skipped++; } + +spin_unlock_irqrestore (&adapter->ptp_tx_lock, flags); }if (skb_vlan_tag_present (skb)) {
drivers/net/ethernet/intel/igc/igc_ptp.c +31 -26
120 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 200/800 igc: Check if hardware TX timestamping is enabled earlier
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit ce58c7cc8b9910f2bc1d038d7ba60c3f011b2cb2 ]
Before requesting a packet transmission to be hardware timestamped, check if the user has TX timestamping enabled. Fixes an issue that if a packet was internally forwarded to the NIC, and it had the SKBTX_HW_TSTAMP flag set, the driver would mark that timestamp as skipped.
In reality, that timestamp was "not for us", as TX timestamp could never be enabled in the NIC.
Checking if the TX timestamping is enabled earlier has a secondary effect that when TX timestamping is disabled, there's no need to check for timestamp timeouts.
We should only take care to free any pending timestamp when TX timestamping is disabled, as that skb would never be released otherwise.
--- drivers/net/ethernet/intel/igc/igc.h | 1 + drivers/net/ethernet/intel/igc/igc_main.c | 5 +-- drivers/net/ethernet/intel/igc/igc_ptp.c | 42 +++++++++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +1 -0
@@ -609,6 +609,7 @@ enum igc_ring_flags_t {IGC_RING_FLAG_TX_CTX_IDX ,IGC_RING_FLAG_TX_DETECT_HANG ,IGC_RING_FLAG_AF_XDP_ZC , + IGC_RING_FLAG_TX_HWTSTAMP, };#define ring_uses_large_buffer (ring) \
drivers/net/ethernet/intel/igc/igc_main.c +3 -2
@@ -1585,7 +1585,8 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, } } -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP )) { +if (unlikely (test_bit (IGC_RING_FLAG_TX_HWTSTAMP , &tx_ring->flags) && +skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP )) {/* FIXME: add support for retrieving timestamps from * the other timer registers before skipping the * timestamping request.
@@ -1593,7 +1594,7 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb,unsigned long flags;spin_lock_irqsave (&adapter->ptp_tx_lock, flags); -if (adapter->tstamp_config.tx_type ==HWTSTAMP_TX_ON && !adapter->ptp_tx_skb) { +if (!adapter->ptp_tx_skb) {skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; tx_flags |=IGC_TX_FLAGS_TSTAMP ;
drivers/net/ethernet/intel/igc/igc_ptp.c +39 -3
69 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 201/800 igc: Retrieve TX timestamp during interrupt handling
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit afa141583d82725f682b2fa762cb36a07f58b3f3 ]
When the interrupt is handled, the TXTT_0 bit in the TSYNCTXCTL register should already be set and the timestamp value already loaded in the appropriate register.
This simplifies the handling, and reduces the latency for retrieving the TX timestamp, which increase the amount of TX timestamps that can be handled in a given time period.
As the "work" function doesn't run in a workqueue anymore, rename it to something more sensible, a event handler.
Using ntpperf[1] we can see the following performance improvements:
Before:
$ sudo ./ntpperf -i enp3s0 -m 10:22:22:22:22:21 -d 192.168.1.3 -s 172.18.0.0/16 -I -H -o -37
| responses | TX timestamp offset (ns)
rate clients | lost invalid basic xleave | min mean max stddev
1000 100 0.00% 0.00% 0.00% 100.00% -56 +9 +52 19
1500 150 0.00% 0.00% 0.00% 100.00% -40 +30 +75 22
2250 225 0.00% 0.00% 0.00% 100.00% -11 +29 +72 15
3375 337 0.00% 0.00% 0.00% 100.00% -18 +40 +88 22
5062 506 0.00% 0.00% 0.00% 100.00% -19 +23 +77 15
7593 759 0.00% 0.00% 0.00% 100.00% +7 +47 +5168 43
11389 1138 0.00% 0.00% 0.00% 100.00% -11 +41 +5240 39
17083 1708 0.00% 0.00% 0.00% 100.00% +19 +60 +5288 50
25624 2562 0.00% 0.00% 0.00% 100.00% +1 +56 +5368 58
38436 3843 0.00% 0.00% 0.00% 100.00% -84 +12 +8847 66
57654 5765 0.00% 0.00% 100.00% 0.00%
86481 8648 0.00% 0.00% 100.00% 0.00%
129721 12972 0.00% 0.00% 100.00% 0.00%
194581 16384 0.00% 0.00% 100.00% 0.00%
291871 16384 27.35% 0.00% 72.65% 0.00%
437806 16384 50.05% 0.00% 49.95% 0.00%After:
$ sudo ./ntpperf -i enp3s0 -m 10:22:22:22:22:21 -d 192.168.1.3 -s 172.18.0.0/16 -I -H -o -37
| responses | TX timestamp offset (ns)
rate clients | lost invalid basic xleave | min mean max stddev
1000 100 0.00% 0.00% 0.00% 100.00% -44 +0 +61 19
1500 150 0.00% 0.00% 0.00% 100.00% -6 +39 +81 16
2250 225 0.00% 0.00% 0.00% 100.00% -22 +25 +69 15
3375 337 0.00% 0.00% 0.00% 100.00% -28 +15 +56 14
5062 506 0.00% 0.00% 0.00% 100.00% +7 +78 +143 27
7593 759 0.00% 0.00% 0.00% 100.00% -54 +24 +144 47
11389 1138 0.00% 0.00% 0.00% 100.00% -90 -33 +28 21
17083 1708 0.00% 0.00% 0.00% 100.00% -50 -2 +35 14
25624 2562 0.00% 0.00% 0.00% 100.00% -62 +7 +66 23
38436 3843 0.00% 0.00% 0.00% 100.00% -33 +30 +5395 36
57654 5765 0.00% 0.00% 100.00% 0.00%
86481 8648 0.00% 0.00% 100.00% 0.00%
129721 12972 0.00% 0.00% 100.00% 0.00%
194581 16384 19.50% 0.00% 80.50% 0.00%
291871 16384 35.81% 0.00% 64.19% 0.00%
437806 16384 55.40% 0.00% 44.60% 0.00%[1] https://github.com/mlichvar/ntpperf
Stable-dep-of: c789ad7cbebc ("igc: Work around HW bug causing missing timestamps")
--- drivers/net/ethernet/intel/igc/igc.h | 2 +- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- drivers/net/ethernet/intel/igc/igc_ptp.c | 15 +++++---------- 3 files changed, 7 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +1 -1
@@ -229,7 +229,6 @@ struct igc_adapter {struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_caps; -struct work_struct ptp_tx_work;/* Access to ptp_tx_skb and ptp_tx_start are protected by the * ptp_tx_lock. */
@@ -666,6 +665,7 @@ int igc_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);int igc_ptp_get_ts_config (struct net_device *netdev,struct ifreq *ifr);void igc_ptp_tx_hang (struct igc_adapter *adapter);void igc_ptp_read (struct igc_adapter *adapter,struct timespec64 *ts); +void igc_ptp_tx_tstamp_event (struct igc_adapter *adapter);#define igc_rx_pg_size (_ring) (PAGE_SIZE << igc_rx_pg_order(_ring))
drivers/net/ethernet/intel/igc/igc_main.c +1 -1
@@ -5245,7 +5245,7 @@ static void igc_tsync_interrupt(struct igc_adapter *adapter)if (tsicr &IGC_TSICR_TXTS ) {/* retrieve hardware timestamp */ -schedule_work (&adapter->ptp_tx_work); +igc_ptp_tx_tstamp_event (adapter); ack |=IGC_TSICR_TXTS ; }
drivers/net/ethernet/intel/igc/igc_ptp.c +5 -10
@@ -540,8 +540,6 @@ static void igc_ptp_clear_tx_tstamp(struct igc_adapter *adapter) {unsigned long flags; -cancel_work_sync (&adapter->ptp_tx_work); -spin_lock_irqsave (&adapter->ptp_tx_lock, flags);dev_kfree_skb_any (adapter->ptp_tx_skb);
@@ -724,16 +722,14 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) }/** -* igc_ptp_tx_work -* @work: pointer to work struct +* igc_ptp_tx_tstamp_event +* @adapter: board private structure * -* This work function checks the TSYNCTXCTL valid bit to determine when -* a timestamp has been taken for the current stored skb. +* Called when a TX timestamp interrupt happens to retrieve the +* timestamp and send it up to the socket. */ -static void igc_ptp_tx_work (struct work_struct *work) +void igc_ptp_tx_tstamp_event (struct igc_adapter *adapter) { - struct igc_adapter *adapter = container_of(work, struct igc_adapter, - ptp_tx_work);struct igc_hw *hw = &adapter->hw;unsigned long flags;u32 tsynctxctl;
@@ -1004,7 +1000,6 @@ void igc_ptp_init(struct igc_adapter *adapter)spin_lock_init (&adapter->ptp_tx_lock);spin_lock_init (&adapter->tmreg_lock); -INIT_WORK (&adapter->ptp_tx_work, igc_ptp_tx_work); adapter->tstamp_config.rx_filter =HWTSTAMP_FILTER_NONE ; adapter->tstamp_config.tx_type =HWTSTAMP_TX_OFF ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 202/800 igc: Work around HW bug causing missing timestamps
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit c789ad7cbebcac5d5f417296c140a1252c689524 ]
There's an hardware issue that can cause missing timestamps. The bug is that the interrupt is only cleared if the IGC_TXSTMPH_0 register is read.
The bug can cause a race condition if a timestamp is captured at the wrong time, and we will miss that timestamp. To reduce the time window that the problem is able to happen, in case no timestamp was ready, we read the "previous" value of the timestamp registers, and we compare with the "current" one, if it didn't change we can be reasonably sure that no timestamp was captured. If they are different, we use the new value as the captured timestamp.
The HW bug is not easy to reproduce, got to reproduce it when smashing the NIC with timestamping requests from multiple applications (e.g. multiple ntpperf instances + ptp4l), after 10s of minutes.
This workaround has more impact when multiple timestamp registers are used, and the IGC_TXSTMPH_0 register always need to be read, so the interrupt is cleared.
--- drivers/net/ethernet/intel/igc/igc_ptp.c | 48 ++++++++++++++++++------ 1 file changed, 37 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/igc/igc_ptp.c +37 -11
@@ -685,14 +685,49 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)struct sk_buff *skb = adapter->ptp_tx_skb;struct skb_shared_hwtstamps shhwtstamps;struct igc_hw *hw = &adapter->hw; +u32 tsynctxctl;int adjust =0 ;u64 regval;if (WARN_ON_ONCE (!skb))return ; - regval =rd32 (IGC_TXSTMPL ); - regval |= (u64 )rd32 (IGC_TXSTMPH ) <<32 ; + tsynctxctl =rd32 (IGC_TSYNCTXCTL ); + tsynctxctl &=IGC_TSYNCTXCTL_TXTT_0 ; +if (tsynctxctl) { + regval =rd32 (IGC_TXSTMPL ); + regval |= (u64 )rd32 (IGC_TXSTMPH ) <<32 ; + }else { +/* There's a bug in the hardware that could cause +* missing interrupts for TX timestamping. The issue +* is that for new interrupts to be triggered, the +* IGC_TXSTMPH_0 register must be read. +* +* To avoid discarding a valid timestamp that just +* happened at the "wrong" time, we need to confirm +* that there was no timestamp captured, we do that by +* assuming that no two timestamps in sequence have +* the same nanosecond value. +* +* So, we read the "low" register, read the "high" +* register (to latch a new timestamp) and read the +* "low" register again, if "old" and "new" versions +* of the "low" register are different, a valid +* timestamp was captured, we can read the "high" +* register again. +*/ +u32 txstmpl_old, txstmpl_new; + + txstmpl_old =rd32 (IGC_TXSTMPL ); +rd32 (IGC_TXSTMPH ); + txstmpl_new =rd32 (IGC_TXSTMPL ); + +if (txstmpl_old == txstmpl_new) +return ; + + regval = txstmpl_new; + regval |= (u64 )rd32 (IGC_TXSTMPH ) <<32 ; + }if (igc_ptp_systim_to_hwtstamp (adapter, &shhwtstamps, regval))return ;
@@ -730,22 +765,13 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)*/ void igc_ptp_tx_tstamp_event (struct igc_adapter *adapter) { -struct igc_hw *hw = &adapter->hw;unsigned long flags; -u32 tsynctxctl;spin_lock_irqsave (&adapter->ptp_tx_lock, flags);if (!adapter->ptp_tx_skb) goto unlock; - tsynctxctl =rd32 (IGC_TSYNCTXCTL ); - tsynctxctl &=IGC_TSYNCTXCTL_TXTT_0 ; -if (!tsynctxctl) { -WARN_ONCE (1 ,"Received a TSTAMP interrupt but no TSTAMP is ready.\n" ); - goto unlock; - } -igc_ptp_tx_hwtstamp (adapter); unlock:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 203/800 net: stmmac: fix double serdes powerdown
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit c4fc88ad2a765224a648db8ab35f125e120fe41b ]
Commit 49725ffc15fc ("net: stmmac: power up/down serdes in stmmac_open/release") correctly added a call to the serdes_powerdown() callback to stmmac_release() but did not remove the one from stmmac_remove() which leads to a doubled call to serdes_powerdown().
This can lead to all kinds of problems: in the case of the qcom ethqos driver, it caused an unbalanced regulator disable splat.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -6
@@ -7457,12 +7457,6 @@ void stmmac_dvr_remove(struct device *dev)netif_carrier_off (ndev);unregister_netdev (ndev); -/* Serdes power down needs to happen after VLAN filter -* is deleted that is triggered by unregister_netdev(). -*/ -if (priv->plat->serdes_powerdown) - priv->plat->serdes_powerdown (ndev, priv->plat->bsp_priv); -#ifdef CONFIG_DEBUG_FS stmmac_exit_fs (ndev);#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 177/800 wifi: mac80211: Remove "Missing iftype sband data/EHT cap" spam
In reply to Greg Kroah-HartmanFrom: Nicolas Cavallari <[email protected]>
[ Upstream commit 6e21e7b8cd897193cee3c2649640efceb3004ba5 ]
In mesh mode, ieee80211_chandef_he_6ghz_oper() is called by mesh_matches_local() for every received mesh beacon.
On a 6 GHz mesh of a HE-only phy, this spams that the hardware does not have EHT capabilities, even if the received mesh beacon does not have an EHT element.
Unlike HE, not supporting EHT in the 6 GHz band is not an error so do not print anything in this case.
--- net/mac80211/util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/mac80211/util.c +1 -3
@@ -3798,10 +3798,8 @@ bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_sub_if_data *sdata, } eht_cap =ieee80211_get_eht_iftype_cap (sband, iftype); -if (!eht_cap) { -sdata_info (sdata,"Missing iftype sband data/EHT cap" ); +if (!eht_cap) eht_oper =NULL ; - } he_6ghz_oper =ieee80211_he_6ghz_oper (he_oper);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 204/800 netlink: fix potential deadlock in netlink_set_err()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 8d61f926d42045961e6b65191c09e3678d86a9cf ]
syzbot reported a possible deadlock in netlink_set_err() [1]
A similar issue was fixed in commit 1d482e666b8e ("netlink: disable IRQs for netlink_lock_table()") in netlink_lock_table()
This patch adds IRQ safety to netlink_set_err() and __netlink_diag_dump() which were not covered by cited commit.
[1]
WARNING: possible irq lock inversion dependency detected 6.4.0-rc6-syzkaller-00240-g4e9f0ec38852 #0 Not tainted
syz-executor.2/23011 just changed the state of lock:ffffffff8e1a7a58 (nl_table_lock){.+.?}-{2:2}, at: netlink_set_err+0x2e/0x3a0 net/netlink/af_netlink.c:1612 but this lock was taken by another, SOFTIRQ-safe lock in the past:
(&local->queue_stop_reason_lock){..-.}-{2:2}
and interrupts could create inverse lock ordering between them.
other info that might help us debug this:
Possible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(nl_table_lock);
local_irq_disable();
lock(&local->queue_stop_reason_lock);
lock(nl_table_lock);
<Interrupt>
lock(&local->queue_stop_reason_lock);*** DEADLOCK ***
--- net/netlink/af_netlink.c | 5 +++-- net/netlink/diag.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
net/netlink/af_netlink.c +3 -2
@@ -1600,6 +1600,7 @@ static int do_one_set_err(struct sock *sk, struct netlink_set_err_data *p)int netlink_set_err (struct sock *ssk,u32 portid,u32 group,int code) {struct netlink_set_err_data info; +unsigned long flags;struct sock *sk;int ret =0 ;
@@ -1609,12 +1610,12 @@ int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code)/* sk->sk_err wants a positive error value */ info.code = -code; -read_lock (&nl_table_lock); +read_lock_irqsave (&nl_table_lock, flags);sk_for_each_bound (sk, &nl_table[ssk->sk_protocol].mc_list) ret +=do_one_set_err (sk, &info); -read_unlock (&nl_table_lock); +read_unlock_irqrestore (&nl_table_lock, flags);return ret; }EXPORT_SYMBOL (netlink_set_err);
net/netlink/diag.c +3 -2
@@ -94,6 +94,7 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,struct net *net =sock_net (skb->sk);struct netlink_diag_req *req;struct netlink_sock *nlsk; +unsigned long flags;struct sock *sk;int num =2 ;int ret =0 ;
@@ -152,7 +153,7 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, num++; mc_list: -read_lock (&nl_table_lock); +read_lock_irqsave (&nl_table_lock, flags);sk_for_each_bound (sk, &tbl->mc_list) {if (sk_hashed (sk))continue ;
@@ -173,7 +174,7 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, } num++; } -read_unlock (&nl_table_lock); +read_unlock_irqrestore (&nl_table_lock, flags); done: cb->args[0 ] = num;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 205/800 netlink: do not hard code device address lenth in fdb dumps
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit aa5406950726e336c5c9585b09799a734b6e77bf ]
syzbot reports that some netdev devices do not have a six bytes address [1]
Replace ETH_ALEN by dev->addr_len.
[1] (Case of a device where dev->addr_len = 4)
BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline] BUG: KMSAN: kernel-infoleak in copyout+0xb8/0x100 lib/iov_iter.c:169 instrument_copy_to_user include/linux/instrumented.h:114 [inline] copyout+0xb8/0x100 lib/iov_iter.c:169 _copy_to_iter+0x6d8/0x1d00 lib/iov_iter.c:536 copy_to_iter include/linux/uio.h:206 [inline] simple_copy_to_iter+0x68/0xa0 net/core/datagram.c:513 __skb_datagram_iter+0x123/0xdc0 net/core/datagram.c:419 skb_copy_datagram_iter+0x5c/0x200 net/core/datagram.c:527 skb_copy_datagram_msg include/linux/skbuff.h:3960 [inline] netlink_recvmsg+0x4ae/0x15a0 net/netlink/af_netlink.c:1970 sock_recvmsg_nosec net/socket.c:1019 [inline] sock_recvmsg net/socket.c:1040 [inline] ____sys_recvmsg+0x283/0x7f0 net/socket.c:2722 ___sys_recvmsg+0x223/0x840 net/socket.c:2764 do_recvmmsg+0x4f9/0xfd0 net/socket.c:2858 __sys_recvmmsg net/socket.c:2937 [inline] __do_sys_recvmmsg net/socket.c:2960 [inline] __se_sys_recvmmsg net/socket.c:2953 [inline] __x64_sys_recvmmsg+0x397/0x490 net/socket.c:2953 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
Uninit was stored to memory at:
__nla_put lib/nlattr.c:1009 [inline] nla_put+0x1c6/0x230 lib/nlattr.c:1067 nlmsg_populate_fdb_fill+0x2b8/0x600 net/core/rtnetlink.c:4071 nlmsg_populate_fdb net/core/rtnetlink.c:4418 [inline] ndo_dflt_fdb_dump+0x616/0x840 net/core/rtnetlink.c:4456 rtnl_fdb_dump+0x14ff/0x1fc0 net/core/rtnetlink.c:4629 netlink_dump+0x9d1/0x1310 net/netlink/af_netlink.c:2268 netlink_recvmsg+0xc5c/0x15a0 net/netlink/af_netlink.c:1995 sock_recvmsg_nosec+0x7a/0x120 net/socket.c:1019 ____sys_recvmsg+0x664/0x7f0 net/socket.c:2720 ___sys_recvmsg+0x223/0x840 net/socket.c:2764 do_recvmmsg+0x4f9/0xfd0 net/socket.c:2858 __sys_recvmmsg net/socket.c:2937 [inline] __do_sys_recvmmsg net/socket.c:2960 [inline] __se_sys_recvmmsg net/socket.c:2953 [inline] __x64_sys_recvmmsg+0x397/0x490 net/socket.c:2953 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
Uninit was created at:
slab_post_alloc_hook+0x12d/0xb60 mm/slab.h:716 slab_alloc_node mm/slub.c:3451 [inline] __kmem_cache_alloc_node+0x4ff/0x8b0 mm/slub.c:3490 kmalloc_trace+0x51/0x200 mm/slab_common.c:1057 kmalloc include/linux/slab.h:559 [inline] __hw_addr_create net/core/dev_addr_lists.c:60 [inline] __hw_addr_add_ex+0x2e5/0x9e0 net/core/dev_addr_lists.c:118 __dev_mc_add net/core/dev_addr_lists.c:867 [inline] dev_mc_add+0x9a/0x130 net/core/dev_addr_lists.c:885 igmp6_group_added+0x267/0xbc0 net/ipv6/mcast.c:680 ipv6_mc_up+0x296/0x3b0 net/ipv6/mcast.c:2754 ipv6_mc_remap+0x1e/0x30 net/ipv6/mcast.c:2708 addrconf_type_change net/ipv6/addrconf.c:3731 [inline] addrconf_notify+0x4d3/0x1d90 net/ipv6/addrconf.c:3699 notifier_call_chain kernel/notifier.c:93 [inline] raw_notifier_call_chain+0xe4/0x430 kernel/notifier.c:461 call_netdevice_notifiers_info net/core/dev.c:1935 [inline] call_netdevice_notifiers_extack net/core/dev.c:1973 [inline] call_netdevice_notifiers+0x1ee/0x2d0 net/core/dev.c:1987 bond_enslave+0xccd/0x53f0 drivers/net/bonding/bond_main.c:1906 do_set_master net/core/rtnetlink.c:2626 [inline] rtnl_newlink_create net/core/rtnetlink.c:3460 [inline] __rtnl_newlink net/core/rtnetlink.c:3660 [inline] rtnl_newlink+0x378c/0x40e0 net/core/rtnetlink.c:3673 rtnetlink_rcv_msg+0x16a6/0x1840 net/core/rtnetlink.c:6395 netlink_rcv_skb+0x371/0x650 net/netlink/af_netlink.c:2546 rtnetlink_rcv+0x34/0x40 net/core/rtnetlink.c:6413 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] netlink_unicast+0xf28/0x1230 net/netlink/af_netlink.c:1365 netlink_sendmsg+0x122f/0x13d0 net/netlink/af_netlink.c:1913 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg net/socket.c:747 [inline] ____sys_sendmsg+0x999/0xd50 net/socket.c:2503 ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2557 __sys_sendmsg net/socket.c:2586 [inline] __do_sys_sendmsg net/socket.c:2595 [inline] __se_sys_sendmsg net/socket.c:2593 [inline] __x64_sys_sendmsg+0x304/0x490 net/socket.c:2593 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
Bytes 2856-2857 of 3500 are uninitialized Memory access of size 3500 starts at ffff888018d99104 Data copied to user address 0000000020000480
--- net/core/rtnetlink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/core/rtnetlink.c +4 -4
@@ -4096,7 +4096,7 @@ static int nlmsg_populate_fdb_fill(struct sk_buff *skb, ndm->ndm_ifindex = dev->ifindex; ndm->ndm_state = ndm_state; -if (nla_put (skb,NDA_LLADDR ,ETH_ALEN , addr)) +if (nla_put (skb,NDA_LLADDR , dev->addr_len, addr)) goto nla_put_failure;if (vid)if (nla_put (skb,NDA_VLAN ,sizeof (u16), &vid))
@@ -4110,10 +4110,10 @@ static int nlmsg_populate_fdb_fill(struct sk_buff *skb,return -EMSGSIZE ; } -static inline size_t rtnl_fdb_nlmsg_size (void ) +static inline size_t rtnl_fdb_nlmsg_size (const struct net_device *dev) {return NLMSG_ALIGN (sizeof (struct ndmsg )) + -nla_total_size (ETH_ALEN ) +/* NDA_LLADDR */ +nla_total_size (dev->addr_len) +/* NDA_LLADDR */ nla_total_size (sizeof (u16)) +/* NDA_VLAN */ 0 ; }
@@ -4125,7 +4125,7 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type,struct sk_buff *skb;int err = -ENOBUFS ; - skb =nlmsg_new (rtnl_fdb_nlmsg_size (),GFP_ATOMIC ); + skb =nlmsg_new (rtnl_fdb_nlmsg_size (dev),GFP_ATOMIC );if (!skb) goto errout;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 178/800 wifi: cfg80211: rewrite merging of inherited elements
In reply to Greg Kroah-HartmanFrom: Benjamin Berg <[email protected]>
[ Upstream commit dfd9aa3e7a456d57b18021d66472ab7ff8373ab7 ]
The cfg80211_gen_new_ie function merges the IEs using inheritance rules. Rewrite this function to fix issues around inheritance rules. In particular, vendor elements do not require any special handling, as they are either all inherited or overridden by the subprofile. Also, add fragmentation handling as this may be needed in some cases.
This also changes the function to not require making a copy. The new version could be optimized a bit by explicitly tracking which IEs have been handled already rather than looking that up again every time.
Note that a small behavioural change is the removal of the SSID special handling. This should be fine for the MBSSID element, as the SSID must be included in the subelement.
--- net/wireless/scan.c | 213 ++++++++++++++++++++++++++------------------ 1 file changed, 124 insertions(+), 89 deletions(-)
net/wireless/scan.c +124 -89
@@ -259,117 +259,152 @@ bool cfg80211_is_element_inherited(const struct element *elem, }EXPORT_SYMBOL (cfg80211_is_element_inherited); -static size_t cfg80211_gen_new_ie (const u8 *ie,size_t ielen, -const u8 *subelement,size_t subie_len, -u8 *new_ie,gfp_t gfp) +static size_t cfg80211_copy_elem_with_frags (const struct element *elem, +const u8 *ie,size_t ie_len, +u8 **pos,u8 *buf,size_t buf_len) { -u8 *pos, *tmp; -const u8 *tmp_old, *tmp_new; -const struct element *non_inherit_elem; -u8 *sub_copy; +if (WARN_ON ((u8 *)elem < ie || elem->data > ie + ie_len || + elem->data + elem->datalen > ie + ie_len)) +return 0 ; -/* copy subelement as we need to change its content to -* mark an ie after it is processed. -*/ - sub_copy =kmemdup (subelement, subie_len, gfp); -if (!sub_copy) +if (elem->datalen +2 > buf + buf_len - *pos)return 0 ; - pos = &new_ie[0 ]; +memcpy (*pos, elem, elem->datalen +2 ); + *pos += elem->datalen +2 ; -/* set new ssid */ - tmp_new =cfg80211_find_ie (WLAN_EID_SSID , sub_copy, subie_len); -if (tmp_new) { -memcpy (pos, tmp_new, tmp_new[1 ] +2 ); - pos += (tmp_new[1 ] +2 ); +/* Finish if it is not fragmented */ +if (elem->datalen !=255 ) +return *pos - buf; + + ie_len = ie + ie_len - elem->data - elem->datalen; + ie = (const u8 *)elem->data + elem->datalen; + +for_each_element (elem, ie, ie_len) { +if (elem->id !=WLAN_EID_FRAGMENT ) +break ; + +if (elem->datalen +2 > buf + buf_len - *pos) +return 0 ; + +memcpy (*pos, elem, elem->datalen +2 ); + *pos += elem->datalen +2 ; + +if (elem->datalen !=255 ) +break ; } -/* get non inheritance list if exists */ - non_inherit_elem = -cfg80211_find_ext_elem (WLAN_EID_EXT_NON_INHERITANCE , - sub_copy, subie_len); +return *pos - buf; +} -/* go through IEs in ie (skip SSID) and subelement, -* merge them into new_ie +static size_t cfg80211_gen_new_ie (const u8 *ie,size_t ielen, +const u8 *subie,size_t subie_len, +u8 *new_ie,size_t new_ie_len) +{ +const struct element *non_inherit_elem, *parent, *sub; +u8 *pos = new_ie; +u8 id, ext_id; +unsigned int match_len; + + non_inherit_elem =cfg80211_find_ext_elem (WLAN_EID_EXT_NON_INHERITANCE , + subie, subie_len); + +/* We copy the elements one by one from the parent to the generated +* elements. +* If they are not inherited (included in subie or in the non +* inheritance element), then we copy all occurrences the first time +* we see this element type. */ - tmp_old =cfg80211_find_ie (WLAN_EID_SSID , ie, ielen); - tmp_old = (tmp_old) ? tmp_old + tmp_old[1 ] +2 : ie; - -while (tmp_old +2 - ie <= ielen && - tmp_old + tmp_old[1 ] +2 - ie <= ielen) { -if (tmp_old[0 ] ==0 ) { - tmp_old++; +for_each_element (parent, ie, ielen) { +if (parent->id ==WLAN_EID_FRAGMENT )continue ; + +if (parent->id ==WLAN_EID_EXTENSION ) { +if (parent->datalen <1 ) +continue ; + + id =WLAN_EID_EXTENSION ; + ext_id = parent->data[0 ]; + match_len =1 ; + }else { + id = parent->id; + match_len =0 ; } -if (tmp_old[0 ] ==WLAN_EID_EXTENSION ) - tmp = (u8 *)cfg80211_find_ext_ie (tmp_old[2 ], sub_copy, - subie_len); -else - tmp = (u8 *)cfg80211_find_ie (tmp_old[0 ], sub_copy, - subie_len); +/* Find first occurrence in subie */ + sub =cfg80211_find_elem_match (id, subie, subie_len, + &ext_id, match_len,0 ); -if (!tmp) { -const struct element *old_elem = (void *)tmp_old; +/* Copy from parent if not in subie and inherited */ +if (!sub && +cfg80211_is_element_inherited (parent, non_inherit_elem)) { +if (!cfg80211_copy_elem_with_frags (parent, + ie, ielen, + &pos, new_ie, + new_ie_len)) +return 0 ; -/* ie in old ie but not in subelement */ -if (cfg80211_is_element_inherited (old_elem, - non_inherit_elem)) { -memcpy (pos, tmp_old, tmp_old[1 ] +2 ); - pos += tmp_old[1 ] +2 ; - } - }else { -/* ie in transmitting ie also in subelement, -* copy from subelement and flag the ie in subelement -* as copied (by setting eid field to WLAN_EID_SSID, -* which is skipped anyway). -* For vendor ie, compare OUI + type + subType to -* determine if they are the same ie. -*/ -if (tmp_old[0 ] ==WLAN_EID_VENDOR_SPECIFIC ) { -if (tmp_old[1 ] >=5 && tmp[1 ] >=5 && - !memcmp (tmp_old +2 , tmp +2 ,5 )) { -/* same vendor ie, copy from -* subelement -*/ -memcpy (pos, tmp, tmp[1 ] +2 ); - pos += tmp[1 ] +2 ; - tmp[0 ] =WLAN_EID_SSID ; - }else { -memcpy (pos, tmp_old, tmp_old[1 ] +2 ); - pos += tmp_old[1 ] +2 ; - } - }else { -/* copy ie from subelement into new ie */ -memcpy (pos, tmp, tmp[1 ] +2 ); - pos += tmp[1 ] +2 ; - tmp[0 ] =WLAN_EID_SSID ; - } +continue ; } -if (tmp_old + tmp_old[1 ] +2 - ie == ielen) -break ; +/* Already copied if an earlier element had the same type */ +if (cfg80211_find_elem_match (id, ie, (u8 *)parent - ie, + &ext_id, match_len,0 )) +continue ; - tmp_old += tmp_old[1 ] +2 ; +/* Not inheriting, copy all similar elements from subie */ +while (sub) { +if (!cfg80211_copy_elem_with_frags (sub, + subie, subie_len, + &pos, new_ie, + new_ie_len)) +return 0 ; + + sub =cfg80211_find_elem_match (id, + sub->data + sub->datalen, + subie_len + subie - + (sub->data + + sub->datalen), + &ext_id, match_len,0 ); + } } -/* go through subelement again to check if there is any ie not -* copied to new ie, skip ssid, capability, bssid-index ie +/* The above misses elements that are included in subie but not in the +* parent, so do a pass over subie and append those. +* Skip the non-tx BSSID caps and non-inheritance element. */ - tmp_new = sub_copy; -while (tmp_new +2 - sub_copy <= subie_len && - tmp_new + tmp_new[1 ] +2 - sub_copy <= subie_len) { -if (!(tmp_new[0 ] ==WLAN_EID_NON_TX_BSSID_CAP || - tmp_new[0 ] ==WLAN_EID_SSID )) { -memcpy (pos, tmp_new, tmp_new[1 ] +2 ); - pos += tmp_new[1 ] +2 ; +for_each_element (sub, subie, subie_len) { +if (sub->id ==WLAN_EID_NON_TX_BSSID_CAP ) +continue ; + +if (sub->id ==WLAN_EID_FRAGMENT ) +continue ; + +if (sub->id ==WLAN_EID_EXTENSION ) { +if (sub->datalen <1 ) +continue ; + + id =WLAN_EID_EXTENSION ; + ext_id = sub->data[0 ]; + match_len =1 ; + +if (ext_id ==WLAN_EID_EXT_NON_INHERITANCE ) +continue ; + }else { + id = sub->id; + match_len =0 ; } -if (tmp_new + tmp_new[1 ] +2 - sub_copy == subie_len) -break ; - tmp_new += tmp_new[1 ] +2 ; + +/* Processed if one was included in the parent */ +if (cfg80211_find_elem_match (id, ie, ielen, + &ext_id, match_len,0 )) +continue ; + +if (!cfg80211_copy_elem_with_frags (sub, subie, subie_len, + &pos, new_ie, new_ie_len)) +return 0 ; } -kfree (sub_copy);return pos - new_ie; }
@@ -2212,7 +2247,7 @@ static void cfg80211_parse_mbssid_data(struct wiphy *wiphy, new_ie_len =cfg80211_gen_new_ie (ie, ielen, profile, profile_len, new_ie, - gfp); +IEEE80211_MAX_DATA_LEN );if (!new_ie_len)continue ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 179/800 wifi: cfg80211: drop incorrect nontransmitted BSS update code
In reply to Greg Kroah-HartmanFrom: Benjamin Berg <[email protected]>
[ Upstream commit 39432f8a3752a87a53fd8d5e51824a43aaae5cab ]
The removed code ran for any BSS that was not included in the MBSSID element in order to update it. However, instead of using the correct inheritance rules, it would simply copy the elements from the transmitting AP. The result is that we would report incorrect elements in this case.
After some discussions, it seems that there are likely not even APs actually using this feature. Either way, removing the code decreases complexity and makes the cfg80211 behaviour more correct.
--- net/wireless/scan.c | 154 ++++---------------------------------------- 1 file changed, 11 insertions(+), 143 deletions(-)
net/wireless/scan.c +11 -143
@@ -2296,118 +2296,6 @@ cfg80211_inform_bss_data(struct wiphy *wiphy, }EXPORT_SYMBOL (cfg80211_inform_bss_data); -static void -cfg80211_parse_mbssid_frame_data (struct wiphy *wiphy, -struct cfg80211_inform_bss *data, -struct ieee80211_mgmt *mgmt,size_t len, -struct cfg80211_non_tx_bss *non_tx_data, -gfp_t gfp) -{ -enum cfg80211_bss_frame_type ftype; -const u8 *ie = mgmt->u.probe_resp.variable; -size_t ielen = len - offsetof(struct ieee80211_mgmt , - u.probe_resp.variable); - - ftype =ieee80211_is_beacon (mgmt->frame_control) ? -CFG80211_BSS_FTYPE_BEACON :CFG80211_BSS_FTYPE_PRESP ; - -cfg80211_parse_mbssid_data (wiphy, data, ftype, mgmt->bssid, -le64_to_cpu (mgmt->u.probe_resp.timestamp), -le16_to_cpu (mgmt->u.probe_resp.beacon_int), - ie, ielen, non_tx_data, gfp); -} - -static void -cfg80211_update_notlisted_nontrans (struct wiphy *wiphy, -struct cfg80211_bss *nontrans_bss, -struct ieee80211_mgmt *mgmt,size_t len) -{ -u8 *ie, *new_ie, *pos; -const struct element *nontrans_ssid; -const u8 *trans_ssid, *mbssid; -size_t ielen = len - offsetof(struct ieee80211_mgmt , - u.probe_resp.variable); -size_t new_ie_len; -struct cfg80211_bss_ies *new_ies; -const struct cfg80211_bss_ies *old; -size_t cpy_len; - -lockdep_assert_held (&wiphy_to_rdev (wiphy)->bss_lock); - - ie = mgmt->u.probe_resp.variable; - - new_ie_len = ielen; - trans_ssid =cfg80211_find_ie (WLAN_EID_SSID , ie, ielen); -if (!trans_ssid) -return ; - new_ie_len -= trans_ssid[1 ]; - mbssid =cfg80211_find_ie (WLAN_EID_MULTIPLE_BSSID , ie, ielen); -/* -* It's not valid to have the MBSSID element before SSID -* ignore if that happens - the code below assumes it is -* after (while copying things inbetween). -*/ -if (!mbssid || mbssid < trans_ssid) -return ; - new_ie_len -= mbssid[1 ]; - - nontrans_ssid =ieee80211_bss_get_elem (nontrans_bss,WLAN_EID_SSID ); -if (!nontrans_ssid) -return ; - - new_ie_len += nontrans_ssid->datalen; - -/* generate new ie for nontrans BSS -* 1. replace SSID with nontrans BSS' SSID -* 2. skip MBSSID IE -*/ - new_ie =kzalloc (new_ie_len,GFP_ATOMIC ); -if (!new_ie) -return ; - - new_ies =kzalloc (sizeof (*new_ies) + new_ie_len,GFP_ATOMIC ); -if (!new_ies) - goto out_free; - - pos = new_ie; - -/* copy the nontransmitted SSID */ - cpy_len = nontrans_ssid->datalen +2 ; -memcpy (pos, nontrans_ssid, cpy_len); - pos += cpy_len; -/* copy the IEs between SSID and MBSSID */ - cpy_len = trans_ssid[1 ] +2 ; -memcpy (pos, (trans_ssid + cpy_len), (mbssid - (trans_ssid + cpy_len))); - pos += (mbssid - (trans_ssid + cpy_len)); -/* copy the IEs after MBSSID */ - cpy_len = mbssid[1 ] +2 ; -memcpy (pos, mbssid + cpy_len, ((ie + ielen) - (mbssid + cpy_len))); - -/* update ie */ - new_ies->len = new_ie_len; - new_ies->tsf =le64_to_cpu (mgmt->u.probe_resp.timestamp); - new_ies->from_beacon =ieee80211_is_beacon (mgmt->frame_control); -memcpy (new_ies->data, new_ie, new_ie_len); -if (ieee80211_is_probe_resp (mgmt->frame_control)) { - old =rcu_access_pointer (nontrans_bss->proberesp_ies); -rcu_assign_pointer (nontrans_bss->proberesp_ies, new_ies); -rcu_assign_pointer (nontrans_bss->ies, new_ies); -if (old) -kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); - }else { - old =rcu_access_pointer (nontrans_bss->beacon_ies); -rcu_assign_pointer (nontrans_bss->beacon_ies, new_ies); -cfg80211_update_hidden_bsses (bss_from_pub (nontrans_bss), - new_ies, old); -rcu_assign_pointer (nontrans_bss->ies, new_ies); -if (old) -kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); - } - -out_free: -kfree (new_ie); -} -/* cfg80211_inform_bss_width_frame helper */ static struct cfg80211_bss * cfg80211_inform_single_bss_frame_data(struct wiphy *wiphy,
@@ -2540,51 +2428,31 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy, struct ieee80211_mgmt *mgmt, size_t len, gfp_t gfp) { - struct cfg80211_bss *res, *tmp_bss; + struct cfg80211_bss *res;const u8 *ie = mgmt->u.probe_resp.variable; -const struct cfg80211_bss_ies *ies1, *ies2;size_t ielen = len - offsetof(struct ieee80211_mgmt , u.probe_resp.variable); +enum cfg80211_bss_frame_type ftype;struct cfg80211_non_tx_bss non_tx_data = {}; res =cfg80211_inform_single_bss_frame_data (wiphy, data, mgmt, len, gfp); +if (!res) +return NULL ;/* don't do any further MBSSID handling for S1G */ if (ieee80211_is_s1g_beacon (mgmt->frame_control))return res; -if (!res || !wiphy->support_mbssid || - !cfg80211_find_elem (WLAN_EID_MULTIPLE_BSSID , ie, ielen)) -return res; -if (wiphy->support_only_he_mbssid && - !cfg80211_find_ext_elem (WLAN_EID_EXT_HE_CAPABILITY , ie, ielen)) -return res; - + ftype =ieee80211_is_beacon (mgmt->frame_control) ? +CFG80211_BSS_FTYPE_BEACON :CFG80211_BSS_FTYPE_PRESP ; non_tx_data.tx_bss = res; -/* process each non-transmitting bss */ -cfg80211_parse_mbssid_frame_data (wiphy, data, mgmt, len, - &non_tx_data, gfp); - -spin_lock_bh (&wiphy_to_rdev (wiphy)->bss_lock); -/* check if the res has other nontransmitting bss which is not -* in MBSSID IE -*/ - ies1 =rcu_access_pointer (res->ies); - -/* go through nontrans_list, if the timestamp of the BSS is -* earlier than the timestamp of the transmitting BSS then -* update it -*/ -list_for_each_entry (tmp_bss, &res->nontrans_list, - nontrans_list) { - ies2 =rcu_access_pointer (tmp_bss->ies); -if (ies2->tsf < ies1->tsf) -cfg80211_update_notlisted_nontrans (wiphy, tmp_bss, - mgmt, len); - } -spin_unlock_bh (&wiphy_to_rdev (wiphy)->bss_lock); +/* process each non-transmitting bss */ +cfg80211_parse_mbssid_data (wiphy, data, ftype, mgmt->bssid, +le64_to_cpu (mgmt->u.probe_resp.timestamp), +le16_to_cpu (mgmt->u.probe_resp.beacon_int), + ie, ielen, &non_tx_data, gfp);return res; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 180/800 wifi: cfg80211: fix regulatory disconnect with OCB/NAN
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit e8c2af660ba0790afd14d5cbc2fd05c6dc85e207 ]
Since regulatory disconnect was added, OCB and NAN interface types were added, which made it completely unusable for any driver that allowed OCB/NAN. Add OCB/NAN (though NAN doesn't do anything, we don't have any info) and also remove all the logic that opts out, so it won't be broken again if/when new interface types are added.
--- include/net/regulatory.h | 13 +------------ net/wireless/core.c | 16 ---------------- net/wireless/reg.c | 14 ++++++++++---- 3 files changed, 11 insertions(+), 32 deletions(-)
include/net/regulatory.h +1 -12
@@ -140,17 +140,6 @@ struct regulatory_request {* otherwise initiating radiation is not allowed. This will enable the * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration * option -* @REGULATORY_IGNORE_STALE_KICKOFF: the regulatory core will _not_ make sure -* all interfaces on this wiphy reside on allowed channels. If this flag -* is not set, upon a regdomain change, the interfaces are given a grace -* period (currently 60 seconds) to disconnect or move to an allowed -* channel. Interfaces on forbidden channels are forcibly disconnected. -* Currently these types of interfaces are supported for enforcement: -* NL80211_IFTYPE_ADHOC, NL80211_IFTYPE_STATION, NL80211_IFTYPE_AP, -* NL80211_IFTYPE_AP_VLAN, NL80211_IFTYPE_MONITOR, -* NL80211_IFTYPE_P2P_CLIENT, NL80211_IFTYPE_P2P_GO, -* NL80211_IFTYPE_P2P_DEVICE. The flag will be set by default if a device -* includes any modes unsupported for enforcement checking. * @REGULATORY_WIPHY_SELF_MANAGED: for devices that employ wiphy-specific * regdom management. These devices will ignore all regdom changes not * originating from their own wiphy.
@@ -177,7 +166,7 @@ enum ieee80211_regulatory_flags {REGULATORY_COUNTRY_IE_FOLLOW_POWER =BIT (3 ),REGULATORY_COUNTRY_IE_IGNORE =BIT (4 ),REGULATORY_ENABLE_RELAX_NO_IR =BIT (5 ), -REGULATORY_IGNORE_STALE_KICKOFF =BIT (6 ), +/* reuse bit 6 next time */ REGULATORY_WIPHY_SELF_MANAGED = BIT(7), };
net/wireless/core.c +0 -16
@@ -721,22 +721,6 @@ int wiphy_register(struct wiphy *wiphy)return -EINVAL ; } -/* -* if a wiphy has unsupported modes for regulatory channel enforcement, -* opt-out of enforcement checking -*/ -if (wiphy->interface_modes & ~(BIT (NL80211_IFTYPE_STATION ) | -BIT (NL80211_IFTYPE_P2P_CLIENT ) | -BIT (NL80211_IFTYPE_AP ) | -BIT (NL80211_IFTYPE_MESH_POINT ) | -BIT (NL80211_IFTYPE_P2P_GO ) | -BIT (NL80211_IFTYPE_ADHOC ) | -BIT (NL80211_IFTYPE_P2P_DEVICE ) | -BIT (NL80211_IFTYPE_NAN ) | -BIT (NL80211_IFTYPE_AP_VLAN ) | -BIT (NL80211_IFTYPE_MONITOR ))) - wiphy->regulatory_flags |=REGULATORY_IGNORE_STALE_KICKOFF ; - if (WARN_ON((wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) && (wiphy->regulatory_flags & (REGULATORY_CUSTOM_REG |
net/wireless/reg.c +10 -4
@@ -2391,9 +2391,17 @@ static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)case NL80211_IFTYPE_P2P_DEVICE :/* no enforcement required */ break ; +case NL80211_IFTYPE_OCB : +if (!wdev->u.ocb.chandef.chan) +continue ; + chandef = wdev->u.ocb.chandef; +break ; +case NL80211_IFTYPE_NAN : +/* we have no info, but NAN is also pretty universal */ +continue ;default :/* others not implemented for now */ -WARN_ON (1 ); +WARN_ON_ONCE (1 );break ; }
@@ -2452,9 +2460,7 @@ static void reg_check_chans_work(struct work_struct *work)rtnl_lock ();list_for_each_entry (rdev, &cfg80211_rdev_list, list) -if (!(rdev->wiphy.regulatory_flags & -REGULATORY_IGNORE_STALE_KICKOFF )) -reg_leave_invalid_chans (&rdev->wiphy); +reg_leave_invalid_chans (&rdev->wiphy);rtnl_unlock (); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 181/800 wifi: ieee80211: Fix the common size calculation for reconfiguration ML
In reply to Greg Kroah-HartmanFrom: Ilan Peer <[email protected]>
[ Upstream commit ce6e1f600b0cfc563a7d607de702262a58cd835d ]
The common information length is found in the first octet of the common information.
--- include/linux/ieee80211.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
include/linux/ieee80211.h +1 -4
@@ -4612,15 +4612,12 @@ static inline u8 ieee80211_mle_common_size(const u8 *data)case IEEE80211_ML_CONTROL_TYPE_BASIC :case IEEE80211_ML_CONTROL_TYPE_PREQ :case IEEE80211_ML_CONTROL_TYPE_TDLS : +case IEEE80211_ML_CONTROL_TYPE_RECONF :/* * The length is the first octet pointed by mle->variable so no * need to add anything */ break ; -case IEEE80211_ML_CONTROL_TYPE_RECONF : -if (control &IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR ) - common +=ETH_ALEN ; -return common;case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS :if (control &IEEE80211_MLC_PRIO_ACCESS_PRES_AP_MLD_MAC_ADDR ) common +=ETH_ALEN ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 182/800 mm: move mm_count into its own cache line
In reply to Greg Kroah-HartmanFrom: Mathieu Desnoyers <[email protected]>
[ Upstream commit c1753fd02a0058ea43cbb31ab26d25be2f6cfe08 ]
The mm_struct mm_count field is frequently updated by mmgrab/mmdrop performed by context switch. This causes false-sharing for surrounding mm_struct fields which are read-mostly.
This has been observed on a 2sockets/112core/224cpu Intel Sapphire Rapids server running hackbench, and by the kernel test robot will-it-scale testcase.
Move the mm_count field into its own cache line to prevent false-sharing with other mm_struct fields.
Move mm_count to the first field of mm_struct to minimize the amount of padding required: rather than adding padding before and after the mm_count field, padding is only added after mm_count.
Note that I noticed this odd comment in mm_struct:
commit 2e3025434a6b ("mm: relocate 'write_protect_seq' in struct mm_struct")
/*
* With some kernel config, the current mmap_lock's offset
* inside 'mm_struct' is at 0x120, which is very optimal, as
* its two hot fields 'count' and 'owner' sit in 2 different
* cachelines, and when mmap_lock is highly contended, both
* of the 2 fields will be accessed frequently, current layout
* will help to reduce cache bouncing.
*
* So please be careful with adding new fields before
* mmap_lock, which can easily push the 2 fields into one
* cacheline.
*/
struct rw_semaphore mmap_lock;
This comment is rather odd for a few reasons:
- It requires addition/removal of mm_struct fields to carefully consider field alignment of _other_ fields,
- It expresses the wish to keep an "optimal" alignment for a specific kernel config.
I suspect that the author of this comment may want to revisit this topic and perhaps introduce a split-struct approach for struct rw_semaphore, if the need is to place various fields of this structure in different cache lines.
--- include/linux/mm_types.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
include/linux/mm_types.h +15 -8
@@ -583,6 +583,21 @@ struct mm_cid {struct kioctx_table ;struct mm_struct {struct { +/* +* Fields which are often written to are placed in a separate +* cache line. +*/ +struct { +/** +* @mm_count: The number of references to &struct +* mm_struct (@mm_users count as 1). +* +* Use mmgrab()/mmdrop() to modify. When this drops to +* 0, the &struct mm_struct is freed. +*/ +atomic_t mm_count; + }____cacheline_aligned_in_smp ; +struct maple_tree mm_mt;#ifdef CONFIG_MMU unsigned long (*get_unmapped_area) (struct file *filp,
@@ -620,14 +635,6 @@ struct mm_struct {*/ atomic_t mm_users; -/** -* @mm_count: The number of references to &struct mm_struct -* (@mm_users count as 1). -* -* Use mmgrab()/mmdrop() to modify. When this drops to 0, the -* &struct mm_struct is freed. -*/ -atomic_t mm_count;#ifdef CONFIG_SCHED_MM_CID /** * @pcpu_cid: Per-cpu current cid.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 183/800 watchdog: remove WATCHDOG_DEFAULT
In reply to Greg Kroah-HartmanFrom: Lecopzer Chen <[email protected]>
[ Upstream commit 810b560e8985725dbd57bbb3f188c231365eb5ae ]
No reference to WATCHDOG_DEFAULT, remove it.
Stable-dep-of: 9ec272c586b0 ("watchdog/hardlockup: keep kernel.nmi_watchdog sysctl as 0444 if probe fails")
--- kernel/watchdog.c | 2 -- 1 file changed, 2 deletions(-)
kernel/watchdog.c +0 -2
@@ -30,10 +30,8 @@static DEFINE_MUTEX (watchdog_mutex);#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) -# define WATCHDOG_DEFAULT (SOFT_WATCHDOG_ENABLED | NMI_WATCHDOG_ENABLED)# define NMI_WATCHDOG_DEFAULT 1#else -# define WATCHDOG_DEFAULT (SOFT_WATCHDOG_ENABLED)# define NMI_WATCHDOG_DEFAULT 0#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 174/800 wifi: iwlwifi: mvm: correctly access HE/EHT sband capa
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit f912959875761084fda351e1257dcfa9d1fa3037 ]
We can't just dereference the sband->iftype_data pointer, that's an array so we need to access the right entry. Use the previously introduced helper functions to do that.
There are also cases, e.g. when loading with disable_11ax=1, where the pointer might be NULL but we still attempt to use it, causing a crash.
--- .../net/wireless/intel/iwlwifi/mvm/rs-fw.c | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c +26 -20
@@ -63,12 +63,11 @@ static u8 rs_fw_sgi_cw_support(struct ieee80211_link_sta *link_sta)static u16 rs_fw_get_config_flags (struct iwl_mvm *mvm,struct ieee80211_vif *vif,struct ieee80211_link_sta *link_sta, -struct ieee80211_supported_band *sband) +const struct ieee80211_sta_he_cap *sband_he_cap) {struct ieee80211_sta_ht_cap *ht_cap = &link_sta->ht_cap;struct ieee80211_sta_vht_cap *vht_cap = &link_sta->vht_cap;struct ieee80211_sta_he_cap *he_cap = &link_sta->he_cap; -const struct ieee80211_sta_he_cap *sband_he_cap;bool vht_ena = vht_cap->vht_supported;u16 flags =0 ;
@@ -94,7 +93,6 @@ static u16 rs_fw_get_config_flags(struct iwl_mvm *mvm, IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD)) flags |= IWL_TLC_MNG_CFG_FLAGS_LDPC_MSK; - sband_he_cap =ieee80211_get_he_iftype_cap_vif (sband, vif);if (sband_he_cap && !(sband_he_cap->he_cap_elem.phy_cap_info[1 ] &IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD ))
@@ -196,16 +194,14 @@ static u16 rs_fw_he_ieee80211_mcs_to_rs_mcs(u16 mcs)static void rs_fw_he_set_enabled_rates (const struct ieee80211_link_sta *link_sta, -struct ieee80211_supported_band *sband, +const struct ieee80211_sta_he_cap *sband_he_cap,struct iwl_tlc_config_cmd_v4 *cmd) {const struct ieee80211_sta_he_cap *he_cap = &link_sta->he_cap;u16 mcs_160 =le16_to_cpu (he_cap->he_mcs_nss_supp.rx_mcs_160);u16 mcs_80 =le16_to_cpu (he_cap->he_mcs_nss_supp.rx_mcs_80); -u16 tx_mcs_80 = -le16_to_cpu (sband->iftype_data->he_cap.he_mcs_nss_supp.tx_mcs_80); -u16 tx_mcs_160 = -le16_to_cpu (sband->iftype_data->he_cap.he_mcs_nss_supp.tx_mcs_160); +u16 tx_mcs_80 =le16_to_cpu (sband_he_cap->he_mcs_nss_supp.tx_mcs_80); +u16 tx_mcs_160 =le16_to_cpu (sband_he_cap->he_mcs_nss_supp.tx_mcs_160);int i;u8 nss = link_sta->rx_nss;
@@ -288,7 +284,8 @@ rs_fw_rs_mcs2eht_mcs(enum IWL_TLC_MCS_PER_BW bw,static void rs_fw_eht_set_enabled_rates (struct ieee80211_vif *vif,const struct ieee80211_link_sta *link_sta, -struct ieee80211_supported_band *sband, +const struct ieee80211_sta_he_cap *sband_he_cap, +const struct ieee80211_sta_eht_cap *sband_eht_cap,struct iwl_tlc_config_cmd_v4 *cmd) {/* peer RX mcs capa */
@@ -296,7 +293,7 @@ rs_fw_eht_set_enabled_rates(struct ieee80211_vif *vif, &link_sta->eht_cap.eht_mcs_nss_supp;/* our TX mcs capa */ const struct ieee80211_eht_mcs_nss_supp *eht_tx_mcs = - &sband->iftype_data->eht_cap.eht_mcs_nss_supp; + &sband_eht_cap->eht_mcs_nss_supp;enum IWL_TLC_MCS_PER_BW bw;struct ieee80211_eht_mcs_nss_supp_20mhz_only mcs_rx_20;
@@ -315,7 +312,7 @@ rs_fw_eht_set_enabled_rates(struct ieee80211_vif *vif, }/* nic is 20Mhz only */ -if (!(sband->iftype_data->he_cap.he_cap_elem.phy_cap_info[0 ] & +if (!(sband_he_cap->he_cap_elem.phy_cap_info[0 ] &IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK_ALL )) { mcs_tx_20 = eht_tx_mcs->only_20mhz; }else {
@@ -369,6 +366,8 @@ rs_fw_eht_set_enabled_rates(struct ieee80211_vif *vif,static void rs_fw_set_supp_rates (struct ieee80211_vif *vif,struct ieee80211_link_sta *link_sta,struct ieee80211_supported_band *sband, +const struct ieee80211_sta_he_cap *sband_he_cap, +const struct ieee80211_sta_eht_cap *sband_eht_cap,struct iwl_tlc_config_cmd_v4 *cmd) {int i;
@@ -387,12 +386,13 @@ static void rs_fw_set_supp_rates(struct ieee80211_vif *vif, cmd->mode =IWL_TLC_MNG_MODE_NON_HT ;/* HT/VHT rates */ -if (link_sta->eht_cap.has_eht) { +if (link_sta->eht_cap.has_eht && sband_he_cap && sband_eht_cap) { cmd->mode =IWL_TLC_MNG_MODE_EHT ; -rs_fw_eht_set_enabled_rates (vif, link_sta, sband, cmd); - }else if (he_cap->has_he) { +rs_fw_eht_set_enabled_rates (vif, link_sta, sband_he_cap, + sband_eht_cap, cmd); + }else if (he_cap->has_he && sband_he_cap) { cmd->mode =IWL_TLC_MNG_MODE_HE ; -rs_fw_he_set_enabled_rates (link_sta, sband, cmd); +rs_fw_he_set_enabled_rates (link_sta, sband_he_cap, cmd); }else if (vht_cap->vht_supported) { cmd->mode =IWL_TLC_MNG_MODE_VHT ;rs_fw_vht_set_enabled_rates (link_sta, vht_cap, cmd);
@@ -575,13 +575,17 @@ void iwl_mvm_rs_fw_rate_init(struct iwl_mvm *mvm,u32 cmd_id =WIDE_ID (DATA_PATH_GROUP ,TLC_MNG_CONFIG_CMD );struct ieee80211_supported_band *sband = hw->wiphy->bands[band];u16 max_amsdu_len =rs_fw_get_max_amsdu_len (sta, link_conf, link_sta); +const struct ieee80211_sta_he_cap *sband_he_cap = +ieee80211_get_he_iftype_cap_vif (sband, vif); +const struct ieee80211_sta_eht_cap *sband_eht_cap = +ieee80211_get_eht_iftype_cap_vif (sband, vif);struct iwl_mvm_link_sta *mvm_link_sta;struct iwl_lq_sta_rs_fw *lq_sta;struct iwl_tlc_config_cmd_v4 cfg_cmd = { .max_ch_width = mvmsta->authorized ?rs_fw_bw_from_sta_bw (link_sta) :IWL_TLC_MNG_CH_WIDTH_20MHZ , .flags =cpu_to_le16 (rs_fw_get_config_flags (mvm, vif, link_sta, - sband)), + sband_he_cap)), .chains =rs_fw_set_active_chains (iwl_mvm_get_valid_tx_ant (mvm)), .sgi_ch_width_supp =rs_fw_sgi_cw_support (link_sta), .max_mpdu_len = iwl_mvm_is_csum_supported(mvm) ?
@@ -595,9 +599,9 @@ void iwl_mvm_rs_fw_rate_init(struct iwl_mvm *mvm,* mutual support by AP and client */ if (CSR_HW_REV_TYPE (mvm->trans->hw_rev) ==IWL_CFG_MAC_TYPE_GL && - sband->iftype_data->eht_cap.has_eht && - sband->iftype_data->eht_cap.eht_cap_elem.phy_cap_info[5 ] & -IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF && + sband_eht_cap && + sband_eht_cap->eht_cap_elem.phy_cap_info[5 ] & +IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF && link_sta->eht_cap.has_eht && link_sta->eht_cap.eht_cap_elem.phy_cap_info[5 ] &IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF ) {
@@ -623,7 +627,9 @@ void iwl_mvm_rs_fw_rate_init(struct iwl_mvm *mvm,#ifdef CONFIG_IWLWIFI_DEBUGFS iwl_mvm_reset_frame_stats (mvm);#endif -rs_fw_set_supp_rates (vif, link_sta, sband, &cfg_cmd); +rs_fw_set_supp_rates (vif, link_sta, sband, + sband_he_cap, sband_eht_cap, + &cfg_cmd);/* * since TLC offload works with one mode we can assume
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 207/800 sch_netem: fix issues in netem_change() vs get_dist_table()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 11b73313c12403f617b47752db0ab3deef201af7 ]
In blamed commit, I missed that get_dist_table() was allocating memory using GFP_KERNEL, and acquiring qdisc lock to perform the swap of newly allocated table with current one.
In this patch, get_dist_table() is allocating memory and copy user data before we acquire the qdisc lock.
Then we perform swap operations while being protected by the lock.
Note that after this patch netem_change() no longer can do partial changes. If an error is returned, qdisc conf is left unchanged.
--- net/sched/sch_netem.c | 59 ++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 34 deletions(-)
net/sched/sch_netem.c +25 -34
@@ -773,12 +773,10 @@ static void dist_free(struct disttable *d)* signed 16 bit values. */ -static int get_dist_table (struct Qdisc *sch,struct disttable **tbl, -const struct nlattr *attr) +static int get_dist_table (struct disttable **tbl,const struct nlattr *attr) {size_t n =nla_len (attr)/sizeof (__s16);const __s16 *data =nla_data (attr); -spinlock_t *root_lock;struct disttable *d;int i;
@@ -793,13 +791,7 @@ static int get_dist_table(struct Qdisc *sch, struct disttable **tbl,for (i =0 ; i < n; i++) d->table[i] = data[i]; - root_lock =qdisc_root_sleeping_lock (sch); - -spin_lock_bh (root_lock); -swap (*tbl, d); -spin_unlock_bh (root_lock); - -dist_free (d); + *tbl = d;return 0 ; }
@@ -956,6 +948,8 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, {struct netem_sched_data *q =qdisc_priv (sch);struct nlattr *tb[TCA_NETEM_MAX +1 ]; +struct disttable *delay_dist =NULL ; +struct disttable *slot_dist =NULL ;struct tc_netem_qopt *qopt;struct clgstate old_clg;int old_loss_model =CLG_RANDOM ;
@@ -966,6 +960,18 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,if (ret <0 )return ret; +if (tb[TCA_NETEM_DELAY_DIST ]) { + ret =get_dist_table (&delay_dist, tb[TCA_NETEM_DELAY_DIST ]); +if (ret) + goto table_free; + } + +if (tb[TCA_NETEM_SLOT_DIST ]) { + ret =get_dist_table (&slot_dist, tb[TCA_NETEM_SLOT_DIST ]); +if (ret) + goto table_free; + } +sch_tree_lock (sch);/* backup q->clg and q->loss_model */ old_clg = q->clg;
@@ -975,26 +981,17 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, ret =get_loss_clg (q, tb[TCA_NETEM_LOSS ]);if (ret) { q->loss_model = old_loss_model; + q->clg = old_clg; goto unlock; } }else { q->loss_model =CLG_RANDOM ; } -if (tb[TCA_NETEM_DELAY_DIST ]) { - ret =get_dist_table (sch, &q->delay_dist, - tb[TCA_NETEM_DELAY_DIST ]); -if (ret) - goto get_table_failure; - } - -if (tb[TCA_NETEM_SLOT_DIST ]) { - ret =get_dist_table (sch, &q->slot_dist, - tb[TCA_NETEM_SLOT_DIST ]); -if (ret) - goto get_table_failure; - } - +if (delay_dist) +swap (q->delay_dist, delay_dist); +if (slot_dist) +swap (q->slot_dist, slot_dist); sch->limit = qopt->limit; q->latency =PSCHED_TICKS2NS (qopt->latency);
@@ -1044,17 +1041,11 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, unlock:sch_tree_unlock (sch); -return ret; -get_table_failure: -/* recover clg and loss_model, in case of -* q->clg and q->loss_model were modified -* in get_loss_clg() -*/ - q->clg = old_clg; - q->loss_model = old_loss_model; - - goto unlock; +table_free: +dist_free (delay_dist); +dist_free (slot_dist); +return ret; } static int netem_init(struct Qdisc *sch, struct nlattr *opt,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 216/800 netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value.
In reply to Greg Kroah-HartmanFrom: Ilia.Gavrilov <[email protected]>
[ Upstream commit f188d30087480eab421cd8ca552fb15f55d57f4d ]
ct_sip_parse_numerical_param() returns only 0 or 1 now.
But process_register_request() and process_register_response() imply checking for a negative value if parsing of a numerical header parameter failed.
The invocation in nf_nat_sip() looks correct:
if (ct_sip_parse_numerical_param(...) > 0 &&
...) { ... }
Make the return value of the function ct_sip_parse_numerical_param() a tristate to fix all the cases
a) return 1 if value is found; *val is set
b) return 0 if value is not found; *val is unchanged
c) return -1 on error; *val is undefined
Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE.
--- net/netfilter/nf_conntrack_sip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_sip.c +1 -1
@@ -611,7 +611,7 @@ int ct_sip_parse_numerical_param(const struct nf_conn *ct, const char *dptr, start +=strlen (name); *val =simple_strtoul (start, &end,0 );if (start == end) -return 0 ; +return -1 ;if (matchoff && matchlen) { *matchoff = start - dptr; *matchlen = end - start;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 217/800 netfilter: nf_tables: unbind non-anonymous set if rule construction fails
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 3e70489721b6c870252c9082c496703677240f53 ]
Otherwise a dangling reference to a rule object that is gone remains in the set binding list.
--- net/netfilter/nf_tables_api.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_tables_api.c +2 -0
@@ -5343,6 +5343,8 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,nft_set_trans_unbind (ctx, set);if (nft_set_is_anonymous (set))nft_deactivate_next (ctx->net, set); +else +list_del_rcu (&binding->list); set->use--;break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 218/800 netfilter: nf_tables: fix underflow in chain reference counter
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b389139f12f287b8ed2e2628b72df89a081f0b59 ]
Set element addition error path decrements reference counter on chains
twice: once on element release and again via nft_data_release().
Then, d6b478666ffa ("netfilter: nf_tables: fix underflow in object reference counter") incorrectly fixed this by removing the stateful object reference count decrement.
Restore the stateful object decrement as in b91d90368837 ("netfilter:nf_tables: fix leaking object reference count") and let nft_data_release() decrement the chain reference counter, so this is done only once.
--- net/netfilter/nf_tables_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +3 -1
@@ -6771,7 +6771,9 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, err_element_clash:kfree (trans); err_elem_free: -nft_set_elem_destroy (set, elem.priv, true); +nf_tables_set_elem_destroy (ctx, set, elem.priv); +if (obj) + obj->use--; err_parse_data:if (nla[NFTA_SET_ELEM_DATA ] !=NULL )nft_data_release (&elem.data.val, desc.type);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 219/800 ipvlan: Fix return value of ipvlan_queue_xmit()
In reply to Greg Kroah-HartmanFrom: Cambda Zhu <[email protected]>
[ Upstream commit 8a9922e7be6d042fa00f894c376473b17a162b66 ]
ipvlan_queue_xmit() should return NET_XMIT_XXX, but ipvlan_xmit_mode_l2/l3() returns rx_handler_result_t or NET_RX_XXX in some cases. ipvlan_rcv_frame() will only return RX_HANDLER_CONSUMED in ipvlan_xmit_mode_l2/l3() because 'local' is true. It's equal to NET_XMIT_SUCCESS. But dev_forward_skb() can return NET_RX_SUCCESS or NET_RX_DROP, and returning NET_RX_DROP(NET_XMIT_DROP) will increase both ipvlan and ipvlan->phy_dev drops counter.
The skb to forward can be treated as xmitted successfully. This patch makes ipvlan_queue_xmit() return NET_XMIT_SUCCESS for forward skb.
--- drivers/net/ipvlan/ipvlan_core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ipvlan/ipvlan_core.c +6 -3
@@ -585,7 +585,8 @@ static int ipvlan_xmit_mode_l3(struct sk_buff *skb, struct net_device *dev)consume_skb (skb);return NET_XMIT_DROP ; } -return ipvlan_rcv_frame (addr, &skb, true); +ipvlan_rcv_frame (addr, &skb, true); +return NET_XMIT_SUCCESS ; } } out:
@@ -611,7 +612,8 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev)consume_skb (skb);return NET_XMIT_DROP ; } -return ipvlan_rcv_frame (addr, &skb, true); +ipvlan_rcv_frame (addr, &skb, true); +return NET_XMIT_SUCCESS ; } } skb =skb_share_check (skb,GFP_ATOMIC );
@@ -623,7 +625,8 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev)* the skb for the main-dev. At the RX side we just return * RX_PASS for it to be processed further on the stack. */ -return dev_forward_skb (ipvlan->phy_dev, skb); +dev_forward_skb (ipvlan->phy_dev, skb); +return NET_XMIT_SUCCESS ; }else if (is_multicast_ether_addr (eth->h_dest)) {skb_reset_mac_header (skb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 220/800 net: dsa: avoid suspicious RCU usage for synced VLAN-aware MAC addresses
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit d06f925f13976ab82167c93467c70a337a0a3cda ]
When using the felix driver (the only one which supports UC filtering and MC filtering) as a DSA master for a random other DSA switch, one can see the following stack trace when the downstream switch ports join a VLAN-aware bridge:
=============================
WARNING: suspicious RCU usage
-----------------------------net/8021q/vlan_core.c:238 suspicious rcu_dereference_protected() usage!
stack backtrace: Workqueue: dsa_ordered dsa_slave_switchdev_event_work Call trace: lockdep_rcu_suspicious+0x170/0x210 vlan_for_each+0x8c/0x188 dsa_slave_sync_uc+0x128/0x178 __hw_addr_sync_dev+0x138/0x158 dsa_slave_set_rx_mode+0x58/0x70 __dev_set_rx_mode+0x88/0xa8 dev_uc_add+0x74/0xa0 dsa_port_bridge_host_fdb_add+0xec/0x180 dsa_slave_switchdev_event_work+0x7c/0x1c8 process_one_work+0x290/0x568
What it's saying is that vlan_for_each() expects rtnl_lock() context and it's not getting it, when it's called from the DSA master's ndo_set_rx_mode().
The caller of that - dsa_slave_set_rx_mode() - is the slave DSA interface's dsa_port_bridge_host_fdb_add() which comes from the deferred dsa_slave_switchdev_event_work().
We went to great lengths to avoid the rtnl_lock() context in that call path in commit 0faf890fc519 ("net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work"), and calling rtnl_lock() is simply not an option due to the possibility of deadlocking when calling dsa_flush_workqueue() from the call paths that do hold rtnl_lock() - basically all of them.
So, when the DSA master calls vlan_for_each() from its ndo_set_rx_mode(), the state of the 8021q driver on this device is really not protected from concurrent access by anything.
Looking at net/8021q/, I don't think that vlan_info->vid_list was particularly designed with RCU traversal in mind, so introducing an RCU read-side form of vlan_for_each() - vlan_for_each_rcu() - won't be so easy, and it also wouldn't be exactly what we need anyway.
In general I believe that the solution isn't in net/8021q/ anyway; vlan_for_each() is not cut out for this task. DSA doesn't need rtnl_lock() to be held per se - since it's not a netdev state change that we're blocking, but rather, just concurrent additions/removals to a VLAN list. We don't even need sleepable context - the callback of vlan_for_each() just schedules deferred work.
The proposed escape is to remove the dependency on vlan_for_each() and to open-code a non-sleepable, rtnl-free alternative to that, based on copies of the VLAN list modified from .ndo_vlan_rx_add_vid() and .ndo_vlan_rx_kill_vid().
--- include/net/dsa.h | 12 +++++-- net/dsa/dsa.c | 2 +- net/dsa/slave.c | 84 ++++++++++++++++++++++++++++++++--------------- net/dsa/switch.c | 4 +-- net/dsa/switch.h | 3 ++ 5 files changed, 74 insertions(+), 31 deletions(-)
include/net/dsa.h +10 -2
@@ -314,9 +314,17 @@ struct dsa_port {struct list_head fdbs;struct list_head mdbs; -/* List of VLANs that CPU and DSA ports are members of. */ struct mutex vlans_lock; -struct list_head vlans; +union { +/* List of VLANs that CPU and DSA ports are members of. +* Access to this is serialized by the sleepable @vlans_lock. +*/ +struct list_head vlans; +/* List of VLANs that user ports are members of. +* Access to this is serialized by netif_addr_lock_bh(). +*/ +struct list_head user_vlans; + }; };/* TODO: ideally DSA ports would have a single dp->link_dp member,
net/dsa/dsa.c +1 -1
@@ -1106,7 +1106,7 @@ static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index)mutex_init (&dp->vlans_lock);INIT_LIST_HEAD (&dp->fdbs);INIT_LIST_HEAD (&dp->mdbs); -INIT_LIST_HEAD (&dp->vlans); +INIT_LIST_HEAD (&dp->vlans);/* also initializes &dp->user_vlans */ INIT_LIST_HEAD (&dp->list);list_add_tail (&dp->list, &dst->ports);
net/dsa/slave.c +58 -26
182 lines not on this page · raw message
net/dsa/switch.c +2 -2
@@ -673,8 +673,8 @@ static bool dsa_port_host_vlan_match(struct dsa_port *dp,return false; } -static struct dsa_vlan *dsa_vlan_find (struct list_head *vlan_list, -const struct switchdev_obj_port_vlan *vlan) +struct dsa_vlan *dsa_vlan_find (struct list_head *vlan_list, +const struct switchdev_obj_port_vlan *vlan) {struct dsa_vlan *v;
net/dsa/switch.h +3 -0
@@ -111,6 +111,9 @@ struct dsa_notifier_master_state_info {bool operational; }; +struct dsa_vlan *dsa_vlan_find (struct list_head *vlan_list, +const struct switchdev_obj_port_vlan *vlan); +int dsa_tree_notify (struct dsa_switch_tree *dst,unsigned long e,void *v);int dsa_broadcast (unsigned long e,void *v);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 221/800 netlink: Add __sock_i_ino() for __netlink_diag_dump().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 25a9c8a4431c364f97f75558cb346d2ad3f53fbb ]
syzbot reported a warning in __local_bh_enable_ip(). [0]
Commit 8d61f926d420 ("netlink: fix potential deadlock in netlink_set_err()") converted read_lock(&nl_table_lock) to read_lock_irqsave() in __netlink_diag_dump() to prevent a deadlock.
However, __netlink_diag_dump() calls sock_i_ino() that uses read_lock_bh() and read_unlock_bh(). If CONFIG_TRACE_IRQFLAGS=y, read_unlock_bh() finally enables IRQ even though it should stay disabled until the following read_unlock_irqrestore().
Using read_lock() in sock_i_ino() would trigger a lockdep splat in another place that was fixed in commit f064af1e500a ("net: fix a lockdep splat"), so let's add __sock_i_ino() that would be safe to use under BH disabled.
[0]:
WARNING: CPU: 0 PID: 5012 at kernel/softirq.c:376 __local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376 Modules linked in: CPU: 0 PID: 5012 Comm: syz-executor487 Not tainted 6.4.0-rc7-syzkaller-00202-g6f68fc395f49 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023 RIP: 0010:__local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376 Code: 45 bf 01 00 00 00 e8 91 5b 0a 00 e8 3c 15 3d 00 fb 65 8b 05 ec e9 b5 7e 85 c0 74 58 5b 5d c3 65 8b 05 b2 b6 b4 7e 85 c0 75 a2 <0f> 0b eb 9e e8 89 15 3d 00 eb 9f 48 89 ef e8 6f 49 18 00 eb a8 0f RSP: 0018:ffffc90003a1f3d0 EFLAGS: 00010046 RAX: 0000000000000000 RBX: 0000000000000201 RCX: 1ffffffff1cf5996 RDX: 0000000000000000 RSI: 0000000000000201 RDI: ffffffff8805c6f3 RBP: ffffffff8805c6f3 R08: 0000000000000001 R09: ffff8880152b03a3 R10: ffffed1002a56074 R11: 0000000000000005 R12: 00000000000073e4 R13: dffffc0000000000 R14: 0000000000000002 R15: 0000000000000000 FS: 0000555556726300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000045ad50 CR3: 000000007c646000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> sock_i_ino+0x83/0xa0 net/core/sock.c:2559 __netlink_diag_dump+0x45c/0x790 net/netlink/diag.c:171 netlink_diag_dump+0xd6/0x230 net/netlink/diag.c:207 netlink_dump+0x570/0xc50 net/netlink/af_netlink.c:2269 __netlink_dump_start+0x64b/0x910 net/netlink/af_netlink.c:2374 netlink_dump_start include/linux/netlink.h:329 [inline] netlink_diag_handler_dump+0x1ae/0x250 net/netlink/diag.c:238 __sock_diag_cmd net/core/sock_diag.c:238 [inline] sock_diag_rcv_msg+0x31e/0x440 net/core/sock_diag.c:269 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2547 sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1365 netlink_sendmsg+0x925/0xe30 net/netlink/af_netlink.c:1914 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg+0xde/0x190 net/socket.c:747 ____sys_sendmsg+0x71c/0x900 net/socket.c:2503 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2557 __sys_sendmsg+0xf7/0x1c0 net/socket.c:2586 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f5303aaabb9 Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffc7506e548 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5303aaabb9 RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000003 RBP: 00007f5303a6ed60 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5303a6edf0 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 </TASK>
--- include/net/sock.h | 1 + net/core/sock.c | 17 ++++++++++++++--- net/netlink/diag.c | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-)
include/net/sock.h +1 -0
@@ -2100,6 +2100,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) }kuid_t sock_i_uid (struct sock *sk); +unsigned long __sock_i_ino (struct sock *sk);unsigned long sock_i_ino (struct sock *sk);static inline kuid_t sock_net_uid (const struct net *net,const struct sock *sk)
net/core/sock.c +14 -3
@@ -2550,13 +2550,24 @@ kuid_t sock_i_uid(struct sock *sk) }EXPORT_SYMBOL (sock_i_uid); -unsigned long sock_i_ino (struct sock *sk) +unsigned long __sock_i_ino (struct sock *sk) {unsigned long ino; -read_lock_bh (&sk->sk_callback_lock); +read_lock (&sk->sk_callback_lock); ino = sk->sk_socket ?SOCK_INODE (sk->sk_socket)->i_ino :0 ; -read_unlock_bh (&sk->sk_callback_lock); +read_unlock (&sk->sk_callback_lock); +return ino; +} +EXPORT_SYMBOL (__sock_i_ino); + +unsigned long sock_i_ino (struct sock *sk) +{ +unsigned long ino; + +local_bh_disable (); + ino =__sock_i_ino (sk); +local_bh_enable ();return ino; }EXPORT_SYMBOL (sock_i_ino);
net/netlink/diag.c +1 -1
@@ -168,7 +168,7 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI, - sock_i_ino(sk)) < 0) { + __sock_i_ino(sk)) < 0) { ret =1 ;break ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 222/800 drm/imx/lcdc: fix a NULL vs IS_ERR() bug in probe
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit dae2f7b89a8436351a2982d0d96a8a56accca576 ]
The devm_drm_dev_alloc() function returns error pointers. It never returns NULL. Fix the check.
--- drivers/gpu/drm/imx/lcdc/imx-lcdc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/imx/lcdc/imx-lcdc.c +2 -2
@@ -400,8 +400,8 @@ static int imx_lcdc_probe(struct platform_device *pdev) lcdc =devm_drm_dev_alloc (dev, &imx_lcdc_drm_driver, struct imx_lcdc, drm); -if (!lcdc) -return -ENOMEM ; +if (IS_ERR (lcdc)) +return PTR_ERR (lcdc); drm = &lcdc->drm;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 223/800 drm/amd/display: Unconditionally print when DP sink power state fails
In reply to Greg Kroah-HartmanFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit e4dfd94d5e3851df607b26ab5b20ad8d94f5ccff ]
The previous 'commit ca9beb8aac68 ("drm/amd/display: Add logging when setting DP sink power state fails")', it is better to unconditionally print "failed to power up sink", because we are returning DC_ERROR_UNEXPECTED.
--- .../drm/amd/display/dc/link/protocols/link_dp_capability.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c +1 -3
@@ -1043,9 +1043,7 @@ static enum dc_status wake_up_aux_channel(struct dc_link *link)DP_SET_POWER , &dpcd_power_state, sizeof(dpcd_power_state)); -if (status <0 ) -DC_LOG_DC ("%s: Failed to power up sink: %s\n" , __func__, - dpcd_power_state ==DP_SET_POWER_D0 ?"D0" :"D3" ); +DC_LOG_DC ("%s: Failed to power up sink\n" , __func__);return DC_ERROR_UNEXPECTED ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 224/800 drm/amd/display: Add logging for display MALL refresh setting
In reply to Greg Kroah-HartmanFrom: Wesley Chalmers <[email protected]>
[ Upstream commit cd8f067a46d34dee3188da184912ae3d64d98444 ]
[WHY]
Add log entry for when display refresh from MALL
settings are sent to SMU.
--- .../drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.c +3 -0
@@ -312,6 +312,9 @@ void dcn30_smu_set_display_refresh_from_mall(struct clk_mgr_internal *clk_mgr, b/* bits 8:7 for cache timer scale, bits 6:1 for cache timer delay, bit 0 = 1 for enable, = 0 for disable */ uint32_t param = (cache_timer_scale <<7 ) | (cache_timer_delay <<1 ) | (enable ?1 :0 ); +smu_print ("SMU Set display refresh from mall: enable = %d, cache_timer_delay = %d, cache_timer_scale = %d\n" , + enable, cache_timer_delay, cache_timer_scale); +dcn30_smu_send_msg_with_param (clk_mgr, DALSMC_MSG_SetDisplayRefreshFromMall, param,NULL ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 225/800 drm/amd/display: fix is_timing_changed() prototype
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 3306ba4b60b2f3d9ac6bddc587a4d702e1ba2224 ]
Three functions in the amdgpu display driver cause -Wmissing-prototype warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_resource.c:1858:6: error: no previous prototype for 'is_timing_changed' [-Werror=missing-prototypes]
is_timing_changed() is actually meant to be a global symbol, but needs a proper name and prototype.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 5 ++--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 6 +++--- drivers/gpu/drm/amd/display/dc/dc.h | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +2 -3
@@ -45,8 +45,7 @@#endif #include "dc/dcn20/dcn20_resource.h" -bool is_timing_changed (struct dc_stream_state *cur_stream, -struct dc_stream_state *new_stream); +#define PEAK_FACTOR_X1000 1006 static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
@@ -1422,7 +1421,7 @@ int pre_validate_dsc(struct drm_atomic_state *state,struct dc_stream_state *stream = dm_state->context->streams[i];if (local_dc_state->streams[i] && -is_timing_changed (stream, local_dc_state->streams[i])) { +dc_is_timing_changed (stream, local_dc_state->streams[i])) {DRM_INFO_ONCE ("crtc[%d] needs mode_changed\n" , i); }else {int ind =find_crtc_index_in_state_by_stream (state, stream);
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +3 -3
@@ -1878,7 +1878,7 @@ bool dc_add_all_planes_for_stream(return add_all_planes_for_stream (dc, stream, &set,1 , context); } -bool is_timing_changed (struct dc_stream_state *cur_stream, +bool dc_is_timing_changed (struct dc_stream_state *cur_stream,struct dc_stream_state *new_stream) {if (cur_stream ==NULL )
@@ -1903,7 +1903,7 @@ static bool are_stream_backends_same(if (stream_a ==NULL || stream_b ==NULL )return false; -if (is_timing_changed (stream_a, stream_b)) +if (dc_is_timing_changed (stream_a, stream_b))return false;if (stream_a->signal != stream_b->signal)
@@ -3528,7 +3528,7 @@ bool pipe_need_reprogram(if (pipe_ctx_old->stream_res.stream_enc != pipe_ctx->stream_res.stream_enc)return true; -if (is_timing_changed (pipe_ctx_old->stream, pipe_ctx->stream)) +if (dc_is_timing_changed (pipe_ctx_old->stream, pipe_ctx->stream))return true;if (pipe_ctx_old->stream->dpms_off != pipe_ctx->stream->dpms_off)
drivers/gpu/drm/amd/display/dc/dc.h +3 -0
@@ -2226,4 +2226,7 @@ void dc_process_dmub_dpia_hpd_int_enable(const struct dc *dc,/* Disable acc mode Interfaces */ void dc_disable_accelerated_mode (struct dc *dc); +bool dc_is_timing_changed (struct dc_stream_state *cur_stream, +struct dc_stream_state *new_stream); +#endif /* DC_INTERFACE_H_ */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 208/800 selftests: rtnetlink: remove netdevsim device after ipsec offload test
In reply to Greg Kroah-HartmanFrom: Sabrina Dubroca <[email protected]>
[ Upstream commit 5f789f103671fec3733ebe756e56adf15c90c21d ]
On systems where netdevsim is built-in or loaded before the test starts, kci_test_ipsec_offload doesn't remove the netdevsim device it created during the test.
--- tools/testing/selftests/net/rtnetlink.sh | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/rtnetlink.sh +1 -0
@@ -860,6 +860,7 @@ EOF fi # clean up any leftovers + echo 0 > /sys/bus/netdevsim/del_device $probed && rmmod netdevsim if [ $ret -ne 0 ]; then
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 226/800 radeon: avoid double free in ci_dpm_init()
In reply to Greg Kroah-HartmanFrom: Nikita Zhandarovich <[email protected]>
[ Upstream commit 20c3dffdccbd494e0dd631d1660aeecbff6775f2 ]
Several calls to ci_dpm_fini() will attempt to free resources that either have been freed before or haven't been allocated yet. This may lead to undefined or dangerous behaviour.
For instance, if r600_parse_extended_power_table() fails, it might call r600_free_extended_power_table() as will ci_dpm_fini() later during error handling.
Fix this by only freeing pointers to objects previously allocated.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/gpu/drm/radeon/ci_dpm.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/ci_dpm.c +20 -8
@@ -5517,6 +5517,7 @@ static int ci_parse_power_table(struct radeon_device *rdev)u8 frev, crev;u8 *power_state_offset;struct ci_ps *ps; +int ret;if (!atom_parse_data_header (mode_info->atom_context, index,NULL , &frev, &crev, &data_offset))
@@ -5546,11 +5547,15 @@ static int ci_parse_power_table(struct radeon_device *rdev) non_clock_array_index = power_state->v2.nonClockInfoIndex; non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) &non_clock_info_array->nonClockInfo[non_clock_array_index]; -if (!rdev->pm.power_state[i].clock_info) -return -EINVAL ; +if (!rdev->pm.power_state[i].clock_info) { + ret = -EINVAL ; + goto err_free_ps; + } ps =kzalloc (sizeof (struct ci_ps ),GFP_KERNEL ); -if (ps ==NULL ) -return -ENOMEM ; +if (ps ==NULL ) { + ret = -ENOMEM ; + goto err_free_ps; + } rdev->pm.dpm.ps[i].ps_priv = ps; ci_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i], non_clock_info,
@@ -5590,6 +5595,12 @@ static int ci_parse_power_table(struct radeon_device *rdev) }return 0 ; + +err_free_ps: +for (i =0 ; i < rdev->pm.dpm.num_ps; i++) +kfree (rdev->pm.dpm.ps[i].ps_priv); +kfree (rdev->pm.dpm.ps); +return ret; } static int ci_get_vbios_boot_values(struct radeon_device *rdev,
@@ -5678,25 +5689,26 @@ int ci_dpm_init(struct radeon_device *rdev) ret =ci_get_vbios_boot_values (rdev, &pi->vbios_boot_state);if (ret) { -ci_dpm_fini (rdev); +kfree (rdev->pm.dpm.priv);return ret; } ret =r600_get_platform_caps (rdev);if (ret) { -ci_dpm_fini (rdev); +kfree (rdev->pm.dpm.priv);return ret; } ret =r600_parse_extended_power_table (rdev);if (ret) { -ci_dpm_fini (rdev); +kfree (rdev->pm.dpm.priv);return ret; } ret =ci_parse_power_table (rdev);if (ret) { -ci_dpm_fini (rdev); +kfree (rdev->pm.dpm.priv); +r600_free_extended_power_table (rdev);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 227/800 drm/amd/display: Explicitly specify update type per plane info change
In reply to Greg Kroah-HartmanFrom: Nicholas Kazlauskas <[email protected]>
[ Upstream commit 710cc1e7cd461446a9325c9bd1e9a54daa462952 ]
[Why]
The bit for flip addr is being set causing the determination for FAST vs MEDIUM to always return MEDIUM when plane info is provided as a surface update. This causes extreme stuttering for the typical atomic update path on Linux.
[How]
Don't use update_flags->raw for determining FAST vs MEDIUM. It's too fragile to changes like this.
Explicitly specify the update type per update flag instead. It's not as clever as checking the bits itself but at least it's correct.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -3
@@ -2504,9 +2504,6 @@ static enum surface_update_type det_surface_update(const struct dc *dc,enum surface_update_type overall_type =UPDATE_TYPE_FAST ;union surface_update_flags *update_flags = &u->surface->update_flags; -if (u->flip_addr) - update_flags->bits.addr_update =1 ; -if (!is_surface_in_context (context, u->surface) || u->surface->force_full_update) { update_flags->raw =0xFFFFFFFF ;return UPDATE_TYPE_FULL ;
Signature · 1 line
2.39.2