DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vinicius Costa Gomes" <vinicius.gomes@intel.com>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCH 4/4] crypto: iaa - use bounce buffer for multi-sg decompress input
Date: Tue, 14 Jul 2026 04:21:36 +0000	[thread overview]
Message-ID: <20260714042137.4C6E01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713-iaa-crypto-fixes-zswap-v1-4-65cac23c684d@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Software fallback decompression writes directly to `req->dst` from the CPU while it is still mapped for DMA (`DMA_FROM_DEVICE`), causing silent data corruption if SWIOTLB (bounce buffers) is active.
--

--- Patch [4]: [PATCH 4/4] crypto: iaa - use bounce buffer for multi-sg decompress input ---
commit b4edd2dc0b34db120356af61156eef630f99393a
Author: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

crypto: iaa - use bounce buffer for multi-sg decompress input

This patch introduces a pre-allocated bounce page to linearize small 
multi-entry source scatterlists for the IAA hardware. This allows the 
driver to decompress these requests in hardware instead of falling back 
to software decompression.

> diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> index 8f68b1478476e..54bde11c454c9 100644
> --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
> +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c

[ ... ]

> @@ -1124,7 +1147,7 @@ static void iaa_desc_complete(struct idxd_desc *idxd_desc,
>  	}
>  err:
>  	dma_unmap_sg(dev, ctx->req->dst, sg_nents(ctx->req->dst), DMA_FROM_DEVICE);
> -	dma_unmap_sg(dev, ctx->req->src, sg_nents(ctx->req->src), DMA_TO_DEVICE);
> +	iaa_unmap_src(dev, ctx->req);

[Severity: Critical]
This is a pre-existing issue, but does the software fallback mechanism in
iaa_desc_complete() risk silent data corruption if SWIOTLB bounce buffers
are active?

When a decompression request fails in hardware (for example, with an
IAA_ANALYTICS_ERROR), the completion handler falls back to software by
calling deflate_generic_decompress(). This software fallback correctly 
writes the decompressed data into the req->dst scatterlist using the CPU.

However, req->dst is still actively mapped for DMA_FROM_DEVICE. When the
code progresses to this error path and calls dma_unmap_sg() with
DMA_FROM_DEVICE, will SWIOTLB physically copy the contents of the device
bounce buffer (which holds the failed hardware output) over the CPU buffer? 

If so, this would overwrite the successfully decompressed data, which could 
lead to memory corruption if used with subsystems like zswap. Does req->dst 
need to be unmapped prior to invoking deflate_generic_decompress()?

>  out:
>  	if (ret != 0)
>  		dev_dbg(dev, "asynchronous compress failed ret=%d\n", ret);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260713-iaa-crypto-fixes-zswap-v1-0-65cac23c684d@intel.com?part=4

  reply	other threads:[~2026-07-14  4:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  4:10 [PATCH 0/4] crypto: iaa - Fixes for multi entry SG lists Vinicius Costa Gomes
2026-07-14  4:10 ` [PATCH 1/4] dmaengine: idxd: assign all engines to group 0 in IAA defaults Vinicius Costa Gomes
2026-07-14  4:21   ` sashiko-bot
2026-07-14 21:53   ` Dave Jiang
2026-07-14 21:55     ` Dave Jiang
2026-07-15  1:38       ` Vinicius Costa Gomes
2026-07-14  4:10 ` [PATCH 2/4] crypto: iaa - fall back to software for multi-entry scatterlists Vinicius Costa Gomes
2026-07-14  4:36   ` sashiko-bot
2026-07-15  1:31     ` Vinicius Costa Gomes
2026-07-14 21:54   ` Dave Jiang
2026-07-14  4:10 ` [PATCH 3/4] crypto: iaa - avoid counting fallback decompression bytes Vinicius Costa Gomes
2026-07-14  4:21   ` sashiko-bot
2026-07-15  1:33     ` Vinicius Costa Gomes
2026-07-14 21:56   ` Dave Jiang
2026-07-14  4:10 ` [PATCH 4/4] crypto: iaa - use bounce buffer for multi-sg decompress input Vinicius Costa Gomes
2026-07-14  4:21   ` sashiko-bot [this message]
2026-07-14 22:01   ` Dave Jiang

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=20260714042137.4C6E01F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vinicius.gomes@intel.com \
    --cc=vkoul@kernel.org \
    /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