lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <5fa8dfeb-8eb6-0de0-a335-e0b4336c29e0@I-love.SAKURA.ne.jp>
Date:   Sat, 27 May 2023 20:04:11 +0900
From:   Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To:     Eric Dumazet <edumazet@...gle.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        "David S. Miller" <davem@...emloft.net>
Cc:     LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] ref_tracker: add stack_depot_save() failure handling to
 ref_tracker_alloc()

stack_depot_save() cannot accept __GFP_NOFAIL flag because
__stack_depot_save() drops gfp flags which are not in
GFP_KERNEL | GFP_ATOMIC | __GFP_NOWARN. Also, changing
__stack_depot_save() to accept __GFP_NOFAIL is not possible
because rmqueue() does not want __GFP_NOFAIL flag for
order == DEPOT_POOL_ORDER allocation request.

Therefore, assume that stack_depot_save(GFP_KERNEL | __GFP_NOFAIL) from
ref_tracker_alloc() can silently fail, and emit "unreliable refcount
tracker." message.

Signed-off-by: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
---
 lib/ref_tracker.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index dc7b14aa3431..ad48ff19adb2 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -84,12 +84,18 @@ int ref_tracker_alloc(struct ref_tracker_dir *dir,
 		gfp_mask |= __GFP_NOFAIL;
 	*trackerp = tracker = kzalloc(sizeof(*tracker), gfp_mask);
 	if (unlikely(!tracker)) {
+nomem:
 		pr_err_once("memory allocation failure, unreliable refcount tracker.\n");
 		refcount_inc(&dir->untracked);
 		return -ENOMEM;
 	}
 	nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
 	tracker->alloc_stack_handle = stack_depot_save(entries, nr_entries, gfp);
+	if (!tracker->alloc_stack_handle) {
+		*trackerp = NULL;
+		kfree(tracker);
+		goto nomem;
+	}
 
 	spin_lock_irqsave(&dir->lock, flags);
 	list_add(&tracker->head, &dir->list);
-- 
2.18.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