Message ID | 20231017125717.241101-1-houtao@huaweicloud.com (mailing list archive) |
---|---|
Headers | show
Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABBB44120B for <bpf@vger.kernel.org>; Tue, 17 Oct 2023 12:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D9F1B9 for <bpf@vger.kernel.org>; Tue, 17 Oct 2023 05:56:13 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4S8v9f05Qgz4f3m6S for <bpf@vger.kernel.org>; Tue, 17 Oct 2023 20:56:06 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgB3BdVihC5lIwrSDA--.31244S4; Tue, 17 Oct 2023 20:56:04 +0800 (CST) From: Hou Tao <houtao@huaweicloud.com> To: bpf@vger.kernel.org Cc: Martin KaFai Lau <martin.lau@linux.dev>, Alexei Starovoitov <alexei.starovoitov@gmail.com>, Andrii Nakryiko <andrii@kernel.org>, Song Liu <song@kernel.org>, Hao Luo <haoluo@google.com>, Yonghong Song <yonghong.song@linux.dev>, Daniel Borkmann <daniel@iogearbox.net>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Jiri Olsa <jolsa@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Hsin-Wei Hung <hsinweih@uci.edu>, houtao1@huawei.com Subject: [PATCH bpf 0/2] bpf: Fix bpf timer kmemleak Date: Tue, 17 Oct 2023 20:57:15 +0800 Message-Id: <20231017125717.241101-1-houtao@huaweicloud.com> X-Mailer: git-send-email 2.29.2 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: <bpf.vger.kernel.org> List-Subscribe: <mailto:bpf+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:bpf+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgB3BdVihC5lIwrSDA--.31244S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Wr4UKrykWryDCrW8AFW3Awb_yoW8Jr1Dpa yrtw13Kry8AFsxJr4ftF9rWrWrta1kKrs8CF1xJ34UA3y7Jr92vF1xKrWa9a9xJrWIvF1f Zr1xtrs5C34kZFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I 0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IY c2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s 026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF 0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0x vE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UWE__UUUUU= X-CM-SenderInfo: xkrx3t3r6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: bpf@iogearbox.net |
Series |
bpf: Fix bpf timer kmemleak
|
expand
|
From: Hou Tao <houtao1@huawei.com> Hi, The patchset aims to fix the kmemleak problem reported by Hsin-Wei Hung [0]. Patch #1 fixes the kmemleak problem by re-checking map->usercnt after timer->timer is assigned. Patch #2 adds a selftest for the kmemleak problem. But it is a bit hard to reproduce the kmemleak by only running the test and I managed to reproduce the problem by both running the test and injecting delay before timer->timer is assigned in bpf_timer_init(). Please see individual patches for more details. And comments are always welcome. [0]: https://lore.kernel.org/bpf/CABcoxUaT2k9hWsS1tNgXyoU3E-=PuOgMn737qK984fbFmfYixQ@mail.gmail.com Hou Tao (2): bpf: Check map->usercnt again after timer->timer is assigned selftests/bpf: Test race between map uref release and bpf timer init kernel/bpf/helpers.c | 14 +- .../bpf/prog_tests/timer_init_race.c | 138 ++++++++++++++++++ .../selftests/bpf/progs/timer_init_race.c | 56 +++++++ 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/timer_init_race.c create mode 100644 tools/testing/selftests/bpf/progs/timer_init_race.c