head: Fixed TOCTOU bug in checking of metadata#12439
Conversation
|
GNU testsuite comparison: |
|
This should be catched at 1st read. But it is currently difficult since we don't distinct read error and write error #12265 . |
|
I don't see how the write error proposed in the PR would be incorporated? We don't have a specific metadata access error so does that need to be added? Otherwise it can fail at two different points with the same error. |
|
We can just remove |
|
Oh I see. To confirm, once |
|
I think we can just do somethin like |
|
How would this look with all of the |
Follow-up to the metadata TOCTOU fix (uutils#11972, PR uutils#12439): - Add a syscall-level regression guard in util/check-safe-traversal.sh: under strace, head must read metadata from the open descriptor (fstat/statx on the fd) and must not stat the path before opening it. Verified this fails on the pre-fix code and passes after. - Add an integration test asserting that an unreadable file produces an error but no "==> name <==" header, matching GNU (the header is only printed after a successful open). - Fix a stray paren in the Windows-branch comment.
|
follow up : #12637 |
Follow-up to the metadata TOCTOU fix (#11972, PR #12439): - Add a syscall-level regression guard in util/check-safe-traversal.sh: under strace, head must read metadata from the open descriptor (fstat/statx on the fd) and must not stat the path before opening it. Verified this fails on the pre-fix code and passes after. - Add an integration test asserting that an unreadable file produces an error but no "==> name <==" header, matching GNU (the header is only printed after a successful open). - Fix a stray paren in the Windows-branch comment.
Fixes #11972.
Doesn't look exploitable in any degree but lack of TOCTOU is perhaps nice to have.
Not sure if a closure was the best way to do
print_header, very open to alternative approaches.