Print this page
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
SMB-122 smbd core dumps in smbd_dc_update / smb_log
SMB-117 Win7 fails to open security properties
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/fs/smbsrv/smb2_query_info.c
+++ new/usr/src/uts/common/fs/smbsrv/smb2_query_info.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
|
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 - * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
13 + * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
14 14 */
15 15
16 16 /*
17 17 * Dispatch function for SMB2_QUERY_INFO
18 18 */
19 19
20 20 #include <smbsrv/smb2_kproto.h>
21 21 #include <smbsrv/smb_fsops.h>
22 22 #include <smbsrv/ntifs.h>
23 23
24 24 smb_sdrc_t
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
25 25 smb2_query_info(smb_request_t *sr)
26 26 {
27 27 smb_queryinfo_t *qi;
28 28 uint16_t StructSize;
29 29 uint32_t oBufLength;
30 30 uint16_t iBufOffset;
31 31 uint32_t iBufLength;
32 32 smb2fid_t smb2fid;
33 33 uint16_t DataOff;
34 34 uint32_t status;
35 - smb_sdrc_t sdrc = SDRC_SUCCESS;
36 35 int rc = 0;
37 36
38 - qi = kmem_zalloc(sizeof (*qi), KM_SLEEP);
37 + qi = smb_srm_zalloc(sr, sizeof (*qi));
39 38
40 39 /*
41 40 * SMB2 Query Info request
42 41 */
43 42 rc = smb_mbc_decodef(
44 43 &sr->smb_data, "wbblw..lllqq",
45 44 &StructSize, /* w */
46 45 &qi->qi_InfoType, /* b */
47 46 &qi->qi_InfoClass, /* b */
48 47 &oBufLength, /* l */
49 48 &iBufOffset, /* w */
50 49 /* reserved .. */
51 50 &iBufLength, /* l */
52 51 &qi->qi_AddlInfo, /* l */
53 52 &qi->qi_Flags, /* l */
54 53 &smb2fid.persistent, /* q */
55 54 &smb2fid.temporal); /* q */
56 - if (rc || StructSize != 41) {
57 - sdrc = SDRC_ERROR;
58 - goto out;
59 - }
55 + if (rc || StructSize != 41)
56 + return (SDRC_ERROR);
60 57
61 - status = smb2sr_lookup_fid(sr, &smb2fid);
62 - if (status) {
63 - smb2sr_put_error(sr, status);
64 - goto out;
65 - }
66 -
67 - if (oBufLength > smb2_max_trans)
68 - oBufLength = smb2_max_trans;
69 -
70 58 /*
71 59 * If there's an input buffer, setup a shadow.
72 60 */
73 61 if (iBufLength) {
74 62 rc = MBC_SHADOW_CHAIN(&qi->in_data, &sr->smb_data,
75 63 sr->smb2_cmd_hdr + iBufOffset, iBufLength);
76 64 if (rc) {
77 - smb2sr_put_error(sr, NT_STATUS_INVALID_PARAMETER);
78 - goto out;
65 + return (SDRC_ERROR);
79 66 }
80 67 }
81 68
69 + if (oBufLength > smb2_max_trans)
70 + oBufLength = smb2_max_trans;
82 71 sr->raw_data.max_bytes = oBufLength;
83 72
73 + status = smb2sr_lookup_fid(sr, &smb2fid);
74 + DTRACE_SMB2_START(op__QueryInfo, smb_request_t *, sr);
75 +
76 + if (status)
77 + goto errout;
78 +
84 79 switch (qi->qi_InfoType) {
85 80 case SMB2_0_INFO_FILE:
86 81 status = smb2_qinfo_file(sr, qi);
87 82 break;
88 83 case SMB2_0_INFO_FILESYSTEM:
89 84 status = smb2_qinfo_fs(sr, qi);
90 85 break;
91 86 case SMB2_0_INFO_SECURITY:
92 87 status = smb2_qinfo_sec(sr, qi);
93 88 break;
94 89 case SMB2_0_INFO_QUOTA:
95 90 status = smb2_qinfo_quota(sr, qi);
96 91 break;
97 92 default:
98 93 status = NT_STATUS_INVALID_PARAMETER;
99 94 break;
100 95 }
101 96
97 +errout:
98 + sr->smb2_status = status;
99 + DTRACE_SMB2_DONE(op__QueryInfo, smb_request_t *, sr);
100 +
102 101 switch (status) {
103 102
104 103 case 0: /* success */
105 104 break;
106 105
107 106 case NT_STATUS_BUFFER_OVERFLOW:
108 107 /* Not really an error, per se. Advisory. */
109 - sr->smb2_status = status;
110 108 break;
111 109
112 110 case NT_STATUS_BUFFER_TOO_SMALL:
113 111 case NT_STATUS_INFO_LENGTH_MISMATCH:
114 112 /*
115 113 * These are special, per. [MS-SMB2] 3.2.5.17
116 114 * The error data is a 4-byte count of the size
117 115 * required to successfully query the data.
118 116 * That error data is built by the functions
119 117 * that returns one of these errors.
120 118 */
121 119 smb2sr_put_error_data(sr, status, &sr->raw_data);
122 - goto out;
120 + return (SDRC_SUCCESS);
123 121
124 122 default:
125 123 smb2sr_put_error(sr, status);
126 - goto out;
124 + return (SDRC_SUCCESS);
127 125 }
128 126
129 127 /*
130 128 * SMB2 Query Info reply
131 129 */
132 130 DataOff = SMB2_HDR_SIZE + 8;
133 131 oBufLength = MBC_LENGTH(&sr->raw_data);
134 132 rc = smb_mbc_encodef(
135 133 &sr->reply, "wwlC",
136 134 9, /* StructSize */ /* w */
137 135 DataOff, /* w */
138 136 oBufLength, /* l */
139 137 &sr->raw_data); /* C */
140 138 if (rc)
141 - sdrc = SDRC_ERROR;
139 + sr->smb2_status = NT_STATUS_INTERNAL_ERROR;
142 140
143 -out:
144 - kmem_free(qi, sizeof (*qi));
145 -
146 - return (sdrc);
141 + return (SDRC_SUCCESS);
147 142 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX