]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.5-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 May 2016 21:17:39 +0000 (14:17 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 May 2016 21:17:39 +0000 (14:17 -0700)
added patches:
f2fs-crypto-fix-corrupted-symlink-in-encrypted-case.patch
f2fs-slightly-reorganize-read_raw_super_block.patch

queue-4.5/f2fs-crypto-fix-corrupted-symlink-in-encrypted-case.patch [new file with mode: 0644]
queue-4.5/f2fs-slightly-reorganize-read_raw_super_block.patch [new file with mode: 0644]
queue-4.5/series

diff --git a/queue-4.5/f2fs-crypto-fix-corrupted-symlink-in-encrypted-case.patch b/queue-4.5/f2fs-crypto-fix-corrupted-symlink-in-encrypted-case.patch
new file mode 100644 (file)
index 0000000..3d0ee81
--- /dev/null
@@ -0,0 +1,49 @@
+From c90e09f7fb498f81cd4e8bb6460d3a26ccebeca3 Mon Sep 17 00:00:00 2001
+From: Jaegeuk Kim <jaegeuk@kernel.org>
+Date: Wed, 30 Mar 2016 13:13:16 -0700
+Subject: f2fs crypto: fix corrupted symlink in encrypted case
+
+From: Jaegeuk Kim <jaegeuk@kernel.org>
+
+commit c90e09f7fb498f81cd4e8bb6460d3a26ccebeca3 upstream.
+
+In the encrypted symlink case, we should check its corrupted symname after
+decrypting it.
+Otherwise, we can report -ENOENT incorrectly, if encrypted symname starts with
+'\0'.
+
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/f2fs/namei.c |   12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+--- a/fs/f2fs/namei.c
++++ b/fs/f2fs/namei.c
+@@ -980,12 +980,6 @@ static const char *f2fs_encrypted_get_li
+       }
+       memcpy(cstr.name, sd->encrypted_path, cstr.len);
+-      /* this is broken symlink case */
+-      if (unlikely(cstr.name[0] == 0)) {
+-              res = -ENOENT;
+-              goto errout;
+-      }
+-
+       if ((cstr.len + sizeof(struct f2fs_encrypted_symlink_data) - 1) >
+                                                               max_size) {
+               /* Symlink data on the disk is corrupted */
+@@ -1002,6 +996,12 @@ static const char *f2fs_encrypted_get_li
+       kfree(cstr.name);
++      /* this is broken symlink case */
++      if (unlikely(pstr.name[0] == 0)) {
++              res = -ENOENT;
++              goto errout;
++      }
++
+       paddr = pstr.name;
+       /* Null-terminate the name */
diff --git a/queue-4.5/f2fs-slightly-reorganize-read_raw_super_block.patch b/queue-4.5/f2fs-slightly-reorganize-read_raw_super_block.patch
new file mode 100644 (file)
index 0000000..c4d4ff3
--- /dev/null
@@ -0,0 +1,133 @@
+From 2b39e9072d79ab2525100413f3f7a0b8a3e15873 Mon Sep 17 00:00:00 2001
+From: Shawn Lin <shawn.lin@rock-chips.com>
+Date: Wed, 17 Feb 2016 08:59:01 +0800
+Subject: f2fs: slightly reorganize read_raw_super_block
+
+From: Shawn Lin <shawn.lin@rock-chips.com>
+
+commit 2b39e9072d79ab2525100413f3f7a0b8a3e15873 upstream.
+
+read_raw_super_block was introduced to help find the
+first valid superblock. Commit da554e48caab ("f2fs:
+recovering broken superblock during mount") changed the
+behaviour to read both of them and check whether need
+the recovery flag or not. So the comment before this
+function isn't consistent with what it actually does.
+Also, the origin code use two tags to round the err
+cases, which isn't so readable. So this patch amend
+the comment and slightly reorganize it.
+
+Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/f2fs/super.c |   77 +++++++++++++++++++++++++++-----------------------------
+ 1 file changed, 38 insertions(+), 39 deletions(-)
+
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -1134,14 +1134,15 @@ static void init_sb_info(struct f2fs_sb_
+ /*
+  * Read f2fs raw super block.
+- * Because we have two copies of super block, so read the first one at first,
+- * if the first one is invalid, move to read the second one.
++ * Because we have two copies of super block, so read both of them
++ * to get the first valid one. If any one of them is broken, we pass
++ * them recovery flag back to the caller.
+  */
+ static int read_raw_super_block(struct super_block *sb,
+                       struct f2fs_super_block **raw_super,
+                       int *valid_super_block, int *recovery)
+ {
+-      int block = 0;
++      int block;
+       struct buffer_head *bh;
+       struct f2fs_super_block *super, *buf;
+       int err = 0;
+@@ -1149,50 +1150,48 @@ static int read_raw_super_block(struct s
+       super = kzalloc(sizeof(struct f2fs_super_block), GFP_KERNEL);
+       if (!super)
+               return -ENOMEM;
+-retry:
+-      bh = sb_bread(sb, block);
+-      if (!bh) {
+-              *recovery = 1;
+-              f2fs_msg(sb, KERN_ERR, "Unable to read %dth superblock",
+-                              block + 1);
+-              err = -EIO;
+-              goto next;
+-      }
+-      buf = (struct f2fs_super_block *)(bh->b_data + F2FS_SUPER_OFFSET);
+-
+-      /* sanity checking of raw super */
+-      if (sanity_check_raw_super(sb, buf)) {
++      for (block = 0; block < 2; block++) {
++              bh = sb_bread(sb, block);
++              if (!bh) {
++                      f2fs_msg(sb, KERN_ERR, "Unable to read %dth superblock",
++                              block + 1);
++                      err = -EIO;
++                      continue;
++              }
++
++              buf = (struct f2fs_super_block *)
++                              (bh->b_data + F2FS_SUPER_OFFSET);
++
++              /* sanity checking of raw super */
++              if (sanity_check_raw_super(sb, buf)) {
++                      f2fs_msg(sb, KERN_ERR,
++                              "Can't find valid F2FS filesystem in %dth superblock",
++                              block + 1);
++                      err = -EINVAL;
++                      brelse(bh);
++                      continue;
++              }
++
++              if (!*raw_super) {
++                      memcpy(super, buf, sizeof(*super));
++                      *valid_super_block = block;
++                      *raw_super = super;
++              }
+               brelse(bh);
+-              *recovery = 1;
+-              f2fs_msg(sb, KERN_ERR,
+-                      "Can't find valid F2FS filesystem in %dth superblock",
+-                                                              block + 1);
+-              err = -EINVAL;
+-              goto next;
+-      }
+-
+-      if (!*raw_super) {
+-              memcpy(super, buf, sizeof(*super));
+-              *valid_super_block = block;
+-              *raw_super = super;
+       }
+-      brelse(bh);
+-next:
+-      /* check the validity of the second superblock */
+-      if (block == 0) {
+-              block++;
+-              goto retry;
+-      }
++      /* Fail to read any one of the superblocks*/
++      if (err < 0)
++              *recovery = 1;
+       /* No valid superblock */
+-      if (!*raw_super) {
++      if (!*raw_super)
+               kfree(super);
+-              return err;
+-      }
++      else
++              err = 0;
+-      return 0;
++      return err;
+ }
+ static int __f2fs_commit_super(struct f2fs_sb_info *sbi, int block)
index 459e14dc964fe6d310ff31aa9db17a26abfb9795..2edf17232493563151495cca46b65ad450445736 100644 (file)
@@ -159,3 +159,5 @@ perf-tools-fix-perf-script-python-database-export-crash.patch
 spi-rockchip-modify-dma-max-burst-to-1.patch
 x86-mm-kmmio-fix-mmiotrace-for-hugepages.patch
 ext4-fix-null-pointer-dereference-in-ext4_mark_inode_dirty.patch
+f2fs-crypto-fix-corrupted-symlink-in-encrypted-case.patch
+f2fs-slightly-reorganize-read_raw_super_block.patch