From: Wake Liu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Wake Liu <wakel@google.com>
Subject: [LTP] [PATCH v2] syscalls/file_attr01: Dynamically expect EOPNOTSUPP on tmpfs without xattr
Date: Mon, 23 Mar 2026 07:48:14 +0000 [thread overview]
Message-ID: <20260323074814.2930709-1-wakel@google.com> (raw)
In-Reply-To: <CAOcRiAF3gkD8QDr2L7g7DXpUwUurYDh7k-vBMmw=um5AdnuNMw@mail.gmail.com>
The syscalls file_getattr and file_setattr return EOPNOTSUPP instead of
EFAULT when the ufattr argument is NULL on tmpfs without xattr support
(CONFIG_TMPFS_XATTR=n). This is because the kernel checks for the
filesystem operation support before dereferencing the user pointer.
This patch adds a runtime check for CONFIG_TMPFS_XATTR when testing
on tmpfs, ensuring the correct errno is expected based on the kernel
configuration. This prevents hiding potential kernel bugs where
EOPNOTSUPP might be returned even when xattr is supported.
Changes in v2:
- Replaced the TST_EXP_FAIL_ARR approach with a dynamic check in run().
- Included tst_kconfig.h and used tst_kconfig_check() to verify
CONFIG_TMPFS_XATTR status.
- Expected EOPNOTSUPP only on tmpfs when xattr support is missing,
otherwise default to EFAULT.
Signed-off-by: Wake Liu <wakel@google.com>
---
testcases/kernel/syscalls/file_attr/file_attr01.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/file_attr/file_attr01.c b/testcases/kernel/syscalls/file_attr/file_attr01.c
index c9c9288a1..43e0f0503 100644
--- a/testcases/kernel/syscalls/file_attr/file_attr01.c
+++ b/testcases/kernel/syscalls/file_attr/file_attr01.c
@@ -18,6 +18,7 @@
#include <string.h>
#include "tst_test.h"
+#include "tst_kconfig.h"
#include "lapi/fs.h"
#include "lapi/fcntl.h"
@@ -115,20 +116,28 @@ static struct tcase {
static void run(unsigned int i)
{
struct tcase *tc = &tcases[i];
+ int exp_errno = tc->exp_errno;
+
+ if (tc->ufattr == (struct file_attr **)(&null_ptr)) {
+ const char *const kconfig[] = {"CONFIG_TMPFS_XATTR=y", NULL};
+
+ if (!strcmp(tst_device->fs_type, "tmpfs") && tst_kconfig_check(kconfig))
+ exp_errno = EOPNOTSUPP;
+ }
if (tst_variant) {
TST_EXP_FAIL(file_getattr(
*tc->dfd, *tc->filename,
*tc->ufattr, *tc->usize,
tc->at_flags),
- tc->exp_errno,
+ exp_errno,
"%s", tc->msg);
} else {
TST_EXP_FAIL(file_setattr(
*tc->dfd, *tc->filename,
*tc->ufattr, *tc->usize,
tc->at_flags),
- tc->exp_errno,
+ exp_errno,
"%s", tc->msg);
}
}
--
2.53.0.983.g0bb29b3bc5-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-03-23 7:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 7:57 [LTP] [PATCH] syscalls/file_attr01: Allow EOPNOTSUPP when attributes is NULL Wake Liu via ltp
2026-03-20 8:57 ` Andrea Cervesato via ltp
2026-03-23 7:26 ` Wake Liu via ltp
2026-03-23 7:48 ` Wake Liu via ltp [this message]
2026-03-23 9:07 ` [LTP] [PATCH v2] syscalls/file_attr01: Dynamically expect EOPNOTSUPP on tmpfs without xattr 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=20260323074814.2930709-1-wakel@google.com \
--to=ltp@lists.linux.it \
--cc=wakel@google.com \
/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