From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757864AbdACJsG (ORCPT ); Tue, 3 Jan 2017 04:48:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35387 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752744AbdACJry (ORCPT ); Tue, 3 Jan 2017 04:47:54 -0500 Subject: Re: [RFC] nodemask: Consider MAX_NUMNODES inside node_isset To: Michal Hocko , Anshuman Khandual References: <20170103082753.25758-1-khandual@linux.vnet.ibm.com> <20170103084418.GC30111@dhcp22.suse.cz> <6c7ecb18-2ad0-f38a-1dc8-3c6c405b87ce@linux.vnet.ibm.com> <20170103091741.GD30111@dhcp22.suse.cz> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, vbabka@suse.cz, akpm@linux-foundation.org From: Anshuman Khandual Date: Tue, 3 Jan 2017 15:17:44 +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: <20170103091741.GD30111@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17010309-1617-0000-0000-00000195A513 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17010309-1618-0000-0000-00004779BCAB Message-Id: <69696e3f-10ca-50b4-3592-9cffba66fc81@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-03_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701030160 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/03/2017 02:47 PM, Michal Hocko wrote: > On Tue 03-01-17 14:37:09, Anshuman Khandual wrote: >> On 01/03/2017 02:14 PM, Michal Hocko wrote: >>> On Tue 03-01-17 13:57:53, Anshuman Khandual wrote: >>>> node_isset can give incorrect result if the node number is beyond the >>>> bitmask size (MAX_NUMNODES in this case) which is not checked inside >>>> test_bit. Hence check for the bit limits (MAX_NUMNODES) inside the >>>> node_isset function before calling test_bit. >>> Could you be more specific when such a thing might happen? Have you seen >>> any in-kernel user who would give such a bogus node? >> >> Have not seen this through any in-kernel use case. While rebasing the CDM >> zonelist rebuilding series, > > Then fix this particular code path... Yeah I did. > >> I came across this through an error path when >> a bogus node value of 256 (MAX_NUMNODES on POWER) is received when we call >> first_node() on an empty nodemask (which itself seems weird as well). > > Does calling first_node on an empty nodemask make any sense? If there is > a risk then I would expect nodes_empty() check before doing any mask > related operations. Hmm, you are right. All these checks should be done by the caller not these nodemask helper functions.