From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795052809; b=133B8F2btWfNtbsVp2HFFoaRehv5BpJORq+X7+pcRSg32Z5R+vKgJ31Y75b5MqtGXKaH 4vAIw/2ZFimYGJdIz3zccCZmsB1168b4Fo/dS9pbh0aoUb1vkqI18eG5ozXUzAku5t9We dmgXeYBEz/+bG+LKHZ3oXAaOVXfFLJpg+SV9T0XMiNzyUCuOAuBYhE8SmrmsHHKD2tr6K UGq/oSoIkDV/hb8/uZAHb+DcTzlcSeMD6Bo+djFcjvJ24fZ1UFWvg+e/ulXp5ukod1++K JYvKJJK7ZlW0Dz73uhFpu8qtMS3UifJK2twuNpB98igBZaFXV2+yvlRs2zmQYfB14ZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795052809; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=VrVJ1K3r10kr1iosdng7zx9eVDXcBTgKxL44hH60mVY=; b=lUqStgHzdfZX9yx6W6huQqrxaKtNqG7Cm5YbTTo9vKBqankyZVg4dBuYQU/B3wD7WdQ1 nd5SvkMT/lKmayF5jLvF7WQ6Os3waLOOa7HvZe3JNVCdJX1UWu3I8/zFGsJiAZSKUFOyE APIxIiHrXvUEhaE6pQwkQ+i2HN5S+fsEqeUuNY2CbZWAHG16S/RRJxAkT4OCzEF2xGxIz QBNPL92D7H4DqHi2bzwXvxPrVIlxvrp/a630o1xq6ONDIYdP2Y7mjfNJ9Yip+5sPlTB59 9zuF0l6HMMiJP7xF1Ze0J0zS4o9eohXCL3+b5W6gPdHpx9nH0WdEQ5Hhn1kot6GcyjQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IuRW4a6Q; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE189606A31C; Thu, 19 Nov 2026 01:46:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IuRW4a6Q Received: by smtp.kernel.org (Postfix) with ESMTPSA id 464BA1F000C4; Thu, 19 Nov 2026 01:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795052808; bh=VrVJ1K3r10kr1iosdng7zx9eVDXcBTgKxL44hH60mVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IuRW4a6QQsPZ7kBtjeQI05zRJRw5ppaZBYj00e4vYNWQDZGiv0TUThYxc/Cw4z8Q7 lCpetvCEIGBx2vvVdnXFFsHk1DIF6o+nOXDaKViVMh6/rnQZLGO6qixO9h6fu4Xzr7 yXd+JoF4STEWIF6F/NvkJgcfUcCAQk0yLfWbw+lI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jean Delu , Helge Deller , Sasha Levin Subject: [PATCH 5.15 0697/2214] parisc: eisa_enumerator: Fix out-of-bounds reads of the EEPROM buffer Date: Wed, 18 Nov 2026 15:39:33 +0100 Message-ID: <20261118150039.703105940@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jean Delu [ Upstream commit c0a3e153804f0c14f4159ddbd2b73483c9cb3577 ] eisa_enumerator() trusts the contents of the EISA EEPROM.  The number of slots is read from the EEPROM header and used to access the slot records at HPEE_SLOT_INFO(i) = 20 + 48*i within the fixed-size eeprom_buf (HPEE_MAX_LENGTH, 8192 bytes) without any bound check.  As struct eeprom_eisa_slot_info is 48 bytes, only 170 records fit into the buffer, but num_slots is a u8 and may be up to 255, so a corrupted EEPROM makes the code read up to about 4 kB past the end of the buffer (e.g. record 254 is accessed at offset 20 + 48*254 = 12212). parse_slot_config() has the same kind of problem: it clamps config_data_length against HPEE_MAX_LENGTH but does not take config_data_offset into account, so the parser can walk past the end of the buffer even when the offset itself is valid. Clamp the number of slots so that all slot records fit into the buffer, and hand the number of bytes actually available to parse_slot_config() and bound the parse by it. Signed-off-by: Jean Delu Cc: stable@vger.kernel.org Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/parisc/eisa_enumerator.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/parisc/eisa_enumerator.c b/drivers/parisc/eisa_enumerator.c index f54a6f4503915..c77fadc1bacaf 100644 --- a/drivers/parisc/eisa_enumerator.c +++ b/drivers/parisc/eisa_enumerator.c @@ -311,6 +311,7 @@ static int configure_function(const unsigned char *buf, int *more) static int parse_slot_config(int slot, const unsigned char *buf, + unsigned int buflen, struct eeprom_eisa_slot_info *es, struct resource *io_parent, struct resource *mem_parent) @@ -333,8 +334,8 @@ static int parse_slot_config(int slot, printk(KERN_INFO "EISA slot %d: %s %s ", slot, board, es->flags&HPEE_FLAG_BOARD_IS_ISA ? "ISA" : "EISA"); - maxlen = es->config_data_length < HPEE_MAX_LENGTH ? - es->config_data_length : HPEE_MAX_LENGTH; + /* never parse beyond the data that is actually in the buffer */ + maxlen = min_t(unsigned int, es->config_data_length, buflen); while ((pos < maxlen) && (num_func <= es->num_functions)) { pos+=configure_function(buf+pos, &function_len); @@ -491,6 +492,13 @@ int eisa_enumerator(unsigned long eeprom_addr, printk(KERN_INFO "Enumerating EISA bus\n"); eh = (struct eeprom_header*)(eeprom_buf); + /* + * The EEPROM contents are not to be trusted: clamp the number of + * slots so that all slot records fit into eeprom_buf. + */ + eh->num_slots = min_t(u8, eh->num_slots, + (HPEE_MAX_LENGTH - sizeof(*eh)) / + sizeof(struct eeprom_eisa_slot_info)); for (i=0;inum_slots;i++) { struct eeprom_eisa_slot_info *es; @@ -503,7 +511,8 @@ int eisa_enumerator(unsigned long eeprom_addr, if (es->config_data_offset < HPEE_MAX_LENGTH) { if (parse_slot_config(i+1, &eeprom_buf[es->config_data_offset], - es, io_parent, mem_parent)) { + HPEE_MAX_LENGTH - es->config_data_offset, + es, io_parent, mem_parent)) { return -1; } } else { -- 2.53.0