Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3504158imw; Thu, 7 Jul 2022 02:59:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tsLIjDm9UQMroiNQ3gaI6m74kZJiHNxoO4Z/wap21quo+/4M3s98gHWVC4BhNr530GFXUA X-Received: by 2002:a17:902:f688:b0:16a:81d4:17e0 with SMTP id l8-20020a170902f68800b0016a81d417e0mr53116125plg.174.1657187952868; Thu, 07 Jul 2022 02:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657187952; cv=none; d=google.com; s=arc-20160816; b=YHdfUyIPb2rTyUx3EPLBIH3X7NAdlDDeWTothCV9dzev2hfO7eNHDfpICvBN71yMOs sh4O6tMNI9q8z6THYrn6xheiBILxr4LBlSbpvkwEP4pssgmpa7CuRdjDP8bsy/Z5hqx0 PAj67Tc+lyYl38SapkyPL3bCtlnt7jnLphuFRCK6ohcwy9DtWBlGl86+782VrxuTfjLS AiTAcbJnRYJQfW1LgIsst6gJJSFlLAOHjEnYZofNCXqmH790igG7N7rDp25zNGvEFPv3 IP0sWTno5FHzB+D8q8BGDrEBusFn4PsOQ7SeyeUCwNy2JLlKtAFZdrR5MudY8xB8o5dk V6oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pZynCaPh+TnSiopib07+yX9vDI3B5AI5xmb++t4Qb9A=; b=Xfjgr6UnjeOsr1GSHYTkRnJrHjnJq7LbFu5GyVhLJ460bLaSjTu/Sdsm6J8Ei8zJ1l 4yf6VNhzkt6jrwcUJ1O9U0y+bgAw6MlRdZoHxhQPRHfF8YSqPOEA8gJl7a85jY4pGXUL lDJ5eDXYQLs5SsaHj/GFd3pmjpcdu45rGuU3m0k6yMPXRoy0sdFxBPe12RC05+YjIk35 BP7jYl4vYiV1pS/qfPO4at2gyCbQXdqS6C4A9K41Rt7mY8pav8eNmI9tspLDNuXYQShE ZfhPTvUGVbXwqT7czB7+CMiyB/Rd+syFEyiCSTFj6jA5aqb4Vc3sr/WMAXFnOFm9d6yk FUwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=KN8kdXW6; 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=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a17090aab0b00b001ef9079bcb4si10935863pjq.22.2022.07.07.02.59.01; Thu, 07 Jul 2022 02:59:12 -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=@canonical.com header.s=20210705 header.b=KN8kdXW6; 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=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235124AbiGGJmq (ORCPT + 99 others); Thu, 7 Jul 2022 05:42:46 -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-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: 8bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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_timer' 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/testing/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 = timer_crash__open_and_load(); - if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load")) - return; - skel->bss->pid = getpid(); - skel->bss->crash_map = 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/testing/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 = 0; -int crash_map = 0; /* 0 for amap, 1 for hmap */ - -SEC("fentry/do_nanosleep") -int sys_enter(void *ctx) -{ - struct map_elem *e, value = {}; - void *map = crash_map ? (void *)&hmap : (void *)&amap; - - if (bpf_get_current_task_btf()->tgid != pid) - return 0; - - *(void **)&value = (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 == 1) { - e = bpf_map_lookup_elem(map, &(int){0}); - if (!e) - return 0; - bpf_timer_cancel(&e->timer); - } - return 0; -} - -char _license[] SEC("license") = "GPL"; -- 2.7.4