[QUESTION] Check PTR_UNTRUSTED usage in sleepable eBPF iterators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks! I would like to check with you if the verifier failure I'm
facing is expected. The verifier rejects the following eBPF program in
recent kernel versions (e.g. 6.8.0-1010-aws). The same program
correctly works on older kernel versions (e.g. 6.5.0-41-generic) so
it's unclear to me why now the verifier should reject it.

```
#define EXE_PATH_MAX_LEN 512
char exe_path[EXE_PATH_MAX_LEN];

SEC("iter.s/task")
int dump_task(struct bpf_iter__task *ctx) {
  struct task_struct *task = ctx->task;

  if (task == NULL) {
    return 0;
  }

  struct file *exe_file = task->mm->exe_file;
  if (exe_file != NULL) {
    bpf_d_path(&(exe_file->f_path), exe_path, EXE_PATH_MAX_LEN);
    bpf_printk("exe path: %s", exe_path);
  }
  return 0;
}
```

Verifier log

```
-- BEGIN PROG LOAD LOG --
0: R1=ctx() R10=fp0
; struct task_struct *task = ctx->task;
0: (79) r1 = *(u64 *)(r1 +8)          ;
R1_w=trusted_ptr_or_null_task_struct(id=1)
; if (task == NULL) {
1: (15) if r1 == 0x0 goto pc+15       ; R1_w=trusted_ptr_task_struct()
; struct file *exe_file = task->mm->exe_file;
2: (79) r1 = *(u64 *)(r1 +2264)       ; R1_w=untrusted_ptr_mm_struct()
; struct file *exe_file = task->mm->exe_file;
3: (79) r1 = *(u64 *)(r1 +1176)       ; R1_w=untrusted_ptr_file()
; if (exe_file != NULL) {
4: (15) if r1 == 0x0 goto pc+12       ; R1_w=untrusted_ptr_file()
5: (b7) r2 = 152                      ; R2_w=152
6: (0f) r1 += r2                      ;
R1_w=untrusted_ptr_file(off=152) R2_w=152
; bpf_d_path(&(exe_file->f_path), exe_path, EXE_PATH_MAX_LEN);
7: (18) r2 = 0xffffa839013ee000       ;
R2_w=map_value(map=bpf_iter.bss,ks=4,vs=528)
9: (b7) r3 = 512                      ; R3_w=512
10: (85) call bpf_d_path#147
R1 type=untrusted_ptr_ expected=ptr_, trusted_ptr_, rcu_ptr_
processed 10 insns (limit 1000000) max_states_per_insn 0 total_states
0 peak_states 0 mark_read 0
-- END PROG LOAD LOG --
```


[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux