From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751518AbdJFGtV (ORCPT ); Fri, 6 Oct 2017 02:49:21 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33908 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750813AbdJFGtU (ORCPT ); Fri, 6 Oct 2017 02:49:20 -0400 Subject: Re: [PATCH] mm: deferred_init_memmap improvements To: Pavel Tatashin , linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, kasan-dev@googlegroups.com, borntraeger@de.ibm.com, heiko.carstens@de.ibm.com, davem@davemloft.net, willy@infradead.org, mhocko@kernel.org, ard.biesheuvel@linaro.org, mark.rutland@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, sam@ravnborg.org, mgorman@techsingularity.net, steven.sistare@oracle.com, daniel.m.jordan@oracle.com, bob.picco@oracle.com References: <20171004152902.17300-1-pasha.tatashin@oracle.com> From: Anshuman Khandual Date: Fri, 6 Oct 2017 12:18:31 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20171004152902.17300-1-pasha.tatashin@oracle.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17100606-0040-0000-0000-000003FFD532 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17100606-0041-0000-0000-000020A146B7 Message-Id: <071d574f-1d8c-5be9-ec92-6227db01bbd3@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-06_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710060101 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/04/2017 08:59 PM, Pavel Tatashin wrote: > This patch fixes another existing issue on systems that have holes in > zones i.e CONFIG_HOLES_IN_ZONE is defined. > > In for_each_mem_pfn_range() we have code like this: > > if (!pfn_valid_within(pfn) > goto free_range; > > Note: 'page' is not set to NULL and is not incremented but 'pfn' advances. page is initialized to NULL at the beginning of the function. PFN advances but we dont proceed unless pfn_valid_within(pfn) holds true which basically should have checked with arch call back if the PFN is valid in presence of memory holes as well. Is not this correct ? > Thus means if deferred struct pages are enabled on systems with these kind > of holes, linux would get memory corruptions. I have fixed this issue by > defining a new macro that performs all the necessary operations when we > free the current set of pages. If we bail out in case PFN is not valid, then how corruption can happen ?