* [PATCH testsuite] tests/binder: Build only for 4.11 and later kernels
@ 2022-01-13 2:09 GONG, Ruiqi
2022-01-31 13:47 ` Ondrej Mosnacek
0 siblings, 1 reply; 3+ messages in thread
From: GONG, Ruiqi @ 2022-01-13 2:09 UTC (permalink / raw)
To: selinux
Cc: Wang Weiyang, Xiu Jianfeng, Xiang Yang, Cui Gaosheng, Lu Jialin,
Yi Yang, Gong Ruiqi
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.
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH testsuite] tests/binder: Build only for 4.11 and later kernels
2022-01-13 2:09 [PATCH testsuite] tests/binder: Build only for 4.11 and later kernels GONG, Ruiqi
@ 2022-01-31 13:47 ` Ondrej Mosnacek
2022-02-09 6:58 ` Gong Ruiqi
0 siblings, 1 reply; 3+ messages in thread
From: Ondrej Mosnacek @ 2022-01-31 13:47 UTC (permalink / raw)
To: GONG, Ruiqi
Cc: SElinux list, Wang Weiyang, Xiu Jianfeng, Xiang Yang,
Cui Gaosheng, Lu Jialin, Yi Yang
On Thu, Jan 13, 2022 at 2:48 AM GONG, Ruiqi <gongruiqi1@huawei.com> 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@huawei.com>
>
> ---
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH testsuite] tests/binder: Build only for 4.11 and later kernels
2022-01-31 13:47 ` Ondrej Mosnacek
@ 2022-02-09 6:58 ` Gong Ruiqi
0 siblings, 0 replies; 3+ messages in thread
From: Gong Ruiqi @ 2022-02-09 6:58 UTC (permalink / raw)
To: Ondrej Mosnacek
Cc: SElinux list, Wang Weiyang, Xiu Jianfeng, Xiang Yang,
Cui Gaosheng, Lu Jialin, Yi Yang
On 2022/01/31 21:47, Ondrej Mosnacek wrote:
> On Thu, Jan 13, 2022 at 2:48 AM GONG, Ruiqi <gongruiqi1@huawei.com> 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
>
Just came back to work from the long New Year holiday... Yeah it sounds
good. Checking the kernel header is a better solution indeed to avoid
overkill. I will prepare a new patch for this. Thx.
>> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
>>
>> ---
>> 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.
>
> .
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-09 6:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13 2:09 [PATCH testsuite] tests/binder: Build only for 4.11 and later kernels GONG, Ruiqi
2022-01-31 13:47 ` Ondrej Mosnacek
2022-02-09 6:58 ` Gong Ruiqi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.