Commit 05ad9175 authored by Olga Kornievskaia's avatar Olga Kornievskaia Committed by Trond Myklebust

NFSv4.2: condition READDIR's mask for security label based on LSM state

Currently, the client will always ask for security_labels if the server
returns that it supports that feature regardless of any LSM modules
(such as Selinux) enforcing security policy. This adds performance
penalty to the READDIR operation.

Client adjusts superblock's support of the security_label based on
the server's support but also current client's configuration of the
LSM modules. Thus, prior to using the default bitmask in READDIR,
this patch checks the server's capabilities and then instructs
READDIR to remove FATTR4_WORD2_SECURITY_LABEL from the bitmask.

v5: fixing silly mistakes of the rushed v4
v4: simplifying logic
v3: changing label's initialization per Ondrej's comment
v2: dropping selinux hook and using the sb cap.
Suggested-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
Suggested-by: default avatarScott Mayhew <smayhew@redhat.com>
Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
Fixes: 2b0143b5 ("VFS: normal filesystems (and lustre): d_inode() annotations")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent e4c72201
...@@ -4965,12 +4965,12 @@ static int _nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred, ...@@ -4965,12 +4965,12 @@ static int _nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred,
u64 cookie, struct page **pages, unsigned int count, bool plus) u64 cookie, struct page **pages, unsigned int count, bool plus)
{ {
struct inode *dir = d_inode(dentry); struct inode *dir = d_inode(dentry);
struct nfs_server *server = NFS_SERVER(dir);
struct nfs4_readdir_arg args = { struct nfs4_readdir_arg args = {
.fh = NFS_FH(dir), .fh = NFS_FH(dir),
.pages = pages, .pages = pages,
.pgbase = 0, .pgbase = 0,
.count = count, .count = count,
.bitmask = NFS_SERVER(d_inode(dentry))->attr_bitmask,
.plus = plus, .plus = plus,
}; };
struct nfs4_readdir_res res; struct nfs4_readdir_res res;
...@@ -4985,9 +4985,15 @@ static int _nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred, ...@@ -4985,9 +4985,15 @@ static int _nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred,
dprintk("%s: dentry = %pd2, cookie = %Lu\n", __func__, dprintk("%s: dentry = %pd2, cookie = %Lu\n", __func__,
dentry, dentry,
(unsigned long long)cookie); (unsigned long long)cookie);
if (!(server->caps & NFS_CAP_SECURITY_LABEL))
args.bitmask = server->attr_bitmask_nl;
else
args.bitmask = server->attr_bitmask;
nfs4_setup_readdir(cookie, NFS_I(dir)->cookieverf, dentry, &args); nfs4_setup_readdir(cookie, NFS_I(dir)->cookieverf, dentry, &args);
res.pgbase = args.pgbase; res.pgbase = args.pgbase;
status = nfs4_call_sync(NFS_SERVER(dir)->client, NFS_SERVER(dir), &msg, &args.seq_args, &res.seq_res, 0); status = nfs4_call_sync(server->client, server, &msg, &args.seq_args,
&res.seq_res, 0);
if (status >= 0) { if (status >= 0) {
memcpy(NFS_I(dir)->cookieverf, res.verifier.data, NFS4_VERIFIER_SIZE); memcpy(NFS_I(dir)->cookieverf, res.verifier.data, NFS4_VERIFIER_SIZE);
status += args.pgbase; status += args.pgbase;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment