48
48
#include <linux/slab.h>
49
49
#include <linux/pagemap.h>
50
50
#include <linux/aio.h>
51
+ #include <linux/gobohide.h>
51
52
52
53
#include <asm/uaccess.h>
53
54
#include <asm/mmu_context.h>
@@ -844,6 +845,7 @@ struct compat_readdir_callback {
844
845
struct dir_context ctx ;
845
846
struct compat_old_linux_dirent __user * dirent ;
846
847
int result ;
848
+ struct dentry * dentry ;
847
849
};
848
850
849
851
static int compat_fillonedir (struct dir_context * ctx , const char * name ,
@@ -893,6 +895,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
893
895
if (!f .file )
894
896
return - EBADF ;
895
897
898
+ buf .dentry = f .file -> f_path .dentry ;
896
899
error = iterate_dir (f .file , & buf .ctx );
897
900
if (buf .result )
898
901
error = buf .result ;
@@ -914,6 +917,7 @@ struct compat_getdents_callback {
914
917
struct compat_linux_dirent __user * previous ;
915
918
int count ;
916
919
int error ;
920
+ struct dentry * dentry ;
917
921
};
918
922
919
923
static int compat_filldir (struct dir_context * ctx , const char * name , int namlen ,
@@ -923,6 +927,7 @@ static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
923
927
struct compat_getdents_callback * buf =
924
928
container_of (ctx , struct compat_getdents_callback , ctx );
925
929
compat_ulong_t d_ino ;
930
+ struct hide * hidden ;
926
931
int reclen = ALIGN (offsetof(struct compat_linux_dirent , d_name ) +
927
932
namlen + 2 , sizeof (compat_long_t ));
928
933
@@ -936,10 +941,20 @@ static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
936
941
}
937
942
dirent = buf -> previous ;
938
943
if (dirent ) {
944
+ hidden = gobohide_get (d_ino , name , namlen , buf -> dentry );
945
+ if (hidden ) {
946
+ gobohide_put (hidden );
947
+ return 0 ;
948
+ }
939
949
if (__put_user (offset , & dirent -> d_off ))
940
950
goto efault ;
941
951
}
942
952
dirent = buf -> current_dir ;
953
+ hidden = gobohide_get (d_ino , name , namlen , buf -> dentry );
954
+ if (hidden ) {
955
+ gobohide_put (hidden );
956
+ return 0 ;
957
+ }
943
958
if (__put_user (d_ino , & dirent -> d_ino ))
944
959
goto efault ;
945
960
if (__put_user (reclen , & dirent -> d_reclen ))
@@ -979,6 +994,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
979
994
if (!f .file )
980
995
return - EBADF ;
981
996
997
+ buf .dentry = f .file -> f_path .dentry ;
982
998
error = iterate_dir (f .file , & buf .ctx );
983
999
if (error >= 0 )
984
1000
error = buf .error ;
@@ -1001,13 +1017,15 @@ struct compat_getdents_callback64 {
1001
1017
struct linux_dirent64 __user * previous ;
1002
1018
int count ;
1003
1019
int error ;
1020
+ struct dentry * dentry ;
1004
1021
};
1005
1022
1006
1023
static int compat_filldir64 (struct dir_context * ctx , const char * name ,
1007
1024
int namlen , loff_t offset , u64 ino ,
1008
1025
unsigned int d_type )
1009
1026
{
1010
1027
struct linux_dirent64 __user * dirent ;
1028
+ struct hide * hidden ;
1011
1029
struct compat_getdents_callback64 * buf =
1012
1030
container_of (ctx , struct compat_getdents_callback64 , ctx );
1013
1031
int reclen = ALIGN (offsetof(struct linux_dirent64 , d_name ) + namlen + 1 ,
@@ -1020,10 +1038,20 @@ static int compat_filldir64(struct dir_context *ctx, const char *name,
1020
1038
dirent = buf -> previous ;
1021
1039
1022
1040
if (dirent ) {
1041
+ hidden = gobohide_get (ino , name , namlen , buf -> dentry );
1042
+ if (hidden ) {
1043
+ gobohide_put (hidden );
1044
+ return 0 ;
1045
+ }
1023
1046
if (__put_user_unaligned (offset , & dirent -> d_off ))
1024
1047
goto efault ;
1025
1048
}
1026
1049
dirent = buf -> current_dir ;
1050
+ hidden = gobohide_get (ino , name , namlen , buf -> dentry );
1051
+ if (hidden ) {
1052
+ gobohide_put (hidden );
1053
+ return 0 ;
1054
+ }
1027
1055
if (__put_user_unaligned (ino , & dirent -> d_ino ))
1028
1056
goto efault ;
1029
1057
off = 0 ;
@@ -1066,6 +1094,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
1066
1094
if (!f .file )
1067
1095
return - EBADF ;
1068
1096
1097
+ buf .dentry = f .file -> f_path .dentry ;
1069
1098
error = iterate_dir (f .file , & buf .ctx );
1070
1099
if (error >= 0 )
1071
1100
error = buf .error ;
0 commit comments