Commit 014bcf4
USB: usb-storage: Prevent divide-by-0 error in isd200_ata_command
The isd200 sub-driver in usb-storage uses the HEADS and SECTORS values
in the ATA ID information to calculate cylinder and head values when
creating a CDB for READ or WRITE commands. The calculation involves
division and modulus operations, which will cause a crash if either of
these values is 0. While this never happens with a genuine device, it
could happen with a flawed or subversive emulation, as reported by the
syzbot fuzzer.
Protect against this possibility by refusing to bind to the device if
either the ATA_ID_HEADS or ATA_ID_SECTORS value in the device's ID
information is 0. This requires isd200_Initialization() to return a
negative error code when initialization fails; currently it always
returns 0 (even when there is an error).
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: syzbot+28748250ab47a8f04100@syzkaller.appspotmail.com
Link: https://lore.kernel.org/linux-usb/0000000000003eb868061245ba7f@google.com/
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reviewed-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/b1e605ea-333f-4ac0-9511-da04f411763e@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 3c4a311 commit 014bcf4
1 file changed
Lines changed: 18 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1105 | 1105 | | |
1106 | 1106 | | |
1107 | 1107 | | |
1108 | | - | |
| 1108 | + | |
1109 | 1109 | | |
1110 | 1110 | | |
1111 | 1111 | | |
| |||
1137 | 1137 | | |
1138 | 1138 | | |
1139 | 1139 | | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1140 | 1147 | | |
1141 | 1148 | | |
1142 | 1149 | | |
| |||
1202 | 1209 | | |
1203 | 1210 | | |
1204 | 1211 | | |
| 1212 | + | |
1205 | 1213 | | |
1206 | 1214 | | |
1207 | 1215 | | |
| |||
1481 | 1489 | | |
1482 | 1490 | | |
1483 | 1491 | | |
| 1492 | + | |
| 1493 | + | |
1484 | 1494 | | |
1485 | 1495 | | |
1486 | 1496 | | |
1487 | 1497 | | |
1488 | | - | |
| 1498 | + | |
1489 | 1499 | | |
| 1500 | + | |
1490 | 1501 | | |
1491 | 1502 | | |
1492 | 1503 | | |
1493 | | - | |
| 1504 | + | |
1494 | 1505 | | |
1495 | | - | |
| 1506 | + | |
| 1507 | + | |
1496 | 1508 | | |
| 1509 | + | |
1497 | 1510 | | |
1498 | 1511 | | |
1499 | | - | |
| 1512 | + | |
1500 | 1513 | | |
1501 | 1514 | | |
1502 | 1515 | | |
| |||
0 commit comments