Skip to content

Commit e782ef7

Browse files
Venkateswararao Jujjuri (JV)ericvh
authored andcommitted
[fs/9P] Add posixacl mount option
The mount option access=client is overloaded as it assumes acl too. Adding posixacl option to enable POSIX ACLs makes it explicit and clear. Also it is convenient in the future to add other types of acls like richacls. Ideally, the access mode 'client' should be just like V9FS_ACCESS_USER except it underscores the location of access check. Traditional 9P protocol lets the server perform access checks but with this mode, all the access checks will be performed on the client itself. Server just follows the client's directive. Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
1 parent 9332685 commit e782ef7

4 files changed

Lines changed: 31 additions & 12 deletions

File tree

‎fs/9p/acl.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ int v9fs_get_acl(struct inode *inode, struct p9_fid *fid)
5959
struct v9fs_session_info *v9ses;
6060

6161
v9ses = v9fs_inode2v9ses(inode);
62-
if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) {
62+
if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) ||
63+
((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) {
6364
set_cached_acl(inode, ACL_TYPE_DEFAULT, NULL);
6465
set_cached_acl(inode, ACL_TYPE_ACCESS, NULL);
6566
return 0;
@@ -104,9 +105,10 @@ int v9fs_check_acl(struct inode *inode, int mask, unsigned int flags)
104105
return -ECHILD;
105106

106107
v9ses = v9fs_inode2v9ses(inode);
107-
if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) {
108+
if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) ||
109+
((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) {
108110
/*
109-
* On access = client mode get the acl
111+
* On access = client and acl = on mode get the acl
110112
* values from the server
111113
*/
112114
return 0;

‎fs/9p/v9fs.c‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ enum {
5555
/* Cache options */
5656
Opt_cache_loose, Opt_fscache,
5757
/* Access options */
58-
Opt_access,
58+
Opt_access, Opt_posixacl,
5959
/* Error token */
6060
Opt_err
6161
};
@@ -73,6 +73,7 @@ static const match_table_t tokens = {
7373
{Opt_fscache, "fscache"},
7474
{Opt_cachetag, "cachetag=%s"},
7575
{Opt_access, "access=%s"},
76+
{Opt_posixacl, "posixacl"},
7677
{Opt_err, NULL}
7778
};
7879

@@ -194,13 +195,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
194195
else if (strcmp(s, "any") == 0)
195196
v9ses->flags |= V9FS_ACCESS_ANY;
196197
else if (strcmp(s, "client") == 0) {
197-
#ifdef CONFIG_9P_FS_POSIX_ACL
198198
v9ses->flags |= V9FS_ACCESS_CLIENT;
199-
#else
200-
P9_DPRINTK(P9_DEBUG_ERROR,
201-
"Not defined CONFIG_9P_FS_POSIX_ACL. "
202-
"Ignoring access=client option\n");
203-
#endif
204199
} else {
205200
v9ses->flags |= V9FS_ACCESS_SINGLE;
206201
v9ses->uid = simple_strtoul(s, &e, 10);
@@ -210,6 +205,16 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
210205
kfree(s);
211206
break;
212207

208+
case Opt_posixacl:
209+
#ifdef CONFIG_9P_FS_POSIX_ACL
210+
v9ses->flags |= V9FS_POSIX_ACL;
211+
#else
212+
P9_DPRINTK(P9_DEBUG_ERROR,
213+
"Not defined CONFIG_9P_FS_POSIX_ACL. "
214+
"Ignoring posixacl option\n");
215+
#endif
216+
break;
217+
213218
default:
214219
continue;
215220
}
@@ -304,6 +309,14 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
304309
v9ses->flags |= V9FS_ACCESS_ANY;
305310
v9ses->uid = ~0;
306311
}
312+
if (!v9fs_proto_dotl(v9ses) ||
313+
!((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)) {
314+
/*
315+
* We support ACL checks on clinet only if the protocol is
316+
* 9P2000.L and access is V9FS_ACCESS_CLIENT.
317+
*/
318+
v9ses->flags &= ~V9FS_ACL_MASK;
319+
}
307320

308321
fid = p9_client_attach(v9ses->clnt, NULL, v9ses->uname, ~0,
309322
v9ses->aname);

‎fs/9p/v9fs.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,26 @@
2828
* @V9FS_PROTO_2000L: whether or not to use 9P2000.l extensions
2929
* @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy
3030
* @V9FS_ACCESS_USER: a new attach will be issued for every user (default)
31+
* @V9FS_ACCESS_CLIENT: Just like user, but access check is performed on client.
3132
* @V9FS_ACCESS_ANY: use a single attach for all users
3233
* @V9FS_ACCESS_MASK: bit mask of different ACCESS options
34+
* @V9FS_POSIX_ACL: POSIX ACLs are enforced
3335
*
3436
* Session flags reflect options selected by users at mount time
3537
*/
3638
#define V9FS_ACCESS_ANY (V9FS_ACCESS_SINGLE | \
3739
V9FS_ACCESS_USER | \
3840
V9FS_ACCESS_CLIENT)
3941
#define V9FS_ACCESS_MASK V9FS_ACCESS_ANY
42+
#define V9FS_ACL_MASK V9FS_POSIX_ACL
4043

4144
enum p9_session_flags {
4245
V9FS_PROTO_2000U = 0x01,
4346
V9FS_PROTO_2000L = 0x02,
4447
V9FS_ACCESS_SINGLE = 0x04,
4548
V9FS_ACCESS_USER = 0x08,
46-
V9FS_ACCESS_CLIENT = 0x10
49+
V9FS_ACCESS_CLIENT = 0x10,
50+
V9FS_POSIX_ACL = 0x20
4751
};
4852

4953
/* possible values of ->cache */

‎fs/9p/vfs_super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
9191
MS_NOATIME;
9292

9393
#ifdef CONFIG_9P_FS_POSIX_ACL
94-
if ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)
94+
if ((v9ses->flags & V9FS_ACL_MASK) == V9FS_POSIX_ACL)
9595
sb->s_flags |= MS_POSIXACL;
9696
#endif
9797

0 commit comments

Comments
 (0)