Commit 46307fd
cgroup: Reorganize css_set_lock and kernfs path processing
The commit 74e4b95 incorrectly wrapped kernfs_walk_and_get
(might_sleep) under css_set_lock (spinlock). css_set_lock is needed by
__cset_cgroup_from_root to ensure stable cset->cgrp_links but not for
kernfs_walk_and_get.
We only need to make sure that the returned root_cgrp won't be freed
under us. This is given in the case of global root because it is static
(cgrp_dfl_root.cgrp). When the root_cgrp is lower in the hierarchy, it
is pinned by cgroup_ns->root_cset (and `current` task cannot switch
namespace asynchronously so ns_proxy pins cgroup_ns).
Note this reasoning won't hold for root cgroups in v1 hierarchies,
therefore create a special-cased helper function just for the default
hierarchy.
Fixes: 74e4b95 ("cgroup: Honor caller's cgroup NS when resolving path")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>1 parent 4de65c5 commit 46307fd
1 file changed
+27
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1392 | 1392 | | |
1393 | 1393 | | |
1394 | 1394 | | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
1395 | 1398 | | |
1396 | 1399 | | |
1397 | 1400 | | |
| |||
1403 | 1406 | | |
1404 | 1407 | | |
1405 | 1408 | | |
| 1409 | + | |
1406 | 1410 | | |
1407 | 1411 | | |
1408 | 1412 | | |
| |||
1414 | 1418 | | |
1415 | 1419 | | |
1416 | 1420 | | |
| 1421 | + | |
1417 | 1422 | | |
1418 | 1423 | | |
1419 | 1424 | | |
| |||
1436 | 1441 | | |
1437 | 1442 | | |
1438 | 1443 | | |
1439 | | - | |
1440 | 1444 | | |
1441 | 1445 | | |
1442 | 1446 | | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
1443 | 1466 | | |
1444 | 1467 | | |
1445 | 1468 | | |
1446 | 1469 | | |
1447 | | - | |
1448 | | - | |
1449 | 1470 | | |
1450 | 1471 | | |
1451 | 1472 | | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
| 1473 | + | |
1456 | 1474 | | |
1457 | 1475 | | |
1458 | 1476 | | |
| |||
6105 | 6123 | | |
6106 | 6124 | | |
6107 | 6125 | | |
6108 | | - | |
6109 | | - | |
6110 | | - | |
| 6126 | + | |
6111 | 6127 | | |
6112 | 6128 | | |
6113 | 6129 | | |
| |||
6686 | 6702 | | |
6687 | 6703 | | |
6688 | 6704 | | |
6689 | | - | |
6690 | | - | |
| 6705 | + | |
6691 | 6706 | | |
6692 | | - | |
6693 | 6707 | | |
6694 | 6708 | | |
6695 | 6709 | | |
| |||
0 commit comments