]> git.baikalelectronics.ru Git - kernel.git/commit
LSM: SafeSetID: rewrite userspace API to atomic updates
authorJann Horn <jannh@google.com>
Wed, 10 Apr 2019 16:56:05 +0000 (09:56 -0700)
committerMicah Morton <mortonm@chromium.org>
Mon, 15 Jul 2019 15:07:29 +0000 (08:07 -0700)
commit504c59000627df08208df074b1cb9c79ea428cec
tree75a711e1f8e03fcddcc50b58db6324e64f564a08
parent53ff829efc532f9e4d7335d84821879926481d96
LSM: SafeSetID: rewrite userspace API to atomic updates

The current API of the SafeSetID LSM uses one write() per rule, and applies
each written rule instantly. This has several downsides:

 - While a policy is being loaded, once a single parent-child pair has been
   loaded, the parent is restricted to that specific child, even if
   subsequent rules would allow transitions to other child UIDs. This means
   that during policy loading, set*uid() can randomly fail.
 - To replace the policy without rebooting, it is necessary to first flush
   all old rules. This creates a time window in which no constraints are
   placed on the use of CAP_SETUID.
 - If we want to perform sanity checks on the final policy, this requires
   that the policy isn't constructed in a piecemeal fashion without telling
   the kernel when it's done.

Other kernel APIs - including things like the userns code and netfilter -
avoid this problem by performing updates atomically. Luckily, SafeSetID
hasn't landed in a stable (upstream) release yet, so maybe it's not too
late to completely change the API.

The new API for SafeSetID is: If you want to change the policy, open
"safesetid/whitelist_policy" and write the entire policy,
newline-delimited, in there.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Micah Morton <mortonm@chromium.org>
security/safesetid/lsm.c
security/safesetid/lsm.h
security/safesetid/securityfs.c
tools/testing/selftests/safesetid/safesetid-test.c