Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp472111rwb; Wed, 28 Sep 2022 05:22:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uEiPEhEn8F1Z8f8LAaqFLG8IsWfq3xXNUIzVHkXKa7ZNOBU4LyLpGCC+1UrXJrX+HEYBP X-Received: by 2002:a17:907:6eaa:b0:783:84e0:3823 with SMTP id sh42-20020a1709076eaa00b0078384e03823mr13259352ejc.601.1664367730668; Wed, 28 Sep 2022 05:22:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664367730; cv=none; d=google.com; s=arc-20160816; b=B14EOzLwOuB77LkeygESfv/oqlG844NlbOBxKZjVStJ2jEh/Bwip5y2o12YfEPGaUT O2WL2PNPRa058MNwCxxh8fi4WjjgtALEc2TC3qol+sSrMHTeN0f1/ForKJHEfJZvof40 V5+qNvj5gqJobTl5RCNN3gVhxr90HsuypdCfYodqUvTg6NZjSuke16yQYKwCWeFzIJr9 VZJgcoly/g6QXVbw2ZQIrjcfLzwm1aFiqPUeEVNoOxhmZsKXEOHTjF08zkebVrldVOMt likCL2UHso6e4/1YPT1CC9RapDrHueleayzKRkG7z9GPmNgs9pghlLxQp8CQFlq+FLCZ IqUg== 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 :dkim-signature; bh=R+tt35RwTcDp8NVFqyIj6r8e594PICPVfST0BDBn7xk=; b=xG0+is7849DUPdYwXacO5KkDRZh5uvVc5MSg5JdALObPUtR9vCk0M1HTPVZm5cr2s3 JDeb2zKg0L1jfSjrqS2FLAYb5mEBAvxn3mOSN2ErRwkn7PWIQaLWEIDocC1I4Y9TUnLn 8zJpGFTBnvrGm4+B3Yl4rF86NhEJMBaSZ51qhgGWuDwoIIZJjFqIRLs5KVAGyGOHJYZd pjeeLgDfAwclCBjiHHq67dTdy2D8cS4rPboZ/RuBPRDsdECG7coaIo3MjELr87RTh+07 KPCQ4LwZSdy25GjLJ00X0Z7xX+CRzDl6NWLmi3Z98C9hAmaWGQjJ++lGZfwubuksNKxc eDJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=tjAURJkU; dkim=pass header.i=@codewreck.org header.s=2 header.b=EKIEJoDT; 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=codewreck.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a1709066b8300b007416e100f3dsi3601434ejr.986.2022.09.28.05.21.44; Wed, 28 Sep 2022 05:22:10 -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=@codewreck.org header.s=2 header.b=tjAURJkU; dkim=pass header.i=@codewreck.org header.s=2 header.b=EKIEJoDT; 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=codewreck.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233456AbiI1LXo (ORCPT + 99 others); Wed, 28 Sep 2022 07:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233625AbiI1LXm (ORCPT ); Wed, 28 Sep 2022 07:23:42 -0400 Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772D3DCEA6; Wed, 28 Sep 2022 04:23:40 -0700 (PDT) Received: by nautica.notk.org (Postfix, from userid 108) id D110EC022; Wed, 28 Sep 2022 13:23:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1664364217; bh=R+tt35RwTcDp8NVFqyIj6r8e594PICPVfST0BDBn7xk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tjAURJkUG3o+n3RG+G2zkCPBfuw65v9S0a7AySU6xqJmFpCWu2vhro9Jpjx9b2urX lvZBUko6OF1huj7hLxqAM5OqqgyQwx1SrjNXatZfsqiPlYiL1BQUho608ft8BevLJY HJ7RTBA2T565CJU5ihWEOK5uV4XB9SjxmQjTRLtJTCnT8A6nNIDyZwvjgKRzOoEO74 qU9ynhEl2KZ49SM3hPrYocxX3dCKEIyaMgX3vx6WD984t/ECs5/4bR9TdfAOSKARdc vrBpjJyv0m+dAcSonnZ9LMit8CCERuMvmWlTBnhfDSa6GVILNyN+S7F1eKw2wSq/mZ pQKF97Jmu5A2Q== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id F011DC009; Wed, 28 Sep 2022 13:23:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1664364216; bh=R+tt35RwTcDp8NVFqyIj6r8e594PICPVfST0BDBn7xk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EKIEJoDTJ7Yc9jBpEtFLr2sp/gEB8RrIEQoj8Lu7A8jxb4E9DzbWsBvtcaFP0UCo9 y13FjvUHpuzgm1XG9JZmoCene6H6DMzMntMQEUgzT3XWBY+fF2unGl/mciRmc6a+9r Exqk4x/OnmD1aAGxYBEGqoBItPVkSvABteTh1c+2FCAKDw4jr3gq5GwCLeMlDt/0VO jKkkBToQ1UGz9xVg4EPZnnkFpvitZYmkpNQtu9GsOlb8jAZG4D0KkfDIaxSiXKo0vW P0ftQJe6r6qocm5Qhz4DQf4iu6wBtSMvlaE18HVVdb4Cuhh5bUj+ylVhrayIMu8tvq YagPFpHIVaKkA== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id d4a4fd30; Wed, 28 Sep 2022 11:23:29 +0000 (UTC) Date: Wed, 28 Sep 2022 20:23:14 +0900 From: asmadeus@codewreck.org To: Leon Romanovsky 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=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Duplicating complicated cleanup code leads to leaks like we used to have; that destroy function already frees up things in the right order. And, well, frankly 9p is a mess anyway; the problem here is that trans_mod->create() doesn't leave any trace we can rely on in a common cleanup function, but the original "proper unwind" missed: - p9_fid_destroy/tags cleanup for anything in the cache (because, yes, apparently fuzzers managed to use the client before it's fully initialized. I don't want to know.) - fcall cache destory I'm not duplicating all this mess. This is the only place that can call destroy before trans_mod create has been called, I wish we'd have a pattern like "clnt->trans = clnt->trans_mod->create()" so we could just check if trans is null, but a destroy parameter will do. ... Well, I guess it's not like there are out of tree trans, I could just change create() to do that if I had infinite time... -- Dominique