Skip to content

fs: fix/improve cpuacct.usage_all parsing#50

Merged
AkihiroSuda merged 1 commit intoopencontainers:mainfrom
kolyshkin:fix-usage-all
Oct 31, 2025
Merged

fs: fix/improve cpuacct.usage_all parsing#50
AkihiroSuda merged 1 commit intoopencontainers:mainfrom
kolyshkin:fix-usage-all

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Oct 29, 2025

This is an alternative to #47, implementing ideas I left as review comments in there.

First, we can reasonably expect the first three fields of cpuacct.usage_all to be cpu user system, even for future kernels, and if we see something different, it doesn't make sense to continue. So check that the header is as expected, and error out otherwise.

Second, if we have more than 3 values, and we've checked that the first 3 are as expected (cpu user system), we can safely ignore extra columns. This fixes an issue on a custom kernel from Tencent, which
adds a few extra columns (see 1), as reported in #46.

Add tests for both cases.

Fixes: #46.

@kolyshkin kolyshkin added this to the 0.0.6 milestone Oct 29, 2025
@kolyshkin
Copy link
Contributor Author

@lifubang PTAL

Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @AkihiroSuda said, it would be nice if the commit message and/or test mentioned that this is necessary because of out-of-tree patches in Tencent's kernels, but otherwise LGTM.

First, we can reasonably expect the first three fields of
cpuacct.usage_all to be "cpu user system", even for future kernels,
and if we see something different, it doesn't make sense to continue.
So check that the header is as expected, and error out otherwise.

Second, if we have more than 3 values, and we've checked that the first
3 are as expected ("cpu user system"), we can safely ignore extra
columns. This fixes an issue on a custom kernel from Tencent, which
adds a few extra columns (see [1]), as reported in issue 46.

Add tests for both cases.

Fixes issue 46.

[1]: OpenCloudOS/TencentOS-kernel-0@0b66781
Reported-by: vimiix <i@vimiix.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin requested a review from AkihiroSuda October 30, 2025 19:17
@kolyshkin kolyshkin changed the title fs: improve cpuacct.usage_all parsing fs: fix/improve cpuacct.usage_all parsing Oct 30, 2025
@kolyshkin
Copy link
Contributor Author

@lifubang PTAL 🙏🏻

@AkihiroSuda AkihiroSuda merged commit e0c56cb into opencontainers:main Oct 31, 2025
14 checks passed
smallprogram added a commit to smallprogram/openwrt_packages that referenced this pull request Jan 29, 2026
cgroups: provide iocost statistics for cgroupv2. (opencontainers/cgroups#43)
cgroups: retry DBus connection when it fails with EAGAIN.(opencontainers/cgroups#45)
cgroups: improve cpuacct.usage_all resilience when parsing data from patched kernels (such as the Tencent kernels). (opencontainers/cgroups#46,opencontainers/cgroups#50)
libct: close child fds on prepareCgroupFD error. (openwrt#4936)
libct: fix mips compilation. (openwrt#4962, openwrt#4967)
When configuring a tmpfs mount, only set the mode= argument if the target path already existed. This fixes a regression introduced in our CVE-2025-52881 mitigation patches. (openwrt#4971, openwrt#4976)
Fix various file descriptor leaks and add additional tests to detect them as comprehensively as possible. (openwrt#5007, openwrt#5021, openwrt#5034)
The "hallucination" helpers added as part of the CVE-2025-52881 mitigation have been made more generic and now apply to all of our pathrs helper functions, which should ensure we will not regress dangling symlink users. (openwrt#4985)
Signed-off-by: David Mandy <smallprogramzhusir@gmail.com>

Signed-off-by: David Mandy <smallprogramzhusir@gmail.com>
smallprogram added a commit to smallprogram/openwrt_packages that referenced this pull request Jan 29, 2026
cgroups: provide iocost statistics for cgroupv2. (opencontainers/cgroups#43)
cgroups: retry DBus connection when it fails with EAGAIN.(opencontainers/cgroups#45)
cgroups: improve cpuacct.usage_all resilience when parsing data from patched kernels (such as the Tencent kernels). (opencontainers/cgroups#46,opencontainers/cgroups#50)
libct: close child fds on prepareCgroupFD error. (openwrt#4936)
libct: fix mips compilation. (openwrt#4962, openwrt#4967)
When configuring a tmpfs mount, only set the mode= argument if the target path already existed. This fixes a regression introduced in our CVE-2025-52881 mitigation patches. (openwrt#4971, openwrt#4976)
Fix various file descriptor leaks and add additional tests to detect them as comprehensively as possible. (openwrt#5007, openwrt#5021, openwrt#5034)
The "hallucination" helpers added as part of the CVE-2025-52881 mitigation have been made more generic and now apply to all of our pathrs helper functions, which should ensure we will not regress dangling symlink users. (openwrt#4985)
Signed-off-by: David Mandy <smallprogramzhusir@gmail.com>
smallprogram added a commit to smallprogram/openwrt_packages that referenced this pull request Jan 29, 2026
cgroups: provide iocost statistics for cgroupv2. (opencontainers/cgroups#43)
cgroups: retry DBus connection when it fails with EAGAIN.(opencontainers/cgroups#45)
cgroups: improve cpuacct.usage_all resilience when parsing data from patched kernels (such as the Tencent kernels). (opencontainers/cgroups#46,opencontainers/cgroups#50)
libct: close child fds on prepareCgroupFD error. (opencontainers/runc#4936)
libct: fix mips compilation. (opencontainers/runc#4962, opencontainers/runc#4967)
When configuring a tmpfs mount, only set the mode= argument if the target path already existed. This fixes a regression introduced in our CVE-2025-52881 mitigation patches. (opencontainers/runc#4971, opencontainers/runc#4976)
Fix various file descriptor leaks and add additional tests to detect them as comprehensively as possible. (opencontainers/runc#5007, opencontainers/runc#5021, opencontainers/runc#5034)
The "hallucination" helpers added as part of the CVE-2025-52881 mitigation have been made more generic and now apply to all of our pathrs helper functions, which should ensure we will not regress dangling symlink users. (opencontainers/runc#4985)
Signed-off-by: David Mandy <smallprogramzhusir@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kubelet fails to start due to cgroups CPU stat parsing failed in k8s 1.34

4 participants