Commit 8b6850f
committed
cgroup: Reorganize css_set_lock and kernfs path processing
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2077665
commit 46307fd
Author: Michal Koutný <mkoutny@suse.com>
Date: Mon, 10 Oct 2022 10:29:18 +0200
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>
Signed-off-by: Waiman Long <longman@redhat.com>1 parent eee9f1d commit 8b6850f
1 file changed
+27
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1378 | 1378 | | |
1379 | 1379 | | |
1380 | 1380 | | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
1381 | 1384 | | |
1382 | 1385 | | |
1383 | 1386 | | |
| |||
1389 | 1392 | | |
1390 | 1393 | | |
1391 | 1394 | | |
| 1395 | + | |
1392 | 1396 | | |
1393 | 1397 | | |
1394 | 1398 | | |
| |||
1400 | 1404 | | |
1401 | 1405 | | |
1402 | 1406 | | |
| 1407 | + | |
1403 | 1408 | | |
1404 | 1409 | | |
1405 | 1410 | | |
| |||
1422 | 1427 | | |
1423 | 1428 | | |
1424 | 1429 | | |
1425 | | - | |
1426 | 1430 | | |
1427 | 1431 | | |
1428 | 1432 | | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
1429 | 1452 | | |
1430 | 1453 | | |
1431 | 1454 | | |
1432 | 1455 | | |
1433 | | - | |
1434 | | - | |
1435 | 1456 | | |
1436 | 1457 | | |
1437 | 1458 | | |
1438 | | - | |
1439 | | - | |
1440 | | - | |
1441 | | - | |
| 1459 | + | |
1442 | 1460 | | |
1443 | 1461 | | |
1444 | 1462 | | |
| |||
6049 | 6067 | | |
6050 | 6068 | | |
6051 | 6069 | | |
6052 | | - | |
6053 | | - | |
6054 | | - | |
| 6070 | + | |
6055 | 6071 | | |
6056 | 6072 | | |
6057 | 6073 | | |
| |||
6619 | 6635 | | |
6620 | 6636 | | |
6621 | 6637 | | |
6622 | | - | |
6623 | | - | |
| 6638 | + | |
6624 | 6639 | | |
6625 | | - | |
6626 | 6640 | | |
6627 | 6641 | | |
6628 | 6642 | | |
| |||
0 commit comments