Commit 94f42b6
committed
osdc: Objecter::linger_by_cookie() for safe cast from uint64
a `linger_ops_set` was added for `Objecter::handle_watch_notify()`
as a safety check before casting `uint64_t cookie` to `LingerOp*`
and deferencing it
neorados also made use of this set through `Objecter::is_valid_watch()`
checks. however, this approach was still susceptible to use-after-free,
because the callers didn't preserve a LingerOp reference between this
check and its use - and the Objecter lock is dropped in between. in
addition, `neorados::RADOS::unwatch_()` was missing its check for
`is_valid_watch()`
librados did not make use of this `is_valid_watch()` at all, so was
casting cookies directly to LingerOp* and dereferencing. this results
in use-after-free for any cookies invalidated by `linger_cancel()` -
for example when called by `CB_DoWatchError`
replace `is_valid_watch()` with a `linger_by_cookie()` function that
* performs the validity check with `linger_ops_set`,
* safely reinterpret_casts the cookie to LingerOp*, and
* returns a reference to the caller via intrusive_ptr<LingerOp>
`librados::IoCtxImpl::watch_check()`, `unwatch()` and `aio_unwatch()`
now call `linger_by_cookie()`, so have to handle the null case by
returning `-ENOTCONN` (this matches neorados' existing behavior)
Fixes: https://tracker.ceph.com/issues/72771
Signed-off-by: Casey Bodley <[email protected]>1 parent 2455a71 commit 94f42b6
File tree
4 files changed
+62
-26
lines changed- src
- librados
- neorados
- osdc
4 files changed
+62
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1745 | 1745 | | |
1746 | 1746 | | |
1747 | 1747 | | |
1748 | | - | |
1749 | | - | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
1750 | 1753 | | |
1751 | 1754 | | |
1752 | 1755 | | |
| |||
1756 | 1759 | | |
1757 | 1760 | | |
1758 | 1761 | | |
1759 | | - | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
1760 | 1767 | | |
1761 | 1768 | | |
1762 | 1769 | | |
| |||
1766 | 1773 | | |
1767 | 1774 | | |
1768 | 1775 | | |
1769 | | - | |
| 1776 | + | |
1770 | 1777 | | |
1771 | 1778 | | |
1772 | 1779 | | |
| |||
1776 | 1783 | | |
1777 | 1784 | | |
1778 | 1785 | | |
1779 | | - | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
1780 | 1790 | | |
1781 | 1791 | | |
1782 | 1792 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1570 | 1570 | | |
1571 | 1571 | | |
1572 | 1572 | | |
1573 | | - | |
1574 | | - | |
| 1573 | + | |
| 1574 | + | |
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
| |||
1611 | 1611 | | |
1612 | 1612 | | |
1613 | 1613 | | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
1617 | 1617 | | |
1618 | 1618 | | |
1619 | 1619 | | |
| |||
1624 | 1624 | | |
1625 | 1625 | | |
1626 | 1626 | | |
1627 | | - | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
1628 | 1633 | | |
1629 | 1634 | | |
1630 | 1635 | | |
| |||
1637 | 1642 | | |
1638 | 1643 | | |
1639 | 1644 | | |
1640 | | - | |
| 1645 | + | |
1641 | 1646 | | |
1642 | 1647 | | |
1643 | 1648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | | - | |
| 660 | + | |
| 661 | + | |
661 | 662 | | |
662 | | - | |
| 663 | + | |
663 | 664 | | |
664 | 665 | | |
665 | 666 | | |
| |||
812 | 813 | | |
813 | 814 | | |
814 | 815 | | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
815 | 822 | | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
816 | 832 | | |
817 | 833 | | |
818 | 834 | | |
| |||
919 | 935 | | |
920 | 936 | | |
921 | 937 | | |
922 | | - | |
923 | | - | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
924 | 942 | | |
925 | 943 | | |
926 | 944 | | |
| |||
935 | 953 | | |
936 | 954 | | |
937 | 955 | | |
938 | | - | |
939 | | - | |
| 956 | + | |
| 957 | + | |
940 | 958 | | |
941 | 959 | | |
942 | 960 | | |
| |||
945 | 963 | | |
946 | 964 | | |
947 | 965 | | |
948 | | - | |
949 | | - | |
| 966 | + | |
| 967 | + | |
950 | 968 | | |
951 | 969 | | |
952 | 970 | | |
| |||
967 | 985 | | |
968 | 986 | | |
969 | 987 | | |
970 | | - | |
| 988 | + | |
971 | 989 | | |
972 | 990 | | |
973 | 991 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2592 | 2592 | | |
2593 | 2593 | | |
2594 | 2594 | | |
2595 | | - | |
2596 | | - | |
2597 | | - | |
2598 | | - | |
2599 | | - | |
2600 | 2595 | | |
2601 | 2596 | | |
2602 | 2597 | | |
| |||
3253 | 3248 | | |
3254 | 3249 | | |
3255 | 3250 | | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
3256 | 3259 | | |
3257 | 3260 | | |
3258 | 3261 | | |
| |||
0 commit comments