From: sashiko-bot@kernel.org
To: "Georgi Djakov" <georgi.djakov@oss.qualcomm.com>
Cc: linux-trace-kernel@vger.kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 4/6] zram: Add QPaCE zcomp backend
Date: Wed, 30 Sep 2026 15:08:30 +0000 [thread overview]
Message-ID: <20260930150830.9CE281F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930145215.3380977-5-georgi.djakov@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] block: zram: signed/unsigned promotion masks hardware errors in qpace_compress
- [High] block: zram: missing qpace availability check causes NULL pointer dereference
- [High] block: zram: unbinding qpace driver causes Use-After-Free in backend
- [Medium] block: zram: qpace backend uses bounce buffers instead of claimed zero-copy DMA mapping
--
commit e4fba83b2c0230490d177ce709e7ea22807d84d4
Author: Georgi Djakov <georgi.djakov@oss.qualcomm.com>
zram: Add QPaCE zcomp backend
Add a zcomp backend for the Qualcomm Page Compression Engine (QPaCE) so
zram can expose qpace-lz4 as a selectable compression algorithm when the
QPaCE driver is available.
> Compress and decompress operations are handled via the QPaCE urgent
> synchronous path: each request DMA-maps the source and destination
> buffers, issues a blocking hardware command, and returns the result size.
[Severity: Medium]
Does the implementation contradict the commit message's claim about DMA
mapping the request buffers? The code allocates static bounce buffers and
performs synchronous memory copies instead of mapping the actual request
memory directly.
> diff --git a/drivers/block/zram/backend_qpace.c b/drivers/block/zram/backend_qpace.c
> new file mode 100644
> index 0000000000000..3af13727adefc
> --- /dev/null
> +++ b/drivers/block/zram/backend_qpace.c
[ ... ]
> +static int qpace_create_ctx(struct zcomp_params *params, struct zcomp_ctx *ctx)
> +{
> + struct device *dev = qpace_get_dma_dev();
[Severity: High]
Is it safe to unconditionally call qpace_get_dma_dev() here without
verifying if the hardware actually probed via qpace_is_dev_available()?
If the QPaCE driver hasn't probed successfully or is missing, the global
qpace_priv pointer remains NULL, and qpace_get_dma_dev() dereferences it:
drivers/soc/qcom/qpace.c:qpace_get_dma_dev() {
return qpace_priv->dev;
}
Could this cause a kernel panic if a user writes 'qpace-lz4' to
/sys/block/zram0/comp_algorithm on an unsupported system?
[Severity: High]
Additionally, does this cache the device pointer without acquiring a robust
reference via get_device() or taking a module reference?
If the QPaCE driver is unbound via sysfs, qpace_priv is destroyed.
Subsequent compress operations or teardown might access the freed device
pointer or qpace_priv structure, leading to a use-after-free.
> + struct qpace_ctx *cc;
> +
> + if (!dev)
> + return -ENODEV;
> +
> + cc = kzalloc_obj(*cc, GFP_KERNEL);
> + if (!cc)
> + return -ENOMEM;
> +
> + cc->dev = dev;
> + cc->in_buf = dma_alloc_coherent(dev, PAGE_SIZE, &cc->in_dma, GFP_KERNEL);
[Severity: Medium]
This statically allocates a bounce buffer rather than preparing to map the
dynamic request buffers. Does this introduce CPU overhead by breaking the
zero-copy DMA design claimed in the commit message?
[ ... ]
> +static void qpace_destroy_ctx(struct zcomp_ctx *ctx)
> +{
> + struct qpace_ctx *cc = ctx->context;
> +
> + if (!cc)
> + return;
> +
> + dma_free_coherent(cc->dev, PAGE_SIZE, cc->out_buf, cc->out_dma);
[Severity: High]
If the device was unbound and qpace_priv was freed, could accessing cc->dev
here trigger a use-after-free during cleanup?
[ ... ]
> +static int qpace_compress(struct zcomp_params *params, struct zcomp_ctx *ctx,
> + struct zcomp_req *req)
> +{
> + struct qpace_algorithm *algo = params->drv_data;
> + struct qpace_ctx *cc = ctx->context;
> + int ret;
> +
> + memcpy(cc->in_buf, req->src, req->src_len);
[Severity: Medium]
Does copying data to the bounce buffer here confirm the data path is not
zero-copy?
> +
> + ret = qpace_urgent_compress(cc->in_dma, cc->out_dma, algo);
> +
> + if (ret == -E2BIG || ret >= PAGE_SIZE) {
[Severity: High]
Are hardware errors from the QPaCE compressor masked here?
If qpace_urgent_compress() returns a negative error code (e.g., -EINVAL),
comparing the signed integer 'ret' to PAGE_SIZE (typically unsigned long)
promotes 'ret' to a large unsigned value.
Would this cause the check to incorrectly pass, silently treating broken or
failed compressions as incompressible data instead of propagating the failure?
> + req->dst_len = PAGE_SIZE;
> + return 0;
> + }
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930145215.3380977-1-georgi.djakov@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-09-30 15:08 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 14:52 [PATCH 0/6] soc: qcom: Add Qualcomm Page Compression Engine (QPaCE) driver Georgi Djakov
2026-09-30 14:52 ` [PATCH 1/6] dt-bindings: soc: qcom: Add QPaCE binding Georgi Djakov
2026-10-02 6:10 ` Krzysztof Kozlowski
2026-09-30 14:52 ` [PATCH 2/6] soc: qcom: qpace: Add Qualcomm Page Compression Engine driver Georgi Djakov
2026-09-30 15:04 ` sashiko-bot
2026-10-03 0:06 ` Oreoluwa Babatunde
2026-10-01 8:50 ` Krzysztof Kozlowski
2026-10-06 23:51 ` Oreoluwa Babatunde
2026-10-07 7:51 ` Krzysztof Kozlowski
2026-10-08 0:08 ` Oreoluwa Babatunde
2026-09-30 14:52 ` [PATCH 3/6] trace: qpace: Add tracepoints for QPaCE operations Georgi Djakov
2026-09-30 15:00 ` sashiko-bot
2026-09-30 14:52 ` [PATCH 4/6] zram: Add QPaCE zcomp backend Georgi Djakov
2026-09-30 15:08 ` sashiko-bot [this message]
2026-10-01 5:43 ` Sergey Senozhatsky
2026-10-06 23:53 ` Oreoluwa Babatunde
2026-10-08 3:52 ` Sergey Senozhatsky
2026-10-01 8:51 ` Krzysztof Kozlowski
2026-10-01 10:27 ` Sergey Senozhatsky
2026-10-07 0:04 ` Oreoluwa Babatunde
2026-10-07 0:03 ` Oreoluwa Babatunde
2026-09-30 14:52 ` [PATCH 5/6] soc: qcom: qpace: Add LLCC slice support Georgi Djakov
2026-09-30 15:08 ` sashiko-bot
2026-09-30 14:52 ` [PATCH 6/6] arm64: dts: qcom: hawi: Add QPaCE DT node Georgi Djakov
2026-09-30 14:59 ` sashiko-bot
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=20260930150830.9CE281F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=georgi.djakov@oss.qualcomm.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.