Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3612116pxu; Tue, 8 Dec 2020 17:17:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyp8ZYg+Mmv5K/yMhnDk70vcqJtUcom+hRFShmAcrMfoU9Cln5Vr0MOklzX1ft3PLHY4koi X-Received: by 2002:aa7:d407:: with SMTP id z7mr661892edq.234.1607476675224; Tue, 08 Dec 2020 17:17:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607476675; cv=none; d=google.com; s=arc-20160816; b=UW72O5PNY1h+vzi1AWaV3YiJ00O2YgLIUSi0GmyCJhxAz1kLjO4F5XOxqRNHAvZ3yf gyPr6GJAQHKc6KAAZ83AiPxUf9rN7xlxY4azv/cHuG2v3nqVJjT/kCykF2nnJ5PM31uM InwkCPNO0k8BX32y0rZATLnO7ZGirYGg9l+HK4fkfJ2ehHAy+pn3ZPfFEHQA/FjIzhzC XIc1eiZmSiEDkIMCKZr2uaMAUTZLZvL01OQajhw0TS7bne+V9cA69+UKfkDtzoI50LxQ TbmBOboz3RbMqg7vQAbyiK8BJu3xVCqS4+t6MtWewhT/akKTUjbMFbrjU4t36gOHn/aT k2vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=xYc9WYGxChyrOZCvu5W8qywcrz7CG4Yfu8mzFGtVndM=; b=w6jm3VSQybNP0UfM8hS6g2b+f5RJJ/PO1cd9w8MPBKz38soIfbgsy9DslS96ReDGhV 6xBOSpge7fNUPZcvORH7OVRcPZg9OZdV73oBg6wVVKYuU3tSBYgXTCiVXfkxJqR8BY6o /TcffNoSY52CRPQlrJLEpOv267RDEXM3Zf40uq7dOFk4i4Zjm2UJl+8YiCU2qENthNJZ hjCAdbS9TTBO8EyJQIX/lLG9dlr+ViInNc0JYn/Pdnaf9XHDus/kDBUjzV3XEH1sdBQB YuR88Y2J4/ufeoYkl3bKGRwqUJ+IABO5gZ/QOQTX58z7O5JCtiezoDs8cIyIt6czj943 YzmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs4si139109edb.555.2020.12.08.17.17.32; Tue, 08 Dec 2020 17:17:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgLIBOD (ORCPT + 99 others); Tue, 8 Dec 2020 20:14:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:37642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbgLIBNq (ORCPT ); Tue, 8 Dec 2020 20:13:46 -0500 From: paulmck@kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, iamjoonsoo.kim@lge.com, andrii@kernel.org, "Paul E. McKenney" , Christoph Lameter , Pekka Enberg , David Rientjes , linux-mm@kvack.org Subject: [PATCH v2 sl-b 4/5] rcu: Make call_rcu() print mem_dump_obj() info for double-freed callback Date: Tue, 8 Dec 2020 17:13:02 -0800 Message-Id: <20201209011303.32737-4-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20201209011124.GA31164@paulmck-ThinkPad-P72> References: <20201209011124.GA31164@paulmck-ThinkPad-P72> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" The debug-object double-free checks in __call_rcu() print out the RCU callback function, which is usually sufficient to track down the double free. However, all uses of things like queue_rcu_work() will have the same RCU callback function (rcu_work_rcufn() in this case), so a diagnostic message for a double queue_rcu_work() needs more than just the callback function. This commit therefore calls mem_dump_obj() to dump out any additional available information on the double-freed callback. Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Reported-by: Andrii Nakryiko Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index b6c9c49..464cf14 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2957,6 +2957,7 @@ static void check_cb_ovld(struct rcu_data *rdp) static void __call_rcu(struct rcu_head *head, rcu_callback_t func) { + static atomic_t doublefrees; unsigned long flags; struct rcu_data *rdp; bool was_alldone; @@ -2970,8 +2971,10 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func) * Use rcu:rcu_callback trace event to find the previous * time callback was passed to __call_rcu(). */ - WARN_ONCE(1, "__call_rcu(): Double-freed CB %p->%pS()!!!\n", - head, head->func); + if (atomic_inc_return(&doublefrees) < 4) { + pr_err("%s(): Double-freed CB %p->%pS()!!! ", __func__, head, head->func); + mem_dump_obj(head); + } WRITE_ONCE(head->func, rcu_leak_callback); return; } -- 2.9.5