Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Łukasz Lebiedziński" <kernel@lvkasz.us>
To: selvarasu.g@samsung.com
Cc: akash.m5@samsung.com, alim.akhtar@samsung.com,
	andre.draszik@linaro.org, dh10.jung@samsung.com,
	jh0801.jung@samsung.com, kernel@lvkasz.us, krzk@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, muhammed.ali@samsung.com,
	neil.armstrong@linaro.org, peter.griffin@linaro.org,
	pritam.sutar@samsung.com, thiagu.r@samsung.com, vkoul@kernel.org
Subject: Re: [PATCH] phy: exynos5-usbdrd: Use dynamic phy_cfg size to prevent OOB access
Date: Wed,  2 Sep 2026 02:04:37 +0200	[thread overview]
Message-ID: <20260902000439.25379-1-kernel@lvkasz.us> (raw)
In-Reply-To: <20260831070309.158069-1-selvarasu.g@samsung.com>

I tested this on my Samsung Galaxy A6 (Exynos7870) with this patch applied
on top of mainline. I wanted to verify the OOB read first before trusting
this fix, so I forced the device tree to request PHY index 1
(phys = <&usbdrd_phy 1>;) - this index does not exist for this SoC,
because the phy_cfg_exynos7870[] array contains only one entry. I added
a temporary pr_info() call after assigning phy_cfg in the probe loop to
display the phy_isol/phy_init values using %pS:

  i=0 phy_isol=exynos7870_usbdrd_phy_isol+0x0/0x60
      phy_init=exynos7870_usbdrd_utmi_init+0x0/0x260
  i=1 phy_isol=exynos5_usbdrd_phy_isol+0x0/0x50
      phy_init=exynos5_usbdrd_utmi_init+0x0/0xc8

For i=1, both function pointers resolve to the exynos5_* variants
instead of the exynos7870 ones - the OOB read lands right on
the adjacent phy_cfg_exynos5[] array in .rodata. No crash occurs, since
these garbage pointers happen to point to valid (though unrelated)
kernel functions rather than something invalid.

With the patch applied, the same debug print shows the loop correctly
stopping at n_phy_cfg=1; i=1 is never reached. Boot and USB both work
fine on the actual PHY index (0).

Tested-by: Łukasz Lebiedziński <kernel@lvkasz.us>

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-09-02  0:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260831070349epcas5p4c62a4e46592dffe95723ddd51a6068e0@epcas5p4.samsung.com>
2026-08-31  7:03 ` [PATCH] phy: exynos5-usbdrd: Use dynamic phy_cfg size to prevent OOB access Selvarasu Ganesan
2026-09-02  0:04   ` Łukasz Lebiedziński [this message]
2026-09-03  3:43     ` Selvarasu Ganesan

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=20260902000439.25379-1-kernel@lvkasz.us \
    --to=kernel@lvkasz.us \
    --cc=akash.m5@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=andre.draszik@linaro.org \
    --cc=dh10.jung@samsung.com \
    --cc=jh0801.jung@samsung.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=muhammed.ali@samsung.com \
    --cc=neil.armstrong@linaro.org \
    --cc=peter.griffin@linaro.org \
    --cc=pritam.sutar@samsung.com \
    --cc=selvarasu.g@samsung.com \
    --cc=thiagu.r@samsung.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