Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3286454pxk; Tue, 15 Sep 2020 15:23:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIpLRaSOlHCcSXlM9Z3VO/suuAMfYR/4WG4kJCSp+BDErBzts84g+iQyFGKhvGz/e/1zc+ X-Received: by 2002:a05:6402:2c3:: with SMTP id b3mr24710788edx.213.1600208636642; Tue, 15 Sep 2020 15:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600208636; cv=none; d=google.com; s=arc-20160816; b=blfqJmQN0cVSbA6lk+kaFIBKo2sadZVGSJ4vRxkdv2tNaBde/euMayKpli0gsJ7C9O h1YdEADO3w/LR3Ca/SHnEo7I9VX1XsNdpPt2dSQfqwBGsj8Nc7y83pT6Fr33388KvShS DqEYf65H498Yh2q7xuOD/urC5jdFkjlloXZLIGqvuZesEMK0CIt5U/G+lXnYQEPj9Coo UQ2zcF4bX3YQKAip3lkRVww8EmNs/Y6ZsZZk6syLXQJLVL62l33OlD5szsuxp0xgtenT dmsEoUOkawwCMwnvgvWQjaIOZAj2IDFEv8wdgsWHhalOf6Y3sih0KN16tRlwj4xtZIv4 YmkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=VFxTXu0P355CoGb1vKNNnPv1QeZEKPKZS8czGGGIWD8=; b=WMF3w/SxhPEM/gzOgiS1wVBCInGKzul4EZL9hfSX1Z1c18Y2Vwl/7ewrcJRB5FPMDa /pAqFu1CVC1YsPL5ZyooIyAMlLRmAxigcYrMZraP4+giG5DF25PkhVRmOPlZjNozvCos 1QZ6mUKk5EzfntCbqbdab2lcR681hxEJO32Cr0RHqz2wmzMAXXoQ3nyxCZMY5FcBrrF0 LeVUb6xw/IMlrwIHfrwanxK33ZqdL6qs8NFvog0L97xj5S0t+RaUZedIfrf95ejtHymc WwXAZwawUd27JM609xPVIn+5j1X67BdENnAYdsjj+stAWE0z7VddPXlopUsDe+EYCnaG j4ZA== ARC-Authentication-Results: i=1; mx.google.com; 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 cb13si6503364edb.153.2020.09.15.15.23.33; Tue, 15 Sep 2020 15:23:56 -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; 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 S1727674AbgIOWW1 (ORCPT + 99 others); Tue, 15 Sep 2020 18:22:27 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:49633 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727681AbgIOQ0Z (ORCPT ); Tue, 15 Sep 2020 12:26:25 -0400 Received: from ip5f5af089.dynamic.kabel-deutschland.de ([95.90.240.137] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kIDlp-0008Gy-Hv; Tue, 15 Sep 2020 16:25:29 +0000 Date: Tue, 15 Sep 2020 18:25:28 +0200 From: Christian Brauner To: Kees Cook 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 14/15] selftests/clone3: Avoid OS-defined clone_args Message-ID: <20200915162528.x7admy45pdqsoke4@wittgenstein> References: <20200912110820.597135-1-keescook@chromium.org> <20200912110820.597135-15-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200912110820.597135-15-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 12, 2020 at 04:08:19AM -0700, Kees Cook wrote: > As the UAPI headers start to appear in distros, we need to avoid > outdated versions of struct clone_args to be able to test modern > features. Additionally pull in the syscall numbers correctly. > > Signed-off-by: Kees Cook > --- Hm, with this patch applied I'm getting: gcc -g -I../../../../usr/include/ clone3_set_tid.c /home/brauner/src/git/linux/linux/tools/testing/selftests/kselftest_harness.h /home/brauner/src/git/linux/linux/tools/testing/selftests/kselftest.h -lcap -o /home/brauner/src/git/linux/linux/tools/testing/selftests/clone3/clone3_set_tid In file included from clone3_set_tid.c:24: clone3_selftests.h:37:8: error: redefinition of ‘struct clone_args’ 37 | struct clone_args { | ^~~~~~~~~~ In file included from clone3_set_tid.c:12: /usr/include/linux/sched.h:92:8: note: originally defined here 92 | struct clone_args { | ^~~~~~~~~~ make: *** [../lib.mk:140: /home/brauner/src/git/linux/linux/tools/testing/selftests/clone3/clone3_set_tid] Error 1 One trick to avoid this could be: #ifndef CLONE_ARGS_SIZE_VER0 #define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */ #endif #ifndef CLONE_ARGS_SIZE_VER1 #define CLONE_ARGS_SIZE_VER1 80 /* sizeof second published struct */ #endif #ifndef CLONE_ARGS_SIZE_VER2 #define CLONE_ARGS_SIZE_VER2 88 /* sizeof third published struct */ #endif struct __clone_args { __aligned_u64 flags; __aligned_u64 pidfd; __aligned_u64 child_tid; __aligned_u64 parent_tid; __aligned_u64 exit_signal; __aligned_u64 stack; __aligned_u64 stack_size; __aligned_u64 tls; __aligned_u64 set_tid; __aligned_u64 set_tid_size; __aligned_u64 cgroup; }; static pid_t sys_clone3(struct __clone_args *args, size_t size) { return syscall(__NR_clone3, args, size); } Christian