SELinux Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH testsuite] tests/Makefile: check if BPF library is installed
@ 2019-09-20 11:50 Ondrej Mosnacek
  2019-09-20 13:02 ` Stephen Smalley
  0 siblings, 1 reply; 3+ messages in thread
From: Ondrej Mosnacek @ 2019-09-20 11:50 UTC (permalink / raw)
  To: selinux

Check for the existence of the <bpf/bpf.h> header before enabling BPF
testing. Otherwise building the tests fails in an environment where
the kernel and policy support BPF, but the library is not installed.

Fixes: 8f0f980a4ad5 ("selinux-testsuite: Add BPF tests")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 tests/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/Makefile b/tests/Makefile
index e5bdfff..e8cf008 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -43,10 +43,12 @@ endif
 
 ifeq ($(shell grep -q bpf $(POLDEV)/include/support/all_perms.spt && echo true),true)
 ifneq ($(shell ./kvercmp $$(uname -r) 4.15),-1)
+ifneq (,$(wildcard $(INCLUDEDIR)/bpf/bpf.h))
 SUBDIRS += bpf
 export CFLAGS += -DHAVE_BPF
 endif
 endif
+endif
 
 ifeq ($(shell grep "^SELINUX_INFINIBAND_ENDPORT_TEST=" infiniband_endport/ibendport_test.conf | cut -d'=' -f 2),1)
 SUBDIRS += infiniband_endport
-- 
2.21.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH testsuite] tests/Makefile: check if BPF library is installed
  2019-09-20 11:50 [PATCH testsuite] tests/Makefile: check if BPF library is installed Ondrej Mosnacek
@ 2019-09-20 13:02 ` Stephen Smalley
  2019-09-20 19:29   ` Ondrej Mosnacek
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2019-09-20 13:02 UTC (permalink / raw)
  To: Ondrej Mosnacek, selinux, Richard Haines

On 9/20/19 7:50 AM, Ondrej Mosnacek wrote:
> Check for the existence of the <bpf/bpf.h> header before enabling BPF
> testing. Otherwise building the tests fails in an environment where
> the kernel and policy support BPF, but the library is not installed.
> 
> Fixes: 8f0f980a4ad5 ("selinux-testsuite: Add BPF tests")
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
>   tests/Makefile | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tests/Makefile b/tests/Makefile
> index e5bdfff..e8cf008 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -43,10 +43,12 @@ endif
>   
>   ifeq ($(shell grep -q bpf $(POLDEV)/include/support/all_perms.spt && echo true),true)
>   ifneq ($(shell ./kvercmp $$(uname -r) 4.15),-1)
> +ifneq (,$(wildcard $(INCLUDEDIR)/bpf/bpf.h))
>   SUBDIRS += bpf
>   export CFLAGS += -DHAVE_BPF
>   endif
>   endif
> +endif

I think Richard had something like this originally and I told him to 
take it out.  The rationale was that he added libbpf-devel as a required 
dependency to the README and we don't want to silently skip tests 
because someone forgot to install some package; I'd rather it fail at 
build time.

>   
>   ifeq ($(shell grep "^SELINUX_INFINIBAND_ENDPORT_TEST=" infiniband_endport/ibendport_test.conf | cut -d'=' -f 2),1)
>   SUBDIRS += infiniband_endport
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH testsuite] tests/Makefile: check if BPF library is installed
  2019-09-20 13:02 ` Stephen Smalley
@ 2019-09-20 19:29   ` Ondrej Mosnacek
  0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Mosnacek @ 2019-09-20 19:29 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: SElinux list, Richard Haines

On Fri, Sep 20, 2019 at 3:02 PM Stephen Smalley <sds@tycho.nsa.gov> wrote:
> On 9/20/19 7:50 AM, Ondrej Mosnacek wrote:
> > Check for the existence of the <bpf/bpf.h> header before enabling BPF
> > testing. Otherwise building the tests fails in an environment where
> > the kernel and policy support BPF, but the library is not installed.
> >
> > Fixes: 8f0f980a4ad5 ("selinux-testsuite: Add BPF tests")
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > ---
> >   tests/Makefile | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/tests/Makefile b/tests/Makefile
> > index e5bdfff..e8cf008 100644
> > --- a/tests/Makefile
> > +++ b/tests/Makefile
> > @@ -43,10 +43,12 @@ endif
> >
> >   ifeq ($(shell grep -q bpf $(POLDEV)/include/support/all_perms.spt && echo true),true)
> >   ifneq ($(shell ./kvercmp $$(uname -r) 4.15),-1)
> > +ifneq (,$(wildcard $(INCLUDEDIR)/bpf/bpf.h))
> >   SUBDIRS += bpf
> >   export CFLAGS += -DHAVE_BPF
> >   endif
> >   endif
> > +endif
>
> I think Richard had something like this originally and I told him to
> take it out.  The rationale was that he added libbpf-devel as a required
> dependency to the README and we don't want to silently skip tests
> because someone forgot to install some package; I'd rather it fail at
> build time.

OK, that makes sense. My motivation was the situation on RHEL-8, where
the kernel and policy matches the existing checks, but there is no
libbpf-devel available (not even in our internal repos or EPEL), but
there really doesn't seem to be any better way to handle that other
than excluding based on distro name/version. For now I'll just
conditionally exclude the test in our wrapper script. (There is a lot
of conditional tweaks already, I might try to upstream them one day so
that they are not split awkwardly between upstream and downstream...)

>
> >
> >   ifeq ($(shell grep "^SELINUX_INFINIBAND_ENDPORT_TEST=" infiniband_endport/ibendport_test.conf | cut -d'=' -f 2),1)
> >   SUBDIRS += infiniband_endport
> >
>

--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 11:50 [PATCH testsuite] tests/Makefile: check if BPF library is installed Ondrej Mosnacek
2019-09-20 13:02 ` Stephen Smalley
2019-09-20 19:29   ` Ondrej Mosnacek

SELinux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux/0 selinux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux selinux/ https://lore.kernel.org/selinux \
		selinux@vger.kernel.org
	public-inbox-index selinux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git