All of lore.kernel.org
 help / color / mirror / Atom feed
* do_mmap Function Issue Report
@ 2018-03-28 15:19 Po-Hao Su
  2018-03-28 17:04 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Po-Hao Su @ 2018-03-28 15:19 UTC (permalink / raw)
  To: linux-mm


[-- Attachment #1.1: Type: text/plain, Size: 1373 bytes --]

Dear Memory Management Maintainer,

I am Po-Hao Su, a graduate student from the Operating Systems and Embedded
Systems Lab at National Cheng Kung University in Taiwan.

I am writing in reference to report a bug in *do_mmap(...)* function.
Recently, I found that there seems a bug after *get_unmapped_area(...)
*function
is return.
*do_mmap(...) *function will check the *addr *parameter is aligned on a
page boundary or not after *get_unmapped_area(...)* function is return.
But it will return *addr *parameter, not an error(probably to *-EINVAL*)
while address not aligned on a page boundary.
Therefore, I think address not aligned on a page boundary should be an
error(*-EINVAL*).

I also discussed this issue with others when the meeting of my lab, others
views are consistent with me.
In view of this, I report the issue. Attached is the patch for this.

If this is a wrong report, I am sorry, and please show me why kernel do it,
if convenient. Thank you.
I look forward to hearing from you.

Best regards,

蘇柏豪, 研究生
作業系統與嵌入式系統實驗室,
國立成功大學資訊工程學系
Email: supohaosu@gmail.com

Po-Hao Su, Graduate Student
Operating Systems and Embedded Systems Lab,
Department of Computer Science and Information Engineering
National Cheng Kung University, Taiwan
Email: supohaosu@gmail.com

[-- Attachment #1.2: Type: text/html, Size: 1850 bytes --]

[-- Attachment #2: linux-4.15.13-patch-pohao --]
[-- Type: application/octet-stream, Size: 410 bytes --]

diff -Nru linux-4.15.13/mm/mmap.c linux-4.15.13-pohao/mm/mmap.c
--- linux-4.15.13/mm/mmap.c	2018-03-24 18:02:53.000000000 +0800
+++ linux-4.15.13-pohao/mm/mmap.c	2018-03-28 22:08:18.768089431 +0800
@@ -1363,7 +1363,7 @@
 	 */
 	addr = get_unmapped_area(file, addr, len, pgoff, flags);
 	if (offset_in_page(addr))
-		return addr;
+		return -EINVAL;
 
 	if (prot == PROT_EXEC) {
 		pkey = execute_only_pkey(mm);

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

* Re: do_mmap Function Issue Report
  2018-03-28 15:19 do_mmap Function Issue Report Po-Hao Su
@ 2018-03-28 17:04 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2018-03-28 17:04 UTC (permalink / raw)
  To: Po-Hao Su; +Cc: linux-mm

On Wed, Mar 28, 2018 at 11:19:30PM +0800, Po-Hao Su wrote:
> I am writing in reference to report a bug in *do_mmap(...)* function.
> Recently, I found that there seems a bug after *get_unmapped_area(...)
> *function
> is return.
> *do_mmap(...) *function will check the *addr *parameter is aligned on a
> page boundary or not after *get_unmapped_area(...)* function is return.
> But it will return *addr *parameter, not an error(probably to *-EINVAL*)
> while address not aligned on a page boundary.
> Therefore, I think address not aligned on a page boundary should be an
> error(*-EINVAL*).

Hi Po-Hao,

I'm afraid you've misunderstood the intent of this code.  The 'addr'
returned from get_unmapped_area() may be an errno, in which case we
want to return it.  Successful invocations of get_unmapped_area do,
of course, return an aligned address.  Your patch would make us return
-EINVAL for all errors, covering up the actual cause of the error (eg
-ENOMEM or -ENODEV)

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

end of thread, other threads:[~2018-03-28 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 15:19 do_mmap Function Issue Report Po-Hao Su
2018-03-28 17:04 ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.