@@ -218,30 +218,48 @@ static inline int ovl_do_symlink(struct ovl_fs *ofs,
218218 return err ;
219219}
220220
221- static inline ssize_t ovl_do_getxattr (struct ovl_fs * ofs , struct dentry * dentry ,
222- const char * name , void * value ,
223- size_t size )
221+ static inline ssize_t ovl_do_getxattr (struct path * path , const char * name ,
222+ void * value , size_t size )
224223{
225- int err = vfs_getxattr (& init_user_ns , dentry , name , value , size );
226- int len = (value && err > 0 ) ? err : 0 ;
224+ int err , len ;
225+
226+ WARN_ON (path -> dentry -> d_sb != path -> mnt -> mnt_sb );
227+
228+ err = vfs_getxattr (mnt_user_ns (path -> mnt ), path -> dentry ,
229+ name , value , size );
230+ len = (value && err > 0 ) ? err : 0 ;
227231
228232 pr_debug ("getxattr(%pd2, \"%s\", \"%*pE\", %zu, 0) = %i\n" ,
229- dentry , name , min (len , 48 ), value , size , err );
233+ path -> dentry , name , min (len , 48 ), value , size , err );
230234 return err ;
231235}
232236
233- static inline ssize_t ovl_getxattr (struct ovl_fs * ofs , struct dentry * dentry ,
234- enum ovl_xattr ox , void * value ,
235- size_t size )
237+ static inline ssize_t ovl_getxattr_upper (struct ovl_fs * ofs ,
238+ struct dentry * upperdentry ,
239+ enum ovl_xattr ox , void * value ,
240+ size_t size )
241+ {
242+ struct path upperpath = {
243+ .dentry = upperdentry ,
244+ .mnt = ovl_upper_mnt (ofs ),
245+ };
246+
247+ return ovl_do_getxattr (& upperpath , ovl_xattr (ofs , ox ), value , size );
248+ }
249+
250+ static inline ssize_t ovl_path_getxattr (struct ovl_fs * ofs ,
251+ struct path * path ,
252+ enum ovl_xattr ox , void * value ,
253+ size_t size )
236254{
237- return ovl_do_getxattr (ofs , dentry , ovl_xattr (ofs , ox ), value , size );
255+ return ovl_do_getxattr (path , ovl_xattr (ofs , ox ), value , size );
238256}
239257
240258static inline int ovl_do_setxattr (struct ovl_fs * ofs , struct dentry * dentry ,
241259 const char * name , const void * value ,
242260 size_t size , int flags )
243261{
244- int err = vfs_setxattr (& init_user_ns , dentry , name , value , size , flags );
262+ int err = vfs_setxattr (ovl_upper_mnt_userns ( ofs ) , dentry , name , value , size , flags );
245263
246264 pr_debug ("setxattr(%pd2, \"%s\", \"%*pE\", %zu, %d) = %i\n" ,
247265 dentry , name , min ((int )size , 48 ), value , size , flags , err );
@@ -258,7 +276,7 @@ static inline int ovl_setxattr(struct ovl_fs *ofs, struct dentry *dentry,
258276static inline int ovl_do_removexattr (struct ovl_fs * ofs , struct dentry * dentry ,
259277 const char * name )
260278{
261- int err = vfs_removexattr (& init_user_ns , dentry , name );
279+ int err = vfs_removexattr (ovl_upper_mnt_userns ( ofs ) , dentry , name );
262280 pr_debug ("removexattr(%pd2, \"%s\") = %i\n" , dentry , name , err );
263281 return err ;
264282}
@@ -394,9 +412,20 @@ struct file *ovl_path_open(struct path *path, int flags);
394412int ovl_copy_up_start (struct dentry * dentry , int flags );
395413void ovl_copy_up_end (struct dentry * dentry );
396414bool ovl_already_copied_up (struct dentry * dentry , int flags );
397- bool ovl_check_origin_xattr (struct ovl_fs * ofs , struct dentry * dentry );
398- bool ovl_check_dir_xattr (struct super_block * sb , struct dentry * dentry ,
399- enum ovl_xattr ox );
415+ bool ovl_path_check_dir_xattr (struct ovl_fs * ofs , struct path * path ,
416+ enum ovl_xattr ox );
417+ bool ovl_path_check_origin_xattr (struct ovl_fs * ofs , struct path * path );
418+
419+ static inline bool ovl_check_origin_xattr (struct ovl_fs * ofs ,
420+ struct dentry * upperdentry )
421+ {
422+ struct path upperpath = {
423+ .dentry = upperdentry ,
424+ .mnt = ovl_upper_mnt (ofs ),
425+ };
426+ return ovl_path_check_origin_xattr (ofs , & upperpath );
427+ }
428+
400429int ovl_check_setxattr (struct ovl_fs * ofs , struct dentry * upperdentry ,
401430 enum ovl_xattr ox , const void * value , size_t size ,
402431 int xerr );
@@ -408,10 +437,9 @@ bool ovl_need_index(struct dentry *dentry);
408437int ovl_nlink_start (struct dentry * dentry );
409438void ovl_nlink_end (struct dentry * dentry );
410439int ovl_lock_rename_workdir (struct dentry * workdir , struct dentry * upperdir );
411- int ovl_check_metacopy_xattr (struct ovl_fs * ofs , struct dentry * dentry );
440+ int ovl_check_metacopy_xattr (struct ovl_fs * ofs , struct path * path );
412441bool ovl_is_metacopy_dentry (struct dentry * dentry );
413- char * ovl_get_redirect_xattr (struct ovl_fs * ofs , struct dentry * dentry ,
414- int padding );
442+ char * ovl_get_redirect_xattr (struct ovl_fs * ofs , struct path * path , int padding );
415443int ovl_sync_status (struct ovl_fs * ofs );
416444
417445static inline void ovl_set_flag (unsigned long flag , struct inode * inode )
@@ -430,9 +458,15 @@ static inline bool ovl_test_flag(unsigned long flag, struct inode *inode)
430458}
431459
432460static inline bool ovl_is_impuredir (struct super_block * sb ,
433- struct dentry * dentry )
461+ struct dentry * upperdentry )
434462{
435- return ovl_check_dir_xattr (sb , dentry , OVL_XATTR_IMPURE );
463+ struct ovl_fs * ofs = OVL_FS (sb );
464+ struct path upperpath = {
465+ .dentry = upperdentry ,
466+ .mnt = ovl_upper_mnt (ofs ),
467+ };
468+
469+ return ovl_path_check_dir_xattr (ofs , & upperpath , OVL_XATTR_IMPURE );
436470}
437471
438472/*
@@ -659,8 +693,7 @@ int ovl_fileattr_set(struct user_namespace *mnt_userns,
659693int ovl_copy_up (struct dentry * dentry );
660694int ovl_copy_up_with_data (struct dentry * dentry );
661695int ovl_maybe_copy_up (struct dentry * dentry , int flags );
662- int ovl_copy_xattr (struct super_block * sb , struct dentry * old ,
663- struct dentry * new );
696+ int ovl_copy_xattr (struct super_block * sb , struct path * path , struct dentry * new );
664697int ovl_set_attr (struct ovl_fs * ofs , struct dentry * upper , struct kstat * stat );
665698struct ovl_fh * ovl_encode_real_fh (struct ovl_fs * ofs , struct dentry * real ,
666699 bool is_upper );
0 commit comments