ARM32: Support mremap() for sigpage/vDSO
Subsystems (6)
PATCH v2 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.
---
v2: (buildbot) Fix (unsinged long) to (void*) cast warning.
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 = 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
Quoted 32 lines · Dmitry Safonov
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 aftermremap().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.Cc linux-arm-kernel at lists.infradead.orgCc Russell King <[email protected]>Cc Will Deacon <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Cc Christopher Covington <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>
Quoted 8 lines
---
v2: (buildbot) Fix (unsinged long) to (void*) cast warning.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(-)
Ping?
Quoted 86 lines
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 = 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
Dmitry
Quoted 36 lines · Dmitry Safonov
Quoted 35 lines · Dmitry Safonov
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 aftermremap().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.Cc linux-arm-kernel at lists.infradead.orgCc Russell King <[email protected]>Cc Will Deacon <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Cc Christopher Covington <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>---
v2: (buildbot) Fix (unsinged long) to (void*) cast warning.
Quoted 7 lines
Quoted 5 lines
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(-)Ping?
Ping?
Quoted 86 lines
Quoted 84 lines
arch/arm/kernel/process.c +8
-0@@ -404,9 +404,17 @@ static unsigned long sigpage_addr(const structmm_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 = 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
Dmitry
Russell King - ARM Linux
maintainerQuoted 43 lines · Dmitry Safonov
Quoted 42 lines · Dmitry Safonov
Quoted 40 lines · Dmitry Safonov
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 aftermremap().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.Cc linux-arm-kernel at lists.infradead.orgCc Russell King <[email protected]>Cc Will Deacon <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Cc Christopher Covington <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>---
v2: (buildbot) Fix (unsinged long) to (void*) cast warning.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(-)
Quoted 3 lines
Quoted 1 line
Ping?
Ping?
I'm mostly happy with the ARM bits, but I can't take the patch without acks from others because it touches other architectures/generic code.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
+ Adding back to CC x86 guys - as I've removed in ping messages.
Quoted 44 lines · Russell King - ARM Linux
Quoted 43 lines · Dmitry Safonov
Quoted 42 lines · Dmitry Safonov
Quoted 40 lines · Dmitry Safonov
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 aftermremap().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.Cc linux-arm-kernel at lists.infradead.orgCc Russell King <[email protected]>Cc Will Deacon <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Cc Christopher Covington <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>---
v2: (buildbot) Fix (unsinged long) to (void*) cast warning.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(-)
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Ping?
Ping?
I'm mostly happy with the ARM bits, but I can't take the patch without acks from others because it touches other architectures/generic code.
Fair enough, thanks.
Andy, does moving of this WARN_ON() looks good to you?
I've done it to reuse it over arches and between vdso/sigpage mappings, reducing code duplication.
Here is the patch, so you don't need to search it in the mailbox:
https://patchwork.kernel.org/patch/9681273/
Signature · 1 line
Dmitry
Quoted 62 lines · Dmitry Safonov
+ Adding back to CC x86 guys - as I've removed in ping messages.
Quoted 49 lines · Russell King - ARM Linux
Quoted 47 lines · Dmitry Safonov
Quoted 45 lines · Dmitry Safonov
Quoted 41 lines · Dmitry Safonov
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 aftermremap().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.Cc linux-arm-kernel at lists.infradead.orgCc Russell King <[email protected]>Cc Will Deacon <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Cc Christopher Covington <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>---
v2: (buildbot) Fix (unsinged long) to (void*) cast warning.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(-)Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Ping?
Ping?
I'm mostly happy with the ARM bits, but I can't take the patch without acks from others because it touches other architectures/generic code.
Quoted 5 lines
Fair enough, thanks.
Andy, does moving of this
WARN_ON()looks good to you?
I've done it to reuse it over arches and between vdso/sigpage mappings, reducing code duplication.
Quoted 6 lines
Here is the patch, so you don't need to search it in the mailbox:
https://patchwork.kernel.org/patch/9681273/--
Dmitry
Quoted 63 lines · Andy Lutomirski
Quoted 62 lines · Dmitry Safonov
+ Adding back to CC x86 guys - as I've removed in ping messages.
Quoted 58 lines · Russell King - ARM Linux
Quoted 47 lines · Dmitry Safonov
Quoted 45 lines · Dmitry Safonov
Quoted 41 lines · Dmitry Safonov
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 aftermremap().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.Cc linux-arm-kernel at lists.infradead.orgCc Russell King <[email protected]>Cc Will Deacon <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Cc Christopher Covington <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>---
v2: (buildbot) Fix (unsinged long) to (void*) cast warning.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(-)Quoted 4 lines
Quoted 1 line
Ping?
Ping?
I'm mostly happy with the ARM bits, but I can't take the patch without acks from others because it touches other architectures/generic code.
Quoted 7 lines
Quoted 5 lines
Fair enough, thanks.
Andy, does moving of this
WARN_ON()looks good to you?
I've done it to reuse it over arches and between vdso/sigpage mappings, reducing code duplication.
Hi Russell,
Should I resend this with ack, or send it to your patch system, or you'll take it from mail?
Thanks,
Dmitry
Russell King - ARM Linux
maintainerQuoted 2 lines · Dmitry Safonov
Should I resend this with ack, or send it to your patch system, or you'll take it from mail?
As most of it is ARM stuff, I suppose it should go via the ARM tree unless anyone has objections. Please put it in the patch system as I won't get to it until towards the end of this week (I'm remotely attending a conference.) Thanks.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.