Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3862207pxb; Tue, 17 Nov 2020 05:39:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2ta/vXQsw716zrH223f6wNBexKhFb8dqQKtDW5Av6yTkwBodbE5yfco1wjPLSnlwiezu8 X-Received: by 2002:aa7:c68d:: with SMTP id n13mr21646591edq.350.1605620350741; Tue, 17 Nov 2020 05:39:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605620350; cv=none; d=google.com; s=arc-20160816; b=y47dyUjmgtXToVKKSryTvsTp6YtRBHa5kprp8WS0JJ+SvToUw4fl8Epx1NoerT1SaP WWGc/Y0YEWmyEKiKxnNLDAqeGkyUyukR3kPwefP7KV4RmuM12l9netysr/YuNdUnqs7A 6zMZWtunyIlXTcX39TphkOb+OIxqP8K8kg3wKBdKR8G1vrpp4m3m5WK4rnixuCHgnAio hR4ql1xnAKIYpswVzX7G6aDWvFb2uK6uvK+zIMTs4gNpbkU1v77PfwEx6ooxatnpZkJ9 W6+SvnFODcUuw60bCkR6yG6GUTNFiUl+dKNdvt1PjDt+HwZqWiwegRAqRzkubClMOQOn i+/g== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ORQzeQcxGxm2L65BEZ8hCjmApxd24QPCS4mZBL12/Dw=; b=WZm2H0J9FMDTFeCY1qMpSNHchRKnEFybCn8nmCsnHbNmr4/6gXi8Kg8aBpZ7/4ZEWE i7EVTMDMN0t9760iDknLCbY3K5CoIZDbfFVIbVbbtsnjlS0xGvvrDVID6hL7OXrwDn54 1nfhovlM0L5xIio3UUMrEZc0LJBDbkE04moDtyZTLXouqfDAONMnvywEIlFnJqdwZSoN E7TPnXEYOW1lEkeFgqcyEQuMfQLvN9gS9WSLVLcF5Hw6DHO/dmXc1UlGfG2o/DPJVDyT MeBskBvUsrBweH6bC8zC4ZIAsItc5XZ5UNpsRlOlwVHmmhWhB8asb0QthhDGk0rTniBz Talw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qWMJeBa9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si13806789ejb.17.2020.11.17.05.38.46; Tue, 17 Nov 2020 05:39:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qWMJeBa9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732055AbgKQNhZ (ORCPT + 99 others); Tue, 17 Nov 2020 08:37:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:48270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732315AbgKQNhI (ORCPT ); Tue, 17 Nov 2020 08:37:08 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF30920870; Tue, 17 Nov 2020 13:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620228; bh=H0dIFFMoiuOw6flSrUg0/ibVcmqoAPx4AYA+UHLxcHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qWMJeBa9OHwuBETH78D5tBDgpvL/Ck4COMfmL4l+z/rhLOCOSof3IAFH1LAwuiFfc Wyav2DiBS54WN9VMHdTqfsYG9lvH+7lqLzhOy8rzQAFEdqSXINdPdOZsMzXV2NHInc CvJAoRlRND2IiJE5BmiFiln9yxJsaH+kVwBh0big= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , Heiner Kallweit , Sasha Levin Subject: [PATCH 5.9 148/255] r8169: fix potential skb double free in an error path Date: Tue, 17 Nov 2020 14:04:48 +0100 Message-Id: <20201117122146.167423295@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiner Kallweit [ Upstream commit cc6528bc9a0c901c83b8220a2e2617f3354d6dd9 ] The caller of rtl8169_tso_csum_v2() frees the skb if false is returned. eth_skb_pad() internally frees the skb on error what would result in a double free. Therefore use __skb_put_padto() directly and instruct it to not free the skb on error. Fixes: b423e9ae49d7 ("r8169: fix offloaded tx checksum for small packets.") Reported-by: Jakub Kicinski Signed-off-by: Heiner Kallweit Link: https://lore.kernel.org/r/f7e68191-acff-9ded-4263-c016428a8762@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/realtek/r8169_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index c74d9c02a805f..ed918c12bc5e9 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4145,7 +4145,8 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp, opts[1] |= transport_offset << TCPHO_SHIFT; } else { if (unlikely(skb->len < ETH_ZLEN && rtl_test_hw_pad_bug(tp))) - return !eth_skb_pad(skb); + /* eth_skb_pad would free the skb on error */ + return !__skb_put_padto(skb, ETH_ZLEN, false); } return true; -- 2.27.0