Skip to content

Commit e40ff21

Browse files
committed
ext4: force revalidation of directory pointer after seekdir(2)
A malicious user could force the directory pointer to be in an invalid spot by using seekdir(2). Use the mechanism we already have to notice if the directory has changed since the last time we called ext4_readdir() to force a revalidation of the pointer. Reported-by: syzbot+1236ce66f79263e8a862@syzkaller.appspotmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org
1 parent 54dd0e0 commit e40ff21

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎fs/ext4/dir.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,15 @@ static loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence)
365365
{
366366
struct inode *inode = file->f_mapping->host;
367367
int dx_dir = is_dx_dir(inode);
368-
loff_t htree_max = ext4_get_htree_eof(file);
368+
loff_t ret, htree_max = ext4_get_htree_eof(file);
369369

370370
if (likely(dx_dir))
371-
return generic_file_llseek_size(file, offset, whence,
371+
ret = generic_file_llseek_size(file, offset, whence,
372372
htree_max, htree_max);
373373
else
374-
return ext4_llseek(file, offset, whence);
374+
ret = ext4_llseek(file, offset, whence);
375+
file->f_version = inode_peek_iversion(inode) - 1;
376+
return ret;
375377
}
376378

377379
/*

0 commit comments

Comments
 (0)