#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/keyctl.h>
#include <linux/key-type.h>
#include <uapi/linux/posix_acl.h>
#include <linux/posix_acl.h>
#include <linux/posix_acl_xattr.h>
#include <keys/user-type.h>
#include "cifspdu.h"
#include "cifsglob.h"
#include "cifsacl.h"
#include "cifsproto.h"
#include "cifs_debug.h"
#include "fs_context.h"
#include "cifs_fs_sb.h"
#include "cifs_unicode.h"
static const struct cifs_sid sid_everyone = …;
static const struct cifs_sid sid_authusers = …;
static const struct cifs_sid sid_unix_users = …;
static const struct cifs_sid sid_unix_groups = …;
static const struct cifs_sid sid_unix_NFS_users = …;
static const struct cifs_sid sid_unix_NFS_groups = …;
static const struct cifs_sid sid_unix_NFS_mode = …;
static const struct cred *root_cred;
static int
cifs_idmap_key_instantiate(struct key *key, struct key_preparsed_payload *prep)
{ … }
static inline void
cifs_idmap_key_destroy(struct key *key)
{ … }
static struct key_type cifs_idmap_key_type = …;
static char *
sid_to_key_str(struct cifs_sid *sidptr, unsigned int type)
{ … }
static int
compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
{ … }
static bool
is_well_known_sid(const struct cifs_sid *psid, uint32_t *puid, bool is_group)
{ … }
static __u16
cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src)
{ … }
static int
id_to_sid(unsigned int cid, uint sidtype, struct cifs_sid *ssid)
{ … }
int
sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
struct cifs_fattr *fattr, uint sidtype)
{ … }
int
init_cifs_idmap(void)
{ … }
void
exit_cifs_idmap(void)
{ … }
static __u32 copy_sec_desc(const struct cifs_ntsd *pntsd,
struct cifs_ntsd *pnntsd,
__u32 sidsoffset,
struct cifs_sid *pownersid,
struct cifs_sid *pgrpsid)
{ … }
static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
umode_t *pdenied, umode_t mask)
{ … }
static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,
__u32 *pace_flags)
{ … }
static __u16 cifs_copy_ace(struct cifs_ace *dst, struct cifs_ace *src, struct cifs_sid *psid)
{ … }
static __u16 fill_ace_for_sid(struct cifs_ace *pntace,
const struct cifs_sid *psid, __u64 nmode,
umode_t bits, __u8 access_type,
bool allow_delete_child)
{ … }
#ifdef CONFIG_CIFS_DEBUG2
static void dump_ace(struct cifs_ace *pace, char *end_of_acl)
{ … }
#endif
static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
struct cifs_sid *pownersid, struct cifs_sid *pgrpsid,
struct cifs_fattr *fattr, bool mode_from_special_sid)
{ … }
unsigned int setup_authusers_ACE(struct cifs_ace *pntace)
{ … }
unsigned int setup_special_mode_ACE(struct cifs_ace *pntace, __u64 nmode)
{ … }
unsigned int setup_special_user_owner_ACE(struct cifs_ace *pntace)
{ … }
static void populate_new_aces(char *nacl_base,
struct cifs_sid *pownersid,
struct cifs_sid *pgrpsid,
__u64 *pnmode, u32 *pnum_aces, u16 *pnsize,
bool modefromsid)
{ … }
static __u16 replace_sids_and_copy_aces(struct cifs_acl *pdacl, struct cifs_acl *pndacl,
struct cifs_sid *pownersid, struct cifs_sid *pgrpsid,
struct cifs_sid *pnownersid, struct cifs_sid *pngrpsid)
{ … }
static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl,
struct cifs_sid *pownersid, struct cifs_sid *pgrpsid,
__u64 *pnmode, bool mode_from_sid)
{ … }
static int parse_sid(struct cifs_sid *psid, char *end_of_acl)
{ … }
static int parse_sec_desc(struct cifs_sb_info *cifs_sb,
struct cifs_ntsd *pntsd, int acl_len, struct cifs_fattr *fattr,
bool get_mode_from_special_sid)
{ … }
static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
__u32 secdesclen, __u32 *pnsecdesclen, __u64 *pnmode, kuid_t uid, kgid_t gid,
bool mode_from_sid, bool id_from_sid, int *aclflag)
{ … }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
const struct cifs_fid *cifsfid, u32 *pacllen,
u32 __maybe_unused unused)
{ … }
static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
const char *path, u32 *pacllen)
{ … }
struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
struct inode *inode, const char *path,
u32 *pacllen, u32 info)
{ … }
int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
struct inode *inode, const char *path, int aclflag)
{ … }
#endif
int
cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
struct inode *inode, bool mode_from_special_sid,
const char *path, const struct cifs_fid *pfid)
{ … }
int
id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
kuid_t uid, kgid_t gid)
{ … }
struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
struct dentry *dentry, int type)
{ … }
int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{ … }