]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSv4.2: Fix initialisation of struct nfs4_label
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 19 Oct 2022 17:12:11 +0000 (13:12 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 28 Nov 2022 03:09:59 +0000 (22:09 -0500)
The call to nfs4_label_init_security() should return a fully initialised
label.

Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs4proc.c

index 86ed5c0142c3da48faa536ec4ab77b17cc1e4320..98a867092039f629c832c4bf32e27ded962fd012 100644 (file)
@@ -122,6 +122,11 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,
        if (nfs_server_capable(dir, NFS_CAP_SECURITY_LABEL) == 0)
                return NULL;
 
+       label->lfs = 0;
+       label->pi = 0;
+       label->len = 0;
+       label->label = NULL;
+
        err = security_dentry_init_security(dentry, sattr->ia_mode,
                                &dentry->d_name, NULL,
                                (void **)&label->label, &label->len);
@@ -3796,7 +3801,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx,
                int open_flags, struct iattr *attr, int *opened)
 {
        struct nfs4_state *state;
-       struct nfs4_label l = {0, 0, 0, NULL}, *label = NULL;
+       struct nfs4_label l, *label;
 
        label = nfs4_label_init_security(dir, ctx->dentry, attr, &l);
 
@@ -4682,7 +4687,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
                 int flags)
 {
        struct nfs_server *server = NFS_SERVER(dir);
-       struct nfs4_label l, *ilabel = NULL;
+       struct nfs4_label l, *ilabel;
        struct nfs_open_context *ctx;
        struct nfs4_state *state;
        int status = 0;
@@ -5033,7 +5038,7 @@ static int nfs4_proc_symlink(struct inode *dir, struct dentry *dentry,
        struct nfs4_exception exception = {
                .interruptible = true,
        };
-       struct nfs4_label l, *label = NULL;
+       struct nfs4_label l, *label;
        int err;
 
        label = nfs4_label_init_security(dir, dentry, sattr, &l);
@@ -5074,7 +5079,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry,
        struct nfs4_exception exception = {
                .interruptible = true,
        };
-       struct nfs4_label l, *label = NULL;
+       struct nfs4_label l, *label;
        int err;
 
        label = nfs4_label_init_security(dir, dentry, sattr, &l);
@@ -5193,7 +5198,7 @@ static int nfs4_proc_mknod(struct inode *dir, struct dentry *dentry,
        struct nfs4_exception exception = {
                .interruptible = true,
        };
-       struct nfs4_label l, *label = NULL;
+       struct nfs4_label l, *label;
        int err;
 
        label = nfs4_label_init_security(dir, dentry, sattr, &l);