public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* RE: 2.5.55-rmk1: user space lossage
       [not found] <3E2F2354.7060508@intrinsyc.com>
@ 2003-01-23  2:34 ` Christopher Hoover
  2003-01-23  9:48   ` David Woodhouse
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Hoover @ 2003-01-23  2:34 UTC (permalink / raw)
  To: 'Frank Becker'; +Cc: linux-arm-kernel, 'linux-mtd'

Aha!  This is the problem:

[ch@friction src]$ diff -B -w -Naurp linux-2.5.{52,53}/fs/jffs2 
diff -B -w -Naurp linux-2.5.52/fs/jffs2/file.c
linux-2.5.53/fs/jffs2/file.c
--- linux-2.5.52/fs/jffs2/file.c        2002-12-15 18:08:24.000000000
-0800
+++ linux-2.5.53/fs/jffs2/file.c        2002-12-23 21:21:34.000000000
-0800
@@ -58,7 +58,7 @@ struct file_operations jffs2_file_operat
        .read =         generic_file_read,
        .write =        generic_file_write,
        .ioctl =        jffs2_ioctl,
-       .mmap =         generic_file_mmap,
+       .mmap =         generic_file_readonly_mmap,
        .fsync =        jffs2_fsync,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,29)
        .sendfile =     generic_file_sendfile
[ch@friction src]$ 

If you reverese this change, 2.5.55-rmk1 behaves.

-ch

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

* Re: 2.5.55-rmk1: user space lossage
  2003-01-23  2:34 ` 2.5.55-rmk1: user space lossage Christopher Hoover
@ 2003-01-23  9:48   ` David Woodhouse
  2003-01-23  9:56     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2003-01-23  9:48 UTC (permalink / raw)
  To: Christopher Hoover
  Cc: 'Frank Becker', linux-arm-kernel, 'linux-mtd',
	akpm, linux-kernel

 < Snip long thread about init segfaulting immediately at boot on 2.5.55 >

ch@murgatroid.com said:
> I just dropped jffs2 from 2.5.52 into 2.5.55 and it works, too.

ch@murgatroid.com said:
> Aha!  This is the problem: 
> -       .mmap =         generic_file_mmap,
> +       .mmap =         generic_file_readonly_mmap,
> If you reverese this change, 2.5.55-rmk1 behaves.

Er, yes. generic_file_readonly_mmap() silently removed the VM_MAYWRITE bit 
from vma->vm_flags when init made a _PRIVATE_ writable mapping, apparently 
on the basis that we have no writepage().

Then we return success anyway.

Then init segfaults when it touches something in that mapping.

/me blames akpm. :)

--
dwmw2

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

* Re: 2.5.55-rmk1: user space lossage
  2003-01-23  9:48   ` David Woodhouse
@ 2003-01-23  9:56     ` Andrew Morton
  2003-01-23 10:01       ` David Woodhouse
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2003-01-23  9:56 UTC (permalink / raw)
  To: David Woodhouse; +Cc: ch, fbecker, linux-arm-kernel, linux-mtd, linux-kernel

David Woodhouse <dwmw2@infradead.org> wrote:
>
> /me blames akpm. :)

Linus did it!

diff -puN mm/filemap.c~generic_file_readonly_mmap-fix mm/filemap.c
--- 25/mm/filemap.c~generic_file_readonly_mmap-fix	2003-01-23 01:55:41.000000000 -0800
+++ 25-akpm/mm/filemap.c	2003-01-23 01:55:45.000000000 -0800
@@ -1312,7 +1312,6 @@ int generic_file_readonly_mmap(struct fi
 {
 	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
 		return -EINVAL;
-	vma->vm_flags &= ~VM_MAYWRITE;
 	return generic_file_mmap(file, vma);
 }
 #else

_

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

* Re: 2.5.55-rmk1: user space lossage
  2003-01-23  9:56     ` Andrew Morton
@ 2003-01-23 10:01       ` David Woodhouse
  2003-01-23 10:06         ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2003-01-23 10:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: ch, fbecker, linux-arm-kernel, linux-mtd, linux-kernel

akpm@digeo.com said:
> Linus did it!

> diff -puN mm/filemap.c~generic_file_readonly_mmap-fix mm/filemap.c
> --- 25/mm/filemap.c~generic_file_readonly_mmap-fix	2003-01-23 01:55:41 -0800
> +++ 25-akpm/mm/filemap.c	2003-01-23 01:55:45 -0800
> @@ -1312,7 +1312,6 @@ int generic_file_readonly_mmap(struct fi
>  {
>  	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
> 		return -EINVAL;
> - 	vma->vm_flags &= ~VM_MAYWRITE;
>  	return generic_file_mmap(file, vma);
>  }
>  #else


-  	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
+-  	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
++ 	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))



...?

--
dwmw2

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

* Re: 2.5.55-rmk1: user space lossage
  2003-01-23 10:01       ` David Woodhouse
@ 2003-01-23 10:06         ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2003-01-23 10:06 UTC (permalink / raw)
  To: David Woodhouse; +Cc: ch, fbecker, linux-arm-kernel, linux-mtd, linux-kernel

David Woodhouse <dwmw2@infradead.org> wrote:
>
> 
> 
> -  	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
> +-  	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
> ++ 	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))

Yup.



We cannot clear VM_MAYWRITE in there - it turns writeable MAP_PRIVATE
mappings into readonly ones.

So change it back to the 2.4 form - disallow a writeable MAP_SHARED mapping
against filesystems which do no implement ->writepage().


 filemap.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff -puN mm/filemap.c~generic_file_readonly_mmap-fix mm/filemap.c
--- 25/mm/filemap.c~generic_file_readonly_mmap-fix	2003-01-23 01:55:41.000000000 -0800
+++ 25-akpm/mm/filemap.c	2003-01-23 02:04:05.000000000 -0800
@@ -1308,11 +1308,13 @@ int generic_file_mmap(struct file * file
 	return 0;
 }
 
+/*
+ * This is for filesystems which do not implement ->writepage.
+ */
 int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma)
 {
-	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
+	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
 		return -EINVAL;
-	vma->vm_flags &= ~VM_MAYWRITE;
 	return generic_file_mmap(file, vma);
 }
 #else

_

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

end of thread, other threads:[~2003-01-23  9:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <3E2F2354.7060508@intrinsyc.com>
2003-01-23  2:34 ` 2.5.55-rmk1: user space lossage Christopher Hoover
2003-01-23  9:48   ` David Woodhouse
2003-01-23  9:56     ` Andrew Morton
2003-01-23 10:01       ` David Woodhouse
2003-01-23 10:06         ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox