linux/security/selinux/ss/sidtab.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * A security identifier table (sidtab) is a lookup table
 * of security context structures indexed by SID value.
 *
 * Original author: Stephen Smalley, <[email protected]>
 * Author: Ondrej Mosnacek, <[email protected]>
 *
 * Copyright (C) 2018 Red Hat, Inc.
 */

#ifndef _SS_SIDTAB_H_
#define _SS_SIDTAB_H_

#include <linux/spinlock_types.h>
#include <linux/log2.h>
#include <linux/hashtable.h>

#include "context.h"

struct sidtab_entry {};

sidtab_entry_inner;

/* align node size to page boundary */
#define SIDTAB_NODE_ALLOC_SHIFT
#define SIDTAB_NODE_ALLOC_SIZE

#define size_to_shift(size)

#define SIDTAB_INNER_SHIFT
#define SIDTAB_INNER_ENTRIES
#define SIDTAB_LEAF_ENTRIES

#define SIDTAB_MAX_BITS
#define SIDTAB_MAX
/* ensure enough tree levels for SIDTAB_MAX entries */
#define SIDTAB_MAX_LEVEL

struct sidtab_node_leaf {};

struct sidtab_node_inner {};

struct sidtab_isid_entry {};

struct sidtab_convert_params {};

#define SIDTAB_HASH_BITS
#define SIDTAB_HASH_BUCKETS

struct sidtab {};

int sidtab_init(struct sidtab *s);
int sidtab_set_initial(struct sidtab *s, u32 sid, struct context *context);
struct sidtab_entry *sidtab_search_entry(struct sidtab *s, u32 sid);
struct sidtab_entry *sidtab_search_entry_force(struct sidtab *s, u32 sid);

static inline struct context *sidtab_search(struct sidtab *s, u32 sid)
{}

static inline struct context *sidtab_search_force(struct sidtab *s, u32 sid)
{}

int sidtab_convert(struct sidtab *s, struct sidtab_convert_params *params);

void sidtab_cancel_convert(struct sidtab *s);

void sidtab_freeze_begin(struct sidtab *s, unsigned long *flags)
	__acquires();
void sidtab_freeze_end(struct sidtab *s, unsigned long *flags)
	__releases();

int sidtab_context_to_sid(struct sidtab *s, struct context *context, u32 *sid);

void sidtab_destroy(struct sidtab *s);

int sidtab_hash_stats(struct sidtab *sidtab, char *page);

#if CONFIG_SECURITY_SELINUX_SID2STR_CACHE_SIZE > 0
void sidtab_sid2str_put(struct sidtab *s, struct sidtab_entry *entry,
			const char *str, u32 str_len);
int sidtab_sid2str_get(struct sidtab *s, struct sidtab_entry *entry, char **out,
		       u32 *out_len);
#else
static inline void sidtab_sid2str_put(struct sidtab *s,
				      struct sidtab_entry *entry,
				      const char *str, u32 str_len)
{
}
static inline int sidtab_sid2str_get(struct sidtab *s,
				     struct sidtab_entry *entry, char **out,
				     u32 *out_len)
{
	return -ENOENT;
}
#endif /* CONFIG_SECURITY_SELINUX_SID2STR_CACHE_SIZE > 0 */

#endif /* _SS_SIDTAB_H_ */