]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
NFS: Don't allocate nfs_fattr on the stack in __nfs42_ssc_open()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 5 Nov 2021 18:23:30 +0000 (14:23 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 Oct 2022 08:39:20 +0000 (10:39 +0200)
BugLink: https://bugs.launchpad.net/bugs/1991717
[ Upstream commit 156cd28562a4e8ca454d11b234d9f634a45d6390 ]

The preferred behaviour is always to allocate struct nfs_fattr from the
slab.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/nfs/nfs4file.c

index 4120e1cb3feef78c219ecb0555d8279d7c609374..61ee03c8bcd2db153483cc08f2fb01abed188e52 100644 (file)
@@ -319,7 +319,7 @@ static int read_name_gen = 1;
 static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
                struct nfs_fh *src_fh, nfs4_stateid *stateid)
 {
-       struct nfs_fattr fattr;
+       struct nfs_fattr *fattr = nfs_alloc_fattr();
        struct file *filep, *res;
        struct nfs_server *server;
        struct inode *r_ino = NULL;
@@ -330,9 +330,10 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
 
        server = NFS_SERVER(ss_mnt->mnt_root->d_inode);
 
-       nfs_fattr_init(&fattr);
+       if (!fattr)
+               return ERR_PTR(-ENOMEM);
 
-       status = nfs4_proc_getattr(server, src_fh, &fattr, NULL, NULL);
+       status = nfs4_proc_getattr(server, src_fh, fattr, NULL, NULL);
        if (status < 0) {
                res = ERR_PTR(status);
                goto out;
@@ -345,7 +346,7 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
                goto out;
        snprintf(read_name, len, SSC_READ_NAME_BODY, read_name_gen++);
 
-       r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, &fattr,
+       r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, fattr,
                        NULL);
        if (IS_ERR(r_ino)) {
                res = ERR_CAST(r_ino);
@@ -390,6 +391,7 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
 out_free_name:
        kfree(read_name);
 out:
+       nfs_free_fattr(fattr);
        return res;
 out_stateowner:
        nfs4_put_state_owner(sp);