В ядре Linux была устранена следующая уязвимость: ocfs2: найти запись xattr снова после преобразования блока в ведро ocfs2_xattr_create_index_block() превращает неиндексированный блок xattr в дерево, копируя его в ведро, и копия сортирует записи: блок удерживает их в порядке вставки, ведро по имени хэша. ocfs2_xattr_update_xattr_search() тем не менее перемещает абонента в индекс поиска. Установка xattr, новое значение которого больше не соответствует блоку, приходит сюда с xs->not_found. Блок сдался, потому что ocfs2_xa_block_can_reuse() хочет точного соответствия размера имени, в то время как ocfs2_xa_bucket_can_reuse() хочет только запись, по крайней мере, такую же большую, как новый, поэтому ведро принимает пару, блок отклонен, и обновление попадает на любую запись, оставленную в этом индексе.
Равные длины проложенных имен заменяют значение другого атрибута, и его имя остается в покое, поэтому setxattr возвращает успех, в то время как запрошенный атрибут сохраняет свое старое значение. Более длинный ocfs2_xa_reuse_entry()'s BUG_ON, а более короткий также отказывается от ведра, поэтому ocfs2_xa_prepare_entry () стирает запись и пишет новое имя над ней, оставляя xe_name_hash, описывающий имя, которого больше нет. Найдите запись снова по имени, которое устанавливается, также соответствуя типу.
Копия содержит каждую запись и каждое имя без изменений, и (тип, имя) пары уникальны в блоке, поэтому совпадение является точным. Тип имеет значение, потому что обработчики удаляют свой префикс перед вызовом ocfs2_xattr_set(), поэтому user.foo и trusted.foo разделяют сохраненное имя, сохраненную длину и хэш, и оба могут сидеть в одном блоке. Название должно исходить от xi, а не от xs->here: неудавшийся набор может удалить имена записей xs->here, и только вызывающее устройство «growing» устанавливает ctxt->set_abort, что останавливает преобразование.
Сканируйте каждую запись, а не сужайте хэш, как это делает ocfs2_find_xe_in_bucket(), поскольку существующая запись хранит хэш, под которым она хранилась, и ядро, которое расширило байты имени, сделало их отличными от тех, что вычисляются сейчас. Пустой результат означает, что запись не пережила неудачный набор, и это стало вставкой; оставляя xs->here в одиночку, он будет указывать на блок, который переписывается как корень дерева, прежде чем вызывающий его снова прочитает его.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: ocfs2: find the xattr entry again after converting a block to a bucket ocfs2_xattr_create_index_block() turns a non-indexed xattr block into a tree by copying it into a bucket, and the copy sorts the entries: a block holds them in insertion order, a bucket by name hash. ocfs2_xattr_update_xattr_search() nevertheless relocates the caller's search by the index the entry had in the block, so unless the two orders agreed it points at an unrelated entry, and nothing between there and the write compares that entry's name with the one being set. Setting an xattr whose new value no longer fits the block arrives here with xs->not_found clear. The block gave up because ocfs2_xa_block_can_reuse() wants an exact namevalue size match, while ocfs2_xa_bucket_can_reuse() only wants an entry at least as large as the new one, so the bucket accepts a pair the block rejected and the update lands on whichever entry the sort left at that index. Equal padded name lengths get that other attribute's value replaced in place and its name left alone, so setxattr returns success while the attribute asked for keeps its old value. A longer one trips ocfs2_xa_reuse_entry()'s BUG_ON, and a shorter one is refused by the bucket as well, so ocfs2_xa_prepare_entry() wipes the entry and writes the new name over it, leaving xe_name_hash describing a name that is no longer there. Find the entry again by the name being set, matching the type as well. The copy carries every entry and every name over unchanged, and (type, name) pairs are unique within a block, so the match is exact. The type matters because the handlers strip their prefix before calling ocfs2_xattr_set(), so user.foo and trusted.foo share a stored name, a stored length and a hash, and both can sit in the same block. The name has to come from xi rather than from xs->here: a failed set can remove the entry xs->here names, and only the "growing" caller sets ctxt->set_abort, which is what stops the conversion. Scan every entry rather than narrowing on the hash the way ocfs2_find_xe_in_bucket() does, since an existing entry keeps the hash it was stored under, which a kernel that sign-extended the name bytes made different from the one computed now. An empty result means the entry did not survive the failed set and this has become an insert; leaving xs->here alone would keep it pointing into the block, which is rewritten as a tree root before the caller reads it again.