Linux Test Project
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: "Ricardo B. Marlière" <rbm@suse.com>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v5 5/8] syscalls/mknod05: Convert to new API
Date: Fri, 6 Jun 2025 13:44:12 +0200	[thread overview]
Message-ID: <20250606114412.GD1289709@pevik> (raw)
In-Reply-To: <20250605-conversions-mknod-v5-5-0b5cff90c21c@suse.com>

Hi Ricardo,

...
> -/*
> - * Test Name: mknod05
> - *
> - * Test Description:
> - *  Verify that mknod(2) succeeds when used by root to create a filesystem
> - *  node with set group-ID bit set on a directory with set group-ID bit set.
> - *  The node created should have set group-ID bit set and its gid should be
> - *  equal to that of its parent directory.

> - *
> - * Expected Result:
> - *  mknod() should return value 0 on success and node created should have
> - *  set group-ID bit set and its gid should be equal to that of its parent
> - *  directory.
> - *
...
> +/*\
> + * Verify that mknod(2) succeeds when used to create a filesystem node with
> + * set group-ID bit set on a directory with set group-ID bit set. The node
very nit: The original reader was not consistent when referring to setuid.
Mostly he used "set-group-ID" which is also used in man chmod(2) and in The
Linux Programming Interface book. Therefore I'll modify before merge:

s/set group-ID/set-group-ID/

> + * created should have set group-ID bit set and its gid should be equal to
> + * that of its parent directory.
>   */

> -#define LTPUSER		"nobody"
> -#define MODE_RWX	S_IFIFO | S_IRWXU | S_IRWXG | S_IRWXO
> -#define MODE_SGID       S_IFIFO | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO

And again, as I noted at mknod0[34].c here is constant used for mknod() uses
S_IFIFO.

> -struct stat buf;		/* struct. to hold stat(2) o/p contents */
> -struct passwd *user1;		/* struct. to hold getpwnam(3) o/p contents */
> +#define MODE_RWX 0777
> +#define MODE_SGID (S_ISGID | 0777)

But you don't use it.

...
> +	SAFE_MKNOD(TEMP_NODE, MODE_SGID, 0);

> -		/*
> -		 *  Attempt to create a filesystem node with group id (sgid)
> -		 *  bit set on a directory with group id (sgid) bit set
> -		 *  such that, the node created by mknod(2) should have
> -		 *  group id (sgid) bit set and node's gid should be equal
> -		 *  to that of effective gid of the process.
> -		 */
> -		TEST(mknod(node_name, MODE_SGID, 0));

I vote for following diff (using a constant you defined also for mknod03.c).
No need to repost, I can change it before merge.

Kind regards,
Petr

+++ testcases/kernel/syscalls/mknod/mknod05.c
@@ -7,8 +7,8 @@
 
 /*\
  * Verify that mknod(2) succeeds when used to create a filesystem node with
- * set group-ID bit set on a directory with set group-ID bit set. The node
- * created should have set group-ID bit set and its gid should be equal to
+ * set-group-ID bit set on a directory with set-group-ID bit set. The node
+ * created should have set-group-ID bit set and its gid should be equal to
  * that of its parent directory.
  */
 
@@ -17,7 +17,7 @@
 #include "tst_test.h"
 
 #define MODE_RWX 0777
-#define MODE_SGID (S_ISGID | 0777)
+#define MODE_FIFO_SGID (S_IFIFO | S_ISGID | 0777)
 
 #define TEMP_DIR "testdir"
 #define TEMP_NODE TEMP_DIR "/testnode"
@@ -29,7 +29,7 @@ static void run(void)
 {
 	struct stat buf;
 
-	SAFE_MKNOD(TEMP_NODE, MODE_SGID, 0);
+	SAFE_MKNOD(TEMP_NODE, MODE_FIFO_SGID, 0);
 
 	SAFE_STAT(TEMP_NODE, &buf);
 	TST_EXP_EQ_LI(buf.st_mode & S_ISGID, S_ISGID);
@@ -48,7 +48,7 @@ static void setup(void)
 
 	SAFE_MKDIR(TEMP_DIR, MODE_RWX);
 	SAFE_CHOWN(TEMP_DIR, nobody_uid, free_gid);
-	SAFE_CHMOD(TEMP_DIR, MODE_SGID);
+	SAFE_CHMOD(TEMP_DIR, MODE_FIFO_SGID);
 }
 
 static struct tst_test test = {

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2025-06-06 11:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 12:52 [LTP] [PATCH v5 0/8] syscalls/mknod: Refactor all tests Ricardo B. Marlière via ltp
2025-06-05 12:52 ` [LTP] [PATCH v5 1/8] syscalls/mknod01: Fix checkpatch.pl warnings Ricardo B. Marlière via ltp
2025-06-05 12:52 ` [LTP] [PATCH v5 2/8] syscalls/mknod02: Use relative path to avoid use of SAFE_CHDIR Ricardo B. Marlière via ltp
2025-06-06 10:08   ` Petr Vorel
2025-06-05 12:52 ` [LTP] [PATCH v5 3/8] syscalls/mknod03: Convert to new API Ricardo B. Marlière via ltp
2025-06-06 10:34   ` Petr Vorel
2025-06-06 11:49   ` Petr Vorel
2025-06-06 11:57     ` Ricardo B. Marlière via ltp
2025-06-06 12:33       ` Petr Vorel
2025-06-05 12:52 ` [LTP] [PATCH v5 4/8] syscalls/mknod04: " Ricardo B. Marlière via ltp
2025-06-06 10:48   ` Petr Vorel
2025-06-06 11:05   ` Ricardo B. Marlière via ltp
2025-06-06 11:27   ` Petr Vorel
2025-06-06 11:31     ` Ricardo B. Marlière via ltp
2025-06-06 13:59       ` Petr Vorel
2025-06-05 12:52 ` [LTP] [PATCH v5 5/8] syscalls/mknod05: " Ricardo B. Marlière via ltp
2025-06-06 11:44   ` Petr Vorel [this message]
2025-06-06 11:45     ` Ricardo B. Marlière via ltp
2025-06-05 12:52 ` [LTP] [PATCH v5 6/8] syscalls/mknod06: " Ricardo B. Marlière via ltp
2025-06-06 12:06   ` Petr Vorel
2025-06-05 12:52 ` [LTP] [PATCH v5 7/8] syscalls/mknod07: " Ricardo B. Marlière via ltp
2025-06-06 12:21   ` Petr Vorel
2025-06-05 12:52 ` [LTP] [PATCH v5 8/8] syscalls/mknod08: " Ricardo B. Marlière 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=20250606114412.GD1289709@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=rbm@suse.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