]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
fixes for 4.14
authorSasha Levin <sashal@kernel.org>
Mon, 30 Sep 2019 12:55:18 +0000 (08:55 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 30 Sep 2019 13:23:31 +0000 (09:23 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.14/f2fs-use-generic-efsbadcrc-efscorrupted.patch [new file with mode: 0644]
queue-4.14/series
queue-4.14/tpm-fix-tpm-1.2-shutdown-sequence-to-prevent-future-.patch [deleted file]

diff --git a/queue-4.14/f2fs-use-generic-efsbadcrc-efscorrupted.patch b/queue-4.14/f2fs-use-generic-efsbadcrc-efscorrupted.patch
new file mode 100644 (file)
index 0000000..56c4ce6
--- /dev/null
@@ -0,0 +1,286 @@
+From eec55314d14589882f00549d306568c4a7b89ab2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 20 Jun 2019 11:36:14 +0800
+Subject: f2fs: use generic EFSBADCRC/EFSCORRUPTED
+
+From: Chao Yu <yuchao0@huawei.com>
+
+[ Upstream commit 10f966bbf521bb9b2e497bbca496a5141f4071d0 ]
+
+f2fs uses EFAULT as error number to indicate filesystem is corrupted
+all the time, but generic filesystems use EUCLEAN for such condition,
+we need to change to follow others.
+
+This patch adds two new macros as below to wrap more generic error
+code macros, and spread them in code.
+
+EFSBADCRC      EBADMSG         /* Bad CRC detected */
+EFSCORRUPTED   EUCLEAN         /* Filesystem is corrupted */
+
+Reported-by: Pavel Machek <pavel@ucw.cz>
+Signed-off-by: Chao Yu <yuchao0@huawei.com>
+Acked-by: Pavel Machek <pavel@ucw.cz>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/checkpoint.c | 8 ++++++--
+ fs/f2fs/data.c       | 8 ++++----
+ fs/f2fs/f2fs.h       | 4 ++++
+ fs/f2fs/inline.c     | 4 ++--
+ fs/f2fs/inode.c      | 4 ++--
+ fs/f2fs/node.c       | 4 ++--
+ fs/f2fs/recovery.c   | 2 +-
+ fs/f2fs/segment.c    | 7 ++++---
+ fs/f2fs/segment.h    | 4 ++--
+ fs/f2fs/super.c      | 2 +-
+ 10 files changed, 28 insertions(+), 19 deletions(-)
+
+diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
+index 624817eeb25e3..170423ff27210 100644
+--- a/fs/f2fs/checkpoint.c
++++ b/fs/f2fs/checkpoint.c
+@@ -793,6 +793,7 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
+       unsigned int cp_blks = 1 + __cp_payload(sbi);
+       block_t cp_blk_no;
+       int i;
++      int err;
+       sbi->ckpt = kzalloc(cp_blks * blk_size, GFP_KERNEL);
+       if (!sbi->ckpt)
+@@ -819,6 +820,7 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
+       } else if (cp2) {
+               cur_page = cp2;
+       } else {
++              err = -EFSCORRUPTED;
+               goto fail_no_cp;
+       }
+@@ -831,8 +833,10 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
+               sbi->cur_cp_pack = 2;
+       /* Sanity checking of checkpoint */
+-      if (sanity_check_ckpt(sbi))
++      if (sanity_check_ckpt(sbi)) {
++              err = -EFSCORRUPTED;
+               goto free_fail_no_cp;
++      }
+       if (cp_blks <= 1)
+               goto done;
+@@ -860,7 +864,7 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
+       f2fs_put_page(cp2, 1);
+ fail_no_cp:
+       kfree(sbi->ckpt);
+-      return -EINVAL;
++      return err;
+ }
+ static void __add_dirty_inode(struct inode *inode, enum inode_type type)
+diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
+index 113d1cd551192..cc57294451940 100644
+--- a/fs/f2fs/data.c
++++ b/fs/f2fs/data.c
+@@ -376,7 +376,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
+       if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr,
+                       __is_meta_io(fio) ? META_GENERIC : DATA_GENERIC))
+-              return -EFAULT;
++              return -EFSCORRUPTED;
+       trace_f2fs_submit_page_bio(page, fio);
+       f2fs_trace_ios(fio, 0);
+@@ -959,7 +959,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
+       if (__is_valid_data_blkaddr(blkaddr) &&
+               !f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC)) {
+-              err = -EFAULT;
++              err = -EFSCORRUPTED;
+               goto sync_out;
+       }
+@@ -1425,7 +1425,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
+               if (!f2fs_is_valid_blkaddr(fio->sbi, fio->old_blkaddr,
+                                                       DATA_GENERIC))
+-                      return -EFAULT;
++                      return -EFSCORRUPTED;
+               ipu_force = true;
+               fio->need_lock = LOCK_DONE;
+@@ -1451,7 +1451,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
+       if (__is_valid_data_blkaddr(fio->old_blkaddr) &&
+               !f2fs_is_valid_blkaddr(fio->sbi, fio->old_blkaddr,
+                                                       DATA_GENERIC)) {
+-              err = -EFAULT;
++              err = -EFSCORRUPTED;
+               goto out_writepage;
+       }
+       /*
+diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
+index 6caae471c1a45..268409cee1c34 100644
+--- a/fs/f2fs/f2fs.h
++++ b/fs/f2fs/f2fs.h
+@@ -3089,3 +3089,7 @@ static inline bool f2fs_may_encrypt(struct inode *inode)
+ }
+ #endif
++
++#define EFSBADCRC     EBADMSG         /* Bad CRC detected */
++#define EFSCORRUPTED  EUCLEAN         /* Filesystem is corrupted */
++
+diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
+index 506e365cf903e..8906f6381b1a4 100644
+--- a/fs/f2fs/inline.c
++++ b/fs/f2fs/inline.c
+@@ -135,7 +135,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
+                       "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, "
+                       "run fsck to fix.",
+                       __func__, dn->inode->i_ino, dn->data_blkaddr);
+-              return -EINVAL;
++              return -EFSCORRUPTED;
+       }
+       f2fs_bug_on(F2FS_P_SB(page), PageWriteback(page));
+@@ -382,7 +382,7 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
+                       "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, "
+                       "run fsck to fix.",
+                       __func__, dir->i_ino, dn.data_blkaddr);
+-              err = -EINVAL;
++              err = -EFSCORRUPTED;
+               goto out;
+       }
+diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
+index e02ed16bc35cd..c6d0687f00fee 100644
+--- a/fs/f2fs/inode.c
++++ b/fs/f2fs/inode.c
+@@ -70,7 +70,7 @@ static int __written_first_block(struct f2fs_sb_info *sbi,
+       if (!__is_valid_data_blkaddr(addr))
+               return 1;
+       if (!f2fs_is_valid_blkaddr(sbi, addr, DATA_GENERIC))
+-              return -EFAULT;
++              return -EFSCORRUPTED;
+       return 0;
+ }
+@@ -300,7 +300,7 @@ static int do_read_inode(struct inode *inode)
+       if (!sanity_check_inode(inode, node_page)) {
+               f2fs_put_page(node_page, 1);
+-              return -EINVAL;
++              return -EFSCORRUPTED;
+       }
+       /* check data exist */
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
+index 12060fbfbb05e..e7b8e2b35e226 100644
+--- a/fs/f2fs/node.c
++++ b/fs/f2fs/node.c
+@@ -39,7 +39,7 @@ int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
+               f2fs_msg(sbi->sb, KERN_WARNING,
+                               "%s: out-of-range nid=%x, run fsck to fix.",
+                               __func__, nid);
+-              return -EINVAL;
++              return -EFSCORRUPTED;
+       }
+       return 0;
+ }
+@@ -1195,7 +1195,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
+       }
+       if (!f2fs_inode_chksum_verify(sbi, page)) {
+-              err = -EBADMSG;
++              err = -EFSBADCRC;
+               goto out_err;
+       }
+ page_hit:
+diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
+index 65a82c5bafcbe..db357e9ad5990 100644
+--- a/fs/f2fs/recovery.c
++++ b/fs/f2fs/recovery.c
+@@ -451,7 +451,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
+                       "Inconsistent ofs_of_node, ino:%lu, ofs:%u, %u",
+                       inode->i_ino, ofs_of_node(dn.node_page),
+                       ofs_of_node(page));
+-              err = -EFAULT;
++              err = -EFSCORRUPTED;
+               goto err;
+       }
+diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
+index 294fdb1b22137..9e5fca35e47d0 100644
+--- a/fs/f2fs/segment.c
++++ b/fs/f2fs/segment.c
+@@ -2216,6 +2216,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
+       if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) {
+               f2fs_msg(sbi->sb, KERN_WARNING,
+                       "Found FS corruption, run fsck to fix.");
++              err = -EFSCORRUPTED;
+               goto out;
+       }
+@@ -3309,7 +3310,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
+                                       "Wrong journal entry on segno %u",
+                                       start);
+                       set_sbi_flag(sbi, SBI_NEED_FSCK);
+-                      err = -EINVAL;
++                      err = -EFSCORRUPTED;
+                       break;
+               }
+@@ -3350,7 +3351,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
+                       "SIT is corrupted node# %u vs %u",
+                       total_node_blocks, valid_node_count(sbi));
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+-              err = -EINVAL;
++              err = -EFSCORRUPTED;
+       }
+       return err;
+@@ -3468,7 +3469,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)
+                               "segno:%u, type:%u, next_blkoff:%u, blkofs:%u",
+                               i, curseg->segno, curseg->alloc_type,
+                               curseg->next_blkoff, blkofs);
+-                      return -EINVAL;
++                      return -EFSCORRUPTED;
+               }
+       }
+       return 0;
+diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
+index e3d8826c5113d..0d46e936d54ed 100644
+--- a/fs/f2fs/segment.h
++++ b/fs/f2fs/segment.h
+@@ -665,7 +665,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
+                               "Mismatch valid blocks %d vs. %d",
+                                       GET_SIT_VBLOCKS(raw_sit), valid_blocks);
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+-              return -EINVAL;
++              return -EFSCORRUPTED;
+       }
+       /* check segment usage, and check boundary of a given segment number */
+@@ -675,7 +675,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
+                               "Wrong valid blocks %d or segno %u",
+                                       GET_SIT_VBLOCKS(raw_sit), segno);
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+-              return -EINVAL;
++              return -EFSCORRUPTED;
+       }
+       return 0;
+ }
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
+index ad839a7996e9b..344aa861774bd 100644
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -2220,7 +2220,7 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi,
+                       f2fs_msg(sb, KERN_ERR,
+                               "Can't find valid F2FS filesystem in %dth superblock",
+                               block + 1);
+-                      err = -EINVAL;
++                      err = -EFSCORRUPTED;
+                       brelse(bh);
+                       continue;
+               }
+-- 
+2.20.1
+
index 5c798f4709a7a640b0be6a55cc229d2a85784f26..0f2490cf4b277581fb1014192bcf4fcc28cac1c8 100644 (file)
@@ -15,7 +15,6 @@ arm64-kpti-whitelist-cortex-a-cpus-that-don-t-implement-the-csv3-field.patch
 alsa-hda-add-laptop-imic-fixup-for-asus-m9v-laptop.patch
 alsa-hda-apply-amd-controller-workaround-for-raven-platform.patch
 objtool-clobber-user-cflags-variable.patch
