lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ8uoz3qM04VQF7FRmnVp_AZjGaPw25GJNn0ah-Jd0=eRCRsjg@mail.gmail.com>
Date:   Thu, 20 Apr 2023 10:12:21 +0200
From:   Magnus Karlsson <magnus.karlsson@...il.com>
To:     Kal Cutter Conley <kal.conley@...tris.com>
Cc:     magnus.karlsson@...el.com, bjorn@...nel.org, ast@...nel.org,
        daniel@...earbox.net, netdev@...r.kernel.org,
        maciej.fijalkowski@...el.com, tirthendu.sarkar@...el.com,
        bpf@...r.kernel.org
Subject: Re: [PATCH bpf-next] selftests/xsk: fix munmap for hugepage allocated umem

On Thu, 20 Apr 2023 at 00:01, Kal Cutter Conley <kal.conley@...tris.com> wrote:
>
> > @@ -1286,16 +1287,19 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
> >         u64 umem_sz = ifobject->umem->num_frames * ifobject->umem->frame_size;
> >         int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
> >         LIBBPF_OPTS(bpf_xdp_query_opts, opts);
> > +       off_t mmap_offset = 0;
> >         void *bufs;
> >         int ret;
> >
> > -       if (ifobject->umem->unaligned_mode)
> > +       if (ifobject->umem->unaligned_mode) {
> >                 mmap_flags |= MAP_HUGETLB;
> > +               mmap_offset = MAP_HUGE_2MB;
> > +       }
>
> MAP_HUGE_2MB should be ORed into mmap_flags. The offset argument
> should be zero for MAP_ANONYMOUS mappings. The tests may still fail if
> the default hugepage size is not 2MB.

You are correct that it should go into the flags field. Misread the
man page so will send a fix.

It was a conscious decision to require a hugepage size of 2M. I want
it to fail if you do not have it since the rest of the code will not
work if you are using some other size. Yes, it is possible to discover
what hugepage sizes exist and act on that, but I want to keep the code
simple.

> >
> >         if (ifobject->shared_umem)
> >                 umem_sz *= 2;
> >
> > -       bufs = mmap(NULL, umem_sz, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
> > +       bufs = mmap(NULL, umem_sz, PROT_READ | PROT_WRITE, mmap_flags, -1, mmap_offset);
> >         if (bufs == MAP_FAILED)
> >                 exit_with_error(errno);
> >
>
> -Kal

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