From: Greg Kroah-Hartman Date: Fri, 19 Nov 2021 12:49:31 +0000 (+0100) Subject: 5.10-stable patches X-Git-Tag: v5.4.161~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bf9a96f6fe11b2c0d3d8f35bb2ffb978052e020;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: block-add-a-helper-to-validate-the-block-size.patch bootconfig-init-fix-memblock-leak-in-xbc_make_cmdline.patch fortify-explicitly-disable-clang-support.patch loop-use-blk_validate_block_size-to-validate-block-size.patch --- diff --git a/queue-5.10/block-add-a-helper-to-validate-the-block-size.patch b/queue-5.10/block-add-a-helper-to-validate-the-block-size.patch new file mode 100644 index 00000000000..72e1e4a9ea1 --- /dev/null +++ b/queue-5.10/block-add-a-helper-to-validate-the-block-size.patch @@ -0,0 +1,41 @@ +From 570b1cac477643cbf01a45fa5d018430a1fddbce Mon Sep 17 00:00:00 2001 +From: Xie Yongji +Date: Tue, 26 Oct 2021 22:40:12 +0800 +Subject: block: Add a helper to validate the block size + +From: Xie Yongji + +commit 570b1cac477643cbf01a45fa5d018430a1fddbce upstream. + +There are some duplicated codes to validate the block +size in block drivers. This limitation actually comes +from block layer, so this patch tries to add a new block +layer helper for that. + +Signed-off-by: Xie Yongji +Link: https://lore.kernel.org/r/20211026144015.188-2-xieyongji@bytedance.com +Signed-off-by: Jens Axboe +Signed-off-by: Tadeusz Struk +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/blkdev.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/include/linux/blkdev.h ++++ b/include/linux/blkdev.h +@@ -59,6 +59,14 @@ struct blk_keyslot_manager; + */ + #define BLKCG_MAX_POLS 5 + ++static inline int blk_validate_block_size(unsigned int bsize) ++{ ++ if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize)) ++ return -EINVAL; ++ ++ return 0; ++} ++ + typedef void (rq_end_io_fn)(struct request *, blk_status_t); + + /* diff --git a/queue-5.10/bootconfig-init-fix-memblock-leak-in-xbc_make_cmdline.patch b/queue-5.10/bootconfig-init-fix-memblock-leak-in-xbc_make_cmdline.patch new file mode 100644 index 00000000000..9096f699c9f --- /dev/null +++ b/queue-5.10/bootconfig-init-fix-memblock-leak-in-xbc_make_cmdline.patch @@ -0,0 +1,33 @@ +From 1ae43851b18afe861120ebd7c426dc44f06bb2bd Mon Sep 17 00:00:00 2001 +From: Masami Hiramatsu +Date: Thu, 16 Sep 2021 15:23:12 +0900 +Subject: bootconfig: init: Fix memblock leak in xbc_make_cmdline() + +From: Masami Hiramatsu + +commit 1ae43851b18afe861120ebd7c426dc44f06bb2bd upstream. + +Free unused memblock in a error case to fix memblock leak +in xbc_make_cmdline(). + +Link: https://lkml.kernel.org/r/163177339181.682366.8713781325929549256.stgit@devnote2 + +Fixes: 51887d03aca1 ("bootconfig: init: Allow admin to use bootconfig for kernel command line") +Signed-off-by: Masami Hiramatsu +Signed-off-by: Steven Rostedt (VMware) +Signed-off-by: Greg Kroah-Hartman + +--- + init/main.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/init/main.c ++++ b/init/main.c +@@ -380,6 +380,7 @@ static char * __init xbc_make_cmdline(co + ret = xbc_snprint_cmdline(new_cmdline, len + 1, root); + if (ret < 0 || ret > len) { + pr_err("Failed to print extra kernel cmdline.\n"); ++ memblock_free(__pa(new_cmdline), len + 1); + return NULL; + } + diff --git a/queue-5.10/fortify-explicitly-disable-clang-support.patch b/queue-5.10/fortify-explicitly-disable-clang-support.patch new file mode 100644 index 00000000000..f9d85018529 --- /dev/null +++ b/queue-5.10/fortify-explicitly-disable-clang-support.patch @@ -0,0 +1,47 @@ +From a52f8a59aef46b59753e583bf4b28fccb069ce64 Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Wed, 12 May 2021 21:51:10 -0700 +Subject: fortify: Explicitly disable Clang support + +From: Kees Cook + +commit a52f8a59aef46b59753e583bf4b28fccb069ce64 upstream. + +Clang has never correctly compiled the FORTIFY_SOURCE defenses due to +a couple bugs: + + Eliding inlines with matching __builtin_* names + https://bugs.llvm.org/show_bug.cgi?id=50322 + + Incorrect __builtin_constant_p() of some globals + https://bugs.llvm.org/show_bug.cgi?id=41459 + +In the process of making improvements to the FORTIFY_SOURCE defenses, the +first (silent) bug (coincidentally) becomes worked around, but exposes +the latter which breaks the build. As such, Clang must not be used with +CONFIG_FORTIFY_SOURCE until at least latter bug is fixed (in Clang 13), +and the fortify routines have been rearranged. + +Update the Kconfig to reflect the reality of the current situation. + +Signed-off-by: Kees Cook +Acked-by: Nick Desaulniers +Link: https://lore.kernel.org/lkml/CAKwvOd=A+ueGV2ihdy5GtgR2fQbcXjjAtVxv3=cPjffpebZB7A@mail.gmail.com +Cc: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + security/Kconfig | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/security/Kconfig ++++ b/security/Kconfig +@@ -191,6 +191,9 @@ config HARDENED_USERCOPY_PAGESPAN + config FORTIFY_SOURCE + bool "Harden common str/mem functions against buffer overflows" + depends on ARCH_HAS_FORTIFY_SOURCE ++ # https://bugs.llvm.org/show_bug.cgi?id=50322 ++ # https://bugs.llvm.org/show_bug.cgi?id=41459 ++ depends on !CC_IS_CLANG + help + Detect overflows of buffers in common string and memory functions + where the compiler can determine and validate the buffer sizes. diff --git a/queue-5.10/loop-use-blk_validate_block_size-to-validate-block-size.patch b/queue-5.10/loop-use-blk_validate_block_size-to-validate-block-size.patch new file mode 100644 index 00000000000..a93da7b5113 --- /dev/null +++ b/queue-5.10/loop-use-blk_validate_block_size-to-validate-block-size.patch @@ -0,0 +1,61 @@ +From af3c570fb0df422b4906ebd11c1bf363d89961d5 Mon Sep 17 00:00:00 2001 +From: Xie Yongji +Date: Tue, 26 Oct 2021 22:40:14 +0800 +Subject: loop: Use blk_validate_block_size() to validate block size + +From: Xie Yongji + +commit af3c570fb0df422b4906ebd11c1bf363d89961d5 upstream. + +Remove loop_validate_block_size() and use the block layer helper +to validate block size. + +Signed-off-by: Xie Yongji +Link: https://lore.kernel.org/r/20211026144015.188-4-xieyongji@bytedance.com +Signed-off-by: Jens Axboe +Cc: Tadeusz Struk +Signed-off-by: Greg Kroah-Hartman +--- + drivers/block/loop.c | 17 ++--------------- + 1 file changed, 2 insertions(+), 15 deletions(-) + +--- a/drivers/block/loop.c ++++ b/drivers/block/loop.c +@@ -229,19 +229,6 @@ static void __loop_update_dio(struct loo + } + + /** +- * loop_validate_block_size() - validates the passed in block size +- * @bsize: size to validate +- */ +-static int +-loop_validate_block_size(unsigned short bsize) +-{ +- if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize)) +- return -EINVAL; +- +- return 0; +-} +- +-/** + * loop_set_size() - sets device size and notifies userspace + * @lo: struct loop_device to set the size for + * @size: new size of the loop device +@@ -1121,7 +1108,7 @@ static int loop_configure(struct loop_de + } + + if (config->block_size) { +- error = loop_validate_block_size(config->block_size); ++ error = blk_validate_block_size(config->block_size); + if (error) + goto out_unlock; + } +@@ -1617,7 +1604,7 @@ static int loop_set_block_size(struct lo + if (lo->lo_state != Lo_bound) + return -ENXIO; + +- err = loop_validate_block_size(arg); ++ err = blk_validate_block_size(arg); + if (err) + return err; + diff --git a/queue-5.10/series b/queue-5.10/series new file mode 100644 index 00000000000..6b7236bff56 --- /dev/null +++ b/queue-5.10/series @@ -0,0 +1,4 @@ +fortify-explicitly-disable-clang-support.patch +block-add-a-helper-to-validate-the-block-size.patch +loop-use-blk_validate_block_size-to-validate-block-size.patch +bootconfig-init-fix-memblock-leak-in-xbc_make_cmdline.patch