* [LTP] [PATCH v1] mount08.c: Restrict overmounting of ephemeral entities on /proc/<pid>/fd/<nr>
@ 2024-12-25 11:42 Wei Gao via ltp
2025-02-19 13:27 ` Andrea Cervesato via ltp
2025-03-19 4:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
0 siblings, 2 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2024-12-25 11:42 UTC (permalink / raw)
To: ltp
Signed-off-by: Wei Gao <wegao@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/mount/.gitignore | 1 +
testcases/kernel/syscalls/mount/mount08.c | 56 ++++++++++++++++++++++
3 files changed, 58 insertions(+)
create mode 100644 testcases/kernel/syscalls/mount/mount08.c
diff --git a/runtest/syscalls b/runtest/syscalls
index ded035ee8..d3abc8b85 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -852,6 +852,7 @@ mount04 mount04
mount05 mount05
mount06 mount06
mount07 mount07
+mount08 mount08
mount_setattr01 mount_setattr01
diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
index 80885dbf0..3eee5863a 100644
--- a/testcases/kernel/syscalls/mount/.gitignore
+++ b/testcases/kernel/syscalls/mount/.gitignore
@@ -6,3 +6,4 @@
/mount05
/mount06
/mount07
+/mount08
diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
new file mode 100644
index 000000000..9b54ea835
--- /dev/null
+++ b/testcases/kernel/syscalls/mount/mount08.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test check restrict overmounting on /proc/<pid>/fd/<nr>.
+ * It is based on the following kernel commit:
+ * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
+ */
+
+#include "tst_test.h"
+#include <sys/mount.h>
+#include "tst_safe_file_at.h"
+
+#define MNTPOINT "mntpoint"
+#define FOO MNTPOINT "/foo"
+#define BAR MNTPOINT "/bar"
+
+static void run(void)
+{
+ char path[PATH_MAX];
+ int foo_fd, newfd, proc_fd;
+
+ foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
+ newfd = SAFE_DUP(foo_fd);
+ SAFE_CLOSE(foo_fd);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
+
+ proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
+
+ TST_EXP_FAIL(
+ mount(BAR, path, "", MS_BIND, 0),
+ ENOENT,
+ "mount() on proc failed expectedly"
+ );
+}
+
+static void setup(void)
+{
+ SAFE_CREAT(FOO, 0777);
+ SAFE_CREAT(BAR, 0777);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test_all = run,
+ .needs_root = 1,
+ .mntpoint = MNTPOINT,
+ .min_kver = "6.12",
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1] mount08.c: Restrict overmounting of ephemeral entities on /proc/<pid>/fd/<nr>
2024-12-25 11:42 [LTP] [PATCH v1] mount08.c: Restrict overmounting of ephemeral entities on /proc/<pid>/fd/<nr> Wei Gao via ltp
@ 2025-02-19 13:27 ` Andrea Cervesato via ltp
2025-03-19 4:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
1 sibling, 0 replies; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2025-02-19 13:27 UTC (permalink / raw)
To: Wei Gao, ltp
Hi!
Some comments below. LGTM otherwise
On 12/25/24 12:42, Wei Gao via ltp wrote:
> Signed-off-by: Wei Gao <wegao@suse.com>
We miss a description here. Maybe something like:
Add a new test to verify that mount will raise ENOENT if we try to mount
on magic links under /proc/<pid>/fd/<nr>.
Refer to the following kernel commit for more information:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
> ---
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/mount/.gitignore | 1 +
> testcases/kernel/syscalls/mount/mount08.c | 56 ++++++++++++++++++++++
> 3 files changed, 58 insertions(+)
> create mode 100644 testcases/kernel/syscalls/mount/mount08.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index ded035ee8..d3abc8b85 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -852,6 +852,7 @@ mount04 mount04
> mount05 mount05
> mount06 mount06
> mount07 mount07
> +mount08 mount08
>
> mount_setattr01 mount_setattr01
>
> diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
> index 80885dbf0..3eee5863a 100644
> --- a/testcases/kernel/syscalls/mount/.gitignore
> +++ b/testcases/kernel/syscalls/mount/.gitignore
> @@ -6,3 +6,4 @@
> /mount05
> /mount06
> /mount07
> +/mount08
> diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
> new file mode 100644
> index 000000000..9b54ea835
> --- /dev/null
> +++ b/testcases/kernel/syscalls/mount/mount08.c
> @@ -0,0 +1,56 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2024 Wei Gao <wegao@suse.com>
> + */
> +
> +/*\
> + * [Description]
This is not needed anymore.
> + *
> + * This test check restrict overmounting on /proc/<pid>/fd/<nr>.
> + * It is based on the following kernel commit:
> + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
"Verify that mount will raise ENOENT if we try to mount on magic links
under /proc/<pid>/fd/<nr>."
Link is not needed if we already have .tags in the "struct tst_test".
See below
> + */
> +
> +#include "tst_test.h"
> +#include <sys/mount.h>
> +#include "tst_safe_file_at.h"
> +
> +#define MNTPOINT "mntpoint"
> +#define FOO MNTPOINT "/foo"
> +#define BAR MNTPOINT "/bar"
> +
> +static void run(void)
> +{
> + char path[PATH_MAX];
> + int foo_fd, newfd, proc_fd;
> +
> + foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
> + newfd = SAFE_DUP(foo_fd);
> + SAFE_CLOSE(foo_fd);
> +
> + sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
> +
> + proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
> +
> + sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
> +
> + TST_EXP_FAIL(
> + mount(BAR, path, "", MS_BIND, 0),
> + ENOENT,
> + "mount() on proc failed expectedly"
> + );
> +}
> +
> +static void setup(void)
> +{
> + SAFE_CREAT(FOO, 0777);
> + SAFE_CREAT(BAR, 0777);
> +}
> +
> +static struct tst_test test = {
> + .setup = setup,
> + .test_all = run,
> + .needs_root = 1,
> + .mntpoint = MNTPOINT,
> + .min_kver = "6.12",
We miss .tags to the kernel commit in here:
> +};
Kind regards,
Andrea Cervesato
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v2] mount08.c: Restrict overmounting of ephemeral entities on /proc/<pid>/fd/<nr>
2024-12-25 11:42 [LTP] [PATCH v1] mount08.c: Restrict overmounting of ephemeral entities on /proc/<pid>/fd/<nr> Wei Gao via ltp
2025-02-19 13:27 ` Andrea Cervesato via ltp
@ 2025-03-19 4:47 ` Wei Gao via ltp
2025-03-20 14:53 ` Andrea Cervesato via ltp
2025-03-21 3:42 ` [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities Wei Gao via ltp
1 sibling, 2 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-03-19 4:47 UTC (permalink / raw)
To: ltp
Signed-off-by: Wei Gao <wegao@suse.com>
Add a new test to verify that mount will raise ENOENT if we try to mount
on magic links under /proc/<pid>/fd/<nr>.
Refer to the following kernel commit for more information:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
Signed-off-by: Wei Gao <wegao@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/mount/.gitignore | 1 +
testcases/kernel/syscalls/mount/mount08.c | 57 ++++++++++++++++++++++
3 files changed, 59 insertions(+)
create mode 100644 testcases/kernel/syscalls/mount/mount08.c
diff --git a/runtest/syscalls b/runtest/syscalls
index ded035ee8..d3abc8b85 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -852,6 +852,7 @@ mount04 mount04
mount05 mount05
mount06 mount06
mount07 mount07
+mount08 mount08
mount_setattr01 mount_setattr01
diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
index 80885dbf0..3eee5863a 100644
--- a/testcases/kernel/syscalls/mount/.gitignore
+++ b/testcases/kernel/syscalls/mount/.gitignore
@@ -6,3 +6,4 @@
/mount05
/mount06
/mount07
+/mount08
diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
new file mode 100644
index 000000000..1938c5519
--- /dev/null
+++ b/testcases/kernel/syscalls/mount/mount08.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*\
+ * Verify that mount will raise ENOENT if we try to mount on magic links
+ * under /proc/<pid>/fd/<nr>.
+ */
+
+#include "tst_test.h"
+#include <sys/mount.h>
+#include "tst_safe_file_at.h"
+
+#define MNTPOINT "mntpoint"
+#define FOO MNTPOINT "/foo"
+#define BAR MNTPOINT "/bar"
+
+static void run(void)
+{
+ char path[PATH_MAX];
+ int foo_fd, newfd, proc_fd;
+
+ foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
+ newfd = SAFE_DUP(foo_fd);
+ SAFE_CLOSE(foo_fd);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
+
+ proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
+
+ TST_EXP_FAIL(
+ mount(BAR, path, "", MS_BIND, 0),
+ ENOENT,
+ "mount() on proc failed expectedly"
+ );
+}
+
+static void setup(void)
+{
+ SAFE_CREAT(FOO, 0777);
+ SAFE_CREAT(BAR, 0777);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test_all = run,
+ .needs_root = 1,
+ .mntpoint = MNTPOINT,
+ .min_kver = "6.12",
+ .tags = (const struct tst_tag[]) {
+ {"linux-git", "d80b065bb172"},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v2] mount08.c: Restrict overmounting of ephemeral entities on /proc/<pid>/fd/<nr>
2025-03-19 4:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
@ 2025-03-20 14:53 ` Andrea Cervesato via ltp
2025-03-21 3:42 ` [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities Wei Gao via ltp
1 sibling, 0 replies; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2025-03-20 14:53 UTC (permalink / raw)
To: Wei Gao, ltp
Hi Wei,
Commit message is a bit long. it should be 72 chars max. Maybe we can
just use "mount08: Restrict overmounting of ephemeral entities".
On 3/19/25 05:47, Wei Gao via ltp wrote:
> Signed-off-by: Wei Gao <wegao@suse.com>
Uhm Signed-off-by here is a weird thing :-)
Otherwise LGTM.
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities
2025-03-19 4:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-03-20 14:53 ` Andrea Cervesato via ltp
@ 2025-03-21 3:42 ` Wei Gao via ltp
2025-03-21 10:27 ` Ricardo B. Marli��re via ltp
2025-03-21 15:11 ` [LTP] [PATCH v4] " Wei Gao via ltp
1 sibling, 2 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-03-21 3:42 UTC (permalink / raw)
To: ltp
Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
Add a new test to verify that mount will raise ENOENT if we try to mount
on magic links under /proc/<pid>/fd/<nr>.
Refer to the following kernel commit for more information:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
Signed-off-by: Wei Gao <wegao@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/mount/.gitignore | 1 +
testcases/kernel/syscalls/mount/mount08.c | 57 ++++++++++++++++++++++
3 files changed, 59 insertions(+)
create mode 100644 testcases/kernel/syscalls/mount/mount08.c
diff --git a/runtest/syscalls b/runtest/syscalls
index ded035ee8..d3abc8b85 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -852,6 +852,7 @@ mount04 mount04
mount05 mount05
mount06 mount06
mount07 mount07
+mount08 mount08
mount_setattr01 mount_setattr01
diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
index 80885dbf0..3eee5863a 100644
--- a/testcases/kernel/syscalls/mount/.gitignore
+++ b/testcases/kernel/syscalls/mount/.gitignore
@@ -6,3 +6,4 @@
/mount05
/mount06
/mount07
+/mount08
diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
new file mode 100644
index 000000000..1938c5519
--- /dev/null
+++ b/testcases/kernel/syscalls/mount/mount08.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*\
+ * Verify that mount will raise ENOENT if we try to mount on magic links
+ * under /proc/<pid>/fd/<nr>.
+ */
+
+#include "tst_test.h"
+#include <sys/mount.h>
+#include "tst_safe_file_at.h"
+
+#define MNTPOINT "mntpoint"
+#define FOO MNTPOINT "/foo"
+#define BAR MNTPOINT "/bar"
+
+static void run(void)
+{
+ char path[PATH_MAX];
+ int foo_fd, newfd, proc_fd;
+
+ foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
+ newfd = SAFE_DUP(foo_fd);
+ SAFE_CLOSE(foo_fd);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
+
+ proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
+
+ TST_EXP_FAIL(
+ mount(BAR, path, "", MS_BIND, 0),
+ ENOENT,
+ "mount() on proc failed expectedly"
+ );
+}
+
+static void setup(void)
+{
+ SAFE_CREAT(FOO, 0777);
+ SAFE_CREAT(BAR, 0777);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test_all = run,
+ .needs_root = 1,
+ .mntpoint = MNTPOINT,
+ .min_kver = "6.12",
+ .tags = (const struct tst_tag[]) {
+ {"linux-git", "d80b065bb172"},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities
2025-03-21 3:42 ` [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities Wei Gao via ltp
@ 2025-03-21 10:27 ` Ricardo B. Marli��re via ltp
2025-03-21 15:14 ` Wei Gao via ltp
2025-03-21 15:11 ` [LTP] [PATCH v4] " Wei Gao via ltp
1 sibling, 1 reply; 18+ messages in thread
From: Ricardo B. Marli��re via ltp @ 2025-03-21 10:27 UTC (permalink / raw)
To: Wei Gao, ltp; +Cc: ltp
On Fri Mar 21, 2025 at 12:42 AM -03, Wei Gao via ltp wrote:
> Signed-off-by: Wei Gao <wegao@suse.com>
> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
This is still wrong. :(
>
> Add a new test to verify that mount will raise ENOENT if we try to mount
> on magic links under /proc/<pid>/fd/<nr>.
> Refer to the following kernel commit for more information:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
>
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/mount/.gitignore | 1 +
> testcases/kernel/syscalls/mount/mount08.c | 57 ++++++++++++++++++++++
> 3 files changed, 59 insertions(+)
> create mode 100644 testcases/kernel/syscalls/mount/mount08.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index ded035ee8..d3abc8b85 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -852,6 +852,7 @@ mount04 mount04
> mount05 mount05
> mount06 mount06
> mount07 mount07
> +mount08 mount08
>
> mount_setattr01 mount_setattr01
>
> diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
> index 80885dbf0..3eee5863a 100644
> --- a/testcases/kernel/syscalls/mount/.gitignore
> +++ b/testcases/kernel/syscalls/mount/.gitignore
> @@ -6,3 +6,4 @@
> /mount05
> /mount06
> /mount07
> +/mount08
> diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
> new file mode 100644
> index 000000000..1938c5519
> --- /dev/null
> +++ b/testcases/kernel/syscalls/mount/mount08.c
> @@ -0,0 +1,57 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2024 Wei Gao <wegao@suse.com>
> + */
> +
> +/*\
> + * Verify that mount will raise ENOENT if we try to mount on magic links
> + * under /proc/<pid>/fd/<nr>.
> + */
> +
> +#include "tst_test.h"
> +#include <sys/mount.h>
> +#include "tst_safe_file_at.h"
> +
> +#define MNTPOINT "mntpoint"
> +#define FOO MNTPOINT "/foo"
> +#define BAR MNTPOINT "/bar"
> +
> +static void run(void)
> +{
> + char path[PATH_MAX];
> + int foo_fd, newfd, proc_fd;
> +
> + foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
> + newfd = SAFE_DUP(foo_fd);
> + SAFE_CLOSE(foo_fd);
> +
> + sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
> +
> + proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
> +
> + sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
> +
> + TST_EXP_FAIL(
> + mount(BAR, path, "", MS_BIND, 0),
> + ENOENT,
> + "mount() on proc failed expectedly"
> + );
> +}
> +
> +static void setup(void)
> +{
> + SAFE_CREAT(FOO, 0777);
> + SAFE_CREAT(BAR, 0777);
> +}
> +
> +static struct tst_test test = {
> + .setup = setup,
> + .test_all = run,
> + .needs_root = 1,
> + .mntpoint = MNTPOINT,
> + .min_kver = "6.12",
> + .tags = (const struct tst_tag[]) {
> + {"linux-git", "d80b065bb172"},
> + {}
> + }
> +};
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v4] mount08.c: Restrict overmounting of ephemeral entities
2025-03-21 3:42 ` [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities Wei Gao via ltp
2025-03-21 10:27 ` Ricardo B. Marli��re via ltp
@ 2025-03-21 15:11 ` Wei Gao via ltp
2025-07-11 13:02 ` Cyril Hrubis
2025-07-21 20:04 ` [LTP] [PATCH v5] " Wei Gao via ltp
1 sibling, 2 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-03-21 15:11 UTC (permalink / raw)
To: ltp
Add a new test to verify that mount will raise ENOENT if we try to mount
on magic links under /proc/<pid>/fd/<nr>.
Refer to the following kernel commit for more information:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/mount/.gitignore | 1 +
testcases/kernel/syscalls/mount/mount08.c | 57 ++++++++++++++++++++++
3 files changed, 59 insertions(+)
create mode 100644 testcases/kernel/syscalls/mount/mount08.c
diff --git a/runtest/syscalls b/runtest/syscalls
index ded035ee8..d3abc8b85 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -852,6 +852,7 @@ mount04 mount04
mount05 mount05
mount06 mount06
mount07 mount07
+mount08 mount08
mount_setattr01 mount_setattr01
diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
index 80885dbf0..3eee5863a 100644
--- a/testcases/kernel/syscalls/mount/.gitignore
+++ b/testcases/kernel/syscalls/mount/.gitignore
@@ -6,3 +6,4 @@
/mount05
/mount06
/mount07
+/mount08
diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
new file mode 100644
index 000000000..1938c5519
--- /dev/null
+++ b/testcases/kernel/syscalls/mount/mount08.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*\
+ * Verify that mount will raise ENOENT if we try to mount on magic links
+ * under /proc/<pid>/fd/<nr>.
+ */
+
+#include "tst_test.h"
+#include <sys/mount.h>
+#include "tst_safe_file_at.h"
+
+#define MNTPOINT "mntpoint"
+#define FOO MNTPOINT "/foo"
+#define BAR MNTPOINT "/bar"
+
+static void run(void)
+{
+ char path[PATH_MAX];
+ int foo_fd, newfd, proc_fd;
+
+ foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
+ newfd = SAFE_DUP(foo_fd);
+ SAFE_CLOSE(foo_fd);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
+
+ proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
+
+ TST_EXP_FAIL(
+ mount(BAR, path, "", MS_BIND, 0),
+ ENOENT,
+ "mount() on proc failed expectedly"
+ );
+}
+
+static void setup(void)
+{
+ SAFE_CREAT(FOO, 0777);
+ SAFE_CREAT(BAR, 0777);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test_all = run,
+ .needs_root = 1,
+ .mntpoint = MNTPOINT,
+ .min_kver = "6.12",
+ .tags = (const struct tst_tag[]) {
+ {"linux-git", "d80b065bb172"},
+ {}
+ }
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities
2025-03-21 10:27 ` Ricardo B. Marli��re via ltp
@ 2025-03-21 15:14 ` Wei Gao via ltp
0 siblings, 0 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-03-21 15:14 UTC (permalink / raw)
To: Ricardo B. Marlière; +Cc: ltp, ltp
On Fri, Mar 21, 2025 at 07:27:30AM -0300, Ricardo B. Marlière wrote:
> On Fri Mar 21, 2025 at 12:42 AM -03, Wei Gao via ltp wrote:
> > Signed-off-by: Wei Gao <wegao@suse.com>
> > Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
>
> This is still wrong. :(
@Ricardo Thanks for point this out.
@Andrea Sorry for misunderstanding your comments in v2 comments.
>
> >
> > Add a new test to verify that mount will raise ENOENT if we try to mount
> > on magic links under /proc/<pid>/fd/<nr>.
> > Refer to the following kernel commit for more information:
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v4] mount08.c: Restrict overmounting of ephemeral entities
2025-03-21 15:11 ` [LTP] [PATCH v4] " Wei Gao via ltp
@ 2025-07-11 13:02 ` Cyril Hrubis
2025-07-21 20:04 ` [LTP] [PATCH v5] " Wei Gao via ltp
1 sibling, 0 replies; 18+ messages in thread
From: Cyril Hrubis @ 2025-07-11 13:02 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi!
> Signed-off-by: Wei Gao <wegao@suse.com>
> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/mount/.gitignore | 1 +
> testcases/kernel/syscalls/mount/mount08.c | 57 ++++++++++++++++++++++
> 3 files changed, 59 insertions(+)
> create mode 100644 testcases/kernel/syscalls/mount/mount08.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index ded035ee8..d3abc8b85 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -852,6 +852,7 @@ mount04 mount04
> mount05 mount05
> mount06 mount06
> mount07 mount07
> +mount08 mount08
>
> mount_setattr01 mount_setattr01
>
> diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
> index 80885dbf0..3eee5863a 100644
> --- a/testcases/kernel/syscalls/mount/.gitignore
> +++ b/testcases/kernel/syscalls/mount/.gitignore
> @@ -6,3 +6,4 @@
> /mount05
> /mount06
> /mount07
> +/mount08
> diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
> new file mode 100644
> index 000000000..1938c5519
> --- /dev/null
> +++ b/testcases/kernel/syscalls/mount/mount08.c
> @@ -0,0 +1,57 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2024 Wei Gao <wegao@suse.com>
> + */
> +
> +/*\
> + * Verify that mount will raise ENOENT if we try to mount on magic links
> + * under /proc/<pid>/fd/<nr>.
> + */
> +
> +#include "tst_test.h"
> +#include <sys/mount.h>
> +#include "tst_safe_file_at.h"
> +
> +#define MNTPOINT "mntpoint"
> +#define FOO MNTPOINT "/foo"
> +#define BAR MNTPOINT "/bar"
> +
> +static void run(void)
> +{
> + char path[PATH_MAX];
> + int foo_fd, newfd, proc_fd;
> +
> + foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
> + newfd = SAFE_DUP(foo_fd);
> + SAFE_CLOSE(foo_fd);
AFAIK the dup() here is not needed, the original reproducer used the
dup() to create a file descriptor with exact number for the loop. In
this case we can just take the fd from SAFE_OPEN() and use it instead of
the newfd.
> + sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
> +
> + proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
> +
> + sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
> +
> + TST_EXP_FAIL(
> + mount(BAR, path, "", MS_BIND, 0),
> + ENOENT,
> + "mount() on proc failed expectedly"
^
This message is used even if the call passed
unexpectedly, so it should describe what is being done
rather than the expected outcome, e.g.:
"mount(/proc/$PID/fd/$FD)"
> + );
You are not closing the file descriptors here, so the test fails with:
"-i 1000" command line params.
> +}
> +
> +static void setup(void)
> +{
> + SAFE_CREAT(FOO, 0777);
> + SAFE_CREAT(BAR, 0777);
This leaks two file descriptors too, but at least it's these are not
opened on each iteration.
If you just need to create a file do SAFE_TOUCH(FOO, 0777, NULL)
instead.
> +}
> +
> +static struct tst_test test = {
> + .setup = setup,
> + .test_all = run,
> + .needs_root = 1,
> + .mntpoint = MNTPOINT,
> + .min_kver = "6.12",
With this you are masking the problem on older kernels, please do not,
as the problem has possible security implications.
> + .tags = (const struct tst_tag[]) {
> + {"linux-git", "d80b065bb172"},
> + {}
> + }
> +};
> --
> 2.35.3
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v5] mount08.c: Restrict overmounting of ephemeral entities
2025-03-21 15:11 ` [LTP] [PATCH v4] " Wei Gao via ltp
2025-07-11 13:02 ` Cyril Hrubis
@ 2025-07-21 20:04 ` Wei Gao via ltp
2025-07-22 6:40 ` Andrea Cervesato via ltp
2025-07-22 18:54 ` [LTP] [PATCH v6] " Wei Gao via ltp
1 sibling, 2 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-07-21 20:04 UTC (permalink / raw)
To: ltp
Add a new test to verify that mount will raise ENOENT if we try to mount
on magic links under /proc/<pid>/fd/<nr>.
Refer to the following kernel commit for more information:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/mount/.gitignore | 1 +
testcases/kernel/syscalls/mount/mount08.c | 57 ++++++++++++++++++++++
3 files changed, 59 insertions(+)
create mode 100644 testcases/kernel/syscalls/mount/mount08.c
diff --git a/runtest/syscalls b/runtest/syscalls
index e738c332b..3531c2a3c 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -865,6 +865,7 @@ mount04 mount04
mount05 mount05
mount06 mount06
mount07 mount07
+mount08 mount08
mount_setattr01 mount_setattr01
diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
index 80885dbf0..3eee5863a 100644
--- a/testcases/kernel/syscalls/mount/.gitignore
+++ b/testcases/kernel/syscalls/mount/.gitignore
@@ -6,3 +6,4 @@
/mount05
/mount06
/mount07
+/mount08
diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
new file mode 100644
index 000000000..1938c5519
--- /dev/null
+++ b/testcases/kernel/syscalls/mount/mount08.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*\
+ * Verify that mount will raise ENOENT if we try to mount on magic links
+ * under /proc/<pid>/fd/<nr>.
+ */
+
+#include "tst_test.h"
+#include <sys/mount.h>
+#include "tst_safe_file_at.h"
+
+#define MNTPOINT "mntpoint"
+#define FOO MNTPOINT "/foo"
+#define BAR MNTPOINT "/bar"
+
+static void run(void)
+{
+ char path[PATH_MAX];
+ int foo_fd, newfd, proc_fd;
+
+ foo_fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
+ newfd = SAFE_DUP(foo_fd);
+ SAFE_CLOSE(foo_fd);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), newfd);
+
+ proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
+
+ TST_EXP_FAIL(
+ mount(BAR, path, "", MS_BIND, 0),
+ ENOENT,
+ "mount() on proc failed expectedly"
+ );
+}
+
+static void setup(void)
+{
+ SAFE_CREAT(FOO, 0777);
+ SAFE_CREAT(BAR, 0777);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test_all = run,
+ .needs_root = 1,
+ .mntpoint = MNTPOINT,
+ .min_kver = "6.12",
+ .tags = (const struct tst_tag[]) {
+ {"linux-git", "d80b065bb172"},
+ {}
+ }
+};
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v5] mount08.c: Restrict overmounting of ephemeral entities
2025-07-21 20:04 ` [LTP] [PATCH v5] " Wei Gao via ltp
@ 2025-07-22 6:40 ` Andrea Cervesato via ltp
2025-07-22 19:00 ` Wei Gao via ltp
2025-07-22 18:54 ` [LTP] [PATCH v6] " Wei Gao via ltp
1 sibling, 1 reply; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-22 6:40 UTC (permalink / raw)
To: Wei Gao, ltp
Hi!
please achieve the v4 given by Cyryil before sending a new patch.
- Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v6] mount08.c: Restrict overmounting of ephemeral entities
2025-07-21 20:04 ` [LTP] [PATCH v5] " Wei Gao via ltp
2025-07-22 6:40 ` Andrea Cervesato via ltp
@ 2025-07-22 18:54 ` Wei Gao via ltp
2025-07-23 11:51 ` Andrea Cervesato via ltp
` (2 more replies)
1 sibling, 3 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-07-22 18:54 UTC (permalink / raw)
To: ltp
Add a new test to verify that mount will raise ENOENT if we try to mount
on magic links under /proc/<pid>/fd/<nr>.
Refer to the following kernel commit for more information:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/mount/.gitignore | 1 +
testcases/kernel/syscalls/mount/mount08.c | 57 ++++++++++++++++++++++
3 files changed, 59 insertions(+)
create mode 100644 testcases/kernel/syscalls/mount/mount08.c
diff --git a/runtest/syscalls b/runtest/syscalls
index e738c332b..3531c2a3c 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -865,6 +865,7 @@ mount04 mount04
mount05 mount05
mount06 mount06
mount07 mount07
+mount08 mount08
mount_setattr01 mount_setattr01
diff --git a/testcases/kernel/syscalls/mount/.gitignore b/testcases/kernel/syscalls/mount/.gitignore
index 80885dbf0..3eee5863a 100644
--- a/testcases/kernel/syscalls/mount/.gitignore
+++ b/testcases/kernel/syscalls/mount/.gitignore
@@ -6,3 +6,4 @@
/mount05
/mount06
/mount07
+/mount08
diff --git a/testcases/kernel/syscalls/mount/mount08.c b/testcases/kernel/syscalls/mount/mount08.c
new file mode 100644
index 000000000..e2824ac55
--- /dev/null
+++ b/testcases/kernel/syscalls/mount/mount08.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*\
+ * Verify that mount will raise ENOENT if we try to mount on magic links
+ * under /proc/<pid>/fd/<nr>.
+ */
+
+#include "tst_test.h"
+#include <sys/mount.h>
+#include "tst_safe_file_at.h"
+
+#define MNTPOINT "mntpoint"
+#define FOO MNTPOINT "/foo"
+#define BAR MNTPOINT "/bar"
+
+static void run(void)
+{
+ char path[PATH_MAX];
+ int fd, proc_fd;
+
+ fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), fd);
+
+ proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
+
+ sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
+
+ TST_EXP_FAIL(
+ mount(BAR, path, "", MS_BIND, 0),
+ ENOENT,
+ "mount(%s)", path
+ );
+
+ SAFE_CLOSE(fd);
+ SAFE_CLOSE(proc_fd);
+}
+
+static void setup(void)
+{
+ SAFE_TOUCH(FOO, 0777, NULL);
+ SAFE_TOUCH(BAR, 0777, NULL);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test_all = run,
+ .needs_root = 1,
+ .mntpoint = MNTPOINT,
+ .tags = (const struct tst_tag[]) {
+ {"linux-git", "d80b065bb172"},
+ {}
+ }
+};
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v5] mount08.c: Restrict overmounting of ephemeral entities
2025-07-22 6:40 ` Andrea Cervesato via ltp
@ 2025-07-22 19:00 ` Wei Gao via ltp
0 siblings, 0 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-07-22 19:00 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
On Tue, Jul 22, 2025 at 08:40:02AM +0200, Andrea Cervesato wrote:
> Hi!
>
> please achieve the v4 given by Cyryil before sending a new patch.
>
Sorry, the diff not --amend before i format patch.
Resent patch v6.
Thansk.
> - Andrea
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v6] mount08.c: Restrict overmounting of ephemeral entities
2025-07-22 18:54 ` [LTP] [PATCH v6] " Wei Gao via ltp
@ 2025-07-23 11:51 ` Andrea Cervesato via ltp
2025-07-23 12:42 ` Cyril Hrubis
2025-07-24 17:04 ` Petr Vorel
2 siblings, 0 replies; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-23 11:51 UTC (permalink / raw)
To: Wei Gao, ltp
Hi!
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v6] mount08.c: Restrict overmounting of ephemeral entities
2025-07-22 18:54 ` [LTP] [PATCH v6] " Wei Gao via ltp
2025-07-23 11:51 ` Andrea Cervesato via ltp
@ 2025-07-23 12:42 ` Cyril Hrubis
2025-07-24 17:04 ` Petr Vorel
2 siblings, 0 replies; 18+ messages in thread
From: Cyril Hrubis @ 2025-07-23 12:42 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v6] mount08.c: Restrict overmounting of ephemeral entities
2025-07-22 18:54 ` [LTP] [PATCH v6] " Wei Gao via ltp
2025-07-23 11:51 ` Andrea Cervesato via ltp
2025-07-23 12:42 ` Cyril Hrubis
@ 2025-07-24 17:04 ` Petr Vorel
2025-07-24 17:10 ` Petr Vorel
2 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-07-24 17:04 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi Wei, all,
> Add a new test to verify that mount will raise ENOENT if we try to mount
> on magic links under /proc/<pid>/fd/<nr>.
> Refer to the following kernel commit for more information:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
...
> --- /dev/null
> +++ b/testcases/kernel/syscalls/mount/mount08.c
> @@ -0,0 +1,57 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2024 Wei Gao <wegao@suse.com>
> + */
> +
> +/*\
> + * Verify that mount will raise ENOENT if we try to mount on magic links
> + * under /proc/<pid>/fd/<nr>.
> + */
> +
> +#include "tst_test.h"
> +#include <sys/mount.h>
> +#include "tst_safe_file_at.h"
> +
> +#define MNTPOINT "mntpoint"
> +#define FOO MNTPOINT "/foo"
> +#define BAR MNTPOINT "/bar"
> +
> +static void run(void)
> +{
> + char path[PATH_MAX];
> + int fd, proc_fd;
> +
> + fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
> +
> + sprintf(path, "/proc/%d/fd/%d", getpid(), fd);
> +
> + proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
> +
> + sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
> +
> + TST_EXP_FAIL(
> + mount(BAR, path, "", MS_BIND, 0),
> + ENOENT,
> + "mount(%s)", path
FYI Test is failing on Tumbleweed 6.15.7, can you please have look?
mount08.c:32: TFAIL: mount(/proc/130511/fd/4) expected ENOENT: EACCES (13)
As Tumbleweed is very close to mainline kernel it will probably fail on mainline
as well. But maybe it's one of few Tumbleweed patches which causes that.
Kind regards,
Petr
> + );
> +
> + SAFE_CLOSE(fd);
> + SAFE_CLOSE(proc_fd);
> +}
> +
> +static void setup(void)
> +{
> + SAFE_TOUCH(FOO, 0777, NULL);
> + SAFE_TOUCH(BAR, 0777, NULL);
> +}
> +
> +static struct tst_test test = {
> + .setup = setup,
> + .test_all = run,
> + .needs_root = 1,
> + .mntpoint = MNTPOINT,
> + .tags = (const struct tst_tag[]) {
> + {"linux-git", "d80b065bb172"},
> + {}
> + }
> +};
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v6] mount08.c: Restrict overmounting of ephemeral entities
2025-07-24 17:04 ` Petr Vorel
@ 2025-07-24 17:10 ` Petr Vorel
2025-07-25 12:54 ` Wei Gao via ltp
0 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-07-24 17:10 UTC (permalink / raw)
To: Wei Gao, ltp, Andrea Cervesato, Cyril Hrubis
> Hi Wei, all,
> > Add a new test to verify that mount will raise ENOENT if we try to mount
> > on magic links under /proc/<pid>/fd/<nr>.
> > Refer to the following kernel commit for more information:
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80b065bb172
> ...
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/mount/mount08.c
> > @@ -0,0 +1,57 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Copyright (C) 2024 Wei Gao <wegao@suse.com>
> > + */
> > +
> > +/*\
> > + * Verify that mount will raise ENOENT if we try to mount on magic links
> > + * under /proc/<pid>/fd/<nr>.
> > + */
> > +
> > +#include "tst_test.h"
> > +#include <sys/mount.h>
> > +#include "tst_safe_file_at.h"
> > +
> > +#define MNTPOINT "mntpoint"
> > +#define FOO MNTPOINT "/foo"
> > +#define BAR MNTPOINT "/bar"
> > +
> > +static void run(void)
> > +{
> > + char path[PATH_MAX];
> > + int fd, proc_fd;
> > +
> > + fd = SAFE_OPEN(FOO, O_RDONLY | O_NONBLOCK, 0640);
> > +
> > + sprintf(path, "/proc/%d/fd/%d", getpid(), fd);
> > +
> > + proc_fd = SAFE_OPENAT(AT_FDCWD, path, O_PATH | O_NOFOLLOW);
> > +
> > + sprintf(path, "/proc/%d/fd/%d", getpid(), proc_fd);
> > +
> > + TST_EXP_FAIL(
> > + mount(BAR, path, "", MS_BIND, 0),
> > + ENOENT,
> > + "mount(%s)", path
> FYI Test is failing on Tumbleweed 6.15.7, can you please have look?
> mount08.c:32: TFAIL: mount(/proc/130511/fd/4) expected ENOENT: EACCES (13)
> As Tumbleweed is very close to mainline kernel it will probably fail on mainline
> as well. But maybe it's one of few Tumbleweed patches which causes that.
Maybe it's just the environment in openQA, because running on Tumbleweed VM with
enabled SELinux it works well on both 6.15.6 and 6.16-rc1.
The same applies to recent error on ioctl_pidfd01:
ioctl_pidfd01.c:28: TFAIL: ioctl(memfd secret, PIDFD_GET_INFO, info) expected EINVAL, EBADF, ENOTTY: EACCES (13)
Kind regards,
Petr
> Kind regards,
> Petr
> > + );
> > +
> > + SAFE_CLOSE(fd);
> > + SAFE_CLOSE(proc_fd);
> > +}
> > +
> > +static void setup(void)
> > +{
> > + SAFE_TOUCH(FOO, 0777, NULL);
> > + SAFE_TOUCH(BAR, 0777, NULL);
> > +}
> > +
> > +static struct tst_test test = {
> > + .setup = setup,
> > + .test_all = run,
> > + .needs_root = 1,
> > + .mntpoint = MNTPOINT,
> > + .tags = (const struct tst_tag[]) {
> > + {"linux-git", "d80b065bb172"},
> > + {}
> > + }
> > +};
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v6] mount08.c: Restrict overmounting of ephemeral entities
2025-07-24 17:10 ` Petr Vorel
@ 2025-07-25 12:54 ` Wei Gao via ltp
0 siblings, 0 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-07-25 12:54 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Thu, Jul 24, 2025 at 07:10:36PM +0200, Petr Vorel wrote:
> > Hi Wei, all,
>
> > FYI Test is failing on Tumbleweed 6.15.7, can you please have look?
> > mount08.c:32: TFAIL: mount(/proc/130511/fd/4) expected ENOENT: EACCES (13)
>
> > As Tumbleweed is very close to mainline kernel it will probably fail on mainline
> > as well. But maybe it's one of few Tumbleweed patches which causes that.
>
> Maybe it's just the environment in openQA, because running on Tumbleweed VM with
> enabled SELinux it works well on both 6.15.6 and 6.16-rc1.
>
> The same applies to recent error on ioctl_pidfd01:
> ioctl_pidfd01.c:28: TFAIL: ioctl(memfd secret, PIDFD_GET_INFO, info) expected EINVAL, EBADF, ENOTTY: EACCES (13)
>
> Kind regards,
> Petr
Will check this, thanks for notification.
>
> > Kind regards,
> > Petr
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-07-25 0:55 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-25 11:42 [LTP] [PATCH v1] mount08.c: Restrict overmounting of ephemeral entities on /proc/<pid>/fd/<nr> Wei Gao via ltp
2025-02-19 13:27 ` Andrea Cervesato via ltp
2025-03-19 4:47 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-03-20 14:53 ` Andrea Cervesato via ltp
2025-03-21 3:42 ` [LTP] [PATCH v3] mount08.c: Restrict overmounting of ephemeral entities Wei Gao via ltp
2025-03-21 10:27 ` Ricardo B. Marli��re via ltp
2025-03-21 15:14 ` Wei Gao via ltp
2025-03-21 15:11 ` [LTP] [PATCH v4] " Wei Gao via ltp
2025-07-11 13:02 ` Cyril Hrubis
2025-07-21 20:04 ` [LTP] [PATCH v5] " Wei Gao via ltp
2025-07-22 6:40 ` Andrea Cervesato via ltp
2025-07-22 19:00 ` Wei Gao via ltp
2025-07-22 18:54 ` [LTP] [PATCH v6] " Wei Gao via ltp
2025-07-23 11:51 ` Andrea Cervesato via ltp
2025-07-23 12:42 ` Cyril Hrubis
2025-07-24 17:04 ` Petr Vorel
2025-07-24 17:10 ` Petr Vorel
2025-07-25 12:54 ` Wei Gao via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox