Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932204AbbLCEge (ORCPT ); Wed, 2 Dec 2015 23:36:34 -0500 Received: from shards.monkeyblade.net ([149.20.54.216]:58916 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758098AbbLCEgd (ORCPT ); Wed, 2 Dec 2015 23:36:33 -0500 Date: Wed, 02 Dec 2015 23:36:28 -0500 (EST) Message-Id: <20151202.233628.1791728126876403392.davem@davemloft.net> To: alexei.starovoitov@gmail.com Cc: ast@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com, kcc@google.com, glider@google.com, edumazet@google.com, sasha.levin@oracle.com, daniel@iogearbox.net Subject: Re: [PATCH net] bpf: fix allocation warnings in bpf maps and integer overflow From: David Miller In-Reply-To: <20151130005934.GA95228@ast-mbp.thefacebook.com> References: <20151130005934.GA95228@ast-mbp.thefacebook.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 02 Dec 2015 20:36:33 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1193 Lines: 27 From: Alexei Starovoitov Date: Sun, 29 Nov 2015 16:59:35 -0800 > From: Alexei Starovoitov > > For large map->value_size the user space can trigger memory allocation warnings like: ... > To avoid never succeeding kmalloc with order >= MAX_ORDER check that > elem->value_size and computed elem_size are within limits for both hash and > array type maps. > Also add __GFP_NOWARN to kmalloc(value_size | elem_size) to avoid OOM warnings. > Note kmalloc(key_size) is highly unlikely to trigger OOM, since key_size <= 512, > so keep those kmalloc-s as-is. > > Large value_size can cause integer overflows in elem_size and map.pages > formulas, so check for that as well. > > Fixes: aaac3ba95e4c ("bpf: charge user for creation of BPF maps and programs") > Reported-by: Dmitry Vyukov > Signed-off-by: Alexei Starovoitov Applied and queued up for -stable, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/