aboutsummaryrefslogtreecommitdiff
path: root/cmd/fscrypt/commands.go
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-03-25 10:13:26 -0700
committerEric Biggers <ebiggers3@gmail.com>2018-03-25 10:22:39 -0700
commitaa88bf4527cced6e3e16ca3e5ae07076cc8217f0 (patch)
tree31ef4df85e4a3507eb44d93636392687fad08aa9 /cmd/fscrypt/commands.go
parent3ef69aaafcfe6df03097d9ebdc8e4c7f7516999b (diff)
security: drop and regain privileges in all threads
After enabling pam_fscrypt for "session" and creating a directory protected with a login protector, I was no longer able to log in as that user. The problem is that the Go runtime is creating threads after pam_fscrypt drops privileges, but pam_fscrypt is not re-acquiring privileges on those threads because the Go wrappers for setreuid(), setregid(), and setgroups() in the "sys/unix" package are using the raw syscalls which operate on the calling thread only. This violates glibc's assumption that all threads have the same uids and gids, causing it to abort() the process when a later module in the PAM stack (pam_mail in my case) tries to drop privileges using the glibc functions. Fix it by dropping and regaining privileges using the glibc functions rather than the "sys/unix" functions. This also avoids any possibility that privileges could be changed in a thread other than the "main" one for pam_fscrypt, since the Go runtime does not guarantee which OS-level thread runs what. It would be nice to also exit all Go worker threads before returning from pam_fscrypt, but the Go runtime doesn't seem to support that.
Diffstat (limited to 'cmd/fscrypt/commands.go')
0 files changed, 0 insertions, 0 deletions