Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13474690ybl; Sun, 29 Dec 2019 12:47:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxcglj6JvQeskO/T6ORfI+vIC74T1NdUcrmg9zgaDPylXSGdvT6uCE/2toiU1m2TR3LF15x X-Received: by 2002:a9d:6b12:: with SMTP id g18mr68063975otp.211.1577652456468; Sun, 29 Dec 2019 12:47:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652456; cv=none; d=google.com; s=arc-20160816; b=MUf4PHlr/p+IGSKGpmjpUlnHJT8v2C6XED8VObrLsIMgYG62SunVZafpGaQbe7PY8z DgNq4xFZ1l2wuhTiAYaX6OD3Cr59LhAdi/REAjYcnMJb9TUnq3IlPdSXheCMDAn+VKAI rz3H9rXN3kXVFvGBkogl4SSAA9fFJ0VVSrpG4FgdfBjy3ARUY+uIzdIKN86YO4ZorN4M fJye7XYchwOQB3I6FjhVtIlvqIu2t+7zwvEfvgxP3ZjV+Ma+NCtq1BxwZJxtjjAbjAWF hj++1kOiu0FHS7CMB+R/BxhZCp68xe3b59naO5LOrxHQMSbklAJs68bGexUBF82Zhut/ NlTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kECzD1IZ8kHTNq+95iQr99BCVdq6TF+G3mwv4phW3Gs=; b=kmGwhJojLenJJsFzfiQzEN5eIppXK2jgUX5kHU8eLoBsH/5HSW2W5ZCB52hnuMm64E cH5B0dN0kYM0TDhlt3V7mbhlaKziPBKdgqICKpP/6vhVrZBkvgSuKPtONAUufrVLBe54 1H6GWAKCns/sUgCEinVdumJwaBurYbJcy+QJ8eoibdEc+6PKwLJFR/KuTQFGM0QTFulW 7OiNlAvIMlPnJQ32/DDjN4i75Ma2m51aHETVGygk2Z78yU3vCCEMU3IjkYqdmOJW399v 3SVUuMAPJdf+r28A0T6curzU1IfKwHVJI+FnJU8ydQsd1FDg/Cjg9Xcli4jmtIxmJjo4 EtDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E1DSRyDk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18si22846232otq.121.2019.12.29.12.47.24; Sun, 29 Dec 2019 12:47:36 -0800 (PST) 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=@kernel.org header.s=default header.b=E1DSRyDk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731859AbfL2RwL (ORCPT + 99 others); Sun, 29 Dec 2019 12:52:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:38072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732210AbfL2RwG (ORCPT ); Sun, 29 Dec 2019 12:52:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D9FC207FF; Sun, 29 Dec 2019 17:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641925; bh=xCXYEYO7WU5ptonoCTDEHOUN/umnP26BvYCg3fb/y1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E1DSRyDkvyvVvMrqAXq9d79HXKMxcFWdy3fxT57IVHacvWu/99NkmunvQmb7LKGB/ MFYt1KLbPIthm0wz+5YWFrtf3/zOEFSLo0h9MhG0pc31BE3xhc94wwl+ZfIxMa+0DG taVLFtbiCFDIfYMfvYclL9Z3thueKkikirLCu6Pw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Leoshkevich , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.4 268/434] s390/bpf: Use kvcalloc for addrs array Date: Sun, 29 Dec 2019 18:25:21 +0100 Message-Id: <20191229172719.740343130@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Leoshkevich [ Upstream commit 166f11d11f6f70439830d09bfa5552ec1b368494 ] A BPF program may consist of 1m instructions, which means JIT instruction-address mapping can be as large as 4m. s390 has FORCE_MAX_ZONEORDER=9 (for memory hotplug reasons), which means maximum kmalloc size is 1m. This makes it impossible to JIT programs with more than 256k instructions. Fix by using kvcalloc, which falls back to vmalloc for larger allocations. An alternative would be to use a radix tree, but that is not supported by bpf_prog_fill_jited_linfo. Signed-off-by: Ilya Leoshkevich Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20191107141838.92202-1-iii@linux.ibm.com Signed-off-by: Sasha Levin --- arch/s390/net/bpf_jit_comp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index ce88211b9c6c..c8c16b5eed6b 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1369,7 +1370,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) } memset(&jit, 0, sizeof(jit)); - jit.addrs = kcalloc(fp->len + 1, sizeof(*jit.addrs), GFP_KERNEL); + jit.addrs = kvcalloc(fp->len + 1, sizeof(*jit.addrs), GFP_KERNEL); if (jit.addrs == NULL) { fp = orig_fp; goto out; @@ -1422,7 +1423,7 @@ skip_init_ctx: if (!fp->is_func || extra_pass) { bpf_prog_fill_jited_linfo(fp, jit.addrs + 1); free_addrs: - kfree(jit.addrs); + kvfree(jit.addrs); kfree(jit_data); fp->aux->jit_data = NULL; } -- 2.20.1