Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6005373imu; Tue, 13 Nov 2018 15:34:15 -0800 (PST) X-Google-Smtp-Source: AJdET5d94nHR34h0jEDFPYL4CwpIxYlGHP9FbFwk3+IzteZFvALGXMgwSGy6CZtPcTKd2jXPtE5t X-Received: by 2002:a63:b16:: with SMTP id 22mr6579982pgl.306.1542152054944; Tue, 13 Nov 2018 15:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542152054; cv=none; d=google.com; s=arc-20160816; b=C4FPv7KhrCGp7EbaBXPD/O/FI4sBsuwkEfWz6rowcNUiCB/XcFIC8Nb4Q4C8Kbb4+p wP05kLubaLETj80OoZFfhhzx4Cef2srrvgDlalxJ8eDpmYxioQuCqApDIMORedzwr/mW ZVMY3s5Hw3mvpAhymUdRCYYlZny/DGgI7WbLue6TjbdJRbdiNfnS/uPWKBhqv5X+hUR0 xEQovFAa9fmMTNj0VlGvw9hG5dnr8+sl4e4Ri96UWcmVQXFEMp1dqdqUsSAHJ8U0cCqj s867GUltJZEdJuPc8Sv8NeGAG+rOfSOi/8hfenpoy0tr3TFc0DO/eFroGq5H0rabBQAs 0A7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=orj3nfHx5URTXzPGm2eVB9BwHXnTAMu9ISWRKn6llNY=; b=mkMki+r6cD/ZDW33w55KKab75CxtlmDQ8LryqoKH0REUTAgGbE4sPzXVwmgHfN6R9c h7feWyVvSPzrt8hFhCKiCWr2QqEyAdSCYErzRBkpLTtfHkuwp0GgEb4Puq+5tK0hp96c WcddhBTmT0CIeiaqmoud2rbCZZcTWddpCAWrmwcT+5gppdTcbSr8gxL8MetvDhM4dtcg ANhbeF79ibzuw8dbvucGKIuAl+NHdtszhmHeJ/aitrDGoJ6sXfsSsgLvU3PieyJN3bmg +lSjhxAi4gZ6jhBe/BLtdVTh0AYBckQfenKiyrPSQcRUdpbmdLqVk07B6lJTE/zJulc6 Q4yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4-v6si23505097plb.237.2018.11.13.15.33.59; Tue, 13 Nov 2018 15:34:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728686AbeKNJck (ORCPT + 99 others); Wed, 14 Nov 2018 04:32:40 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52974 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbeKNJck (ORCPT ); Wed, 14 Nov 2018 04:32:40 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4168B412; Tue, 13 Nov 2018 23:32:05 +0000 (UTC) Date: Tue, 13 Nov 2018 15:32:04 -0800 From: Andrew Morton To: Vlastimil Babka Cc: Michal Hocko , Kyungtae Kim , pavel.tatashin@microsoft.com, osalvador@suse.de, rppt@linux.vnet.ibm.com, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, alexander.h.duyck@linux.intel.com, mgorman@techsingularity.net, lifeasageek@gmail.com, threeearcat@gmail.com, syzkaller@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Konstantin Khlebnikov Subject: Re: UBSAN: Undefined behaviour in mm/page_alloc.c Message-Id: <20181113153204.ea0c0895866838de9e3bc8d0@linux-foundation.org> In-Reply-To: References: <20181109084353.GA5321@dhcp22.suse.cz> <20181113094305.GM15120@dhcp22.suse.cz> <20181113151503.fd370e28cb9df5a0933e9b04@linux-foundation.org> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Nov 2018 00:23:28 +0100 Vlastimil Babka wrote: > On 11/14/18 12:15 AM, Andrew Morton wrote: > > On Tue, 13 Nov 2018 10:43:05 +0100 Michal Hocko wrote: > > > >> --- a/mm/page_alloc.c > >> +++ b/mm/page_alloc.c > >> @@ -4364,6 +4353,15 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, > >> gfp_t alloc_mask; /* The gfp_t that was actually used for allocation */ > >> struct alloc_context ac = { }; > >> > >> + /* > >> + * There are several places where we assume that the order value is sane > >> + * so bail out early if the request is out of bound. > >> + */ > >> + if (unlikely(order >= MAX_ORDER)) { > >> + WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN)); > >> + return NULL; > >> + } > >> + > > > > I know "everybody enables CONFIG_DEBUG_VM", but given this is fastpath, > > we could help those who choose not to enable it by using > > > > #ifdef CONFIG_DEBUG_VM > > if (WARN_ON_ONCE(order >= MAX_ORDER && !(gfp_mask & __GFP_NOWARN))) > > return NULL; > > #endif > > Hmm, but that would mean there's still potential undefined behavior for > !CONFIG_DEBUG_VM, so I would prefer not to do it like that. > What does "potential undefined behavior" mean here?