Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-5.3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup

Pull cgroup fix from Tejun Heo:
"Roman found and fixed a bug in the cgroup2 freezer which allows new
child cgroup to escape frozen state"

* 'for-5.3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
cgroup: freezer: fix frozen state inheritance
kselftests: cgroup: add freezer mkdir test

+63 -1
+9 -1
kernel/cgroup/cgroup.c
··· 5255 5255 * if the parent has to be frozen, the child has too. 5256 5256 */ 5257 5257 cgrp->freezer.e_freeze = parent->freezer.e_freeze; 5258 - if (cgrp->freezer.e_freeze) 5258 + if (cgrp->freezer.e_freeze) { 5259 + /* 5260 + * Set the CGRP_FREEZE flag, so when a process will be 5261 + * attached to the child cgroup, it will become frozen. 5262 + * At this point the new cgroup is unpopulated, so we can 5263 + * consider it frozen immediately. 5264 + */ 5265 + set_bit(CGRP_FREEZE, &cgrp->flags); 5259 5266 set_bit(CGRP_FROZEN, &cgrp->flags); 5267 + } 5260 5268 5261 5269 spin_lock_irq(&css_set_lock); 5262 5270 for (tcgrp = cgrp; tcgrp; tcgrp = cgroup_parent(tcgrp)) {
+54
tools/testing/selftests/cgroup/test_freezer.c
··· 448 448 } 449 449 450 450 /* 451 + * The test creates a cgroups and freezes it. Then it creates a child cgroup 452 + * and populates it with a task. After that it checks that the child cgroup 453 + * is frozen and the parent cgroup remains frozen too. 454 + */ 455 + static int test_cgfreezer_mkdir(const char *root) 456 + { 457 + int ret = KSFT_FAIL; 458 + char *parent, *child = NULL; 459 + int pid; 460 + 461 + parent = cg_name(root, "cg_test_mkdir_A"); 462 + if (!parent) 463 + goto cleanup; 464 + 465 + child = cg_name(parent, "cg_test_mkdir_B"); 466 + if (!child) 467 + goto cleanup; 468 + 469 + if (cg_create(parent)) 470 + goto cleanup; 471 + 472 + if (cg_freeze_wait(parent, true)) 473 + goto cleanup; 474 + 475 + if (cg_create(child)) 476 + goto cleanup; 477 + 478 + pid = cg_run_nowait(child, child_fn, NULL); 479 + if (pid < 0) 480 + goto cleanup; 481 + 482 + if (cg_wait_for_proc_count(child, 1)) 483 + goto cleanup; 484 + 485 + if (cg_check_frozen(child, true)) 486 + goto cleanup; 487 + 488 + if (cg_check_frozen(parent, true)) 489 + goto cleanup; 490 + 491 + ret = KSFT_PASS; 492 + 493 + cleanup: 494 + if (child) 495 + cg_destroy(child); 496 + free(child); 497 + if (parent) 498 + cg_destroy(parent); 499 + free(parent); 500 + return ret; 501 + } 502 + 503 + /* 451 504 * The test creates two nested cgroups, freezes the parent 452 505 * and removes the child. Then it checks that the parent cgroup 453 506 * remains frozen and it's possible to create a new child ··· 868 815 T(test_cgfreezer_simple), 869 816 T(test_cgfreezer_tree), 870 817 T(test_cgfreezer_forkbomb), 818 + T(test_cgfreezer_mkdir), 871 819 T(test_cgfreezer_rmdir), 872 820 T(test_cgfreezer_migrate), 873 821 T(test_cgfreezer_ptrace),