From patchwork Tue Nov 5 04:13:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 2006636 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Lxqo0kYc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjFMF5jp5z1xxb for ; Tue, 5 Nov 2024 15:13:45 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EA1CF3D1B05 for ; Tue, 5 Nov 2024 05:13:42 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id EEF273D1A54 for ; Tue, 5 Nov 2024 05:13:39 +0100 (CET) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=liwang@redhat.com; receiver=lists.linux.it) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id B38FE102098E for ; Tue, 5 Nov 2024 05:13:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730780016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6x80RNR2cUdD1DeCco9DSgmLiQ/1n3aWGz08ludJAhA=; b=Lxqo0kYcFmBFq0jj+OUDqBHzli0CM0qjncieQ4Snc2IY1exQJacFTefZnh3V+bzGMc+ZbA oUgPLVv3y3QQnNHeetykGlsRMXCXRmBDFIT0/bCfEKxNIaXjcoG1TBpTiARYBTn+rY9c/G V+2XDBMp4ujRaP7JsPo7+CNIra/ZcUQ= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-MPmBrUF3M9yTjcNr9WnHgw-1; Mon, 04 Nov 2024 23:13:34 -0500 X-MC-Unique: MPmBrUF3M9yTjcNr9WnHgw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 72D691955F10 for ; Tue, 5 Nov 2024 04:13:33 +0000 (UTC) Received: from dell-per7425-02.rhts.eng.pek2.redhat.com (dell-per7425-02.rhts.eng.pek2.redhat.com [10.73.116.18]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2950519560A3 for ; Tue, 5 Nov 2024 04:13:31 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Tue, 5 Nov 2024 12:13:24 +0800 Message-ID: <20241105041326.18531-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 1/2] lapi: Add new field socket scoping to landlock_ruleset_attr X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Mainline kernel commit 21d52e295 ("landlock: Add abstract UNIX socket scoping") introduces a new "scoped" member to the struct landlock_ruleset_attr. Signed-off-by: Li Wang Reviewed-by: Wei Gao --- include/lapi/landlock.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/lapi/landlock.h b/include/lapi/landlock.h index 211d171eb..5fb6d3755 100644 --- a/include/lapi/landlock.h +++ b/include/lapi/landlock.h @@ -19,6 +19,7 @@ struct landlock_ruleset_attr { uint64_t handled_access_fs; uint64_t handled_access_net; + uint64_t scoped; }; #endif From patchwork Tue Nov 5 04:13:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 2006637 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XsNfHL9r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjFMY4kKGz1xxb for ; Tue, 5 Nov 2024 15:14:01 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AD9543D1AFE for ; Tue, 5 Nov 2024 05:13:59 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id DA3673D1A54 for ; Tue, 5 Nov 2024 05:13:40 +0100 (CET) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=liwang@redhat.com; receiver=lists.linux.it) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id CDDDF669A7E for ; Tue, 5 Nov 2024 05:13:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730780018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s2sIX2ZmFSbEoSSNsG4Sk2q1r1IstiM5MQMVTyddYL4=; b=XsNfHL9rn7qsdu84qy/C9RWoRhciiIUcrw6HypZDIoK4XmPyS6W7G0PQAvZl+AMkVFysfT 3IvxjkxmTNNlqnHWgo03eb/ZD5CDEQ2wRgQUyn1cBDG1HSBgAnSf4Irbp/RRwmz1GroDu6 jxBpEoLlB8zrDmc8BSJwXqu4kZxSfgg= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-335-0WhfIgK3Oji2WO4MJkh5ng-1; Mon, 04 Nov 2024 23:13:36 -0500 X-MC-Unique: 0WhfIgK3Oji2WO4MJkh5ng-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D2AD119560A2 for ; Tue, 5 Nov 2024 04:13:35 +0000 (UTC) Received: from dell-per7425-02.rhts.eng.pek2.redhat.com (dell-per7425-02.rhts.eng.pek2.redhat.com [10.73.116.18]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 930A219560A3 for ; Tue, 5 Nov 2024 04:13:33 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Tue, 5 Nov 2024 12:13:25 +0800 Message-ID: <20241105041326.18531-2-liwang@redhat.com> In-Reply-To: <20241105041326.18531-1-liwang@redhat.com> References: <20241105041326.18531-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 2/2] landlock01: used fixed size for rule_small_size X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The landlock01 test is failing on kernel v6.12-rc6 with the following error: landlock01.c:49: TFAIL: Size is too small expected EINVAL: ENOMSG (42) Previously, rule_small_size was calculated conditionally based on the presence of the handled_access_net field in the struct landlock_ruleset_attr. However, the kernel's landlock_create_ruleset() function still uses the size up to handled_access_fs to determine the minimal acceptable size for backward compatibility, regardless of any new fields added. According to the Landlock maintainer[1], this behavior will remain for backward compatibility reasons. Therefore, it's unnecessary to conditionally adjust rule_small_size based on new fields. This patch simplifies the test by setting rule_small_size to 'sizeof(__u64) - 1', which effectively tests the minimal size based on handled_access_fs. [1] https://lists.linux.it/pipermail/ltp/2024-July/039084.html Signed-off-by: Li Wang --- testcases/kernel/syscalls/landlock/landlock01.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/syscalls/landlock/landlock01.c b/testcases/kernel/syscalls/landlock/landlock01.c index 083685c64..c375e5154 100644 --- a/testcases/kernel/syscalls/landlock/landlock01.c +++ b/testcases/kernel/syscalls/landlock/landlock01.c @@ -62,11 +62,17 @@ static void setup(void) rule_size = sizeof(struct landlock_ruleset_attr); -#ifdef HAVE_STRUCT_LANDLOCK_RULESET_ATTR_HANDLED_ACCESS_NET - rule_small_size = rule_size - sizeof(uint64_t) - 1; -#else - rule_small_size = rule_size - 1; -#endif + /* + * Kernel introduces two new fields 'handled_access_net' and 'scoped' + * in the structure 'landlock_ruleset_attr'. However, in the function + * 'landlock_create_ruleset()', it still uses the first field + * 'handled_access_fs' to calculate the minimal size for backward + * compatibility reason. + * + * Therefore, here test 'sizeof(__u64) - 1' is sufficient to determine + * the minimum size for 'rule_small_size'. + */ + rule_small_size = sizeof(__u64) - 1; rule_big_size = SAFE_SYSCONF(_SC_PAGESIZE) + 1; }