From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E95AEC433ED for ; Fri, 7 May 2021 10:26:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF11D613F0 for ; Fri, 7 May 2021 10:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236487AbhEGK1j (ORCPT ); Fri, 7 May 2021 06:27:39 -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