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 v2] vfio/mlx5: fix possible overflow in tracking max message size
Date: Sun, 13 Jul 2025 10:56:52 +0300 [thread overview]
Message-ID: <b7cfa490-bc6c-4375-898a-7e4d12579f5d@nvidia.com> (raw)
In-Reply-To: <20250711150026.19818a98.alex.williamson@redhat.com>
On 12/07/2025 0:00, Alex Williamson wrote:
> On Tue, 1 Jul 2025 14:40:17 +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 integer constant to u64 type.
>>
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Suggested-by: Alex Williamson <alex.williamson@redhat.com>
>> Signed-off-by: Artem Sadovnikov <a.sadovnikov@ispras.ru>
>> ---
>> Changes from v1:
>> - The constant type was changed instead of variable type.
>> - The patch name was accidentally cut and is now fixed.
>> - LKML: https://lore.kernel.org/all/20250629095843.13349-1-a.sadovnikov@ispras.ru/
>> ---
>> drivers/vfio/pci/mlx5/cmd.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/vfio/pci/mlx5/cmd.c b/drivers/vfio/pci/mlx5/cmd.c
>> index 5b919a0b2524..a92b095b90f6 100644
>> --- a/drivers/vfio/pci/mlx5/cmd.c
>> +++ b/drivers/vfio/pci/mlx5/cmd.c
>> @@ -1523,8 +1523,8 @@ int mlx5vf_start_page_tracker(struct vfio_device *vdev,
>> log_max_msg_size = MLX5_CAP_ADV_VIRTUALIZATION(mdev, pg_track_log_max_msg_size);
>> max_msg_size = (1ULL << log_max_msg_size);
>> /* The RQ must hold at least 4 WQEs/messages for successful QP creation */
>> - if (rq_size < 4 * max_msg_size)
>> - rq_size = 4 * max_msg_size;
>> + if (rq_size < 4ULL * max_msg_size)
>> + rq_size = 4ULL * max_msg_size;
>>
>> memset(tracker, 0, sizeof(*tracker));
>> tracker->uar = mlx5_get_uars_page(mdev);
>
> LGTM, Yishai? Thanks,
>
> Alex
>
Reviewed-by: Yishai Hadas <yishaih@nvidia.com>
next prev parent reply other threads:[~2025-07-13 7:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 14:40 Artem Sadovnikov
2025-07-11 21:00 ` Alex Williamson
2025-07-13 7:56 ` Yishai Hadas [this message]
2025-07-16 20:20 ` Alex Williamson
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=b7cfa490-bc6c-4375-898a-7e4d12579f5d@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®