Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
rewrite efivarfs_set_variable() [9896c26-based]
This patch rewrites the efivarfs_set_variable() function, to address the following issues: - a size_t value is printed with %zd -- size_t is unsigned, so it should be printed with %zu or %zx, - a VLA is used for storing input of basically unbounded size -- we should use a range-checked malloc() call instead, - the efivarfs file is opened for writing while it may be immutable -- this is the trickiest issue to resolve, - passing just O_APPEND|O_CREAT to open() is undefined -- O_WRONLY is required, and O_APPEND and (O_CREAT | O_EXCL) should both be independent of it (and of each other), - some error branches call efi_error() without setting errno first, - the variable is removed on any write failure, even if we didn't create the variable -- failed writes are expected to be atomic (from the kernel side and from the firmware side) and not to leave behind side effects; so only delete the variable on error if we created it. A small helper function efivarfs_make_fd_mutable() is introduced as well. (It's best to review the new efivarfs_set_variable() function in its entirety, with the patch applied, rather than comparing old vs. new, hunk for hunk.) Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1516599 Signed-off-by: Laszlo Ersek <lersek@redhat.com>
- Loading branch information
Showing
1 changed file
with
126 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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