#ifndef _LINUX_CAPABILITY_H
#define _LINUX_CAPABILITY_H
#include <uapi/linux/capability.h>
#include <linux/uidgid.h>
#include <linux/bits.h>
#define _KERNEL_CAPABILITY_VERSION …
extern int file_caps_enabled;
kernel_cap_t;
struct cpu_vfs_cap_data { … };
#define _USER_CAP_HEADER_SIZE …
#define _KERNEL_CAP_T_SIZE …
struct file;
struct inode;
struct dentry;
struct task_struct;
struct user_namespace;
struct mnt_idmap;
#define CAP_FS_MASK …
#define CAP_VALID_MASK …
#define CAP_EMPTY_SET …
#define CAP_FULL_SET …
#define CAP_FS_SET …
#define CAP_NFSD_SET …
#define cap_clear(c) …
#define cap_raise(c, flag) …
#define cap_lower(c, flag) …
#define cap_raised(c, flag) …
static inline kernel_cap_t cap_combine(const kernel_cap_t a,
const kernel_cap_t b)
{ … }
static inline kernel_cap_t cap_intersect(const kernel_cap_t a,
const kernel_cap_t b)
{ … }
static inline kernel_cap_t cap_drop(const kernel_cap_t a,
const kernel_cap_t drop)
{ … }
static inline bool cap_isclear(const kernel_cap_t a)
{ … }
static inline bool cap_isidentical(const kernel_cap_t a, const kernel_cap_t b)
{ … }
static inline bool cap_issubset(const kernel_cap_t a, const kernel_cap_t set)
{ … }
static inline kernel_cap_t cap_drop_fs_set(const kernel_cap_t a)
{ … }
static inline kernel_cap_t cap_raise_fs_set(const kernel_cap_t a,
const kernel_cap_t permitted)
{ … }
static inline kernel_cap_t cap_drop_nfsd_set(const kernel_cap_t a)
{ … }
static inline kernel_cap_t cap_raise_nfsd_set(const kernel_cap_t a,
const kernel_cap_t permitted)
{ … }
#ifdef CONFIG_MULTIUSER
extern bool has_capability(struct task_struct *t, int cap);
extern bool has_ns_capability(struct task_struct *t,
struct user_namespace *ns, int cap);
extern bool has_capability_noaudit(struct task_struct *t, int cap);
extern bool has_ns_capability_noaudit(struct task_struct *t,
struct user_namespace *ns, int cap);
extern bool capable(int cap);
extern bool ns_capable(struct user_namespace *ns, int cap);
extern bool ns_capable_noaudit(struct user_namespace *ns, int cap);
extern bool ns_capable_setid(struct user_namespace *ns, int cap);
#else
static inline bool has_capability(struct task_struct *t, int cap)
{
return true;
}
static inline bool has_ns_capability(struct task_struct *t,
struct user_namespace *ns, int cap)
{
return true;
}
static inline bool has_capability_noaudit(struct task_struct *t, int cap)
{
return true;
}
static inline bool has_ns_capability_noaudit(struct task_struct *t,
struct user_namespace *ns, int cap)
{
return true;
}
static inline bool capable(int cap)
{
return true;
}
static inline bool ns_capable(struct user_namespace *ns, int cap)
{
return true;
}
static inline bool ns_capable_noaudit(struct user_namespace *ns, int cap)
{
return true;
}
static inline bool ns_capable_setid(struct user_namespace *ns, int cap)
{
return true;
}
#endif
bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
struct mnt_idmap *idmap,
const struct inode *inode);
bool capable_wrt_inode_uidgid(struct mnt_idmap *idmap,
const struct inode *inode, int cap);
extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
extern bool ptracer_capable(struct task_struct *tsk, struct user_namespace *ns);
static inline bool perfmon_capable(void)
{ … }
static inline bool bpf_capable(void)
{ … }
static inline bool checkpoint_restore_ns_capable(struct user_namespace *ns)
{ … }
int get_vfs_caps_from_disk(struct mnt_idmap *idmap,
const struct dentry *dentry,
struct cpu_vfs_cap_data *cpu_caps);
int cap_convert_nscap(struct mnt_idmap *idmap, struct dentry *dentry,
const void **ivalue, size_t size);
#endif