From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA775C54EBC for ; Wed, 4 Jan 2023 14:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672841249; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=HnqvU7+uzJaZkngKGkJyY5Dl3BCY1boSbGLqeDV5kIQ=; b=c5ZYvpLRlY95Zevt2Jh+LgI/MH6QaWVZUpYkGATE3TanDf5KbIf9RVwJ+MLqVYLQyQzAT3 UBunE4kJEIeTcvxr6eChen7dEWBCbpEAsNGmbrkzu2eBu1FxTFcNsKaePQo3NCoorPTBzo iLKbWlqV55zQrAwge4mqKkMnDJ4Ed9U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-128-F3qsVjDXNHivrsQW8BWZlg-1; Wed, 04 Jan 2023 09:07:26 -0500 X-MC-Unique: F3qsVjDXNHivrsQW8BWZlg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 935198533EF; Wed, 4 Jan 2023 14:07:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3428492C1B; Wed, 4 Jan 2023 14:07:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B768D1946A72; Wed, 4 Jan 2023 14:07:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3389A1946587 for ; Tue, 3 Jan 2023 18:12:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D4B3A2026D68; Tue, 3 Jan 2023 18:12:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA0BF2026D4B for ; Tue, 3 Jan 2023 18:12:23 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99ED21C00403 for ; Tue, 3 Jan 2023 18:12:23 +0000 (UTC) Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-314-4qfncZCpMlOltiqaQ93_qg-1; Tue, 03 Jan 2023 13:12:21 -0500 X-MC-Unique: 4qfncZCpMlOltiqaQ93_qg-1 Received: by mail-il1-f180.google.com with SMTP id c20so14584649ilj.10 for ; Tue, 03 Jan 2023 10:12:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:message-id:thread-topic:subject :from:date:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GO1V8/zoXG2+E8MXdFkLhzLUXI8HS7nbu4QDqEVUVk4=; b=q30+4GxeTh9k82ru7Tl+JIa+xbMIV24b5lj88M9kPzxAMYHWa9Tk1jcmgGxPRTlB/Z 6FQ8pn5yTRsstkx15bMeN7WArM0Zq7B5Iw8F3XXJNy0BO+PYEgNtqxBHZa7wU4S4XhX5 znKmrHY/SUdfvJc9Zgkn07SQPOpZC+0jEWGRyLuFlWkmPttZrORO8ZllScXRlk3UWkQu 7V/iCo/9QE1dgOCr3RslX/jNwYK1qnG2bpJE8En22MkT+JjBCtJfHTfQ38AZNX8MCr7E FaOdTdmtN3VScCEXg38+PDkr1RGNvuRL60lLnfbVJlhiu9qlWIl+PApVKPIXdphuILAY yZ4g== X-Gm-Message-State: AFqh2koaNsdAFlYBQ4Of+7ubXQXU6OBoskqxMp5QnpwURAmJzPGGbst3 PZLOQQEzay3rI4oBKN+Rjwg= X-Google-Smtp-Source: AMrXdXvUm2cSG+kPR9yrrKK6gjSK0HSMnrOLkqLv7IK3+RP1vLpbnotnv+h+PDDJPmTvSJJxlfaBCA== X-Received: by 2002:a05:6e02:78f:b0:300:5860:f07e with SMTP id q15-20020a056e02078f00b003005860f07emr29416356ils.31.1672769540101; Tue, 03 Jan 2023 10:12:20 -0800 (PST) Received: from LAPTOP-4OFSRCBD ([2601:281:c502:6e30:314c:dc76:6124:6f0e]) by smtp.gmail.com with ESMTPSA id k12-20020a92c24c000000b0030c0dce44b1sm6553653ilo.15.2023.01.03.10.12.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2023 10:12:19 -0800 (PST) MIME-Version: 1.0 Date: Tue, 3 Jan 2023 11:12:18 -0700 From: Bryce Subject: Re: [PATCH v2] bpf: restore the ebpf program ID for BPF_AUDIT_UNLOAD and PERF_BPF_EVENT_PROG_UNLOAD Thread-Topic: Re: [PATCH v2] bpf: restore the ebpf program ID for BPF_AUDIT_UNLOAD and PERF_BPF_EVENT_PROG_UNLOAD Message-ID: <294DC0E6-5B0C-4ED5-B22C-C6E4A86B0A43@hxcore.ol> To: "paul@paul-moore.com" X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Bulk-Signature: yes X-Mimecast-Spam-Signature: bulk X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mailman-Approved-At: Wed, 04 Jan 2023 14:07:19 +0000 X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "bpf@vger.kernel.org" , "linux-audit@redhat.com" , "burn.alting@iinet.net.au" , "ast@kernel.org" , "sdf@google.com" Errors-To: linux-audit-bounces@redhat.com Sender: "Linux-audit" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 1 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="===============7445430453268346090==" --===============7445430453268346090== Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"
Wh=
en changing the ebpf program put() routines to support being called
from within IRQ context the pro=
gram ID was reset to zero prior to
calling the perf event and audit UNLOAD record generators, which=
resulted in problems as=
 the ebpf program ID was bogus (always zero).
This patch resolves this by adding a new flag, bpf_pr=
og::valid_id, to
indic=
ate when the bpf_prog_aux ID field is valid; it is set to true/1=
in bpf_prog_alloc_id() and set to =
false/0 in bpf_prog_free_id().=C2=A0 In
order to help ensure that access to the bpf_prog_aux ID fie= ld takes
into account th=
e new valid_id flag, the bpf_prog_aux ID field is
renamed to bpf_prog_aux::__id and a getter functi=
on,
bpf_prog_get_id(), w=
as created and all users of bpf_prog_aux::id were
converted to the new caller.=C2=A0 Exceptions to =
this include some of the
internal ebpf functions and the xdp trace points, although the latter=
still take into account the =
valid_id flag.
&nbs=
p;
I also modified the bpf_au=
dit_prog() logic used to associate the
AUDIT_BPF record with other associated records, e.g. @ctx != =3D NULL.
Instead of key=
ing off the operation, it now keys off the execution
context, e.g. '!in_irg && !irqs_disabl=
ed()', which is much more
the associated audit state =
(other audit records).
<=
o:p> 
Fixes: d809e134be7=
a ("bpf: Prepare bpf_prog_put() to be called from irq context.")<=
o:p>
Reported-by: Burn Alting=
 <burn.alting@iinet.net.au>
Reported-by: Jiri Olsa <olsajiri@gmail.com>
Signed-off-by: Paul Moore <paul@paul=
-moore.com>
&nbs=
p;
--
* v2
=C2=A0 - change subj
=
=C2=A0 - add mention of the perf regression
=C2=A0 - drop the dedicated program audit ID=
=C2=A0 - add the bpf_prog::v=
alid_id flag, bpf_prog_get_id() getter
=C2=A0 - convert prog ID users to new ID getter
* v1
=C2=A0 - subj was: "bpf: restore the ebpf audit UN=
LOAD id field"
=C2=
=A0 - initial draft
---<=
o:p>
 drivers/net/netdevsim/b=
pf.c=C2=A0 |=C2=A0 6 ++++--
 include/linux/bpf.h=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0| 11 +++++++++--
 =
include/linux/bpf_verifier.h |=C2=A0 2 +-
<= pre> include/trace/events/xdp.h=C2=A0=C2=A0 |=C2=A0 4 ++--
 kernel/bpf/arraymap.c=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/bpf_struct_ops.c=C2=A0 |=C2=A0 2 +=
-
 kernel/bpf/cgroup.c=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/core.c=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/cpumap.c=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/devmap.c=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/syscall.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 | 27 +++++++++++++++------------
 kernel/events/core.c=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 6 +++++-
 kernel/trace/bpf_trace.c=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=
=A0 2 +-
 net/core/dev.c=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 |=C2=A0 2 +-
 =
net/core/filter.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 |=C2=A0 3 ++-
=
 net/core/rtnetlink.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=
