6.4.4-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 107/800 libbpf: btf_dump_type_data_check_overflow needs to consider BTF_MEMBER_BITFIELD_SIZE
In reply to Greg Kroah-HartmanFrom: Martin KaFai Lau <[email protected]>
[ Upstream commit c39028b333f3a3a765c5c0b9726b8e38aedf0ba1 ]
The btf_dump/struct_data selftest is failing with:
[...]
test_btf_dump_struct_data:FAIL:unexpected return value dumping fs_context unexpected unexpected return value dumping fs_context: actual -7 != expected 264 [...]
The reason is in btf_dump_type_data_check_overflow(). It does not use BTF_MEMBER_BITFIELD_SIZE from the struct's member (btf_member). Instead, it is using the enum size which is 4. It had been working till the recent commit 4e04143c869c ("fs_context: drop the unused lsm_flags member") removed an integer member which also removed the 4 bytes padding at the end of the fs_context. Missing this 4 bytes padding exposed this bug. In particular, when btf_dump_type_data_check_overflow() reaches the member 'phase', -E2BIG is returned.
The fix is to pass bit_sz to btf_dump_type_data_check_overflow(). In btf_dump_type_data_check_overflow(), it does a different size check when bit_sz is not zero.
The current fs_context:
[3600] ENUM 'fs_context_purpose' encoding=UNSIGNED size=4 vlen=3
'FS_CONTEXT_FOR_MOUNT' val=0 'FS_CONTEXT_FOR_SUBMOUNT' val=1 'FS_CONTEXT_FOR_RECONFIGURE' val=2
[3601] ENUM 'fs_context_phase' encoding=UNSIGNED size=4 vlen=7
'FS_CONTEXT_CREATE_PARAMS' val=0 'FS_CONTEXT_CREATING' val=1 'FS_CONTEXT_AWAITING_MOUNT' val=2 'FS_CONTEXT_AWAITING_RECONF' val=3 'FS_CONTEXT_RECONF_PARAMS' val=4 'FS_CONTEXT_RECONFIGURING' val=5 'FS_CONTEXT_FAILED' val=6
[3602] STRUCT 'fs_context' size=264 vlen=21
'ops' type_id=3603 bits_offset=0 'uapi_mutex' type_id=235 bits_offset=64 'fs_type' type_id=872 bits_offset=1216 'fs_private' type_id=21 bits_offset=1280 'sget_key' type_id=21 bits_offset=1344 'root' type_id=781 bits_offset=1408 'user_ns' type_id=251 bits_offset=1472 'net_ns' type_id=984 bits_offset=1536 'cred' type_id=1785 bits_offset=1600 'log' type_id=3621 bits_offset=1664 'source' type_id=42 bits_offset=1792 'security' type_id=21 bits_offset=1856 's_fs_info' type_id=21 bits_offset=1920 'sb_flags' type_id=20 bits_offset=1984 'sb_flags_mask' type_id=20 bits_offset=2016 's_iflags' type_id=20 bits_offset=2048 'purpose' type_id=3600 bits_offset=2080 bitfield_size=8 'phase' type_id=3601 bits_offset=2088 bitfield_size=8 'need_free' type_id=67 bits_offset=2096 bitfield_size=1 'global' type_id=67 bits_offset=2097 bitfield_size=1 'oldapi' type_id=67 bits_offset=2098 bitfield_size=1
--- tools/lib/bpf/btf_dump.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
tools/lib/bpf/btf_dump.c +19 -3
@@ -2250,9 +2250,25 @@ static int btf_dump_type_data_check_overflow(struct btf_dump *d,const struct btf_type *t, __u32 id, const void *data, - __u8 bits_offset) + __u8 bits_offset, + __u8 bit_sz) { - __s64 size = btf__resolve_size(d->btf, id); + __s64 size; + +if (bit_sz) { +/* bits_offset is at most 7. bit_sz is at most 128. */ +__u8 nr_bytes = (bits_offset + bit_sz +7 ) /8 ; + +/* When bit_sz is non zero, it is called from +* btf_dump_struct_data() where it only cares about +* negative error value. +* Return nr_bytes in success case to make it +* consistent as the regular integer case below. +*/ +return data + nr_bytes > d->typed_dump->data_end ? -E2BIG : nr_bytes; + } + + size =btf__resolve_size (d->btf, id);if (size <0 || size >=INT_MAX ) { pr_warn("unexpected size [%zu] for id [%u]\n",
@@ -2407,7 +2423,7 @@ static int btf_dump_dump_type_data(struct btf_dump *d, {int size, err =0 ; - size =btf_dump_type_data_check_overflow (d, t, id, data, bits_offset); + size =btf_dump_type_data_check_overflow (d, t, id, data, bits_offset, bit_sz);if (size <0 )return size; err =btf_dump_type_data_check_zero (d, t, id, data, bits_offset, bit_sz);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 108/800 bpf: encapsulate precision backtracking bookkeeping
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 407958a0e980b9e1842ab87b5a1040521e1e24e9 ]
Add struct backtrack_state and straightforward API around it to keep track of register and stack masks used and maintained during precision backtracking process. Having this logic separately allow to keep high-level backtracking algorithm cleaner, but also it sets us up to cleanly keep track of register and stack masks per frame, allowing (with some further logic adjustments) to perform precision backpropagation across multiple frames (i.e., subprog calls).
Stable-dep-of: f655badf2a8f ("bpf: fix propagate_precision() logic for inner frames")
--- include/linux/bpf_verifier.h | 14 ++ kernel/bpf/verifier.c | 249 +++++++++++++++++++++++++---------- 2 files changed, 196 insertions(+), 67 deletions(-)
include/linux/bpf_verifier.h +14 -0
@@ -238,6 +238,10 @@ enum bpf_stack_slot_type {#define BPF_REG_SIZE 8/* size of eBPF register in bytes */ +#define BPF_REGMASK_ARGS ((1 << BPF_REG_1) | (1 << BPF_REG_2) | \ + (1 << BPF_REG_3) | (1 << BPF_REG_4) | \ + (1 << BPF_REG_5)) +#define BPF_DYNPTR_SIZE sizeof(struct bpf_dynptr_kern)#define BPF_DYNPTR_NR_SLOTS (BPF_DYNPTR_SIZE / BPF_REG_SIZE)
@@ -541,6 +545,15 @@ struct bpf_subprog_info {bool is_async_cb; }; +struct bpf_verifier_env ; + +struct backtrack_state { +struct bpf_verifier_env *env; +u32 frame; +u32 reg_masks[MAX_CALL_FRAMES ]; +u64 stack_masks[MAX_CALL_FRAMES ]; +}; +/* single container for all structs * one verifier_env per bpf_check() call */
@@ -578,6 +591,7 @@ struct bpf_verifier_env {int *insn_stack;int cur_stack; } cfg; +struct backtrack_state bt;u32 pass_cnt;/* number of times do_check() was called */ u32 subprog_cnt;/* number of instructions analyzed by the verifier */
kernel/bpf/verifier.c +182 -67
445 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 109/800 bpf: improve precision backtrack logging
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit d9439c21a9e4769bfd83a03ab39056164d44ac31 ]
Add helper to format register and stack masks in more human-readable format. Adjust logging a bit during backtrack propagation and especially during forcing precision fallback logic to make it clearer what's going on (with log_level=2, of course), and also start reporting affected frame depth. This is in preparation for having more than one active frame later when precision propagation between subprog calls is added.
Stable-dep-of: f655badf2a8f ("bpf: fix propagate_precision() logic for inner frames")
--- include/linux/bpf_verifier.h | 13 ++- kernel/bpf/verifier.c | 72 ++++++++++-- .../testing/selftests/bpf/verifier/precise.c | 106 +++++++++--------- 3 files changed, 128 insertions(+), 63 deletions(-)
include/linux/bpf_verifier.h +9 -4
@@ -18,8 +18,11 @@* that converting umax_value to int cannot overflow. */ #define BPF_MAX_VAR_SIZ (1 << 29) -/* size of type_str_buf in bpf_verifier. */ -#define TYPE_STR_BUF_LEN 128 +/* size of tmp_str_buf in bpf_verifier. +* we need at least 306 bytes to fit full stack mask representation +* (in the "-8,-16,...,-512" form) +*/ +#define TMP_STR_BUF_LEN 320/* Liveness marks, used for registers and spilled-regs (in stack slots). * Read marks propagate upwards until they find a write mark; they record that
@@ -620,8 +623,10 @@ struct bpf_verifier_env {/* Same as scratched_regs but for stack slots */ u64 scratched_stack_slots;u64 prev_log_pos, prev_insn_print_pos; -/* buffer used in reg_type_str() to generate reg_type string */ -char type_str_buf[TYPE_STR_BUF_LEN ]; +/* buffer used to generate temporary string representations, +* e.g., in reg_type_str() to generate reg_type string +*/ +char tmp_str_buf[TMP_STR_BUF_LEN ]; }; __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log,
kernel/bpf/verifier.c +65 -7
118 lines not on this page · raw message
tools/testing/selftests/bpf/verifier/precise.c +54 -52
130 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 110/800 bpf: maintain bitmasks across all active frames in __mark_chain_precision
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 1ef22b6865a73a8aed36d43375fe8c7b30869326 ]
Teach __mark_chain_precision logic to maintain register/stack masks across all active frames when going from child state to parent state. Currently this should be mostly no-op, as precision backtracking usually bails out when encountering subprog entry/exit.
It's not very apparent from the diff due to increased indentation, but the logic remains the same, except everything is done on specific fr frame index. Calls to bt_clear_reg() and bt_clear_slot() are replaced with frame-specific bt_clear_frame_reg() and bt_clear_frame_slot(), where frame index is passed explicitly, instead of using current frame number.
We also adjust logging to emit affected frame number. And we also add better logging of human-readable register and stack slot masks, similar to previous patch.
Stable-dep-of: f655badf2a8f ("bpf: fix propagate_precision() logic for inner frames")
--- kernel/bpf/verifier.c | 100 ++++++++++-------- .../testing/selftests/bpf/verifier/precise.c | 18 ++-- 2 files changed, 62 insertions(+), 56 deletions(-)
kernel/bpf/verifier.c +53 -47
@@ -3694,7 +3694,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int frame, int rstruct bpf_func_state *func;struct bpf_reg_state *reg;bool skip_first = true; -int i, err; +int i, fr, err;if (!env->bpf_capable)return 0 ;
@@ -3803,56 +3803,62 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int frame, int rif (!st)break ; - func = st->frame[frame]; -bitmap_from_u64 (mask,bt_reg_mask (bt)); -for_each_set_bit (i, mask,32 ) { - reg = &func->regs[i]; -if (reg->type !=SCALAR_VALUE ) { -bt_clear_reg (bt, i); -continue ; +for (fr = bt->frame; fr >=0 ; fr--) { + func = st->frame[fr]; +bitmap_from_u64 (mask,bt_frame_reg_mask (bt, fr)); +for_each_set_bit (i, mask,32 ) { + reg = &func->regs[i]; +if (reg->type !=SCALAR_VALUE ) { +bt_clear_frame_reg (bt, fr, i); +continue ; + } +if (reg->precise) +bt_clear_frame_reg (bt, fr, i); +else + reg->precise = true; } -if (reg->precise) -bt_clear_reg (bt, i); -else - reg->precise = true; - } -bitmap_from_u64 (mask,bt_stack_mask (bt)); -for_each_set_bit (i, mask,64 ) { -if (i >= func->allocated_stack /BPF_REG_SIZE ) { -/* the sequence of instructions: -* 2: (bf) r3 = r10 -* 3: (7b) *(u64 *)(r3 -8) = r0 -* 4: (79) r4 = *(u64 *)(r10 -8) -* doesn't contain jmps. It's backtracked -* as a single block. -* During backtracking insn 3 is not recognized as -* stack access, so at the end of backtracking -* stack slot fp-8 is still marked in stack_mask. -* However the parent state may not have accessed -* fp-8 and it's "unallocated" stack space. -* In such case fallback to conservative. -*/ -mark_all_scalars_precise (env, st); -bt_reset (bt); -return 0 ; - } +bitmap_from_u64 (mask,bt_frame_stack_mask (bt, fr)); +for_each_set_bit (i, mask,64 ) { +if (i >= func->allocated_stack /BPF_REG_SIZE ) { +/* the sequence of instructions: +* 2: (bf) r3 = r10 +* 3: (7b) *(u64 *)(r3 -8) = r0 +* 4: (79) r4 = *(u64 *)(r10 -8) +* doesn't contain jmps. It's backtracked +* as a single block. +* During backtracking insn 3 is not recognized as +* stack access, so at the end of backtracking +* stack slot fp-8 is still marked in stack_mask. +* However the parent state may not have accessed +* fp-8 and it's "unallocated" stack space. +* In such case fallback to conservative. +*/ +mark_all_scalars_precise (env, st); +bt_reset (bt); +return 0 ; + } -if (!is_spilled_scalar_reg (&func->stack[i])) { -bt_clear_slot (bt, i); -continue ; +if (!is_spilled_scalar_reg (&func->stack[i])) { +bt_clear_frame_slot (bt, fr, i); +continue ; + } + reg = &func->stack[i].spilled_ptr; +if (reg->precise) +bt_clear_frame_slot (bt, fr, i); +else + reg->precise = true; + } +if (env->log.level &BPF_LOG_LEVEL2 ) { +fmt_reg_mask (env->tmp_str_buf,TMP_STR_BUF_LEN , +bt_frame_reg_mask (bt, fr)); +verbose (env,"mark_precise: frame%d: parent state regs=%s " , + fr, env->tmp_str_buf); +fmt_stack_mask (env->tmp_str_buf,TMP_STR_BUF_LEN , +bt_frame_stack_mask (bt, fr)); +verbose (env,"stack=%s: " , env->tmp_str_buf); +print_verifier_state (env, func, true); } - reg = &func->stack[i].spilled_ptr; -if (reg->precise) -bt_clear_slot (bt, i); -else - reg->precise = true; - } -if (env->log.level &BPF_LOG_LEVEL2 ) { -verbose (env,"parent %s regs=%x stack=%llx marks:" , - !bt_empty (bt) ?"didn't have" :"already had" , -bt_reg_mask (bt),bt_stack_mask (bt)); -print_verifier_state (env, func, true); }if (bt_empty (bt))
tools/testing/selftests/bpf/verifier/precise.c +9 -9
@@ -44,7 +44,7 @@ mark_precise: frame0: regs=r2 stack= before 23\ mark_precise: frame0: regs=r2 stack= before 22\ mark_precise: frame0: regs=r2 stack= before 20\ - parent didn't have regs=4 stack=0 marks:\ + 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=r9 stack= before 18\
@@ -55,7 +55,7 @@ mark_precise: frame0: regs=r9 stack= before 12\ mark_precise: frame0: regs=r9 stack= before 11\ mark_precise: frame0: regs=r9 stack= before 10\ - parent already had regs=0 stack=0 marks:", + mark_precise: frame0: parent state regs= stack=:", }, { "precise: test 2",
@@ -104,15 +104,15 @@ mark_precise: frame0: regs=r2 stack= before 24\ mark_precise: frame0: regs=r2 stack= before 23\ mark_precise: frame0: regs=r2 stack= before 22\ - parent didn't have regs=4 stack=0 marks:\ + 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\ - parent didn't have regs=4 stack=0 marks:\ + mark_precise: frame0: parent state regs=r2 stack=:\ mark_precise: frame0: last_idx 19 first_idx 17\ mark_precise: frame0: regs=r2 stack= before 19\ mark_precise: frame0: regs=r9 stack= before 18\ mark_precise: frame0: regs=r8,r9 stack= before 17\ - parent already had regs=0 stack=0 marks:", + mark_precise: frame0: parent state regs= stack=:", }, { "precise: cross frame pruning",
@@ -153,14 +153,14 @@ .prog_type = BPF_PROG_TYPE_XDP, .flags = BPF_F_TEST_STATE_FREQ, .errstr ="mark_precise: frame0: last_idx 5 first_idx 5\ -parent didn't have regs=10 stack=0 marks:\ +mark_precise: frame0: parent state regs=r4 stack=:\ mark_precise: frame0: last_idx 4 first_idx 2\ mark_precise: frame0: regs=r4 stack= before 4\ mark_precise: frame0: regs=r4 stack= before 3\ mark_precise: frame0: regs= stack=-8 before 2\ mark_precise: frame0: falling back to forcing all scalars precise\ mark_precise: frame0: last_idx 5 first_idx 5\ - parent didn't have regs=1 stack=0 marks:", + mark_precise: frame0: parent state regs=r0 stack=:", .result = VERBOSE_ACCEPT, .retval = -1, },
@@ -179,7 +179,7 @@ .prog_type = BPF_PROG_TYPE_XDP, .flags = BPF_F_TEST_STATE_FREQ, .errstr ="mark_precise: frame0: last_idx 6 first_idx 6\ -parent didn't have regs=10 stack=0 marks:\ +mark_precise: frame0: parent state regs=r4 stack=:\ mark_precise: frame0: last_idx 5 first_idx 3\ mark_precise: frame0: regs=r4 stack= before 5\ mark_precise: frame0: regs=r4 stack= before 4\
@@ -188,7 +188,7 @@ force_precise: frame0: forcing r0 to be precise\ force_precise: frame0: forcing r0 to be precise\ mark_precise: frame0: last_idx 6 first_idx 6\ - parent didn't have regs=1 stack=0 marks:\ + mark_precise: frame0: parent state regs=r0 stack=:\ mark_precise: frame0: last_idx 5 first_idx 3\ mark_precise: frame0: regs=r0 stack= before 5", .result = VERBOSE_ACCEPT,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 111/800 bpf: fix propagate_precision() logic for inner frames
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit f655badf2a8fc028433d9583bf86a6b473721f09 ]
Fix propagate_precision() logic to perform propagation of all necessary registers and stack slots across all active frames *in one batch step*.
Doing this for each register/slot in each individual frame is wasteful, but the main problem is that backtracking of instruction in any frame except the deepest one just doesn't work. This is due to backtracking logic relying on jump history, and available jump history always starts (or ends, depending how you view it) in current frame. So, if prog A (frame #0) called subprog B (frame #1) and we need to propagate precision of, say, register R6 (callee-saved) within frame #0, we actually don't even know where jump history that corresponds to prog A even starts. We'd need to skip subprog part of jump history first to be able to do this.
Luckily, with struct backtrack_state and __mark_chain_precision() handling bitmasks tracking/propagation across all active frames at the same time (added in previous patch), propagate_precision() can be both fixed and sped up by setting all the necessary bits across all frames and then performing one __mark_chain_precision() pass. This makes it unnecessary to skip subprog parts of jump history.
We also improve logging along the way, to clearly specify which registers' and slots' precision markings are propagated within which frame. Each frame will have dedicated line and all registers and stack slots from that frame will be reported in format similar to precision backtrack regs/stack logging. E.g.:
frame 1: propagating r1,r2,r3,fp-8,fp-16
frame 0: propagating r3,r9,fp-120
--- kernel/bpf/verifier.c | 65 +++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 30 deletions(-)
kernel/bpf/verifier.c +35 -30
@@ -3684,8 +3684,7 @@ static void mark_all_scalars_imprecise(struct bpf_verifier_env *env, struct bpf_* mark_all_scalars_imprecise() to hopefully get more permissive and generic * finalized states which help in short circuiting more future states. */ -static int __mark_chain_precision (struct bpf_verifier_env *env,int frame,int regno, -int spi) +static int __mark_chain_precision (struct bpf_verifier_env *env,int regno) {struct backtrack_state *bt = &env->bt;struct bpf_verifier_state *st = env->cur_state;
@@ -3700,13 +3699,13 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int frame, int rreturn 0 ;/* set frame number from which we are starting to backtrack */ -bt_init (bt, frame); +bt_init (bt, env->cur_state->curframe);/* Do sanity checks against current state of register and/or stack * slot, but don't set precise flag in current state, as precision * tracking in the current state is unnecessary. */ - func = st->frame[frame]; + func = st->frame[bt->frame];if (regno >=0 ) { reg = &func->regs[regno];if (reg->type !=SCALAR_VALUE ) {
@@ -3716,13 +3715,6 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int frame, int rbt_set_reg (bt, regno); } -while (spi >=0 ) { -if (!is_spilled_scalar_reg (&func->stack[spi])) -break ; -bt_set_slot (bt, spi); -break ; - } -if (bt_empty (bt))return 0 ;
@@ -3872,17 +3864,15 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int frame, int rint mark_chain_precision (struct bpf_verifier_env *env,int regno) { -return __mark_chain_precision (env, env->cur_state->curframe, regno,-1 ); -} - -static int mark_chain_precision_frame (struct bpf_verifier_env *env,int frame,int regno) -{ -return __mark_chain_precision (env, frame, regno,-1 ); +return __mark_chain_precision (env, regno); } -static int mark_chain_precision_stack_frame (struct bpf_verifier_env *env,int frame,int spi) +/* mark_chain_precision_batch() assumes that env->bt is set in the caller to +* desired reg and stack masks across all relevant frames +*/ +static int mark_chain_precision_batch (struct bpf_verifier_env *env) { -return __mark_chain_precision (env, frame,-1 , spi); +return __mark_chain_precision (env,-1 ); }static bool is_spillable_regtype (enum bpf_reg_type type)
@@ -15298,20 +15288,25 @@ static int propagate_precision(struct bpf_verifier_env *env,struct bpf_reg_state *state_reg;struct bpf_func_state *state;int i, err =0 , fr; +bool first;for (fr = old->curframe; fr >=0 ; fr--) { state = old->frame[fr]; state_reg = state->regs; + first = true;for (i =0 ; i <BPF_REG_FP ; i++, state_reg++) {if (state_reg->type !=SCALAR_VALUE || !state_reg->precise || !(state_reg->live ®_LIVE_READ ))continue ; -if (env->log.level &BPF_LOG_LEVEL2 ) -verbose (env,"frame %d: propagating r%d\n" , fr, i); - err =mark_chain_precision_frame (env, fr, i); -if (err <0 ) -return err; +if (env->log.level &BPF_LOG_LEVEL2 ) { +if (first) +verbose (env,"frame %d: propagating r%d" , fr, i); +else +verbose (env,",r%d" , i); + } +bt_set_frame_reg (&env->bt, fr, i); + first = false; }for (i =0 ; i < state->allocated_stack /BPF_REG_SIZE ; i++) {
@@ -15322,14 +15317,24 @@ static int propagate_precision(struct bpf_verifier_env *env, !state_reg->precise || !(state_reg->live & REG_LIVE_READ)) continue; -if (env->log.level &BPF_LOG_LEVEL2 ) -verbose (env,"frame %d: propagating fp%d\n" , - fr, (-i -1 ) *BPF_REG_SIZE ); - err =mark_chain_precision_stack_frame (env, fr, i); -if (err <0 ) -return err; +if (env->log.level &BPF_LOG_LEVEL2 ) { +if (first) +verbose (env,"frame %d: propagating fp%d" , + fr, (-i -1 ) *BPF_REG_SIZE ); +else +verbose (env,",fp%d" , (-i -1 ) *BPF_REG_SIZE ); + } +bt_set_frame_slot (&env->bt, fr, i); + first = false; } +if (!first) +verbose (env,"\n" ); } + + err =mark_chain_precision_batch (env); +if (err <0 ) +return err; +return 0 ; }
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 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 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 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 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
Re: [PATCH 6.4 118/800] net/handshake: Unpin sock->file if a handshake is cancelled
Quoted 52 lines · Greg Kroah-Hartman
From: Chuck Lever <[email protected]>
[ Upstream commit
f921bd41001ccff2249f5f443f2917f7ef937daf]If user space never calls DONE, sock->file's reference count remains elevated. Enable
sock->fileto be freed eventually in this case.Reported-by Jakub Kacinski <[email protected]>Fixes 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")Signed-off-by Chuck Lever <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
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); +
Quoted 8 lines
out_true:trace_handshake_cancel(net, req, sk);Signature · 1 line
2.39.2
Don't take this one. It's fixed by a later commit:
361b6889ae636926cdff517add240c3c8e24593a
that reverts it.
--
Chuck Lever
Greg Kroah-Hartman
maintainerRe: [PATCH 6.4 118/800] net/handshake: Unpin sock->file if a handshake is cancelled
Quoted 63 lines · Chuck Lever III
Quoted 52 lines · Greg Kroah-Hartman
From: Chuck Lever <[email protected]>
[ Upstream commit
f921bd41001ccff2249f5f443f2917f7ef937daf]If user space never calls DONE, sock->file's reference count remains elevated. Enable
sock->fileto be freed eventually in this case.Reported-by Jakub Kacinski <[email protected]>Fixes 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")Signed-off-by Chuck Lever <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
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); +Quoted 8 lines
out_true:trace_handshake_cancel(net, req, sk);Signature · 1 line
2.39.2Don't take this one. It's fixed by a later commit:
Quoted 3 lines
361b6889ae636926cdff517add240c3c8e24593athat reverts it.
How? That commit is in 6.4 already, yet this commit, is from 6.5-rc1.
confused,
greg k-h
Re: [PATCH 6.4 118/800] net/handshake: Unpin sock->file if a handshake is cancelled
Quoted 68 lines · Greg Kroah-Hartman
Quoted 63 lines · Chuck Lever III
Quoted 52 lines · Greg Kroah-Hartman
From: Chuck Lever <[email protected]>
[ Upstream commit
f921bd41001ccff2249f5f443f2917f7ef937daf]If user space never calls DONE, sock->file's reference count remains elevated. Enable
sock->fileto be freed eventually in this case.Reported-by Jakub Kacinski <[email protected]>Fixes 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")Signed-off-by Chuck Lever <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
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); +Quoted 8 lines
out_true:trace_handshake_cancel(net, req, sk);Signature · 1 line
2.39.2Don't take this one. It's fixed by a later commit:
Quoted 5 lines
Quoted 3 lines
361b6889ae636926cdff517add240c3c8e24593athat reverts it.
How? That commit is in 6.4 already, yet this commit, is from 6.5-rc1.
I do not see f921bd41001ccff2249f5f443f2917f7ef937daf in v6.5-rc2. Whatever that is, it's not in upstream.
[cel@manet server-development]$ git log --pretty=oneline v6.5-rc2 -- net/handshake/ 173780ff18a93298ca84224cc79df69f9cc198ce Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net361b6889ae636926cdff517add240c3c8e24593a net/handshake: remove fput() that causes use-after-free 9b66ee06e5ca2698d0ba12a7ad7188cb724279e7 net: ynl: prefix uAPI header include with uapi/ 26fb5480a27d34975cc2b680b77af189620dd740 net/handshake: Enable the SNI extension to work properly 1ce77c998f0415d7d9d91cb9bd7665e25c8f75f1 net/handshake: Unpin sock->file if a handshake is cancelled fc490880e39d86c65ab2bcbd357af1950fa55e48 net/handshake: handshake_genl_notify() shouldn't ignore @flags 7afc6d0a107ffbd448c96eb2458b9e64a5af7860 net/handshake: Fix uninitialized local variable 7ea9c1ec66bc099b0bfba961a8a46dfe25d7d8e4 net/handshake: Fix handshake_dup() ref counting a095326e2c0f33743ce8e887d5b90edf3f36cced net/handshake: Remove unneeded check from handshake_dup() 18c40a1cc1d990c51381ef48cd93fdb31d5cd903 net/handshake: Fix sock->file allocation b21c7ba6d9a5532add3827a3b49f49cbc0cb9779 net/handshake: Squelch allocation warning during Kunit test 6aa445e39693bff9c98b12f960e66b4e18c7378b net/handshake: Fix section mismatch in handshake_exit 88232ec1ec5ecf4aa5de439cff3d5e2b7adcac93 net/handshake: Add Kunit tests for the handshake consumer API 2fd5532044a89d2403b543520b4902e196f7d165 net/handshake: Add a kernel API for requesting a TLSv1.3 handshake 3b3009ea8abb713b022d94fba95ec270cf6e7eae net/handshake: Create a NETLINK service for handling handshake requests [cel@manet server-development]$
But I do see 1ce77c998f0415d7d9d91cb9bd7665e25c8f75f1 and the commit that reverts it, 361b6889ae636926cdff517add240c3c8e24593a.
--
Chuck Lever
Greg Kroah-Hartman
maintainerRe: [PATCH 6.4 118/800] net/handshake: Unpin sock->file if a handshake is cancelled
Quoted 68 lines · Chuck Lever III
Quoted 68 lines · Greg Kroah-Hartman
Quoted 63 lines · Chuck Lever III
Quoted 52 lines · Greg Kroah-Hartman
From: Chuck Lever <[email protected]>
[ Upstream commit
f921bd41001ccff2249f5f443f2917f7ef937daf]If user space never calls DONE, sock->file's reference count remains elevated. Enable
sock->fileto be freed eventually in this case.Reported-by Jakub Kacinski <[email protected]>Fixes 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")Signed-off-by Chuck Lever <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
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); +Quoted 8 lines
out_true:trace_handshake_cancel(net, req, sk);Signature · 1 line
2.39.2Don't take this one. It's fixed by a later commit:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
361b6889ae636926cdff517add240c3c8e24593athat reverts it.
How? That commit is in 6.4 already, yet this commit, is from 6.5-rc1.
I do not see
f921bd41001ccff2249f5f443f2917f7ef937dafin v6.5-rc2. Whatever that is, it's not in upstream.
I see it:
$ git describe --contains f921bd41001ccff2249f5f443f2917f7ef937daf v6.5-rc1~163^2~292^2~1 $ git show --oneline f921bd41001ccff2249f5f443f2917f7ef937daf | head -n 1 f921bd41001c net/handshake: Unpin sock->file if a handshake is cancelled
$ git describe --contains 361b6889ae636926cdff517add240c3c8e24593a v6.4-rc7~17^2~14 $ git show --oneline 361b6889ae636926cdff517add240c3c8e24593a | head -n 1 361b6889ae63 net/handshake: remove fput() that causes use-after-free
So commit 361b6889ae63 ("net/handshake: remove fput() that causes use-after-free") came into 6.4-rc7, and commit f921bd41001c ("net/handshake: Unpin sock->file if a handshake is cancelled") came into 6.5-rc1.
Quoted 18 lines
[cel@manet server-development]$ git log --pretty=oneline v6.5-rc2 --
net/handshake/173780ff18a93298ca84224cc79df69f9cc198ceMergegit://git.kernel.org/pub/scm/linux/kernel/git/netdev/net361b6889ae636926cdff517add240c3c8e24593anet/handshake: removefput()that causes use-after-free9b66ee06e5ca2698d0ba12a7ad7188cb724279e7net: ynl: prefix uAPI header include with uapi/26fb5480a27d34975cc2b680b77af189620dd740net/handshake: Enable the SNI extension to work properly1ce77c998f0415d7d9d91cb9bd7665e25c8f75f1net/handshake: Unpinsock->fileif a handshake is cancelledfc490880e39d86c65ab2bcbd357af1950fa55e48net/handshake:handshake_genl_notify()shouldn't ignore @flags7afc6d0a107ffbd448c96eb2458b9e64a5af7860net/handshake: Fix uninitialized local variable7ea9c1ec66bc099b0bfba961a8a46dfe25d7d8e4net/handshake: Fixhandshake_dup()ref countinga095326e2c0f33743ce8e887d5b90edf3f36ccednet/handshake: Remove unneeded check fromhandshake_dup()18c40a1cc1d990c51381ef48cd93fdb31d5cd903net/handshake: Fixsock->fileallocationb21c7ba6d9a5532add3827a3b49f49cbc0cb9779net/handshake: Squelch allocation warning during Kunit test6aa445e39693bff9c98b12f960e66b4e18c7378bnet/handshake: Fix section mismatch inhandshake_exit88232ec1ec5ecf4aa5de439cff3d5e2b7adcac93net/handshake: Add Kunit tests for the handshake consumer API2fd5532044a89d2403b543520b4902e196f7d165net/handshake: Add a kernel API for requesting a TLSv1.3 handshake3b3009ea8abb713b022d94fba95ec270cf6e7eaenet/handshake: Create a NETLINK service for handling handshake requests [cel@manet server-development]$
Quoted 2 lines
But I do see
1ce77c998f0415d7d9d91cb9bd7665e25c8f75f1and the commit that reverts it,361b6889ae636926cdff517add240c3c8e24593a.
Very strange. As this is confusing, I'll just drop it for now until someone can straighten it out :)
thanks,
greg k-h
Re: [PATCH 6.4 118/800] net/handshake: Unpin sock->file if a handshake is cancelled
Quoted 79 lines · Greg Kroah-Hartman
Quoted 74 lines · Chuck Lever III
Quoted 73 lines · Greg Kroah-Hartman
Quoted 63 lines · Chuck Lever III
Quoted 52 lines · Greg Kroah-Hartman
From: Chuck Lever <[email protected]>
[ Upstream commit
f921bd41001ccff2249f5f443f2917f7ef937daf]If user space never calls DONE, sock->file's reference count remains elevated. Enable
sock->fileto be freed eventually in this case.Reported-by Jakub Kacinski <[email protected]>Fixes 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")Signed-off-by Chuck Lever <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
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); +Quoted 8 lines
out_true:trace_handshake_cancel(net, req, sk);Signature · 1 line
2.39.2Don't take this one. It's fixed by a later commit:
Quoted 3 lines
361b6889ae636926cdff517add240c3c8e24593athat reverts it.
How? That commit is in 6.4 already, yet this commit, is from 6.5-rc1.
Quoted 8 lines
Quoted 2 lines
I do not see
f921bd41001ccff2249f5f443f2917f7ef937dafin v6.5-rc2. Whatever that is, it's not in upstream.I see it:
$ git describe --contains f921bd41001ccff2249f5f443f2917f7ef937daf v6.5-rc1~163^2~292^2~1 $ git show --oneline f921bd41001ccff2249f5f443f2917f7ef937daf | head -n 1 f921bd41001c net/handshake: Unpin sock->file if a handshake is cancelled
Yes, I see it too, it's in the repo. But it's not in the commit history of tag v6.5-rc2, and the source tree, as of v6.5-rc2, does not have that change.
Quoted 9 lines
$ git describe --contains 361b6889ae636926cdff517add240c3c8e24593a v6.4-rc7~17^2~14 $ git show --oneline 361b6889ae636926cdff517add240c3c8e24593a | head -n 1 361b6889ae63 net/handshake: remove fput() that causes use-after-freeSo commit
361b6889ae63("net/handshake: removefput()that causes use-after-free") came into 6.4-rc7, and commitf921bd41001c("net/handshake: Unpinsock->fileif a handshake is cancelled") came into 6.5-rc1.
f921bd41001c isn't in 6.5-rc at all, according to the commit history.
Quoted 18 lines
Quoted 18 lines
[cel@manet server-development]$ git log --pretty=oneline v6.5-rc2 --
net/handshake/173780ff18a93298ca84224cc79df69f9cc198ceMergegit://git.kernel.org/pub/scm/linux/kernel/git/netdev/net361b6889ae636926cdff517add240c3c8e24593anet/handshake: removefput()that causes use-after-free9b66ee06e5ca2698d0ba12a7ad7188cb724279e7net: ynl: prefix uAPI header include with uapi/26fb5480a27d34975cc2b680b77af189620dd740net/handshake: Enable the SNI extension to work properly1ce77c998f0415d7d9d91cb9bd7665e25c8f75f1net/handshake: Unpinsock->fileif a handshake is cancelledfc490880e39d86c65ab2bcbd357af1950fa55e48net/handshake:handshake_genl_notify()shouldn't ignore @flags7afc6d0a107ffbd448c96eb2458b9e64a5af7860net/handshake: Fix uninitialized local variable7ea9c1ec66bc099b0bfba961a8a46dfe25d7d8e4net/handshake: Fixhandshake_dup()ref countinga095326e2c0f33743ce8e887d5b90edf3f36ccednet/handshake: Remove unneeded check fromhandshake_dup()18c40a1cc1d990c51381ef48cd93fdb31d5cd903net/handshake: Fixsock->fileallocationb21c7ba6d9a5532add3827a3b49f49cbc0cb9779net/handshake: Squelch allocation warning during Kunit test6aa445e39693bff9c98b12f960e66b4e18c7378bnet/handshake: Fix section mismatch inhandshake_exit88232ec1ec5ecf4aa5de439cff3d5e2b7adcac93net/handshake: Add Kunit tests for the handshake consumer API2fd5532044a89d2403b543520b4902e196f7d165net/handshake: Add a kernel API for requesting a TLSv1.3 handshake3b3009ea8abb713b022d94fba95ec270cf6e7eaenet/handshake: Create a NETLINK service for handling handshake requests [cel@manet server-development]$
Quoted 5 lines
Quoted 2 lines
But I do see
1ce77c998f0415d7d9d91cb9bd7665e25c8f75f1and the commit that reverts it,361b6889ae636926cdff517add240c3c8e24593a.Very strange. As this is confusing, I'll just drop it for now until someone can straighten it out :)
Thanks for dropping!
--
Chuck Lever
Greg Kroah-Hartman
maintainerRe: [PATCH 6.4 118/800] net/handshake: Unpin sock->file if a handshake is cancelled
Quoted 98 lines · Chuck Lever III
Quoted 79 lines · Greg Kroah-Hartman
Quoted 74 lines · Chuck Lever III
Quoted 73 lines · Greg Kroah-Hartman
Quoted 63 lines · Chuck Lever III
Quoted 52 lines · Greg Kroah-Hartman
From: Chuck Lever <[email protected]>
[ Upstream commit
f921bd41001ccff2249f5f443f2917f7ef937daf]If user space never calls DONE, sock->file's reference count remains elevated. Enable
sock->fileto be freed eventually in this case.Reported-by Jakub Kacinski <[email protected]>Fixes 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")Signed-off-by Chuck Lever <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
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); +Quoted 8 lines
out_true:trace_handshake_cancel(net, req, sk);Signature · 1 line
2.39.2Don't take this one. It's fixed by a later commit:
Quoted 3 lines
361b6889ae636926cdff517add240c3c8e24593athat reverts it.
How? That commit is in 6.4 already, yet this commit, is from 6.5-rc1.
Quoted 8 lines
Quoted 2 lines
I do not see
f921bd41001ccff2249f5f443f2917f7ef937dafin v6.5-rc2. Whatever that is, it's not in upstream.I see it:
$ git describe --contains f921bd41001ccff2249f5f443f2917f7ef937daf v6.5-rc1~163^2~292^2~1 $ git show --oneline f921bd41001ccff2249f5f443f2917f7ef937daf | head -n 1 f921bd41001c net/handshake: Unpin sock->file if a handshake is cancelledYes, I see it too, it's in the repo. But it's not in the commit history of tag v6.5-rc2, and the source tree, as of v6.5-rc2, does not have that change.
Quoted 5 lines
$ git describe --contains 361b6889ae636926cdff517add240c3c8e24593a v6.4-rc7~17^2~14 $ git show --oneline 361b6889ae636926cdff517add240c3c8e24593a | head -n 1 361b6889ae63 net/handshake: remove fput() that causes use-after-free
Quoted 9 lines
Quoted 4 lines
So commit
361b6889ae63("net/handshake: removefput()that causes use-after-free") came into 6.4-rc7, and commitf921bd41001c("net/handshake: Unpinsock->fileif a handshake is cancelled") came into 6.5-rc1.
f921bd41001cisn't in 6.5-rc at all, according to the commit history.Quoted 1 line
Quoted 1 line
[cel@manet server-development]$ git log --pretty=oneline v6.5-rc2 --
net/handshake/
I think the issue is that you are comparing it to the current state of net/handshake, if you look overall at the log, you will see it:
$ git log --pretty=oneline v6.5-rc2 | grep f921bd41001ccff2249f5f443f2917f7ef937daf f921bd41001ccff2249f5f443f2917f7ef937daf net/handshake: Unpin sock->file if a handshake is cancelled
Or just a normal "git log" will also show it.
There is a way to say "ignore the current state of the directory I'm asking for the log for, and just give me all the commits that touched it" but I can't ever remember the option to git log for it.
Ah, it's the --full-history option:
$ git log --pretty=oneline --full-history v6.5-rc2 -- net/handshake/ | grep f921bd41001ccff2249f5f443f2917f7ef937daf f921bd41001ccff2249f5f443f2917f7ef937daf net/handshake: Unpin sock->file if a handshake is cancelled
So yes, it's really there. Read the "History Simplification" section in the git log manpage for all the details as to why it didn't show up in your command. And one day I'll actually remember that option...
thanks,
greg k-h
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 206/800 bonding: do not assume skb mac_header is set
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6a940abdef3162e5723f1495b8a49859d1708f79 ]
Drivers must not assume in their ndo_start_xmit() that skbs have their mac_header set. skb->data is all what is needed.
bonding seems to be one of the last offender as caught by syzbot:
WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 skb_mac_offset include/linux/skbuff.h:2913 [inline] WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_xmit_hash drivers/net/bonding/bond_main.c:4170 [inline] WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_xmit_3ad_xor_slave_get drivers/net/bonding/bond_main.c:5149 [inline] WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_3ad_xor_xmit drivers/net/bonding/bond_main.c:5186 [inline] WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 __bond_start_xmit drivers/net/bonding/bond_main.c:5442 [inline] WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_start_xmit+0x14ab/0x19d0 drivers/net/bonding/bond_main.c:5470 Modules linked in: CPU: 1 PID: 12155 Comm: syz-executor.3 Not tainted 6.1.30-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023 RIP: 0010:skb_mac_header include/linux/skbuff.h:2907 [inline] RIP: 0010:skb_mac_offset include/linux/skbuff.h:2913 [inline] RIP: 0010:bond_xmit_hash drivers/net/bonding/bond_main.c:4170 [inline] RIP: 0010:bond_xmit_3ad_xor_slave_get drivers/net/bonding/bond_main.c:5149 [inline] RIP: 0010:bond_3ad_xor_xmit drivers/net/bonding/bond_main.c:5186 [inline] RIP: 0010:__bond_start_xmit drivers/net/bonding/bond_main.c:5442 [inline] RIP: 0010:bond_start_xmit+0x14ab/0x19d0 drivers/net/bonding/bond_main.c:5470 Code: 8b 7c 24 30 e8 76 dd 1a 01 48 85 c0 74 0d 48 89 c3 e8 29 67 2e fe e9 15 ef ff ff e8 1f 67 2e fe e9 10 ef ff ff e8 15 67 2e fe <0f> 0b e9 45 f8 ff ff e8 09 67 2e fe e9 dc fa ff ff e8 ff 66 2e fe RSP: 0018:ffffc90002fff6e0 EFLAGS: 00010283 RAX: ffffffff835874db RBX: 000000000000ffff RCX: 0000000000040000 RDX: ffffc90004dcf000 RSI: 00000000000000b5 RDI: 00000000000000b6 RBP: ffffc90002fff8b8 R08: ffffffff83586d16 R09: ffffffff83586584 R10: 0000000000000007 R11: ffff8881599fc780 R12: ffff88811b6a7b7e R13: 1ffff110236d4f6f R14: ffff88811b6a7ac0 R15: 1ffff110236d4f76 FS: 00007f2e9eb47700(0000) GS:ffff8881f6b00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b2e421000 CR3: 000000010e6d4000 CR4: 00000000003526e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> [<ffffffff8471a49f>] netdev_start_xmit include/linux/netdevice.h:4925 [inline] [<ffffffff8471a49f>] __dev_direct_xmit+0x4ef/0x850 net/core/dev.c:4380 [<ffffffff851d845b>] dev_direct_xmit include/linux/netdevice.h:3043 [inline] [<ffffffff851d845b>] packet_direct_xmit+0x18b/0x300 net/packet/af_packet.c:284 [<ffffffff851c7472>] packet_snd net/packet/af_packet.c:3112 [inline] [<ffffffff851c7472>] packet_sendmsg+0x4a22/0x64d0 net/packet/af_packet.c:3143 [<ffffffff8467a4b2>] sock_sendmsg_nosec net/socket.c:716 [inline] [<ffffffff8467a4b2>] sock_sendmsg net/socket.c:736 [inline] [<ffffffff8467a4b2>] __sys_sendto+0x472/0x5f0 net/socket.c:2139 [<ffffffff8467a715>] __do_sys_sendto net/socket.c:2151 [inline] [<ffffffff8467a715>] __se_sys_sendto net/socket.c:2147 [inline] [<ffffffff8467a715>] __x64_sys_sendto+0xe5/0x100 net/socket.c:2147 [<ffffffff8553071f>] do_syscall_x64 arch/x86/entry/common.c:50 [inline] [<ffffffff8553071f>] do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80 [<ffffffff85600087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
--- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
@@ -4197,7 +4197,7 @@ u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb)return skb->hash;return __bond_xmit_hash (bond, skb, skb->data, skb->protocol, -skb_mac_offset (skb),skb_network_offset (skb), +0 ,skb_network_offset (skb),skb_headlen (skb)); }
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 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 209/800 gtp: Fix use-after-free in __gtp_encap_destroy().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit ce3aee7114c575fab32a5e9e939d4bbb3dcca79f ]
syzkaller reported use-after-free in __gtp_encap_destroy(). [0]
It shows the same process freed sk and touched it illegally.
Commit e198987e7dd7 ("gtp: fix suspicious RCU usage") added lock_sock() and release_sock() in __gtp_encap_destroy() to protect sk->sk_user_data, but release_sock() is called after sock_put() releases the last refcnt.
[0]:
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline] BUG: KASAN: slab-use-after-free in atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline] BUG: KASAN: slab-use-after-free in queued_spin_lock include/asm-generic/qspinlock.h:111 [inline] BUG: KASAN: slab-use-after-free in do_raw_spin_lock include/linux/spinlock.h:186 [inline] BUG: KASAN: slab-use-after-free in __raw_spin_lock_bh include/linux/spinlock_api_smp.h:127 [inline] BUG: KASAN: slab-use-after-free in _raw_spin_lock_bh+0x75/0xe0 kernel/locking/spinlock.c:178 Write of size 4 at addr ffff88800dbef398 by task syz-executor.2/2401 CPU: 1 PID: 2401 Comm: syz-executor.2 Not tainted 6.4.0-rc5-01219-gfa0e21fa4443 #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x72/0xa0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:351 [inline] print_report+0xcc/0x620 mm/kasan/report.c:462 kasan_report+0xb2/0xe0 mm/kasan/report.c:572 check_region_inline mm/kasan/generic.c:181 [inline] kasan_check_range+0x39/0x1c0 mm/kasan/generic.c:187 instrument_atomic_read_write include/linux/instrumented.h:96 [inline] atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline] queued_spin_lock include/asm-generic/qspinlock.h:111 [inline] do_raw_spin_lock include/linux/spinlock.h:186 [inline] __raw_spin_lock_bh include/linux/spinlock_api_smp.h:127 [inline] _raw_spin_lock_bh+0x75/0xe0 kernel/locking/spinlock.c:178 spin_lock_bh include/linux/spinlock.h:355 [inline] release_sock+0x1f/0x1a0 net/core/sock.c:3526 gtp_encap_disable_sock drivers/net/gtp.c:651 [inline] gtp_encap_disable+0xb9/0x220 drivers/net/gtp.c:664 gtp_dev_uninit+0x19/0x50 drivers/net/gtp.c:728 unregister_netdevice_many_notify+0x97e/0x1520 net/core/dev.c:10841 rtnl_delete_link net/core/rtnetlink.c:3216 [inline] rtnl_dellink+0x3c0/0xb30 net/core/rtnetlink.c:3268 rtnetlink_rcv_msg+0x450/0xb10 net/core/rtnetlink.c:6423 netlink_rcv_skb+0x15d/0x450 net/netlink/af_netlink.c:2548 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] netlink_unicast+0x700/0x930 net/netlink/af_netlink.c:1365 netlink_sendmsg+0x91c/0xe30 net/netlink/af_netlink.c:1913 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg+0x1b7/0x200 net/socket.c:747 ____sys_sendmsg+0x75a/0x990 net/socket.c:2493 ___sys_sendmsg+0x11d/0x1c0 net/socket.c:2547 __sys_sendmsg+0xfe/0x1d0 net/socket.c:2576 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc RIP: 0033:0x7f1168b1fe5d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 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 8b 0d 73 9f 1b 00 f7 d8 64 89 01 48 RSP: 002b:00007f1167edccc8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00000000004bbf80 RCX: 00007f1168b1fe5d RDX: 0000000000000000 RSI: 00000000200002c0 RDI: 0000000000000003 RBP: 00000000004bbf80 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000000b R14: 00007f1168b80530 R15: 0000000000000000 </TASK> Allocated by task 1483: kasan_save_stack+0x22/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 __kasan_slab_alloc+0x59/0x70 mm/kasan/common.c:328 kasan_slab_alloc include/linux/kasan.h:186 [inline] slab_post_alloc_hook mm/slab.h:711 [inline] slab_alloc_node mm/slub.c:3451 [inline] slab_alloc mm/slub.c:3459 [inline] __kmem_cache_alloc_lru mm/slub.c:3466 [inline] kmem_cache_alloc+0x16d/0x340 mm/slub.c:3475 sk_prot_alloc+0x5f/0x280 net/core/sock.c:2073 sk_alloc+0x34/0x6c0 net/core/sock.c:2132 inet6_create net/ipv6/af_inet6.c:192 [inline] inet6_create+0x2c7/0xf20 net/ipv6/af_inet6.c:119 __sock_create+0x2a1/0x530 net/socket.c:1535 sock_create net/socket.c:1586 [inline] __sys_socket_create net/socket.c:1623 [inline] __sys_socket_create net/socket.c:1608 [inline] __sys_socket+0x137/0x250 net/socket.c:1651 __do_sys_socket net/socket.c:1664 [inline] __se_sys_socket net/socket.c:1662 [inline] __x64_sys_socket+0x72/0xb0 net/socket.c:1662 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc Freed by task 2401: kasan_save_stack+0x22/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2e/0x50 mm/kasan/generic.c:521 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free mm/kasan/common.c:200 [inline] __kasan_slab_free+0x10c/0x1b0 mm/kasan/common.c:244 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook mm/slub.c:1807 [inline] slab_free mm/slub.c:3786 [inline] kmem_cache_free+0xb4/0x490 mm/slub.c:3808 sk_prot_free net/core/sock.c:2113 [inline] __sk_destruct+0x500/0x720 net/core/sock.c:2207 sk_destruct+0xc1/0xe0 net/core/sock.c:2222 __sk_free+0xed/0x3d0 net/core/sock.c:2233 sk_free+0x7c/0xa0 net/core/sock.c:2244 sock_put include/net/sock.h:1981 [inline] __gtp_encap_destroy+0x165/0x1b0 drivers/net/gtp.c:634 gtp_encap_disable_sock drivers/net/gtp.c:651 [inline] gtp_encap_disable+0xb9/0x220 drivers/net/gtp.c:664 gtp_dev_uninit+0x19/0x50 drivers/net/gtp.c:728 unregister_netdevice_many_notify+0x97e/0x1520 net/core/dev.c:10841 rtnl_delete_link net/core/rtnetlink.c:3216 [inline] rtnl_dellink+0x3c0/0xb30 net/core/rtnetlink.c:3268 rtnetlink_rcv_msg+0x450/0xb10 net/core/rtnetlink.c:6423 netlink_rcv_skb+0x15d/0x450 net/netlink/af_netlink.c:2548 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] netlink_unicast+0x700/0x930 net/netlink/af_netlink.c:1365 netlink_sendmsg+0x91c/0xe30 net/netlink/af_netlink.c:1913 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg+0x1b7/0x200 net/socket.c:747 ____sys_sendmsg+0x75a/0x990 net/socket.c:2493 ___sys_sendmsg+0x11d/0x1c0 net/socket.c:2547 __sys_sendmsg+0xfe/0x1d0 net/socket.c:2576 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc The buggy address belongs to the object at ffff88800dbef300 which belongs to the cache UDPv6 of size 1344
The buggy address is located 152 bytes inside of
freed 1344-byte region [ffff88800dbef300, ffff88800dbef840)
The buggy address belongs to the physical page:
page:00000000d31bfed5 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88800dbeed40 pfn:0xdbe8 head:00000000d31bfed5 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 memcg:ffff888008ee0801
flags: 0x100000000010200(slab|head|node=0|zone=1)page_type: 0xffffffff()
raw: 0100000000010200 ffff88800c7a3000 dead000000000122 0000000000000000
raw: ffff88800dbeed40 0000000080160015 00000001ffffffff ffff888008ee0801
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88800dbef280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800dbef300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88800dbef380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88800dbef400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800dbef480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- drivers/net/gtp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/gtp.c +2 -0
@@ -631,7 +631,9 @@ static void __gtp_encap_destroy(struct sock *sk) gtp->sk1u =NULL ;udp_sk (sk)->encap_type =0 ;rcu_assign_sk_user_data (sk,NULL ); +release_sock (sk);sock_put (sk); +return ; }release_sock (sk); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 210/800 net: axienet: Move reset before 64-bit DMA detection
In reply to Greg Kroah-HartmanFrom: Maxim Kochetkov <[email protected]>
[ Upstream commit f1bc9fc4a06de0108e0dca2a9a7e99ba1fc632f9 ]
64-bit DMA detection will fail if axienet was started before (by boot loader, boot ROM, etc). In this state axienet will not start properly. XAXIDMA_TX_CDESC_OFFSET + 4 register (MM2S_CURDESC_MSB) is used to detect 64-bit DMA capability here. But datasheet says: When DMACR.RS is 1 (axienet is in enabled state), CURDESC_PTR becomes Read Only (RO) and is used to fetch the first descriptor. So iowrite32()/ioread32() trick to this register to detect 64-bit DMA will not work.
So move axienet reset before 64-bit DMA detection.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5 -5
@@ -2042,6 +2042,11 @@ static int axienet_probe(struct platform_device *pdev) goto cleanup_clk; } +/* Reset core now that clocks are enabled, prior to accessing MDIO */ + ret =__axienet_device_reset (lp); +if (ret) + goto cleanup_clk; +/* Autodetect the need for 64-bit DMA pointers. * When the IP is configured for a bus width bigger than 32 bits, * writing the MSB registers is mandatory, even if they are all 0.
@@ -2096,11 +2101,6 @@ static int axienet_probe(struct platform_device *pdev) lp->coalesce_count_tx =XAXIDMA_DFT_TX_THRESHOLD ; lp->coalesce_usec_tx =XAXIDMA_DFT_TX_USEC ; -/* Reset core now that clocks are enabled, prior to accessing MDIO */ - ret =__axienet_device_reset (lp); -if (ret) - goto cleanup_clk; - ret =axienet_mdio_setup (lp);if (ret) dev_warn(&pdev->dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 211/800 ocfs2: Fix use of slab data with sendpage
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 86d7bd6e66e9925f0f04a7bcf3c92c05fdfefb5a ]
ocfs2 uses kzalloc() to allocate buffers for o2net_hand, o2net_keep_req and o2net_keep_resp and then passes these to sendpage. This isn't really allowed as the lifetime of slab objects is not controlled by page ref - though in this case it will probably work. sendmsg() with MSG_SPLICE_PAGES will, however, print a warning and give an error.
Fix it to use folio_alloc() instead to allocate a buffer for the handshake message, keepalive request and reply messages.
--- fs/ocfs2/cluster/tcp.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
fs/ocfs2/cluster/tcp.c +12 -11
@@ -2087,18 +2087,24 @@ void o2net_stop_listening(struct o2nm_node *node)int o2net_init (void ) { +struct folio *folio; +void *p;unsigned long i;o2quo_init (); -o2net_debugfs_init (); - o2net_hand =kzalloc (sizeof (struct o2net_handshake ),GFP_KERNEL ); - o2net_keep_req =kzalloc (sizeof (struct o2net_msg ),GFP_KERNEL ); - o2net_keep_resp =kzalloc (sizeof (struct o2net_msg ),GFP_KERNEL ); -if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) + folio =folio_alloc (GFP_KERNEL | __GFP_ZERO,0 ); +if (!folio) goto out; + p =folio_address (folio); + o2net_hand = p; + p +=sizeof (struct o2net_handshake ); + o2net_keep_req = p; + p +=sizeof (struct o2net_msg ); + o2net_keep_resp = p; + o2net_hand->protocol_version =cpu_to_be64 (O2NET_PROTOCOL_VERSION ); o2net_hand->connector_id =cpu_to_be64 (1 );
@@ -2124,9 +2130,6 @@ int o2net_init(void)return 0 ; out: -kfree (o2net_hand); -kfree (o2net_keep_req); -kfree (o2net_keep_resp);o2net_debugfs_exit ();o2quo_exit ();return -ENOMEM ;
@@ -2135,8 +2138,6 @@ int o2net_init(void)void o2net_exit (void ) {o2quo_exit (); -kfree (o2net_hand); -kfree (o2net_keep_req); -kfree (o2net_keep_resp);o2net_debugfs_exit (); +folio_put (virt_to_folio (o2net_hand)); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 212/800 sfc: fix crash when reading stats while NIC is resetting
In reply to Greg Kroah-HartmanFrom: Edward Cree <[email protected]>
[ Upstream commit d1b355438b8325a486f087e506d412c4e852f37b ]
efx_net_stats() (.ndo_get_stats64) can be called during an ethtool
selftest, during which time nic_data->mc_stats is NULL as the NIC has been fini'd. In this case do not attempt to fetch the latest stats from the hardware, else we will crash on a NULL dereference:
BUG: kernel NULL pointer dereference, address: 0000000000000038
RIP efx_nic_update_stats
abridged calltrace:
efx_ef10_update_stats_pf
efx_net_stats
dev_get_stats
dev_seq_printf_statsSkipping the read is safe, we will simply give out stale stats. To ensure that the free in efx_ef10_fini_nic() does not race against
efx_ef10_update_stats_pf(), which could cause a TOCTTOU bug, take the efx->stats_lock in fini_nic (it is already held across update_stats).
--- drivers/net/ethernet/sfc/ef10.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/sfc/ef10.c +10 -3
@@ -1297,8 +1297,10 @@ static void efx_ef10_fini_nic(struct efx_nic *efx) {struct efx_ef10_nic_data *nic_data = efx->nic_data; +spin_lock_bh (&efx->stats_lock);kfree (nic_data->mc_stats); nic_data->mc_stats =NULL ; +spin_unlock_bh (&efx->stats_lock); }static int efx_ef10_init_nic (struct efx_nic *efx)
@@ -1852,9 +1854,14 @@ static size_t efx_ef10_update_stats_pf(struct efx_nic *efx, u64 *full_stats,efx_ef10_get_stat_mask (efx, mask); -efx_nic_copy_stats (efx, nic_data->mc_stats); -efx_nic_update_stats (efx_ef10_stat_desc,EF10_STAT_COUNT , - mask, stats, nic_data->mc_stats, false); +/* If NIC was fini'd (probably resetting), then we can't read +* updated stats right now. +*/ +if (nic_data->mc_stats) { +efx_nic_copy_stats (efx, nic_data->mc_stats); +efx_nic_update_stats (efx_ef10_stat_desc,EF10_STAT_COUNT , + mask, stats, nic_data->mc_stats, false); + }/* Update derived statistics */ efx_nic_fix_nodesc_drop_stat(efx,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 213/800 net: nfc: Fix use-after-free caused by nfc_llcp_find_local
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
[ Upstream commit 6709d4b7bc2e079241fdef15d1160581c5261c10 ]
This commit fixes several use-after-free that caused by function nfc_llcp_find_local(). For example, one UAF can happen when below buggy time window occurs.
// nfc_genl_llc_get_params | // nfc_unregister_device
|
dev = nfc_get_device(idx); | device_lock(...)
if (!dev) | dev->shutting_down = true;
return -ENODEV; | device_unlock(...);
|
device_lock(...); | // nfc_llcp_unregister_device
| nfc_llcp_find_local()
nfc_llcp_find_local(...); |
| local_cleanup()
if (!local) { |
rc = -ENODEV; | // nfc_llcp_local_put
goto exit; | kref_put(.., local_release)
} |
| // local_release
| list_del(&local->list)
// nfc_genl_send_params | kfree()
local->dev->idx !!!UAF!!! |
|and the crash trace for the one of the discussed UAF like:
BUG: KASAN: slab-use-after-free in nfc_genl_llc_get_params+0x72f/0x780 net/nfc/netlink.c:1045 Read of size 8 at addr ffff888105b0e410 by task 20114 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x72/0xa0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:319 [inline] print_report+0xcc/0x620 mm/kasan/report.c:430 kasan_report+0xb2/0xe0 mm/kasan/report.c:536 nfc_genl_send_params net/nfc/netlink.c:999 [inline] nfc_genl_llc_get_params+0x72f/0x780 net/nfc/netlink.c:1045 genl_family_rcv_msg_doit.isra.0+0x1ee/0x2e0 net/netlink/genetlink.c:968 genl_family_rcv_msg net/netlink/genetlink.c:1048 [inline] genl_rcv_msg+0x503/0x7d0 net/netlink/genetlink.c:1065 netlink_rcv_skb+0x161/0x430 net/netlink/af_netlink.c:2548 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1076 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] netlink_unicast+0x644/0x900 net/netlink/af_netlink.c:1365 netlink_sendmsg+0x934/0xe70 net/netlink/af_netlink.c:1913 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg+0x1b6/0x200 net/socket.c:747 ____sys_sendmsg+0x6e9/0x890 net/socket.c:2501 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2555 __sys_sendmsg+0xf7/0x1d0 net/socket.c:2584 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc RIP: 0033:0x7f34640a2389 RSP: 002b:00007f3463415168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f34641c1f80 RCX: 00007f34640a2389 RDX: 0000000000000000 RSI: 0000000020000240 RDI: 0000000000000006 RBP: 00007f34640ed493 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffe38449ecf R14: 00007f3463415300 R15: 0000000000022000 </TASK> Allocated by task 20116: kasan_save_stack+0x22/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x7f/0x90 mm/kasan/common.c:383 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [inline] nfc_llcp_register_device+0x49/0xa40 net/nfc/llcp_core.c:1567 nfc_register_device+0x61/0x260 net/nfc/core.c:1124 nci_register_device+0x776/0xb20 net/nfc/nci/core.c:1257 virtual_ncidev_open+0x147/0x230 drivers/nfc/virtual_ncidev.c:148 misc_open+0x379/0x4a0 drivers/char/misc.c:165 chrdev_open+0x26c/0x780 fs/char_dev.c:414 do_dentry_open+0x6c4/0x12a0 fs/open.c:920 do_open fs/namei.c:3560 [inline] path_openat+0x24fe/0x37e0 fs/namei.c:3715 do_filp_open+0x1ba/0x410 fs/namei.c:3742 do_sys_openat2+0x171/0x4c0 fs/open.c:1356 do_sys_open fs/open.c:1372 [inline] __do_sys_openat fs/open.c:1388 [inline] __se_sys_openat fs/open.c:1383 [inline] __x64_sys_openat+0x143/0x200 fs/open.c:1383 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc Freed by task 20115: kasan_save_stack+0x22/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2e/0x50 mm/kasan/generic.c:521 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free mm/kasan/common.c:200 [inline] __kasan_slab_free+0x10a/0x190 mm/kasan/common.c:244 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook mm/slub.c:1807 [inline] slab_free mm/slub.c:3787 [inline] __kmem_cache_free+0x7a/0x190 mm/slub.c:3800 local_release net/nfc/llcp_core.c:174 [inline] kref_put include/linux/kref.h:65 [inline] nfc_llcp_local_put net/nfc/llcp_core.c:182 [inline] nfc_llcp_local_put net/nfc/llcp_core.c:177 [inline] nfc_llcp_unregister_device+0x206/0x290 net/nfc/llcp_core.c:1620 nfc_unregister_device+0x160/0x1d0 net/nfc/core.c:1179 virtual_ncidev_close+0x52/0xa0 drivers/nfc/virtual_ncidev.c:163 __fput+0x252/0xa20 fs/file_table.c:321 task_work_run+0x174/0x270 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x108/0x110 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x21/0x50 kernel/entry/common.c:297 do_syscall_64+0x4c/0x90 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x72/0xdc Last potentially related work creation: kasan_save_stack+0x22/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0x95/0xb0 mm/kasan/generic.c:491 kvfree_call_rcu+0x29/0xa80 kernel/rcu/tree.c:3328 drop_sysctl_table+0x3be/0x4e0 fs/proc/proc_sysctl.c:1735 unregister_sysctl_table.part.0+0x9c/0x190 fs/proc/proc_sysctl.c:1773 unregister_sysctl_table+0x24/0x30 fs/proc/proc_sysctl.c:1753 neigh_sysctl_unregister+0x5f/0x80 net/core/neighbour.c:3895 addrconf_notify+0x140/0x17b0 net/ipv6/addrconf.c:3684 notifier_call_chain+0xbe/0x210 kernel/notifier.c:87 call_netdevice_notifiers_info+0xb5/0x150 net/core/dev.c:1937 call_netdevice_notifiers_extack net/core/dev.c:1975 [inline] call_netdevice_notifiers net/core/dev.c:1989 [inline] dev_change_name+0x3c3/0x870 net/core/dev.c:1211 dev_ifsioc+0x800/0xf70 net/core/dev_ioctl.c:376 dev_ioctl+0x3d9/0xf80 net/core/dev_ioctl.c:542 sock_do_ioctl+0x160/0x260 net/socket.c:1213 sock_ioctl+0x3f9/0x670 net/socket.c:1316 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x19e/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc The buggy address belongs to the object at ffff888105b0e400 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 16 bytes inside of
freed 1024-byte region [ffff888105b0e400, ffff888105b0e800)
The buggy address belongs to the physical page:
head:ffffea000416c200 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000010200(slab|head|node=0|zone=2)
raw: 0200000000010200 ffff8881000430c0 ffffea00044c7010 ffffea0004510e10
raw: 0000000000000000 00000000000a000a 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888105b0e300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888105b0e380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888105b0e400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888105b0e480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888105b0e500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fbIn summary, this patch solves those use-after-free by
1. Re-implement the nfc_llcp_find_local(). The current version does not grab the reference when getting the local from the linked list. For example, the llcp_sock_bind() gets the reference like below:
// llcp_sock_bind()
local = nfc_llcp_find_local(dev); // A
..... \
| raceable
..... /
llcp_sock->local = nfc_llcp_local_get(local); // BThere is an apparent race window that one can drop the reference and free the local object fetched in (A) before (B) gets the reference.
2. Some callers of the nfc_llcp_find_local() do not grab the reference at all. For example, the nfc_genl_llc_{{get/set}_params/sdreq} functions. We add the nfc_llcp_local_put() for them. Moreover, we add the necessary error handling function to put the reference.
3. Add the nfc_llcp_remove_local() helper. The local object is removed from the linked list in local_release() when all reference is gone. This patch removes it when nfc_llcp_unregister_device() is called.
Therefore, every caller of nfc_llcp_find_local() will get a reference even when the nfc_llcp_unregister_device() is called. This promises no use-after-free for the local object is ever possible.
--- net/nfc/llcp.h | 1 - net/nfc/llcp_commands.c | 12 +++++++--- net/nfc/llcp_core.c | 49 +++++++++++++++++++++++++++++++++++------ net/nfc/llcp_sock.c | 18 ++++++++------- net/nfc/netlink.c | 20 ++++++++++++----- net/nfc/nfc.h | 1 + 6 files changed, 77 insertions(+), 24 deletions(-)
net/nfc/llcp.h +0 -1
@@ -201,7 +201,6 @@ void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *s);void nfc_llcp_sock_unlink (struct llcp_sock_list *l,struct sock *s);void nfc_llcp_socket_remote_param_init (struct nfc_llcp_sock *sock);struct nfc_llcp_local *nfc_llcp_find_local (struct nfc_dev *dev); -struct nfc_llcp_local *nfc_llcp_local_get (struct nfc_llcp_local *local);int nfc_llcp_local_put (struct nfc_llcp_local *local);u8 nfc_llcp_get_sdp_ssap (struct nfc_llcp_local *local,struct nfc_llcp_sock *sock);
net/nfc/llcp_commands.c +9 -3
@@ -359,6 +359,7 @@ int nfc_llcp_send_symm(struct nfc_dev *dev)struct sk_buff *skb;struct nfc_llcp_local *local;u16 size =0 ; +int err; local =nfc_llcp_find_local (dev);if (local ==NULL )
@@ -368,8 +369,10 @@ int nfc_llcp_send_symm(struct nfc_dev *dev) size += dev->tx_headroom + dev->tx_tailroom +NFC_HEADER_SIZE ; skb =alloc_skb (size,GFP_KERNEL ); -if (skb ==NULL ) -return -ENOMEM ; +if (skb ==NULL ) { + err = -ENOMEM ; + goto out; + }skb_reserve (skb, dev->tx_headroom +NFC_HEADER_SIZE );
@@ -379,8 +382,11 @@ int nfc_llcp_send_symm(struct nfc_dev *dev)nfc_llcp_send_to_raw_sock (local, skb,NFC_DIRECTION_TX ); -return nfc_data_exchange (dev, local->target_idx, skb, + err =nfc_data_exchange (dev, local->target_idx, skb, nfc_llcp_recv, local); +out: +nfc_llcp_local_put (local); +return err; }int nfc_llcp_send_connect (struct nfc_llcp_sock *sock)
net/nfc/llcp_core.c +42 -7
123 lines not on this page · raw message
net/nfc/llcp_sock.c +10 -8
@@ -99,7 +99,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) } llcp_sock->dev = dev; - llcp_sock->local =nfc_llcp_local_get (local); + llcp_sock->local = local; llcp_sock->nfc_protocol = llcp_addr.nfc_protocol; llcp_sock->service_name_len = min_t(unsigned int, llcp_addr.service_name_len,
@@ -186,7 +186,7 @@ static int llcp_raw_sock_bind(struct socket *sock, struct sockaddr *addr, } llcp_sock->dev = dev; - llcp_sock->local =nfc_llcp_local_get (local); + llcp_sock->local = local; llcp_sock->nfc_protocol = llcp_addr.nfc_protocol;nfc_llcp_sock_link (&local->raw_sockets, sk);
@@ -696,22 +696,22 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,if (dev->dep_link_up == false) { ret = -ENOLINK ;device_unlock (&dev->dev); - goto put_dev; + goto sock_llcp_put_local; }device_unlock (&dev->dev);if (local->rf_mode ==NFC_RF_INITIATOR && addr->target_idx != local->target_idx) { ret = -ENOLINK ; - goto put_dev; + goto sock_llcp_put_local; } llcp_sock->dev = dev; - llcp_sock->local =nfc_llcp_local_get (local); + llcp_sock->local = local; llcp_sock->ssap =nfc_llcp_get_local_ssap (local);if (llcp_sock->ssap ==LLCP_SAP_MAX ) { ret = -ENOMEM ; - goto sock_llcp_put_local; + goto sock_llcp_nullify; } llcp_sock->reserved_ssap = llcp_sock->ssap;
@@ -757,11 +757,13 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, sock_llcp_release:nfc_llcp_put_ssap (local, llcp_sock->ssap); -sock_llcp_put_local: -nfc_llcp_local_put (llcp_sock->local); +sock_llcp_nullify: llcp_sock->local =NULL ; llcp_sock->dev =NULL ; +sock_llcp_put_local: +nfc_llcp_local_put (local); + put_dev:nfc_put_device (dev);
net/nfc/netlink.c +15 -5
@@ -1039,11 +1039,14 @@ static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info) msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg) { rc = -ENOMEM ; - goto exit; + goto put_local; } rc =nfc_genl_send_params (msg, local, info->snd_portid, info->snd_seq); +put_local: +nfc_llcp_local_put (local); + exit:device_unlock (&dev->dev);
@@ -1105,7 +1108,7 @@ static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info)if (info->attrs[NFC_ATTR_LLC_PARAM_LTO ]) {if (dev->dep_link_up) { rc = -EINPROGRESS ; - goto exit; + goto put_local; } local->lto =nla_get_u8 (info->attrs[NFC_ATTR_LLC_PARAM_LTO ]);
@@ -1117,6 +1120,9 @@ static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info)if (info->attrs[NFC_ATTR_LLC_PARAM_MIUX ]) local->miux =cpu_to_be16 (miux); +put_local: +nfc_llcp_local_put (local); + exit:device_unlock (&dev->dev);
@@ -1172,7 +1178,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)if (rc !=0 ) { rc = -EINVAL ; - goto exit; + goto put_local; }if (!sdp_attrs[NFC_SDP_ATTR_URI ])
@@ -1191,7 +1197,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) sdreq =nfc_llcp_build_sdreq_tlv (tid, uri, uri_len);if (sdreq ==NULL ) { rc = -ENOMEM ; - goto exit; + goto put_local; } tlvs_len += sdreq->tlv_len;
@@ -1201,10 +1207,14 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)if (hlist_empty (&sdreq_list)) { rc = -EINVAL ; - goto exit; + goto put_local; } rc =nfc_llcp_send_snl_sdreq (local, &sdreq_list, tlvs_len); + +put_local: +nfc_llcp_local_put (local); + exit:device_unlock (&dev->dev);
net/nfc/nfc.h +1 -0
@@ -52,6 +52,7 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, const u8 *gb, u8 gb_len);u8 *nfc_llcp_general_bytes (struct nfc_dev *dev,size_t *general_bytes_len);int nfc_llcp_data_received (struct nfc_dev *dev,struct sk_buff *skb);struct nfc_llcp_local *nfc_llcp_find_local (struct nfc_dev *dev); +int nfc_llcp_local_put (struct nfc_llcp_local *local);int __init nfc_llcp_init (void );void nfc_llcp_exit (void );void nfc_llcp_free_sdp_tlv (struct nfc_llcp_sdp_tlv *sdp);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 214/800 lib/ts_bm: reset initial match offset for every block of text
In reply to Greg Kroah-HartmanFrom: Jeremy Sowden <[email protected]>
[ Upstream commit 6f67fbf8192da80c4db01a1800c7fceaca9cf1f9 ]
The shift variable which indicates the offset in the string at which to start matching the pattern is initialized to bm->patlen - 1, but it is not reset when a new block is retrieved. This means the implemen- tation may start looking at later and later positions in each successive block and miss occurrences of the pattern at the beginning. E.g., consider a HTTP packet held in a non-linear skb, where the HTTP request line occurs in the second block:
[... 52 bytes of packet headers ...]
GET /bmtest HTTP/1.1\r\nHost: www.example.com\r\n\r\n
and the pattern is "GET /bmtest".
Once the first block comprising the packet headers has been examined, shift will be pointing to somewhere near the end of the block, and so when the second block is examined the request line at the beginning will be missed.
Reinitialize the variable for each new block.
--- lib/ts_bm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/ts_bm.c +3 -1
@@ -60,10 +60,12 @@ static unsigned int bm_find(struct ts_config *conf, struct ts_state *state)struct ts_bm *bm =ts_config_priv (conf);unsigned int i, text_len, consumed = state->offset;const u8 *text; -int shift = bm->patlen -1 , bs; +int bs;const u8 icase = conf->flags &TS_IGNORECASE ;for (;;) { +int shift = bm->patlen -1 ; + text_len = conf->get_next_block (consumed, &text, conf, state);if (unlikely (text_len ==0 ))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 215/800 netfilter: conntrack: dccp: copy entire header to stack buffer, not just basic one
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit ff0a3a7d52ff7282dbd183e7fc29a1fe386b0c30 ]
Eric Dumazet says:
nf_conntrack_dccp_packet() has an unique:
dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
And nothing more is 'pulled' from the packet, depending on the content. dh->dccph_doff, and/or dh->dccph_x ...)
So dccp_ack_seq() is happily reading stuff past the _dh buffer.
BUG: KASAN: stack-out-of-bounds in nf_conntrack_dccp_packet+0x1134/0x11c0 Read of size 4 at addr ffff000128f66e0c by task syz-executor.2/29371
[..]
Fix this by increasing the stack buffer to also include room for the extra sequence numbers and all the known dccp packet type headers, then pull again after the initial validation of the basic header.
While at it, mark packets invalid that lack 48bit sequence bit but where RFC says the type MUST use them.
Compile tested only.
v2: first skb_header_pointer() now needs to adjust the size to
only pull the generic header. (Eric)
Heads-up: I intend to remove dccp conntrack support later this year.
--- net/netfilter/nf_conntrack_proto_dccp.c | 52 +++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_proto_dccp.c +49 -3
@@ -432,9 +432,19 @@ static bool dccp_error(const struct dccp_hdr *dh, struct sk_buff *skb, unsigned int dataoff, const struct nf_hook_state *state) { +static const unsigned long require_seq48 =1 <<DCCP_PKT_REQUEST | +1 <<DCCP_PKT_RESPONSE | +1 <<DCCP_PKT_CLOSEREQ | +1 <<DCCP_PKT_CLOSE | +1 <<DCCP_PKT_RESET | +1 <<DCCP_PKT_SYNC | +1 <<DCCP_PKT_SYNCACK ;unsigned int dccp_len = skb->len - dataoff;unsigned int cscov;const char *msg; +u8 type; + +BUILD_BUG_ON (DCCP_PKT_INVALID >=BITS_PER_LONG );if (dh->dccph_doff *4 <sizeof (struct dccp_hdr ) || dh->dccph_doff *4 > dccp_len) {
@@ -459,34 +469,70 @@ static bool dccp_error(const struct dccp_hdr *dh, goto out_invalid; } -if (dh->dccph_type >=DCCP_PKT_INVALID ) { + type = dh->dccph_type; +if (type >=DCCP_PKT_INVALID ) { msg ="nf_ct_dccp: reserved packet type " ; goto out_invalid; } + +if (test_bit (type, &require_seq48) && !dh->dccph_x) { + msg ="nf_ct_dccp: type lacks 48bit sequence numbers" ; + goto out_invalid; + } +return false; out_invalid:nf_l4proto_log_invalid (skb, state,IPPROTO_DCCP ,"%s" , msg);return true; } +struct nf_conntrack_dccp_buf { +struct dccp_hdr dh;/* generic header part */ +struct dccp_hdr_ext ext;/* optional depending dh->dccph_x */ +union {/* depends on header type */ +struct dccp_hdr_ack_bits ack; +struct dccp_hdr_request req; +struct dccp_hdr_response response; +struct dccp_hdr_reset rst; + } u; +}; + +static struct dccp_hdr * +dccp_header_pointer (const struct sk_buff *skb,int offset,const struct dccp_hdr *dh, +struct nf_conntrack_dccp_buf *buf) +{ +unsigned int hdrlen =__dccp_hdr_len (dh); + +if (hdrlen >sizeof (*buf)) +return NULL ; + +return skb_header_pointer (skb, offset, hdrlen, buf); +} +int nf_conntrack_dccp_packet (struct nf_conn *ct,struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info ctinfo,const struct nf_hook_state *state) {enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo); -struct dccp_hdr _dh, *dh; +struct nf_conntrack_dccp_buf _dh;u_int8_t type, old_state, new_state;enum ct_dccp_roles role;unsigned int *timeouts; +struct dccp_hdr *dh; - dh =skb_header_pointer (skb, dataoff,sizeof (_dh), &_dh); + dh =skb_header_pointer (skb, dataoff,sizeof (*dh), &_dh.dh);if (!dh)return NF_DROP ;if (dccp_error (dh, skb, dataoff, state))return -NF_ACCEPT ; +/* pull again, including possible 48 bit sequences and subtype header */ + dh =dccp_header_pointer (skb, dataoff, dh, &_dh); +if (!dh) +return NF_DROP ; + type = dh->dccph_type;if (!nf_ct_is_confirmed (ct) && !dccp_new (ct, skb, dh, state))return -NF_ACCEPT ;
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