ARM32: Support mremap() for sigpage/vDSO
Subsystems (6)
PATCH 1/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 (and sigpage is not used in that case).
--- arch/arm/kernel/process.c | 8 ++++++++ arch/arm/kernel/vdso.c | 18 ++++++++++++++++++ arch/x86/entry/vdso/vma.c | 3 --- mm/mmap.c | 4 ++++ 4 files changed, 30 insertions(+), 3 deletions(-)
arch/arm/kernel/process.c +8 -0
@@ -404,9 +404,17 @@ static unsigned long sigpage_addr(const struct mm_struct *mm,static struct page *signal_page;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 = { .name ="[sigpage]" , .pages = &signal_page, + .mremap = sigpage_mremap, };int arch_setup_additional_pages (struct linux_binprm *bprm,int uses_interp)
arch/arm/kernel/vdso.c +18 -0
@@ -54,8 +54,26 @@ static const struct vm_special_mapping vdso_data_mapping = { .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 = (void __user *)new_vma->vm_start; + +return 0 ; +} +static struct vm_special_mapping vdso_text_mapping__ro_after_init = { .name ="[vdso]" , + .mremap = vdso_mremap, };struct elfinfo {
arch/x86/entry/vdso/vma.c +0 -3
@@ -77,9 +77,6 @@ static int vdso_mremap(const struct vm_special_mapping *sm,if (image->size != new_size)return -EINVAL ; -if (WARN_ON_ONCE (current->mm != new_vma->vm_mm)) -return -EFAULT ; -vdso_fix_landing (image, new_vma); current->mm->context.vdso = (void __user *)new_vma->vm_start;
mm/mmap.c +4 -0
@@ -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; +if (WARN_ON_ONCE (current->mm != new_vma->vm_mm)) +return -EFAULT ; +if (sm->mremap)return sm->mremap (sm, new_vma); +return 0 ; }
Signature · 1 line
2.12.2
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/ARM32-Support-mremap-for-sigpage-vDSO/20170414-190018 config: arm-sunxi_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc…
Hi Dmitry,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.11-rc6 next-20170413]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/ARM32-Support-mremap-for-sigpage-vDSO/20170414-190018
config: arm-sunxi_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All warnings (new ones prefixed by >>):
arch/arm/kernel/vdso.c: In function 'vdso_mremap':
>> arch/arm/kernel/vdso.c:69:28: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
current->mm->context.vdso = (void __user *)new_vma->vm_start;
^vim +69 arch/arm/kernel/vdso.c
53 .name = "[vvar]",
54 .pages = &vdso_data_page,
55 };
56
57 static int vdso_mremap(const struct vm_special_mapping *sm,
58 struct vm_area_struct *new_vma)
59 {
60 unsigned long new_size = new_vma->vm_end - new_vma->vm_start;
61 unsigned long vdso_size;
62
63 /* without VVAR page */
64 vdso_size = (vdso_total_pages - 1) << PAGE_SHIFT;
65
66 if (vdso_size != new_size)
67 return -EINVAL;
68
> 69 current->mm->context.vdso = (void __user *)new_vma->vm_start;
70
71 return 0;
72 }
73
74 static struct vm_special_mapping vdso_text_mapping __ro_after_init = {
75 .name = "[vdso]",
76 .mremap = vdso_mremap,
77 };---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 20767 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170414/e61d08a5/attachment-0001.gz>