public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v4 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+
@ 2026-03-18 11:13 Jan Polensky
  2026-03-18 11:13 ` [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jan Polensky @ 2026-03-18 11:13 UTC (permalink / raw)
  To: chrubis, pvorel; +Cc: Linux Test Project

Linux 7.1.0 allows user.* xattrs on sockets (dc0876b9846d). Update
fsetxattr02/setxattr02 to expect success on 7.1.0+ (instead of -EPERM).

Changes since v3:
- Simplify the logic (thanks Andrea)
Changes since v2:
- Move kernel check into setup() & add helper (thanks Petr)
- Alter test description
Changes since v1:
- Fix kernel version 7.0+ -> 7.1.0+ (thanks Petr)
- Fix comments

Jan Polensky (2):
  fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  setxattr02: Adapt test for kernel 7.1.0+ socket xattr support

 testcases/kernel/syscalls/fsetxattr/fsetxattr02.c | 15 ++++++++++++++-
 testcases/kernel/syscalls/setxattr/setxattr02.c   | 13 ++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

--
2.53.0


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  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
  2026-03-18 15:18   ` Petr Vorel
  2026-03-18 11:13 ` [LTP] [PATCH v4 2/2] setxattr02: " 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
  2 siblings, 1 reply; 7+ messages in thread
From: Jan Polensky @ 2026-03-18 11:13 UTC (permalink / raw)
  To: chrubis, pvorel; +Cc: Linux Test Project

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v4 2/2] setxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  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 ` [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
@ 2026-03-18 11:13 ` Jan Polensky
  2026-03-18 15:18   ` Petr Vorel
  2026-03-20  9:50 ` [LTP] [PATCH v4 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+ Andrea Cervesato via ltp
  2 siblings, 1 reply; 7+ messages in thread
From: Jan Polensky @ 2026-03-18 11:13 UTC (permalink / raw)
  To: chrubis, pvorel; +Cc: Linux Test Project

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 setxattr(2) on sockets with kernel 7.1.0+.

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

Signed-off-by: Jan Polensky <japo@linux.ibm.com>
---
 testcases/kernel/syscalls/setxattr/setxattr02.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/setxattr/setxattr02.c b/testcases/kernel/syscalls/setxattr/setxattr02.c
index 9f5f998da9ba..151e8f308bbf 100644
--- a/testcases/kernel/syscalls/setxattr/setxattr02.c
+++ b/testcases/kernel/syscalls/setxattr/setxattr02.c
@@ -15,7 +15,8 @@
  * - EPERM - set attribute to a FIFO
  * - EPERM - set attribute to a char special file
  * - EPERM - set attribute to a block special file
- * - EPERM - set attribute to a UNIX domain socket
+ * - EPERM/SUCCEED - set attribute to a UNIX domain socket (dc0876b9846d
+ *   "xattr: support extended attributes on sockets")
  */
 
 #include "config.h"
@@ -49,6 +50,8 @@
 #define BLK      "setxattr02blk"
 #define SOCK     "setxattr02sock"
 
+static bool socket_xattr_supported;
+
 struct test_case {
 	char *fname;
 	char *key;
@@ -57,7 +60,9 @@ struct test_case {
 	int flags;
 	int exp_err;
 	int needskeyset;
+	bool check_xattr;
 };
+
 static struct test_case tc[] = {
 	{			/* case 00, set attr to reg */
 	 .fname = FILENAME,
@@ -115,6 +120,7 @@ static struct test_case tc[] = {
 	 .size = XATTR_TEST_VALUE_SIZE,
 	 .flags = XATTR_CREATE,
 	 .exp_err = EPERM,
+	 .check_xattr = true,
 	 },
 };
 
@@ -126,6 +132,9 @@ static void verify_setxattr(unsigned int i)
 				XATTR_CREATE);
 	}
 
+	if (tc[i].check_xattr && socket_xattr_supported)
+		tc[i].exp_err = 0;
+
 	TEST(setxattr(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
 			tc[i].flags));
 
@@ -185,6 +194,8 @@ static void setup(void)
 	SAFE_MKNOD(CHR, S_IFCHR | 0777, dev);
 	SAFE_MKNOD(BLK, S_IFBLK | 0777, 0);
 	SAFE_MKNOD(SOCK, S_IFSOCK | 0777, 0);
+
+	socket_xattr_supported = (tst_kvercmp(7, 1, 0) >= 0);
 }
 
 static struct tst_test test = {
-- 
2.53.0


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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v4 2/2] setxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2026-03-18 15:18 UTC (permalink / raw)
  To: Jan Polensky; +Cc: Linux Test Project

Hi Jan,

> +static bool socket_xattr_supported;
> +
>  struct test_case {
>  	char *fname;
>  	char *key;
> @@ -57,7 +60,9 @@ struct test_case {
>  	int flags;
>  	int exp_err;
>  	int needskeyset;
> +	bool check_xattr;

Maybe more readable would be 'check_kver' (I can change it before merge).

>  };
> +
>  static struct test_case tc[] = {
>  	{			/* case 00, set attr to reg */
>  	 .fname = FILENAME,
> @@ -115,6 +120,7 @@ static struct test_case tc[] = {
>  	 .size = XATTR_TEST_VALUE_SIZE,
>  	 .flags = XATTR_CREATE,
>  	 .exp_err = EPERM,
> +	 .check_xattr = true,
>  	 },
>  };

> @@ -126,6 +132,9 @@ static void verify_setxattr(unsigned int i)
>  				XATTR_CREATE);
>  	}

> +	if (tc[i].check_xattr && socket_xattr_supported)
> +		tc[i].exp_err = 0;
> +
>  	TEST(setxattr(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
>  			tc[i].flags));

> @@ -185,6 +194,8 @@ static void setup(void)
>  	SAFE_MKNOD(CHR, S_IFCHR | 0777, dev);
>  	SAFE_MKNOD(BLK, S_IFBLK | 0777, 0);
>  	SAFE_MKNOD(SOCK, S_IFSOCK | 0777, 0);
> +
> +	socket_xattr_supported = (tst_kvercmp(7, 1, 0) >= 0);

Brackets are not needed (not a mistake, but I'll remove it before merge).

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  2026-03-18 11:13 ` [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
@ 2026-03-18 15:18   ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-03-18 15:18 UTC (permalink / raw)
  To: Jan Polensky; +Cc: Linux Test Project

Hi Jan,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

(the same notes as for the second commit).

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v4 2/2] setxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  2026-03-18 15:18   ` Petr Vorel
@ 2026-03-20  9:32     ` Jan Polensky
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Polensky @ 2026-03-20  9:32 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Linux Test Project

Hi Petr,
> Hi Jan,
>
> > +static bool socket_xattr_supported;
> > +
> >  struct test_case {
> >  	char *fname;
> >  	char *key;
> > @@ -57,7 +60,9 @@ struct test_case {
> >  	int flags;
> >  	int exp_err;
> >  	int needskeyset;
> > +	bool check_xattr;
>
> Maybe more readable would be 'check_kver' (I can change it before merge).
>
> >  };
> > +
> >  static struct test_case tc[] = {
> >  	{			/* case 00, set attr to reg */
> >  	 .fname = FILENAME,
> > @@ -115,6 +120,7 @@ static struct test_case tc[] = {
> >  	 .size = XATTR_TEST_VALUE_SIZE,
> >  	 .flags = XATTR_CREATE,
> >  	 .exp_err = EPERM,
> > +	 .check_xattr = true,
> >  	 },
> >  };
>
> > @@ -126,6 +132,9 @@ static void verify_setxattr(unsigned int i)
> >  				XATTR_CREATE);
> >  	}
>
> > +	if (tc[i].check_xattr && socket_xattr_supported)
> > +		tc[i].exp_err = 0;
> > +
> >  	TEST(setxattr(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
> >  			tc[i].flags));
>
> > @@ -185,6 +194,8 @@ static void setup(void)
> >  	SAFE_MKNOD(CHR, S_IFCHR | 0777, dev);
> >  	SAFE_MKNOD(BLK, S_IFBLK | 0777, 0);
> >  	SAFE_MKNOD(SOCK, S_IFSOCK | 0777, 0);
> > +
> > +	socket_xattr_supported = (tst_kvercmp(7, 1, 0) >= 0);
>
> Brackets are not needed (not a mistake, but I'll remove it before merge).
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> Kind regards,
> Petr
Thank you very much, I appreciate it!

Kind regards,
Jan

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v4 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+
  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 ` [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
  2026-03-18 11:13 ` [LTP] [PATCH v4 2/2] setxattr02: " Jan Polensky
@ 2026-03-20  9:50 ` Andrea Cervesato via ltp
  2 siblings, 0 replies; 7+ messages in thread
From: Andrea Cervesato via ltp @ 2026-03-20  9:50 UTC (permalink / raw)
  To: Jan Polensky; +Cc: Linux Test Project

Merged with the suggested edits from me and Petr.

Kind regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-03-20  9:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [LTP] [PATCH v4 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
2026-03-18 15:18   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox