From: Trond Myklebust <trond.myklebust@hammerspace.com>
Date: Wed, 19 Oct 2022 13:12:11 -0400
Subject: [PATCH] NFSv4.2: Fix initialisation of struct nfs4_label
Git-commit: c528f70f504434eaff993a5ddd52203a2010d51f
Patch-mainline: v6.2
References: git-fixes
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>
Acked-by: NeilBrown <neilb@suse.com>
---
fs/nfs/nfs4proc.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -120,6 +120,11 @@ nfs4_label_init_security(struct inode *d
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)
@@ -3522,7 +3527,7 @@ nfs4_atomic_open(struct inode *dir, stru
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);
@@ -4223,7 +4228,7 @@ nfs4_proc_create(struct inode *dir, stru
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;
@@ -4510,7 +4515,7 @@ static int nfs4_proc_symlink(struct inod
struct page *page, unsigned int len, struct iattr *sattr)
{
struct nfs4_exception exception = { };
- struct nfs4_label l, *label = NULL;
+ struct nfs4_label l, *label;
int err;
label = nfs4_label_init_security(dir, dentry, sattr, &l);
@@ -4549,7 +4554,7 @@ static int nfs4_proc_mkdir(struct inode
{
struct nfs_server *server = NFS_SERVER(dir);
struct nfs4_exception exception = { };
- struct nfs4_label l, *label = NULL;
+ struct nfs4_label l, *label;
int err;
label = nfs4_label_init_security(dir, dentry, sattr, &l);
@@ -4666,7 +4671,7 @@ static int nfs4_proc_mknod(struct inode
{
struct nfs_server *server = NFS_SERVER(dir);
struct nfs4_exception exception = { };
- struct nfs4_label l, *label = NULL;
+ struct nfs4_label l, *label;
int err;
label = nfs4_label_init_security(dir, dentry, sattr, &l);