Commit cfaca65
ksmbd: validate inherited ACE SID length
commit 996454bc0da84d5a1dedb1a7861823087e01a7ae upstream.
smb_inherit_dacl() walks the parent directory DACL loaded from the
security descriptor xattr. It verifies that each ACE contains the fixed
SID header before using it, but does not verify that the variable-length
SID described by sid.num_subauth is fully contained in the ACE.
A malformed inheritable ACE can advertise more subauthorities than are
present in the ACE. compare_sids() may then read past the ACE.
smb_set_ace() also clamps the copied destination SID, but used the
unchecked source SID count to compute the inherited ACE size. That could
advance the temporary inherited ACE buffer pointer and nt_size accounting
past the allocated buffer.
Fix this by validating the parent ACE SID count and SID length before
using the SID during inheritance. Compute the inherited ACE size from the
copied SID so the size matches the bounded destination SID. Reject the
inherited DACL if size accumulation would overflow smb_acl.size or the
security descriptor allocation size.
Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Shota Zaizen <s@zaizen.me>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 1aa60fea7f637c071f529ad6784aecca2f2f0c5f)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>1 parent 2f223bd commit cfaca65
1 file changed
Lines changed: 52 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1068 | 1068 | | |
1069 | 1069 | | |
1070 | 1070 | | |
1071 | | - | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
1072 | 1091 | | |
1073 | 1092 | | |
1074 | 1093 | | |
| |||
1157 | 1176 | | |
1158 | 1177 | | |
1159 | 1178 | | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
1160 | 1185 | | |
1161 | 1186 | | |
1162 | 1187 | | |
| |||
1186 | 1211 | | |
1187 | 1212 | | |
1188 | 1213 | | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1194 | 1220 | | |
1195 | 1221 | | |
1196 | 1222 | | |
1197 | 1223 | | |
1198 | 1224 | | |
1199 | 1225 | | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
1205 | 1232 | | |
1206 | 1233 | | |
1207 | 1234 | | |
| |||
1211 | 1238 | | |
1212 | 1239 | | |
1213 | 1240 | | |
1214 | | - | |
| 1241 | + | |
1215 | 1242 | | |
1216 | 1243 | | |
1217 | 1244 | | |
| |||
1224 | 1251 | | |
1225 | 1252 | | |
1226 | 1253 | | |
1227 | | - | |
1228 | | - | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1229 | 1267 | | |
1230 | 1268 | | |
1231 | 1269 | | |
| |||
0 commit comments