Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2247094pxp; Mon, 21 Mar 2022 14:54:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySpA/XcA9UOYu0d7AtcGwALnlhlowxfjUDaUF1gQv7Vxmqr+e9fFVPsAsdfl1jICSFa6nm X-Received: by 2002:aa7:888b:0:b0:4f7:68d3:16b9 with SMTP id z11-20020aa7888b000000b004f768d316b9mr25332550pfe.0.1647899685297; Mon, 21 Mar 2022 14:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647899685; cv=none; d=google.com; s=arc-20160816; b=oo2kNUTXB182mpmapuG+k5cX42HTivNdD2T+fNUsS/sQyG7KpgiIElc3iE6+EG8C/9 UXjB59rjO+WxWyZgNz9RoSrGNvQu1SfXcYuu6wrn8B1+tj1urBsGPXY3Di52t2Q2nIrl GJGx1TYQRNo8xfZnQb5AiGYLCgkBH1GrvXJDTMB2R8VPXu64jux1da6D2pKm2rD5ZDG5 zuXPiK2F1asZIQYlct/m3S7jl6jI1uvTe9OZEFq5EJE5eOEPJtAZpsS09vFvuKv4UIMA fybLx3XYyz4DNYyuLzGi5nBhpuC6BZdd0qXC6clZOAfnEMOvK7Efp3tDaXhkQGu2DgMu V/JA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nR4Ny7x3jGhcjyoDaD02VrTd5fMj8IfXS3nXBHe79tU=; b=BbyzTV8iA4bLUEYSR4SjlQ+qlyLY4VzrgNTN4ApnmfvJvIcVSLTLCGmOidxvD6qhXh mtD9xIFoYJmbrdEN9Mh9L/nIGla0u8+ydXTMbAFvcby5IHlbP7CIbaGooY3PpHnMGxgR tjTcHbtMQLpepnWxqWghsrqASmnItONxvZtxztwPpc0IsTNhSzKxswqhgTXjq3KUr2vH 6Kvb3YRxbM669lbqV+cWbpdpyZy1U5TFBq3UKYEQn7UrCJ2t3GLMPCXncgkw/MjAO1N1 6uR57rk+VgZWNDcHVd3/DMDuUGvDdKxKLDlDJMWKdtiOgyq0p+eNmRFVmejR46bbbavt +4xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YEKPWPwE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s200-20020a632cd1000000b003816043efa6si14662618pgs.411.2022.03.21.14.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 14:54:45 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YEKPWPwE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4364E2C808A; Mon, 21 Mar 2022 14:21:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348520AbiCUOFf (ORCPT + 99 others); Mon, 21 Mar 2022 10:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349161AbiCUN73 (ORCPT ); Mon, 21 Mar 2022 09:59:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DA0B17E34; Mon, 21 Mar 2022 06:58:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 833786125C; Mon, 21 Mar 2022 13:58:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 937CBC340E8; Mon, 21 Mar 2022 13:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871083; bh=JsBG2MyiRhsA2oGen2dAlVo6MAvoBKtGqss16qFVF4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YEKPWPwESqiCRGNiviQgHrfGtxs2lVfmjvMI0XJBf5M+5rxEfo1i9OkzhCyJ2wDiC Q51UFqcNez7U+9uW4uE6d3e29BHdSokqyNvHFVS3Q/YOd088rmOPiACEQgMPg0f37i dURGRkS/8r5HKx72DnpJdr63OtAFj+0yvtyhOyhU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geliang Tang , Tommi Rantala , Kumar Kartikeya Dwivedi , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.4 17/17] Revert "selftests/bpf: Add test for bpf_timer overwriting crash" Date: Mon, 21 Mar 2022 14:52:53 +0100 Message-Id: <20220321133217.653517515@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133217.148831184@linuxfoundation.org> References: <20220321133217.148831184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 From: Greg Kroah-Hartman This reverts commit dcf55b071de9231e197ba7b1a2d0a423e8d7d33a which is commit a7e75016a0753c24d6c995bc02501ae35368e333 upstream. It is reported to break the bpf self-tests. Reported-by: Geliang Tang Reported-by: Tommi Rantala Cc: Kumar Kartikeya Dwivedi Cc: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20220209070324.1093182-3-memxor@gmail.com Cc: Sasha Levin Link: https://lore.kernel.org/r/a0a7298ca5c64b3d0ecfcc8821c2de79186fa9f7.camel@nokia.com Link: https://lore.kernel.org/r/HE1PR0402MB3497CB13A12C4D15D20A1FCCF8139@HE1PR0402MB3497.eurprd04.prod.outlook.com Signed-off-by: Greg Kroah-Hartman --- tools/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 --- 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); -} --- 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";