Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3471054rwa; Tue, 23 Aug 2022 05:25:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR4K85ze0vBf68AljQKOmInivPaQm/FIBIoynkbJN+N9JUmgV9DLdkc11Mk81BwTzqwX825I X-Received: by 2002:a17:90b:3d7:b0:1fa:e708:ef43 with SMTP id go23-20020a17090b03d700b001fae708ef43mr3083870pjb.239.1661257537685; Tue, 23 Aug 2022 05:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257537; cv=none; d=google.com; s=arc-20160816; b=BtRtcrgeRNmGFAvPDB2+Ks4bLQErShmdI5+bgl/IRi4A7ubO4g++SmbGUZDVf7lUKF 3Dxt8S6QdE/yU1bGlK9vCJ/Rig7KnXJSmkPZSWJnIcq67jvtGQoj1sq4yNcRiCOPE1GH GJ2IW28fz/ZubAASL66sEO/aIHXAJvZzijad9ZT6FK+YOLjVn0Tr+zqgZhoP2xYF1ulr D6wHyZGKtC2uAdtuBkkGM9NRYxVzt2Jg24qC+7I6EltSfGG1TIL1bOWXZJZW2V1+8jdH UWtZyK2cEokJ3L4XKUKZa5nqL/lZ7AFK6OpIEvmWVUz+uvyPlB5ldm0+APtXop7LMr0l jPYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=q8hDInjWLcH3BsRk9GQuzOcEdLLsD3Vos9lIlvge39s=; b=B2TXGx4iyU+43CAZS7pgZtVI+OS5mk1TcBTHQQG9A+ZOAiqULXLLfVpxsnB9+XzOJj rMdVV+INl8tB3sI5VdwioPM9f0LdW2ydmv6s+DTgZ2PwCNpkIYk+iqSWK5hTPtIrbMBd uBc8pbbz7xSvIA/Yg1He647ynyZ/91jj2ihbx/4WO8poN0OdEWlbTGOxWEJOVm9QkLzW GCyqd51CE/rzKokGK2DAKaesc1wtabBcMVND4bPH2WR717A0/VlK/GNB0lFeb8kc/2ol syaUyrb0bRcXbQjtZwOA1CdmRwjtbLNWeQjMFgUyNKBJveHN/8CqXGBBwnUL8GRiDQI0 lO0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="QJz0a/n4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a170902cf0600b0016786f2d1d8si1666345plg.475.2022.08.23.05.25.26; Tue, 23 Aug 2022 05:25:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="QJz0a/n4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354859AbiHWKpK (ORCPT + 99 others); Tue, 23 Aug 2022 06:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355711AbiHWKg4 (ORCPT ); Tue, 23 Aug 2022 06:36:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D279A6C22; Tue, 23 Aug 2022 02:07:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9FE4E6158D; Tue, 23 Aug 2022 09:07:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2B16C433D6; Tue, 23 Aug 2022 09:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245641; bh=kEJ44uGQhbsnlEsOnJCVVttPofYwKWyYENYgbKrdolw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJz0a/n4O7lY0E4L4toPKQmTHVz+OnY2avEqTSTvTCO2vCiw9IJgDb0LUGbQJ+k5/ 106HjGUZI0PdR9AFnvdDpAx4E1V0Iu7d3++pZxXU1Htd+x8QuRjDYPUu7zSwULFtYY KlrueIFIILBodMra+xgVskGpTFB5GBPy0xNvSdm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+ad24705d3fd6463b18c6@syzkaller.appspotmail.com, Jakub Kicinski , Andrii Nakryiko , Sasha Levin Subject: [PATCH 4.19 110/287] netdevsim: Avoid allocation warnings triggered from user space Date: Tue, 23 Aug 2022 10:24:39 +0200 Message-Id: <20220823080104.076774622@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jakub Kicinski [ Upstream commit d0b80a9edb1a029ff913e81b47540e57ad034329 ] We need to suppress warnings from sily map sizes. Also switch from GFP_USER to GFP_KERNEL_ACCOUNT, I'm pretty sure I misunderstood the flags when writing this code. Fixes: 395cacb5f1a0 ("netdevsim: bpf: support fake map offload") Reported-by: syzbot+ad24705d3fd6463b18c6@syzkaller.appspotmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220726213605.154204-1-kuba@kernel.org Signed-off-by: Sasha Levin --- drivers/net/netdevsim/bpf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c index 12f100392ed1..ca9042ddb6d7 100644 --- a/drivers/net/netdevsim/bpf.c +++ b/drivers/net/netdevsim/bpf.c @@ -330,10 +330,12 @@ nsim_map_alloc_elem(struct bpf_offloaded_map *offmap, unsigned int idx) { struct nsim_bpf_bound_map *nmap = offmap->dev_priv; - nmap->entry[idx].key = kmalloc(offmap->map.key_size, GFP_USER); + nmap->entry[idx].key = kmalloc(offmap->map.key_size, + GFP_KERNEL_ACCOUNT | __GFP_NOWARN); if (!nmap->entry[idx].key) return -ENOMEM; - nmap->entry[idx].value = kmalloc(offmap->map.value_size, GFP_USER); + nmap->entry[idx].value = kmalloc(offmap->map.value_size, + GFP_KERNEL_ACCOUNT | __GFP_NOWARN); if (!nmap->entry[idx].value) { kfree(nmap->entry[idx].key); nmap->entry[idx].key = NULL; @@ -475,7 +477,7 @@ nsim_bpf_map_alloc(struct netdevsim *ns, struct bpf_offloaded_map *offmap) if (offmap->map.map_flags) return -EINVAL; - nmap = kzalloc(sizeof(*nmap), GFP_USER); + nmap = kzalloc(sizeof(*nmap), GFP_KERNEL_ACCOUNT); if (!nmap) return -ENOMEM; -- 2.35.1