Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2935185imm; Mon, 24 Sep 2018 12:32:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV624HsjRJr1yO2/I3SUGCs9q1DOOve8XB+2++/3ed4BWTttvJiiepe8xs9ybw/nLgq2Lyaki X-Received: by 2002:a17:902:aa83:: with SMTP id d3-v6mr245771plr.242.1537817532072; Mon, 24 Sep 2018 12:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537817532; cv=none; d=google.com; s=arc-20160816; b=IYOTNWPIBhCgjujY0fEYshf0ggwl0brRsNtZWB0Ewz29F7CYLF4gxxKXoWFtXyQMLW ceMFd3R7mhpSmnf329GzZ/Zdjy6TXRfvxj5fPw0v0gaEqmL4QvFGoG1kKJK0r/bow4LI NW2z3hj+zc6Abmd8LX/27dSthhmM7k9BzvqZj6W7m5i+XWCkusxw/2CckEfLpZWKxrkb 82TfHoG6wZ0QlzVSGFCskT65jgxQHaYxnpx07rjUDrAtE62xjDfzHDro7WJi7FQTPTj1 GPymkj6s5Ni9QHq4LCcxM5Lm5HFMBAnltlyiFZfoySv4TthU/44Y7C+MsPDujoCfiykI ItuQ== 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:dkim-signature; bh=GoIeO8bXjKM7x9bySHS8IWgy1hg5fcicbTVb281PNWQ=; b=Kd6gWOBbo4+TFZ5gM8Zv9nEoI2+zSHCj6gXDt4sw7hzI5GpSNxd57s5WPZyReK3xZ4 kAgV2Dt71pNMCR8wSrSsClo1PPCQevQWybvwTWai3cN4/PaeD8TmdHuy6t4p+PXktjRo Dmv6yk6y0M7zz9udRgCIxe3Zxfayfa6rxPVqKIuCXtTyhf1LGQCBXRYbN5OmBoQQEl1Z EoJ2w8lN0GH3s6+2kBRbOpZA4pspofM1DLGeZuvNheujyFIlbUTCI6NDu4qbIgFLRaC/ +Mf37w+WcW34hBODB+tNckgflYgNUSu+vc8VpRuE1xcgxg52A0j8gQRYVcFvHTcKte6G c3AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jCpGUd4i; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5-v6si115511pgf.561.2018.09.24.12.31.56; Mon, 24 Sep 2018 12:32:12 -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=@gmail.com header.s=20161025 header.b=jCpGUd4i; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387620AbeIYApd (ORCPT + 99 others); Mon, 24 Sep 2018 20:45:33 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42195 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728811AbeIYApc (ORCPT ); Mon, 24 Sep 2018 20:45:32 -0400 Received: by mail-pg1-f195.google.com with SMTP id y4-v6so9562871pgp.9; Mon, 24 Sep 2018 11:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GoIeO8bXjKM7x9bySHS8IWgy1hg5fcicbTVb281PNWQ=; b=jCpGUd4ikkKkCPlSbydVbwbkb6UyrHXdqN8seQ9496Hx6XgBuZXpPNymM02nl8+1bS i6qGQ2wAxGNklhvsTK6c4bT04rN5lxqgQSvHedr1vIw9f61g/t1f21wVKYGoPYOFaK8I A2pWN9WSAqZyDCY+IsZzu5wBA2hvNnr0To30NG6cERg5g+45EpAEyak9kxtWULMmT7I4 hMd0d6AxBGh1I0pmlSw1nw8gTei8OlCPn5eeDpTU3MTG9vBv1aHIf/U1PG9Fh3BUzGOE Wa4hDuh/62Kxyf0RZMnx6G3KulBu2oWgECwUjla/ChewDEdQZ6snCi0pywwDWx9dZDqZ HJ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GoIeO8bXjKM7x9bySHS8IWgy1hg5fcicbTVb281PNWQ=; b=m08TYxJgeeDNnO4N4g0qJTu7SPksyKsj/EvgsLPYtuzuZ/rAUVpWUTwhpFnCthQLxj hieaSBux8T6KtgN4oyiB6MYfnk2Kg0HudohnEy26tBQlZsJf7WxECIni7vf2t/BLaIoi kUqkjvCwahvWechuIpA4XQZ3kNZe7X+JFwfpxDJI/0bG7dWU0KoKZoGsb9qHjNRdRjHO fRvpT6plZdDpVR/z5Gr0KUfn8zUBz+NUKqmPbiKVAjE0sj5FMPaq7VDRS9MjPwby1f58 nqzEK9ejBz/iQz5sZEa2cgEsO6O7XcJYoEXyQ+LixgEFm0mXwG0PDYDt2PU+P17zgpTk HCtQ== X-Gm-Message-State: ABuFfojzuzW1hAZ9enSh0GD5GXNZd6JyF/JNYNgQRvAALh2f69dVpP/y md/FkarV2HKCf7Ijz7/oDW4= X-Received: by 2002:a62:444d:: with SMTP id r74-v6mr125983pfa.96.1537814521765; Mon, 24 Sep 2018 11:42:01 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id w23-v6sm60667pgi.18.2018.09.24.11.41.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Sep 2018 11:42:00 -0700 (PDT) Date: Mon, 24 Sep 2018 11:41:58 -0700 From: Dmitry Torokhov To: Christopher Lameter Cc: Dmitry Vyukov , syzbot+87829a10073277282ad1@syzkaller.appspotmail.com, Pekka Enberg , "linux-input@vger.kernel.org" , lkml , Henrik Rydberg , syzkaller-bugs , Linux-MM Subject: Re: WARNING: kmalloc bug in input_mt_init_slots Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <010001660c4a8bbe-91200766-00df-48bd-bc60-a03da2ccdb7d-000000@email.amazonses.com> 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 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. Thanks. -- Dmitry