From patchwork Fri May 6 21:33:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 570426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E980CC433F5 for ; Fri, 6 May 2022 21:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389937AbiEFVhL (ORCPT ); Fri, 6 May 2022 17:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444526AbiEFVhK (ORCPT ); Fri, 6 May 2022 17:37:10 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A74176F4A7; Fri, 6 May 2022 14:33:26 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651872805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Jeq5X8rBctwhIa1PWWHIqsjYqzv8yFjidcBuzCv/foM=; b=RxKlV8jfy3G27pBeNxf1ljB+JSQCw9i5bGNEezGrA2mf3fAcKm7klSuuxt/tdmJAznnGeq r0Yc2iqrlvhYo6led263WaMFE2R3pRmJI/3dOyDx3rD373mKFqDxfnQ0uikXcjE/gqbQcS qdUCHVhHDayc4UJKCqIPUZqPelEgnh6Ropi2KCSxHevhgrjETFb9pqD8BbcrtkXV/tLcud sK6OsNbo9R5xfXtP/9Hv4Xt3x/zo3jjPh9MCqthFqy5HKOKB4AzZy1eqmeKPC1oBD4pS83 T48LQsmXGhFGaTLdNDnGIadjzEhBN/LVPbllbK2N3soNfn/bhb/FXByt2T9uLw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651872805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Jeq5X8rBctwhIa1PWWHIqsjYqzv8yFjidcBuzCv/foM=; b=3Qs9mj50WwC4qI0K86sJbOxn9gMgDSusBkQmxzHDuSMsV7Wp11akMswqQfYcUxBBovfx/2 Dri4+jp9g7hT4SBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson , Greg Kroah-Hartman , Jiri Slaby , linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, Marek Szyprowski Subject: [PATCH next v1] serial: msm_serial: disable interrupts in __msm_console_write() Date: Fri, 6 May 2022 23:39:24 +0206 Message-Id: <20220506213324.470461-1-john.ogness@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org __msm_console_write() assumes that interrupts are disabled, but with threaded console printers it is possible that the write() callback of the console is called with interrupts enabled. Explicitly disable interrupts using local_irq_save() to preserve the assumed context. Reported-by: Marek Szyprowski Signed-off-by: John Ogness --- Note: I checked the other serial drivers and this was the only one that assumed interrupts off for write(). drivers/tty/serial/msm_serial.c | 5 +++++ 1 file changed, 5 insertions(+) base-commit: 38a288f5941ef03752887ad86f2d85442358c99a diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index 23c94b927776..e676ec761f18 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -1599,6 +1599,7 @@ static inline struct uart_port *msm_get_port_from_line(unsigned int line) static void __msm_console_write(struct uart_port *port, const char *s, unsigned int count, bool is_uartdm) { + unsigned long flags; int i; int num_newlines = 0; bool replaced = false; @@ -1616,6 +1617,8 @@ static void __msm_console_write(struct uart_port *port, const char *s, num_newlines++; count += num_newlines; + local_irq_save(flags); + if (port->sysrq) locked = 0; else if (oops_in_progress) @@ -1661,6 +1664,8 @@ static void __msm_console_write(struct uart_port *port, const char *s, if (locked) spin_unlock(&port->lock); + + local_irq_restore(flags); } static void msm_console_write(struct console *co, const char *s,