Repository navigation
Conversation
With an explicit --conf in a directory lightningd can't write, setconfig
fails with "Cannot write to config file", as it should. But
config_not_writable() hands the filename to the command with tal_steal(),
and with --conf that filename is ld->config_filename itself, so freeing
the failed command frees it.
The next setconfig then reads the freed name, passes the writability
check against the wrong directory, and lightningd aborts in
append_to_file() ("Could not write to config : No such file or
directory").
Return a copy instead, as the other branch of config_not_writable()
already does.
Introduced in 5e79cd4 ("lightningd: check for writability before
allowing setconfig.").
Fixes: ElementsProject#9351
Changelog-Fixed: lightningd: a `setconfig` after one that failed to write an explicit `--conf` file no longer crashes the node.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:
tools/lightning-downgradeFixes #9351.
With an explicit
--confin a directory lightningd can't write, the firstsetconfigfails with "Cannot write to config file", as it should. Butconfig_not_writable()hands the file name to the command withtal_steal(), and with--confthat name isld->config_filenameitself, so freeing the failed command frees it. The nextsetconfigreads the freed name, passes the writability check against the wrong directory, and lightningd aborts inappend_to_file().This returns a copy instead, like the other branch of
config_not_writable()already does. Introduced in 5e79cd4.The test starts a node with
--confin a read-only directory and callssetconfigtwice: both calls must fail with "Cannot write to config file", and the node must still be running.This doesn't conflict with #9356, which makes the persistence path return errors instead of calling
fatal(). That PR doesn't fix this bug on its own: with it, the second call still reads freed memory.