Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2013497imu; Wed, 21 Nov 2018 05:33:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/WP02tMYOyBvYRX0oVUfygnq2aaqR0RA3mWgAQ8UU7SAuouSZrVwedDWm3Ipy+AHE1sqdnA X-Received: by 2002:a63:e950:: with SMTP id q16mr5965992pgj.138.1542807202960; Wed, 21 Nov 2018 05:33:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542807202; cv=none; d=google.com; s=arc-20160816; b=fBua5aRyEwC06i1TFsAfhVcTGStMnqUr76NNQ/eHQcPWMDQGpIbdr4mGQZAwdPBJ2a o+uvez24Sqp+9b6BORke0sXXWyQ8bKf7OZolGWTQuWOMH0IbopQvWazH8eG4W7aTJMON V4IBFC4rU9WqX9I3esXb8cMjFTKYJNE+jjlGHLaC9Afx9adoTOFf1vPcOXRvzjlbXtHZ Js+Z+q31Ypp1L0PO34tZXVdo4PNnhFiILupbRj8Fkm6b2L9syv5ayBXnLjimT+EeCgEF x9XJFWTyaDFoThKwW/ngRqB1joA7HziQTUyCo7PV56tCvVZrvoUQGREb8JrgmMoXiLYq Xn4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ua5Rr10lwHQvZaAtuEira9MgKRm7EfMgP/0yT234Uxw=; b=Ds9TE+iGxWeGlFPbEeBt7Wzj9YMAeXus1yZdREWAv4RTz1QnvY8ZCwno9Szatrv443 ZhAL+FDXjevBaBCzZ6gVCKnXfgd91XLbbBP1PHSSuFX0Dn+HkmmBo2EHT7RS/6JK4oou 5x/FiN9lhvBpAVr85f64s00lo6kVlccGWLIOabGOdt5BRApSXVLNafg8r0osHzqmDlgI 3uMv4Be8/RhJ283ln0bgWAuimC3jfn4eISx6Dyam5B3hQWXdHmK2U3k/SXc0cAh7S8z6 EQq44aI5Osx5DBlWxMS1Ntpf46KcsQQGoOWrkVQLVZJJctcj0SJgdDZ53EXn1qv4lP1W vNdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BaxVc/Eh"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9-v6si54370877pfe.76.2018.11.21.05.32.59; Wed, 21 Nov 2018 05:33:22 -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=@linaro.org header.s=google header.b="BaxVc/Eh"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730927AbeKUXwE (ORCPT + 99 others); Wed, 21 Nov 2018 18:52:04 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:46357 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729128AbeKUXwE (ORCPT ); Wed, 21 Nov 2018 18:52:04 -0500 Received: by mail-ed1-f65.google.com with SMTP id o10so4818490edt.13 for ; Wed, 21 Nov 2018 05:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ua5Rr10lwHQvZaAtuEira9MgKRm7EfMgP/0yT234Uxw=; b=BaxVc/Eh5J9Ay0ueMrqcTiPg+8RlZM80+ExLfcaPieTzUwa3hPsZBvJnzhpmMw9ZO8 8q2ScdC7WhN88IA9dnY1FHIbPbZKD0WLa0ctSbbWqc14rzGIxA7jotkWM8nGOwckye7Q H4Zq6NalCr/TE43QKQbjjUrUZ6yRLTlytbE14= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ua5Rr10lwHQvZaAtuEira9MgKRm7EfMgP/0yT234Uxw=; b=JeBWnj+cgYbtxqCnijVDnLr/dYEp+oIXsz7qUb3miaJHGXsJWCajeesTmFQVEVPq79 O4bbOSJjLV9qjWfVNHW3LjzfRZ/FaNhQw8BP8UMyvirSmyfo8SIScrZ6lS77XgeDouZ0 Nr3mzZUhTT3bgL+gE/YOg/pb3zxJK68rlC0+CUx7t/j2ix52PUMdepw7x8XhGDssS4yb LpMG3umztQazE0Il9eGE5lRoScAPETmxAqCn0QT/p7c4zAevnt2r6ampayE5Zbt8YGTP jhfD/A4CVoEAJe01SLJjtpu3AHNgdU6ZWDFp7XSWrNqhwhtfTmDgsAC+AM374QgzH1lW k/kw== X-Gm-Message-State: AA+aEWbgu2W6ofVTQhuocA7yEkzDKjjVRmxPuWFJHYDBXpNfSlsVRZFW hLJSdba1DuBseO8zVecD33BOmQ== X-Received: by 2002:a50:b8e5:: with SMTP id l92mr5627576ede.294.1542806262119; Wed, 21 Nov 2018 05:17:42 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id f4sm11501597edb.21.2018.11.21.05.17.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 05:17:41 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Daniel Borkmann , Alexei Starovoitov , Rick Edgecombe , Eric Dumazet , Jann Horn , Kees Cook , Jessica Yu , Arnd Bergmann , Catalin Marinas , Will Deacon , Mark Rutland , "David S. Miller" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 0/2] bpf: permit JIT allocations to be served outside the module region Date: Wed, 21 Nov 2018 14:17:31 +0100 Message-Id: <20181121131733.14910-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On arm64, modules are allocated from a 128 MB window which is close to the core kernel, so that relative direct branches are guaranteed to be in range (except in some KASLR configurations). Also, module_alloc() is in charge of allocating KASAN shadow memory when running with KASAN enabled. This means that the way BPF reuses module_alloc()/module_memfree() is undesirable on arm64 (and potentially other architectures as well), and so this series refactors BPF's use of those functions to permit architectures to change this behavior. Patch #1 breaks out the module_alloc() and module_memfree() calls into __weak functions so they can be overridden. Patch #4 implements the new alloc/free overrides for arm64 Changes since v1: - Drop misguided attempt to 'fix' and refactor the free path. Instead, just add another __weak wrapper for the invocation of module_memfree() Cc: Daniel Borkmann Cc: Alexei Starovoitov Cc: Rick Edgecombe Cc: Eric Dumazet Cc: Jann Horn Cc: Kees Cook Cc: Jessica Yu Cc: Arnd Bergmann Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: "David S. Miller" Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org Ard Biesheuvel (2): bpf: add __weak hook for allocating executable memory arm64/bpf: don't allocate BPF JIT programs in module memory arch/arm64/net/bpf_jit_comp.c | 10 ++++++++++ kernel/bpf/core.c | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) -- 2.17.1