From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: arcmsr: Fix potential DMA leaks on XOR allocation failure
Date: Tue, 17 Nov 2026 15:17:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-219043@kernel.org> (raw)
In-Reply-To: <20261117-571e631490-scsi-arcmsr-0@mail.sdu.edu.cn>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] scsi: arcmsr: hardware-controlled pointer dereference in
arcmsr_ccb_complete() [1]
--
commit 5ed92826e96263be26f2281fb2284bdbe1e52cb8
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
scsi: arcmsr: Fix potential DMA leaks on XOR allocation failure
This commit checks for DMA allocation failure in arcmsr_alloc_xor_buffer()
and frees the CCB pool in arcmsr_alloc_ccb_pool() if XOR buffer allocation
fails.
> diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
> index 8aa948f06cacf..52caa800397e3 100644
> --- a/drivers/scsi/arcmsr/arcmsr_hba.c
> +++ b/drivers/scsi/arcmsr/arcmsr_hba.c
[ ... ]
> @@ -895,8 +899,10 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb)
> break;
> }
> if ((acb->firm_PicStatus >> 24) & 0x0f) {
> - if (arcmsr_alloc_xor_buffer(acb))
> + if (arcmsr_alloc_xor_buffer(acb)) {
> + arcmsr_free_ccb_pool(acb);
> return -ENOMEM;
> + }
> }
> return 0;
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but can a compromised or
malicious PCI device overwrite the kernel pointers embedded in struct
CommandControlBlock [1]?
arcmsr_alloc_ccb_pool() allocates the CommandControlBlock array in
DMA-coherent memory via dma_alloc_coherent(), and those structures hold
host pointers including ccb->acb, ccb->pcmd, and ccb->list:
drivers/scsi/arcmsr/arcmsr_hba.c:arcmsr_alloc_ccb_pool() {
...
dma_coherent = dma_alloc_coherent(&pdev->dev, acb->uncache_size, &dma_coherent_handle, GFP_KERNEL);
...
ccb_tmp = dma_coherent;
...
for(i = 0; i < acb->maxFreeCCB; i++){
...
ccb_tmp->acb = acb;
...
INIT_LIST_HEAD(&ccb_tmp->list);
...
}
On I/O completion, arcmsr_ccb_complete() trusts those device-accessible
fields and passes them to atomic_dec(), scsi_dma_unmap(),
spin_lock_irqsave(), list_add_tail(), and scsi_done():
drivers/scsi/arcmsr/arcmsr_hba.c:arcmsr_ccb_complete() {
struct AdapterControlBlock *acb = ccb->acb;
struct scsi_cmnd *pcmd = ccb->pcmd;
unsigned long flags;
atomic_dec(&acb->ccboutstandingcount);
scsi_dma_unmap(ccb->pcmd);
ccb->startdone = ARCMSR_CCB_DONE;
spin_lock_irqsave(&acb->ccblist_lock, flags);
list_add_tail(&ccb->list, &acb->ccb_free_list);
spin_unlock_irqrestore(&acb->ccblist_lock, flags);
scsi_done(pcmd);
}
Overwriting these pointers via DMA allows arbitrary kernel memory writes
and control-flow hijacking. Host-only metadata should be kept in regular
kernel memory rather than inside the DMA-coherent CCB buffer.
[1] https://sashiko.dev/#/bug/linux-a10df3d7-0d0e-4b31-a2dd-416f0ee6e806
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-571e631490-scsi-arcmsr-0@mail.sdu.edu.cn?part=1
prev parent reply other threads:[~2026-11-17 15:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 14:51 [PATCH] scsi: arcmsr: Fix potential DMA leaks on XOR allocation failure Guangshuo Li
2026-11-17 15:17 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-219043@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=liguangshuo@mail.sdu.edu.cn \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox