diff options
| author | Chenxi Hou <ch395@njit.edu> | 2026-01-21 20:32:50 -0500 |
|---|---|---|
| committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2026-01-22 15:07:39 +0100 |
| commit | 2b14660c1caf0b67adf99428a225f71ed653437d (patch) | |
| tree | 2df54724fb023d52e9acb731b5369f688f94543b /tools/perf/lib/Documentation/tutorial/git@git.tavy.me:linux.git | |
| parent | 779c59274d03cc5c07237a2c845dfb71cff77705 (diff) | |
mtd: jedec_probe: fix shift-out-of-bounds UB in JEDEC ID masking
UBSAN reports shift-out-of-bounds in jedec_read_mfr() and jedec_read_id():
UBSAN: shift-out-of-bounds in drivers/mtd/chips/jedec_probe.c:1924:13
shift exponent 32 is too large for 32-bit type 'int'
UBSAN: shift-out-of-bounds in drivers/mtd/chips/jedec_probe.c:1940:12
shift exponent 32 is too large for 32-bit type 'int'
The JEDEC manufacturer/device ID masking uses:
(1 << (cfi->device_type * 8)) - 1
When cfi->device_type is 4, this evaluates to 1 << 32. Since the
literal '1' has type int, this is a 32-bit shift and is undefined behavior.
Fix it by using a 64-bit literal (1ULL) so the shift is performed in a 64-bit type.
Co-developed-by: Hui Peng <benquike@gmail.com>
Signed-off-by: Hui Peng <benquike@gmail.com>
Co-developed-by: Zhihao Yao (Zephyr) <zhihao.yao@njit.edu>
Signed-off-by: Zhihao Yao (Zephyr) <zhihao.yao@njit.edu>
Signed-off-by: Chenxi Hou <ch395@njit.edu>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'tools/perf/lib/Documentation/tutorial/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions
