linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shaohua Li <shli@fb.com>
To: linux-mm@kvack.org
Cc: Kernel-team@fb.com, Benjamin LaHaise <bcrl@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 2/2] aio: make aio .mremap handle size changes
Date: Tue, 3 Feb 2015 11:18:53 -0800	[thread overview]
Message-ID: <798fafb96373cfab0707457a266dd137016cd1e9.1422986358.git.shli@fb.com> (raw)
In-Reply-To: <b885312bcea6e8c89889412936fb93305a4d139d.1422986358.git.shli@fb.com>

mremap aio ring buffer to another smaller vma is legal. For example,
mremap the ring buffer from the begining, though after the mremap, some
ring buffer pages can't be accessed in userspace because vma size is
shrinked. The problem is ctx->mmap_size isn't changed if the new ring
buffer vma size is changed. Latter io_destroy will zap all vmas within
mmap_size, which might zap unrelated vmas.

Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Shaohua Li <shli@fb.com>
---
 fs/aio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/aio.c b/fs/aio.c
index 1b7893e..fa354cf 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -306,6 +306,7 @@ static void aio_ring_remap(struct file *file, struct vm_area_struct *vma)
 		ctx = table->table[i];
 		if (ctx && ctx->aio_ring_file == file) {
 			ctx->user_id = ctx->mmap_base = vma->vm_start;
+			ctx->mmap_size = vma->vm_end - vma->vm_start;
 			break;
 		}
 	}
-- 
1.8.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-02-03 19:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 19:18 [PATCH 1/2] mremap: don't allow VM_MIXEDMAP vma expanding Shaohua Li
2015-02-03 19:18 ` Shaohua Li [this message]
2015-02-03 19:23   ` [PATCH 2/2] aio: make aio .mremap handle size changes Benjamin LaHaise
2015-02-03 19:31     ` Shaohua Li
2015-02-03 19:48       ` Benjamin LaHaise
2015-02-03 21:31         ` Shaohua Li
2015-02-03 21:47           ` Benjamin LaHaise
2015-02-03 22:58             ` Shaohua Li
2015-02-03 23:25               ` Benjamin LaHaise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=798fafb96373cfab0707457a266dd137016cd1e9.1422986358.git.shli@fb.com \
    --to=shli@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=bcrl@kvack.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox