From: Greg Kroah-Hartman Date: Sun, 17 Oct 2021 10:48:16 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v4.14.252~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=247301c53deaaf47d92a9e101bca72b6709adf60;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-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 s390-fix-strrchr-implementation.patch --- diff --git a/queue-4.14/btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch b/queue-4.14/btrfs-check-for-error-when-looking-up-inode-during-dir-entry-replay.patch new file mode 100644 index 00000000000..566764234d9 --- /dev/null +++ b/queue-4.14/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 +@@ -1730,8 +1730,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; + +@@ -1751,12 +1751,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.14/btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch b/queue-4.14/btrfs-deal-with-errors-when-adding-inode-reference-during-log-replay.patch new file mode 100644 index 00000000000..1c4c73ed292 --- /dev/null +++ b/queue-4.14/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 +@@ -1161,7 +1161,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; +@@ -1171,7 +1174,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.14/btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch b/queue-4.14/btrfs-deal-with-errors-when-replaying-dir-entry-during-log-replay.patch new file mode 100644 index 00000000000..e56ecc26d05 --- /dev/null +++ b/queue-4.14/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 +@@ -1766,7 +1766,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.14/s390-fix-strrchr-implementation.patch b/queue-4.14/s390-fix-strrchr-implementation.patch new file mode 100644 index 00000000000..51c511743a2 --- /dev/null +++ b/queue-4.14/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.14/series b/queue-4.14/series index 1494aab854e..c6d2ce7c163 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -1,2 +1,6 @@ stable-clamp-sublevel-in-4.14.patch alsa-seq-fix-a-potential-uaf-by-wrong-private_free-call-order.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