From 6e96a7de2900c315457b0836691c6673dccdd171 Mon Sep 17 00:00:00 2001 From: Kernel Build Daemon Date: Mar 03 2021 06:20:38 +0000 Subject: Merge branch 'SLE12-SP5' into SLE12-SP5-AZURE --- diff --git a/patches.suse/btrfs-add-zstd-support.patch b/patches.suse/btrfs-add-zstd-support.patch index b41bc46..1f34d48 100644 --- a/patches.suse/btrfs-add-zstd-support.patch +++ b/patches.suse/btrfs-add-zstd-support.patch @@ -67,22 +67,20 @@ Signed-off-by: Nick Terrell Signed-off-by: Chris Mason Acked-by: Johannes Thumshirn --- - fs/btrfs/Kconfig | 2 + - fs/btrfs/Makefile | 2 +- - fs/btrfs/compression.c | 1 + - fs/btrfs/compression.h | 6 +- - fs/btrfs/ctree.h | 1 + - fs/btrfs/disk-io.c | 2 + - fs/btrfs/ioctl.c | 6 +- - fs/btrfs/props.c | 6 + - fs/btrfs/super.c | 12 +- - fs/btrfs/sysfs.c | 2 + - fs/btrfs/zstd.c | 432 +++++++++++++++++++++++++++++++++++++++++++++ - include/uapi/linux/btrfs.h | 8 +- + fs/btrfs/Kconfig | 2 + fs/btrfs/Makefile | 2 + fs/btrfs/compression.c | 1 + fs/btrfs/compression.h | 6 + fs/btrfs/ctree.h | 1 + fs/btrfs/disk-io.c | 2 + fs/btrfs/ioctl.c | 6 + fs/btrfs/props.c | 6 + fs/btrfs/super.c | 12 + + fs/btrfs/sysfs.c | 2 + fs/btrfs/zstd.c | 432 +++++++++++++++++++++++++++++++++++++++++++++ + include/uapi/linux/btrfs.h | 8 12 files changed, 468 insertions(+), 12 deletions(-) -diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig -index 80e9c18ea64f..a26c63b4ad68 100644 --- a/fs/btrfs/Kconfig +++ b/fs/btrfs/Kconfig @@ -6,6 +6,8 @@ config BTRFS_FS @@ -94,11 +92,9 @@ index 80e9c18ea64f..a26c63b4ad68 100644 select RAID6_PQ select XOR_BLOCKS select SRCU -diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile -index 128ce17a80b0..962a95aefb81 100644 --- a/fs/btrfs/Makefile +++ b/fs/btrfs/Makefile -@@ -6,7 +6,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \ +@@ -6,7 +6,7 @@ btrfs-y += super.o ctree.o extent-tree.o transaction.o inode.o file.o tree-defrag.o \ extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \ extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \ @@ -107,11 +103,9 @@ index 128ce17a80b0..962a95aefb81 100644 compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \ reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \ uuid-tree.o props.o hash.o free-space-tree.o -diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c -index d2ef9ac2a630..4ff42d18a64d 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c -@@ -704,6 +704,7 @@ static struct { +@@ -717,6 +717,7 @@ static struct { static const struct btrfs_compress_op * const btrfs_compress_op[] = { &btrfs_zlib_compress, &btrfs_lzo_compress, @@ -119,8 +113,6 @@ index d2ef9ac2a630..4ff42d18a64d 100644 }; void __init btrfs_init_compress(void) -diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h -index 87f6d3332163..2269e00854d8 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h @@ -99,8 +99,9 @@ enum btrfs_compression_type { @@ -142,11 +134,9 @@ index 87f6d3332163..2269e00854d8 100644 +extern const struct btrfs_compress_op btrfs_zstd_compress; #endif -diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h -index 3f3eb7b17cac..845d77c097d6 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h -@@ -270,6 +270,7 @@ struct btrfs_super_block { +@@ -271,6 +271,7 @@ struct btrfs_super_block { BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \ BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \ BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \ @@ -154,11 +144,9 @@ index 3f3eb7b17cac..845d77c097d6 100644 BTRFS_FEATURE_INCOMPAT_RAID56 | \ BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF | \ BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA | \ -diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c -index 080e2ebb8aa0..04632f4de933 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c -@@ -2828,6 +2828,8 @@ int open_ctree(struct super_block *sb, +@@ -2830,6 +2830,8 @@ int open_ctree(struct super_block *sb, features |= BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF; if (fs_info->compress_type == BTRFS_COMPRESS_LZO) features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO; @@ -167,11 +155,9 @@ index 080e2ebb8aa0..04632f4de933 100644 if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA) btrfs_info(fs_info, "has skinny extents"); -diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c -index fa1b78cf25f6..b9963d94d727 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c -@@ -327,8 +327,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) +@@ -327,8 +327,10 @@ static int btrfs_ioctl_setflags(struct f if (fs_info->compress_type == BTRFS_COMPRESS_LZO) comp = "lzo"; @@ -183,7 +169,7 @@ index fa1b78cf25f6..b9963d94d727 100644 ret = btrfs_set_prop(inode, "btrfs.compression", comp, strlen(comp), 0); if (ret) -@@ -1466,6 +1468,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, +@@ -1466,6 +1468,8 @@ int btrfs_defrag_file(struct inode *inod if (range->compress_type == BTRFS_COMPRESS_LZO) { btrfs_set_fs_incompat(fs_info, COMPRESS_LZO); @@ -192,11 +178,9 @@ index fa1b78cf25f6..b9963d94d727 100644 } ret = defrag_count; -diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c -index 4b23ae5d0e5c..20631e9273a0 100644 --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c -@@ -390,6 +390,8 @@ static int prop_compression_validate(const char *value, size_t len) +@@ -383,6 +383,8 @@ static int prop_compression_validate(con return 0; else if (!strncmp("zlib", value, len)) return 0; @@ -205,16 +189,16 @@ index 4b23ae5d0e5c..20631e9273a0 100644 return -EINVAL; } -@@ -412,6 +414,8 @@ static int prop_compression_apply(struct inode *inode, +@@ -405,6 +407,8 @@ static int prop_compression_apply(struct type = BTRFS_COMPRESS_LZO; - else if (!strncmp("zlib", value, len)) + else if (!strncmp("zlib", value, 4)) type = BTRFS_COMPRESS_ZLIB; + else if (!strncmp("zstd", value, len)) + type = BTRFS_COMPRESS_ZSTD; else return -EINVAL; -@@ -429,6 +433,8 @@ static const char *prop_compression_extract(struct inode *inode) +@@ -422,6 +426,8 @@ static const char *prop_compression_extr return "zlib"; case BTRFS_COMPRESS_LZO: return "lzo"; @@ -223,11 +207,9 @@ index 4b23ae5d0e5c..20631e9273a0 100644 } return NULL; -diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c -index 12540b6104b5..c370deadb790 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c -@@ -513,6 +513,14 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, +@@ -514,6 +514,14 @@ int btrfs_parse_options(struct btrfs_fs_ btrfs_clear_opt(info->mount_opt, NODATASUM); btrfs_set_fs_incompat(info, COMPRESS_LZO); no_compress = 0; @@ -242,7 +224,7 @@ index 12540b6104b5..c370deadb790 100644 } else if (strncmp(args[0].from, "no", 2) == 0) { compress_type = "no"; btrfs_clear_opt(info->mount_opt, COMPRESS); -@@ -1227,8 +1235,10 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) +@@ -1241,8 +1249,10 @@ static int btrfs_show_options(struct seq if (btrfs_test_opt(info, COMPRESS)) { if (info->compress_type == BTRFS_COMPRESS_ZLIB) compress_type = "zlib"; @@ -254,11 +236,9 @@ index 12540b6104b5..c370deadb790 100644 if (btrfs_test_opt(info, FORCE_COMPRESS)) seq_printf(seq, ",compress-force=%s", compress_type); else -diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c -index c2d5f3580b4c..2b6d37c09a81 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c -@@ -200,6 +200,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(mixed_backref, MIXED_BACKREF); +@@ -200,6 +200,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(mixed_backref, BTRFS_FEAT_ATTR_INCOMPAT(default_subvol, DEFAULT_SUBVOL); BTRFS_FEAT_ATTR_INCOMPAT(mixed_groups, MIXED_GROUPS); BTRFS_FEAT_ATTR_INCOMPAT(compress_lzo, COMPRESS_LZO); @@ -266,7 +246,7 @@ index c2d5f3580b4c..2b6d37c09a81 100644 BTRFS_FEAT_ATTR_INCOMPAT(big_metadata, BIG_METADATA); BTRFS_FEAT_ATTR_INCOMPAT(extended_iref, EXTENDED_IREF); BTRFS_FEAT_ATTR_INCOMPAT(raid56, RAID56); -@@ -212,6 +213,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = { +@@ -212,6 +213,7 @@ static struct attribute *btrfs_supported BTRFS_FEAT_ATTR_PTR(default_subvol), BTRFS_FEAT_ATTR_PTR(mixed_groups), BTRFS_FEAT_ATTR_PTR(compress_lzo), @@ -274,9 +254,6 @@ index c2d5f3580b4c..2b6d37c09a81 100644 BTRFS_FEAT_ATTR_PTR(big_metadata), BTRFS_FEAT_ATTR_PTR(extended_iref), BTRFS_FEAT_ATTR_PTR(raid56), -diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c -new file mode 100644 -index 000000000000..607ce47b483a --- /dev/null +++ b/fs/btrfs/zstd.c @@ -0,0 +1,432 @@ @@ -712,8 +689,6 @@ index 000000000000..607ce47b483a + .decompress_bio = zstd_decompress_bio, + .decompress = zstd_decompress, +}; -diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h -index 9aa74f317747..378230c163d5 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h @@ -255,13 +255,7 @@ struct btrfs_ioctl_fs_info_args { @@ -731,4 +706,3 @@ index 9aa74f317747..378230c163d5 100644 /* * older kernels tried to do bigger metadata blocks, but the - diff --git a/patches.suse/btrfs-cleanup-try_flush_qgroup.patch b/patches.suse/btrfs-cleanup-try_flush_qgroup.patch new file mode 100644 index 0000000..e538af8 --- /dev/null +++ b/patches.suse/btrfs-cleanup-try_flush_qgroup.patch @@ -0,0 +1,77 @@ +From: Nikolay Borisov +Date: Fri, 19 Feb 2021 12:36:26 +0200 +Subject: btrfs: Cleanup try_flush_qgroup +Patch-mainline: Submitted, 23.02.2021 - btrfs mailing list +References: bsc#1182047 + +It's no longer expected to call this function with an open transaction +so all the hacks concerning this can be removed. In fact it'll +constitute a bug to call this function with a transaction already held +so WARN in this case. + +Acked-by: Nikolay Borisov +--- + fs/btrfs/qgroup.c | 35 +++++++---------------------------- + 1 file changed, 7 insertions(+), 28 deletions(-) + +diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c +index fbef95bc3557..c9e82e0c88e3 100644 +--- a/fs/btrfs/qgroup.c ++++ b/fs/btrfs/qgroup.c +@@ -3535,37 +3535,19 @@ static int try_flush_qgroup(struct btrfs_root *root) + { + struct btrfs_trans_handle *trans; + int ret; +- bool can_commit = true; + +- /* +- * If current process holds a transaction, we shouldn't flush, as we +- * assume all space reservation happens before a transaction handle is +- * held. +- * +- * But there are cases like btrfs_delayed_item_reserve_metadata() where +- * we try to reserve space with one transction handle already held. +- * In that case we can't commit transaction, but at least try to end it +- * and hope the started data writes can free some space. +- */ +- if (current->journal_info && +- current->journal_info != BTRFS_SEND_TRANS_STUB) +- can_commit = false; ++ /* Can't hold an open transaction or we run the risk of deadlocking. */ ++ ASSERT(current->journal_info == NULL || ++ current->journal_info == BTRFS_SEND_TRANS_STUB); ++ if (WARN_ON(current->journal_info && ++ current->journal_info != BTRFS_SEND_TRANS_STUB)) ++ return 0; + + /* + * We don't want to run flush again and again, so if there is a running + * one, we won't try to start a new flush, but exit directly. + */ + if (test_and_set_bit(BTRFS_ROOT_QGROUP_FLUSHING, &root->state)) { +- /* +- * We are already holding a transaction, thus we can block other +- * threads from flushing. So exit right now. This increases +- * the chance of EDQUOT for heavy load and near limit cases. +- * But we can argue that if we're already near limit, EDQUOT is +- * unavoidable anyway. +- */ +- if (!can_commit) +- return 0; +- + wait_event(root->qgroup_flush_wait, + !test_bit(BTRFS_ROOT_QGROUP_FLUSHING, &root->state)); + return 0; +@@ -3582,10 +3564,7 @@ static int try_flush_qgroup(struct btrfs_root *root) + goto out; + } + +- if (can_commit) +- ret = btrfs_commit_transaction(trans); +- else +- ret = btrfs_end_transaction(trans); ++ ret = btrfs_commit_transaction(trans); + out: + clear_bit(BTRFS_ROOT_QGROUP_FLUSHING, &root->state); + wake_up(&root->qgroup_flush_wait); + diff --git a/patches.suse/btrfs-correctly-validate-compression-type.patch b/patches.suse/btrfs-correctly-validate-compression-type.patch new file mode 100644 index 0000000..f1428e5 --- /dev/null +++ b/patches.suse/btrfs-correctly-validate-compression-type.patch @@ -0,0 +1,161 @@ +From: Johannes Thumshirn +Date: Thu, 6 Jun 2019 12:07:15 +0200 +Subject: btrfs: correctly validate compression type +Git-commit: aa53e3bfac7205fb3a8815ac1c937fd6ed01b41e +Patch-mainline: v5.3-rc1 +References: bsc#1182269 + +Nikolay reported the following KASAN splat when running btrfs/048: + +[ 1843.470920] ================================================================== +[ 1843.471971] BUG: KASAN: slab-out-of-bounds in strncmp+0x66/0xb0 +[ 1843.472775] Read of size 1 at addr ffff888111e369e2 by task btrfs/3979 + +[ 1843.473904] CPU: 3 PID: 3979 Comm: btrfs Not tainted 5.2.0-rc3-default #536 +[ 1843.475009] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 +[ 1843.476322] Call Trace: +[ 1843.476674] dump_stack+0x7c/0xbb +[ 1843.477132] ? strncmp+0x66/0xb0 +[ 1843.477587] print_address_description+0x114/0x320 +[ 1843.478256] ? strncmp+0x66/0xb0 +[ 1843.478740] ? strncmp+0x66/0xb0 +[ 1843.479185] __kasan_report+0x14e/0x192 +[ 1843.479759] ? strncmp+0x66/0xb0 +[ 1843.480209] kasan_report+0xe/0x20 +[ 1843.480679] strncmp+0x66/0xb0 +[ 1843.481105] prop_compression_validate+0x24/0x70 +[ 1843.481798] btrfs_xattr_handler_set_prop+0x65/0x160 +[ 1843.482509] __vfs_setxattr+0x71/0x90 +[ 1843.483012] __vfs_setxattr_noperm+0x84/0x130 +[ 1843.483606] vfs_setxattr+0xac/0xb0 +[ 1843.484085] setxattr+0x18c/0x230 +[ 1843.484546] ? vfs_setxattr+0xb0/0xb0 +[ 1843.485048] ? __mod_node_page_state+0x1f/0xa0 +[ 1843.485672] ? _raw_spin_unlock+0x24/0x40 +[ 1843.486233] ? __handle_mm_fault+0x988/0x1290 +[ 1843.486823] ? lock_acquire+0xb4/0x1e0 +[ 1843.487330] ? lock_acquire+0xb4/0x1e0 +[ 1843.487842] ? mnt_want_write_file+0x3c/0x80 +[ 1843.488442] ? debug_lockdep_rcu_enabled+0x22/0x40 +[ 1843.489089] ? rcu_sync_lockdep_assert+0xe/0x70 +[ 1843.489707] ? __sb_start_write+0x158/0x200 +[ 1843.490278] ? mnt_want_write_file+0x3c/0x80 +[ 1843.490855] ? __mnt_want_write+0x98/0xe0 +[ 1843.491397] __x64_sys_fsetxattr+0xba/0xe0 +[ 1843.492201] ? trace_hardirqs_off_thunk+0x1a/0x1c +[ 1843.493201] do_syscall_64+0x6c/0x230 +[ 1843.493988] entry_SYSCALL_64_after_hwframe+0x49/0xbe +[ 1843.495041] RIP: 0033:0x7fa7a8a7707a +[ 1843.495819] Code: 48 8b 0d 21 de 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 be 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ee dd 2b 00 f7 d8 64 89 01 48 +[ 1843.499203] RSP: 002b:00007ffcb73bca38 EFLAGS: 00000202 ORIG_RAX: 00000000000000be +[ 1843.500210] RAX: ffffffffffffffda RBX: 00007ffcb73bda9d RCX: 00007fa7a8a7707a +[ 1843.501170] RDX: 00007ffcb73bda9d RSI: 00000000006dc050 RDI: 0000000000000003 +[ 1843.502152] RBP: 00000000006dc050 R08: 0000000000000000 R09: 0000000000000000 +[ 1843.503109] R10: 0000000000000002 R11: 0000000000000202 R12: 00007ffcb73bda91 +[ 1843.504055] R13: 0000000000000003 R14: 00007ffcb73bda82 R15: ffffffffffffffff + +[ 1843.505268] Allocated by task 3979: +[ 1843.505771] save_stack+0x19/0x80 +[ 1843.506211] __kasan_kmalloc.constprop.5+0xa0/0xd0 +[ 1843.506836] setxattr+0xeb/0x230 +[ 1843.507264] __x64_sys_fsetxattr+0xba/0xe0 +[ 1843.507886] do_syscall_64+0x6c/0x230 +[ 1843.508429] entry_SYSCALL_64_after_hwframe+0x49/0xbe + +[ 1843.509558] Freed by task 0: +[ 1843.510188] (stack is not available) + +[ 1843.511309] The buggy address belongs to the object at ffff888111e369e0 + which belongs to the cache kmalloc-8 of size 8 +[ 1843.514095] The buggy address is located 2 bytes inside of + 8-byte region [ffff888111e369e0, ffff888111e369e8) +[ 1843.516524] The buggy address belongs to the page: +[ 1843.517561] page:ffff88813f478d80 refcount:1 mapcount:0 mapping:ffff88811940c300 index:0xffff888111e373b8 compound_mapcount: 0 +[ 1843.519993] flags: 0x4404000010200(slab|head) +[ 1843.520951] raw: 0004404000010200 ffff88813f48b008 ffff888119403d50 ffff88811940c300 +[ 1843.522616] raw: ffff888111e373b8 000000000016000f 00000001ffffffff 0000000000000000 +[ 1843.524281] page dumped because: kasan: bad access detected + +[ 1843.525936] Memory state around the buggy address: +[ 1843.526975] ffff888111e36880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 1843.528479] ffff888111e36900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 1843.530138] >ffff888111e36980: fc fc fc fc fc fc fc fc fc fc fc fc 02 fc fc fc +[ 1843.531877] ^ +[ 1843.533287] ffff888111e36a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 1843.534874] ffff888111e36a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 1843.536468] ================================================================== + +This is caused by supplying a too short compression value ('lz') in the +test-case and comparing it to 'lzo' with strncmp() and a length of 3. +strncmp() read past the 'lz' when looking for the 'o' and thus caused an +out-of-bounds read. + +Introduce a new check 'btrfs_compress_is_valid_type()' which not only +checks the user-supplied value against known compression types, but also +employs checks for too short values. + +Reported-by: Nikolay Borisov +Fixes: 272e5326c783 ("btrfs: prop: fix vanished compression property after failed set") +CC: stable@vger.kernel.org # 5.1+ +Reviewed-by: Nikolay Borisov +Signed-off-by: Johannes Thumshirn +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Acked-by: Nikolay Borisov +--- + fs/btrfs/compression.c | 18 ++++++++++++++++++ + fs/btrfs/compression.h | 2 ++ + fs/btrfs/props.c | 6 +----- + 3 files changed, 21 insertions(+), 5 deletions(-) + +--- a/fs/btrfs/compression.c ++++ b/fs/btrfs/compression.c +@@ -42,6 +42,24 @@ + #include "extent_io.h" + #include "extent_map.h" + ++static const char* const btrfs_compress_types[] = { "", "zlib", "lzo", "zstd" }; ++ ++bool btrfs_compress_is_valid_type(const char *str, size_t len) ++{ ++ int i; ++ ++ for (i = 1; i < ARRAY_SIZE(btrfs_compress_types); i++) { ++ size_t comp_len = strlen(btrfs_compress_types[i]); ++ ++ if (len < comp_len) ++ continue; ++ ++ if (!strncmp(btrfs_compress_types[i], str, comp_len)) ++ return true; ++ } ++ return false; ++} ++ + static int btrfs_decompress_bio(struct compressed_bio *cb); + + static inline int compressed_bio_size(struct btrfs_fs_info *fs_info, +--- a/fs/btrfs/compression.h ++++ b/fs/btrfs/compression.h +@@ -131,4 +131,6 @@ extern const struct btrfs_compress_op bt + extern const struct btrfs_compress_op btrfs_lzo_compress; + extern const struct btrfs_compress_op btrfs_zstd_compress; + ++bool btrfs_compress_is_valid_type(const char *str, size_t len); ++ + #endif +--- a/fs/btrfs/props.c ++++ b/fs/btrfs/props.c +@@ -379,11 +379,7 @@ int btrfs_subvol_inherit_props(struct bt + + static int prop_compression_validate(const char *value, size_t len) + { +- if (!strncmp("lzo", value, 3)) +- return 0; +- else if (!strncmp("zlib", value, 4)) +- return 0; +- else if (!strncmp("zstd", value, 4)) ++ if (btrfs_compress_is_valid_type(value, len)) + return 0; + + return -EINVAL; diff --git a/patches.suse/btrfs-don-t-flush-from-btrfs_delayed_inode_reserve_metadata.patch b/patches.suse/btrfs-don-t-flush-from-btrfs_delayed_inode_reserve_metadata.patch new file mode 100644 index 0000000..c094ecd --- /dev/null +++ b/patches.suse/btrfs-don-t-flush-from-btrfs_delayed_inode_reserve_metadata.patch @@ -0,0 +1,135 @@ +From: Nikolay Borisov +Date: Fri, 19 Feb 2021 12:09:43 +0200 +Subject: btrfs: Don't flush from btrfs_delayed_inode_reserve_metadata +Patch-mainline: Submitted, 23.02.2021 - btrfs mailing list +References: bsc#1182047 + +Calling btrfs_qgroup_reserve_meta_prealloc from +btrfs_delayed_inode_reserve_metadata can result in flushing delalloc +while holding a transaction and delayed node locks. This is is dead-lock +prone. In the past multiple commits: + + * ae5e070eaca9 ("btrfs: qgroup: don't try to wait flushing if we're +already holding a transaction") + + * 6f23277a49e6 ("btrfs: qgroup: don't commit transaction when we already + hold the handle") + +Tried to solve various aspects of this but this was always a +whack-a-mole game. Unfortunately those 2 fixes don't solve a deadlock +scenario involving btrfs_delayed_node::mutex. Namely, one thread +can call btrfs_dirty_inode as a result of reading a file and modifying +its atime: + +> PID: 6963 TASK: ffff8c7f3f94c000 CPU: 2 COMMAND: "http-0.0.0.0-62" +> #0 [ffffaedd02a67a00] __schedule at ffffffffa529e07d +> #1 [ffffaedd02a67a90] schedule at ffffffffa529e4ff +> #2 [ffffaedd02a67aa0] schedule_timeout at ffffffffa52a1bdd +> #3 [ffffaedd02a67b18] wait_for_completion at ffffffffa529eeea <-- sleeps with delayed node mutex held +> #4 [ffffaedd02a67b68] start_delalloc_inodes at ffffffffc0380db5 [btrfs] +> #5 [ffffaedd02a67be8] btrfs_start_delalloc_snapshot at ffffffffc0393836 [btrfs] +> #6 [ffffaedd02a67bf0] try_flush_qgroup at ffffffffc03f04b2 [btrfs] +> #7 [ffffaedd02a67c40] __btrfs_qgroup_reserve_meta at ffffffffc03f5bb6 [btrfs] <-- tries to reserve space and starts delalloc inodes. +> #8 [ffffaedd02a67c68] btrfs_delayed_update_inode at ffffffffc03e31aa [btrfs] <-- Acquires delayed node mutex +> #9 [ffffaedd02a67cc0] btrfs_update_inode at ffffffffc0385ba8 [btrfs] +> #10 [ffffaedd02a67ce8] btrfs_dirty_inode at ffffffffc038627b [btrfs] <-- TRANSACTIION OPENED +> #11 [ffffaedd02a67d18] touch_atime at ffffffffa4cf0000 +> #12 [ffffaedd02a67d58] generic_file_read_iter at ffffffffa4c1f123 +> #13 [ffffaedd02a67e40] new_sync_read at ffffffffa4ccdc8a +> #14 [ffffaedd02a67ec8] vfs_read at ffffffffa4cd0849 +> #15 [ffffaedd02a67ef8] ksys_read at ffffffffa4cd0bd1 +> #16 [ffffaedd02a67f38] do_syscall_64 at ffffffffa4a052eb +> #17 [ffffaedd02a67f50] entry_SYSCALL_64_after_hwframe at ffffffffa540008c + +This will cause an asynchronous work to flush the delalloc inodes to +happen which can try to acquire the same delayed_node mutex: + +> PID: 455 TASK: ffff8c8085fa4000 CPU: 5 COMMAND: "kworker/u16:30" +> #0 [ffffaedd009f77b0] __schedule at ffffffffa529e07d +> #1 [ffffaedd009f7840] schedule at ffffffffa529e4ff +> #2 [ffffaedd009f7850] schedule_preempt_disabled at ffffffffa529e80a +> #3 [ffffaedd009f7858] __mutex_lock at ffffffffa529fdcb <--- goes to sleep, never wakes up. +> #4 [ffffaedd009f78f8] btrfs_delayed_update_inode at ffffffffc03e3143 [btrfs] <-- tries to acquire the mutex +> #5 [ffffaedd009f7950] btrfs_update_inode at ffffffffc0385ba8 [btrfs] <-- This is the same inode that pid 6963 is holding +> #6 [ffffaedd009f7978] cow_file_range_inline.constprop.78 at ffffffffc0386be7 [btrfs] +> #7 [ffffaedd009f7a30] cow_file_range at ffffffffc03879c1 [btrfs] +> #8 [ffffaedd009f7ab8] btrfs_run_delalloc_range at ffffffffc038894c [btrfs] +> #9 [ffffaedd009f7b40] writepage_delalloc at ffffffffc03a3c8f [btrfs] +> #10 [ffffaedd009f7ba0] __extent_writepage at ffffffffc03a4c01 [btrfs] +> #11 [ffffaedd009f7c08] extent_write_cache_pages at ffffffffc03a500b [btrfs] +> #12 [ffffaedd009f7d08] extent_writepages at ffffffffc03a6de2 [btrfs] +> #13 [ffffaedd009f7d38] do_writepages at ffffffffa4c277eb +> #14 [ffffaedd009f7db8] __filemap_fdatawrite_range at ffffffffa4c1e5bb +> #15 [ffffaedd009f7e40] btrfs_run_delalloc_work at ffffffffc0380987 [btrfs] <-- starts running delayed nodes +> #16 [ffffaedd009f7e58] normal_work_helper at ffffffffc03b706c [btrfs] +> #17 [ffffaedd009f7e98] process_one_work at ffffffffa4aba4e4 +> #18 [ffffaedd009f7ed8] worker_thread at ffffffffa4aba6fd +> #19 [ffffaedd009f7f10] kthread at ffffffffa4ac0a3d +> #20 [ffffaedd009f7f50] ret_from_fork at ffffffffa54001ff + +To fully address those cases the complete fix is to never issue any +flushing while holding the transaction or the delayed node lock. This +patch achieves it by calling qgroup_reserve_meta directly which will +either succeed without flushing or will fail and return -EDQUOT. In the +latter case that return value is going to be propagated to +btrfs_dirty_inode which will fallback to start a new transaction. That's +fine as the majority of time we expect the inode will have +BTRFS_DELAYED_NODE_INODE_DIRTY flag set which will result in directly +copying the in-memory state. + +Acked-by: Nikolay Borisov +--- + fs/btrfs/delayed-inode.c | 3 ++- + fs/btrfs/inode.c | 2 +- + fs/btrfs/qgroup.c | 4 ++-- + fs/btrfs/qgroup.h | 3 +++ + 4 files changed, 8 insertions(+), 4 deletions(-) + +--- a/fs/btrfs/delayed-inode.c ++++ b/fs/btrfs/delayed-inode.c +@@ -612,7 +612,8 @@ static int btrfs_delayed_inode_reserve_m + */ + if (!src_rsv || (!trans->bytes_reserved && + src_rsv->type != BTRFS_BLOCK_RSV_DELALLOC)) { +- ret = btrfs_qgroup_reserve_meta_prealloc(root, num_bytes, true); ++ ret = qgroup_reserve_meta(root, num_bytes, ++ BTRFS_QGROUP_RSV_META_PREALLOC, true); + if (ret < 0) + return ret; + ret = btrfs_block_rsv_add(root, dst_rsv, num_bytes, +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -5997,7 +5997,7 @@ static int btrfs_dirty_inode(struct inod + return PTR_ERR(trans); + + ret = btrfs_update_inode(trans, root, inode); +- if (ret && ret == -ENOSPC) { ++ if (ret && (ret == -ENOSPC || ret == -EDQUOT)) { + /* whoops, lets try again with the full transaction */ + btrfs_end_transaction(trans); + trans = btrfs_start_transaction(root, 1); +--- a/fs/btrfs/qgroup.c ++++ b/fs/btrfs/qgroup.c +@@ -3775,8 +3775,8 @@ static int sub_root_meta_rsv(struct btrf + return num_bytes; + } + +-static int qgroup_reserve_meta(struct btrfs_root *root, int num_bytes, +- enum btrfs_qgroup_rsv_type type, bool enforce) ++int qgroup_reserve_meta(struct btrfs_root *root, int num_bytes, ++ enum btrfs_qgroup_rsv_type type, bool enforce) + { + struct btrfs_fs_info *fs_info = root->fs_info; + int ret; +--- a/fs/btrfs/qgroup.h ++++ b/fs/btrfs/qgroup.h +@@ -343,6 +343,9 @@ int btrfs_verify_qgroup_counts(struct bt + u64 rfer, u64 excl); + #endif + ++int qgroup_reserve_meta(struct btrfs_root *root, int num_bytes, ++ enum btrfs_qgroup_rsv_type type, bool enforce); ++ + /* New io_tree based accurate qgroup reserve API */ + int btrfs_qgroup_reserve_data(struct inode *inode, + struct extent_changeset **reserved, u64 start, u64 len); diff --git a/patches.suse/btrfs-free-correct-amount-of-space-in-btrfs_delayed_inode_reserve_metadata.patch b/patches.suse/btrfs-free-correct-amount-of-space-in-btrfs_delayed_inode_reserve_metadata.patch new file mode 100644 index 0000000..8ef4d4d --- /dev/null +++ b/patches.suse/btrfs-free-correct-amount-of-space-in-btrfs_delayed_inode_reserve_metadata.patch @@ -0,0 +1,34 @@ +From: Nikolay Borisov +Date: Tue, 16 Feb 2021 17:28:16 +0200 +Subject: btrfs: Free correct amount of space in + btrfs_delayed_inode_reserve_metadata +Patch-mainline: Submitted, 23.02.2020 - btrfs mailing list +References: bsc#1182047 + +Following commit f218ea6c4792 ("btrfs: delayed-inode: Remove wrong +qgroup meta reservation calls") this function now reserves num_bytes, +rather than the fixed amount of nodesize. As such this requires the +same amount to be freed in case of failure. Fix this by adjusting +the amount we are freeing. + +Fixes f218ea6c4792 ("btrfs: delayed-inode: Remove wrong qgroup meta reservation calls") + +Acked-by: Nikolay Borisov +--- + fs/btrfs/delayed-inode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c +index ec0b50b8c5d6..ac9966e76a2f 100644 +--- a/fs/btrfs/delayed-inode.c ++++ b/fs/btrfs/delayed-inode.c +@@ -649,7 +649,7 @@ static int btrfs_delayed_inode_reserve_metadata( + btrfs_ino(inode), + num_bytes, 1); + } else { +- btrfs_qgroup_free_meta_prealloc(root, fs_info->nodesize); ++ btrfs_qgroup_free_meta_prealloc(root, num_bytes); + } + return ret; + } + diff --git a/patches.suse/btrfs-prepare-for-extensions-in-compression-options.patch b/patches.suse/btrfs-prepare-for-extensions-in-compression-options.patch new file mode 100644 index 0000000..e37efdb --- /dev/null +++ b/patches.suse/btrfs-prepare-for-extensions-in-compression-options.patch @@ -0,0 +1,66 @@ +From: David Sterba +Date: Mon, 17 Jul 2017 18:11:10 +0200 +Subject: btrfs: prepare for extensions in compression options +Git-commit: a7164fa4e055daf6368cb68ed946aa5a362a1a75 +Patch-mainline: v4.14-rc1 +References: bsc#1182269 + +This is a minimal patch intended to be backported to older kernels. +We're going to extend the string specifying the compression method and +this would fail on kernels before that change (the string is compared +exactly). + +Relax the string matching only to the prefix, ie. ignoring anything that +goes after "zlib" or "lzo", regardless of th format extension we decide +to use. This applies to the mount options and properties. + +That way, patched old kernels could be booted on systems already +utilizing the new compression spec. + +Applicable since commit 63541927c8d11, v3.14. + +Signed-off-by: David Sterba +Acked-by: Nikolay Borisov +--- + fs/btrfs/props.c | 4 ++-- + fs/btrfs/super.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c +index 916f5cf9b292..09c0266f248d 100644 +--- a/fs/btrfs/props.c ++++ b/fs/btrfs/props.c +@@ -408,9 +408,9 @@ static int prop_compression_apply(struct inode *inode, + return 0; + } + +- if (!strncmp("lzo", value, len)) ++ if (!strncmp("lzo", value, 3)) + type = BTRFS_COMPRESS_LZO; +- else if (!strncmp("zlib", value, len)) ++ else if (!strncmp("zlib", value, 4)) + type = BTRFS_COMPRESS_ZLIB; + else + return -EINVAL; +diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c +index 64981fc8e39e..8a9bcad3b06a 100644 +--- a/fs/btrfs/super.c ++++ b/fs/btrfs/super.c +@@ -499,14 +499,14 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, + btrfs_test_opt(info, FORCE_COMPRESS); + if (token == Opt_compress || + token == Opt_compress_force || +- strcmp(args[0].from, "zlib") == 0) { ++ strncmp(args[0].from, "zlib", 4) == 0) { + compress_type = "zlib"; + info->compress_type = BTRFS_COMPRESS_ZLIB; + btrfs_set_opt(info->mount_opt, COMPRESS); + btrfs_clear_opt(info->mount_opt, NODATACOW); + btrfs_clear_opt(info->mount_opt, NODATASUM); + no_compress = 0; +- } else if (strcmp(args[0].from, "lzo") == 0) { ++ } else if (strncmp(args[0].from, "lzo", 3) == 0) { + compress_type = "lzo"; + info->compress_type = BTRFS_COMPRESS_LZO; + btrfs_set_opt(info->mount_opt, COMPRESS); + diff --git a/patches.suse/btrfs-prop-fix-vanished-compression-property-after-failed-set.patch b/patches.suse/btrfs-prop-fix-vanished-compression-property-after-failed-set.patch new file mode 100644 index 0000000..a75b9c6 --- /dev/null +++ b/patches.suse/btrfs-prop-fix-vanished-compression-property-after-failed-set.patch @@ -0,0 +1,53 @@ +From: Anand Jain +Date: Tue, 2 Apr 2019 18:07:40 +0800 +Subject: btrfs: prop: fix vanished compression property after failed set +Git-commit: 272e5326c7837697882ce3162029ba893059b616 +Patch-mainline: v5.1-rc5 +References: bsc#1182269 + +The compression property resets to NULL, instead of the old value if we +fail to set the new compression parameter. + + $ btrfs prop get /btrfs compression + compression=lzo + $ btrfs prop set /btrfs compression zli + ERROR: failed to set compression for /btrfs: Invalid argument + $ btrfs prop get /btrfs compression + +This is because the compression property ->validate() is successful for +'zli' as the strncmp() used the length passed from the userspace. + +Fix it by using the expected string length in strncmp(). + +Fixes: 63541927c8d1 ("Btrfs: add support for inode properties") +Fixes: 5c1aab1dd544 ("btrfs: Add zstd support") +CC: stable@vger.kernel.org # 4.14+ +Reviewed-by: Nikolay Borisov +Signed-off-by: Anand Jain +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Acked-by: Nikolay Borisov +--- + fs/btrfs/props.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c +index fd19f3078566..61d22a56c0ba 100644 +--- a/fs/btrfs/props.c ++++ b/fs/btrfs/props.c +@@ -366,11 +366,11 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans, + + static int prop_compression_validate(const char *value, size_t len) + { +- if (!strncmp("lzo", value, len)) ++ if (!strncmp("lzo", value, 3)) + return 0; +- else if (!strncmp("zlib", value, len)) ++ else if (!strncmp("zlib", value, 4)) + return 0; +- else if (!strncmp("zstd", value, len)) ++ else if (!strncmp("zstd", value, 4)) + return 0; + + return -EINVAL; + diff --git a/patches.suse/btrfs-prop-fix-zstd-compression-parameter-validation.patch b/patches.suse/btrfs-prop-fix-zstd-compression-parameter-validation.patch new file mode 100644 index 0000000..b3d8dce --- /dev/null +++ b/patches.suse/btrfs-prop-fix-zstd-compression-parameter-validation.patch @@ -0,0 +1,40 @@ +From: Anand Jain +Date: Tue, 2 Apr 2019 18:07:38 +0800 +Subject: btrfs: prop: fix zstd compression parameter validation +Git-commit: 50398fde997f6be8faebdb5f38e9c9c467370f51 +Patch-mainline: v5.1-rc5 +References: bsc#1182269 + +We let pass zstd compression parameter even if it is not fully valid. +For example: + + $ btrfs prop set /btrfs compression zst + $ btrfs prop get /btrfs compression + compression=zst + +zlib and lzo are fine. + +Fix it by checking the correct prefix length. + +Fixes: 5c1aab1dd544 ("btrfs: Add zstd support") +CC: stable@vger.kernel.org # 4.14+ +Reviewed-by: Nikolay Borisov +Signed-off-by: Anand Jain +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Acked-by: Nikolay Borisov +--- + fs/btrfs/props.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/btrfs/props.c ++++ b/fs/btrfs/props.c +@@ -407,7 +407,7 @@ static int prop_compression_apply(struct + type = BTRFS_COMPRESS_LZO; + else if (!strncmp("zlib", value, 4)) + type = BTRFS_COMPRESS_ZLIB; +- else if (!strncmp("zstd", value, len)) ++ else if (!strncmp("zstd", value, 4)) + type = BTRFS_COMPRESS_ZSTD; + else + return -EINVAL; diff --git a/patches.suse/btrfs-remove-btrfs_inode-from-btrfs_delayed_inode_reserve_metadata.patch b/patches.suse/btrfs-remove-btrfs_inode-from-btrfs_delayed_inode_reserve_metadata.patch new file mode 100644 index 0000000..3e1dec4 --- /dev/null +++ b/patches.suse/btrfs-remove-btrfs_inode-from-btrfs_delayed_inode_reserve_metadata.patch @@ -0,0 +1,52 @@ +From: Nikolay Borisov +Date: Tue, 16 Feb 2021 17:37:13 +0200 +Subject: btrfs: Remove btrfs_inode from btrfs_delayed_inode_reserve_metadata +Patch-mainline: Submitted, 23.02.2021 - btrfs mailing list +References: bsc#1182047 + +It's only used for tracepoint to obtain the ino, but we already have +the ino from btrfs_delayed_node::inode_id. + +Acked-by: Nikolay Borisov +--- + fs/btrfs/delayed-inode.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +--- a/fs/btrfs/delayed-inode.c ++++ b/fs/btrfs/delayed-inode.c +@@ -587,7 +587,6 @@ static void btrfs_delayed_item_release_m + static int btrfs_delayed_inode_reserve_metadata( + struct btrfs_trans_handle *trans, + struct btrfs_root *root, +- struct btrfs_inode *inode, + struct btrfs_delayed_node *node) + { + struct btrfs_fs_info *fs_info = root->fs_info; +@@ -632,7 +631,7 @@ static int btrfs_delayed_inode_reserve_m + node->bytes_reserved = num_bytes; + trace_btrfs_space_reservation(fs_info, + "delayed_inode", +- btrfs_ino(inode), ++ node->inode_id, + num_bytes, 1); + } else { + btrfs_qgroup_free_meta_prealloc(root, num_bytes); +@@ -643,7 +642,7 @@ static int btrfs_delayed_inode_reserve_m + ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes, 1); + if (!ret) { + trace_btrfs_space_reservation(fs_info, "delayed_inode", +- btrfs_ino(inode), num_bytes, 1); ++ node->inode_id, num_bytes, 1); + node->bytes_reserved = num_bytes; + } + +@@ -1812,8 +1811,7 @@ int btrfs_delayed_update_inode(struct bt + goto release_node; + } + +- ret = btrfs_delayed_inode_reserve_metadata(trans, root, BTRFS_I(inode), +- delayed_node); ++ ret = btrfs_delayed_inode_reserve_metadata(trans, root, delayed_node); + if (ret) + goto release_node; + diff --git a/patches.suse/btrfs-simplify-code-flow-in-btrfs_delayed_inode_reserve_metadata.patch b/patches.suse/btrfs-simplify-code-flow-in-btrfs_delayed_inode_reserve_metadata.patch new file mode 100644 index 0000000..21f7c61 --- /dev/null +++ b/patches.suse/btrfs-simplify-code-flow-in-btrfs_delayed_inode_reserve_metadata.patch @@ -0,0 +1,50 @@ +From: Nikolay Borisov +Date: Wed, 17 Feb 2021 09:30:31 +0200 +Subject: btrfs: Simplify code flow in btrfs_delayed_inode_reserve_metadata +Patch-mainline: Submitted, 23.02.2021 - btrfs mailing list +References: bsc#1182047 + +btrfs_block_rsv_add can return only ENOSPC since it's called with +NO_FLUSH modifier. This so simplify the logic in +btrfs_delayed_inode_reserve_metadata to exploit this invariant. + +Acked-by: Nikolay Borisov +--- + fs/btrfs/delayed-inode.c | 23 +++-------------------- + 1 file changed, 3 insertions(+), 20 deletions(-) + +--- a/fs/btrfs/delayed-inode.c ++++ b/fs/btrfs/delayed-inode.c +@@ -617,29 +617,12 @@ static int btrfs_delayed_inode_reserve_m + return ret; + ret = btrfs_block_rsv_add(root, dst_rsv, num_bytes, + BTRFS_RESERVE_NO_FLUSH); +- /* +- * Since we're under a transaction reserve_metadata_bytes could +- * try to commit the transaction which will make it return +- * EAGAIN to make us stop the transaction we have, so return +- * ENOSPC instead so that btrfs_dirty_inode knows what to do. +- */ +- if (ret == -EAGAIN) { +- ret = -ENOSPC; ++ if (ret) + btrfs_qgroup_free_meta_prealloc(root, num_bytes); +- } +- if (!ret) { +- node->bytes_reserved = num_bytes; +- trace_btrfs_space_reservation(fs_info, +- "delayed_inode", +- node->inode_id, +- num_bytes, 1); +- } else { +- btrfs_qgroup_free_meta_prealloc(root, num_bytes); +- } +- return ret; ++ } else { ++ ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes, 1); + } + +- ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes, 1); + if (!ret) { + trace_btrfs_space_reservation(fs_info, "delayed_inode", + node->inode_id, num_bytes, 1); diff --git a/patches.suse/btrfs-unlock-extents-in-btrfs_zero_range-in-case-of-errors.patch b/patches.suse/btrfs-unlock-extents-in-btrfs_zero_range-in-case-of-errors.patch new file mode 100644 index 0000000..255f640 --- /dev/null +++ b/patches.suse/btrfs-unlock-extents-in-btrfs_zero_range-in-case-of-errors.patch @@ -0,0 +1,33 @@ +From: Nikolay Borisov +Date: Tue, 23 Feb 2021 15:17:43 +0200 +Subject: btrfs: Unlock extents in btrfs_zero_range in case of errors +Patch-mainline: Submitted, 23.02.2021 - btrfs mailing list +References: bsc#1182047 + +If btrfs_qgroup_reserve_data returns an error (i.e quota limit reached) +the handling logic directly goes to the 'out' label without first +unlocking the extent range between lockstart, lockend. This results in +deadlocks as processes try to lock the same extent. + +Fixes: a7f8b1c2ac21 ("btrfs: file: reserve qgroup space after the hole punch range is locked") + +Acked-by: Nikolay Borisov +--- + fs/btrfs/file.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/fs/btrfs/file.c ++++ b/fs/btrfs/file.c +@@ -3006,8 +3006,11 @@ reserve_space: + goto out; + ret = btrfs_qgroup_reserve_data(inode, &data_reserved, + alloc_start, bytes_to_reserve); +- if (ret) ++ if (ret) { ++ unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, ++ lockend, &cached_state, GFP_KERNEL); + goto out; ++ } + ret = btrfs_prealloc_file_range(inode, mode, alloc_start, + alloc_end - alloc_start, + i_blocksize(inode), diff --git a/patches.suse/msft-hv-2226-Drivers-hv-vmbus-Avoid-use-after-free-in-vmbus_onoff.patch b/patches.suse/msft-hv-2226-Drivers-hv-vmbus-Avoid-use-after-free-in-vmbus_onoff.patch new file mode 100644 index 0000000..57a648d --- /dev/null +++ b/patches.suse/msft-hv-2226-Drivers-hv-vmbus-Avoid-use-after-free-in-vmbus_onoff.patch @@ -0,0 +1,39 @@ +From: "Andrea Parri (Microsoft)" +Date: Wed, 9 Dec 2020 08:08:25 +0100 +Patch-mainline: v5.12-rc1 +Subject: Drivers: hv: vmbus: Avoid use-after-free in vmbus_onoffer_rescind() +Git-commit: e3fa4b747f085d2cda09bba0533b86fa76038635 +References: git-fixes + +When channel->device_obj is non-NULL, vmbus_onoffer_rescind() could +invoke put_device(), that will eventually release the device and free +the channel object (cf. vmbus_device_release()). However, a pointer +to the object is dereferenced again later to load the primary_channel. +The use-after-free can be avoided by noticing that this load/check is +redundant if device_obj is non-NULL: primary_channel must be NULL if +device_obj is non-NULL, cf. vmbus_add_channel_work(). + +Fixes: 54a66265d6754b ("Drivers: hv: vmbus: Fix rescind handling") +Reported-by: Juan Vazquez +Signed-off-by: Andrea Parri (Microsoft) +Reviewed-by: Michael Kelley +Link: https://lore.kernel.org/r/20201209070827.29335-5-parri.andrea@gmail.com +Signed-off-by: Wei Liu +Acked-by: Olaf Hering +--- + drivers/hv/channel_mgmt.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c +--- a/drivers/hv/channel_mgmt.c ++++ b/drivers/hv/channel_mgmt.c +@@ -1116,8 +1116,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) + vmbus_device_unregister(channel->device_obj); + put_device(dev); + } +- } +- if (channel->primary_channel != NULL) { ++ } else if (channel->primary_channel != NULL) { + /* + * Sub-channel is being rescinded. Following is the channel + * close sequence when initiated from the driveri (refer to diff --git a/patches.suse/powerpc-pseries-eeh-Make-pseries_pcibios_bus_add_dev.patch b/patches.suse/powerpc-pseries-eeh-Make-pseries_pcibios_bus_add_dev.patch new file mode 100644 index 0000000..4b24609 --- /dev/null +++ b/patches.suse/powerpc-pseries-eeh-Make-pseries_pcibios_bus_add_dev.patch @@ -0,0 +1,43 @@ +From 44159329e0ad160af7cc7e84fa6d97531c8ed78f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= +Date: Mon, 4 Jan 2021 15:31:46 +0100 +Subject: [PATCH] powerpc/pseries/eeh: Make pseries_pcibios_bus_add_device() + static +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +References: FATE#324970, bsc#1078720, git-fixes +Patch-mainline: v5.12-rc1 +Git-commit: 44159329e0ad160af7cc7e84fa6d97531c8ed78f + +pseries_pcibios_bus_add_device() is a local routine defining the +pcibios_bus_add_device() handler of the pseries machine in +eeh_pseries_init(). It doesn't need to be external. + +It fixes this W=1 compile error: + +../arch/powerpc/platforms/pseries/eeh_pseries.c:46:6: error: no previous prototype for ‘pseries_pcibios_bus_add_device’ [-Werror=missing-prototypes] + 46 | void pseries_pcibios_bus_add_device(struct pci_dev *pdev) + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Fixes: dae7253f9f78 ("powerpc/pseries: Add pseries SR-IOV Machine dependent calls") +Signed-off-by: Cédric Le Goater +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20210104143206.695198-4-clg@kaod.org +Acked-by: Michal Suchanek +--- + arch/powerpc/platforms/pseries/eeh_pseries.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/powerpc/platforms/pseries/eeh_pseries.c ++++ b/arch/powerpc/platforms/pseries/eeh_pseries.c +@@ -57,7 +57,7 @@ static int ibm_get_config_addr_info2; + static int ibm_configure_pe; + + #ifdef CONFIG_PCI_IOV +-void pseries_pcibios_bus_add_device(struct pci_dev *pdev) ++static void pseries_pcibios_bus_add_device(struct pci_dev *pdev) + { + struct pci_dn *pdn = pci_get_pdn(pdev); + struct pci_dn *physfn_pdn; diff --git a/patches.suse/powerpc-pseries-ras-Make-init_ras_hotplug_IRQ-static.patch b/patches.suse/powerpc-pseries-ras-Make-init_ras_hotplug_IRQ-static.patch new file mode 100644 index 0000000..4d5b14f --- /dev/null +++ b/patches.suse/powerpc-pseries-ras-Make-init_ras_hotplug_IRQ-static.patch @@ -0,0 +1,46 @@ +From 90db8bf24d133654032a1c7dd46aa5096627b9ff Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= +Date: Mon, 4 Jan 2021 15:31:47 +0100 +Subject: [PATCH] powerpc/pseries/ras: Make init_ras_hotplug_IRQ() static +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +References: FATE#322022, bsc#1065729. git-fixes +Patch-mainline: v5.12-rc1 +Git-commit: 90db8bf24d133654032a1c7dd46aa5096627b9ff + +init_ras_hotplug_IRQ() is a local routine used by a machine init call +and it doesn't need to be external. + +It fixes this W=1 compile error: + +../arch/powerpc/platforms/pseries/ras.c:125:12: error: no previous prototype for ‘init_ras_hotplug_IRQ’ [-Werror=missing-prototypes] + 125 | int __init init_ras_hotplug_IRQ(void) + | ^~~~~~~~~~~~~~~~~~~~ + +Fixes: c9dccf1d074a ("powerpc/pseries: Enable RAS hotplug events later") +Signed-off-by: Cédric Le Goater +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20210104143206.695198-5-clg@kaod.org +Acked-by: Michal Suchanek +--- + arch/powerpc/platforms/pseries/ras.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c +index bcb614ffce6a..d2fca1aa6742 100644 +--- a/arch/powerpc/platforms/pseries/ras.c ++++ b/arch/powerpc/platforms/pseries/ras.c +@@ -122,7 +122,7 @@ static inline u8 rtas_mc_error_sub_type(const struct pseries_mc_errorlog *mlog) + * devices or systems (e.g. hugepages) that have not been initialized at the + * subsys stage. + */ +-int __init init_ras_hotplug_IRQ(void) ++static int __init init_ras_hotplug_IRQ(void) + { + struct device_node *np; + +-- +2.26.2 + diff --git a/series.conf b/series.conf index 70b6163..d05ae85 100644 --- a/series.conf +++ b/series.conf @@ -10343,6 +10343,7 @@ patches.suse/0013-btrfs-clean-up-extraneous-computations-in-add_delaye.patch patches.suse/btrfs-remove-redundant-argument-of-flush_space.patch patches.suse/btrfs-use-GFP_KERNEL-in-mount-and-remount.patch + patches.suse/btrfs-prepare-for-extensions-in-compression-options.patch patches.suse/btrfs-account-for-pinned-bytes-in-should_alloc_chunk.patch patches.suse/btrfs-fix-readdir-deadlock-with-pagefault.patch patches.suse/0001-Btrfs-fix-assertion-failure-during-fsync-in-no-holes.patch @@ -48295,6 +48296,8 @@ patches.suse/RDMA-hns-Fix-bug-that-caused-srq-creation-to-fail.patch patches.suse/RDMA-hns-Bugfix-for-SCC-hem-free.patch patches.suse/btrfs-do-not-allow-trimming-when-a-fs-is-mounted-wit.patch + patches.suse/btrfs-prop-fix-zstd-compression-parameter-validation.patch + patches.suse/btrfs-prop-fix-vanished-compression-property-after-failed-set.patch patches.suse/0001-drm-udl-add-a-release-method-and-delay-modeset-teard.patch patches.suse/0003-drm-mediatek-Fix-an-error-code-in-mtk_hdmi_dt_parse_.patch patches.suse/drm-mediatek-fix-possible-object-reference-leak.patch @@ -51014,6 +51017,7 @@ patches.suse/btrfs-Always-use-a-cached-extent_state-in-btrfs_lock.patch patches.suse/btrfs-Return-EAGAIN-if-we-can-t-start-no-snpashot-wr.patch patches.suse/btrfs-fix-data-loss-after-inode-eviction-renaming-it.patch + patches.suse/btrfs-correctly-validate-compression-type.patch patches.suse/btrfs-qgroup-Don-t-hold-qgroup_ioctl_lock-in-btrfs_q.patch patches.suse/Btrfs-prevent-send-failures-and-crashes-due-to-concu.patch patches.suse/btrfs-fix-fsync-not-persisting-dentry-deletions-due-.patch @@ -57983,6 +57987,7 @@ patches.suse/ACPI-property-Satisfy-kernel-doc-validator-part-1.patch patches.suse/ACPI-configfs-add-missing-check-after-configfs_regis.patch patches.suse/xfs-reduce-quota-reservation-when-doing-a-dax-unwrit.patch + patches.suse/msft-hv-2226-Drivers-hv-vmbus-Avoid-use-after-free-in-vmbus_onoff.patch patches.suse/media-vsp1-Fix-an-error-handling-path-in-the-probe-f.patch patches.suse/media-media-pci-Fix-memleak-in-empress_init.patch patches.suse/media-tm6000-Fix-memleak-in-tm6000_start_stream.patch @@ -58016,6 +58021,8 @@ patches.suse/scsi-lpfc-Simplify-bool-comparison.patch patches.suse/quota-Fix-memory-leak-when-handling-corrupted-quota-.patch patches.suse/powerpc-perf-hv-24x7-Dont-create-sysfs-event-files-f.patch + patches.suse/powerpc-pseries-eeh-Make-pseries_pcibios_bus_add_dev.patch + patches.suse/powerpc-pseries-ras-Make-init_ras_hotplug_IRQ-static.patch patches.suse/powerpc-pseries-dlpar-handle-ibm-configure-connector.patch patches.suse/HID-wacom-Ignore-attempts-to-overwrite-the-touch_max.patch patches.suse/HID-core-detect-and-skip-invalid-inputs-to-snto32.patch @@ -58417,6 +58424,12 @@ patches.suse/btrfs-qgroups-fix-rescan-worker-running-races.patch patches.suse/btrfs-suspend-qgroups-during-relocation-recovery.patch patches.suse/btrfs-relocation-Work-around-dead-relocation-stage-l.patch + patches.suse/btrfs-free-correct-amount-of-space-in-btrfs_delayed_inode_reserve_metadata.patch + patches.suse/btrfs-don-t-flush-from-btrfs_delayed_inode_reserve_metadata.patch + patches.suse/btrfs-cleanup-try_flush_qgroup.patch + patches.suse/btrfs-remove-btrfs_inode-from-btrfs_delayed_inode_reserve_metadata.patch + patches.suse/btrfs-simplify-code-flow-in-btrfs_delayed_inode_reserve_metadata.patch + patches.suse/btrfs-unlock-extents-in-btrfs_zero_range-in-case-of-errors.patch patches.suse/reiserfs-add-check-to-detect-corrupted-directory-entry.patch patches.suse/reiserfs-don-t-panic-on-bad-directory-entries.patch