Commit 18abda7
iommu/vt-d: Fix general protection fault in aux_detach_device()
The aux-domain attach/detach are not tracked, some data structures might
be used after free. This causes general protection faults when multiple
subdevices are created and assigned to a same guest machine:
| general protection fault, probably for non-canonical address 0xdead000000000100: 0000 [#1] SMP NOPTI
| RIP: 0010:intel_iommu_aux_detach_device+0x12a/0x1f0
| [...]
| Call Trace:
| iommu_aux_detach_device+0x24/0x70
| vfio_mdev_detach_domain+0x3b/0x60
| ? vfio_mdev_set_domain+0x50/0x50
| iommu_group_for_each_dev+0x4f/0x80
| vfio_iommu_detach_group.isra.0+0x22/0x30
| vfio_iommu_type1_detach_group.cold+0x71/0x211
| ? find_exported_symbol_in_section+0x4a/0xd0
| ? each_symbol_section+0x28/0x50
| __vfio_group_unset_container+0x4d/0x150
| vfio_group_try_dissolve_container+0x25/0x30
| vfio_group_put_external_user+0x13/0x20
| kvm_vfio_group_put_external_user+0x27/0x40 [kvm]
| kvm_vfio_destroy+0x45/0xb0 [kvm]
| kvm_put_kvm+0x1bb/0x2e0 [kvm]
| kvm_vm_release+0x22/0x30 [kvm]
| __fput+0xcc/0x260
| ____fput+0xe/0x10
| task_work_run+0x8f/0xb0
| do_exit+0x358/0xaf0
| ? wake_up_state+0x10/0x20
| ? signal_wake_up_state+0x1a/0x30
| do_group_exit+0x47/0xb0
| __x64_sys_exit_group+0x18/0x20
| do_syscall_64+0x57/0x1d0
| entry_SYSCALL_64_after_hwframe+0x44/0xa9
Fix the crash by tracking the subdevices when attaching and detaching
aux-domains.
Fixes: 67b8e02 ("iommu/vt-d: Aux-domain specific domain attach/detach")
Co-developed-by: Xin Zeng <xin.zeng@intel.com>
Signed-off-by: Xin Zeng <xin.zeng@intel.com>
Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/1609949037-25291-3-git-send-email-yi.l.liu@intel.com
Signed-off-by: Will Deacon <will@kernel.org>1 parent 9ad9f45 commit 18abda7
2 files changed
Lines changed: 82 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1877 | 1877 | | |
1878 | 1878 | | |
1879 | 1879 | | |
| 1880 | + | |
1880 | 1881 | | |
1881 | 1882 | | |
1882 | 1883 | | |
| |||
2547 | 2548 | | |
2548 | 2549 | | |
2549 | 2550 | | |
2550 | | - | |
| 2551 | + | |
2551 | 2552 | | |
2552 | 2553 | | |
2553 | 2554 | | |
| |||
4475 | 4476 | | |
4476 | 4477 | | |
4477 | 4478 | | |
4478 | | - | |
4479 | | - | |
| 4479 | + | |
| 4480 | + | |
| 4481 | + | |
| 4482 | + | |
| 4483 | + | |
| 4484 | + | |
| 4485 | + | |
| 4486 | + | |
| 4487 | + | |
| 4488 | + | |
| 4489 | + | |
| 4490 | + | |
| 4491 | + | |
| 4492 | + | |
| 4493 | + | |
| 4494 | + | |
| 4495 | + | |
4480 | 4496 | | |
4481 | 4497 | | |
| 4498 | + | |
4482 | 4499 | | |
4483 | 4500 | | |
4484 | 4501 | | |
4485 | | - | |
| 4502 | + | |
| 4503 | + | |
| 4504 | + | |
| 4505 | + | |
| 4506 | + | |
| 4507 | + | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
4486 | 4511 | | |
4487 | | - | |
4488 | | - | |
| 4512 | + | |
4489 | 4513 | | |
4490 | 4514 | | |
4491 | | - | |
4492 | | - | |
| 4515 | + | |
| 4516 | + | |
4493 | 4517 | | |
4494 | 4518 | | |
| 4519 | + | |
| 4520 | + | |
4495 | 4521 | | |
4496 | 4522 | | |
4497 | | - | |
4498 | | - | |
| 4523 | + | |
| 4524 | + | |
4499 | 4525 | | |
4500 | | - | |
4501 | | - | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
4502 | 4532 | | |
4503 | | - | |
4504 | | - | |
| 4533 | + | |
4505 | 4534 | | |
4506 | 4535 | | |
4507 | 4536 | | |
| |||
4530 | 4559 | | |
4531 | 4560 | | |
4532 | 4561 | | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
4533 | 4575 | | |
4534 | 4576 | | |
4535 | 4577 | | |
| |||
4548 | 4590 | | |
4549 | 4591 | | |
4550 | 4592 | | |
4551 | | - | |
4552 | | - | |
4553 | | - | |
4554 | 4593 | | |
| 4594 | + | |
| 4595 | + | |
4555 | 4596 | | |
4556 | 4597 | | |
4557 | 4598 | | |
| |||
4560 | 4601 | | |
4561 | 4602 | | |
4562 | 4603 | | |
| 4604 | + | |
| 4605 | + | |
4563 | 4606 | | |
4564 | | - | |
| 4607 | + | |
4565 | 4608 | | |
4566 | 4609 | | |
4567 | 4610 | | |
| |||
4581 | 4624 | | |
4582 | 4625 | | |
4583 | 4626 | | |
4584 | | - | |
4585 | | - | |
4586 | | - | |
4587 | | - | |
4588 | | - | |
4589 | | - | |
| 4627 | + | |
| 4628 | + | |
| 4629 | + | |
| 4630 | + | |
| 4631 | + | |
| 4632 | + | |
| 4633 | + | |
4590 | 4634 | | |
4591 | 4635 | | |
| 4636 | + | |
| 4637 | + | |
| 4638 | + | |
4592 | 4639 | | |
4593 | 4640 | | |
4594 | 4641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
536 | | - | |
537 | 536 | | |
538 | 537 | | |
539 | 538 | | |
540 | | - | |
| 539 | + | |
541 | 540 | | |
542 | 541 | | |
543 | 542 | | |
| |||
610 | 609 | | |
611 | 610 | | |
612 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
613 | 621 | | |
614 | 622 | | |
615 | 623 | | |
616 | 624 | | |
617 | 625 | | |
618 | | - | |
619 | | - | |
620 | | - | |
| 626 | + | |
621 | 627 | | |
622 | 628 | | |
623 | 629 | | |
| |||
0 commit comments