From: Greg Kroah-Hartman Date: Tue, 13 Feb 2024 14:58:22 +0000 (+0100) Subject: 6.1-stable patches X-Git-Tag: v6.1.78~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63c378561f8e48c5f35f1aa6fd5af39a6e553c92;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: f2fs-add-helper-to-check-compression-level.patch rdma-irdma-fix-support-for-64k-pages.patch vhost-use-kzalloc-instead-of-kmalloc-followed-by-memset.patch --- diff --git a/queue-6.1/f2fs-add-helper-to-check-compression-level.patch b/queue-6.1/f2fs-add-helper-to-check-compression-level.patch new file mode 100644 index 00000000000..9734a0f14b2 --- /dev/null +++ b/queue-6.1/f2fs-add-helper-to-check-compression-level.patch @@ -0,0 +1,160 @@ +From c571fbb5b59a3741e48014faa92c2f14bc59fe50 Mon Sep 17 00:00:00 2001 +From: Sheng Yong +Date: Mon, 12 Jun 2023 11:01:16 +0800 +Subject: f2fs: add helper to check compression level + +From: Sheng Yong + +commit c571fbb5b59a3741e48014faa92c2f14bc59fe50 upstream. + +This patch adds a helper function to check if compression level is +valid. + +Meanwhile, this patch fixes a reported issue [1]: + +The issue is easily reproducible by: + +1. dd if=/dev/zero of=test.img count=100 bs=1M +2. mkfs.f2fs -f -O compression,extra_attr ./test.img +3. mount -t f2fs -o compress_algorithm=zstd:6,compress_chksum,atgc,gc_merge,lazytime ./test.img /mnt + +resulting in + +[ 60.789982] F2FS-fs (loop0): invalid zstd compress level: 6 + +A bugzilla report has been submitted in +https://bugzilla.kernel.org/show_bug.cgi?id=218471 + +[1] https://lore.kernel.org/lkml/ZcWDOjKEnPDxZ0Or@google.com/T/ + +The root cause is commit 00e120b5e4b5 ("f2fs: assign default compression +level") tries to check low boundary of compress level w/ zstd_min_clevel(), +however, since commit e0c1b49f5b67 ("lib: zstd: Upgrade to latest upstream +zstd version 1.4.10"), zstd supports negative compress level, it cast type +for negative value returned from zstd_min_clevel() to unsigned int in below +check condition, result in repored issue. + + if (level < zstd_min_clevel() || ... + +This patch fixes this issue by casting type for level to int before +comparison. + +Fixes: 00e120b5e4b5 ("f2fs: assign default compression level") +Signed-off-by: Sheng Yong +Reviewed-by: Chao Yu +Signed-off-by: Jaegeuk Kim +Signed-off-by: Chao Yu +Signed-off-by: Greg Kroah-Hartman +--- + fs/f2fs/compress.c | 27 +++++++++++++++++++++++++++ + fs/f2fs/f2fs.h | 2 ++ + fs/f2fs/super.c | 4 ++-- + 3 files changed, 31 insertions(+), 2 deletions(-) + +--- a/fs/f2fs/compress.c ++++ b/fs/f2fs/compress.c +@@ -55,6 +55,7 @@ struct f2fs_compress_ops { + int (*init_decompress_ctx)(struct decompress_io_ctx *dic); + void (*destroy_decompress_ctx)(struct decompress_io_ctx *dic); + int (*decompress_pages)(struct decompress_io_ctx *dic); ++ bool (*is_level_valid)(int level); + }; + + static unsigned int offset_in_cluster(struct compress_ctx *cc, pgoff_t index) +@@ -322,11 +323,21 @@ static int lz4_decompress_pages(struct d + return 0; + } + ++static bool lz4_is_level_valid(int lvl) ++{ ++#ifdef CONFIG_F2FS_FS_LZ4HC ++ return !lvl || (lvl >= LZ4HC_MIN_CLEVEL && lvl <= LZ4HC_MAX_CLEVEL); ++#else ++ return lvl == 0; ++#endif ++} ++ + static const struct f2fs_compress_ops f2fs_lz4_ops = { + .init_compress_ctx = lz4_init_compress_ctx, + .destroy_compress_ctx = lz4_destroy_compress_ctx, + .compress_pages = lz4_compress_pages, + .decompress_pages = lz4_decompress_pages, ++ .is_level_valid = lz4_is_level_valid, + }; + #endif + +@@ -490,6 +501,11 @@ static int zstd_decompress_pages(struct + return 0; + } + ++static bool zstd_is_level_valid(int lvl) ++{ ++ return lvl >= zstd_min_clevel() && lvl <= zstd_max_clevel(); ++} ++ + static const struct f2fs_compress_ops f2fs_zstd_ops = { + .init_compress_ctx = zstd_init_compress_ctx, + .destroy_compress_ctx = zstd_destroy_compress_ctx, +@@ -497,6 +513,7 @@ static const struct f2fs_compress_ops f2 + .init_decompress_ctx = zstd_init_decompress_ctx, + .destroy_decompress_ctx = zstd_destroy_decompress_ctx, + .decompress_pages = zstd_decompress_pages, ++ .is_level_valid = zstd_is_level_valid, + }; + #endif + +@@ -555,6 +572,16 @@ bool f2fs_is_compress_backend_ready(stru + return f2fs_cops[F2FS_I(inode)->i_compress_algorithm]; + } + ++bool f2fs_is_compress_level_valid(int alg, int lvl) ++{ ++ const struct f2fs_compress_ops *cops = f2fs_cops[alg]; ++ ++ if (cops->is_level_valid) ++ return cops->is_level_valid(lvl); ++ ++ return lvl == 0; ++} ++ + static mempool_t *compress_page_pool; + static int num_compress_pages = 512; + module_param(num_compress_pages, uint, 0444); +--- a/fs/f2fs/f2fs.h ++++ b/fs/f2fs/f2fs.h +@@ -4219,6 +4219,7 @@ bool f2fs_compress_write_end(struct inod + int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock); + void f2fs_compress_write_end_io(struct bio *bio, struct page *page); + bool f2fs_is_compress_backend_ready(struct inode *inode); ++bool f2fs_is_compress_level_valid(int alg, int lvl); + int f2fs_init_compress_mempool(void); + void f2fs_destroy_compress_mempool(void); + void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task); +@@ -4283,6 +4284,7 @@ static inline bool f2fs_is_compress_back + /* not support compression */ + return false; + } ++static inline bool f2fs_is_compress_level_valid(int alg, int lvl) { return false; } + static inline struct page *f2fs_compress_control_page(struct page *page) + { + WARN_ON_ONCE(1); +--- a/fs/f2fs/super.c ++++ b/fs/f2fs/super.c +@@ -628,7 +628,7 @@ static int f2fs_set_lz4hc_level(struct f + if (kstrtouint(str + 1, 10, &level)) + return -EINVAL; + +- if (level < LZ4HC_MIN_CLEVEL || level > LZ4HC_MAX_CLEVEL) { ++ if (!f2fs_is_compress_level_valid(COMPRESS_LZ4, level)) { + f2fs_info(sbi, "invalid lz4hc compress level: %d", level); + return -EINVAL; + } +@@ -666,7 +666,7 @@ static int f2fs_set_zstd_level(struct f2 + if (kstrtouint(str + 1, 10, &level)) + return -EINVAL; + +- if (level < zstd_min_clevel() || level > zstd_max_clevel()) { ++ if (!f2fs_is_compress_level_valid(COMPRESS_ZSTD, level)) { + f2fs_info(sbi, "invalid zstd compress level: %d", level); + return -EINVAL; + } diff --git a/queue-6.1/rdma-irdma-fix-support-for-64k-pages.patch b/queue-6.1/rdma-irdma-fix-support-for-64k-pages.patch new file mode 100644 index 00000000000..2542c292646 --- /dev/null +++ b/queue-6.1/rdma-irdma-fix-support-for-64k-pages.patch @@ -0,0 +1,36 @@ +From 03769f72d66edab82484449ed594cb6b00ae0223 Mon Sep 17 00:00:00 2001 +From: Mike Marciniszyn +Date: Wed, 29 Nov 2023 14:21:43 -0600 +Subject: RDMA/irdma: Fix support for 64k pages + +From: Mike Marciniszyn + +commit 03769f72d66edab82484449ed594cb6b00ae0223 upstream. + +Virtual QP and CQ require a 4K HW page size but the driver passes +PAGE_SIZE to ib_umem_find_best_pgsz() instead. + +Fix this by using the appropriate 4k value in the bitmap passed to +ib_umem_find_best_pgsz(). + +Fixes: 693a5386eff0 ("RDMA/irdma: Split mr alloc and free into new functions") +Link: https://lore.kernel.org/r/20231129202143.1434-4-shiraz.saleem@intel.com +Signed-off-by: Mike Marciniszyn +Signed-off-by: Shiraz Saleem +Signed-off-by: Jason Gunthorpe +Signed-off-by: Greg Kroah-Hartman +--- + drivers/infiniband/hw/irdma/verbs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/infiniband/hw/irdma/verbs.c ++++ b/drivers/infiniband/hw/irdma/verbs.c +@@ -2825,7 +2825,7 @@ static struct ib_mr *irdma_reg_user_mr(s + iwmr->ibmr.pd = pd; + iwmr->ibmr.device = pd->device; + iwmr->ibmr.iova = virt; +- iwmr->page_size = PAGE_SIZE; ++ iwmr->page_size = SZ_4K; + + if (req.reg_type == IRDMA_MEMREG_TYPE_MEM) { + iwmr->page_size = ib_umem_find_best_pgsz(region, diff --git a/queue-6.1/series b/queue-6.1/series index 2a2f7abb567..024a63afb4e 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -57,3 +57,6 @@ input-i8042-fix-strange-behavior-of-touchpad-on-clevo-ns70pu.patch input-atkbd-skip-atkbd_cmd_setleds-when-skipping-atkbd_cmd_getid.patch io_uring-net-fix-sr-len-for-ioring_op_recv-with-msg_waitall-and-buffers.patch revert-asoc-amd-add-new-dmi-entries-for-acp5x-platform.patch +vhost-use-kzalloc-instead-of-kmalloc-followed-by-memset.patch +rdma-irdma-fix-support-for-64k-pages.patch +f2fs-add-helper-to-check-compression-level.patch diff --git a/queue-6.1/vhost-use-kzalloc-instead-of-kmalloc-followed-by-memset.patch b/queue-6.1/vhost-use-kzalloc-instead-of-kmalloc-followed-by-memset.patch new file mode 100644 index 00000000000..c567070753d --- /dev/null +++ b/queue-6.1/vhost-use-kzalloc-instead-of-kmalloc-followed-by-memset.patch @@ -0,0 +1,39 @@ +From 4d8df0f5f79f747d75a7d356d9b9ea40a4e4c8a9 Mon Sep 17 00:00:00 2001 +From: Prathu Baronia +Date: Mon, 22 May 2023 14:20:19 +0530 +Subject: vhost: use kzalloc() instead of kmalloc() followed by memset() + +From: Prathu Baronia + +commit 4d8df0f5f79f747d75a7d356d9b9ea40a4e4c8a9 upstream. + +Use kzalloc() to allocate new zeroed out msg node instead of +memsetting a node allocated with kmalloc(). + +Signed-off-by: Prathu Baronia +Message-Id: <20230522085019.42914-1-prathubaronia2011@gmail.com> +Signed-off-by: Michael S. Tsirkin +Reviewed-by: Stefano Garzarella +Signed-off-by: Ajay Kaher +Signed-off-by: Greg Kroah-Hartman +--- + drivers/vhost/vhost.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +--- a/drivers/vhost/vhost.c ++++ b/drivers/vhost/vhost.c +@@ -2588,12 +2588,11 @@ EXPORT_SYMBOL_GPL(vhost_disable_notify); + /* Create a new message. */ + struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) + { +- struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); ++ /* Make sure all padding within the structure is initialized. */ ++ struct vhost_msg_node *node = kzalloc(sizeof(*node), GFP_KERNEL); + if (!node) + return NULL; + +- /* Make sure all padding within the structure is initialized. */ +- memset(&node->msg, 0, sizeof node->msg); + node->vq = vq; + node->msg.type = type; + return node;