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 A81D814BFA2; Sun, 7 Sep 2025 20:17:58 +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=1757276278; cv=none; b=pHGa4BsUfFWL8aM3dUIx1M67nADm2BTrhQbyvDrC896j4idyPXIIv9Ofs9jJMz/3YJibsZTLK5h1L+EBvgrNuOwIvrsFKAsHnjPGa6vSFuzAr+yNOO68BeNgkZAuWdMuPKVVxA05K22Wt0/hkM/nhuLL75pFMdmmY7nNe9aNt5M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757276278; c=relaxed/simple; bh=ChCpEGZGyEQ9YMuFvcmu7GPLbB+FArCMCnIQ72d9Owo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oUah0NTZyPNU4Hzl44tKzB4ThGpL7Dw35Mrjg/bs1/mlTpuDdtTOBpvYhkt3yrx9ma3GHYOBV+pMecEihfDXIBKbZPJ+pZhb8lICZfMqXk7IPqjvNIjRST/7DZKSWVlpcXy12hoANQwX+eqG7Ug2JJVmDtmhF6yTy5oyPpIu1wA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BXmS8eG6; 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="BXmS8eG6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A577C4CEF0; Sun, 7 Sep 2025 20:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757276278; bh=ChCpEGZGyEQ9YMuFvcmu7GPLbB+FArCMCnIQ72d9Owo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BXmS8eG6HiSZLMpx1NhLO+pyTeoVzL+z/qsAtVFBShdrFzkN28Qv9vSrqOwr+Ijtg EjpS3MzT80c2HLhbHQpQSWOoMFct3IkOILl01Uc0PPLPMy8tMvKG3zfBHstBYjHSuQ jbco/0uz8nwcsR34lgX0ixFQNsoCPn5oFEBHz6t8= 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.1 052/104] e1000e: fix heap overflow in e1000_set_eeprom Date: Sun, 7 Sep 2025 21:58:09 +0200 Message-ID: <20250907195609.037868703@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250907195607.664912704@linuxfoundation.org> References: <20250907195607.664912704@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.1-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 @@ -559,12 +559,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) @@ -579,6 +579,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);