Blame SOURCES/CVE-2021-33909.patch

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