From patchwork Fri Feb 14 20:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucas A. M. Magalhaes" X-Patchwork-Id: 1238347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109779-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48K53Y5D4Lz9sVM for ; Sat, 15 Feb 2020 07:44:57 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=MvhGicQxYg/wZnpoPqy4PrPiFoTULC3D0FHqnUJDBUoh2EB/zMmZq o2Zq9TVnR9jie2FS91Kiqr+R9giWME3Zim6p6vacTt9UJS1HpShuYFQ/cjMXJb21 /DIvkka8i3mu2kq3vB2qbn5Vxrh9hMoUSD8a2PDZ4pEAdhvsKuNv1k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=/yatkeSdpZlHKDPWjSQUYe43DH0=; b=s+WUyDlLR+OlUDr4fuc2BQkwbfoh oYVno8v45XCj4sseVGFjUWIBdzW2CdLOYGPpS1o+oLOcxfEZez44B3yMJzmdWXv4 THwDDou02iNkdqymJn0SlTQV/Q3ypVOUW+FUYkXNRHjJe7Si2ojGeIhv4XpSQL4u sRgZQEfYQUHxNHg= Received: (qmail 1199 invoked by alias); 14 Feb 2020 20:44:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 1188 invoked by uid 89); 14 Feb 2020 20:44:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2158 X-HELO: mx0a-001b2d01.pphosted.com From: "Lucas A. M. Magalhaes" To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH v3] Fix tst-pkey expectations on pkey_get [BZ #23202] Date: Fri, 14 Feb 2020 17:44:42 -0300 Message-Id: <20200214204442.2963-1-lamm@linux.ibm.com> In-Reply-To: <20200213184157.16778-1-lamm@linux.ibm.com> References: <20200213184157.16778-1-lamm@linux.ibm.com> MIME-Version: 1.0 From the GNU C Library manual the pkey_set can receive a combination of PKEY_DISABLE_WRITE and PKEY_DISABLE_ACCESS. However PKEY_DISABLE_ACCESS is more restrictive than PKEY_DISABLE_WRITE and includes its behavior. The test expects that after setting (PKEY_DISABLE_WRITE|PKEY_DISABLE_ACCESS) pkey_get should return the same. This may not be true as PKEY_DISABLE_ACCESS will succeed in describe the state of the key in this case. The pkey behavior during signal handling is different between x86 and POWER. This change make the test compatible with both architectures. --- Hi, This test still needs the patch on the link to work on POWER. https://sourceware.org/ml/libc-alpha/2018-05/msg00760.html in V3: - Commit message changes. - Add comments. in V2: - Fix signal handling expectations to accept x86 and POWER behavior. sysdeps/unix/sysv/linux/tst-pkey.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c index 4ea1bc4f9a..34a4d890b5 100644 --- a/sysdeps/unix/sysv/linux/tst-pkey.c +++ b/sysdeps/unix/sysv/linux/tst-pkey.c @@ -37,7 +37,7 @@ static pthread_barrier_t barrier; /* The keys used for testing. These have been allocated with access rights set based on their array index. */ -enum { key_count = 4 }; +enum { key_count = 3 }; static int keys[key_count]; static volatile int *pages[key_count]; @@ -111,14 +111,16 @@ check_page_access (int page, bool write) } static volatile sig_atomic_t sigusr1_handler_ran; - -/* Used to check that access is revoked in signal handlers. */ +/* Used to check the behavior in signal handlers. In x86 all access are +revoked during signal handling. Otherwise in PowerPC the key will hold it's +permissions. This test accepts both approaches. */ static void sigusr1_handler (int signum) { TEST_COMPARE (signum, SIGUSR1); for (int i = 0; i < key_count; ++i) - TEST_COMPARE (pkey_get (keys[i]), PKEY_DISABLE_ACCESS); + TEST_VERIFY (pkey_get (keys[i]) == PKEY_DISABLE_ACCESS + || pkey_get (keys[i]) == i); sigusr1_handler_ran = 1; }