summaryrefslogtreecommitdiffstats
path: root/security/safesetid/lsm.h
diff options
context:
space:
mode:
authorJann Horn2019-04-10 18:55:34 +0200
committerMicah Morton2019-07-15 17:05:48 +0200
commit1cd02a27a9473fed0294561137cfb7dcc9b3aaa0 (patch)
tree50f7aad2ffd88d37bcf508ccc772d70444fe2fff /security/safesetid/lsm.h
parentLSM: SafeSetID: fix check for setresuid(new1, new2, new3) (diff)
downloadkernel-qcow2-linux-1cd02a27a9473fed0294561137cfb7dcc9b3aaa0.tar.gz
kernel-qcow2-linux-1cd02a27a9473fed0294561137cfb7dcc9b3aaa0.tar.xz
kernel-qcow2-linux-1cd02a27a9473fed0294561137cfb7dcc9b3aaa0.zip
LSM: SafeSetID: refactor policy hash table
parent_kuid and child_kuid are kuids, there is no reason to make them uint64_t. (And anyway, in the kernel, the normal name for that would be u64, not uint64_t.) check_setuid_policy_hashtable_key() and check_setuid_policy_hashtable_key_value() are basically the same thing, merge them. Also fix the comment that claimed that (1<<8)==128. Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Micah Morton <mortonm@chromium.org>
Diffstat (limited to 'security/safesetid/lsm.h')
-rw-r--r--security/safesetid/lsm.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/security/safesetid/lsm.h b/security/safesetid/lsm.h
index c1ea3c265fcf..6806f902794c 100644
--- a/security/safesetid/lsm.h
+++ b/security/safesetid/lsm.h
@@ -15,6 +15,8 @@
#define _SAFESETID_H
#include <linux/types.h>
+#include <linux/uidgid.h>
+#include <linux/hashtable.h>
/* Flag indicating whether initialization completed */
extern int safesetid_initialized;
@@ -25,6 +27,23 @@ enum safesetid_whitelist_file_write_type {
SAFESETID_WHITELIST_FLUSH, /* Flush whitelist policies. */
};
+enum sid_policy_type {
+ SIDPOL_DEFAULT, /* source ID is unaffected by policy */
+ SIDPOL_CONSTRAINED, /* source ID is affected by policy */
+ SIDPOL_ALLOWED /* target ID explicitly allowed */
+};
+
+/*
+ * Hash table entry to store safesetid policy signifying that 'src_uid'
+ * can setid to 'dst_uid'.
+ */
+struct entry {
+ struct hlist_node next;
+ struct hlist_node dlist; /* for deletion cleanup */
+ kuid_t src_uid;
+ kuid_t dst_uid;
+};
+
/* Add entry to safesetid whitelist to allow 'parent' to setid to 'child'. */
int add_safesetid_whitelist_entry(kuid_t parent, kuid_t child);