forked fromtorvalds/linux
- Notifications
You must be signed in to change notification settings - Fork0
Commit2b40553
USB: gadget: f_ncm: Fix NDP16 datagram validation
commit2b74b0a ("USB: gadget: f_ncm: add bounds checks to ncm_unwrap_ntb()")adds important bounds checking however it unfortunately also introduces abug with respect to section 3.3.1 of the NCM specification.wDatagramIndex[1] : "Byte index, in little endian, of the second datagramdescribed by this NDP16. If zero, then this marks the end of the sequenceof datagrams in this NDP16."wDatagramLength[1]: "Byte length, in little endian, of the second datagramdescribed by this NDP16. If zero, then this marks the end of the sequenceof datagrams in this NDP16."wDatagramIndex[1] and wDatagramLength[1] respectively then may be zero butthat does not mean we should throw away the data referenced bywDatagramIndex[0] and wDatagramLength[0] as is currently the case.Breaking the loop on (index2 == 0 || dg_len2 == 0) should come at the endas was previously the case and checks for index2 and dg_len2 should beremoved since zero is valid.I'm not sure how much testing the above patch received but for me right nowafter enumeration ping doesn't work. Reverting the commit restores ping,scp, etc.The extra validation associated with wDatagramIndex[0] andwDatagramLength[0] appears to be valid so, this change removes the incorrectrestriction on wDatagramIndex[1] and wDatagramLength[1] restoring dataprocessing between host and device.Fixes:2b74b0a ("USB: gadget: f_ncm: add bounds checks to ncm_unwrap_ntb()")Cc: Ilja Van Sprundel <ivansprundel@ioactive.com>Cc: Brooke Basile <brookebasile@gmail.com>Cc: stable <stable@kernel.org>Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>Link:https://lore.kernel.org/r/20200920170158.1217068-1-bryan.odonoghue@linaro.orgSigned-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parenta311283 commit2b40553
1 file changed
+2
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1189 | 1189 | | |
1190 | 1190 | | |
1191 | 1191 | | |
1192 | | - | |
1193 | 1192 | | |
1194 | 1193 | | |
1195 | 1194 | | |
| |||
1216 | 1215 | | |
1217 | 1216 | | |
1218 | 1217 | | |
1219 | | - | |
1220 | 1218 | | |
1221 | 1219 | | |
1222 | 1220 | | |
| |||
1232 | 1230 | | |
1233 | 1231 | | |
1234 | 1232 | | |
1235 | | - | |
1236 | | - | |
1237 | 1233 | | |
1238 | 1234 | | |
1239 | 1235 | | |
| |||
1312 | 1308 | | |
1313 | 1309 | | |
1314 | 1310 | | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | 1311 | | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
1330 | | - | |
1331 | | - | |
1332 | 1312 | | |
1333 | 1313 | | |
1334 | 1314 | | |
1335 | 1315 | | |
1336 | 1316 | | |
1337 | 1317 | | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
1343 | | - | |
1344 | | - | |
1345 | | - | |
1346 | 1318 | | |
1347 | 1319 | | |
1348 | 1320 | | |
| |||
1359 | 1331 | | |
1360 | 1332 | | |
1361 | 1333 | | |
| 1334 | + | |
| 1335 | + | |
1362 | 1336 | | |
1363 | 1337 | | |
1364 | 1338 | | |
| |||
0 commit comments
Comments
(0)