License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Definitions for mount interface. This describes the in the kernel build
|
|
|
|
|
* linkedlist with mounted filesystems.
|
|
|
|
|
*
|
|
|
|
|
* Author: Marco van Wieringen <mvw@planets.elm.net>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#ifndef _LINUX_MOUNT_H
|
|
|
|
|
#define _LINUX_MOUNT_H
|
|
|
|
|
|
2005-07-12 20:58:07 +00:00
|
|
|
#include <linux/types.h>
|
2022-03-02 00:56:53 +00:00
|
|
|
#include <asm/barrier.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-23 09:02:58 +00:00
|
|
|
struct super_block;
|
|
|
|
|
struct dentry;
|
2022-03-02 00:56:53 +00:00
|
|
|
struct user_namespace;
|
2022-10-26 10:51:27 +00:00
|
|
|
struct mnt_idmap;
|
2022-03-02 00:56:53 +00:00
|
|
|
struct file_system_type;
|
2018-11-04 11:48:34 +00:00
|
|
|
struct fs_context;
|
2022-03-02 00:56:53 +00:00
|
|
|
struct file;
|
|
|
|
|
struct path;
|
2006-06-23 09:02:58 +00:00
|
|
|
|
fs: convert mount flags to enum
In prior kernel versions (5.8-6.8), commit 9f6c61f96f2d9 ("proc/mounts:
add cursor") introduced MNT_CURSOR, a flag used by readers from
/proc/mounts to keep their place while reading the file. Later, commit
2eea9ce4310d8 ("mounts: keep list of mounts in an rbtree") removed this
flag and its value has since been repurposed.
For debuggers iterating over the list of mounts, cursors should be
skipped as they are irrelevant. Detecting whether an element is a cursor
can be difficult. Since the MNT_CURSOR flag is a preprocessor constant,
it's not present in debuginfo, and since its value is repurposed, we
cannot hard-code it. For this specific issue, cursors are possible to
detect in other ways, but ideally, we would be able to read the mount
flag definitions out of the debuginfo. For that reason, convert the
mount flags to an enum.
Link: https://github.com/osandov/drgn/pull/496
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/20250507223402.2795029-1-stephen.s.brennan@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-07 22:34:01 +00:00
|
|
|
enum mount_flags {
|
|
|
|
|
MNT_NOSUID = 0x01,
|
|
|
|
|
MNT_NODEV = 0x02,
|
|
|
|
|
MNT_NOEXEC = 0x04,
|
|
|
|
|
MNT_NOATIME = 0x08,
|
|
|
|
|
MNT_NODIRATIME = 0x10,
|
|
|
|
|
MNT_RELATIME = 0x20,
|
|
|
|
|
MNT_READONLY = 0x40, /* does the user want this to be r/o? */
|
|
|
|
|
MNT_NOSYMFOLLOW = 0x80,
|
2006-01-08 09:03:19 +00:00
|
|
|
|
fs: convert mount flags to enum
In prior kernel versions (5.8-6.8), commit 9f6c61f96f2d9 ("proc/mounts:
add cursor") introduced MNT_CURSOR, a flag used by readers from
/proc/mounts to keep their place while reading the file. Later, commit
2eea9ce4310d8 ("mounts: keep list of mounts in an rbtree") removed this
flag and its value has since been repurposed.
For debuggers iterating over the list of mounts, cursors should be
skipped as they are irrelevant. Detecting whether an element is a cursor
can be difficult. Since the MNT_CURSOR flag is a preprocessor constant,
it's not present in debuginfo, and since its value is repurposed, we
cannot hard-code it. For this specific issue, cursors are possible to
detect in other ways, but ideally, we would be able to read the mount
flag definitions out of the debuginfo. For that reason, convert the
mount flags to an enum.
Link: https://github.com/osandov/drgn/pull/496
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/20250507223402.2795029-1-stephen.s.brennan@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-07 22:34:01 +00:00
|
|
|
MNT_SHRINKABLE = 0x100,
|
|
|
|
|
MNT_WRITE_HOLD = 0x200,
|
2006-06-09 13:34:17 +00:00
|
|
|
|
fs: convert mount flags to enum
In prior kernel versions (5.8-6.8), commit 9f6c61f96f2d9 ("proc/mounts:
add cursor") introduced MNT_CURSOR, a flag used by readers from
/proc/mounts to keep their place while reading the file. Later, commit
2eea9ce4310d8 ("mounts: keep list of mounts in an rbtree") removed this
flag and its value has since been repurposed.
For debuggers iterating over the list of mounts, cursors should be
skipped as they are irrelevant. Detecting whether an element is a cursor
can be difficult. Since the MNT_CURSOR flag is a preprocessor constant,
it's not present in debuginfo, and since its value is repurposed, we
cannot hard-code it. For this specific issue, cursors are possible to
detect in other ways, but ideally, we would be able to read the mount
flag definitions out of the debuginfo. For that reason, convert the
mount flags to an enum.
Link: https://github.com/osandov/drgn/pull/496
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/20250507223402.2795029-1-stephen.s.brennan@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-07 22:34:01 +00:00
|
|
|
MNT_SHARED = 0x1000, /* if the vfsmount is a shared mount */
|
|
|
|
|
MNT_UNBINDABLE = 0x2000, /* if the vfsmount is a unbindable mount */
|
|
|
|
|
|
|
|
|
|
MNT_INTERNAL = 0x4000,
|
2010-01-26 19:20:47 +00:00
|
|
|
|
fs: convert mount flags to enum
In prior kernel versions (5.8-6.8), commit 9f6c61f96f2d9 ("proc/mounts:
add cursor") introduced MNT_CURSOR, a flag used by readers from
/proc/mounts to keep their place while reading the file. Later, commit
2eea9ce4310d8 ("mounts: keep list of mounts in an rbtree") removed this
flag and its value has since been repurposed.
For debuggers iterating over the list of mounts, cursors should be
skipped as they are irrelevant. Detecting whether an element is a cursor
can be difficult. Since the MNT_CURSOR flag is a preprocessor constant,
it's not present in debuginfo, and since its value is repurposed, we
cannot hard-code it. For this specific issue, cursors are possible to
detect in other ways, but ideally, we would be able to read the mount
flag definitions out of the debuginfo. For that reason, convert the
mount flags to an enum.
Link: https://github.com/osandov/drgn/pull/496
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/20250507223402.2795029-1-stephen.s.brennan@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-07 22:34:01 +00:00
|
|
|
MNT_LOCK_ATIME = 0x040000,
|
|
|
|
|
MNT_LOCK_NOEXEC = 0x080000,
|
|
|
|
|
MNT_LOCK_NOSUID = 0x100000,
|
|
|
|
|
MNT_LOCK_NODEV = 0x200000,
|
|
|
|
|
MNT_LOCK_READONLY = 0x400000,
|
|
|
|
|
MNT_LOCKED = 0x800000,
|
|
|
|
|
MNT_DOOMED = 0x1000000,
|
|
|
|
|
MNT_SYNC_UMOUNT = 0x2000000,
|
|
|
|
|
MNT_MARKED = 0x4000000,
|
|
|
|
|
MNT_UMOUNT = 0x8000000,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
fs: convert mount flags to enum
In prior kernel versions (5.8-6.8), commit 9f6c61f96f2d9 ("proc/mounts:
add cursor") introduced MNT_CURSOR, a flag used by readers from
/proc/mounts to keep their place while reading the file. Later, commit
2eea9ce4310d8 ("mounts: keep list of mounts in an rbtree") removed this
flag and its value has since been repurposed.
For debuggers iterating over the list of mounts, cursors should be
skipped as they are irrelevant. Detecting whether an element is a cursor
can be difficult. Since the MNT_CURSOR flag is a preprocessor constant,
it's not present in debuginfo, and since its value is repurposed, we
cannot hard-code it. For this specific issue, cursors are possible to
detect in other ways, but ideally, we would be able to read the mount
flag definitions out of the debuginfo. For that reason, convert the
mount flags to an enum.
Link: https://github.com/osandov/drgn/pull/496
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/20250507223402.2795029-1-stephen.s.brennan@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-07 22:34:01 +00:00
|
|
|
/*
|
|
|
|
|
* MNT_SHARED_MASK is the set of flags that should be cleared when a
|
|
|
|
|
* mount becomes shared. Currently, this is only the flag that says a
|
|
|
|
|
* mount cannot be bind mounted, since this is how we create a mount
|
|
|
|
|
* that shares events with another mount. If you add a new MNT_*
|
|
|
|
|
* flag, consider how it interacts with shared mounts.
|
|
|
|
|
*/
|
|
|
|
|
MNT_SHARED_MASK = MNT_UNBINDABLE,
|
|
|
|
|
MNT_USER_SETTABLE_MASK = MNT_NOSUID | MNT_NODEV | MNT_NOEXEC
|
|
|
|
|
| MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME
|
|
|
|
|
| MNT_READONLY | MNT_NOSYMFOLLOW,
|
|
|
|
|
MNT_ATIME_MASK = MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
fs: convert mount flags to enum
In prior kernel versions (5.8-6.8), commit 9f6c61f96f2d9 ("proc/mounts:
add cursor") introduced MNT_CURSOR, a flag used by readers from
/proc/mounts to keep their place while reading the file. Later, commit
2eea9ce4310d8 ("mounts: keep list of mounts in an rbtree") removed this
flag and its value has since been repurposed.
For debuggers iterating over the list of mounts, cursors should be
skipped as they are irrelevant. Detecting whether an element is a cursor
can be difficult. Since the MNT_CURSOR flag is a preprocessor constant,
it's not present in debuginfo, and since its value is repurposed, we
cannot hard-code it. For this specific issue, cursors are possible to
detect in other ways, but ideally, we would be able to read the mount
flag definitions out of the debuginfo. For that reason, convert the
mount flags to an enum.
Link: https://github.com/osandov/drgn/pull/496
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/20250507223402.2795029-1-stephen.s.brennan@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-07 22:34:01 +00:00
|
|
|
MNT_INTERNAL_FLAGS = MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL |
|
2025-05-04 17:28:37 +00:00
|
|
|
MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED |
|
|
|
|
|
MNT_LOCKED,
|
fs: convert mount flags to enum
In prior kernel versions (5.8-6.8), commit 9f6c61f96f2d9 ("proc/mounts:
add cursor") introduced MNT_CURSOR, a flag used by readers from
/proc/mounts to keep their place while reading the file. Later, commit
2eea9ce4310d8 ("mounts: keep list of mounts in an rbtree") removed this
flag and its value has since been repurposed.
For debuggers iterating over the list of mounts, cursors should be
skipped as they are irrelevant. Detecting whether an element is a cursor
can be difficult. Since the MNT_CURSOR flag is a preprocessor constant,
it's not present in debuginfo, and since its value is repurposed, we
cannot hard-code it. For this specific issue, cursors are possible to
detect in other ways, but ideally, we would be able to read the mount
flag definitions out of the debuginfo. For that reason, convert the
mount flags to an enum.
Link: https://github.com/osandov/drgn/pull/496
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/20250507223402.2795029-1-stephen.s.brennan@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-07 22:34:01 +00:00
|
|
|
};
|
2013-03-22 10:10:15 +00:00
|
|
|
|
2005-11-07 22:19:07 +00:00
|
|
|
struct vfsmount {
|
2005-04-16 22:20:36 +00:00
|
|
|
struct dentry *mnt_root; /* root of the mounted tree */
|
|
|
|
|
struct super_block *mnt_sb; /* pointer to superblock */
|
|
|
|
|
int mnt_flags;
|
2022-10-26 10:51:27 +00:00
|
|
|
struct mnt_idmap *mnt_idmap;
|
2016-10-28 08:22:25 +00:00
|
|
|
} __randomize_layout;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-10-26 10:51:27 +00:00
|
|
|
static inline struct mnt_idmap *mnt_idmap(const struct vfsmount *mnt)
|
2021-01-21 13:19:20 +00:00
|
|
|
{
|
2021-01-21 13:19:54 +00:00
|
|
|
/* Pairs with smp_store_release() in do_idmap_mount(). */
|
2024-11-30 05:17:11 +00:00
|
|
|
return READ_ONCE(mnt->mnt_idmap);
|
2021-01-21 13:19:20 +00:00
|
|
|
}
|
|
|
|
|
|
2008-02-15 22:37:30 +00:00
|
|
|
extern int mnt_want_write(struct vfsmount *mnt);
|
2009-04-26 10:25:55 +00:00
|
|
|
extern int mnt_want_write_file(struct file *file);
|
2008-02-15 22:37:30 +00:00
|
|
|
extern void mnt_drop_write(struct vfsmount *mnt);
|
2011-12-09 13:06:57 +00:00
|
|
|
extern void mnt_drop_write_file(struct file *file);
|
fs: scale mntget/mntput
The problem that this patch aims to fix is vfsmount refcounting scalability.
We need to take a reference on the vfsmount for every successful path lookup,
which often go to the same mount point.
The fundamental difficulty is that a "simple" reference count can never be made
scalable, because any time a reference is dropped, we must check whether that
was the last reference. To do that requires communication with all other CPUs
that may have taken a reference count.
We can make refcounts more scalable in a couple of ways, involving keeping
distributed counters, and checking for the global-zero condition less
frequently.
- check the global sum once every interval (this will delay zero detection
for some interval, so it's probably a showstopper for vfsmounts).
- keep a local count and only taking the global sum when local reaches 0 (this
is difficult for vfsmounts, because we can't hold preempt off for the life of
a reference, so a counter would need to be per-thread or tied strongly to a
particular CPU which requires more locking).
- keep a local difference of increments and decrements, which allows us to sum
the total difference and hence find the refcount when summing all CPUs. Then,
keep a single integer "long" refcount for slow and long lasting references,
and only take the global sum of local counters when the long refcount is 0.
This last scheme is what I implemented here. Attached mounts and process root
and working directory references are "long" references, and everything else is
a short reference.
This allows scalable vfsmount references during path walking over mounted
subtrees and unattached (lazy umounted) mounts with processes still running
in them.
This results in one fewer atomic op in the fastpath: mntget is now just a
per-CPU inc, rather than an atomic inc; and mntput just requires a spinlock
and non-atomic decrement in the common case. However code is otherwise bigger
and heavier, so single threaded performance is basically a wash.
Signed-off-by: Nick Piggin <npiggin@kernel.dk>
2011-01-07 06:50:11 +00:00
|
|
|
extern void mntput(struct vfsmount *mnt);
|
|
|
|
|
extern struct vfsmount *mntget(struct vfsmount *mnt);
|
2023-01-27 18:46:51 +00:00
|
|
|
extern void mnt_make_shortterm(struct vfsmount *mnt);
|
2016-11-21 00:45:28 +00:00
|
|
|
extern struct vfsmount *mnt_clone_internal(const struct path *path);
|
2018-11-01 23:07:25 +00:00
|
|
|
extern bool __mnt_is_readonly(struct vfsmount *mnt);
|
fs: Treat foreign mounts as nosuid
If a process gets access to a mount from a different user
namespace, that process should not be able to take advantage of
setuid files or selinux entrypoints from that filesystem. Prevent
this by treating mounts from other mount namespaces and those not
owned by current_user_ns() or an ancestor as nosuid.
This will make it safer to allow more complex filesystems to be
mounted in non-root user namespaces.
This does not remove the need for MNT_LOCK_NOSUID. The setuid,
setgid, and file capability bits can no longer be abused if code in
a user namespace were to clear nosuid on an untrusted filesystem,
but this patch, by itself, is insufficient to protect the system
from abuse of files that, when execed, would increase MAC privilege.
As a more concrete explanation, any task that can manipulate a
vfsmount associated with a given user namespace already has
capabilities in that namespace and all of its descendents. If they
can cause a malicious setuid, setgid, or file-caps executable to
appear in that mount, then that executable will only allow them to
elevate privileges in exactly the set of namespaces in which they
are already privileges.
On the other hand, if they can cause a malicious executable to
appear with a dangerous MAC label, running it could change the
caller's security context in a way that should not have been
possible, even inside the namespace in which the task is confined.
As a hardening measure, this would have made CVE-2014-5207 much
more difficult to exploit.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
2016-06-23 21:41:05 +00:00
|
|
|
extern bool mnt_may_suid(struct vfsmount *mnt);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-11-21 00:45:28 +00:00
|
|
|
extern struct vfsmount *clone_private_mount(const struct path *path);
|
2023-09-08 13:28:59 +00:00
|
|
|
int mnt_get_write_access(struct vfsmount *mnt);
|
|
|
|
|
void mnt_put_write_access(struct vfsmount *mnt);
|
2014-10-23 22:14:36 +00:00
|
|
|
|
2018-11-04 11:48:34 +00:00
|
|
|
extern struct vfsmount *fc_mount(struct fs_context *fc);
|
|
|
|
|
extern struct vfsmount *vfs_create_mount(struct fs_context *fc);
|
2006-06-09 13:34:15 +00:00
|
|
|
extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
|
|
|
|
|
int flags, const char *name,
|
|
|
|
|
void *data);
|
|
|
|
|
|
2011-01-14 19:10:03 +00:00
|
|
|
extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
|
2005-04-16 22:20:36 +00:00
|
|
|
extern void mark_mounts_for_expiry(struct list_head *mounts);
|
|
|
|
|
|
2016-11-23 21:03:41 +00:00
|
|
|
extern bool path_is_mountpoint(const struct path *path);
|
|
|
|
|
|
2022-03-02 22:49:09 +00:00
|
|
|
extern bool our_mnt(struct vfsmount *mnt);
|
|
|
|
|
|
|
|
|
|
extern struct vfsmount *kern_mount(struct file_system_type *);
|
|
|
|
|
extern void kern_unmount(struct vfsmount *mnt);
|
|
|
|
|
extern int may_umount_tree(struct vfsmount *);
|
|
|
|
|
extern int may_umount(struct vfsmount *);
|
2025-01-13 15:14:00 +00:00
|
|
|
int do_mount(const char *, const char __user *,
|
2022-03-02 22:49:09 +00:00
|
|
|
const char *, unsigned long, void *);
|
replace collect_mounts()/drop_collected_mounts() with a safer variant
collect_mounts() has several problems - one can't iterate over the results
directly, so it has to be done with callback passed to iterate_mounts();
it has an oopsable race with d_invalidate(); it creates temporary clones
of mounts invisibly for sync umount (IOW, you can have non-lazy umount
succeed leaving filesystem not mounted anywhere and yet still busy).
A saner approach is to give caller an array of struct path that would pin
every mount in a subtree, without cloning any mounts.
* collect_mounts()/drop_collected_mounts()/iterate_mounts() is gone
* collect_paths(where, preallocated, size) gives either ERR_PTR(-E...) or
a pointer to array of struct path, one for each chunk of tree visible under
'where' (i.e. the first element is a copy of where, followed by (mount,root)
for everything mounted under it - the same set collect_mounts() would give).
Unlike collect_mounts(), the mounts are *not* cloned - we just get pinning
references to the roots of subtrees in the caller's namespace.
Array is terminated by {NULL, NULL} struct path. If it fits into
preallocated array (on-stack, normally), that's where it goes; otherwise
it's allocated by kmalloc_array(). Passing 0 as size means that 'preallocated'
is ignored (and expected to be NULL).
* drop_collected_paths(paths, preallocated) is given the array returned
by an earlier call of collect_paths() and the preallocated array passed to that
call. All mount/dentry references are dropped and array is kfree'd if it's not
equal to 'preallocated'.
* instead of iterate_mounts(), users should just iterate over array
of struct path - nothing exotic is needed for that. Existing users (all in
audit_tree.c) are converted.
[folded a fix for braino reported by Venkat Rao Bagalkote <venkat88@linux.ibm.com>]
Fixes: 80b5dce8c59b0 ("vfs: Add a function to lazily unmount all mounts from any dentry")
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2025-06-17 04:09:51 +00:00
|
|
|
extern struct path *collect_paths(const struct path *, struct path *, unsigned);
|
|
|
|
|
extern void drop_collected_paths(struct path *, struct path *);
|
2020-06-04 08:48:19 +00:00
|
|
|
extern void kern_unmount_array(struct vfsmount *mnt[], unsigned int num);
|
|
|
|
|
|
2023-05-17 13:11:00 +00:00
|
|
|
extern int cifs_root_data(char **dev, char **opts);
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* _LINUX_MOUNT_H */
|