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] [day] [month] [year] [list]
Message-ID: <CAA-VZPnTBOOAxu+VqupzDqej_wheXYbOGxG0nuV+eMPqS35GKQ@mail.gmail.com>
Date:   Thu, 8 Sep 2022 16:44:45 -0700
From:   YiFei Zhu <zhuyifei@...gle.com>
To:     Martin KaFai Lau <martin.lau@...ux.dev>
Cc:     bpf@...r.kernel.org, netdev@...r.kernel.org,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Stanislav Fomichev <sdf@...gle.com>,
        John Fastabend <john.fastabend@...il.com>,
        Jiri Olsa <jolsa@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        David Ahern <dsahern@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH v3 bpf-next 3/3] selftests/bpf: Ensure cgroup/connect{4,6}
 programs can bind unpriv ICMP ping

On Thu, Sep 8, 2022 at 4:32 PM Martin KaFai Lau <martin.lau@...ux.dev> wrote:
>
> On 9/8/22 4:16 PM, YiFei Zhu wrote:
> > +void test_connect_ping(void)
> > +{
> > +     struct connect_ping *skel;
> > +     int cgroup_fd;
> > +
> > +     if (!ASSERT_OK(unshare(CLONE_NEWNET | CLONE_NEWNS), "unshare"))
> > +             return;
> > +
> > +     /* overmount sysfs, and making original sysfs private so overmount
> > +      * does not propagate to other mntns.
> > +      */
> > +     if (!ASSERT_OK(mount("none", "/sys", NULL, MS_PRIVATE, NULL),
> > +                    "remount-private-sys"))
> > +             return;
> > +     if (!ASSERT_OK(mount("sysfs", "/sys", "sysfs", 0, NULL),
> > +                    "mount-sys"))
> > +             return;
> > +     if (!ASSERT_OK(mount("bpffs", "/sys/fs/bpf", "bpf", 0, NULL),
> > +                    "mount-bpf"))
> > +             goto clean_mount;
> > +
> > +     if (!ASSERT_OK(system("ip link set dev lo up"), "lo-up"))
> > +             goto clean_mount;
> > +     if (!ASSERT_OK(system("ip addr add 1.1.1.1 dev lo"), "lo-addr-v4"))
> > +             goto clean_mount;
> > +     if (!ASSERT_OK(system("ip -6 addr add 2001:db8::1 dev lo"), "lo-addr-v6"))
> > +             goto clean_mount;
> > +     if (write_sysctl("/proc/sys/net/ipv4/ping_group_range", "0 0"))
> > +             goto clean_mount;
> > +
> > +     cgroup_fd = test__join_cgroup("/connect_ping");
> > +     if (!ASSERT_GE(cgroup_fd, 0, "cg-create"))
> > +             goto clean_mount;
> > +
> > +     skel = connect_ping__open_and_load();
> > +     if (!ASSERT_OK_PTR(skel, "skel-load"))
> > +             goto close_cgroup;
> > +     skel->links.connect_v4_prog =
> > +             bpf_program__attach_cgroup(skel->progs.connect_v4_prog, cgroup_fd);
> > +     if (!ASSERT_OK_PTR(skel->links.connect_v4_prog, "cg-attach-v4"))
> > +             goto close_cgroup;
>
> connect_ping__destroy() is also needed in this error path.
>
> I had already mentioned that in v2.  I went back to v2 and noticed my
> editor some how merged my reply with the previous quoted line ">".  A
> similar thing happened in my recent replies also.  I hope it appears
> fine this time.

Oops, I missed that and thought that was part of a quote. Let me fix
that and send a v4.

> > +     skel->links.connect_v6_prog =
> > +             bpf_program__attach_cgroup(skel->progs.connect_v6_prog, cgroup_fd);
> > +     if (!ASSERT_OK_PTR(skel->links.connect_v6_prog, "cg-attach-v6"))
> > +             goto close_cgroup;
>
> Same here.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