The kernel documentation says:
> The value stored can be of any size, however, all array elements are
> aligned to 8 bytes.
https://www.kernel.org/doc/html/v6.8/bpf/map_array.html
Fixes: 333b3e5fab75 ("ebpf: Added eBPF map update through mmap.")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
ebpf/ebpf_rss.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
index 2e506f974357..d102f3dd0929 100644
--- a/ebpf/ebpf_rss.c
+++ b/ebpf/ebpf_rss.c
@@ -185,13 +185,18 @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
uint16_t *indirections_table,
size_t len)
{
+ char *cursor = ctx->mmap_indirections_table;
+
if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
return false;
}
- memcpy(ctx->mmap_indirections_table, indirections_table,
- sizeof(*indirections_table) * len);
+ for (size_t i = 0; i < len; i++) {
+ *(uint16_t *)cursor = indirections_table[i];
+ cursor += 8;
+ }
+
return true;
}
--
2.44.0
Hi Andrew,
Can you please check the indirection table copy and ack on the patch
if the fix is correct
Thanks,
Yuri
On Wed, Mar 27, 2024 at 4:05 AM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>
> The kernel documentation says:
> > The value stored can be of any size, however, all array elements are
> > aligned to 8 bytes.
> https://www.kernel.org/doc/html/v6.8/bpf/map_array.html
>
> Fixes: 333b3e5fab75 ("ebpf: Added eBPF map update through mmap.")
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> ebpf/ebpf_rss.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
> index 2e506f974357..d102f3dd0929 100644
> --- a/ebpf/ebpf_rss.c
> +++ b/ebpf/ebpf_rss.c
> @@ -185,13 +185,18 @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
> uint16_t *indirections_table,
> size_t len)
> {
> + char *cursor = ctx->mmap_indirections_table;
> +
> if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
> len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
> return false;
> }
>
> - memcpy(ctx->mmap_indirections_table, indirections_table,
> - sizeof(*indirections_table) * len);
> + for (size_t i = 0; i < len; i++) {
> + *(uint16_t *)cursor = indirections_table[i];
> + cursor += 8;
> + }
> +
> return true;
> }
>
>
> --
> 2.44.0
>
Hi all,
I've reviewed and checked - this patch is necessary!
Acked-by: andrew@daynix.com
On Thu, Mar 28, 2024 at 11:39 AM Yuri Benditovich
<yuri.benditovich@daynix.com> wrote:
>
> Hi Andrew,
> Can you please check the indirection table copy and ack on the patch
> if the fix is correct
>
> Thanks,
> Yuri
>
> On Wed, Mar 27, 2024 at 4:05 AM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
> >
> > The kernel documentation says:
> > > The value stored can be of any size, however, all array elements are
> > > aligned to 8 bytes.
> > https://www.kernel.org/doc/html/v6.8/bpf/map_array.html
> >
> > Fixes: 333b3e5fab75 ("ebpf: Added eBPF map update through mmap.")
> > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> > ---
> > ebpf/ebpf_rss.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
> > index 2e506f974357..d102f3dd0929 100644
> > --- a/ebpf/ebpf_rss.c
> > +++ b/ebpf/ebpf_rss.c
> > @@ -185,13 +185,18 @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
> > uint16_t *indirections_table,
> > size_t len)
> > {
> > + char *cursor = ctx->mmap_indirections_table;
> > +
> > if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
> > len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
> > return false;
> > }
> >
> > - memcpy(ctx->mmap_indirections_table, indirections_table,
> > - sizeof(*indirections_table) * len);
> > + for (size_t i = 0; i < len; i++) {
> > + *(uint16_t *)cursor = indirections_table[i];
> > + cursor += 8;
> > + }
> > +
> > return true;
> > }
> >
> >
> > --
> > 2.44.0
> >
© 2016 - 2026 Red Hat, Inc.