From: Greg Kroah-Hartman Date: Sat, 9 Oct 2021 14:13:33 +0000 (+0200) Subject: 4.4-stable patches X-Git-Tag: v5.14.12~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f749c9679eee0f2ce8d83c6db804afc1ec32da83;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: nfsd4-handle-the-nfsv4-readdir-dircount-hint-being-zero.patch --- diff --git a/queue-4.4/nfsd4-handle-the-nfsv4-readdir-dircount-hint-being-zero.patch b/queue-4.4/nfsd4-handle-the-nfsv4-readdir-dircount-hint-being-zero.patch new file mode 100644 index 00000000000..1ed40bdfebb --- /dev/null +++ b/queue-4.4/nfsd4-handle-the-nfsv4-readdir-dircount-hint-being-zero.patch @@ -0,0 +1,52 @@ +From f2e717d655040d632c9015f19aa4275f8b16e7f2 Mon Sep 17 00:00:00 2001 +From: Trond Myklebust +Date: Thu, 30 Sep 2021 15:44:41 -0400 +Subject: nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero + +From: Trond Myklebust + +commit f2e717d655040d632c9015f19aa4275f8b16e7f2 upstream. + +RFC3530 notes that the 'dircount' field may be zero, in which case the +recommendation is to ignore it, and only enforce the 'maxcount' field. +In RFC5661, this recommendation to ignore a zero valued field becomes a +requirement. + +Fixes: aee377644146 ("nfsd4: fix rd_dircount enforcement") +Cc: +Signed-off-by: Trond Myklebust +Signed-off-by: Chuck Lever +Signed-off-by: Greg Kroah-Hartman +--- + fs/nfsd/nfs4xdr.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +--- a/fs/nfsd/nfs4xdr.c ++++ b/fs/nfsd/nfs4xdr.c +@@ -2988,15 +2988,18 @@ nfsd4_encode_dirent(void *ccdv, const ch + goto fail; + cd->rd_maxcount -= entry_bytes; + /* +- * RFC 3530 14.2.24 describes rd_dircount as only a "hint", so +- * let's always let through the first entry, at least: ++ * RFC 3530 14.2.24 describes rd_dircount as only a "hint", and ++ * notes that it could be zero. If it is zero, then the server ++ * should enforce only the rd_maxcount value. + */ +- if (!cd->rd_dircount) +- goto fail; +- name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8; +- if (name_and_cookie > cd->rd_dircount && cd->cookie_offset) +- goto fail; +- cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie); ++ if (cd->rd_dircount) { ++ name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8; ++ if (name_and_cookie > cd->rd_dircount && cd->cookie_offset) ++ goto fail; ++ cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie); ++ if (!cd->rd_dircount) ++ cd->rd_maxcount = 0; ++ } + + cd->cookie_offset = cookie_offset; + skip_entry: diff --git a/queue-4.4/series b/queue-4.4/series index fa71354d2ef..9d6fcb320b7 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -1,2 +1,3 @@ usb-cdc-acm-fix-racy-tty-buffer-accesses.patch usb-cdc-acm-fix-break-reporting.patch +nfsd4-handle-the-nfsv4-readdir-dircount-hint-being-zero.patch