]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Jan 2023 15:53:38 +0000 (16:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Jan 2023 15:53:38 +0000 (16:53 +0100)
added patches:
ext4-don-t-allow-journal-inode-to-have-encrypt-flag.patch
selftests-set-the-build-variable-to-absolute-path.patch

queue-5.10/ext4-don-t-allow-journal-inode-to-have-encrypt-flag.patch [new file with mode: 0644]
queue-5.10/selftests-set-the-build-variable-to-absolute-path.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/ext4-don-t-allow-journal-inode-to-have-encrypt-flag.patch b/queue-5.10/ext4-don-t-allow-journal-inode-to-have-encrypt-flag.patch
new file mode 100644 (file)
index 0000000..b86f91d
--- /dev/null
@@ -0,0 +1,58 @@
+From 105c78e12468413e426625831faa7db4284e1fec Mon Sep 17 00:00:00 2001
+From: Eric Biggers <ebiggers@google.com>
+Date: Tue, 1 Nov 2022 22:33:12 -0700
+Subject: ext4: don't allow journal inode to have encrypt flag
+
+From: Eric Biggers <ebiggers@google.com>
+
+commit 105c78e12468413e426625831faa7db4284e1fec upstream.
+
+Mounting a filesystem whose journal inode has the encrypt flag causes a
+NULL dereference in fscrypt_limit_io_blocks() when the 'inlinecrypt'
+mount option is used.
+
+The problem is that when jbd2_journal_init_inode() calls bmap(), it
+eventually finds its way into ext4_iomap_begin(), which calls
+fscrypt_limit_io_blocks().  fscrypt_limit_io_blocks() requires that if
+the inode is encrypted, then its encryption key must already be set up.
+That's not the case here, since the journal inode is never "opened" like
+a normal file would be.  Hence the crash.
+
+A reproducer is:
+
+    mkfs.ext4 -F /dev/vdb
+    debugfs -w /dev/vdb -R "set_inode_field <8> flags 0x80808"
+    mount /dev/vdb /mnt -o inlinecrypt
+
+To fix this, make ext4 consider journal inodes with the encrypt flag to
+be invalid.  (Note, maybe other flags should be rejected on the journal
+inode too.  For now, this is just the minimal fix for the above issue.)
+
+I've marked this as fixing the commit that introduced the call to
+fscrypt_limit_io_blocks(), since that's what made an actual crash start
+being possible.  But this fix could be applied to any version of ext4
+that supports the encrypt feature.
+
+Reported-by: syzbot+ba9dac45bc76c490b7c3@syzkaller.appspotmail.com
+Fixes: 38ea50daa7a4 ("ext4: support direct I/O with fscrypt using blk-crypto")
+Cc: stable@vger.kernel.org
+Signed-off-by: Eric Biggers <ebiggers@google.com>
+Link: https://lore.kernel.org/r/20221102053312.189962-1-ebiggers@kernel.org
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Cc: stable@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/super.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -5262,7 +5262,7 @@ static struct inode *ext4_get_journal_in
+       jbd_debug(2, "Journal inode found at %p: %lld bytes\n",
+                 journal_inode, journal_inode->i_size);
+-      if (!S_ISREG(journal_inode->i_mode)) {
++      if (!S_ISREG(journal_inode->i_mode) || IS_ENCRYPTED(journal_inode)) {
+               ext4_msg(sb, KERN_ERR, "invalid journal inode");
+               iput(journal_inode);
+               return NULL;
diff --git a/queue-5.10/selftests-set-the-build-variable-to-absolute-path.patch b/queue-5.10/selftests-set-the-build-variable-to-absolute-path.patch
new file mode 100644 (file)
index 0000000..3650122
--- /dev/null
@@ -0,0 +1,70 @@
+From 5ad51ab618de5d05f4e692ebabeb6fe6289aaa57 Mon Sep 17 00:00:00 2001
+From: Muhammad Usama Anjum <usama.anjum@collabora.com>
+Date: Wed, 19 Jan 2022 15:15:22 +0500
+Subject: selftests: set the BUILD variable to absolute path
+
+From: Muhammad Usama Anjum <usama.anjum@collabora.com>
+
+commit 5ad51ab618de5d05f4e692ebabeb6fe6289aaa57 upstream.
+
+The build of kselftests fails if relative path is specified through
+KBUILD_OUTPUT or O=<path> method. BUILD variable is used to determine
+the path of the output objects. When make is run from other directories
+with relative paths, the exact path of the build objects is ambiguous
+and build fails.
+
+       make[1]: Entering directory '/home/usama/repos/kernel/linux_mainline2/tools/testing/selftests/alsa'
+       gcc     mixer-test.c -L/usr/lib/x86_64-linux-gnu -lasound  -o build/kselftest/alsa/mixer-test
+       /usr/bin/ld: cannot open output file build/kselftest/alsa/mixer-test
+
+Set the BUILD variable to the absolute path of the output directory.
+Make the logic readable and easy to follow. Use spaces instead of tabs
+for indentation as if with tab indentation is considered recipe in make.
+
+Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
+Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
+Signed-off-by: Tyler Hicks (Microsoft) <code@tyhicks.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/Makefile |   26 +++++++++++++++++---------
+ 1 file changed, 17 insertions(+), 9 deletions(-)
+
+--- a/tools/testing/selftests/Makefile
++++ b/tools/testing/selftests/Makefile
+@@ -103,19 +103,27 @@ ifdef building_out_of_srctree
+ override LDFLAGS =
+ endif
+-ifneq ($(O),)
+-      BUILD := $(O)/kselftest
++top_srcdir ?= ../../..
++
++ifeq ("$(origin O)", "command line")
++  KBUILD_OUTPUT := $(O)
++endif
++
++ifneq ($(KBUILD_OUTPUT),)
++  # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
++  # expand a shell special character '~'. We use a somewhat tedious way here.
++  abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
++  $(if $(abs_objtree),, \
++    $(error failed to create output directory "$(KBUILD_OUTPUT)"))
++  # $(realpath ...) resolves symlinks
++  abs_objtree := $(realpath $(abs_objtree))
++  BUILD := $(abs_objtree)/kselftest
+ else
+-      ifneq ($(KBUILD_OUTPUT),)
+-              BUILD := $(KBUILD_OUTPUT)/kselftest
+-      else
+-              BUILD := $(shell pwd)
+-              DEFAULT_INSTALL_HDR_PATH := 1
+-      endif
++  BUILD := $(CURDIR)
++  DEFAULT_INSTALL_HDR_PATH := 1
+ endif
+ # Prepare for headers install
+-top_srcdir ?= ../../..
+ include $(top_srcdir)/scripts/subarch.include
+ ARCH           ?= $(SUBARCH)
+ export KSFT_KHDR_INSTALL_DONE := 1
index 808c7bc5d22c9abf10799a7f70d6bd949b8976f6..f4ed250abb1dc457672946346b35ba239712b5dc 100644 (file)
@@ -763,3 +763,5 @@ fbdev-matroxfb-g200ew-increase-max-memory-from-1-mb-to-16-mb.patch
 riscv-uaccess-fix-type-of-0-variable-on-error-in-get_user.patch
 drm-i915-gvt-fix-gvt-debugfs-destroy.patch
 drm-i915-gvt-fix-vgpu-debugfs-clean-in-remove.patch
+ext4-don-t-allow-journal-inode-to-have-encrypt-flag.patch
+selftests-set-the-build-variable-to-absolute-path.patch