Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1518179pxk; Fri, 18 Sep 2020 15:02:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUQn6R6NyTSFZp7djO5598ohu4TsnTdpyQ+bPJyNud77J1KTxdbKVFhx1oFPI8/tXEcZAL X-Received: by 2002:a17:906:a00d:: with SMTP id p13mr39348072ejy.535.1600466527393; Fri, 18 Sep 2020 15:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600466527; cv=none; d=google.com; s=arc-20160816; b=jbB9QE5LjHrw1jt7M82lI3aMwRcQIfGKym2s/flgt+jwNwxDl6ncqivQKKyezRqOmL QeBAXhp6DWqbeYlqCH3L4hSRZV4jmxqLC+fxuE6BgEI3h7+SwJv7YqXvIjTw1SNjjIMQ 5aMcKkpN9xbGVTqXvYND0/vShjvNiqZgNLB5CCai6+PY58T3mJdNE4sZzVw/bQsMHK69 zVNocPYBULRYXYGE79fAwhOOrqikD5dY9R8pl9ZwCPyqIBzKYPr/MwQOQKKCKIyR5oVY iHEljhToa0ao2wRXjaWrQGrh2/qysY2MU/1sSLNsRM1AbJzxmeSc5JoWuu0rquTv3fZg YKrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pJBH8ZPv0AF6T9qJPivtnFQaJz8js4rTDIDjnmZyXeI=; b=lmNLk3OsQoqxxrOtJh66CRDvfLaOHEzVZdLezCIilElEL7eOKkfjJD56Ag5Mizuqf3 2juxFL84G2V7SrAwtg9wJphYIxAVyuiL//vZq6Cu62oVwqNfaEKFjIrZumnZjoW36erh YxYOnShGy2kuEcgFYnZXNL/8azcD5NKutnDPAhkJlWfoNIi9rb6pNjmpWDX5SQVhI6FP 1Sl0qCgjOQKzYY4/Rgbon/y1fb4Zji6yoSYzxHYgZuQcy0uFBcia0xZo6+tH1Xsxr1W4 jp0OUgxlcN+OGFUhhpLP14+98OdfXAihoY7TzSNy2d972ecFROPc1hmdLeKQR3RSafEz 9k5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dloeuJ4R; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si3283167edr.538.2020.09.18.15.01.42; Fri, 18 Sep 2020 15:02:07 -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=@chromium.org header.s=google header.b=dloeuJ4R; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726218AbgIRWAD (ORCPT + 99 others); Fri, 18 Sep 2020 18:00:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgIRWAD (ORCPT ); Fri, 18 Sep 2020 18:00:03 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 619E9C0613CF for ; Fri, 18 Sep 2020 15:00:03 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id j34so4237911pgi.7 for ; Fri, 18 Sep 2020 15:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pJBH8ZPv0AF6T9qJPivtnFQaJz8js4rTDIDjnmZyXeI=; b=dloeuJ4RhaMSkvzvysZ/KZ60uKiixW7yqpP4zHkEBZEOj0pCe6aPREHiRMfjC9a2sT NDRDXB+ZvN5NCDfLObc3yaHXCoMy1bgChNi0/bDSzXyKsXtqJdhEsyrk6Y1YRocaD3Wu iLl7HHFzt9nFe0Yx0aT6Ga95BI79loU3yy9TA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pJBH8ZPv0AF6T9qJPivtnFQaJz8js4rTDIDjnmZyXeI=; b=WluE+Fuzs/zqs5nf0WLlXZ+815uJbckO7bSOXvlri49+wRHsihMgdVnHT1eTlh4hIw zuUFkXkT8jSQkA8E/wnO3/K3XF7+iX+2555HlW/ZtEvNy9E/9sm/rBXAzopbQCo7C0kN XSDb0mexyePh4zwR7gNvp0P6ZCdKBmMG5GBZNJKgn8Zf3BMuO+DeUgtdquaej7SrnwjR /yP/NjUaktlboyTLAbYiqbJe7gXaVUUP3UQtSou8+SmhdKAuy9N9+2WicYxHWVb4pkvH BHmkXCpULGxkw65lP1SawGDVr89HuRMIOGp7hCEC+tEV76/5/r2f0LOImbwFgnS8YLYG tj0A== X-Gm-Message-State: AOAM530K86OPXw91+2TtrLX/+iWlKEjy/yMy8fOEa3liYstj9aVIJltZ wqIoDyuGhkMWUpK7S0XEmZvE1w== X-Received: by 2002:a63:4d48:: with SMTP id n8mr29596199pgl.70.1600466402906; Fri, 18 Sep 2020 15:00:02 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l14sm3727747pjy.1.2020.09.18.15.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 15:00:02 -0700 (PDT) Date: Fri, 18 Sep 2020 15:00:01 -0700 From: Kees Cook To: Christian Brauner Cc: linux-kernel@vger.kernel.org, Thadeu Lima de Souza Cascardo , Max Filippov , Michael Ellerman , 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 03/15] selftests/seccomp: mips: Define SYSCALL_NUM_SET macro Message-ID: <202009181459.C22A1EC7@keescook> References: <20200912110820.597135-1-keescook@chromium.org> <20200912110820.597135-4-keescook@chromium.org> <20200915155546.ht4vo7nqswxrgymb@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200915155546.ht4vo7nqswxrgymb@wittgenstein> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 05:55:46PM +0200, Christian Brauner wrote: > On Sat, Sep 12, 2020 at 04:08:08AM -0700, Kees Cook wrote: > > Remove the mips special-case in change_syscall(). > > > > Signed-off-by: Kees Cook > > --- > > tools/testing/selftests/seccomp/seccomp_bpf.c | 17 +++++++++-------- > > 1 file changed, 9 insertions(+), 8 deletions(-) > > > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > > index 1c83e743bfb1..02a9a6599746 100644 > > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > > @@ -1742,6 +1742,13 @@ TEST_F(TRACE_poke, getpid_runs_normally) > > # define ARCH_REGS struct pt_regs > > # define SYSCALL_NUM(_regs) (_regs).regs[2] > > # define SYSCALL_SYSCALL_NUM regs[4] > > +# define SYSCALL_NUM_SET(_regs, _nr) \ > > + do { \ > > + if ((_regs).regs[2] == __NR_O32_Linux) \ > > + (_regs).regs[4] = _nr; \ > > + else \ > > + (_regs).regs[2] = _nr; \ > > + } while (0) > > I think that > > # define SYSCALL_NUM_SET(_regs, _nr) \ > do { \ > if (SYSCALL_NUM(_regs) == __NR_O32_Linux) \ > (_regs).regs[4] = _nr; \ > else \ > (_regs).regs[2] = _nr; \ > } while (0) > > would read better but that's just a matter of taste. :) That's how I started originally, but when I realized that I'd have to reorganize SYSCALL_NUM() too, it seem best to have minimal churn, so I left it open coded here, since that's how it needs to be in the end. > Looks good! > Acked-by: Christian Brauner Thanks for the reviews! -- Kees Cook