From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Petr Oros <poros@redhat.com>
Cc: <netdev@vger.kernel.org>, <intel-wired-lan@lists.osuosl.org>,
<jesse.brandeburg@intel.com>, <linux-kernel@vger.kernel.org>,
<edumazet@google.com>, <anthony.l.nguyen@intel.com>,
<kuba@kernel.org>, <pabeni@redhat.com>, <davem@davemloft.net>
Subject: Re: [Intel-wired-lan] [PATCH net] ice: copy last block omitted in ice_get_module_eeprom()
Date: Wed, 1 Mar 2023 16:13:40 +0100 [thread overview]
Message-ID: <32fdf39c-9772-61a1-e0d7-40a564f640a2@intel.com> (raw)
In-Reply-To: <20230228204139.2264495-1-poros@redhat.com>
From: Petr Oros <poros@redhat.com>
Date: Tue, 28 Feb 2023 21:41:39 +0100
> ice_get_module_eeprom() is broken since commit e9c9692c8a81 ("ice:
> Reimplement module reads used by ethtool") In this refactor,
> ice_get_module_eeprom() reads the eeprom in blocks of size 8.
> But the condition that should protect the buffer overflow
> ignores the last block. The last block always contains zeros.
> Fix adding memcpy for last block.
[...]
> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> index b360bd8f15998b..33b2bee5cfb40f 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> @@ -4356,6 +4356,8 @@ ice_get_module_eeprom(struct net_device *netdev,
> /* Make sure we have enough room for the new block */
> if ((i + SFF_READ_BLOCK_SIZE) < ee->len)
> memcpy(data + i, value, SFF_READ_BLOCK_SIZE);
> + else if (ee->len - i > 0)
> + memcpy(data + i, value, ee->len - i);
Maybe just unify those two?
copy_len = min_t(u32, SFF_READ_BLOCK_SIZE,
ee->len - i);
memcpy(data + i, value, copy_len);
That's pretty much a reword of your code.
The functional change is good to me.
> }
> }
> return 0;
Thanks,
Olek
next prev parent reply other threads:[~2023-03-01 15:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 20:41 Petr Oros
2023-03-01 15:13 ` Alexander Lobakin [this message]
2023-03-01 17:14 ` [PATCH net v2] " Petr Oros
2023-03-01 19:26 ` Jesse Brandeburg
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=32fdf39c-9772-61a1-e0d7-40a564f640a2@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jesse.brandeburg@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
/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
Powered by JetHome