* [PATCH v2] selftests/seccomp: Get page size from sysconf
@ 2015-11-13 3:17 Bamvor Jian Zhang
[not found] ` <1447384671-17758-1-git-send-email-bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Bamvor Jian Zhang @ 2015-11-13 3:17 UTC (permalink / raw)
To: linux-api-u79uwXL29TY76Z2rM5mHXA
Cc: rsesek-hpIqsD4AKlfQT0dZR+AlfA, keescook-F7+t8E8rja9g9hUCZPvPmw,
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw, Bamvor Jian Zhang
The commit fd88d16c58c2 ("selftests/seccomp: Be more precise with
syscall arguments.") use PAGE_SIZE directly which lead to build
failure on arm64.
Replace it with generic interface(sysconf(_SC_PAGESIZE)) to fix this
failure.
Build and test successful on x86_64 and arm64.
Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
Add assertion for page_size.
tools/testing/selftests/seccomp/seccomp_bpf.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index e38cc54..882fe83 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -492,6 +492,9 @@ TEST_SIGNAL(KILL_one_arg_six, SIGSYS)
pid_t parent = getppid();
int fd;
void *map1, *map2;
+ int page_size = sysconf(_SC_PAGESIZE);
+
+ ASSERT_LT(0, page_size);
ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
ASSERT_EQ(0, ret);
@@ -504,16 +507,16 @@ TEST_SIGNAL(KILL_one_arg_six, SIGSYS)
EXPECT_EQ(parent, syscall(__NR_getppid));
map1 = (void *)syscall(sysno,
- NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, PAGE_SIZE);
+ NULL, page_size, PROT_READ, MAP_PRIVATE, fd, page_size);
EXPECT_NE(MAP_FAILED, map1);
/* mmap2() should never return. */
map2 = (void *)syscall(sysno,
- NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
+ NULL, page_size, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
EXPECT_EQ(MAP_FAILED, map2);
/* The test failed, so clean up the resources. */
- munmap(map1, PAGE_SIZE);
- munmap(map2, PAGE_SIZE);
+ munmap(map1, page_size);
+ munmap(map2, page_size);
close(fd);
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftests/seccomp: Get page size from sysconf
[not found] ` <1447384671-17758-1-git-send-email-bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-11-13 22:41 ` Kees Cook
2015-11-16 5:42 ` Michael Ellerman
2015-11-17 2:26 ` Shuah Khan
0 siblings, 2 replies; 4+ messages in thread
From: Kees Cook @ 2015-11-13 22:41 UTC (permalink / raw)
To: Shuah Khan; +Cc: Linux API, Robert Sesek, Bamvor Jian Zhang
On Thu, Nov 12, 2015 at 7:17 PM, Bamvor Jian Zhang
<bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> The commit fd88d16c58c2 ("selftests/seccomp: Be more precise with
> syscall arguments.") use PAGE_SIZE directly which lead to build
> failure on arm64.
>
> Replace it with generic interface(sysconf(_SC_PAGESIZE)) to fix this
> failure.
>
> Build and test successful on x86_64 and arm64.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Acked-by: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Shuah, can you please pull this for kselftest? It fixes arm64 after
Robert's changes.
Thanks!
-Kees
> ---
> Add assertion for page_size.
>
> tools/testing/selftests/seccomp/seccomp_bpf.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index e38cc54..882fe83 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -492,6 +492,9 @@ TEST_SIGNAL(KILL_one_arg_six, SIGSYS)
> pid_t parent = getppid();
> int fd;
> void *map1, *map2;
> + int page_size = sysconf(_SC_PAGESIZE);
> +
> + ASSERT_LT(0, page_size);
>
> ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
> ASSERT_EQ(0, ret);
> @@ -504,16 +507,16 @@ TEST_SIGNAL(KILL_one_arg_six, SIGSYS)
>
> EXPECT_EQ(parent, syscall(__NR_getppid));
> map1 = (void *)syscall(sysno,
> - NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, PAGE_SIZE);
> + NULL, page_size, PROT_READ, MAP_PRIVATE, fd, page_size);
> EXPECT_NE(MAP_FAILED, map1);
> /* mmap2() should never return. */
> map2 = (void *)syscall(sysno,
> - NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
> + NULL, page_size, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
> EXPECT_EQ(MAP_FAILED, map2);
>
> /* The test failed, so clean up the resources. */
> - munmap(map1, PAGE_SIZE);
> - munmap(map2, PAGE_SIZE);
> + munmap(map1, page_size);
> + munmap(map2, page_size);
> close(fd);
> }
>
> --
> 2.1.4
>
--
Kees Cook
Chrome OS Security
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftests/seccomp: Get page size from sysconf
2015-11-13 22:41 ` Kees Cook
@ 2015-11-16 5:42 ` Michael Ellerman
2015-11-17 2:26 ` Shuah Khan
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2015-11-16 5:42 UTC (permalink / raw)
To: Kees Cook, Shuah Khan; +Cc: Linux API, Robert Sesek, Bamvor Jian Zhang
On Fri, 2015-11-13 at 14:41 -0800, Kees Cook wrote:
> On Thu, Nov 12, 2015 at 7:17 PM, Bamvor Jian Zhang
> <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> > The commit fd88d16c58c2 ("selftests/seccomp: Be more precise with
> > syscall arguments.") use PAGE_SIZE directly which lead to build
> > failure on arm64.
> >
> > Replace it with generic interface(sysconf(_SC_PAGESIZE)) to fix this
> > failure.
> >
> > Build and test successful on x86_64 and arm64.
> >
> > Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Acked-by: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>
> Shuah, can you please pull this for kselftest? It fixes arm64 after
> Robert's changes.
Also works on powerpc with 64k pages.
Tested-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftests/seccomp: Get page size from sysconf
2015-11-13 22:41 ` Kees Cook
2015-11-16 5:42 ` Michael Ellerman
@ 2015-11-17 2:26 ` Shuah Khan
1 sibling, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2015-11-17 2:26 UTC (permalink / raw)
To: Kees Cook; +Cc: Linux API, Robert Sesek, Bamvor Jian Zhang, Shuah Khan
On 11/13/2015 03:41 PM, Kees Cook wrote:
> On Thu, Nov 12, 2015 at 7:17 PM, Bamvor Jian Zhang
> <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
>> The commit fd88d16c58c2 ("selftests/seccomp: Be more precise with
>> syscall arguments.") use PAGE_SIZE directly which lead to build
>> failure on arm64.
>>
>> Replace it with generic interface(sysconf(_SC_PAGESIZE)) to fix this
>> failure.
>>
>> Build and test successful on x86_64 and arm64.
>>
>> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Acked-by: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>
> Shuah, can you please pull this for kselftest? It fixes arm64 after
> Robert's changes.
>
Thanks for finding and fixing this. Applied to linux-kselftest fixes
for 4.4-rc2 with Kees's Ack.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-17 2:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 3:17 [PATCH v2] selftests/seccomp: Get page size from sysconf Bamvor Jian Zhang
[not found] ` <1447384671-17758-1-git-send-email-bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-11-13 22:41 ` Kees Cook
2015-11-16 5:42 ` Michael Ellerman
2015-11-17 2:26 ` Shuah Khan
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.