@@ -888,24 +888,43 @@ listxattr(struct dentry *d, char __user *list, size_t size)
888
888
return error ;
889
889
}
890
890
891
- static ssize_t path_listxattr (const char __user * pathname , char __user * list ,
892
- size_t size , unsigned int lookup_flags )
891
+ static
892
+ ssize_t file_listxattr (struct file * f , char __user * list , size_t size )
893
+ {
894
+ audit_file (f );
895
+ return listxattr (f -> f_path .dentry , list , size );
896
+ }
897
+
898
+ /* unconditionally consumes filename */
899
+ static
900
+ ssize_t filename_listxattr (int dfd , struct filename * filename ,
901
+ unsigned int lookup_flags ,
902
+ char __user * list , size_t size )
893
903
{
894
904
struct path path ;
895
905
ssize_t error ;
896
906
retry :
897
- error = user_path_at ( AT_FDCWD , pathname , lookup_flags , & path );
907
+ error = filename_lookup ( dfd , filename , lookup_flags , & path , NULL );
898
908
if (error )
899
- return error ;
909
+ goto out ;
900
910
error = listxattr (path .dentry , list , size );
901
911
path_put (& path );
902
912
if (retry_estale (error , lookup_flags )) {
903
913
lookup_flags |= LOOKUP_REVAL ;
904
914
goto retry ;
905
915
}
916
+ out :
917
+ putname (filename );
906
918
return error ;
907
919
}
908
920
921
+ static ssize_t path_listxattr (const char __user * pathname , char __user * list ,
922
+ size_t size , unsigned int lookup_flags )
923
+ {
924
+ return filename_listxattr (AT_FDCWD , getname (pathname ), lookup_flags ,
925
+ list , size );
926
+ }
927
+
909
928
SYSCALL_DEFINE3 (listxattr , const char __user * , pathname , char __user * , list ,
910
929
size_t , size )
911
930
{
@@ -924,8 +943,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
924
943
925
944
if (fd_empty (f ))
926
945
return - EBADF ;
927
- audit_file (fd_file (f ));
928
- return listxattr (fd_file (f )-> f_path .dentry , list , size );
946
+ return file_listxattr (fd_file (f ), list , size );
929
947
}
930
948
931
949
/*
0 commit comments