On Thu, Jan 13, 2022 at 2:48 AM GONG, Ruiqi <gongruiqi1@xxxxxxxxxx> wrote: > Following compilation errors occur when building the tests with > userspace headers exported from kernel 4.4: > > binder_common.c:111:14: error: ‘const struct flat_binder_object’ has no > member named ‘hdr’ > switch (obj->hdr.type) { > ^ > client.c:58:9: error: dereferencing pointer to incomplete type > if (obj->hdr.type != BINDER_TYPE_FD) { > ^ > > It's been checked that member `hdr` of `struct flat_binder_object` and > `struct binder_fd_object` were both introduced by commit feba3900cabb > ("binder: Split flat_binder_object") in kernel v4.11-rc1. Fix this > by adding kernel version check at compile time. Sorry for the late reaction... In a corner case, one might be on a system where the kernel UAPI headers don't match the running kernel version 100%, so I'd prefer to grep the header for 'struct binder_fd_object' over a kernel version check here. In this case the actual ABI is the same before and after the kernel commit, so it makes sense to only check if we have a <linux/android/binder.h> that we can compile against. Something like: ifeq ($(shell grep -q 'struct binder_fd_object' $(INCLUDEDIR)/linux/android/binder.h && echo true),true) ... endif > Signed-off-by: GONG, Ruiqi <gongruiqi1@xxxxxxxxxx> > > --- > tests/Makefile | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tests/Makefile b/tests/Makefile > index 3f7cae3..22458a7 100644 > --- a/tests/Makefile > +++ b/tests/Makefile > @@ -54,8 +54,10 @@ SUBDIRS += prlimit > endif > > ifeq ($(shell grep -q binder $(POLDEV)/include/support/all_perms.spt && test -e $(INCLUDEDIR)/linux/android/binder.h && echo true),true) > +ifneq ($(shell ./kvercmp $$(uname -r) 4.11),-1) > SUBDIRS += binder > endif > +endif > > ifeq ($(shell grep -q bpf $(POLDEV)/include/support/all_perms.spt && echo true),true) > ifneq ($(shell ./kvercmp $$(uname -r) 4.15),-1) > -- > 2.17.1 > -- Ondrej Mosnacek Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.