Qian Cai
7e23452002
percpu_counter: fix a data race at vm_committed_as
...
"vm_committed_as.count" could be accessed concurrently as reported by
KCSAN,
BUG: KCSAN: data-race in __vm_enough_memory / percpu_counter_add_batch
write to 0xffffffff9451c538 of 8 bytes by task 65879 on cpu 35:
percpu_counter_add_batch+0x83/0xd0
percpu_counter_add_batch at lib/percpu_counter.c:91
__vm_enough_memory+0xb9/0x260
dup_mm+0x3a4/0x8f0
copy_process+0x2458/0x3240
_do_fork+0xaa/0x9f0
__do_sys_clone+0x125/0x160
__x64_sys_clone+0x70/0x90
do_syscall_64+0x91/0xb05
entry_SYSCALL_64_after_hwframe+0x49/0xbe
read to 0xffffffff9451c538 of 8 bytes by task 66773 on cpu 19:
__vm_enough_memory+0x199/0x260
percpu_counter_read_positive at include/linux/percpu_counter.h:81
(inlined by) __vm_enough_memory at mm/util.c:839
mmap_region+0x1b2/0xa10
do_mmap+0x45c/0x700
vm_mmap_pgoff+0xc0/0x130
ksys_mmap_pgoff+0x6e/0x300
__x64_sys_mmap+0x33/0x40
do_syscall_64+0x91/0xb05
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The read is outside percpu_counter::lock critical section which results in
a data race. Fix it by adding a READ_ONCE() in
percpu_counter_read_positive() which could also service as the existing
compiler memory barrier.
Signed-off-by: Qian Cai <cai@lca.pw >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Acked-by: Marco Elver <elver@google.com >
Link: http://lkml.kernel.org/r/1582302724-2804-1-git-send-email-cai@lca.pw
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2020-04-07 10:43:43 -07:00
..
2020-04-01 08:03:28 +02:00
2020-03-23 13:07:08 +01:00
2020-03-24 16:19:01 -07:00
2020-04-03 15:05:35 -07:00
2020-04-01 14:47:40 -07:00
2020-03-31 21:29:04 +02:00
2020-03-08 17:28:51 +00:00
2020-03-24 12:43:47 +00:00
2020-03-17 20:48:41 +01:00
2020-04-01 18:18:18 -07:00
2020-03-26 14:45:31 +01:00
2020-03-30 10:14:19 +02:00
2020-03-15 15:20:16 +01:00
2020-03-15 15:20:16 +01:00
2020-03-15 15:20:16 +01:00
2020-03-15 15:20:16 +01:00
2020-03-15 15:20:16 +01:00
2020-03-17 22:50:30 +00:00
2020-03-19 13:59:46 +01:00
2020-03-31 22:08:54 +02:00
2020-04-03 15:05:35 -07:00
2020-03-06 21:31:23 +01:00
2020-03-30 11:45:18 -07:00
2020-03-24 07:57:08 -06:00
2020-03-18 21:57:20 +00:00
2020-03-08 22:07:09 -07:00
2020-04-03 11:30:20 -07:00
2020-04-03 15:05:35 -07:00
2020-03-20 19:25:14 +05:30
2020-03-31 16:18:55 -07:00
2020-03-27 12:17:31 -04:00
2020-03-16 22:08:34 -04:00
2020-04-02 15:50:04 -07:00
2020-04-06 10:14:39 -07:00
2020-03-28 13:19:05 -05:00
2020-03-31 10:05:01 -07:00
2020-03-25 10:03:36 -05:00
2020-03-27 12:04:34 -06:00
2020-03-12 15:48:37 -07:00
2020-04-07 10:43:42 -07:00
2020-03-21 15:23:53 +01:00
2020-03-27 10:23:43 -06:00
2020-03-30 11:43:51 -07:00
2020-03-30 01:34:00 +02:00
2020-03-30 01:34:00 +02:00
2020-03-30 14:59:53 -07:00
2020-03-30 17:36:33 -07:00
2020-03-30 19:52:37 -07:00
2020-03-27 16:07:24 -07:00
2020-03-28 13:21:08 +01:00
2020-04-03 11:30:20 -07:00
2020-03-25 17:38:23 -07:00
2020-03-21 15:23:56 +01:00
2020-03-31 11:04:05 -07:00
2020-04-07 10:43:42 -07:00
2020-04-07 10:43:42 -07:00
2020-03-21 16:00:24 +01:00
2020-03-17 15:26:43 +01:00
2020-03-21 15:23:53 +01:00
2020-03-21 11:32:20 +01:00
2020-03-28 11:42:55 +01:00
2020-03-16 15:48:54 +00:00
2020-03-20 13:06:18 +01:00
2020-04-03 11:32:13 -04:00
2020-04-01 14:47:40 -07:00
2020-03-25 08:35:03 +09:00
2020-03-12 22:34:48 -07:00
2020-03-09 11:12:19 +01:00
2020-03-16 10:48:12 +01:00
2020-03-11 14:56:14 +05:30
2020-03-10 10:30:52 +01:00
2020-03-20 14:57:54 +01:00
2020-03-31 11:04:05 -07:00
2020-03-21 15:24:00 +01:00
2020-03-22 23:06:34 +01:00
2020-03-17 20:56:58 -07:00
2020-03-19 07:41:01 +01:00
2020-03-25 08:16:13 +09:00
2020-03-25 23:17:16 +01:00
2020-03-20 08:47:27 -06:00
2020-03-13 12:49:51 -07:00
2020-03-20 14:54:04 +01:00
2020-04-04 11:58:55 -07:00
2020-03-19 21:56:54 -07:00
2020-03-25 10:27:16 +01:00
2020-03-25 10:27:16 +01:00
2020-03-30 11:20:13 -07:00
2020-04-07 10:43:38 -07:00
2020-03-21 16:03:53 +01:00
2020-03-17 17:25:06 +01:00
2020-03-27 20:19:24 -03:00
2020-04-07 10:43:39 -07:00
2020-04-02 09:35:32 -07:00
2020-04-02 09:35:32 -07:00
2020-03-10 12:20:04 +01:00
2020-04-02 15:54:13 -07:00
2020-03-29 21:25:29 -07:00
2020-03-12 07:43:57 -04:00
2020-03-12 22:34:48 -07:00
2020-03-13 14:25:46 +01:00
2020-03-08 11:06:42 +01:00
2020-03-11 14:15:20 -06:00
2020-03-12 07:07:38 -06:00
2020-03-23 22:00:02 -07:00
2020-03-29 22:30:57 -07:00
2020-03-21 16:00:24 +01:00
2020-03-08 11:06:40 +01:00
2020-03-17 19:13:32 +01:00
2020-04-01 13:20:14 +02:00
2020-03-21 15:23:58 +01:00
2020-04-02 09:35:30 -07:00
2020-03-16 15:53:47 -04:00
2020-03-29 12:40:41 +01:00
2020-04-02 09:35:25 -07:00
2020-03-30 18:51:47 -07:00
2020-03-31 10:48:03 -04:00
2020-03-26 10:28:20 -06:00
2020-03-31 17:29:33 -07:00
2020-03-17 17:25:06 +01:00
2020-03-23 18:40:25 +01:00
2020-03-30 01:34:00 +02:00
2020-03-31 17:29:33 -07:00
2020-03-21 15:23:56 +01:00
2020-03-09 20:13:16 -07:00
2020-03-17 22:51:16 -07:00
2020-04-02 09:35:28 -07:00
2020-04-07 10:43:41 -07:00
2020-04-07 10:43:40 -07:00
2020-04-02 09:35:31 -07:00
2020-04-07 10:43:41 -07:00
2020-03-26 15:51:07 +01:00
2020-03-26 14:33:38 -03:00
2020-03-15 17:10:14 -07:00
2020-03-19 07:41:02 +01:00
2020-04-07 10:43:38 -07:00
2020-04-07 10:43:41 -07:00
2020-04-07 10:43:39 -07:00
2020-04-07 10:43:42 -07:00
2020-04-03 13:22:40 -07:00
2020-03-24 13:42:44 +01:00
2020-03-24 07:57:08 -06:00
2020-03-21 16:00:24 +01:00
2020-03-13 21:08:19 -04:00
2020-03-26 20:17:36 -07:00
2020-03-30 19:52:37 -07:00
2020-03-18 16:35:48 -07:00
2020-03-25 18:58:11 -07:00
2020-03-30 19:56:50 -04:00
2020-03-19 07:41:02 +01:00
2020-04-02 09:35:27 -07:00
2020-04-07 10:43:39 -07:00
2020-04-07 10:43:38 -07:00
2020-04-07 10:43:38 -07:00
2020-03-25 09:50:09 -06:00
2020-04-03 14:25:02 -07:00
2020-03-28 13:19:04 -05:00
2020-04-02 17:57:10 +01:00
2020-04-02 17:57:10 +01:00
2020-04-03 14:25:02 -07:00
2020-04-07 10:43:43 -07:00
2020-03-27 10:41:44 -03:00
2020-03-23 22:00:02 -07:00
2020-03-30 11:52:27 -07:00
2020-04-01 08:06:54 +02:00
2020-03-17 18:31:05 +01:00
2020-04-07 10:43:42 -07:00
2020-04-02 11:22:17 -07:00
2020-03-20 13:06:18 +01:00
2020-03-20 13:06:19 +01:00
2020-03-30 11:16:38 -07:00
2020-03-21 16:00:22 +01:00
2020-03-25 22:29:45 -07:00
2020-03-06 22:33:38 -08:00
2020-03-27 16:39:01 -04:00
2020-04-02 18:47:30 +02:00
2020-03-21 16:00:24 +01:00
2020-03-21 16:00:24 +01:00
2020-04-02 11:22:17 -07:00
2020-03-31 15:49:51 -07:00
2020-04-07 10:43:42 -07:00
2020-03-17 15:58:00 +01:00
2020-03-12 17:16:42 +01:00
2020-04-07 10:43:38 -07:00
2020-03-26 14:41:22 -04:00
2020-03-29 21:53:18 -07:00
2020-03-09 22:34:58 +01:00
2020-03-30 12:18:49 -07:00
2020-03-21 16:00:24 +01:00
2020-03-21 16:00:24 +01:00
2020-04-07 10:43:43 -07:00
2020-03-18 09:50:20 +00:00
2020-03-09 20:13:16 -07:00
2020-03-23 13:41:55 +01:00
2020-04-02 09:35:27 -07:00
2020-04-07 10:43:41 -07:00
2020-04-05 11:34:35 -07:00
2020-03-07 09:52:02 +01:00
2020-03-29 22:14:48 -07:00
2020-03-21 17:48:13 +01:00
2020-03-30 18:51:47 -07:00
2020-03-21 15:23:58 +01:00
2020-03-21 15:23:57 +01:00
2020-03-30 14:59:53 -07:00
2020-04-02 09:35:26 -07:00
2020-03-19 17:48:36 -04:00
2020-03-18 12:34:10 +01:00
2020-04-07 10:43:39 -07:00
2020-03-23 17:01:47 +01:00
2020-03-24 09:32:41 -06:00
2020-04-07 10:43:38 -07:00
2020-03-21 18:56:06 -07:00
2020-04-03 12:27:36 -07:00
2020-03-12 17:42:08 -04:00
2020-03-16 15:53:47 -04:00
2020-03-09 11:12:19 +01:00