Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5414860pxj; Wed, 23 Jun 2021 00:17:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRRz27Bm9Qm6ZuYK94rrbU3K1/FoIgT4OkGTvzL3Jozq+/++kqEx8ca5ynDTijOk68BjBo X-Received: by 2002:a17:906:e15:: with SMTP id l21mr8153045eji.386.1624432667442; Wed, 23 Jun 2021 00:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624432667; cv=none; d=google.com; s=arc-20160816; b=Dy5RRWCaCtCEcoYuj8jTJxf5yGKYUWjK/jkfza9JgxCDHxe338blU8ENdKta/hMlEx vSKf4ReUBzoxvK6MPl2gVNoiTY1Gmb4AkfA14OaBObdXcV5jPRB6seY1elYvqKdukFIu mMGOLbBPX1C8p0kw9IIUn2aV3RNRH8LOx/6dGx00j3+wtTaJsyY3iPatJ8WYUOTJ9+ef E8Q8A2UCcN1E8AWOfCzxOS50+Po8pSQM6EeamZRpgraHqLpF5Pz0Qht6ppv9s4bhYVgS PCjLKJ2clfNGkqcIUPqbPM9kxQ7qenLLGZgawskRp/fbKWt1f8Q5N9c7A2m8bswcwc7U 5uDQ== 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=gUYucQ8HqQ2jObNB1QQJmkZpO17aNXY0zhfqtWAGLis=; b=EM8J3nKqhis2E8dcGcSMu7INwlrfc+NqrJVsavqmlpAdow2GBHg9jzfgvd8USdGccm 4aVoqtm+YushvWKlJWayWFmKhBWygcEy8SCC6SUX8HJu/Num+jQuXAr5p0zdJZiUb4ZJ Qhr16x2C5Cij18i1997lNebc/kZl5mI8XyPtjvCUM8T+jTqpgUtmeDvk5yVluyrqzCF4 lMUdQfp9wovgT6j0jtAtKmS2lVDKK3LpuLWFMBHtHBDvK58xPBDJ8T834LQMd+AUxWmg QoGrMcASsjUk88X/KZcmqGEOLoErVCmrDysjXeCOKgMIXGhc5DUJ9dC8TESJ63AxtypZ n4gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EZYWZsX+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si7793065edq.228.2021.06.23.00.17.24; Wed, 23 Jun 2021 00:17:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EZYWZsX+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbhFWHSk (ORCPT + 99 others); Wed, 23 Jun 2021 03:18:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:55386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhFWHSk (ORCPT ); Wed, 23 Jun 2021 03:18:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 310CD60FD8; Wed, 23 Jun 2021 07:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624432583; bh=gUYucQ8HqQ2jObNB1QQJmkZpO17aNXY0zhfqtWAGLis=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EZYWZsX+gSkaay0/bPyGEhWn9N2f89q6Dt6acyO2DKx3OHXEipV3rh5kBnwumed0X 56d3eK1ZORCMmsqp7yD6mQafEamLu4vn46EDM4xV6+7PqxFlqi7SzJi7h6EDEWiL3U YvWto2U8UsquF718sZDwfwtjWwTk8xBIqzRAeZD/tavCg3gejCICQagW3LVNmV3tTA Out2aJQqKZ7jHeLxVRY0fymnIT7cdMntT2vLqPsUiLNOKZXPnafJMgMb3STB8CDM+B 623Wpd9tlhw0kKEYCBU4D5P4gPj6YUnzMojwNRzx7d/nLZ6eYHgS3TMyBL7Hdwx2X0 6o2RefQdSdzvQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1lvx7U-0004eB-JY; Wed, 23 Jun 2021 09:16:21 +0200 Date: Wed, 23 Jun 2021 09:16:20 +0200 From: Johan Hovold To: Saubhik Mukherjee Cc: Greg KH , jirislaby@kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org, andrianov@ispras.ru Subject: Re: [PATCH] tty: serial: owl: Fix data race in owl_uart_remove Message-ID: References: <20210617110443.6526-1-saubhik.mukherjee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 23, 2021 at 11:06:53AM +0530, Saubhik Mukherjee wrote: > On 6/17/21 4:52 PM, Greg KH wrote: > > On Thu, Jun 17, 2021 at 04:34:43PM +0530, Saubhik Mukherjee wrote: > >> Suppose the driver is registered and a UART port is added. Once an > >> application opens the port, owl_uart_startup is called which registers > >> the interrupt handler owl_uart_irq. > >> > >> We could have the following race condition: > >> > >> When device is removed, owl_uart_remove is called, which calls > >> uart_remove_one_port, which calls owl_uart_release_port, which writes > >> NULL to port->membase. At this point parallely, an interrupt could be > >> handled by owl_uart_irq which reads port->membase. > >> > >> This is because it is possible to remove device without closing a port. > >> Thus, we need to check it and call owl_uart_shutdown in owl_uart_remove. No, this makes no sense at all. The port is deregistered and hung up by uart_remove_one_port() (and the interrupt line is consequently disabled by the driver) before it is released so this can never happen. > >> Found by Linux Driver Verification project (linuxtesting.org). And you clearly did not test this, which you should mention. Johan