mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Abel Vesa <abelvesa@kernel.org>, Andy Gross <agross@kernel.org>,
	Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
Cc: Jeff Hugo <jeff.hugo@oss.qualcomm.com>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Abel Vesa <abel.vesa@oss.qualcomm.com>,
	Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH 0/2] soc: qcom: mdt_loader: Fix integer overflows in segment bounds checks
Date: Sun, 06 Dec 2026 00:26:06 +0200	[thread overview]
Message-ID: <20261206-mdt-loader-overflow-v1-0-9bf8e7781247@oss.qualcomm.com> (raw)

Sashiko reported that the segment bounds check in
qcom_mdt_load_no_init() can be bypassed on 32-bit platforms, where
offset + p_memsz is computed in 32 bits and can wrap around, letting a
crafted firmware image zero memory beyond the end of the memory region.
Patch 1 fixes that by doing the check in 64 bits, which also covers the
offset getting truncated with LPAE.

While looking at it, qcom_mdt_read_metadata() turned out to have similar
issues: it copies the ELF header using a size taken from the image
without checking it against the size of the firmware, which reads out
of bounds on any platform, and its other size computations can wrap on
32-bit. Patch 2 fixes these.

Prepared with help from an LLM-based assistant.

Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
---
Abel Vesa (2):
      soc: qcom: mdt_loader: Fix segment bounds check overflow on 32-bit
      soc: qcom: mdt_loader: Validate metadata sizes against the firmware

 drivers/soc/qcom/mdt_loader.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
---
base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
change-id: 20261205-mdt-loader-overflow-fa009fc16041

Best regards,
-- 

Abel


             reply	other threads:[~2026-12-05 22:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 22:26 Abel Vesa [this message]
2026-12-05 22:26 ` [PATCH 1/2] soc: qcom: mdt_loader: Fix segment bounds check overflow on 32-bit Abel Vesa
2026-12-05 22:26 ` [PATCH 2/2] soc: qcom: mdt_loader: Validate metadata sizes against the firmware Abel Vesa

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=20261206-mdt-loader-overflow-v1-0-9bf8e7781247@oss.qualcomm.com \
    --to=abel.vesa@oss.qualcomm.com \
    --cc=abelvesa@kernel.org \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=jeff.hugo@oss.qualcomm.com \
    --cc=jeffrey.l.hugo@gmail.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashiko-bot@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

all inboxes | Powered by JetHome®