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>
This commit is contained in:
Jann Horn
2019-04-10 09:55:34 -07:00
committed by Micah Morton
parent 7ef6b3062f
commit 1cd02a27a9
2 changed files with 37 additions and 44 deletions

View File

@@ -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);