From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: Naotaka Hamaguchi <n.hamaguchi@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm: mmap system call does not return EOVERFLOW
Date: Tue, 27 Dec 2011 21:04:13 -0500 [thread overview]
Message-ID: <CAHGf_=rW6_94NbxB1cUbrXo+YntDy7RM26XMcqk_SHXVESaSzg@mail.gmail.com> (raw)
In-Reply-To: <4EF96406.6080102@jp.fujitsu.com>
> ----------------------------------------------------------------------
> arch/x86/kernel/syscall_table_32.S:
> ...
> 194 .long sys_mmap_pgoff
> ...
>
> mm/mmap.c:
> 1080 SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
> 1081 unsigned long, prot, unsigned long, flags,
> 1082 unsigned long, fd, unsigned long, pgoff)
> ...
> 1111 down_write(¤t->mm->mmap_sem);
> 1112 retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
> 1113 up_write(¤t->mm->mmap_sem);
> ----------------------------------------------------------------------
>
>> value. We have
>> no reason to make artificial limit. Why don't you meke a overflow
>> check in sys_mmap()?
>
> I consider it is better to make an overflow check in do_mmap_pgoff.
> There are two reasons:
>
> 1. If we make an overflow check in the entrance of system call, we
> have to check in sys_mmap for x86_64 and in sys_mmap_pgoff for
> x86. It means that we have to check for each architecture
> individually. Therefore, it is more effective to make an
> overflow check in do_mmap_pgoff because both sys_mmap and
> sys_mmap_pgoff call do_mmap_pgoff.
arch/x86/include/asm/posix_types_32.h
---------------------------------------------
typedef long __kernel_off_t;
So, your patch introduce 2GB limitation to 32bit arch. It makes no sense.
> 2. Because the argument "offset" of sys_mmap is a multiple
> of the page size(otherwise, EINVAL is returned.), no information
> is lost after shifting right by PAGE_SHIFT bits. Therefore
> to make an overflow check in do_mmap_pgoff is equivalent
> to check in sys_mmap.
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2011-12-28 2:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-22 9:35 Naotaka Hamaguchi
2011-12-22 16:58 ` KOSAKI Motohiro
2011-12-22 17:41 ` KOSAKI Motohiro
2011-12-27 6:21 ` Naotaka Hamaguchi
2011-12-28 2:04 ` KOSAKI Motohiro [this message]
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='CAHGf_=rW6_94NbxB1cUbrXo+YntDy7RM26XMcqk_SHXVESaSzg@mail.gmail.com' \
--to=kosaki.motohiro@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=n.hamaguchi@jp.fujitsu.com \
/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