From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Magnus Karlsson <magnus.karlsson@gmail.com>
Cc: <magnus.karlsson@intel.com>, <bjorn@kernel.org>, <ast@kernel.org>,
<daniel@iogearbox.net>, <netdev@vger.kernel.org>,
<jonathan.lemon@gmail.com>, <bpf@vger.kernel.org>,
Alasdair McWilliam <alasdair.mcwilliam@outlook.com>,
Intrusion Shield Team <dnevil@intrusion.com>
Subject: Re: [PATCH bpf] xsk: fix corrupted packets for XDP_SHARED_UMEM
Date: Fri, 12 Aug 2022 15:06:12 +0200 [thread overview]
Message-ID: <YvZQRKcEO6JsyDfa@boxer> (raw)
In-Reply-To: <20220812113259.531-1-magnus.karlsson@gmail.com>
On Fri, Aug 12, 2022 at 01:32:59PM +0200, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
>
> Fix an issue in XDP_SHARED_UMEM mode together with aligned mode were
s/were/where
> packets are corrupted for the second and any further sockets bound to
> the same umem. In other words, this does not affect the first socket
> bound to the umem. The culprit for this bug is that the initialization
> of the DMA addresses for the pre-populated xsk buffer pool entries was
> not performed for any socket but the first one bound to the umem. Only
> the linear array of DMA addresses was populated. Fix this by
> populating the DMA addresses in the xsk buffer pool for every socket
> bound to the same umem.
>
> Fixes: 94033cd8e73b8 ("xsk: Optimize for aligned case")
> Reported-by: Alasdair McWilliam <alasdair.mcwilliam@outlook.com>
> Reported-by: Intrusion Shield Team <dnevil@intrusion.com>
> Tested-by: Alasdair McWilliam <alasdair.mcwilliam@outlook.com>
> Link: https://lore.kernel.org/xdp-newbies/6205E10C-292E-4995-9D10-409649354226@outlook.com/
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
> net/xdp/xsk_buff_pool.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index f70112176b7c..a71a8c6edf55 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -379,6 +379,16 @@ static void xp_check_dma_contiguity(struct xsk_dma_map *dma_map)
>
> static int xp_init_dma_info(struct xsk_buff_pool *pool, struct xsk_dma_map *dma_map)
> {
> + if (!pool->unaligned) {
> + u32 i;
> +
> + for (i = 0; i < pool->heads_cnt; i++) {
> + struct xdp_buff_xsk *xskb = &pool->heads[i];
> +
> + xp_init_xskb_dma(xskb, pool, dma_map->dma_pages, xskb->orig_addr);
I wondered if it would be better to move it to the end of func and use
pool->dma_pages, but it probably doesn't matter in the end.
Great catch!
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> + }
> + }
> +
> pool->dma_pages = kvcalloc(dma_map->dma_pages_cnt, sizeof(*pool->dma_pages), GFP_KERNEL);
> if (!pool->dma_pages)
> return -ENOMEM;
> @@ -428,12 +438,6 @@ int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev,
>
> if (pool->unaligned)
> xp_check_dma_contiguity(dma_map);
> - else
> - for (i = 0; i < pool->heads_cnt; i++) {
> - struct xdp_buff_xsk *xskb = &pool->heads[i];
> -
> - xp_init_xskb_dma(xskb, pool, dma_map->dma_pages, xskb->orig_addr);
> - }
>
> err = xp_init_dma_info(pool, dma_map);
> if (err) {
>
> base-commit: 4e4588f1c4d2e67c993208f0550ef3fae33abce4
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-08-12 13:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 11:32 [PATCH bpf] xsk: fix corrupted packets for XDP_SHARED_UMEM Magnus Karlsson
2022-08-12 13:06 ` Maciej Fijalkowski [this message]
2022-08-15 15:36 ` patchwork-bot+netdevbpf
-- strict thread matches above, loose matches on Subject: below --
2022-08-11 11:55 Magnus Karlsson
2022-08-11 17:20 ` Alasdair McWilliam
2022-08-11 18:22 ` Maciej Fijalkowski
2022-08-12 5:59 ` Magnus Karlsson
2022-08-12 10:29 ` Alasdair McWilliam
2022-08-12 10:37 ` Maciej Fijalkowski
2022-09-09 10:15 ` Alasdair McWilliam
2022-09-09 11:04 ` Maciej Fijalkowski
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=YvZQRKcEO6JsyDfa@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=alasdair.mcwilliam@outlook.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dnevil@intrusion.com \
--cc=jonathan.lemon@gmail.com \
--cc=magnus.karlsson@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.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.