Skip to content

Commit 199f045

Browse files
shunghsiyugregkh
authored andcommitted
Revert "bpf: support non-r10 register spill/fill to/from stack in precision tracking"
Revert commit ecc2aee which is commit 41f6f64 upstream. Levi reported that commit ecc2aee ("bpf: support non-r10 register spill/fill to/from stack in precision tracking") cause eBPF program that previously loads successfully in stable 6.6 now fails to load, when the same program also loads successfully in v6.13-rc5. Revert ecc2aee until the problem has been probably figured out and resolved. Fixes: ecc2aee ("bpf: support non-r10 register spill/fill to/from stack in precision tracking") Reported-by: Levi Zim <[email protected]> Link: https://lore.kernel.org/stable/MEYP282MB2312C3C8801476C4F262D6E1C6162@MEYP282MB2312.AUSP282.PROD.OUTLOOK.COM/ Signed-off-by: Shung-Hsi Yu <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bc6962f commit 199f045

File tree

4 files changed

+98
-169
lines changed

4 files changed

+98
-169
lines changed

include/linux/bpf_verifier.h

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -319,34 +319,12 @@ struct bpf_func_state {
319319
struct bpf_stack_state *stack;
320320
};
321321

322-
#define MAX_CALL_FRAMES 8
323-
324-
/* instruction history flags, used in bpf_jmp_history_entry.flags field */
325-
enum {
326-
/* instruction references stack slot through PTR_TO_STACK register;
327-
* we also store stack's frame number in lower 3 bits (MAX_CALL_FRAMES is 8)
328-
* and accessed stack slot's index in next 6 bits (MAX_BPF_STACK is 512,
329-
* 8 bytes per slot, so slot index (spi) is [0, 63])
330-
*/
331-
INSN_F_FRAMENO_MASK = 0x7, /* 3 bits */
332-
333-
INSN_F_SPI_MASK = 0x3f, /* 6 bits */
334-
INSN_F_SPI_SHIFT = 3, /* shifted 3 bits to the left */
335-
336-
INSN_F_STACK_ACCESS = BIT(9), /* we need 10 bits total */
337-
};
338-
339-
static_assert(INSN_F_FRAMENO_MASK + 1 >= MAX_CALL_FRAMES);
340-
static_assert(INSN_F_SPI_MASK + 1 >= MAX_BPF_STACK / 8);
341-
342-
struct bpf_jmp_history_entry {
322+
struct bpf_idx_pair {
323+
u32 prev_idx;
343324
u32 idx;
344-
/* insn idx can't be bigger than 1 million */
345-
u32 prev_idx : 22;
346-
/* special flags, e.g., whether insn is doing register stack spill/load */
347-
u32 flags : 10;
348325
};
349326

327+
#define MAX_CALL_FRAMES 8
350328
/* Maximum number of register states that can exist at once */
351329
#define BPF_ID_MAP_SIZE ((MAX_BPF_REG + MAX_BPF_STACK / BPF_REG_SIZE) * MAX_CALL_FRAMES)
352330
struct bpf_verifier_state {
@@ -429,7 +407,7 @@ struct bpf_verifier_state {
429407
* For most states jmp_history_cnt is [0-3].
430408
* For loops can go up to ~40.
431409
*/
432-
struct bpf_jmp_history_entry *jmp_history;
410+
struct bpf_idx_pair *jmp_history;
433411
u32 jmp_history_cnt;
434412
u32 dfs_depth;
435413
u32 callback_unroll_depth;
@@ -662,7 +640,6 @@ struct bpf_verifier_env {
662640
int cur_stack;
663641
} cfg;
664642
struct backtrack_state bt;
665-
struct bpf_jmp_history_entry *cur_hist_ent;
666643
u32 pass_cnt; /* number of times do_check() was called */
667644
u32 subprog_cnt;
668645
/* number of instructions analyzed by the verifier */

0 commit comments

Comments
 (0)