Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1399273pxb; Thu, 24 Mar 2022 19:48:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi8kORu0GCSHuN8LITxH17OgO8ujo4qvSVdSEG3A/TxfBEN5I4zXgmHmcXL9pET3wZICRu X-Received: by 2002:a17:907:2d20:b0:6df:8c3f:730a with SMTP id gs32-20020a1709072d2000b006df8c3f730amr9261344ejc.725.1648176525941; Thu, 24 Mar 2022 19:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648176525; cv=none; d=google.com; s=arc-20160816; b=cGszBwAFf+acRRMIerBCAIZVBQUMY00KHpE6nq+rp3XNXtWWFb+7UVc5lIZ9xGyL5O k4sHNm/nGtiu2DFJdiF/pMLlYGSaNf4pmvi/pE1Vvy+KNChyuesPwcoEHNP9+NGjUKpc ZWEyfko/WxabK5E12SlWymmC8meUd72mTQq1Pm2F3WIEwpEnY3nvKuuBCPSzOF0eVdle cm8ODEb6Gwhms0pT8CSPwD7vZW92awhwqz1c8L0FJohi0t4/qPR8caYFTXgqFK8dH44t xnMrYKeMZJyFOOMcA7OfI0eqAm//RBLcAmoDqYAf7UzSHW6B+aagw7WXt3I8p3r72YNM zxEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:to:from:subject:message-id; bh=YAq3DIxqciEPlTiZTwcy6KNBxjqs3UnPc37ddjFb1+s=; b=t8vQydQSDooVTyGkqsfk+zgA6pm8WM8ybwhk7ixBCHtAd9VZCOWqmueBQEZ8UqHLf8 CfXe3JCbK1On1hr05INhCFoDKfODvb5TaB245XMx2aoOAhOYeqx6vFQo1EhA7s8ZVdN4 eflOVhDxeDOdwTsldsGUlyiLeGVyskOx7fzvzgLt3k1Ac6ofTfrU/O8VZJ2VZxs8Y2VJ JITfvIQuRaPn6qBwxqteABDhPcwtVI6h2HMgSyLXslqwNkhMXcGA5w5lW+uS0btARcQ4 NoY1Yc6sVcOrfja5mdAy4D5ceG/gGil7d8IGEBQpV2SkVhC/rcsMufB4jG+1+YyQx4et cyPg== ARC-Authentication-Results: i=1; mx.google.com; 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 eq17-20020a056402299100b00418c2b5bd6esi1390105edb.80.2022.03.24.19.48.21; Thu, 24 Mar 2022 19:48:45 -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; 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 S1347914AbiCXDTk (ORCPT + 99 others); Wed, 23 Mar 2022 23:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241880AbiCXDTh (ORCPT ); Wed, 23 Mar 2022 23:19:37 -0400 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C604DD6; Wed, 23 Mar 2022 20:18:04 -0700 (PDT) Received: from [192.168.12.102] (unknown [159.196.94.94]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id 255C82029E; Thu, 24 Mar 2022 11:17:56 +0800 (AWST) Message-ID: <61ac01e70c293b7e0d378436f7617daaad552fcf.camel@codeconstruct.com.au> Subject: Re: [PATCH v0] mctp: fix netdev reference bug From: Matt Johnston To: Lin Ma , jk@codeconstruct.com.au, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 24 Mar 2022 11:17:56 +0800 In-Reply-To: <20220324023904.7173-1-linma@zju.edu.cn> References: <20220324023904.7173-1-linma@zju.edu.cn> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4-1ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Lin Ma, On Thu, 2022-03-24 at 10:39 +0800, Lin Ma wrote: > In extended addressing mode, function mctp_local_output() fetch netdev > through dev_get_by_index_rcu, which won't increase netdev's reference > counter. Hence, the reference may underflow when mctp_local_output calls > dev_put(), results in possible use after free. > > This patch adds dev_hold() to fix the reference bug. This was already fixed in net-next to increment the refcount in __mctp_dev_get() and use mctp_dev_put(). dc121c008491 ("mctp: make __mctp_dev_get() take a refcount hold") e297db3eadd7 ("mctp: Fix incorrect netdev unref for extended addr") Thanks, Matt