Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4125557ybf; Tue, 3 Mar 2020 20:49:31 -0800 (PST) X-Google-Smtp-Source: ADFU+vsOr+UjQM8z4Oq7IVwesxXRkuLMe4GNmp3AV+L4d9zLDmogSY9tf7P/uZERLyNTgxNcMzQL X-Received: by 2002:aca:b589:: with SMTP id e131mr596369oif.82.1583297370928; Tue, 03 Mar 2020 20:49:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583297370; cv=none; d=google.com; s=arc-20160816; b=p7iwn8F3vhmXFb6fJmKF4i6WgRUBX7NNE2topZEWuexRrQd7z0U7Hj2j93Me5kJIqs ErFcPc/SRcX8ZEFZzTMJERRGNgULHqY00oBS9Q2Sous/78qV6OM2gxQQ7Bau4CEmUe8n k2yfdqu8B6q8f+J94680gs5Vog5RCP0pAVSDyrCqeYLNOyOPZW/5m4wrfVF1JMQxc7d3 fut0M39zyQUWParL8KSi52mibEf7+fX4/v3BwEOt+lmFlIcYOI/SRejptVy7NL+YkSPh NJZWl6Jd1a6BQOAEwIVzAleohDHmic0vL7AwmDaMAd/GdPUuWox9mpNpGKXKW1Lqvf7Q b2iQ== 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=tLh2t8ZxrQBaE7gNcsphAEc0sv2uDeMMUkAe4uCR56E=; b=mZz0NzuWJ80pAUtr+byJyhf/lMbtAKdEVAhlp0sjwABSahMSeszztsmBIjI08BS3n3 p9AXefKQf0qvHGDrbjMcURJ8uxH7TNqz59p3LlSKM007JIkmzvjYqKNf78yhAl44/pzM tWW+MK6VJov6zKf34UF78fpUeJzoMZQFtVPwqrj6/ufJ8kk46zloWYX62FF/V2tBJ4Kl 6Gu0lFGDV1qF5cg+s8nUvBpeHYytrNo02UaI8uZIMetGaxaL+ul+Cpve3JYmIH0C8mbu +zDrAAlv54BOle1m2vP+MBH/tnW/DWYckpO9eEzIX7r73o2s1/pdRKk1JgTL77KZy8sD r1Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HCInrvUh; 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 m7si534203oie.138.2020.03.03.20.49.18; Tue, 03 Mar 2020 20:49:30 -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=HCInrvUh; 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 S1727026AbgCDEtP (ORCPT + 99 others); Tue, 3 Mar 2020 23:49:15 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:44924 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgCDEtP (ORCPT ); Tue, 3 Mar 2020 23:49:15 -0500 Received: by mail-qk1-f196.google.com with SMTP id f198so380317qke.11; Tue, 03 Mar 2020 20:49:14 -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=tLh2t8ZxrQBaE7gNcsphAEc0sv2uDeMMUkAe4uCR56E=; b=HCInrvUhEUF02OYcK6mqXOlHVZL0s9reDN2rTvIbiPTBOSzaRK9Do71mx1576p4F+N bv4uKyqWe2Dr4Thtu9gu7hJ/aoKMqPA4k5XFCGbzIonR6tQwc/wCkisy4UAVSSp5GA6c fUjhUDxXy59ieUrYiBZeVCe18ewiyzVkjgDOhuCuqAIXNL9UdT39sUACcpiLSvbWde2q GmtVJ5ubTTylyiKCpK2c6xvjXBMpsUwjg4kc33x42yU/cbS5p4yWfyjVoGIYViZ3A1N4 tvx7t9/6Hx/2KooiORFGr3cwgkdANj8RYKjt62MrvYQZW+YehRpuhrooViVvgOapYnoM QG9g== 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=tLh2t8ZxrQBaE7gNcsphAEc0sv2uDeMMUkAe4uCR56E=; b=IuLD8ynFmDa0GGsCPLz+TnmRoWYoUROvDVFwlpdrUyxwjQ0mrczbvV2vml41Do5vAf kW9m7oxHDs5cKQ5CbJM/90wT93OKEduzfKhbUVaYsAdym6dJKq130Bmw9TIOekMkDah6 +cmsZZnrZDKVSyYsOaJHTPhPQxL2DqbbTSnJ7j+bRDlZHMs7MVha6nZCRQWZnjkteQTx LB3CI4D3wZF37bkp4XXGiiujD0Xe/h2xC5NFvo/Q86J/+fqzqifNN7mBPzrSO6Rp5jVq VkBfP9ttfAe20vhF1S/Vi22Ia4tRuphWfqOz0pfTEsYzCIUlAbWDDd+u1TszxucGQxzO fjDw== X-Gm-Message-State: ANhLgQ1O0PJrPIqHGYN7dUKf+6UU5ZRk5upgYR2Jn1VXXrzsSg/xodQL T5ix6uAg83VSXNUzbI2K/5FQzDnwZA+bRkfv1NU= X-Received: by 2002:a37:a2d6:: with SMTP id l205mr1319554qke.92.1583297353989; Tue, 03 Mar 2020 20:49:13 -0800 (PST) MIME-Version: 1.0 References: <20200304015528.29661-1-kpsingh@chromium.org> <20200304015528.29661-2-kpsingh@chromium.org> In-Reply-To: <20200304015528.29661-2-kpsingh@chromium.org> From: Andrii Nakryiko Date: Tue, 3 Mar 2020 20:49:02 -0800 Message-ID: Subject: Re: [PATCH bpf-next v2 1/7] bpf: Refactor trampoline update code To: KP Singh Cc: linux-security-module@vger.kernel.org, open list , bpf , Alexei Starovoitov , Daniel Borkmann , Paul Turner , Jann Horn , Florent Revest , Brendan Jackman 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 Tue, Mar 3, 2020 at 5:56 PM KP Singh wrote: > > From: KP Singh > > As we need to introduce a third type of attachment for trampolines, the > flattened signature of arch_prepare_bpf_trampoline gets even more > complicated. > > Refactor the prog and count argument to arch_prepare_bpf_trampoline to > use bpf_tramp_progs to simplify the addition and accounting for new > attachment types. > > Signed-off-by: KP Singh > --- See note about const-ification of trampoline and naming suggestion, but looks good overall: Acked-by: Andrii Nakryiko > arch/x86/net/bpf_jit_comp.c | 31 ++++++++++--------- > include/linux/bpf.h | 13 ++++++-- > kernel/bpf/bpf_struct_ops.c | 12 ++++++- > kernel/bpf/trampoline.c | 62 +++++++++++++++++++++---------------- > 4 files changed, 73 insertions(+), 45 deletions(-) > [...] > diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c > index 704fa787fec0..cfe96d4cd89f 100644 > --- a/kernel/bpf/trampoline.c > +++ b/kernel/bpf/trampoline.c > @@ -190,40 +190,49 @@ static int register_fentry(struct bpf_trampoline *tr, void *new_addr) > return ret; > } > > -/* Each call __bpf_prog_enter + call bpf_func + call __bpf_prog_exit is ~50 > - * bytes on x86. Pick a number to fit into BPF_IMAGE_SIZE / 2 > - */ > -#define BPF_MAX_TRAMP_PROGS 40 > +static struct bpf_tramp_progs * > +bpf_trampoline_update_progs(struct bpf_trampoline *tr, int *total) reading the code again, seems like bpf_trampoline_update_progs is really more like bpf_trampoline_get_progs, no? It doesn't modify trampoline itself, so might as well mark tr as const pointer. > +{ > + struct bpf_tramp_progs *tprogs; > + struct bpf_prog **progs; > + struct bpf_prog_aux *aux; > + int kind; > + [...]