From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753841AbdDKVbW (ORCPT ); Tue, 11 Apr 2017 17:31:22 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:43104 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753819AbdDKVbU (ORCPT ); Tue, 11 Apr 2017 17:31:20 -0400 Subject: Re: [PATCH] mm/migrate: check for null vma before dereferencing it To: Andrew Morton References: <20170411125102.19497-1-colin.king@canonical.com> <20170411142633.d01ba0aaeb3e6075d517208c@linux-foundation.org> Cc: Vlastimil Babka , Minchan Kim , Mel Gorman , Johannes Weiner , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , "Kirill A . Shutemov" , linux-mm@kvack.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org From: Colin Ian King Message-ID: Date: Tue, 11 Apr 2017 22:31:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170411142633.d01ba0aaeb3e6075d517208c@linux-foundation.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/04/17 22:26, Andrew Morton wrote: > On Tue, 11 Apr 2017 13:51:02 +0100 Colin King wrote: > >> From: Colin Ian King >> >> check if vma is null before dereferencing it, this avoiding any >> potential null pointer dereferences on vma via the is_vm_hugetlb_page >> call or the direct vma->vm_flags reference. >> >> Detected with CoverityScan, CID#1427995 ("Dereference before null check") >> >> ... >> >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -2757,10 +2757,10 @@ int migrate_vma(const struct migrate_vma_ops *ops, >> /* Sanity check the arguments */ >> start &= PAGE_MASK; >> end &= PAGE_MASK; >> - if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) >> - return -EINVAL; >> if (!vma || !ops || !src || !dst || start >= end) >> return -EINVAL; >> + if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) >> + return -EINVAL; >> if (start < vma->vm_start || start >= vma->vm_end) >> return -EINVAL; >> if (end <= vma->vm_start || end > vma->vm_end) > > I don't know what kernel version this is against but I don't think it's > anything recent? I should have said it was against linux-next > > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >