From: Yishai Hadas <yishaih@nvidia.com>
To: Alex Williamson <alex.williamson@redhat.com>,
Artem Sadovnikov <a.sadovnikov@ispras.ru>
Cc: <kvm@vger.kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Kevin Tian <kevin.tian@intel.com>, <linux-kernel@vger.kernel.org>,
<lvc-project@linuxtesting.org>
Subject: Re: [PATCH] vfio/mlx5: fix possible overflow in tracking max
Date: Tue, 1 Jul 2025 17:18:55 +0300 [thread overview]
Message-ID: <b68e4945-92cb-44f0-a364-2fe52520683a@nvidia.com> (raw)
In-Reply-To: <20250630112831.2207fa2e.alex.williamson@redhat.com>
On 30/06/2025 20:28, Alex Williamson wrote:
> On Sun, 29 Jun 2025 09:58:43 +0000
> Artem Sadovnikov <a.sadovnikov@ispras.ru> wrote:
>
>> MLX cap pg_track_log_max_msg_size consists of 5 bits, value of which is
>> used as power of 2 for max_msg_size. This can lead to multiplication
>> overflow between max_msg_size (u32) and integer constant, and afterwards
>> incorrect value is being written to rq_size.
>>
>> Fix this issue by extending max_msg_size up to u64 so multiplication will
>> be extended to u64.
>
> Personally I'd go with changing the multiplier to 4ULL rather than
> changing the storage size here, but let's wait for Yishai and Jason.
> Thanks,
>
> Alex
>
Yes, let's go with Alex's suggestion.
max_msg_size based on the CAP, can't be larger than u32.
Yishai
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Signed-off-by: Artem Sadovnikov <a.sadovnikov@ispras.ru>
>> ---
>> drivers/vfio/pci/mlx5/cmd.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/vfio/pci/mlx5/cmd.c b/drivers/vfio/pci/mlx5/cmd.c
>> index 5b919a0b2524..0bdaf1d23a78 100644
>> --- a/drivers/vfio/pci/mlx5/cmd.c
>> +++ b/drivers/vfio/pci/mlx5/cmd.c
>> @@ -1503,7 +1503,7 @@ int mlx5vf_start_page_tracker(struct vfio_device *vdev,
>> struct mlx5_vhca_qp *fw_qp;
>> struct mlx5_core_dev *mdev;
>> u32 log_max_msg_size;
>> - u32 max_msg_size;
>> + u64 max_msg_size;
>> u64 rq_size = SZ_2M;
>> u32 max_recv_wr;
>> int err;
>
prev parent reply other threads:[~2025-07-01 14:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-29 9:58 Artem Sadovnikov
2025-06-30 17:28 ` Alex Williamson
2025-07-01 14:18 ` Yishai Hadas [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=b68e4945-92cb-44f0-a364-2fe52520683a@nvidia.com \
--to=yishaih@nvidia.com \
--cc=a.sadovnikov@ispras.ru \
--cc=alex.williamson@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=shameerali.kolothum.thodi@huawei.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
all inboxes | Powered by JetHome®