Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp250180pxj; Fri, 7 May 2021 07:54:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd6QuCmuRDrVOC+m+BPpc4m9+iuTKbQmCFU85+K5eHOjGBtDijCZpmWSe6MNtkjsyhiv5m X-Received: by 2002:a65:4c8e:: with SMTP id m14mr10069499pgt.377.1620399287630; Fri, 07 May 2021 07:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620399287; cv=none; d=google.com; s=arc-20160816; b=d1NeLf80yLXdNMiVRjeTOHnx8dNW0PN958+KTLmeIXhX0hkpedWMQZP+Szoeyduyrj 9xY4Wi2RO9oBuHjpGkBqBH1GCm1b9yuqqUhDiyEM5tHhsJdW7UZ4IPpWzf4EAhvsQWzi zFmtsVNNGV0OcYVMzv4pUWH1OjrK/yWpuLZho5E5K+DnGoY0terMm95XWrkQK2KhCdrC MzW/lj0t48+0cZELEw9XGLl5qFsIGYmHiZJOUAU3KkCPE/E+x7BwK1fuLBNUONWRU3dd 3kDfqNWZNxRxXSJwLDlB02ZXyFD6zGJAMTkIb47puHuUPnFblAARyr3LCQhV7JogEzgU aV4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=WS2EGpfjc/Hj675M/gI88ld+ywU1UUy9jpzvRGmuqd8=; b=eMkZEwk99M0wWsxMAWwYv3VhXm4ARxAUTx66bs4VXZjwunJFElb2myedmT8uIK079s 1Nq4n3NvWxW4wpXYan3MpKIVDKJ5nj0JK9M1fpMIzwfHSI9P4pN5/by9TakRHZyNVgS8 reIiLtCg77fgv2QdoQ11nFFciivoGXIf64wOuZ+RpjImOIGWHoz4SYzc4CoZqGXvLNUj R6r71EHzaVZrpLWXNLHNdAJVoRAmtj4SMNNf1i6UJ78xhtgVFjYSUtpPpZSrsoF5SJLy MtdLBauzdAB7k41JGVtlCeZ887EWIQErsQngDlk16sPR2JiuR/xvLcX+8tNJKp7dNwZo oLxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j64si8388086pfb.142.2021.05.07.07.54.34; Fri, 07 May 2021 07:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236427AbhEGK1h (ORCPT + 99 others); Fri, 7 May 2021 06:27:37 -0400 Received: from outbound-smtp37.blacknight.com ([46.22.139.220]:33947 "EHLO outbound-smtp37.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234400AbhEGK1g (ORCPT ); Fri, 7 May 2021 06:27:36 -0400 Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp37.blacknight.com (Postfix) with ESMTPS id D46781A24 for ; Fri, 7 May 2021 11:26:35 +0100 (IST) Received: (qmail 12395 invoked from network); 7 May 2021 10:26:35 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.16.112]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 7 May 2021 10:26:35 -0000 Date: Fri, 7 May 2021 11:26:34 +0100 From: Mel Gorman To: Rasmus Villemoes Cc: Andrew Morton , Alexander Lobakin , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/page_alloc: __alloc_pages_bulk(): do bounds check before accessing array Message-ID: <20210507102634.GD9524@techsingularity.net> References: <20210507064504.1712559-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210507064504.1712559-1-linux@rasmusvillemoes.dk> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 07, 2021 at 08:45:03AM +0200, Rasmus Villemoes wrote: > In the event that somebody would call this with an already fully > populated page_array, the last loop iteration would do an access > beyond the end of page_array. > > It's of course extremely unlikely that would ever be done, but this > triggers my internal static analyzer. Also, if it really is not > supposed to be invoked this way (i.e., with no NULL entries in > page_array), the nr_populated instead. > > Fixes: 0f87d9d30f21 (mm/page_alloc: add an array-based interface to the bulk page allocator) > Signed-off-by: Rasmus Villemoes Acked-by: Mel Gorman -- Mel Gorman SUSE Labs