netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Jurgens <danielj@nvidia.com>
To: Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, mst@redhat.com, jasowang@redhat.com,
	pabeni@redhat.com, virtualization@lists.linux.dev,
	parav@nvidia.com, shshitrit@nvidia.com, yohadt@nvidia.com,
	xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
	shameerali.kolothum.thodi@huawei.com, jgg@ziepe.ca,
	kevin.tian@intel.com, kuba@kernel.org, andrew+netdev@lunn.ch,
	edumazet@google.com
Subject: Re: [PATCH net-next v10 05/12] virtio_net: Query and set flow filter caps
Date: Mon, 17 Nov 2025 15:21:08 -0600	[thread overview]
Message-ID: <8b4325db-4237-46fb-aa54-bda65168f016@nvidia.com> (raw)
In-Reply-To: <aRuRGD-d7kImAKb3@horms.kernel.org>

On 11/17/25 3:18 PM, Simon Horman wrote:
> On Mon, Nov 17, 2025 at 11:49:54AM -0600, Dan Jurgens wrote:
>> On 11/17/25 11:16 AM, Simon Horman wrote:
>>> On Wed, Nov 12, 2025 at 01:34:28PM -0600, Daniel Jurgens wrote:
> 
> ...
> 
>>>> +	for (i = 0; i < ff->ff_mask->count; i++) {
>>>> +		if (sel->length > MAX_SEL_LEN) {
>>>> +			err = -EINVAL;
>>>> +			goto err_ff_action;
>>>> +		}
>>>> +		real_ff_mask_size += sizeof(struct virtio_net_ff_selector) + sel->length;
>>>> +		sel = (void *)sel + sizeof(*sel) + sel->length;
>>>> +	}
>>>
>>> Hi Daniel,
>>>
>>> I'm not sure that the bounds checking in the loop above is adequate.
>>> For example, if ff->ff_mask->count is larger than expected.
>>> Or sel->length returns MAX_SEL_LEN each time then it seems
>>> than sel could overrun the space allocated for ff->ff_mask.
>>>
>>> Flagged by Claude Code with https://github.com/masoncl/review-prompts/
>>>
>>
>> I can also bound the loop by VIRTIO_NET_FF_MASK_TYPE_MAX. I'll also
>> address your comments about classifier and rules limits on patch 7 here,
>> by checking the rules and classifier limits are > 0.
> 
> Thanks.
> 
> I think that even if the loop is bounded there is still (a much smaller)
> scope for an overflow. This is because selectors isn't large enough for
> VIRTIO_NET_FF_MASK_TYPE_MAX entries if all of them have length ==
> MAX_SEL_LEN.
> 
>>
>> I'll wait to push a new version until I hear back from Michael about the
>> threading comment he made on the cover letter.
>>

I actually moved the if (real_ff_mask_size > ff_mask_size) check into
the loop, before updating the selector pointer.

  reply	other threads:[~2025-11-17 21:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 19:34 [PATCH net-next v10 01/12] virtio_pci: Remove supported_cap size build assert Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 02/12] virtio: Add config_op for admin commands Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 03/12] virtio: Expose generic device capability operations Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 04/12] virtio: Expose object create and destroy API Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 05/12] virtio_net: Query and set flow filter caps Daniel Jurgens
2025-11-17 17:16   ` Simon Horman
2025-11-17 17:49     ` Dan Jurgens
2025-11-17 21:18       ` Simon Horman
2025-11-17 21:21         ` Dan Jurgens [this message]
2025-11-18  9:45           ` Simon Horman
2025-11-12 19:34 ` [PATCH net-next v10 06/12] virtio_net: Create a FF group for ethtool steering Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 07/12] virtio_net: Implement layer 2 ethtool flow rules Daniel Jurgens
2025-11-17 17:15   ` Simon Horman
2025-11-12 19:34 ` [PATCH net-next v10 08/12] virtio_net: Use existing classifier if possible Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 09/12] virtio_net: Implement IPv4 ethtool flow rules Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 10/12] virtio_net: Add support for IPv6 ethtool steering Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 11/12] virtio_net: Add support for TCP and UDP ethtool rules Daniel Jurgens
2025-11-12 19:34 ` [PATCH net-next v10 12/12] virtio_net: Add get ethtool flow rules ops Daniel Jurgens

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=8b4325db-4237-46fb-aa54-bda65168f016@nvidia.com \
    --to=danielj@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=horms@kernel.org \
    --cc=jasowang@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=kevin.tian@intel.com \
    --cc=kuba@kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parav@nvidia.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=shshitrit@nvidia.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    --cc=yohadt@nvidia.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).