From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EE444315A; Sun, 7 Sep 2025 20:43:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757277832; cv=none; b=p1M5wCRgIr7AlMiwyC+o4i+z7W60qdDxojhqbAZrd0r0l3iWwq1z6ZSMifyZNfIzlTaxUF0yd5KY21yfwbapkAEUN8W+fIK1+3iS8MtmWCleSXpypmVFcVbuY5sLlWUtuOUqcxK8AhhOtZX75tEJM8gm2RYdbwpurKCkTrkqGYE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757277832; c=relaxed/simple; bh=olih+fW+k2lNvWwRcOabYVtTagEOYYVKhrcOj0YjlXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D8zB+Kwo8rT2C9JYlJW7g0rLnlupr9EuZbaOzGn/L9GWn7nEC2drmFt+w/sqYBA4D1kQkwSOvRr6dMLG4vwBeKLcEmEex7KrdA4XZfUGtEsxTUzZ/UQJU5F+3Mm/MB/61ZVTWgsdwD5/mpV9QLBuFchj9iJ+5ehqPOWLCEF8xNs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pL4ds7Wl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pL4ds7Wl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1431EC4CEF0; Sun, 7 Sep 2025 20:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757277832; bh=olih+fW+k2lNvWwRcOabYVtTagEOYYVKhrcOj0YjlXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pL4ds7Wl3tHMSoEVXPLqVCi9jVnUbLiBxfaMb0LL8g09cVVbSC+qpCEr4XEzRvWJ3 2pVo56QWl4VK33NXglIxo/oPGjAI3FHqBrjmiXs8nJzTxgpfv3WBvOfvcq/YbR0Ive JpsF8ccc1JhiBBJagE+W+BkAWfF+nTfXu2NT6+5Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikael Wessel , Vitaly Lifshits , Mor Bar-Gabay , Tony Nguyen Subject: [PATCH 6.16 137/183] e1000e: fix heap overflow in e1000_set_eeprom Date: Sun, 7 Sep 2025 21:59:24 +0200 Message-ID: <20250907195619.047616948@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250907195615.802693401@linuxfoundation.org> References: <20250907195615.802693401@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vitaly Lifshits commit 90fb7db49c6dbac961c6b8ebfd741141ffbc8545 upstream. Fix a possible heap overflow in e1000_set_eeprom function by adding input validation for the requested length of the change in the EEPROM. In addition, change the variable type from int to size_t for better code practices and rearrange declarations to RCT. Cc: stable@vger.kernel.org Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)") Co-developed-by: Mikael Wessel Signed-off-by: Mikael Wessel Signed-off-by: Vitaly Lifshits Tested-by: Mor Bar-Gabay Signed-off-by: Tony Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/e1000e/ethtool.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -549,12 +549,12 @@ static int e1000_set_eeprom(struct net_d { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; + size_t total_len, max_len; u16 *eeprom_buff; - void *ptr; - int max_len; + int ret_val = 0; int first_word; int last_word; - int ret_val = 0; + void *ptr; u16 i; if (eeprom->len == 0) @@ -569,6 +569,10 @@ static int e1000_set_eeprom(struct net_d max_len = hw->nvm.word_size * 2; + if (check_add_overflow(eeprom->offset, eeprom->len, &total_len) || + total_len > max_len) + return -EFBIG; + first_word = eeprom->offset >> 1; last_word = (eeprom->offset + eeprom->len - 1) >> 1; eeprom_buff = kmalloc(max_len, GFP_KERNEL);