[PATCH 0/3] phy: samsung-ufs: fix gs101 OOB read and use counted config tables
André Draszik
andre.draszik at linaro.org
Fri Nov 27 02:40:20 PST 2026
Hi,
Booting a gs101 platform with generic KASAN enabled triggers a
global-out-of-bounds read during UFS PHY calibration because
tensor_gs101_pre_pwr_hs_config[] omits the END_UFS_PHY_CFG sentinel.
This series starts with the minimal fix suitable for backporting to
stable kernels, followed by two hardening patches to prevent missing
sentinels and out-of-bounds config table accesses in the future:
- Fix the global-out-of-bounds read on gs101 by adding the missing
END_UFS_PHY_CFG terminator (tagged for stable).
- Embed the per-SoC config pointer arrays in struct
samsung_ufs_phy_drvdata with fixed bounds and move them to .rodata.
- Replace END_UFS_PHY_CFG sentinel iteration with ARRAY_SIZE()-counted
tables annotated with __counted_by_ptr().
On arm64 (non-debug build), the two refactor patches shrink
phy-exynos-ufs.o by 144 bytes overall (.text -160, .data -176,
.rodata +192).
Note that exynosautov9_ufs_phy.wait_for_cdr is never called (before or
after this series), because exynosautov9 defines neither a
CFG_POST_PWR_HS table nor hibern8 tables - this series preserves the
existing wait_for_cdr behaviour.
Tested on Pixel 6 (gs101) with generic KASAN and UBSAN_BOUNDS enabled,
including UFS hibern8 enter/exit cycles.
Cheers
Andre'
Signed-off-by: André Draszik <andre.draszik at linaro.org>
---
André Draszik (3):
phy: samsung: gs101-ufs: terminate pre_pwr_hs config
phy: samsung-ufs: embed cfgs arrays in drvdata
phy: samsung-ufs: use counted config tables
drivers/phy/samsung/phy-exynos7-ufs.c | 17 ++++------
drivers/phy/samsung/phy-exynosautov9-ufs.c | 14 +++-----
drivers/phy/samsung/phy-exynosautov920-ufs.c | 25 +++++++--------
drivers/phy/samsung/phy-fsd-ufs.c | 23 ++++++-------
drivers/phy/samsung/phy-gs101-ufs.c | 26 ++++++---------
drivers/phy/samsung/phy-samsung-ufs.c | 48 ++++++++++++++--------------
drivers/phy/samsung/phy-samsung-ufs.h | 26 ++++++++++++---
7 files changed, 87 insertions(+), 92 deletions(-)
---
base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5
change-id: 20261125-gs101-ufs-phy-oob-80303a651f4b
Best regards,
--
André Draszik <andre.draszik at linaro.org>
More information about the linux-arm-kernel
mailing list