Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp414378rwd; Mon, 12 Jun 2023 16:01:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qltmH6FHDYskl4LbgTINha3wKwE9MnhSaLF+RHrxZagh3VhhUuLe7KuEm6tpvsX6RraLZ X-Received: by 2002:aa7:ca46:0:b0:513:fa61:397a with SMTP id j6-20020aa7ca46000000b00513fa61397amr8241781edt.12.1686610860088; Mon, 12 Jun 2023 16:01:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686610860; cv=pass; d=google.com; s=arc-20160816; b=m4/lucfR3+JCGX2L8RHa9qR7FP4ucAfmBdvJiNFt4nQKxBSevNbQtJHlrCt4tChgbm Wh8QLrQH3MC/dZ9QnRkjq/sRHILGzGqUgkDHoQ0DayT0ccFnWeunpJFVBQNIL32VqTPS +Tr3uZvPxQOiZa+5XXkguS0ZMYV0RqYSNLYPWlNKySv2AmDE9UBHdTHeoppd67EEc9Ip +MKcuORqnpi1ziQzjqClkG7W8TIvskCQgAcRYrK6ngkI0hDU4BwzPtFLE8CuReAuLMLs Zu2PYeHDKIDxl0z9aE/DbrIBLb6dUF7T2ecYwleUmGqkfef2mYzwBe4lh/ONQAbwKfCy YYZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Uw+jdfJkDSDc1rZ9hM9IyUE6VppD4X6NU4hjQZ4wAUI=; b=OpZnmUNUaRSGrYHH/OaMoQEVnjYv7EXv8g1kqsin5fpzUQ8tHYXLvU2q9zTYULXDLi x4Ayaz6Z1O1jOKLPWFtv43VN9L7HQAq2e74B+277w2fYVMg6jbHA41cWsOaw5Arxnt34 Q5W9VSF46/jZiklxtKw72o5WphtLyM4Yqkap2GhCU3996sm2bSZs3UlZZhMD2WA7SRhY mnK2MeC2xRN0EucesIOFmkiSRMiNOAYefc3hFECA2phlqDtZa/y1TJTmAeDkWx7eY23Q DyPUXgkWaRRKfA22vq2HYN1AgVIzl1MwLky22E4bA4zke61N2PE0CM1vgqtV47dv90UT lIgw== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b=T0L7vk4O; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020aa7c30e000000b00514565ee239si6754626edq.516.2023.06.12.16.00.35; Mon, 12 Jun 2023 16:00:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b=T0L7vk4O; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238793AbjFLWMc (ORCPT + 99 others); Mon, 12 Jun 2023 18:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237269AbjFLWMa (ORCPT ); Mon, 12 Jun 2023 18:12:30 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9944510C2 for ; Mon, 12 Jun 2023 15:12:29 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id BD1076C1DF8 for ; Mon, 12 Jun 2023 22:12:28 +0000 (UTC) Received: from pdx1-sub0-mail-a251.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 333AD6C1B6E for ; Mon, 12 Jun 2023 22:12:28 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1686607948; a=rsa-sha256; cv=none; b=bTV1UFnAdmXNS8XQiXs+xJsn/W4SiWf+wxEVF9BJ7mQk6hH7LQSGjqiX0acDnr2eSZWj1C cyDwwR79b3M+KTe8SaidVQUFfdZQdixqBo/mWphd5xXlAygVNX6fRAq5TZQ91lfA8r4Vuu 9O4pVkCjmuODrLYy1f7qP09iVNJCt5zLBIZf6Zf0ErSXpzupaTAnf0iXo0nexJLPoUW8xO mkJR1vLHdKRe/eyzflTtxNtpnq4Fdmyo3yBuXyta96UYIJa8SMR6NK0RJ8GWUDkGozYxv/ 1bMv9HbWnoXmxXr0otZlQUSdpPno4c//Gv9ooAL78Ay2pYcOyW5IVMe615mCbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1686607948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Uw+jdfJkDSDc1rZ9hM9IyUE6VppD4X6NU4hjQZ4wAUI=; b=fT/HJCUllDuVFP9bbaW/bInQtHrHy0Db9kw9FZjmraZLLlQL0IIXEEvjJAqTeUFq8J36aX 8RUroHSuIOOGDVLcssFcfvhQ1xhv2Gf1m1dav7fBGfxjFK7eWd1aIAbCYK7oXKAzJN1vfX NTh3Nf1vzqb6urBD8NajZZqiv4IAd9mzxcPeIvBmssNo/DfOmVIzYIihcnLZEwiH11woqt hAAPMKXnCEm3pdh4Q0ea6wGv/I1zOB51humLjTybNs7ibEAOB9rU9xI/kbrL5TTgwSNtcF TIXQktTtP4GtpOS+s5Y8NXFwiMs9VET0LTGoHxbkL33TAzxeE4ZHwPjyxv0pYQ== ARC-Authentication-Results: i=1; rspamd-6c69b8658d-49kw4; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@templeofstupid.com X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|kjlx@templeofstupid.com X-MailChannels-Auth-Id: dreamhost X-Grain-Shoe: 0bf68c0d26b4758d_1686607948460_1280644191 X-MC-Loop-Signature: 1686607948460:2263035550 X-MC-Ingress-Time: 1686607948460 Received: from pdx1-sub0-mail-a251.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.120.163.21 (trex/6.8.1); Mon, 12 Jun 2023 22:12:28 +0000 Received: from kmjvbox (c-73-93-64-36.hsd1.ca.comcast.net [73.93.64.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kjlx@templeofstupid.com) by pdx1-sub0-mail-a251.dreamhost.com (Postfix) with ESMTPSA id 4Qg5XC6R1Fz1W for ; Mon, 12 Jun 2023 15:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=templeofstupid.com; s=dreamhost; t=1686607947; bh=Uw+jdfJkDSDc1rZ9hM9IyUE6VppD4X6NU4hjQZ4wAUI=; h=Date:From:To:Cc:Subject:Content-Type:Content-Transfer-Encoding; b=T0L7vk4O69gYcbijBG0CV2wgiyLUD+Egvqf9UPhHzPGDJ0GcwpLzSXWh0Vvgmil2+ jJwnAwHCyHep6WqnreF599PvBJAva7xQzkK4zDxQopoKRFfGMCyhKbe6l/L7P/KytS L+veVyzegHpzsbt76DOXBV4n5Rzm8dj+lqDNNKqM= Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e0085 by kmjvbox (DragonFly Mail Agent v0.12); Mon, 12 Jun 2023 15:12:26 -0700 Date: Mon, 12 Jun 2023 15:12:26 -0700 From: Krister Johansen To: Alexei Starovoitov Cc: Ilya Leoshkevich , Krister Johansen , bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , LKML , "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [PATCH bpf v3 2/2] selftests/bpf: add a test for subprogram extables Message-ID: <20230612221226.GA2077@templeofstupid.com> References: <9e3041e182a75f558f1132f915ddf2ee7e859c6e.1686268304.git.kjlx@templeofstupid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 12, 2023 at 03:07:22PM -0700, Alexei Starovoitov wrote: > On Mon, Jun 12, 2023 at 6:46 AM Ilya Leoshkevich wrote: > > > > On Fri, 2023-06-09 at 11:15 -0700, Alexei Starovoitov wrote: > > > On Thu, Jun 8, 2023 at 5:11 PM Krister Johansen > > > wrote: > > > > > > > > In certain situations a program with subprograms may have a NULL > > > > extable entry. This should not happen, and when it does, it turns > > > > a > > > > single trap into multiple. Add a test case for further debugging > > > > and to > > > > prevent regressions. N.b: without any other patches this can panic > > > > or > > > > oops a kernel. > > > > > > > > Signed-off-by: Krister Johansen > > > > --- > > > > .../bpf/prog_tests/subprogs_extable.c | 31 +++++++++++++ > > > > .../bpf/progs/test_subprogs_extable.c | 46 > > > > +++++++++++++++++++ > > > > 2 files changed, 77 insertions(+) > > > > create mode 100644 > > > > tools/testing/selftests/bpf/prog_tests/subprogs_extable.c > > > > create mode 100644 > > > > tools/testing/selftests/bpf/progs/test_subprogs_extable.c > > > > > > > > diff --git > > > > a/tools/testing/selftests/bpf/prog_tests/subprogs_extable.c > > > > b/tools/testing/selftests/bpf/prog_tests/subprogs_extable.c > > > > new file mode 100644 > > > > index 000000000000..2201988274a4 > > > > --- /dev/null > > > > +++ b/tools/testing/selftests/bpf/prog_tests/subprogs_extable.c > > > > @@ -0,0 +1,31 @@ > > > > +// SPDX-License-Identifier: GPL-2.0 > > > > + > > > > +#include > > > > +#include "test_subprogs_extable.skel.h" > > > > + > > > > +void test_subprogs_extable(void) > > > > +{ > > > > + const int READ_SZ = 456; > > > > + struct test_subprogs_extable *skel; > > > > + int err; > > > > + > > > > + skel = test_subprogs_extable__open(); > > > > + if (!ASSERT_OK_PTR(skel, "skel_open")) > > > > + return; > > > > + > > > > + err = test_subprogs_extable__load(skel); > > > > + if (!ASSERT_OK(err, "skel_load")) > > > > + goto cleanup; > > > > + > > > > + err = test_subprogs_extable__attach(skel); > > > > + if (!ASSERT_OK(err, "skel_attach")) > > > > + goto cleanup; > > > > + > > > > + /* trigger tracepoint */ > > > > + ASSERT_OK(trigger_module_test_read(READ_SZ), > > > > "trigger_read"); > > > > + > > > > + test_subprogs_extable__detach(skel); > > > > + > > > > +cleanup: > > > > + test_subprogs_extable__destroy(skel); > > > > +} > > > > diff --git > > > > a/tools/testing/selftests/bpf/progs/test_subprogs_extable.c > > > > b/tools/testing/selftests/bpf/progs/test_subprogs_extable.c > > > > new file mode 100644 > > > > index 000000000000..c3ff66bf4cbe > > > > --- /dev/null > > > > +++ b/tools/testing/selftests/bpf/progs/test_subprogs_extable.c > > > > @@ -0,0 +1,46 @@ > > > > +// SPDX-License-Identifier: GPL-2.0 > > > > + > > > > +#include "vmlinux.h" > > > > +#include > > > > +#include > > > > + > > > > +struct { > > > > + __uint(type, BPF_MAP_TYPE_ARRAY); > > > > + __uint(max_entries, 8); > > > > + __type(key, __u32); > > > > + __type(value, __u64); > > > > +} test_array SEC(".maps"); > > > > + > > > > +static __u64 test_cb(struct bpf_map *map, __u32 *key, __u64 *val, > > > > void *data) > > > > +{ > > > > + return 1; > > > > +} > > > > + > > > > +SEC("fexit/bpf_testmod_return_ptr") > > > > +int BPF_PROG(handle_fexit_ret_subprogs, int arg, struct file *ret) > > > > +{ > > > > + *(volatile long *)ret; > > > > + *(volatile int *)&ret->f_mode; > > > > + bpf_for_each_map_elem(&test_array, test_cb, NULL, 0); > > > > + return 0; > > > > +} > > > > + > > > > +SEC("fexit/bpf_testmod_return_ptr") > > > > +int BPF_PROG(handle_fexit_ret_subprogs2, int arg, struct file > > > > *ret) > > > > +{ > > > > + *(volatile long *)ret; > > > > + *(volatile int *)&ret->f_mode; > > > > + bpf_for_each_map_elem(&test_array, test_cb, NULL, 0); > > > > + return 0; > > > > +} > > > > + > > > > +SEC("fexit/bpf_testmod_return_ptr") > > > > +int BPF_PROG(handle_fexit_ret_subprogs3, int arg, struct file > > > > *ret) > > > > +{ > > > > + *(volatile long *)ret; > > > > + *(volatile int *)&ret->f_mode; > > > > + bpf_for_each_map_elem(&test_array, test_cb, NULL, 0); > > > > + return 0; > > > > +} > > > > > > What is the point of attaching 3 the same progs to the same hook? > > > One would be enough to test it, no? > > > > > > In other news... > > > Looks like this test is triggering a bug on s390. > > > > > > Ilya, > > > please take a look: > > > https://github.com/kernel-patches/bpf/actions/runs/5216942096/jobs/9416404780 > > > > > > bpf_prog_78c0d4c618ed2df7_handle_fexit_ret_subprogs3 > > > is crashing the kernel. > > > A bug in extable logic on s390? > > > > I think we also need this: > > > > --- a/kernel/bpf/verifier.c > > +++ b/kernel/bpf/verifier.c > > @@ -17664,6 +17664,7 @@ static int jit_subprogs(struct bpf_verifier_env > > *env) > > prog->bpf_func = func[0]->bpf_func; > > prog->jited_len = func[0]->jited_len; > > prog->aux->extable = func[0]->aux->extable; > > + prog->aux->num_exentries = func[0]->aux->num_exentries; > > prog->aux->func = func; > > prog->aux->func_cnt = env->subprog_cnt; > > bpf_prog_jit_attempt_done(prog); > > > > The reason is that s390 JIT doubles the number of extable entries due > > to how the hardware works (some exceptions point to the failing insn, > > some point to the next one). > > > > With that: > > > > Acked-by: Ilya Leoshkevich > > Tested-by: Ilya Leoshkevich > > > > for the v4 series. > > Great. > > Krister, > could you please resubmit v5 adding the above change and Ilya's tags to patch 1? > > I'd like to see green BPF CI on all platforms before landing. Thanks Alexei and Ilya, and yes, absolutely. I'm hoping to have a v5 out a little later this afternoon. -K