Thomas Graf
57a09bf0a4
bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers
...
A BPF program is required to check the return register of a
map_elem_lookup() call before accessing memory. The verifier keeps
track of this by converting the type of the result register from
PTR_TO_MAP_VALUE_OR_NULL to PTR_TO_MAP_VALUE after a conditional
jump ensures safety. This check is currently exclusively performed
for the result register 0.
In the event the compiler reorders instructions, BPF_MOV64_REG
instructions may be moved before the conditional jump which causes
them to keep their type PTR_TO_MAP_VALUE_OR_NULL to which the
verifier objects when the register is accessed:
0: (b7) r1 = 10
1: (7b) *(u64 *)(r10 -8) = r1
2: (bf) r2 = r10
3: (07) r2 += -8
4: (18) r1 = 0x59c00000
6: (85) call 1
7: (bf) r4 = r0
8: (15) if r0 == 0x0 goto pc+1
R0=map_value(ks=8,vs=8) R4=map_value_or_null(ks=8,vs=8) R10=fp
9: (7a) *(u64 *)(r4 +0) = 0
R4 invalid mem access 'map_value_or_null'
This commit extends the verifier to keep track of all identical
PTR_TO_MAP_VALUE_OR_NULL registers after a map_elem_lookup() by
assigning them an ID and then marking them all when the conditional
jump is observed.
Signed-off-by: Thomas Graf <tgraf@suug.ch >
Reviewed-by: Josef Bacik <jbacik@fb.com >
Acked-by: Daniel Borkmann <daniel@iogearbox.net >
Acked-by: Alexei Starovoitov <ast@kernel.org >
Signed-off-by: David S. Miller <davem@davemloft.net >
2016-10-19 11:09:28 -04:00
..
2016-10-12 11:01:37 -07:00
2016-10-05 10:11:24 -07:00
2016-09-22 10:01:21 +02:00
2016-10-03 16:13:50 +02:00
2016-09-15 21:15:40 +05:30
2016-09-10 16:48:46 +05:30
2016-10-11 15:06:33 -07:00
2016-09-14 20:42:03 +02:00
2016-09-12 20:32:42 +01:00
2016-10-07 08:35:35 -07:00
2016-10-09 17:04:33 -07:00
2016-10-13 10:13:24 -04:00
2016-10-05 11:34:53 -07:00
2016-10-08 20:56:54 -07:00
2016-09-12 19:59:39 +02:00
2016-10-03 19:43:08 -07:00
2016-09-10 17:31:39 +05:30
2016-10-11 13:22:22 -07:00
2016-09-21 02:08:04 +02:00
2016-10-14 11:59:58 -04:00
2016-10-07 09:45:43 -07:00
2016-09-30 09:13:58 -07:00
2016-09-30 09:14:10 -07:00
2016-10-13 21:28:20 -07:00
2016-09-14 20:37:50 +02:00
2016-09-12 20:32:40 +01:00
2016-10-03 20:11:49 -07:00
2016-09-20 14:35:59 -05:00
2016-09-05 12:41:46 +02:00
2016-09-27 12:54:03 +02:00
2016-10-11 15:06:31 -07:00
2016-10-11 15:06:31 -07:00
2016-09-22 07:48:03 -06:00
2016-09-09 12:09:24 +03:00
2016-10-07 18:46:26 -07:00
2016-09-14 09:18:06 -06:00
2016-09-23 11:30:38 -06:00
2016-09-15 08:42:03 -06:00
2016-10-09 17:32:20 -07:00
2016-09-14 11:48:34 -06:00
2016-09-15 18:29:06 -04:00
2016-10-07 18:46:28 -07:00
2016-10-19 11:09:28 -04:00
2016-09-29 01:35:35 -04:00
2016-09-09 12:09:24 +03:00
2016-10-06 09:52:23 -07:00
2016-09-23 14:44:03 -07:00
2016-10-07 18:46:29 -07:00
2016-09-27 21:20:53 -04:00
2016-09-05 11:50:42 +02:00
2016-10-07 18:46:30 -07:00
2016-10-07 18:46:30 -07:00
2016-10-06 11:19:10 -07:00
2016-10-07 18:46:30 -07:00
2016-10-11 15:06:30 -07:00
2016-09-19 11:24:50 +10:00
2016-09-16 12:44:20 +02:00
2016-09-21 12:13:31 +02:00
2016-09-06 13:08:40 +09:00
2016-09-14 13:56:38 -04:00
2016-09-16 09:34:15 +01:00
2016-09-26 22:16:41 +05:30
2016-09-16 09:34:22 +01:00
2016-10-11 15:06:32 -07:00
2016-09-13 20:21:55 +02:00
2016-10-11 15:06:33 -07:00
2016-10-06 09:07:44 -04:00
2016-09-16 08:53:41 +02:00
2016-09-30 10:05:46 -07:00
2016-10-03 09:11:14 -07:00
2016-09-27 18:47:38 -04:00
2016-09-09 19:36:04 -07:00
2016-10-11 15:06:34 -07:00
2016-10-07 15:15:33 -07:00
2016-10-07 18:46:26 -07:00
2016-09-16 12:44:20 +02:00
2016-09-02 12:47:55 -04:00
2016-10-06 11:48:41 -07:00
2016-09-29 10:40:13 +02:00
2016-10-07 18:46:28 -07:00
2016-10-07 18:46:29 -07:00
2016-09-08 21:34:15 -07:00
2016-10-05 10:11:24 -07:00
2016-09-05 13:52:38 +02:00
2016-09-24 10:48:18 +02:00
2016-09-01 22:48:33 -07:00
2016-09-24 08:01:26 -04:00
2016-10-07 23:50:39 -04:00
2016-09-08 17:10:28 -07:00
2016-09-08 16:13:09 -07:00
2016-09-16 09:18:54 +02:00
2016-09-20 18:02:35 +02:00
2016-09-14 22:11:09 +02:00
2016-10-03 09:53:59 +11:00
2016-09-16 09:34:15 +01:00
2016-09-14 09:18:09 -06:00
2016-09-30 01:54:28 -04:00
2016-09-20 23:20:32 +02:00
2016-09-14 15:28:15 +02:00
2016-10-07 18:46:26 -07:00
2016-10-03 13:22:39 -07:00
2016-10-09 12:23:38 -07:00
2016-10-07 18:46:30 -07:00
2016-10-11 15:06:33 -07:00
2016-10-11 15:06:33 -07:00
2016-10-11 15:06:33 -07:00
2016-10-05 10:11:24 -07:00
2016-09-16 16:57:47 +02:00
2016-09-15 16:49:39 +02:00
2016-09-30 19:13:42 -07:00
2016-09-21 07:57:31 -06:00
2016-09-14 12:57:43 -07:00
2016-09-24 10:48:32 +02:00
2016-09-19 13:42:38 -04:00
2016-09-19 12:27:10 +10:00
2016-09-15 21:13:50 +05:30
2016-09-27 12:33:47 +02:00
2016-10-07 18:46:28 -07:00
2016-10-07 18:46:29 -07:00
2016-09-01 17:52:01 -07:00
2016-10-07 18:46:27 -07:00
2016-10-07 18:46:30 -07:00
2016-09-01 17:52:01 -07:00
2016-09-30 12:46:48 -05:00
2016-09-25 23:41:39 -04:00
2016-09-25 23:41:39 -04:00
2016-09-14 22:11:08 +02:00
2016-10-07 09:20:53 -07:00
2016-10-18 11:45:00 -04:00
2016-09-25 14:38:48 +02:00
2016-09-25 23:34:19 +02:00
2016-09-27 14:34:01 -04:00
2016-09-22 15:54:27 -04:00
2016-09-19 13:11:13 -04:00
2016-10-07 18:46:30 -07:00
2016-09-28 17:43:15 +02:00
2016-10-03 23:38:11 +02:00
2016-09-16 09:34:14 +01:00
2016-09-15 08:33:01 -05:00
2016-09-28 08:53:14 +05:30
2016-10-07 18:46:28 -07:00
2016-09-19 21:44:30 +02:00
2016-10-07 18:46:27 -07:00
2016-10-07 18:46:27 -07:00
2016-10-11 15:06:34 -07:00
2016-10-07 11:46:37 -07:00
2016-09-22 15:25:54 +02:00
2016-10-05 10:11:24 -07:00
2016-10-18 11:56:31 -04:00
2016-10-18 11:56:31 -04:00
2016-10-05 18:24:00 -04:00
2016-09-09 13:02:28 +02:00
2016-09-13 02:49:34 +02:00
2016-09-27 21:52:00 -04:00
2016-10-08 11:06:08 -04:00
2016-10-09 12:23:38 -07:00
2016-09-22 19:59:41 -05:00
2016-09-30 15:26:52 -07:00
2016-09-08 15:01:10 -07:00
2016-09-08 15:01:10 -07:00
2016-09-22 02:18:33 -04:00
2016-09-05 16:45:39 +02:00
2016-09-12 20:01:43 +01:00
2016-10-11 15:06:30 -07:00
2016-10-11 15:06:32 -07:00
2016-09-16 12:06:24 +01:00
2016-10-11 15:06:32 -07:00
2016-10-02 22:50:21 -07:00
2016-09-20 04:43:36 -04:00
2016-09-08 22:15:25 -07:00
2016-09-01 16:56:15 -07:00
2016-09-17 08:39:12 -06:00
2016-10-07 18:46:28 -07:00
2016-09-19 12:27:10 +10:00
2016-10-11 15:06:33 -07:00
2016-10-07 18:46:30 -07:00
2016-09-28 17:46:46 +02:00
2016-10-07 15:36:58 -07:00
2016-09-06 18:30:20 +02:00
2016-10-18 14:14:20 -04:00
2016-09-05 13:52:39 +02:00
2016-10-05 18:23:36 -04:00
2016-09-13 02:17:19 +02:00
2016-10-07 18:46:27 -07:00
2016-09-09 13:02:27 +02:00
2016-10-06 09:52:23 -07:00
2016-09-15 09:51:14 -04:00
2016-09-21 00:23:00 -04:00
2016-09-27 14:35:21 +08:00
2016-09-24 09:35:06 +02:00
2016-09-22 17:02:55 +02:00
2016-09-30 11:46:40 +02:00
2016-10-10 13:38:49 -07:00
2016-09-13 08:08:24 +02:00
2016-09-22 20:00:36 -05:00
2016-09-30 10:54:03 +02:00
2016-10-08 10:27:10 +02:00
2016-09-21 00:22:59 -04:00
2016-10-07 18:46:27 -07:00
2016-10-07 21:48:36 -04:00