public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+
@ 2026-03-14 15:13 Jan Polensky
  2026-03-14 15:13 ` [LTP] [PATCH v2 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
  2026-03-14 15:13 ` [LTP] [PATCH v2 2/2] setxattr02: " Jan Polensky
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Polensky @ 2026-03-14 15: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).

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 | 7 ++++++-
 testcases/kernel/syscalls/setxattr/setxattr02.c   | 6 +++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

-- 
2.53.0


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

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

* [LTP] [PATCH v2 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  2026-03-14 15:13 [LTP] [PATCH v2 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+ Jan Polensky
@ 2026-03-14 15:13 ` Jan Polensky
  2026-03-14 15:13 ` [LTP] [PATCH v2 2/2] setxattr02: " Jan Polensky
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Polensky @ 2026-03-14 15: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+.

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

diff --git a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
index 18490a865871..335a8868ac73 100644
--- a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
+++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
@@ -19,7 +19,8 @@
  * - 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. Will SUCCEED on kernel
+ *   with commit dc0876b9846d.
  */
 
 /*
@@ -158,6 +159,10 @@ static void verify_fsetxattr(unsigned int i)
 	if (TST_RET == -1 && TST_ERR == EOPNOTSUPP)
 		tst_brk(TCONF, "fsetxattr(2) not supported");
 
+	/* consider kernels with commit dc0876b9846d */
+	if ((tst_kvercmp(7, 1, 0) >= 0) && (strncmp(tc[i].fname, SOCK, strlen(SOCK)) == 0))
+		tc[i].exp_err = 0;
+
 	/* success */
 
 	if (!tc[i].exp_err) {
-- 
2.53.0


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

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

* [LTP] [PATCH v2 2/2] setxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  2026-03-14 15:13 [LTP] [PATCH v2 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+ Jan Polensky
  2026-03-14 15:13 ` [LTP] [PATCH v2 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
@ 2026-03-14 15:13 ` Jan Polensky
  2026-03-16  7:56   ` Petr Vorel
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Polensky @ 2026-03-14 15: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+.

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

diff --git a/testcases/kernel/syscalls/setxattr/setxattr02.c b/testcases/kernel/syscalls/setxattr/setxattr02.c
index 9f5f998da9ba..c905f42dbb9e 100644
--- a/testcases/kernel/syscalls/setxattr/setxattr02.c
+++ b/testcases/kernel/syscalls/setxattr/setxattr02.c
@@ -15,7 +15,7 @@
  * - 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 (commit dc0876b9846d)
  */
 
 #include "config.h"
@@ -132,6 +132,10 @@ static void verify_setxattr(unsigned int i)
 	if (TST_RET == -1 && TST_ERR == EOPNOTSUPP)
 		tst_brk(TCONF, "setxattr(2) not supported");
 
+	/* consider kernels with commit dc0876b9846d */
+	if ((tst_kvercmp(7, 1, 0) >= 0) && (strncmp(tc[i].fname, SOCK, strlen(SOCK)) == 0))
+		tc[i].exp_err = 0;
+
 	/* success */
 
 	if (!tc[i].exp_err) {
-- 
2.53.0


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

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

* Re: [LTP] [PATCH v2 2/2] setxattr02: Adapt test for kernel 7.1.0+ socket xattr support
  2026-03-14 15:13 ` [LTP] [PATCH v2 2/2] setxattr02: " Jan Polensky
@ 2026-03-16  7:56   ` Petr Vorel
  2026-03-16  9:07     ` Jan Polensky
  0 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2026-03-16  7:56 UTC (permalink / raw)
  To: Jan Polensky; +Cc: Linux Test Project

Hi Jan,

> 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+.

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

> diff --git a/testcases/kernel/syscalls/setxattr/setxattr02.c b/testcases/kernel/syscalls/setxattr/setxattr02.c
> index 9f5f998da9ba..c905f42dbb9e 100644
> --- a/testcases/kernel/syscalls/setxattr/setxattr02.c
> +++ b/testcases/kernel/syscalls/setxattr/setxattr02.c
> @@ -15,7 +15,7 @@
>   * - 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 (commit dc0876b9846d)
>   */

>  #include "config.h"
> @@ -132,6 +132,10 @@ static void verify_setxattr(unsigned int i)
>  	if (TST_RET == -1 && TST_ERR == EOPNOTSUPP)
>  		tst_brk(TCONF, "setxattr(2) not supported");

> +	/* consider kernels with commit dc0876b9846d */
> +	if ((tst_kvercmp(7, 1, 0) >= 0) && (strncmp(tc[i].fname, SOCK, strlen(SOCK)) == 0))
> +		tc[i].exp_err = 0;
I'm sorry I haven't pointed out it on v1.

1) Kernel detection should be in the setup function (otherwise kernel detection
is done 7x, but needed only 1x, and when run more times with -i1000 it's even
more time wasted), result stored into static variable, see:
testcases/kernel/syscalls/userfaultfd/userfaultfd01.c

2) While checking file name works, we usually try to somehow move the check into
struct test_case.

testcases/kernel/syscalls/finit_module/finit_module02.c
function pointer to in the test struct, function fixes the errno, code run in
the setup.

In this case when a single case requires it, I would combine these 2 approaches:

1) detect kver in the setup

#define BEFORE_7_1 1
#define AFTER_7_1 2
static int kver;

static void setup(void)
{
	...
	if (tst_kvercmp(7, 1, 0) >= 0)
		kver = AFTER_7_1;
	else
		kver = BEFORE_7_1;
}

2) custom function
struct test_case {
	...
	void (*fix_errno)(struct test_case *tc);
};

