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:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user