Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4656297iob; Sun, 8 May 2022 20:50:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+QRWv7CF3Ck2LpdRREXuePKZa3yHS40vKJ4IoxrtmXP8SzdmAqJ2ZCoA/SfZqtrI7yz3+ X-Received: by 2002:a62:ed0b:0:b0:505:7675:1119 with SMTP id u11-20020a62ed0b000000b0050576751119mr14188625pfh.4.1652068235555; Sun, 08 May 2022 20:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652068235; cv=none; d=google.com; s=arc-20160816; b=CapiyPC9ZQRmqBlF4qy5dkFg0Y1kChxUJi4OSPGM3RZAIl3sIEqHzMy+Ht34Y3anN7 pTAV0FrrvtYhva/SztLb82Dbgo0wtC1U7t15yfXxhESqOVKv51VlDGxuFmANSZQiL1pe Cr/YEol+CwybaEXBf4fW15WVpatkhbYOkSXEn8kjCdOcXMu5MIWs/dnI6UBMYEk2Bqiv Xi+lqPl906ehm7/Wh+hblau+tLz/lE7Qc9ec/79XOoi6oDGNGA1uo3SGHNRLAPZ7hKTZ VZzP7cdvYfT7Cpd/SoIHJCkPoO9hkvDXkJs6nySpMOpfvze78yJ58lTHdDsjI7Bgt8bG vlNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=7G+zUj54eBfyktDcZa4ZbAJ+odaEfrQMWJTCSbKdy3k=; b=t2EhXjNU4hKKxNTo2c7OaVSB5/oNSw2VosHljz+y8vNb9kXY0liSx3S/pFi5kVTvOY 5EbBx1phwRxNn2iMwQIHXEKrwNa56RqC1bShayk/JpN8Fym1cdQwJhhcjxSkf4Te4Gzr Ik6dNugNtR/pmnczo4+gw+vPqVnlSHtaLqAGj1RN50sWFtNG+d1lLTR3X2oGc2j9m61V IKc8EhEZTSPedjpfb9eKtKI6ygp3/5dA5CD3Gl/CZ7mSCreYeS+7lbQu0vu4uN97RVQr 9kz6RmN/U/As9UGfpgI4QjMyuvXJvrokctx7I5gMH0Hfui+Ck4+kw98peBBjDw5+NJWw arMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iGAXFGuL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e21-20020a635455000000b003c1e7f30a28si3593454pgm.584.2022.05.08.20.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:50:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iGAXFGuL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6C27F238; Sun, 8 May 2022 20:50:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231858AbiEHLG2 (ORCPT + 99 others); Sun, 8 May 2022 07:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230432AbiEHLG0 (ORCPT ); Sun, 8 May 2022 07:06:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE81ADF1B for ; Sun, 8 May 2022 04:02:36 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1652007754; 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: in-reply-to:in-reply-to:references:references; bh=7G+zUj54eBfyktDcZa4ZbAJ+odaEfrQMWJTCSbKdy3k=; b=iGAXFGuLvVo6RpqFLMh0I7GAsJs9x6RUuD0iLq6O3k1p1jaLIT1/Dnjl1o8u3Mk8My2mvO P3I5idFwbQ2uMmyBEghYRQAOJ52/jbcCUG9kpi7BDGQqqxgS1M4Knh2rfp1xSkGv2OqYup GSybEJMYYY+ieyrk1J32AG14PfLXRTU7sMUyHloRCtBoKES1lZXKjc32wqh6Md/fjKI1J0 QuU6Fox4owf6UrYQzJCl0HXVDRAenF6AMq3e5Zl3mQ30S/jhXFddru6bjClYUnvmFI6WSI coRXikGGhJzUQfhprSwM/G20Usso5Oq7HnlArGepFuPbe4/8v7oJkBd1yISKTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1652007754; 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: in-reply-to:in-reply-to:references:references; bh=7G+zUj54eBfyktDcZa4ZbAJ+odaEfrQMWJTCSbKdy3k=; b=fMm0K8kzoOwNve1dseEdxD4RAMHY82afC7BOqFI9E8ghspP/h/+mXruaz2MaO63rE24efU +7qpfIyUWZ8o00Aw== To: Neil Armstrong , Marek Szyprowski , Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-amlogic@lists.infradead.org Subject: Re: [PATCH printk v5 1/1] printk: extend console_lock for per-console locking In-Reply-To: References: <2a82eae7-a256-f70c-fd82-4e510750906e@samsung.com> <87fslyv6y3.fsf@jogness.linutronix.de> <51dfc4a0-f6cf-092f-109f-a04eeb240655@samsung.com> <87k0b6blz2.fsf@jogness.linutronix.de> <32bba8f8-dec7-78aa-f2e5-f62928412eda@samsung.com> <45849b63-d7a8-5cc3-26ad-256a28d09991@samsung.com> <87pmktm2a9.fsf@jogness.linutronix.de> <87a6bwapij.fsf@jogness.linutronix.de> <87zgjvd2zb.fsf@jogness.linutronix.de> Date: Sun, 08 May 2022 13:08:33 +0206 Message-ID: <871qx4qoc6.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Neil, On 2022-05-06, Neil Armstrong wrote: > Thanks all for figuring out the issue, perhaps other uart drivers > could fall in the same issue if startup code isn't protected with > lock? When preparing for the official patch submission [0], I needed quite a bit of time to understand why another function (meson_uart_reset) should not and cannot acquire the port->lock. I then started investigating some other drivers and indeed I see lots of potential problems. Any console initializing port->lock from the driver's probe() is probably wrong (and there are lots of them). But as I've learned with the meson driver, the details are subtle. Each driver will need to be carefully evaluated to see if it is actually safe. uart_ops->startup() is called without holding port->lock. If the device is a console, it is already registered and printing. driver->probe() is called without holding port->lock. If the device is a console, it is already registered and printing. For both functions, port->lock might not be initialized yet, so blindly acquiring it is wrong. Note that this is not related to the introduction of kthread printing. I've put it on my TODO list to go through the ~76 console drivers to investigate their startup() and probe() implementations. But I will not be able to do this quickly. My time might be better spent writing to all the maintainers asking them to please verify the usage. John Ogness [0] https://lore.kernel.org/lkml/20220508103547.626355-1-john.ogness@linutronix.de