Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1367512imu; Sat, 17 Nov 2018 23:50:50 -0800 (PST) X-Google-Smtp-Source: AJdET5cTeiYGfiaCEBo7oTZP9QKMPa/g1RsVtZyyK1hCWUFAqBfRUiYUnkBwCay1DEVWb14vvwtT X-Received: by 2002:a17:902:e002:: with SMTP id ca2mr14127426plb.103.1542527450498; Sat, 17 Nov 2018 23:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542527450; cv=none; d=google.com; s=arc-20160816; b=HFoxFYE4iglCRCbgUflFcqq20uXU/6u/4Gb4i8K4m0kl2fg98mfrH5MVBOhRpccLOq vKh6A43N+sQvkbvhv794Gd0DI7Ln9VPVTbLJJR6TBqVxPWWIxhSu/huDWcCcmPqHqTfA CN8aY/2flDLAqPmqBFRWcbudTUF5pIlxOb69PQYocOHw+Grl6jKcmoWCRqJtQ3AUJM6h mENgpip7Z2bKmb5+wh/y1qLxFG9VXeQr0jYWAoqsr64eamnqh5XI743wapy6+wOgZaNB GRMdpUiFcUx6WytWEjH9vXfa/0/V4c2G7Rvle0sRB04oqTN17iZobDGTq2Sh28vpu7gy /pmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mmUp9bVLzAjLxvxpuGqKyizUS3hwC0JQZLZ/D3xx8Dw=; b=yaBucK0Emb5r56Z4JVl8ar5CujeeYyjZBRHqOZU3tk80YbmgltMyqc7p5dfeJINsbA BF4LmeZYSNkRoEAYlbYl8vB8xkjasix0TQfXZofSH1HOdUlR7RwaLLaNTkFuxLOHIov6 wxZGMK+mhVyFAN5por4LTJB3c3nxliGH0YQlfkyO6gzPXSicY9B5KNhmebN7PMplZhNV E+g5Rfmao56jo5sWtO8Vtde2If3UeLFvGKz8a/6ciTOBP4JpJKgLIv7hAM7VUJ3KGRMR Ozl285g01Vaq5IS/QMtHVky74BoUjCodAZZ01PYYPnSorehkpqOI38Orau/nY59ARO1S aUJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E7ls5kEI; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c3si12375256pgi.370.2018.11.17.23.50.35; Sat, 17 Nov 2018 23:50:50 -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=@gmail.com header.s=20161025 header.b=E7ls5kEI; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727236AbeKRSJB (ORCPT + 99 others); Sun, 18 Nov 2018 13:09:01 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:40727 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbeKRSJB (ORCPT ); Sun, 18 Nov 2018 13:09:01 -0500 Received: by mail-qk1-f196.google.com with SMTP id y16so44147818qki.7; Sat, 17 Nov 2018 23:49:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mmUp9bVLzAjLxvxpuGqKyizUS3hwC0JQZLZ/D3xx8Dw=; b=E7ls5kEIfXFrL+O3NSrT0/OjSCJW5QTbXrKomsxzn2oupTGH3ZXPKGoQgkbSU8B5Zl gkc+zA/bX4ToSOFH2H5o6CtP4ricuUiCt2wanR+G6FwpSQOBW3YqB07UnpSrjYVgaH9L bIJlxpteq/vKIBBFHQdhciAJI7S0R4RQG3wd7Lk+SzhND9BeAx77n7nUVXQx5KdcEo3V suJgNmxMeltBkBRyRUxPQ+qYIFc1ZF/O/4h+UoJUTgM+gG3V0dlSfSlKhW8T/GatjXQD 1Yp0kRC12IXkvaMP11VbHXkIvMeaXLe9Wc+4XDsFVSx4QSWlbZWXdcLNkeIww6Ur8c5r R9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mmUp9bVLzAjLxvxpuGqKyizUS3hwC0JQZLZ/D3xx8Dw=; b=JkFQMLPcPOK10JKkrcygm/4pgmaPk9aI8xSy9LNUrsTJQaNz4dhCz256TkVgqL+c8Q H7h0M/BnCJbtKY/GLaiX5wAkxfZU8m/bD9HyWOYk8X6e1uCBll2JhsZsGj16ZUf94mR5 HNaQokNfO2QW0vX/YPkHMk7gHfGEej8pjSVSMFatCLey7bRue8y26Fu//UUGTpt9IA8c wkr/9i8icEJghemmgejDMjOnEP0zeO+U3TNnvc1Hd3o+wNF8mPENSq1UhY8jd9wNskMU uPPxv4QlCvy11QXMSp5he221FB3NndjVY4OXfl1NXSEB9Z4tzdIJns7g2GFp2rlw3Tw2 VQqw== X-Gm-Message-State: AGRZ1gIafhudGwv188me4r8qeIqF2rA5MgIzq9Wm6Ev+XHRXo5Ah44AG mFtfmH88iAENfLXZ6ox9PYO6tg+BLLIVBChJtGE= X-Received: by 2002:a37:41d2:: with SMTP id o201mr16064899qka.24.1542527368265; Sat, 17 Nov 2018 23:49:28 -0800 (PST) MIME-Version: 1.0 References: <20181117185715.25198-1-ard.biesheuvel@linaro.org> In-Reply-To: <20181117185715.25198-1-ard.biesheuvel@linaro.org> From: Y Song Date: Sun, 18 Nov 2018 07:48:59 +0000 Message-ID: Subject: Re: [PATCH 0/4] bpf: permit JIT allocations to be served outside the module region To: ard.biesheuvel@linaro.org Cc: LKML , Daniel Borkmann , Alexei Starovoitov , rick.p.edgecombe@intel.com, eric.dumazet@gmail.com, jannh@google.com, Kees Cook , jeyu@kernel.org, arnd@arndb.de, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, ralf@linux-mips.org, paul.burton@mips.com, jhogan@kernel.org, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, David Miller , linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, netdev Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 17, 2018 at 6:58 PM Ard Biesheuvel wrote: > > 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 fixes a bug introduced during the merge window, where the new > alloc/free tracking does not account for memory that is freed by some > arch code. > > Patch #2 refactors the freeing path so that architectures can switch to > something other than module_memfree(). > > Patch #3 does the same for module_alloc(). > > Patch #4 implements the new alloc/free overrides for arm64 Except a minor comment, the whole patch set looks good to me. Acked-by: Yonghong Song > > 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: Ralf Baechle > Cc: Paul Burton > Cc: James Hogan > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: "David S. Miller" > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-mips@linux-mips.org > Cc: linuxppc-dev@lists.ozlabs.org > Cc: sparclinux@vger.kernel.org > Cc: netdev@vger.kernel.org > > Ard Biesheuvel (4): > bpf: account for freed JIT allocations in arch code > net/bpf: refactor freeing of executable allocations > 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 | 11 ++++++++++ > arch/mips/net/bpf_jit.c | 7 ++----- > arch/powerpc/net/bpf_jit_comp.c | 7 ++----- > arch/powerpc/net/bpf_jit_comp64.c | 12 +++-------- > arch/sparc/net/bpf_jit_comp_32.c | 7 ++----- > kernel/bpf/core.c | 22 ++++++++++---------- > 6 files changed, 31 insertions(+), 35 deletions(-) > > -- > 2.17.1 >