All of lore.kernel.org
 help / color / mirror / Atom feed
* + mm-fix-align-error-when-get_addr-in-unmapped_area_topdown.patch added to -mm tree
@ 2022-04-12 21:24 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2022-04-12 21:24 UTC (permalink / raw)
  To: mm-commits, michel, hughd, 21cnbao, lipeifeng, akpm


The patch titled
     Subject: mm/mmap.c: fix align-error when get_addr in unmapped_area_topdown
has been added to the -mm tree.  Its filename is
     mm-fix-align-error-when-get_addr-in-unmapped_area_topdown.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-fix-align-error-when-get_addr-in-unmapped_area_topdown.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-fix-align-error-when-get_addr-in-unmapped_area_topdown.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: lipeifeng <lipeifeng@oppo.com>
Subject: mm/mmap.c: fix align-error when get_addr in unmapped_area_topdown

When we found a suitable gap_end(> info->high_limit), gap_end must be set
to info->high_limit.  And we will get the gap_end after computing highest
gap address at the desired alignment.

2096 found:
2097         if (gap_end > info->high_limit)
2098                 gap_end = info->high_limit;
2099
2100 found_highest:
2101         gap_end -= info->length;
2102         gap_end -= (gap_end - info->align_offset) & info->align_mask;
2103
2104         VM_BUG_ON(gap_end < info->low_limit);
2105         VM_BUG_ON(gap_end < gap_start);
2106         return gap_end;

so we must promise: info->high_limit - info->low_limit >= info->length +
info->align_mask.

Otherwise in rare cases(info->high_limit - info->low_limit < info->length
+ info->align_mask) we will get the addr in align-error if found suitable
gap_end(> info->high_limit).

Link: https://lkml.kernel.org/r/20220412081014.399-1-lipeifeng@oppo.com
Signed-off-by: lipeifeng <lipeifeng@oppo.com>
Cc: Michel Lespinasse <michel@lespinasse.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Barry Song <21cnbao@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---


--- a/mm/mmap.c~mm-fix-align-error-when-get_addr-in-unmapped_area_topdown
+++ a/mm/mmap.c
@@ -2015,7 +2015,6 @@ static unsigned long unmapped_area_topdo
 	if (length < info->length)
 		return -ENOMEM;
 
-	length = info->length;
 	/*
 	 * Adjust search limits by the desired length.
 	 * See implementation comment at top of unmapped_area().
@@ -2027,6 +2026,8 @@ static unsigned long unmapped_area_topdo
 
 	if (info->low_limit > high_limit)
 		return -ENOMEM;
+
+	length = info->length;
 	low_limit = info->low_limit + length;
 
 	/* Check highest gap, which does not precede any rbtree node */
_

Patches currently in -mm which might be from lipeifeng@oppo.com are

mm-modify-the-method-to-search-addr-in-unmapped_area_topdown.patch
mm-fix-align-error-when-get_addr-in-unmapped_area_topdown.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-12 23:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 21:24 + mm-fix-align-error-when-get_addr-in-unmapped_area_topdown.patch added to -mm tree Andrew Morton

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.