Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2933991iog; Mon, 20 Jun 2022 07:47:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1voDKxO0EA2w/Dt+shBQqrCBqJMsLw+g+VqNhvh4Hg251eJsMBUw9JLeDNK8grdEh5jsyKW X-Received: by 2002:a17:902:8644:b0:168:fe0e:f92d with SMTP id y4-20020a170902864400b00168fe0ef92dmr24190426plt.23.1655736455868; Mon, 20 Jun 2022 07:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736455; cv=none; d=google.com; s=arc-20160816; b=fq91JMA7gOFwTKfYTPGMemOViv04PVTb5gZgjK6w1OBICpVXtETbUO4w8/i3qMT7Ii R+PyrJ483dxCZ4zyysnLgkH4Gtt9uyOSJGoZklI/JhYCI51ZfcZY0QFsLmmXZ1F9cnYQ 4NoOhyrWCeNlL0VWzh2u9edWMqXfZOmjvxugo+f0K19LisITz4Bf9vpa5FkcfBQ5dwpi a2aRFQuNSQinZKBbyyXpFUGEPvFm4iTpGVzC6Vb4CzaJAAUu5NHw4njU7kN93/VaRstT bEo1QR0sKGzzFK9Y+MBI8qI5t4/5u4gbpQg7Zv9F7Kj+i32B+j+E9j3r/KXY/R53HO3a N/rg== 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=jOBKk4JYeBw03Z2P6D6d7NGIoy2CnIKDSwKskNzLd3E=; b=R983REtsqAO+Tm71/MZLCZn7R24ahoNqgsILet+yhKon2Y9bgVGqZ6I7/herXSxLUO kSpwFsQo2kbk9gyV+pTRA3E/KIrhMUwUEvlvbZYpZtZ29QB0xVaYIWwRvs+cMHsxHOxq sGxA9D6ojEQnX5P/Yt6NqwUt+qR1IBqq8kswINtJcX+11TVTETkyg9DlXr3t2ciDfnJC 3vXU5EgBQ/w2L0AKHmy+gHE/B97OAqeWhTwLtziFn4zoCzt5ao4rLu+rOL8zPLZsfdjj fftIJP5gYqJAg0Ao++cRpAgt4InH2WEMiuEn6MBiV8niUE5TQ/dbuFLOy83VX2Ak0Qa6 n8jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jFi9Z1e+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a63ab07000000b003fc4a3b9fbesi4884211pgf.818.2022.06.20.07.47.20; Mon, 20 Jun 2022 07:47:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@linuxfoundation.org header.s=korg header.b=jFi9Z1e+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347248AbiFTOX6 (ORCPT + 99 others); Mon, 20 Jun 2022 10:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245157AbiFTOXq (ORCPT ); Mon, 20 Jun 2022 10:23:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1751E3EA; Mon, 20 Jun 2022 06:38:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9BB9B614A2; Mon, 20 Jun 2022 13:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A80AC3411B; Mon, 20 Jun 2022 13:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655732332; bh=xeNQ0+6hDjpNvZkk4v9Q9lxDKoWOP3OWykh/y4PzEg4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jFi9Z1e+H3yTylWZ6HfCXs2xOcJteAbnw0pJcK11A8lNApLffBb7jaoxbtrdIB/dt JSKMgzhjwpHtnv0TyD1GSGaWsfl0TcZHgZrH+Fal+Dueu8QsDkGW31FQHq9eJYuOa8 7njbVEtvUXZUBG1dmz638qYD4/HnGfoqevK+FSP0= Date: Mon, 20 Jun 2022 15:36:16 +0200 From: Greg Kroah-Hartman To: Jean-Philippe Brucker Cc: Zhangfei Gao , Arnd Bergmann , Herbert Xu , Wangzhou , Jonathan Cameron , linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux-foundation.org, Yang Shen Subject: Re: [PATCH] uacce: fix concurrency of fops_open and uacce_remove Message-ID: References: <20220610123423.27496-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-crypto@vger.kernel.org On Mon, Jun 20, 2022 at 02:24:31PM +0100, Jean-Philippe Brucker wrote: > On Fri, Jun 17, 2022 at 02:05:21PM +0800, Zhangfei Gao wrote: > > > The refcount only ensures that the uacce_device object is not freed as > > > long as there are open fds. But uacce_remove() can run while there are > > > open fds, or fds in the process of being opened. And atfer uacce_remove() > > > runs, the uacce_device object still exists but is mostly unusable. For > > > example once the module is freed, uacce->ops is not valid anymore. But > > > currently uacce_fops_open() may dereference the ops in this case: > > > > > > uacce_fops_open() > > > if (!uacce->parent->driver) > > > /* Still valid, keep going */ > > > ... rmmod > > > uacce_remove() > > > ... free_module() > > > uacce->ops->get_queue() /* BUG */ > > > > uacce_remove should wait for uacce->queues_lock, until fops_open release the > > lock. > > If open happen just after the uacce_remove: unlock, uacce_bind_queue in open > > should fail. > > Ah yes sorry, I lost sight of what this patch was adding. But we could > have the same issue with the patch, just in a different order, no? > > uacce_fops_open() > uacce = xa_load() > ... rmmod Um, how is rmmod called if the file descriptor is open? That should not be possible if the owner of the file descriptor is properly set. Please fix that up. thanks, greg k-h