CVE-2022-49647

In the Linux kernel, the following vulnerability has been resolved: cgroup: Use separate src/dst nodes when preloading css_sets for migration Each cset (css_set) is pinned by its tasks. When we're moving tasks around across csets for a migration, we need to hold the source and destination csets to ensure that they don't go away while we're moving tasks about. This is done by linking cset->mg_preload_node on either the mgctx->preloaded_src_csets or mgctx->preloaded_dst_csets list. Using the same cset->mg_preload_node for both the src and dst lists was deemed okay as a cset can't be both the source and destination at the same time. Unfortunately, this overloading becomes problematic when multiple tasks are involved in a migration and some of them are identity noop migrations while others are actually moving across cgroups. For example, this can happen with the following sequence on cgroup1: #1> mkdir -p /sys/fs/cgroup/misc/a/b #2> echo $$ > /sys/fs/cgroup/misc/a/cgroup.procs #3> RUN_A_COMMAND_WHICH_CREATES_MULTIPLE_THREADS & #4> PID=$! #5> echo $PID > /sys/fs/cgroup/misc/a/b/tasks #6> echo $PID > /sys/fs/cgroup/misc/a/cgroup.procs the process including the group leader back into a. In this final migration, non-leader threads would be doing identity migration while the group leader is doing an actual one. After #3, let's say the whole process was in cset A, and that after #4, the leader moves to cset B. Then, during #6, the following happens: 1. cgroup_migrate_add_src() is called on B for the leader. 2. cgroup_migrate_add_src() is called on A for the other threads. 3. cgroup_migrate_prepare_dst() is called. It scans the src list. 4. It notices that B wants to migrate to A, so it tries to A to the dst list but realizes that its ->mg_preload_node is already busy. 5. and then it notices A wants to migrate to A as it's an identity migration, it culls it by list_del_init()'ing its ->mg_preload_node and putting references accordingly. 6. The rest of migration takes place with B on the src list but nothing on the dst list. This means that A isn't held while migration is in progress. If all tasks leave A before the migration finishes and the incoming task pins it, the cset will be destroyed leading to use-after-free. This is caused by overloading cset->mg_preload_node for both src and dst preload lists. We wanted to exclude the cset from the src list but ended up inadvertently excluding it from the dst list too. This patch fixes the issue by separating out cset->mg_preload_node into ->mg_src_preload_node and ->mg_dst_preload_node, so that the src and dst preloadings don't interfere with each other.
Configurations

Configuration 1 (hide)

OR cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc4:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc5:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc6:*:*:*:*:*:*

History

24 Mar 2025, 19:00

Type Values Removed Values Added
First Time Linux linux Kernel
Linux
CPE cpe:2.3:o:linux:linux_kernel:5.19:rc6:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc5:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:5.19:rc4:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
References () https://git.kernel.org/stable/c/05f7658210d1d331e8dd4cb6e7bbbe3df5f5ac27 - () https://git.kernel.org/stable/c/05f7658210d1d331e8dd4cb6e7bbbe3df5f5ac27 - Patch
References () https://git.kernel.org/stable/c/07fd5b6cdf3cc30bfde8fe0f644771688be04447 - () https://git.kernel.org/stable/c/07fd5b6cdf3cc30bfde8fe0f644771688be04447 - Patch
References () https://git.kernel.org/stable/c/0e41774b564befa6d271e8d5086bf870d617a4e6 - () https://git.kernel.org/stable/c/0e41774b564befa6d271e8d5086bf870d617a4e6 - Patch
References () https://git.kernel.org/stable/c/54aee4e5ce8c21555286a6333e46c1713880cf93 - () https://git.kernel.org/stable/c/54aee4e5ce8c21555286a6333e46c1713880cf93 - Patch
References () https://git.kernel.org/stable/c/7657e3958535d101a24ab4400f9b8062b9107cc4 - () https://git.kernel.org/stable/c/7657e3958535d101a24ab4400f9b8062b9107cc4 - Patch
References () https://git.kernel.org/stable/c/ad44e05f3e016bdcb1ad25af35ade5b5f41ccd68 - () https://git.kernel.org/stable/c/ad44e05f3e016bdcb1ad25af35ade5b5f41ccd68 - Patch
References () https://git.kernel.org/stable/c/cec2bbdcc14fbaa6b95ee15a7c423b05d97038be - () https://git.kernel.org/stable/c/cec2bbdcc14fbaa6b95ee15a7c423b05d97038be - Patch

