Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp446737rwb; Wed, 28 Sep 2022 05:04:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fuLE7rJ295VFngm3DOfcMvXyBCkctv+uXB1G7SAHeFCb5tNbWfvjOw3HcOcyDdSz33rOP X-Received: by 2002:a17:907:a40a:b0:783:afc3:fa34 with SMTP id sg10-20020a170907a40a00b00783afc3fa34mr11335813ejc.643.1664366695793; Wed, 28 Sep 2022 05:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664366695; cv=none; d=google.com; s=arc-20160816; b=J5MKxVi7ZWymZYRTX50tMoPYHHToudKkuVBuareraVoi2goFrnzAiTboD2GiB9tSL2 yyPqCakExbk68MMFj/Hclhlv9HA8Dst4AFsCiTL7lAo7jd6Z7Nd2KKtuxLkPPNsGRocZ SEU+p8YPLXpySJS5+K3uMIJexSnGtFdk/ymzDo++E/RWu9Mo2z3upd5XtPI3w16RthwI Hg08KVZTaJaiLOi/fw1ouCH20Zuse5xoB+++VSPKGHw7GYGgCaDwzPPQNK+G1Supivux f0xWxFZK00InM631nhxUDb1doOJ3uxfESYugJ753oaMQIBu+myqoYXQ1GCHuew61KQyw +XXA== 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=KnYd69pb8JCWe/e7vyu9vi6t6Jb33OX+CSamUGuXc38=; b=XosqelgiwKtX2XRYudNzvZ1nEiXyAKu6vu7THJvwfzdwEQaqTmVRbnl/ujE0pNQdG7 +av+wO1LLRymxw06SqD10cRKFforpdd1l0C/SOhqNqwlVRtvUeoVDUlPGbbbgg6w6acW UGXtJbbtiasXE824QUbReNJTEWpHyXIxpIrdxjCST/6G+J/KJYl1p+fR3v0jJr/EDPVo gnpbHtWyCpJrkaUp+WOIFI/MWaXUErjR8YqGaiwbUYeexJngfrymtmrY9EghgxEmJZAv Eg5CJ9PJuF1VCDBij0stPO+JzquZWjleNM0eSq8bYG8DQHkhkH4e17Lnz29JVljV6NUy QMXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ciZbc4xk; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020a50d58b000000b004572a1eeb1bsi4386236edi.329.2022.09.28.05.04.30; Wed, 28 Sep 2022 05:04:55 -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=@kernel.org header.s=k20201202 header.b=ciZbc4xk; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233638AbiI1LyP (ORCPT + 99 others); Wed, 28 Sep 2022 07:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233582AbiI1LyN (ORCPT ); Wed, 28 Sep 2022 07:54:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB0405E56F; Wed, 28 Sep 2022 04:54:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0E38FB82056; Wed, 28 Sep 2022 11:54:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB66AC433C1; Wed, 28 Sep 2022 11:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664366048; bh=hulhezLqRBKK8E1gjp7vWO38O+DMT/KxUVnBXOBSOQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ciZbc4xklNIJ97bZwBY5d7bmodICuHbMRWrgm8tempqdCWxWdya+TI6BcT5FCDlVb 83spigJLPisO/aER9kNRqrXLyGJY7q1tKoxORHltsXfb/JjO6EC/8zdQXRYUviXJhA lKgb3UJjuBtBGGNb1mjDWlVU/co4yEAVssSepnumbGj5qYHzA172ZKI2iVtnvyHzd5 vlIAE0ginJ3c2F7mJ0ZTI/0CzkiwkIYSZfuGwDPZkS/eVMkd7Zq3Z1co8eP/egAzGd dR8AubT7rWigPqSLxaxuwgjBP7IFL1z0eV9U2gF/VFYnk9ocCPk3uap3XbTCATHap0 ZdXVmuBB8RiuA== Date: Wed, 28 Sep 2022 14:54:03 +0300 From: Leon Romanovsky To: asmadeus@codewreck.org Cc: syzbot , davem@davemloft.net, edumazet@google.com, ericvh@gmail.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux_oss@crudebyte.com, lucho@ionkov.net, netdev@vger.kernel.org, pabeni@redhat.com, syzkaller-bugs@googlegroups.com, v9fs-developer@lists.sourceforge.net Subject: Re: [syzbot] KASAN: use-after-free Read in rdma_close Message-ID: References: <00000000000015ac7905e97ebaed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.2 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 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-kernel@vger.kernel.org On Wed, Sep 28, 2022 at 08:23:14PM +0900, asmadeus@codewreck.org wrote: > Leon Romanovsky wrote on Wed, Sep 28, 2022 at 01:49:19PM +0300: > > > But I agree I did get that wrong: trans_mod->close() wasn't called if > > > create failed. > > > We do want the idr_for_each_entry() that is in p9_client_destroy so > > > rather than revert the commit (fix a bug, create a new one..) I'd rather > > > split it out in an internal function that takes a 'bool close' or > > > something to not duplicate the rest. > > > (Bit of a nitpick, sure) > > > > Please do proper unwind without extra variable. > > > > Proper unwind means that you will call to symmetrical functions in > > destroy as you used in create: > > alloc -> free > > create -> close > > e.t.c > > > > When you use some global function like you did, there is huge chance > > to see unwind bugs. > > No. Let's agree to disagree. > > Duplicating complicated cleanup code leads to leaks like we used to > have; that destroy function already frees up things in the right order. It is pretty straightforward code, nothing complex there. Just pause for a minute, and ask yourself how totally random guy who looked on this syzbot bug just because RDMA name in it, found the issue so quickly. I will give a hint, I saw not symmetrical error unwind in call trace. Thanks