4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
5 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
7 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
8 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
9 * Copyright (C) 2016 Mellanox Techonologies
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * Due to this file being licensed under the GPL there is controversy over
17 * whether this permits you to write a module that #includes this file
18 * without placing your module under the GPL. Please consult a lawyer for
19 * advice before doing this.
23 #ifndef __LINUX_SECURITY_H
24 #define __LINUX_SECURITY_H
26 #include <linux/kernel_read_file.h>
27 #include <linux/key.h>
28 #include <linux/capability.h>
30 #include <linux/slab.h>
31 #include <linux/err.h>
32 #include <linux/string.h>
38 struct kernel_siginfo
;
51 struct file_operations
;
61 struct watch_notification
;
63 /* Default (no) options for the capable function */
64 #define CAP_OPT_NONE 0x0
65 /* If capable should audit the security request */
66 #define CAP_OPT_NOAUDIT BIT(1)
67 /* If capable is being called by a setid function */
68 #define CAP_OPT_INSETID BIT(2)
70 /* LSM Agnostic defines for fs_context::lsm_flags */
71 #define SECURITY_LSM_NATIVE_LABELS 1
75 struct user_namespace
;
83 * These are reasons that can be passed to the security_locked_down()
84 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
85 * ability for userland to modify kernel code) are placed before
86 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel
87 * confidentiality (ie, the ability for userland to extract
88 * information from the running kernel that would otherwise be
89 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
91 * LSM authors should note that the semantics of any given lockdown
92 * reason are not guaranteed to be stable - the same reason may block
93 * one set of features in one kernel release, and a slightly different
94 * set of features in a later kernel release. LSMs that seek to expose
95 * lockdown policy at any level of granularity other than "none",
96 * "integrity" or "confidentiality" are responsible for either
97 * ensuring that they expose a consistent level of functionality to
98 * userland, or ensuring that userland is aware that this is
99 * potentially a moving target. It is easy to misuse this information
100 * in a way that could break userspace. Please be careful not to do
103 * If you add to this, remember to extend lockdown_reasons in
104 * security/lockdown/lockdown.c.
106 enum lockdown_reason
{
108 LOCKDOWN_MODULE_SIGNATURE
,
112 LOCKDOWN_HIBERNATION
,
116 LOCKDOWN_ACPI_TABLES
,
118 LOCKDOWN_TIOCSSERIAL
,
119 LOCKDOWN_MODULE_PARAMETERS
,
123 LOCKDOWN_BPF_WRITE_USER
,
124 LOCKDOWN_INTEGRITY_MAX
,
127 LOCKDOWN_BPF_READ_KERNEL
,
131 LOCKDOWN_XFRM_SECRET
,
132 LOCKDOWN_CONFIDENTIALITY_MAX
,
135 extern const char *const lockdown_reasons
[LOCKDOWN_CONFIDENTIALITY_MAX
+1];
138 * A "security context" is the text representation of
139 * the information used by LSMs.
140 * This structure contains the string, its length, and which LSM
144 char *context
; /* Provided by the module */
146 int slot
; /* Identifies the module */
150 * lsmcontext_init - initialize an lsmcontext structure.
151 * @cp: Pointer to the context to initialize
152 * @context: Initial context, or NULL
153 * @size: Size of context, or 0
154 * @slot: Which LSM provided the context
156 * Fill in the lsmcontext from the provided information.
157 * This is a scaffolding function that will be removed when
158 * lsmcontext integration is complete.
160 static inline void lsmcontext_init(struct lsmcontext
*cp
, char *context
,
164 cp
->context
= context
;
169 * Data exported by the security modules
171 * Any LSM that provides secid or secctx based hooks must be included.
173 #define LSMBLOB_ENTRIES ( \
174 (IS_ENABLED(CONFIG_SECURITY_SELINUX) ? 1 : 0) + \
175 (IS_ENABLED(CONFIG_SECURITY_SMACK) ? 1 : 0) + \
176 (IS_ENABLED(CONFIG_SECURITY_APPARMOR) ? 1 : 0) + \
177 (IS_ENABLED(CONFIG_BPF_LSM) ? 1 : 0))
180 u32 secid
[LSMBLOB_ENTRIES
];
183 #define LSMBLOB_INVALID -1 /* Not a valid LSM slot number */
184 #define LSMBLOB_NEEDED -2 /* Slot requested on initialization */
185 #define LSMBLOB_NOT_NEEDED -3 /* Slot not requested */
186 #define LSMBLOB_DISPLAY -4 /* Use the "display" slot */
187 #define LSMBLOB_FIRST -5 /* Use the default "display" slot */
190 * lsmblob_init - initialize an lsmblob structure.
191 * @blob: Pointer to the data to initialize
192 * @secid: The initial secid value
194 * Set all secid for all modules to the specified value.
196 static inline void lsmblob_init(struct lsmblob
*blob
, u32 secid
)
200 for (i
= 0; i
< LSMBLOB_ENTRIES
; i
++)
201 blob
->secid
[i
] = secid
;
205 * lsmblob_is_set - report if there is an value in the lsmblob
206 * @blob: Pointer to the exported LSM data
208 * Returns true if there is a secid set, false otherwise
210 static inline bool lsmblob_is_set(struct lsmblob
*blob
)
212 struct lsmblob empty
= {};
214 return !!memcmp(blob
, &empty
, sizeof(*blob
));
218 * lsmblob_equal - report if the two lsmblob's are equal
219 * @bloba: Pointer to one LSM data
220 * @blobb: Pointer to the other LSM data
222 * Returns true if all entries in the two are equal, false otherwise
224 static inline bool lsmblob_equal(struct lsmblob
*bloba
, struct lsmblob
*blobb
)
226 return !memcmp(bloba
, blobb
, sizeof(*bloba
));
230 * lsmblob_value - find the first non-zero value in an lsmblob structure.
231 * @blob: Pointer to the data
233 * This needs to be used with extreme caution, as the cases where
234 * it is appropriate are rare.
236 * Return the first secid value set in the lsmblob.
237 * There should only be one.
239 static inline u32
lsmblob_value(const struct lsmblob
*blob
)
243 for (i
= 0; i
< LSMBLOB_ENTRIES
; i
++)
245 return blob
->secid
[i
];
250 const char *security_lsm_slot_name(int slot
);
252 static inline bool lsm_multiple_contexts(void)
254 #ifdef CONFIG_SECURITY
255 return security_lsm_slot_name(1) != NULL
;
261 /* These functions are in security/commoncap.c */
262 extern int cap_capable(const struct cred
*cred
, struct user_namespace
*ns
,
263 int cap
, unsigned int opts
);
264 extern int cap_settime(const struct timespec64
*ts
, const struct timezone
*tz
);
265 extern int cap_ptrace_access_check(struct task_struct
*child
, unsigned int mode
);
266 extern int cap_ptrace_traceme(struct task_struct
*parent
);
267 extern int cap_capget(struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
268 extern int cap_capset(struct cred
*new, const struct cred
*old
,
269 const kernel_cap_t
*effective
,
270 const kernel_cap_t
*inheritable
,
271 const kernel_cap_t
*permitted
);
272 extern int cap_bprm_creds_from_file(struct linux_binprm
*bprm
, struct file
*file
);
273 int cap_inode_setxattr(struct dentry
*dentry
, const char *name
,
274 const void *value
, size_t size
, int flags
);
275 int cap_inode_removexattr(struct user_namespace
*mnt_userns
,
276 struct dentry
*dentry
, const char *name
);
277 int cap_inode_need_killpriv(struct dentry
*dentry
);
278 int cap_inode_killpriv(struct user_namespace
*mnt_userns
,
279 struct dentry
*dentry
);
280 int cap_inode_getsecurity(struct user_namespace
*mnt_userns
,
281 struct inode
*inode
, const char *name
, void **buffer
,
283 extern int cap_mmap_addr(unsigned long addr
);
284 extern int cap_mmap_file(struct file
*file
, unsigned long reqprot
,
285 unsigned long prot
, unsigned long flags
);
286 extern int cap_task_fix_setuid(struct cred
*new, const struct cred
*old
, int flags
);
287 extern int cap_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
288 unsigned long arg4
, unsigned long arg5
);
289 extern int cap_task_setscheduler(struct task_struct
*p
);
290 extern int cap_task_setioprio(struct task_struct
*p
, int ioprio
);
291 extern int cap_task_setnice(struct task_struct
*p
, int nice
);
292 extern int cap_vm_enough_memory(struct mm_struct
*mm
, long pages
);
301 struct xfrm_selector
;
304 struct xfrm_user_sec_ctx
;
306 struct sctp_endpoint
;
309 extern unsigned long mmap_min_addr
;
310 extern unsigned long dac_mmap_min_addr
;
312 #define mmap_min_addr 0UL
313 #define dac_mmap_min_addr 0UL
317 * Values used in the task_security_ops calls
319 /* setuid or setgid, id0 == uid or gid */
320 #define LSM_SETID_ID 1
322 /* setreuid or setregid, id0 == real, id1 == eff */
323 #define LSM_SETID_RE 2
325 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
326 #define LSM_SETID_RES 4
328 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
329 #define LSM_SETID_FS 8
331 /* Flags for security_task_prlimit(). */
332 #define LSM_PRLIMIT_READ 1
333 #define LSM_PRLIMIT_WRITE 2
335 /* forward declares to avoid warnings */
339 /* bprm->unsafe reasons */
340 #define LSM_UNSAFE_SHARE 1
341 #define LSM_UNSAFE_PTRACE 2
342 #define LSM_UNSAFE_NO_NEW_PRIVS 4
345 extern int mmap_min_addr_handler(struct ctl_table
*table
, int write
,
346 void *buffer
, size_t *lenp
, loff_t
*ppos
);
349 /* security_inode_init_security callback function to write xattrs */
350 typedef int (*initxattrs
) (struct inode
*inode
,
351 const struct xattr
*xattr_array
, void *fs_data
);
354 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
355 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
356 #define __data_id_stringify(dummy, str) #str,
358 enum kernel_load_data_id
{
359 __kernel_read_file_id(__data_id_enumify
)
362 static const char * const kernel_load_data_str
[] = {
363 __kernel_read_file_id(__data_id_stringify
)
366 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id
)
368 if ((unsigned)id
>= LOADING_MAX_ID
)
369 return kernel_load_data_str
[LOADING_UNKNOWN
];
371 return kernel_load_data_str
[id
];
374 #ifdef CONFIG_SECURITY
376 int call_blocking_lsm_notifier(enum lsm_event event
, void *data
);
377 int register_blocking_lsm_notifier(struct notifier_block
*nb
);
378 int unregister_blocking_lsm_notifier(struct notifier_block
*nb
);
381 extern int security_init(void);
382 extern int early_security_init(void);
384 /* Security operations */
385 int security_binder_set_context_mgr(const struct cred
*mgr
);
386 int security_binder_transaction(const struct cred
*from
,
387 const struct cred
*to
);
388 int security_binder_transfer_binder(const struct cred
*from
,
389 const struct cred
*to
);
390 int security_binder_transfer_file(const struct cred
*from
,
391 const struct cred
*to
, struct file
*file
);
392 int security_ptrace_access_check(struct task_struct
*child
, unsigned int mode
);
393 int security_ptrace_traceme(struct task_struct
*parent
);
394 int security_capget(struct task_struct
*target
,
395 kernel_cap_t
*effective
,
396 kernel_cap_t
*inheritable
,
397 kernel_cap_t
*permitted
);
398 int security_capset(struct cred
*new, const struct cred
*old
,
399 const kernel_cap_t
*effective
,
400 const kernel_cap_t
*inheritable
,
401 const kernel_cap_t
*permitted
);
402 int security_capable(const struct cred
*cred
,
403 struct user_namespace
*ns
,
406 int security_quotactl(int cmds
, int type
, int id
, struct super_block
*sb
);
407 int security_quota_on(struct dentry
*dentry
);
408 int security_syslog(int type
);
409 int security_settime64(const struct timespec64
*ts
, const struct timezone
*tz
);
410 int security_vm_enough_memory_mm(struct mm_struct
*mm
, long pages
);
411 int security_bprm_creds_for_exec(struct linux_binprm
*bprm
);
412 int security_bprm_creds_from_file(struct linux_binprm
*bprm
, struct file
*file
);
413 int security_bprm_check(struct linux_binprm
*bprm
);
414 void security_bprm_committing_creds(struct linux_binprm
*bprm
);
415 void security_bprm_committed_creds(struct linux_binprm
*bprm
);
416 int security_fs_context_dup(struct fs_context
*fc
, struct fs_context
*src_fc
);
417 int security_fs_context_parse_param(struct fs_context
*fc
, struct fs_parameter
*param
);
418 int security_sb_alloc(struct super_block
*sb
);
419 void security_sb_delete(struct super_block
*sb
);
420 void security_sb_free(struct super_block
*sb
);
421 void security_free_mnt_opts(void **mnt_opts
);
422 int security_sb_eat_lsm_opts(char *options
, void **mnt_opts
);
423 int security_sb_mnt_opts_compat(struct super_block
*sb
, void *mnt_opts
);
424 int security_sb_remount(struct super_block
*sb
, void *mnt_opts
);
425 int security_sb_kern_mount(struct super_block
*sb
);
426 int security_sb_show_options(struct seq_file
*m
, struct super_block
*sb
);
427 int security_sb_statfs(struct dentry
*dentry
);
428 int security_sb_mount(const char *dev_name
, const struct path
*path
,
429 const char *type
, unsigned long flags
, void *data
);
430 int security_sb_umount(struct vfsmount
*mnt
, int flags
);
431 int security_sb_pivotroot(const struct path
*old_path
, const struct path
*new_path
);
432 int security_sb_set_mnt_opts(struct super_block
*sb
,
434 unsigned long kern_flags
,
435 unsigned long *set_kern_flags
);
436 int security_sb_clone_mnt_opts(const struct super_block
*oldsb
,
437 struct super_block
*newsb
,
438 unsigned long kern_flags
,
439 unsigned long *set_kern_flags
);
440 int security_add_mnt_opt(const char *option
, const char *val
,
441 int len
, void **mnt_opts
);
442 int security_move_mount(const struct path
*from_path
, const struct path
*to_path
);
443 int security_dentry_init_security(struct dentry
*dentry
, int mode
,
444 const struct qstr
*name
, void **ctx
,
446 int security_dentry_create_files_as(struct dentry
*dentry
, int mode
,
448 const struct cred
*old
,
450 int security_path_notify(const struct path
*path
, u64 mask
,
451 unsigned int obj_type
);
452 int security_inode_alloc(struct inode
*inode
);
453 void security_inode_free(struct inode
*inode
);
454 int security_inode_init_security(struct inode
*inode
, struct inode
*dir
,
455 const struct qstr
*qstr
,
456 initxattrs initxattrs
, void *fs_data
);
457 int security_inode_init_security_anon(struct inode
*inode
,
458 const struct qstr
*name
,
459 const struct inode
*context_inode
);
460 int security_old_inode_init_security(struct inode
*inode
, struct inode
*dir
,
461 const struct qstr
*qstr
, const char **name
,
462 void **value
, size_t *len
);
463 int security_inode_create(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
);
464 int security_inode_link(struct dentry
*old_dentry
, struct inode
*dir
,
465 struct dentry
*new_dentry
);
466 int security_inode_unlink(struct inode
*dir
, struct dentry
*dentry
);
467 int security_inode_symlink(struct inode
*dir
, struct dentry
*dentry
,
468 const char *old_name
);
469 int security_inode_mkdir(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
);
470 int security_inode_rmdir(struct inode
*dir
, struct dentry
*dentry
);
471 int security_inode_mknod(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
, dev_t dev
);
472 int security_inode_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
473 struct inode
*new_dir
, struct dentry
*new_dentry
,
475 int security_inode_readlink(struct dentry
*dentry
);
476 int security_inode_follow_link(struct dentry
*dentry
, struct inode
*inode
,
478 int security_inode_permission(struct inode
*inode
, int mask
);
479 int security_inode_setattr(struct dentry
*dentry
, struct iattr
*attr
);
480 int security_inode_getattr(const struct path
*path
);
481 int security_inode_setxattr(struct user_namespace
*mnt_userns
,
482 struct dentry
*dentry
, const char *name
,
483 const void *value
, size_t size
, int flags
);
484 void security_inode_post_setxattr(struct dentry
*dentry
, const char *name
,
485 const void *value
, size_t size
, int flags
);
486 int security_inode_getxattr(struct dentry
*dentry
, const char *name
);
487 int security_inode_listxattr(struct dentry
*dentry
);
488 int security_inode_removexattr(struct user_namespace
*mnt_userns
,
489 struct dentry
*dentry
, const char *name
);
490 int security_inode_need_killpriv(struct dentry
*dentry
);
491 int security_inode_killpriv(struct user_namespace
*mnt_userns
,
492 struct dentry
*dentry
);
493 int security_inode_getsecurity(struct user_namespace
*mnt_userns
,
494 struct inode
*inode
, const char *name
,
495 void **buffer
, bool alloc
);
496 int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
);
497 int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
);
498 void security_inode_getsecid(struct inode
*inode
, struct lsmblob
*blob
);
499 int security_inode_copy_up(struct dentry
*src
, struct cred
**new);
500 int security_inode_copy_up_xattr(const char *name
);
501 int security_kernfs_init_security(struct kernfs_node
*kn_dir
,
502 struct kernfs_node
*kn
);
503 int security_file_permission(struct file
*file
, int mask
);
504 int security_file_alloc(struct file
*file
);
505 void security_file_free(struct file
*file
);
506 int security_file_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
);
507 int security_mmap_file(struct file
*file
, unsigned long prot
,
508 unsigned long flags
);
509 int security_mmap_addr(unsigned long addr
);
510 int security_file_mprotect(struct vm_area_struct
*vma
, unsigned long reqprot
,
512 int security_file_lock(struct file
*file
, unsigned int cmd
);
513 int security_file_fcntl(struct file
*file
, unsigned int cmd
, unsigned long arg
);
514 void security_file_set_fowner(struct file
*file
);
515 int security_file_send_sigiotask(struct task_struct
*tsk
,
516 struct fown_struct
*fown
, int sig
);
517 int security_file_receive(struct file
*file
);
518 int security_file_open(struct file
*file
);
519 int security_task_alloc(struct task_struct
*task
, unsigned long clone_flags
);
520 void security_task_free(struct task_struct
*task
);
521 int security_cred_alloc_blank(struct cred
*cred
, gfp_t gfp
);
522 void security_cred_free(struct cred
*cred
);
523 int security_prepare_creds(struct cred
*new, const struct cred
*old
, gfp_t gfp
);
524 void security_transfer_creds(struct cred
*new, const struct cred
*old
);
525 void security_cred_getsecid(const struct cred
*c
, struct lsmblob
*blob
);
526 int security_kernel_act_as(struct cred
*new, struct lsmblob
*blob
);
527 int security_kernel_create_files_as(struct cred
*new, struct inode
*inode
);
528 int security_kernel_module_request(char *kmod_name
);
529 int security_kernel_load_data(enum kernel_load_data_id id
, bool contents
);
530 int security_kernel_post_load_data(char *buf
, loff_t size
,
531 enum kernel_load_data_id id
,
533 int security_kernel_read_file(struct file
*file
, enum kernel_read_file_id id
,
535 int security_kernel_post_read_file(struct file
*file
, char *buf
, loff_t size
,
536 enum kernel_read_file_id id
);
537 int security_task_fix_setuid(struct cred
*new, const struct cred
*old
,
539 int security_task_fix_setgid(struct cred
*new, const struct cred
*old
,
541 int security_task_setpgid(struct task_struct
*p
, pid_t pgid
);
542 int security_task_getpgid(struct task_struct
*p
);
543 int security_task_getsid(struct task_struct
*p
);
544 void security_task_getsecid_subj(struct task_struct
*p
, struct lsmblob
*blob
);
545 void security_task_getsecid_obj(struct task_struct
*p
, struct lsmblob
*blob
);
546 int security_task_setnice(struct task_struct
*p
, int nice
);
547 int security_task_setioprio(struct task_struct
*p
, int ioprio
);
548 int security_task_getioprio(struct task_struct
*p
);
549 int security_task_prlimit(const struct cred
*cred
, const struct cred
*tcred
,
551 int security_task_setrlimit(struct task_struct
*p
, unsigned int resource
,
552 struct rlimit
*new_rlim
);
553 int security_task_setscheduler(struct task_struct
*p
);
554 int security_task_getscheduler(struct task_struct
*p
);
555 int security_task_movememory(struct task_struct
*p
);
556 int security_task_kill(struct task_struct
*p
, struct kernel_siginfo
*info
,
557 int sig
, const struct cred
*cred
);
558 int security_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
559 unsigned long arg4
, unsigned long arg5
);
560 void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
);
561 int security_ipc_permission(struct kern_ipc_perm
*ipcp
, short flag
);
562 void security_ipc_getsecid(struct kern_ipc_perm
*ipcp
, struct lsmblob
*blob
);
563 int security_msg_msg_alloc(struct msg_msg
*msg
);
564 void security_msg_msg_free(struct msg_msg
*msg
);
565 int security_msg_queue_alloc(struct kern_ipc_perm
*msq
);
566 void security_msg_queue_free(struct kern_ipc_perm
*msq
);
567 int security_msg_queue_associate(struct kern_ipc_perm
*msq
, int msqflg
);
568 int security_msg_queue_msgctl(struct kern_ipc_perm
*msq
, int cmd
);
569 int security_msg_queue_msgsnd(struct kern_ipc_perm
*msq
,
570 struct msg_msg
*msg
, int msqflg
);
571 int security_msg_queue_msgrcv(struct kern_ipc_perm
*msq
, struct msg_msg
*msg
,
572 struct task_struct
*target
, long type
, int mode
);
573 int security_shm_alloc(struct kern_ipc_perm
*shp
);
574 void security_shm_free(struct kern_ipc_perm
*shp
);
575 int security_shm_associate(struct kern_ipc_perm
*shp
, int shmflg
);
576 int security_shm_shmctl(struct kern_ipc_perm
*shp
, int cmd
);
577 int security_shm_shmat(struct kern_ipc_perm
*shp
, char __user
*shmaddr
, int shmflg
);
578 int security_sem_alloc(struct kern_ipc_perm
*sma
);
579 void security_sem_free(struct kern_ipc_perm
*sma
);
580 int security_sem_associate(struct kern_ipc_perm
*sma
, int semflg
);
581 int security_sem_semctl(struct kern_ipc_perm
*sma
, int cmd
);
582 int security_sem_semop(struct kern_ipc_perm
*sma
, struct sembuf
*sops
,
583 unsigned nsops
, int alter
);
584 void security_d_instantiate(struct dentry
*dentry
, struct inode
*inode
);
585 int security_getprocattr(struct task_struct
*p
, const char *lsm
, char *name
,
587 int security_setprocattr(const char *lsm
, const char *name
, void *value
,
589 int security_netlink_send(struct sock
*sk
, struct sk_buff
*skb
);
590 int security_ismaclabel(const char *name
);
591 int security_secid_to_secctx(struct lsmblob
*blob
, struct lsmcontext
*cp
,
593 int security_secctx_to_secid(const char *secdata
, u32 seclen
,
594 struct lsmblob
*blob
);
595 void security_release_secctx(struct lsmcontext
*cp
);
596 void security_inode_invalidate_secctx(struct inode
*inode
);
597 int security_inode_notifysecctx(struct inode
*inode
, void *ctx
, u32 ctxlen
);
598 int security_inode_setsecctx(struct dentry
*dentry
, void *ctx
, u32 ctxlen
);
599 int security_inode_getsecctx(struct inode
*inode
, struct lsmcontext
*cp
);
600 int security_locked_down(enum lockdown_reason what
);
601 int security_lock_kernel_down(const char *where
, enum lockdown_reason level
);
602 #else /* CONFIG_SECURITY */
604 static inline int call_blocking_lsm_notifier(enum lsm_event event
, void *data
)
609 static inline int register_blocking_lsm_notifier(struct notifier_block
*nb
)
614 static inline int unregister_blocking_lsm_notifier(struct notifier_block
*nb
)
619 static inline void security_free_mnt_opts(void **mnt_opts
)
624 * This is the default capabilities functionality. Most of these functions
625 * are just stubbed out, but a few must call the proper capable code.
628 static inline int security_init(void)
633 static inline int early_security_init(void)
638 static inline int security_binder_set_context_mgr(const struct cred
*mgr
)
643 static inline int security_binder_transaction(const struct cred
*from
,
644 const struct cred
*to
)
649 static inline int security_binder_transfer_binder(const struct cred
*from
,
650 const struct cred
*to
)
655 static inline int security_binder_transfer_file(const struct cred
*from
,
656 const struct cred
*to
,
662 static inline int security_ptrace_access_check(struct task_struct
*child
,
665 return cap_ptrace_access_check(child
, mode
);
668 static inline int security_ptrace_traceme(struct task_struct
*parent
)
670 return cap_ptrace_traceme(parent
);
673 static inline int security_capget(struct task_struct
*target
,
674 kernel_cap_t
*effective
,
675 kernel_cap_t
*inheritable
,
676 kernel_cap_t
*permitted
)
678 return cap_capget(target
, effective
, inheritable
, permitted
);
681 static inline int security_capset(struct cred
*new,
682 const struct cred
*old
,
683 const kernel_cap_t
*effective
,
684 const kernel_cap_t
*inheritable
,
685 const kernel_cap_t
*permitted
)
687 return cap_capset(new, old
, effective
, inheritable
, permitted
);
690 static inline int security_capable(const struct cred
*cred
,
691 struct user_namespace
*ns
,
695 return cap_capable(cred
, ns
, cap
, opts
);
698 static inline int security_quotactl(int cmds
, int type
, int id
,
699 struct super_block
*sb
)
704 static inline int security_quota_on(struct dentry
*dentry
)
709 static inline int security_syslog(int type
)
714 static inline int security_settime64(const struct timespec64
*ts
,
715 const struct timezone
*tz
)
717 return cap_settime(ts
, tz
);
720 static inline int security_vm_enough_memory_mm(struct mm_struct
*mm
, long pages
)
722 return __vm_enough_memory(mm
, pages
, cap_vm_enough_memory(mm
, pages
));
725 static inline int security_bprm_creds_for_exec(struct linux_binprm
*bprm
)
730 static inline int security_bprm_creds_from_file(struct linux_binprm
*bprm
,
733 return cap_bprm_creds_from_file(bprm
, file
);
736 static inline int security_bprm_check(struct linux_binprm
*bprm
)
741 static inline void security_bprm_committing_creds(struct linux_binprm
*bprm
)
745 static inline void security_bprm_committed_creds(struct linux_binprm
*bprm
)
749 static inline int security_fs_context_dup(struct fs_context
*fc
,
750 struct fs_context
*src_fc
)
754 static inline int security_fs_context_parse_param(struct fs_context
*fc
,
755 struct fs_parameter
*param
)
760 static inline int security_sb_alloc(struct super_block
*sb
)
765 static inline void security_sb_delete(struct super_block
*sb
)
768 static inline void security_sb_free(struct super_block
*sb
)
771 static inline int security_sb_eat_lsm_opts(char *options
,
777 static inline int security_sb_remount(struct super_block
*sb
,
783 static inline int security_sb_mnt_opts_compat(struct super_block
*sb
,
790 static inline int security_sb_kern_mount(struct super_block
*sb
)
795 static inline int security_sb_show_options(struct seq_file
*m
,
796 struct super_block
*sb
)
801 static inline int security_sb_statfs(struct dentry
*dentry
)
806 static inline int security_sb_mount(const char *dev_name
, const struct path
*path
,
807 const char *type
, unsigned long flags
,
813 static inline int security_sb_umount(struct vfsmount
*mnt
, int flags
)
818 static inline int security_sb_pivotroot(const struct path
*old_path
,
819 const struct path
*new_path
)
824 static inline int security_sb_set_mnt_opts(struct super_block
*sb
,
826 unsigned long kern_flags
,
827 unsigned long *set_kern_flags
)
832 static inline int security_sb_clone_mnt_opts(const struct super_block
*oldsb
,
833 struct super_block
*newsb
,
834 unsigned long kern_flags
,
835 unsigned long *set_kern_flags
)
840 static inline int security_add_mnt_opt(const char *option
, const char *val
,
841 int len
, void **mnt_opts
)
846 static inline int security_move_mount(const struct path
*from_path
,
847 const struct path
*to_path
)
852 static inline int security_path_notify(const struct path
*path
, u64 mask
,
853 unsigned int obj_type
)
858 static inline int security_inode_alloc(struct inode
*inode
)
863 static inline void security_inode_free(struct inode
*inode
)
866 static inline int security_dentry_init_security(struct dentry
*dentry
,
868 const struct qstr
*name
,
875 static inline int security_dentry_create_files_as(struct dentry
*dentry
,
876 int mode
, struct qstr
*name
,
877 const struct cred
*old
,
884 static inline int security_inode_init_security(struct inode
*inode
,
886 const struct qstr
*qstr
,
887 const initxattrs xattrs
,
893 static inline int security_inode_init_security_anon(struct inode
*inode
,
894 const struct qstr
*name
,
895 const struct inode
*context_inode
)
900 static inline int security_old_inode_init_security(struct inode
*inode
,
902 const struct qstr
*qstr
,
904 void **value
, size_t *len
)
909 static inline int security_inode_create(struct inode
*dir
,
910 struct dentry
*dentry
,
916 static inline int security_inode_link(struct dentry
*old_dentry
,
918 struct dentry
*new_dentry
)
923 static inline int security_inode_unlink(struct inode
*dir
,
924 struct dentry
*dentry
)
929 static inline int security_inode_symlink(struct inode
*dir
,
930 struct dentry
*dentry
,
931 const char *old_name
)
936 static inline int security_inode_mkdir(struct inode
*dir
,
937 struct dentry
*dentry
,
943 static inline int security_inode_rmdir(struct inode
*dir
,
944 struct dentry
*dentry
)
949 static inline int security_inode_mknod(struct inode
*dir
,
950 struct dentry
*dentry
,
956 static inline int security_inode_rename(struct inode
*old_dir
,
957 struct dentry
*old_dentry
,
958 struct inode
*new_dir
,
959 struct dentry
*new_dentry
,
965 static inline int security_inode_readlink(struct dentry
*dentry
)
970 static inline int security_inode_follow_link(struct dentry
*dentry
,
977 static inline int security_inode_permission(struct inode
*inode
, int mask
)
982 static inline int security_inode_setattr(struct dentry
*dentry
,
988 static inline int security_inode_getattr(const struct path
*path
)
993 static inline int security_inode_setxattr(struct user_namespace
*mnt_userns
,
994 struct dentry
*dentry
, const char *name
, const void *value
,
995 size_t size
, int flags
)
997 return cap_inode_setxattr(dentry
, name
, value
, size
, flags
);
1000 static inline void security_inode_post_setxattr(struct dentry
*dentry
,
1001 const char *name
, const void *value
, size_t size
, int flags
)
1004 static inline int security_inode_getxattr(struct dentry
*dentry
,
1010 static inline int security_inode_listxattr(struct dentry
*dentry
)
1015 static inline int security_inode_removexattr(struct user_namespace
*mnt_userns
,
1016 struct dentry
*dentry
,
1019 return cap_inode_removexattr(mnt_userns
, dentry
, name
);
1022 static inline int security_inode_need_killpriv(struct dentry
*dentry
)
1024 return cap_inode_need_killpriv(dentry
);
1027 static inline int security_inode_killpriv(struct user_namespace
*mnt_userns
,
1028 struct dentry
*dentry
)
1030 return cap_inode_killpriv(mnt_userns
, dentry
);
1033 static inline int security_inode_getsecurity(struct user_namespace
*mnt_userns
,
1034 struct inode
*inode
,
1035 const char *name
, void **buffer
,
1038 return cap_inode_getsecurity(mnt_userns
, inode
, name
, buffer
, alloc
);
1041 static inline int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
1046 static inline int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
1051 static inline void security_inode_getsecid(struct inode
*inode
,
1052 struct lsmblob
*blob
)
1054 lsmblob_init(blob
, 0);
1057 static inline int security_inode_copy_up(struct dentry
*src
, struct cred
**new)
1062 static inline int security_kernfs_init_security(struct kernfs_node
*kn_dir
,
1063 struct kernfs_node
*kn
)
1068 static inline int security_inode_copy_up_xattr(const char *name
)
1073 static inline int security_file_permission(struct file
*file
, int mask
)
1078 static inline int security_file_alloc(struct file
*file
)
1083 static inline void security_file_free(struct file
*file
)
1086 static inline int security_file_ioctl(struct file
*file
, unsigned int cmd
,
1092 static inline int security_mmap_file(struct file
*file
, unsigned long prot
,
1093 unsigned long flags
)
1098 static inline int security_mmap_addr(unsigned long addr
)
1100 return cap_mmap_addr(addr
);
1103 static inline int security_file_mprotect(struct vm_area_struct
*vma
,
1104 unsigned long reqprot
,
1110 static inline int security_file_lock(struct file
*file
, unsigned int cmd
)
1115 static inline int security_file_fcntl(struct file
*file
, unsigned int cmd
,
1121 static inline void security_file_set_fowner(struct file
*file
)
1126 static inline int security_file_send_sigiotask(struct task_struct
*tsk
,
1127 struct fown_struct
*fown
,
1133 static inline int security_file_receive(struct file
*file
)
1138 static inline int security_file_open(struct file
*file
)
1143 static inline int security_task_alloc(struct task_struct
*task
,
1144 unsigned long clone_flags
)
1149 static inline void security_task_free(struct task_struct
*task
)
1152 static inline int security_cred_alloc_blank(struct cred
*cred
, gfp_t gfp
)
1157 static inline void security_cred_free(struct cred
*cred
)
1160 static inline int security_prepare_creds(struct cred
*new,
1161 const struct cred
*old
,
1167 static inline void security_transfer_creds(struct cred
*new,
1168 const struct cred
*old
)
1172 static inline int security_kernel_act_as(struct cred
*cred
,
1173 struct lsmblob
*blob
)
1178 static inline int security_kernel_create_files_as(struct cred
*cred
,
1179 struct inode
*inode
)
1184 static inline int security_kernel_module_request(char *kmod_name
)
1189 static inline int security_kernel_load_data(enum kernel_load_data_id id
, bool contents
)
1194 static inline int security_kernel_post_load_data(char *buf
, loff_t size
,
1195 enum kernel_load_data_id id
,
1201 static inline int security_kernel_read_file(struct file
*file
,
1202 enum kernel_read_file_id id
,
1208 static inline int security_kernel_post_read_file(struct file
*file
,
1209 char *buf
, loff_t size
,
1210 enum kernel_read_file_id id
)
1215 static inline int security_task_fix_setuid(struct cred
*new,
1216 const struct cred
*old
,
1219 return cap_task_fix_setuid(new, old
, flags
);
1222 static inline int security_task_fix_setgid(struct cred
*new,
1223 const struct cred
*old
,
1229 static inline int security_task_setpgid(struct task_struct
*p
, pid_t pgid
)
1234 static inline int security_task_getpgid(struct task_struct
*p
)
1239 static inline int security_task_getsid(struct task_struct
*p
)
1244 static inline void security_task_getsecid_subj(struct task_struct
*p
,
1245 struct lsmblob
*blob
)
1247 lsmblob_init(blob
, 0);
1250 static inline void security_task_getsecid_obj(struct task_struct
*p
,
1251 struct lsmblob
*blob
)
1253 lsmblob_init(blob
, 0);
1256 static inline int security_task_setnice(struct task_struct
*p
, int nice
)
1258 return cap_task_setnice(p
, nice
);
1261 static inline int security_task_setioprio(struct task_struct
*p
, int ioprio
)
1263 return cap_task_setioprio(p
, ioprio
);
1266 static inline int security_task_getioprio(struct task_struct
*p
)
1271 static inline int security_task_prlimit(const struct cred
*cred
,
1272 const struct cred
*tcred
,
1278 static inline int security_task_setrlimit(struct task_struct
*p
,
1279 unsigned int resource
,
1280 struct rlimit
*new_rlim
)
1285 static inline int security_task_setscheduler(struct task_struct
*p
)
1287 return cap_task_setscheduler(p
);
1290 static inline int security_task_getscheduler(struct task_struct
*p
)
1295 static inline int security_task_movememory(struct task_struct
*p
)
1300 static inline int security_task_kill(struct task_struct
*p
,
1301 struct kernel_siginfo
*info
, int sig
,
1302 const struct cred
*cred
)
1307 static inline int security_task_prctl(int option
, unsigned long arg2
,
1312 return cap_task_prctl(option
, arg2
, arg3
, arg4
, arg5
);
1315 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
1318 static inline int security_ipc_permission(struct kern_ipc_perm
*ipcp
,
1324 static inline void security_ipc_getsecid(struct kern_ipc_perm
*ipcp
,
1325 struct lsmblob
*blob
)
1327 lsmblob_init(blob
, 0);
1330 static inline int security_msg_msg_alloc(struct msg_msg
*msg
)
1335 static inline void security_msg_msg_free(struct msg_msg
*msg
)
1338 static inline int security_msg_queue_alloc(struct kern_ipc_perm
*msq
)
1343 static inline void security_msg_queue_free(struct kern_ipc_perm
*msq
)
1346 static inline int security_msg_queue_associate(struct kern_ipc_perm
*msq
,
1352 static inline int security_msg_queue_msgctl(struct kern_ipc_perm
*msq
, int cmd
)
1357 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm
*msq
,
1358 struct msg_msg
*msg
, int msqflg
)
1363 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm
*msq
,
1364 struct msg_msg
*msg
,
1365 struct task_struct
*target
,
1366 long type
, int mode
)
1371 static inline int security_shm_alloc(struct kern_ipc_perm
*shp
)
1376 static inline void security_shm_free(struct kern_ipc_perm
*shp
)
1379 static inline int security_shm_associate(struct kern_ipc_perm
*shp
,
1385 static inline int security_shm_shmctl(struct kern_ipc_perm
*shp
, int cmd
)
1390 static inline int security_shm_shmat(struct kern_ipc_perm
*shp
,
1391 char __user
*shmaddr
, int shmflg
)
1396 static inline int security_sem_alloc(struct kern_ipc_perm
*sma
)
1401 static inline void security_sem_free(struct kern_ipc_perm
*sma
)
1404 static inline int security_sem_associate(struct kern_ipc_perm
*sma
, int semflg
)
1409 static inline int security_sem_semctl(struct kern_ipc_perm
*sma
, int cmd
)
1414 static inline int security_sem_semop(struct kern_ipc_perm
*sma
,
1415 struct sembuf
*sops
, unsigned nsops
,
1421 static inline void security_d_instantiate(struct dentry
*dentry
,
1422 struct inode
*inode
)
1425 static inline int security_getprocattr(struct task_struct
*p
, const char *lsm
,
1426 char *name
, char **value
)
1431 static inline int security_setprocattr(const char *lsm
, char *name
,
1432 void *value
, size_t size
)
1437 static inline int security_netlink_send(struct sock
*sk
, struct sk_buff
*skb
)
1442 static inline int security_ismaclabel(const char *name
)
1447 static inline int security_secid_to_secctx(struct lsmblob
*blob
,
1448 struct lsmcontext
*cp
, int display
)
1453 static inline int security_secctx_to_secid(const char *secdata
,
1455 struct lsmblob
*blob
)
1460 static inline void security_release_secctx(struct lsmcontext
*cp
)
1464 static inline void security_inode_invalidate_secctx(struct inode
*inode
)
1468 static inline int security_inode_notifysecctx(struct inode
*inode
, void *ctx
, u32 ctxlen
)
1472 static inline int security_inode_setsecctx(struct dentry
*dentry
, void *ctx
, u32 ctxlen
)
1476 static inline int security_inode_getsecctx(struct inode
*inode
,
1477 struct lsmcontext
*cp
)
1481 static inline int security_locked_down(enum lockdown_reason what
)
1485 static inline int security_lock_kernel_down(const char *where
, enum lockdown_reason level
)
1489 #endif /* CONFIG_SECURITY */
1491 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1492 int security_post_notification(const struct cred
*w_cred
,
1493 const struct cred
*cred
,
1494 struct watch_notification
*n
);
1496 static inline int security_post_notification(const struct cred
*w_cred
,
1497 const struct cred
*cred
,
1498 struct watch_notification
*n
)
1504 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1505 int security_watch_key(struct key
*key
);
1507 static inline int security_watch_key(struct key
*key
)
1513 #ifdef CONFIG_SECURITY_NETWORK
1515 int security_unix_stream_connect(struct sock
*sock
, struct sock
*other
, struct sock
*newsk
);
1516 int security_unix_may_send(struct socket
*sock
, struct socket
*other
);
1517 int security_socket_create(int family
, int type
, int protocol
, int kern
);
1518 int security_socket_post_create(struct socket
*sock
, int family
,
1519 int type
, int protocol
, int kern
);
1520 int security_socket_socketpair(struct socket
*socka
, struct socket
*sockb
);
1521 int security_socket_bind(struct socket
*sock
, struct sockaddr
*address
, int addrlen
);
1522 int security_socket_connect(struct socket
*sock
, struct sockaddr
*address
, int addrlen
);
1523 int security_socket_listen(struct socket
*sock
, int backlog
);
1524 int security_socket_accept(struct socket
*sock
, struct socket
*newsock
);
1525 int security_socket_sendmsg(struct socket
*sock
, struct msghdr
*msg
, int size
);
1526 int security_socket_recvmsg(struct socket
*sock
, struct msghdr
*msg
,
1527 int size
, int flags
);
1528 int security_socket_getsockname(struct socket
*sock
);
1529 int security_socket_getpeername(struct socket
*sock
);
1530 int security_socket_getsockopt(struct socket
*sock
, int level
, int optname
);
1531 int security_socket_setsockopt(struct socket
*sock
, int level
, int optname
);
1532 int security_socket_shutdown(struct socket
*sock
, int how
);
1533 int security_sock_rcv_skb(struct sock
*sk
, struct sk_buff
*skb
);
1534 int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
1535 int __user
*optlen
, unsigned len
);
1536 int security_socket_getpeersec_dgram(struct socket
*sock
, struct sk_buff
*skb
,
1537 struct lsmblob
*blob
);
1538 int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
);
1539 void security_sk_free(struct sock
*sk
);
1540 void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
);
1541 void security_sk_classify_flow(struct sock
*sk
, struct flowi_common
*flic
);
1542 void security_req_classify_flow(const struct request_sock
*req
,
1543 struct flowi_common
*flic
);
1544 void security_sock_graft(struct sock
*sk
, struct socket
*parent
);
1545 int security_inet_conn_request(const struct sock
*sk
,
1546 struct sk_buff
*skb
, struct request_sock
*req
);
1547 void security_inet_csk_clone(struct sock
*newsk
,
1548 const struct request_sock
*req
);
1549 void security_inet_conn_established(struct sock
*sk
,
1550 struct sk_buff
*skb
);
1551 int security_secmark_relabel_packet(struct lsmblob
*blob
);
1552 void security_secmark_refcount_inc(void);
1553 void security_secmark_refcount_dec(void);
1554 int security_tun_dev_alloc_security(void **security
);
1555 void security_tun_dev_free_security(void *security
);
1556 int security_tun_dev_create(void);
1557 int security_tun_dev_attach_queue(void *security
);
1558 int security_tun_dev_attach(struct sock
*sk
, void *security
);
1559 int security_tun_dev_open(void *security
);
1560 int security_sctp_assoc_request(struct sctp_endpoint
*ep
, struct sk_buff
*skb
);
1561 int security_sctp_bind_connect(struct sock
*sk
, int optname
,
1562 struct sockaddr
*address
, int addrlen
);
1563 void security_sctp_sk_clone(struct sctp_endpoint
*ep
, struct sock
*sk
,
1564 struct sock
*newsk
);
1566 #else /* CONFIG_SECURITY_NETWORK */
1567 static inline int security_unix_stream_connect(struct sock
*sock
,
1574 static inline int security_unix_may_send(struct socket
*sock
,
1575 struct socket
*other
)
1580 static inline int security_socket_create(int family
, int type
,
1581 int protocol
, int kern
)
1586 static inline int security_socket_post_create(struct socket
*sock
,
1589 int protocol
, int kern
)
1594 static inline int security_socket_socketpair(struct socket
*socka
,
1595 struct socket
*sockb
)
1600 static inline int security_socket_bind(struct socket
*sock
,
1601 struct sockaddr
*address
,
1607 static inline int security_socket_connect(struct socket
*sock
,
1608 struct sockaddr
*address
,
1614 static inline int security_socket_listen(struct socket
*sock
, int backlog
)
1619 static inline int security_socket_accept(struct socket
*sock
,
1620 struct socket
*newsock
)
1625 static inline int security_socket_sendmsg(struct socket
*sock
,
1626 struct msghdr
*msg
, int size
)
1631 static inline int security_socket_recvmsg(struct socket
*sock
,
1632 struct msghdr
*msg
, int size
,
1638 static inline int security_socket_getsockname(struct socket
*sock
)
1643 static inline int security_socket_getpeername(struct socket
*sock
)
1648 static inline int security_socket_getsockopt(struct socket
*sock
,
1649 int level
, int optname
)
1654 static inline int security_socket_setsockopt(struct socket
*sock
,
1655 int level
, int optname
)
1660 static inline int security_socket_shutdown(struct socket
*sock
, int how
)
1664 static inline int security_sock_rcv_skb(struct sock
*sk
,
1665 struct sk_buff
*skb
)
1670 static inline int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
1671 int __user
*optlen
, unsigned len
)
1673 return -ENOPROTOOPT
;
1676 static inline int security_socket_getpeersec_dgram(struct socket
*sock
,
1677 struct sk_buff
*skb
,
1678 struct lsmblob
*blob
)
1680 return -ENOPROTOOPT
;
1683 static inline int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
1688 static inline void security_sk_free(struct sock
*sk
)
1692 static inline void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
)
1696 static inline void security_sk_classify_flow(struct sock
*sk
,
1697 struct flowi_common
*flic
)
1701 static inline void security_req_classify_flow(const struct request_sock
*req
,
1702 struct flowi_common
*flic
)
1706 static inline void security_sock_graft(struct sock
*sk
, struct socket
*parent
)
1710 static inline int security_inet_conn_request(const struct sock
*sk
,
1711 struct sk_buff
*skb
, struct request_sock
*req
)
1716 static inline void security_inet_csk_clone(struct sock
*newsk
,
1717 const struct request_sock
*req
)
1721 static inline void security_inet_conn_established(struct sock
*sk
,
1722 struct sk_buff
*skb
)
1726 static inline int security_secmark_relabel_packet(struct lsmblob
*blob
)
1731 static inline void security_secmark_refcount_inc(void)
1735 static inline void security_secmark_refcount_dec(void)
1739 static inline int security_tun_dev_alloc_security(void **security
)
1744 static inline void security_tun_dev_free_security(void *security
)
1748 static inline int security_tun_dev_create(void)
1753 static inline int security_tun_dev_attach_queue(void *security
)
1758 static inline int security_tun_dev_attach(struct sock
*sk
, void *security
)
1763 static inline int security_tun_dev_open(void *security
)
1768 static inline int security_sctp_assoc_request(struct sctp_endpoint
*ep
,
1769 struct sk_buff
*skb
)
1774 static inline int security_sctp_bind_connect(struct sock
*sk
, int optname
,
1775 struct sockaddr
*address
,
1781 static inline void security_sctp_sk_clone(struct sctp_endpoint
*ep
,
1786 #endif /* CONFIG_SECURITY_NETWORK */
1788 #ifdef CONFIG_SECURITY_INFINIBAND
1789 int security_ib_pkey_access(void *sec
, u64 subnet_prefix
, u16 pkey
);
1790 int security_ib_endport_manage_subnet(void *sec
, const char *name
, u8 port_num
);
1791 int security_ib_alloc_security(void **sec
);
1792 void security_ib_free_security(void *sec
);
1793 #else /* CONFIG_SECURITY_INFINIBAND */
1794 static inline int security_ib_pkey_access(void *sec
, u64 subnet_prefix
, u16 pkey
)
1799 static inline int security_ib_endport_manage_subnet(void *sec
, const char *dev_name
, u8 port_num
)
1804 static inline int security_ib_alloc_security(void **sec
)
1809 static inline void security_ib_free_security(void *sec
)
1812 #endif /* CONFIG_SECURITY_INFINIBAND */
1814 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1816 int security_xfrm_policy_alloc(struct xfrm_sec_ctx
**ctxp
,
1817 struct xfrm_user_sec_ctx
*sec_ctx
, gfp_t gfp
);
1818 int security_xfrm_policy_clone(struct xfrm_sec_ctx
*old_ctx
, struct xfrm_sec_ctx
**new_ctxp
);
1819 void security_xfrm_policy_free(struct xfrm_sec_ctx
*ctx
);
1820 int security_xfrm_policy_delete(struct xfrm_sec_ctx
*ctx
);
1821 int security_xfrm_state_alloc(struct xfrm_state
*x
, struct xfrm_user_sec_ctx
*sec_ctx
);
1822 int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
1823 struct xfrm_sec_ctx
*polsec
, u32 secid
);
1824 int security_xfrm_state_delete(struct xfrm_state
*x
);
1825 void security_xfrm_state_free(struct xfrm_state
*x
);
1826 int security_xfrm_policy_lookup(struct xfrm_sec_ctx
*ctx
, u32 fl_secid
);
1827 int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
1828 struct xfrm_policy
*xp
,
1829 const struct flowi_common
*flic
);
1830 int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
);
1831 void security_skb_classify_flow(struct sk_buff
*skb
, struct flowi_common
*flic
);
1833 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1835 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx
**ctxp
,
1836 struct xfrm_user_sec_ctx
*sec_ctx
,
1842 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx
*old
, struct xfrm_sec_ctx
**new_ctxp
)
1847 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx
*ctx
)
1851 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx
*ctx
)
1856 static inline int security_xfrm_state_alloc(struct xfrm_state
*x
,
1857 struct xfrm_user_sec_ctx
*sec_ctx
)
1862 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
1863 struct xfrm_sec_ctx
*polsec
, u32 secid
)
1868 static inline void security_xfrm_state_free(struct xfrm_state
*x
)
1872 static inline int security_xfrm_state_delete(struct xfrm_state
*x
)
1877 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx
*ctx
, u32 fl_secid
)
1882 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
1883 struct xfrm_policy
*xp
,
1884 const struct flowi_common
*flic
)
1889 static inline int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
)
1894 static inline void security_skb_classify_flow(struct sk_buff
*skb
,
1895 struct flowi_common
*flic
)
1899 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1901 #ifdef CONFIG_SECURITY_PATH
1902 int security_path_unlink(const struct path
*dir
, struct dentry
*dentry
);
1903 int security_path_mkdir(const struct path
*dir
, struct dentry
*dentry
, umode_t mode
);
1904 int security_path_rmdir(const struct path
*dir
, struct dentry
*dentry
);
1905 int security_path_mknod(const struct path
*dir
, struct dentry
*dentry
, umode_t mode
,
1907 int security_path_truncate(const struct path
*path
);
1908 int security_path_symlink(const struct path
*dir
, struct dentry
*dentry
,
1909 const char *old_name
);
1910 int security_path_link(struct dentry
*old_dentry
, const struct path
*new_dir
,
1911 struct dentry
*new_dentry
);
1912 int security_path_rename(const struct path
*old_dir
, struct dentry
*old_dentry
,
1913 const struct path
*new_dir
, struct dentry
*new_dentry
,
1914 unsigned int flags
);
1915 int security_path_chmod(const struct path
*path
, umode_t mode
);
1916 int security_path_chown(const struct path
*path
, kuid_t uid
, kgid_t gid
);
1917 int security_path_chroot(const struct path
*path
);
1918 #else /* CONFIG_SECURITY_PATH */
1919 static inline int security_path_unlink(const struct path
*dir
, struct dentry
*dentry
)
1924 static inline int security_path_mkdir(const struct path
*dir
, struct dentry
*dentry
,
1930 static inline int security_path_rmdir(const struct path
*dir
, struct dentry
*dentry
)
1935 static inline int security_path_mknod(const struct path
*dir
, struct dentry
*dentry
,
1936 umode_t mode
, unsigned int dev
)
1941 static inline int security_path_truncate(const struct path
*path
)
1946 static inline int security_path_symlink(const struct path
*dir
, struct dentry
*dentry
,
1947 const char *old_name
)
1952 static inline int security_path_link(struct dentry
*old_dentry
,
1953 const struct path
*new_dir
,
1954 struct dentry
*new_dentry
)
1959 static inline int security_path_rename(const struct path
*old_dir
,
1960 struct dentry
*old_dentry
,
1961 const struct path
*new_dir
,
1962 struct dentry
*new_dentry
,
1968 static inline int security_path_chmod(const struct path
*path
, umode_t mode
)
1973 static inline int security_path_chown(const struct path
*path
, kuid_t uid
, kgid_t gid
)
1978 static inline int security_path_chroot(const struct path
*path
)
1982 #endif /* CONFIG_SECURITY_PATH */
1985 #ifdef CONFIG_SECURITY
1987 int security_key_alloc(struct key
*key
, const struct cred
*cred
, unsigned long flags
);
1988 void security_key_free(struct key
*key
);
1989 int security_key_permission(key_ref_t key_ref
, const struct cred
*cred
,
1990 enum key_need_perm need_perm
);
1991 int security_key_getsecurity(struct key
*key
, char **_buffer
);
1995 static inline int security_key_alloc(struct key
*key
,
1996 const struct cred
*cred
,
1997 unsigned long flags
)
2002 static inline void security_key_free(struct key
*key
)
2006 static inline int security_key_permission(key_ref_t key_ref
,
2007 const struct cred
*cred
,
2008 enum key_need_perm need_perm
)
2013 static inline int security_key_getsecurity(struct key
*key
, char **_buffer
)
2020 #endif /* CONFIG_KEYS */
2023 #ifdef CONFIG_SECURITY
2024 int security_audit_rule_init(u32 field
, u32 op
, char *rulestr
, void **lsmrule
);
2025 int security_audit_rule_known(struct audit_krule
*krule
);
2026 int security_audit_rule_match(struct lsmblob
*blob
, u32 field
, u32 op
,
2028 void security_audit_rule_free(void **lsmrule
);
2032 static inline int security_audit_rule_init(u32 field
, u32 op
, char *rulestr
,
2038 static inline int security_audit_rule_known(struct audit_krule
*krule
)
2043 static inline int security_audit_rule_match(struct lsmblob
*blob
, u32 field
,
2044 u32 op
, void **lsmrule
)
2049 static inline void security_audit_rule_free(void **lsmrule
)
2052 #endif /* CONFIG_SECURITY */
2053 #endif /* CONFIG_AUDIT */
2055 #ifdef CONFIG_SECURITYFS
2057 extern struct dentry
*securityfs_create_file(const char *name
, umode_t mode
,
2058 struct dentry
*parent
, void *data
,
2059 const struct file_operations
*fops
);
2060 extern struct dentry
*securityfs_create_dir(const char *name
, struct dentry
*parent
);
2061 struct dentry
*securityfs_create_symlink(const char *name
,
2062 struct dentry
*parent
,
2064 const struct inode_operations
*iops
);
2065 extern void securityfs_remove(struct dentry
*dentry
);
2067 #else /* CONFIG_SECURITYFS */
2069 static inline struct dentry
*securityfs_create_dir(const char *name
,
2070 struct dentry
*parent
)
2072 return ERR_PTR(-ENODEV
);
2075 static inline struct dentry
*securityfs_create_file(const char *name
,
2077 struct dentry
*parent
,
2079 const struct file_operations
*fops
)
2081 return ERR_PTR(-ENODEV
);
2084 static inline struct dentry
*securityfs_create_symlink(const char *name
,
2085 struct dentry
*parent
,
2087 const struct inode_operations
*iops
)
2089 return ERR_PTR(-ENODEV
);
2092 static inline void securityfs_remove(struct dentry
*dentry
)
2097 #ifdef CONFIG_BPF_SYSCALL
2101 struct bpf_prog_aux
;
2102 #ifdef CONFIG_SECURITY
2103 extern int security_bpf(int cmd
, union bpf_attr
*attr
, unsigned int size
);
2104 extern int security_bpf_map(struct bpf_map
*map
, fmode_t fmode
);
2105 extern int security_bpf_prog(struct bpf_prog
*prog
);
2106 extern int security_bpf_map_alloc(struct bpf_map
*map
);
2107 extern void security_bpf_map_free(struct bpf_map
*map
);
2108 extern int security_bpf_prog_alloc(struct bpf_prog_aux
*aux
);
2109 extern void security_bpf_prog_free(struct bpf_prog_aux
*aux
);
2111 static inline int security_bpf(int cmd
, union bpf_attr
*attr
,
2117 static inline int security_bpf_map(struct bpf_map
*map
, fmode_t fmode
)
2122 static inline int security_bpf_prog(struct bpf_prog
*prog
)
2127 static inline int security_bpf_map_alloc(struct bpf_map
*map
)
2132 static inline void security_bpf_map_free(struct bpf_map
*map
)
2135 static inline int security_bpf_prog_alloc(struct bpf_prog_aux
*aux
)
2140 static inline void security_bpf_prog_free(struct bpf_prog_aux
*aux
)
2142 #endif /* CONFIG_SECURITY */
2143 #endif /* CONFIG_BPF_SYSCALL */
2145 #ifdef CONFIG_PERF_EVENTS
2146 struct perf_event_attr
;
2149 #ifdef CONFIG_SECURITY
2150 extern int security_perf_event_open(struct perf_event_attr
*attr
, int type
);
2151 extern int security_perf_event_alloc(struct perf_event
*event
);
2152 extern void security_perf_event_free(struct perf_event
*event
);
2153 extern int security_perf_event_read(struct perf_event
*event
);
2154 extern int security_perf_event_write(struct perf_event
*event
);
2156 static inline int security_perf_event_open(struct perf_event_attr
*attr
,
2162 static inline int security_perf_event_alloc(struct perf_event
*event
)
2167 static inline void security_perf_event_free(struct perf_event
*event
)
2171 static inline int security_perf_event_read(struct perf_event
*event
)
2176 static inline int security_perf_event_write(struct perf_event
*event
)
2180 #endif /* CONFIG_SECURITY */
2181 #endif /* CONFIG_PERF_EVENTS */
2183 #endif /* ! __LINUX_SECURITY_H */