Kai-Heng Feng
67a00c299c
ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS
...
commit 1e41e693f458eef2d5728207dbd327cd3b16580a upstream.
UBSAN complains about array-index-out-of-bounds:
[ 1.980703] kernel: UBSAN: array-index-out-of-bounds in /build/linux-9H675w/linux-5.15.0/drivers/ata/libahci.c:968:41
[ 1.980709] kernel: index 15 is out of range for type 'ahci_em_priv [8]'
[ 1.980713] kernel: CPU: 0 PID: 209 Comm: scsi_eh_8 Not tainted 5.15.0-25-generic #25-Ubuntu
[ 1.980716] kernel: Hardware name: System manufacturer System Product Name/P5Q3, BIOS 1102 06/11/2010
[ 1.980718] kernel: Call Trace:
[ 1.980721] kernel: <TASK>
[ 1.980723] kernel: show_stack+0x52/0x58
[ 1.980729] kernel: dump_stack_lvl+0x4a/0x5f
[ 1.980734] kernel: dump_stack+0x10/0x12
[ 1.980736] kernel: ubsan_epilogue+0x9/0x45
[ 1.980739] kernel: __ubsan_handle_out_of_bounds.cold+0x44/0x49
[ 1.980742] kernel: ahci_qc_issue+0x166/0x170 [libahci]
[ 1.980748] kernel: ata_qc_issue+0x135/0x240
[ 1.980752] kernel: ata_exec_internal_sg+0x2c4/0x580
[ 1.980754] kernel: ? vprintk_default+0x1d/0x20
[ 1.980759] kernel: ata_exec_internal+0x67/0xa0
[ 1.980762] kernel: sata_pmp_read+0x8d/0xc0
[ 1.980765] kernel: sata_pmp_read_gscr+0x3c/0x90
[ 1.980768] kernel: sata_pmp_attach+0x8b/0x310
[ 1.980771] kernel: ata_eh_revalidate_and_attach+0x28c/0x4b0
[ 1.980775] kernel: ata_eh_recover+0x6b6/0xb30
[ 1.980778] kernel: ? ahci_do_hardreset+0x180/0x180 [libahci]
[ 1.980783] kernel: ? ahci_stop_engine+0xb0/0xb0 [libahci]
[ 1.980787] kernel: ? ahci_do_softreset+0x290/0x290 [libahci]
[ 1.980792] kernel: ? trace_event_raw_event_ata_eh_link_autopsy_qc+0xe0/0xe0
[ 1.980795] kernel: sata_pmp_eh_recover.isra.0+0x214/0x560
[ 1.980799] kernel: sata_pmp_error_handler+0x23/0x40
[ 1.980802] kernel: ahci_error_handler+0x43/0x80 [libahci]
[ 1.980806] kernel: ata_scsi_port_error_handler+0x2b1/0x600
[ 1.980810] kernel: ata_scsi_error+0x9c/0xd0
[ 1.980813] kernel: scsi_error_handler+0xa1/0x180
[ 1.980817] kernel: ? scsi_unjam_host+0x1c0/0x1c0
[ 1.980820] kernel: kthread+0x12a/0x150
[ 1.980823] kernel: ? set_kthread_struct+0x50/0x50
[ 1.980826] kernel: ret_from_fork+0x22/0x30
[ 1.980831] kernel: </TASK>
This happens because sata_pmp_init_links() initialize link->pmp up to
SATA_PMP_MAX_PORTS while em_priv is declared as 8 elements array.
I can't find the maximum Enclosure Management ports specified in AHCI
spec v1.3.1, but "12.2.1 LED message type" states that "Port Multiplier
Information" can utilize 4 bits, which implies it can support up to 16
ports. Hence, use SATA_PMP_MAX_PORTS as EM_MAX_SLOTS to resolve the
issue.
BugLink: https://bugs.launchpad.net/bugs/1970074
Cc: stable@vger.kernel.org
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-03 23:52:24 +09:00
..
2020-10-01 13:14:54 +02:00
2021-03-04 09:39:40 +01:00
2018-08-22 08:08:27 -07:00
2018-08-22 08:08:27 -07:00
2018-08-22 08:08:27 -07:00
2022-11-03 23:52:24 +09:00
2018-08-22 08:08:27 -07:00
2019-12-05 09:21:06 +01:00
2017-03-06 15:40:59 -05:00
2019-11-20 18:46:06 +01:00
2018-08-22 08:08:27 -07:00
2018-08-22 08:08:27 -07:00
2018-08-22 08:08:27 -07:00
2021-07-20 16:16:04 +02:00
2018-08-22 08:08:27 -07:00
2018-08-22 08:08:27 -07:00
2021-12-08 08:50:12 +01:00
2022-11-03 23:52:24 +09:00
2018-01-08 06:15:41 -08:00
2019-11-24 08:19:33 +01:00
2022-10-26 13:19:40 +02:00
2020-10-01 13:14:54 +02:00
2022-10-05 10:36:44 +02:00
2022-08-25 11:15:34 +02:00
2020-04-17 10:48:52 +02:00
2021-12-22 09:19:03 +01:00
2021-08-12 13:19:44 +02:00
2016-05-09 12:36:46 -04:00
2022-06-14 16:59:39 +02:00
2017-11-02 11:10:55 +01:00
2019-08-25 10:47:54 +02:00
2018-06-19 22:02:25 -04:00
2018-04-03 17:42:25 -07:00
2018-01-11 17:23:23 -06:00
2017-08-11 10:35:07 -07:00
2021-05-22 10:59:33 +02:00
2017-09-18 20:24:21 -07:00
2018-01-08 04:02:02 -08:00
2017-10-23 07:06:09 -07:00
2018-03-01 13:59:03 -08:00
2018-07-11 10:45:28 -07:00
2017-08-11 10:35:07 -07:00
2021-07-20 16:15:47 +02:00
2018-03-01 13:58:17 -08:00
2018-08-27 14:25:54 -06:00
2018-03-19 07:41:36 -07:00
2022-03-08 19:04:07 +01:00
2016-07-12 11:02:05 -04:00
2018-07-11 10:45:28 -07:00
2018-08-24 13:20:33 -07:00
2018-02-18 05:26:07 -08:00
2021-05-22 10:59:33 +02:00
2015-08-24 15:27:11 -05:00
2021-10-20 11:23:04 +02:00
2020-10-01 13:14:54 +02:00
2022-04-27 13:39:44 +02:00
2018-02-18 05:23:25 -08:00
2016-08-30 11:59:47 -04:00
2022-06-14 16:59:35 +02:00
2017-03-06 15:18:01 -05:00
2018-07-11 10:45:28 -07:00
2018-07-11 10:45:28 -07:00
2018-01-25 07:28:31 -08:00
2018-07-11 10:45:28 -07:00
2020-10-01 13:14:54 +02:00
2021-07-20 16:15:47 +02:00
2017-06-12 14:06:34 -04:00
2018-07-07 17:52:26 +02:00
2017-06-12 14:06:34 -04:00
2018-07-11 10:45:28 -07:00
2020-10-01 13:14:54 +02:00
2022-04-15 14:15:06 +02:00
2021-12-08 08:50:12 +01:00
2017-08-11 10:32:09 -07:00
2017-11-02 11:10:55 +01:00
2021-07-20 16:15:47 +02:00
2020-10-01 13:14:54 +02:00
2021-11-02 18:26:44 +01:00
2020-11-05 11:08:38 +01:00
2020-10-01 13:14:54 +02:00
2017-05-16 11:25:59 -04:00
2020-10-01 13:14:54 +02:00
2020-11-05 11:08:35 +01:00
2020-10-01 13:14:54 +02:00
2020-10-01 13:14:54 +02:00
2017-05-16 11:25:59 -04:00
2017-07-18 18:02:36 -04:00
2020-10-01 13:14:54 +02:00
2017-05-16 11:25:59 -04:00
2017-06-26 16:54:53 -04:00
2017-05-16 11:25:59 -04:00
2017-11-02 11:10:55 +01:00