public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Polensky <japo@linux.ibm.com>
To: chrubis@suse.cz, pvorel@suse.cz
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support
Date: Wed, 18 Mar 2026 12:13:05 +0100	[thread overview]
Message-ID: <20260318111306.98139-2-japo@linux.ibm.com> (raw)
In-Reply-To: <20260318111306.98139-1-japo@linux.ibm.com>

Starting with kernel 7.1.0, sockets support extended attributes in the
user.* namespace. This behavior was enabled by dc0876b9846d ("xattr: support
extended attributes on sockets"), which permits user.* xattrs on S_IFSOCK
inodes (previously rejected with -EPERM).

Adapts the test to expect success (exp_err = 0) instead of EPERM when
testing fsetxattr(2) on sockets with kernel 7.1.0+.

Behavior:
- Kernel < 7.1.0: fsetxattr() on socket returns -EPERM (original behavior)
- Kernel >= 7.1.0: fsetxattr() on socket returns 0 (success, new behavior)

Signed-off-by: Jan Polensky <japo@linux.ibm.com>
---
 testcases/kernel/syscalls/fsetxattr/fsetxattr02.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
index 18490a865871..49dcd7cefbe8 100644
--- a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
+++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
@@ -19,7 +19,10 @@
  * - Set attribute to a block special file, fsetxattr(2) should
  *   return -1 and set errno to EPERM.
  * - Set attribute to a UNIX domain socket, fsetxattr(2) should
- *   return -1 and set errno to EPERM.
+ *   return -1 and set errno to EPERM on kernels < 7.1.0.
+ *   On kernel 7.1.0+ (dc0876b9846d "xattr: support extended
+ *   attributes on sockets"), returns 0 (success) as sockets now
+ *   support user.* xattrs.
  */
 
 /*
@@ -62,6 +65,8 @@
 #define BLK      MNTPOINT"/fsetxattr02blk"
 #define SOCK     "fsetxattr02sock"
 
+static bool socket_xattr_supported;
+
 struct test_case {
 	char *fname;
 	int fd;
@@ -73,7 +78,9 @@ struct test_case {
 	int exp_err;
 	int issocket;
 	int needskeyset;
+	bool check_xattr;
 };
+
 static struct test_case tc[] = {
 	{			/* case 00, set attr to reg */
 	 .fname = FILENAME,
@@ -139,6 +146,7 @@ static struct test_case tc[] = {
 	 .flags = XATTR_CREATE,
 	 .exp_err = EPERM,
 	 .issocket = 1,
+	 .check_xattr = true,
 	 },
 };
 
@@ -152,6 +160,9 @@ static void verify_fsetxattr(unsigned int i)
 				XATTR_CREATE);
 	}
 
+	if (tc[i].check_xattr && socket_xattr_supported)
+		tc[i].exp_err = 0;
+
 	TEST(fsetxattr(tc[i].fd, tc[i].key, tc[i].value, tc[i].size,
 			tc[i].flags));
 
@@ -233,6 +244,8 @@ static void setup(void)
 		SAFE_BIND(tc[i].fd, (const struct sockaddr *) &sun,
 				sizeof(struct sockaddr_un));
 	}
+
+	socket_xattr_supported = (tst_kvercmp(7, 1, 0) >= 0);
 }
 
 static void cleanup(void)
-- 
2.53.0


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

  reply	other threads:[~2026-03-18 11:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 11:13 [LTP] [PATCH v4 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+ Jan Polensky
2026-03-18 11:13 ` Jan Polensky [this message]
2026-03-18 15:18   ` [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Petr Vorel
2026-03-18 11:13 ` [LTP] [PATCH v4 2/2] setxattr02: " Jan Polensky
2026-03-18 15:18   ` Petr Vorel
2026-03-20  9:32     ` Jan Polensky
2026-03-20  9:50 ` [LTP] [PATCH v4 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+ 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=20260318111306.98139-2-japo@linux.ibm.com \
    --to=japo@linux.ibm.com \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /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