From: Jan Kara Date: Wed, 25 Jan 2023 10:43:03 +0000 (+0100) Subject: udf: Fix directory iteration for longer tail extents X-Git-Tag: v6.1.122~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c450489f9c86cc9bde7d39d941c5ae6d05051e8;p=thirdparty%2Fkernel%2Fstable.git udf: Fix directory iteration for longer tail extents commit 1ea1cd11c72d1405a6b98440a9d5ea82dfa07166 upstream. When directory's last extent has more that one block and its length is not multiple of a block side, the code wrongly decided to move to the next extent instead of processing the last partial block. This led to directory corruption. Fix the rounding issue. Signed-off-by: Jan Kara Cc: Shreenidhi Shedi Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/udf/directory.c b/fs/udf/directory.c index 04169e428fdfa..76dd2e35e0981 100644 --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -170,7 +170,7 @@ static struct buffer_head *udf_fiiter_bread_blk(struct udf_fileident_iter *iter) static int udf_fiiter_advance_blk(struct udf_fileident_iter *iter) { iter->loffset++; - if (iter->loffset < iter->elen >> iter->dir->i_blkbits) + if (iter->loffset < DIV_ROUND_UP(iter->elen, 1<dir->i_blkbits)) return 0; iter->loffset = 0;