Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1450427ybl; Sun, 19 Jan 2020 03:33:07 -0800 (PST) X-Google-Smtp-Source: APXvYqz7Zn9PA2eQ/K00R1StgF78rQnyGYj9jGe1HD6D8NWFi89du8tTbidlZuh9ble6JUOfXzff X-Received: by 2002:a05:6830:124b:: with SMTP id s11mr12271037otp.333.1579433586946; Sun, 19 Jan 2020 03:33:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579433586; cv=none; d=google.com; s=arc-20160816; b=MQJyaxIA2GEXRYJQGnlJA5SEQ0trvzO/58NRZjDj6eWPjCby5T0n/kT2qwtpyMhFnu wKllPmrUuxFx3TCAPiw6/HlInvb5PRgiUB+4J7IoxRgX9E+WgrnENaJZi0BHPf4Fdc+9 honGy2YkVM1ZyWE5Mk5Gwd5P82IGSNTUDfnUgPyyywBDirExO/LWK6Wr8SF+Aq8Mmobq tWk7u3fu0NQgRVYWRUKjIwYmPw7ueMgxvM48h5ZWn/uHStSQko41bNQ2KljG/syZ0eDW PLumfym0Q2hgO9AxdtSSAs6z8osUxkcBarHVVMNbfNTgyK1nRUejT6+tL+uAp2pSxmug QGIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=q17/M2HwFamLCVENttalKEIjTVoO9jzyu/o9qoBnxeY=; b=HfzX1iJdK6XLcaSYkhXmGNcer1Nwja3sPDXp7TWSy3SHWW4zqlOEs8Qr7BQEXJqQ3m hHagPUJAsjSEw1raqPDrT2nxzbrsjeEkBYXsvY1fUaEqIBoUtZjv8370WV0t3LKJAd7T xe3gzTOp9rtNu/TFgyczc8FiXKi51jqAvbM6CW6NMWBwvakR5TMu5ws7cIeJ3OrXKq/D QXnXeSTuDeJwTFlRbSOnSSo73csnl6YZghy79ZPO4s9PesgiG6aj7HT0JhhWUQNtJ425 wF+fEe2VYhs0Vn8CvawXJaYv0r4QLyGJr/OD19cm80yKaBOTTICD6gLInz8crZGBTQgu X8gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g14si18146047otl.258.2020.01.19.03.32.55; Sun, 19 Jan 2020 03:33:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728665AbgASLbh (ORCPT + 99 others); Sun, 19 Jan 2020 06:31:37 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:47454 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727118AbgASLb2 (ORCPT ); Sun, 19 Jan 2020 06:31:28 -0500 Received: from localhost (unknown [62.21.130.100]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 9C41414CDB4DB; Sun, 19 Jan 2020 03:31:26 -0800 (PST) Date: Sun, 19 Jan 2020 11:00:31 +0100 (CET) Message-Id: <20200119.110031.253679721520131241.davem@davemloft.net> To: blackgod016574@gmail.com Cc: siva.kallam@broadcom.com, prashant@broadcom.com, mchan@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] driver: tg3: fix potential UAF in tigon3_dma_hwbug_workaround() From: David Miller In-Reply-To: <20200116033044.GA2783@hunterzg-yangtiant6900c-00> References: <20200116033044.GA2783@hunterzg-yangtiant6900c-00> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sun, 19 Jan 2020 03:31:27 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gen Zhang Date: Thu, 16 Jan 2020 11:30:44 +0800 > In tigon3_dma_hwbug_workaround(), pskb is first stored in skb. And this > function is to store new_skb into pskb at the end. However, in the error > paths when new_skb is freed by dev_kfree_skb_any(), stroing new_skb to pskb > should be prevented. > > And freeing skb with dev_consume_skb_any() should be executed after storing > new_skb to pskb, because freeing skb will free pskb (alias). > > Signed-off-by: Gen Zhang There are no bugs here. The caller never references "*pskb" when an error is returned. So it is safe to store any value whatsoever into that pointer. 'skb' never changes it's value even if we store something into *pskb because we've loaded it into a local variable. So it is always safe to call dev_consume_skb_any() on 'skb' in any order with respect to that assignment. I'm not applying this until you can show a real bug resulting from the current code, and if so you'll need to add that explanation to your commit message. Thanks.