From 2de1ee6dd822857daaad9793259eb0a8478ee584 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Wed, 31 May 2023 17:25:46 +0530 Subject: [PATCH] BACKPORT: FROMLIST: ovl: Let helper ovl_i_path_real() return the realinode Let helper ovl_i_path_real() return the realinode to prepare for checking non-null realinode in rcu walking path. Signed-off-by: Zhihao Cheng Reviewed-by: Amir Goldstein Bug: 285105314 Link: https://lore.kernel.org/lkml/20230516-topografie-gejubelt-dba162b6e735@brauner/T/ Change-Id: I4fed6fe0874215eb381b6879565a98b855916931 Signed-off-by: Pradeep P V K --- fs/overlayfs/overlayfs.h | 2 +- fs/overlayfs/util.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 09fa935db5aa..86e17ddbc160 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -368,7 +368,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry); void ovl_path_upper(struct dentry *dentry, struct path *path); void ovl_path_lower(struct dentry *dentry, struct path *path); void ovl_path_lowerdata(struct dentry *dentry, struct path *path); -void ovl_i_path_real(struct inode *inode, struct path *path); +struct inode *ovl_i_path_real(struct inode *inode, struct path *path); enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); enum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path); struct dentry *ovl_dentry_upper(struct dentry *dentry); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 4197dab4951e..4089ccc33c36 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -259,7 +259,7 @@ struct dentry *ovl_i_dentry_upper(struct inode *inode) return ovl_upperdentry_dereference(OVL_I(inode)); } -void ovl_i_path_real(struct inode *inode, struct path *path) +struct inode *ovl_i_path_real(struct inode *inode, struct path *path) { path->dentry = ovl_i_dentry_upper(inode); if (!path->dentry) { @@ -268,6 +268,8 @@ void ovl_i_path_real(struct inode *inode, struct path *path) } else { path->mnt = ovl_upper_mnt(OVL_FS(inode->i_sb)); } + + return path->dentry ? d_inode(path->dentry) : NULL; } struct inode *ovl_inode_upper(struct inode *inode) @@ -1114,8 +1116,7 @@ void ovl_copyattr(struct inode *inode) struct inode *realinode; struct user_namespace *real_mnt_userns; - ovl_i_path_real(inode, &realpath); - realinode = d_inode(realpath.dentry); + realinode = ovl_i_path_real(inode, &realpath); real_mnt_userns = mnt_user_ns(realpath.mnt); inode->i_uid = i_uid_into_mnt(real_mnt_userns, realinode);