Commit 85b9679
committed
mm: memcg: use READ_ONCE()/WRITE_ONCE() to access stock->cached
jira KERNEL-325
Rebuild_History Non-Buildable kernel-4.18.0-553.89.1.el8_10
commit-author Roman Gushchin <roman.gushchin@linux.dev>
commit f785a8f
A memcg pointer in the percpu stock can be accessed by drain_all_stock()
from another cpu in a lockless way. In theory it might lead to an issue,
similar to the one which has been discovered with stock->cached_objcg,
where the pointer was zeroed between the check for being NULL and
dereferencing. In this case the issue is unlikely a real problem, but to
make it bulletproof and similar to stock->cached_objcg, let's annotate all
accesses to stock->cached with READ_ONCE()/WTRITE_ONCE().
Link: https://lkml.kernel.org/r/20230502160839.361544-2-roman.gushchin@linux.dev
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Acked-by: Shakeel Butt <shakeelb@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit f785a8f)
Signed-off-by: Jonathan Maple <jmaple@ciq.com>1 parent 86dfd78 commit 85b9679
1 file changed
+6
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2307 | 2307 | | |
2308 | 2308 | | |
2309 | 2309 | | |
2310 | | - | |
| 2310 | + | |
2311 | 2311 | | |
2312 | 2312 | | |
2313 | 2313 | | |
| |||
2322 | 2322 | | |
2323 | 2323 | | |
2324 | 2324 | | |
2325 | | - | |
| 2325 | + | |
2326 | 2326 | | |
2327 | 2327 | | |
2328 | 2328 | | |
| |||
2335 | 2335 | | |
2336 | 2336 | | |
2337 | 2337 | | |
2338 | | - | |
| 2338 | + | |
2339 | 2339 | | |
2340 | 2340 | | |
2341 | 2341 | | |
| |||
2371 | 2371 | | |
2372 | 2372 | | |
2373 | 2373 | | |
2374 | | - | |
| 2374 | + | |
2375 | 2375 | | |
2376 | 2376 | | |
2377 | | - | |
| 2377 | + | |
2378 | 2378 | | |
2379 | 2379 | | |
2380 | 2380 | | |
| |||
2408 | 2408 | | |
2409 | 2409 | | |
2410 | 2410 | | |
2411 | | - | |
| 2411 | + | |
2412 | 2412 | | |
2413 | 2413 | | |
2414 | 2414 | | |
| |||
0 commit comments