Skip to content

Commit 71342db

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
NFSv4.1: Enable access to the NFSv4.1 'dacl' and 'sacl' attributes
Enable access to the NFSv4 acl via the NFSv4.1 'dacl' and 'sacl' attributes. This allows the server to authenticate the DACL and the SACL operations separately, since reading and/or editing the SACL is usually considered to be a privileged operation. It also allows the propagation of automatic inheritance information that was not supported by the NFSv4.0 'acl' attribute. Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent db145db commit 71342db

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

fs/nfs/nfs4proc.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7698,6 +7698,55 @@ static bool nfs4_xattr_list_nfs4_acl(struct dentry *dentry)
76987698
return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_ACL);
76997699
}
77007700

7701+
#if defined(CONFIG_NFS_V4_1)
7702+
#define XATTR_NAME_NFSV4_DACL "system.nfs4_dacl"
7703+
7704+
static int nfs4_xattr_set_nfs4_dacl(const struct xattr_handler *handler,
7705+
struct user_namespace *mnt_userns,
7706+
struct dentry *unused, struct inode *inode,
7707+
const char *key, const void *buf,
7708+
size_t buflen, int flags)
7709+
{
7710+
return nfs4_proc_set_acl(inode, buf, buflen, NFS4ACL_DACL);
7711+
}
7712+
7713+
static int nfs4_xattr_get_nfs4_dacl(const struct xattr_handler *handler,
7714+
struct dentry *unused, struct inode *inode,
7715+
const char *key, void *buf, size_t buflen)
7716+
{
7717+
return nfs4_proc_get_acl(inode, buf, buflen, NFS4ACL_DACL);
7718+
}
7719+
7720+
static bool nfs4_xattr_list_nfs4_dacl(struct dentry *dentry)
7721+
{
7722+
return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_DACL);
7723+
}
7724+
7725+
#define XATTR_NAME_NFSV4_SACL "system.nfs4_sacl"
7726+
7727+
static int nfs4_xattr_set_nfs4_sacl(const struct xattr_handler *handler,
7728+
struct user_namespace *mnt_userns,
7729+
struct dentry *unused, struct inode *inode,
7730+
const char *key, const void *buf,
7731+
size_t buflen, int flags)
7732+
{
7733+
return nfs4_proc_set_acl(inode, buf, buflen, NFS4ACL_SACL);
7734+
}
7735+
7736+
static int nfs4_xattr_get_nfs4_sacl(const struct xattr_handler *handler,
7737+
struct dentry *unused, struct inode *inode,
7738+
const char *key, void *buf, size_t buflen)
7739+
{
7740+
return nfs4_proc_get_acl(inode, buf, buflen, NFS4ACL_SACL);
7741+
}
7742+
7743+
static bool nfs4_xattr_list_nfs4_sacl(struct dentry *dentry)
7744+
{
7745+
return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_SACL);
7746+
}
7747+
7748+
#endif
7749+
77017750
#ifdef CONFIG_NFS_V4_SECURITY_LABEL
77027751

77037752
static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler,
@@ -10615,6 +10664,22 @@ static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
1061510664
.set = nfs4_xattr_set_nfs4_acl,
1061610665
};
1061710666

10667+
#if defined(CONFIG_NFS_V4_1)
10668+
static const struct xattr_handler nfs4_xattr_nfs4_dacl_handler = {
10669+
.name = XATTR_NAME_NFSV4_DACL,
10670+
.list = nfs4_xattr_list_nfs4_dacl,
10671+
.get = nfs4_xattr_get_nfs4_dacl,
10672+
.set = nfs4_xattr_set_nfs4_dacl,
10673+
};
10674+
10675+
static const struct xattr_handler nfs4_xattr_nfs4_sacl_handler = {
10676+
.name = XATTR_NAME_NFSV4_SACL,
10677+
.list = nfs4_xattr_list_nfs4_sacl,
10678+
.get = nfs4_xattr_get_nfs4_sacl,
10679+
.set = nfs4_xattr_set_nfs4_sacl,
10680+
};
10681+
#endif
10682+
1061810683
#ifdef CONFIG_NFS_V4_2
1061910684
static const struct xattr_handler nfs4_xattr_nfs4_user_handler = {
1062010685
.prefix = XATTR_USER_PREFIX,
@@ -10625,6 +10690,10 @@ static const struct xattr_handler nfs4_xattr_nfs4_user_handler = {
1062510690

1062610691
const struct xattr_handler *nfs4_xattr_handlers[] = {
1062710692
&nfs4_xattr_nfs4_acl_handler,
10693+
#if defined(CONFIG_NFS_V4_1)
10694+
&nfs4_xattr_nfs4_dacl_handler,
10695+
&nfs4_xattr_nfs4_sacl_handler,
10696+
#endif
1062810697
#ifdef CONFIG_NFS_V4_SECURITY_LABEL
1062910698
&nfs4_xattr_nfs4_label_handler,
1063010699
#endif

0 commit comments

Comments
 (0)