udf: Fix directory iteration for longer tail extents
authorJan Kara <jack@suse.cz>
Wed, 25 Jan 2023 10:43:03 +0000 (11:43 +0100)
committerJan Kara <jack@suse.cz>
Thu, 26 Jan 2023 15:46:32 +0000 (16:46 +0100)
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 <jack@suse.cz>
fs/udf/directory.c

index b1424e2aa86829578609aa1d70675abe96744391..31f1bf8ab8481825a41a448f7462294f80301bd7 100644 (file)
@@ -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<<iter->dir->i_blkbits))
                return 0;
 
        iter->loffset = 0;