2 * Stub functions for the default security function pointers in case no
3 * security model is loaded.
5 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
6 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
7 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include <linux/config.h>
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/security.h>
19 #include <linux/skbuff.h>
20 #include <linux/netlink.h>
22 static int dummy_ptrace (struct task_struct
*parent
, struct task_struct
*child
)
27 static int dummy_capget (struct task_struct
*target
, kernel_cap_t
* effective
,
28 kernel_cap_t
* inheritable
, kernel_cap_t
* permitted
)
33 static int dummy_capset_check (struct task_struct
*target
,
34 kernel_cap_t
* effective
,
35 kernel_cap_t
* inheritable
,
36 kernel_cap_t
* permitted
)
41 static void dummy_capset_set (struct task_struct
*target
,
42 kernel_cap_t
* effective
,
43 kernel_cap_t
* inheritable
,
44 kernel_cap_t
* permitted
)
49 static int dummy_acct (struct file
*file
)
54 static int dummy_capable (struct task_struct
*tsk
, int cap
)
56 if (cap_is_fs_cap (cap
) ? tsk
->fsuid
== 0 : tsk
->euid
== 0)
57 /* capability granted */
60 /* capability denied */
64 static int dummy_sys_security (unsigned int id
, unsigned int call
,
70 static int dummy_quotactl (int cmds
, int type
, int id
, struct super_block
*sb
)
75 static int dummy_quota_on (struct file
*f
)
80 static int dummy_bprm_alloc_security (struct linux_binprm
*bprm
)
85 static void dummy_bprm_free_security (struct linux_binprm
*bprm
)
90 static void dummy_bprm_compute_creds (struct linux_binprm
*bprm
)
95 static int dummy_bprm_set_security (struct linux_binprm
*bprm
)
100 static int dummy_bprm_check_security (struct linux_binprm
*bprm
)
105 static int dummy_sb_alloc_security (struct super_block
*sb
)
110 static void dummy_sb_free_security (struct super_block
*sb
)
115 static int dummy_sb_statfs (struct super_block
*sb
)
120 static int dummy_mount (char *dev_name
, struct nameidata
*nd
, char *type
,
121 unsigned long flags
, void *data
)
126 static int dummy_check_sb (struct vfsmount
*mnt
, struct nameidata
*nd
)
131 static int dummy_umount (struct vfsmount
*mnt
, int flags
)
136 static void dummy_umount_close (struct vfsmount
*mnt
)
141 static void dummy_umount_busy (struct vfsmount
*mnt
)
146 static void dummy_post_remount (struct vfsmount
*mnt
, unsigned long flags
,
153 static void dummy_post_mountroot (void)
158 static void dummy_post_addmount (struct vfsmount
*mnt
, struct nameidata
*nd
)
163 static int dummy_pivotroot (struct nameidata
*old_nd
, struct nameidata
*new_nd
)
168 static void dummy_post_pivotroot (struct nameidata
*old_nd
, struct nameidata
*new_nd
)
173 static int dummy_inode_alloc_security (struct inode
*inode
)
178 static void dummy_inode_free_security (struct inode
*inode
)
183 static int dummy_inode_create (struct inode
*inode
, struct dentry
*dentry
,
189 static void dummy_inode_post_create (struct inode
*inode
, struct dentry
*dentry
,
195 static int dummy_inode_link (struct dentry
*old_dentry
, struct inode
*inode
,
196 struct dentry
*new_dentry
)
201 static void dummy_inode_post_link (struct dentry
*old_dentry
,
203 struct dentry
*new_dentry
)
208 static int dummy_inode_unlink (struct inode
*inode
, struct dentry
*dentry
)
213 static int dummy_inode_symlink (struct inode
*inode
, struct dentry
*dentry
,
219 static void dummy_inode_post_symlink (struct inode
*inode
,
220 struct dentry
*dentry
, const char *name
)
225 static int dummy_inode_mkdir (struct inode
*inode
, struct dentry
*dentry
,
231 static void dummy_inode_post_mkdir (struct inode
*inode
, struct dentry
*dentry
,
237 static int dummy_inode_rmdir (struct inode
*inode
, struct dentry
*dentry
)
242 static int dummy_inode_mknod (struct inode
*inode
, struct dentry
*dentry
,
243 int major
, dev_t minor
)
248 static void dummy_inode_post_mknod (struct inode
*inode
, struct dentry
*dentry
,
249 int major
, dev_t minor
)
254 static int dummy_inode_rename (struct inode
*old_inode
,
255 struct dentry
*old_dentry
,
256 struct inode
*new_inode
,
257 struct dentry
*new_dentry
)
262 static void dummy_inode_post_rename (struct inode
*old_inode
,
263 struct dentry
*old_dentry
,
264 struct inode
*new_inode
,
265 struct dentry
*new_dentry
)
270 static int dummy_inode_readlink (struct dentry
*dentry
)
275 static int dummy_inode_follow_link (struct dentry
*dentry
,
276 struct nameidata
*nameidata
)
281 static int dummy_inode_permission (struct inode
*inode
, int mask
)
286 static int dummy_inode_permission_lite (struct inode
*inode
, int mask
)
291 static int dummy_inode_setattr (struct dentry
*dentry
, struct iattr
*iattr
)
296 static int dummy_inode_getattr (struct vfsmount
*mnt
, struct dentry
*dentry
)
301 static void dummy_post_lookup (struct inode
*ino
, struct dentry
*d
)
306 static void dummy_delete (struct inode
*ino
)
311 static int dummy_inode_setxattr (struct dentry
*dentry
, char *name
, void *value
,
312 size_t size
, int flags
)
317 static int dummy_inode_getxattr (struct dentry
*dentry
, char *name
)
322 static int dummy_inode_listxattr (struct dentry
*dentry
)
327 static int dummy_inode_removexattr (struct dentry
*dentry
, char *name
)
332 static int dummy_file_permission (struct file
*file
, int mask
)
337 static int dummy_file_alloc_security (struct file
*file
)
342 static void dummy_file_free_security (struct file
*file
)
347 static int dummy_file_llseek (struct file
*file
)
352 static int dummy_file_ioctl (struct file
*file
, unsigned int command
,
358 static int dummy_file_mmap (struct file
*file
, unsigned long prot
,
364 static int dummy_file_mprotect (struct vm_area_struct
*vma
, unsigned long prot
)
369 static int dummy_file_lock (struct file
*file
, unsigned int cmd
)
374 static int dummy_file_fcntl (struct file
*file
, unsigned int cmd
,
380 static int dummy_file_set_fowner (struct file
*file
)
385 static int dummy_file_send_sigiotask (struct task_struct
*tsk
,
386 struct fown_struct
*fown
, int fd
,
392 static int dummy_file_receive (struct file
*file
)
397 static int dummy_task_create (unsigned long clone_flags
)
402 static int dummy_task_alloc_security (struct task_struct
*p
)
407 static void dummy_task_free_security (struct task_struct
*p
)
412 static int dummy_task_setuid (uid_t id0
, uid_t id1
, uid_t id2
, int flags
)
417 static int dummy_task_post_setuid (uid_t id0
, uid_t id1
, uid_t id2
, int flags
)
422 static int dummy_task_setgid (gid_t id0
, gid_t id1
, gid_t id2
, int flags
)
427 static int dummy_task_setpgid (struct task_struct
*p
, pid_t pgid
)
432 static int dummy_task_getpgid (struct task_struct
*p
)
437 static int dummy_task_getsid (struct task_struct
*p
)
442 static int dummy_task_setgroups (int gidsetsize
, gid_t
* grouplist
)
447 static int dummy_task_setnice (struct task_struct
*p
, int nice
)
452 static int dummy_task_setrlimit (unsigned int resource
, struct rlimit
*new_rlim
)
457 static int dummy_task_setscheduler (struct task_struct
*p
, int policy
,
458 struct sched_param
*lp
)
463 static int dummy_task_getscheduler (struct task_struct
*p
)
468 static int dummy_task_wait (struct task_struct
*p
)
473 static int dummy_task_kill (struct task_struct
*p
, struct siginfo
*info
,
479 static int dummy_task_prctl (int option
, unsigned long arg2
, unsigned long arg3
,
480 unsigned long arg4
, unsigned long arg5
)
485 static void dummy_task_kmod_set_label (void)
490 static void dummy_task_reparent_to_init (struct task_struct
*p
)
492 p
->euid
= p
->fsuid
= 0;
496 static int dummy_ipc_permission (struct kern_ipc_perm
*ipcp
, short flag
)
502 static int dummy_msg_queue_alloc_security (struct msg_queue
*msq
)
507 static void dummy_msg_queue_free_security (struct msg_queue
*msq
)
512 static int dummy_shm_alloc_security (struct shmid_kernel
*shp
)
517 static void dummy_shm_free_security (struct shmid_kernel
*shp
)
522 static int dummy_sem_alloc_security (struct sem_array
*sma
)
527 static void dummy_sem_free_security (struct sem_array
*sma
)
532 static int dummy_register (const char *name
, struct security_operations
*ops
)
537 static int dummy_unregister (const char *name
, struct security_operations
*ops
)
542 struct security_operations dummy_security_ops
= {
543 .ptrace
= dummy_ptrace
,
544 .capget
= dummy_capget
,
545 .capset_check
= dummy_capset_check
,
546 .capset_set
= dummy_capset_set
,
548 .capable
= dummy_capable
,
549 .sys_security
= dummy_sys_security
,
550 .quotactl
= dummy_quotactl
,
551 .quota_on
= dummy_quota_on
,
553 .bprm_alloc_security
= dummy_bprm_alloc_security
,
554 .bprm_free_security
= dummy_bprm_free_security
,
555 .bprm_compute_creds
= dummy_bprm_compute_creds
,
556 .bprm_set_security
= dummy_bprm_set_security
,
557 .bprm_check_security
= dummy_bprm_check_security
,
559 .sb_alloc_security
= dummy_sb_alloc_security
,
560 .sb_free_security
= dummy_sb_free_security
,
561 .sb_statfs
= dummy_sb_statfs
,
562 .sb_mount
= dummy_mount
,
563 .sb_check_sb
= dummy_check_sb
,
564 .sb_umount
= dummy_umount
,
565 .sb_umount_close
= dummy_umount_close
,
566 .sb_umount_busy
= dummy_umount_busy
,
567 .sb_post_remount
= dummy_post_remount
,
568 .sb_post_mountroot
= dummy_post_mountroot
,
569 .sb_post_addmount
= dummy_post_addmount
,
570 .sb_pivotroot
= dummy_pivotroot
,
571 .sb_post_pivotroot
= dummy_post_pivotroot
,
573 .inode_alloc_security
= dummy_inode_alloc_security
,
574 .inode_free_security
= dummy_inode_free_security
,
575 .inode_create
= dummy_inode_create
,
576 .inode_post_create
= dummy_inode_post_create
,
577 .inode_link
= dummy_inode_link
,
578 .inode_post_link
= dummy_inode_post_link
,
579 .inode_unlink
= dummy_inode_unlink
,
580 .inode_symlink
= dummy_inode_symlink
,
581 .inode_post_symlink
= dummy_inode_post_symlink
,
582 .inode_mkdir
= dummy_inode_mkdir
,
583 .inode_post_mkdir
= dummy_inode_post_mkdir
,
584 .inode_rmdir
= dummy_inode_rmdir
,
585 .inode_mknod
= dummy_inode_mknod
,
586 .inode_post_mknod
= dummy_inode_post_mknod
,
587 .inode_rename
= dummy_inode_rename
,
588 .inode_post_rename
= dummy_inode_post_rename
,
589 .inode_readlink
= dummy_inode_readlink
,
590 .inode_follow_link
= dummy_inode_follow_link
,
591 .inode_permission
= dummy_inode_permission
,
592 .inode_permission_lite
= dummy_inode_permission_lite
,
593 .inode_setattr
= dummy_inode_setattr
,
594 .inode_getattr
= dummy_inode_getattr
,
595 .inode_post_lookup
= dummy_post_lookup
,
596 .inode_delete
= dummy_delete
,
597 .inode_setxattr
= dummy_inode_setxattr
,
598 .inode_getxattr
= dummy_inode_getxattr
,
599 .inode_listxattr
= dummy_inode_listxattr
,
600 .inode_removexattr
= dummy_inode_removexattr
,
602 .file_permission
= dummy_file_permission
,
603 .file_alloc_security
= dummy_file_alloc_security
,
604 .file_free_security
= dummy_file_free_security
,
605 .file_llseek
= dummy_file_llseek
,
606 .file_ioctl
= dummy_file_ioctl
,
607 .file_mmap
= dummy_file_mmap
,
608 .file_mprotect
= dummy_file_mprotect
,
609 .file_lock
= dummy_file_lock
,
610 .file_fcntl
= dummy_file_fcntl
,
611 .file_set_fowner
= dummy_file_set_fowner
,
612 .file_send_sigiotask
= dummy_file_send_sigiotask
,
613 .file_receive
= dummy_file_receive
,
615 .task_create
= dummy_task_create
,
616 .task_alloc_security
= dummy_task_alloc_security
,
617 .task_free_security
= dummy_task_free_security
,
618 .task_setuid
= dummy_task_setuid
,
619 .task_post_setuid
= dummy_task_post_setuid
,
620 .task_setgid
= dummy_task_setgid
,
621 .task_setpgid
= dummy_task_setpgid
,
622 .task_getpgid
= dummy_task_getpgid
,
623 .task_getsid
= dummy_task_getsid
,
624 .task_setgroups
= dummy_task_setgroups
,
625 .task_setnice
= dummy_task_setnice
,
626 .task_setrlimit
= dummy_task_setrlimit
,
627 .task_setscheduler
= dummy_task_setscheduler
,
628 .task_getscheduler
= dummy_task_getscheduler
,
629 .task_wait
= dummy_task_wait
,
630 .task_kill
= dummy_task_kill
,
631 .task_prctl
= dummy_task_prctl
,
632 .task_kmod_set_label
= dummy_task_kmod_set_label
,
633 .task_reparent_to_init
= dummy_task_reparent_to_init
,
635 .ipc_permission
= dummy_ipc_permission
,
637 .msg_queue_alloc_security
= dummy_msg_queue_alloc_security
,
638 .msg_queue_free_security
= dummy_msg_queue_free_security
,
640 .shm_alloc_security
= dummy_shm_alloc_security
,
641 .shm_free_security
= dummy_shm_free_security
,
643 .sem_alloc_security
= dummy_sem_alloc_security
,
644 .sem_free_security
= dummy_sem_free_security
,
646 .register_security
= dummy_register
,
647 .unregister_security
= dummy_unregister
,