summaryrefstree
path: root/kernel/security/proca/proca_table.h
blob: 63ad70429fec239e655fc8b67bcd88b69fdc2912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * PROCA task descriptors table
 *
 * Copyright (C) 2018 Samsung Electronics, Inc.
 * Hryhorii Tur, <hryhorii.tur@partner.samsung.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _LINUX_PROCA_TABLE_H
#define _LINUX_PROCA_TABLE_H

#include <linux/hashtable.h>
#include <linux/sched.h>

#include "proca_task_descr.h"

#define PROCA_TASKS_TABLE_SHIFT 10

struct proca_table {
	unsigned int hash_tables_shift;

	DECLARE_HASHTABLE(pid_map, PROCA_TASKS_TABLE_SHIFT);
	spinlock_t pid_map_lock;

	DECLARE_HASHTABLE(app_name_map, PROCA_TASKS_TABLE_SHIFT);
	spinlock_t app_name_map_lock;
};

void proca_table_init(struct proca_table *table);

void proca_table_add_task_descr(struct proca_table *table,
				struct proca_task_descr *descr);

struct proca_task_descr *proca_table_get_by_task(
					struct proca_table *table,
					const struct task_struct *task);

struct proca_task_descr *proca_table_remove_by_task(
					struct proca_table *table,
					const struct task_struct *task);

void proca_table_remove_task_descr(struct proca_table *table,
				   struct proca_task_descr *descr);
#endif //_LINUX_PROCA_TABLE_H