From: Wake Liu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Wake Liu <wakel@google.com>
Subject: [LTP] [PATCH] syscalls/file_attr01: Allow EOPNOTSUPP when attributes is NULL
Date: Fri, 20 Mar 2026 07:57:33 +0000 [thread overview]
Message-ID: <20260320075733.936817-1-wakel@google.com> (raw)
The syscalls file_getattr and file_setattr may return EOPNOTSUPP
instead of EFAULT when the ufattr argument is NULL, specifically on
filesystems that do not support extended attributes (e.g., tmpfs when
CONFIG_TMPFS_XATTR is disabled).
In the kernel, the fileattr_get/set operations are checked before the
pointer dereference. If the filesystem does not define these operations,
the kernel returns -ENOIOCTLCMD (translated to EOPNOTSUPP in userspace)
before checking the validity of the user-provided pointer.
This is a valid behavior for kernel configurations where extended
attributes are not enabled for certain filesystems. This leads to
test failures on such systems:
TFAIL: File attributes is NULL expected EFAULT: EOPNOTSUPP (95)
This patch updates the test case to support multiple expected errnos
using TST_EXP_FAIL_ARR, allowing both EFAULT and EOPNOTSUPP for the NULL
attributes test case.
Signed-off-by: Wake Liu <wakel@google.com>
---
.../kernel/syscalls/file_attr/file_attr01.c | 35 ++++++++++++-------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/testcases/kernel/syscalls/file_attr/file_attr01.c b/testcases/kernel/syscalls/file_attr/file_attr01.c
index c9c9288a1..02aea66a6 100644
--- a/testcases/kernel/syscalls/file_attr/file_attr01.c
+++ b/testcases/kernel/syscalls/file_attr/file_attr01.c
@@ -42,7 +42,8 @@ static struct tcase {
struct file_attr **ufattr;
size_t *usize;
int at_flags;
- int exp_errno;
+ int exp_errs[2];
+ int exp_errs_cnt;
char *msg;
} tcases[] = {
{
@@ -50,7 +51,8 @@ static struct tcase {
.filename = &valid_filename,
.ufattr = &valid_file_attr,
.usize = &valid_usize,
- .exp_errno = EBADF,
+ .exp_errs = {EBADF},
+ .exp_errs_cnt = 1,
.msg = "Invalid file descriptor",
},
{
@@ -58,7 +60,8 @@ static struct tcase {
.filename = &invalid_filename,
.ufattr = &valid_file_attr,
.usize = &valid_usize,
- .exp_errno = ENOENT,
+ .exp_errs = {ENOENT},
+ .exp_errs_cnt = 1,
.msg = "File doesn't exist",
},
{
@@ -66,7 +69,8 @@ static struct tcase {
.filename = &null_ptr,
.ufattr = &valid_file_attr,
.usize = &valid_usize,
- .exp_errno = EFAULT,
+ .exp_errs = {EFAULT},
+ .exp_errs_cnt = 1,
.msg = "Filename is NULL",
},
{
@@ -74,7 +78,8 @@ static struct tcase {
.filename = &valid_filename,
.ufattr = (struct file_attr **)(&null_ptr),
.usize = &valid_usize,
- .exp_errno = EFAULT,
+ .exp_errs = {EFAULT, EOPNOTSUPP},
+ .exp_errs_cnt = 2,
.msg = "File attributes is NULL",
},
{
@@ -82,7 +87,8 @@ static struct tcase {
.filename = &valid_filename,
.ufattr = &valid_file_attr,
.usize = &zero,
- .exp_errno = EINVAL,
+ .exp_errs = {EINVAL},
+ .exp_errs_cnt = 1,
.msg = "File attributes size is zero",
},
{
@@ -90,7 +96,8 @@ static struct tcase {
.filename = &valid_filename,
.ufattr = &valid_file_attr,
.usize = &small_usize,
- .exp_errno = EINVAL,
+ .exp_errs = {EINVAL},
+ .exp_errs_cnt = 1,
.msg = "File attributes size is too small",
},
{
@@ -98,7 +105,8 @@ static struct tcase {
.filename = &valid_filename,
.ufattr = &valid_file_attr,
.usize = &big_usize,
- .exp_errno = E2BIG,
+ .exp_errs = {E2BIG},
+ .exp_errs_cnt = 1,
.msg = "File attributes size is too big",
},
{
@@ -107,7 +115,8 @@ static struct tcase {
.ufattr = &valid_file_attr,
.usize = &valid_usize,
.at_flags = -1,
- .exp_errno = EINVAL,
+ .exp_errs = {EINVAL},
+ .exp_errs_cnt = 1,
.msg = "Invalid AT flags",
},
};
@@ -117,18 +126,18 @@ static void run(unsigned int i)
struct tcase *tc = &tcases[i];
if (tst_variant) {
- TST_EXP_FAIL(file_getattr(
+ TST_EXP_FAIL_ARR(file_getattr(
*tc->dfd, *tc->filename,
*tc->ufattr, *tc->usize,
tc->at_flags),
- tc->exp_errno,
+ tc->exp_errs, tc->exp_errs_cnt,
"%s", tc->msg);
} else {
- TST_EXP_FAIL(file_setattr(
+ TST_EXP_FAIL_ARR(file_setattr(
*tc->dfd, *tc->filename,
*tc->ufattr, *tc->usize,
tc->at_flags),
- tc->exp_errno,
+ tc->exp_errs, tc->exp_errs_cnt,
"%s", tc->msg);
}
}
--
2.53.0.983.g0bb29b3bc5-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-03-20 7:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 7:57 Wake Liu via ltp [this message]
2026-03-20 8:57 ` [LTP] [PATCH] syscalls/file_attr01: Allow EOPNOTSUPP when attributes is NULL Andrea Cervesato via ltp
2026-03-23 7:26 ` Wake Liu via ltp
2026-03-23 7:48 ` [LTP] [PATCH v2] syscalls/file_attr01: Dynamically expect EOPNOTSUPP on tmpfs without xattr Wake Liu via ltp
2026-03-23 9:07 ` 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=20260320075733.936817-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