Return-Path: From: Jan Kara To: Cc: Jan Kara , Anatoly Trosinenko , stable@vger.kernel.org Subject: [PATCH 1/3] udf: Detect incorrect directory size Date: Thu, 14 Jun 2018 17:27:40 +0200 Message-Id: <20180614152742.20640-2-jack@suse.cz> In-Reply-To: <20180614152742.20640-1-jack@suse.cz> References: <20180614152742.20640-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Detect when a directory entry is (possibly partially) beyond directory size and return EIO in that case since it means the filesystem is corrupted. Otherwise directory operations can further corrupt the directory and possibly also oops the kernel. CC: Anatoly Trosinenko CC: stable@vger.kernel.org Reported-by: Anatoly Trosinenko Signed-off-by: Jan Kara --- fs/udf/directory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/udf/directory.c b/fs/udf/directory.c index 0a98a2369738..3835f983cc99 100644 --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -152,6 +152,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, sizeof(struct fileIdentDesc)); } } + /* Got last entry outside of dir size - fs is corrupted! */ + if (*nf_pos > dir->i_size) + return NULL; return fi; } -- 2.16.4