New locking/refcounting for fs_struct
* all changes of current->fs are done under task_lock and write_lock of old fs->lock * refcount is not atomic anymore (same protection) * its decrements are done when removing reference from current; at the same time we decide whether to free it. * put_fs_struct() is gone * new field - ->in_exec. Set by check_unsafe_exec() if we are trying to do execve() and only subthreads share fs_struct. Cleared when finishing exec (success and failure alike). Makes CLONE_FS fail with -EAGAIN if set. * check_unsafe_exec() may fail with -EAGAIN if another execve() from subthread is in progress. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@ -4,12 +4,10 @@
|
||||
#include <linux/path.h>
|
||||
|
||||
struct fs_struct {
|
||||
atomic_t count; /* This usage count is used by check_unsafe_exec() for
|
||||
* security checking purposes - therefore it may not be
|
||||
* incremented, except by clone(CLONE_FS).
|
||||
*/
|
||||
int users;
|
||||
rwlock_t lock;
|
||||
int umask;
|
||||
int in_exec;
|
||||
struct path root, pwd;
|
||||
};
|
||||
|
||||
@ -19,7 +17,7 @@ extern void exit_fs(struct task_struct *);
|
||||
extern void set_fs_root(struct fs_struct *, struct path *);
|
||||
extern void set_fs_pwd(struct fs_struct *, struct path *);
|
||||
extern struct fs_struct *copy_fs_struct(struct fs_struct *);
|
||||
extern void put_fs_struct(struct fs_struct *);
|
||||
extern void free_fs_struct(struct fs_struct *);
|
||||
extern void daemonize_fs_struct(void);
|
||||
extern int unshare_fs_struct(void);
|
||||
|
||||
|
Reference in New Issue
Block a user