linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 -next] x86,vdso: Fix an OOPS accessing the hpet mapping w/o an hpet
@ 2014-05-14 23:46 Andy Lutomirski
  2014-05-15  3:18 ` Hillf Danton
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Lutomirski @ 2014-05-14 23:46 UTC (permalink / raw)
  To: x86, Andrew Morton, Sasha Levin, linux-mm, Dave Jones
  Cc: LKML, Andy Lutomirski, Stefani Seibold

The oops can be triggered in qemu using -no-hpet (but not nohpet) by
reading a couple of pages past the end of the vdso text.  This
should send SIGBUS instead of OOPSing.

The bug was introduced by:

commit 7a59ed415f5b57469e22e41fc4188d5399e0b194
Author: Stefani Seibold <stefani@seibold.net>
Date:   Mon Mar 17 23:22:09 2014 +0100

    x86, vdso: Add 32 bit VDSO time support for 32 bit kernel

which is new in 3.15.

This will be fixed separately in 3.15, but that patch will not apply
to tip/x86/vdso.  This is the equivalent fix for tip/x86/vdso and,
presumably, 3.16.

Cc: Stefani Seibold <stefani@seibold.net>
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
---
 arch/x86/vdso/vma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index e915eae..8ad0081 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -90,6 +90,7 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
 	struct vm_area_struct *vma;
 	unsigned long addr;
 	int ret = 0;
+	static struct page *no_pages[] = {NULL};
 
 	if (calculate_addr) {
 		addr = vdso_addr(current->mm->start_stack,
@@ -125,7 +126,7 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
 				       addr + image->size,
 				       image->sym_end_mapping - image->size,
 				       VM_READ,
-				       NULL);
+				       no_pages);
 
 	if (IS_ERR(vma)) {
 		ret = PTR_ERR(vma);
-- 
1.9.0


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

* Re: [PATCH v2 -next] x86,vdso: Fix an OOPS accessing the hpet mapping w/o an hpet
  2014-05-14 23:46 [PATCH v2 -next] x86,vdso: Fix an OOPS accessing the hpet mapping w/o an hpet Andy Lutomirski
@ 2014-05-15  3:18 ` Hillf Danton
  2014-05-15  3:38   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2014-05-15  3:18 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: x86, Andrew Morton, Sasha Levin, linux-mm, Dave Jones, LKML,
	Stefani Seibold

Hi Andy,

