Skip to content

Commit f4e89f1

Browse files
pchelkin91Trond Myklebust
authored andcommitted
NFSv4: fix out path in __nfs4_get_acl_uncached
Another highly rare error case when a page allocating loop (inside __nfs4_get_acl_uncached, this time) is not properly unwound on error. Since pages array is allocated being uninitialized, need to free only lower array indices. NULL checks were useful before commit 62a1573 ("NFSv4 fix acl retrieval over krb5i/krb5p mounts") when the array had been initialized to zero on stack. Found by Linux Verification Center (linuxtesting.org). Fixes: 62a1573 ("NFSv4 fix acl retrieval over krb5i/krb5p mounts") Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 4e3733f commit f4e89f1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/nfs/nfs4proc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6004,9 +6004,8 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf,
60046004
out_ok:
60056005
ret = res.acl_len;
60066006
out_free:
6007-
for (i = 0; i < npages; i++)
6008-
if (pages[i])
6009-
__free_page(pages[i]);
6007+
while (--i >= 0)
6008+
__free_page(pages[i]);
60106009
if (res.acl_scratch)
60116010
__free_page(res.acl_scratch);
60126011
kfree(pages);

0 commit comments

Comments
 (0)