Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp885206rdb; Wed, 6 Dec 2023 02:48:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkWEFe2IQu5J8ISYr5r9VE5IFYYKnplVQuPKnqTUYIGRt5pWZUol/zw4HzCBLX8a9TOZvm X-Received: by 2002:a17:902:f546:b0:1d0:265:6a2c with SMTP id h6-20020a170902f54600b001d002656a2cmr789562plf.11.1701859700116; Wed, 06 Dec 2023 02:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701859700; cv=none; d=google.com; s=arc-20160816; b=dRbNDLW8P/NxTrG1PopvzCpVEXAYc6Cc+OhV45amGEYziAg2xOWVKmwrI60fBNnTuZ BdjAwRcZ2llV5Td5JaCKBN45WDbdxuNoARvKq+KWApp5Z9fB/otIXTAHvz5b/xh1lpbQ PLf5wdKV/0Sik2im+2dE4N/M6JLNyl8msVRsosIibmlzD9jAm5OrbF36faAzxOCKyIKU nopXMZ+pFWVjxq9PD5QSywyp6zcO0TOqhUJzdGPG8J3/gs5l4xHcKsP+Ip8+8s3McBHN r5AO57YRHCtcgpzypgAReMG04WcXsjB7zHK9E3mAhAolNAvHY9Dy9JjXNmDUK6qzxlSB Ynjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Tvr+wZuWLjk8prt1x/6hIZLKUrQpVd6qxv/alDG6+W8=; fh=4rVgixwFXLpXtYUPlvl0v51BdahxdJ34SK57uQxb5Lc=; b=UyBs5Snnl1HhfbbN6nmaj9kMkfxo1J0gfqN8DBR2nx500yfa4GedhmjIRLiSGL7KqB i7eJh+K78/lU5DgzY7CSq3jKXXFN3qt+e4/FySMzHfk7JIwU33+Dk349PtW0BGBIeQjp LotqQVj/HvAYkAiW0gUJpq8L8Hulcu6nNggk1bC5tdX0wKk/pTE5uI3UyQDqYUOGSz4t 2RrvGgxIZMzsLjRulV6+vdJfIndTGqrGTWUHQAVHkXJheiA9jgCeC7GfBgChoFFIE2b0 YWBZCHuiZuJHBxLMWNtZCXdS64hvWdn3u8tcWwe9FKqPS79ScnmJlkfatGUMuKVua6x4 M/jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=unK7AS3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d16-20020a170902ced000b001d06d30071dsi7753133plg.651.2023.12.06.02.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:48:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=unK7AS3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3E6EA8033DF7; Wed, 6 Dec 2023 02:48:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377684AbjLFKsB (ORCPT + 99 others); Wed, 6 Dec 2023 05:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377846AbjLFKrg (ORCPT ); Wed, 6 Dec 2023 05:47:36 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F291FD9; Wed, 6 Dec 2023 02:46:50 -0800 (PST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1C7CB22035; Wed, 6 Dec 2023 10:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1701859607; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tvr+wZuWLjk8prt1x/6hIZLKUrQpVd6qxv/alDG6+W8=; b=unK7AS3Cg4pIF3+wrVJCEBQpXSLpS8lwYo4HyRLgQYo5tfw4JxvANAmdDDXQJXB8SNqbQw Ud871XDWRtnqr+JH5efDPaEYlO3pWko0LJWBR4iXWznCTO0cViZtWUeNoeMu1SlB1rlKv6 +avrHb+G/LxY3TFk1jyRjSfk8F7GzEM= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 845E12C153; Wed, 6 Dec 2023 10:46:44 +0000 (UTC) Date: Wed, 6 Dec 2023 11:46:43 +0100 From: Petr Mladek To: Herve Codina Cc: Saravana Kannan , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Sakari Ailus , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , stable@vger.kernel.org Subject: Re: [PATCH v3 1/1] lib/vsprintf: Fix %pfwf when current node refcount == 0 Message-ID: References: <20231114152655.409331-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231114152655.409331-1-herve.codina@bootlin.com> X-Spamd-Bar: ++++++++++++++++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=suse.com (policy=quarantine); spf=fail (smtp-out1.suse.de: domain of pmladek@suse.com does not designate 149.44.160.134 as permitted sender) smtp.mailfrom=pmladek@suse.com X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [18.00 / 50.00]; RDNS_NONE(1.00)[]; SPAMHAUS_XBL(0.00)[149.44.160.134:from]; TO_DN_SOME(0.00)[]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; HFILTER_HELO_IP_A(1.00)[relay2.suse.de]; HFILTER_HELO_NORES_A_OR_MX(0.30)[relay2.suse.de]; MX_GOOD(-0.01)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.10)[65.55%]; RDNS_DNSFAIL(0.00)[]; ARC_NA(0.00)[]; R_SPF_FAIL(1.00)[-all]; FROM_HAS_DN(0.00)[]; DMARC_POLICY_QUARANTINE(1.50)[suse.com : No valid SPF, No valid DKIM,quarantine]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; VIOLATED_DIRECT_SPF(3.50)[]; RCPT_COUNT_TWELVE(0.00)[14]; DBL_BLOCKED_OPENRESOLVER(0.00)[intel.com:email,bootlin.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HOSTNAME_UNKNOWN(2.50)[] X-Spam-Score: 18.00 X-Rspamd-Queue-Id: 1C7CB22035 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:48:17 -0800 (PST) On Tue 2023-11-14 16:26:55, Herve Codina wrote: > A refcount issue can appeared in __fwnode_link_del() due to the > pr_debug() call: > WARNING: CPU: 0 PID: 901 at lib/refcount.c:25 refcount_warn_saturate+0xe5/0x110 > Call Trace: > > ... > of_node_get+0x1e/0x30 > of_fwnode_get+0x28/0x40 > fwnode_full_name_string+0x34/0x90 > fwnode_string+0xdb/0x140 > ... > vsnprintf+0x17b/0x630 > ... > __fwnode_link_del+0x25/0xa0 > fwnode_links_purge+0x39/0xb0 > of_node_release+0xd9/0x180 > ... > > Indeed, an fwnode (of_node) is being destroyed and so, of_node_release() > is called because the of_node refcount reached 0. > >From of_node_release() several function calls are done and lead to > a pr_debug() calls with %pfwf to print the fwnode full name. > The issue is not present if we change %pfwf to %pfwP. > > To print the full name, %pfwf iterates over the current node and its > parents and obtain/drop a reference to all nodes involved. > > In order to allow to print the full name (%pfwf) of a node while it is > being destroyed, do not obtain/drop a reference to this current node. > > Fixes: a92eb7621b9f ("lib/vsprintf: Make use of fwnode API to obtain node names and separators") > Cc: stable@vger.kernel.org > Signed-off-by: Herve Codina > Reviewed-by: Sakari Ailus > Reviewed-by: Andy Shevchenko I have pushed the fix into printk/linux.git, branch for-6.8. Please, let me know if you would prefer to push this into 6.7. The "Fixes:" tag points to a pretty old commit from v5.5 so it does not look like a super urgent fix. And I always prefer when fixes spend some time in linux-next. Best Regards, Petr