Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
  deal with races in /proc/*/{syscall,stack,personality}
  proc: enable writing to /proc/pid/mem
  proc: make check_mem_permission() return an mm_struct on success
  proc: hold cred_guard_mutex in check_mem_permission()
  proc: disable mem_write after exec
  mm: implement access_remote_vm
  mm: factor out main logic of access_process_vm
  mm: use mm_struct to resolve gate vma's in __get_user_pages
  mm: arch: rename in_gate_area_no_task to in_gate_area_no_mm
  mm: arch: make in_gate_area take an mm_struct instead of a task_struct
  mm: arch: make get_gate_vma take an mm_struct instead of a task_struct
  x86: mark associated mm when running a task in 32 bit compatibility mode
  x86: add context tag to mark mm when running a task in 32-bit compatibility mode
  auxv: require the target to be tracable (or yourself)
  close race in /proc/*/environ
  report errors in /proc/*/*map* sanely
  pagemap: close races with suid execve
  make sessionid permissions in /proc/*/task/* match those in /proc/*
  fix leaks in path_lookupat()

Fix up trivial conflicts in fs/proc/base.c
  • Loading branch information
torvalds committed Mar 24, 2011
2 parents 2f284c8 + a9712bc commit b81a618
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 134 deletions.
6 changes: 3 additions & 3 deletions arch/powerpc/kernel/vdso.c
Expand Up @@ -820,17 +820,17 @@ static int __init vdso_init(void)
}
arch_initcall(vdso_init);

int in_gate_area_no_task(unsigned long addr)
int in_gate_area_no_mm(unsigned long addr)
{
return 0;
}

int in_gate_area(struct task_struct *task, unsigned long addr)
int in_gate_area(struct mm_struct *mm, unsigned long addr)
{
return 0;
}

struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
{
return NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/s390/kernel/vdso.c
Expand Up @@ -337,17 +337,17 @@ static int __init vdso_init(void)
}
arch_initcall(vdso_init);

int in_gate_area_no_task(unsigned long addr)
int in_gate_area_no_mm(unsigned long addr)
{
return 0;
}

int in_gate_area(struct task_struct *task, unsigned long addr)
int in_gate_area(struct mm_struct *mm, unsigned long addr)
{
return 0;
}

struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
{
return NULL;
}
6 changes: 3 additions & 3 deletions arch/sh/kernel/vsyscall/vsyscall.c
Expand Up @@ -94,17 +94,17 @@ const char *arch_vma_name(struct vm_area_struct *vma)
return NULL;
}

struct vm_area_struct *get_gate_vma(struct task_struct *task)
struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
{
return NULL;
}

int in_gate_area(struct task_struct *task, unsigned long address)
int in_gate_area(struct mm_struct *mm, unsigned long address)
{
return 0;
}

int in_gate_area_no_task(unsigned long address)
int in_gate_area_no_mm(unsigned long address)
{
return 0;
}
1 change: 1 addition & 0 deletions arch/x86/ia32/ia32_aout.c
Expand Up @@ -298,6 +298,7 @@ static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs)
/* OK, This is the point of no return */
set_personality(PER_LINUX);
set_thread_flag(TIF_IA32);
current->mm->context.ia32_compat = 1;

setup_new_exec(bprm);

Expand Down
6 changes: 6 additions & 0 deletions arch/x86/include/asm/mmu.h
Expand Up @@ -13,6 +13,12 @@ typedef struct {
int size;
struct mutex lock;
void *vdso;

#ifdef CONFIG_X86_64
/* True if mm supports a task running in 32 bit compatibility mode. */
unsigned short ia32_compat;
#endif

} mm_context_t;

#ifdef CONFIG_SMP
Expand Down
8 changes: 8 additions & 0 deletions arch/x86/kernel/process_64.c
Expand Up @@ -501,6 +501,10 @@ void set_personality_64bit(void)
/* Make sure to be in 64bit mode */
clear_thread_flag(TIF_IA32);

