Dave Hansen
e0fbff18bb
uaccess: Add speculation barrier to copy_from_user()
...
commit 74e19ef0ff upstream.
The results of "access_ok()" can be mis-speculated. The result is that
you can end speculatively:
if (access_ok(from, size))
// Right here
even for bad from/size combinations. On first glance, it would be ideal
to just add a speculation barrier to "access_ok()" so that its results
can never be mis-speculated.
But there are lots of system calls just doing access_ok() via
"copy_to_user()" and friends (example: fstat() and friends). Those are
generally not problematic because they do not _consume_ data from
userspace other than the pointer. They are also very quick and common
system calls that should not be needlessly slowed down.
"copy_from_user()" on the other hand uses a user-controller pointer and
is frequently followed up with code that might affect caches. Take
something like this:
if (!copy_from_user(&kernelvar, uptr, size))
do_something_with(kernelvar);
If userspace passes in an evil 'uptr' that *actually* points to a kernel
addresses, and then do_something_with() has cache (or other)
side-effects, it could allow userspace to infer kernel data values.
Add a barrier to the common copy_from_user() code to prevent
mis-speculated values which happen after the copy.
Also add a stub for architectures that do not define barrier_nospec().
This makes the macro usable in generic code.
Since the barrier is now usable in generic code, the x86 #ifdef in the
BPF code can also go away.
Reported-by: Jordy Zomer <jordyzomer@google.com >
Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org >
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Acked-by: Daniel Borkmann <daniel@iogearbox.net > # BPF bits
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-02-25 11:50:31 +01:00
..
2022-06-25 11:46:26 +02:00
2023-01-18 09:26:05 +01:00
2019-09-10 10:32:19 +01:00
2019-12-05 15:37:22 +01:00
2019-05-31 06:47:29 -07:00
2020-01-27 14:46:30 +01:00
2022-08-25 11:11:25 +02:00
2022-03-16 12:57:07 +01:00
2020-10-01 13:12:29 +02:00
2022-06-14 16:54:02 +02:00
2021-06-03 08:36:11 +02:00
2022-09-05 10:25:03 +02:00
2022-09-15 12:23:49 +02:00
2021-09-22 11:45:17 +02:00
2020-06-30 15:38:04 -04:00
2020-01-23 08:20:37 +01:00
2023-02-06 07:46:33 +01:00
2021-05-22 10:57:29 +02:00
2023-01-18 09:26:40 +01:00
2022-08-25 11:11:13 +02:00
2021-05-22 10:57:12 +02:00
2020-01-09 10:17:55 +01:00
2022-04-02 12:41:10 +02:00
2022-10-26 13:17:05 +02:00
2019-12-17 20:38:59 +01:00
2019-03-05 17:58:01 +01:00
2021-02-23 14:00:30 +01:00
2019-07-03 13:15:58 +02:00
2020-08-21 09:48:15 +02:00
2020-01-29 15:02:39 +01:00
2020-06-25 15:41:57 +02:00
2019-04-17 08:37:52 +02:00
2022-11-10 15:47:24 +01:00
2022-04-20 09:08:08 +02:00
2020-05-20 08:17:03 +02:00
2021-06-10 12:43:53 +02:00
2022-03-11 10:13:28 +01:00
2022-09-15 12:23:51 +02:00
2019-10-05 12:48:01 +02:00
2020-12-29 13:46:44 +01:00
2021-11-12 14:28:23 +01:00
2019-08-16 10:13:47 +02:00
2022-07-21 20:42:43 +02:00
2022-12-14 11:26:13 +01:00
2019-04-05 22:31:31 +02:00
2019-08-06 19:05:24 +02:00
2019-08-06 19:05:23 +02:00
2019-12-05 15:38:23 +01:00
2019-06-09 09:18:19 +02:00
2021-01-30 13:31:14 +01:00
2021-10-06 15:05:06 +02:00
2021-05-26 11:47:01 +02:00
2021-11-26 11:40:24 +01:00
2022-11-10 15:47:24 +01:00
2022-11-01 19:14:44 +01:00
2019-11-20 18:00:23 +01:00
2019-03-13 14:03:06 -07:00
2022-06-25 11:46:35 +02:00
2021-10-06 15:05:11 +02:00
2020-10-01 13:12:30 +02:00
2020-04-24 08:00:36 +02:00
2020-09-09 19:03:12 +02:00
2021-08-26 08:37:04 -04:00
2022-05-25 08:41:22 +02:00
2020-02-28 16:36:01 +01:00
2022-10-26 13:17:04 +02:00
2019-11-20 18:00:45 +01:00
2021-03-11 13:51:06 +01:00
2022-11-10 15:47:23 +01:00
2021-10-27 09:51:40 +02:00
2020-06-25 15:41:57 +02:00
2022-04-27 13:15:28 +02:00
2023-01-18 09:26:11 +01:00
2021-04-07 12:47:03 +02:00
2019-11-24 08:22:48 +01:00
2021-12-08 08:46:55 +01:00
2021-11-26 11:40:22 +01:00
2020-10-14 09:51:10 +02:00
2023-01-18 09:26:10 +01:00
2021-02-23 14:00:29 +01:00
2020-04-02 16:34:21 +02:00
2019-12-05 15:37:52 +01:00
2020-06-25 15:42:00 +02:00
2019-11-10 11:25:26 +01:00
2019-09-10 10:32:13 +01:00
2019-03-23 14:35:27 +01:00
2021-12-14 10:16:53 +01:00
2020-11-05 11:07:05 +01:00
2020-01-04 14:00:08 +01:00
2023-02-22 12:46:05 +01:00
2022-06-25 11:46:35 +02:00
2020-08-21 09:48:00 +02:00
2020-09-23 10:46:34 +02:00
2021-03-03 18:22:57 +01:00
2020-09-09 19:03:12 +02:00
2020-05-10 10:29:03 +02:00
2022-03-23 09:01:35 +01:00
2020-01-12 12:12:04 +01:00
2021-03-30 14:40:10 +02:00
2019-08-09 17:53:35 +02:00
2020-12-11 13:39:03 +01:00
2020-03-20 10:54:13 +01:00
2021-02-03 23:22:23 +01:00
2020-02-28 16:36:15 +01:00
2020-07-29 07:42:58 +02:00
2020-04-24 08:00:28 +02:00
2022-10-26 13:17:08 +02:00
2021-12-08 08:46:53 +01:00
2021-03-03 18:22:57 +01:00
2020-08-21 09:48:23 +02:00
2019-04-05 22:31:35 +02:00
2019-12-17 20:38:50 +01:00
2021-01-09 13:37:39 +01:00
2023-02-06 07:46:34 +01:00
2019-12-17 20:38:50 +01:00
2022-07-02 16:18:11 +02:00
2020-04-24 08:01:25 +02:00
2021-03-03 18:22:46 +01:00
2022-08-25 11:11:25 +02:00
2020-06-20 10:25:11 +02:00
2020-10-14 09:51:14 +02:00
2021-12-08 08:46:54 +01:00
2021-02-07 14:47:41 +01:00
2022-08-25 11:11:29 +02:00
2021-11-26 11:40:20 +01:00
2020-01-04 13:59:54 +01:00
2019-06-09 09:18:17 +02:00
2020-02-28 16:36:03 +01:00
2021-09-22 11:45:24 +02:00
2020-09-09 19:03:10 +02:00
2021-11-26 11:40:20 +01:00
2022-06-14 16:53:51 +02:00
2021-10-09 14:09:45 +02:00
2021-04-07 12:47:03 +02:00
2021-09-22 11:45:34 +02:00
2019-12-31 12:37:21 +01:00
2019-11-12 19:18:00 +01:00
2022-06-25 11:46:40 +02:00
2021-07-11 12:48:09 +02:00
2022-04-20 09:08:30 +02:00
2022-11-01 19:14:44 +01:00
2021-05-22 10:57:24 +02:00
2021-08-26 08:37:04 -04:00
2021-03-30 14:40:12 +02:00
2022-05-18 09:18:05 +02:00
2022-04-20 09:08:08 +02:00
2022-04-20 09:08:28 +02:00
2020-10-01 13:12:40 +02:00
2019-09-06 10:21:00 +02:00
2022-06-14 16:54:01 +02:00
2023-02-25 11:50:31 +01:00
2020-04-24 08:00:36 +02:00
2021-01-09 13:37:38 +01:00
2023-01-18 09:26:04 +01:00
2020-10-29 09:07:08 +01:00
2020-10-29 09:07:10 +01:00
2020-05-27 16:43:05 +02:00
2020-04-02 16:34:20 +02:00
2021-07-11 12:48:12 +02:00
2022-08-25 11:11:13 +02:00
2020-04-24 08:00:37 +02:00
2022-04-20 09:08:18 +02:00
2020-04-24 08:01:20 +02:00
2022-12-08 11:16:32 +01:00
2020-03-20 10:54:12 +01:00
2019-05-04 09:15:18 +02:00
2020-05-20 08:17:09 +02:00
2020-01-17 19:45:41 +01:00
2020-01-04 14:00:12 +01:00
2022-06-25 11:46:39 +02:00
2019-03-23 14:35:24 +01:00
2019-06-11 12:21:48 +02:00
2022-06-14 16:53:43 +02:00
2019-06-15 11:54:59 +02:00
2019-12-17 20:38:38 +01:00
2020-01-04 13:59:43 +01:00
2019-12-17 20:39:43 +01:00
2023-02-25 11:50:31 +01:00
2022-07-02 16:18:08 +02:00
2020-02-28 16:36:03 +01:00
2019-07-31 07:28:25 +02:00
2019-04-05 22:31:26 +02:00
2019-12-05 15:36:51 +01:00
2019-04-05 22:31:25 +02:00
2022-09-05 10:25:06 +02:00
2021-11-26 11:40:34 +01:00
2019-11-12 19:18:30 +01:00
2022-02-23 11:57:33 +01:00
2021-11-26 11:40:20 +01:00
2020-04-02 16:34:36 +02:00
2020-12-29 13:47:00 +01:00
2020-10-01 13:12:31 +02:00
2019-12-05 15:37:26 +01:00
2022-09-28 10:56:52 +02:00
2021-12-08 08:46:53 +01:00
2020-01-27 14:46:43 +01:00
2022-06-25 11:46:39 +02:00
2022-07-07 17:31:18 +02:00
2021-05-22 10:57:35 +02:00
2019-05-31 06:47:23 -07:00
2019-03-13 14:03:20 -07:00
2021-03-17 16:34:35 +01:00
2021-02-23 14:00:30 +01:00
2020-04-24 08:00:31 +02:00
2019-12-05 15:37:51 +01:00
2020-04-24 08:01:20 +02:00
2023-02-06 07:46:33 +01:00
2021-03-07 11:27:45 +01:00
2022-10-26 13:17:00 +02:00
2021-03-24 11:05:05 +01:00
2020-11-18 18:27:52 +01:00
2019-12-21 10:47:36 +01:00
2023-01-18 09:26:09 +01:00
2022-06-25 11:46:38 +02:00
2020-12-29 13:47:00 +01:00
2020-08-21 09:48:02 +02:00
2021-05-22 10:57:29 +02:00
2022-07-29 17:06:53 +02:00
2020-12-11 13:39:04 +01:00
2021-03-30 14:40:09 +02:00
2020-09-09 19:03:11 +02:00
2019-02-15 08:09:14 +01:00
2021-03-24 11:05:02 +01:00
2022-09-15 12:23:51 +02:00
2020-06-20 10:25:16 +02:00
2022-03-16 12:57:09 +01:00
2021-12-29 12:17:33 +01:00
2019-04-17 08:37:53 +02:00
2020-10-14 09:51:06 +02:00
2022-03-16 12:57:09 +01:00
2020-05-02 17:24:21 +02:00
2019-07-21 09:04:37 +02:00
2020-04-02 16:34:36 +02:00
2021-12-14 10:16:55 +01:00
2020-08-21 09:48:00 +02:00
2021-03-07 11:27:46 +01:00