Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp544986imu; Fri, 9 Nov 2018 01:57:00 -0800 (PST) X-Google-Smtp-Source: AJdET5eB7JAwkaebj+wG4FUfSFvE8Mozi5erojqAj91qHXSIAuo9pDyINjQEthcNis4/AVf02jYc X-Received: by 2002:a63:a41:: with SMTP id z1mr6864744pgk.117.1541757419959; Fri, 09 Nov 2018 01:56:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541757419; cv=none; d=google.com; s=arc-20160816; b=vsn2gOoXs/Zct9C4kd7/Fnmf7bKd/HATnqoBzqhVzvUdHhjXwAwJAvkiXYgN07kGoo 5BxjKuBeao2Lo8LGfh4XQwniNpEfkI/7bZ3Iut2HmBpiT3ZXqB4CrtY/Xfqkyajn80VF SCCveHHZBOKXjkO9cQcZC3pjyUhanSbmRYlZaJ0Vnh/1G8Mo0P/JaFfZ57IG5IK7bpzF mVNtwPgd1wSRHH8ITM5ftpo3sq5CzB7xz8WertgutovlsT/r8BknmA4zV2JFrUC98gCh Su2a5IjLrfFWO333ZhpDmCk+dZM4wM8VshaqX13THv1KB8DZ8ppe6iC6cGv9TOzFimKq GFww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PRXyMigSJ/sf7MBaTPaRbbb1BNuoxFrtYjIOTslQBbQ=; b=OJkRj7PHYeX/X2u5041/RaMBIG6M15TPyc5KJPewbsVz4FSYRegcuFNq2OHPcz4Z3h QPFm/PsCs/IosXR129z44Q347QJGDkCBjKvqtJxW1Sqa79hQq10N5ZEKDqUxFNxtRJS0 rCxsYCEXPNq8z4R6vLiG57Li5k/YwaqkD2ypU0+yjmQVUM1khZumeT9rqckkjnvT3azg jkmjGr25PRn6AWc6XxBrTIB5DosuOT+BdayidFCYbCtT1POX4PTRa8MY8pupPV6XvV5C V+hmWQWFtrm9cwJ4VP6bRm7vvI9CyT5IjExZvnfppVv1eRpp9FBTc2rNdBVXhG7C5IJh z1Xg== 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 g13si5884930pgk.165.2018.11.09.01.56.44; Fri, 09 Nov 2018 01:56:59 -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 S1728032AbeKITgC (ORCPT + 99 others); Fri, 9 Nov 2018 14:36:02 -0500 Received: from outbound-smtp11.blacknight.com ([46.22.139.106]:53249 "EHLO outbound-smtp11.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbeKITgC (ORCPT ); Fri, 9 Nov 2018 14:36:02 -0500 Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp11.blacknight.com (Postfix) with ESMTPS id 5CBDB1C2F5C for ; Fri, 9 Nov 2018 09:56:11 +0000 (GMT) Received: (qmail 11997 invoked from network); 9 Nov 2018 09:56:11 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[37.228.229.69]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 9 Nov 2018 09:56:11 -0000 Date: Fri, 9 Nov 2018 09:56:09 +0000 From: Mel Gorman To: Michal Hocko Cc: Kyungtae Kim , akpm@linux-foundation.org, pavel.tatashin@microsoft.com, vbabka@suse.cz, osalvador@suse.de, rppt@linux.vnet.ibm.com, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, alexander.h.duyck@linux.intel.com, 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: <20181109095609.GC23260@techsingularity.net> References: <20181109084353.GA5321@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20181109084353.GA5321@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 09, 2018 at 09:43:53AM +0100, Michal Hocko wrote: > On Thu 08-11-18 23:09:23, Kyungtae Kim wrote: > > We report a bug in v4.19-rc2 (4.20-rc1 as well, I guess): > > > > kernel config: https://kt0755.github.io/etc/config_v2-4.19 > > repro: https://kt0755.github.io/etc/repro.c4074.c > > > > In the middle of page request, this arose because order is too large to handle > > (mm/page_alloc.c:3119). It actually comes from that order is > > controllable by user input > > via raw_cmd_ioctl without its sanity check, thereby causing memory problem. > > To stop it, we can use like MAX_ORDER for bounds check before using it. > > Yes, we do only check the max order in the slow path. We have already > discussed something similar with Konstantin [1][2]. Basically kvmalloc > for a large size might get to the page allocator with an out of bound > order and warn during direct reclaim. > > I am wondering whether really want to check for the order in the fast > path instead. I have hard time to imagine this could cause a measurable > impact. > > The full patch is below > > [1] http://lkml.kernel.org/r/154109387197.925352.10499549042420271600.stgit@buzz > [2] http://lkml.kernel.org/r/154106356066.887821.4649178319705436373.stgit@buzz > I'm ok with such changes under the policy "there is no point being fast if we're broken". It's unfortunate and I know the original microoptimisation was mine but if the fast-path check ends up being a problem then I/we go back to finding ways of making the page allocator faster from a fundamental algorithmic point of view and not a microoptimisation approach. There is potential fruit there, just none that is low-hanging. -- Mel Gorman SUSE Labs