udev.if 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. ## <summary>Policy for udev.</summary>
  2. ########################################
  3. ## <summary>
  4. ## Send generic signals to udev.
  5. ## </summary>
  6. ## <param name="domain">
  7. ## <summary>
  8. ## Domain allowed access.
  9. ## </summary>
  10. ## </param>
  11. #
  12. interface(`udev_signal',`
  13. gen_require(`
  14. type udev_t;
  15. ')
  16. allow $1 udev_t:process signal;
  17. ')
  18. ########################################
  19. ## <summary>
  20. ## Execute udev in the udev domain.
  21. ## </summary>
  22. ## <param name="domain">
  23. ## <summary>
  24. ## Domain allowed to transition.
  25. ## </summary>
  26. ## </param>
  27. #
  28. interface(`udev_domtrans',`
  29. gen_require(`
  30. type udev_t, udev_exec_t;
  31. ')
  32. domtrans_pattern($1, udev_exec_t, udev_t)
  33. ')
  34. ########################################
  35. ## <summary>
  36. ## Execute udev in the caller domain.
  37. ## </summary>
  38. ## <param name="domain">
  39. ## <summary>
  40. ## Domain allowed access.
  41. ## </summary>
  42. ## </param>
  43. #
  44. interface(`udev_exec',`
  45. gen_require(`
  46. type udev_exec_t;
  47. ')
  48. can_exec($1, udev_exec_t)
  49. ')
  50. ########################################
  51. ## <summary>
  52. ## Execute a udev helper in the udev domain.
  53. ## </summary>
  54. ## <param name="domain">
  55. ## <summary>
  56. ## Domain allowed to transition.
  57. ## </summary>
  58. ## </param>
  59. #
  60. interface(`udev_helper_domtrans',`
  61. gen_require(`
  62. type udev_t, udev_helper_exec_t;
  63. ')
  64. domtrans_pattern($1, udev_helper_exec_t, udev_t)
  65. ')
  66. ########################################
  67. ## <summary>
  68. ## Allow process to read udev process state.
  69. ## </summary>
  70. ## <param name="domain">
  71. ## <summary>
  72. ## Domain allowed access.
  73. ## </summary>
  74. ## </param>
  75. #
  76. interface(`udev_read_state',`
  77. gen_require(`
  78. type udev_t;
  79. ')
  80. kernel_search_proc($1)
  81. allow $1 udev_t:file read_file_perms;
  82. allow $1 udev_t:lnk_file read_lnk_file_perms;
  83. ')
  84. ########################################
  85. ## <summary>
  86. ## Do not audit attempts to inherit a
  87. ## udev file descriptor.
  88. ## </summary>
  89. ## <param name="domain">
  90. ## <summary>
  91. ## Domain to not audit.
  92. ## </summary>
  93. ## </param>
  94. #
  95. interface(`udev_dontaudit_use_fds',`
  96. gen_require(`
  97. type udev_t;
  98. ')
  99. dontaudit $1 udev_t:fd use;
  100. ')
  101. ########################################
  102. ## <summary>
  103. ## Do not audit attempts to read or write
  104. ## to a udev unix datagram socket.
  105. ## </summary>
  106. ## <param name="domain">
  107. ## <summary>
  108. ## Domain to not audit.
  109. ## </summary>
  110. ## </param>
  111. #
  112. interface(`udev_dontaudit_rw_dgram_sockets',`
  113. gen_require(`
  114. type udev_t;
  115. ')
  116. dontaudit $1 udev_t:unix_dgram_socket { read write };
  117. ')
  118. ########################################
  119. ## <summary>
  120. ## Manage udev rules files
  121. ## </summary>
  122. ## <param name="domain">
  123. ## <summary>
  124. ## Domain allowed access.
  125. ## </summary>
  126. ## </param>
  127. #
  128. interface(`udev_manage_rules_files',`
  129. gen_require(`
  130. type udev_rules_t;
  131. ')
  132. manage_files_pattern($1, udev_rules_t, udev_rules_t)
  133. files_search_etc($1)
  134. udev_search_pids($1)
  135. ')
  136. ########################################
  137. ## <summary>
  138. ## Do not audit search of udev database directories.
  139. ## </summary>
  140. ## <param name="domain">
  141. ## <summary>
  142. ## Domain to not audit.
  143. ## </summary>
  144. ## </param>
  145. #
  146. interface(`udev_dontaudit_search_db',`
  147. gen_require(`
  148. type udev_tbl_t;
  149. ')
  150. dontaudit $1 udev_tbl_t:dir search_dir_perms;
  151. ')
  152. ########################################
  153. ## <summary>
  154. ## Allow process to read the table dir
  155. ## </summary>
  156. ## <param name="domain">
  157. ## <summary>
  158. ## The type of the process performing this action.
  159. ## </summary>
  160. ## </param>
  161. #
  162. interface(`udev_list_table_dir',`
  163. gen_require(`
  164. type udev_tbl_t;
  165. ')
  166. allow $1 udev_tbl_t:dir list_dir_perms;
  167. ')
  168. ########################################
  169. ## <summary>
  170. ## Read the udev device table.
  171. ## </summary>
  172. ## <desc>
  173. ## <p>
  174. ## Allow the specified domain to read the udev device table.
  175. ## </p>
  176. ## </desc>
  177. ## <param name="domain">
  178. ## <summary>
  179. ## Domain allowed access.
  180. ## </summary>
  181. ## </param>
  182. ## <infoflow type="read" weight="10"/>
  183. #
  184. interface(`udev_read_db',`
  185. gen_require(`
  186. type udev_tbl_t;
  187. ')
  188. allow $1 udev_tbl_t:dir list_dir_perms;
  189. read_files_pattern($1, udev_tbl_t, udev_tbl_t)
  190. read_lnk_files_pattern($1, udev_tbl_t, udev_tbl_t)
  191. dev_list_all_dev_nodes($1)
  192. files_search_etc($1)
  193. udev_search_pids($1)
  194. ')
  195. ########################################
  196. ## <summary>
  197. ## Allow process to modify list of devices.
  198. ## </summary>
  199. ## <param name="domain">
  200. ## <summary>
  201. ## Domain allowed access.
  202. ## </summary>
  203. ## </param>
  204. #
  205. interface(`udev_rw_db',`
  206. gen_require(`
  207. type udev_tbl_t;
  208. ')
  209. dev_list_all_dev_nodes($1)
  210. allow $1 udev_tbl_t:file rw_file_perms;
  211. ')
  212. ########################################
  213. ## <summary>
  214. ## Search through udev pid content
  215. ## </summary>
  216. ## <param name="domain">
  217. ## <summary>
  218. ## Domain allowed access.
  219. ## </summary>
  220. ## </param>
  221. #
  222. interface(`udev_search_pids',`
  223. gen_require(`
  224. type udev_var_run_t;
  225. ')
  226. files_search_pids($1)
  227. search_dirs_pattern($1, udev_var_run_t, udev_var_run_t)
  228. ')
  229. ########################################
  230. ## <summary>
  231. ## dontaudit attempts to read/write udev pidfiles
  232. ## </summary>
  233. ## <param name="domain">
  234. ## <summary>
  235. ## Domain allowed access.
  236. ## </summary>
  237. ## </param>
  238. #
  239. interface(`dontaudit_udev_pidfile_rw',`
  240. gen_require(`
  241. type udev_var_run_t;
  242. ')
  243. dontaudit $1 udev_var_run_t:file { read write };
  244. ')
  245. ########################################
  246. ## <summary>
  247. ## Create, read, write, and delete
  248. ## udev pid directories
  249. ## </summary>
  250. ## <param name="domain">
  251. ## <summary>
  252. ## Domain allowed access.
  253. ## </summary>
  254. ## </param>
  255. #
  256. interface(`udev_manage_pid_dirs',`
  257. gen_require(`
  258. type udev_var_run_t;
  259. ')
  260. files_search_var($1)
  261. manage_dirs_pattern($1, udev_var_run_t, udev_var_run_t)
  262. ')
  263. ########################################
  264. ## <summary>
  265. ## Allow process to modify relabelto udev database
  266. ## </summary>
  267. ## <param name="domain">
  268. ## <summary>
  269. ## Domain allowed access.
  270. ## </summary>
  271. ## </param>
  272. #
  273. interface(`udev_relabelto_db',`
  274. gen_require(`
  275. type udev_var_run_t;
  276. ')
  277. files_search_pids($1)
  278. allow $1 udev_var_run_t:file relabelto_file_perms;
  279. allow $1 udev_var_run_t:lnk_file relabelto_file_perms;
  280. ')
  281. ########################################
  282. ## <summary>
  283. ## Read udev pid files.
  284. ## </summary>
  285. ## <param name="domain">
  286. ## <summary>
  287. ## Domain allowed access.
  288. ## </summary>
  289. ## </param>
  290. #
  291. interface(`udev_read_pid_files',`
  292. gen_require(`
  293. type udev_var_run_t;
  294. ')
  295. files_search_pids($1)
  296. read_files_pattern($1, udev_var_run_t, udev_var_run_t)
  297. ')
  298. ########################################
  299. ## <summary>
  300. ## Create, read, write, and delete
  301. ## udev pid files.
  302. ## </summary>
  303. ## <param name="domain">
  304. ## <summary>
  305. ## Domain allowed access.
  306. ## </summary>
  307. ## </param>
  308. #
  309. interface(`udev_manage_pid_files',`
  310. gen_require(`
  311. type udev_var_run_t;
  312. ')
  313. files_search_pids($1)
  314. manage_files_pattern($1, udev_var_run_t, udev_var_run_t)
  315. ')
  316. ########################################
  317. ## <summary>
  318. ## Create directories in the run location with udev_var_run_t type
  319. ## </summary>
  320. ## <param name="domain">
  321. ## <summary>
  322. ## Domain allowed access.
  323. ## </summary>
  324. ## </param>
  325. ## <param name="name" optional="true">
  326. ## <summary>
  327. ## Name of the directory that is created
  328. ## </summary>
  329. ## </param>
  330. #
  331. interface(`udev_generic_pid_filetrans_run_dirs',`
  332. gen_require(`
  333. type udev_var_run_t;
  334. ')
  335. files_pid_filetrans($1, udev_var_run_t, dir, $2)
  336. ')
  337. #######################################
  338. ## <summary>
  339. ## Allow caller to create kobject uevent socket for udev
  340. ## </summary>
  341. ## <param name="domain">
  342. ## <summary>
  343. ## Domain allowed access.
  344. ## </summary>
  345. ## </param>
  346. #
  347. interface(`udev_create_kobject_uevent_socket',`
  348. gen_require(`
  349. type udev_t;
  350. role system_r;
  351. ')
  352. allow $1 udev_t:netlink_kobject_uevent_socket create_socket_perms;
  353. ')
  354. #######################################
  355. ## <summary>
  356. ## Allow udev_t to write to a unix_stream_socket
  357. ## </summary>
  358. ## <param name="domain">
  359. ## <summary>
  360. ## domain to connect to
  361. ## </summary>
  362. ## </param>
  363. #
  364. interface(`udev_write_socket',`
  365. gen_require(`
  366. type udev_t;
  367. ')
  368. allow udev_t $1:unix_stream_socket connectto;
  369. ')
  370. #######################################
  371. ## <summary>
  372. ## Allows process to write to a udp socket of type udev_t
  373. ## </summary>
  374. ## <param name="domain">
  375. ## <summary>
  376. ## Domain allowed access
  377. ## </summary>
  378. ## </param>
  379. #
  380. interface(`connect_udev_udp_socket',`
  381. gen_require(`
  382. type udev_t;
  383. ')
  384. allow $1 udev_t:udp_socket { read write };
  385. ')