From patchwork Tue Jun 6 16:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1791324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=wshAMV9V; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QbGdf3Zt9z20WK for ; Wed, 7 Jun 2023 02:48:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 553793858023 for ; Tue, 6 Jun 2023 16:48:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 553793858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686070132; bh=zfJDEJLHX2fHjfwtjRikxwK0Wu9vDKRnhVEYdVR6rFo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wshAMV9VbBNlg+sDjwbgIBMAxBGmfnaaxwAC0OPpDPNfNoUtO4jBmjKZ5E08l7vkR EtwmfbRjZQQlgJNBFU5UoQmj10fTn1ny7ly6tlmlbMOvMqmWwjyyvx9DLc8eysdIoG ZaAfI7P4fpBdo4jBibgHqOKWhWAwhS+KaXcTvjKI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id 66A02385802F for ; Tue, 6 Jun 2023 16:48:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66A02385802F Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-19f7e8f8e3bso3471443fac.3 for ; Tue, 06 Jun 2023 09:48:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686070115; x=1688662115; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zfJDEJLHX2fHjfwtjRikxwK0Wu9vDKRnhVEYdVR6rFo=; b=DyBRtd8YOqHdXdCsRnFBw1vq1YU6TKNT4LNMACnV1uHhK5Z2iHSns3ltXLlVAH/6LW T9o8I9UPESQOi+L+d3Q/lXZvqNB7+qViIKX0EapVy3W6c5QYkOu2olvSNfN3wb0rsLO4 YOKp1HnYeu5SiwDOtt95x3F4oh98d2vJV77aQ/O5Hw8AyDeRIxtGnGyKdF3VfuAEqWJT WCenMsYDonlN8do9JXbrzxvDp/4ONQEmMVOZYTASsggRcuTw2WprzmvveIMWlkDEorE2 j4SBPm8iGwn/Ndh9gsYu1usTJbKakviDr+AtKngOlY2iC9VQ6vDT4jpiOrNpjo7cmx3B Adkw== X-Gm-Message-State: AC+VfDzlJqXHSKE9rVFfBf1QVcCBkluQyJM6v29oZXM0yFKk+Zs+RK9Y EFR5vT3kbjjReEfVlILgN+bU/6lUCrMesv+Zpv+vPQ== X-Google-Smtp-Source: ACHHUZ7XBuWAQFoCyqk3jFxZmtAfM2n2moP8/2LwKLIjsmCxF1B9gwA1+9EahiTtculGIoIrP5kbJg== X-Received: by 2002:a05:6870:d2a9:b0:19f:2257:686d with SMTP id d41-20020a056870d2a900b0019f2257686dmr1460115oae.13.1686070114989; Tue, 06 Jun 2023 09:48:34 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:fe49:fdea:76b2:3604:b95d]) by smtp.gmail.com with ESMTPSA id s10-20020a056870628a00b0019f44a07b35sm4947688oan.51.2023.06.06.09.48.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 09:48:34 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] linux: Handle personality filtering for 32 bits Date: Tue, 6 Jun 2023 13:48:30 -0300 Message-Id: <20230606164830.126052-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Since commit e0043e17dfc52fe170274, 32 bit personality wrapper does not set errno because kernel default implementation always successfully changes the personality if requested (although some arch-specific implementations might return an error, like aarch64). However if syscall is being filtered (by a seccomp filter for instance) there is no way to distinguish a syscall error (INTERNAL_SYSCALL_ERROR_P) from a possible kernel value. So in this case just set the test as unsupported. --- sysdeps/unix/sysv/linux/tst-personality.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/tst-personality.c b/sysdeps/unix/sysv/linux/tst-personality.c index 5e59627826..79d9c607e1 100644 --- a/sysdeps/unix/sysv/linux/tst-personality.c +++ b/sysdeps/unix/sysv/linux/tst-personality.c @@ -34,10 +34,17 @@ do_test (void) if (r == -1) { /* The syscall argument might be filtered by kernel, so the - test can not check for the bug issue. */ + test can not check for the bug issue. For 32 bit architectures + the syscall wrapper also never sets the errno (check commit + e0043e17dfc52fe170274 for a full explanation), so in this case + there is no way to detected if the syscall is filtered. */ +#if __WORDSIZE == 32 + FAIL_UNSUPPORTED ("personality syscall argument are filtered"); +#else if (errno == EPERM) FAIL_UNSUPPORTED ("personality syscall argument are filtered"); FAIL_EXIT1 ("personality (%#x) failed: %m", test_persona); +#endif } TEST_COMPARE (r, saved_persona);