From patchwork Thu Jan 16 13:39:12 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: 37406 X-Patchwork-Delegate: fweimer@redhat.com Received: (qmail 109349 invoked by alias); 16 Jan 2020 13:39:18 -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 109338 invoked by uid 89); 16 Jan 2020 13:39:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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=HContent-Transfer-Encoding:8bit X-HELO: mx0a-001b2d01.pphosted.com From: "Lucas A. M. Magalhaes" To: libc-alpha@sourceware.org Cc: tuliom@linux.ibm.com Subject: [PATCH] Fix tst-pkey.c pkey_alloc return checks and manual Date: Thu, 16 Jan 2020 10:39:12 -0300 Message-Id: <20200116133912.2578-1-lamm@linux.ibm.com> MIME-Version: 1.0 This test was failing in some powerpc systems as it was not checking for ENOSPC return. As said on the Linux man-pages and can be observed by the implementation at mm/mprotect.c in the Linux Kernel source. The syscall pkey_alloc can return EINVAL or ENOSPC. ENOSPC will indicate either that all keys are in use or that the kernel does not support pkeys. Reviewed-by: Gabriel F. T. Gomes --- manual/memory.texi | 4 ++++ sysdeps/unix/sysv/linux/tst-pkey.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/manual/memory.texi b/manual/memory.texi index b565dd69f2..aa5011e4f9 100644 --- a/manual/memory.texi +++ b/manual/memory.texi @@ -3288,6 +3288,10 @@ in which memory protection keys are disabled. @item ENOSPC All available protection keys already have been allocated. + +The system does not implement memory protection keys or runs in a mode +in which memory protection keys are disabled. + @end table @end deftypefun diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c index 4c4fbae3ad..4ea1bc4f9a 100644 --- a/sysdeps/unix/sysv/linux/tst-pkey.c +++ b/sysdeps/unix/sysv/linux/tst-pkey.c @@ -197,6 +197,10 @@ do_test (void) if (errno == EINVAL) FAIL_UNSUPPORTED ("CPU does not support memory protection keys: %m"); + if (errno == ENOSPC) + FAIL_UNSUPPORTED + ("no keys available or kernel does not support memory" + " protection keys"); FAIL_EXIT1 ("pkey_alloc: %m"); } TEST_COMPARE (pkey_get (keys[0]), 0);