Commit 4b1530f
mm/memcontrol,alloc_tag: handle slabobj_ext access under KASAN poison
In the near future, slabobj_ext may reside outside the allocated slab
object range within a slab, which could be reported as an out-of-bounds
access by KASAN.
As suggested by Andrey Konovalov [1], explicitly disable KASAN and KMSAN
checks when accessing slabobj_ext within slab allocator, memory profiling,
and memory cgroup code. While an alternative approach could be to unpoison
slabobj_ext, out-of-bounds accesses outside the slab allocator are
generally more common.
Move metadata_access_enable()/disable() helpers to mm/slab.h so that
it can be used outside mm/slub.c. However, as suggested by Suren
Baghdasaryan [2], instead of calling them directly from mm code (which is
more prone to errors), change users to access slabobj_ext via get/put
APIs:
- Users should call get_slab_obj_exts() to access slabobj_metadata
and call put_slab_obj_exts() when it's done.
- From now on, accessing it outside the section covered by
get_slab_obj_exts() ~ put_slab_obj_exts() is illegal.
This ensures that accesses to slabobj_ext metadata won't be reported
as access violations.
Call kasan_reset_tag() in slab_obj_ext() before returning the address to
prevent SW or HW tag-based KASAN from reporting false positives.
Suggested-by: Andrey Konovalov <andreyknvl@gmail.com>
Suggested-by: Suren Baghdasaryan <surenb@google.com>
Link: https://lore.kernel.org/linux-mm/CA+fCnZezoWn40BaS3cgmCeLwjT+5AndzcQLc=wH3BjMCu6_YCw@mail.gmail.com [1]
Link: https://lore.kernel.org/linux-mm/CAJuCfpG=Lb4WhYuPkSpdNO4Ehtjm1YcEEK0OM=3g9i=LxmpHSQ@mail.gmail.com [2]
Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
Link: https://patch.msgid.link/20260113061845.159790-7-harry.yoo@oracle.com
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>1 parent 7a8e71b commit 4b1530f
3 files changed
Lines changed: 95 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2604 | 2604 | | |
2605 | 2605 | | |
2606 | 2606 | | |
| 2607 | + | |
2607 | 2608 | | |
2608 | 2609 | | |
2609 | | - | |
2610 | | - | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
2611 | 2617 | | |
2612 | 2618 | | |
2613 | 2619 | | |
| |||
3219 | 3225 | | |
3220 | 3226 | | |
3221 | 3227 | | |
| 3228 | + | |
3222 | 3229 | | |
3223 | 3230 | | |
3224 | 3231 | | |
3225 | 3232 | | |
| 3233 | + | |
3226 | 3234 | | |
3227 | 3235 | | |
3228 | 3236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
511 | 529 | | |
512 | 530 | | |
513 | 531 | | |
| |||
517 | 535 | | |
518 | 536 | | |
519 | 537 | | |
520 | | - | |
521 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
522 | 554 | | |
523 | 555 | | |
524 | 556 | | |
| |||
537 | 569 | | |
538 | 570 | | |
539 | 571 | | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
540 | 583 | | |
541 | 584 | | |
542 | 585 | | |
| |||
565 | 608 | | |
566 | 609 | | |
567 | 610 | | |
| 611 | + | |
568 | 612 | | |
569 | 613 | | |
570 | 614 | | |
571 | 615 | | |
572 | 616 | | |
| 617 | + | |
| 618 | + | |
573 | 619 | | |
574 | 620 | | |
575 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
576 | 624 | | |
577 | 625 | | |
578 | 626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
972 | 972 | | |
973 | 973 | | |
974 | 974 | | |
975 | | - | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | | - | |
991 | | - | |
992 | | - | |
993 | 975 | | |
994 | 976 | | |
995 | 977 | | |
| |||
2055 | 2037 | | |
2056 | 2038 | | |
2057 | 2039 | | |
2058 | | - | |
2059 | 2040 | | |
| 2041 | + | |
2060 | 2042 | | |
2061 | 2043 | | |
2062 | 2044 | | |
2063 | 2045 | | |
| 2046 | + | |
2064 | 2047 | | |
2065 | 2048 | | |
2066 | 2049 | | |
2067 | 2050 | | |
2068 | 2051 | | |
2069 | | - | |
| 2052 | + | |
| 2053 | + | |
2070 | 2054 | | |
| 2055 | + | |
2071 | 2056 | | |
2072 | 2057 | | |
2073 | 2058 | | |
2074 | 2059 | | |
| 2060 | + | |
2075 | 2061 | | |
2076 | 2062 | | |
2077 | 2063 | | |
| |||
2287 | 2273 | | |
2288 | 2274 | | |
2289 | 2275 | | |
2290 | | - | |
2291 | | - | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
2292 | 2279 | | |
2293 | | - | |
2294 | | - | |
2295 | | - | |
2296 | | - | |
2297 | | - | |
2298 | | - | |
| 2280 | + | |
2299 | 2281 | | |
2300 | 2282 | | |
2301 | 2283 | | |
2302 | | - | |
| 2284 | + | |
2303 | 2285 | | |
2304 | 2286 | | |
2305 | | - | |
2306 | | - | |
| 2287 | + | |
2307 | 2288 | | |
2308 | 2289 | | |
| 2290 | + | |
2309 | 2291 | | |
2310 | 2292 | | |
2311 | 2293 | | |
2312 | 2294 | | |
| 2295 | + | |
2313 | 2296 | | |
| 2297 | + | |
2314 | 2298 | | |
2315 | 2299 | | |
2316 | 2300 | | |
| |||
2321 | 2305 | | |
2322 | 2306 | | |
2323 | 2307 | | |
2324 | | - | |
| 2308 | + | |
| 2309 | + | |
2325 | 2310 | | |
2326 | 2311 | | |
2327 | 2312 | | |
2328 | 2313 | | |
2329 | 2314 | | |
2330 | | - | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
2331 | 2320 | | |
2332 | | - | |
| 2321 | + | |
| 2322 | + | |
2333 | 2323 | | |
| 2324 | + | |
2334 | 2325 | | |
2335 | 2326 | | |
2336 | 2327 | | |
| |||
2356 | 2347 | | |
2357 | 2348 | | |
2358 | 2349 | | |
| 2350 | + | |
2359 | 2351 | | |
2360 | 2352 | | |
2361 | 2353 | | |
2362 | 2354 | | |
2363 | 2355 | | |
| 2356 | + | |
2364 | 2357 | | |
2365 | 2358 | | |
2366 | 2359 | | |
| |||
2427 | 2420 | | |
2428 | 2421 | | |
2429 | 2422 | | |
| 2423 | + | |
2430 | 2424 | | |
| 2425 | + | |
2431 | 2426 | | |
2432 | 2427 | | |
2433 | 2428 | | |
| |||
2477 | 2472 | | |
2478 | 2473 | | |
2479 | 2474 | | |
| 2475 | + | |
2480 | 2476 | | |
2481 | 2477 | | |
2482 | | - | |
| 2478 | + | |
| 2479 | + | |
2483 | 2480 | | |
| 2481 | + | |
| 2482 | + | |
2484 | 2483 | | |
2485 | 2484 | | |
2486 | 2485 | | |
| |||
0 commit comments