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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A234C4332F for ; Wed, 14 Dec 2022 07:51:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237538AbiLNHvR (ORCPT ); Wed, 14 Dec 2022 02:51:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237342AbiLNHvP (ORCPT ); Wed, 14 Dec 2022 02:51:15 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D39DA1AF00 for ; Tue, 13 Dec 2022 23:51:14 -0800 (PST) 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 763DE617F4 for ; Wed, 14 Dec 2022 07:51:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18223C433EF; Wed, 14 Dec 2022 07:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671004273; bh=73X2UfaQ6K5nlHyk8iDz1B9vETU61BYsdzqVT9sIzLk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C851pKNhc0y9b7ObZjHgootcQ4wmfWb3MKTdHruZFVPue1wq6Bt/vj47A/+C30Dcw G40cMWH4tu4aY0f/i7F4kqK5/6y2GTgvO0HX35k3Dtsx77NdZ6JPkunyZ27MQi2vfX GgFYW2X3/4U9cwYGdGQONbHSFYDzYCgErrldA7HmNwIQiH8sr1E5NaEnSoi4xIicTv X73KvcQaKIwT8eS51iDws1NF92lhZZAESelqgAjhYA/hHXUrHIx4jmUXIse8aRE6+j Idikhwe+MiCAx4RMLpapxvfG62gFG5/oSpmX6Ix8E2S+Ac7mZwmc8TdTtf//9jQh1U r/5tr6haw7cTg== Date: Wed, 14 Dec 2022 09:51:09 +0200 From: Leon Romanovsky To: Jakub Kicinski Cc: Nir Levy , davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org Subject: Re: [PATCH net v2] net: atm: Fix use-after-free bug in atm_dev_register() Message-ID: References: <20221211124943.3004-1-bhr166@gmail.com> <20221213191233.5d0a7c8f@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221213191233.5d0a7c8f@kernel.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Dec 13, 2022 at 07:12:33PM -0800, Jakub Kicinski wrote: > On Mon, 12 Dec 2022 09:12:30 +0200 Leon Romanovsky wrote: > > > v2: Call put_device in atm_register_sysfs instead of atm_dev_register. > > > > Reviewed-by: Leon Romanovsky > > On one of the previous versions you commented that > atm_unregister_sysfs() also needs to move to unregister() rather > than del(): > > https://lore.kernel.org/all/Y48CwyATYAAcPgqT@unreal/ > > Is that not the case? Yes, it should, but it is much larger change than this fix and someone needs to do it as a separate patch. You can't simply replace device_del() in atm_unregister_sysfs() because how atm_dev_put() is implemented. The latter blindly calls to put_device(&dev->class_dev) and you can't remove it without close look on all atm_dev_put() callers. > > Also atm_dev_register() still frees the dev on atm_register_sysfs() > failure, is that okay? Yes, the kernel panic points that class_dev (not dev) had use-after-free. Thanks