В ядре Linux устранена следующая уязвимость: mm/mempolicy: заряжать общие узлы политики Any локальный пользователь может обойти memory.max с mbind() на файле tmpfs, и выделить неограниченную память ядра. mbind() устанавливает политику памяти NUMA для диапазона отображения. Если отображение состоит из shmem и друзей, ядро также сохраняет политику в inode, в дереве с одной записью на диапазон файла. Каждый mbind() на одной странице отображения может добавить один общий узел политики (struct sp_node) и одну struct mempolicy к этому дереву.
Они переживают картирование и остаются там до тех пор, пока инод не будет уничтожен. Дерево не ограничено размером файла, поэтому файл может быть пустым. Память, которую может выделить пространство пользователя, должна быть заряжена в cgroup памяти.
Кэш плиты делает это для всех своих объектов, если он создан с помощью SLAB_ACCOUNT. numa_policy_init() создает кэш плиты для обеих структур без SLAB_ACCOUNT, поэтому они не заряжаются ни для какой cgroup. Воспроизводится с mbind() на отдельных страницах пустого файла tmpfs, из cgroup с memory.max8M: глобальный убийца OOM убил задачи, принадлежащие root, и машина запаниковала. Исправьте это, создав оба кэша с SLAB_ACCOUNT.
Это изменение подразумевает, что mbind () теперь может выйти из строя при запуске в пределах memcg. Кроме того, policy_cache также служит задачам и политикам VMA, поэтому теперь они также учитываются. Обратите внимание, что ограничения по файлам не очень полезны, так как пользователь может просто использовать много файлов; наличие ограничений для пользователя также сложно.
Исправление, сгенерированное LLM и представленное Chris Mason в частном порядке. [david: меньшие настройки описания ]
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: mm/mempolicy: charge shared policy nodes Any local user can bypass memory.max with mbind() on a tmpfs file, and allocate unbounded kernel memory. mbind() sets a NUMA memory policy for a range of a mapping. If the mapping is of a shmem and friends, the kernel also stores the policy on the inode, in a tree with one entry per range of the file. Each mbind() on a single page of a mapping can add one shared policy node (struct sp_node) and one struct mempolicy to that tree. They outlive the mapping and stay around until the inode is destroyed. The tree is not bounded by the file size, so the file can be empty. Memory that user space can allocate must be charged to a memory cgroup. A slab cache does that for all of its objects if it is created with SLAB_ACCOUNT. numa_policy_init() creates the slab caches for both structs without SLAB_ACCOUNT, so they are not charged to any cgroup. Reproduced with mbind() on single pages of an empty tmpfs file, from a cgroup with memory.max=8M: the global OOM killer killed tasks owned by root, and the machine panicked. Fix this by creating both caches with SLAB_ACCOUNT. This change implies that mbind() can now fail when running into memcg limits. Further, the policy_cache also serves task and VMA policies, so they are similarly accounted now. Note that per-file limits are not really helpful, as the user could simply use many files; having limits per user is tricky as well. Fix generated by an LLM and submitted by Chris Mason in private. [ david: smaller description tweaks ]