From: Greg Kroah-Hartman Date: Fri, 17 Mar 2023 13:02:16 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.14.311~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7901cd73caf794947cb64d72dc4382e44907eea7;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch fs-sysfs_emit_at-remove-page_size-alignment-check.patch series --- diff --git a/queue-4.14/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch b/queue-4.14/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch new file mode 100644 index 00000000000..8671e46c2ae --- /dev/null +++ b/queue-4.14/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch @@ -0,0 +1,70 @@ +From ffec85d53d0f39ee4680a2cf0795255e000e1feb Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Thu, 2 Feb 2023 16:55:03 -0800 +Subject: ext4: fix cgroup writeback accounting with fs-layer encryption + +From: Eric Biggers + +commit ffec85d53d0f39ee4680a2cf0795255e000e1feb upstream. + +When writing a page from an encrypted file that is using +filesystem-layer encryption (not inline encryption), ext4 encrypts the +pagecache page into a bounce page, then writes the bounce page. + +It also passes the bounce page to wbc_account_cgroup_owner(). That's +incorrect, because the bounce page is a newly allocated temporary page +that doesn't have the memory cgroup of the original pagecache page. +This makes wbc_account_cgroup_owner() not account the I/O to the owner +of the pagecache page as it should. + +Fix this by always passing the pagecache page to +wbc_account_cgroup_owner(). + +Fixes: 001e4a8775f6 ("ext4: implement cgroup writeback support") +Cc: stable@vger.kernel.org +Reported-by: Matthew Wilcox (Oracle) +Signed-off-by: Eric Biggers +Acked-by: Tejun Heo +Link: https://lore.kernel.org/r/20230203005503.141557-1-ebiggers@kernel.org +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/page-io.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +--- a/fs/ext4/page-io.c ++++ b/fs/ext4/page-io.c +@@ -388,7 +388,8 @@ static int io_submit_init_bio(struct ext + + static int io_submit_add_bh(struct ext4_io_submit *io, + struct inode *inode, +- struct page *page, ++ struct page *pagecache_page, ++ struct page *bounce_page, + struct buffer_head *bh) + { + int ret; +@@ -403,10 +404,11 @@ submit_and_retry: + return ret; + io->io_bio->bi_write_hint = inode->i_write_hint; + } +- ret = bio_add_page(io->io_bio, page, bh->b_size, bh_offset(bh)); ++ ret = bio_add_page(io->io_bio, bounce_page ?: pagecache_page, ++ bh->b_size, bh_offset(bh)); + if (ret != bh->b_size) + goto submit_and_retry; +- wbc_account_io(io->io_wbc, page, bh->b_size); ++ wbc_account_io(io->io_wbc, pagecache_page, bh->b_size); + io->io_next_block++; + return 0; + } +@@ -514,8 +516,7 @@ int ext4_bio_write_page(struct ext4_io_s + do { + if (!buffer_async_write(bh)) + continue; +- ret = io_submit_add_bh(io, inode, +- data_page ? data_page : page, bh); ++ ret = io_submit_add_bh(io, inode, page, data_page, bh); + if (ret) { + /* + * We only get here on ENOMEM. Not much else diff --git a/queue-4.14/fs-sysfs_emit_at-remove-page_size-alignment-check.patch b/queue-4.14/fs-sysfs_emit_at-remove-page_size-alignment-check.patch new file mode 100644 index 00000000000..a2a71732e64 --- /dev/null +++ b/queue-4.14/fs-sysfs_emit_at-remove-page_size-alignment-check.patch @@ -0,0 +1,62 @@ +From ebiggers@kernel.org Fri Mar 17 13:57:17 2023 +From: Eric Biggers +Date: Thu, 16 Mar 2023 23:27:43 -0700 +Subject: fs: sysfs_emit_at: Remove PAGE_SIZE alignment check +To: stable@vger.kernel.org +Cc: Joe Perches , Lucas Wei , linux-mm@kvack.org, kernel test robot +Message-ID: <20230317062743.313169-1-ebiggers@kernel.org> + +From: Eric Biggers + +From: Eric Biggers + +[No upstream commit because this fixes a bug in a backport.] + +Before upstream commit 59bb47985c1d ("mm, sl[aou]b: guarantee natural +alignment for kmalloc(power-of-two)") which went into v5.4, kmalloc did +*not* always guarantee that PAGE_SIZE allocations are PAGE_SIZE-aligned. + +Upstream commit 2efc459d06f1 ("sysfs: Add sysfs_emit and sysfs_emit_at +to format sysfs output") added two WARN()s that trigger when PAGE_SIZE +allocations are not PAGE_SIZE-aligned. This was backported to old +kernels that don't guarantee PAGE_SIZE alignment. + +Commit 10ddfb495232 ("fs: sysfs_emit: Remove PAGE_SIZE alignment check") +in 4.19.y, and its equivalent in 4.14.y and 4.9.y, tried to fix this +bug. However, only it handled sysfs_emit(), not sysfs_emit_at(). + +Fix it in sysfs_emit_at() too. + +A reproducer is to build the kernel with the following options: + + CONFIG_SLUB=y + CONFIG_SLUB_DEBUG=y + CONFIG_SLUB_DEBUG_ON=y + CONFIG_PM=y + CONFIG_SUSPEND=y + CONFIG_PM_WAKELOCKS=y + +Then run: + + echo foo > /sys/power/wake_lock && cat /sys/power/wake_lock + +Fixes: cb1f69d53ac8 ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output") +Reported-by: kernel test robot +Link: https://lore.kernel.org/r/202303141634.1e64fd76-yujie.liu@intel.com +Signed-off-by: Eric Biggers +Signed-off-by: Greg Kroah-Hartman +--- + fs/sysfs/file.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/sysfs/file.c ++++ b/fs/sysfs/file.c +@@ -592,7 +592,7 @@ int sysfs_emit_at(char *buf, int at, con + va_list args; + int len; + +- if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE, ++ if (WARN(!buf || at < 0 || at >= PAGE_SIZE, + "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at)) + return 0; + diff --git a/queue-4.14/series b/queue-4.14/series new file mode 100644 index 00000000000..7aa1bcaa1e1 --- /dev/null +++ b/queue-4.14/series @@ -0,0 +1,2 @@ +ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch +fs-sysfs_emit_at-remove-page_size-alignment-check.patch