Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1879611pxk; Sun, 13 Sep 2020 20:43:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9w6J+7R1VyeFUU1FOgYlLputLsvbJL5wv1yUO/pSVhyGyLY+MzEEchAWiltL/MoS+njiw X-Received: by 2002:a50:fc08:: with SMTP id i8mr15622104edr.257.1600055013017; Sun, 13 Sep 2020 20:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600055013; cv=none; d=google.com; s=arc-20160816; b=lJ4SzyezPVOHXq/d+uWhvKb74Z9B6naxl3PlJVEfxtA2OR0XKiE2QdJAcEEkC2FJv7 6L3I+RknsXWVznIGBBLXZZ9ysiTblTYBj9JA9tFMhJIhwKzPhvVR1ZgiFCrifJeDKPG+ EqMWeYOGOwkNuZLYk0vuVBAdH+jSTTKvSBipM00Z//Vk5l7y3fKg3sxHK0qAsqtyMI7t pw7NFERCWwFFzqHN2zrlFsS0pw40XOAyakXieqCfygc2zetpn2dPvcCjYLTeJWlA8lDv Em+zItarhUqWmc0211DRpTUbuxTzQAEvljcq+IxzF0BlOX7UBvL17XAZBZX580h21OHu iYuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=YIbWZuX+2VRVXsevs5ag3gBa+xMyJEe3QhN2NPVk/OM=; b=j6mUV+CbmYcbbHglCFz5GqdPEGi4VG9JGeZfrH/DDd7v1i/HXePTipPEod3IIpuhiC r6XRA2MZB4HFeeq7s+XtcFqeSrytxO+Rp2e0KEgb7yGoosgFvFDFpn6UNtqKZs8n87gp AO41yIrONgnPzZS8jIXkAJMluxWEK4E0QPTqEA4W7XMRRgjm7d57a70qHqNtaPzp1m24 QR7L+iEnvb4Kr+4TOM5jLTCqQFbpHcZuTD6THwhrOkiQQbGsbV7UWGMSE9+ug02wkeMn 1heDqjPtdgzwf62XmkdpDxpjJhvh1A8hqtBDZTrfR7nf8dwIDWH4ACoDP+QoWuJxvDQR teiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=ldhHUItJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si5987816ejf.3.2020.09.13.20.43.10; Sun, 13 Sep 2020 20:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=ldhHUItJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726071AbgINDit (ORCPT + 99 others); Sun, 13 Sep 2020 23:38:49 -0400 Received: from ozlabs.org ([203.11.71.1]:55859 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbgINDir (ORCPT ); Sun, 13 Sep 2020 23:38:47 -0400 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 Cc: Kees Cook , Thadeu Lima de Souza Cascardo , Max Filippov , Christian Brauner , Andy Lutomirski , Will Drewry , linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.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 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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