Yonghong Song
1d68f22b3d
bpf: Handle spilled PTR_TO_BTF_ID properly when checking stack_boundary
This specifically to handle the case like below:
// ptr below is a socket ptr identified by PTR_TO_BTF_ID
u64 param[2] = { ptr, val };
bpf_seq_printf(seq, fmt, sizeof(fmt), param, sizeof(param));
In this case, the 16 bytes stack for "param" contains:
8 bytes for ptr with spilled PTR_TO_BTF_ID
8 bytes for val as STACK_MISC
The current verifier will complain the ptr should not be visible
to the helper.
...
16: (7b) *(u64 *)(r10 -64) = r2
18: (7b) *(u64 *)(r10 -56) = r1
19: (bf) r4 = r10
;
20: (07) r4 += -64
; BPF_SEQ_PRINTF(seq, fmt1, (long)s, s->sk_protocol);
21: (bf) r1 = r6
22: (18) r2 = 0xffffa8d00018605a
24: (b4) w3 = 10
25: (b4) w5 = 16
26: (85) call bpf_seq_printf#125
R0=inv(id=0) R1_w=ptr_seq_file(id=0,off=0,imm=0)
R2_w=map_value(id=0,off=90,ks=4,vs=144,imm=0) R3_w=inv10
R4_w=fp-64 R5_w=inv16 R6=ptr_seq_file(id=0,off=0,imm=0)
R7=ptr_netlink_sock(id=0,off=0,imm=0) R10=fp0 fp-56_w=mmmmmmmm
fp-64_w=ptr_
last_idx 26 first_idx 13
regs=8 stack=0 before 25: (b4) w5 = 16
regs=8 stack=0 before 24: (b4) w3 = 10
invalid indirect read from stack off -64+0 size 16
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200509175915.2476783-1-yhs@fb.com
2020-05-09 17:05:27 -07:00
..
2020-05-09 17:05:27 -07:00
2020-04-28 17:27:07 -07:00
2020-04-07 10:43:42 -07:00
2020-04-03 13:12:26 -07:00
2020-04-08 21:46:57 +02:00
2020-04-28 21:23:38 +02:00
2020-04-10 15:36:22 -07:00
2020-04-14 10:08:50 +02:00
2019-11-27 11:42:01 -08:00
2020-04-08 12:05:07 +02:00
2020-04-06 21:42:36 +02:00
2020-04-27 02:07:40 -04:00
2020-04-14 08:36:41 +02:00
2020-04-28 21:23:38 +02:00
2020-04-28 21:23:38 +02:00
2020-05-09 17:05:26 -07:00
2020-03-25 11:50:48 +01:00
2019-12-18 18:07:31 +01:00
2020-03-23 18:19:06 +01:00
2020-04-06 08:58:42 -07:00
2020-04-20 17:10:58 -04:00
2020-03-12 10:42:51 -04:00
2020-02-22 20:36:47 -05:00
2020-03-12 10:42:51 -04:00
2020-02-21 11:22:15 -08:00
2020-02-04 03:05:26 +00:00
2020-02-14 16:05:04 +01:00
2020-03-30 18:06:39 -07:00
2020-03-25 10:04:01 -05:00
2019-09-25 17:51:39 -07:00
2020-04-24 15:49:00 -05:00
2020-04-07 10:43:42 -07:00
2020-04-15 09:56:32 +02:00
2019-10-06 09:11:37 -06:00
2020-03-30 16:17:15 -07:00
2019-11-11 20:10:01 +09:00
2020-03-21 16:00:24 +01:00
2019-08-29 15:10:10 +01:00
2020-04-07 10:43:44 -07:00
2020-03-25 10:04:01 -05:00
2019-12-08 14:37:36 +01:00
2019-11-12 11:35:32 +01:00
2019-12-04 19:44:14 -08:00
2020-01-08 16:32:55 +00:00
2019-09-06 23:58:44 +02:00
2020-01-08 16:32:55 +00:00
2020-01-08 16:32:55 +00:00
2020-01-08 16:32:55 +00:00
2020-04-10 15:36:22 -07:00
2020-04-27 02:07:40 -04:00
2020-03-20 13:06:20 +01:00
2020-04-27 02:07:40 -04:00
2020-01-31 10:30:41 -08:00
2020-04-21 13:27:37 -07:00
2020-03-21 18:56:06 -07:00
2020-01-14 12:20:48 +01:00
2020-03-06 12:28:24 +11:00
2019-11-25 09:15:42 +01:00
2020-04-27 02:07:40 -04:00
2020-04-10 12:59:56 -07:00
2020-02-04 03:05:26 +00:00
2020-01-18 13:51:39 +01:00
2019-09-24 15:54:09 -07:00
2019-12-25 10:41:20 +01:00
2020-04-27 02:07:40 -04:00
2020-04-23 13:30:18 -07:00
2020-03-25 12:59:37 +01:00
2020-03-21 16:03:54 +01:00
2019-11-11 10:30:59 +01:00
2020-01-17 10:19:21 +01:00
2019-11-15 14:38:30 +01:00
2020-03-03 19:34:32 +01:00
2019-11-26 13:03:56 -06:00
2020-01-09 16:42:29 -07:00
2020-05-05 11:59:32 -07:00
2020-03-02 14:06:33 -07:00
2019-12-04 15:18:39 +01:00
2020-03-30 18:06:39 -07:00
2019-12-18 18:07:31 +01:00
2020-04-07 21:51:27 +02:00
2020-04-27 02:07:40 -04:00
2020-02-07 15:34:12 +01:00
2020-04-27 02:07:40 -04:00
2020-04-27 02:07:40 -04:00
2020-04-08 11:35:20 +02:00