* [PATCH] mm: madvise: complete input validation before taking lock
@ 2013-04-10 23:45 Rasmus Villemoes
2013-04-10 23:50 ` David Rientjes
2013-04-10 23:56 ` KOSAKI Motohiro
0 siblings, 2 replies; 3+ messages in thread
From: Rasmus Villemoes @ 2013-04-10 23:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, linux-mm
In madvise(), there doesn't seem to be any reason for taking the
¤t->mm->mmap_sem before start and len_in have been
validated. Incidentally, this removes the need for the out: label.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
diff --git a/mm/madvise.c b/mm/madvise.c
index c58c94b..d2ae668 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -473,27 +473,27 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
if (!madvise_behavior_valid(behavior))
return error;
- write = madvise_need_mmap_write(behavior);
- if (write)
- down_write(¤t->mm->mmap_sem);
- else
- down_read(¤t->mm->mmap_sem);
-
if (start & ~PAGE_MASK)
- goto out;
+ return error;
len = (len_in + ~PAGE_MASK) & PAGE_MASK;
/* Check to see whether len was rounded up from small -ve to zero */
if (len_in && !len)
- goto out;
+ return error;
end = start + len;
if (end < start)
- goto out;
+ return error;
error = 0;
if (end == start)
- goto out;
+ return error;
+
+ write = madvise_need_mmap_write(behavior);
+ if (write)
+ down_write(¤t->mm->mmap_sem);
+ else
+ down_read(¤t->mm->mmap_sem);
/*
* If the interval [start,end) covers some unmapped address
@@ -541,7 +541,6 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
}
out_plug:
blk_finish_plug(&plug);
-out:
if (write)
up_write(¤t->mm->mmap_sem);
else
--
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>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: madvise: complete input validation before taking lock
2013-04-10 23:45 [PATCH] mm: madvise: complete input validation before taking lock Rasmus Villemoes
@ 2013-04-10 23:50 ` David Rientjes
2013-04-10 23:56 ` KOSAKI Motohiro
1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2013-04-10 23:50 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Andrew Morton, linux-kernel, linux-mm
On Wed, 10 Apr 2013, Rasmus Villemoes wrote:
> In madvise(), there doesn't seem to be any reason for taking the
> ¤t->mm->mmap_sem before start and len_in have been
> validated. Incidentally, this removes the need for the out: label.
>
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: David Rientjes <rientjes@google.com>
Would be nice to do s/out_plug/out/ now if you have a chance.
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: madvise: complete input validation before taking lock
2013-04-10 23:45 [PATCH] mm: madvise: complete input validation before taking lock Rasmus Villemoes
2013-04-10 23:50 ` David Rientjes
@ 2013-04-10 23:56 ` KOSAKI Motohiro
1 sibling, 0 replies; 3+ messages in thread
From: KOSAKI Motohiro @ 2013-04-10 23:56 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Andrew Morton, linux-kernel, linux-mm, kosaki.motohiro
(4/10/13 7:45 PM), Rasmus Villemoes wrote:
> In madvise(), there doesn't seem to be any reason for taking the
> ¤t->mm->mmap_sem before start and len_in have been
> validated. Incidentally, this removes the need for the out: label.
>
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Looks good.
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-10 23:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-10 23:45 [PATCH] mm: madvise: complete input validation before taking lock Rasmus Villemoes
2013-04-10 23:50 ` David Rientjes
2013-04-10 23:56 ` KOSAKI Motohiro
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).