mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>, stable@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, Eli Cohen <elic@nvidia.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH for 5.10] vdpa_sim: fix param validation in vdpasim_get_config()
Date: Thu, 18 Feb 2021 14:39:15 +0800	[thread overview]
Message-ID: <d5f8c1b7-9506-6a84-dbba-53bf21897e5f@redhat.com> (raw)
In-Reply-To: <20210211162519.215418-1-sgarzare@redhat.com>


On 2021/2/12 上午12:25, Stefano Garzarella wrote:
> Commit 65b709586e222fa6ffd4166ac7fdb5d5dad113ee upstream.
>
> Before this patch, if 'offset + len' was equal to
> sizeof(struct virtio_net_config), the entire buffer wasn't filled,
> returning incorrect values to the caller.
>
> Since 'vdpasim->config' type is 'struct virtio_net_config', we can
> safely copy its content under this condition.
>
> Commit 65b709586e22 ("vdpa_sim: add get_config callback in
> vdpasim_dev_attr") unintentionally solved it upstream while
> refactoring vdpa_sim.c to support multiple devices. But we don't want
> to backport it to stable branches as it contains many changes.
>
> Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
> Cc: <stable@vger.kernel.org> # 5.10.x
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
>   drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> index 6a90fdb9cbfc..8ca178d7b02f 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -572,7 +572,7 @@ static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset,
>   {
>   	struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
>   
> -	if (offset + len < sizeof(struct virtio_net_config))
> +	if (offset + len <= sizeof(struct virtio_net_config))
>   		memcpy(buf, (u8 *)&vdpasim->config + offset, len);
>   }
>   


Acked-by: Jason Wang <jasowang@redhat.com>



      parent reply	other threads:[~2021-02-18  7:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11 16:25 Stefano Garzarella
2021-02-15 14:32 ` Greg KH
2021-02-15 15:03   ` Stefano Garzarella
2021-02-15 15:23     ` Greg KH
2021-02-16 13:55       ` Stefano Garzarella
2021-02-18  6:39 ` Jason Wang [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=d5f8c1b7-9506-6a84-dbba-53bf21897e5f@redhat.com \
    --to=jasowang@redhat.com \
    --cc=elic@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /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®