You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
Remove two unneeded exports and make two symbols static in fs/mpage.c
Cleanup after commit 585d3bc06f
Trim includes of fdtable.h
Don't crap into descriptor table in binfmt_som
Trim includes in binfmt_elf
Don't mess with descriptor table in load_elf_binary()
Get rid of indirect include of fs_struct.h
New helper - current_umask()
check_unsafe_exec() doesn't care about signal handlers sharing
New locking/refcounting for fs_struct
Take fs_struct handling to new file (fs/fs_struct.c)
Get rid of bumping fs_struct refcount in pivot_root(2)
Kill unsharing fs_struct in __set_personality()
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
#include <asm/system.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/fs_struct.h>
|
||||
#include <linux/init_task.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
@@ -635,7 +635,7 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
|
||||
if (dentry->d_inode)
|
||||
goto out_dput;
|
||||
|
||||
mode &= ~current->fs->umask;
|
||||
mode &= ~current_umask();
|
||||
|
||||
if (flags & SPU_CREATE_GANG)
|
||||
ret = spufs_create_gang(nd->path.dentry->d_inode,
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
*/
|
||||
|
||||
#include <linux/audit.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fdtable.h>
|
||||
#include <linux/tty.h>
|
||||
|
||||
struct tty_audit_buf {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <linux/tty_flip.h>
|
||||
#include <linux/devpts_fs.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fdtable.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/ctype.h>
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ obj-y := open.o read_write.o file_table.o super.o \
|
||||
attr.o bad_inode.o file.o filesystems.o namespace.o \
|
||||
seq_file.o xattr.o libfs.o fs-writeback.o \
|
||||
pnode.o drop_caches.o splice.o sync.o utimes.o \
|
||||
stack.o
|
||||
stack.o fs_struct.o
|
||||
|
||||
ifeq ($(CONFIG_BLOCK),y)
|
||||
obj-y += buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
|
||||
|
||||
+2
-20
@@ -12,8 +12,6 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/stat.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/mman.h>
|
||||
#include <linux/errno.h>
|
||||
@@ -21,20 +19,15 @@
|
||||
#include <linux/binfmts.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fcntl.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/shm.h>
|
||||
#include <linux/personality.h>
|
||||
#include <linux/elfcore.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/highuid.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/elf.h>
|
||||
#include <linux/utsname.h>
|
||||
@@ -576,7 +569,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
||||
unsigned long error;
|
||||
struct elf_phdr *elf_ppnt, *elf_phdata;
|
||||
unsigned long elf_bss, elf_brk;
|
||||
int elf_exec_fileno;
|
||||
int retval, i;
|
||||
unsigned int size;
|
||||
unsigned long elf_entry;
|
||||
@@ -631,12 +623,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
||||
goto out_free_ph;
|
||||
}
|
||||
|
||||
retval = get_unused_fd();
|
||||
if (retval < 0)
|
||||
goto out_free_ph;
|
||||
get_file(bprm->file);
|
||||
fd_install(elf_exec_fileno = retval, bprm->file);
|
||||
|
||||
elf_ppnt = elf_phdata;
|
||||
elf_bss = 0;
|
||||
elf_brk = 0;
|
||||
@@ -655,13 +641,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
||||
retval = -ENOEXEC;
|
||||
if (elf_ppnt->p_filesz > PATH_MAX ||
|
||||
elf_ppnt->p_filesz < 2)
|
||||
goto out_free_file;
|
||||
goto out_free_ph;
|
||||
|
||||
retval = -ENOMEM;
|
||||
elf_interpreter = kmalloc(elf_ppnt->p_filesz,
|
||||
GFP_KERNEL);
|
||||
if (!elf_interpreter)
|
||||
goto out_free_file;
|
||||
goto out_free_ph;
|
||||
|
||||
retval = kernel_read(bprm->file, elf_ppnt->p_offset,
|
||||
elf_interpreter,
|
||||
@@ -956,8 +942,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
||||
|
||||
kfree(elf_phdata);
|
||||
|
||||
sys_close(elf_exec_fileno);
|
||||
|
||||
set_binfmt(&elf_format);
|
||||
|
||||
#ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES
|
||||
@@ -1028,8 +1012,6 @@ out_free_dentry:
|
||||
fput(interpreter);
|
||||
out_free_interp:
|
||||
kfree(elf_interpreter);
|
||||
out_free_file:
|
||||
sys_close(elf_exec_fileno);
|
||||
out_free_ph:
|
||||
kfree(elf_phdata);
|
||||
goto out;
|
||||
|
||||
@@ -188,7 +188,6 @@ out:
|
||||
static int
|
||||
load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
||||
{
|
||||
int som_exec_fileno;
|
||||
int retval;
|
||||
unsigned int size;
|
||||
unsigned long som_entry;
|
||||
@@ -220,12 +219,6 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
retval = get_unused_fd();
|
||||
if (retval < 0)
|
||||
goto out_free;
|
||||
get_file(bprm->file);
|
||||
fd_install(som_exec_fileno = retval, bprm->file);
|
||||
|
||||
/* Flush all traces of the currently running executable */
|
||||
retval = flush_old_exec(bprm);
|
||||
if (retval)
|
||||
|
||||
@@ -204,6 +204,7 @@ int fsync_bdev(struct block_device *bdev)
|
||||
}
|
||||
return sync_blockdev(bdev);
|
||||
}
|
||||
EXPORT_SYMBOL(fsync_bdev);
|
||||
|
||||
/**
|
||||
* freeze_bdev -- lock a filesystem and force it into a consistent state
|
||||
|
||||
+1
-1
@@ -256,7 +256,7 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir)
|
||||
}
|
||||
|
||||
if (!acl)
|
||||
inode->i_mode &= ~current->fs->umask;
|
||||
inode->i_mode &= ~current_umask();
|
||||
}
|
||||
|
||||
if (IS_POSIXACL(dir) && acl) {
|
||||
|
||||
+1
-1
@@ -267,7 +267,7 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name,
|
||||
goto out_dput;
|
||||
|
||||
if (!IS_POSIXACL(parent->dentry->d_inode))
|
||||
mode &= ~current->fs->umask;
|
||||
mode &= ~current_umask();
|
||||
|
||||
error = mnt_want_write(parent->mnt);
|
||||
if (error)
|
||||
|
||||
@@ -3315,7 +3315,6 @@ EXPORT_SYMBOL(cont_write_begin);
|
||||
EXPORT_SYMBOL(end_buffer_read_sync);
|
||||
EXPORT_SYMBOL(end_buffer_write_sync);
|
||||
EXPORT_SYMBOL(file_fsync);
|
||||
EXPORT_SYMBOL(fsync_bdev);
|
||||
EXPORT_SYMBOL(generic_block_bmap);
|
||||
EXPORT_SYMBOL(generic_cont_expand_simple);
|
||||
EXPORT_SYMBOL(init_buffer);
|
||||
|
||||
+2
-2
@@ -254,7 +254,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
mode &= ~current->fs->umask;
|
||||
mode &= ~current_umask();
|
||||
if (oplockEnabled)
|
||||
oplock = REQ_OPLOCK;
|
||||
|
||||
@@ -479,7 +479,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
|
||||
rc = -ENOMEM;
|
||||
else if (pTcon->unix_ext) {
|
||||
struct cifs_unix_set_info_args args = {
|
||||
.mode = mode & ~current->fs->umask,
|
||||
.mode = mode & ~current_umask(),
|
||||
.ctime = NO_CHANGE_64,
|
||||
.atime = NO_CHANGE_64,
|
||||
.mtime = NO_CHANGE_64,
|
||||
|
||||
+2
-2
@@ -1125,7 +1125,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
|
||||
goto mkdir_out;
|
||||
}
|
||||
|
||||
mode &= ~current->fs->umask;
|
||||
mode &= ~current_umask();
|
||||
rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT,
|
||||
mode, NULL /* netfid */, pInfo, &oplock,
|
||||
full_path, cifs_sb->local_nls,
|
||||
@@ -1204,7 +1204,7 @@ mkdir_get_info:
|
||||
if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
|
||||
direntry->d_inode->i_nlink = 2;
|
||||
|
||||
mode &= ~current->fs->umask;
|
||||
mode &= ~current_umask();
|
||||
/* must turn on setgid bit if parent dir has it */
|
||||
if (inode->i_mode & S_ISGID)
|
||||
mode |= S_ISGID;
|
||||
|
||||
+14
-2
@@ -51,6 +51,7 @@
|
||||
#include <linux/poll.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/eventpoll.h>
|
||||
#include <linux/fs_struct.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/mmu_context.h>
|
||||
@@ -1502,12 +1503,15 @@ int compat_do_execve(char * filename,
|
||||
bprm->cred = prepare_exec_creds();
|
||||
if (!bprm->cred)
|
||||
goto out_unlock;
|
||||
check_unsafe_exec(bprm);
|
||||
|
||||
retval = check_unsafe_exec(bprm);
|
||||
if (retval)
|
||||
goto out_unlock;
|
||||
|
||||
file = open_exec(filename);
|
||||
retval = PTR_ERR(file);
|
||||
if (IS_ERR(file))
|
||||
goto out_unlock;
|
||||
goto out_unmark;
|
||||
|
||||
sched_exec();
|
||||
|
||||
@@ -1549,6 +1553,9 @@ int compat_do_execve(char * filename,
|
||||
goto out;
|
||||
|
||||
/* execve succeeded */
|
||||
write_lock(¤t->fs->lock);
|
||||
current->fs->in_exec = 0;
|
||||
write_unlock(¤t->fs->lock);
|
||||
current->in_execve = 0;
|
||||
mutex_unlock(¤t->cred_exec_mutex);
|
||||
acct_update_integrals(current);
|
||||
@@ -1567,6 +1574,11 @@ out_file:
|
||||
fput(bprm->file);
|
||||
}
|
||||
|
||||
out_unmark:
|
||||
write_lock(¤t->fs->lock);
|
||||
current->fs->in_exec = 0;
|
||||
write_unlock(¤t->fs->lock);
|
||||
|
||||
out_unlock:
|
||||
current->in_execve = 0;
|
||||
mutex_unlock(¤t->cred_exec_mutex);
|
||||
|
||||
+1
-1
@@ -17,7 +17,6 @@
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/fdtable.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/fsnotify.h>
|
||||
#include <linux/slab.h>
|
||||
@@ -32,6 +31,7 @@
|
||||
#include <linux/seqlock.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/bootmem.h>
|
||||
#include <linux/fs_struct.h>
|
||||
#include "internal.h"
|
||||
|
||||
int sysctl_vfs_cache_pressure __read_mostly = 100;
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <linux/tracehook.h>
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/fsnotify.h>
|
||||
#include <linux/fs_struct.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/mmu_context.h>
|
||||
@@ -1056,28 +1057,35 @@ EXPORT_SYMBOL(install_exec_creds);
|
||||
* - the caller must hold current->cred_exec_mutex to protect against
|
||||
* PTRACE_ATTACH
|
||||
*/
|
||||
void check_unsafe_exec(struct linux_binprm *bprm)
|
||||
int check_unsafe_exec(struct linux_binprm *bprm)
|
||||
{
|
||||
struct task_struct *p = current, *t;
|
||||
unsigned long flags;
|
||||
unsigned n_fs, n_sighand;
|
||||
unsigned n_fs;
|
||||
int res = 0;
|
||||
|
||||
bprm->unsafe = tracehook_unsafe_exec(p);
|
||||
|
||||
n_fs = 1;
|
||||
n_sighand = 1;
|
||||
write_lock(&p->fs->lock);
|
||||
lock_task_sighand(p, &flags);
|
||||
for (t = next_thread(p); t != p; t = next_thread(t)) {
|
||||
if (t->fs == p->fs)
|
||||
n_fs++;
|
||||
n_sighand++;
|
||||
}
|
||||
|
||||
if (atomic_read(&p->fs->count) > n_fs ||
|
||||
atomic_read(&p->sighand->count) > n_sighand)
|
||||
if (p->fs->users > n_fs) {
|
||||
bprm->unsafe |= LSM_UNSAFE_SHARE;
|
||||
} else {
|
||||
if (p->fs->in_exec)
|
||||
res = -EAGAIN;
|
||||
p->fs->in_exec = 1;
|
||||
}
|
||||
|
||||
unlock_task_sighand(p, &flags);
|
||||
write_unlock(&p->fs->lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1296,12 +1304,15 @@ int do_execve(char * filename,
|
||||
bprm->cred = prepare_exec_creds();
|
||||
if (!bprm->cred)
|
||||
goto out_unlock;
|
||||
check_unsafe_exec(bprm);
|
||||
|
||||
retval = check_unsafe_exec(bprm);
|
||||
if (retval)
|
||||
goto out_unlock;
|
||||
|
||||
file = open_exec(filename);
|
||||
retval = PTR_ERR(file);
|
||||
if (IS_ERR(file))
|
||||
goto out_unlock;
|
||||
goto out_unmark;
|
||||
|
||||
sched_exec();
|
||||
|
||||
@@ -1344,6 +1355,9 @@ int do_execve(char * filename,
|
||||
goto out;
|
||||
|
||||
/* execve succeeded */
|
||||
write_lock(¤t->fs->lock);
|
||||
current->fs->in_exec = 0;
|
||||
write_unlock(¤t->fs->lock);
|
||||
current->in_execve = 0;
|
||||
mutex_unlock(¤t->cred_exec_mutex);
|
||||
acct_update_integrals(current);
|
||||
@@ -1362,6 +1376,11 @@ out_file:
|
||||
fput(bprm->file);
|
||||
}
|
||||
|
||||
out_unmark:
|
||||
write_lock(¤t->fs->lock);
|
||||
current->fs->in_exec = 0;
|
||||
write_unlock(¤t->fs->lock);
|
||||
|
||||
out_unlock:
|
||||
current->in_execve = 0;
|
||||
mutex_unlock(¤t->cred_exec_mutex);
|
||||
|
||||
+1
-1
@@ -318,7 +318,7 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
|
||||
return PTR_ERR(acl);
|
||||
}
|
||||
if (!acl)
|
||||
inode->i_mode &= ~current->fs->umask;
|
||||
inode->i_mode &= ~current_umask();
|
||||
}
|
||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||
struct posix_acl *clone;
|
||||
|
||||
+1
-1
@@ -323,7 +323,7 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||
return PTR_ERR(acl);
|
||||
}
|
||||
if (!acl)
|
||||
inode->i_mode &= ~current->fs->umask;
|
||||
inode->i_mode &= ~current_umask();
|
||||
}
|
||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||
struct posix_acl *clone;
|
||||
|
||||
+1
-1
@@ -323,7 +323,7 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||
return PTR_ERR(acl);
|
||||
}
|
||||
if (!acl)
|
||||
inode->i_mode &= ~current->fs->umask;
|
||||
inode->i_mode &= ~current_umask();
|
||||
}
|
||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||
struct posix_acl *clone;
|
||||
|
||||
+1
-1
@@ -934,7 +934,7 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug,
|
||||
|
||||
opts->fs_uid = current_uid();
|
||||
opts->fs_gid = current_gid();
|
||||
opts->fs_fmask = opts->fs_dmask = current->fs->umask;
|
||||
opts->fs_fmask = current_umask();
|
||||
opts->allow_utime = -1;
|
||||
opts->codepage = fat_default_codepage;
|
||||
opts->iocharset = fat_default_iocharset;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user