Advertisement
PtLSM

Empty LSM

May 17th, 2012
2,490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 24.99 KB | None | 0 0
  1. //INCLUDES/////////////////////////////////////////////////////////////////////
  2.  
  3. #include <linux/init.h>
  4. #include <linux/kd.h>
  5. #include <linux/kernel.h>
  6. #include <linux/tracehook.h>
  7. #include <linux/errno.h>
  8. #include <linux/ext2_fs.h>
  9. #include <linux/sched.h>
  10. #include <linux/security.h>
  11. #include <linux/xattr.h>
  12. #include <linux/capability.h>
  13. #include <linux/unistd.h>
  14. #include <linux/mm.h>
  15. #include <linux/mman.h>
  16. #include <linux/slab.h>
  17. #include <linux/pagemap.h>
  18. #include <linux/proc_fs.h>
  19. #include <linux/swap.h>
  20. #include <linux/spinlock.h>
  21. #include <linux/syscalls.h>
  22. #include <linux/dcache.h>
  23. #include <linux/file.h>
  24. #include <linux/fdtable.h>
  25. #include <linux/namei.h>
  26. #include <linux/mount.h>
  27. #include <linux/netfilter_ipv4.h>
  28. #include <linux/netfilter_ipv6.h>
  29. #include <linux/tty.h>
  30. #include <net/icmp.h>
  31. #include <net/ip.h>     /* for local_port_range[] */
  32. #include <net/tcp.h>        /* struct or_callable used in sock_rcv_skb */
  33. #include <net/net_namespace.h>
  34. #include <net/netlabel.h>
  35. #include <linux/uaccess.h>
  36. #include <asm/ioctls.h>
  37. #include <asm/atomic.h>
  38. #include <linux/bitops.h>
  39. #include <linux/interrupt.h>
  40. #include <linux/netdevice.h>    /* for network interface checks */
  41. #include <linux/netlink.h>
  42. #include <linux/tcp.h>
  43. #include <linux/udp.h>
  44. #include <linux/dccp.h>
  45. #include <linux/quota.h>
  46. #include <linux/un.h>       /* for Unix socket types */
  47. #include <net/af_unix.h>    /* for Unix socket types */
  48. #include <linux/parser.h>
  49. #include <linux/nfs_mount.h>
  50. #include <net/ipv6.h>
  51. #include <linux/hugetlb.h>
  52. #include <linux/personality.h>
  53. #include <linux/audit.h>
  54. #include <linux/string.h>
  55. #include <linux/selinux.h>
  56. #include <linux/mutex.h>
  57. #include <linux/posix-timers.h>
  58. #include <linux/syslog.h>
  59. #include <linux/user_namespace.h>
  60.  
  61.  
  62. //DEFINES//////////////////////////////////////////////////////////////////////
  63.  
  64. #define MODULE_NAME "ptlsm"
  65.  
  66.  
  67. //ABOUT////////////////////////////////////////////////////////////////////////
  68.  
  69. MODULE_AUTHOR("ksajxai");
  70. MODULE_DESCRIPTION("Simple Linux Security Module");
  71. MODULE_LICENSE("GPL");
  72. MODULE_VERSION("0.1.2");
  73.  
  74.  
  75. //GLOBALS//////////////////////////////////////////////////////////////////////
  76.  
  77. extern struct security_operations *security_ops;
  78.  
  79.  
  80. //HOOKS/////////////////////////////////////////////////////////////////////////
  81.  
  82. static int ptlsm_ptrace_access_check(struct task_struct *child,
  83.                      unsigned int mode)
  84. {
  85.     return 0;
  86. }
  87.  
  88. static int ptlsm_ptrace_traceme(struct task_struct *parent)
  89. {
  90.     return 0;
  91. }
  92.  
  93. static int ptlsm_capget(struct task_struct *target, kernel_cap_t *effective,
  94.               kernel_cap_t *inheritable, kernel_cap_t *permitted)
  95. {
  96.     return 0;
  97. }
  98.  
  99. static int ptlsm_capset(struct cred *new, const struct cred *old,
  100.               const kernel_cap_t *effective,
  101.               const kernel_cap_t *inheritable,
  102.               const kernel_cap_t *permitted)
  103. {
  104.     return 0;
  105. }
  106.  
  107. static int ptlsm_capable(struct task_struct *tsk, const struct cred *cred,
  108.                struct user_namespace *ns, int cap, int audit)
  109. {
  110.     return 0;
  111. }
  112.  
  113. static int ptlsm_quotactl(int cmds, int type, int id, struct super_block *sb)
  114. {
  115.     return 0;
  116. }
  117.  
  118. static int ptlsm_quota_on(struct dentry *dentry)
  119. {
  120.     return 0;
  121. }
  122.  
  123. static int ptlsm_syslog(int type)
  124. {
  125.     return 0;
  126. }
  127.  
  128.  
  129. static int ptlsm_vm_enough_memory(struct mm_struct *mm, long pages)
  130. {
  131.     return 0;
  132. }
  133.  
  134. /* binprm security operations */
  135.  
  136. static int ptlsm_bprm_set_creds(struct linux_binprm *bprm)
  137. {
  138.     return 0;
  139. }
  140.  
  141. static int ptlsm_bprm_secureexec(struct linux_binprm *bprm)
  142. {
  143.     return 0;
  144. }
  145.  
  146. static void ptlsm_bprm_committing_creds(struct linux_binprm *bprm)
  147. {
  148.    
  149. }
  150.  
  151. static void ptlsm_bprm_committed_creds(struct linux_binprm *bprm)
  152. {
  153.    
  154. }
  155.  
  156. static int ptlsm_sb_alloc_security(struct super_block *sb)
  157. {
  158.     return 0;
  159. }
  160.  
  161. static void ptlsm_sb_free_security(struct super_block *sb)
  162. {
  163.  
  164. }
  165.  
  166. static int ptlsm_sb_copy_data(char *orig, char *copy)
  167. {
  168.     return 0;
  169. }
  170.  
  171. static int ptlsm_sb_remount(struct super_block *sb, void *data)
  172. {
  173.     return 0;
  174. }
  175.  
  176. static int ptlsm_sb_kern_mount(struct super_block *sb, int flags, void *data)
  177. {
  178.     return 0;
  179. }
  180.  
  181. static int ptlsm_sb_statfs(struct dentry *dentry)
  182. {
  183.     return 0;
  184. }
  185.  
  186. static int ptlsm_mount(char *dev_name, struct path *path, char *type, unsigned long flags, void *data)
  187. {
  188.     return 0;
  189. }
  190.  
  191. static int ptlsm_umount(struct vfsmount *mnt, int flags)
  192. {
  193.     return 0;
  194. }
  195.  
  196.  
  197. /* inode security operations */
  198.  
  199. static int ptlsm_inode_alloc_security(struct inode *inode)
  200. {
  201.     return 0;
  202. }
  203.  
  204. static void ptlsm_inode_free_security(struct inode *inode)
  205. {
  206.  
  207. }
  208.  
  209. static int ptlsm_inode_init_security(struct inode *inode, struct inode *dir,
  210.                        const struct qstr *qstr, char **name,
  211.                        void **value, size_t *len)
  212. {
  213.     return 0;
  214. }
  215.  
  216. static int ptlsm_inode_create(struct inode *dir, struct dentry *dentry, int mask)
  217. {
  218.     return 0;
  219. }
  220.  
  221. static int ptlsm_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
  222. {
  223.     return 0;
  224. }
  225.  
  226. static int ptlsm_inode_unlink(struct inode *dir, struct dentry *dentry)
  227. {
  228.     return 0;
  229. }
  230.  
  231. static int ptlsm_inode_symlink(struct inode *dir, struct dentry *dentry, const char *name)
  232. {
  233.     return 0;
  234. }
  235.  
  236. static int ptlsm_inode_mkdir(struct inode *dir, struct dentry *dentry, int mask)
  237. {
  238.     return 0;
  239. }
  240.  
  241. static int ptlsm_inode_rmdir(struct inode *dir, struct dentry *dentry)
  242. {
  243.     return 0;
  244. }
  245.  
  246. static int ptlsm_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
  247. {
  248.     return 0;
  249. }
  250.  
  251. static int ptlsm_inode_rename(struct inode *old_inode, struct dentry *old_dentry,
  252.                 struct inode *new_inode, struct dentry *new_dentry)
  253. {
  254.     return 0;
  255. }
  256.  
  257. static int ptlsm_inode_readlink(struct dentry *dentry)
  258. {
  259.     return 0;
  260. }
  261.  
  262. static int ptlsm_inode_follow_link(struct dentry *dentry, struct nameidata *nameidata)
  263. {
  264.     return 0;
  265. }
  266.  
  267. static int ptlsm_inode_permission(struct inode *inode, int mask, unsigned flags)
  268. {
  269.     return 0;
  270. }
  271.  
  272. static void ptlsm_sb_clone_mnt_opts(const struct super_block *oldsb,
  273.                     struct super_block *newsb)
  274. {
  275.  
  276. }
  277.  
  278. static int ptlsm_file_set_fowner(struct file *file)
  279. {
  280.     return 0;
  281. }
  282.  
  283. static int ptlsm_parse_opts_str(char *options, struct security_mnt_opts *opts)
  284. {
  285.     return 0;
  286. }
  287.  
  288. static int ptlsm_inode_setattr(struct dentry *dentry, struct iattr *iattr)
  289. {
  290.     return 0;
  291. }
  292.  
  293. static int ptlsm_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
  294. {
  295.     return 0;
  296. }
  297.  
  298. static int ptlsm_inode_setotherxattr(struct dentry *dentry, const char *name)
  299. {
  300.     return 0;
  301. }
  302.  
  303. static int ptlsm_inode_setxattr(struct dentry *dentry, const char *name,
  304.                   const void *value, size_t size, int flags)
  305. {
  306.     return 0;
  307. }
  308.  
  309. static void ptlsm_inode_post_setxattr(struct dentry *dentry, const char *name,
  310.                     const void *value, size_t size,
  311.                     int flags)
  312. {
  313.    
  314. }
  315.  
  316. static int ptlsm_inode_getxattr(struct dentry *dentry, const char *name)
  317. {
  318.     return 0;
  319. }
  320.  
  321. static int ptlsm_inode_listxattr(struct dentry *dentry)
  322. {
  323.     return 0;
  324. }
  325.  
  326. static int ptlsm_inode_removexattr(struct dentry *dentry, const char *name)
  327. {
  328.     return 0;
  329. }
  330.  
  331. static int ptlsm_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
  332. {
  333.     return 0;
  334. }
  335.  
  336. static int ptlsm_inode_setsecurity(struct inode *inode, const char *name,
  337.                      const void *value, size_t size, int flags)
  338. {
  339.     return 0;
  340. }
  341.  
  342. static int ptlsm_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  343. {
  344.     return 0;
  345. }
  346.  
  347. static void ptlsm_inode_getsecid(const struct inode *inode, u32 *secid)
  348. {
  349.    
  350. }
  351.  
  352.  
  353. /* file security operations */
  354.  
  355. static int ptlsm_revalidate_file_permission(struct file *file, int mask)
  356. {
  357.     return 0;
  358. }
  359.  
  360. static int ptlsm_file_permission(struct file *file, int mask)
  361. {
  362.     return 0;
  363. }
  364.  
  365. static int ptlsm_file_alloc_security(struct file *file)
  366. {
  367.     return 0;
  368. }
  369.  
  370. static void ptlsm_file_free_security(struct file *file)
  371. {
  372.  
  373. }
  374.  
  375. static int ptlsm_file_ioctl(struct file *file, unsigned int cmd,
  376.                   unsigned long arg)
  377. {
  378.     return 0;
  379. }
  380.  
  381. static int file_map_prot_check(struct file *file, unsigned long prot, int shared)
  382. {
  383.     return 0;
  384. }
  385.  
  386. static int ptlsm_file_mmap(struct file *file, unsigned long reqprot,
  387.                  unsigned long prot, unsigned long flags,
  388.                  unsigned long addr, unsigned long addr_only)
  389. {
  390.     return 0;
  391. }
  392.  
  393. static int ptlsm_file_mprotect(struct vm_area_struct *vma,
  394.                  unsigned long reqprot,
  395.                  unsigned long prot)
  396. {
  397.     return 0;
  398. }
  399.  
  400. static int ptlsm_file_lock(struct file *file, unsigned int cmd)
  401. {
  402.     return 0;
  403. }
  404.  
  405. static int ptlsm_file_fcntl(struct file *file, unsigned int cmd,
  406.                   unsigned long arg)
  407. {
  408.     return 0;
  409. }
  410.  
  411. static int ptlsm_file_send_sigiotask(struct task_struct *tsk,
  412.                        struct fown_struct *fown, int signum)
  413. {
  414.     return 0;
  415. }
  416.  
  417. static int ptlsm_file_receive(struct file *file)
  418. {
  419.     return 0;
  420. }
  421.  
  422. static int ptlsm_dentry_open(struct file *file, const struct cred *cred)
  423. {
  424.     return 0;
  425. }
  426.  
  427.  
  428. /* task security operations */
  429.  
  430. static int ptlsm_task_create(unsigned long clone_flags)
  431. {
  432.     return 0;
  433. }
  434.  
  435. static int ptlsm_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  436. {
  437.     return 0;
  438. }
  439.  
  440. static void ptlsm_cred_free(struct cred *cred)
  441. {
  442.    
  443. }
  444.  
  445. static int ptlsm_cred_prepare(struct cred *new, const struct cred *old,
  446.                 gfp_t gfp)
  447. {
  448.     return 0;
  449. }
  450.  
  451. static void ptlsm_cred_transfer(struct cred *new, const struct cred *old)
  452. {
  453.  
  454. }
  455.  
  456. static int ptlsm_kernel_act_as(struct cred *new, u32 secid)
  457. {
  458.     return 0;
  459. }
  460.  
  461. static int ptlsm_kernel_create_files_as(struct cred *new, struct inode *inode)
  462. {
  463.     return 0;
  464. }
  465.  
  466. static int ptlsm_kernel_module_request(char *kmod_name)
  467. {
  468.     return 0;
  469. }
  470.  
  471. static int ptlsm_task_setpgid(struct task_struct *p, pid_t pgid)
  472. {
  473.     return 0;
  474. }
  475.  
  476. static int ptlsm_task_getpgid(struct task_struct *p)
  477. {
  478.     return 0;
  479. }
  480.  
  481. static int ptlsm_task_getsid(struct task_struct *p)
  482. {
  483.     return 0;
  484. }
  485.  
  486. static void ptlsm_task_getsecid(struct task_struct *p, u32 *secid)
  487. {
  488.    
  489. }
  490.  
  491. static int ptlsm_task_setnice(struct task_struct *p, int nice)
  492. {
  493.     return 0;
  494. }
  495.  
  496. static int ptlsm_task_setioprio(struct task_struct *p, int ioprio)
  497. {
  498.     return 0;
  499. }
  500.  
  501. static int ptlsm_task_getioprio(struct task_struct *p)
  502. {
  503.     return 0;
  504. }
  505.  
  506. static int ptlsm_task_setrlimit(struct task_struct *p, unsigned int resource,
  507.         struct rlimit *new_rlim)
  508. {
  509.     return 0;
  510. }
  511.  
  512. static int ptlsm_task_setscheduler(struct task_struct *p)
  513. {
  514.     return 0;
  515. }
  516.  
  517. static int ptlsm_task_getscheduler(struct task_struct *p)
  518. {
  519.     return 0;
  520. }
  521.  
  522. static int ptlsm_task_movememory(struct task_struct *p)
  523. {
  524.     return 0;
  525. }
  526.  
  527. static int ptlsm_task_kill(struct task_struct *p, struct siginfo *info,
  528.                 int sig, u32 secid)
  529. {
  530.     return 0;
  531. }
  532.  
  533. static int ptlsm_task_wait(struct task_struct *p)
  534. {
  535.     return 0;
  536. }
  537.  
  538. static void ptlsm_task_to_inode(struct task_struct *p,
  539.                   struct inode *inode)
  540. {
  541.  
  542. }
  543.  
  544.  
  545. /* socket security operations */
  546.  
  547. static int ptlsm_socket_create(int family, int type,
  548.                  int protocol, int kern)
  549. {
  550.     return 0;
  551. }
  552.  
  553. static int ptlsm_socket_post_create(struct socket *sock, int family,
  554.                       int type, int protocol, int kern)
  555. {
  556.     return 0;
  557. }
  558.  
  559. static int ptlsm_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen)
  560. {
  561.     return 0;
  562. }
  563.  
  564. static int ptlsm_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen)
  565. {
  566.     return 0;
  567. }
  568.  
  569. static int ptlsm_socket_listen(struct socket *sock, int backlog)
  570. {
  571.     return 0;
  572. }
  573.  
  574. static int ptlsm_socket_accept(struct socket *sock, struct socket *newsock)
  575. {
  576.     return 0;
  577. }
  578.  
  579. static int ptlsm_socket_sendmsg(struct socket *sock, struct msghdr *msg,
  580.                   int size)
  581. {
  582.     return 0;
  583. }
  584.  
  585. static int ptlsm_socket_recvmsg(struct socket *sock, struct msghdr *msg,
  586.                   int size, int flags)
  587. {
  588.     return 0;
  589. }
  590.  
  591. static int ptlsm_socket_getsockname(struct socket *sock)
  592. {
  593.     return 0;
  594. }
  595.  
  596. static int ptlsm_socket_getpeername(struct socket *sock)
  597. {
  598.     return 0;
  599. }
  600.  
  601. static int ptlsm_socket_setsockopt(struct socket *sock, int level, int optname)
  602. {
  603.     return 0;
  604. }
  605.  
  606. static int ptlsm_socket_getsockopt(struct socket *sock, int level,
  607.                      int optname)
  608. {
  609.     return 0;
  610. }
  611.  
  612. static int ptlsm_socket_shutdown(struct socket *sock, int how)
  613. {
  614.     return 0;
  615. }
  616.  
  617. static int ptlsm_socket_unix_stream_connect(struct sock *sock,
  618.                           struct sock *other,
  619.                           struct sock *newsk)
  620. {
  621.     return 0;
  622. }
  623.  
  624. static int ptlsm_sb_show_options(struct seq_file *m, struct super_block *sb)
  625. {
  626.     return 0;
  627. }
  628.  
  629. static int ptlsm_set_mnt_opts(struct super_block *sb,
  630.                 struct security_mnt_opts *opts)
  631. {
  632.     return 0;
  633. }
  634.  
  635. static int ptlsm_socket_unix_may_send(struct socket *sock,
  636.                     struct socket *other)
  637. {
  638.     return 0;
  639. }
  640.  
  641. static int ptlsm_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
  642.                        u16 family)
  643. {
  644.     return 0;
  645. }
  646.  
  647. static int ptlsm_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
  648. {
  649.     return 0;
  650. }
  651.  
  652. static int ptlsm_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  653.                         int __user *optlen, unsigned len)
  654. {
  655.     return 0;
  656. }
  657.  
  658. static int ptlsm_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  659. {
  660.     return 0;
  661. }
  662.  
  663. static int ptlsm_sk_alloc_security(struct sock *sk, int family, gfp_t priority)
  664. {
  665.     return 0;
  666. }
  667.  
  668. static void ptlsm_sk_free_security(struct sock *sk)
  669. {
  670.    
  671. }
  672.  
  673. static void ptlsm_sk_clone_security(const struct sock *sk, struct sock *newsk)
  674. {
  675.    
  676. }
  677.  
  678. static void ptlsm_sk_getsecid(struct sock *sk, u32 *secid)
  679. {
  680.    
  681. }
  682.  
  683. static void ptlsm_sock_graft(struct sock *sk, struct socket *parent)
  684. {
  685.    
  686. }
  687.  
  688. static int ptlsm_inet_conn_request(struct sock *sk, struct sk_buff *skb,
  689.                      struct request_sock *req)
  690. {
  691.     return 0;
  692. }
  693.  
  694. static void ptlsm_inet_csk_clone(struct sock *newsk,
  695.                    const struct request_sock *req)
  696. {
  697.    
  698. }
  699.  
  700. static void ptlsm_inet_conn_established(struct sock *sk, struct sk_buff *skb)
  701. {
  702.    
  703. }
  704.  
  705. static int ptlsm_secmark_relabel_packet(u32 sid)
  706. {
  707.     return 0;
  708. }
  709.  
  710. static void ptlsm_secmark_refcount_inc(void)
  711. {
  712.  
  713. }
  714.  
  715. static void ptlsm_secmark_refcount_dec(void)
  716. {
  717.    
  718. }
  719.  
  720. static void ptlsm_req_classify_flow(const struct request_sock *req,
  721.                       struct flowi *fl)
  722. {
  723.    
  724. }
  725.  
  726. static int ptlsm_tun_dev_create(void)
  727. {
  728.     return 0;
  729. }
  730.  
  731. static void ptlsm_tun_dev_post_create(struct sock *sk)
  732. {
  733.    
  734. }
  735.  
  736. static int ptlsm_tun_dev_attach(struct sock *sk)
  737. {
  738.     return 0;
  739. }
  740.  
  741. static int ptlsm_nlmsg_perm(struct sock *sk, struct sk_buff *skb)
  742. {
  743.     return 0;
  744. }
  745.  
  746.  
  747. static int ptlsm_netlink_send(struct sock *sk, struct sk_buff *skb)
  748. {
  749.     return 0;
  750. }
  751.  
  752. static int ptlsm_netlink_recv(struct sk_buff *skb, int capability)
  753. {
  754.     return 0;
  755. }
  756.  
  757. static int ipc_alloc_security(struct task_struct *task,
  758.                   struct kern_ipc_perm *perm,
  759.                   u16 sclass)
  760. {
  761.     return 0;
  762. }
  763.  
  764. static void ipc_free_security(struct kern_ipc_perm *perm)
  765. {
  766.    
  767. }
  768.  
  769. static int msg_msg_alloc_security(struct msg_msg *msg)
  770. {
  771.     return 0;
  772. }
  773.  
  774. static void msg_msg_free_security(struct msg_msg *msg)
  775. {
  776.    
  777. }
  778.  
  779. static int ipc_has_perm(struct kern_ipc_perm *ipc_perms,
  780.             u32 perms)
  781. {
  782.     return 0;
  783. }
  784.  
  785. static int ptlsm_msg_msg_alloc_security(struct msg_msg *msg)
  786. {
  787.     return 0;
  788. }
  789.  
  790. static void ptlsm_msg_msg_free_security(struct msg_msg *msg)
  791. {
  792.    
  793. }
  794.  
  795. static int ptlsm_msg_queue_alloc_security(struct msg_queue *msq)
  796. {
  797.     return 0;
  798. }
  799.  
  800. static void ptlsm_msg_queue_free_security(struct msg_queue *msq)
  801. {
  802.    
  803. }
  804.  
  805. static int ptlsm_msg_queue_associate(struct msg_queue *msq, int msqflg)
  806. {
  807.     return 0;
  808. }
  809.  
  810. static int ptlsm_msg_queue_msgctl(struct msg_queue *msq, int cmd)
  811. {
  812.     return 0;
  813. }
  814.  
  815. static int ptlsm_msg_queue_msgsnd(struct msg_queue *msq, struct msg_msg *msg, int msqflg)
  816. {
  817.     return 0;
  818. }
  819.  
  820. static int ptlsm_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
  821.                     struct task_struct *target,
  822.                     long type, int mode)
  823. {
  824.     return 0;
  825. }
  826.  
  827.  
  828. /* Shared Memory security operations */
  829.  
  830. static int ptlsm_shm_alloc_security(struct shmid_kernel *shp)
  831. {
  832.     return 0;
  833. }
  834.  
  835. static void ptlsm_shm_free_security(struct shmid_kernel *shp)
  836. {
  837.    
  838. }
  839.  
  840. static int ptlsm_shm_associate(struct shmid_kernel *shp, int shmflg)
  841. {
  842.     return 0;
  843. }
  844.  
  845. static int ptlsm_shm_shmctl(struct shmid_kernel *shp, int cmd)
  846. {
  847.     return 0;
  848. }
  849.  
  850. static int ptlsm_shm_shmat(struct shmid_kernel *shp,
  851.                  char __user *shmaddr, int shmflg)
  852. {
  853.     return 0;
  854. }
  855.  
  856.  
  857. /* Semaphore security operations */
  858.  
  859. static int ptlsm_sem_alloc_security(struct sem_array *sma)
  860. {
  861. return 0;
  862. }
  863.  
  864. static void ptlsm_sem_free_security(struct sem_array *sma)
  865. {
  866.  
  867. }
  868.  
  869. static int ptlsm_sem_associate(struct sem_array *sma, int semflg)
  870. {
  871.     return 0;
  872. }
  873.  
  874. static int ptlsm_sem_semctl(struct sem_array *sma, int cmd)
  875. {
  876.     return 0;
  877. }
  878.  
  879. static int ptlsm_sem_semop(struct sem_array *sma,
  880.                  struct sembuf *sops, unsigned nsops, int alter)
  881. {
  882.     return 0;
  883. }
  884.  
  885. static int ptlsm_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
  886. {
  887.     return 0;
  888. }
  889.  
  890. static void ptlsm_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
  891. {
  892.  
  893. }
  894.  
  895. static void ptlsm_d_instantiate(struct dentry *dentry, struct inode *inode)
  896. {
  897.    
  898. }
  899.  
  900. static int ptlsm_getprocattr(struct task_struct *p,
  901.                    char *name, char **value)
  902. {
  903.     return 0;
  904. }
  905.  
  906. static int ptlsm_setprocattr(struct task_struct *p,
  907.                    char *name, void *value, size_t size)
  908. {
  909.     return 0;
  910. }
  911.  
  912. static int ptlsm_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  913. {
  914.     return 0;
  915. }
  916.  
  917. static int ptlsm_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
  918. {
  919.     return 0;
  920. }
  921.  
  922. static void ptlsm_release_secctx(char *secdata, u32 seclen)
  923. {
  924.    
  925. }
  926.  
  927. static int ptlsm_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
  928. {
  929.     return 0;
  930. }
  931.  
  932. static int ptlsm_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
  933. {
  934.     return 0;
  935. }
  936.  
  937. static int ptlsm_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
  938. {
  939.     return 0;
  940. }
  941.  
  942.  
  943. //STRUCTS//////////////////////////////////////////////////////////////////////
  944. static struct security_operations ptlsm_ops = {
  945.     .name =             "ptlsm",
  946.  
  947.     .ptrace_access_check        =       ptlsm_ptrace_access_check,
  948.     .ptrace_traceme             =       ptlsm_ptrace_traceme,
  949.     .capget                     =       ptlsm_capget,
  950.     .capset                     =       ptlsm_capset,
  951.     .capable                    =       ptlsm_capable,
  952.     .quotactl                   =       ptlsm_quotactl,
  953.     .quota_on                   =       ptlsm_quota_on,
  954.     .syslog                     =       ptlsm_syslog,
  955.     .vm_enough_memory           =       ptlsm_vm_enough_memory,
  956.  
  957.     .netlink_send               =       ptlsm_netlink_send,
  958.     .netlink_recv               =       ptlsm_netlink_recv,
  959.  
  960.     .bprm_set_creds             =       ptlsm_bprm_set_creds,
  961.     .bprm_committing_creds      =       ptlsm_bprm_committing_creds,
  962.     .bprm_committed_creds       =       ptlsm_bprm_committed_creds,
  963.     .bprm_secureexec            =       ptlsm_bprm_secureexec,
  964.  
  965.     .sb_alloc_security          =       ptlsm_sb_alloc_security,
  966.     .sb_free_security           =       ptlsm_sb_free_security,
  967.     .sb_copy_data               =       ptlsm_sb_copy_data,
  968.     .sb_remount                 =       ptlsm_sb_remount,
  969.     .sb_kern_mount              =       ptlsm_sb_kern_mount,
  970.     .sb_show_options            =       ptlsm_sb_show_options,
  971.     .sb_statfs                  =       ptlsm_sb_statfs,
  972.     .sb_mount                   =       ptlsm_mount,
  973.     .sb_umount                  =       ptlsm_umount,
  974.     .sb_set_mnt_opts            =       ptlsm_set_mnt_opts,
  975.     .sb_clone_mnt_opts          =       ptlsm_sb_clone_mnt_opts,
  976.     .sb_parse_opts_str          =       ptlsm_parse_opts_str,
  977.  
  978.     .inode_alloc_security       =       ptlsm_inode_alloc_security,
  979.     .inode_free_security        =       ptlsm_inode_free_security,
  980.     .inode_init_security        =       ptlsm_inode_init_security,
  981.     .inode_create               =       ptlsm_inode_create,
  982.     .inode_link                 =       ptlsm_inode_link,
  983.     .inode_unlink               =       ptlsm_inode_unlink,
  984.     .inode_symlink              =       ptlsm_inode_symlink,
  985.     .inode_mkdir                =       ptlsm_inode_mkdir,
  986.     .inode_rmdir                =       ptlsm_inode_rmdir,
  987.     .inode_mknod                =       ptlsm_inode_mknod,
  988.     .inode_rename               =       ptlsm_inode_rename,
  989.     .inode_readlink             =       ptlsm_inode_readlink,
  990.     .inode_follow_link          =       ptlsm_inode_follow_link,
  991.     .inode_permission           =       ptlsm_inode_permission,
  992.     .inode_setattr              =       ptlsm_inode_setattr,
  993.     .inode_getattr              =       ptlsm_inode_getattr,
  994.     .inode_setxattr             =       ptlsm_inode_setxattr,
  995.     .inode_post_setxattr        =       ptlsm_inode_post_setxattr,
  996.     .inode_getxattr             =       ptlsm_inode_getxattr,
  997.     .inode_listxattr            =       ptlsm_inode_listxattr,
  998.     .inode_removexattr          =       ptlsm_inode_removexattr,
  999.     .inode_getsecurity          =       ptlsm_inode_getsecurity,
  1000.     .inode_setsecurity          =       ptlsm_inode_setsecurity,
  1001.     .inode_listsecurity         =       ptlsm_inode_listsecurity,
  1002.     .inode_getsecid             =       ptlsm_inode_getsecid,
  1003.  
  1004.     .file_permission            =       ptlsm_file_permission,
  1005.     .file_alloc_security        =       ptlsm_file_alloc_security,
  1006.     .file_free_security         =       ptlsm_file_free_security,
  1007.     .file_ioctl                 =       ptlsm_file_ioctl,
  1008.     .file_mmap                  =       ptlsm_file_mmap,
  1009.     .file_mprotect              =       ptlsm_file_mprotect,
  1010.     .file_lock                  =       ptlsm_file_lock,
  1011.     .file_fcntl                 =       ptlsm_file_fcntl,
  1012.     .file_set_fowner            =       ptlsm_file_set_fowner,
  1013.     .file_send_sigiotask        =       ptlsm_file_send_sigiotask,
  1014.     .file_receive               =       ptlsm_file_receive,
  1015.    
  1016.     .dentry_open                =       ptlsm_dentry_open,
  1017.  
  1018.     .task_create                =       ptlsm_task_create,
  1019.     .cred_alloc_blank           =       ptlsm_cred_alloc_blank,
  1020.     .cred_free                  =       ptlsm_cred_free,
  1021.     .cred_prepare               =       ptlsm_cred_prepare,
  1022.     .cred_transfer              =       ptlsm_cred_transfer,
  1023.     .kernel_act_as              =       ptlsm_kernel_act_as,
  1024.     .kernel_create_files_as     =       ptlsm_kernel_create_files_as,
  1025.     .kernel_module_request      =       ptlsm_kernel_module_request,
  1026.     .task_setpgid               =       ptlsm_task_setpgid,
  1027.     .task_getpgid               =       ptlsm_task_getpgid,
  1028.     .task_getsid                =       ptlsm_task_getsid,
  1029.     .task_getsecid              =       ptlsm_task_getsecid,
  1030.     .task_setnice               =       ptlsm_task_setnice,
  1031.     .task_setioprio             =       ptlsm_task_setioprio,
  1032.     .task_getioprio             =       ptlsm_task_getioprio,
  1033.     .task_setrlimit             =       ptlsm_task_setrlimit,
  1034.     .task_setscheduler          =       ptlsm_task_setscheduler,
  1035.     .task_getscheduler          =       ptlsm_task_getscheduler,
  1036.     .task_movememory            =       ptlsm_task_movememory,
  1037.     .task_kill                  =       ptlsm_task_kill,
  1038.     .task_wait                  =       ptlsm_task_wait,
  1039.     .task_to_inode              =       ptlsm_task_to_inode,
  1040.  
  1041.     .ipc_permission             =       ptlsm_ipc_permission,
  1042.     .ipc_getsecid               =       ptlsm_ipc_getsecid,
  1043.  
  1044.     .msg_msg_alloc_security     =       ptlsm_msg_msg_alloc_security,
  1045.     .msg_msg_free_security      =       ptlsm_msg_msg_free_security,
  1046.  
  1047.     .msg_queue_alloc_security   =       ptlsm_msg_queue_alloc_security,
  1048.     .msg_queue_free_security    =       ptlsm_msg_queue_free_security,
  1049.     .msg_queue_associate        =       ptlsm_msg_queue_associate,
  1050.     .msg_queue_msgctl           =       ptlsm_msg_queue_msgctl,
  1051.     .msg_queue_msgsnd           =       ptlsm_msg_queue_msgsnd,
  1052.     .msg_queue_msgrcv           =       ptlsm_msg_queue_msgrcv,
  1053.  
  1054.     .shm_alloc_security         =       ptlsm_shm_alloc_security,
  1055.     .shm_free_security          =       ptlsm_shm_free_security,
  1056.     .shm_associate              =       ptlsm_shm_associate,
  1057.     .shm_shmctl                 =       ptlsm_shm_shmctl,
  1058.     .shm_shmat                  =       ptlsm_shm_shmat,
  1059.  
  1060.     .sem_alloc_security         =       ptlsm_sem_alloc_security,
  1061.     .sem_free_security          =       ptlsm_sem_free_security,
  1062.     .sem_associate              =       ptlsm_sem_associate,
  1063.     .sem_semctl                 =       ptlsm_sem_semctl,
  1064.     .sem_semop                  =       ptlsm_sem_semop,
  1065.  
  1066.     .d_instantiate              =       ptlsm_d_instantiate,
  1067.  
  1068.     .getprocattr                =       ptlsm_getprocattr,
  1069.     .setprocattr                =       ptlsm_setprocattr,
  1070.  
  1071.     .secid_to_secctx            =       ptlsm_secid_to_secctx,
  1072.     .secctx_to_secid            =       ptlsm_secctx_to_secid,
  1073.     .release_secctx             =       ptlsm_release_secctx,
  1074.     .inode_notifysecctx         =       ptlsm_inode_notifysecctx,
  1075.     .inode_setsecctx            =       ptlsm_inode_setsecctx,
  1076.     .inode_getsecctx            =       ptlsm_inode_getsecctx,
  1077.  
  1078.     .unix_stream_connect        =       ptlsm_socket_unix_stream_connect,
  1079.     .unix_may_send              =       ptlsm_socket_unix_may_send,
  1080.  
  1081.     .socket_create              =       ptlsm_socket_create,
  1082.     .socket_post_create         =       ptlsm_socket_post_create,
  1083.     .socket_bind                =       ptlsm_socket_bind,
  1084.     .socket_connect             =       ptlsm_socket_connect,
  1085.     .socket_listen              =       ptlsm_socket_listen,
  1086.     .socket_accept              =       ptlsm_socket_accept,
  1087.     .socket_sendmsg             =       ptlsm_socket_sendmsg,
  1088.     .socket_recvmsg             =       ptlsm_socket_recvmsg,
  1089.     .socket_getsockname         =       ptlsm_socket_getsockname,
  1090.     .socket_getpeername         =       ptlsm_socket_getpeername,
  1091.     .socket_getsockopt          =       ptlsm_socket_getsockopt,
  1092.     .socket_setsockopt          =       ptlsm_socket_setsockopt,
  1093.     .socket_shutdown            =       ptlsm_socket_shutdown,
  1094.     .socket_sock_rcv_skb        =       ptlsm_socket_sock_rcv_skb,
  1095.     .socket_getpeersec_stream   =       ptlsm_socket_getpeersec_stream,
  1096.     .socket_getpeersec_dgram    =       ptlsm_socket_getpeersec_dgram,
  1097.     .sk_alloc_security          =       ptlsm_sk_alloc_security,
  1098.     .sk_free_security           =       ptlsm_sk_free_security,
  1099.     .sk_clone_security          =       ptlsm_sk_clone_security,
  1100.     .sk_getsecid                =       ptlsm_sk_getsecid,
  1101.     .sock_graft                 =       ptlsm_sock_graft,
  1102.     .inet_conn_request          =       ptlsm_inet_conn_request,
  1103.     .inet_csk_clone             =       ptlsm_inet_csk_clone,
  1104.     .inet_conn_established      =       ptlsm_inet_conn_established,
  1105.     .secmark_relabel_packet     =       ptlsm_secmark_relabel_packet,
  1106.     .secmark_refcount_inc       =       ptlsm_secmark_refcount_inc,
  1107.     .secmark_refcount_dec       =       ptlsm_secmark_refcount_dec,
  1108.     .req_classify_flow          =       ptlsm_req_classify_flow,
  1109.     .tun_dev_create             =       ptlsm_tun_dev_create,
  1110.     .tun_dev_post_create        =       ptlsm_tun_dev_post_create,
  1111.     .tun_dev_attach             =       ptlsm_tun_dev_attach,
  1112. };
  1113.  
  1114.  
  1115. //INIT/////////////////////////////////////////////////////////////////////////
  1116.  
  1117. static __init int ptlsm_init(void)
  1118. {
  1119.     if (register_security(&ptlsm_ops))
  1120.     {
  1121.         panic(KERN_INFO "Failed to register ptlsm module\n");
  1122.     }
  1123.    
  1124.     printk(KERN_ALERT "PtLSM started");
  1125.    
  1126.     return 0;
  1127. }
  1128.  
  1129.  
  1130. //MACROSES/////////////////////////////////////////////////////////////////////
  1131.  
  1132. module_init(ptlsm_init);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement