From nobody Sun Apr 19 02:15:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6182CC43334 for ; Thu, 7 Jul 2022 09:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235090AbiGGJmr (ORCPT ); Thu, 7 Jul 2022 05:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235013AbiGGJmn (ORCPT ); Thu, 7 Jul 2022 05:42:43 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F01E145077 for ; Thu, 7 Jul 2022 02:42:41 -0700 (PDT) Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (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) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4AEA03F201 for ; Thu, 7 Jul 2022 09:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657186959; bh=pZynCaPh+TnSiopib07+yX9vDI3B5AI5xmb++t4Qb9A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KN8kdXW6d09yM2V8ktdCMTrL3fIuOqYkxDV/+qOTtCC/qHoE5drmQMPD4A/oBzyDY OX1aXQQBC/XdM87Ty81i314dcp55F8WD5QNpXP/7Udo8DjnwQhEuP7nGF6BfI0a2/L WRtQssgHI4wj0/Ze7beelWqwh7KgPsyfGI0SkdkEHdwuRALJ9Sdc2cjKMeSZp1QV4+ ZL8mWA1od2T189JnPri82xf0OsMJBNVQPPd2lSxVuegpSqqxmW6GXhwUPjqrWhqDl4 uELMMmh4MWL1KIR1EkH77JMBf66O2wnelpAaj6AfrsXe68iZMc/rT1juWCgW46toqK A2zG66oedmInA== Received: by mail-pf1-f197.google.com with SMTP id c67-20020a621c46000000b005251cf9feb0so6690097pfc.20 for ; Thu, 07 Jul 2022 02:42:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pZynCaPh+TnSiopib07+yX9vDI3B5AI5xmb++t4Qb9A=; b=A5pyuyXkwneYcILhuN0coQ6xlVSMh5eqxdlSfXDWT/APzSNRJfH1DFzp4W2r675BCr umry/7/awpHNQxW+k2hLiuF5rABs5Ps0PMlBwOPlOVKCZq4lJeJbPQg9jmZlhJaUkOpp CGZd2SGjHFjp++2Tvbx17m7LVgsAhr/ZvXhi5oG4op2MlLx8d4TIn4RrQArlM3Sg0/zK b2vf2HZ56xNOM8+QCbv+x8r2IthNuZGpaMTe/LPOq2REYvpM75tNGLS9eTOYZLi7zLhN nE4ANwRQZjivKlmQT015ZAyH7T9ggpsupPRCZp+XeBDMklAFbX0SkLaJ1X4mpsYUQfrI DuLA== X-Gm-Message-State: AJIora+Nw9U+jW3WvPeBd0pEVxTtEGm0E2AIn7RwAeRlEjoBL36k5GE4 4nGQWgps7145tELjN/qXkP7Oc2d+NjHuJ9rnVxZIUKFn9tDDTxErQilTENVwOjkw+YjnzS2KpE1 Hm/aG+jE/vo6RglhD8mQKl0x5cVu60c+U/t8qmXry X-Received: by 2002:a17:90b:2249:b0:1ef:2097:8448 with SMTP id hk9-20020a17090b224900b001ef20978448mr4162958pjb.97.1657186956238; Thu, 07 Jul 2022 02:42:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vx385uLz6R6MIjDaU9j35k7VtJZpvs3rQMyTvkYkckrOkY/88nPGQnMd6CZpWdAovnFVFn6g== X-Received: by 2002:a17:90b:2249:b0:1ef:2097:8448 with SMTP id hk9-20020a17090b224900b001ef20978448mr4162941pjb.97.1657186956013; Thu, 07 Jul 2022 02:42:36 -0700 (PDT) Received: from localhost.localdomain (223-137-51-72.emome-ip.hinet.net. [223.137.51.72]) by smtp.gmail.com with ESMTPSA id w15-20020a1709027b8f00b0016230703ca3sm27085064pll.231.2022.07.07.02.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 02:42:35 -0700 (PDT) From: Po-Hsu Lin To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: memxor@gmail.com, linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, shuah@kernel.org, bpf@vger.kernel.org, po-hsu.lin@canonical.com Subject: [PATCH stable 5.15 1/1] Revert "selftests/bpf: Add test for bpf_timer overwriting crash" Date: Thu, 7 Jul 2022 17:42:07 +0800 Message-Id: <20220707094207.229875-2-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707094207.229875-1-po-hsu.lin@canonical.com> References: <20220707094207.229875-1-po-hsu.lin@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This reverts commit b0028e1cc1faf2e5d88ad4065590aca90d650182 which is commit a7e75016a0753c24d6c995bc02501ae35368e333 upstream. It will break the bpf self-tests build with: progs/timer_crash.c:8:19: error: field has incomplete type 'struct bpf_time= r' struct bpf_timer timer; ^ /home/ubuntu/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helper= _defs.h:39:8: note: forward declaration of 'struct bpf_timer' struct bpf_timer; ^ 1 error generated. This test can only be built with 5.17 and newer kernels. Signed-off-by: Po-Hsu Lin --- .../testing/selftests/bpf/prog_tests/timer_crash.c | 32 ------------- tools/testing/selftests/bpf/progs/timer_crash.c | 54 ------------------= ---- 2 files changed, 86 deletions(-) delete mode 100644 tools/testing/selftests/bpf/prog_tests/timer_crash.c delete mode 100644 tools/testing/selftests/bpf/progs/timer_crash.c diff --git a/tools/testing/selftests/bpf/prog_tests/timer_crash.c b/tools/t= esting/selftests/bpf/prog_tests/timer_crash.c deleted file mode 100644 index f74b823..00000000 --- a/tools/testing/selftests/bpf/prog_tests/timer_crash.c +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include "timer_crash.skel.h" - -enum { - MODE_ARRAY, - MODE_HASH, -}; - -static void test_timer_crash_mode(int mode) -{ - struct timer_crash *skel; - - skel =3D timer_crash__open_and_load(); - if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load")) - return; - skel->bss->pid =3D getpid(); - skel->bss->crash_map =3D mode; - if (!ASSERT_OK(timer_crash__attach(skel), "timer_crash__attach")) - goto end; - usleep(1); -end: - timer_crash__destroy(skel); -} - -void test_timer_crash(void) -{ - if (test__start_subtest("array")) - test_timer_crash_mode(MODE_ARRAY); - if (test__start_subtest("hash")) - test_timer_crash_mode(MODE_HASH); -} diff --git a/tools/testing/selftests/bpf/progs/timer_crash.c b/tools/testin= g/selftests/bpf/progs/timer_crash.c deleted file mode 100644 index f8f7944..00000000 --- a/tools/testing/selftests/bpf/progs/timer_crash.c +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include -#include -#include - -struct map_elem { - struct bpf_timer timer; - struct bpf_spin_lock lock; -}; - -struct { - __uint(type, BPF_MAP_TYPE_ARRAY); - __uint(max_entries, 1); - __type(key, int); - __type(value, struct map_elem); -} amap SEC(".maps"); - -struct { - __uint(type, BPF_MAP_TYPE_HASH); - __uint(max_entries, 1); - __type(key, int); - __type(value, struct map_elem); -} hmap SEC(".maps"); - -int pid =3D 0; -int crash_map =3D 0; /* 0 for amap, 1 for hmap */ - -SEC("fentry/do_nanosleep") -int sys_enter(void *ctx) -{ - struct map_elem *e, value =3D {}; - void *map =3D crash_map ? (void *)&hmap : (void *)&amap; - - if (bpf_get_current_task_btf()->tgid !=3D pid) - return 0; - - *(void **)&value =3D (void *)0xdeadcaf3; - - bpf_map_update_elem(map, &(int){0}, &value, 0); - /* For array map, doing bpf_map_update_elem will do a - * check_and_free_timer_in_array, which will trigger the crash if timer - * pointer was overwritten, for hmap we need to use bpf_timer_cancel. - */ - if (crash_map =3D=3D 1) { - e =3D bpf_map_lookup_elem(map, &(int){0}); - if (!e) - return 0; - bpf_timer_cancel(&e->timer); - } - return 0; -} - -char _license[] SEC("license") =3D "GPL"; --=20 2.7.4