static void fix_sock(struct tcase *tc)
{
	/* dc0876b9846d ("xattr: support extended attributes on sockets") */
	if (kver == AFTER_7_1)
		tc[i].exp_err = 0;
}

static void verify_setxattr(unsigned int i)
{
	if (tc[i].fix_errno)
		tc[i].fix_errno(&tc[i]);
	...
}

Also, it helps reviewing when your cover letter contains changelog.
On single patch it can be added under --- (so that it's not part of the commit
message.

Kind regards,
Petr
> +
>  	/* success */

>  	if (!tc[i].exp_err) {

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

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

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

On Mon, Mar 16, 2026 at 08:56:37AM +0100, Petr Vorel wrote:
Hi Petr,
> Hi Jan,
>
> >  		tst_brk(TCONF, "setxattr(2) not supported");
>
> > +	/* consider kernels with commit dc0876b9846d */
> > +	if ((tst_kvercmp(7, 1, 0) >= 0) && (strncmp(tc[i].fname, SOCK, strlen(SOCK)) == 0))
> > +		tc[i].exp_err = 0;
> I'm sorry I haven't pointed out it on v1.
>
> 1) Kernel detection should be in the setup function (otherwise kernel detection
> is done 7x, but needed only 1x, and when run more times with -i1000 it's even
> more time wasted), result stored into static variable, see:
> testcases/kernel/syscalls/userfaultfd/userfaultfd01.c
>
> 2) While checking file name works, we usually try to somehow move the check into
> struct test_case.
>
> testcases/kernel/syscalls/finit_module/finit_module02.c
> function pointer to in the test struct, function fixes the errno, code run in
> the setup.
>
> In this case when a single case requires it, I would combine these 2 approaches:
>
> 1) detect kver in the setup
>
> #define BEFORE_7_1 1
> #define AFTER_7_1 2
> static int kver;
>
> static void setup(void)
> {
> 	...
> 	if (tst_kvercmp(7, 1, 0) >= 0)
> 		kver = AFTER_7_1;
> 	else
> 		kver = BEFORE_7_1;
> }
>
> 2) custom function
> struct test_case {
> 	...
> 	void (*fix_errno)(struct test_case *tc);
> };
>
> static void fix_sock(struct tcase *tc)
> {
> 	/* dc0876b9846d ("xattr: support extended attributes on sockets") */
> 	if (kver == AFTER_7_1)
> 		tc[i].exp_err = 0;
> }
>
> static void verify_setxattr(unsigned int i)
> {
> 	if (tc[i].fix_errno)
> 		tc[i].fix_errno(&tc[i]);
> 	...
> }
>
> Also, it helps reviewing when your cover letter contains changelog.
> On single patch it can be added under --- (so that it's not part of the commit
> message.
>
> Kind regards,
> Petr
> > +
> >  	/* success */
>
> >  	if (!tc[i].exp_err) {
Thank you for the suggestions, I appreciate them and will take them into
account. I’ll send an updated version soon.

Kind regards,
Jan

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

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-14 15:13 [LTP] [PATCH v2 0/2] LTP: adjust socket xattr tests for kernel 7.1.0+ Jan Polensky
2026-03-14 15:13 ` [LTP] [PATCH v2 1/2] fsetxattr02: Adapt test for kernel 7.1.0+ socket xattr support Jan Polensky
2026-03-14 15:13 ` [LTP] [PATCH v2 2/2] setxattr02: " Jan Polensky
2026-03-16  7:56   ` Petr Vorel
2026-03-16  9:07     ` Jan Polensky

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