From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C6B3C4338F for ; Tue, 17 Aug 2021 16:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0318360FD7 for ; Tue, 17 Aug 2021 16:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231325AbhHQQbi (ORCPT ); Tue, 17 Aug 2021 12:31:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:45058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbhHQQaM (ORCPT ); Tue, 17 Aug 2021 12:30:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E4B8761029; Tue, 17 Aug 2021 16:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629217687; bh=dGpS5njND7yROyvBrT3f246BeO+pDM1JwuML6ZYX06Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JSZny/ippjRGtvilvidsApBuYJmtBDquYL4MrunJZE3OQxmvmxIP+td3O9fR/hN/Q M0F8KryN9BD8A5HKO/Cg3cWPY1oh2jTVaj3fOsUM1RrqcT5VwgyqqsOj9gZsir+RQ1 oXcadQ+e25rQaWSYMG+UM4qrKQOf0hStg+toq6v8= Date: Tue, 17 Aug 2021 18:28:05 +0200 From: Greg KH To: Saubhik Mukherjee Cc: isdn@linux-pingi.de, jirislaby@kernel.org, dsterba@suse.com, jcmvbkbc@gmail.com, johannes@sipsolutions.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, andrianov@ispras.ru Subject: Re: [question] potential race between capinc_tty_init & capi_release Message-ID: References: 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 Tue, Aug 17, 2021 at 02:43:22PM +0530, Saubhik Mukherjee wrote: > In drivers/isdn/capi/capi.c, based on the output of a static analysis tool, > we found the possibility of the following race condition: Do you know of any isdn capi devices out there in the world right now? > > In capi_init, register_chrdev registers file operations callbacks, > capi_fops. Then capinc_tty_init is executed. > > Simultaneously the following chain of calls can occur (after a successful > capi_open call). > > capi_release -> capincci_free -> capincci_free_minor -> capiminor_free -> > tty_unregister_device > > tty_unregister_device reads capinc_tty_driver, which might not have been > initialized at this point. So, we have a race between capi_release and > capinc_tty_init. > > If this is a possible race scenario, maybe moving register_chrdev after > capinc_tty_init could fix it. But I am not sure if this will break something > else. Please let me know if this is a potential race and can be fixed as > mentioned. Would you be racing now if someone opened/closed the tty device node before the char device node was created? Anyway, this is really old and obsolete code, odds are it can just be removed entirely. thanks, greg k-h