From: Petr Machata <petrm@nvidia.com>
To: Ido Schimmel <idosch@nvidia.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Petr Machata <petrm@nvidia.com>, <mlxsw@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
<netdev@vger.kernel.org>
Subject: Re: [PATCH net-next 1/3] mlxsw: Warn about invalid accesses to array fields
Date: Mon, 8 Jul 2024 11:45:03 +0200 [thread overview]
Message-ID: <87le2ctdwb.fsf@nvidia.com> (raw)
In-Reply-To: <ZoVGqJVBWUVNtsrc@shredder.lan>
Ido Schimmel <idosch@nvidia.com> writes:
> On Tue, Jul 02, 2024 at 09:08:17AM +0200, Przemek Kitszel wrote:
>> On 7/1/24 18:41, Petr Machata wrote:
>> >
>> > Suggested-by: Ido Schimmel <idosch@nvidia.com>
>> > Signed-off-by: Petr Machata <petrm@nvidia.com>
>> > Reviewed-by: Ido Schimmel <idosch@nvidia.com>
>> > ---
>> > drivers/net/ethernet/mellanox/mlxsw/item.h | 2 ++
>> > 1 file changed, 2 insertions(+)
>> >
>> > diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h b/drivers/net/ethernet/mellanox/mlxsw/item.h
>> > index cfafbeb42586..9f7133735760 100644
>> > --- a/drivers/net/ethernet/mellanox/mlxsw/item.h
>> > +++ b/drivers/net/ethernet/mellanox/mlxsw/item.h
>> > @@ -218,6 +218,8 @@ __mlxsw_item_bit_array_offset(const struct mlxsw_item *item,
>> > }
>> > max_index = (item->size.bytes << 3) / item->element_size - 1;
>> > + if (WARN_ON(index > max_index))
>> > + index = 0;
>>
>> you have BUG*() calls just above those lines :(
>> anyway, WARN_ON_ONCE(), and perhaps you need to print some additional
>> data to finally fix this?
>
> The trace should be enough, but more info can be added:
>
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h b/drivers/net/ethernet/mellanox/mlxsw/item.h
> index 9f7133735760..a619a0736bd1 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/item.h
> +++ b/drivers/net/ethernet/mellanox/mlxsw/item.h
> @@ -218,7 +218,9 @@ __mlxsw_item_bit_array_offset(const struct mlxsw_item *item,
> }
>
> max_index = (item->size.bytes << 3) / item->element_size - 1;
> - if (WARN_ON(index > max_index))
> + if (WARN_ONCE(index > max_index,
> + "name=%s,index=%u,max_index=%u\n", item->name, index,
> + max_index))
> index = 0;
> be_index = max_index - index;
> offset = be_index * item->element_size >> 3;
>
> Will leave it to Petr to decide what he wants to include there.
Thanks, I'll send a v2.
next prev parent reply other threads:[~2024-07-08 9:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 16:41 [PATCH net-next 0/3] mlxsw: Improvements Petr Machata
2024-07-01 16:41 ` [PATCH net-next 1/3] mlxsw: Warn about invalid accesses to array fields Petr Machata
2024-07-02 7:08 ` Przemek Kitszel
2024-07-03 12:40 ` Ido Schimmel
2024-07-08 9:45 ` Petr Machata [this message]
2024-07-01 16:41 ` [PATCH net-next 2/3] mlxsw: core_thermal: Report valid current state during cooling device registration Petr Machata
2024-07-02 7:27 ` Przemek Kitszel
2024-07-09 16:06 ` Rafael J. Wysocki
2024-07-01 16:41 ` [PATCH net-next 3/3] mlxsw: pci: Lock configuration space of upstream bridge during reset Petr Machata
2024-07-02 7:35 ` Przemek Kitszel
2024-07-03 14:42 ` Ido Schimmel
2024-07-12 21:21 ` Bjorn Helgaas
2024-07-14 11:29 ` Ido Schimmel
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=87le2ctdwb.fsf@nvidia.com \
--to=petrm@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.