aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2018-04-01 23:21:03 -0400
committerTheodore Ts'o <tytso@mit.edu>2018-04-01 23:21:03 -0400
commite40ff213898502d299351cc2fe1e350cd186f0d3 (patch)
tree48d024ff8abaa9efca5d38d93602188211c0130a
parent54dd0e0a1b255f115f8647fc6fb93273251b01b9 (diff)
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
-rw-r--r--fs/ext4/dir.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index da87cf757f7d..e2902d394f1b 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -365,13 +365,15 @@ static loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence)
365{ 365{
366 struct inode *inode = file->f_mapping->host; 366 struct inode *inode = file->f_mapping->host;
367 int dx_dir = is_dx_dir(inode); 367 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);
369 369
370 if (likely(dx_dir)) 370 if (likely(dx_dir))
371 return generic_file_llseek_size(file, offset, whence, 371 ret = generic_file_llseek_size(file, offset, whence,
372 htree_max, htree_max); 372 htree_max, htree_max);
373 else 373 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;
375} 377}
376 378
377/* 379/*