* [LTP] [PATCH] Added new_behavior flag to detect kernel version Kernel >= 6.11: Tests that creat() succeeds (write to executed file allowed)
@ 2026-04-08 5:33 lepillai
0 siblings, 0 replies; 5+ messages in thread
From: lepillai @ 2026-04-08 5:33 UTC (permalink / raw)
To: ltp; +Cc: lekshmi-cpillai
From: lekshmi-cpillai <lekshmi@ktes.isst.tadn.ibm.com>
---
testcases/kernel/syscalls/creat/creat07.c | 38 ++++++++++++++++-------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
index c7b85ee69..762022301 100644
--- a/testcases/kernel/syscalls/creat/creat07.c
+++ b/testcases/kernel/syscalls/creat/creat07.c
@@ -19,6 +19,8 @@
#define TEST_APP "creat07_child"
+static int new_behavior;
+
static void verify_creat(void)
{
pid_t pid;
@@ -33,16 +35,26 @@ static void verify_creat(void)
TEST(creat(TEST_APP, O_WRONLY));
- if (TST_RET != -1) {
- tst_res(TFAIL, "creat() succeeded unexpectedly");
- return;
+ if (new_behavior) {
+ /* Kernel >= 6.11: write to executed file is allowed */
+ if (TST_RET != -1) {
+ SAFE_CLOSE(TST_RET);
+ tst_res(TPASS, "creat() succeeded as expected (new behavior)");
+ } else {
+ tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
+ }
+ } else {
+ /* Kernel < 6.11: write to executed file returns ETXTBSY */
+ if (TST_RET != -1) {
+ tst_res(TFAIL, "creat() succeeded unexpectedly");
+ SAFE_CLOSE(TST_RET);
+ } else if (TST_ERR == ETXTBSY) {
+ tst_res(TPASS, "creat() received ETXTBSY");
+ } else {
+ tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
+ }
}
- if (TST_ERR == ETXTBSY)
- tst_res(TPASS, "creat() received EXTBSY");
- else
- tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
-
SAFE_KILL(pid, SIGKILL);
SAFE_WAITPID(pid, NULL, 0);
}
@@ -50,9 +62,13 @@ static void verify_creat(void)
static void setup(void)
{
if ((tst_kvercmp(6, 11, 0)) >= 0) {
- tst_brk(TCONF, "Skipping test, write to executed file is "
- "allowed since 6.11-rc1.\n"
- "2a010c412853 (\"fs: don't block i_writecount during exec\")");
+ new_behavior = 1;
+ tst_res(TINFO, "Testing new behavior: write to executed file is "
+ "allowed since 6.11-rc1 (2a010c412853)");
+ } else {
+ new_behavior = 0;
+ tst_res(TINFO, "Testing old behavior: write to executed file "
+ "returns ETXTBSY");
}
}
--
2.39.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH] Added new_behavior flag to detect kernel version Kernel >= 6.11: Tests that creat() succeeds (write to executed file allowed)
@ 2026-04-08 5:36 lepillai
2026-04-08 10:10 ` Cyril Hrubis
2026-04-21 5:02 ` lepillai
0 siblings, 2 replies; 5+ messages in thread
From: lepillai @ 2026-04-08 5:36 UTC (permalink / raw)
To: ltp; +Cc: lekshmi-cpillai
From: lekshmi-cpillai <lekshmi@ktes.isst.tadn.ibm.com>
Signed-off-by: lekshmi-cpillai <lepillai@linux.ibm.com>
---
testcases/kernel/syscalls/creat/creat07.c | 38 ++++++++++++++++-------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
index c7b85ee69..762022301 100644
--- a/testcases/kernel/syscalls/creat/creat07.c
+++ b/testcases/kernel/syscalls/creat/creat07.c
@@ -19,6 +19,8 @@
#define TEST_APP "creat07_child"
+static int new_behavior;
+
static void verify_creat(void)
{
pid_t pid;
@@ -33,16 +35,26 @@ static void verify_creat(void)
TEST(creat(TEST_APP, O_WRONLY));
- if (TST_RET != -1) {
- tst_res(TFAIL, "creat() succeeded unexpectedly");
- return;
+ if (new_behavior) {
+ /* Kernel >= 6.11: write to executed file is allowed */
+ if (TST_RET != -1) {
+ SAFE_CLOSE(TST_RET);
+ tst_res(TPASS, "creat() succeeded as expected (new behavior)");
+ } else {
+ tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
+ }
+ } else {
+ /* Kernel < 6.11: write to executed file returns ETXTBSY */
+ if (TST_RET != -1) {
+ tst_res(TFAIL, "creat() succeeded unexpectedly");
+ SAFE_CLOSE(TST_RET);
+ } else if (TST_ERR == ETXTBSY) {
+ tst_res(TPASS, "creat() received ETXTBSY");
+ } else {
+ tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
+ }
}
- if (TST_ERR == ETXTBSY)
- tst_res(TPASS, "creat() received EXTBSY");
- else
- tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
-
SAFE_KILL(pid, SIGKILL);
SAFE_WAITPID(pid, NULL, 0);
}
@@ -50,9 +62,13 @@ static void verify_creat(void)
static void setup(void)
{
if ((tst_kvercmp(6, 11, 0)) >= 0) {
- tst_brk(TCONF, "Skipping test, write to executed file is "
- "allowed since 6.11-rc1.\n"
- "2a010c412853 (\"fs: don't block i_writecount during exec\")");
+ new_behavior = 1;
+ tst_res(TINFO, "Testing new behavior: write to executed file is "
+ "allowed since 6.11-rc1 (2a010c412853)");
+ } else {
+ new_behavior = 0;
+ tst_res(TINFO, "Testing old behavior: write to executed file "
+ "returns ETXTBSY");
}
}
--
2.39.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] Added new_behavior flag to detect kernel version Kernel >= 6.11: Tests that creat() succeeds (write to executed file allowed)
2026-04-08 5:36 lepillai
@ 2026-04-08 10:10 ` Cyril Hrubis
2026-04-21 5:02 ` lepillai
1 sibling, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2026-04-08 10:10 UTC (permalink / raw)
To: lepillai; +Cc: lekshmi-cpillai, ltp
Hi!
> +static int new_behavior;
> +
> static void verify_creat(void)
> {
> pid_t pid;
> @@ -33,16 +35,26 @@ static void verify_creat(void)
>
> TEST(creat(TEST_APP, O_WRONLY));
>
> - if (TST_RET != -1) {
> - tst_res(TFAIL, "creat() succeeded unexpectedly");
> - return;
> + if (new_behavior) {
> + /* Kernel >= 6.11: write to executed file is allowed */
> + if (TST_RET != -1) {
> + SAFE_CLOSE(TST_RET);
> + tst_res(TPASS, "creat() succeeded as expected (new behavior)");
> + } else {
> + tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
> + }
> + } else {
> + /* Kernel < 6.11: write to executed file returns ETXTBSY */
> + if (TST_RET != -1) {
> + tst_res(TFAIL, "creat() succeeded unexpectedly");
> + SAFE_CLOSE(TST_RET);
> + } else if (TST_ERR == ETXTBSY) {
> + tst_res(TPASS, "creat() received ETXTBSY");
> + } else {
> + tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
> + }
> }
>
> - if (TST_ERR == ETXTBSY)
> - tst_res(TPASS, "creat() received EXTBSY");
> - else
> - tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
> -
> SAFE_KILL(pid, SIGKILL);
> SAFE_WAITPID(pid, NULL, 0);
> }
> @@ -50,9 +62,13 @@ static void verify_creat(void)
> static void setup(void)
> {
> if ((tst_kvercmp(6, 11, 0)) >= 0) {
> - tst_brk(TCONF, "Skipping test, write to executed file is "
> - "allowed since 6.11-rc1.\n"
> - "2a010c412853 (\"fs: don't block i_writecount during exec\")");
> + new_behavior = 1;
> + tst_res(TINFO, "Testing new behavior: write to executed file is "
> + "allowed since 6.11-rc1 (2a010c412853)");
> + } else {
> + new_behavior = 0;
> + tst_res(TINFO, "Testing old behavior: write to executed file "
> + "returns ETXTBSY");
Apart from the code being ugly and having way too much verbose messages
the test is likely broken with -i 2 command line option on newer
kernels.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH] Added new_behavior flag to detect kernel version Kernel >= 6.11: Tests that creat() succeeds (write to executed file allowed)
2026-04-08 5:36 lepillai
2026-04-08 10:10 ` Cyril Hrubis
@ 2026-04-21 5:02 ` lepillai
2026-04-28 8:46 ` Andrea Cervesato via ltp
1 sibling, 1 reply; 5+ messages in thread
From: lepillai @ 2026-04-21 5:02 UTC (permalink / raw)
To: ltp; +Cc: lekshmi-cpillai
From: lekshmi-cpillai <lekshmi@ktes.isst.tadn.ibm.com>
---
testcases/kernel/syscalls/creat/creat07.c | 38 ++++++++++++++++-------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
index c7b85ee69..762022301 100644
--- a/testcases/kernel/syscalls/creat/creat07.c
+++ b/testcases/kernel/syscalls/creat/creat07.c
@@ -19,6 +19,8 @@
#define TEST_APP "creat07_child"
+static int new_behavior;
+
static void verify_creat(void)
{
pid_t pid;
@@ -33,16 +35,26 @@ static void verify_creat(void)
TEST(creat(TEST_APP, O_WRONLY));
- if (TST_RET != -1) {
- tst_res(TFAIL, "creat() succeeded unexpectedly");
- return;
+ if (new_behavior) {
+ /* Kernel >= 6.11: write to executed file is allowed */
+ if (TST_RET != -1) {
+ SAFE_CLOSE(TST_RET);
+ tst_res(TPASS, "creat() succeeded as expected (new behavior)");
+ } else {
+ tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
+ }
+ } else {
+ /* Kernel < 6.11: write to executed file returns ETXTBSY */
+ if (TST_RET != -1) {
+ tst_res(TFAIL, "creat() succeeded unexpectedly");
+ SAFE_CLOSE(TST_RET);
+ } else if (TST_ERR == ETXTBSY) {
+ tst_res(TPASS, "creat() received ETXTBSY");
+ } else {
+ tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
+ }
}
- if (TST_ERR == ETXTBSY)
- tst_res(TPASS, "creat() received EXTBSY");
- else
- tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
-
SAFE_KILL(pid, SIGKILL);
SAFE_WAITPID(pid, NULL, 0);
}
@@ -50,9 +62,13 @@ static void verify_creat(void)
static void setup(void)
{
if ((tst_kvercmp(6, 11, 0)) >= 0) {
- tst_brk(TCONF, "Skipping test, write to executed file is "
- "allowed since 6.11-rc1.\n"
- "2a010c412853 (\"fs: don't block i_writecount during exec\")");
+ new_behavior = 1;
+ tst_res(TINFO, "Testing new behavior: write to executed file is "
+ "allowed since 6.11-rc1 (2a010c412853)");
+ } else {
+ new_behavior = 0;
+ tst_res(TINFO, "Testing old behavior: write to executed file "
+ "returns ETXTBSY");
}
}
--
2.39.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] Added new_behavior flag to detect kernel version Kernel >= 6.11: Tests that creat() succeeds (write to executed file allowed)
2026-04-21 5:02 ` lepillai
@ 2026-04-28 8:46 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2026-04-28 8:46 UTC (permalink / raw)
To: lepillai; +Cc: lekshmi-cpillai, ltp
Hi,
> From: lekshmi-cpillai <lekshmi@ktes.isst.tadn.ibm.com>
>
> ---
> testcases/kernel/syscalls/creat/creat07.c | 38 ++++++++++++++++-------
> 1 file changed, 27 insertions(+), 11 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
> index c7b85ee69..762022301 100644
> --- a/testcases/kernel/syscalls/creat/creat07.c
> +++ b/testcases/kernel/syscalls/creat/creat07.c
> @@ -19,6 +19,8 @@
>
> #define TEST_APP "creat07_child"
>
> +static int new_behavior;
> +
> static void verify_creat(void)
> {
> pid_t pid;
> @@ -33,16 +35,26 @@ static void verify_creat(void)
>
> TEST(creat(TEST_APP, O_WRONLY));
>
> - if (TST_RET != -1) {
> - tst_res(TFAIL, "creat() succeeded unexpectedly");
> - return;
> + if (new_behavior) {
> + /* Kernel >= 6.11: write to executed file is allowed */
> + if (TST_RET != -1) {
> + SAFE_CLOSE(TST_RET);
> + tst_res(TPASS, "creat() succeeded as expected (new behavior)");
> + } else {
> + tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
> + }
> + } else {
> + /* Kernel < 6.11: write to executed file returns ETXTBSY */
> + if (TST_RET != -1) {
> + tst_res(TFAIL, "creat() succeeded unexpectedly");
> + SAFE_CLOSE(TST_RET);
> + } else if (TST_ERR == ETXTBSY) {
> + tst_res(TPASS, "creat() received ETXTBSY");
> + } else {
> + tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
> + }
> }
>
> - if (TST_ERR == ETXTBSY)
> - tst_res(TPASS, "creat() received EXTBSY");
> - else
> - tst_res(TFAIL | TTERRNO, "creat() failed unexpectedly");
> -
> SAFE_KILL(pid, SIGKILL);
> SAFE_WAITPID(pid, NULL, 0);
> }
> @@ -50,9 +62,13 @@ static void verify_creat(void)
> static void setup(void)
> {
> if ((tst_kvercmp(6, 11, 0)) >= 0) {
> - tst_brk(TCONF, "Skipping test, write to executed file is "
> - "allowed since 6.11-rc1.\n"
> - "2a010c412853 (\"fs: don't block i_writecount during exec\")");
> + new_behavior = 1;
> + tst_res(TINFO, "Testing new behavior: write to executed file is "
> + "allowed since 6.11-rc1 (2a010c412853)");
> + } else {
> + new_behavior = 0;
> + tst_res(TINFO, "Testing old behavior: write to executed file "
> + "returns ETXTBSY");
> }
> }
>
> --
> 2.39.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
There's too much going on in these nested statements. The `new_behavior`
is not needed, we only need to save the error code (-1 or ETXTBSY) inside
a static variable.
If it's not -1, TST_EXP_ERR() can be used. Otherwise we print a TPASS.
The kernel version is printed before every test execution, so there's no
need to show any information about it.
Also test it with `-i` parameter. The test is likely broken with this patch.
Kind Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-28 8:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 5:33 [LTP] [PATCH] Added new_behavior flag to detect kernel version Kernel >= 6.11: Tests that creat() succeeds (write to executed file allowed) lepillai
-- strict thread matches above, loose matches on Subject: below --
2026-04-08 5:36 lepillai
2026-04-08 10:10 ` Cyril Hrubis
2026-04-21 5:02 ` lepillai
2026-04-28 8:46 ` Andrea Cervesato via ltp
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.