 block: fix blktrace debugfs entries leakage · gregkh/linux@dd7de37 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 676 Star 636 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit dd7de37 Browse files Browse files YuKuai-huawei authored and axboe committed block: fix blktrace debugfs entries leakage Commit 99d055b ("block: remove per-disk debugfs files in blk_unregister_queue") moves blk_trace_shutdown() from blk_release_queue() to blk_unregister_queue(), this is safe if blktrace is created through sysfs, however, there is a regression in corner case. blktrace can still be enabled after del_gendisk() through ioctl if the disk is opened before del_gendisk(), and if blktrace is not shutdown through ioctl before closing the disk, debugfs entries will be leaked. Fix this problem by shutdown blktrace in disk_release(), this is safe because blk_trace_remove() is reentrant. Fixes: 99d055b ("block: remove per-disk debugfs files in blk_unregister_queue") Signed-off-by: Yu Kuai &lt;yukuai3@huawei.com&gt; Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt; Link: https://lore.kernel.org/r/20230610022003.2557284-4-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt; 1 parent db59133 commit dd7de37 Copy full SHA for dd7de37 1 file changed + 4 - 1 Lines changed: 4 additions &amp; 1 deletion File tree Expand file tree Collapse file tree Open diff view settings Filter options block genhd.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ block/genhd.c ‎ Copy file name to clipboard Expand all lines: block/genhd.c + 4 - 1 Lines changed: 4 additions &amp; 1 deletion Original file line number Diff line number Diff line change @@ -25,8 +25,9 @@ 25 25 #include &lt;linux/pm_runtime.h&gt; 26 26 #include &lt;linux/badblocks.h&gt; 27 27 #include &lt;linux/part_stat.h&gt; 28 - #include "blk-throttle.h" 28 + #include &lt;linux/blktrace_api.h&gt; 29 29 30 + #include &quot;blk-throttle.h&quot; 30 31 #include &quot;blk.h&quot; 31 32 #include &quot;blk-mq-sched.h&quot; 32 33 #include &quot;blk-rq-qos.h&quot; @@ -1147,6 +1148,8 @@ static void disk_release(struct device *dev) 1147 1148 might_sleep (); 1148 1149 WARN_ON_ONCE ( disk_live ( disk )); 1149 1150 1151 + blk_trace_remove ( disk -&gt; queue ); 1152 + 1150 1153 /* 1151 1154 * To undo the all initialization from blk_mq_init_allocated_queue in 1152 1155 * case of a probe failure where add_disk is never called we have to 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 