Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1281409imw; Tue, 5 Jul 2022 06:57:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1td7RFbvU2C/TI46uOpODRBhKBEccnWLijTYZ5bFfjQTNcAmIZCWvu2kGwEn3gRGUtnmmJD X-Received: by 2002:a50:fd93:0:b0:43a:71e2:781e with SMTP id o19-20020a50fd93000000b0043a71e2781emr7986463edt.396.1657029420263; Tue, 05 Jul 2022 06:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657029420; cv=none; d=google.com; s=arc-20160816; b=odLkPsvcH3BKSfI4GQAeYGMm9EwtHS8E/h8dBrmYbJET4aNX/tY+hexllHTIshY3GR xS+wvmFSElzLIiUbBIMOvFvmzdvQt+l1ZPwbJHhTq0+qODTZ3hpuYsDsQjX8OdNTEibN ot54wd3YMngdaoq5N1De8dVO3WFy/DkrTVh91UPbac10T90aLHD5mLIQaFq2U7rRqbVO bT+y3QfZCMx0mY2TE9gUbB8g4rQQiaTbAzciCeNlfnL49wl5ATUJOT9U1Vj33b1gqC6G 3aDZvrrEwA3fSmuIXsLD4GneNxZkIwDdD6LvUvBoT2GD9ND7PVjszugTLb4oxWTzzC7Q bLEw== 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=MV/9robfJ8dyu1dzaK7LWHNMYMEjsO1EwYVbeXZRAbk=; b=YRkHqaestQk1A9z0Hhn4hhMEGr7TnZvoOLE9LX3cHuyJqZE3m9cTXelRa/L+v2g/eF jJ7CDTDGqoswBpf3ampoZJmhPng3VCiYh/uOph6uR/4ro753sOUvutJaHp6Iq1+wU3I/ 1s+khBNwBCk4HmLpXeFzg87b4URpMHom4MpuCema1Q4ZQdOjxNT+vQ6OrQfEEw8CdtjN JpaJzwPOCulQl1Ms8n/h1Lv3dSU4iou8Drdp5hFseFdvefaOfDJ44gUItNhqdsXi4giY qvGgnSYOAUalb03TDFv8Ak4TLlT62Q7ImV3/YbGisCFycjLocTk/CO/kxetKmPkzBGPW aVRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=OogdDWH7; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs10-20020a170906dc8a00b0072ae569d6a0si2819517ejc.632.2022.07.05.06.56.34; Tue, 05 Jul 2022 06:57:00 -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=@ziepe.ca header.s=google header.b=OogdDWH7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231924AbiGENPr (ORCPT + 99 others); Tue, 5 Jul 2022 09:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231713AbiGENPZ (ORCPT ); Tue, 5 Jul 2022 09:15:25 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB7F35DC4 for ; Tue, 5 Jul 2022 05:39:35 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id x1so13390574qtv.8 for ; Tue, 05 Jul 2022 05:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MV/9robfJ8dyu1dzaK7LWHNMYMEjsO1EwYVbeXZRAbk=; b=OogdDWH7Cz1tYCj8sXZquslNIbgXiTkWCg6YZwVFVw1Vm9fbVxgkCoLz9+p6UVNYYC oZYiE6gGxNIbLNrcQkQCfLOXCkExR+vFekIHKLdSYAwTS2t00Ln/w5v3R9EccL6pJLSg ZOEjcfm1n0zQgpoBKKOlrAV4r/dJ0NNWLaVW0wLcEMYc1WK7eBOSub1lTOlLEZc7kthD cDbg0cfUe06wq6qh0OSbNGiFcVapWRPEn87VUN4txRHP5R08y0HmjsvWjdId81vBxavT izY0PsCfZ3GKY6EtRr9BnYxhYv6sgp8lm2sEOMtdLEOEvSNlZMgMSFNemUqy2eOoFbXq pqxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MV/9robfJ8dyu1dzaK7LWHNMYMEjsO1EwYVbeXZRAbk=; b=6GRfZ9Pqrb1dnFp5cTkL8i4ed/TJ2fKiWzklLqxWr5v5QNGErrIvTqUa+zh9lpoGuU fUPAkBW5AgSXRDuPA5PhhYhrSxoOgH8s28LV8rdMwZUcqGI5jH9o5FMQXgBv2la1nUHk YQusE/f57tEQzUdmWOqVUqtm+4vry2VzD2Q8Fo01/8PSE7nid4rwEnQWJVedbWMseIdp TfPAjHdWFwetfR4u0zRN3tz/deIzT37c3/8r3w1DiF6oMP8vqLxBbUkzYBSz2Wxad9zZ t2loBNxCyA9ROS9J1t9ytBJyCr8M69LIKWyBWSnkSNsCnTZAwVciHtW0nn9FUAdVzaMR FtDg== X-Gm-Message-State: AJIora+R07hO98uhvWIKjHFoFKikdX0j830FjEgc3mE+a/mm2fQRQDEg 9CKcTwFovGu6b3Z4MA/om3v4PA== X-Received: by 2002:ac8:578a:0:b0:31d:3ca6:d7e0 with SMTP id v10-20020ac8578a000000b0031d3ca6d7e0mr16265174qta.181.1657024774610; Tue, 05 Jul 2022 05:39:34 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id bx15-20020a05622a090f00b0031c56d5f7e1sm13508248qtb.92.2022.07.05.05.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 05:39:34 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1o8hq1-006TzK-Ez; Tue, 05 Jul 2022 09:39:33 -0300 Date: Tue, 5 Jul 2022 09:39:33 -0300 From: Jason Gunthorpe To: Bart Van Assche Cc: Hillf Danton , Mike Christie , "lizhijian@fujitsu.com" , Leon Romanovsky , "linux-rdma@vger.kernel.org" , "target-devel@vger.kernel.org" , open list Subject: Re: use-after-free in srpt_enable_tpg() Message-ID: <20220705123933.GD23621@ziepe.ca> References: <17649b9c-7e42-1625-8bc9-8ad333ab771c@fujitsu.com> <20220701015934.1105-1-hdanton@sina.com> <20220703021119.1109-1-hdanton@sina.com> <20220704001157.1644-1-hdanton@sina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Mon, Jul 04, 2022 at 09:34:07PM -0700, Bart Van Assche wrote: > On 7/3/22 17:11, Hillf Danton wrote: > > On Sun, 3 Jul 2022 07:55:05 -0700 Bart Van Assche wrote: > > > However, I'm not sure that would make a > > > significant difference since there is a similar while-loop in one of the > > > callers of srpt_remove_one() (disable_device() in the RDMA core). > > > > Hehe... feel free to shed light on how the loop in RDMA core is currently > > making the loop in srpt more prone to uaf? > > In my email I was referring to the following code in disable_device(): > > wait_for_completion(&device->unreg_completion); > > I think that code shows that device removal by the RDMA core is synchronous > in nature. Even if the ib_srpt source code would be modified such that the > objects referred by that code live longer, the wait loop in disable_device() > would wait for the ib_device reference counts to drop to zero. That is not really the "ib_device" reference count it is the "registration" reference count. IB has a system where drivers/ulp can create critical regions where the ib device must be registered using the ib_device_try_get()/put calls. "Must be registered" is useful in a number of places but should not be held for a long period. This is distinct from the normal struct device refcount that simply keeps the ib_device memory alive. Jason