-tpm-fix-tpm-1.2-shutdown-sequence-to-prevent-future-.patch
 pinctrl-sprd-use-define-directive-for-sprd_pinconf_p.patch
 power-supply-sysfs-ratelimit-property-read-error-mes.patch
 locking-lockdep-add-debug_locks-check-in-__lock_down.patch-14091
@@ -31,3 +30,4 @@ net-don-t-warn-in-inet-diag-when-ipv6-is-disabled.patch
 acpi-video-add-new-hw_changes_brightness-quirk-set-i.patch
 xfs-don-t-crash-on-null-attr-fork-xfs_bmapi_read.patch
 bluetooth-btrtl-additional-realtek-8822ce-bluetooth-.patch
+f2fs-use-generic-efsbadcrc-efscorrupted.patch
diff --git a/queue-4.14/tpm-fix-tpm-1.2-shutdown-sequence-to-prevent-future-.patch b/queue-4.14/tpm-fix-tpm-1.2-shutdown-sequence-to-prevent-future-.patch
deleted file mode 100644 (file)
index ec3b908..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-From e09e1a3e589e38ff8c402f7c97d30491b502dd2e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 25 Sep 2019 13:15:32 +0300
-Subject: tpm: Fix TPM 1.2 Shutdown sequence to prevent future TPM operations
-
-From: Vadim Sukhomlinov <sukhomlinov@google.com>
-
-commit db4d8cb9c9f2af71c4d087817160d866ed572cc9 upstream
-
-TPM 2.0 Shutdown involve sending TPM2_Shutdown to TPM chip and disabling
-future TPM operations. TPM 1.2 behavior was different, future TPM
-operations weren't disabled, causing rare issues. This patch ensures
-that future TPM operations are disabled.
-
-Fixes: d1bd4a792d39 ("tpm: Issue a TPM2_Shutdown for TPM2 devices.")
-Cc: stable@vger.kernel.org
-Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com>
-[dianders: resolved merge conflicts with mainline]
-Signed-off-by: Douglas Anderson <dianders@chromium.org>
-Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
-Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/char/tpm/tpm-chip.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
-index 0eca20c5a80cf..ede8c1deca979 100644
---- a/drivers/char/tpm/tpm-chip.c
-+++ b/drivers/char/tpm/tpm-chip.c
-@@ -158,12 +158,15 @@ static int tpm_class_shutdown(struct device *dev)
- {
-       struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
-+      down_write(&chip->ops_sem);
-       if (chip->flags & TPM_CHIP_FLAG_TPM2) {
-               down_write(&chip->ops_sem);
-               tpm2_shutdown(chip, TPM2_SU_CLEAR);
-               chip->ops = NULL;
-               up_write(&chip->ops_sem);
-       }
-+      chip->ops = NULL;
-+      up_write(&chip->ops_sem);
-       return 0;
- }
--- 
-2.20.1
-