Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1518558pxk; Fri, 18 Sep 2020 15:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA/f5Y7RivLhalwwJaketD1q47tE1Ro1TOuqiG6MhGm7zHkovRNN4zMB0vBF+ZknJH5/P7 X-Received: by 2002:a50:d65e:: with SMTP id c30mr41196322edj.57.1600466565537; Fri, 18 Sep 2020 15:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600466565; cv=none; d=google.com; s=arc-20160816; b=m5Fv53Pa0pjN7BxUvBwgkySrck9pwfM6TEKOqB0AvmgpP3AO0sUtctYFnvBDlcWW29 yBSGMV5YtS+mmTTDysCKAZYQTZVLcL1X5YHPm1iA9sc2QMv49LSDJxJkE4rHr97UIxoI R6rDNAmGwEttf+aKTAnNd4G/D2n+Yi3mLTJm3Qsm2/0KNTR9faXrsxjWWZqn96L6LqPw qZjnEr7H92s2157GZAVVH5PnhxZAQSK1mrBeb65xqaee6updxVUdr3wVqGflyS46CCCV 8EjLkSgcZtGLJ2XgrptKcfnUqkx6x0vIraw8RG1aXETp9snXBn2Qg2aRphqhh84+5Aam ybPQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JxUdFoGAxFplTWGtoXNZgS71eI4uX7HGfO5ucGAc8lo=; b=NcmAX8AcnHLYng9qECU4jRTQrigdo5YVdNhTDPSyDhtTiFAGYsFljNHOWjgnsGcAxL m0Riu9aLFJCe2xGeYg5OaRAltIcFdL0IW2UTX6ro93wDbnlGoH5tGKP+y/euK7Zy/kd1 PcAhpfQlp9ztW0KN/pvhIMSTTGbXrboCrprcVmFq0lssQULJF0/Vex4sCwgRQf7X9q5x BHBNIXdayRwi74PKEr4qYJsUIAbH95WISlFMsQs31+XuOt6wRTufysPhY+TZU9b90hjY 8y8+g2qPXWhEujDV0JPnY3ItD0bLqzWhL7GZDWaxNFEAPrgsMgX+nEk5JJ2NScCrC/HH jk4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F3F4STQx; 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 p25si2979334ejw.682.2020.09.18.15.02.22; Fri, 18 Sep 2020 15:02:45 -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=F3F4STQx; 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 S1726262AbgIRWAu (ORCPT + 99 others); Fri, 18 Sep 2020 18:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgIRWAu (ORCPT ); Fri, 18 Sep 2020 18:00:50 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BAC2C0613CE for ; Fri, 18 Sep 2020 15:00:50 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g29so4256078pgl.2 for ; Fri, 18 Sep 2020 15:00:50 -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:content-transfer-encoding:in-reply-to; bh=JxUdFoGAxFplTWGtoXNZgS71eI4uX7HGfO5ucGAc8lo=; b=F3F4STQx9TEbezd5dpqkh+1WgHncbTN/t8oI9gLXFGTIZBF4umVMyWZs6/5SC4DPNe BdEswkxGJNvw8UKNxsjmhcgGCOWOfL+FnYmzid7dcH3dg8ENtuW1e1zau+x+4ZWOfwET oYzijV7/xANP6xFwAgQjhsqbAUPQauG787ODk= 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:content-transfer-encoding :in-reply-to; bh=JxUdFoGAxFplTWGtoXNZgS71eI4uX7HGfO5ucGAc8lo=; b=YRUlfKwoXrJdQCQrTZtOU/aPzOl1YzGf0HqBr6zMSGpAqpdlLqAguTkk0frg724rV6 KHpU76oSG7mxoUYxuwhoTm7JpefKj1xxq7qJy0haoYE1vW0rY3mWZZ6uXf2e3uEr/J6b m0AFPXljxGbN6Sj0IpkwJZGyrDp+v5s5MAQFfUxkw40ZnSnQ5bSMUytWW6H1133ulwMD wizsIrZ91mVvD/Q9L4nCDgqPjq2iIs6kfjr5yjN5dAIwwwBqfQoenmMJyHsW1B7u4jgi ZQS4AAbQqPXx4s92gARmxzKZaKjqr29SGySDEAsVgs2xDSmF2rVU0b65lUtMF3Xy+OvT 0A3g== X-Gm-Message-State: AOAM530Ca8aEPcN6el4dXN1rs0iWCKwt9BKXb0P2rnOwinDyncCyLDm5 nOS4ebabx511f4M9YhRz6j9dNA== X-Received: by 2002:a63:5b5c:: with SMTP id l28mr1381997pgm.243.1600466449680; Fri, 18 Sep 2020 15:00:49 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id v204sm4236125pfc.10.2020.09.18.15.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 15:00:48 -0700 (PDT) Date: Fri, 18 Sep 2020 15:00:48 -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 14/15] selftests/clone3: Avoid OS-defined clone_args Message-ID: <202009181500.9A560349@keescook> References: <20200912110820.597135-1-keescook@chromium.org> <20200912110820.597135-15-keescook@chromium.org> <20200915162528.x7admy45pdqsoke4@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200915162528.x7admy45pdqsoke4@wittgenstein> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 06:25:28PM +0200, Christian Brauner wrote: > 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 Hm, weird. > 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); > } Yeah, that has fewer down sides. I'll rework it. -- Kees Cook