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: <5ec6cdc36590c_71142afbf66925b87e@john-XPS-13-9370.notmuch>
Date:   Thu, 21 May 2020 11:51:47 -0700
From:   John Fastabend <john.fastabend@...il.com>
To:     Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>, ast@...nel.org,
        daniel@...earbox.net
Cc:     lmb@...udflare.com, bpf@...r.kernel.org, jakub@...udflare.com,
        netdev@...r.kernel.org
Subject: Re: [bpf-next PATCH v3 4/5] bpf: selftests, add sk_msg helpers load
 and attach test

Yonghong Song wrote:
> 
> 
> On 5/21/20 7:35 AM, John Fastabend wrote:
> > The test itself is not particularly useful but it encodes a common
> > pattern we have.
> > 
> > Namely do a sk storage lookup then depending on data here decide if
> > we need to do more work or alternatively allow packet to PASS. Then
> > if we need to do more work consult task_struct for more information
> > about the running task. Finally based on this additional information
> > drop or pass the data. In this case the suspicious check is not so
> > realisitic but it encodes the general pattern and uses the helpers
> > so we test the workflow.
> > 
> > This is a load test to ensure verifier correctly handles this case.
> > 
> > Signed-off-by: John Fastabend <john.fastabend@...il.com>
> > ---
> >   .../selftests/bpf/prog_tests/sockmap_basic.c       |   57 ++++++++++++++++++++
> >   .../selftests/bpf/progs/test_skmsg_load_helpers.c  |   48 +++++++++++++++++
> >   2 files changed, 105 insertions(+)
> >   create mode 100644 tools/testing/selftests/bpf/progs/test_skmsg_load_helpers.c
> > 
> > diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> > index aa43e0b..cacb4ad 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> > @@ -1,13 +1,46 @@
> >   // SPDX-License-Identifier: GPL-2.0
> >   // Copyright (c) 2020 Cloudflare
> > +#include <error.h>
> >   
> >   #include "test_progs.h"
> > +#include "test_skmsg_load_helpers.skel.h"
> >   
> >   #define TCP_REPAIR		19	/* TCP sock is under repair right now */
> >   
> >   #define TCP_REPAIR_ON		1
> >   #define TCP_REPAIR_OFF_NO_WP	-1	/* Turn off without window probes */
> >   
> > +#define _FAIL(errnum, fmt...)                                                  \
> > +	({                                                                     \
> > +		error_at_line(0, (errnum), __func__, __LINE__, fmt);           \
> > +		CHECK_FAIL(true);                                              \
> > +	})
> > +#define FAIL(fmt...) _FAIL(0, fmt)
> > +#define FAIL_ERRNO(fmt...) _FAIL(errno, fmt)
> > +#define FAIL_LIBBPF(err, msg)                                                  \
> > +	({                                                                     \
> > +		char __buf[MAX_STRERR_LEN];                                    \
> > +		libbpf_strerror((err), __buf, sizeof(__buf));                  \
> > +		FAIL("%s: %s", (msg), __buf);                                  \
> > +	})
> 
> Can we use existing macros in test_progs.h?
> This will be consistent with other test_progs selftests.

That will work. I was planning to come back and cleanup tests that are
not using the test_progs.h variants but good point no point in adding
one more.

> 
> > +
> > +#define xbpf_prog_attach(prog, target, type, flags)                            \
> > +	({                                                                     \
> > +		int __ret =                                                    \
> > +			bpf_prog_attach((prog), (target), (type), (flags));    \
> > +		if (__ret == -1)                                               \
> > +			FAIL_ERRNO("prog_attach(" #type ")");                  \
> > +		__ret;                                                         \
> > +	})
> > +
> > +#define xbpf_prog_detach2(prog, target, type)                                  \
> > +	({                                                                     \
> > +		int __ret = bpf_prog_detach2((prog), (target), (type));        \
> > +		if (__ret == -1)                                               \
> > +			FAIL_ERRNO("prog_detach2(" #type ")");                 \
> > +		__ret;                                                         \
> > +	})
> 
> The above xbpf_prog_attach() and xbpf_prog_detach2()
> are only called once, maybe fold into the calling function itself?
> 

Sure.

Thanks,
John

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