Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2208706rdd; Fri, 12 Jan 2024 02:46:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPhc3mrMTSWutKPdiiohcjaR8HZ/Y1cmrCf6Aqu/fGKud9AfgeuhtRb3u1MfFIiEj6oBgF X-Received: by 2002:a17:902:d545:b0:1d3:edd9:1f13 with SMTP id z5-20020a170902d54500b001d3edd91f13mr1139621plf.67.1705056374492; Fri, 12 Jan 2024 02:46:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705056374; cv=none; d=google.com; s=arc-20160816; b=y5Wrr6x3hkByGvSZoLCiIHRAqU3W47IxaUtPaIcyZOrGzB5bTQSDtDb+PpPn98Mzt5 rlMEkX3PdC7wvKT0wODpTOuaMFWB2bRQc6wqqSpMy/v0ffKqUFrB/xYEJzZqc0opO34K zsV+IuMu9bSNrG7rdoU3XM1sxz3G2JZLVo3IkDkoNQXLgG8m3bTPMB6zW47wOV1OWBrg jPMLotO/9Mn8rVS2Nar1P4CY4M3Q/o7MjL2nw0S79vIBCLhX3nl2+5k2o0QueVS+giFF /8w85sBp9R/wp+2TCQWgqCwFqsoItVYGxRWelZYic0lyf4iaf0/H6sun0fb7oCyP5Sbw ioOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YWVp05nioglp06ybhnoorVf99MA+B3utPPGLrf/cX8Y=; fh=/Qa4Uk+KNtBefIAVqp5G8oXskUlioTEzO5DzZrHpy64=; b=gq1l1wTG+n/QHazMeyKYbxPoPcKVG1S8vLgQiPtB+cY+Fg0FbY2+2yTDlyzQJ1tHrJ UWeoKJTV0eMfOBx1WkdgPSKkVPJ6eZXfkd4ORvPZtbNK6gEBhBOQcORuFPsjQDvgmtk6 F+xaoWKiNtZ+6fGflYc6hF4y2HkEMg5mMBxbyfXyqblVvZErscK+IJOSeH1m4w5ERH2i LOEYSRPz5V53qIbQpXp83x75VkEFhjMe7T731zSoP089lHAeyBmxaYppt1DCm/1Q4RBm 0JBqfx/OZOqIwJYnmXSmv95uvXtkd06lQ1wkG6XncCIeJH9iCVVygAWfnZlTYrRfQDOZ 9+UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@digikod.net header.s=20191114 header.b=B5Q4g6J+; spf=pass (google.com: domain of linux-kernel+bounces-24595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24595-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i15-20020a17090332cf00b001d4af53a8edsi3213821plr.340.2024.01.12.02.46.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 02:46:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@digikod.net header.s=20191114 header.b=B5Q4g6J+; spf=pass (google.com: domain of linux-kernel+bounces-24595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24595-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 244F5287C66 for ; Fri, 12 Jan 2024 10:46:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3865C5B5D7; Fri, 12 Jan 2024 10:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="B5Q4g6J+" Received: from smtp-bc0b.mail.infomaniak.ch (smtp-bc0b.mail.infomaniak.ch [45.157.188.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB6AA58225; Fri, 12 Jan 2024 10:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-2-0001.mail.infomaniak.ch (unknown [10.5.36.108]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4TBJ9H14c2zMrVlh; Fri, 12 Jan 2024 10:45:55 +0000 (UTC) Received: from unknown by smtp-2-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4TBJ9F6wTHzMpnPg; Fri, 12 Jan 2024 11:45:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1705056355; bh=0Xtl3exMkr4Vgw7Wdk8vaxK8FVOPw6r5Xm7224/uacI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B5Q4g6J+O2tyneb1iQmU5aC28ekvXJiODUBdbxXp+reDFQO06bkLNdDqy1wvR8lKA 1rp03Ctp7sl++jxkF95VZibIwOecuro7KatD9sJFp3vjMqfmAJKLNu5sfw2rZ9T7im gdFDZizKF9Xmyeah3V0Utlwp7/5nodNRDU0gk5bI= Date: Fri, 12 Jan 2024 11:45:52 +0100 From: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= To: Hu Yadi Cc: jmorris@namei.org, serge@hallyn.com, shuah@kernel.org, mathieu.desnoyers@efficios.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, 514118380@qq.com, Konstantin Meskhidze Subject: Re: [PATCH v3] selftests/landlock:Fix two build issues Message-ID: <20240112.mixei4sei0Pi@digikod.net> References: <20240112071245.669-1-hu.yadi@h3c.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240112071245.669-1-hu.yadi@h3c.com> X-Infomaniak-Routing: alpha On Fri, Jan 12, 2024 at 03:12:45PM +0800, Hu Yadi wrote: > From: "Hu.Yadi" > > Two issues comes up while building selftest/landlock on my side > (gcc 7.3/glibc-2.28/kernel-4.19) > > the first one is as to gettid > > net_test.c: In function ‘set_service’: > net_test.c:91:45: warning: implicit declaration of function ‘gettid’; [-Wimplicit-function-declaration] > "_selftests-landlock-net-tid%d-index%d", gettid(), > ^~~~~~ > getgid > net_test.c:(.text+0x4e0): undefined reference to `gettid' > > the second is compiler error > gcc -Wall -O2 -isystem fs_test.c -lcap -o selftests/landlock/fs_test > fs_test.c:4575:9: error: initializer element is not constant > .mnt = mnt_tmp, > ^~~~~~~ > > this patch is to fix them > > Signed-off-by: Hu.Yadi > Suggested-by: Jiao > Reviewed-by: Berlin > --- > Changes v3 -> v2: > - add helper of gettid instead of __NR_gettid > - add gcc/glibc version info in comments > Changes v1 -> v2: > - fix whitespace error > - replace SYS_gettid with _NR_gettid > > tools/testing/selftests/landlock/fs_test.c | 5 ++++- > tools/testing/selftests/landlock/net_test.c | 9 +++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c > index 18e1f86a6234..a992cf7c0ad1 100644 > --- a/tools/testing/selftests/landlock/fs_test.c > +++ b/tools/testing/selftests/landlock/fs_test.c > @@ -4572,7 +4572,10 @@ FIXTURE_VARIANT(layout3_fs) > /* clang-format off */ > FIXTURE_VARIANT_ADD(layout3_fs, tmpfs) { > /* clang-format on */ > - .mnt = mnt_tmp, > + .mnt = { > + .type = "tmpfs", > + .data = "size=4m,mode=700", OK, C doesn't play nice with constants. A better approach would be to define MNT_TMP_DATA, and use it with this fixture variant and the mnt_tmp variable. No need for a MNT_TMP_TYPE though. While you're at it, you can also make the mnt_tmp variable static const. You can create two patches from this one. This first hunk with: Fixes: 04f9070e99a4 ("selftests/landlock: Add tests for pseudo filesystems") > + }, > .file_path = file1_s1d1, > }; > > diff --git a/tools/testing/selftests/landlock/net_test.c b/tools/testing/selftests/landlock/net_test.c > index 929e21c4db05..12a6744568e2 100644 > --- a/tools/testing/selftests/landlock/net_test.c > +++ b/tools/testing/selftests/landlock/net_test.c > @@ -21,6 +21,15 @@ > > #include "common.h" ..and this second hunk for another patch with: Fixes: a549d055a22e ("selftests/landlock: Add network tests") Cc: Konstantin Meskhidze > > +#ifndef gettid > +static pid_t gettid(void) > +{ > + return syscall(__NR_gettid); > +} > + Please remove this newline. > +#endif You can move this gettid hunk to common.h, under the landlock_restrict_self block. > + > + > const short sock_port_start = (1 << 10); > > static const char loopback_ipv4[] = "127.0.0.1"; > -- > 2.23.0 >