From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4F52C433E2 for ; Mon, 14 Sep 2020 03:40:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87B0E21655 for ; Mon, 14 Sep 2020 03:40:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jN7r0eul"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="ldhHUItJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87B0E21655 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/IEm7aq0xZ2L/LgX8x0CKJsuHBkrTD18SwUnlwUjxBw=; b=jN7r0eul+CAV7b/OOu/6N2T7l gyx0UKNyHdfvQ911Nhk+9gEpS3fqzNXgJ60+uulmYpjSFON/0BUq9j3maAeyNFwxkThb0yEPQ0iR/ rpls40euIIgjKcjXaFltv9rs6D+Wpr2EbyiG5LYnW+XPMnpYPL9zeemgIy1htD+Ht875DjadXlW0A VMqDmSPdCSLL14cUHhjR2j9NRIu3qfZhrGKjQPJ/6146xYokGjNHU20nT+Ul49L/sGxJH5NChOmGn XktAJUzzgYyomZCEqCAHoibds5/I3wuZ3gUJNwt7RmhJnNjDcuoJPLPPy6uL+aa4bvwycob/eANP5 iqKcjrhvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHfKR-0000bs-En; Mon, 14 Sep 2020 03:38:55 +0000 Received: from bilbo.ozlabs.org ([203.11.71.1] helo=ozlabs.org) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHfKO-0000Zr-IT for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 03:38:53 +0000 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4BqXC775j3z9sTR; Mon, 14 Sep 2020 13:38:43 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1600054725; bh=WSYInpRYBtYDkZHBmQQDThkXjUE9NyRyhjskGzBOWfs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ldhHUItJlbckAFthBQwfzljIGVNGGy6y4M98azT/BZOxPnqEu0BODf5RZB5v+neFy rfYyn3r+eDg/2K1P9lS394q3hoLl37t06b0X9b35e8/dI9bVMYm23lPi05FGhQ7z9C Isa7kMcyiKZXGtsXQ8iCTg4dFgEdseOX0NKSmqPPjBKZuU2R0y5THdXI4kFcpeqqCG d9HLOXJ7zYr60UdwFJbiXw5lvWWrzrQgPTwdbH6YQwaaS6Mj0MToJ89PrdSwxf2pYI 6G4p4fDMIRyX/oc9cmZAn2VP0PLlNIKOCMcSOPWOgPdN+35V1iqo6AYk3qv4Wct9/l Uga4UjBME7XXQ== From: Michael Ellerman To: Kees Cook , linux-kernel@vger.kernel.org Subject: Re: [PATCH 12/15] selftests/seccomp: powerpc: Fix seccomp return value testing In-Reply-To: <20200912110820.597135-13-keescook@chromium.org> References: <20200912110820.597135-1-keescook@chromium.org> <20200912110820.597135-13-keescook@chromium.org> Date: Mon, 14 Sep 2020 13:38:40 +1000 Message-ID: <87363lqb7j.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200913_233852_837920_128C5D6A X-CRM114-Status: GOOD ( 14.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thadeu Lima de Souza Cascardo , Will Drewry , Kees Cook , linux-xtensa@linux-xtensa.org, linux-mips@vger.kernel.org, Andy Lutomirski , Max Filippov , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Christian Brauner Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Kees Cook writes: > On powerpc, the errno is not inverted, and depends on ccr.so being > set. Add this to a powerpc definition of SYSCALL_RET_SET(). > > Co-developed-by: Thadeu Lima de Souza Cascardo > Signed-off-by: Thadeu Lima de Souza Cascardo > Link: https://lore.kernel.org/linux-kselftest/20200911181012.171027-1-cascardo@canonical.com/ > Fixes: 5d83c2b37d43 ("selftests/seccomp: Add powerpc support") > Signed-off-by: Kees Cook > --- > tools/testing/selftests/seccomp/seccomp_bpf.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) This looks right to me, and matches what strace does AFAICS. Reviewed-by: Michael Ellerman cheers > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 623953a53032..bbab2420d708 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -1750,6 +1750,21 @@ TEST_F(TRACE_poke, getpid_runs_normally) > # define ARCH_REGS struct pt_regs > # define SYSCALL_NUM(_regs) (_regs).gpr[0] > # define SYSCALL_RET(_regs) (_regs).gpr[3] > +# define SYSCALL_RET_SET(_regs, _val) \ > + do { \ > + typeof(_val) _result = (_val); \ > + /* \ > + * A syscall error is signaled by CR0 SO bit \ > + * and the code is stored as a positive value. \ > + */ \ > + if (_result < 0) { \ > + SYSCALL_RET(_regs) = -result; \ > + (_regs).ccr |= 0x10000000; \ > + } else { \ > + SYSCALL_RET(_regs) = result; \ > + (_regs).ccr &= ~0x10000000; \ > + } \ > + } while (0) > #elif defined(__s390__) > # define ARCH_REGS s390_regs > # define SYSCALL_NUM(_regs) (_regs).gprs[2] > -- > 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel