summaryrefslogtreecommitdiff
path: root/util/nvmutil
AgeCommit message (Collapse)Author
14 hoursanother commentLeah Rowe
it's a pretty insane hack. i should probably just use normal fchmod Signed-off-by: Leah Rowe <leah@libreboot.org>
14 hourscommentLeah Rowe
also improved the macro, making it stricter Signed-off-by: Leah Rowe <leah@libreboot.org>
14 hourscleanup (fix potential overflow in mkstemp)Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
14 hoursfsync_dir: abort if path length is emptyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
14 hoursnvmutil: prevent theoretical overflow on time()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
14 hoursalso O_NOFOLLOWLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
14 hoursutil/nvmutil: dir fsync with O_DIRECTORYLeah Rowe
guards against replacement attacks, on systems that support this flag Signed-off-by: Leah Rowe <leah@libreboot.org>
14 hoursutil/nvmutil: fix mkstemp randomnessLeah Rowe
i made the string longer, but forgot to adjust it. the new random function is also better Signed-off-by: Leah Rowe <leah@libreboot.org>
15 hourscastLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
15 hoursutil/nvmutil: more reliable fallback cryptoLeah Rowe
we assume the fallback will be rare, so now we make the mix static and keep xoring it, on the theory that the number of failures on urandom will be random, and tthat the fallback may only apply once or twice in thousands of calls. the time jitter is adjusted; rather than judge the difference between two points close to each other in time, we judge tthe randomness in difference of time elapsed. this mitigates fast CPUs being very fast and introducing rounding errors, and also improves performonce on much slower CPUs Signed-off-by: Leah Rowe <leah@libreboot.org>
16 hoursutil/nvmutil: use real rename() syscallLeah Rowe
i was being cute earlier, but the rewrite defeats the purpose of atomic file handling in nvmutil, by not actually renaming! it was more like, doing an actual copy, which meant that corruption is likely during power loss i've commented the code because i may use it in a library in the future. Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursnvmutil: harden against hardlink attacksLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursredundancyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/nvmutil: loop EINTR on fsyncLeah Rowe
this improves reliability, making it more likely that data actually gets synced, since fsync can return -1 with EINTR, indicating that a re-try should be attempted. Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hourspointer safetyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursdon't use PATH_MAXLeah Rowe
unreliable Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursmacro safetyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/nvmutil: portable S_IFMTLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/nvmutil: remove integer typedefsLeah Rowe
better to just use standard names Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/nvmutil: remove global staticsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/nvmutil: fix unveil usageLeah Rowe
arandom probably isn't available on super old obsd right?????? rather, unveil isn't. on systems that have arandom yet we should not unveil something that may not exist on modern systems just don't unveil arandom, and don't check arandom if unveil is enabled Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/nvmutil: proper /dev/fd search in fchmodLeah Rowe
some systems may not even have it works with /dev/fd (bsd/mac etc) works with linux (/proc/self/fd) and falls back on super old systems that have neither Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: tidy up makefile optionsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursnope. put -Werror in the makefileLeah Rowe
not compiling without it is a bug don't let the default exclude it Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursnvmutil makefile: define WERROR but blank itLeah Rowe
settting it to -Werror is wrong, should set it not -Werror. however, put the WERROR variable in the make command. that way, i could test with make WERROR=-Werror Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: portable fchmodLeah Rowe
and with that, now the code compiles on gcc with -std=c90 -pedantic with -Werror and -Wall -Wextra Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursRevert "util/nvmutil: don't use fsync()"Leah Rowe
This reverts commit bdb43afac6edef21a15f99b8c3beac01be8b86f7.
19 hoursutil/nvmutil: longer string in mkstempLeah Rowe
have A-Z too, for more randomness Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: don't use mktempLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: don't declare libc prototypesLeah Rowe
i no longer use -Werror these can actually conflict on some weird systems, so better just remove them Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: portable memcpy/memcmpLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: more portable close()Leah Rowe
close may set errno to EINTR, which could cause weird edge case behaviour in our prw() functtion Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: more secure tmpdir()Leah Rowe
use stat instead of access (race conditions) Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: fix O_NONBLOCK fallbackLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: more secure mkstempLeah Rowe
try a few more times until success explicitly return EEXIST when needed we try multiple times and check more thoroughly if a file exists, thus reducing the risk of race conditions Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: more reliable TMPDIR handlingLeah Rowe
more portable Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: don't use fsync()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: more portable functtionsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: add portable malloc externLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: don't use size_t/ssize_tLeah Rowe
not portable. some old systems don't have it, or handle it very poorly unsigned long is a reasonable way to refer to indexes inside pointters Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: don't use SSIZE_MAX (not portable)Leah Rowe
some old systems don't have ssize_t or size_t Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: typeset size_t explicitlyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: run-time CHAR_BIT testLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: lower default PATH_LENLeah Rowe
older unix needed lower Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: portable struct timevalLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: portable S_ISREGLeah Rowe
very old libc doesn't have it Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursmktemp prototypeLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: portable gettimeofdayLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: use portable mkstempLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/nvmutil: better urandom portabilityLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>