From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: Mikael Wessel <post@mikaelkw.online>, <netdev@vger.kernel.org>
Cc: <intel-wired-lan@lists.osuosl.org>,
<torvalds@linuxfoundation.org>, <przemyslaw.kitszel@intel.com>,
<andrew@lunn.ch>, <kuba@kernel.org>, <pabeni@redhat.com>,
<security@kernel.org>, <stable@vger.kernel.org>,
<davem@davemloft.net>, <edumazet@google.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] e1000e: fix heap overflow in e1000_set_eeprom()
Date: Wed, 28 May 2025 08:33:36 -0700 [thread overview]
Message-ID: <cc70d2d6-df72-4032-8d9b-fb96f4ef3ed0@intel.com> (raw)
In-Reply-To: <20250527211332.50455-1-post@mikaelkw.online>
On 5/27/2025 2:13 PM, Mikael Wessel wrote:
> The ETHTOOL_SETEEPROM ioctl copies user data into a kmalloc'ed buffer
> without validating eeprom->len and eeprom->offset. A CAP_NET_ADMIN
> user can overflow the heap and crash the kernel or gain code execution.
>
> Validate length and offset before kmalloc() to avoid leaking eeprom_buff.
>
> Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)")
> Reported-by: Mikael Wessel <post@mikaelkw.online>
> Signed-off-by: Mikael Wessel <post@mikaelkw.online>
> Cc: stable@vger.kernel.org
> ---
> drivers/net/ethernet/intel/e1000e/ethtool.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
> index 98e541e39730..d04e59528619 100644
> --- a/drivers/net/ethernet/intel/e1000e/ethtool.c
> +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
> @@ -561,7 +561,7 @@ static int e1000_set_eeprom(struct net_device *netdev,
> return -EOPNOTSUPP;
>
> if (eeprom->magic !=
> - (adapter->pdev->vendor | (adapter->pdev->device << 16)))
> + (adapter->pdev->vendor | (adapter->pdev->device << 16)))
As Andrew already pointed out, please omit.
> return -EFAULT;
>
> if (adapter->flags & FLAG_READ_ONLY_NVM)
> @@ -569,6 +569,10 @@ static int e1000_set_eeprom(struct net_device *netdev,
>
> max_len = hw->nvm.word_size * 2;
>
> + /* bounds check: offset + len must not exceed EEPROM size */
> + if (eeprom->offset + eeprom->len > max_len)
> + return -EINVAL;
> +
> first_word = eeprom->offset >> 1;
> last_word = (eeprom->offset + eeprom->len - 1) >> 1;
> eeprom_buff = kmalloc(max_len, GFP_KERNEL);
> @@ -596,9 +600,6 @@ static int e1000_set_eeprom(struct net_device *netdev,
> for (i = 0; i < last_word - first_word + 1; i++)
> le16_to_cpus(&eeprom_buff[i]);
>
> - if (eeprom->len > max_len ||
> - eeprom->offset > max_len - eeprom->len)
> - return -EINVAL;
Seems like this patch is based on top of your previous version?
https://lore.kernel.org/all/20250527085612.11354-2-post@mikaelkw.online/
Please a provide a patch that can apply without need for previous versions.
Thanks,
Tony
prev parent reply other threads:[~2025-05-28 15:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 21:13 [PATCH] e1000e: fix heap overflow in e1000_set_eeprom() Mikael Wessel
2025-05-27 21:42 ` Andrew Lunn
2025-05-28 15:33 ` Tony Nguyen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc70d2d6-df72-4032-8d9b-fb96f4ef3ed0@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=post@mikaelkw.online \
--cc=przemyslaw.kitszel@intel.com \
--cc=security@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).