Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2449520rwd; Fri, 9 Jun 2023 11:19:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4rpDqt3OXOoF+bogd7OdVjH6DLoCko/O+v+b5/lO9MSANhwn21k5JAA+RbY1HLsPGFV0JV X-Received: by 2002:a17:902:7603:b0:1ad:bb89:16f6 with SMTP id k3-20020a170902760300b001adbb8916f6mr1455033pll.50.1686334787954; Fri, 09 Jun 2023 11:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686334787; cv=none; d=google.com; s=arc-20160816; b=qOWWHunu26wSlvCtsxX5T9nZdJH+h2M3piqaunpkqRpqPAAlOng4BrS4fDYtCIedKS ByuiTikRf8nOLuc86P309LZT315tu3AmR9dBXkqgfE0ox7PUPrx1anA8I+6H7ZOpae4I /ozSPaCpe1bcnYtgHX1THKZ3Nw6DzcYI5m4dw8XoxVv9T25WVfez+gwT1qjPHRZv4HFq lhcHvEbAlUI9xHMK0Rpdi9VNLxP7+PiLtGBsJDmp+Oe0QsChMWlUJ0tS/bNaobLx9z1d j8lmA+Amaq8Nllpz75zNFlQjWaryYHymCxoIzZ6jGXHjeD6edRR/Rxt1Tj0pEeayJ914 MlpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Cjni4d3UMj1znH7uhH7utbW9YPqd4ueWaeLPtTPh3wY=; b=g9SBUFrGvgyYqcJL6u+h4llT/tILd1dIOW0DaAhHzmSYJ9IsdJyn/MTHfm9Jand/77 QXC0QeXyRLk/hXZ3njg/baPh6LXj4wa9MisAv9wmETj1b/sxiJ8GhLbKCbaNad/GQWJ1 QPxFH4N/6FPq85JhZ8OFQhFDqAOGL636P61ccn4W6uSyaeOP83nt5ZA7xlVaJR8LM+R8 eO+2qGeQMaLQXgjwJsQG7QKIV8JvC1CAGhTQkH7KmB4Xa9jp0xFNRoS7Al89hnsqPpuU 979VP/y4HUE+XSHbM0OHVmiQDTL+69O56hyIczzMs8YTeLZk84gypq+yX9e9JE+Pzp+B nJJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=OB8fokvl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a170902e5c100b001b047410425si3041507plf.503.2023.06.09.11.19.26; Fri, 09 Jun 2023 11:19:47 -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=pass header.i=@gmail.com header.s=20221208 header.b=OB8fokvl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbjFISQH (ORCPT + 99 others); Fri, 9 Jun 2023 14:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjFISQG (ORCPT ); Fri, 9 Jun 2023 14:16:06 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61DA535A9; Fri, 9 Jun 2023 11:15:32 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2b1adf27823so23697641fa.2; Fri, 09 Jun 2023 11:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686334530; x=1688926530; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Cjni4d3UMj1znH7uhH7utbW9YPqd4ueWaeLPtTPh3wY=; b=OB8fokvltk+wBSHhCvaF2w42HaAb0n47rWuoa9s8ArbiQZeVG++WwLE+0o4GUK5270 6SvbsFcdkPHkBnuQJ0vDHcAeI8/NXfD7zcERvnM3HlCWyV84R4geQ5zTnaM9GwnIvvb9 d/E719YsGqlgTEpaf0lgjRoyYNcpxEh/OHSI2GRWEXBWyzJNun0HL4kl0WARAPpMr+MT jb6i4IlJnOJyVWF8kJso8KS9eJSLOYrC0kGRA05ZZJGEddCn//h+uL1Yc4RshfQWBIlc R6uksC73UK2ge3Cga6yR1qMSIK3kWZ17ibd+6UIgjSGBzPeKVScAEfznl87zx66GDQDf ejtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686334530; x=1688926530; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cjni4d3UMj1znH7uhH7utbW9YPqd4ueWaeLPtTPh3wY=; b=OVFBjMP7af00prR1NlFly/vHDBgRikW4UgEl0cWJS2x3d/DvUJWVXGJk+2yCZ37rmp AWYyDeHQDZIcMGNADhwahqIH+DKL1XrtUD//VX+OLIOPoor4ZWIeyNZtC5jNRsBC6gHu A2ZPt8I80b0Tt1BD87ou9xFdmqYLGduRenzhAjODUsnfKsBPVbgwu8PC0kX68ptRvM1D YKnkfVmF4UtWmQ5Gs6qMGFtcM8pLdLC/zoUo3CwlyaLVyRX5pYHFdI6gJDblDcgcH+6w kezWBcjxVFGt/MSScah7wlXUpU5v3bcqgZi2EB2CNmcRBR7fmCxd12j4io8thVejQXhd XgWw== X-Gm-Message-State: AC+VfDy6U4HEn9Hx3fp61sBFe+m5EYkMOY6reXNkUDbjLClP0JXLPm1I rYqepgZ0FwJYI4grfNcBQEui417csVcpmvrb+M8= X-Received: by 2002:a2e:924d:0:b0:2b1:a89a:5f2b with SMTP id v13-20020a2e924d000000b002b1a89a5f2bmr1648988ljg.2.1686334530025; Fri, 09 Jun 2023 11:15:30 -0700 (PDT) MIME-Version: 1.0 References: <9e3041e182a75f558f1132f915ddf2ee7e859c6e.1686268304.git.kjlx@templeofstupid.com> In-Reply-To: <9e3041e182a75f558f1132f915ddf2ee7e859c6e.1686268304.git.kjlx@templeofstupid.com> From: Alexei Starovoitov Date: Fri, 9 Jun 2023 11:15:18 -0700 Message-ID: Subject: Re: [PATCH bpf v3 2/2] selftests/bpf: add a test for subprogram extables To: Krister Johansen , Ilya Leoshkevich Cc: 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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thu, Jun 8, 2023 at 5:11=E2=80=AFPM 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_extab= le.c > create mode 100644 tools/testing/selftests/bpf/progs/test_subprogs_extab= le.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 =3D 456; > + struct test_subprogs_extable *skel; > + int err; > + > + skel =3D test_subprogs_extable__open(); > + if (!ASSERT_OK_PTR(skel, "skel_open")) > + return; > + > + err =3D test_subprogs_extable__load(skel); > + if (!ASSERT_OK(err, "skel_load")) > + goto cleanup; > + > + err =3D 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/94164047= 80 bpf_prog_78c0d4c618ed2df7_handle_fexit_ret_subprogs3 is crashing the kernel. A bug in extable logic on s390?