summaryrefstree
path: root/kernel/security/defex_lsm/defex_config.c
blob: 17103b4f0d06bbc66b683c89b36f15101d4ddac9 (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
/*
 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
*/

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/defex.h>
#include "include/defex_internal.h"


int defex_get_features(void)
{
	int features = 0;
#ifdef DEFEX_PED_ENABLE
#if !defined(DEFEX_PERMISSIVE_PED)
	features |= GLOBAL_PED_STATUS;
#else
	if (global_privesc_obj->status != 0)
		features |= FEATURE_CHECK_CREDS;
	if (global_privesc_obj->status == 2)
		features |= FEATURE_CHECK_CREDS_SOFT;
#endif /* DEFEX_PERMISSIVE_PED */
#endif /* DEFEX_PED_ENABLE */

#ifdef DEFEX_SAFEPLACE_ENABLE
#if !defined(DEFEX_PERMISSIVE_SP)
	features |= GLOBAL_SAFEPLACE_STATUS;
#else
	if (global_safeplace_obj->status != 0)
		features |= FEATURE_SAFEPLACE;
	if (global_safeplace_obj->status == 2)
		features |= FEATURE_SAFEPLACE_SOFT;
#endif /* DEFEX_PERMISSIVE_SP */
#endif /* DEFEX_SAFEPLACE_ENABLE */
	return features;
}