0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef __LINUX_SECURITY_H
0024 #define __LINUX_SECURITY_H
0025
0026 #include <linux/kernel_read_file.h>
0027 #include <linux/key.h>
0028 #include <linux/capability.h>
0029 #include <linux/fs.h>
0030 #include <linux/slab.h>
0031 #include <linux/err.h>
0032 #include <linux/string.h>
0033 #include <linux/mm.h>
0034
0035 struct linux_binprm;
0036 struct cred;
0037 struct rlimit;
0038 struct kernel_siginfo;
0039 struct sembuf;
0040 struct kern_ipc_perm;
0041 struct audit_context;
0042 struct super_block;
0043 struct inode;
0044 struct dentry;
0045 struct file;
0046 struct vfsmount;
0047 struct path;
0048 struct qstr;
0049 struct iattr;
0050 struct fown_struct;
0051 struct file_operations;
0052 struct msg_msg;
0053 struct xattr;
0054 struct kernfs_node;
0055 struct xfrm_sec_ctx;
0056 struct mm_struct;
0057 struct fs_context;
0058 struct fs_parameter;
0059 enum fs_value_type;
0060 struct watch;
0061 struct watch_notification;
0062
0063
0064 #define CAP_OPT_NONE 0x0
0065
0066 #define CAP_OPT_NOAUDIT BIT(1)
0067
0068 #define CAP_OPT_INSETID BIT(2)
0069
0070
0071 #define SECURITY_LSM_NATIVE_LABELS 1
0072
0073 struct ctl_table;
0074 struct audit_krule;
0075 struct user_namespace;
0076 struct timezone;
0077
0078 enum lsm_event {
0079 LSM_POLICY_CHANGE,
0080 };
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 enum lockdown_reason {
0107 LOCKDOWN_NONE,
0108 LOCKDOWN_MODULE_SIGNATURE,
0109 LOCKDOWN_DEV_MEM,
0110 LOCKDOWN_EFI_TEST,
0111 LOCKDOWN_KEXEC,
0112 LOCKDOWN_HIBERNATION,
0113 LOCKDOWN_PCI_ACCESS,
0114 LOCKDOWN_IOPORT,
0115 LOCKDOWN_MSR,
0116 LOCKDOWN_ACPI_TABLES,
0117 LOCKDOWN_PCMCIA_CIS,
0118 LOCKDOWN_TIOCSSERIAL,
0119 LOCKDOWN_MODULE_PARAMETERS,
0120 LOCKDOWN_MMIOTRACE,
0121 LOCKDOWN_DEBUGFS,
0122 LOCKDOWN_XMON_WR,
0123 LOCKDOWN_BPF_WRITE_USER,
0124 LOCKDOWN_DBG_WRITE_KERNEL,
0125 LOCKDOWN_INTEGRITY_MAX,
0126 LOCKDOWN_KCORE,
0127 LOCKDOWN_KPROBES,
0128 LOCKDOWN_BPF_READ_KERNEL,
0129 LOCKDOWN_DBG_READ_KERNEL,
0130 LOCKDOWN_PERF,
0131 LOCKDOWN_TRACEFS,
0132 LOCKDOWN_XMON_RW,
0133 LOCKDOWN_XFRM_SECRET,
0134 LOCKDOWN_CONFIDENTIALITY_MAX,
0135 };
0136
0137 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
0138
0139
0140 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
0141 int cap, unsigned int opts);
0142 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
0143 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
0144 extern int cap_ptrace_traceme(struct task_struct *parent);
0145 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
0146 extern int cap_capset(struct cred *new, const struct cred *old,
0147 const kernel_cap_t *effective,
0148 const kernel_cap_t *inheritable,
0149 const kernel_cap_t *permitted);
0150 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
0151 int cap_inode_setxattr(struct dentry *dentry, const char *name,
0152 const void *value, size_t size, int flags);
0153 int cap_inode_removexattr(struct user_namespace *mnt_userns,
0154 struct dentry *dentry, const char *name);
0155 int cap_inode_need_killpriv(struct dentry *dentry);
0156 int cap_inode_killpriv(struct user_namespace *mnt_userns,
0157 struct dentry *dentry);
0158 int cap_inode_getsecurity(struct user_namespace *mnt_userns,
0159 struct inode *inode, const char *name, void **buffer,
0160 bool alloc);
0161 extern int cap_mmap_addr(unsigned long addr);
0162 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
0163 unsigned long prot, unsigned long flags);
0164 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
0165 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
0166 unsigned long arg4, unsigned long arg5);
0167 extern int cap_task_setscheduler(struct task_struct *p);
0168 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
0169 extern int cap_task_setnice(struct task_struct *p, int nice);
0170 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
0171
0172 struct msghdr;
0173 struct sk_buff;
0174 struct sock;
0175 struct sockaddr;
0176 struct socket;
0177 struct flowi_common;
0178 struct dst_entry;
0179 struct xfrm_selector;
0180 struct xfrm_policy;
0181 struct xfrm_state;
0182 struct xfrm_user_sec_ctx;
0183 struct seq_file;
0184 struct sctp_association;
0185
0186 #ifdef CONFIG_MMU
0187 extern unsigned long mmap_min_addr;
0188 extern unsigned long dac_mmap_min_addr;
0189 #else
0190 #define mmap_min_addr 0UL
0191 #define dac_mmap_min_addr 0UL
0192 #endif
0193
0194
0195
0196
0197
0198 #define LSM_SETID_ID 1
0199
0200
0201 #define LSM_SETID_RE 2
0202
0203
0204 #define LSM_SETID_RES 4
0205
0206
0207 #define LSM_SETID_FS 8
0208
0209
0210 #define LSM_PRLIMIT_READ 1
0211 #define LSM_PRLIMIT_WRITE 2
0212
0213
0214 struct sched_param;
0215 struct request_sock;
0216
0217
0218 #define LSM_UNSAFE_SHARE 1
0219 #define LSM_UNSAFE_PTRACE 2
0220 #define LSM_UNSAFE_NO_NEW_PRIVS 4
0221
0222 #ifdef CONFIG_MMU
0223 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
0224 void *buffer, size_t *lenp, loff_t *ppos);
0225 #endif
0226
0227
0228 typedef int (*initxattrs) (struct inode *inode,
0229 const struct xattr *xattr_array, void *fs_data);
0230
0231
0232
0233 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
0234 #define __data_id_stringify(dummy, str) #str,
0235
0236 enum kernel_load_data_id {
0237 __kernel_read_file_id(__data_id_enumify)
0238 };
0239
0240 static const char * const kernel_load_data_str[] = {
0241 __kernel_read_file_id(__data_id_stringify)
0242 };
0243
0244 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
0245 {
0246 if ((unsigned)id >= LOADING_MAX_ID)
0247 return kernel_load_data_str[LOADING_UNKNOWN];
0248
0249 return kernel_load_data_str[id];
0250 }
0251
0252 #ifdef CONFIG_SECURITY
0253
0254 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
0255 int register_blocking_lsm_notifier(struct notifier_block *nb);
0256 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
0257
0258
0259 extern int security_init(void);
0260 extern int early_security_init(void);
0261
0262
0263 int security_binder_set_context_mgr(const struct cred *mgr);
0264 int security_binder_transaction(const struct cred *from,
0265 const struct cred *to);
0266 int security_binder_transfer_binder(const struct cred *from,
0267 const struct cred *to);
0268 int security_binder_transfer_file(const struct cred *from,
0269 const struct cred *to, struct file *file);
0270 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
0271 int security_ptrace_traceme(struct task_struct *parent);
0272 int security_capget(struct task_struct *target,
0273 kernel_cap_t *effective,
0274 kernel_cap_t *inheritable,
0275 kernel_cap_t *permitted);
0276 int security_capset(struct cred *new, const struct cred *old,
0277 const kernel_cap_t *effective,
0278 const kernel_cap_t *inheritable,
0279 const kernel_cap_t *permitted);
0280 int security_capable(const struct cred *cred,
0281 struct user_namespace *ns,
0282 int cap,
0283 unsigned int opts);
0284 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
0285 int security_quota_on(struct dentry *dentry);
0286 int security_syslog(int type);
0287 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
0288 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
0289 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
0290 int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
0291 int security_bprm_check(struct linux_binprm *bprm);
0292 void security_bprm_committing_creds(struct linux_binprm *bprm);
0293 void security_bprm_committed_creds(struct linux_binprm *bprm);
0294 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
0295 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
0296 int security_sb_alloc(struct super_block *sb);
0297 void security_sb_delete(struct super_block *sb);
0298 void security_sb_free(struct super_block *sb);
0299 void security_free_mnt_opts(void **mnt_opts);
0300 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
0301 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
0302 int security_sb_remount(struct super_block *sb, void *mnt_opts);
0303 int security_sb_kern_mount(struct super_block *sb);
0304 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
0305 int security_sb_statfs(struct dentry *dentry);
0306 int security_sb_mount(const char *dev_name, const struct path *path,
0307 const char *type, unsigned long flags, void *data);
0308 int security_sb_umount(struct vfsmount *mnt, int flags);
0309 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
0310 int security_sb_set_mnt_opts(struct super_block *sb,
0311 void *mnt_opts,
0312 unsigned long kern_flags,
0313 unsigned long *set_kern_flags);
0314 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
0315 struct super_block *newsb,
0316 unsigned long kern_flags,
0317 unsigned long *set_kern_flags);
0318 int security_move_mount(const struct path *from_path, const struct path *to_path);
0319 int security_dentry_init_security(struct dentry *dentry, int mode,
0320 const struct qstr *name,
0321 const char **xattr_name, void **ctx,
0322 u32 *ctxlen);
0323 int security_dentry_create_files_as(struct dentry *dentry, int mode,
0324 struct qstr *name,
0325 const struct cred *old,
0326 struct cred *new);
0327 int security_path_notify(const struct path *path, u64 mask,
0328 unsigned int obj_type);
0329 int security_inode_alloc(struct inode *inode);
0330 void security_inode_free(struct inode *inode);
0331 int security_inode_init_security(struct inode *inode, struct inode *dir,
0332 const struct qstr *qstr,
0333 initxattrs initxattrs, void *fs_data);
0334 int security_inode_init_security_anon(struct inode *inode,
0335 const struct qstr *name,
0336 const struct inode *context_inode);
0337 int security_old_inode_init_security(struct inode *inode, struct inode *dir,
0338 const struct qstr *qstr, const char **name,
0339 void **value, size_t *len);
0340 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
0341 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
0342 struct dentry *new_dentry);
0343 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
0344 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
0345 const char *old_name);
0346 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
0347 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
0348 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
0349 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
0350 struct inode *new_dir, struct dentry *new_dentry,
0351 unsigned int flags);
0352 int security_inode_readlink(struct dentry *dentry);
0353 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
0354 bool rcu);
0355 int security_inode_permission(struct inode *inode, int mask);
0356 int security_inode_setattr(struct user_namespace *mnt_userns,
0357 struct dentry *dentry, struct iattr *attr);
0358 int security_inode_getattr(const struct path *path);
0359 int security_inode_setxattr(struct user_namespace *mnt_userns,
0360 struct dentry *dentry, const char *name,
0361 const void *value, size_t size, int flags);
0362 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
0363 const void *value, size_t size, int flags);
0364 int security_inode_getxattr(struct dentry *dentry, const char *name);
0365 int security_inode_listxattr(struct dentry *dentry);
0366 int security_inode_removexattr(struct user_namespace *mnt_userns,
0367 struct dentry *dentry, const char *name);
0368 int security_inode_need_killpriv(struct dentry *dentry);
0369 int security_inode_killpriv(struct user_namespace *mnt_userns,
0370 struct dentry *dentry);
0371 int security_inode_getsecurity(struct user_namespace *mnt_userns,
0372 struct inode *inode, const char *name,
0373 void **buffer, bool alloc);
0374 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
0375 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
0376 void security_inode_getsecid(struct inode *inode, u32 *secid);
0377 int security_inode_copy_up(struct dentry *src, struct cred **new);
0378 int security_inode_copy_up_xattr(const char *name);
0379 int security_kernfs_init_security(struct kernfs_node *kn_dir,
0380 struct kernfs_node *kn);
0381 int security_file_permission(struct file *file, int mask);
0382 int security_file_alloc(struct file *file);
0383 void security_file_free(struct file *file);
0384 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
0385 int security_mmap_file(struct file *file, unsigned long prot,
0386 unsigned long flags);
0387 int security_mmap_addr(unsigned long addr);
0388 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
0389 unsigned long prot);
0390 int security_file_lock(struct file *file, unsigned int cmd);
0391 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
0392 void security_file_set_fowner(struct file *file);
0393 int security_file_send_sigiotask(struct task_struct *tsk,
0394 struct fown_struct *fown, int sig);
0395 int security_file_receive(struct file *file);
0396 int security_file_open(struct file *file);
0397 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
0398 void security_task_free(struct task_struct *task);
0399 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
0400 void security_cred_free(struct cred *cred);
0401 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
0402 void security_transfer_creds(struct cred *new, const struct cred *old);
0403 void security_cred_getsecid(const struct cred *c, u32 *secid);
0404 int security_kernel_act_as(struct cred *new, u32 secid);
0405 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
0406 int security_kernel_module_request(char *kmod_name);
0407 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
0408 int security_kernel_post_load_data(char *buf, loff_t size,
0409 enum kernel_load_data_id id,
0410 char *description);
0411 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
0412 bool contents);
0413 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
0414 enum kernel_read_file_id id);
0415 int security_task_fix_setuid(struct cred *new, const struct cred *old,
0416 int flags);
0417 int security_task_fix_setgid(struct cred *new, const struct cred *old,
0418 int flags);
0419 int security_task_fix_setgroups(struct cred *new, const struct cred *old);
0420 int security_task_setpgid(struct task_struct *p, pid_t pgid);
0421 int security_task_getpgid(struct task_struct *p);
0422 int security_task_getsid(struct task_struct *p);
0423 void security_current_getsecid_subj(u32 *secid);
0424 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
0425 int security_task_setnice(struct task_struct *p, int nice);
0426 int security_task_setioprio(struct task_struct *p, int ioprio);
0427 int security_task_getioprio(struct task_struct *p);
0428 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
0429 unsigned int flags);
0430 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
0431 struct rlimit *new_rlim);
0432 int security_task_setscheduler(struct task_struct *p);
0433 int security_task_getscheduler(struct task_struct *p);
0434 int security_task_movememory(struct task_struct *p);
0435 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
0436 int sig, const struct cred *cred);
0437 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
0438 unsigned long arg4, unsigned long arg5);
0439 void security_task_to_inode(struct task_struct *p, struct inode *inode);
0440 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
0441 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
0442 int security_msg_msg_alloc(struct msg_msg *msg);
0443 void security_msg_msg_free(struct msg_msg *msg);
0444 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
0445 void security_msg_queue_free(struct kern_ipc_perm *msq);
0446 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
0447 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
0448 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
0449 struct msg_msg *msg, int msqflg);
0450 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
0451 struct task_struct *target, long type, int mode);
0452 int security_shm_alloc(struct kern_ipc_perm *shp);
0453 void security_shm_free(struct kern_ipc_perm *shp);
0454 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
0455 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
0456 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
0457 int security_sem_alloc(struct kern_ipc_perm *sma);
0458 void security_sem_free(struct kern_ipc_perm *sma);
0459 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
0460 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
0461 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
0462 unsigned nsops, int alter);
0463 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
0464 int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
0465 char **value);
0466 int security_setprocattr(const char *lsm, const char *name, void *value,
0467 size_t size);
0468 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
0469 int security_ismaclabel(const char *name);
0470 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
0471 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
0472 void security_release_secctx(char *secdata, u32 seclen);
0473 void security_inode_invalidate_secctx(struct inode *inode);
0474 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
0475 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
0476 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
0477 int security_locked_down(enum lockdown_reason what);
0478 #else
0479
0480 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
0481 {
0482 return 0;
0483 }
0484
0485 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
0486 {
0487 return 0;
0488 }
0489
0490 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
0491 {
0492 return 0;
0493 }
0494
0495 static inline void security_free_mnt_opts(void **mnt_opts)
0496 {
0497 }
0498
0499
0500
0501
0502
0503
0504 static inline int security_init(void)
0505 {
0506 return 0;
0507 }
0508
0509 static inline int early_security_init(void)
0510 {
0511 return 0;
0512 }
0513
0514 static inline int security_binder_set_context_mgr(const struct cred *mgr)
0515 {
0516 return 0;
0517 }
0518
0519 static inline int security_binder_transaction(const struct cred *from,
0520 const struct cred *to)
0521 {
0522 return 0;
0523 }
0524
0525 static inline int security_binder_transfer_binder(const struct cred *from,
0526 const struct cred *to)
0527 {
0528 return 0;
0529 }
0530
0531 static inline int security_binder_transfer_file(const struct cred *from,
0532 const struct cred *to,
0533 struct file *file)
0534 {
0535 return 0;
0536 }
0537
0538 static inline int security_ptrace_access_check(struct task_struct *child,
0539 unsigned int mode)
0540 {
0541 return cap_ptrace_access_check(child, mode);
0542 }
0543
0544 static inline int security_ptrace_traceme(struct task_struct *parent)
0545 {
0546 return cap_ptrace_traceme(parent);
0547 }
0548
0549 static inline int security_capget(struct task_struct *target,
0550 kernel_cap_t *effective,
0551 kernel_cap_t *inheritable,
0552 kernel_cap_t *permitted)
0553 {
0554 return cap_capget(target, effective, inheritable, permitted);
0555 }
0556
0557 static inline int security_capset(struct cred *new,
0558 const struct cred *old,
0559 const kernel_cap_t *effective,
0560 const kernel_cap_t *inheritable,
0561 const kernel_cap_t *permitted)
0562 {
0563 return cap_capset(new, old, effective, inheritable, permitted);
0564 }
0565
0566 static inline int security_capable(const struct cred *cred,
0567 struct user_namespace *ns,
0568 int cap,
0569 unsigned int opts)
0570 {
0571 return cap_capable(cred, ns, cap, opts);
0572 }
0573
0574 static inline int security_quotactl(int cmds, int type, int id,
0575 struct super_block *sb)
0576 {
0577 return 0;
0578 }
0579
0580 static inline int security_quota_on(struct dentry *dentry)
0581 {
0582 return 0;
0583 }
0584
0585 static inline int security_syslog(int type)
0586 {
0587 return 0;
0588 }
0589
0590 static inline int security_settime64(const struct timespec64 *ts,
0591 const struct timezone *tz)
0592 {
0593 return cap_settime(ts, tz);
0594 }
0595
0596 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
0597 {
0598 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
0599 }
0600
0601 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
0602 {
0603 return 0;
0604 }
0605
0606 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
0607 struct file *file)
0608 {
0609 return cap_bprm_creds_from_file(bprm, file);
0610 }
0611
0612 static inline int security_bprm_check(struct linux_binprm *bprm)
0613 {
0614 return 0;
0615 }
0616
0617 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
0618 {
0619 }
0620
0621 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
0622 {
0623 }
0624
0625 static inline int security_fs_context_dup(struct fs_context *fc,
0626 struct fs_context *src_fc)
0627 {
0628 return 0;
0629 }
0630 static inline int security_fs_context_parse_param(struct fs_context *fc,
0631 struct fs_parameter *param)
0632 {
0633 return -ENOPARAM;
0634 }
0635
0636 static inline int security_sb_alloc(struct super_block *sb)
0637 {
0638 return 0;
0639 }
0640
0641 static inline void security_sb_delete(struct super_block *sb)
0642 { }
0643
0644 static inline void security_sb_free(struct super_block *sb)
0645 { }
0646
0647 static inline int security_sb_eat_lsm_opts(char *options,
0648 void **mnt_opts)
0649 {
0650 return 0;
0651 }
0652
0653 static inline int security_sb_remount(struct super_block *sb,
0654 void *mnt_opts)
0655 {
0656 return 0;
0657 }
0658
0659 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
0660 void *mnt_opts)
0661 {
0662 return 0;
0663 }
0664
0665
0666 static inline int security_sb_kern_mount(struct super_block *sb)
0667 {
0668 return 0;
0669 }
0670
0671 static inline int security_sb_show_options(struct seq_file *m,
0672 struct super_block *sb)
0673 {
0674 return 0;
0675 }
0676
0677 static inline int security_sb_statfs(struct dentry *dentry)
0678 {
0679 return 0;
0680 }
0681
0682 static inline int security_sb_mount(const char *dev_name, const struct path *path,
0683 const char *type, unsigned long flags,
0684 void *data)
0685 {
0686 return 0;
0687 }
0688
0689 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
0690 {
0691 return 0;
0692 }
0693
0694 static inline int security_sb_pivotroot(const struct path *old_path,
0695 const struct path *new_path)
0696 {
0697 return 0;
0698 }
0699
0700 static inline int security_sb_set_mnt_opts(struct super_block *sb,
0701 void *mnt_opts,
0702 unsigned long kern_flags,
0703 unsigned long *set_kern_flags)
0704 {
0705 return 0;
0706 }
0707
0708 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
0709 struct super_block *newsb,
0710 unsigned long kern_flags,
0711 unsigned long *set_kern_flags)
0712 {
0713 return 0;
0714 }
0715
0716 static inline int security_move_mount(const struct path *from_path,
0717 const struct path *to_path)
0718 {
0719 return 0;
0720 }
0721
0722 static inline int security_path_notify(const struct path *path, u64 mask,
0723 unsigned int obj_type)
0724 {
0725 return 0;
0726 }
0727
0728 static inline int security_inode_alloc(struct inode *inode)
0729 {
0730 return 0;
0731 }
0732
0733 static inline void security_inode_free(struct inode *inode)
0734 { }
0735
0736 static inline int security_dentry_init_security(struct dentry *dentry,
0737 int mode,
0738 const struct qstr *name,
0739 const char **xattr_name,
0740 void **ctx,
0741 u32 *ctxlen)
0742 {
0743 return -EOPNOTSUPP;
0744 }
0745
0746 static inline int security_dentry_create_files_as(struct dentry *dentry,
0747 int mode, struct qstr *name,
0748 const struct cred *old,
0749 struct cred *new)
0750 {
0751 return 0;
0752 }
0753
0754
0755 static inline int security_inode_init_security(struct inode *inode,
0756 struct inode *dir,
0757 const struct qstr *qstr,
0758 const initxattrs xattrs,
0759 void *fs_data)
0760 {
0761 return 0;
0762 }
0763
0764 static inline int security_inode_init_security_anon(struct inode *inode,
0765 const struct qstr *name,
0766 const struct inode *context_inode)
0767 {
0768 return 0;
0769 }
0770
0771 static inline int security_old_inode_init_security(struct inode *inode,
0772 struct inode *dir,
0773 const struct qstr *qstr,
0774 const char **name,
0775 void **value, size_t *len)
0776 {
0777 return -EOPNOTSUPP;
0778 }
0779
0780 static inline int security_inode_create(struct inode *dir,
0781 struct dentry *dentry,
0782 umode_t mode)
0783 {
0784 return 0;
0785 }
0786
0787 static inline int security_inode_link(struct dentry *old_dentry,
0788 struct inode *dir,
0789 struct dentry *new_dentry)
0790 {
0791 return 0;
0792 }
0793
0794 static inline int security_inode_unlink(struct inode *dir,
0795 struct dentry *dentry)
0796 {
0797 return 0;
0798 }
0799
0800 static inline int security_inode_symlink(struct inode *dir,
0801 struct dentry *dentry,
0802 const char *old_name)
0803 {
0804 return 0;
0805 }
0806
0807 static inline int security_inode_mkdir(struct inode *dir,
0808 struct dentry *dentry,
0809 int mode)
0810 {
0811 return 0;
0812 }
0813
0814 static inline int security_inode_rmdir(struct inode *dir,
0815 struct dentry *dentry)
0816 {
0817 return 0;
0818 }
0819
0820 static inline int security_inode_mknod(struct inode *dir,
0821 struct dentry *dentry,
0822 int mode, dev_t dev)
0823 {
0824 return 0;
0825 }
0826
0827 static inline int security_inode_rename(struct inode *old_dir,
0828 struct dentry *old_dentry,
0829 struct inode *new_dir,
0830 struct dentry *new_dentry,
0831 unsigned int flags)
0832 {
0833 return 0;
0834 }
0835
0836 static inline int security_inode_readlink(struct dentry *dentry)
0837 {
0838 return 0;
0839 }
0840
0841 static inline int security_inode_follow_link(struct dentry *dentry,
0842 struct inode *inode,
0843 bool rcu)
0844 {
0845 return 0;
0846 }
0847
0848 static inline int security_inode_permission(struct inode *inode, int mask)
0849 {
0850 return 0;
0851 }
0852
0853 static inline int security_inode_setattr(struct user_namespace *mnt_userns,
0854 struct dentry *dentry,
0855 struct iattr *attr)
0856 {
0857 return 0;
0858 }
0859
0860 static inline int security_inode_getattr(const struct path *path)
0861 {
0862 return 0;
0863 }
0864
0865 static inline int security_inode_setxattr(struct user_namespace *mnt_userns,
0866 struct dentry *dentry, const char *name, const void *value,
0867 size_t size, int flags)
0868 {
0869 return cap_inode_setxattr(dentry, name, value, size, flags);
0870 }
0871
0872 static inline void security_inode_post_setxattr(struct dentry *dentry,
0873 const char *name, const void *value, size_t size, int flags)
0874 { }
0875
0876 static inline int security_inode_getxattr(struct dentry *dentry,
0877 const char *name)
0878 {
0879 return 0;
0880 }
0881
0882 static inline int security_inode_listxattr(struct dentry *dentry)
0883 {
0884 return 0;
0885 }
0886
0887 static inline int security_inode_removexattr(struct user_namespace *mnt_userns,
0888 struct dentry *dentry,
0889 const char *name)
0890 {
0891 return cap_inode_removexattr(mnt_userns, dentry, name);
0892 }
0893
0894 static inline int security_inode_need_killpriv(struct dentry *dentry)
0895 {
0896 return cap_inode_need_killpriv(dentry);
0897 }
0898
0899 static inline int security_inode_killpriv(struct user_namespace *mnt_userns,
0900 struct dentry *dentry)
0901 {
0902 return cap_inode_killpriv(mnt_userns, dentry);
0903 }
0904
0905 static inline int security_inode_getsecurity(struct user_namespace *mnt_userns,
0906 struct inode *inode,
0907 const char *name, void **buffer,
0908 bool alloc)
0909 {
0910 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc);
0911 }
0912
0913 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
0914 {
0915 return -EOPNOTSUPP;
0916 }
0917
0918 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
0919 {
0920 return 0;
0921 }
0922
0923 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
0924 {
0925 *secid = 0;
0926 }
0927
0928 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
0929 {
0930 return 0;
0931 }
0932
0933 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
0934 struct kernfs_node *kn)
0935 {
0936 return 0;
0937 }
0938
0939 static inline int security_inode_copy_up_xattr(const char *name)
0940 {
0941 return -EOPNOTSUPP;
0942 }
0943
0944 static inline int security_file_permission(struct file *file, int mask)
0945 {
0946 return 0;
0947 }
0948
0949 static inline int security_file_alloc(struct file *file)
0950 {
0951 return 0;
0952 }
0953
0954 static inline void security_file_free(struct file *file)
0955 { }
0956
0957 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
0958 unsigned long arg)
0959 {
0960 return 0;
0961 }
0962
0963 static inline int security_mmap_file(struct file *file, unsigned long prot,
0964 unsigned long flags)
0965 {
0966 return 0;
0967 }
0968
0969 static inline int security_mmap_addr(unsigned long addr)
0970 {
0971 return cap_mmap_addr(addr);
0972 }
0973
0974 static inline int security_file_mprotect(struct vm_area_struct *vma,
0975 unsigned long reqprot,
0976 unsigned long prot)
0977 {
0978 return 0;
0979 }
0980
0981 static inline int security_file_lock(struct file *file, unsigned int cmd)
0982 {
0983 return 0;
0984 }
0985
0986 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
0987 unsigned long arg)
0988 {
0989 return 0;
0990 }
0991
0992 static inline void security_file_set_fowner(struct file *file)
0993 {
0994 return;
0995 }
0996
0997 static inline int security_file_send_sigiotask(struct task_struct *tsk,
0998 struct fown_struct *fown,
0999 int sig)
1000 {
1001 return 0;
1002 }
1003
1004 static inline int security_file_receive(struct file *file)
1005 {
1006 return 0;
1007 }
1008
1009 static inline int security_file_open(struct file *file)
1010 {
1011 return 0;
1012 }
1013
1014 static inline int security_task_alloc(struct task_struct *task,
1015 unsigned long clone_flags)
1016 {
1017 return 0;
1018 }
1019
1020 static inline void security_task_free(struct task_struct *task)
1021 { }
1022
1023 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1024 {
1025 return 0;
1026 }
1027
1028 static inline void security_cred_free(struct cred *cred)
1029 { }
1030
1031 static inline int security_prepare_creds(struct cred *new,
1032 const struct cred *old,
1033 gfp_t gfp)
1034 {
1035 return 0;
1036 }
1037
1038 static inline void security_transfer_creds(struct cred *new,
1039 const struct cred *old)
1040 {
1041 }
1042
1043 static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1044 {
1045 *secid = 0;
1046 }
1047
1048 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1049 {
1050 return 0;
1051 }
1052
1053 static inline int security_kernel_create_files_as(struct cred *cred,
1054 struct inode *inode)
1055 {
1056 return 0;
1057 }
1058
1059 static inline int security_kernel_module_request(char *kmod_name)
1060 {
1061 return 0;
1062 }
1063
1064 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1065 {
1066 return 0;
1067 }
1068
1069 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1070 enum kernel_load_data_id id,
1071 char *description)
1072 {
1073 return 0;
1074 }
1075
1076 static inline int security_kernel_read_file(struct file *file,
1077 enum kernel_read_file_id id,
1078 bool contents)
1079 {
1080 return 0;
1081 }
1082
1083 static inline int security_kernel_post_read_file(struct file *file,
1084 char *buf, loff_t size,
1085 enum kernel_read_file_id id)
1086 {
1087 return 0;
1088 }
1089
1090 static inline int security_task_fix_setuid(struct cred *new,
1091 const struct cred *old,
1092 int flags)
1093 {
1094 return cap_task_fix_setuid(new, old, flags);
1095 }
1096
1097 static inline int security_task_fix_setgid(struct cred *new,
1098 const struct cred *old,
1099 int flags)
1100 {
1101 return 0;
1102 }
1103
1104 static inline int security_task_fix_setgroups(struct cred *new,
1105 const struct cred *old)
1106 {
1107 return 0;
1108 }
1109
1110 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1111 {
1112 return 0;
1113 }
1114
1115 static inline int security_task_getpgid(struct task_struct *p)
1116 {
1117 return 0;
1118 }
1119
1120 static inline int security_task_getsid(struct task_struct *p)
1121 {
1122 return 0;
1123 }
1124
1125 static inline void security_current_getsecid_subj(u32 *secid)
1126 {
1127 *secid = 0;
1128 }
1129
1130 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1131 {
1132 *secid = 0;
1133 }
1134
1135 static inline int security_task_setnice(struct task_struct *p, int nice)
1136 {
1137 return cap_task_setnice(p, nice);
1138 }
1139
1140 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1141 {
1142 return cap_task_setioprio(p, ioprio);
1143 }
1144
1145 static inline int security_task_getioprio(struct task_struct *p)
1146 {
1147 return 0;
1148 }
1149
1150 static inline int security_task_prlimit(const struct cred *cred,
1151 const struct cred *tcred,
1152 unsigned int flags)
1153 {
1154 return 0;
1155 }
1156
1157 static inline int security_task_setrlimit(struct task_struct *p,
1158 unsigned int resource,
1159 struct rlimit *new_rlim)
1160 {
1161 return 0;
1162 }
1163
1164 static inline int security_task_setscheduler(struct task_struct *p)
1165 {
1166 return cap_task_setscheduler(p);
1167 }
1168
1169 static inline int security_task_getscheduler(struct task_struct *p)
1170 {
1171 return 0;
1172 }
1173
1174 static inline int security_task_movememory(struct task_struct *p)
1175 {
1176 return 0;
1177 }
1178
1179 static inline int security_task_kill(struct task_struct *p,
1180 struct kernel_siginfo *info, int sig,
1181 const struct cred *cred)
1182 {
1183 return 0;
1184 }
1185
1186 static inline int security_task_prctl(int option, unsigned long arg2,
1187 unsigned long arg3,
1188 unsigned long arg4,
1189 unsigned long arg5)
1190 {
1191 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1192 }
1193
1194 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1195 { }
1196
1197 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1198 short flag)
1199 {
1200 return 0;
1201 }
1202
1203 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1204 {
1205 *secid = 0;
1206 }
1207
1208 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1209 {
1210 return 0;
1211 }
1212
1213 static inline void security_msg_msg_free(struct msg_msg *msg)
1214 { }
1215
1216 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1217 {
1218 return 0;
1219 }
1220
1221 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1222 { }
1223
1224 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1225 int msqflg)
1226 {
1227 return 0;
1228 }
1229
1230 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1231 {
1232 return 0;
1233 }
1234
1235 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1236 struct msg_msg *msg, int msqflg)
1237 {
1238 return 0;
1239 }
1240
1241 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1242 struct msg_msg *msg,
1243 struct task_struct *target,
1244 long type, int mode)
1245 {
1246 return 0;
1247 }
1248
1249 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1250 {
1251 return 0;
1252 }
1253
1254 static inline void security_shm_free(struct kern_ipc_perm *shp)
1255 { }
1256
1257 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1258 int shmflg)
1259 {
1260 return 0;
1261 }
1262
1263 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1264 {
1265 return 0;
1266 }
1267
1268 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1269 char __user *shmaddr, int shmflg)
1270 {
1271 return 0;
1272 }
1273
1274 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1275 {
1276 return 0;
1277 }
1278
1279 static inline void security_sem_free(struct kern_ipc_perm *sma)
1280 { }
1281
1282 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1283 {
1284 return 0;
1285 }
1286
1287 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1288 {
1289 return 0;
1290 }
1291
1292 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1293 struct sembuf *sops, unsigned nsops,
1294 int alter)
1295 {
1296 return 0;
1297 }
1298
1299 static inline void security_d_instantiate(struct dentry *dentry,
1300 struct inode *inode)
1301 { }
1302
1303 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1304 char *name, char **value)
1305 {
1306 return -EINVAL;
1307 }
1308
1309 static inline int security_setprocattr(const char *lsm, char *name,
1310 void *value, size_t size)
1311 {
1312 return -EINVAL;
1313 }
1314
1315 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1316 {
1317 return 0;
1318 }
1319
1320 static inline int security_ismaclabel(const char *name)
1321 {
1322 return 0;
1323 }
1324
1325 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1326 {
1327 return -EOPNOTSUPP;
1328 }
1329
1330 static inline int security_secctx_to_secid(const char *secdata,
1331 u32 seclen,
1332 u32 *secid)
1333 {
1334 return -EOPNOTSUPP;
1335 }
1336
1337 static inline void security_release_secctx(char *secdata, u32 seclen)
1338 {
1339 }
1340
1341 static inline void security_inode_invalidate_secctx(struct inode *inode)
1342 {
1343 }
1344
1345 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1346 {
1347 return -EOPNOTSUPP;
1348 }
1349 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1350 {
1351 return -EOPNOTSUPP;
1352 }
1353 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1354 {
1355 return -EOPNOTSUPP;
1356 }
1357 static inline int security_locked_down(enum lockdown_reason what)
1358 {
1359 return 0;
1360 }
1361 #endif
1362
1363 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1364 int security_post_notification(const struct cred *w_cred,
1365 const struct cred *cred,
1366 struct watch_notification *n);
1367 #else
1368 static inline int security_post_notification(const struct cred *w_cred,
1369 const struct cred *cred,
1370 struct watch_notification *n)
1371 {
1372 return 0;
1373 }
1374 #endif
1375
1376 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1377 int security_watch_key(struct key *key);
1378 #else
1379 static inline int security_watch_key(struct key *key)
1380 {
1381 return 0;
1382 }
1383 #endif
1384
1385 #ifdef CONFIG_SECURITY_NETWORK
1386
1387 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1388 int security_unix_may_send(struct socket *sock, struct socket *other);
1389 int security_socket_create(int family, int type, int protocol, int kern);
1390 int security_socket_post_create(struct socket *sock, int family,
1391 int type, int protocol, int kern);
1392 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1393 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1394 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1395 int security_socket_listen(struct socket *sock, int backlog);
1396 int security_socket_accept(struct socket *sock, struct socket *newsock);
1397 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1398 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1399 int size, int flags);
1400 int security_socket_getsockname(struct socket *sock);
1401 int security_socket_getpeername(struct socket *sock);
1402 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1403 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1404 int security_socket_shutdown(struct socket *sock, int how);
1405 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1406 int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1407 int __user *optlen, unsigned len);
1408 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1409 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1410 void security_sk_free(struct sock *sk);
1411 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1412 void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic);
1413 void security_req_classify_flow(const struct request_sock *req,
1414 struct flowi_common *flic);
1415 void security_sock_graft(struct sock*sk, struct socket *parent);
1416 int security_inet_conn_request(const struct sock *sk,
1417 struct sk_buff *skb, struct request_sock *req);
1418 void security_inet_csk_clone(struct sock *newsk,
1419 const struct request_sock *req);
1420 void security_inet_conn_established(struct sock *sk,
1421 struct sk_buff *skb);
1422 int security_secmark_relabel_packet(u32 secid);
1423 void security_secmark_refcount_inc(void);
1424 void security_secmark_refcount_dec(void);
1425 int security_tun_dev_alloc_security(void **security);
1426 void security_tun_dev_free_security(void *security);
1427 int security_tun_dev_create(void);
1428 int security_tun_dev_attach_queue(void *security);
1429 int security_tun_dev_attach(struct sock *sk, void *security);
1430 int security_tun_dev_open(void *security);
1431 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1432 int security_sctp_bind_connect(struct sock *sk, int optname,
1433 struct sockaddr *address, int addrlen);
1434 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1435 struct sock *newsk);
1436 int security_sctp_assoc_established(struct sctp_association *asoc,
1437 struct sk_buff *skb);
1438
1439 #else
1440 static inline int security_unix_stream_connect(struct sock *sock,
1441 struct sock *other,
1442 struct sock *newsk)
1443 {
1444 return 0;
1445 }
1446
1447 static inline int security_unix_may_send(struct socket *sock,
1448 struct socket *other)
1449 {
1450 return 0;
1451 }
1452
1453 static inline int security_socket_create(int family, int type,
1454 int protocol, int kern)
1455 {
1456 return 0;
1457 }
1458
1459 static inline int security_socket_post_create(struct socket *sock,
1460 int family,
1461 int type,
1462 int protocol, int kern)
1463 {
1464 return 0;
1465 }
1466
1467 static inline int security_socket_socketpair(struct socket *socka,
1468 struct socket *sockb)
1469 {
1470 return 0;
1471 }
1472
1473 static inline int security_socket_bind(struct socket *sock,
1474 struct sockaddr *address,
1475 int addrlen)
1476 {
1477 return 0;
1478 }
1479
1480 static inline int security_socket_connect(struct socket *sock,
1481 struct sockaddr *address,
1482 int addrlen)
1483 {
1484 return 0;
1485 }
1486
1487 static inline int security_socket_listen(struct socket *sock, int backlog)
1488 {
1489 return 0;
1490 }
1491
1492 static inline int security_socket_accept(struct socket *sock,
1493 struct socket *newsock)
1494 {
1495 return 0;
1496 }
1497
1498 static inline int security_socket_sendmsg(struct socket *sock,
1499 struct msghdr *msg, int size)
1500 {
1501 return 0;
1502 }
1503
1504 static inline int security_socket_recvmsg(struct socket *sock,
1505 struct msghdr *msg, int size,
1506 int flags)
1507 {
1508 return 0;
1509 }
1510
1511 static inline int security_socket_getsockname(struct socket *sock)
1512 {
1513 return 0;
1514 }
1515
1516 static inline int security_socket_getpeername(struct socket *sock)
1517 {
1518 return 0;
1519 }
1520
1521 static inline int security_socket_getsockopt(struct socket *sock,
1522 int level, int optname)
1523 {
1524 return 0;
1525 }
1526
1527 static inline int security_socket_setsockopt(struct socket *sock,
1528 int level, int optname)
1529 {
1530 return 0;
1531 }
1532
1533 static inline int security_socket_shutdown(struct socket *sock, int how)
1534 {
1535 return 0;
1536 }
1537 static inline int security_sock_rcv_skb(struct sock *sk,
1538 struct sk_buff *skb)
1539 {
1540 return 0;
1541 }
1542
1543 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1544 int __user *optlen, unsigned len)
1545 {
1546 return -ENOPROTOOPT;
1547 }
1548
1549 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1550 {
1551 return -ENOPROTOOPT;
1552 }
1553
1554 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1555 {
1556 return 0;
1557 }
1558
1559 static inline void security_sk_free(struct sock *sk)
1560 {
1561 }
1562
1563 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1564 {
1565 }
1566
1567 static inline void security_sk_classify_flow(struct sock *sk,
1568 struct flowi_common *flic)
1569 {
1570 }
1571
1572 static inline void security_req_classify_flow(const struct request_sock *req,
1573 struct flowi_common *flic)
1574 {
1575 }
1576
1577 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1578 {
1579 }
1580
1581 static inline int security_inet_conn_request(const struct sock *sk,
1582 struct sk_buff *skb, struct request_sock *req)
1583 {
1584 return 0;
1585 }
1586
1587 static inline void security_inet_csk_clone(struct sock *newsk,
1588 const struct request_sock *req)
1589 {
1590 }
1591
1592 static inline void security_inet_conn_established(struct sock *sk,
1593 struct sk_buff *skb)
1594 {
1595 }
1596
1597 static inline int security_secmark_relabel_packet(u32 secid)
1598 {
1599 return 0;
1600 }
1601
1602 static inline void security_secmark_refcount_inc(void)
1603 {
1604 }
1605
1606 static inline void security_secmark_refcount_dec(void)
1607 {
1608 }
1609
1610 static inline int security_tun_dev_alloc_security(void **security)
1611 {
1612 return 0;
1613 }
1614
1615 static inline void security_tun_dev_free_security(void *security)
1616 {
1617 }
1618
1619 static inline int security_tun_dev_create(void)
1620 {
1621 return 0;
1622 }
1623
1624 static inline int security_tun_dev_attach_queue(void *security)
1625 {
1626 return 0;
1627 }
1628
1629 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1630 {
1631 return 0;
1632 }
1633
1634 static inline int security_tun_dev_open(void *security)
1635 {
1636 return 0;
1637 }
1638
1639 static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1640 struct sk_buff *skb)
1641 {
1642 return 0;
1643 }
1644
1645 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1646 struct sockaddr *address,
1647 int addrlen)
1648 {
1649 return 0;
1650 }
1651
1652 static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1653 struct sock *sk,
1654 struct sock *newsk)
1655 {
1656 }
1657
1658 static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1659 struct sk_buff *skb)
1660 {
1661 return 0;
1662 }
1663 #endif
1664
1665 #ifdef CONFIG_SECURITY_INFINIBAND
1666 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1667 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1668 int security_ib_alloc_security(void **sec);
1669 void security_ib_free_security(void *sec);
1670 #else
1671 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1672 {
1673 return 0;
1674 }
1675
1676 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1677 {
1678 return 0;
1679 }
1680
1681 static inline int security_ib_alloc_security(void **sec)
1682 {
1683 return 0;
1684 }
1685
1686 static inline void security_ib_free_security(void *sec)
1687 {
1688 }
1689 #endif
1690
1691 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1692
1693 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1694 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1695 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1696 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1697 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1698 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1699 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1700 struct xfrm_sec_ctx *polsec, u32 secid);
1701 int security_xfrm_state_delete(struct xfrm_state *x);
1702 void security_xfrm_state_free(struct xfrm_state *x);
1703 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1704 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1705 struct xfrm_policy *xp,
1706 const struct flowi_common *flic);
1707 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1708 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1709
1710 #else
1711
1712 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1713 struct xfrm_user_sec_ctx *sec_ctx,
1714 gfp_t gfp)
1715 {
1716 return 0;
1717 }
1718
1719 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1720 {
1721 return 0;
1722 }
1723
1724 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1725 {
1726 }
1727
1728 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1729 {
1730 return 0;
1731 }
1732
1733 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1734 struct xfrm_user_sec_ctx *sec_ctx)
1735 {
1736 return 0;
1737 }
1738
1739 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1740 struct xfrm_sec_ctx *polsec, u32 secid)
1741 {
1742 return 0;
1743 }
1744
1745 static inline void security_xfrm_state_free(struct xfrm_state *x)
1746 {
1747 }
1748
1749 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1750 {
1751 return 0;
1752 }
1753
1754 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1755 {
1756 return 0;
1757 }
1758
1759 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1760 struct xfrm_policy *xp,
1761 const struct flowi_common *flic)
1762 {
1763 return 1;
1764 }
1765
1766 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1767 {
1768 return 0;
1769 }
1770
1771 static inline void security_skb_classify_flow(struct sk_buff *skb,
1772 struct flowi_common *flic)
1773 {
1774 }
1775
1776 #endif
1777
1778 #ifdef CONFIG_SECURITY_PATH
1779 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1780 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1781 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1782 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1783 unsigned int dev);
1784 int security_path_truncate(const struct path *path);
1785 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1786 const char *old_name);
1787 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1788 struct dentry *new_dentry);
1789 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1790 const struct path *new_dir, struct dentry *new_dentry,
1791 unsigned int flags);
1792 int security_path_chmod(const struct path *path, umode_t mode);
1793 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1794 int security_path_chroot(const struct path *path);
1795 #else
1796 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1797 {
1798 return 0;
1799 }
1800
1801 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1802 umode_t mode)
1803 {
1804 return 0;
1805 }
1806
1807 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1808 {
1809 return 0;
1810 }
1811
1812 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1813 umode_t mode, unsigned int dev)
1814 {
1815 return 0;
1816 }
1817
1818 static inline int security_path_truncate(const struct path *path)
1819 {
1820 return 0;
1821 }
1822
1823 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1824 const char *old_name)
1825 {
1826 return 0;
1827 }
1828
1829 static inline int security_path_link(struct dentry *old_dentry,
1830 const struct path *new_dir,
1831 struct dentry *new_dentry)
1832 {
1833 return 0;
1834 }
1835
1836 static inline int security_path_rename(const struct path *old_dir,
1837 struct dentry *old_dentry,
1838 const struct path *new_dir,
1839 struct dentry *new_dentry,
1840 unsigned int flags)
1841 {
1842 return 0;
1843 }
1844
1845 static inline int security_path_chmod(const struct path *path, umode_t mode)
1846 {
1847 return 0;
1848 }
1849
1850 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1851 {
1852 return 0;
1853 }
1854
1855 static inline int security_path_chroot(const struct path *path)
1856 {
1857 return 0;
1858 }
1859 #endif
1860
1861 #ifdef CONFIG_KEYS
1862 #ifdef CONFIG_SECURITY
1863
1864 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
1865 void security_key_free(struct key *key);
1866 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1867 enum key_need_perm need_perm);
1868 int security_key_getsecurity(struct key *key, char **_buffer);
1869
1870 #else
1871
1872 static inline int security_key_alloc(struct key *key,
1873 const struct cred *cred,
1874 unsigned long flags)
1875 {
1876 return 0;
1877 }
1878
1879 static inline void security_key_free(struct key *key)
1880 {
1881 }
1882
1883 static inline int security_key_permission(key_ref_t key_ref,
1884 const struct cred *cred,
1885 enum key_need_perm need_perm)
1886 {
1887 return 0;
1888 }
1889
1890 static inline int security_key_getsecurity(struct key *key, char **_buffer)
1891 {
1892 *_buffer = NULL;
1893 return 0;
1894 }
1895
1896 #endif
1897 #endif
1898
1899 #ifdef CONFIG_AUDIT
1900 #ifdef CONFIG_SECURITY
1901 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1902 int security_audit_rule_known(struct audit_krule *krule);
1903 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
1904 void security_audit_rule_free(void *lsmrule);
1905
1906 #else
1907
1908 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1909 void **lsmrule)
1910 {
1911 return 0;
1912 }
1913
1914 static inline int security_audit_rule_known(struct audit_krule *krule)
1915 {
1916 return 0;
1917 }
1918
1919 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
1920 void *lsmrule)
1921 {
1922 return 0;
1923 }
1924
1925 static inline void security_audit_rule_free(void *lsmrule)
1926 { }
1927
1928 #endif
1929 #endif
1930
1931 #ifdef CONFIG_SECURITYFS
1932
1933 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
1934 struct dentry *parent, void *data,
1935 const struct file_operations *fops);
1936 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1937 struct dentry *securityfs_create_symlink(const char *name,
1938 struct dentry *parent,
1939 const char *target,
1940 const struct inode_operations *iops);
1941 extern void securityfs_remove(struct dentry *dentry);
1942
1943 #else
1944
1945 static inline struct dentry *securityfs_create_dir(const char *name,
1946 struct dentry *parent)
1947 {
1948 return ERR_PTR(-ENODEV);
1949 }
1950
1951 static inline struct dentry *securityfs_create_file(const char *name,
1952 umode_t mode,
1953 struct dentry *parent,
1954 void *data,
1955 const struct file_operations *fops)
1956 {
1957 return ERR_PTR(-ENODEV);
1958 }
1959
1960 static inline struct dentry *securityfs_create_symlink(const char *name,
1961 struct dentry *parent,
1962 const char *target,
1963 const struct inode_operations *iops)
1964 {
1965 return ERR_PTR(-ENODEV);
1966 }
1967
1968 static inline void securityfs_remove(struct dentry *dentry)
1969 {}
1970
1971 #endif
1972
1973 #ifdef CONFIG_BPF_SYSCALL
1974 union bpf_attr;
1975 struct bpf_map;
1976 struct bpf_prog;
1977 struct bpf_prog_aux;
1978 #ifdef CONFIG_SECURITY
1979 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
1980 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
1981 extern int security_bpf_prog(struct bpf_prog *prog);
1982 extern int security_bpf_map_alloc(struct bpf_map *map);
1983 extern void security_bpf_map_free(struct bpf_map *map);
1984 extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
1985 extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
1986 #else
1987 static inline int security_bpf(int cmd, union bpf_attr *attr,
1988 unsigned int size)
1989 {
1990 return 0;
1991 }
1992
1993 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
1994 {
1995 return 0;
1996 }
1997
1998 static inline int security_bpf_prog(struct bpf_prog *prog)
1999 {
2000 return 0;
2001 }
2002
2003 static inline int security_bpf_map_alloc(struct bpf_map *map)
2004 {
2005 return 0;
2006 }
2007
2008 static inline void security_bpf_map_free(struct bpf_map *map)
2009 { }
2010
2011 static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
2012 {
2013 return 0;
2014 }
2015
2016 static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2017 { }
2018 #endif
2019 #endif
2020
2021 #ifdef CONFIG_PERF_EVENTS
2022 struct perf_event_attr;
2023 struct perf_event;
2024
2025 #ifdef CONFIG_SECURITY
2026 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2027 extern int security_perf_event_alloc(struct perf_event *event);
2028 extern void security_perf_event_free(struct perf_event *event);
2029 extern int security_perf_event_read(struct perf_event *event);
2030 extern int security_perf_event_write(struct perf_event *event);
2031 #else
2032 static inline int security_perf_event_open(struct perf_event_attr *attr,
2033 int type)
2034 {
2035 return 0;
2036 }
2037
2038 static inline int security_perf_event_alloc(struct perf_event *event)
2039 {
2040 return 0;
2041 }
2042
2043 static inline void security_perf_event_free(struct perf_event *event)
2044 {
2045 }
2046
2047 static inline int security_perf_event_read(struct perf_event *event)
2048 {
2049 return 0;
2050 }
2051
2052 static inline int security_perf_event_write(struct perf_event *event)
2053 {
2054 return 0;
2055 }
2056 #endif
2057 #endif
2058
2059 #ifdef CONFIG_IO_URING
2060 #ifdef CONFIG_SECURITY
2061 extern int security_uring_override_creds(const struct cred *new);
2062 extern int security_uring_sqpoll(void);
2063 extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2064 #else
2065 static inline int security_uring_override_creds(const struct cred *new)
2066 {
2067 return 0;
2068 }
2069 static inline int security_uring_sqpoll(void)
2070 {
2071 return 0;
2072 }
2073 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2074 {
2075 return 0;
2076 }
2077 #endif
2078 #endif
2079
2080 #endif