Re: Serious error in autofs docs, which has design implications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 ---- On Fri, 22 Aug 2025 16:31:46 +0400  Ian Kent <raven@xxxxxxxxxx> wrote --- 
 > On 21/8/25 15:53, Askar Safin wrote:
 > > autofs.rst says:
 > >> mounting onto a directory is considered to be "beyond a `stat`"
 > > in https://elixir.bootlin.com/linux/v6.17-rc2/source/Documentation/filesystems/autofs.rst#L109
 > >
 > > This is not true. Mounting does not trigger automounts.
 > 
 > I don't understand that statement either, it's been many years

Let me explain.

Some syscalls follow (and trigger) automounts in last
component of path, and some - not.

stat(2) is one of syscalls, which don't follow
automounts in last component of supplied path.

Many other syscalls do follow automounts.

autofs.rst calls syscalls, which follow automounts,
as "beyond a stat".

Notably mount(2) doesn't follow automounts in second argument
(i. e. mountpoint). I know this, because I closely did read the code.
Also I did experiment (see source in the end of this letter).
Experiment was on 6.17-rc1.

But "autofs.rst" says:
> mounting onto a directory is considered to be "beyond a `stat`"

I. e. "autofs.rst" says that mount(2) does follow automounts.

This is wrong, as I explained above. (Again: I did experiment,
so I'm totally sure that this "autofs.rst" sentence is wrong.)

Moreover, then "autofs.rst" proceeds to explain why
DCACHE_MANAGE_TRANSIT was introduced, based on this wrong fact.

So it is possible that DCACHE_MANAGE_TRANSIT is in fact, not needed.

I'm not asking for removal of DCACHE_MANAGE_TRANSIT.

I merely point error in autofs.rst file and ask for fix.

And if in process of fixing autofs.rst you will notice that
DCACHE_MANAGE_TRANSIT is indeed not needed, then,
of course, it should be removed.

--
Askar Safin
https://types.pl/@safinaskar

====

// This code is public domain
// You should be root in initial user namespace

#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sched.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/syscall.h>
#include <sys/vfs.h>
#include <sys/sysmacros.h>
#include <sys/statvfs.h>
#include <sys/wait.h>
#include <linux/openat2.h>
#include <linux/nsfs.h>

#define MY_ASSERT(cond) do { \
    if (!(cond)) { \
        fprintf (stderr, "%d: %s: assertion failed\n", __LINE__, #cond); \
        exit (1); \
    } \
} while (0)

#define MY_ASSERT_ERRNO(cond) do { \
    if (!(cond)) { \
        fprintf (stderr, "%d: %s: %m\n", __LINE__, #cond); \
        exit (1); \
    } \
} while (0)

static void
mount_debugfs (void)
{
    if (mount (NULL, "/tmp/debugfs", "debugfs", 0, NULL) != 0)
        {
            perror ("mount debugfs");
            exit (1);
        }
}

int
main (void)
{
    MY_ASSERT_ERRNO (chdir ("/") == 0);
    MY_ASSERT_ERRNO (unshare (CLONE_NEWNS) == 0);
    MY_ASSERT_ERRNO (mount (NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL) == 0);
    MY_ASSERT_ERRNO (mount (NULL, "/tmp", "tmpfs", 0, NULL) == 0);
    MY_ASSERT_ERRNO (mkdir ("/tmp/debugfs", 0777) == 0);
    mount_debugfs ();
    MY_ASSERT_ERRNO (mount (NULL, "/tmp/debugfs/tracing", "tmpfs", 0, NULL) == 0);
    execlp ("/bin/busybox", "sh", NULL);
    MY_ASSERT (false);
}





[Index of Archives]     [Linux Filesystem Development]     [Linux Ext4]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux