public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] landlock01: used fixed size for rule_small_size
Date: Tue,  5 Nov 2024 12:13:25 +0800	[thread overview]
Message-ID: <20241105041326.18531-2-liwang@redhat.com> (raw)
In-Reply-To: <20241105041326.18531-1-liwang@redhat.com>

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 <liwang@redhat.com>
---
 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;
 }
-- 
2.47.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-11-05  4:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05  4:13 [LTP] [PATCH 1/2] lapi: Add new field socket scoping to landlock_ruleset_attr Li Wang
2024-11-05  4:13 ` Li Wang [this message]
2024-11-05 10:43   ` [LTP] [PATCH 2/2] landlock01: used fixed size for rule_small_size Wei Gao via ltp
2024-11-05 12:00     ` Li Wang
2024-11-05 10:43 ` [LTP] [PATCH 1/2] lapi: Add new field socket scoping to landlock_ruleset_attr Wei Gao via ltp
2024-11-05 11:20 ` Andrea Cervesato via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241105041326.18531-2-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox