All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v6] mount08.c: Restrict overmounting of ephemeral entities
Date: Thu, 24 Jul 2025 19:04:24 +0200	[thread overview]
Message-ID: <20250724170424.GA108771@pevik> (raw)
In-Reply-To: <20250722185503.3224765-1-wegao@suse.com>

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

  parent reply	other threads:[~2025-07-24 17:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-07-24 17:10             ` Petr Vorel
2025-07-25 12:54               ` Wei Gao 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=20250724170424.GA108771@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=wegao@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 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.