From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758824AbdJQEcu (ORCPT ); Tue, 17 Oct 2017 00:32:50 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:52013 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758385AbdJQEct (ORCPT ); Tue, 17 Oct 2017 00:32:49 -0400 X-Google-Smtp-Source: AOwi7QCUXo0ASDtmaBTIophduK96wxrgb0e9FuVDSrL5gCmkEbY/vJz5PoHXVroKQYRgmkxhzONIOQ== Subject: Re: [PATCH] bpf: devmap: Check attr->max_entries more carefully To: Richard Weinberger , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, daniel@iogearbox.net, ast@kernel.org, sp3485@columbia.edu References: <20171015220020.8157-1-richard@nod.at> <100542240.i6NpMmsy5C@blindfold> From: John Fastabend Message-ID: <0b5e4a49-3738-5b57-1abf-1912b2afff2c@gmail.com> Date: Mon, 16 Oct 2017 21:30:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <100542240.i6NpMmsy5C@blindfold> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/15/2017 03:13 PM, Richard Weinberger wrote: > Am Montag, 16. Oktober 2017, 00:00:20 CEST schrieb Richard Weinberger: >> max_entries is user controlled and used as input for __alloc_percpu(). >> This function expects that the allocation size is a power of two and >> less than PCPU_MIN_UNIT_SIZE. >> Otherwise a WARN() is triggered. > > On a second though, I think we should also have a hard limit for ->max_entries > or check for an overflow here: > Or just, static u64 dev_map_bitmap_size(const union bpf_attr *attr) { return BITS_TO_LONGS((u64) attr->max_entries) * sizeof(unsigned long); } Let me know if you want me to send a patch or if you want to. Thanks, John > static u64 dev_map_bitmap_size(const union bpf_attr *attr) > { > return BITS_TO_LONGS(attr->max_entries) * sizeof(unsigned long); > } > > Thanks, > //richard >