diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2005-09-09 16:10:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-09 17:03:44 -0400 |
commit | d8a5ba45457e4a22aa39c939121efd7bb6c76672 (patch) | |
tree | 686aa90d8c953326b8d2eeef9352e456cdb0ad52 /fs/fuse/fuse_i.h | |
parent | 04578f174f43d29b569500f01ba772afa4016330 (diff) |
[PATCH] FUSE - core
This patch adds FUSE core.
This contains the following files:
o inode.c
- superblock operations (alloc_inode, destroy_inode, read_inode,
clear_inode, put_super, show_options)
- registers FUSE filesystem
o fuse_i.h
- private header file
Requirements
============
The most important difference between orinary filesystems and FUSE is
the fact, that the filesystem data/metadata is provided by a userspace
process run with the privileges of the mount "owner" instead of the
kernel, or some remote entity usually running with elevated
privileges.
The security implication of this is that a non-privileged user must
not be able to use this capability to compromise the system. Obvious
requirements arising from this are:
- mount owner should not be able to get elevated privileges with the
help of the mounted filesystem
- mount owner should not be able to induce undesired behavior in
other users' or the super user's processes
- mount owner should not get illegitimate access to information from
other users' and the super user's processes
These are currently ensured with the following constraints:
1) mount is only allowed to directory or file which the mount owner
can modify without limitation (write access + no sticky bit for
directories)
2) nosuid,nodev mount options are forced
3) any process running with fsuid different from the owner is denied
all access to the filesystem
1) and 2) are ensured by the "fusermount" mount utility which is a
setuid root application doing the actual mount operation.
3) is ensured by a check in the permission() method in kernel
I started thinking about doing 3) in a different way because Christoph
H. made a big deal out of it, saying that FUSE is unacceptable into
mainline in this form.
The suggested use of private namespaces would be OK, but in their
current form have many limitations that make their use impractical (as
discussed in this thread).
Suggested improvements that would address these limitations:
- implement shared subtrees
- allow a process to join an existing namespace (make namespaces
first-class objects)
- implement the namespace creation/joining in a PAM module
With all that in place the check of owner against current->fsuid may
be removed from the FUSE kernel module, without compromising the
security requirements.
Suid programs still interesting questions, since they get access even
to the private namespace causing some information leak (exact
order/timing of filesystem operations performed), giving some
ptrace-like capabilities to unprivileged users. BTW this problem is
not strictly limited to the namespace approach, since suid programs
setting fsuid and accessing users' files will succeed with the current
approach too.
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/fuse/fuse_i.h')
-rw-r--r-- | fs/fuse/fuse_i.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h new file mode 100644 index 000000000000..eed6e89ce01f --- /dev/null +++ b/fs/fuse/fuse_i.h | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | FUSE: Filesystem in Userspace | ||
3 | Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu> | ||
4 | |||
5 | This program can be distributed under the terms of the GNU GPL. | ||
6 | See the file COPYING. | ||
7 | */ | ||
8 | |||
9 | #include <linux/fuse.h> | ||
10 | #include <linux/fs.h> | ||
11 | #include <linux/wait.h> | ||
12 | #include <linux/list.h> | ||
13 | #include <linux/spinlock.h> | ||
14 | #include <linux/mm.h> | ||
15 | #include <linux/backing-dev.h> | ||
16 | #include <asm/semaphore.h> | ||
17 | |||
18 | /** FUSE inode */ | ||
19 | struct fuse_inode { | ||
20 | /** Inode data */ | ||
21 | struct inode inode; | ||
22 | |||
23 | /** Unique ID, which identifies the inode between userspace | ||
24 | * and kernel */ | ||
25 | u64 nodeid; | ||
26 | |||
27 | /** Time in jiffies until the file attributes are valid */ | ||
28 | unsigned long i_time; | ||
29 | }; | ||
30 | |||
31 | /** | ||
32 | * A Fuse connection. | ||
33 | * | ||
34 | * This structure is created, when the filesystem is mounted, and is | ||
35 | * destroyed, when the client device is closed and the filesystem is | ||
36 | * unmounted. | ||
37 | */ | ||
38 | struct fuse_conn { | ||
39 | /** The superblock of the mounted filesystem */ | ||
40 | struct super_block *sb; | ||
41 | |||
42 | /** The user id for this mount */ | ||
43 | uid_t user_id; | ||
44 | |||
45 | /** Backing dev info */ | ||
46 | struct backing_dev_info bdi; | ||
47 | }; | ||
48 | |||
49 | static inline struct fuse_conn **get_fuse_conn_super_p(struct super_block *sb) | ||
50 | { | ||
51 | return (struct fuse_conn **) &sb->s_fs_info; | ||
52 | } | ||
53 | |||
54 | static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) | ||
55 | { | ||
56 | return *get_fuse_conn_super_p(sb); | ||
57 | } | ||
58 | |||
59 | static inline struct fuse_conn *get_fuse_conn(struct inode *inode) | ||
60 | { | ||
61 | return get_fuse_conn_super(inode->i_sb); | ||
62 | } | ||
63 | |||
64 | static inline struct fuse_inode *get_fuse_inode(struct inode *inode) | ||
65 | { | ||
66 | return container_of(inode, struct fuse_inode, inode); | ||
67 | } | ||
68 | |||
69 | static inline u64 get_node_id(struct inode *inode) | ||
70 | { | ||
71 | return get_fuse_inode(inode)->nodeid; | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * This is the single global spinlock which protects FUSE's structures | ||
76 | * | ||
77 | * The following data is protected by this lock: | ||
78 | * | ||
79 | * - the s_fs_info field of the super block | ||
80 | * - the sb (super_block) field in fuse_conn | ||
81 | */ | ||
82 | extern spinlock_t fuse_lock; | ||
83 | |||
84 | /** | ||
85 | * Check if the connection can be released, and if yes, then free the | ||
86 | * connection structure | ||
87 | */ | ||
88 | void fuse_release_conn(struct fuse_conn *fc); | ||
89 | |||