Fix panic due to nil dereference cgroups v2#11069
Fix panic due to nil dereference cgroups v2#11069AkihiroSuda merged 1 commit intocontainerd:mainfrom
Conversation
|
Notice the change only fixes/avoid the nil deference panic issue. It seems in current shim implementation, cgroups related errors in are ignored (only logged) and don't cause task |
Signed-off-by: Jin Dong <[email protected]>
ad5509e to
0903f20
Compare
|
@AkihiroSuda could you PTAL? I realized the same issue exists in two places ( |
|
hi @AkihiroSuda could you please re-add this to merge queue? thanks. Last time it was moved out due to criu install/download failures. |
|
/cherrypick release/2.0 |
|
@djdongjin: new pull request created: #11098 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/cherrypick release/1.7 |
|
/cherrypick release/1.6 |
|
@djdongjin: #11069 failed to apply on top of branch "release/1.7": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@djdongjin: #11069 failed to apply on top of branch "release/1.6": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Fix #11001
When the shim creates a container within
NewContainer, the cgroups v1/v2 may be nil due to errors.containerd/cmd/containerd-shim-runc-v2/runc/container.go
Lines 149 to 166 in 566f9f4
However, a
nilpointer of*cgroupsv2.Managertype is not annilinterface{}. And it can be converted back to*cgroupsv2.Managertype (the resulted var will benil) which causes nil deference panic inStartin the above issue. (sample: https://go.dev/play/p/ZThwvj1n3g8)containerd/cmd/containerd-shim-runc-v2/task/service.go
Lines 316 to 317 in 566f9f4
The fix is to return directly on error (to avoid
container.cgroup = cg), so the switch inStartwill match neithercgroup1.Cgroup(interface) nor*cgroupsv2.Manager.