libgocryptfs/internal/syscallcompat
Jakob Unterwurzacher 72b975867a fusefronted: allow_other: close race between mknod and chown
If the user manages to replace the directory with
a symlink at just the right time, we could be tricked
into chown'ing the wrong file.

This change fixes the race by using fchownat, which
unfortunately is not available on darwin, hence a compat
wrapper is added.

Scenario, as described by @slackner at
https://github.com/rfjakob/gocryptfs/issues/177 :

1. Create a forward mount point with `plaintextnames` enabled
2. Mount as root user with `allow_other`
3. For testing purposes create a file `/tmp/file_owned_by_root`
   which is owned by the root user
4. As a regular user run inside of the GoCryptFS mount:

```
mkdir tempdir
mknod tempdir/file_owned_by_root p &
mv tempdir tempdir2
ln -s /tmp tempdir
```

When the steps are done fast enough and in the right order
(run in a loop!), the device file will be created in
`tempdir`, but the `lchown` will be executed by following
the symlink. As a result, the ownership of the file located
at `/tmp/file_owned_by_root` will be changed.
2017-11-27 21:04:45 +01:00
..
getdents_linux.go syscallcompat: Getdents: warn once if we get DT_UNKNOWN 2017-09-03 15:05:54 +02:00
getdents_other.go syscallcompat: implement Getdents() 2017-08-15 19:03:57 +02:00
getdents_test.go tests: don't read /proc, the number of entries changes too quickly 2017-10-22 18:13:08 +02:00
sys_darwin.go fusefronted: allow_other: close race between mknod and chown 2017-11-27 21:04:45 +01:00
sys_linux.go fusefronted: allow_other: close race between mknod and chown 2017-11-27 21:04:45 +01:00