blob: 8701343a2b08df10d5529b1a4fc999e2d4b964b4 [file] [log] [blame]
Karthikeyan Ramasubramanian5b502d3642012-09-23 22:23:36 -06001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _MSM_IPC_ROUTER_SECURITY_H
14#define _MSM_IPC_ROUTER_SECURITY_H
15
16#include <linux/types.h>
17#include <linux/socket.h>
18#include <linux/errno.h>
19
20#ifdef CONFIG_MSM_IPC_ROUTER_SECURITY
21#include <linux/android_aid.h>
22
23/**
24 * check_permisions() - Check whether the process has permissions to
25 * create an interface handle with IPC Router
26 *
27 * @return: true if the process has permissions, else false.
28 */
29int check_permissions(void);
30
31/**
32 * msm_ipc_config_sec_rules() - Add a security rule to the database
33 * @arg: Pointer to the buffer containing the rule.
34 *
35 * @return: 0 if successfully added, < 0 for error.
36 *
37 * A security rule is defined using <Service_ID: Group_ID> tuple. The rule
38 * implies that a user-space process in order to send a QMI message to
39 * service Service_ID should belong to the Linux group Group_ID.
40 */
41int msm_ipc_config_sec_rules(void *arg);
42
43/**
44 * msm_ipc_get_security_rule() - Get the security rule corresponding to a
45 * service
46 * @service_id: Service ID for which the rule has to be got.
47 * @instance_id: Instance ID for which the rule has to be got.
48 *
49 * @return: Returns the rule info on success, NULL on error.
50 *
51 * This function is used when the service comes up and gets registered with
52 * the IPC Router.
53 */
54void *msm_ipc_get_security_rule(uint32_t service_id, uint32_t instance_id);
55
56/**
57 * msm_ipc_check_send_permissions() - Check if the sendng process has
58 * permissions specified as per the rule
59 * @data: Security rule to be checked.
60 *
61 * @return: true if the process has permissions, else false.
62 *
63 * This function is used to check if the current executing process has
64 * permissions to send message to the remote entity. The security rule
65 * corresponding to the remote entity is specified by "data" parameter
66 */
67int msm_ipc_check_send_permissions(void *data);
68
69/**
70 * msm_ipc_router_security_init() - Initialize the security rule database
71 *
72 * @return: 0 if successful, < 0 for error.
73 */
74int msm_ipc_router_security_init(void);
75
76#else
77
78static inline int check_permissions(void)
79{
80 return 1;
81}
82
83static inline int msm_ipc_config_sec_rules(void *arg)
84{
85 return -ENODEV;
86}
87
88static inline void *msm_ipc_get_security_rule(uint32_t service_id,
89 uint32_t instance_id)
90{
91 return NULL;
92}
93
94static inline int msm_ipc_check_send_permissions(void *data)
95{
96 return 1;
97}
98
99static inline int msm_ipc_router_security_init(void)
100{
101 return 0;
102}
103#endif
104#endif