linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ralph Campbell <rcampbell@nvidia.com>
To: Vlastimil Babka <vbabka@suse.cz>, <linux-mm@kvack.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm/migrate: initialize pud_entry in migrate_vma()
Date: Mon, 26 Aug 2019 10:30:46 -0700	[thread overview]
Message-ID: <dcadcd98-e9b4-2b4e-8a9f-5a1ef0ece0d5@nvidia.com> (raw)
In-Reply-To: <0d639edf-9f96-c170-4920-d64c2891d35d@suse.cz>


On 8/26/19 8:11 AM, Vlastimil Babka wrote:
> On 7/20/19 1:32 AM, Ralph Campbell wrote:
>> When CONFIG_MIGRATE_VMA_HELPER is enabled, migrate_vma() calls
>> migrate_vma_collect() which initializes a struct mm_walk but
>> didn't initialize mm_walk.pud_entry. (Found by code inspection)
>> Use a C structure initialization to make sure it is set to NULL.
>>
>> Fixes: 8763cb45ab967 ("mm/migrate: new memory migration helper for use with
>> device memory")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
>> Cc: "Jérôme Glisse" <jglisse@redhat.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
> 
> So this bug can manifest by some garbage address on stack being called, right? I
> wonder, how comes it didn't actually happen yet?

Right.
Probably because HMM isn't widely being used in production yet.

> 
>> ---
>>   mm/migrate.c | 17 +++++++----------
>>   1 file changed, 7 insertions(+), 10 deletions(-)
>>
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index 515718392b24..a42858d8e00b 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -2340,16 +2340,13 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
>>   static void migrate_vma_collect(struct migrate_vma *migrate)
>>   {
>>   	struct mmu_notifier_range range;
>> -	struct mm_walk mm_walk;
>> -
>> -	mm_walk.pmd_entry = migrate_vma_collect_pmd;
>> -	mm_walk.pte_entry = NULL;
>> -	mm_walk.pte_hole = migrate_vma_collect_hole;
>> -	mm_walk.hugetlb_entry = NULL;
>> -	mm_walk.test_walk = NULL;
>> -	mm_walk.vma = migrate->vma;
>> -	mm_walk.mm = migrate->vma->vm_mm;
>> -	mm_walk.private = migrate;
>> +	struct mm_walk mm_walk = {
>> +		.pmd_entry = migrate_vma_collect_pmd,
>> +		.pte_hole = migrate_vma_collect_hole,
>> +		.vma = migrate->vma,
>> +		.mm = migrate->vma->vm_mm,
>> +		.private = migrate,
>> +	};
>>   
>>   	mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm_walk.mm,
>>   				migrate->start,
>>
> 


      reply	other threads:[~2019-08-26 17:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 23:32 Ralph Campbell
2019-07-20  2:03 ` John Hubbard
2019-07-20 12:23 ` Sasha Levin
2019-08-26 15:11 ` Vlastimil Babka
2019-08-26 17:30   ` Ralph Campbell [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=dcadcd98-e9b4-2b4e-8a9f-5a1ef0ece0d5@nvidia.com \
    --to=rcampbell@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=jglisse@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@suse.cz \
    /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