27 Feb 2025, 19:15

Type Values Removed Values Added
Summary
  • (es) En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: cgroup: usar nodos src/dst separados al precargar css_sets para la migración Cada cset (css_set) está fijado por sus tareas. Cuando estamos moviendo tareas entre csets para una migración, necesitamos mantener los csets de origen y destino para asegurarnos de que no desaparezcan mientras movemos tareas. Esto se hace vinculando cset->mg_preload_node en la lista mgctx->preloaded_src_csets o mgctx->preloaded_dst_csets. Se consideró correcto usar el mismo cset->mg_preload_node para las listas src y dst, ya que un cset no puede ser el origen y el destino al mismo tiempo. Desafortunadamente, esta sobrecarga se vuelve problemática cuando hay varias tareas involucradas en una migración y algunas de ellas son migraciones de noop de identidad mientras que otras en realidad se están moviendo entre cgroup1: #1> mkdir -p /sys/fs/cgroup/misc/a/b #2> echo $$ > /sys/fs/cgroup/misc/a/cgroup.procs #3> RUN_A_COMMAND_WHICH_CREATES_MULTIPLE_THREADS & #4> PID=$! #5> echo $PID > /sys/fs/cgroup/misc/a/b/tasks #6> echo $PID > /sys/fs/cgroup/misc/a/cgroup.procs el proceso que incluye al líder del grupo de nuevo en a. En esta migración final, los subprocesos que no son líderes estarían realizando la migración de identidad mientras que el líder del grupo está realizando una real. Después del n.° 3, digamos que todo el proceso estaba en cset A, y que después del n.° 4, el líder se mueve al cset B. Luego, durante el n.° 6, sucede lo siguiente: 1. se llama a cgroup_migrate_add_src() en B para el líder. 2. se llama a cgroup_migrate_add_src() en A para los otros subprocesos. 3. se llama a cgroup_migrate_prepare_dst(). Escanea la lista src. 4. Se da cuenta de que B quiere migrar a A, por lo que intenta llevar A a la lista dst pero se da cuenta de que su ->mg_preload_node ya está ocupado. 5. y luego se da cuenta de que A quiere migrar a A como es una migración de identidad, lo descarta haciendo list_del_init()'ing su ->mg_preload_node y poniendo referencias en consecuencia. 6. El resto de la migración se lleva a cabo con B en la lista src pero nada en la lista dst. Esto significa que A no se mantiene mientras la migración está en progreso. Si todas las tareas abandonan A antes de que finalice la migración y la tarea entrante lo fija, el cset se destruirá, lo que provocará un use-after-free. Esto se debe a la sobrecarga de cset->mg_preload_node para las listas de precarga de src y dst. Queríamos excluir el cset de la lista de src, pero terminamos excluyéndolo inadvertidamente también de la lista de dst. Este parche soluciona el problema al separar cset->mg_preload_node en ->mg_src_preload_node y ->mg_dst_preload_node, de modo que las precargas de src y dst no interfieran entre sí.
CWE CWE-416
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 7.8

26 Feb 2025, 07:01

Type Values Removed Values Added
New CVE

Information

Published : 2025-02-26 07:01

Updated : 2025-03-24 19:00


NVD link : CVE-2022-49647

Mitre link : CVE-2022-49647

CVE.ORG link : CVE-2022-49647


JSON object : View

Products Affected

linux

  • linux_kernel
CWE
CWE-416

Use After Free