From patchwork Fri Nov 15 14:54:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 13876341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21E78D68BC5 for ; Fri, 15 Nov 2024 14:55:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78B896B0089; Fri, 15 Nov 2024 09:55:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7621A6B008A; Fri, 15 Nov 2024 09:55:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6028A6B008C; Fri, 15 Nov 2024 09:55:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 452B96B0089 for ; Fri, 15 Nov 2024 09:55:22 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F05F01617F5 for ; Fri, 15 Nov 2024 14:55:21 +0000 (UTC) X-FDA: 82788626340.22.5451FBA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 4F32D140012 for ; Fri, 15 Nov 2024 14:54:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wwr70W8E; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of acarmina@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=acarmina@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731682340; a=rsa-sha256; cv=none; b=WBR5w7lj2tpkggivOJoPZlOFqPe5WM0eZxRBNaRvTpcITHPWKcCoQndUxTCRbLi9rrn9tg kxctZ0PmGa9qLmxlOggqP0RwCn0H1jztLvhsfT8NUx8jAHfdyGTxhDRPSMXiH6mKDuTTA+ KTNiESy3wEgOaCYk56T0fwEe+UxrhQs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wwr70W8E; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of acarmina@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=acarmina@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731682340; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=PqNdtpLz0Z/Hn+npcA0fhAnYIz8cgAQdOnYnK9kLQZw=; b=HcHl2vUR8XGhzhHjB+RYLhagnhZO5MR4KTWbjMbUwqkEyKz4m7qlv6WvJ7VDbZ+YPf0fDx Y7/VJ2+X4or1FfrM+uS6wz8EyvTpYblKXQrd3/6o6cQ01c1346ZrmW/MMTg3r2m0PuJs+e gA5Yyr1m1qL0KpYNNLsiA4Cb6EpNG3Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731682519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PqNdtpLz0Z/Hn+npcA0fhAnYIz8cgAQdOnYnK9kLQZw=; b=Wwr70W8E0z48HTpGWnKoQYKI6AxFWZYkCheK00lfq5odh8bJ2n+8ERiHv7YfrwO5a5RTGA 9BJBOA/LFVwVJSnkbv+i4SzH3tEHuRNr7HSmfu68OrRMSDvcZbTCrJ3PuOoXTJY1nMJhA7 ecZGlKUOO7X1s47NDZ3Ge5y1T4CZozw= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-0eCzVLWRNUKApqfezVCyFQ-1; Fri, 15 Nov 2024 09:55:14 -0500 X-MC-Unique: 0eCzVLWRNUKApqfezVCyFQ-1 X-Mimecast-MFC-AGG-ID: 0eCzVLWRNUKApqfezVCyFQ Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a9a194d672bso170661566b.2 for ; Fri, 15 Nov 2024 06:55:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731682510; x=1732287310; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PqNdtpLz0Z/Hn+npcA0fhAnYIz8cgAQdOnYnK9kLQZw=; b=G4w+0cUjYfRTHz9wlSprAimY+n8nzNBxghNSpK4ZFouDIMyknelI4A4jDEoQ+4FTOq aRJQCWAKJY37DKK1PpLg4nB1W50qkvd11RfiVedOCG96O/HpZqM38eUsu1o3dWnhOUrR CaqtUtem4ZZxH+QBfyxA4kO3+jccyg48tBWU7Ql8N+qPcL5xshfCjk2jrfY9xaw5W/80 fYFWLf9fBAOAsLRsfdhHs2VSlyayqjTNQcuWRDCj+LmaDfRmFnrvqtGx7wPNyarHTthX kADNCFDAyiWtx9Rc50c3RleL7qL/B5OTG63jxDPhshuMkmslPmnA3QQ18TUGY8mynrQc 02Mw== X-Forwarded-Encrypted: i=1; AJvYcCW+pb0EowFHCwgyIj0AOejhv87AfWLlR220UiQcxfUKXYlb+gUkVA+izTnFb1EkkmbYFO4lbhaBAw==@kvack.org X-Gm-Message-State: AOJu0YyBLtH+ChVtCz+vaM71LfelcRIzQxzTdXxVxYzVbLb3TQex9TM6 uvO10O5GjL8Qj+WRIl+M0y+JYC1y7AHr5OwwTdzm8P0OeXcQCc/WjgZJ3WRWRsn0tWRO70qVqlt FjUsSDB/CuweaZ1N69VwHajtu9vZdMLAraNrs9ZhiDcVeyGmVL4B3fHZL/HU= X-Received: by 2002:a17:907:e8c:b0:a8d:439d:5c3c with SMTP id a640c23a62f3a-aa4833f629bmr222198766b.8.1731682509789; Fri, 15 Nov 2024 06:55:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+z/uNjTnq0MDmP9QjuWGPH8Gp/jb4j2oIjCkfNT/KDz74keEWKIP7MnZO4bB6+NTYxvrzXw== X-Received: by 2002:a17:907:e8c:b0:a8d:439d:5c3c with SMTP id a640c23a62f3a-aa4833f629bmr222196566b.8.1731682509341; Fri, 15 Nov 2024 06:55:09 -0800 (PST) Received: from lab.hqhome163.com ([194.183.10.152]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa20dffd6a6sm185567366b.99.2024.11.15.06.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 06:55:08 -0800 (PST) From: Alessandro Carminati To: Catalin Marinas , Andrew Morton , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev Cc: Alessandro Carminati , Juri Lelli , Gabriele Paoloni , Alessandro Carminati Subject: [RFC] mm/kmemleak: Fix sleeping function called from invalid context at print message Date: Fri, 15 Nov 2024 14:54:10 +0000 Message-Id: <20241115145410.114376-1-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: O-E3unN4kKYZql_K7BQfY1O8r4Kz-uSB60014HbO8YM_1731682512 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Stat-Signature: cotxxd3nwnkeo8316qigjk34mx4yfrba X-Rspamd-Queue-Id: 4F32D140012 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1731682485-946677 X-HE-Meta: U2FsdGVkX18eG5D19v2GUjptuKaPURBoAGIpVsMMxyQpBU30ftq/x1RCziF83bz7vfFbUWarC87802C08Bz6QCSZJbg2ANBRWylDJVWgJ+2f9xg7oiWH6CvQtY63Z2M00s9//Vh7LLwFDjUWzMMVFPy6yLTfdFrNzboPZrfGUBwUnHdAK+eBzw7jAz0PX5Jozx2tVzCu9DehvSJ5MHnUnAf0z4quZ9LbOjIe7zfK5P5zwANikHJJWeF3FeqCovj4urRVDjFckOjtv7UdhN6NwBGBJRYlNGs766q5MkTGnjeT/K70BfVC5K6EvlwWhK7tG21cSEzO5WAtL6AhAxafkSXxGVwu9REaCXiCq8Q6GG9aIlaYMgUhqbc5yQfTUfsx4T8zvOymge/GAZVsGkokukF48sJOUN7DldfOgzDEgEkN+B2B35K8US5tAzRwiVh08mUa1mV6rmM49wRTZMOATjE2h4Jaao92rxiD1X9NDJT2DQI1AWX6WECtZ3mELkQEO9PX1vI5XAuzdvHSs6Uyp7zFjKOUe3FLzUIGV5l/kk1qXiQezzetH/ey+MlZpQI5/zA2F7THzfT1sQygAmNazpWkZ1JpACIh6dfZwyo89Ug2QzapFye+9VGA4NVJz0ZTK/k8VR71dtqMj7P1cPJ1cHcEkz+pvL3hecFS4V2/u3Yjag57QtT6DBbKiwLHnCsLU7/LnfdMEgi+nvDjA5OgC9px4j3daSNE1K5VGkdvSIr8vBDLl34Zw4oN2nUwh/22RBbmwr+CPjoxdt95YVKnlDHoXANMTXeV28VX9ok5HbpGsHFx5R+vovEqzfUd2j01qPvzWL4bZ2lfsoK5nQTuRbq1Qstz6kad0xVwtev+S8mhU3LmQc6afnYQnKVxRTW6QgA+ZpJdLgOOS3YICJ382KM4Ujn6mkLvYulptddPvRYTPdmQ5+Nl507wsZ4b1JMv/FTvMNVxUlGBa6NvzVO V1P6LMrP pp/jQ2horPsN+5ITBxiNlqr3b2tAgzFTsrjVdeSFK1w6Tz/0JbyaKrHAXf3yzTQGZQsgjhORxEnLVXLhY8BuGho4qSgSDmoHMQAZfHUAmagjTKnVByo+wy5dvDgP0eNluuOa7JLiqbTUY5QU9SlTCaXr5MBdnkNnXHMXknLCUmDcY6sqpNZPN5wV0QBB8pgxYQUNOwBLKv646tBfh5UmXhEC7eDNW0i+gzbd0KqxtG8ZosJd26xd3rw/t94TnvYtrbbQCd0rIBvni6oVh5YQ13UFzcbls0vmFd/nr9nHejtLgk+yLzZ5eoLxlr3Ve2uHxnqT0c1Nz0/uOXXD8G6/SZh2fNhytxrP41gaR0Gq7O5x6+NZb8GcbmAFU7A9oaWskV3eH4tT6yP4cxJ3IRw3pigq6ufV7QXZNaVCtHtCbHDnsSco= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Address a bug in the kernel that triggers a "sleeping function called from invalid context" warning when /sys/kernel/debug/kmemleak is printed under specific conditions: - CONFIG_PREEMPT_RT=y - Set SELinux as the LSM for the system - Set kptr_restrict to 1 - kmemleak buffer contains at least one item Ensure the kmemleak buffer contains at least one item Commit 8c96f1bc6fc49c724c4cdd22d3e99260263b7384 ("mm/kmemleak: turn kmemleak_lock and object->lock to raw_spinlock_t") introduced a change where kmemleak_seq_show is executed in atomic context within the RT kernel. However, the SELinux capability check in this function flow still relies on regular spinlocks, leading to potential race conditions that trigger an error when printing the kmemleak backtrace. Move the backtrace printing out of the critical section. Use a stack variable to store the backtrace pointers, avoiding spinlocks in the atomic context. Implement delta encoding to minimize the stack memory footprint, addressing the potentially large memory demands for storing these pointers on 64-bit systems. Signed-off-by: Alessandro Carminati --- ``` [ 159.247069] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 [ 159.247193] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 136, name: cat [ 159.247241] preempt_count: 1, expected: 0 [ 159.247277] RCU nest depth: 2, expected: 2 [ 159.247388] 6 locks held by cat/136: [ 159.247438] #0: ffff32e64bcbf950 (&p->lock){+.+.}-{3:3}, at: seq_read_iter+0xb8/0xe30 [ 159.248835] #1: ffffafe6aaa9dea0 (scan_mutex){+.+.}-{3:3}, at: kmemleak_seq_start+0x34/0x128 [ 159.249053] #3: ffff32e6546b1cd0 (&object->lock){....}-{2:2}, at: kmemleak_seq_show+0x3c/0x1e0 [ 159.249127] #4: ffffafe6aa8d8560 (rcu_read_lock){....}-{1:2}, at: has_ns_capability_noaudit+0x8/0x1b0 [ 159.249205] #5: ffffafe6aabbc0f8 (notif_lock){+.+.}-{2:2}, at: avc_compute_av+0xc4/0x3d0 [ 159.249364] irq event stamp: 136660 [ 159.249407] hardirqs last enabled at (136659): [] _raw_spin_unlock_irqrestore+0xa8/0xd8 [ 159.249465] hardirqs last disabled at (136660): [] _raw_spin_lock_irqsave+0x8c/0xb0 [ 159.249518] softirqs last enabled at (0): [] copy_process+0x11d8/0x3df8 [ 159.249571] softirqs last disabled at (0): [<0000000000000000>] 0x0 [ 159.249970] Preemption disabled at: [ 159.249988] [] kmemleak_seq_show+0x3c/0x1e0 [ 159.250609] CPU: 1 UID: 0 PID: 136 Comm: cat Tainted: G E 6.11.0-rt7+ #34 [ 159.250797] Tainted: [E]=UNSIGNED_MODULE [ 159.250822] Hardware name: linux,dummy-virt (DT) [ 159.251050] Call trace: [ 159.251079] dump_backtrace+0xa0/0x128 [ 159.251132] show_stack+0x1c/0x30 [ 159.251156] dump_stack_lvl+0xe8/0x198 [ 159.251180] dump_stack+0x18/0x20 [ 159.251227] rt_spin_lock+0x8c/0x1a8 [ 159.251273] avc_perm_nonode+0xa0/0x150 [ 159.251316] cred_has_capability.isra.0+0x118/0x218 [ 159.251340] selinux_capable+0x50/0x80 [ 159.251363] security_capable+0x7c/0xd0 [ 159.251388] has_ns_capability_noaudit+0x94/0x1b0 [ 159.251412] has_capability_noaudit+0x20/0x30 [ 159.251437] restricted_pointer+0x21c/0x4b0 [ 159.251461] pointer+0x298/0x760 [ 159.251482] vsnprintf+0x330/0xf70 [ 159.251504] seq_printf+0x178/0x218 [ 159.251526] print_unreferenced+0x1a4/0x2d0 [ 159.251551] kmemleak_seq_show+0xd0/0x1e0 [ 159.251576] seq_read_iter+0x354/0xe30 [ 159.251599] seq_read+0x250/0x378 [ 159.251622] full_proxy_read+0xd8/0x148 [ 159.251649] vfs_read+0x190/0x918 [ 159.251672] ksys_read+0xf0/0x1e0 [ 159.251693] __arm64_sys_read+0x70/0xa8 [ 159.251716] invoke_syscall.constprop.0+0xd4/0x1d8 [ 159.251767] el0_svc+0x50/0x158 [ 159.251813] el0t_64_sync+0x17c/0x180 ``` I have considered three potential approaches to address this matter: 1. Remove Raw Pointer Printing The simplest solution is to eliminate raw pointer printing from the report. This approach involves minimal changes to the kernel code and is straightforward to implement. While I am confident that omitting the raw address would result in negligible information loss in most scenarios, some may perceive it as a feature regression. Below is an example of the modification: ``` - warn_or_seq_printf(seq, " [<%pK>] %pS\n", ptr, ptr); + warn_or_seq_printf(seq, " %pS\n", ptr); ``` This change may be acceptable since the %pS format outputs a hex string if no kallsyms are available. However, it modifies the original behavior, and in the kallsyms scenario, the raw pointer would no longer be present. 2. Modify SELinux to Avoid Sleeping Spinlocks Another option is to alter the SELinux capability check to use non-sleeping spinlocks. However, this approach is not advisable. The SELinux capability check is extensively used across the kernel and is far more critical than the kmemleak reporting feature. Adapting it to address this rare issue could unnecessarily introduce latency across the entire kernel, particularly as kmemleak is rarely used in production environments. 3. Move Stack Trace Printing Outside the Atomic Section The third and preferred approach is to move the stack trace printing outside the atomic section. This would preserve the current functionality without modifying SELinux. The primary challenge here lies in making the backtrace pointers available after exiting the critical section, as they are captured within it. To address this, the backtrace pointers can be copied to a safe location, enabling access once the raw_spinlock is released. Options for Creating a Safe Location for Backtrace Pointers Several strategies have been considered for storing the backtrace pointers safely: * Dynamic Allocation * Allocating memory with kmalloc cannot be done within a raw_spinlock area. Using GFP_ATOMIC is also infeasible. * Since the code that prints the message is inside a loop, executed potentially multiple times, it is only within the raw_spinlock section that we can determine whether allocation is needed. * Allocating and deallocating memory on every loop iteration would be prohibitively expensive. * Global Data Section * In this strategy, the message would be printed after exiting the raw_spinlock protected section. * However, this approach risks data corruption if another occurrence of the issue arises before the first operation completes. * Per-CPU Data * The same concerns as with global data apply here. While data corruption is less likely, it is not impossible. * Stack * Using the stack is the best option since each thread has its own stack, ensuring data isolation. However, the size of the data poses a challenge. * Exporting a full stack trace pointer list requires considerable space. A 32-level stack trace in a 64-bit system would require 256 bytes, which is contrary to best practices for stack size management. To mitigate this, I propose using delta encoding to store the addresses. This method reduces the size of each address from 8 bytes to 4 bytes on 64-bit systems. While this introduces some complexity, it significantly reduces memory usage and allows us to preserve the kmemleak reports in their current form. mm/kmemleak.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 0400f5e8ac60..fc5869e09280 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -274,6 +274,44 @@ static void kmemleak_disable(void); pr_warn(fmt, ##__VA_ARGS__); \ } while (0) +#define PTR_STORAGE_OP_OK -1 +#define PTR_STORAGE_OP_FAIL 0 +#define PTR_STORAGE_CAPACITY 32 + +struct ptr_storage { + unsigned long base; + u32 data[PTR_STORAGE_CAPACITY]; + int nr_entries; +}; + +static int ptr_storage_insert(unsigned long p, struct ptr_storage *s) +{ + unsigned long diff_data; + + if (s->nr_entries != 0) { + diff_data = s->base - p; + if (s->nr_entries < PTR_STORAGE_CAPACITY) { + s->data[((s->nr_entries - 1))] = diff_data & 0xffffffff; + s->nr_entries++; + return PTR_STORAGE_OP_OK; + } + return PTR_STORAGE_OP_FAIL; + } + s->base = p; + s->nr_entries++; + return PTR_STORAGE_OP_OK; +} + +static void *ptr_storage_get(struct ptr_storage *s, int item_no) +{ + if (item_no < s->nr_entries && item_no > 0) + return (void *)s->base - (s32)s->data[(item_no - 1)]; + + if (item_no == 0) + return (void *)s->base; + return NULL; +} + static void warn_or_seq_hex_dump(struct seq_file *seq, int prefix_type, int rowsize, int groupsize, const void *buf, size_t len, bool ascii) @@ -357,11 +395,13 @@ static bool unreferenced_object(struct kmemleak_object *object) * print_unreferenced function must be called with the object->lock held. */ static void print_unreferenced(struct seq_file *seq, - struct kmemleak_object *object) + struct kmemleak_object *object, + struct ptr_storage *s) { int i; unsigned long *entries; unsigned int nr_entries; + unsigned long tmp; nr_entries = stack_depot_fetch(object->trace_handle, &entries); warn_or_seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n", @@ -372,8 +412,8 @@ static void print_unreferenced(struct seq_file *seq, warn_or_seq_printf(seq, " backtrace (crc %x):\n", object->checksum); for (i = 0; i < nr_entries; i++) { - void *ptr = (void *)entries[i]; - warn_or_seq_printf(seq, " [<%pK>] %pS\n", ptr, ptr); + tmp = (unsigned long)entries[i]; + ptr_storage_insert(tmp, s); } } @@ -1625,6 +1665,10 @@ static void kmemleak_scan(void) struct zone *zone; int __maybe_unused i; int new_leaks = 0; + struct ptr_storage s = {0}; + bool do_print = false; + void *tmp; + int inx; jiffies_last_scan = jiffies; @@ -1783,12 +1827,20 @@ static void kmemleak_scan(void) !(object->flags & OBJECT_REPORTED)) { object->flags |= OBJECT_REPORTED; - if (kmemleak_verbose) - print_unreferenced(NULL, object); + if (kmemleak_verbose) { + print_unreferenced(NULL, object, &s); + do_print = true; + } new_leaks++; } raw_spin_unlock_irq(&object->lock); + if (kmemleak_verbose && do_print) { + for (inx = 0; inx < s.nr_entries; inx++) { + tmp = ptr_storage_get(&s, i); + warn_or_seq_printf(NULL, " [<%pK>] %pS\n", tmp, tmp); + } + } } rcu_read_unlock(); @@ -1939,11 +1991,23 @@ static int kmemleak_seq_show(struct seq_file *seq, void *v) { struct kmemleak_object *object = v; unsigned long flags; + struct ptr_storage s = {0}; + void *tmp; + int i; + bool do_print = false; raw_spin_lock_irqsave(&object->lock, flags); - if ((object->flags & OBJECT_REPORTED) && unreferenced_object(object)) - print_unreferenced(seq, object); + if ((object->flags & OBJECT_REPORTED) && unreferenced_object(object)) { + print_unreferenced(seq, object, &s); + do_print = true; + } raw_spin_unlock_irqrestore(&object->lock, flags); + if (do_print) { + for (i = 0; i < s.nr_entries; i++) { + tmp = ptr_storage_get(&s, i); + warn_or_seq_printf(seq, " [<%pK>] %pS\n", tmp, tmp); + } + } return 0; }