Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp857107rdb; Wed, 6 Dec 2023 01:42:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCejUe20HqPJ31eDVkXFpKexak8hiHyFO8OmMtu/Dj1TO0JsZiq7n67jNT8z/aNeyqcD0j X-Received: by 2002:a05:6a20:8628:b0:18f:97c:4f53 with SMTP id l40-20020a056a20862800b0018f097c4f53mr252499pze.95.1701855776602; Wed, 06 Dec 2023 01:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701855776; cv=none; d=google.com; s=arc-20160816; b=FUS/i1HLxeqQ43jRZxiWbqtLdSna0FWeJ1/z2zEBxkrL10h+XDuypS23nTHCCZ3sR5 caHLEdXVMs2GPHay38vmf8+LE1qWo8S8lwPgc7UjI8oZT/Gj/LtrEGWkckfiKlqLeDf1 EHuZuj/iZU948QF3fCP3MuyJLTxH0sUvl1DhS+F9xbiML4A/nt5aax13Zgll6NG9Ea74 tPo+ifTle+i2dEiU6MFhr6CYmf9Db9gfhk8l1XAy1Sfaxc9fPNz6cBu9mSC8JkHX/iDO 4QLpKVy82K0DV1h2haLaCdPXL3o8oIOe1a4KYzBbyLfLYq6zXE5fjYgIOSPS8ukEXhWm ZrXw== 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=O1QvXJzrYPxwf/jH/dMEoBbUwymUHFJ9jHtCqg5uIqo=; fh=Tsf/c5oJxpVi7+JySlQrOjqw9HxW7Gg1aq1IWE/Gbek=; b=Hj/yh7ViYlkaHfbrgzl8vP+1EBeGEfxsZDpZt/Ch7eLw2Gp5JGAmB2Wh/cji5TXs+I zvOdkRNwnNNPAxPoEiYWJT7FpFPS13xSBz7soT6bHfhMax0wTblw3W21UqghRvVf8bJp TN4zjSTYZ+XbdNRrJCes2VtI/HOsD0HCfWxHZaCKpdsEtb1X6LAIizG+ZXhniyMgXzg8 U3aK76LCp3D2TvA5vlwewb5iNZFzWXUEtVoP07mKHll/XBTXqIbFzQGzZMU/BHJEHzAF cRxTSQ6Ic6zM0TmA5izYM0iZZODGIv0L+/47FIOzCGHvIg31qkOC8RkZjjjadPNDswDr qteA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Xz3fQ3Ha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s1-20020a170902a50100b001d08ac11b93si5943825plq.374.2023.12.06.01.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 01:42:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Xz3fQ3Ha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id DB559809F88A; Wed, 6 Dec 2023 01:42:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377117AbjLFJmi (ORCPT + 99 others); Wed, 6 Dec 2023 04:42:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbjLFJmg (ORCPT ); Wed, 6 Dec 2023 04:42: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 EB81DB9 for ; Wed, 6 Dec 2023 01:42:42 -0800 (PST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8692121ECC; Wed, 6 Dec 2023 09:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1701855756; 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=O1QvXJzrYPxwf/jH/dMEoBbUwymUHFJ9jHtCqg5uIqo=; b=Xz3fQ3HaTVchPQaxJ5uQVf8AtNeJJ7BDbinSE4auHPap4FApReCjkwLHZxRoorx1NSlBna MOt72hAjgqljqkuoQskwOCIfdALQpB+v5SYZCYv/YsNKOnpRlrDH25svyG65i6ucAo6mR/ bGMkEXbONVyH2BcCWtJ/zgMkejGRuik= 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 3A8A22C153; Wed, 6 Dec 2023 09:42:31 +0000 (UTC) Date: Wed, 6 Dec 2023 10:42:31 +0100 From: Petr Mladek To: Tetsuo Handa Cc: Hillf Danton , syzbot , linux-kernel@vger.kernel.org, Matthew Wilcox , John Ogness , Waiman Long , Linus Torvalds , syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [kernel?] possible deadlock in stack_depot_put Message-ID: References: <000000000000784b1c060b0074a2@google.com> <20231205113107.1324-1-hdanton@sina.com> <317e077b-71a7-4112-a7d0-5c49efce4f39@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <317e077b-71a7-4112-a7d0-5c49efce4f39@I-love.SAKURA.ne.jp> X-Spam-Score: 27.14 X-Spamd-Result: default: False [27.14 / 50.00]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[149.44.160.134:from]; RDNS_NONE(1.00)[]; TO_DN_SOME(0.00)[]; RWL_MAILSPIKE_GOOD(0.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)[]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; SUBJECT_HAS_QUESTION(0.00)[]; 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]; FREEMAIL_ENVRCPT(0.00)[sina.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[186b55175d8360728234]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(2.86)[0.952]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; VIOLATED_DIRECT_SPF(3.50)[]; NEURAL_SPAM_LONG(3.48)[0.996]; DBL_BLOCKED_OPENRESOLVER(0.00)[bootlin.com:url]; FUZZY_BLOCKED(0.00)[rspamd.com]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_CC(0.00)[sina.com,syzkaller.appspotmail.com,vger.kernel.org,infradead.org,linutronix.de,redhat.com,linux-foundation.org,googlegroups.com]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; SUSPICIOUS_RECIPS(1.50)[]; RCVD_COUNT_TWO(0.00)[2] X-Spamd-Bar: +++++++++++++++++++++++++++ X-Rspamd-Server: rspamd1 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-Queue-Id: 8692121ECC 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 06 Dec 2023 01:42:54 -0800 (PST) On Tue 2023-12-05 21:00:46, Tetsuo Handa wrote: > On 2023/12/05 20:31, Hillf Danton wrote: > > Unlike down_trylock(), mutex_trylock() is unable to trigger any lockdep > > warning, so why is a binary semaphore prefered over mutex? > > The mutex has limitations which makes it impossible to use for console lock. > > https://elixir.bootlin.com/linux/v6.7-rc4/source/kernel/locking/mutex.c#L537 In particular, mutexes can't be acquired in an interrupt context not even via mutex_trylock(). > By the way, this is a KASAN bug saying "refcount_t: underflow; use-after-free.". > Possibly a candidate for printk_deferred_enter() user? In practice, it would mean adding printk_deferred_enter() printk_deferred_exit() around the KASAN/stackdepot code which might be called in any context and might print a message. For example, see show_one_worker_pool(). It should be used only when really needed because it reduces the chance to see the messages. But honestly, I do not see a better solution. printk_deferred() is used on many locations inside the scheduler to avoid these deadlocks between console_sem and rq->lock. It should be solved by the printk rework introducing per-console locks. It might eventually allow to get rid of console_sem completely. But it might be a long ride until all console drivers get converted. Best Regards, Petr