ipc_router_security.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Copyright (c) 2012-2014,2016 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. #ifndef _IPC_ROUTER_SECURITY_H
  13. #define _IPC_ROUTER_SECURITY_H
  14. #include <linux/types.h>
  15. #include <linux/socket.h>
  16. #include <linux/errno.h>
  17. #ifdef CONFIG_IPC_ROUTER_SECURITY
  18. #include <linux/android_aid.h>
  19. /**
  20. * check_permisions() - Check whether the process has permissions to
  21. * create an interface handle with IPC Router
  22. *
  23. * @return: true if the process has permissions, else false.
  24. */
  25. int check_permissions(void);
  26. /**
  27. * msm_ipc_config_sec_rules() - Add a security rule to the database
  28. * @arg: Pointer to the buffer containing the rule.
  29. *
  30. * @return: 0 if successfully added, < 0 for error.
  31. *
  32. * A security rule is defined using <Service_ID: Group_ID> tuple. The rule
  33. * implies that a user-space process in order to send a QMI message to
  34. * service Service_ID should belong to the Linux group Group_ID.
  35. */
  36. int msm_ipc_config_sec_rules(void *arg);
  37. /**
  38. * msm_ipc_get_security_rule() - Get the security rule corresponding to a
  39. * service
  40. * @service_id: Service ID for which the rule has to be got.
  41. * @instance_id: Instance ID for which the rule has to be got.
  42. *
  43. * @return: Returns the rule info on success, NULL on error.
  44. *
  45. * This function is used when the service comes up and gets registered with
  46. * the IPC Router.
  47. */
  48. void *msm_ipc_get_security_rule(u32 service_id, u32 instance_id);
  49. /**
  50. * msm_ipc_check_send_permissions() - Check if the sendng process has
  51. * permissions specified as per the rule
  52. * @data: Security rule to be checked.
  53. *
  54. * @return: true if the process has permissions, else false.
  55. *
  56. * This function is used to check if the current executing process has
  57. * permissions to send message to the remote entity. The security rule
  58. * corresponding to the remote entity is specified by "data" parameter
  59. */
  60. int msm_ipc_check_send_permissions(void *data);
  61. /**
  62. * msm_ipc_router_security_init() - Initialize the security rule database
  63. *
  64. * @return: 0 if successful, < 0 for error.
  65. */
  66. int msm_ipc_router_security_init(void);
  67. /**
  68. * wait_for_irsc_completion() - Wait for IPC Router Security Configuration
  69. * (IRSC) to complete
  70. */
  71. void wait_for_irsc_completion(void);
  72. /**
  73. * signal_irsc_completion() - Signal the completion of IRSC
  74. */
  75. void signal_irsc_completion(void);
  76. #else
  77. static inline int check_permissions(void)
  78. {
  79. return 1;
  80. }
  81. static inline int msm_ipc_config_sec_rules(void *arg)
  82. {
  83. return -ENODEV;
  84. }
  85. static inline void *msm_ipc_get_security_rule(u32 service_id,
  86. u32 instance_id)
  87. {
  88. return NULL;
  89. }
  90. static inline int msm_ipc_check_send_permissions(void *data)
  91. {
  92. return 1;
  93. }
  94. static inline int msm_ipc_router_security_init(void)
  95. {
  96. return 0;
  97. }
  98. static inline void wait_for_irsc_completion(void) { }
  99. static inline void signal_irsc_completion(void) { }
  100. #endif
  101. #endif