Skip to contentSkip to conversation

SCSI_EH: How does EH guarantee there is no UAF of scsi_cmnd if host reset failed

Question Wenchao Hao 2 participants 3 messages Apr 19, 2022 – Apr 21, 2022 SCSI

lore
Share & tools
lore
#0 lore raw

Hi all, I am wondered how does SCSI EH guarantee there is no UAF of scsi_cmnd if host reset failed. If host reset failed and eh_cmd_q of shost is not empty, these command in eh_cmd_q would be added to done_q in scsi_eh_offline_sdevs() and finished by scsi_eh_flush_done_q(). So these scsi_cmnd and it's related request would be freed.

While since host reset failed, we can not guarantee the LLDDs has cleared all references to these commands in eh_cmd_q. Is there any possibility that the LLDDs reference to these commands? If this happened, then a using after free issue would occur.

Waiting for your response.

#1 lore raw
Quoted 6 lines · Wenchao Hao

Hi all, I am wondered how does SCSI EH guarantee there is no UAF of scsi_cmnd if host reset failed. If host reset failed and eh_cmd_q of shost is not empty, these command in eh_cmd_q would be added to done_q in scsi_eh_offline_sdevs() and finished by scsi_eh_flush_done_q(). So these scsi_cmnd and it's related request would be freed.

Yes.

Quoted 5 lines

While since host reset failed, we can not guarantee the LLDDs has cleared all references to these commands in eh_cmd_q. Is there any possibility that the LLDDs reference to these commands? If this happened, then a using after free issue would occur.

If host reset has failed there are _no_ assumptions we can make about commands, and not even about the PCI device itself. So in effect, once host_reset failed the system is hosed.

We _might_ be able to resurrect the system by doing PCI EEH, but not many systems nor drivers implement that.

Cheers,

Hannes

#2 lore raw
Quoted 17 lines · Hannes Reinecke
Quoted 6 lines · Wenchao Hao

Hi all, I am wondered how does SCSI EH guarantee there is no UAF of scsi_cmnd if host reset failed. If host reset failed and eh_cmd_q of shost is not empty, these command in eh_cmd_q would be added to done_q in scsi_eh_offline_sdevs() and finished by scsi_eh_flush_done_q(). So these scsi_cmnd and it's related request would be freed.

Yes.

Quoted 5 lines

While since host reset failed, we can not guarantee the LLDDs has cleared all references to these commands in eh_cmd_q. Is there any possibility that the LLDDs reference to these commands? If this happened, then a using after free issue would occur.

If host reset has failed there are _no_ assumptions we can make about commands, and not even about the PCI device itself. So in effect, once host_reset failed the system is hosed.

Quoted 7 lines

We _might_ be able to resurrect the system by doing PCI EEH, but not many systems nor drivers implement that.

Cheers,

Hannes

.

Thanks a lot for your reply. I am writing single LUN reset EH flow which discussed in previous mail and testing it, if the test result is good I would post it.

By the way, you said you would make EH rework, are you doing it? Could you tell us your plan if it's not secret.