| Age | Commit message (Collapse) | Author |
|
The RENAME_NOREPLACE emulation checked for an existing newpath with
Fstatat(..., 0), which follows symlinks. A dangling symlink at newpath
returned ENOENT, so we went ahead and replaced it, violating NOREPLACE.
Use AT_SYMLINK_NOFOLLOW.
Also return errors other than ENOENT instead of proceeding with the
rename, and drop a duplicated NOREPLACE|EXCHANGE check.
The check-then-rename emulation remains inherently racy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
.gocryptfs.reverse.conf is passed through to gocryptfs.conf in the
reverse view unencrypted. lookupConf, VirtualConfNode.Getattr and
VirtualConfNode.Open accessed it via syscall.Stat/Open on the full path,
following symlinks. Anybody with write access to the backing directory
could replace it with a symlink to, for example, /etc/shadow and read the
target in plaintext through the mount when gocryptfs runs as root.
Add RootNode.openConf(), which opens the file relative to the backing
dir with O_NOFOLLOW|O_NONBLOCK (O_NONBLOCK so a FIFO cannot hang us) and
rejects anything that is not a regular file. Use it for all three.
Add TestConfigSymlink as a regression test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
openWriteOnlyFile chmods the file via woFd and then reopens it by name.
O_NOFOLLOW prevents following symlinks, but cName could still have been
replaced by a different regular file in between, and we would return an
fd to that file.
Add syscallcompat.ReopenFd():
* Linux: open /proc/self/fd/N, which always resolves to the file woFd
refers to.
* Other platforms: reopen by name and compare dev/ino against woFd,
returning EAGAIN on mismatch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
FchmodatNofollow called syscall.Openat directly, so the O_PATH fd lacked
O_CLOEXEC and could leak to child processes (logger(1)), which is exactly
what our Openat() wrapper prevents. Use the wrapper, which also retries
on EINTR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
AT_SYMLINK_NOFOLLOW
Our helper did Fstatat(AT_SYMLINK_NOFOLLOW) followed by a symlink-following
unix.Faccessat(..., 0). If the file is swapped for a symlink in between, we
check access on the symlink target.
x/sys now handles AT_SYMLINK_NOFOLLOW on all our platforms: faccessat2 with
fallback emulation on Linux, libc faccessat on Darwin, and the native
syscall on FreeBSD. The Darwin breakage that caused the revert in
3d6b2685 should no longer apply.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
|
|
|
|
In a git worktree, .git is a file rather than a directory, so the
version came out as "[unknown]".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Because otherwise, perhaps unsurprisingly, it does not build on 386,
breaking our ci.
|
|
|
|
Latest go-fuse (see next commit) uses one fd internally for splicing.
|
|
|
|
Fixes #1023
|
|
Relates-to: #1023
https://github.com/rfjakob/gocryptfs/issues/1023
|
|
Added a warning about the website gocryptfs.com not being affiliated with the project.
|
|
There is a performance penalty here, but the alternative is
potential data loss on a system crash / power outage as shown in
https://github.com/rfjakob/gocryptfs/issues/1033 .
Also deduplicate the code a little using goto.
Fixes https://github.com/rfjakob/gocryptfs/issues/1033
|
|
Before:
$ mkdir asd
mkdir: cannot create directory ‘asd’: Operation not supported
Sep 01 22:24:15 brikett gocryptfs[185344]: go-fuse: can't convert error type: wanted 16 bytes, got 0
After:
$ mkdir asdasd
mkdir: cannot create directory ‘asdasd’: Input/output error
Sep 01 22:25:00 brikett gocryptfs[185784]: prepareAtSyscall: could not read gocryptfs.diriv: wanted 16 bytes, got 0
https://github.com/rfjakob/gocryptfs/issues/1033
|
|
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 6 to 7.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v6...v7)
---
updated-dependencies:
- dependency-name: actions/setup-go
dependency-version: '7'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
|
|
We should never call it in -plaintextnames mode.
|
|
|
|
Avoid eager per-entry metadata work for names-only listings, and
add -readdirplus for workloads that benefit from eager attributes.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
node.Setattr opens its own file handle and called truncate directly,
without ContentLock. truncate ends in doWrite, which documents that the
caller holds that lock, and file.Setattr and Allocate both take it.
Besides leaving a path truncate unserialized against concurrent writes,
this skipped the write-operation counter that ContentLock.Lock()
increments. isConsecutiveWrite() reads that counter to notice foreign
modifications, so an already-open handle kept assuming its next write
appends, skipped writePadHole() and grew the file past a short last
block. That block no longer decrypted, and every later operation on the
file failed with EIO.
Fixes #1024
|
|
Forward the backing filesystem's STATX_BTIME on Linux while preserving
existing metadata translations and fallback behavior.
On Linux 6.6 and newer, this allows statx consumers such as GNU stat
to report birth time when the backing filesystem provides it. Older
kernels and backing filesystems without birth-time support retain the
existing behavior. No on-disk format change or migration is required.
Reverse mode remains unchanged.
Fixes #868.
Related context: #732
|
|
|
|
|
|
|
|
...and one typo.
|
|
|
|
|
|
|
|
Prevent reads and writes concurrent with the truncate operation. It's
racy on tmpfs and ext4 ( https://lore.kernel.org/all/18e9fa0f-ec31-9107-459c-ae1694503f87@gmail.com/t/ )
as evident by TestOpenTruncate test failures:
=== RUN TestOpenTruncate
cluster_test.go:209: POSIX compliance issue: non-exlusive create failed with err=file exists
doRead 16384215: corrupt block #0: cipher: message authentication failed
ino16384215 fh8: RMW read failed: errno=5
cluster_test.go:214: iteration 1: WriteAt: write /tmp/gocryptfs-test-parent-1026/1358464214/TestOpenTruncate.1788296708.mnt2/foo: input/output error
--- FAIL: TestOpenTruncate (0.06s)
FAIL
exit status 1
FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 7.880s
Relates-to: https://github.com/rfjakob/gocryptfs/issues/56
|
|
Complain loudly when the underlying storage does not support
byte-range locks.
https://github.com/rfjakob/gocryptfs/issues/754
|
|
With -sharedstorage, when we get a decryption error, we lock the
byte range and try again.
This makes concurrent R/W safe agains torn writes.
https://github.com/rfjakob/gocryptfs/issues/754
|
|
Add the -sharedstorage flag to the mounts and make it more
severe by adjusting the I/O and file sizes to arbitrary unaligned
values.
It passes *most of the time*.
If it fails, it's like this, and the reason is that there is no
fcntl locks in the READ path yet.
gocryptfs/tests/cluster$ go test -run TestClusterConcurrentRW -v
=== RUN TestClusterConcurrentRW
doRead 2895433: corrupt block #0: cipher: message authentication failed
doRead 2895433: corrupt block #0: cipher: message authentication failed
doRead 2895433: corrupt block #0: cipher: message authentication failed
cluster_test.go:98: readThread iteration 9165: ReadAt failed: read /var/tmp/gocryptfs-test-parent-1026/3021427391/TestClusterConcurrentRW.366469887.mnt1/foo: input/output error
--- FAIL: TestClusterConcurrentRW (0.40s)
FAIL
exit status 1
FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 0.406s
|
|
As we must write complete ciphertext blocks (except at EOF), non-overlapping
plaintext writes can overlap in the ciphertext.
And because overlapping writes can turn the data into data soup (see
TestPoCTornWrite) we serialize them using fcntl locking.
|
|
|
|
|
|
Scary. But explains why TestConcurrentCreate fails.
gocryptfs/tests/cluster$ go test -run TestPoCTornWrite
--- FAIL: TestPoCTornWrite (0.00s)
poc_test.go:210: iteration 214: inconsistent block: d6d6d6d6d6d6d6d6d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1
FAIL
|
|
With -sharedstorage, we keep the on-disk file header.
Other mounts may have the file ID cached so we cannot mess with it.
This makes TestOpenTruncate pass.
|
|
This fails right now:
1 jakob@brikett:~/go/src/github.com/rfjakob/gocryptfs/tests/cluster$ go test -run TestOpenTruncate -v
=== RUN TestOpenTruncate
cluster_test.go:235: POSIX compliance issue: non-exlusive create failed with err=file exists
doWrite 2898550: corrupt header: ParseHeader: header is all-zero. Header hexdump: 000000000000000000000000000000000000
cluster_test.go:240: iteration 1: WriteAt: write /var/tmp/gocryptfs-test-parent-1026/1896094179/TestOpenTruncate.4202105280.mnt2/foo: input/output error
--- FAIL: TestOpenTruncate (0.10s)
FAIL
exit status 1
FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 0.099s
1 jakob@brikett:~/go/src/github.com/rfjakob/gocryptfs/tests/cluster$ go test -run TestOpenTruncate -v
=== RUN TestOpenTruncate
cluster_test.go:235: POSIX compliance issue: non-exlusive create failed with err=file exists
doRead 2898565: corrupt block #0: cipher: message authentication failed
ino2898565 fh9: RMW read failed: errno=5
cluster_test.go:240: iteration 8: WriteAt: write /var/tmp/gocryptfs-test-parent-1026/652691834/TestOpenTruncate.281532388.mnt1/foo: input/output error
--- FAIL: TestOpenTruncate (0.09s)
FAIL
exit status 1
FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 0.095s
|
|
|
|
This exercises the byte-range locks we just added.
|
|
Multiple host writing to the same empty file at the same time
could have overwritten each other's newly created file header,
leading to data corruption.
Fix the race by placing a byte-range lock on the file when
creating the file header.
|
|
|
|
pjdfstest results
|
|
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.45.0 to 0.52.0.
- [Commits](https://github.com/golang/crypto/compare/v0.45.0...v0.52.0)
---
updated-dependencies:
- dependency-name: golang.org/x/crypto
dependency-version: 0.52.0
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
|
|
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)
---
updated-dependencies:
- dependency-name: actions/checkout
dependency-version: '7'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
|
|
In reverse mode, a custom config file passed via -config that lives inside
CIPHERDIR was presented as an ordinary encrypted file in the encrypted view,
which is useless and confusing. By default the config is mapped to a virtual
gocryptfs.conf, but ConfigCustom skips that mapping, so an in-CIPHERDIR custom
config was neither mapped nor hidden.
Plumb the config path into the reverse RootNode and treat a custom config file
located inside CIPHERDIR as excluded in isExcludedPlain, hiding it from both
readdir and lookup. Also document the -config reverse-mode behaviour in
MANPAGE.md and add a regression test.
Fixes #1009
|
|
|
|
use maps and slices instead of explicit for loop
|