]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.53/udf-detect-incorrect-directory-size.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.53 / udf-detect-incorrect-directory-size.patch
CommitLineData
0f714131
GKH
1From fa65653e575fbd958bdf5fb9c4a71a324e39510d Mon Sep 17 00:00:00 2001
2From: Jan Kara <jack@suse.cz>
3Date: Wed, 13 Jun 2018 12:09:22 +0200
4Subject: udf: Detect incorrect directory size
5
6From: Jan Kara <jack@suse.cz>
7
8commit fa65653e575fbd958bdf5fb9c4a71a324e39510d upstream.
9
10Detect when a directory entry is (possibly partially) beyond directory
11size and return EIO in that case since it means the filesystem is
12corrupted. Otherwise directory operations can further corrupt the
13directory and possibly also oops the kernel.
14
15CC: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
16CC: stable@vger.kernel.org
17Reported-and-tested-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
18Signed-off-by: Jan Kara <jack@suse.cz>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 fs/udf/directory.c | 3 +++
23 1 file changed, 3 insertions(+)
24
25--- a/fs/udf/directory.c
26+++ b/fs/udf/directory.c
27@@ -151,6 +151,9 @@ struct fileIdentDesc *udf_fileident_read
28 sizeof(struct fileIdentDesc));
29 }
30 }
31+ /* Got last entry outside of dir size - fs is corrupted! */
32+ if (*nf_pos > dir->i_size)
33+ return NULL;
34 return fi;
35 }
36