Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6176286ybx; Mon, 11 Nov 2019 05:10:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyKQjANwL/Sm6J7xa3s/b9mv7ytpoMI88ixHbHTG9BXoKGpffFK9CCPmWOA4MWKhBjSBJaW X-Received: by 2002:a17:906:22c9:: with SMTP id q9mr22544454eja.198.1573477816100; Mon, 11 Nov 2019 05:10:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573477816; cv=none; d=google.com; s=arc-20160816; b=E5nlXOnkOWKGnrFdQfwGzTyuWMCCjTgH1/3zHnuEbf/rcCL2z1vWJmL/i0lgiUYmBg 9yF9Wb8P+OVweYD7fU30p2ARxsqrnF7Sv8WYjNVy/jgJiXS65LL5Gtb34d/R7XLeCfSF j75Rk0Dg8JlEkU7ZuBS023hHpHb3CiN5h4Uf34/EEkmEysHCR0ZZT0jzFD+xKAe1wn5D Jy+4Eekmu1OkkabBsteCM/SSCM4OR5AoOZly+47Ct4JvcnrtLoKMfhAEZ7ZHiHzssgch DSJF5gxhwqw+5OBt7ckVJh+jEH/A8SDO0lq9kdFXC7XbsscLQCEBQeuq4dmUcC9iSnGX sq7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=DzBq2JeeHz9WxcGbwUpnFSm2KvcJD42Dv3YGZ9ap1R0=; b=vICK+D1GxdlSMDREneKpnKtDUDZMF9xkLCNhBi/5XP2CfEHEkTdklx9ofh1bGfBTvw TZi5SzeMc44gQtsNxhe9pybdWARzowcKEmkE+SPdiYWIfetBAv1YDnQcWWSBSsv/oXru 9ePpzJvUXGzrJcRZrFxjshpiNZiHWy5uvQjfMMdUUpfviRQUJJgDObgz75fKuTvpy1Vv EuhdvakhzxvZ6U1CNoSPsBncMf0c0rz9KKqB92rWNFrmTxu/C5xQy66Zd8Dcbtj9jb0y lorcZOlpFbfnt/IvqC7R3EJyiDeFQbzRkOcYbbId3+TIedWs9cddYqcOKJv78/XQajSA 3uyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si11194268ede.61.2019.11.11.05.09.51; Mon, 11 Nov 2019 05:10:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726965AbfKKNHc (ORCPT + 99 others); Mon, 11 Nov 2019 08:07:32 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:48675 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726843AbfKKNHc (ORCPT ); Mon, 11 Nov 2019 08:07:32 -0500 Received: from p54ac5540.dip0.t-ipconnect.de ([84.172.85.64] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iU9Pk-0002a2-Cn; Mon, 11 Nov 2019 13:07:28 +0000 Date: Mon, 11 Nov 2019 14:07:27 +0100 From: Christian Brauner To: Adrian Reber Cc: Shuah Khan , Eugene Syromiatnikov , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] selftests: add tests for clone3() Message-ID: <20191111130726.ccr6c663r6bre67x@wittgenstein> References: <20191108185629.309414-1-areber@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191108185629.309414-1-areber@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 08, 2019 at 07:56:29PM +0100, Adrian Reber wrote: > +static void test_clone3(uint64_t flags, size_t size, int expected, > + enum test_mode test_mode) > +{ > + int ret; > + > + ksft_print_msg( > + "[%d] Trying clone3() with flags %#" PRIx64 " (size %zu)\n", > + getpid(), flags, size); > + ret = call_clone3(flags, size, test_mode); > + ksft_print_msg("[%d] clone3() with flags says: %d expected %d\n", > + getpid(), ret, expected); > + if (ret != expected) > + ksft_test_result_fail( > + "[%d] Result (%d) is different than expected (%d)\n", > + getpid(), ret, expected); > + else > + ksft_test_result_pass( > + "[%d] Result (%d) matches expectation (%d)\n", > + getpid(), ret, expected); > +} > +int main(int argc, char *argv[]) Nit: missing \n between } and int main(). I'll just fix that up myself. > + /* > + * Do a clone3() with sizeof(struct clone_args) + 8 > + * and all members set to 0. This resets exit_signal and wait() > + * will not get a result. That comment is not true and now also misleading since you now pass _WALL to waitpid() above. I'll just remove it when applying. > + */ > + test_clone3(0, sizeof(struct clone_args) + 8, 0, CLONE3_ARGS_ALL_0); > + > + /* Do a clone3() with > page size */ > + test_clone3(0, getpagesize() + 8, -E2BIG, CLONE3_ARGS_NO_TEST); > + > + /* Do a clone3() with CLONE3_ARGS_SIZE_V0 in a new PID NS. */ > + if (uid == 0) > + test_clone3(CLONE_NEWPID, CLONE3_ARGS_SIZE_V0, 0, > + CLONE3_ARGS_NO_TEST); > + else > + ksft_test_result_skip("Skipping clone3() with CLONE_NEWPID\n"); > + > + /* Do a clone3() with CLONE3_ARGS_SIZE_V0 - 8 in a new PID NS */ > + test_clone3(CLONE_NEWPID, CLONE3_ARGS_SIZE_V0 - 8, -EINVAL, > + CLONE3_ARGS_NO_TEST); > + > + /* Do a clone3() with sizeof(struct clone_args) + 8 in a new PID NS */ > + if (uid == 0) > + test_clone3(CLONE_NEWPID, sizeof(struct clone_args) + 8, 0, > + CLONE3_ARGS_NO_TEST); So there's a missing test condition here, no? I've just realized you're passing in sizeof(struct clone_args) + 8 which hits the first excess space 64 bit value which is 0. That's good and the reason why this test passes. But I don't see any test for sizoef(struct clone_args_extended) or at least sizeof(struct clone_args) + 16 such that you actually hit the second 64 bit integer which is initialized to 1 and thus clone3() should fail with -E2BIG.If I haven't overlooked this test, can you please add it? It's quite important since it's a different codepath than the sizeof(PAGE_SIZE) + 8 codepath. Thanks! Christian