From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751618AbdJOWNJ (ORCPT ); Sun, 15 Oct 2017 18:13:09 -0400 Received: from mail.sigma-star.at ([95.130.255.111]:45996 "EHLO mail.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbdJOWNI (ORCPT ); Sun, 15 Oct 2017 18:13:08 -0400 From: Richard Weinberger To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, daniel@iogearbox.net, ast@kernel.org, sp3485@columbia.edu Subject: Re: [PATCH] bpf: devmap: Check attr->max_entries more carefully Date: Mon, 16 Oct 2017 00:13:43 +0200 Message-ID: <100542240.i6NpMmsy5C@blindfold> In-Reply-To: <20171015220020.8157-1-richard@nod.at> References: <20171015220020.8157-1-richard@nod.at> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: static u64 dev_map_bitmap_size(const union bpf_attr *attr) { return BITS_TO_LONGS(attr->max_entries) * sizeof(unsigned long); } Thanks, //richard