В ядре Linux устранена следующая уязвимость:
binfmt_misc: установите have_execfd только после открытия интерпретатора
load_misc_binary() вызывает bprm->have_execfd, как только видит «O»
(или «C»). Это происходит задолго до открытия интерпретатора. Если
в случае неудачного открытия флаг остается установленным на bprm. binfmt_misc находится в
заголовок списка форматов, поэтому ошибка открытия интерпретатора возвращает
-ENOEXEC позволяет перейти к более позднему формату поиска.
Это значит, что это
запускает соответствующий двоичный файл напрямую, никогда не устанавливая интерпретатор. Итак
bprm->исполняемый файл имеет значение NULL, а have_execfd ложно запрашивает дескриптор
присутствует. Следовательно, Begin_new_exec() разыменовывает отсутствующий исполняемый файл:
will_dump(bprm, bprm->исполняемый файл);
и NULL разыгрывает.
Если бы не это, передача позже в той же функции
в любом случае потерпел бы неудачу. FD_ADD(0, bprm->исполняемый файл) отклоняет NULL
файл с -ENOMEM. Оба сайта прошли точку невозврата, так что
exec не может быть отменен в любом случае.
Доступ к нему могут получить непривилегированные пользователи, поскольку можно смонтировать binfmt_misc.
в пространствах имен пользователей. Таким образом, пользователь может зарегистрировать запись «О», чья
интерпретатор живет на монтировании FUSE, сервер FUSE не может открыть
с -ENOEXEC и выполните собственный файл ELF, соответствующий записи.
have_execfd означает только что-то рядом с исполняемым файлом, который он описывает.
который не устанавливается до тех пор, пока интерпретатор не будет открыт и подготовлен. Итак, давайте поднимем его там, рядом с execfd_creds, который уже установлен в
этот момент.
Открытый сбой теперь оставляет это ясным, поэтому резервный формат
получает учетные данные из двоичного файла и не выдает AT_EXECFD, как это было бы
для любого родного исполнителя. Перезапись argv load_misc_binary() выполняется раньше.
открытие все еще не отменено. Это означает, что двоичный файл видит интерпретатор
путь в argv[0] и собственный путь в argv[1], но это предшествует этому
изменение и стало заметным только после того, как руководитель перестал ошибаться.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: binfmt_misc: set have_execfd only once the interpreter is opened load_misc_binary() raises bprm->have_execfd as soon as it sees the 'O' (or 'C') flag. This happens well before it opens the interpreter. If that open fails the flag stays set on the bprm. binfmt_misc is at the head of the format list so an interpreter open failure that returns -ENOEXEC lets the search fall through to a later format. This means it runs the matched binary directly having never staged an interpreter. So bprm->executable is NULL while have_execfd falsely claims a descriptor is present. Consequently, begin_new_exec() dereferences the missing executable: would_dump(bprm, bprm->executable); and NULL derefs. Had it not, the hand-off later in the same function would have failed anyway. FD_ADD(0, bprm->executable) rejects a NULL file with -ENOMEM. Both sites are past the point of no return so the exec cannot be unwound either way. This can be reached by unprivileged users as binfmt_misc can be mounted in user namespaces. So a user can register an 'O' entry whose interpreter lives on a FUSE mount, have the FUSE server fail the open with -ENOEXEC and execute a native ELF file that matches the entry. have_execfd only means anything alongside the executable it describes which is not set until the interpreter has been opened and staged. So lets raise it there, next to execfd_creds, which is already set at that point. An open failure now leaves it clear, so the fallback format derives credentials from the binary and emits no AT_EXECFD, as it would for any native exec. The argv rewrite load_misc_binary() performs before the open is still not undone. This means the binary sees the interpreter path in argv[0] and its own path in argv[1] but that predates this change and only became observable once the exec stopped faulting.