@@ -957,33 +957,58 @@ removexattr(struct mnt_idmap *idmap, struct dentry *d, const char *name)
957
957
return vfs_removexattr (idmap , d , name );
958
958
}
959
959
960
- static int path_removexattr (const char __user * pathname ,
961
- const char __user * name , unsigned int lookup_flags )
960
+ static int file_removexattr (struct file * f , struct xattr_name * kname )
961
+ {
962
+ int error = mnt_want_write_file (f );
963
+
964
+ if (!error ) {
965
+ audit_file (f );
966
+ error = removexattr (file_mnt_idmap (f ),
967
+ f -> f_path .dentry , kname -> name );
968
+ mnt_drop_write_file (f );
969
+ }
970
+ return error ;
971
+ }
972
+
973
+ /* unconditionally consumes filename */
974
+ static int filename_removexattr (int dfd , struct filename * filename ,
975
+ unsigned int lookup_flags , struct xattr_name * kname )
962
976
{
963
977
struct path path ;
964
978
int error ;
965
- struct xattr_name kname ;
966
979
967
- error = import_xattr_name (& kname , name );
968
- if (error )
969
- return error ;
970
980
retry :
971
- error = user_path_at ( AT_FDCWD , pathname , lookup_flags , & path );
981
+ error = filename_lookup ( dfd , filename , lookup_flags , & path , NULL );
972
982
if (error )
973
- return error ;
983
+ goto out ;
974
984
error = mnt_want_write (path .mnt );
975
985
if (!error ) {
976
- error = removexattr (mnt_idmap (path .mnt ), path .dentry , kname . name );
986
+ error = removexattr (mnt_idmap (path .mnt ), path .dentry , kname -> name );
977
987
mnt_drop_write (path .mnt );
978
988
}
979
989
path_put (& path );
980
990
if (retry_estale (error , lookup_flags )) {
981
991
lookup_flags |= LOOKUP_REVAL ;
982
992
goto retry ;
983
993
}
994
+ out :
995
+ putname (filename );
984
996
return error ;
985
997
}
986
998
999
+ static int path_removexattr (const char __user * pathname ,
1000
+ const char __user * name , unsigned int lookup_flags )
1001
+ {
1002
+ struct xattr_name kname ;
1003
+ int error ;
1004
+
1005
+ error = import_xattr_name (& kname , name );
1006
+ if (error )
1007
+ return error ;
1008
+ return filename_removexattr (AT_FDCWD , getname (pathname ), lookup_flags ,
1009
+ & kname );
1010
+ }
1011
+
987
1012
SYSCALL_DEFINE2 (removexattr , const char __user * , pathname ,
988
1013
const char __user * , name )
989
1014
{
@@ -1004,19 +1029,11 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
1004
1029
1005
1030
if (fd_empty (f ))
1006
1031
return - EBADF ;
1007
- audit_file (fd_file (f ));
1008
1032
1009
1033
error = import_xattr_name (& kname , name );
1010
1034
if (error )
1011
1035
return error ;
1012
-
1013
- error = mnt_want_write_file (fd_file (f ));
1014
- if (!error ) {
1015
- error = removexattr (file_mnt_idmap (fd_file (f )),
1016
- fd_file (f )-> f_path .dentry , kname .name );
1017
- mnt_drop_write_file (fd_file (f ));
1018
- }
1019
- return error ;
1036
+ return file_removexattr (fd_file (f ), & kname );
1020
1037
}
1021
1038
1022
1039
int xattr_list_one (char * * buffer , ssize_t * remaining_size , const char * name )
0 commit comments