Blame SOURCES/CVE-2021-33909.patch

70257a
From: Joe Lawrence <joe.lawrence@redhat.com>
70257a
Date: Tue,  6 Jul 2021 13:18:44 -0400
70257a
Subject: [kernel team] [EMBARGOED KPATCH 7.9] seq_file: kpatch fix for
70257a
	CVE-2021-33909
70257a
70257a
Kernels:
70257a
3.10.0-1160.el7
70257a
3.10.0-1160.2.1.el7
70257a
3.10.0-1160.2.2.el7
70257a
3.10.0-1160.6.1.el7
70257a
3.10.0-1160.11.1.el7
70257a
3.10.0-1160.15.2.el7
70257a
3.10.0-1160.21.1.el7
70257a
3.10.0-1160.24.1.el7
70257a
3.10.0-1160.25.1.el7
70257a
3.10.0-1160.31.1.el7
70257a
70257a
Changes since last build:
70257a
arches: x86_64 ppc64le
70257a
seq_file.o: changed function: seq_read
70257a
seq_file.o: changed function: single_open_size
70257a
seq_file.o: changed function: traverse
70257a
---------------------------
70257a
70257a
Kernels:
70257a
3.10.0-1160.el7
70257a
3.10.0-1160.2.1.el7
70257a
3.10.0-1160.2.2.el7
70257a
3.10.0-1160.6.1.el7
70257a
3.10.0-1160.11.1.el7
70257a
3.10.0-1160.15.2.el7
70257a
3.10.0-1160.21.1.el7
70257a
3.10.0-1160.24.1.el7
70257a
3.10.0-1160.25.1.el7
70257a
3.10.0-1160.31.1.el7
70257a
70257a
Modifications:
70257a
- inline PAGE_CACHE_SHIFT rather than including linux/pagemap.h and
70257a
  fighting kABI fallout (and potentially more inadvertent changes)
70257a
70257a
commit 1236d5dd5b9f13ccbb44979a5652a4b137b968a4
70257a
Author: Ian Kent <ikent@redhat.com>
70257a
Date:   Thu Jul 1 09:13:59 2021 +0800
70257a
70257a
    seq_file: Disallow extremely large seq buffer allocations
70257a
70257a
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1975251
70257a
70257a
    Brew build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=37832573
70257a
70257a
    Testing: The patch has been tested by Qualys and it has been
70257a
             confirmed the patch fixes the problem.
70257a
70257a
    Upstream status: RHEL only (CVE-2021-33909)
70257a
70257a
    Conflicts: include/fs.h uses PAGE_CACHE_SHIFT in the definition of
70257a
      MAX_RW_COUNT which isn't defined in fs/seq_file.c and including
70257a
      linux/pagemap.h breaks kabi (since it makes kabi aware of additional
70257a
      structs) even though there are no changes to any structures. So the
70257a
      include needs to be added and excluded from the kabi calculation.
70257a
70257a
    Author: Eric Sandeen <sandeen@redhat.com>
70257a
70257a
    seq_file: Disallow extremely large seq buffer allocations
70257a
70257a
    There is no reasonable need for a buffer larger than this,
70257a
    and it avoids int overflow pitfalls.
70257a
70257a
    Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
70257a
    Signed-off-by: Eric Sandeen <sandeen@redhat.com>
70257a
70257a
    Signed-off-by: Ian Kent <ikent@redhat.com>
70257a
70257a
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
70257a
Acked-by: Artem Savkov <asavkov@redhat.com>
70257a
Acked-by: Yannick Cote <ycote@redhat.com>
70257a
---
70257a
70257a
Z-MR: https://gitlab.com/redhat/prdsc/rhel/src/kernel-private/rhel-7/-/merge_requests/7
70257a
70257a
KT0 test PASS: https://beaker.engineering.redhat.com/jobs/5525685
70257a
for kpatch-patch-3_10_0-1160-1-7.el7 scratch build:
70257a
https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=37846414
70257a
70257a
 fs/seq_file.c | 23 +++++++++++++++++++++++
70257a
 1 file changed, 23 insertions(+)
70257a
70257a
diff --git a/fs/seq_file.c b/fs/seq_file.c
70257a
index bc7a9ec855aa..daef8f4bdbd0 100644
70257a
--- a/fs/seq_file.c
70257a
+++ b/fs/seq_file.c
70257a
@@ -5,6 +5,26 @@
70257a
  * initial implementation -- AV, Oct 2001.
70257a
  */
70257a
 
70257a
+/* inline linux/pagemap.h :: PAGE_CACHE_MASK and dependency values */
70257a
+
70257a
+/* arch/x86/include/asm/page_types.h */
70257a
+#ifdef __x86_64__
70257a
+# define PAGE_CACHE_MASK	(~((1UL << 12)-1))
70257a
+#endif
70257a
+
70257a
+/* arch/powerpc/include/asm/page.h */
70257a
+#ifdef __powerpc64__
70257a
+# if defined(CONFIG_PPC_256K_PAGES)
70257a
+#  define PAGE_CACHE_MASK	(~((1 << 18) - 1))
70257a
+# elif defined(CONFIG_PPC_64K_PAGES)
70257a
+#  define PAGE_CACHE_MASK	(~((1 << 16) - 1))
70257a
+# elif defined(CONFIG_PPC_16K_PAGES)
70257a
+#  define PAGE_CACHE_MASK	(~((1 << 14) - 1))
70257a
+# else
70257a
+#  define PAGE_CACHE_MASK	(~((1 << 12) - 1))
70257a
+# endif
70257a
+#endif
70257a
+
70257a
 #include <linux/fs.h>
70257a
 #include <linux/export.h>
70257a
 #include <linux/seq_file.h>
70257a
@@ -26,6 +46,9 @@ static void seq_set_overflow(struct seq_file *m)
70257a
 
70257a
 static void *seq_buf_alloc(unsigned long size)
70257a
 {
70257a
+	if (unlikely(size > MAX_RW_COUNT))
70257a
+		return NULL;
70257a
+
70257a
 	return kvmalloc(size, GFP_KERNEL);
70257a
 }
70257a
 
70257a
-- 
70257a
2.26.3
70257a
70257a