diff options
author | Steve French <smfrench@gmail.com> | 2012-12-08 23:08:06 -0500 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-12-09 20:45:45 -0500 |
commit | 38107d45cf452761a74fe512190e23f36834d6dd (patch) | |
tree | bc0c08d21ba5b26b74b69edbe0ce27be951c10a2 /fs | |
parent | 1f6306806c1494bea51b93f96e105e93a96e3c22 (diff) |
Do not send SMB2 signatures for SMB3 frames
Restructure code to make SMB2 vs. SMB3 signing a protocol
specific op. SMB3 signing (AES_CMAC) is not enabled yet,
but this restructuring at least makes sure we don't send
an smb2 signature on an smb3 signed connection. A followon
patch will add AES_CMAC and enable smb3 signing.
Signed-off-by: Steve French <smfrench@gmail.com>
Acked-by: Jeff Layton <jlayton@samba.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/cifsglob.h | 4 | ||||
-rw-r--r-- | fs/cifs/connect.c | 2 | ||||
-rw-r--r-- | fs/cifs/smb2ops.c | 68 | ||||
-rw-r--r-- | fs/cifs/smb2proto.h | 4 | ||||
-rw-r--r-- | fs/cifs/smb2transport.c | 13 |
5 files changed, 86 insertions, 5 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 74a07b604ffd..dfab450a191e 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -367,6 +367,8 @@ struct smb_version_operations { | |||
367 | void (*set_lease_key)(struct inode *, struct cifs_fid *fid); | 367 | void (*set_lease_key)(struct inode *, struct cifs_fid *fid); |
368 | /* generate new lease key */ | 368 | /* generate new lease key */ |
369 | void (*new_lease_key)(struct cifs_fid *fid); | 369 | void (*new_lease_key)(struct cifs_fid *fid); |
370 | int (*calc_signature)(struct smb_rqst *rqst, | ||
371 | struct TCP_Server_Info *server); | ||
370 | }; | 372 | }; |
371 | 373 | ||
372 | struct smb_version_values { | 374 | struct smb_version_values { |
@@ -1489,6 +1491,6 @@ extern struct smb_version_values smb20_values; | |||
1489 | extern struct smb_version_operations smb21_operations; | 1491 | extern struct smb_version_operations smb21_operations; |
1490 | extern struct smb_version_values smb21_values; | 1492 | extern struct smb_version_values smb21_values; |
1491 | #define SMB30_VERSION_STRING "3.0" | 1493 | #define SMB30_VERSION_STRING "3.0" |
1492 | /*extern struct smb_version_operations smb30_operations; */ /* not needed yet */ | 1494 | extern struct smb_version_operations smb30_operations; |
1493 | extern struct smb_version_values smb30_values; | 1495 | extern struct smb_version_values smb30_values; |
1494 | #endif /* _CIFS_GLOB_H */ | 1496 | #endif /* _CIFS_GLOB_H */ |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 290c13442f75..f3276239e075 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1085,7 +1085,7 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol) | |||
1085 | vol->vals = &smb21_values; | 1085 | vol->vals = &smb21_values; |
1086 | break; | 1086 | break; |
1087 | case Smb_30: | 1087 | case Smb_30: |
1088 | vol->ops = &smb21_operations; /* currently identical with 2.1 */ | 1088 | vol->ops = &smb30_operations; |
1089 | vol->vals = &smb30_values; | 1089 | vol->vals = &smb30_values; |
1090 | break; | 1090 | break; |
1091 | #endif | 1091 | #endif |
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index ad4d96a4bff5..d79de7bc4435 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c | |||
@@ -623,6 +623,74 @@ struct smb_version_operations smb21_operations = { | |||
623 | .get_lease_key = smb2_get_lease_key, | 623 | .get_lease_key = smb2_get_lease_key, |
624 | .set_lease_key = smb2_set_lease_key, | 624 | .set_lease_key = smb2_set_lease_key, |
625 | .new_lease_key = smb2_new_lease_key, | 625 | .new_lease_key = smb2_new_lease_key, |
626 | .calc_signature = smb2_calc_signature, | ||
627 | }; | ||
628 | |||
629 | |||
630 | struct smb_version_operations smb30_operations = { | ||
631 | .compare_fids = smb2_compare_fids, | ||
632 | .setup_request = smb2_setup_request, | ||
633 | .setup_async_request = smb2_setup_async_request, | ||
634 | .check_receive = smb2_check_receive, | ||
635 | .add_credits = smb2_add_credits, | ||
636 | .set_credits = smb2_set_credits, | ||
637 | .get_credits_field = smb2_get_credits_field, | ||
638 | .get_credits = smb2_get_credits, | ||
639 | .get_next_mid = smb2_get_next_mid, | ||
640 | .read_data_offset = smb2_read_data_offset, | ||
641 | .read_data_length = smb2_read_data_length, | ||
642 | .map_error = map_smb2_to_linux_error, | ||
643 | .find_mid = smb2_find_mid, | ||
644 | .check_message = smb2_check_message, | ||
645 | .dump_detail = smb2_dump_detail, | ||
646 | .clear_stats = smb2_clear_stats, | ||
647 | .print_stats = smb2_print_stats, | ||
648 | .is_oplock_break = smb2_is_valid_oplock_break, | ||
649 | .need_neg = smb2_need_neg, | ||
650 | .negotiate = smb2_negotiate, | ||
651 | .negotiate_wsize = smb2_negotiate_wsize, | ||
652 | .negotiate_rsize = smb2_negotiate_rsize, | ||
653 | .sess_setup = SMB2_sess_setup, | ||
654 | .logoff = SMB2_logoff, | ||
655 | .tree_connect = SMB2_tcon, | ||
656 | .tree_disconnect = SMB2_tdis, | ||
657 | .is_path_accessible = smb2_is_path_accessible, | ||
658 | .can_echo = smb2_can_echo, | ||
659 | .echo = SMB2_echo, | ||
660 | .query_path_info = smb2_query_path_info, | ||
661 | .get_srv_inum = smb2_get_srv_inum, | ||
662 | .query_file_info = smb2_query_file_info, | ||
663 | .set_path_size = smb2_set_path_size, | ||
664 | .set_file_size = smb2_set_file_size, | ||
665 | .set_file_info = smb2_set_file_info, | ||
666 | .mkdir = smb2_mkdir, | ||
667 | .mkdir_setinfo = smb2_mkdir_setinfo, | ||
668 | .rmdir = smb2_rmdir, | ||
669 | .unlink = smb2_unlink, | ||
670 | .rename = smb2_rename_path, | ||
671 | .create_hardlink = smb2_create_hardlink, | ||
672 | .open = smb2_open_file, | ||
673 | .set_fid = smb2_set_fid, | ||
674 | .close = smb2_close_file, | ||
675 | .flush = smb2_flush_file, | ||
676 | .async_readv = smb2_async_readv, | ||
677 | .async_writev = smb2_async_writev, | ||
678 | .sync_read = smb2_sync_read, | ||
679 | .sync_write = smb2_sync_write, | ||
680 | .query_dir_first = smb2_query_dir_first, | ||
681 | .query_dir_next = smb2_query_dir_next, | ||
682 | .close_dir = smb2_close_dir, | ||
683 | .calc_smb_size = smb2_calc_size, | ||
684 | .is_status_pending = smb2_is_status_pending, | ||
685 | .oplock_response = smb2_oplock_response, | ||
686 | .queryfs = smb2_queryfs, | ||
687 | .mand_lock = smb2_mand_lock, | ||
688 | .mand_unlock_range = smb2_unlock_range, | ||
689 | .push_mand_locks = smb2_push_mandatory_locks, | ||
690 | .get_lease_key = smb2_get_lease_key, | ||
691 | .set_lease_key = smb2_set_lease_key, | ||
692 | .new_lease_key = smb2_new_lease_key, | ||
693 | .calc_signature = smb3_calc_signature, | ||
626 | }; | 694 | }; |
627 | 695 | ||
628 | struct smb_version_values smb20_values = { | 696 | struct smb_version_values smb20_values = { |
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index 7d25f8b14f93..2aa3535e38ce 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h | |||
@@ -47,6 +47,10 @@ extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses, | |||
47 | struct smb_rqst *rqst); | 47 | struct smb_rqst *rqst); |
48 | extern struct mid_q_entry *smb2_setup_async_request( | 48 | extern struct mid_q_entry *smb2_setup_async_request( |
49 | struct TCP_Server_Info *server, struct smb_rqst *rqst); | 49 | struct TCP_Server_Info *server, struct smb_rqst *rqst); |
50 | extern int smb2_calc_signature(struct smb_rqst *rqst, | ||
51 | struct TCP_Server_Info *server); | ||
52 | extern int smb3_calc_signature(struct smb_rqst *rqst, | ||
53 | struct TCP_Server_Info *server); | ||
50 | extern void smb2_echo_request(struct work_struct *work); | 54 | extern void smb2_echo_request(struct work_struct *work); |
51 | extern __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode); | 55 | extern __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode); |
52 | extern __u8 smb2_map_lease_to_oplock(__le32 lease_state); | 56 | extern __u8 smb2_map_lease_to_oplock(__le32 lease_state); |
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 2a5fdf26f79f..8dd73e61d762 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "smb2status.h" | 39 | #include "smb2status.h" |
40 | #include "smb2glob.h" | 40 | #include "smb2glob.h" |
41 | 41 | ||
42 | static int | 42 | int |
43 | smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | 43 | smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) |
44 | { | 44 | { |
45 | int i, rc; | 45 | int i, rc; |
@@ -116,6 +116,13 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
116 | return rc; | 116 | return rc; |
117 | } | 117 | } |
118 | 118 | ||
119 | int | ||
120 | smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | ||
121 | { | ||
122 | cFYI(1, "smb3 signatures not supported yet"); | ||
123 | return -EOPNOTSUPP; | ||
124 | } | ||
125 | |||
119 | /* must be called with server->srv_mutex held */ | 126 | /* must be called with server->srv_mutex held */ |
120 | static int | 127 | static int |
121 | smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server) | 128 | smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server) |
@@ -132,7 +139,7 @@ smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
132 | return rc; | 139 | return rc; |
133 | } | 140 | } |
134 | 141 | ||
135 | rc = smb2_calc_signature(rqst, server); | 142 | rc = server->ops->calc_signature(rqst, server); |
136 | 143 | ||
137 | return rc; | 144 | return rc; |
138 | } | 145 | } |
@@ -168,7 +175,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | |||
168 | memset(smb2_pdu->Signature, 0, SMB2_SIGNATURE_SIZE); | 175 | memset(smb2_pdu->Signature, 0, SMB2_SIGNATURE_SIZE); |
169 | 176 | ||
170 | mutex_lock(&server->srv_mutex); | 177 | mutex_lock(&server->srv_mutex); |
171 | rc = smb2_calc_signature(rqst, server); | 178 | rc = server->ops->calc_signature(rqst, server); |
172 | mutex_unlock(&server->srv_mutex); | 179 | mutex_unlock(&server->srv_mutex); |
173 | 180 | ||
174 | if (rc) | 181 | if (rc) |