Skip to content

Commit

Permalink
ocfs2_dentry_revalidate(): use stable parent inode and name passed by…
Browse files Browse the repository at this point in the history
… caller

theoretically, ->d_name use in there is a UAF, but only if you are messing with
tracepoints...

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jan 28, 2025
1 parent ffeeaad commit 9640fe5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions fs/ocfs2/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,16 @@ static int ocfs2_dentry_revalidate(struct inode *dir, const struct qstr *name,
inode = d_inode(dentry);
osb = OCFS2_SB(dentry->d_sb);

trace_ocfs2_dentry_revalidate(dentry, dentry->d_name.len,
dentry->d_name.name);
trace_ocfs2_dentry_revalidate(dentry, name->len, name->name);

/* For a negative dentry -
* check the generation number of the parent and compare with the
* one stored in the inode.
*/
if (inode == NULL) {
unsigned long gen = (unsigned long) dentry->d_fsdata;
unsigned long pgen;
spin_lock(&dentry->d_lock);
pgen = OCFS2_I(d_inode(dentry->d_parent))->ip_dir_lock_gen;
spin_unlock(&dentry->d_lock);
trace_ocfs2_dentry_revalidate_negative(dentry->d_name.len,
dentry->d_name.name,
unsigned long pgen = OCFS2_I(dir)->ip_dir_lock_gen;
trace_ocfs2_dentry_revalidate_negative(name->len, name->name,
pgen, gen);
if (gen != pgen)
goto bail;
Expand Down

0 comments on commit 9640fe5

Please sign in to comment.