netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Michal Schmidt <mschmidt@redhat.com>,
	netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
	Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Paul Greenwalt <paul.greenwalt@intel.com>,
	Petr Oros <poros@redhat.com>
Subject: Re: [PATCH net] ice: fix theoretical out-of-bounds access in ethtool link modes
Date: Tue, 5 Dec 2023 20:46:28 +0000	[thread overview]
Message-ID: <20231205204628.GX50400@kernel.org> (raw)
In-Reply-To: <f78a8937-0811-03e8-464d-47f404a3718b@intel.com>

On Fri, Dec 01, 2023 at 08:33:36AM +0100, Przemek Kitszel wrote:
> On 11/30/23 17:58, Michal Schmidt wrote:
> > To map phy types reported by the hardware to ethtool link mode bits,
> > ice uses two lookup tables (phy_type_low_lkup, phy_type_high_lkup).
> > The "low" table has 64 elements to cover every possible bit the hardware
> > may report, but the "high" table has only 13. If the hardware reports a
> > higher bit in phy_types_high, the driver would access memory beyond the
> > lookup table's end.
> > 
> > Instead of iterating through all 64 bits of phy_types_{low,high}, use
> > the sizes of the respective lookup tables.
> > 
> > Fixes: 9136e1f1e5c3 ("ice: refactor PHY type to ethtool link mode")
> > Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
> > ---
> >   drivers/net/ethernet/intel/ice/ice_ethtool.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> > index a34083567e6f..bde9bc74f928 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> > @@ -1850,14 +1850,14 @@ ice_phy_type_to_ethtool(struct net_device *netdev,
> >   	linkmode_zero(ks->link_modes.supported);
> >   	linkmode_zero(ks->link_modes.advertising);
> > -	for (i = 0; i < BITS_PER_TYPE(u64); i++) {
> > +	for (i = 0; i < ARRAY_SIZE(phy_type_low_lkup); i++) {
> >   		if (phy_types_low & BIT_ULL(i))
> >   			ice_linkmode_set_bit(&phy_type_low_lkup[i], ks,
> >   					     req_speeds, advert_phy_type_lo,
> >   					     i);
> >   	}
> > -	for (i = 0; i < BITS_PER_TYPE(u64); i++) {
> > +	for (i = 0; i < ARRAY_SIZE(phy_type_high_lkup); i++) {
> >   		if (phy_types_high & BIT_ULL(i))
> >   			ice_linkmode_set_bit(&phy_type_high_lkup[i], ks,
> >   					     req_speeds, advert_phy_type_hi,
> 
> I guess that that "HW reported" number really goes through the FW in
> some way, so one could indeed spoil that in some way,
> what makes sense to target it at -net.
> 
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

Reviewed-by: Simon Horman <horms@kernel.org>


  reply	other threads:[~2023-12-05 20:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 16:58 [PATCH net] ice: fix theoretical out-of-bounds access in ethtool link modes Michal Schmidt
2023-12-01  7:33 ` Przemek Kitszel
2023-12-05 20:46   ` Simon Horman [this message]
2023-12-11  4:55 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy

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=20231205204628.GX50400@kernel.org \
    --to=horms@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=mschmidt@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=paul.greenwalt@intel.com \
    --cc=poros@redhat.com \
    --cc=przemyslaw.kitszel@intel.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;
as well as URLs for NNTP newsgroup(s).