/* Ensure the corresponding mm is not marked. */
if (current->mm)
current->mm->context.ia32_compat = 0;

/* TBD: overwrites user setup. Should have two bits.
But 64bit processes have always behaved this way,
so it's not too bad. The main problem is just that
Expand All @@ -516,6 +520,10 @@ void set_personality_ia32(void)
set_thread_flag(TIF_IA32);
current->personality |= force_personality32;

/* Mark the associated mm as containing 32-bit tasks. */
if (current->mm)
current->mm->context.ia32_compat = 1;

/* Prepare the first "return" to user space */
current_thread_info()->status |= TS_COMPAT;
}
Expand Down
16 changes: 8 additions & 8 deletions arch/x86/mm/init_64.c
Expand Up @@ -862,18 +862,18 @@ static struct vm_area_struct gate_vma = {
.vm_flags = VM_READ | VM_EXEC
};

struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
{
#ifdef CONFIG_IA32_EMULATION
if (test_tsk_thread_flag(tsk, TIF_IA32))
if (!mm || mm->context.ia32_compat)
return NULL;
#endif
return &gate_vma;
}

int in_gate_area(struct task_struct *task, unsigned long addr)
int in_gate_area(struct mm_struct *mm, unsigned long addr)
{
struct vm_area_struct *vma = get_gate_vma(task);
struct vm_area_struct *vma = get_gate_vma(mm);

if (!vma)
return 0;
Expand All @@ -882,11 +882,11 @@ int in_gate_area(struct task_struct *task, unsigned long addr)
}

/*
* Use this when you have no reliable task/vma, typically from interrupt
* context. It is less reliable than using the task's vma and may give
* false positives:
* Use this when you have no reliable mm, typically from interrupt
* context. It is less reliable than using a task's mm and may give
* false positives.
*/
int in_gate_area_no_task(unsigned long addr)
int in_gate_area_no_mm(unsigned long addr)
{
return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
}
Expand Down
15 changes: 8 additions & 7 deletions arch/x86/vdso/vdso32-setup.c
Expand Up @@ -417,24 +417,25 @@ const char *arch_vma_name(struct vm_area_struct *vma)
return NULL;
}

struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
{
struct mm_struct *mm = tsk->mm;

/* Check to see if this task was created in compat vdso mode */
/*
* Check to see if the corresponding task was created in compat vdso
* mode.
*/
if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
return &gate_vma;
return NULL;
}

int in_gate_area(struct task_struct *task, unsigned long addr)
int in_gate_area(struct mm_struct *mm, unsigned long addr)
{
const struct vm_area_struct *vma = get_gate_vma(task);
const struct vm_area_struct *vma = get_gate_vma(mm);

return vma && addr >= vma->vm_start && addr < vma->vm_end;
}

int in_gate_area_no_task(unsigned long addr)
int in_gate_area_no_mm(unsigned long addr)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/binfmt_elf.c
Expand Up @@ -1906,7 +1906,7 @@ static int elf_core_dump(struct coredump_params *cprm)
segs = current->mm->map_count;
segs += elf_core_extra_phdrs();

gate_vma = get_gate_vma(current);
gate_vma = get_gate_vma(current->mm);
if (gate_vma != NULL)
segs++;

Expand Down
7 changes: 5 additions & 2 deletions fs/namei.c
Expand Up @@ -1650,13 +1650,16 @@ static int path_lookupat(int dfd, const char *name,
err = -ECHILD;
}

if (!err)
if (!err) {
err = handle_reval_path(nd);
if (err)
path_put(&nd->path);
}

if (!err && nd->flags & LOOKUP_DIRECTORY) {
if (!nd->inode->i_op->lookup) {
path_put(&nd->path);
return -ENOTDIR;
err = -ENOTDIR;
}
}

Expand Down

0 comments on commit b81a618

Please sign in to comment.