Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp517423oof; Tue, 25 Sep 2018 00:40:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV62V9JGlbGm0l1dtX0tnkGNCfWTBcrjcL1Qu5lv8NMGYKPkAoysGv60GKvaunUp0FsAdjtWT X-Received: by 2002:a17:902:6909:: with SMTP id j9-v6mr2302725plk.196.1537861235419; Tue, 25 Sep 2018 00:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537861235; cv=none; d=google.com; s=arc-20160816; b=zSM2FsSkTb9uhZx1YigXC1ivMIMnUfvOj5+XOOaHOVzUT/lZR9dlGWIblDx85nTD6X PgVBJsNN0SG8wBzSnPJ84EPJMU9BpKDz6FLTBqFvfgEozHc5/zr3mAwLWSRgYco44PYF LJs8UY82vMxKs7M08PXWqpGsymPBdhTAMz3PVsIlLvJaIpM2Vg7rpaswxt+XpEWL4a7M LZpI+YaQ0SBzIZLeZnhNpvSio7ALA+LO1Uk6aKFbzGy4y3AzLkQ5Uig+oLfl+a3HPYx+ tWaoqYgp5cSnw4KDPCk43tMLQfn+jCV3wF3NbbVW4kLUWrc0onXkFoQHEcOy1+HUhZcQ q+hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=zkjPu8sqVqVlLQn3HHnoX4VB3fNmHWl+/O0NQYXKt7s=; b=DKKbUfUNL2jjbHYlC4cIzSGKqqwMzY6aGnDCFPp9Q2d/W1BRMIJGFmU3IU1mO0jsBI yYyNOm48JDEmbDIexk6ING/3uTctEGXJIlEavDqz8XZraiiWs5YnaH7nZpP412danLTV NgTNbKQ4yPhH1SHlY3QgE8M2gN2+vKs+U9CL7noNUNN8CXZGcoA8V6BHL4C9IsCMuThU dIiiYx32nKVS1B+EC5jAGPEszCbXZqPVEElAHxVRoeWQNbvbRh/J/mvLJCCw8HFcVtsC ruJkK/3zzFWKolGdvpuJh2AsJkszeQU+sxyBUfCX0qz3nftDpQmrvhQnlKDwoSlUT2ae Zh5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Wq1FBMT3; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22-v6si1524486pgv.323.2018.09.25.00.40.19; Tue, 25 Sep 2018 00:40:35 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=Wq1FBMT3; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728582AbeIYNq3 (ORCPT + 99 others); Tue, 25 Sep 2018 09:46:29 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:40045 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727265AbeIYNq3 (ORCPT ); Tue, 25 Sep 2018 09:46:29 -0400 Received: by mail-it1-f194.google.com with SMTP id h23-v6so13989803ita.5 for ; Tue, 25 Sep 2018 00:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=zkjPu8sqVqVlLQn3HHnoX4VB3fNmHWl+/O0NQYXKt7s=; b=Wq1FBMT3PMs5fbM/J0OhPdOEHu5hLONYqafU9CU7IOD2bCDwjHFhc0U3JvNpACtlgL OTopbEkiUZ3CHQ6M3pH4a9YfspKwqE+ZxlYV/ALUmeXji0Jfc3y3QQ48QCDCG+lHrSzE 8LTmwhQonFwnOSv4CEFyXzPoKmv2BFGGqlijW84MX3y9fBhginYPCbYjoWJPUCFoBAzz XwdBf7usAJcbboLjAt9EHdfPobv98DwuU23ekKyGV3MSkRDrrv4vEZvp0sMuPxN1wZpk b2TcJwhM9OpRnaD/U97G3d+d4Jr9/dT+L7d82bTsTHB6ZGUP/22Uqw1XPeEFKOBkqfhV 13sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zkjPu8sqVqVlLQn3HHnoX4VB3fNmHWl+/O0NQYXKt7s=; b=k/79exvfNcWyOBe4/UOlRVpr37aHn8JyPu2r/l5EB2TPT0V9iJPArd4Cl/8T87OiaC zBm6bU3NfoJ05NTo8atNAWw2pSv89sIAn0m0m9lv1Mc7rZh2rJLK+iVpYBN72GWkgvTV QRKAU1rwXLXYrgVEtRaXwera2plpWU3Z8vHyv19hnsZOF4fC51SZNEwryTLbmSW2Wf4q GfP0jfZY+hIZGXKzilJu+Q1C5r0k5AuUZ/bSJsqIhi8189k/UbkiG+qk9ulXMvxgoox5 pfc2vA8d/WZ131ysNlIDJVs08mW2HE2eMdt4FBrfAP2T2GL73jAKT6sUvA//IOOA0aMm 8O1Q== X-Gm-Message-State: ABuFfogbWucC4IBSOqevZx+9eTa5vdGOhjypEBPCVfGHQBTsVWsoFf2E red0PiSjtXYweD2mvEaB8dS+53JCGj5hzLlp74pC+g== X-Received: by 2002:a24:c0c5:: with SMTP id u188-v6mr527094itf.57.1537861213087; Tue, 25 Sep 2018 00:40:13 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:ab8c:0:0:0:0:0 with HTTP; Tue, 25 Sep 2018 00:39:52 -0700 (PDT) In-Reply-To: <20180924184158.GA156847@dtor-ws> References: <000000000000e5f76c057664e73d@google.com> <010001660c1fafb2-6d0dc7e1-d898-4589-874c-1be1af94e22d-000000@email.amazonses.com> <010001660c4a8bbe-91200766-00df-48bd-bc60-a03da2ccdb7d-000000@email.amazonses.com> <20180924184158.GA156847@dtor-ws> From: Dmitry Vyukov Date: Tue, 25 Sep 2018 09:39:52 +0200 Message-ID: Subject: Re: WARNING: kmalloc bug in input_mt_init_slots To: Dmitry Torokhov Cc: Christopher Lameter , syzbot+87829a10073277282ad1@syzkaller.appspotmail.com, Pekka Enberg , "linux-input@vger.kernel.org" , lkml , Henrik Rydberg , syzkaller-bugs , Linux-MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 24, 2018 at 8:41 PM, Dmitry Torokhov wrote: > On Mon, Sep 24, 2018 at 03:55:04PM +0000, Christopher Lameter wrote: >> On Mon, 24 Sep 2018, Dmitry Vyukov wrote: >> >> > On Mon, Sep 24, 2018 at 5:08 PM, Christopher Lameter wrote: >> > > On Sun, 23 Sep 2018, Dmitry Vyukov wrote: >> > > >> > >> What was the motivation behind that WARNING about large allocations in >> > >> kmalloc? Why do we want to know about them? Is the general policy that >> > >> kmalloc calls with potentially large size requests need to use NOWARN? >> > >> If this WARNING still considered useful? Or we should change it to >> > >> pr_err? >> > > >> > > In general large allocs should be satisfied by the page allocator. The >> > > slab allocators are used for allocating and managing small objects. The >> > > page allocator has mechanisms to deal with large objects (compound pages, >> > > multiple page sized allocs etc). >> > >> > I am asking more about the status of this warning. If it fires in >> > input_mt_init_slots(), does it mean that input_mt_init_slots() needs >> > to be fixed? If not, then we need to change this warning to something >> > else. >> >> Hmmm.. kmalloc falls back to the page allocator already? >> >> See >> >> static __always_inline void *kmalloc(size_t size, gfp_t flags) >> { >> if (__builtin_constant_p(size)) { > > It would not be a constant here though. > >> if (size > KMALLOC_MAX_CACHE_SIZE) >> return kmalloc_large(size, flags); >> >> >> Note that this uses KMALLOC_MAX_CACHE_SIZE which should be smaller than >> KMALLOC_MAX_SIZE. >> >> >> How large is the allocation? AFACIT nRequests larger than KMALLOC_MAX_SIZE >> are larger than the maximum allowed by the page allocator. Thus the warning >> and the NULL return. > > The size in this particular case is being derived from a value passed > from userspace. Input core does not care about any limits on size of > memory kmalloc() can support and is perfectly happy with getting NULL > and telling userspace to go away with their silly requests by returning > -ENOMEM. > > For the record: I definitely do not want to pre-sanitize size neither in > uinput nor in input core. Christopher, Assuming that the size is large enough to fail in all allocators, is this warning still useful? How? Should we remove it?