[LTP] [PATCH] syscalls/file_attr01: Allow EOPNOTSUPP when attributes is NULL
Wake Liu
wakel@google.com
Mon Mar 23 08:26:06 CET 2026
> Hi Wake,
>
> > 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).
>
> Patch is technically correct but EOPNOTSUPP should not be tested int this way,
> since we are not checking the underlying kernel configuration. For instance,
> we might have xattr support, but getting EOPNOTSUPP and have a TPASS. This
> would be a kernel bug hidden by the test structure.
>
> In other circumstances (if xattr was our testing goal) we might have used
> .needs_kconfig, but in this case we should use a different approach:
>
> - we verify at runtime that our kernel supports xattr via tst_kconfig_check()
> - if kernel doesn't support xattr, we expect EOPNOTSUPP. Otherwise, EFAULT
>
> In this way we make sure that syscalls are raising the proper error according
> to the kernel configuration.
>
> WDYT?
>
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com
Hi Andrea,
Thanks for the quick review and the detailed feedback.
I agree with your assessment that allowing EOPNOTSUPP unconditionally
could potentially mask a kernel bug if xattr support is present but
returns the wrong error. That's definitely something we should avoid.
Your suggested approach using tst_kconfig_check() at runtime to verify
kernel xattr support is much more robust and is the correct way to
handle this. It ensures the syscalls raise the proper error based on
the configuration.
I will revise the patch (v2) to implement this logic:
* Check xattr support via tst_kconfig_check().
* If xattr is not supported, expect EOPNOTSUPP.
* Otherwise, expect EFAULT.
I'll send it out shortly.
Thanks again,
--
Best Regards,
Wake Liu
More information about the ltp
mailing list