mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yeswanth Krishna <yeswanth@linux.ibm.com>
To: Disha Goel <disgoel@linux.ibm.com>, shuah@kernel.org
Cc: brauner@kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] selftests/filesystems: allow security.selinux xattr in listxattr kernfs test
Date: Wed, 17 Jun 2026 16:48:11 +0530	[thread overview]
Message-ID: <6017445d-6cd3-4b20-8678-4a09ef20ce6c@linux.ibm.com> (raw)
In-Reply-To: <20260521101758.14639-2-disgoel@linux.ibm.com>

On 21/05/26 3:47 pm, Disha Goel wrote:

> kernfs_test assumes that flistxattr() on /sys/kernel/warn_count always
> returns an empty list. However, systems with SELinux enabled may expose
> security.selinux xattr via listxattr() during policy load, which makes
> the test fail even though kernfs is behaving correctly.
>
> Allow security.selinux xattr in kernfs_listxattr while continuing to
> reject other unexpected xattrs. Keep the existing user.foo getxattr
> check unchanged.
>
> This avoids false failures on SELinux-enabled systems while preserving
> the original purpose of the test.
>
> Signed-off-by: Disha Goel<disgoel@linux.ibm.com>
> ---

Hi Disha,

I have tested this patch on my ppc64le system and it works as expected.

Test Environment:
- Kernel: Linux (mainline)

Logs
====
# make -C tools/testing/selftests/filesystems run_tests
make: Entering directory '/root/linux/tools/testing/selftests/filesystems'
# timeout set to 45
# selftests: filesystems: kernfs_test
# TAP version 13
# 1..2
# # Starting 2 tests from 1 test cases.
# #  RUN           global.kernfs_listxattr ...
# #            OK  global.kernfs_listxattr
# ok 1 global.kernfs_listxattr
# #  RUN           global.kernfs_getxattr ...
# #            OK  global.kernfs_getxattr
# ok 2 global.kernfs_getxattr
# # PASSED: 2 / 2 tests passed.
# # Totals: pass:2 fail:0 xfail:0 xpass:0 skip:0 error:0
ok 3 selftests: filesystems: kernfs_test
|All filesystem selftests also passed without issues.|

Please add below tag.

Tested-by: Yeswanth Krishna<yeswanth@linux.ibm.com>

Thanks,
Yeswanth Krishna

>   .../selftests/filesystems/kernfs_test.c       | 27 +++++++++++++++++--
>   1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/filesystems/kernfs_test.c b/tools/testing/selftests/filesystems/kernfs_test.c
> index 84c2b910a60d..a5e480d662e0 100644
> --- a/tools/testing/selftests/filesystems/kernfs_test.c
> +++ b/tools/testing/selftests/filesystems/kernfs_test.c
> @@ -4,6 +4,8 @@
>   
>   #include <fcntl.h>
>   #include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
>   #include <sys/stat.h>
>   #include <sys/xattr.h>
>   
> @@ -12,12 +14,33 @@
>   
>   TEST(kernfs_listxattr)
>   {
> +	char *buf, *xattr;
> +	ssize_t len, ret;
>   	int fd;
>   
> -	/* Read-only file that can never have any extended attributes set. */
> +	/* Read-only file that can never have any extended attributes set.
> +	 * However, SELinux may set security.selinux xattr on kernfs files
> +	 * during policy load, so we explicitly ignore it.
> +	 */
>   	fd = open("/sys/kernel/warn_count", O_RDONLY | O_CLOEXEC);
>   	ASSERT_GE(fd, 0);
> -	ASSERT_EQ(flistxattr(fd, NULL, 0), 0);
> +
> +	len = flistxattr(fd, NULL, 0);
> +	ASSERT_GE(len, 0);
> +
> +	if (len > 0) {
> +		buf = malloc(len);
> +		ASSERT_NE(buf, NULL);
> +
> +		ret = flistxattr(fd, buf, len);
> +		ASSERT_EQ(ret, len);
> +
> +		for (xattr = buf; xattr < buf + len; xattr += strlen(xattr) + 1)
> +			ASSERT_EQ(strcmp(xattr, "security.selinux"), 0);
> +
> +		free(buf);
> +	}
> +
>   	EXPECT_EQ(close(fd), 0);
>   }
>   

  parent reply	other threads:[~2026-06-17 11:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 10:17 [PATCH v2 1/2] selftests/filesystems: Move file_stressor to dedicated subdirectory Disha Goel
2026-05-21 10:17 ` [PATCH v2 2/2] selftests/filesystems: allow security.selinux xattr in listxattr kernfs test Disha Goel
2026-06-15  5:19   ` Ojaswin Mujoo
2026-06-17 11:18   ` Yeswanth Krishna [this message]
2026-06-15  5:12 ` [PATCH v2 1/2] selftests/filesystems: Move file_stressor to dedicated subdirectory Ojaswin Mujoo
2026-06-17 11:14 ` Yeswanth Krishna

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=6017445d-6cd3-4b20-8678-4a09ef20ce6c@linux.ibm.com \
    --to=yeswanth@linux.ibm.com \
    --cc=brauner@kernel.org \
    --cc=disgoel@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /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

all inboxes | Powered by JetHome®