2019-10-12 23:19:11 +02:00
From 5c3f08d31a4619454ef4db3501dbf2679867ba7f Mon Sep 17 00:00:00 2001
From: Petr Vorel <pvorel@suse.cz>
2019-10-01 20:52:30 +02:00
Date: Tue, 1 Oct 2019 14:46:22 +0200
Subject: [PATCH] pkeys: Fix uclibc build caused by conflicting signature
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
uClibc defines pkey_{alloc,free,mprotect} signatures in
2019-10-12 23:19:11 +02:00
<bits/mman-shared.h>, which is included by <bits/mman-linux.h>. Because
2019-10-01 20:52:30 +02:00
it does not implement them, our implementation signature conflicts, as
2019-10-12 23:19:11 +02:00
it uses static. Add 'ltp_' prefix to our helper functions (suggested by Jan).
2019-10-01 20:52:30 +02:00
Fixed build error:
In file included from pkey01.c:32:0:
pkey.h:18:19: error: static declaration of ‘ pkey_mprotect’ follows non-static declaration
static inline int pkey_mprotect(void *addr, size_t len, int prot, int pkey)
^
In file included from /opt/br-test-pkg/br-arm-full/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/mman-linux.h:115:0,
from /opt/br-test-pkg/br-arm-full/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/mman.h:40,
from /opt/br-test-pkg/br-arm-full/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/mman.h:41,
from pkey01.c:29:
/opt/br-test-pkg/br-arm-full/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/mman-shared.h:73:5: note: previous declaration of ‘ pkey_mprotect’ was here
int pkey_mprotect (void *__addr, size_t __len, int __prot, int __pkey) __THROW;
^
In file included from pkey01.c:32:0:
Found with test-pkg tool from Buildroot distribution.
Fixes: 90c2dc89f ("pkey: add test for memory protection keys")
2019-10-12 23:19:11 +02:00
Reported-by: Petr Vorel <petr.vorel@gmail.com>
Suggested-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
[Upstream status: 5c3f08d31a4619454ef4db3501dbf2679867ba7f]
2019-10-01 20:52:30 +02:00
---
2019-10-12 23:19:11 +02:00
testcases/kernel/syscalls/pkeys/pkey.h | 15 ++++++++++-----
testcases/kernel/syscalls/pkeys/pkey01.c | 8 ++++----
2 files changed, 14 insertions(+), 9 deletions(-)
2019-10-01 20:52:30 +02:00
diff --git a/testcases/kernel/syscalls/pkeys/pkey.h b/testcases/kernel/syscalls/pkeys/pkey.h
2019-10-12 23:19:11 +02:00
index d623244eb..3c1204978 100644
2019-10-01 20:52:30 +02:00
--- a/testcases/kernel/syscalls/pkeys/pkey.h
+++ b/testcases/kernel/syscalls/pkeys/pkey.h
2019-10-12 23:19:11 +02:00
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2019 Red Hat, Inc.
+ * Copyright (c) Linux Test Project, 2019
*/
#ifndef PKEYS_H
@@ -15,25 +16,29 @@
2019-10-01 20:52:30 +02:00
#endif
#ifndef HAVE_PKEY_MPROTECT
-static inline int pkey_mprotect(void *addr, size_t len, int prot, int pkey)
2019-10-12 23:19:11 +02:00
+inline int ltp_pkey_mprotect(void *addr, size_t len, int prot, int pkey)
2019-10-01 20:52:30 +02:00
{
return tst_syscall(__NR_pkey_mprotect, addr, len, prot, pkey);
}
-static inline int pkey_alloc(unsigned int flags, unsigned int access_rights)
2019-10-12 23:19:11 +02:00
+inline int ltp_pkey_alloc(unsigned int flags, unsigned int access_rights)
2019-10-01 20:52:30 +02:00
{
return tst_syscall(__NR_pkey_alloc, flags, access_rights);
}
-static inline int pkey_free(int pkey)
2019-10-12 23:19:11 +02:00
+inline int ltp_pkey_free(int pkey)
2019-10-01 20:52:30 +02:00
{
return tst_syscall(__NR_pkey_free, pkey);
}
2019-10-12 23:19:11 +02:00
+#else
+#define ltp_pkey_alloc pkey_alloc
+#define ltp_pkey_free pkey_free
+#define ltp_pkey_mprotect pkey_mprotect
#endif /* HAVE_PKEY_MPROTECT */
static inline void check_pkey_support(void)
{
- int pkey = pkey_alloc(0, 0);
+ int pkey = ltp_pkey_alloc(0, 0);
if (pkey == -1) {
if (errno == ENOSYS)
@@ -44,7 +49,7 @@ static inline void check_pkey_support(void)
tst_brk(TCONF, "pkeys are not available for test");
}
- pkey_free(pkey);
+ ltp_pkey_free(pkey);
}
#endif /* PKEYS_H */
diff --git a/testcases/kernel/syscalls/pkeys/pkey01.c b/testcases/kernel/syscalls/pkeys/pkey01.c
index b6b7e5cba..fa84e71f3 100644
--- a/testcases/kernel/syscalls/pkeys/pkey01.c
+++ b/testcases/kernel/syscalls/pkeys/pkey01.c
@@ -157,12 +157,12 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
buffer = SAFE_MMAP(NULL, size, mpa->prot, mpa->flags, fd, 0);
- pkey = pkey_alloc(tc->flags, tc->access_rights);
+ pkey = ltp_pkey_alloc(tc->flags, tc->access_rights);
if (pkey == -1)
tst_brk(TBROK | TERRNO, "pkey_alloc failed");
tst_res(TINFO, "Set %s on (%s) buffer", tc->name, flag_to_str(mpa->flags));
- if (pkey_mprotect(buffer, size, mpa->prot, pkey) == -1)
+ if (ltp_pkey_mprotect(buffer, size, mpa->prot, pkey) == -1)
tst_brk(TBROK | TERRNO, "pkey_mprotect failed");
pid = SAFE_FORK();
@@ -189,7 +189,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
tst_res(TFAIL, "Child: %s", tst_strstatus(status));
tst_res(TINFO, "Remove %s from the buffer", tc->name);
- if (pkey_mprotect(buffer, size, mpa->prot, 0x0) == -1)
+ if (ltp_pkey_mprotect(buffer, size, mpa->prot, 0x0) == -1)
tst_brk(TBROK | TERRNO, "pkey_mprotect failed");
switch (mpa->prot) {
@@ -211,7 +211,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
SAFE_MUNMAP(buffer, size);
- if (pkey_free(pkey) == -1)
+ if (ltp_pkey_free(pkey) == -1)
tst_brk(TBROK | TERRNO, "pkey_free failed");
}
2019-10-01 20:52:30 +02:00
--
2.23.0