OSD: Reject inverted ranges in primary LIST #176
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:osd-primary-list-inverted-range"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
A primary LIST (
OSD_OP_SEC_LISTwithOSD_LIST_PRIMARY) withmin_stripeabovemax_stripemadeadd_primary_list()start fromlower_bound(min), which lies afterupper_bound(max). If an unclean (degraded, misplaced, incomplete or inconsistent) object of the PG was between the two bounds, the loop never met its end iterator and walked past the end of the btree: an out-of-bounds read, and the result set filled with garbage until the OSD ran out of memory. The OSD stops answering meanwhile.The request validation in
continue_primary_list()already forcesmin_inode == max_inode, so the stripes alone decide the order. This rejects an inverted range there with-EINVAL, like the other malformed requests, which also skips the store LIST. It is the primary-LIST sibling of6d7223d9"OSD: Reject inverted ranges in DESCRIBE".Such a request comes from a client, e.g.
vitastor-cli rm-data --min-offset A --max-offset Bwith A > B while the PG is degraded, or any client with read access to the inode whenuse_permsis on.Tested: new
test_primary_list_inverted_rangeinosd_test: a replicated PG with three degraded objects, then a primary LIST withmin_stripe=0x50000,max_stripe=0x30000(must get-EINVAL), and one withmin_stripe=0x30000and no upper bound (must still list the two objects above it). Without the fix, ASan reportsheap-buffer-overflowinadd_primary_list(), and a build without ASan never returns while its memory grows. With the fix the request gets-EINVAL, and the wholeosd_testpasses.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA