Skip to content

Commit c528f70

Browse files
author
Trond Myklebust
committed
NFSv4.2: Fix initialisation of struct nfs4_label
The call to nfs4_label_init_security() should return a fully initialised label. Fixes: aa9c266 ("NFS: Client implementation of Labeled-NFS") Signed-off-by: Trond Myklebust <[email protected]>
1 parent 43c1031 commit c528f70

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

fs/nfs/nfs4proc.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,
122122
if (nfs_server_capable(dir, NFS_CAP_SECURITY_LABEL) == 0)
123123
return NULL;
124124

125+
label->lfs = 0;
126+
label->pi = 0;
127+
label->len = 0;
128+
label->label = NULL;
129+
125130
err = security_dentry_init_security(dentry, sattr->ia_mode,
126131
&dentry->d_name, NULL,
127132
(void **)&label->label, &label->len);
@@ -3796,7 +3801,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx,
37963801
int open_flags, struct iattr *attr, int *opened)
37973802
{
37983803
struct nfs4_state *state;
3799-
struct nfs4_label l = {0, 0, 0, NULL}, *label = NULL;
3804+
struct nfs4_label l, *label;
38003805

38013806
label = nfs4_label_init_security(dir, ctx->dentry, attr, &l);
38023807

@@ -4682,7 +4687,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
46824687
int flags)
46834688
{
46844689
struct nfs_server *server = NFS_SERVER(dir);
4685-
struct nfs4_label l, *ilabel = NULL;
4690+
struct nfs4_label l, *ilabel;
46864691
struct nfs_open_context *ctx;
46874692
struct nfs4_state *state;
46884693
int status = 0;
@@ -5033,7 +5038,7 @@ static int nfs4_proc_symlink(struct inode *dir, struct dentry *dentry,
50335038
struct nfs4_exception exception = {
50345039
.interruptible = true,
50355040
};
5036-
struct nfs4_label l, *label = NULL;
5041+
struct nfs4_label l, *label;
50375042
int err;
50385043

50395044
label = nfs4_label_init_security(dir, dentry, sattr, &l);
@@ -5074,7 +5079,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry,
50745079
struct nfs4_exception exception = {
50755080
.interruptible = true,
50765081
};
5077-
struct nfs4_label l, *label = NULL;
5082+
struct nfs4_label l, *label;
50785083
int err;
50795084

50805085
label = nfs4_label_init_security(dir, dentry, sattr, &l);
@@ -5193,7 +5198,7 @@ static int nfs4_proc_mknod(struct inode *dir, struct dentry *dentry,
51935198
struct nfs4_exception exception = {
51945199
.interruptible = true,
51955200
};
5196-
struct nfs4_label l, *label = NULL;
5201+
struct nfs4_label l, *label;
51975202
int err;
51985203

51995204
label = nfs4_label_init_security(dir, dentry, sattr, &l);

0 commit comments

Comments
 (0)