Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1237494pxp; Thu, 17 Mar 2022 05:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0OeKbCm7tWf7kqiz9MzoK7X16nfBClnbybB3/43ME4E2KODVStmYwEUMHi1hQAIAL2qFv X-Received: by 2002:a17:902:a704:b0:151:6d3b:946e with SMTP id w4-20020a170902a70400b001516d3b946emr5055579plq.130.1647521764340; Thu, 17 Mar 2022 05:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647521764; cv=none; d=google.com; s=arc-20160816; b=svFyqHEckzzUkqm6Pyl1JHClM0FtmwlXCUA2xtMGXmCEpgOpWe3/C17cIA5OsCFwiP uTguG8ktnoMpNXC9iJpGfIZCDqkWXdwWispKHYEszer2HdqOlzSFeVWXJEqMK5cBpzTg cjBANb6emvVwPvl+aDRhnsAL2XxDRFvvjdht0X71d6IDKKRlSjqfNIr0rfJFOVv1eo3C xvslswr6iMw2VpHYV/14tvzEILRntQ3euRiCsf/HdV2SrHGQ1bcsgJrYx+JDHdj7+GUm faqh6bDHW9x2UGfUgbSxha+VfTubVho1YCQs/KOEOhu0zlK88poMjCjwdRGmGz0h3IZx 23xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yX02XpRMKMKyrhCKJ+Q/Jp6VfNS2QcQlDe8XZZXmMQE=; b=0XlK6+PrDz+0Fk8NqvvdCUv2SDtLqbOLDlDSy3Xim1rqNdTDmbQTntKQgIgxGk6Mz7 y8ibDrq8Vkd00y+0+AjK3EeNsswjGbV8wY9WNIg6SnEEyrLO+iNL8BkbJJuQ5qODJ2M6 BQ6XTYNX4DGdLk5351CeVN344QPpsxSQq1frpFpZUxUw+wdHLX6ikrZpKgjOC0F7A9fa TOAJxpj5uY4n57fvM/a9qBU7UFIa8tvwjFEoZ8bbHYCm3nr0PCR1T45lyEal1UTcfl2r pRWSAkpm+N1f8qKyO1IjZuC2NR93axO3m4OGjV9cQSW3jwV8xwUZIlVcFwYFvw2qoJNc qQlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="T/fwsf7a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k66-20020a636f45000000b003816043ee2asi2101056pgc.31.2022.03.17.05.55.49; Thu, 17 Mar 2022 05:56:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="T/fwsf7a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233501AbiCQMYN (ORCPT + 99 others); Thu, 17 Mar 2022 08:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232878AbiCQMYL (ORCPT ); Thu, 17 Mar 2022 08:24:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9EAE19F6CC for ; Thu, 17 Mar 2022 05:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647519773; 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=yX02XpRMKMKyrhCKJ+Q/Jp6VfNS2QcQlDe8XZZXmMQE=; b=T/fwsf7aMqsLDKmY3Cim6NchmxuEdmFLpfBfuEuLx5p44hGgOhmU9dl1r/iDIBSD/XHAD9 wd4h19iixDQjO7zgAYEhFC1Nusissv72pY8IfoSUCs4iJIhFmKUkz6S7OSosz8P4ozCbfA /9U6jEptHWJs9S3oRc1QcH0tppjiixg= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-YPsi2uNoNdKh6w4hBWiQpw-1; Thu, 17 Mar 2022 08:22:52 -0400 X-MC-Unique: YPsi2uNoNdKh6w4hBWiQpw-1 Received: by mail-lj1-f197.google.com with SMTP id d16-20020a2e8910000000b00247ff33e987so1995364lji.14 for ; Thu, 17 Mar 2022 05:22:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yX02XpRMKMKyrhCKJ+Q/Jp6VfNS2QcQlDe8XZZXmMQE=; b=wgPek6WjJq8Af7OvBe+Y+BLbAt6qkBViRn5IBPmQLzR6nHUiv3lA3b53VaEdXAbkLb qGBEQuxKAyENnMSNCoch9sNIavOK5dcuWnS/9vCrDNOnC4hIdMi7tAstDKO4mbjHQow3 KfbPWXmeNJc1IPzaNw7/x3UPz64jvMP71T19SHO6ll1pwsA/AAznlZfQRCls6W0vgvAI YhcHwiCa4DTaVTAz5R1g9445AhpntfPtQ6isK6vZB4p4uwPcJ/HWumyeojFiexfzoH89 YM7I8pQKHUfOLQQLDcfW4+Q6ps+BTKUKfVm/rYUq1PhgZZbSYSEwo8lwTNwFPSuIfFeR gAxg== X-Gm-Message-State: AOAM531+uuk1uPiLthUwbnohPHJQ+S7B9+lAZQGlO1g/xRpeZwIkhzjS QxBFR3vTjKUEliJ+r233xsCM43QbQwFVZoRL0dlnBDR+HKrkPIkSGOFiw4N2jgY4q0FeVMI22Iy NY7MhSyUJ9ly4YxdPFnJdgMqO1iWPQ+24+lbKraLF X-Received: by 2002:ac2:4189:0:b0:448:bc2b:e762 with SMTP id z9-20020ac24189000000b00448bc2be762mr2576753lfh.471.1647519770417; Thu, 17 Mar 2022 05:22:50 -0700 (PDT) X-Received: by 2002:ac2:4189:0:b0:448:bc2b:e762 with SMTP id z9-20020ac24189000000b00448bc2be762mr2576737lfh.471.1647519770215; Thu, 17 Mar 2022 05:22:50 -0700 (PDT) MIME-Version: 1.0 References: <20220316143646.13301-1-wander@redhat.com> <20220316143646.13301-6-wander@redhat.com> <4914513f-cdb8-7698-be7f-968d343c5693@kernel.org> In-Reply-To: <4914513f-cdb8-7698-be7f-968d343c5693@kernel.org> From: Wander Costa Date: Thu, 17 Mar 2022 09:22:39 -0300 Message-ID: Subject: Re: [PATCH v4 5/5] serial/8250: Only use fifo after the port is initialized in console_write To: Jiri Slaby Cc: Wander Lairson Costa , Greg Kroah-Hartman , Johan Hovold , "Maciej W. Rozycki" , Serge Semin , Lukas Wunner , =?UTF-8?Q?Pali_Roh=C3=A1r?= , "open list:SERIAL DRIVERS" , open list , Steven Rostedt , Sergey Senozhatsky , =?UTF-8?Q?Andr=C3=A9_Goddard_Rosa?= , Sudip Mukherjee , Andy Shevchenko , David Laight , Jon Hunter , phil@raspberrypi.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 17, 2022 at 4:06 AM Jiri Slaby wrote: > > On 16. 03. 22, 15:36, Wander Lairson Costa wrote: > > The serial driver set the value of uart_8250_port.fcr in the function > > serial8250_config_port, but only writes the value to the controller > > register later in the initalization code. > > > > That opens a small window in which is not safe to use the fifo for > > console write. > > > > Make sure the port is initialized correctly before reading the FCR > > cached value. > > > > Unfortunately, I lost track of who originally reported the issue. If > > s/he is reading this, please speak up so I can give you the due credit. > > > > Signed-off-by: Wander Lairson Costa > > --- > > drivers/tty/serial/8250/8250_port.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c > > index 4acf620be241..7e2227161555 100644 > > --- a/drivers/tty/serial/8250/8250_port.c > > +++ b/drivers/tty/serial/8250/8250_port.c > > @@ -3416,6 +3416,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, > > !(up->capabilities & UART_CAP_MINI) && > > up->tx_loadsz > 1 && > > (up->fcr & UART_FCR_ENABLE_FIFO) && > > + test_bit(TTY_PORT_INITIALIZED, &port->state->port.iflags) && > > Cannot be port->state be NULL sometimes here? > IIUC, state is assigned at early port registration in uart_add_one_port(), so this function wouldn't be called when state is NULL. But I think it causes no harm to add an extra check. Thanks! > > /* > > * After we put a data in the FIFO, the controller will send > > * it regardless of the CTS state. Therefore, only use fifo > > > -- > js > suse labs >