Commit 6ccbb31
committed
Fix vtable slot bounds checking for refined receiver types
When receiver types are refined during compilation (e.g., from an interface
to a concrete implementor), the vtable slot offset computed against the
original resolved class may fall outside the bounds of the refined class's
vtable. This can lead to reading arbitrary memory values as J9Method pointers,
causing crashes or incorrect devirtualization.
This commit adds vtable slot validation in three critical locations:
1. TR_PersistentCHTable::findSingleAbstractImplementer
- Added bounds check
2. TR_J9VMBase::getResolvedVirtualMethod
- Added bounds check
3. TR_J9VirtualCallSite::findCallSiteForAbstractClass
- Added name/signature verification
This fixes the root cause of a class of failures observed with invalid
vtable slot indices being used post-refinement, and we run into such issues
in the scenario described below:
- A virtual call is resolved against one class (e.g., interface implementor A)
- The receiver type is refined to a different class (e.g., implementor B)
- The vtable slot from class A is used to index into class B's vtable
- Class B's vtable may be smaller or have different layout, causing OOB access
Signed-off-by: Nazim Bhuiyan <nubhuiyan@ibm.com>1 parent 7458bef commit 6ccbb31
3 files changed
Lines changed: 57 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
501 | 517 | | |
502 | 518 | | |
503 | 519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7402 | 7402 | | |
7403 | 7403 | | |
7404 | 7404 | | |
7405 | | - | |
7406 | | - | |
| 7405 | + | |
| 7406 | + | |
| 7407 | + | |
| 7408 | + | |
| 7409 | + | |
| 7410 | + | |
| 7411 | + | |
| 7412 | + | |
| 7413 | + | |
| 7414 | + | |
| 7415 | + | |
| 7416 | + | |
| 7417 | + | |
| 7418 | + | |
| 7419 | + | |
| 7420 | + | |
| 7421 | + | |
| 7422 | + | |
| 7423 | + | |
| 7424 | + | |
| 7425 | + | |
| 7426 | + | |
| 7427 | + | |
| 7428 | + | |
| 7429 | + | |
| 7430 | + | |
7407 | 7431 | | |
7408 | 7432 | | |
7409 | 7433 | | |
7410 | 7434 | | |
7411 | | - | |
7412 | 7435 | | |
7413 | 7436 | | |
7414 | 7437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
444 | 459 | | |
445 | 460 | | |
446 | 461 | | |
| |||
1358 | 1373 | | |
1359 | 1374 | | |
1360 | 1375 | | |
1361 | | - | |
| |||
0 commit comments