On Thu, May 15, 2014 at 7:46 AM, Andy Lutomirski <luto@amacapital.net> wrote:
> The oops can be triggered in qemu using -no-hpet (but not nohpet) by
> reading a couple of pages past the end of the vdso text.  This
> should send SIGBUS instead of OOPSing.
>
> The bug was introduced by:
>
> commit 7a59ed415f5b57469e22e41fc4188d5399e0b194
> Author: Stefani Seibold <stefani@seibold.net>
> Date:   Mon Mar 17 23:22:09 2014 +0100
>
>     x86, vdso: Add 32 bit VDSO time support for 32 bit kernel
>
> which is new in 3.15.
>
> This will be fixed separately in 3.15, but that patch will not apply
> to tip/x86/vdso.  This is the equivalent fix for tip/x86/vdso and,
> presumably, 3.16.
>
> Cc: Stefani Seibold <stefani@seibold.net>
> Reported-by: Sasha Levin <sasha.levin@oracle.com>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> ---
>  arch/x86/vdso/vma.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
> index e915eae..8ad0081 100644
> --- a/arch/x86/vdso/vma.c
> +++ b/arch/x86/vdso/vma.c
> @@ -90,6 +90,7 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
>         struct vm_area_struct *vma;
>         unsigned long addr;
>         int ret = 0;
> +       static struct page *no_pages[] = {NULL};
>
>         if (calculate_addr) {
>                 addr = vdso_addr(current->mm->start_stack,
> @@ -125,7 +126,7 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
>                                        addr + image->size,
>                                        image->sym_end_mapping - image->size,
>                                        VM_READ,
> -                                      NULL);
> +                                      no_pages);
>
>         if (IS_ERR(vma)) {
>                 ret = PTR_ERR(vma);
> --
> 1.9.0
>
As the comment says,
/*
 * Called with mm->mmap_sem held for writing.
 * Insert a new vma covering the given region, with the given flags.
 * Its pages are supplied by the given array of struct page *.
 * The array can be shorter than len >> PAGE_SHIFT if it's null-terminated.
 * The region past the last page supplied will always produce SIGBUS.
 * The array pointer and the pages it points to are assumed to stay alive
 * for as long as this mapping might exist.
 */
struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
   unsigned long addr, unsigned long len,
   unsigned long vm_flags, struct page **pages)
{

we can send sigbus at fault time if no pages are supplied at install time.

thanks
Hillf

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

* Re: [PATCH v2 -next] x86,vdso: Fix an OOPS accessing the hpet mapping w/o an hpet
  2014-05-15  3:18 ` Hillf Danton
@ 2014-05-15  3:38   ` Andrew Morton
  2014-05-15  4:15     ` Hillf Danton
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2014-05-15  3:38 UTC (permalink / raw)
  To: Hillf Danton
  Cc: Andy Lutomirski, x86, Sasha Levin, linux-mm, Dave Jones, LKML,
	Stefani Seibold

On Thu, 15 May 2014 11:18:29 +0800 Hillf Danton <dhillf@gmail.com> wrote:

> > --- a/arch/x86/vdso/vma.c
> > +++ b/arch/x86/vdso/vma.c
> > @@ -90,6 +90,7 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
> >         struct vm_area_struct *vma;
> >         unsigned long addr;
> >         int ret = 0;
> > +       static struct page *no_pages[] = {NULL};
> >
> >         if (calculate_addr) {
> >                 addr = vdso_addr(current->mm->start_stack,
> > @@ -125,7 +126,7 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
> >                                        addr + image->size,
> >                                        image->sym_end_mapping - image->size,
> >                                        VM_READ,
> > -                                      NULL);
> > +                                      no_pages);
> >
> >         if (IS_ERR(vma)) {
> >                 ret = PTR_ERR(vma);
> > --
> > 1.9.0
> >
> As the comment says,
> /*
>  * Called with mm->mmap_sem held for writing.
>  * Insert a new vma covering the given region, with the given flags.
>  * Its pages are supplied by the given array of struct page *.
>  * The array can be shorter than len >> PAGE_SHIFT if it's null-terminated.
>  * The region past the last page supplied will always produce SIGBUS.
>  * The array pointer and the pages it points to are assumed to stay alive
>  * for as long as this mapping might exist.
>  */
> struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
>    unsigned long addr, unsigned long len,
>    unsigned long vm_flags, struct page **pages)
> {
> 
> we can send sigbus at fault time if no pages are supplied at install time.

Yes, but the way to communicate "no pages" is to pass (*pages)==NULL. 
Passing (pages)==NULL causes the code to oops at fault time.

We could easily change the interface so that pages==NULL means "no
pages" but that isn't the way it works at present.


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

* Re: [PATCH v2 -next] x86,vdso: Fix an OOPS accessing the hpet mapping w/o an hpet
  2014-05-15  3:38   ` Andrew Morton
@ 2014-05-15  4:15     ` Hillf Danton
  0 siblings, 0 replies; 4+ messages in thread
From: Hillf Danton @ 2014-05-15  4:15 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andy Lutomirski, x86, Sasha Levin, linux-mm, Dave Jones, LKML,
	Stefani Seibold

On Thu, May 15, 2014 at 11:38 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> We could easily change the interface so that pages==NULL means "no
> pages" but that isn't the way it works at present.
>
Yeah, thanks /Hillf

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

end of thread, other threads:[~2014-05-15  4:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-14 23:46 [PATCH v2 -next] x86,vdso: Fix an OOPS accessing the hpet mapping w/o an hpet Andy Lutomirski
2014-05-15  3:18 ` Hillf Danton
2014-05-15  3:38   ` Andrew Morton
2014-05-15  4:15     ` Hillf Danton

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).