Skip to content

Commit cf4ef78

Browse files
Stanislav GoriainovMiklos Szeredi
authored andcommitted
ovl: Add comment on upperredirect reassignment
If memory for uperredirect was allocated with kstrdup() in upperdir != NULL and d.redirect != NULL path, it may seem that it can be lost when upperredirect is reassigned later, but it's not possible. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 0a2d0d3 ("ovl: Check redirect on index as well") Signed-off-by: Stanislav Goriainov <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent af4dcb6 commit cf4ef78

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/overlayfs/namei.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,11 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
10861086
.mnt = ovl_upper_mnt(ofs),
10871087
};
10881088

1089+
/*
1090+
* It's safe to assign upperredirect here: the previous
1091+
* assignment of happens only if upperdentry is non-NULL, and
1092+
* this one only if upperdentry is NULL.
1093+
*/
10891094
upperredirect = ovl_get_redirect_xattr(ofs, &upperpath, 0);
10901095
if (IS_ERR(upperredirect)) {
10911096
err = PTR_ERR(upperredirect);

0 commit comments

Comments
 (0)