linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/vdso: small fixups for map_vdso
@ 2016-10-27 14:15 Dmitry Safonov
  2016-10-27 14:15 ` [PATCH 1/2] x86/prctl/uapi: remove ifdef for CHECKPOINT_RESTORE Dmitry Safonov
  2016-10-27 14:15 ` [PATCH 2/2] x86/vdso: set vdso pointer only after success Dmitry Safonov
  0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Safonov @ 2016-10-27 14:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, 0x7f454c46, Cyrill Gorcunov, Paul Bolle,
	Andy Lutomirski, oleg, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, linux-mm, x86, Peter Zijlstra

The first one is a fixup for arch_prctl constants uapi visability,
the second is code simplification.

Dmitry Safonov (2):
  x86/prctl/uapi: remove ifdef for CHECKPOINT_RESTORE
  x86/vdso: set vdso pointer only after success

 arch/x86/entry/vdso/vma.c         | 10 +++-------
 arch/x86/include/uapi/asm/prctl.h |  8 +++-----
 2 files changed, 6 insertions(+), 12 deletions(-)

-- 
2.10.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] x86/prctl/uapi: remove ifdef for CHECKPOINT_RESTORE
  2016-10-27 14:15 [PATCH 0/2] x86/vdso: small fixups for map_vdso Dmitry Safonov
@ 2016-10-27 14:15 ` Dmitry Safonov
  2016-10-28  6:48   ` [tip:x86/asm] x86/prctl/uapi: Remove #ifdef " tip-bot for Dmitry Safonov
  2016-10-27 14:15 ` [PATCH 2/2] x86/vdso: set vdso pointer only after success Dmitry Safonov
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry Safonov @ 2016-10-27 14:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, 0x7f454c46, Cyrill Gorcunov, Paul Bolle,
	Andy Lutomirski, oleg, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, linux-mm, x86

As userspace knows nothing about kernel config, this ifdefs
will make prctl constants invisible to userspace.
Let it be clean'n'simple: remove ifdefs.
If kernel has CONFIG_CHECKPOINT_RESTORE disabled, sys_prctl()
will return -EINVAL for those prctls.

Fixes: 2eefd8789698 ("x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*")
Cc: 0x7f454c46@gmail.com
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Paul Bolle <pebolle@tiscali.nl>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: oleg@redhat.com
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-mm@kvack.org
Cc: x86@kernel.org
Reported-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
---
 arch/x86/include/uapi/asm/prctl.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/uapi/asm/prctl.h b/arch/x86/include/uapi/asm/prctl.h
index ae135de547f5..835aa51c7f6e 100644
--- a/arch/x86/include/uapi/asm/prctl.h
+++ b/arch/x86/include/uapi/asm/prctl.h
@@ -6,10 +6,8 @@
 #define ARCH_GET_FS 0x1003
 #define ARCH_GET_GS 0x1004
 
-#ifdef CONFIG_CHECKPOINT_RESTORE
-# define ARCH_MAP_VDSO_X32	0x2001
-# define ARCH_MAP_VDSO_32	0x2002
-# define ARCH_MAP_VDSO_64	0x2003
-#endif
+#define ARCH_MAP_VDSO_X32	0x2001
+#define ARCH_MAP_VDSO_32	0x2002
+#define ARCH_MAP_VDSO_64	0x2003
 
 #endif /* _ASM_X86_PRCTL_H */
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] x86/vdso: set vdso pointer only after success
  2016-10-27 14:15 [PATCH 0/2] x86/vdso: small fixups for map_vdso Dmitry Safonov
  2016-10-27 14:15 ` [PATCH 1/2] x86/prctl/uapi: remove ifdef for CHECKPOINT_RESTORE Dmitry Safonov
@ 2016-10-27 14:15 ` Dmitry Safonov
  2016-10-27 22:25   ` Andy Lutomirski
  2016-10-28  6:49   ` [tip:x86/asm] x86/vdso: Set vDSO " tip-bot for Dmitry Safonov
  1 sibling, 2 replies; 6+ messages in thread
From: Dmitry Safonov @ 2016-10-27 14:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, 0x7f454c46, Cyrill Gorcunov, Andy Lutomirski,
	oleg, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, linux-mm, x86

Those pointers were initialized before call to _install_special_mapping
after the commit f7b6eb3fa072 ("x86: Set context.vdso before installing
the mapping"). This is not required anymore as special mappings have
their vma name and don't use arch_vma_name() after commit a62c34bd2a8a
("x86, mm: Improve _install_special_mapping and fix x86 vdso naming").
So, this way to init looks less entangled.
I even belive, we can remove null initializers:
- on failure load_elf_binary() will not start a new thread;
- arch_prctl will have the same pointers as before syscall.

Cc: 0x7f454c46@gmail.com
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: oleg@redhat.com
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-mm@kvack.org
Cc: x86@kernel.org
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
---
 arch/x86/entry/vdso/vma.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 23c881caabd1..e739002427ed 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -161,8 +161,6 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
 	}
 
 	text_start = addr - image->sym_vvar_start;
-	current->mm->context.vdso = (void __user *)text_start;
-	current->mm->context.vdso_image = image;
 
 	/*
 	 * MAYWRITE to allow gdb to COW and set breakpoints
@@ -189,14 +187,12 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
 	if (IS_ERR(vma)) {
 		ret = PTR_ERR(vma);
 		do_munmap(mm, text_start, image->size);
+	} else {
+		current->mm->context.vdso = (void __user *)text_start;
+		current->mm->context.vdso_image = image;
 	}
 
 up_fail:
-	if (ret) {
-		current->mm->context.vdso = NULL;
-		current->mm->context.vdso_image = NULL;
-	}
-
 	up_write(&mm->mmap_sem);
 	return ret;
 }
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] x86/vdso: set vdso pointer only after success
  2016-10-27 14:15 ` [PATCH 2/2] x86/vdso: set vdso pointer only after success Dmitry Safonov
@ 2016-10-27 22:25   ` Andy Lutomirski
  2016-10-28  6:49   ` [tip:x86/asm] x86/vdso: Set vDSO " tip-bot for Dmitry Safonov
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Lutomirski @ 2016-10-27 22:25 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Dmitry Safonov, Cyrill Gorcunov, Andy Lutomirski,
	Oleg Nesterov, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, linux-mm, X86 ML

On Thu, Oct 27, 2016 at 7:15 AM, Dmitry Safonov <dsafonov@virtuozzo.com> wrote:
> Those pointers were initialized before call to _install_special_mapping
> after the commit f7b6eb3fa072 ("x86: Set context.vdso before installing
> the mapping"). This is not required anymore as special mappings have
> their vma name and don't use arch_vma_name() after commit a62c34bd2a8a
> ("x86, mm: Improve _install_special_mapping and fix x86 vdso naming").
> So, this way to init looks less entangled.
> I even belive, we can remove null initializers:
> - on failure load_elf_binary() will not start a new thread;
> - arch_prctl will have the same pointers as before syscall.

Acked-by: Andy Lutomirski <luto@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:x86/asm] x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE
  2016-10-27 14:15 ` [PATCH 1/2] x86/prctl/uapi: remove ifdef for CHECKPOINT_RESTORE Dmitry Safonov
@ 2016-10-28  6:48   ` tip-bot for Dmitry Safonov
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Dmitry Safonov @ 2016-10-28  6:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, brgerst, gorcunov, luto, linux-kernel, hpa, pebolle,
	dsafonov, peterz, dvlasenk, bp, jpoimboe, torvalds, tglx

Commit-ID:  a01aa6c9f40fe03c82032e7f8b3bcf1e6c93ac0e
Gitweb:     http://git.kernel.org/tip/a01aa6c9f40fe03c82032e7f8b3bcf1e6c93ac0e
Author:     Dmitry Safonov <dsafonov@virtuozzo.com>
AuthorDate: Thu, 27 Oct 2016 17:15:15 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 28 Oct 2016 08:15:55 +0200

x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE

As userspace knows nothing about kernel config, thus #ifdefs
around ABI prctl constants makes them invisible to userspace.

Let it be clean'n'simple: remove #ifdefs.

If kernel has CONFIG_CHECKPOINT_RESTORE disabled, sys_prctl()
will return -EINVAL for those prctls.

Reported-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: 0x7f454c46@gmail.com
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Cc: oleg@redhat.com
Fixes: 2eefd8789698 ("x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*")
Link: http://lkml.kernel.org/r/20161027141516.28447-2-dsafonov@virtuozzo.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/uapi/asm/prctl.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/uapi/asm/prctl.h b/arch/x86/include/uapi/asm/prctl.h
index ae135de..835aa51 100644
--- a/arch/x86/include/uapi/asm/prctl.h
+++ b/arch/x86/include/uapi/asm/prctl.h
@@ -6,10 +6,8 @@
 #define ARCH_GET_FS 0x1003
 #define ARCH_GET_GS 0x1004
 
-#ifdef CONFIG_CHECKPOINT_RESTORE
-# define ARCH_MAP_VDSO_X32	0x2001
-# define ARCH_MAP_VDSO_32	0x2002
-# define ARCH_MAP_VDSO_64	0x2003
-#endif
+#define ARCH_MAP_VDSO_X32	0x2001
+#define ARCH_MAP_VDSO_32	0x2002
+#define ARCH_MAP_VDSO_64	0x2003
 
 #endif /* _ASM_X86_PRCTL_H */

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:x86/asm] x86/vdso: Set vDSO pointer only after success
  2016-10-27 14:15 ` [PATCH 2/2] x86/vdso: set vdso pointer only after success Dmitry Safonov
  2016-10-27 22:25   ` Andy Lutomirski
@ 2016-10-28  6:49   ` tip-bot for Dmitry Safonov
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Dmitry Safonov @ 2016-10-28  6:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, jpoimboe, luto, brgerst, dvlasenk, mingo,
	a.p.zijlstra, torvalds, gorcunov, hpa, dsafonov, bp, peterz,
	tglx

Commit-ID:  67dece7d4c5841e84a3c795e79bf0dcd5be54f55
Gitweb:     http://git.kernel.org/tip/67dece7d4c5841e84a3c795e79bf0dcd5be54f55
Author:     Dmitry Safonov <dsafonov@virtuozzo.com>
AuthorDate: Thu, 27 Oct 2016 17:15:16 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 28 Oct 2016 08:15:55 +0200

x86/vdso: Set vDSO pointer only after success

Those pointers were initialized before call to _install_special_mapping()
after the commit:

  f7b6eb3fa072 ("x86: Set context.vdso before installing the mapping")

This is not required anymore as special mappings have their vma name and
don't use arch_vma_name() after commit:

  a62c34bd2a8a ("x86, mm: Improve _install_special_mapping and fix x86 vdso naming")

So, this way to init looks less entangled.

I even belive that we can remove NULL initializers:

 - on failure load_elf_binary() will not start a new thread;
 - arch_prctl will have the same pointers as before syscall.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: 0x7f454c46@gmail.com
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Cc: oleg@redhat.com
Link: http://lkml.kernel.org/r/20161027141516.28447-3-dsafonov@virtuozzo.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/entry/vdso/vma.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 23c881c..e739002 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -161,8 +161,6 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
 	}
 
 	text_start = addr - image->sym_vvar_start;
-	current->mm->context.vdso = (void __user *)text_start;
-	current->mm->context.vdso_image = image;
 
 	/*
 	 * MAYWRITE to allow gdb to COW and set breakpoints
@@ -189,14 +187,12 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
 	if (IS_ERR(vma)) {
 		ret = PTR_ERR(vma);
 		do_munmap(mm, text_start, image->size);
+	} else {
+		current->mm->context.vdso = (void __user *)text_start;
+		current->mm->context.vdso_image = image;
 	}
 
 up_fail:
-	if (ret) {
-		current->mm->context.vdso = NULL;
-		current->mm->context.vdso_image = NULL;
-	}
-
 	up_write(&mm->mmap_sem);
 	return ret;
 }

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-28  6:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 14:15 [PATCH 0/2] x86/vdso: small fixups for map_vdso Dmitry Safonov
2016-10-27 14:15 ` [PATCH 1/2] x86/prctl/uapi: remove ifdef for CHECKPOINT_RESTORE Dmitry Safonov
2016-10-28  6:48   ` [tip:x86/asm] x86/prctl/uapi: Remove #ifdef " tip-bot for Dmitry Safonov
2016-10-27 14:15 ` [PATCH 2/2] x86/vdso: set vdso pointer only after success Dmitry Safonov
2016-10-27 22:25   ` Andy Lutomirski
2016-10-28  6:49   ` [tip:x86/asm] x86/vdso: Set vDSO " tip-bot for Dmitry Safonov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).