Skip to content

Extend prevent-late-fallback by lock-counter #1732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

zentax-dev
Copy link
Collaborator

@zentax-dev zentax-dev commented Jun 15, 2025

This feature allows to lock the the remaining_attempts counter.
When remaining_attempts is locked, the bootloader should not decremented and incremented the variable anymore during each boot.
It is active when a slot is marked good and inactive when a slot is marked active.
This way it prevents fallback to an earlier version, whilst inhibiting additional write cycles to the target medium.
The status can be printed out with barebox-state and rauc status.
In a prelimary talk with @ejoerns the decision was made to not add this to the D-Bus interface yet. It will be added in a future pull request.
This feature also needs to be supported by the bootloader.
So far, a patch has been handed in for barebox to support this feature, see

@zentax-dev zentax-dev requested review from ejoerns and jluebbe June 15, 2025 11:23
@zentax-dev zentax-dev added the enhancement Adds new functionality or enhanced handling to RAUC label Jun 15, 2025
@zentax-dev zentax-dev self-assigned this Jun 15, 2025
Copy link

codecov bot commented Jun 15, 2025

Codecov Report

Attention: Patch coverage is 82.48848% with 38 lines in your changes missing coverage. Please review.

Project coverage is 84.49%. Comparing base (9c5cd7b) to head (20120bc).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/bootloaders/barebox.c 68.75% 15 Missing ⚠️
src/context.c 41.66% 7 Missing ⚠️
src/mark.c 33.33% 6 Missing ⚠️
src/bootchooser.c 84.61% 4 Missing ⚠️
src/main.c 66.66% 4 Missing ⚠️
src/config_file.c 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1732      +/-   ##
==========================================
- Coverage   84.51%   84.49%   -0.03%     
==========================================
  Files          76       76              
  Lines       22385    22599     +214     
==========================================
+ Hits        18918    19094     +176     
- Misses       3467     3505      +38     
Flag Coverage Δ
service=false 81.02% <82.48%> (+0.01%) ⬆️
service=true 84.45% <83.80%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch 2 times, most recently from 8c35bbb to 65208dc Compare June 18, 2025 12:33
@zentax-dev zentax-dev changed the title Add boot slots locking Extend prevent-late-fallback by lock-counter Jun 18, 2025
@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch from 65208dc to cc71a48 Compare June 19, 2025 11:01
@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch 2 times, most recently from 71c4606 to 5c3cfc8 Compare June 19, 2025 13:32
Copy link
Member

@ejoerns ejoerns left a comment

Choose a reason for hiding this comment

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

@zentax-dev Thank you for the contribution!

I had a look at the code and left some comments where I think the feature still deserves some rework. I guess most are just about proper wording/naming and error handling.

You should also point out in the documentation when and why boot counter locking might be preferable to the existing 'mark bad other' solution we have.

@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch 6 times, most recently from aab499f to 5d18924 Compare June 20, 2025 13:13
@zentax-dev
Copy link
Collaborator Author

zentax-dev commented Jun 20, 2025

Thanks for the feedback, think I got everything now. Forced pushed the changes

@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch from 5d18924 to aa96409 Compare June 23, 2025 09:10
@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch from aa96409 to 9875dd0 Compare June 23, 2025 11:04
@zentax-dev zentax-dev removed their assignment Jun 23, 2025
@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch 3 times, most recently from 6314e02 to aaaf0c5 Compare June 23, 2025 12:54
@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch from aaaf0c5 to acc361d Compare June 24, 2025 08:34
@jluebbe jluebbe requested review from ejoerns and a3f June 25, 2025 15:42
Lars Schmidt added 7 commits June 26, 2025 11:23
The new option for prevent late fallback adds the possibility
to lock the attempts counter. It is a global setting and is not
bound to any specific slot.
When activated, the counter of the slot that is marked good will
be locked and not decrease and increase anymore.
It will be unlocked again, when the slot is marked active.
The config option does not have any influence on which slot is
bootet, it will just stop decrementing the remaining attempts
counter in the bootloader.

Signed-off-by: Lars Schmidt <l.schmidt@pengutronix.de>
Forward the counter locking option to the barebox bootloader.
So the barebox can then stop decrementing the remaining_attempts
counter.
It inhibits fall-back to a previous version of the system, which
can happen if a system is rebootet too frequently before a slot
is marked good again and the remaining_attempts counter is
incrememented. As a side effect, it inhibits excessive write
cycles on the storage medium.

This also needs changes to barebox, see [1].

[1] https://lists.infradead.org/pipermail/barebox/2025-June/051393.html

Signed-off-by: Lars Schmidt <l.schmidt@pengutronix.de>
The setting is currently only supported by barebox.

Signed-off-by: Lars Schmidt <l.schmidt@pengutronix.de>
The attempts counter will be locked/frozen, after it is
marked good and will be unlocked/unfrozen again when it
is marked active.

Signed-off-by: Lars Schmidt <l.schmidt@pengutronix.de>
This adds the option to print the current state of prevent-late-fallback
and also to enable and disable sets the lock-counter via userspace.
The possibility to get/set it via D-Bus is not yet
implemented and will be added separately.

Signed-off-by: Lars Schmidt <l.schmidt@pengutronix.de>
It is best to show problems with inconsistent configuration early.
When counter locking is enabled in rauc, it must also be set in the
bootloader.

Signed-off-by: Lars Schmidt <l.schmidt@pengutronix.de>
Signed-off-by: Lars Schmidt <l.schmidt@pengutronix.de>
@zentax-dev zentax-dev force-pushed the lsc/boot_slot_locking branch from 6ea2c5f to 20120bc Compare June 26, 2025 09:24
Copy link
Contributor

@a3f a3f left a comment

Choose a reason for hiding this comment

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

I have no further comments on the series and haven't looked deep enough to put a checkmark on it.

@zentax-dev
Copy link
Collaborator Author

I have no further comments on the series and haven't looked deep enough to put a checkmark on it.

I'll mark your remarks as resolved then

@zentax-dev
Copy link
Collaborator Author

@ejoerns would be nice if you could review this again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds new functionality or enhanced handling to RAUC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants