Blame SOURCES/CVE-2021-33909.patch

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