From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 04/10] setxattr02: add setxattrat variant
Date: Tue, 7 Oct 2025 14:40:38 +0200 [thread overview]
Message-ID: <aOUKRrt9yH1leYrX@yuki.lan> (raw)
In-Reply-To: <20251007-xattrat-v2-4-bf458fa66358@suse.com>
On Tue, Oct 07, 2025 at 08:46:56AM +0200, Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> testcases/kernel/syscalls/setxattr/setxattr02.c | 79 +++++++++++++++++++------
> 1 file changed, 60 insertions(+), 19 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/setxattr/setxattr02.c b/testcases/kernel/syscalls/setxattr/setxattr02.c
> index 9f5f998da..b5042a0df 100644
> --- a/testcases/kernel/syscalls/setxattr/setxattr02.c
> +++ b/testcases/kernel/syscalls/setxattr/setxattr02.c
> @@ -19,6 +19,10 @@
> */
>
> #include "config.h"
> +#include "tst_test.h"
> +
> +#ifdef HAVE_SYS_XATTR_H
> +
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <sys/sysmacros.h>
> @@ -30,12 +34,10 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> -#ifdef HAVE_SYS_XATTR_H
> -# include <sys/xattr.h>
> -#endif
> -#include "tst_test.h"
> +#include "lapi/xattr.h"
> +#include "lapi/fcntl.h"
> +#include <sys/xattr.h>
>
> -#ifdef HAVE_SYS_XATTR_H
> #define XATTR_TEST_KEY "user.testkey"
> #define XATTR_TEST_VALUE "this is a test value"
> #define XATTR_TEST_VALUE_SIZE 20
> @@ -49,6 +51,8 @@
> #define BLK "setxattr02blk"
> #define SOCK "setxattr02sock"
>
> +static int tmpdir_fd = -1;
> +
> struct test_case {
> char *fname;
> char *key;
> @@ -120,39 +124,58 @@ static struct test_case tc[] = {
>
> static void verify_setxattr(unsigned int i)
> {
> + char *sysname;
> +
> /* some tests might require existing keys for each iteration */
> if (tc[i].needskeyset) {
> SAFE_SETXATTR(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
> - XATTR_CREATE);
> + XATTR_CREATE);
> }
>
> - TEST(setxattr(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
> - tc[i].flags));
> + if (tst_variant) {
> + sysname = "setxattrat";
> +
> + struct xattr_args args = {
> + .value = (uint64_t)tc[i].value,
> + .size = tc[i].size,
> + .flags = tc[i].flags,
> + };
> +
> + int at_flags = tc[i].needskeyset ? 0 : AT_SYMLINK_NOFOLLOW;
I do not get why this is needed.
In kernel:
SYSCALL_DEFINE5(setxattr, const char __user *, pathname,
const char __user *, name, const void __user *, value,
size_t, size, int, flags)
{
return path_setxattrat(AT_FDCWD, pathname, 0, name, value, size, flags);
^
the setxattr() the
always sets the
at_flags to 0
}
So shouldn't setxattrat() just work the same if we pass 0 there?
It's the lsetxattr() syscall that passes AT_SYMLINK_NOFOLLOW:
SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname,
const char __user *, name, const void __user *, value,
size_t, size, int, flags)
{
return path_setxattrat(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, name,
value, size, flags);
}
> static void setup(void)
> @@ -185,12 +208,30 @@ static void setup(void)
> SAFE_MKNOD(CHR, S_IFCHR | 0777, dev);
> SAFE_MKNOD(BLK, S_IFBLK | 0777, 0);
> SAFE_MKNOD(SOCK, S_IFSOCK | 0777, 0);
> +
> + tmpdir_fd = SAFE_OPEN(tst_tmpdir_path(), O_DIRECTORY);
This is memleak, on the top of that can't we just use the AT_FDCWD
instead? Or if you want to make sure that the syscall works with a real
fd we can do SAFE_OPEN(".", O_DIRECTORY) instead....
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-10-07 12:40 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 6:46 [LTP] [PATCH v2 00/10] setxattrat coverage Andrea Cervesato
2025-10-07 6:46 ` [LTP] [PATCH v2 01/10] lapi: add struct xattr_args fallback Andrea Cervesato
2025-10-07 11:50 ` Cyril Hrubis
2025-10-07 6:46 ` [LTP] [PATCH v2 02/10] lapi: add setxattrat() fallback definition Andrea Cervesato
2025-10-07 12:05 ` Cyril Hrubis
2025-10-07 15:16 ` Cyril Hrubis
2025-10-07 6:46 ` [LTP] [PATCH v2 03/10] setxattr01: add setxattrat variant Andrea Cervesato
2025-10-07 12:29 ` Cyril Hrubis
2025-10-07 13:16 ` Andrea Cervesato via ltp
2025-10-07 14:35 ` Cyril Hrubis
2025-10-08 10:40 ` Andrea Cervesato via ltp
2025-10-08 12:16 ` Cyril Hrubis
2025-10-07 6:46 ` [LTP] [PATCH v2 04/10] setxattr02: " Andrea Cervesato
2025-10-07 12:40 ` Cyril Hrubis [this message]
2025-10-07 6:46 ` [LTP] [PATCH v2 05/10] setxattr03: " Andrea Cervesato
2025-10-07 15:11 ` Cyril Hrubis
2025-10-07 6:46 ` [LTP] [PATCH v2 06/10] lapi: add getxattrat() fallback Andrea Cervesato
2025-10-07 15:21 ` Cyril Hrubis
2025-10-07 6:46 ` [LTP] [PATCH v2 07/10] lapi: add removexattrat() fallback Andrea Cervesato
2025-10-07 15:26 ` Cyril Hrubis
2025-10-07 6:47 ` [LTP] [PATCH v2 08/10] lapi: add safe *xattrat macros Andrea Cervesato
2025-10-08 9:36 ` Cyril Hrubis
2025-10-07 6:47 ` [LTP] [PATCH v2 09/10] Add setxattrat01 test Andrea Cervesato
2025-10-08 9:44 ` Cyril Hrubis
2025-10-13 7:54 ` Andrea Cervesato via ltp
2025-10-07 6:47 ` [LTP] [PATCH v2 10/10] Add setxattrat02 test Andrea Cervesato
2025-10-08 10:02 ` Cyril Hrubis
2025-10-10 11:05 ` 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=aOUKRrt9yH1leYrX@yuki.lan \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/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