Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6446200rwl; Tue, 4 Apr 2023 12:54:55 -0700 (PDT) X-Google-Smtp-Source: AKy350a7LALNEDcrqTv5UjrIzezDYlAdwD6KM4chexR0hNl93S6/Ms2F4ybKdy5ERZ1zIXz7KnVV X-Received: by 2002:aa7:c699:0:b0:4bf:33e8:21ff with SMTP id n25-20020aa7c699000000b004bf33e821ffmr509772edq.30.1680638094973; Tue, 04 Apr 2023 12:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680638094; cv=none; d=google.com; s=arc-20160816; b=MpTZJQdO76TOiPZx4gGb/JE0qB6q9K79EWd7QP2CXrZ1AAe2zv49R+oGcJHofnMatl 8hDu/H2+es3coYq1VrOsy1t6LryF/Mi6pYkU3MnY4htqrvvqs+O1W40t/dvKE657cO6H cuF5ej8PuIx02ijdW9BMN8GyBAyeHuTvAZfQDQ+4dsENueJyvoeGs1kVTwO5yY1f8m71 C3cl3GMKDMe67BCSO7lnvE2SMkIMsG0asesIlN8BcSdP64n6ndtxqevvQt48WdWj+grW LO2VMwvmazTcE/pBBsV+4c0JTUiN+uvOIS1gYZLc4MNE5REj9RrsVBagV1ld1wCplGWY fFzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:dkim-signature; bh=lD67j6SxTjZbTv5P71UENRMA1FJt5EF83rP2C9EpLL8=; b=vnoXdTtjySkU8Vr/nCadoDcpz29U8IA3vFWOA8+Df9SCFv0IJ/RGBbP6x55OffXYXO d/RYNzUjDZCa6OF66r81qKXLpnc0iaGULxTb8g1vnA15ct5v3tWxHjFeAcUzjSAjMUZ3 AdTb0+w3fpV2q8MBzxF34UGEXgVPErGeuak71q+8rHry2o1QN/z88bckQYAf72Y5iG+7 dFWS0j+kPlSE8IOnYfWaid2uKf0sYl0SNtm5Oaep53GmCULLiGCGgcN2UbzNwxijfnMg +HyKoHKqktlKl0e7babovRJD+ok5T200rxfctqIc5z9ccndFGOoXI2f4KeKcRuSTRrKy gRSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=vbr463yL; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=QndEKGPN; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a50ec96000000b004fe968996c7si631021edr.216.2023.04.04.12.54.30; Tue, 04 Apr 2023 12:54:54 -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=fail header.i=@alu.unizg.hr header.s=mail header.b=vbr463yL; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=QndEKGPN; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236167AbjDDTwW (ORCPT + 99 others); Tue, 4 Apr 2023 15:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbjDDTwU (ORCPT ); Tue, 4 Apr 2023 15:52:20 -0400 Received: from domac.alu.hr (domac.alu.unizg.hr [161.53.235.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0CF11705; Tue, 4 Apr 2023 12:52:17 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id DA44A604F7; Tue, 4 Apr 2023 21:52:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1680637935; bh=517XR0X/jWCzTJ7yxauRblo40oIwOYagNQNSBg+Elk8=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=vbr463yLg6E/91ja4r5cUTG4PFXK6EE2y/wP/YOQolcwyCqDrW+cwvb4T3lJG0fIT 1NsS4sN2IWO11KVqNzyx8zrTjJ1MOtmdvhsbDzAOd7qGi7+mxnaMKIgWzk5lqpbFA9 43k/ZrYET1d17fDawSzGxKdqdy/33DTAAHtOkVT3Dydzg6tRVMcFCHXuXwyapg99N9 YylAZe+ysoN0dVM51AeznBFhLmxPUh5Xk6dJAgaTi110PTzMoq/CYn4zWdCUKnPbdc ybdGOkgJnorco6VLHlusvU+TqVZ5eq0wuCgasDavAzazFJi2Ekg/pfkPfwUVBUyXiv cKc+hUKeuhPgg== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tpLIWn--HPqm; Tue, 4 Apr 2023 21:52:12 +0200 (CEST) Received: from [192.168.1.4] (unknown [94.250.188.177]) by domac.alu.hr (Postfix) with ESMTPSA id B2C90604F5; Tue, 4 Apr 2023 21:52:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1680637932; bh=517XR0X/jWCzTJ7yxauRblo40oIwOYagNQNSBg+Elk8=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=QndEKGPN3KzRPtffYaMI11AaybT1KKz461JBirev43xcrCnGGOfbEk34KUSxiIkzM WiGlvBuUCSKCc2BLwPtgRXixp2TBiaqZeRnhkzjfZn2EzhJ+ddC4E3qnL8j2Rg9XgG 4yohloX2Z7bOK/asPheDOnmtH6hQf33SX8mWdVGtlN9FinfW1Bxx7u/KFSVvlnMycy gYFhns5UokvpbuCh5Ju4Ph9/M1k8OmEUktS4O8nk080bnCaVJqr+fW1a43n2slsp9D ZI4pCBtkGrsk11E+498fgyP+HIzOhH/k3BHTpSg2aLcj22jQxNCSKuAsXdPxcuFFFy g7GnZeFVGeJpA== Message-ID: <76134d9f-a5ba-6a0d-37b3-28310b4a1e91@alu.unizg.hr> Date: Tue, 4 Apr 2023 21:52:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 From: Mirsad Goran Todorovac Subject: Re: [BUG RESEND] [BISECTED]: selftest: ftracetest: memleak in vfs_write() To: LKML Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Thorsten Leemhuis , Ulf Hansson , Steven Rostedt , Masami Hiramatsu , Shuah Khan , linux-kselftest@vger.kernel.org References: Content-Language: en-US, hr In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS 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 Hi, No progress on this bug report, so it is still unpatched in 6.3-rc5 so I am submitting again. Please see the relevant data at the bottom: On 27. 01. 2023. 19:36, Mirsad Goran Todorovac wrote: > Hi all, > > I came across a memory leak with the vanilla mainline Torvalds tree kernel > with MGLRU and CONFIG_KMEMLEAK enabled: > > unreferenced object 0xffff8d7c92ad5180 (size 192): > comm "ftracetest", pid 2738512, jiffies 4335176273 (age 4842.976s) > hex dump (first 32 bytes): > c0 59 ad 92 7c 8d ff ff 60 dd d7 31 7c 8d ff ff .Y..|...`..1|... > 60 55 df 97 ff ff ff ff 09 00 02 00 00 00 00 00 `U.............. > backtrace: > [] __kmem_cache_alloc_node+0x1e0/0x340 > [] kmalloc_trace+0x2a/0xa0 > [] tracing_log_err+0x16c/0x1b0 > [] append_filter_err+0x113/0x1d0 > [] create_event_filter+0xba/0xe0 > [] set_trigger_filter+0x98/0x160 > [] event_trigger_parse+0x104/0x180 > [] trigger_process_regex+0xc3/0x110 > [] event_trigger_write+0x77/0xe0 > [] vfs_write+0xd1/0x420 > [] ksys_write+0x7b/0x100 > [] __x64_sys_write+0x19/0x20 > [] do_syscall_64+0x58/0x80 > [] entry_SYSCALL_64_after_hwframe+0x72/0xdc > unreferenced object 0xffff8d7b076be000 (size 32): > comm "ftracetest", pid 2738512, jiffies 4335176273 (age 4842.976s) > hex dump (first 32 bytes): > 0a 20 20 43 6f 6d 6d 61 6e 64 3a 20 61 0a 00 00 . Command: a... > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [] __kmem_cache_alloc_node+0x1e0/0x340 > [] __kmalloc+0x4d/0xd0 > [] tracing_log_err+0x184/0x1b0 > [] append_filter_err+0x113/0x1d0 > [] create_event_filter+0xba/0xe0 > [] set_trigger_filter+0x98/0x160 > [] event_trigger_parse+0x104/0x180 > [] trigger_process_regex+0xc3/0x110 > [] event_trigger_write+0x77/0xe0 > [] vfs_write+0xd1/0x420 > [] ksys_write+0x7b/0x100 > [] __x64_sys_write+0x19/0x20 > [] do_syscall_64+0x58/0x80 > [] entry_SYSCALL_64_after_hwframe+0x72/0xdc > unreferenced object 0xffff8d7c92ad59c0 (size 192): > comm "ftracetest", pid 2738512, jiffies 4335176280 (age 4843.088s) > hex dump (first 32 bytes): > c0 5c ad 92 7c 8d ff ff 80 51 ad 92 7c 8d ff ff .\..|....Q..|... > 60 55 df 97 ff ff ff ff 01 00 0b 00 00 00 00 00 `U.............. > backtrace: > [] __kmem_cache_alloc_node+0x1e0/0x340 > [] kmalloc_trace+0x2a/0xa0 > [] tracing_log_err+0x16c/0x1b0 > [] append_filter_err+0x113/0x1d0 > [] create_event_filter+0xba/0xe0 > [] set_trigger_filter+0x98/0x160 > [] event_trigger_parse+0x104/0x180 > [] trigger_process_regex+0xc3/0x110 > [] event_trigger_write+0x77/0xe0 > [] vfs_write+0xd1/0x420 > [] ksys_write+0x7b/0x100 > [] __x64_sys_write+0x19/0x20 > [] do_syscall_64+0x58/0x80 > [] entry_SYSCALL_64_after_hwframe+0x72/0xdc > > The bug was noticed on Lenovo desktop 10TX000VCR (LENOVO_MT_10TX_BU_Lenovo_FM_V530S-07ICB) > running AlmaLinux 8.7 (Stone Smilodon), a CentOS clone, with the compiler: > > mtodorov@domac:~/linux/kernel/linux_torvalds$ gcc --version > gcc (Debian 8.3.0-6) 8.3.0 > Copyright (C) 2018 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > mtodorov@domac:~/linux/kernel/linux_torvalds$ > > Bisecting gave the following culprit commit: > > git bisect good a92ce570c81dc0feaeb12a429b4bc65686d17967 > # good: [c6f613e5f35b0e2154d5ca12f0e8e0be0c19be9a] ipmi/watchdog: use strscpy() to instead of strncpy() > git bisect good c6f613e5f35b0e2154d5ca12f0e8e0be0c19be9a > # good: [90b12f423d3c8a89424c7bdde18e1923dfd0941e] Merge tag 'for-linus-6.2-1' of https://github.com/cminyard/linux-ipmi > git bisect good 90b12f423d3c8a89424c7bdde18e1923dfd0941e > # first bad commit: [71946a25f357a51dcce849367501d7fb04c0465b] Merge tag 'mmc-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc > > The commit was merged on December 13th 2022. > > It is a huge commit. > > The selftests/ftrace/ftracetest triggers this leak, sometimes several times in a run. > ftracetest requires root permission to run, but I haven't yet realised whether a non-superuser > could devise an automated script to abuse this leak exhausting all kernel's memory. > > Non-root user gets a EPERM error when trying to access /proc/sys/kernel internals: > > [marvin@pc-mtodorov linux_torvalds]$ tools/testing/selftests/ftrace/ftracetest > Error: this must be run by root user > tools/testing/selftests/ftrace/ftracetest: line 46: /proc/sys/kernel/sched_rt_runtime_us: Permission denied > [marvin@pc-mtodorov linux_torvalds]$ > > Hope this helps. > > According to the Code of Conduct, I have Cc:-ed maintainers from get_maintainers.pl and > I will add Thorsten because this is sort of a regression :-) The debug output is like follows: unreferenced object 0xffff93a3dc2d1e18 (size 192): comm "ftracetest", pid 12451, jiffies 4295087353 (age 463.476s) hex dump (first 32 bytes): 20 08 2d dc a3 93 ff ff c0 bd 5d cd a3 93 ff ff .-.......]..... c0 bf 85 b6 ff ff ff ff 09 00 02 00 00 00 00 00 ................ backtrace: [] slab_post_alloc_hook+0x8c/0x3e0 [] __kmem_cache_alloc_node+0x1d9/0x2a0 [] kmalloc_trace+0x2e/0xc0 [] tracing_log_err+0x18b/0x1d0 [] append_filter_err.isra.13+0x119/0x190 [] create_filter+0xbf/0xe0 [] create_event_filter+0x10/0x20 [] set_trigger_filter+0xa0/0x180 [] event_trigger_parse+0xf5/0x160 [] trigger_process_regex+0xc9/0x120 [] event_trigger_write+0x86/0xf0 [] vfs_write+0xf2/0x520 [] ksys_write+0x68/0xe0 [] __x64_sys_write+0x1e/0x30 [] do_syscall_64+0x5c/0x90 [] entry_SYSCALL_64_after_hwframe+0x72/0xdc unreferenced object 0xffff93a3873dda20 (size 32): comm "ftracetest", pid 12451, jiffies 4295087353 (age 463.476s) hex dump (first 32 bytes): 0a 20 20 43 6f 6d 6d 61 6e 64 3a 20 61 0a 00 00 . Command: a... 00 00 cc cc cc cc cc cc cc cc cc cc cc cc cc cc ................ backtrace: [] slab_post_alloc_hook+0x8c/0x3e0 [] __kmem_cache_alloc_node+0x1d9/0x2a0 [] __kmalloc+0x55/0x160 [] tracing_log_err+0x1a3/0x1d0 [] append_filter_err.isra.13+0x119/0x190 [] create_filter+0xbf/0xe0 [] create_event_filter+0x10/0x20 [] set_trigger_filter+0xa0/0x180 [] event_trigger_parse+0xf5/0x160 [] trigger_process_regex+0xc9/0x120 [] event_trigger_write+0x86/0xf0 [] vfs_write+0xf2/0x520 [] ksys_write+0x68/0xe0 [] __x64_sys_write+0x1e/0x30 [] do_syscall_64+0x5c/0x90 [] entry_SYSCALL_64_after_hwframe+0x72/0xdc Please find the complete debug info at the URL: https://domac.alu.unizg.hr/~mtodorov/linux/bugreports/ftracetest/ Bisect log is [edited]: > git bisect good a92ce570c81dc0feaeb12a429b4bc65686d17967 > # good: [c6f613e5f35b0e2154d5ca12f0e8e0be0c19be9a] ipmi/watchdog: use strscpy() to instead of strncpy() > git bisect good c6f613e5f35b0e2154d5ca12f0e8e0be0c19be9a > # good: [90b12f423d3c8a89424c7bdde18e1923dfd0941e] Merge tag 'for-linus-6.2-1' of https://github.com/cminyard/linux-ipmi > git bisect good 90b12f423d3c8a89424c7bdde18e1923dfd0941e > # first bad commit: [71946a25f357a51dcce849367501d7fb04c0465b] Merge tag 'mmc-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc > > The commit was merged on December 13th 2022. The amount of applied diffs in the culprit commit 71946a25f357a51dcce849367501d7fb04c0465b prevents me from bisecting further - I do not know which changes depend of which, and which can be tested independently. Hopefully I might come up with a reproducer, but I need some feedback first. Maybe there are ways to narrow down the lines of code that could have caused the leaks, yet I am completely new to the kernel/trace subtree. Apologies for not Cc:ing Ulf nine weeks ago, but it was an omission, not deliberate act. Best regards, Mirsad -- Mirsad Goran Todorovac Sistem inženjer Grafički fakultet | Akademija likovnih umjetnosti Sveučilište u Zagrebu System engineer Faculty of Graphic Arts | Academy of Fine Arts University of Zagreb, Republic of Croatia The European Union "I see something approaching fast ... Will it be friends with me?"