All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Paul Durrant <paul.durrant@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>, <davem@davemloft.net>,
	xen-devel <xen-devel@lists.xenproject.org>,
	<netdev@vger.kernel.org>
Subject: Re: [PATCH 2/3] xen-netback: validate queue numbers in xenvif_set_hash_mapping()
Date: Wed, 29 Aug 2018 09:25:08 +0100	[thread overview]
Message-ID: <20180829082508.dczaww7fowq2c3z3@citrix.com> (raw)
In-Reply-To: <5B85636102000078001E2A4D@prv1-mh.provo.novell.com>

On Tue, Aug 28, 2018 at 08:59:45AM -0600, Jan Beulich wrote:
> Checking them before the grant copy means nothing as to the validity of
> the incoming request. As we shouldn't make the new data live before
> having validated it, introduce a second instance of the mapping array.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> ---
>  drivers/net/xen-netback/common.h    |    3 ++-
>  drivers/net/xen-netback/hash.c      |   20 ++++++++++++++------
>  drivers/net/xen-netback/interface.c |    3 ++-
>  3 files changed, 18 insertions(+), 8 deletions(-)
> 
> --- 4.19-rc1-xen-netback-set-hash-mapping.orig/drivers/net/xen-netback/common.h
> +++ 4.19-rc1-xen-netback-set-hash-mapping/drivers/net/xen-netback/common.h
> @@ -241,8 +241,9 @@ struct xenvif_hash_cache {
>  struct xenvif_hash {
>  	unsigned int alg;
>  	u32 flags;
> +	bool mapping_sel;
>  	u8 key[XEN_NETBK_MAX_HASH_KEY_SIZE];
> -	u32 mapping[XEN_NETBK_MAX_HASH_MAPPING_SIZE];
> +	u32 mapping[2][XEN_NETBK_MAX_HASH_MAPPING_SIZE];
>  	unsigned int size;
>  	struct xenvif_hash_cache cache;
>  };
> --- 4.19-rc1-xen-netback-set-hash-mapping.orig/drivers/net/xen-netback/hash.c
> +++ 4.19-rc1-xen-netback-set-hash-mapping/drivers/net/xen-netback/hash.c
> @@ -324,7 +324,8 @@ u32 xenvif_set_hash_mapping_size(struct
>  		return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>  
>  	vif->hash.size = size;
> -	memset(vif->hash.mapping, 0, sizeof(u32) * size);
> +	memset(vif->hash.mapping[vif->hash.mapping_sel], 0,
> +	       sizeof(u32) * size);
>  
>  	return XEN_NETIF_CTRL_STATUS_SUCCESS;
>  }
> @@ -332,7 +333,7 @@ u32 xenvif_set_hash_mapping_size(struct
>  u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
>  			    u32 off)
>  {
> -	u32 *mapping = vif->hash.mapping;
> +	u32 *mapping = vif->hash.mapping[!vif->hash.mapping_sel];

Can you rename this to inactive_mapping so the code can be followed more
easily?

The code looks correct to me, but I would like Paul to have a look
before it can go in.

Wei.

  reply	other threads:[~2018-08-29 12:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 14:54 [PATCH 0/3] xen-netback: hash mapping hanling adjustments Jan Beulich
2018-08-28 14:59 ` [PATCH 1/3] xen-netback: fix input validation in xenvif_set_hash_mapping() Jan Beulich
2018-08-28 14:59 ` [PATCH 2/3] xen-netback: validate queue numbers " Jan Beulich
2018-08-29  8:25   ` Wei Liu [this message]
2018-08-29  8:25   ` Wei Liu
2018-09-03  9:23   ` Paul Durrant
2018-09-03  9:23   ` Paul Durrant
2018-08-28 14:59 ` Jan Beulich
2018-08-28 15:00 ` [PATCH 3/3] xen-netback: handle page straddling " Jan Beulich
2018-08-28 15:00 ` Jan Beulich
2018-08-29  8:26   ` Wei Liu
2018-08-29  8:26   ` Wei Liu
2018-09-03  9:28   ` Paul Durrant
2018-09-03  9:28   ` Paul Durrant
2018-09-11  8:12 ` [PATCH 0/3] xen-netback: hash mapping hanling adjustments Jan Beulich
2018-09-11  8:12 ` Jan Beulich
2018-09-11 10:16   ` Wei Liu
2018-09-11 10:16   ` Wei Liu
2018-09-24  7:43     ` Ping: " Jan Beulich
2018-09-24 16:49       ` David Miller
     [not found]         ` <C61B6A85020000F18A491530@prv1-mh.provo.novell.com>
2018-09-25  8:18           ` Jan Beulich
2018-09-25  8:18           ` Jan Beulich
2018-09-24 16:49       ` David Miller
2018-09-24  7:43     ` Jan Beulich
2018-09-25  8:11 ` [PATCH net 0/3 RESEND] xen-netback: hash mapping handling adjustments Jan Beulich
2018-09-25 17:40   ` David Miller
2018-09-25 17:40   ` David Miller
2018-09-25  8:11 ` Jan Beulich
2018-09-25  8:12 ` [PATCH net 1/3 RESEND] xen-netback: fix input validation in xenvif_set_hash_mapping() Jan Beulich
2018-09-25  8:12 ` Jan Beulich
2018-09-25  8:13 ` [PATCH net 2/3 RESEND] xen-netback: validate queue numbers " Jan Beulich
2018-09-25  8:13 ` Jan Beulich
2018-09-25  8:13 ` [PATCH net 3/3 RESEND] xen-netback: handle page straddling " Jan Beulich
2018-09-25  8:13 ` Jan Beulich

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=20180829082508.dczaww7fowq2c3z3@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=paul.durrant@citrix.com \
    --cc=xen-devel@lists.xenproject.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 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.