From a1dac68476f2d0a7babdac7ac2d901252a1b8ee7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 17 Oct 2021 12:48:32 +0200 Subject: [PATCH] 4.19-stable patches added patches: btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch nds32-ftrace-fix-error-invalid-operands-und-and-und-sections-for.patch s390-fix-strrchr-implementation.patch --- ...ing-up-inode-during-dir-entry-replay.patch | 53 ++++++++++++ ...ng-inode-reference-during-log-replay.patch | 51 +++++++++++ ...eplaying-dir-entry-during-log-replay.patch | 44 ++++++++++ ...id-operands-und-and-und-sections-for.patch | 85 +++++++++++++++++++ .../s390-fix-strrchr-implementation.patch | 49 +++++++++++ queue-4.19/series | 5 ++ 6 files changed, 287 insertions(+) create mode 100644 queue-4.19/btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch create mode 100644 queue-4.19/btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch create mode 100644 queue-4.19/btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch create mode 100644 queue-4.19/nds32-ftrace-fix-error-invalid-operands-und-and-und-sections-for.patch create mode 100644 queue-4.19/s390-fix-strrchr-implementation.patch diff --git a/queue-4.19/btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch b/queue-4.19/btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch new file mode 100644 index 00000000000..d90c65dc293 --- /dev/null +++ b/queue-4.19/btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch @@ -0,0 +1,53 @@ +From cfd312695b71df04c3a2597859ff12c470d1e2e4 Mon Sep 17 00:00:00 2001 +From: Filipe Manana +Date: Fri, 1 Oct 2021 13:48:18 +0100 +Subject: btrfs: check for error when looking up inode during dir entry replay + +From: Filipe Manana + +commit cfd312695b71df04c3a2597859ff12c470d1e2e4 upstream. + +At replay_one_name(), we are treating any error from btrfs_lookup_inode() +as if the inode does not exists. Fix this by checking for an error and +returning it to the caller. + +CC: stable@vger.kernel.org # 4.14+ +Signed-off-by: Filipe Manana +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/tree-log.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -1871,8 +1871,8 @@ static noinline int replay_one_name(stru + struct btrfs_key log_key; + struct inode *dir; + u8 log_type; +- int exists; +- int ret = 0; ++ bool exists; ++ int ret; + bool update_size = (key->type == BTRFS_DIR_INDEX_KEY); + bool name_added = false; + +@@ -1892,12 +1892,12 @@ static noinline int replay_one_name(stru + name_len); + + btrfs_dir_item_key_to_cpu(eb, di, &log_key); +- exists = btrfs_lookup_inode(trans, root, path, &log_key, 0); +- if (exists == 0) +- exists = 1; +- else +- exists = 0; ++ ret = btrfs_lookup_inode(trans, root, path, &log_key, 0); + btrfs_release_path(path); ++ if (ret < 0) ++ goto out; ++ exists = (ret == 0); ++ ret = 0; + + if (key->type == BTRFS_DIR_ITEM_KEY) { + dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid, diff --git a/queue-4.19/btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch b/queue-4.19/btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch new file mode 100644 index 00000000000..d30978dc6da --- /dev/null +++ b/queue-4.19/btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch @@ -0,0 +1,51 @@ +From 52db77791fe24538c8aa2a183248399715f6b380 Mon Sep 17 00:00:00 2001 +From: Filipe Manana +Date: Fri, 1 Oct 2021 13:52:32 +0100 +Subject: btrfs: deal with errors when adding inode reference during log replay + +From: Filipe Manana + +commit 52db77791fe24538c8aa2a183248399715f6b380 upstream. + +At __inode_add_ref(), we treating any error returned from +btrfs_lookup_dir_item() or from btrfs_lookup_dir_index_item() as meaning +that there is no existing directory entry in the fs/subvolume tree. +This is not correct since we can get errors such as, for example, -EIO +when reading extent buffers while searching the fs/subvolume's btree. + +So fix that and return the error to the caller when it is not -ENOENT. + +CC: stable@vger.kernel.org # 4.14+ +Signed-off-by: Filipe Manana +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/tree-log.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -1141,7 +1141,10 @@ next: + /* look for a conflicting sequence number */ + di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir), + ref_index, name, namelen, 0); +- if (di && !IS_ERR(di)) { ++ if (IS_ERR(di)) { ++ if (PTR_ERR(di) != -ENOENT) ++ return PTR_ERR(di); ++ } else if (di) { + ret = drop_one_dir_item(trans, root, path, dir, di); + if (ret) + return ret; +@@ -1151,7 +1154,9 @@ next: + /* look for a conflicing name */ + di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir), + name, namelen, 0); +- if (di && !IS_ERR(di)) { ++ if (IS_ERR(di)) { ++ return PTR_ERR(di); ++ } else if (di) { + ret = drop_one_dir_item(trans, root, path, dir, di); + if (ret) + return ret; diff --git a/queue-4.19/btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch b/queue-4.19/btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch new file mode 100644 index 00000000000..9ac00397071 --- /dev/null +++ b/queue-4.19/btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch @@ -0,0 +1,44 @@ +From e15ac6413745e3def00e663de00aea5a717311c1 Mon Sep 17 00:00:00 2001 +From: Filipe Manana +Date: Fri, 1 Oct 2021 13:52:31 +0100 +Subject: btrfs: deal with errors when replaying dir entry during log replay + +From: Filipe Manana + +commit e15ac6413745e3def00e663de00aea5a717311c1 upstream. + +At replay_one_one(), we are treating any error returned from +btrfs_lookup_dir_item() or from btrfs_lookup_dir_index_item() as meaning +that there is no existing directory entry in the fs/subvolume tree. +This is not correct since we can get errors such as, for example, -EIO +when reading extent buffers while searching the fs/subvolume's btree. + +So fix that and return the error to the caller when it is not -ENOENT. + +CC: stable@vger.kernel.org # 4.14+ +Signed-off-by: Filipe Manana +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/tree-log.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -1907,7 +1907,14 @@ static noinline int replay_one_name(stru + ret = -EINVAL; + goto out; + } +- if (IS_ERR_OR_NULL(dst_di)) { ++ ++ if (dst_di == ERR_PTR(-ENOENT)) ++ dst_di = NULL; ++ ++ if (IS_ERR(dst_di)) { ++ ret = PTR_ERR(dst_di); ++ goto out; ++ } else if (!dst_di) { + /* we need a sequence number to insert, so we only + * do inserts for the BTRFS_DIR_INDEX_KEY types + */ diff --git a/queue-4.19/nds32-ftrace-fix-error-invalid-operands-und-and-und-sections-for.patch b/queue-4.19/nds32-ftrace-fix-error-invalid-operands-und-and-und-sections-for.patch new file mode 100644 index 00000000000..80bc4475e87 --- /dev/null +++ b/queue-4.19/nds32-ftrace-fix-error-invalid-operands-und-and-und-sections-for.patch @@ -0,0 +1,85 @@ +From be358af1191b1b2fedebd8f3421cafdc8edacc7d Mon Sep 17 00:00:00 2001 +From: Steven Rostedt +Date: Thu, 14 Oct 2021 14:35:07 -0400 +Subject: nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^' + +From: Steven Rostedt + +commit be358af1191b1b2fedebd8f3421cafdc8edacc7d upstream. + +I received a build failure for a new patch I'm working on the nds32 +architecture, and when I went to test it, I couldn't get to my build error, +because it failed to build with a bunch of: + + Error: invalid operands (*UND* and *UND* sections) for `^' + +issues with various files. Those files were temporary asm files that looked +like: kernel/.tmp_mc_fork.s + +I decided to look deeper, and found that the "mc" portion of that name +stood for "mcount", and was created by the recordmcount.pl script. One that +I wrote over a decade ago. Once I knew the source of the problem, I was +able to investigate it further. + +The way the recordmcount.pl script works (BTW, there's a C version that +simply modifies the ELF object) is by doing an "objdump" on the object +file. Looks for all the calls to "mcount", and creates an offset of those +locations from some global variable it can use (usually a global function +name, found with <.*>:). Creates a asm file that is a table of references +to these locations, using the found variable/function. Compiles it and +links it back into the original object file. This asm file is called +".tmp_mc_.s". + +The problem here is that the objdump produced by the nds32 object file, +contains things that look like: + + 0000159a <.L3^B1>: + 159a: c6 00 beqz38 $r6, 159a <.L3^B1> + 159a: R_NDS32_9_PCREL_RELA .text+0x159e + 159c: 84 d2 movi55 $r6, #-14 + 159e: 80 06 mov55 $r0, $r6 + 15a0: ec 3c addi10.sp #0x3c + +Where ".L3^B1 is somehow selected as the "global" variable to index off of. + +Then the assembly file that holds the mcount locations looks like this: + + .section __mcount_loc,"a",@progbits + .align 2 + .long .L3^B1 + -5522 + .long .L3^B1 + -5384 + .long .L3^B1 + -5270 + .long .L3^B1 + -5098 + .long .L3^B1 + -4970 + .long .L3^B1 + -4758 + .long .L3^B1 + -4122 + [...] + +And when it is compiled back to an object to link to the original object, +the compile fails on the "^" symbol. + +Simple solution for now, is to have the perl script ignore using function +symbols that have an "^" in the name. + +Link: https://lkml.kernel.org/r/20211014143507.4ad2c0f7@gandalf.local.home + +Cc: stable@vger.kernel.org +Acked-by: Greentime Hu +Fixes: fbf58a52ac088 ("nds32/ftrace: Add RECORD_MCOUNT support") +Signed-off-by: Steven Rostedt (VMware) +Signed-off-by: Greg Kroah-Hartman +--- + scripts/recordmcount.pl | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/scripts/recordmcount.pl ++++ b/scripts/recordmcount.pl +@@ -222,7 +222,7 @@ if ($arch =~ /(x86(_64)?)|(i386)/) { + $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; + $weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)"; + $section_regex = "Disassembly of section\\s+(\\S+):"; +-$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; ++$function_regex = "^([0-9a-fA-F]+)\\s+<([^^]*?)>:"; + $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)\$"; + $section_type = '@progbits'; + $mcount_adjust = 0; diff --git a/queue-4.19/s390-fix-strrchr-implementation.patch b/queue-4.19/s390-fix-strrchr-implementation.patch new file mode 100644 index 00000000000..705e1996d6d --- /dev/null +++ b/queue-4.19/s390-fix-strrchr-implementation.patch @@ -0,0 +1,49 @@ +From 8e0ab8e26b72a80e991c66a8abc16e6c856abe3d Mon Sep 17 00:00:00 2001 +From: Roberto Sassu +Date: Tue, 5 Oct 2021 14:08:36 +0200 +Subject: s390: fix strrchr() implementation + +From: Roberto Sassu + +commit 8e0ab8e26b72a80e991c66a8abc16e6c856abe3d upstream. + +Fix two problems found in the strrchr() implementation for s390 +architectures: evaluate empty strings (return the string address instead of +NULL, if '\0' is passed as second argument); evaluate the first character +of non-empty strings (the current implementation stops at the second). + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Cc: stable@vger.kernel.org +Reported-by: Heiko Carstens (incorrect behavior with empty strings) +Signed-off-by: Roberto Sassu +Link: https://lore.kernel.org/r/20211005120836.60630-1-roberto.sassu@huawei.com +Signed-off-by: Heiko Carstens +Signed-off-by: Vasily Gorbik +Signed-off-by: Greg Kroah-Hartman +--- + arch/s390/lib/string.c | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +--- a/arch/s390/lib/string.c ++++ b/arch/s390/lib/string.c +@@ -227,14 +227,13 @@ EXPORT_SYMBOL(strcmp); + */ + char *strrchr(const char *s, int c) + { +- size_t len = __strend(s) - s; ++ ssize_t len = __strend(s) - s; + +- if (len) +- do { +- if (s[len] == (char) c) +- return (char *) s + len; +- } while (--len > 0); +- return NULL; ++ do { ++ if (s[len] == (char)c) ++ return (char *)s + len; ++ } while (--len >= 0); ++ return NULL; + } + EXPORT_SYMBOL(strrchr); + diff --git a/queue-4.19/series b/queue-4.19/series index 3bef3e2be61..eaa0cddab1e 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -2,3 +2,8 @@ alsa-seq-fix-a-potential-uaf-by-wrong-private_free-call-order.patch alsa-hda-realtek-complete-partial-device-name-to-avoid-ambiguity.patch alsa-hda-realtek-add-quirk-for-clevo-x170km-g.patch alsa-hda-realtek-alc236-headset-mic-recording-issue.patch +nds32-ftrace-fix-error-invalid-operands-und-and-und-sections-for.patch +s390-fix-strrchr-implementation.patch +btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch +btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch +btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch -- 2.47.3