Dave Hansen
3b6ce54cfa
uaccess: Add speculation barrier to copy_from_user()
...
commit 74e19ef0ff8061ef55957c3abd71614ef0f42f47 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:55:03 +01:00
..
2022-04-08 14:40:02 +02:00
2021-04-14 08:42:06 +02:00
2022-12-19 12:27:32 +01:00
2022-12-02 17:40:03 +01:00
2020-10-12 15:29:26 +02:00
2020-10-29 17:22:59 -05:00
2020-09-20 19:01:34 -07:00
2021-05-14 09:50:05 +02:00
2020-10-15 18:42:13 -07:00
2022-06-09 10:21:15 +02:00
2023-01-14 10:15:58 +01:00
2020-10-15 07:57:55 +02:00
2020-10-29 17:22:59 -05:00
2022-08-21 15:16:09 +02:00
2021-06-16 12:01:44 +02:00
2022-11-03 23:57:54 +09:00
2022-12-08 11:23:57 +01:00
2022-08-21 15:16:16 +02:00
2023-01-14 10:16:48 +01:00
2021-04-21 13:00:56 +02:00
2022-08-31 17:15:17 +02:00
2020-09-28 14:53:45 +01:00
2020-09-16 17:38:02 +05:30
2022-11-25 17:45:41 +01:00
2021-09-15 09:50:26 +02:00
2020-10-17 11:18:18 -07:00
2022-05-15 20:00:08 +02:00
2023-02-01 08:23:19 +01:00
2023-01-14 10:15:11 +01:00
2021-03-04 11:38:14 +01:00
2021-09-08 08:49:01 +02:00
2023-01-14 10:16:44 +01:00
2022-10-26 13:25:31 +02:00
2021-03-09 11:11:13 +01:00
2021-12-08 09:03:20 +01:00
2020-09-12 10:45:56 -07:00
2020-09-17 19:21:16 +02:00
2020-10-08 17:17:27 +02:00
2022-03-11 12:11:52 +01:00
2020-09-24 16:44:44 -07:00
2022-10-26 13:25:35 +02:00
2020-09-24 13:43:39 -06:00
2020-10-13 11:37:11 +02:00
2022-04-08 14:40:44 +02:00
2021-07-14 16:56:53 +02:00
2022-07-29 17:19:25 +02:00
2022-08-21 15:15:45 +02:00
2020-10-16 11:11:20 -07:00
2021-06-03 09:00:45 +02:00
2020-10-13 15:05:05 -06:00
2022-04-08 14:39:55 +02:00
2020-10-05 10:47:43 -06:00
2021-01-12 20:18:17 +01:00
2022-01-27 10:54:08 +01:00
2021-11-21 13:46:35 +01:00
2022-08-21 15:15:36 +02:00
2020-11-19 08:55:44 -05:00
2021-08-04 12:46:41 +02:00
2022-11-16 09:57:09 +01:00
2021-09-03 10:09:31 +02:00
2022-08-03 12:00:52 +02:00
2021-03-30 14:32:05 +02:00
2020-09-21 15:00:40 -07:00
2020-10-02 15:00:49 -07:00
2022-09-15 11:32:02 +02:00
2020-12-11 14:02:14 -08:00
2020-10-16 11:11:19 -07:00
2020-10-25 14:51:49 -07:00
2021-09-26 14:08:59 +02:00
2021-11-18 14:04:32 +01:00
2022-07-21 21:20:00 +02:00
2022-12-14 11:31:57 +01:00
2023-02-01 08:23:08 +01:00
2022-01-27 10:54:05 +01:00
2020-10-13 18:38:34 -07:00
2020-10-12 16:44:57 -07:00
2022-10-15 07:55:51 +02:00
2022-10-15 07:55:51 +02:00
2021-07-20 16:05:46 +02:00
2022-10-15 07:55:51 +02:00
2021-09-30 10:11:07 +02:00
2021-05-26 12:06:56 +02:00
2021-11-18 14:03:49 +01:00
2021-06-03 09:00:45 +02:00
2021-05-28 13:17:43 +02:00
2020-09-30 11:50:35 -07:00
2022-04-08 14:40:45 +02:00
2020-09-28 19:47:41 +02:00
2020-09-17 10:19:52 +03:00
2022-07-25 11:26:40 +02:00
2020-11-10 18:31:17 +01:00
2022-05-30 09:33:36 +02:00
2020-10-16 17:21:51 +02:00
2020-10-13 15:58:10 -07:00
2021-09-08 08:49:00 +02:00
2021-03-09 11:11:13 +01:00
2020-10-19 14:28:30 -07:00
2020-09-23 21:29:49 -07:00
2021-06-30 08:47:18 -04:00
2023-01-14 10:15:19 +01:00
2020-09-24 21:56:24 +02:00
2020-09-22 11:27:48 +02:00
2020-09-29 17:50:10 +09:00
2023-01-14 10:16:31 +01:00
2021-03-30 14:32:06 +02:00
2021-08-18 08:59:17 +02:00
2022-07-07 17:52:17 +02:00
2021-01-19 18:27:22 +01:00
2020-10-06 07:07:06 +02:00
2020-09-25 06:12:25 +02:00
2020-10-20 10:41:07 +02:00
2022-05-25 09:17:55 +02:00
2022-10-26 13:25:34 +02:00
2021-03-11 14:17:27 +01:00
2020-09-10 18:19:16 +02:00
2023-01-14 10:16:50 +01:00
2021-05-19 10:13:13 +02:00
2021-10-27 09:56:51 +02:00
2021-09-15 09:50:37 +02:00
2023-01-04 11:39:22 +01:00
2023-01-04 11:39:18 +01:00
2022-04-27 13:53:45 +02:00
2021-11-18 14:04:25 +01:00
2021-09-18 13:40:21 +02:00
2023-01-14 10:15:22 +01:00
2021-03-04 11:38:41 +01:00
2020-10-25 14:51:49 -07:00
2021-04-07 15:00:11 +02:00
2020-09-10 14:03:31 -07:00
2020-10-16 11:11:22 -07:00
2022-07-12 16:32:18 +02:00
2023-01-04 11:39:17 +01:00
2023-01-04 11:39:18 +01:00
2021-11-18 14:03:42 +01:00
2020-10-25 14:51:49 -07:00
2022-06-09 10:20:49 +02:00
2022-01-20 09:17:49 +01:00
2020-09-16 19:12:27 -04:00
2023-01-14 10:16:47 +01:00
2022-11-10 18:14:25 +01:00
2020-12-30 11:54:18 +01:00
2022-02-01 17:25:48 +01:00
2020-10-08 15:29:06 -04:00
2020-11-12 13:59:04 -07:00
2020-10-15 14:43:29 -07:00
2022-01-27 10:54:16 +01:00
2023-01-14 10:16:42 +01:00
2020-10-22 22:44:35 +02:00
2021-06-18 10:00:04 +02:00
2021-09-15 09:50:25 +02:00
2021-07-25 14:36:18 +02:00
2021-09-18 13:40:36 +02:00
2023-02-22 12:55:56 +01:00
2022-05-30 09:33:36 +02:00
2020-09-23 09:42:39 -07:00
2023-01-14 10:16:13 +01:00
2020-09-09 10:22:40 +02:00
2020-09-09 10:38:28 +02:00
2021-05-19 10:12:54 +02:00
2021-03-04 11:38:46 +01:00
2020-09-10 09:32:31 -06:00
2020-10-12 12:08:35 +02:00
2020-10-16 11:11:20 -07:00
2020-09-28 15:07:41 +02:00
2022-03-23 09:13:28 +01:00
2020-09-23 13:24:34 -07:00
2021-03-30 14:31:57 +02:00
2020-10-05 13:37:03 +02:00
2022-09-28 11:10:35 +02:00
2020-10-25 14:51:49 -07:00
2020-10-25 14:51:49 -07:00
2020-10-16 17:35:36 +02:00
2021-09-18 13:40:14 +02:00
2020-09-17 19:21:16 +02:00
2020-09-18 09:13:40 +03:00
2020-09-08 16:28:49 +03:00
2023-01-14 10:15:58 +01:00
2023-01-04 11:39:23 +01:00
2020-10-20 07:10:14 -06:00
2020-11-04 08:52:46 -08:00
2021-05-14 09:50:32 +02:00
2020-09-25 16:30:06 +02:00
2020-10-16 11:11:18 -07:00
2022-10-26 13:25:42 +02:00
2021-12-01 09:19:10 +01:00
2020-09-16 08:54:53 -05:00
2022-04-13 21:00:56 +02:00
2021-08-18 08:59:15 +02:00
2020-11-30 12:21:31 +01:00
2020-10-08 18:00:08 +02:00
2020-11-19 22:38:29 -05:00
2020-10-29 13:17:58 -05:00
2020-10-16 11:11:19 -07:00
2022-06-14 18:32:44 +02:00
2020-10-13 18:38:32 -07:00
2021-01-09 13:46:23 +01:00
2020-10-05 13:37:04 +02:00
2021-11-18 14:03:56 +01:00
2023-02-01 08:23:20 +01:00
2022-07-21 21:20:11 +02:00
2021-03-04 11:37:59 +01:00
2022-08-21 15:16:08 +02:00
2021-03-04 11:38:46 +01:00
2021-03-04 11:38:20 +01:00
2021-12-08 09:03:20 +01:00
2021-02-07 15:37:17 +01:00
2022-10-30 09:41:15 +01:00
2021-11-18 14:03:37 +01:00
2021-02-03 23:28:40 +01:00
2021-09-30 10:11:04 +02:00
2020-10-16 11:11:20 -07:00
2021-09-15 09:50:41 +02:00
2021-09-15 09:50:41 +02:00
2022-08-21 15:15:33 +02:00
2022-06-09 10:21:09 +02:00
2022-06-09 10:21:09 +02:00
2022-06-09 10:21:18 +02:00
2021-04-21 13:01:00 +02:00
2020-10-15 07:49:46 +02:00
2023-01-14 10:16:44 +01:00
2022-12-14 11:31:59 +01:00
2021-10-09 14:40:56 +02:00
2022-01-05 12:40:29 +01:00
2022-02-23 12:00:56 +01:00
2021-09-22 12:27:59 +02:00
2021-03-17 17:06:25 +01:00
2022-07-12 16:32:18 +02:00
2021-03-04 11:38:21 +01:00
2020-09-28 12:16:13 +02:00
2020-10-02 11:33:47 +02:00
2020-09-11 17:41:55 -07:00
2021-06-03 09:00:45 +02:00
2021-06-23 14:42:49 +02:00
2022-08-21 15:15:21 +02:00
2020-10-13 18:38:31 -07:00
2021-06-30 08:47:26 -04:00
2021-03-30 14:32:06 +02:00
2022-05-15 20:00:09 +02:00
2020-10-28 14:08:54 +00:00
2020-10-25 14:51:49 -07:00
2020-09-25 17:48:54 +10:00
2021-08-18 08:59:17 +02:00
2021-03-30 14:32:07 +02:00
2023-01-04 11:39:16 +01:00
2023-01-04 11:39:24 +01:00
2022-05-18 10:23:42 +02:00
2023-01-14 10:16:18 +01:00
2020-10-30 12:57:39 +01:00
2020-10-30 12:57:39 +01:00
2020-10-21 18:24:08 -07:00
2020-10-07 14:28:39 -04:00
2020-10-07 14:28:39 -04:00
2022-04-13 21:01:03 +02:00
2020-11-30 10:52:22 -05:00
2020-10-21 10:31:20 -04:00
2021-05-19 10:13:02 +02:00
2020-09-22 13:58:40 +02:00
2022-08-25 11:38:20 +02:00
2020-10-16 11:11:18 -07:00
2022-06-14 18:32:45 +02:00
2023-02-25 11:55:03 +01:00
2020-11-22 10:48:22 -08:00
2023-01-14 10:16:25 +01:00
2023-02-22 12:55:54 +01:00
2022-07-25 11:26:47 +02:00
2022-09-23 14:16:58 +02:00
2021-07-19 09:44:39 +02:00
2021-03-09 11:11:13 +01:00
2020-09-25 17:48:54 +10:00
2022-10-26 13:25:23 +02:00
2020-10-13 18:38:35 -07:00
2020-10-17 11:18:18 -07:00
2020-10-16 11:11:15 -07:00
2020-09-25 18:01:48 -04:00
2020-10-16 11:11:16 -07:00
2021-06-30 08:47:29 -04:00
2022-08-21 15:16:18 +02:00
2020-09-17 12:27:43 -05:00
2020-09-17 16:44:03 -05:00
2021-05-19 10:13:01 +02:00
2021-05-19 10:13:01 +02:00
2022-06-22 14:13:20 +02:00
2020-09-11 09:30:01 +03:00
2020-10-25 14:51:49 -07:00
2020-10-06 07:29:36 -06:00
2020-09-16 16:26:56 +02:00
2022-02-01 17:25:45 +01:00
2020-11-09 18:12:34 +01:00
2022-02-08 18:30:35 +01:00
2021-03-30 14:32:05 +02:00
2020-10-18 09:27:10 -07:00
2022-06-06 08:42:41 +02:00
2021-05-14 09:50:14 +02:00
2020-10-16 17:53:22 +02:00
2022-07-12 16:32:18 +02:00
2021-05-19 10:12:51 +02:00
2021-11-18 14:04:29 +01:00
2020-09-10 19:27:59 +02:00
2022-05-30 09:33:43 +02:00
2020-09-14 09:45:34 -07:00
2020-10-25 14:51:49 -07:00
2023-01-14 10:15:28 +01:00
2020-10-14 16:09:32 -07:00
2020-09-11 21:47:10 -07:00
2020-09-22 17:50:32 +02:00
2022-02-05 12:37:55 +01:00
2022-02-05 12:37:55 +01:00
2022-04-08 14:39:56 +02:00
2020-09-27 13:29:49 -07:00
2021-06-23 14:42:45 +02:00
2022-06-09 10:20:49 +02:00
2020-09-14 15:45:25 +02:00
2021-04-07 15:00:13 +02:00
2020-09-17 13:00:46 -04:00
2020-10-13 08:41:26 -04:00
2023-02-25 11:55:02 +01:00
2020-10-13 18:38:28 -07:00
2022-06-29 08:59:44 +02:00
2020-09-10 11:19:29 +02:00
2020-09-23 19:32:09 -07:00
2021-09-18 13:40:19 +02:00
2020-10-28 11:41:15 -06:00
2020-10-05 18:35:30 +01:00
2020-10-13 19:20:54 -05:00
2022-11-25 17:45:49 +01:00
2022-09-05 10:28:56 +02:00
2020-10-04 19:51:43 -07:00
2021-11-18 14:04:22 +01:00
2022-07-12 16:32:22 +02:00
2021-01-09 13:46:24 +01:00
2020-10-05 20:45:45 -03:00
2023-01-04 11:39:23 +01:00
2020-09-14 07:31:03 +01:00
2022-06-09 10:21:09 +02:00
2020-12-30 11:53:42 +01:00
2021-11-18 14:04:27 +01:00
2021-03-17 17:06:34 +01:00
2022-10-26 13:25:36 +02:00
2022-11-10 18:14:14 +01:00
2020-10-29 13:17:58 -05:00
2022-05-30 09:33:43 +02:00
2023-01-14 10:16:10 +01:00
2022-09-05 10:28:56 +02:00
2020-10-25 11:39:02 -07:00
2021-05-14 09:50:46 +02:00
2020-09-30 11:50:35 -07:00
2023-01-04 11:39:17 +01:00
2020-10-25 14:51:49 -07:00
2020-10-22 14:15:51 -06:00
2021-09-03 10:09:30 +02:00
2021-09-03 10:09:30 +02:00
2020-09-19 13:13:39 -07:00
2020-09-18 14:24:16 +01:00
2020-09-26 22:55:05 -04:00
2020-09-18 16:45:50 -04:00
2021-03-30 14:31:53 +02:00
2021-03-30 14:31:53 +02:00
2022-11-25 17:45:54 +01:00
2023-02-22 12:55:53 +01:00
2021-03-17 17:06:34 +01:00
2020-09-30 10:50:30 +02:00
2020-10-06 11:18:04 +02:00
2022-02-16 12:54:22 +01:00
2020-10-13 18:38:30 -07:00
2021-07-25 14:36:17 +02:00
2021-07-25 14:36:18 +02:00
2021-05-07 11:04:32 +02:00
2023-01-04 11:39:23 +01:00
2023-02-01 08:23:18 +01:00
2020-10-02 12:02:30 +02:00
2023-01-04 11:39:23 +01:00
2022-10-26 13:25:23 +02:00
2022-03-02 11:42:47 +01:00
2022-06-09 10:21:11 +02:00
2021-03-25 09:04:16 +01:00
2021-09-16 12:51:23 +02:00
2020-09-24 22:12:18 +02:00
2023-01-14 10:15:16 +01:00
2022-05-30 09:33:41 +02:00
2022-03-08 19:09:34 +01:00
2023-01-18 11:44:52 +01:00
2021-11-18 14:04:11 +01:00
2021-11-26 10:39:14 +01:00
2020-12-30 11:53:42 +01:00
2020-10-05 12:43:53 +02:00
2023-01-04 11:39:22 +01:00
2020-10-15 15:51:28 -07:00
2021-07-14 16:55:46 +02:00
2021-05-14 09:50:18 +02:00
2022-07-29 17:19:28 +02:00
2021-03-04 11:37:36 +01:00
2021-05-14 09:50:18 +02:00
2021-03-30 14:31:51 +02:00
2022-08-25 11:38:14 +02:00
2020-10-24 10:57:57 -07:00
2021-05-14 09:50:31 +02:00
2023-01-04 11:39:16 +01:00
2020-09-10 14:03:31 -07:00
2023-02-01 08:23:23 +01:00
2021-03-25 09:04:14 +01:00
2023-01-24 07:19:58 +01:00
2021-09-08 08:49:00 +02:00
2021-03-30 14:32:03 +02:00
2023-02-15 17:22:10 +01:00
2020-10-23 11:55:27 -04:00
2022-08-21 15:16:07 +02:00
2020-09-08 13:33:11 +02:00
2022-03-16 14:16:02 +01:00
2021-12-29 12:25:56 +01:00
2022-03-16 14:16:01 +01:00
2021-02-10 09:29:21 +01:00
2020-10-16 11:11:19 -07:00
2020-10-05 13:21:49 +02:00
2022-08-21 15:15:29 +02:00
2022-03-16 14:16:03 +01:00
2021-04-07 15:00:06 +02:00
2020-10-20 14:39:37 -07:00
2021-03-07 12:34:15 +01:00