@@ -2874,7 +2874,7 @@ int smb2_open(struct ksmbd_work *work)
2874
2874
int req_op_level = 0 , open_flags = 0 , may_flags = 0 , file_info = 0 ;
2875
2875
int rc = 0 ;
2876
2876
int contxt_cnt = 0 , query_disk_id = 0 ;
2877
- int maximal_access_ctxt = 0 , posix_ctxt = 0 ;
2877
+ bool maximal_access_ctxt = false , posix_ctxt = false ;
2878
2878
int s_type = 0 ;
2879
2879
int next_off = 0 ;
2880
2880
char * name = NULL ;
@@ -2903,6 +2903,27 @@ int smb2_open(struct ksmbd_work *work)
2903
2903
return create_smb2_pipe (work );
2904
2904
}
2905
2905
2906
+ if (req -> CreateContextsOffset && tcon -> posix_extensions ) {
2907
+ context = smb2_find_context_vals (req , SMB2_CREATE_TAG_POSIX , 16 );
2908
+ if (IS_ERR (context )) {
2909
+ rc = PTR_ERR (context );
2910
+ goto err_out2 ;
2911
+ } else if (context ) {
2912
+ struct create_posix * posix = (struct create_posix * )context ;
2913
+
2914
+ if (le16_to_cpu (context -> DataOffset ) +
2915
+ le32_to_cpu (context -> DataLength ) <
2916
+ sizeof (struct create_posix ) - 4 ) {
2917
+ rc = - EINVAL ;
2918
+ goto err_out2 ;
2919
+ }
2920
+ ksmbd_debug (SMB , "get posix context\n" );
2921
+
2922
+ posix_mode = le32_to_cpu (posix -> Mode );
2923
+ posix_ctxt = true;
2924
+ }
2925
+ }
2926
+
2906
2927
if (req -> NameLength ) {
2907
2928
name = smb2_get_name ((char * )req + le16_to_cpu (req -> NameOffset ),
2908
2929
le16_to_cpu (req -> NameLength ),
@@ -2925,9 +2946,11 @@ int smb2_open(struct ksmbd_work *work)
2925
2946
goto err_out2 ;
2926
2947
}
2927
2948
2928
- rc = ksmbd_validate_filename (name );
2929
- if (rc < 0 )
2930
- goto err_out2 ;
2949
+ if (posix_ctxt == false) {
2950
+ rc = ksmbd_validate_filename (name );
2951
+ if (rc < 0 )
2952
+ goto err_out2 ;
2953
+ }
2931
2954
2932
2955
if (ksmbd_share_veto_filename (share , name )) {
2933
2956
rc = - ENOENT ;
@@ -3085,28 +3108,6 @@ int smb2_open(struct ksmbd_work *work)
3085
3108
rc = - EBADF ;
3086
3109
goto err_out2 ;
3087
3110
}
3088
-
3089
- if (tcon -> posix_extensions ) {
3090
- context = smb2_find_context_vals (req ,
3091
- SMB2_CREATE_TAG_POSIX , 16 );
3092
- if (IS_ERR (context )) {
3093
- rc = PTR_ERR (context );
3094
- goto err_out2 ;
3095
- } else if (context ) {
3096
- struct create_posix * posix =
3097
- (struct create_posix * )context ;
3098
- if (le16_to_cpu (context -> DataOffset ) +
3099
- le32_to_cpu (context -> DataLength ) <
3100
- sizeof (struct create_posix ) - 4 ) {
3101
- rc = - EINVAL ;
3102
- goto err_out2 ;
3103
- }
3104
- ksmbd_debug (SMB , "get posix context\n" );
3105
-
3106
- posix_mode = le32_to_cpu (posix -> Mode );
3107
- posix_ctxt = 1 ;
3108
- }
3109
- }
3110
3111
}
3111
3112
3112
3113
if (ksmbd_override_fsids (work )) {
0 commit comments