Alexei Starovoitov
83b570c004
bpf: Prevent memory disambiguation attack
commit af86ca4e30 upstream.
Detect code patterns where malicious 'speculative store bypass' can be used
and sanitize such patterns.
39: (bf) r3 = r10
40: (07) r3 += -216
41: (79) r8 = *(u64 *)(r7 +0) // slow read
42: (7a) *(u64 *)(r10 -72) = 0 // verifier inserts this instruction
43: (7b) *(u64 *)(r8 +0) = r3 // this store becomes slow due to r8
44: (79) r1 = *(u64 *)(r6 +0) // cpu speculatively executes this load
45: (71) r2 = *(u8 *)(r1 +0) // speculatively arbitrary 'load byte'
// is now sanitized
Above code after x86 JIT becomes:
e5: mov %rbp,%rdx
e8: add $0xffffffffffffff28,%rdx
ef: mov 0x0(%r13),%r14
f3: movq $0x0,-0x48(%rbp)
fb: mov %rdx,0x0(%r14)
ff: mov 0x0(%rbx),%rdi
103: movzbq 0x0(%rdi),%rsi
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bwh: Backported to 4.14:
- Add bpf_verifier_env parameter to check_stack_write()
- Look up stack slot_types with state->stack_slot_type[] rather than
state->stack[].slot_type[]
- Drop bpf_verifier_env argument to verbose()
- Adjust context]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-05 19:41:10 +01:00
..
2018-12-05 19:41:10 +01:00
2018-10-18 09:16:24 +02:00
2017-08-22 18:43:23 -07:00
2018-12-01 09:42:54 +01:00
2018-11-04 14:52:40 +01:00
2017-11-02 11:10:55 +01:00
2018-11-13 11:15:09 -08:00
2018-09-09 19:55:58 +02:00
2018-11-13 11:14:51 -08:00
2018-09-09 19:55:58 +02:00
2018-11-21 09:24:17 +01:00
2018-12-01 09:43:00 +01:00
2018-11-27 16:10:49 +01:00
2018-10-03 17:00:50 -07:00
2018-09-29 03:06:04 -07:00
2015-10-21 15:18:35 +01:00
2018-01-10 09:31:17 +01:00
2018-02-16 20:23:05 +01:00
2017-05-03 11:05:15 -07:00
2017-11-02 11:10:55 +01:00
2018-09-26 08:38:09 +02:00
2018-05-30 07:52:39 +02:00
2017-09-03 20:21:24 -04:00
2018-08-03 07:50:39 +02:00
2018-08-06 16:20:49 +02:00
2014-06-04 16:54:14 -07:00
2018-11-13 11:15:08 -08:00
2017-11-02 11:10:55 +01:00
2018-05-16 10:10:26 +02:00
2016-12-24 11:46:01 -08:00
2015-11-24 09:56:43 +01:00
2017-07-31 13:09:49 +02:00
2018-11-23 08:19:27 +01:00
2018-01-17 09:45:27 +01:00
2014-08-25 15:42:19 -07:00
2017-05-18 10:30:19 -06:00
2018-08-03 07:50:38 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-02-13 10:19:49 +01:00
2017-09-23 16:50:20 -04:00
2018-09-15 09:45:27 +02:00
2016-07-28 16:07:41 -07:00
2017-11-02 11:10:55 +01:00
2018-02-03 17:38:47 +01:00
2017-12-20 10:10:18 +01:00
2018-08-03 07:50:23 +02:00
2015-11-23 09:44:58 +01:00
2017-12-14 09:53:13 +01:00
2017-07-10 16:32:34 -07:00
2017-11-02 11:10:55 +01:00
2016-10-25 11:31:51 +02:00
2018-08-03 07:50:22 +02:00
2017-07-18 11:38:04 +02:00
2017-07-12 16:26:02 -07:00
2017-11-02 11:10:55 +01:00
2017-07-12 16:26:00 -07:00
2017-09-08 18:26:51 -07:00
2018-11-13 11:14:55 -08:00
2017-07-12 16:25:59 -07:00
2018-08-03 07:50:21 +02:00
2017-03-02 08:42:39 +01:00
2017-11-02 11:10:55 +01:00
2018-10-20 09:48:53 +02:00
2016-04-11 22:43:43 +01:00
2018-10-03 17:00:53 -07:00
2017-02-24 17:46:56 -08:00
2017-03-13 15:57:41 -03:00
2017-05-26 10:10:37 +02:00
2017-08-17 10:40:26 +02:00
2017-10-03 17:54:26 -07:00
2017-07-20 07:43:58 -05:00
2017-08-21 12:47:31 -07:00
2017-03-02 08:42:39 +01:00
2017-07-24 14:30:28 -05:00
2017-11-02 11:10:55 +01:00
2015-09-10 13:29:01 -07:00
2018-05-30 07:52:00 +02:00
2018-04-24 09:36:22 +02:00
2018-05-22 18:54:04 +02:00
2018-11-13 11:15:07 -08:00
2018-08-15 18:13:00 +02:00
2017-10-04 10:53:54 +02:00
2017-11-02 11:10:55 +01:00
2018-08-15 18:12:47 +02:00
2017-03-08 09:18:02 +01:00
2018-09-05 09:26:36 +02:00
2017-11-02 11:10:55 +01:00
2018-09-09 19:56:00 +02:00
2017-11-02 11:10:55 +01:00
2018-12-01 09:42:59 +01:00
2017-12-25 14:26:21 +01:00
2017-05-08 17:15:12 -07:00
2014-08-08 15:57:18 -07:00
2017-07-25 13:04:45 -07:00
2018-05-09 09:51:50 +02:00
2017-03-02 08:42:39 +01:00
2017-03-06 15:26:37 -06:00
2017-12-20 10:10:18 +01:00
2017-09-08 18:26:50 -07:00
2017-08-29 15:14:38 +02:00
2018-09-09 19:56:00 +02:00
2014-08-26 13:45:45 -04:00
2017-03-02 08:42:29 +01:00
2018-09-09 19:56:00 +02:00
2017-03-02 08:42:38 +01:00
2018-09-05 09:26:42 +02:00
2018-09-05 09:26:42 +02:00
2017-11-06 12:26:49 -08:00
2018-09-05 09:26:42 +02:00