Skip to content

core: refactor config parser; fix ktls configuration; fix crashes/ub#2222

Merged
BareosBot merged 23 commits intobareos:masterfrom
sebsura:dev/ssura/master/refactor-config-part-1
Apr 14, 2025
Merged

core: refactor config parser; fix ktls configuration; fix crashes/ub#2222
BareosBot merged 23 commits intobareos:masterfrom
sebsura:dev/ssura/master/refactor-config-part-1

Conversation

@sebsura
Copy link
Contributor

@sebsura sebsura commented Mar 21, 2025

Thank you for contributing to the Bareos Project!

This pr fixes a lot of bugs in our configuration & config parser. It also changes how we define our configuration to make sure that these mistakes cannot happen anymore. The PR also contains the following fixes:

  • make the ktls configuration useful
    The ktls configuration of each daemon will now determine whether that particular daemon tries to use it.
  • remove odr violations from the sd (the same file was getting compiled twice)
  • fix out of bounds reads in the fd
  • fix crashes related to reload
    Now each configuration gets kept alive by their predecessors, which means that jobs which incorrectly try to access out of date configurations, will not create use-after-free situations.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Required backport PRs have been created
  • Correct milestone is set
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

@sebsura sebsura force-pushed the dev/ssura/master/refactor-config-part-1 branch 2 times, most recently from 6254b22 to d5e7442 Compare March 24, 2025 07:09
@sebsura sebsura self-assigned this Mar 24, 2025
@sebsura sebsura added enhancement bug This addresses a bug labels Mar 24, 2025
@sebsura sebsura added this to the 25.0.0 milestone Mar 24, 2025
@sebsura sebsura linked an issue Mar 24, 2025 that may be closed by this pull request
Copy link
Contributor

@florian-at-bareos florian-at-bareos left a comment

Choose a reason for hiding this comment

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

Great work!
I think there are some really nice improvements to the config parser code.

I have some small remarks and some larger ones, since this PR is already really big and implementing some of this might require quite some time, feel free to write whether you want to invest the effort or not.

Copy link
Contributor

@florian-at-bareos florian-at-bareos left a comment

Choose a reason for hiding this comment

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

Great work! I especially like the ResourceItem config system you wrote!

If you want you can replace the const char* with std::optional<std::string_view> (see above discussion) but since this was a const char* before we can also just leave it as is for now.

In case you haven't noticed:
Some of your commit titles are longer than 50 characters.

@florian-at-bareos
Copy link
Contributor

maybe rename to "refactor config parser" since there are more changes than in parse_conf?

@sebsura sebsura changed the title core: refactor parse_conf core: refactor config parser Apr 11, 2025
@sebsura
Copy link
Contributor Author

sebsura commented Apr 11, 2025

maybe rename to "refactor config parser" since there are more changes than in parse_conf?

good idea!

@sebsura sebsura force-pushed the dev/ssura/master/refactor-config-part-1 branch 2 times, most recently from e8babeb to 0bab41b Compare April 14, 2025 05:31
@sebsura sebsura force-pushed the dev/ssura/master/refactor-config-part-1 branch from 0bab41b to 4e6bdca Compare April 14, 2025 06:49
sebsura added 11 commits April 14, 2025 08:54
If we read a string that does not match a resource name when trying to
parse a resource, then we would do out of bounds reads for !function!
pointers.  This is obviously not great!
A lot of configuration code expects that e.g. ResourceTable has R_NUM
elements, which causes oob reads because R_JOB/R_STORAGE arent
actually resource types.

R_STORAGE seems to be unused and R_JOB is only used once for
formatting a string.
Obviously we want to always use the `EnableKtls` setting of the daemon
and not from the "target", as otherwise it would be impossible to use
ktls between fd and sd.
Also removes direct dependency on ConfigurationParser from
ConfigResourceContainer.
Each configresourcecontainer now keeps its successors alive.  This
ensures that if something (i.e. a job) keeps alive its configuration,
and accidentally accesses the global configuration afterwards (without
saving it as well), then the daemon will not crash because of use
after free, as the newer configurations are now also kept alive
implicitly as well.
@sebsura sebsura force-pushed the dev/ssura/master/refactor-config-part-1 branch from 4e6bdca to 718de2c Compare April 14, 2025 07:20
@sebsura sebsura changed the title core: refactor config parser core: refactor config parser; fix ktls configuration; fix crashes/ub Apr 14, 2025
@BareosBot BareosBot merged commit 0c6dc67 into bareos:master Apr 14, 2025
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Director crash when labeling tapes while job is stuck

4 participants