=A0 2 +-
 net/core/sock_=
map.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 net/ipv6/seg6_local.c=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 3 ++-
 net/sched/act_bpf.c=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 net/sched/cls_bpf.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 20 files changed, 52 insertions(+), 34 deletions(-)<=
/span>
 
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/n=
et/netdevsim/bpf.c
index=
 50854265864d..2795f03f5f34 100644
--- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
@@ -109,7 +109,7 @@ nsim_bpf_offload(struct =
netdevsim *ns, struct bpf_prog *prog, bool oldprog)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0"bad offload state, expected offload %sto be acti=
ve",
 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0oldprog ? "&quo=
t; : "not ");
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ns->bpf_offloaded =3D prog;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 ns->bpf_offloaded_id =3D prog ? prog->aux->id : 0;<=
/o:p>
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 ns->bpf_offloaded_id =3D prog ? bpf_prog_get_id(prog) : 0;
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 nsim_prog_set_loaded(prog, true);
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
@@ -221,6 +221,7 @@ static int nsim_bpf_creat=
e_prog(struct nsim_dev *nsim_dev,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct nsim_bpf_bound_prog =
*state;
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 char name[16];
<=
strong> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int ret;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u=
32 id;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 state =3D kzalloc(sizeof(*state), GFP_KERNEL);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!state=
)
@@ -239,7 +240,8 @@ st=
atic int nsim_bpf_create_prog(struct nsim_dev *nsim_dev,<=
/strong>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ret;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 debugfs_create_=
u32("id", 0400, state->ddir, &prog->aux->id);
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 id =3D bpf_prog_get_id(prog);
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 debugfs_create_u32(&q= uot;id", 0400, state->ddir, &id);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 debugfs_create_=
file("state", 0400, state->ddir,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 =C2=A0=C2=A0=C2=A0=C2=A0&state->state, &nsim_bpf_string_fops);<=
o:p>
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 debugfs_create_bool("loaded", 0400, state->ddi=
r, &state->is_loaded);
=
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 9e7d46d16032..18e965bd7db9 10064=
4
--- a/include/linux/bp=
f.h
+++ b/include/linux/=
bpf.h
@@ -1102,7 +1102,7=
 @@ struct bpf_prog_aux {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u=
32 max_tp_access;
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 stack_depth;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 id;
+=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 u32 __id; /* access via bpf_prog_get_id() to check bpf_prog::v=
alid_id */
 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 u32 func_cnt; /* used by non-func prog as the numb=
er of func progs */
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 func_idx; /* 0 for non-func prog, the=
 index in func array for func prog */
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 attach_btf_id; /* i=
n-kernel BTF type id to attach to */
<=
strong>@@ -1197,7 +1197,8 @@ struct bpf_prog {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enforce_expected_att=
ach_type:1, /* Enforce expected_attach_type checking at attach time */=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ca=
ll_get_stack:1, /* Do we call bpf_get_stack() or bpf_get_stackid() */<=
/o:p>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ca=
ll_get_func_ip:1, /* Do we call get_func_ip() */=
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tstamp_type_access:1; /=
* Accessed __sk_buff->tstamp_type */
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tstamp_type_access:1, /* Accesse= d __sk_buff->tstamp_type */
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 valid_id:1; /* Is bpf_prog::aux::__id val=
id? */
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 enum bpf_prog_type=C2=A0=C2=A0=C2=A0=C2=A0 type;=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Type of BPF program =
*/
 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 enum bpf_attach_type=C2=A0=C2=A0 expected_attach_type; /=
* For some prog types */
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 len;=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* =
Number of filter blocks */
@@ -1688,6 +1689,12 @@ void bpf_prog_inc(struct bpf_prog *prog);
 struct bpf_prog * __must_check=
 bpf_prog_inc_not_zero(struct bpf_prog *prog);
 void bpf_prog_put(struct bpf_prog *prog);
+static inline u32 bpf_prog_get_id(const struct bpf_pro=
g *prog)
+{
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 if (WARN(!prog->valid_id, "Attempting to use an invalid eBPF pr=
ogram"))
+=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 retur=
n 0;
+=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 return prog->aux->__id;=
+}
 void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock);
 void bpf_map_free_id(struct b=
pf_map *map, bool do_idr_lock);
 
diff --git a/i=
nclude/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 9e1e6965f407..525c02cc12ea 100644<=
o:p>
--- a/include/linux/bpf_=
verifier.h
+++ b/include=
/linux/bpf_verifier.h
@@=
 -604,7 +604,7 @@ static inline u64 bpf_trampoline_compute_key(const struct=
 bpf_prog *tgt_prog,
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0struct btf *btf, u32 btf_id)
 {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (tgt_prog)
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ((u64)tgt_prog->aux-&g=
t;id << 32) | btf_id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 return ((u64)bpf_prog_get_id(tgt_prog) << 32) | btf_id;
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 else
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 return ((u64)btf_obj_id(btf) << 32) | 0x80000000 | btf_id;
diff --git a/include/trace/events/xdp.h b/include/trac=
e/events/xdp.h
index c40=
fc97f9417..a1c3048872ea 100644
--- a/include/trace/events/xdp.h
+++ b/include/trace/events/xdp.h=
@@ -39,7 +39,7 @@ TRACE_EVENT(xdp_exception,<=
/o:p>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 ),
 
+=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __ent=
ry->prog_id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D (xdp->valid_id ? =
xdp->aux->__id : 0);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 __entry->act=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 =3D act;
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 __entry->ifindex=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D dev->ifi=
ndex;
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 ),
@@ -120,7 +120,7 @@ DECLARE_EVENT_CLASS(xdp_redirect_template,<=
/span>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 map_index =3D 0;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 }
 
-=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->prog_id=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D xdp->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->prog_id=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 =3D (xdp->valid_id ? xdp->aux->__id : 0);=
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->act=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D XDP_REDIRE=
CT;
 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->if=
index=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D dev->ifindex;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->err=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D err;=
diff --git a/kernel/bpf/arraymap.c b/kern=
el/bpf/arraymap.c
index=
 832b2659e96e..d19db5980b1b 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
=
@@ -905,7 +905,7 @@ static void prog_fd_array_put_ptr(vo=
id *ptr)
 
=C2=A0static u32 prog_fd_array_sys_lo=
okup_elem(void *ptr)
 {<=
o:p>
-=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 return ((struct bpf_prog *)ptr)->aux->id;<=
/span>
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 return bpf_prog_get_id((struct bpf_prog *)ptr);
 }
 
=C2=A0/* decrem=
ent refcnt of all bpf_progs that are stored in this map */
diff --git a/kernel/bpf/bpf_struct_ops.c=
 b/kernel/bpf/bpf_struct_ops.c
index 84b2d9dba79a..6c20e6cd9442 100644
--- a/kernel/bpf/bpf_struct_ops.c<=
/strong>
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -488,7 +488,7 @@ static int b=
pf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 image +=3D err;
 
<=
strong>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 /* put prog_id to udata */
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *(unsigned long *)(udata + moff) =3D prog=
->aux->id;
+=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 *(unsigned long *)(udata + moff) =3D bpf_prog_get_id(prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
}
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 r=
efcount_set(&kvalue->refcnt, 1);
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c=
index bf2fdb33fb31..4a8d26f1=
d5d1 100644
--- a/kernel=
/bpf/cgroup.c
+++ b/kern=
el/bpf/cgroup.c
@@ -1091=
,7 +1091,7 @@ static int __cgroup_bpf_query(struct cgroup *cgrp, const unio=
n bpf_attr *attr,
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i =3D 0;=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 hlist_for_each_entry(pl, progs, node) {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog =3D prog_list_p=
rog(pl);
-=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 id =3D prog->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D bpf_prog_get_id(prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 if (copy_to_user(prog_ids + i, &id, sizeof(id)))
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 return -EFAULT;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (++i =3D=3D cnt)
diff --git a/kernel/bpf/core.c b/ker=
nel/bpf/core.c
index 25a=
54e04560e..ea3938ab6f5b 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -2293,7 +2293,7 @@ static bool bpf_prog_array_copy_core(struct bp=
f_prog_array *array,
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (item =3D array->items; item-&g=
t;prog; item++) {
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 if (item->prog =3D=3D &dummy_bpf_prog.prog)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 continue;
-=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 prog_ids[i] =3D item->prog->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog_ids[i] =3D bpf_prog_get_id(item->prog);=
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (++i =3D=3D re=
quest_cnt) {
 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 item++;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 break;
diff --git=
 a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index b5ba34ddd4b6..3f3423d03aea 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c=
@@ -413,7 +413,7 @@ static int __c=
pu_map_load_bpf_program(struct bpf_cpu_map_entry *rcpu,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EINVAL;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rcpu->value=
.bpf_prog.id =3D prog->aux->id;
=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rcpu->value.bpf_prog=
.id =3D bpf_prog_get_id(prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rcpu->prog =3D prog;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;=
diff --git a/kernel/bpf=
/devmap.c b/kernel/bpf/devmap.c
index f9a87dcc5535..d46309d4aa9e 100644<=
/pre>
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -868,7 +868,7 @@ static struct bpf_dtab_netd=
ev *__dev_map_alloc_node(struct net *net,
<= pre> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->dtab =3D dt= ab;
 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 if (prog) {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 dev->xdp_prog =3D prog;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 dev->val.bpf_prog.id =3D prog->aux->id;=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->val.bpf_prog.id=
 =3D bpf_prog_get_id(prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->xdp_prog =3D NULL;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->val.bpf_prog.id =3D 0;
diff --git a/kernel/bpf/s=
yscall.c b/kernel/bpf/syscall.c
index 7b373a5e861f..9e862ef792cb 100644<=
/pre>
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1958,13 +1958,14 @@ static void bpf_audit=
_prog(const struct bpf_prog *prog, unsigned int op)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return;
<= pre> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (audit_enabled = =3D=3D AUDIT_OFF)
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 return;
-=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 if (op =3D=3D BPF_AUDIT_LOAD)
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!i=
n_irq() && !irqs_disabled())
<=
strong> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 ctx =3D audit_context();
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ab =3D audit_log_=
start(ctx, GFP_ATOMIC, AUDIT_BPF);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(!ab))
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return;<=
/strong>
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* l=
og the id regardless of bpf_prog::valid_id */
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 audit_log_forma=
t(ab, "prog-id=3D%u op=3D%s",
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog= ->aux->id, bpf_audit_str[op]);
<=
strong>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0  prog-&g=
t;aux->__id, bpf_audit_str[op]);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 audit_log_end(ab);
 }<=
/pre>
 
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 idr_preload(GFP_KERNEL);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_lock_bh(&pr= og_idr_lock);
 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D idr_alloc_cyclic(&prog_idr, prog, 1,=
 INT_MAX, GFP_ATOMIC);
-=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (id > 0)
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog->aux->id =3D id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 if (id > 0) {
+=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 prog->aux->__id =3D id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 prog->valid_id =3D true;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }<= /strong>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin=
_unlock_bh(&prog_idr_lock);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 idr_preload_end();=
 
=
@@ -1996,7 +1999,7 @@ void bpf_prog_free_id(struct bpf_p=
rog *prog, bool do_idr_lock)
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* disappears - even if som=
eone grabs an fd to them they are unusable,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* simply wa=
iting for refcnt to drop to be freed.
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
if (!prog->aux->id)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (do_idr_lock)
@@ -2004,8 +2007,8 @@ void bpf_=
prog_free_id(struct bpf_prog *prog, bool do_idr_lock)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __acquire(&prog_=
idr_lock);
 <=
/span>
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 idr_remove(&prog_idr, prog->aux->id);
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog->=
aux->id =3D 0;
+=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 idr_remove(&prog_idr, prog->aux-&g=
t;__id);
+=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 prog->valid_id =3D false;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (do_idr_lock)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock_irqrestore(&am=
p;prog_idr_lock, flags);
@@ -2154,7 +2157,7 @@ static void bpf_prog_show_fdinfo(struct seq_file *m,=
 struct file *filp)
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 =C2=A0=C2=A0=C2=A0prog->jited,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0prog_tag,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0prog->pages * 1ULL << P=
AGE_SHIFT,
-=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0 prog->aux->id,
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 =C2=A0=C2=A0 bpf_prog_get_id(prog),
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0stats.nsecs,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0stats.cnt,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0stats=
.misses,
@@ -2786,7 +278=
9,7 @@ static void bpf_link_show_fdinfo(struct seq_file *m, struct file *fi=
lp)
 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=
=C2=A0bpf_link_type_strs[link->type],
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0link->id,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0prog_tag,
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 prog->aux->id=
);
+=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 b=
pf_prog_get_id(prog));
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (link->ops->show_fdinfo)=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 link->ops->show_f=
dinfo(link, m);
 }<=
/o:p>
@@ -3914,7 +3917,7 @@ static =
int bpf_prog_get_info_by_fd(struct file *file,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EFAULT;
 
=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.type =3D prog->type;
-=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 info.id =3D prog->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.id =3D bpf=
_prog_get_id(prog);
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.load_time =3D prog->aux->load_=
time;
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 info.created_by_uid =3D from_kuid_munged(current_user=
_ns(),
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0prog->aux->user->uid);
@@ -4261,7 +4264,7 @@ static int bpf_link_get_=
info_by_fd(struct file *file,
=
 
=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.type =3D link->type;<=
/strong>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info=
.id =3D link->id;
-=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.prog_id =3D link->prog->aux=
->id;
+=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 info.prog_id =3D bpf_prog_get_id(link->prog);
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (=
link->ops->fill_link_info) {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 err =3D link->ops->fill_link_info(link, &info);
@@ -4426,7 +4429,7 @@ sta=
tic int bpf_task_fd_query(const union bpf_attr *attr,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 struct bpf_raw_event_map *btp =3D raw_tp->btp;
 
=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 er=
r =3D bpf_task_fd_query_copy(attr, uattr,
<= pre>-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0 raw_tp->link.prog->aux->id,
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0=C2=A0 bpf_prog_get_id(raw_tp->link.prog),=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0BPF_FD_TYPE_RAW_TRACEPOINT,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0btp->tp->name, 0, 0);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 goto put_file;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index aefc1e08e015..c24e897d27f1 10064=
4
--- a/kernel/events/co=
re.c
+++ b/kernel/events=
/core.c
@@ -9001,7 +9001=
,11 @@ void perf_event_bpf_event(struct bpf_prog *prog,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 },
 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .type =3D type,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 .flags =3D flags,
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .id =3D prog-&=
gt;aux->id,
+=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0  * don't use bpf_prog_get_id() as the id may be marked
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0  * invalid on PERF_BPF_EVENT_PROG_UNLOAD events
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0  */
+=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .id =3D prog->aux->_=
_id,
 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 },<=
/span>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 };
 
diff --git a/kernel/trace/bpf_trace.c b=
/kernel/trace/bpf_trace.c
--- a/kernel/trace/bpf_trace.c=
+++ b/kernel/trace/bpf_trace.c
@@ -2344,7 +2344,7 @@ int bpf_get_perf_even=
t_info(const struct perf_event *event, u32 *prog_id,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (prog=
->type =3D=3D BPF_PROG_TYPE_PERF_EVENT)
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 return -EOPNOTSUPP;
 
-=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *prog_id =3D prog->aux->id;=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 *prog_id =3D bpf_prog_get_id(prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 flags =3D event=
->tp_event->flags;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 is_tracepoint =3D flags & TRACE_=
EVENT_FL_TRACEPOINT;
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 is_syscall_tp =3D is_syscall_trace_eve=
nt(event->tp_event);
=
diff --git a/net/core/dev.c b/net/core/dev.c
index fa53830d0683..0d39ef22cf4b 100644
--- a/net/core/dev.c=
+++ b/net/core/dev.c
@@ -9068,7 +9068,7 @@ u32 dev_xdp_prog_id(st=
ruct net_device *dev, enum bpf_xdp_mode mode)
 {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct bpf_prog *prog =3D dev_xdp_pr=
og(dev, mode);
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 return prog ? prog->aux->id : 0;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return prog ? b=
pf_prog_get_id(prog) : 0;
 =
=C2=A0static void dev_xdp_set_link(struct=
 net_device *dev, enum bpf_xdp_mode mode,
<= pre>diff --git a/net/core/filter.c b/net/core/filter.c
index bb0136e7a8e4..282ccfe34c=
ed 100644
--- a/net/core=
/filter.c
+++ b/net/core=
/filter.c
@@ -8729,7 +87=
29,8 @@ void bpf_warn_invalid_xdp_action(struct net_device *dev, struct bpf=
_prog *prog,
 
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0act > act_max ? "Ille=
gal" : "Driver unsupported",
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 act, prog->aux->nam=
e, prog->aux->id, dev ? dev->name : "N/A");
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 act,=
 prog->aux->name, bpf_prog_get_id(prog),
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 dev ? dev->name : &=
quot;N/A");
 }
 EXPORT_SYMBOL_GPL(bpf_war=
n_invalid_xdp_action);
 =
diff --git a/net/core/r=
tnetlink.c b/net/core/rtnetlink.c
index 74864dc46a7e..1f7e36909541 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1453,7 +1453,7 @@ static u32 rtnl_xdp_p=
rog_skb(struct net_device *dev)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 generic_xdp_prog =3D rtnl_der=
eference(dev->xdp_prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!generic_xdp_prog)=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 retur=
n generic_xdp_prog->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return bpf_prog_get_id(gen=
eric_xdp_prog);
 }<=
/o:p>
 <=
/pre>
=C2=A0static u32 rtnl_xdp_prog_drv(struct net_devic=
e *dev)
diff --git a/net=
/core/sock_map.c b/net/core/sock_map.c
index a660baedd9e7..550ec6cb3aee 100644
--- a/net/core/sock_map.c<=
/strong>
+++ b/net/core/sock_map.c
@@ -1518,7 +1518,7 @@ int sock_map_bpf_p=
rog_query(const union bpf_attr *attr,
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* we do not hold the r=
efcnt, the bpf prog may be released
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* asynchronously an=
d the id would be set to 0.
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D dat=
a_race(prog->aux->id);
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D data_race(bpf_prog_get_id=
(prog));
 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 if (id =3D=3D 0)
<= pre> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 prog_cnt =3D 0;
diff =
--git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index 8370726ae7bf..440ce3aba802 100644<=
/o:p>
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local=
.c
@@ -1543,7 +1543,8 @@=
 static int put_nla_bpf(struct sk_buff *skb, struct seg6_local_lwt *slwt)
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 if (!nest)
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 return -EMSGSIZE;
 
-=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 if (nla_put_u32(skb, SEG6_LOCAL_BPF_PROG, slwt->bpf.p=
rog->aux->id))
+=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nla_put_u32(skb, SEG6_LOCAL_BPF_PR=
OG,
+=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bpf_prog_get_id(slwt->bpf.prog)))=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMSGSIZE;<=
/o:p>
 <=
/pre>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (slwt=
->bpf.name &&
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index b79eee44e24e..604a29e482b0 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c=
@@ -121,7 +121,7 @@ sta=
tic int tcf_bpf_dump_ebpf_info(const struct tcf_bpf *prog,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0=C2=A0nla_put_string(skb, TCA_ACT_BPF_NAME, prog->bpf_=
name))
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMS=
GSIZE;
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i=
f (nla_put_u32(skb, TCA_ACT_BPF_ID, prog->filter->aux->id))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 if (nla_put_u32(skb, TCA_ACT_BPF_ID, bpf_prog_get_id(prog->fil=
ter)))
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMS=
GSIZE;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 nla =3D nla_reserve(skb, TCA_ACT_BPF_TAG, sizeof(prog->filter->ta=
g));
diff --git a/net/sc=
hed/cls_bpf.c b/net/sched/cls_bpf.c
index bc317b3eac12..eb5ac6be589e 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -565,7 +565,7 @@ static int cls_bpf_dump=
_ebpf_info(const struct cls_bpf_prog *prog,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=
=A0=C2=A0nla_put_string(skb, TCA_BPF_NAME, prog->bpf_name))
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMSGSIZE;<=
/span>
 
<= pre>-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nla_put_u32(skb= , TCA_BPF_ID, prog->filter->aux->id))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nla_put_u3=
2(skb, TCA_BPF_ID, bpf_prog_get_id(prog->filter)))
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMSGSIZE;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nla =3D nla_reserve(skb=
, TCA_BPF_TAG, sizeof(prog->filter->tag));=
-- 
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>2.39.0
 <=
/o:p>
 
From mboxrd@z Thu Jan=C2=A0 1 00:00:00 1970
Return-Path: <linux-aud=
it-bounces@redhat.com>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 aws-us-west-2-korg-lkml-1.web.codeaurora.org
Received: from us-smtp-delivery-124.mimecast.co=
m (us-smtp-delivery-124.mimecast.com [170.10.133.124])
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (=
using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))<=
/o:p>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 (No client certificate requested)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 by smt=
p.lore.kernel.org (Postfix) with ESMTPS id 65980C4332F
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 f=
or <linux-audit@archiver.kernel.org>; Fri, 23 Dec 2022 18:55:59 +0000=
 (UTC)
DKIM-Signature: v=
=3D1; a=3Drsa-sha256; c=3Drelaxed/relaxed; d=3Dredhat.com;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 s=3Dmimecast20190719; t=3D1671821758;
<= pre>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 h=3Dfrom:from:= sender:sender:reply-to:subject:subject:date:date:
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0  messa=
ge-id:message-id:to:to:cc:cc:mime-version:mime-version:
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
 content-type:content-type:
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0  content-transfer-encoding:c=
ontent-transfer-encoding:list-id:list-help:
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0  list-unsubs=
cribe:list-subscribe:list-post;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bh=3DasiHuOkcbekxm31BZtp=
hD1tarMMM2R55B6VI8uEw3FA=3D;
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 b=3DWJPnwgvdFHmpzbzjaEuEThM=
elSKYZRDlo4cFHDulVhXJ/Ss58r3z18CC9PzUb6wX/Fb+7v<=
/pre>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 y7yoYFAm=
bk/Md5nMNhpZlgyPnPnbODNEyW0PERlvGqpzvGVy2VFEGI3+T3dwrQvDytPA77
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 20j9tmT1WkfK/jrUHaFEqIxAfT2Tefg=3D
<= pre>Received: from mimecast-mx02.redhat.com (mimecast-mx02.re= dhat.com
 [66.187.233.88=
]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=3DTLSv1.2, cipher=3DTLS_ECDHE_RSA_WITH_=
AES_256_GCM_SHA384) id
 =
us-mta-50-6CpqV3ReND6cE_3Xaf36Yw-1; Fri, 23 Dec 2022 13:55:55 -0500
X-MC-Unique: 6CpqV3ReND6cE_3Xaf=
36Yw-1
Received: from sm=
tp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3])=
=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 =
bits))
=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 (No client certificate requested)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D96C918E0921;
=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 Fri, 23 Dec 2022 18:55:53 +0000 (UTC)<=
/strong>
Received: from mm-prod-listman-01.mail-001=
.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100])
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
by smtp.corp.redhat.com (Postfix) with ESMTP id 52241111F3B0;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 Fri, 23 Dec 2022 18:55:53 +0000 (UTC)
Received: from mm-prod-listman-01.mail-001.prod.us-eas=
t-1.aws.redhat.com (localhost [IPv6:::1])
<= pre>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 by mm-prod-lis= tman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 13E2= 119465B3;
=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Fri, 23 Dec 2022 18:55:53 +0000 (UTC)
Received: from smtp.corp.redha=
t.com (int-mx08.intmail.prod.int.rdu2.redhat.com=
 [10.11.54.8])
by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.c= om (Postfix) with
 ESMT=
P id 8076C19465B1 for <linux-audit@listman.corp.redhat.com>;
 Fri, 23 Dec 2022 18:55:40 +0000=
 (UTC)
Received: by smtp=
.corp.redhat.com (Postfix)
 id 63792C15BAE; Fri, 23 Dec 2022 18:55:40 +0000 (UTC)=
Received: from mimecast-mx02.redhat.com
 (mimecast09.extmail.prod=
.ext.rdu2.redhat.com [10.11.55.25])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BD04C15BA0
 for <linux-audit@redh=
at.com>; Fri, 23 Dec 2022 18:55:40 +0000 (UTC)
Received: from us-smtp-1.mimecast.com (us-smtp-de=
livery-1.mimecast.com
 [=
207.211.31.120])
 (usi=
ng TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requeste=
d)
 by mimecast-mx02.red=
hat.com (Postfix) with ESMTPS id 368682802E21
 for <linux-audit@redhat.com>; Fri, 23 Dec 2022=
 18:55:40 +0000 (UTC)
Re=
ceived: from mail-qt1-f179.google.com (mail-qt1-f179.google.com<=
/span>
 [209.85.160.179]) by relay.mimecas=
t.com with ESMTP with STARTTLS
 (version=3DTLSv1.3, cipher=3DTLS_AES_128_GCM_SHA256) id<=
/span>
 us-mta-351-8jm3k5RPMXuhVSaa4HoaEQ-=
1; Fri, 23 Dec 2022 13:55:35 -0500
X-MC-Unique: 8jm3k5RPMXuhVSaa4HoaEQ-1=
Received: by mail-qt1-f179.google.com with SMTP id=
 jr11so4365783qtb.7
 for=
 <linux-audit@redhat.com>; Fri, 23 Dec 2022 10:55:35 -0800 (PST)=
X-Google-DKIM-Signature: v=
=3D1; a=3Drsa-sha256; c=3Drelaxed/relaxed;
=
 d=3D1e100.net; s=3D20210112;=
 h=3Dcontent-transfer-encoding:mime-version:messag=
e-id:date:subject:cc
 :t=
o:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;=
 bh=3DlhhMHYaC67tFGFGcSbdKjULs2J3+Vd+1RKeEK+kH4Cc=
=3D;
 b=3DitYWBwQzT2IG38=
JZODIH43Lt37xgbpxCciGTUE0pxiBb4R0BVfglKTRZUoSpsecCh5
 BITxTnRvEGVFanI98hkbV9P1gc5ytMQdTUc0w4pZdIJIL=
8ECFJWNoLXl8/k0yKG+tkfg
=
 TyytJZrvg9ppTB/d0m7LyRiN0V9LdJAsvJamLh3xC6MfRNc/seesBywpxwPaaP217dcv<=
/o:p>
 N/Kf93pUOd9X7uaVSnQUOeaVT+tI=
8a7a/TaMWD7GBwu9gkp5CjeiyTq2mjmrp3NZoJMt
FeZY3WgAw/ZkwjgCu8kzC3o8tEUpyrni2GtHiSAiAk9xMFIWfhycXUWA/= 613WiWbOQu9
 lhOw=3D=3D<=
o:p>
X-Gm-Message-State: AFqh=
2kpgCCpDOTXUW01dFIt25uq1J/2MGMGf5BeauNNa7CUW6zwhE6al
 PQsL6Lt+6WCia6nkn+LvZiKXTt//CncOFBk=3D
X-Google-Smtp-Source: AMrXdXu8=
cul6nGNvqFpetdDXyEX3mJ61V9n58IzDc+hHnff1D4ZmgroXFQTgbc8qqkB+rVWcDXxesw=3D=
=3D
X-Received: by 2002:=
ac8:7354:0:b0:3a6:a699:3cd8 with SMTP id
q20-20020ac87354000000b003a6a6993cd8mr12926355qtp.57.1671= 821734468;
=C2=A0Fri, 2=
3 Dec 2022 10:55:34 -0800 (PST)
Received: from localhost (pool-108-26-161-203.bstnma.fios.verizon.n=
et.
 [108.26.161.203]) b=
y smtp.gmail.com with ESMTPSA id
 bm36-20020a05620a19a400b006fa4cac54a5sm2696550qkb.72.2022.12.23.1=
0.55.31
 (version=3DTLS1=
_3 cipher=3DTLS_AES_256_GCM_SHA384 bits=3D256/256);
 Fri, 23 Dec 2022 10:55:32 -0800 (PST)
From: Paul Moore <paul@paul-m=
oore.com>
To: linux-a=
udit@redhat.com,
=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bpf@vger.kernel.org
Subject: [PATCH v2] bpf: restore the eb=
pf program ID for BPF_AUDIT_UNLOAD and
PERF_BPF_EVENT_PROG_UNLOAD
=
Date: Fri, 23 Dec 2022 13:55:31 -0500<=
/strong>
Message-Id: <20221223185531.222689-1-pa=
ul@paul-moore.com>
MI=
ME-Version: 1.0
X-Mimeca=
st-Impersonation-Protect: Policy=3DCLT - Impersonation Protection
 Similar Mo=
nitored External Domain=3Dfalse; Custom External Domain=3Dfalse;=
 Mimecast External Domain=3Dfalse;=
 Newly Observed Domain=3Dfalse;
 Internal User Name=3Dfalse; Custom Display Name List=3Dfalse;=
 Reply-to Address Mismatch=
=3Dfalse; Targeted Threat Dictionary=3Dfalse;
 Mimecast Threat Dictionary=3Dfalse; Custom Threat Di=
ctionary=3Dfalse
X-Sca=
nned-By: MIMEDefang 3.1 on 10.11.54.8
=
X-BeenThere: linux-audit@redhat.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Linux Audit Discussion <linux-audit.redhat=
.com>
List-Unsubscrib=
e: <https://listman.redhat.com/mailman/options/linux-audit>,
 <mailto:linux-audit-request@=
redhat.com?subject=3Dunsubscribe>
<=
strong>List-Archive: <http://listman.redhat.com/archives/linux-aud=
it/>
List-Post: <m=
ailto:linux-audit@redhat.com>
List-Help: <mailto:linux-audit-request@redhat.com?subject=3Dhel=
p>
List-Subscribe: &l=
t;https://listman.redhat.com/mailman/listinfo/linux-audit>,
 <mailto:linux-audit-request@redh=
at.com?subject=3Dsubscribe>
Cc: Burn Alting <burn.alting@iinet.net.au>, Alexei Starovoitov=
 <ast@kernel.org>,
 Stanislav Fomichev <sdf@google.com>
Errors-To: linux-audit-bounces@redhat.com
Sender: "Linux-audit" <l=
inux-audit-bounces@redhat.com>
X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com<=
/span>
Content-Type: text/plain; charset=
=3D"us-ascii"
=
Content-Transfer-Encoding: 7bit
 
When chan=
ging the ebpf program put() routines to support being called
from within IRQ context the program ID=
 was reset to zero prior to
calling the perf event and audit UNLOAD record generators, which
resulted in problems as the eb=
pf program ID was bogus (always zero).
This patch resolves this by adding a new flag, bpf_prog::val= id_id, to
indicate when =
the bpf_prog_aux ID field is valid; it is set to true/1
in bpf_prog_alloc_id() and set to false/0 i=
n bpf_prog_free_id().=C2=A0 In
order to help ensure that access to the bpf_prog_aux ID field takes<=
o:p>
into account the new val=
id_id flag, the bpf_prog_aux ID field is
renamed to bpf_prog_aux::__id and a getter function,<= /o:p>
bpf_prog_get_id(), was create=
d and all users of bpf_prog_aux::id were
converted to the new caller.=C2=A0 Exceptions to this incl= ude some of the
internal=
 ebpf functions and the xdp trace points, although the latter
still take into account the valid_id =
flag.
 <=
/span>
I also modified the bpf_audit_prog(=
) logic used to associate the
=
AUDIT_BPF record with other associated records, e.g. @ctx !=3D NULL.<=
o:p>
Instead of keying off th=
e operation, it now keys off the execution
=
context, e.g. '!in_irg && !irqs_disabled()', whi=
ch is much more
appropri=
ate and should help better connect the UNLOAD operations with
the associated audit state (other aud=
it records).
 =
Fixes: d809e134be7a ("b=
pf: Prepare bpf_prog_put() to be called from irq context.")=
Reported-by: Burn Alting <burn.=
alting@iinet.net.au>
=
Reported-by: Jiri Olsa <olsajiri@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com=
>
 
--
<= pre>* v2
=
=C2=A0 - change subj
=C2=
=A0 - add mention of the perf regression
=C2=A0 - drop the dedicated program audit ID
=C2=A0 - add the bpf_prog::valid_id f=
lag, bpf_prog_get_id() getter
=
=C2=A0 - convert prog ID users to new ID getter
* v1
=C2=A0 - subj was: "bpf: restore the ebpf audit UNLOAD id f=
ield"
=C2=A0 - init=
ial draft
---=
 drivers/net/netdevsim/bpf.c=C2=A0=
 |=C2=A0 6 ++++--
 incl=
ude/linux/bpf.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 11 =
+++++++++--
 include/lin=
ux/bpf_verifier.h |=C2=A0 2 +-
 include/trace/events/xdp.h=C2=A0=C2=A0 |=C2=A0 4 ++--
 kernel/bpf/arraymap.c=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
kernel/bpf/bpf_struct_ops.c=C2=A0 |=C2=A0 2 +-=
 kernel/bpf/cgroup.c=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/core.c=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/cpumap.c=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 kernel/bpf/devmap.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
=
 kernel/bpf/syscall.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 | 27 +++++++++++++++------------
=
 kernel/events/core.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 |=C2=A0 6 +++++-
 kernel/trace/bpf_trace.c=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 net/core/dev.c=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=
=C2=A0 2 +-
 net/core/fi=
lter.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=
=C2=A0 3 ++-
 net/core/r=
tnetlink.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 net/core/sock_map.c=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 net/ipv6/seg6_local.c=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 3 ++-
<= pre> net/sched/act_bpf.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0 2 +-
 net/sched/cls_bpf.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 |=C2=A0 2 +-
 =
20 files changed, 52 insertions(+), 34 deletions(-)
 
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim=
/bpf.c
index 50854265864=
d..2795f03f5f34 100644
-=
-- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
=
@@ -109,7 +109,7 @@ nsim_bpf_offload(struct netdevsim *n=
s, struct bpf_prog *prog, bool oldprog)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0"bad offload state, expected offload %sto be active",
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0oldprog ? "" : "n=
ot ");
 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 ns->bpf_offloaded =3D prog;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ns=
->bpf_offloaded_id =3D prog ? prog->aux->id : 0;=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ns-=
>bpf_offloaded_id =3D prog ? bpf_prog_get_id(prog) : 0;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ns=
im_prog_set_loaded(prog, true);
 
=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
@@ -221,6 +221,7 @@ static int nsim_bpf_create_prog(struct= nsim_dev *nsim_dev,
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct nsim_bpf_bound_prog *state;
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 char name[16];
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int ret;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 id;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 state=
 =3D kzalloc(sizeof(*state), GFP_KERNEL);
<= pre> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!state)
@@ -239,7 +240,8 @@ static int =
nsim_bpf_create_prog(struct nsim_dev *nsim_dev,<=
/pre>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ret;
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
 
<=
strong>-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 debugfs_create_u32("=
;id", 0400, state->ddir, &prog->aux->id);
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i=
d =3D bpf_prog_get_id(prog);
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 debugfs_create_u32("id"=
;, 0400, state->ddir, &id);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 debugfs_create_file("=
state", 0400, state->ddir,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0=C2=A0=C2=A0&state->state, &nsim_bpf_string_fops);=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 debugfs_create_bool("loaded", 0400, state->ddir, &stat=
e->is_loaded);
diff =
--git a/include/linux/bpf.h b/include/linux/bpf.h
index 9e7d46d16032..18e965bd7db9 100644
+++ b/include/linux/bpf.h<=
/o:p>
@@ -1102,7 +1102,7 @@ struct =
bpf_prog_aux {
 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 max_pkt_offset;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 max_tp=
_access;
 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 u32 stack_depth;
<= pre>-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 id;<= /span>
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 u32 __id; /* access via bpf_prog_get_id() to check bpf_prog::valid_id *=
/
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 u32 func_cnt; /* used by non-func prog as the number of fun=
c progs */
 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 u32 func_idx; /* 0 for non-func prog, the index in=
 func array for func prog */
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 attach_btf_id; /* in-kernel =
BTF type id to attach to */
@@ -1197,7 +1197,8 @@ struct bpf_prog {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enforce_expected_attach_type:=
1, /* Enforce expected_attach_type checking at attach time */
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 call_get_st=
ack:1, /* Do we call bpf_get_stack() or bpf_get_stackid() */
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 call_get_fu=
nc_ip:1, /* Do we call get_func_ip() */
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tstamp_type_access:1; /* Accesse= d __sk_buff->tstamp_type */
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tstamp_type_access:1, /* Accessed __sk_bu=
ff->tstamp_type */
+=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 valid_id:1; /* Is bpf_prog::aux::__id valid? */
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 enum bpf_prog_type=C2=A0=C2=A0=C2=A0=C2=A0 type;=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Type of BPF program */
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 enum bpf_attach_type=C2=A0=C2=A0 expected_attach_type; /* For som=
e prog types */
 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 len;=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Number=
 of filter blocks */
@@ =
-1688,6 +1689,12 @@ void bpf_prog_inc(struct bpf_prog *prog);
 struct bpf_prog * __must_check bpf_p=
rog_inc_not_zero(struct bpf_prog *prog);
void bpf_prog_put(struct bpf_prog *prog);
 
=
+static inline u32 bpf_prog_get_id(const struct bpf_prog *pro=
g)
+{<=
/strong>
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (=
WARN(!prog->valid_id, "Attempting to use an invalid eBPF program&qu=
ot;))
+=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
+=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 return prog->aux->__id;
=
+}
 v=
oid bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock);
 void bpf_map_free_id(struct bpf_map=
 *map, bool do_idr_lock);
diff --git a/include=
/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 9e1e6965f407..525c02cc12ea 100644
--- a/include/linux/bpf_verifi=
er.h
+++ b/include/linux=
/bpf_verifier.h
@@ -604,=
7 +604,7 @@ static inline u64 bpf_trampoline_compute_key(const struct bpf_p=
rog *tgt_prog,
 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0struct btf *btf, u32 btf_id)
 {
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ((u64)tgt_prog->aux->id &=
lt;< 32) | btf_id;
+=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 return ((u64)bpf_prog_get_id(tgt_prog) << 32) | btf_id;
 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 retur=
n ((u64)btf_obj_id(btf) << 32) | 0x80000000 | btf_id;
 }
diff --git a/include/trace/events/xdp.h b/include/trace/even= ts/xdp.h
index c40fc97f9=
417..a1c3048872ea 100644
--- a/include/trace/events/xdp.h
+++ b/include/trace/events/xdp.h
=
@@ -39,7 +39,7 @@ TRACE_EVENT(xdp_exception,<=
/span>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 ),
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 TP_fast_assign(
-=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 __entry->prog_id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D xdp->aux-&g=
t;id;
+=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->=
;prog_id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D (xdp->valid_id ? xdp-&g=
t;aux->__id : 0);
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 __entry->act=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 =3D act;
 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __=
entry->ifindex=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D dev->ifindex;<=
o:p>
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 ),
@@ -1=
20,7 +120,7 @@ DECLARE_EVENT_CLASS(xdp_redirect_template,=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 map_index =3D 0;
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 }
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->prog_id=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D xdp->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->prog_id=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 =3D (xdp->valid_id ? xdp->aux->__id : 0);<=
/o:p>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->act=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D XDP_REDIRECT;
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->ifindex=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D dev->ifindex;=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->err=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D err;
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf=
/arraymap.c
index 832b26=
59e96e..d19db5980b1b 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -905,7 +905,7 @@ static void prog_fd_array_put_ptr(void *ptr=
)
 
=C2=A0static u32 prog_fd_array_sys_lookup_el=
em(void *ptr)
 {
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 return ((struct bpf_prog *)ptr)->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return=
 bpf_prog_get_id((struct bpf_prog *)ptr);
<= pre> }
 
=C2=A0/* decrement refcnt=
 of all bpf_progs that are stored in this map */=
diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/=
bpf/bpf_struct_ops.c
ind=
ex 84b2d9dba79a..6c20e6cd9442 100644
<=
strong>--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c<=
/strong>
@@ -488,7 +488,7 @@ static int bpf_struct_=
ops_map_update_elem(struct bpf_map *map, void *key,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 image +=3D err;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 /* put prog_id to udata */
=
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 *(unsigned long *)(udata + moff) =3D prog->aux-=
>id;
+=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *(unsigned =
long *)(udata + moff) =3D bpf_prog_get_id(prog);=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }=
 
=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 refcount_set(=
&kvalue->refcnt, 1);
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index bf2fdb33fb31..4a8d26f1d5d1 100644<=
o:p>
--- a/kernel/bpf/cgroup.=
c
+++ b/kernel/bpf/cgrou=
p.c
@@ -1091,7 +1091,7 @=
@ static int __cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *=
attr,
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i =3D 0;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 hlist_for_each_entry(pl, progs, node) {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog =3D prog_list_prog(pl);
-=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 id =3D prog->aux->id;
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D bpf_prog_get_id(prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (copy_to=
_user(prog_ids + i, &id, sizeof(id)))
<= pre> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 return -EFAULT;
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (++i =3D=3D cnt)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core=
.c
index 25a54e04560e..e=
a3938ab6f5b 100644
--- a=
/kernel/bpf/core.c
+++ b=
/kernel/bpf/core.c
@@ -2=
293,7 +2293,7 @@ static bool bpf_prog_array_copy_core(struct bpf_prog_array=
 *array,
 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 for (item =3D array->items; item->prog; item=
++) {
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (item-&g=
t;prog =3D=3D &dummy_bpf_prog.prog)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 conti= nue;
-=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog_ids[i] =
=3D item->prog->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 prog_ids[i] =3D bpf_prog_get_id(item->prog);<=
/span>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (++i =3D=3D request_cnt) {=
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 item++;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break= ;
diff --git a/kernel/bp=
f/cpumap.c b/kernel/bpf/cpumap.c
index b5ba34ddd4b6..3f3423d03aea 100644=
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -413,7 +413,7 @@ static int __cpu_map_load_=
bpf_program(struct bpf_cpu_map_entry *rcpu,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 return -EINVAL;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }<= /strong>
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rcpu->value.bpf_prog.id=
 =3D prog->aux->id;
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rcpu->prog =3D prog;=
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;=
diff --git a/kernel/bpf/devmap.c b=
/kernel/bpf/devmap.c
ind=
ex f9a87dcc5535..d46309d4aa9e 100644
<=
strong>--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -868,7 +868,7 @@ static struct bpf_dtab_netdev *__dev_m= ap_alloc_node(struct net *net,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->dtab =3D dtab;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 if (prog) {
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 dev->xdp_prog =3D prog;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 dev->val.bpf_prog.id =3D prog->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->val.bpf_prog.id =3D bpf_pro=
g_get_id(prog);
 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 dev->xdp_prog =3D NULL;=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->val.bpf_prog.id =3D 0;
diff --git a/kernel/bpf/syscall.c b/k=
ernel/bpf/syscall.c
inde=
x 7b373a5e861f..9e862ef792cb 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c<= pre>@@ -1958,13 +1958,14 @@ static void bpf_audit_prog(const = struct bpf_prog *prog, unsigned int op) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 return;
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (audit_enabled =3D=3D AUDIT_=
OFF)
 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 if (op =3D=3D BPF_AUDIT_LOAD)
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!in_irq() &&a= mp; !irqs_disabled())
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 ctx =3D audit_context();
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ab =3D audit_log_start(ctx, GFP_=
ATOMIC, AUDIT_BPF);
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(!ab))
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return;
<= pre>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* log the id regar= dless of bpf_prog::valid_id */
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 audit_log_format(ab, "pro=
g-id=3D%u op=3D%s",
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0  prog->aux->id=
, bpf_audit_str[op]);
+=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0  prog->aux->__id,=
 bpf_audit_str[op]);
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 audit_log_end(ab);
 }
 
@@ -1975,8 =
+1976,10 @@ static int bpf_prog_alloc_id(struct bpf_prog *prog)<=
/span>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 idr_preload(GFP_KERNEL);
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_lock_bh(&prog_idr_lock)=
;
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 id =3D idr_alloc_cyclic(&prog_idr, prog, 1, INT_MAX, GF=
P_ATOMIC);
-=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 if (id > 0)
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 prog->aux->id =3D id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (id >=
 0) {
+=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog->au=
x->__id =3D id;
+=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 prog->valid_id =3D true;
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock_bh(&=
amp;prog_idr_lock);
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 idr_preload_end();
 
@@ -1996,7 +1999,7 @@ void bpf_prog_free_id(struct bpf_prog *prog, b=
ool do_idr_lock)
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* disappears - even if someone grab=
s an fd to them they are unusable,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* simply waiting for=
 refcnt to drop to be freed.
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!prog=
->aux->id)
+=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!prog->valid_id)=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return;<=
/pre>
 
@@ -2004,8 +2007,8 @@ void bpf_prog_f=
ree_id(struct bpf_prog *prog, bool do_idr_lock)<=
/pre>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __acquire(&prog_idr_lo=
ck);
 =
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 idr=
_remove(&prog_idr, prog->aux->id);
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prog->aux->=
;id =3D 0;
+=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 idr_remove(&prog_idr, prog->aux->__id);<=
o:p>
+=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 prog->valid_id =3D false;
 
=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (do_idr_lock)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock_irqrestore(&prog=
_idr_lock, flags);
@@ -2=
154,7 +2157,7 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struc=
t file *filp)
 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=
=A0=C2=A0=C2=A0prog->jited,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0prog_tag,
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0prog->pages * 1ULL << PAGE= _SHIFT,
-=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0 prog->aux->id,
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 =C2=A0=C2=A0 bpf_prog_get_id(prog),
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0stats.nsecs,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0stats.cnt,
@@ -2786,7 +2789,7=
 @@ static void bpf_link_show_fdinfo(struct seq_file *m, struct file *filp)=
 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=
=A0bpf_link_type_strs[link->type],
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0link->id,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0prog_tag,
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 prog->aux->id);<=
o:p>
+=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 bpf_=
prog_get_id(prog));
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (link->ops->show_fdinfo)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 link->ops->show_fdin=
fo(link, m);
 }
@@ -3914,7 +3917,7 @@ static int=
 bpf_prog_get_info_by_fd(struct file *file,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 return -EFAULT;
=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.type =3D prog->type;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 info.id =3D prog->aux->id;
=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.id =3D bpf_pr=
og_get_id(prog);
 =C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.load_time =3D prog->aux->load_=
time;
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 info.created_by_uid =3D from_kuid_munged(current_user=
_ns(),
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0prog->aux->user->uid);
@@ -4261,7 +4264,7 @@ static int bpf_link_get_=
info_by_fd(struct file *file,
=
 
=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.type =3D link->type;<=
/strong>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info=
.id =3D link->id;
-=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info.prog_id =3D link->prog->aux=
->id;
+=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 info.prog_id =3D bpf_prog_get_id(link->prog);
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (=
link->ops->fill_link_info) {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 err =3D link->ops->fill_link_info(link, &info);
@@ -4426,7 +4429,7 @@ sta=
tic int bpf_task_fd_query(const union bpf_attr *attr,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 struct bpf_raw_event_map *btp =3D raw_tp->btp;
 
=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 er=
r =3D bpf_task_fd_query_copy(attr, uattr,
<= pre>-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0 raw_tp->link.prog->aux->id,
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0=C2=A0 bpf_prog_get_id(raw_tp->link.prog),=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0BPF_FD_TYPE_RAW_TRACEPOINT,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0btp->tp->name, 0, 0);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 goto put_file;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index aefc1e08e015..c24e897d27f1 10064=
4
--- a/kernel/events/co=
re.c
+++ b/kernel/events=
/core.c
@@ -9001,7 +9001=
,11 @@ void perf_event_bpf_event(struct bpf_prog *prog,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 },
 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .type =3D type,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 .flags =3D flags,
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .id =3D prog-&=
gt;aux->id,
+=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0  * don't use bpf_prog_get_id() as the id may be marked
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0  * invalid on PERF_BPF_EVENT_PROG_UNLOAD events
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0  */
+=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .id =3D prog->aux->_=
_id,
 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 },<=
/span>
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 };
 
diff --git a/kernel/trace/bpf_trace.c b=
/kernel/trace/bpf_trace.c
--- a/kernel/trace/bpf_trace.c=
+++ b/kernel/trace/bpf_trace.c
@@ -2344,7 +2344,7 @@ int bpf_get_perf_even=
t_info(const struct perf_event *event, u32 *prog_id,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (prog=
->type =3D=3D BPF_PROG_TYPE_PERF_EVENT)
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 return -EOPNOTSUPP;
 
-=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *prog_id =3D prog->aux->id;=
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 *prog_id =3D bpf_prog_get_id(prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 flags =3D event=
->tp_event->flags;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 is_tracepoint =3D flags & TRACE_=
EVENT_FL_TRACEPOINT;
 =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 is_syscall_tp =3D is_syscall_trace_eve=
nt(event->tp_event);
=
diff --git a/net/core/dev.c b/net/core/dev.c
index fa53830d0683..0d39ef22cf4b 100644
--- a/net/core/dev.c=
+++ b/net/core/dev.c
@@ -9068,7 +9068,7 @@ u32 dev_xdp_prog_id(st=
ruct net_device *dev, enum bpf_xdp_mode mode)
 {
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct bpf_prog *prog =3D dev_xdp_pr=
og(dev, mode);
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 return prog ? prog->aux->id : 0;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return prog ? b=
pf_prog_get_id(prog) : 0;
 =
=C2=A0static void dev_xdp_set_link(struct=
 net_device *dev, enum bpf_xdp_mode mode,
<= pre>diff --git a/net/core/filter.c b/net/core/filter.c
index bb0136e7a8e4..282ccfe34c=
ed 100644
--- a/net/core=
/filter.c
+++ b/net/core=
/filter.c
@@ -8729,7 +87=
29,8 @@ void bpf_warn_invalid_xdp_action(struct net_device *dev, struct bpf=
_prog *prog,
 
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0act > act_max ? "Ille=
gal" : "Driver unsupported",
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 act, prog->aux->nam=
e, prog->aux->id, dev ? dev->name : "N/A");
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 act,=
 prog->aux->name, bpf_prog_get_id(prog),
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 dev ? dev->name : &=
quot;N/A");
 }
 EXPORT_SYMBOL_GPL(bpf_war=
n_invalid_xdp_action);
 =
diff --git a/net/core/r=
tnetlink.c b/net/core/rtnetlink.c
index 74864dc46a7e..1f7e36909541 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1453,7 +1453,7 @@ static u32 rtnl_xdp_p=
rog_skb(struct net_device *dev)
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 generic_xdp_prog =3D rtnl_der=
eference(dev->xdp_prog);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!generic_xdp_prog)=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 retur=
n generic_xdp_prog->aux->id;
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return bpf_prog_get_id(gen=
eric_xdp_prog);
 }<=
/o:p>
 <=
/pre>
=C2=A0static u32 rtnl_xdp_prog_drv(struct net_devic=
e *dev)
diff --git a/net=
/core/sock_map.c b/net/core/sock_map.c
index a660baedd9e7..550ec6cb3aee 100644
--- a/net/core/sock_map.c<=
/strong>
+++ b/net/core/sock_map.c
@@ -1518,7 +1518,7 @@ int sock_map_bpf_p=
rog_query(const union bpf_attr *attr,
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* we do not hold the r=
efcnt, the bpf prog may be released
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* asynchronously an=
d the id would be set to 0.
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D dat=
a_race(prog->aux->id);
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D data_race(bpf_prog_get_id=
(prog));
 =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 if (id =3D=3D 0)
<= pre> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 prog_cnt =3D 0;
diff =
--git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index 8370726ae7bf..440ce3aba802 100644<=
/o:p>
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local=
.c
@@ -1543,7 +1543,8 @@=
 static int put_nla_bpf(struct sk_buff *skb, struct seg6_local_lwt *slwt)
 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 if (!nest)
=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 return -EMSGSIZE;
 
-=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 if (nla_put_u32(skb, SEG6_LOCAL_BPF_PROG, slwt->bpf.p=
rog->aux->id))
+=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nla_put_u32(skb, SEG6_LOCAL_BPF_PR=
OG,
+=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bpf_prog_get_id(slwt->bpf.prog)))=
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMSGSIZE;<=
/o:p>
 <=
/pre>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (slwt=
->bpf.name &&
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index b79eee44e24e..604a29e482b0 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c=
@@ -121,7 +121,7 @@ sta=
tic int tcf_bpf_dump_ebpf_info(const struct tcf_bpf *prog,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0=C2=A0nla_put_string(skb, TCA_ACT_BPF_NAME, prog->bpf_=
name))
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMS=
GSIZE;
 
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i=
f (nla_put_u32(skb, TCA_ACT_BPF_ID, prog->filter->aux->id))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 if (nla_put_u32(skb, TCA_ACT_BPF_ID, bpf_prog_get_id(prog->fil=
ter)))
 =C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMS=
GSIZE;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 nla =3D nla_reserve(skb, TCA_ACT_BPF_TAG, sizeof(prog->filter->ta=
g));
diff --git a/net/sc=
hed/cls_bpf.c b/net/sched/cls_bpf.c
index bc317b3eac12..eb5ac6be589e 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -565,7 +565,7 @@ static int cls_bpf_dump=
_ebpf_info(const struct cls_bpf_prog *prog,
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=
=A0=C2=A0nla_put_string(skb, TCA_BPF_NAME, prog->bpf_name))
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMSGSIZE;<=
/span>
 
<= pre>-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nla_put_u32(skb= , TCA_BPF_ID, prog->filter->aux->id))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nla_put_u3=
2(skb, TCA_BPF_ID, bpf_prog_get_id(prog->filter)))
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EMSGSIZE;
 
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nla =3D nla_reserve(skb=
, TCA_BPF_TAG, sizeof(prog->filter->tag));=
-- 
<=
span style=3D'font-family:"Courier New";background:yellow;mso-highlight:yel=
low'>2.39.0
 <=
/o:p>
--=
Linux-audit mailing list
Linux-audit@redhat.com=
https://listman.redhat.com/mailman/listinfo/linux-=
audit

 

 

Sent from Mail for Windows

 

--===============7445430453268346090== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit --===============7445430453268346090==--