Add kernel lockdown utility functions#6306
Conversation
|
All 3 definitions are functioning as expected
|
There was a problem hiding this comment.
Code Review
This pull request introduces functionality to manage kernel lockdown states in avocado/utils/linux.py, including functions to check the current mode and enable integrity or confidentiality modes via sysfs. The review feedback correctly identifies that the dmesg log verification used during the enablement process is redundant and fragile, as the state change is already confirmed by reading the sysfs file. Consequently, it is recommended to remove these checks and the associated dmesg module import to improve reliability and performance.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6306 +/- ##
==========================================
- Coverage 71.69% 71.58% -0.12%
==========================================
Files 206 206
Lines 23480 23519 +39
==========================================
Hits 16835 16835
- Misses 6645 6684 +39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
26301c9 to
e0f48e3
Compare
|
Hi @maramsmurthy, could you please rebase your branch on current |
e0f48e3 to
30f005f
Compare
Thank you so much for the update @harvey0100 ! Will do as suggested |
This commit adds three new utility functions to avocado.utils.linux for managing kernel lockdown security feature: 1. is_kernel_lockdown_enabled(): Check current lockdown state - Returns tuple of (mode, is_enabled) - Supports none, integrity, and confidentiality modes - Handles cases where lockdown feature is unavailable 2. enable_kernel_lockdown_integrity(): Enable integrity mode - Prevents kernel modification - Verifies mode change via sysfs 3. enable_kernel_lockdown_confidentiality(): Enable confidentiality mode - Most restrictive mode (prevents modification and data exposure) - Verifies mode change via sysfs All functions follow PEP 8 standards and include comprehensive docstrings. Lockdown mode transitions are one-way at runtime and require reboot to downgrade. Changes in v2 (addressing gemini-code-assist review): - Removed redundant and fragile dmesg verification from lockdown functions - Removed unused dmesg import - Simplified logic to rely solely on sysfs state verification - Improved reliability and performance by avoiding expensive dmesg operations Signed-off-by: Maram Srimannarayana Murthy <msmurthy@linux.vnet.ibm.com>
30f005f to
ac57af8
Compare
|
The fedora-rawhide-x86_64 builds are failing on many pull requests from what I can see, is this normal @harvey0100? Also @vaishnavibhat, what about a pull request in aautils that moves the linux file there in one first commit and this diff as second commit? I think adding code to the local avocado utils is only going to make future migration to aautils harder which is why this might be a good time to do it. |
Thanks for bringing this up! I'm also not aware of the root cause for the fedora-rawhide-x86_64 build failure. I've been observing this issue across multiple PRs recently, so it appears to be a broader infrastructure or dependency issue rather than something specific to this PR. I'll wait for @harvey0100 input on this, as they may have more context about the CI environment. In the meantime, I'll continue monitoring the other test results. @pevogam - Could you please comment about this context on one of @vaishnavibhat's open PRs? This will help ensure she's aware of the discussion and any relevant implications for her work. However, at this point in time, we'd like to proceed with adding this functionality to avocado.utils for the following reasons:
That said, I'd like to get @PraveenPenguin opinion on this approach to ensure we're aligned with the project's long-term direction. If there's strong consensus that we should migrate to aautils now, I'm happy to raise a separate PR under aautils for the same functionality. What do you think would be the best path forward? |
Would you mind linking to a particular PR because I don't find any open PRs on
Indeed, I could try to look into this but my concern is that the failing workflow is directly tied with Fedora and Fedora maintainers and red hatters like @harvey0100 are better related to their workflows. Let's see, if he is too busy I could look for any easy fixes or temporarily disabling / expected-fail-ing this particular workflow. |
This commit adds three new utility functions to avocado.utils.linux for managing kernel lockdown security feature:
is_kernel_lockdown_enabled(): Check current lockdown state
enable_kernel_lockdown_integrity(): Enable integrity mode
enable_kernel_lockdown_confidentiality(): Enable confidentiality mode
All functions follow PEP 8 standards and include comprehensive docstrings. Lockdown mode transitions are one-way at runtime and require reboot to downgrade.