[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CABAmdSf=wQn7qdjnEZTdQms9DNaE_PFxypsvX9ZG-i1EoUQQCQ@mail.gmail.com>
Date: Fri, 8 Mar 2024 14:27:27 +0800
From: hy c <harry.hycc@...il.com>
To: linux-kernel@...r.kernel.org
Subject: Subject: Inquiry Regarding Obtaining Mount Point Path in fsconfig Syscall
Description: I'm developing a kernel module that includes a syscall
hook named fsconfig, intended for managing operations related to
remounting readonly mountpoints. I'm looking to extract the mount
point path within the fsconfig hook.
Specifically, when a user executes mount /dev/sda /tmp/mytest -o
remount,ro, I'd like to extract the string /tmp/mytest.
I've attempted several methods, including trying to retrieve the mount
point path from the fs_context structure, but haven't yet found a
satisfactory solution.
Methods Tried:
Attempted starting from fc_context->dentry, but the result was simply
"/", which didn't meet the requirement.
Explored using d_path, but it requires accessing the path structure
within the fsconfig syscall, which isn't feasible in the current
environment.
I also came across the __is_local_mountpoint function in the kernel
source code, which seems to suggest that iterating through all
mountpoints might be a solution. I've attempted this approach and
successfully identified the mount corresponding to the fs_context, but
there's an issue regarding namespace_sem.
Primary Questions:
1. Is there a secure method to obtain the mount point path through
fs_context without needing to modify kernel code? (Assuming fs_context
always corresponds to a mounted file system.)
2. If we can only iterate through mountpoints, how can we address the
challenge of not being able to access the semaphore securely?
Environment Information:
Linux Kernel Version: 6.6
I sincerely appreciate your assistance and support.
Powered by blists - more mailing lists