From patchwork Wed Oct 9 06:39:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1173605 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46p4MP68j5z9s7T for ; Wed, 9 Oct 2019 17:39:45 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 48F8D3C220E for ; Wed, 9 Oct 2019 08:39:43 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id 93A7D3C136E for ; Wed, 9 Oct 2019 08:39:40 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id ED485600E37 for ; Wed, 9 Oct 2019 08:38:22 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9CDEEAC40; Wed, 9 Oct 2019 06:39:37 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Wed, 9 Oct 2019 08:39:28 +0200 Message-Id: <20191009063928.27270-1-pvorel@suse.cz> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v3] pkeys: Fix uclibc build caused by conflicting signature X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Removing static fixes the problem. uClibc defines pkey_{alloc,free,mprotect} signatures in , which is included by . 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 Suggested-by: Jan Stancek Signed-off-by: Petr Vorel --- Changes v2->v3: * Fix build failure on #ifndef HAVE_PKEY_MPROTECT caused by some direct calls to pkey_* instead of using ltp_pkey_*. Sorry for the noise. Changes v1->v4: * Added ltp_ prefix and definitions instead simple removing static keyword (suggested by Jan). Kind regards, Petr 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"); }