]> git.baikalelectronics.ru Git - kernel.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:07 +0000 (11:41 +0100)
[ Upstream commit c528f70f504434eaff993a5ddd52203a2010d51f ]

The call to nfs4_label_init_security() should return a fully initialised
label.

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

index 77c2c88621bee07d1f67c93d12f5def9b2970b23..3da48dd67b834d8db5b4470f0adbd699d9a32415 100644 (file)
@@ -121,6 +121,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, (void **)&label->label, &label->len);
        if (err == 0)
@@ -3742,7 +3747,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);
 
@@ -4497,7 +4502,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;
@@ -4850,7 +4855,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);
@@ -4891,7 +4896,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);
@@ -5012,7 +5017,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);