kumquat-buildroot/package/ltp-testsuite/0002-pkeys-Fix-uclibc-build-caused-by-conflicting-signatu.patch
Petr Vorel fb4588d056 package/ltp-testsuite: update patch
0002-pkeys-Fix-uclibc-build-caused-by-conflicting-signatu.patch
(patch was accepted in a slightly different form)

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-10-13 22:45:09 +02:00

136 lines
4.9 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 5c3f08d31a4619454ef4db3501dbf2679867ba7f Mon Sep 17 00:00:00 2001
From: Petr Vorel <pvorel@suse.cz>
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
<bits/mman-shared.h>, which is included by <bits/mman-linux.h>. Because
it does not implement them, our implementation signature conflicts, as
it uses static. Add 'ltp_' prefix to our helper functions (suggested by Jan).
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")
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]
---
testcases/kernel/syscalls/pkeys/pkey.h | 15 ++++++++++-----
testcases/kernel/syscalls/pkeys/pkey01.c | 8 ++++----
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/testcases/kernel/syscalls/pkeys/pkey.h b/testcases/kernel/syscalls/pkeys/pkey.h
index d623244eb..3c1204978 100644
--- a/testcases/kernel/syscalls/pkeys/pkey.h
+++ b/testcases/kernel/syscalls/pkeys/pkey.h
@@ -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 @@
#endif
#ifndef HAVE_PKEY_MPROTECT
-static inline int pkey_mprotect(void *addr, size_t len, int prot, int pkey)
+inline int ltp_pkey_mprotect(void *addr, size_t len, int prot, int pkey)
{
return tst_syscall(__NR_pkey_mprotect, addr, len, prot, pkey);
}
-static inline int pkey_alloc(unsigned int flags, unsigned int access_rights)
+inline int ltp_pkey_alloc(unsigned int flags, unsigned int access_rights)
{
return tst_syscall(__NR_pkey_alloc, flags, access_rights);
}
-static inline int pkey_free(int pkey)
+inline int ltp_pkey_free(int pkey)
{
return tst_syscall(__NR_pkey_free, pkey);
}
+#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");
}
--
2.23.0