[PATCH v2] platform/x86: ibm_rtl: Fix potential OOB read at signature search

From: Takashi Iwai

Date: Wed Oct 21 2026 - 02:47:02 EST


The loop for signature search fetches 22 bytes of struct ibm_rtl_table
at each check, while the loop count is calculated in 4 bytes unit,
which means that, at the last entry, it fetches over the limit.

Rewrite the loop to use the byte offset and correct the boundary
condition check for avoiding the potential OOB access.

Fixes: 15dd100349b8 ("platform/x86: ibm_rtl: fix EBDA signature search pointer arithmetic")
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
v1->v2: Replace loop counter with offset and correct boundary check

drivers/platform/x86/ibm_rtl.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
index 139956168cf9..82fda8d9178b 100644
--- a/drivers/platform/x86/ibm_rtl.c
+++ b/drivers/platform/x86/ibm_rtl.c
@@ -234,9 +234,9 @@ static const struct dmi_system_id ibm_rtl_dmi_table[] __initconst = {
};

static int __init ibm_rtl_init(void) {
- unsigned long ebda_addr, ebda_size;
+ unsigned long ebda_addr, ebda_size, offset;
unsigned int ebda_kb;
- int ret = -ENODEV, i;
+ int ret = -ENODEV;

if (force)
pr_warn("module loaded by force\n");
@@ -271,9 +271,9 @@ static int __init ibm_rtl_init(void) {
return -ENOMEM;

/* search for the _RTL_ signature at the start of the table */
- for (i = 0 ; i < ebda_size/sizeof(unsigned int); i++) {
+ for (offset = 0; offset + sizeof(*rtl_table) <= ebda_size; offset += 4) {
struct ibm_rtl_table __iomem * tmp;
- tmp = (struct ibm_rtl_table __iomem *) (ebda_map + i*sizeof(unsigned int));
+ tmp = (struct ibm_rtl_table __iomem *) (ebda_map + offset);
if ((readq(&tmp->signature) & RTL_MASK) == RTL_SIGNATURE) {
phys_addr_t addr;
unsigned int plen;
--
2.55.0