summaryrefslogtreecommitdiff
path: root/util
AgeCommit message (Collapse)Author
16 hoursutil/nvmutil: use ulong on ptr castsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
16 hoursutil/nvmutil: remove rw_file_onceLeah Rowe
we don't need it anymore. Signed-off-by: Leah Rowe <leah@libreboot.org>
16 hoursutil/nvmutil: move looping logic to rw_file_exactLeah Rowe
rw_file_once was doing what rw_file_exact should be doing _once does what it says: once we were passing an offset (rc) to it that it was not meaningfully using. this makes the code now more robust, especially if we later swap out or break _once - then we don't get weird behaviour (if there is a regression). Signed-off-by: Leah Rowe <leah@libreboot.org>
16 hoursnvmutil: move increment logic to rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursnvmutil: fix redundant checkLeah Rowe
we already check not-zero in the next if Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/nvmutil: cast gbe file size on ptr cmpLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/nvmutil: even safer pointer comparisonLeah Rowe
we assert now that ulong is the size of a pointer, therefore we know that it can fit a pointer reliably. this code is written for c90 spec so lacks uintptr Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/nvmutil: safer pointer comparisonLeah Rowe
technically we're never supposed to do arithmetic on pointers (there's uintptr for that) very anal fix Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/nvmutil: enable arc4random on linuxLeah Rowe
not available on older systems. can just pass the relevant flag in the compiler: HAVE_ARC4RANDOM_BUF=0 at build time if you need the fallback. Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/nvmutil: re-add arc4randomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: 5 retries, not 10Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: check if gbe.bin is seekableLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: check inode during post-verifyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: warn about gbe.bin hard linksLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: guard file replacement attacksLeah Rowe
i already also guard other toctuo attacks :) Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: guard against unlinking fileLeah Rowe
if someone deletes gbe.bin while operating, nvmutil will now abort Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: don't use /dev/urandomLeah Rowe
too over engineered and cumbersome. the new security in prw() makes it brittle, and i'd rather not move checks outside of it. the fallback rand is random enough. Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: fix file checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: fix cast checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: more aggressive file checkingLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: prevent overflow in rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: verify final offset in pwrite/preadLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/nvmutil: check regular file in rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/nvmutil: fix if (PWRITE)Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/nvmutil: don't check o_append in prwLeah Rowe
slow, per call. prw should be generic. do it just for gbe files, once Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/nvmutil: configurable eintr/eagainLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/nvmutil: configurable retries/preadLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/nvmutil: support real pwrite/preadLeah Rowe
build flag Signed-off-by: Leah Rowe <leah@libreboot.org>
22 hoursutil/nvmutil: better commented I/O functionsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
22 hoursutil/nvmutil: make eintr/eagain setup clearerLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursnvmutil: fix rval in close_filesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: don't check write checksums on partialLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: don't recurse err/close_filesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: restore pad before reading to itLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: don't show checksum on bad pwriteLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: always restore saved errnoLeah Rowe
the last lseek there is only there to reset state, so its errors are irrelevant. Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: post-write verification reportLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/nvmutil: optimise fsync / write checkLeah Rowe
write all at once, then sync all at once, then verify all at once. this increases the chancce that all data gets written first, in the case of power less, because fsync may take a while on some systems. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: set EIO on bad memcmpLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: split up rw_gbe_file_partLeah Rowe
the post-verification stage deserves a function Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: detect partial gbe rwLeah Rowe
we already covered this in prw() which is what ultimately gets called, but still. it's logically correct not to check it here. Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: verify gbe contents after writingLeah Rowe
read it back and check. sync to disk first. Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: consistent typesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: handle zero return in rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: rename lseek_eintrLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: fix lseek eintr err checkLeah Rowe
it should be is equal, not not equal Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: rename err_eagain() to try_err()Leah Rowe
makes more sense in code Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: make EINTR configurable in prw()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: tidy up prw()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
37 hoursutil/nvmutil: extra overflow check in prwLeah Rowe
compliant posix systems should never meet this check, but i put it here. spec != implementation Signed-off-by: Leah Rowe <leah@libreboot.org>