ARM: 8683/1: ARM32: Support mremap() for sigpage/vDSO
CRIU restores application mappings on the same place where they were before Checkpoint. That means, that we need to move vDSO and sigpage during restore on exactly the same place where they were before C/R. Make mremap() code update mm->context.{sigpage,vdso} pointers during VMA move. Sigpage is used for landing after handling a signal - if the pointer is not updated during moving, the application might crash on any signal after mremap(). vDSO pointer on ARM32 is used only for setting auxv at this moment, update it during mremap() in case of future usage. Without those updates, current work of CRIU on ARM32 is not reliable. Historically, we error Checkpointing if we find vDSO page on ARM32 and suggest user to disable CONFIG_VDSO. But that's not correct - it goes from x86 where signal processing is ended in vDSO blob. For arm32 it's sigpage, which is not disabled with `CONFIG_VDSO=n'. Looks like C/R was working by luck - because userspace on ARM32 at this moment always sets SA_RESTORER. Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com> Acked-by: Andy Lutomirski <luto@amacapital.net> Cc: linux-arm-kernel@lists.infradead.org Cc: Will Deacon <will.deacon@arm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Pavel Emelyanov <xemul@virtuozzo.com> Cc: Christopher Covington <cov@codeaurora.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
This commit is contained in:
parent
2d618fee69
commit
280e87e98c
|
@ -404,9 +404,17 @@ static unsigned long sigpage_addr(const struct mm_struct *mm,
|
||||||
static struct page *signal_page;
|
static struct page *signal_page;
|
||||||
extern struct page *get_signal_page(void);
|
extern struct page *get_signal_page(void);
|
||||||
|
|
||||||
|
static int sigpage_mremap(const struct vm_special_mapping *sm,
|
||||||
|
struct vm_area_struct *new_vma)
|
||||||
|
{
|
||||||
|
current->mm->context.sigpage = new_vma->vm_start;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct vm_special_mapping sigpage_mapping = {
|
static const struct vm_special_mapping sigpage_mapping = {
|
||||||
.name = "[sigpage]",
|
.name = "[sigpage]",
|
||||||
.pages = &signal_page,
|
.pages = &signal_page,
|
||||||
|
.mremap = sigpage_mremap,
|
||||||
};
|
};
|
||||||
|
|
||||||
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
|
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
|
||||||
|
|
|
@ -54,8 +54,26 @@ static const struct vm_special_mapping vdso_data_mapping = {
|
||||||
.pages = &vdso_data_page,
|
.pages = &vdso_data_page,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int vdso_mremap(const struct vm_special_mapping *sm,
|
||||||
|
struct vm_area_struct *new_vma)
|
||||||
|
{
|
||||||
|
unsigned long new_size = new_vma->vm_end - new_vma->vm_start;
|
||||||
|
unsigned long vdso_size;
|
||||||
|
|
||||||
|
/* without VVAR page */
|
||||||
|
vdso_size = (vdso_total_pages - 1) << PAGE_SHIFT;
|
||||||
|
|
||||||
|
if (vdso_size != new_size)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
current->mm->context.vdso = new_vma->vm_start;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct vm_special_mapping vdso_text_mapping __ro_after_init = {
|
static struct vm_special_mapping vdso_text_mapping __ro_after_init = {
|
||||||
.name = "[vdso]",
|
.name = "[vdso]",
|
||||||
|
.mremap = vdso_mremap,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct elfinfo {
|
struct elfinfo {
|
||||||
|
|
|
@ -78,9 +78,6 @@ static int vdso_mremap(const struct vm_special_mapping *sm,
|
||||||
if (image->size != new_size)
|
if (image->size != new_size)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (WARN_ON_ONCE(current->mm != new_vma->vm_mm))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
vdso_fix_landing(image, new_vma);
|
vdso_fix_landing(image, new_vma);
|
||||||
current->mm->context.vdso = (void __user *)new_vma->vm_start;
|
current->mm->context.vdso = (void __user *)new_vma->vm_start;
|
||||||
|
|
||||||
|
|
|
@ -3152,8 +3152,12 @@ static int special_mapping_mremap(struct vm_area_struct *new_vma)
|
||||||
{
|
{
|
||||||
struct vm_special_mapping *sm = new_vma->vm_private_data;
|
struct vm_special_mapping *sm = new_vma->vm_private_data;
|
||||||
|
|
||||||
|
if (WARN_ON_ONCE(current->mm != new_vma->vm_mm))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
if (sm->mremap)
|
if (sm->mremap)
|
||||||
return sm->mremap(sm, new_vma);
|
return sm->mremap(sm, new_vma);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue