capability.c 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  1. /*
  2. * Capabilities Linux Security Module
  3. *
  4. * This is the default security module in case no other module is loaded.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. */
  12. #include <linux/security.h>
  13. static int cap_binder_set_context_mgr(struct task_struct *mgr)
  14. {
  15. return 0;
  16. }
  17. static int cap_binder_transaction(struct task_struct *from,
  18. struct task_struct *to)
  19. {
  20. return 0;
  21. }
  22. static int cap_binder_transfer_binder(struct task_struct *from,
  23. struct task_struct *to)
  24. {
  25. return 0;
  26. }
  27. static int cap_binder_transfer_file(struct task_struct *from,
  28. struct task_struct *to, struct file *file)
  29. {
  30. return 0;
  31. }
  32. static int cap_syslog(int type)
  33. {
  34. return 0;
  35. }
  36. static int cap_quotactl(int cmds, int type, int id, struct super_block *sb)
  37. {
  38. return 0;
  39. }
  40. static int cap_quota_on(struct dentry *dentry)
  41. {
  42. return 0;
  43. }
  44. static int cap_bprm_check_security(struct linux_binprm *bprm)
  45. {
  46. return 0;
  47. }
  48. static void cap_bprm_committing_creds(struct linux_binprm *bprm)
  49. {
  50. }
  51. static void cap_bprm_committed_creds(struct linux_binprm *bprm)
  52. {
  53. }
  54. static int cap_sb_alloc_security(struct super_block *sb)
  55. {
  56. return 0;
  57. }
  58. static void cap_sb_free_security(struct super_block *sb)
  59. {
  60. }
  61. static int cap_sb_copy_data(char *orig, char *copy)
  62. {
  63. return 0;
  64. }
  65. static int cap_sb_remount(struct super_block *sb, void *data)
  66. {
  67. return 0;
  68. }
  69. static int cap_sb_kern_mount(struct super_block *sb, int flags, void *data)
  70. {
  71. return 0;
  72. }
  73. static int cap_sb_show_options(struct seq_file *m, struct super_block *sb)
  74. {
  75. return 0;
  76. }
  77. static int cap_sb_statfs(struct dentry *dentry)
  78. {
  79. return 0;
  80. }
  81. static int cap_sb_mount(const char *dev_name, struct path *path,
  82. const char *type, unsigned long flags, void *data)
  83. {
  84. return 0;
  85. }
  86. static int cap_sb_umount(struct vfsmount *mnt, int flags)
  87. {
  88. return 0;
  89. }
  90. static int cap_sb_pivotroot(struct path *old_path, struct path *new_path)
  91. {
  92. return 0;
  93. }
  94. static int cap_sb_set_mnt_opts(struct super_block *sb,
  95. struct security_mnt_opts *opts,
  96. unsigned long kern_flags,
  97. unsigned long *set_kern_flags)
  98. {
  99. if (unlikely(opts->num_mnt_opts))
  100. return -EOPNOTSUPP;
  101. return 0;
  102. }
  103. static int cap_sb_clone_mnt_opts(const struct super_block *oldsb,
  104. struct super_block *newsb)
  105. {
  106. return 0;
  107. }
  108. static int cap_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
  109. {
  110. return 0;
  111. }
  112. static int cap_dentry_init_security(struct dentry *dentry, int mode,
  113. struct qstr *name, void **ctx,
  114. u32 *ctxlen)
  115. {
  116. return -EOPNOTSUPP;
  117. }
  118. static int cap_inode_alloc_security(struct inode *inode)
  119. {
  120. return 0;
  121. }
  122. static void cap_inode_free_security(struct inode *inode)
  123. {
  124. }
  125. static int cap_inode_init_security(struct inode *inode, struct inode *dir,
  126. const struct qstr *qstr, const char **name,
  127. void **value, size_t *len)
  128. {
  129. return -EOPNOTSUPP;
  130. }
  131. static int cap_inode_create(struct inode *inode, struct dentry *dentry,
  132. umode_t mask)
  133. {
  134. return 0;
  135. }
  136. static int cap_inode_link(struct dentry *old_dentry, struct inode *inode,
  137. struct dentry *new_dentry)
  138. {
  139. return 0;
  140. }
  141. static int cap_inode_unlink(struct inode *inode, struct dentry *dentry)
  142. {
  143. return 0;
  144. }
  145. static int cap_inode_symlink(struct inode *inode, struct dentry *dentry,
  146. const char *name)
  147. {
  148. return 0;
  149. }
  150. static int cap_inode_mkdir(struct inode *inode, struct dentry *dentry,
  151. umode_t mask)
  152. {
  153. return 0;
  154. }
  155. static int cap_inode_rmdir(struct inode *inode, struct dentry *dentry)
  156. {
  157. return 0;
  158. }
  159. static int cap_inode_mknod(struct inode *inode, struct dentry *dentry,
  160. umode_t mode, dev_t dev)
  161. {
  162. return 0;
  163. }
  164. static int cap_inode_rename(struct inode *old_inode, struct dentry *old_dentry,
  165. struct inode *new_inode, struct dentry *new_dentry)
  166. {
  167. return 0;
  168. }
  169. static int cap_inode_readlink(struct dentry *dentry)
  170. {
  171. return 0;
  172. }
  173. static int cap_inode_follow_link(struct dentry *dentry)
  174. {
  175. return 0;
  176. }
  177. static int cap_inode_permission(struct inode *inode, int mask)
  178. {
  179. return 0;
  180. }
  181. static int cap_inode_setattr(struct dentry *dentry, struct iattr *iattr)
  182. {
  183. return 0;
  184. }
  185. static int cap_inode_getattr(const struct path *path)
  186. {
  187. return 0;
  188. }
  189. static void cap_inode_post_setxattr(struct dentry *dentry, const char *name,
  190. const void *value, size_t size, int flags)
  191. {
  192. }
  193. static int cap_inode_getxattr(struct dentry *dentry, const char *name)
  194. {
  195. return 0;
  196. }
  197. static int cap_inode_listxattr(struct dentry *dentry)
  198. {
  199. return 0;
  200. }
  201. static int cap_inode_getsecurity(const struct inode *inode, const char *name,
  202. void **buffer, bool alloc)
  203. {
  204. return -EOPNOTSUPP;
  205. }
  206. static int cap_inode_setsecurity(struct inode *inode, const char *name,
  207. const void *value, size_t size, int flags)
  208. {
  209. return -EOPNOTSUPP;
  210. }
  211. static int cap_inode_listsecurity(struct inode *inode, char *buffer,
  212. size_t buffer_size)
  213. {
  214. return 0;
  215. }
  216. static void cap_inode_getsecid(const struct inode *inode, u32 *secid)
  217. {
  218. *secid = 0;
  219. }
  220. #ifdef CONFIG_SECURITY_PATH
  221. static int cap_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
  222. unsigned int dev)
  223. {
  224. return 0;
  225. }
  226. static int cap_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode)
  227. {
  228. return 0;
  229. }
  230. static int cap_path_rmdir(struct path *dir, struct dentry *dentry)
  231. {
  232. return 0;
  233. }
  234. static int cap_path_unlink(struct path *dir, struct dentry *dentry)
  235. {
  236. return 0;
  237. }
  238. static int cap_path_symlink(struct path *dir, struct dentry *dentry,
  239. const char *old_name)
  240. {
  241. return 0;
  242. }
  243. static int cap_path_link(struct dentry *old_dentry, struct path *new_dir,
  244. struct dentry *new_dentry)
  245. {
  246. return 0;
  247. }
  248. static int cap_path_rename(struct path *old_path, struct dentry *old_dentry,
  249. struct path *new_path, struct dentry *new_dentry)
  250. {
  251. return 0;
  252. }
  253. static int cap_path_truncate(struct path *path)
  254. {
  255. return 0;
  256. }
  257. static int cap_path_chmod(struct path *path, umode_t mode)
  258. {
  259. return 0;
  260. }
  261. static int cap_path_chown(struct path *path, kuid_t uid, kgid_t gid)
  262. {
  263. return 0;
  264. }
  265. static int cap_path_chroot(struct path *root)
  266. {
  267. return 0;
  268. }
  269. #endif
  270. static int cap_file_permission(struct file *file, int mask)
  271. {
  272. return 0;
  273. }
  274. static int cap_file_alloc_security(struct file *file)
  275. {
  276. return 0;
  277. }
  278. static void cap_file_free_security(struct file *file)
  279. {
  280. }
  281. static int cap_file_ioctl(struct file *file, unsigned int command,
  282. unsigned long arg)
  283. {
  284. return 0;
  285. }
  286. static int cap_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
  287. unsigned long prot)
  288. {
  289. return 0;
  290. }
  291. static int cap_file_lock(struct file *file, unsigned int cmd)
  292. {
  293. return 0;
  294. }
  295. static int cap_file_fcntl(struct file *file, unsigned int cmd,
  296. unsigned long arg)
  297. {
  298. return 0;
  299. }
  300. static void cap_file_set_fowner(struct file *file)
  301. {
  302. return;
  303. }
  304. static int cap_file_send_sigiotask(struct task_struct *tsk,
  305. struct fown_struct *fown, int sig)
  306. {
  307. return 0;
  308. }
  309. static int cap_file_receive(struct file *file)
  310. {
  311. return 0;
  312. }
  313. static int cap_file_open(struct file *file, const struct cred *cred)
  314. {
  315. return 0;
  316. }
  317. static int cap_task_create(unsigned long clone_flags)
  318. {
  319. return 0;
  320. }
  321. static void cap_task_free(struct task_struct *task)
  322. {
  323. }
  324. static int cap_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  325. {
  326. return 0;
  327. }
  328. static void cap_cred_free(struct cred *cred)
  329. {
  330. }
  331. static int cap_cred_prepare(struct cred *new, const struct cred *old, gfp_t gfp)
  332. {
  333. return 0;
  334. }
  335. static void cap_cred_transfer(struct cred *new, const struct cred *old)
  336. {
  337. }
  338. static int cap_kernel_act_as(struct cred *new, u32 secid)
  339. {
  340. return 0;
  341. }
  342. static int cap_kernel_create_files_as(struct cred *new, struct inode *inode)
  343. {
  344. return 0;
  345. }
  346. static int cap_kernel_fw_from_file(struct file *file, char *buf, size_t size)
  347. {
  348. return 0;
  349. }
  350. static int cap_kernel_module_request(char *kmod_name)
  351. {
  352. return 0;
  353. }
  354. static int cap_kernel_module_from_file(struct file *file)
  355. {
  356. return 0;
  357. }
  358. static int cap_task_setpgid(struct task_struct *p, pid_t pgid)
  359. {
  360. return 0;
  361. }
  362. static int cap_task_getpgid(struct task_struct *p)
  363. {
  364. return 0;
  365. }
  366. static int cap_task_getsid(struct task_struct *p)
  367. {
  368. return 0;
  369. }
  370. static void cap_task_getsecid(struct task_struct *p, u32 *secid)
  371. {
  372. *secid = 0;
  373. }
  374. static int cap_task_getioprio(struct task_struct *p)
  375. {
  376. return 0;
  377. }
  378. static int cap_task_setrlimit(struct task_struct *p, unsigned int resource,
  379. struct rlimit *new_rlim)
  380. {
  381. return 0;
  382. }
  383. static int cap_task_getscheduler(struct task_struct *p)
  384. {
  385. return 0;
  386. }
  387. static int cap_task_movememory(struct task_struct *p)
  388. {
  389. return 0;
  390. }
  391. static int cap_task_wait(struct task_struct *p)
  392. {
  393. return 0;
  394. }
  395. static int cap_task_kill(struct task_struct *p, struct siginfo *info,
  396. int sig, u32 secid)
  397. {
  398. return 0;
  399. }
  400. static void cap_task_to_inode(struct task_struct *p, struct inode *inode)
  401. {
  402. }
  403. static int cap_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
  404. {
  405. return 0;
  406. }
  407. static void cap_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
  408. {
  409. *secid = 0;
  410. }
  411. static int cap_msg_msg_alloc_security(struct msg_msg *msg)
  412. {
  413. return 0;
  414. }
  415. static void cap_msg_msg_free_security(struct msg_msg *msg)
  416. {
  417. }
  418. static int cap_msg_queue_alloc_security(struct msg_queue *msq)
  419. {
  420. return 0;
  421. }
  422. static void cap_msg_queue_free_security(struct msg_queue *msq)
  423. {
  424. }
  425. static int cap_msg_queue_associate(struct msg_queue *msq, int msqflg)
  426. {
  427. return 0;
  428. }
  429. static int cap_msg_queue_msgctl(struct msg_queue *msq, int cmd)
  430. {
  431. return 0;
  432. }
  433. static int cap_msg_queue_msgsnd(struct msg_queue *msq, struct msg_msg *msg,
  434. int msgflg)
  435. {
  436. return 0;
  437. }
  438. static int cap_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
  439. struct task_struct *target, long type, int mode)
  440. {
  441. return 0;
  442. }
  443. static int cap_shm_alloc_security(struct shmid_kernel *shp)
  444. {
  445. return 0;
  446. }
  447. static void cap_shm_free_security(struct shmid_kernel *shp)
  448. {
  449. }
  450. static int cap_shm_associate(struct shmid_kernel *shp, int shmflg)
  451. {
  452. return 0;
  453. }
  454. static int cap_shm_shmctl(struct shmid_kernel *shp, int cmd)
  455. {
  456. return 0;
  457. }
  458. static int cap_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr,
  459. int shmflg)
  460. {
  461. return 0;
  462. }
  463. static int cap_sem_alloc_security(struct sem_array *sma)
  464. {
  465. return 0;
  466. }
  467. static void cap_sem_free_security(struct sem_array *sma)
  468. {
  469. }
  470. static int cap_sem_associate(struct sem_array *sma, int semflg)
  471. {
  472. return 0;
  473. }
  474. static int cap_sem_semctl(struct sem_array *sma, int cmd)
  475. {
  476. return 0;
  477. }
  478. static int cap_sem_semop(struct sem_array *sma, struct sembuf *sops,
  479. unsigned nsops, int alter)
  480. {
  481. return 0;
  482. }
  483. #ifdef CONFIG_SECURITY_NETWORK
  484. static int cap_unix_stream_connect(struct sock *sock, struct sock *other,
  485. struct sock *newsk)
  486. {
  487. return 0;
  488. }
  489. static int cap_unix_may_send(struct socket *sock, struct socket *other)
  490. {
  491. return 0;
  492. }
  493. static int cap_socket_create(int family, int type, int protocol, int kern)
  494. {
  495. return 0;
  496. }
  497. static int cap_socket_post_create(struct socket *sock, int family, int type,
  498. int protocol, int kern)
  499. {
  500. return 0;
  501. }
  502. static int cap_socket_bind(struct socket *sock, struct sockaddr *address,
  503. int addrlen)
  504. {
  505. return 0;
  506. }
  507. static int cap_socket_connect(struct socket *sock, struct sockaddr *address,
  508. int addrlen)
  509. {
  510. return 0;
  511. }
  512. static int cap_socket_listen(struct socket *sock, int backlog)
  513. {
  514. return 0;
  515. }
  516. static int cap_socket_accept(struct socket *sock, struct socket *newsock)
  517. {
  518. return 0;
  519. }
  520. static int cap_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size)
  521. {
  522. return 0;
  523. }
  524. static int cap_socket_recvmsg(struct socket *sock, struct msghdr *msg,
  525. int size, int flags)
  526. {
  527. return 0;
  528. }
  529. static int cap_socket_getsockname(struct socket *sock)
  530. {
  531. return 0;
  532. }
  533. static int cap_socket_getpeername(struct socket *sock)
  534. {
  535. return 0;
  536. }
  537. static int cap_socket_setsockopt(struct socket *sock, int level, int optname)
  538. {
  539. return 0;
  540. }
  541. static int cap_socket_getsockopt(struct socket *sock, int level, int optname)
  542. {
  543. return 0;
  544. }
  545. static int cap_socket_shutdown(struct socket *sock, int how)
  546. {
  547. return 0;
  548. }
  549. static int cap_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
  550. {
  551. return 0;
  552. }
  553. static int cap_socket_getpeersec_stream(struct socket *sock,
  554. char __user *optval,
  555. int __user *optlen, unsigned len)
  556. {
  557. return -ENOPROTOOPT;
  558. }
  559. static int cap_socket_getpeersec_dgram(struct socket *sock,
  560. struct sk_buff *skb, u32 *secid)
  561. {
  562. return -ENOPROTOOPT;
  563. }
  564. static int cap_sk_alloc_security(struct sock *sk, int family, gfp_t priority)
  565. {
  566. return 0;
  567. }
  568. static void cap_sk_free_security(struct sock *sk)
  569. {
  570. }
  571. static void cap_sk_clone_security(const struct sock *sk, struct sock *newsk)
  572. {
  573. }
  574. static void cap_sk_getsecid(struct sock *sk, u32 *secid)
  575. {
  576. }
  577. static void cap_sock_graft(struct sock *sk, struct socket *parent)
  578. {
  579. }
  580. static int cap_inet_conn_request(struct sock *sk, struct sk_buff *skb,
  581. struct request_sock *req)
  582. {
  583. return 0;
  584. }
  585. static void cap_inet_csk_clone(struct sock *newsk,
  586. const struct request_sock *req)
  587. {
  588. }
  589. static void cap_inet_conn_established(struct sock *sk, struct sk_buff *skb)
  590. {
  591. }
  592. static int cap_secmark_relabel_packet(u32 secid)
  593. {
  594. return 0;
  595. }
  596. static void cap_secmark_refcount_inc(void)
  597. {
  598. }
  599. static void cap_secmark_refcount_dec(void)
  600. {
  601. }
  602. static void cap_req_classify_flow(const struct request_sock *req,
  603. struct flowi *fl)
  604. {
  605. }
  606. static int cap_tun_dev_alloc_security(void **security)
  607. {
  608. return 0;
  609. }
  610. static void cap_tun_dev_free_security(void *security)
  611. {
  612. }
  613. static int cap_tun_dev_create(void)
  614. {
  615. return 0;
  616. }
  617. static int cap_tun_dev_attach_queue(void *security)
  618. {
  619. return 0;
  620. }
  621. static int cap_tun_dev_attach(struct sock *sk, void *security)
  622. {
  623. return 0;
  624. }
  625. static int cap_tun_dev_open(void *security)
  626. {
  627. return 0;
  628. }
  629. #endif /* CONFIG_SECURITY_NETWORK */
  630. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  631. static int cap_xfrm_policy_alloc_security(struct xfrm_sec_ctx **ctxp,
  632. struct xfrm_user_sec_ctx *sec_ctx,
  633. gfp_t gfp)
  634. {
  635. return 0;
  636. }
  637. static int cap_xfrm_policy_clone_security(struct xfrm_sec_ctx *old_ctx,
  638. struct xfrm_sec_ctx **new_ctxp)
  639. {
  640. return 0;
  641. }
  642. static void cap_xfrm_policy_free_security(struct xfrm_sec_ctx *ctx)
  643. {
  644. }
  645. static int cap_xfrm_policy_delete_security(struct xfrm_sec_ctx *ctx)
  646. {
  647. return 0;
  648. }
  649. static int cap_xfrm_state_alloc(struct xfrm_state *x,
  650. struct xfrm_user_sec_ctx *sec_ctx)
  651. {
  652. return 0;
  653. }
  654. static int cap_xfrm_state_alloc_acquire(struct xfrm_state *x,
  655. struct xfrm_sec_ctx *polsec,
  656. u32 secid)
  657. {
  658. return 0;
  659. }
  660. static void cap_xfrm_state_free_security(struct xfrm_state *x)
  661. {
  662. }
  663. static int cap_xfrm_state_delete_security(struct xfrm_state *x)
  664. {
  665. return 0;
  666. }
  667. static int cap_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 sk_sid, u8 dir)
  668. {
  669. return 0;
  670. }
  671. static int cap_xfrm_state_pol_flow_match(struct xfrm_state *x,
  672. struct xfrm_policy *xp,
  673. const struct flowi *fl)
  674. {
  675. return 1;
  676. }
  677. static int cap_xfrm_decode_session(struct sk_buff *skb, u32 *fl, int ckall)
  678. {
  679. return 0;
  680. }
  681. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  682. static void cap_d_instantiate(struct dentry *dentry, struct inode *inode)
  683. {
  684. }
  685. static int cap_getprocattr(struct task_struct *p, char *name, char **value)
  686. {
  687. return -EINVAL;
  688. }
  689. static int cap_setprocattr(struct task_struct *p, char *name, void *value,
  690. size_t size)
  691. {
  692. return -EINVAL;
  693. }
  694. static int cap_ismaclabel(const char *name)
  695. {
  696. return 0;
  697. }
  698. static int cap_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  699. {
  700. return -EOPNOTSUPP;
  701. }
  702. static int cap_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
  703. {
  704. *secid = 0;
  705. return 0;
  706. }
  707. static void cap_release_secctx(char *secdata, u32 seclen)
  708. {
  709. }
  710. static int cap_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
  711. {
  712. return 0;
  713. }
  714. static int cap_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
  715. {
  716. return 0;
  717. }
  718. static int cap_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
  719. {
  720. return -EOPNOTSUPP;
  721. }
  722. #ifdef CONFIG_KEYS
  723. static int cap_key_alloc(struct key *key, const struct cred *cred,
  724. unsigned long flags)
  725. {
  726. return 0;
  727. }
  728. static void cap_key_free(struct key *key)
  729. {
  730. }
  731. static int cap_key_permission(key_ref_t key_ref, const struct cred *cred,
  732. unsigned perm)
  733. {
  734. return 0;
  735. }
  736. static int cap_key_getsecurity(struct key *key, char **_buffer)
  737. {
  738. *_buffer = NULL;
  739. return 0;
  740. }
  741. #endif /* CONFIG_KEYS */
  742. #ifdef CONFIG_AUDIT
  743. static int cap_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule)
  744. {
  745. return 0;
  746. }
  747. static int cap_audit_rule_known(struct audit_krule *krule)
  748. {
  749. return 0;
  750. }
  751. static int cap_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
  752. struct audit_context *actx)
  753. {
  754. return 0;
  755. }
  756. static void cap_audit_rule_free(void *lsmrule)
  757. {
  758. }
  759. #endif /* CONFIG_AUDIT */
  760. #define set_to_cap_if_null(ops, function) \
  761. do { \
  762. if (!ops->function) { \
  763. ops->function = cap_##function; \
  764. pr_debug("Had to override the " #function \
  765. " security operation with the default.\n");\
  766. } \
  767. } while (0)
  768. void __init security_fixup_ops(struct security_operations *ops)
  769. {
  770. set_to_cap_if_null(ops, binder_set_context_mgr);
  771. set_to_cap_if_null(ops, binder_transaction);
  772. set_to_cap_if_null(ops, binder_transfer_binder);
  773. set_to_cap_if_null(ops, binder_transfer_file);
  774. set_to_cap_if_null(ops, ptrace_access_check);
  775. set_to_cap_if_null(ops, ptrace_traceme);
  776. set_to_cap_if_null(ops, capget);
  777. set_to_cap_if_null(ops, capset);
  778. set_to_cap_if_null(ops, capable);
  779. set_to_cap_if_null(ops, quotactl);
  780. set_to_cap_if_null(ops, quota_on);
  781. set_to_cap_if_null(ops, syslog);
  782. set_to_cap_if_null(ops, settime);
  783. set_to_cap_if_null(ops, vm_enough_memory);
  784. set_to_cap_if_null(ops, bprm_set_creds);
  785. set_to_cap_if_null(ops, bprm_committing_creds);
  786. set_to_cap_if_null(ops, bprm_committed_creds);
  787. set_to_cap_if_null(ops, bprm_check_security);
  788. set_to_cap_if_null(ops, bprm_secureexec);
  789. set_to_cap_if_null(ops, sb_alloc_security);
  790. set_to_cap_if_null(ops, sb_free_security);
  791. set_to_cap_if_null(ops, sb_copy_data);
  792. set_to_cap_if_null(ops, sb_remount);
  793. set_to_cap_if_null(ops, sb_kern_mount);
  794. set_to_cap_if_null(ops, sb_show_options);
  795. set_to_cap_if_null(ops, sb_statfs);
  796. set_to_cap_if_null(ops, sb_mount);
  797. set_to_cap_if_null(ops, sb_umount);
  798. set_to_cap_if_null(ops, sb_pivotroot);
  799. set_to_cap_if_null(ops, sb_set_mnt_opts);
  800. set_to_cap_if_null(ops, sb_clone_mnt_opts);
  801. set_to_cap_if_null(ops, sb_parse_opts_str);
  802. set_to_cap_if_null(ops, dentry_init_security);
  803. set_to_cap_if_null(ops, inode_alloc_security);
  804. set_to_cap_if_null(ops, inode_free_security);
  805. set_to_cap_if_null(ops, inode_init_security);
  806. set_to_cap_if_null(ops, inode_create);
  807. set_to_cap_if_null(ops, inode_link);
  808. set_to_cap_if_null(ops, inode_unlink);
  809. set_to_cap_if_null(ops, inode_symlink);
  810. set_to_cap_if_null(ops, inode_mkdir);
  811. set_to_cap_if_null(ops, inode_rmdir);
  812. set_to_cap_if_null(ops, inode_mknod);
  813. set_to_cap_if_null(ops, inode_rename);
  814. set_to_cap_if_null(ops, inode_readlink);
  815. set_to_cap_if_null(ops, inode_follow_link);
  816. set_to_cap_if_null(ops, inode_permission);
  817. set_to_cap_if_null(ops, inode_setattr);
  818. set_to_cap_if_null(ops, inode_getattr);
  819. set_to_cap_if_null(ops, inode_setxattr);
  820. set_to_cap_if_null(ops, inode_post_setxattr);
  821. set_to_cap_if_null(ops, inode_getxattr);
  822. set_to_cap_if_null(ops, inode_listxattr);
  823. set_to_cap_if_null(ops, inode_removexattr);
  824. set_to_cap_if_null(ops, inode_need_killpriv);
  825. set_to_cap_if_null(ops, inode_killpriv);
  826. set_to_cap_if_null(ops, inode_getsecurity);
  827. set_to_cap_if_null(ops, inode_setsecurity);
  828. set_to_cap_if_null(ops, inode_listsecurity);
  829. set_to_cap_if_null(ops, inode_getsecid);
  830. #ifdef CONFIG_SECURITY_PATH
  831. set_to_cap_if_null(ops, path_mknod);
  832. set_to_cap_if_null(ops, path_mkdir);
  833. set_to_cap_if_null(ops, path_rmdir);
  834. set_to_cap_if_null(ops, path_unlink);
  835. set_to_cap_if_null(ops, path_symlink);
  836. set_to_cap_if_null(ops, path_link);
  837. set_to_cap_if_null(ops, path_rename);
  838. set_to_cap_if_null(ops, path_truncate);
  839. set_to_cap_if_null(ops, path_chmod);
  840. set_to_cap_if_null(ops, path_chown);
  841. set_to_cap_if_null(ops, path_chroot);
  842. #endif
  843. set_to_cap_if_null(ops, file_permission);
  844. set_to_cap_if_null(ops, file_alloc_security);
  845. set_to_cap_if_null(ops, file_free_security);
  846. set_to_cap_if_null(ops, file_ioctl);
  847. set_to_cap_if_null(ops, mmap_addr);
  848. set_to_cap_if_null(ops, mmap_file);
  849. set_to_cap_if_null(ops, file_mprotect);
  850. set_to_cap_if_null(ops, file_lock);
  851. set_to_cap_if_null(ops, file_fcntl);
  852. set_to_cap_if_null(ops, file_set_fowner);
  853. set_to_cap_if_null(ops, file_send_sigiotask);
  854. set_to_cap_if_null(ops, file_receive);
  855. set_to_cap_if_null(ops, file_open);
  856. set_to_cap_if_null(ops, task_create);
  857. set_to_cap_if_null(ops, task_free);
  858. set_to_cap_if_null(ops, cred_alloc_blank);
  859. set_to_cap_if_null(ops, cred_free);
  860. set_to_cap_if_null(ops, cred_prepare);
  861. set_to_cap_if_null(ops, cred_transfer);
  862. set_to_cap_if_null(ops, kernel_act_as);
  863. set_to_cap_if_null(ops, kernel_create_files_as);
  864. set_to_cap_if_null(ops, kernel_fw_from_file);
  865. set_to_cap_if_null(ops, kernel_module_request);
  866. set_to_cap_if_null(ops, kernel_module_from_file);
  867. set_to_cap_if_null(ops, task_fix_setuid);
  868. set_to_cap_if_null(ops, task_setpgid);
  869. set_to_cap_if_null(ops, task_getpgid);
  870. set_to_cap_if_null(ops, task_getsid);
  871. set_to_cap_if_null(ops, task_getsecid);
  872. set_to_cap_if_null(ops, task_setnice);
  873. set_to_cap_if_null(ops, task_setioprio);
  874. set_to_cap_if_null(ops, task_getioprio);
  875. set_to_cap_if_null(ops, task_setrlimit);
  876. set_to_cap_if_null(ops, task_setscheduler);
  877. set_to_cap_if_null(ops, task_getscheduler);
  878. set_to_cap_if_null(ops, task_movememory);
  879. set_to_cap_if_null(ops, task_wait);
  880. set_to_cap_if_null(ops, task_kill);
  881. set_to_cap_if_null(ops, task_prctl);
  882. set_to_cap_if_null(ops, task_to_inode);
  883. set_to_cap_if_null(ops, ipc_permission);
  884. set_to_cap_if_null(ops, ipc_getsecid);
  885. set_to_cap_if_null(ops, msg_msg_alloc_security);
  886. set_to_cap_if_null(ops, msg_msg_free_security);
  887. set_to_cap_if_null(ops, msg_queue_alloc_security);
  888. set_to_cap_if_null(ops, msg_queue_free_security);
  889. set_to_cap_if_null(ops, msg_queue_associate);
  890. set_to_cap_if_null(ops, msg_queue_msgctl);
  891. set_to_cap_if_null(ops, msg_queue_msgsnd);
  892. set_to_cap_if_null(ops, msg_queue_msgrcv);
  893. set_to_cap_if_null(ops, shm_alloc_security);
  894. set_to_cap_if_null(ops, shm_free_security);
  895. set_to_cap_if_null(ops, shm_associate);
  896. set_to_cap_if_null(ops, shm_shmctl);
  897. set_to_cap_if_null(ops, shm_shmat);
  898. set_to_cap_if_null(ops, sem_alloc_security);
  899. set_to_cap_if_null(ops, sem_free_security);
  900. set_to_cap_if_null(ops, sem_associate);
  901. set_to_cap_if_null(ops, sem_semctl);
  902. set_to_cap_if_null(ops, sem_semop);
  903. set_to_cap_if_null(ops, netlink_send);
  904. set_to_cap_if_null(ops, d_instantiate);
  905. set_to_cap_if_null(ops, getprocattr);
  906. set_to_cap_if_null(ops, setprocattr);
  907. set_to_cap_if_null(ops, ismaclabel);
  908. set_to_cap_if_null(ops, secid_to_secctx);
  909. set_to_cap_if_null(ops, secctx_to_secid);
  910. set_to_cap_if_null(ops, release_secctx);
  911. set_to_cap_if_null(ops, inode_notifysecctx);
  912. set_to_cap_if_null(ops, inode_setsecctx);
  913. set_to_cap_if_null(ops, inode_getsecctx);
  914. #ifdef CONFIG_SECURITY_NETWORK
  915. set_to_cap_if_null(ops, unix_stream_connect);
  916. set_to_cap_if_null(ops, unix_may_send);
  917. set_to_cap_if_null(ops, socket_create);
  918. set_to_cap_if_null(ops, socket_post_create);
  919. set_to_cap_if_null(ops, socket_bind);
  920. set_to_cap_if_null(ops, socket_connect);
  921. set_to_cap_if_null(ops, socket_listen);
  922. set_to_cap_if_null(ops, socket_accept);
  923. set_to_cap_if_null(ops, socket_sendmsg);
  924. set_to_cap_if_null(ops, socket_recvmsg);
  925. set_to_cap_if_null(ops, socket_getsockname);
  926. set_to_cap_if_null(ops, socket_getpeername);
  927. set_to_cap_if_null(ops, socket_setsockopt);
  928. set_to_cap_if_null(ops, socket_getsockopt);
  929. set_to_cap_if_null(ops, socket_shutdown);
  930. set_to_cap_if_null(ops, socket_sock_rcv_skb);
  931. set_to_cap_if_null(ops, socket_getpeersec_stream);
  932. set_to_cap_if_null(ops, socket_getpeersec_dgram);
  933. set_to_cap_if_null(ops, sk_alloc_security);
  934. set_to_cap_if_null(ops, sk_free_security);
  935. set_to_cap_if_null(ops, sk_clone_security);
  936. set_to_cap_if_null(ops, sk_getsecid);
  937. set_to_cap_if_null(ops, sock_graft);
  938. set_to_cap_if_null(ops, inet_conn_request);
  939. set_to_cap_if_null(ops, inet_csk_clone);
  940. set_to_cap_if_null(ops, inet_conn_established);
  941. set_to_cap_if_null(ops, secmark_relabel_packet);
  942. set_to_cap_if_null(ops, secmark_refcount_inc);
  943. set_to_cap_if_null(ops, secmark_refcount_dec);
  944. set_to_cap_if_null(ops, req_classify_flow);
  945. set_to_cap_if_null(ops, tun_dev_alloc_security);
  946. set_to_cap_if_null(ops, tun_dev_free_security);
  947. set_to_cap_if_null(ops, tun_dev_create);
  948. set_to_cap_if_null(ops, tun_dev_open);
  949. set_to_cap_if_null(ops, tun_dev_attach_queue);
  950. set_to_cap_if_null(ops, tun_dev_attach);
  951. #endif /* CONFIG_SECURITY_NETWORK */
  952. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  953. set_to_cap_if_null(ops, xfrm_policy_alloc_security);
  954. set_to_cap_if_null(ops, xfrm_policy_clone_security);
  955. set_to_cap_if_null(ops, xfrm_policy_free_security);
  956. set_to_cap_if_null(ops, xfrm_policy_delete_security);
  957. set_to_cap_if_null(ops, xfrm_state_alloc);
  958. set_to_cap_if_null(ops, xfrm_state_alloc_acquire);
  959. set_to_cap_if_null(ops, xfrm_state_free_security);
  960. set_to_cap_if_null(ops, xfrm_state_delete_security);
  961. set_to_cap_if_null(ops, xfrm_policy_lookup);
  962. set_to_cap_if_null(ops, xfrm_state_pol_flow_match);
  963. set_to_cap_if_null(ops, xfrm_decode_session);
  964. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  965. #ifdef CONFIG_KEYS
  966. set_to_cap_if_null(ops, key_alloc);
  967. set_to_cap_if_null(ops, key_free);
  968. set_to_cap_if_null(ops, key_permission);
  969. set_to_cap_if_null(ops, key_getsecurity);
  970. #endif /* CONFIG_KEYS */
  971. #ifdef CONFIG_AUDIT
  972. set_to_cap_if_null(ops, audit_rule_init);
  973. set_to_cap_if_null(ops, audit_rule_known);
  974. set_to_cap_if_null(ops, audit_rule_match);
  975. set_to_cap_if_null(ops, audit_rule_free);
  976. #endif
  977. }