Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3874385pxb; Tue, 17 Nov 2020 05:58:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJySSNJNru7QrVK+ZQkGa2EyYGa3D7UdZlKWSkpOrnOaZPjgk74oOnADzU3yQYfVnDHXOOaX X-Received: by 2002:a05:6402:1f0:: with SMTP id i16mr20750025edy.122.1605621523378; Tue, 17 Nov 2020 05:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621523; cv=none; d=google.com; s=arc-20160816; b=QJPeb4TBfKSYgtJwvlfVU2zPiHeX62aPQlFBFHUFbV6qfIK7DifvUEyi9qDGwyPuDp RvcwksZdCW4DWaJE+2h2IbqVqTfjJWql02wS6I8rIJcZOr1ezfVmmLBXkxl7L7N40rXN +NLpYkQfeVtOQELA/NZZPJNW9E+GjBca0SQVC+6bUF2FwnHtAhxwG/uSlg0HKZfMNlhh fkx4pv8lP0qPtrFxXf+CrV/Gig3MsRV8xgnnKw8WsINOqPMub9xvspXmV3iIFio/OwJt hS+Dg3y/AZRZP4DD20fbbE2o+GVsOCf7tOMeAF41u6S1fTx0Qo4/hqtgYXNL+UPL/Grw KbLw== 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=EWprLVp1yywR1MkabXE4WhpcWw6zDnCIBuW44bkLtsg=; b=opKFdHhhFBKzZTnro72Lky6HKI2d596TMd0v2QiaDofgLFLtNm17hmM5KpoqqbLmEP A/zQnvV0fGT+puVlp67D8Hvk7Zu+P391o27fL6zn/8iGO49uyyzPXnMpmeiOC+o7YpO0 xxJT3YS8w3/6uKo7uMbyHucvRA9AW6R+d1jaSSmjGNrVmu4rElnfUvcQPxeVGA2NqKvR i3DBHwntHMLQFD6qGaWMbXU5GicpBbIPzt6o03MdKzXb88RkDvZyY6O7xscvZFmkjtqg Z5Im1AO9bK3rUqdqA0uUgvdB9u1Hwu0MVlFZetaUQIWwOijEdM0W1OeyqXSRsmBjtY/t xTtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cVXAeSbo; 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 a3si1013980edv.447.2020.11.17.05.58.19; Tue, 17 Nov 2020 05:58:43 -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=cVXAeSbo; 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 S1731091AbgKQNWC (ORCPT + 99 others); Tue, 17 Nov 2020 08:22:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:55464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730903AbgKQNVg (ORCPT ); Tue, 17 Nov 2020 08:21:36 -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 681382463D; Tue, 17 Nov 2020 13:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619296; bh=lYCvS8uv3GpQUoX8NeUyQRO0vxZpsmJopGZ9FeAy600=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cVXAeSbo38vWYrCVYcQdCkGNLCgPZfoGccz4Kqxd1DIus4z4k+9VvKYEffStFII63 nPqwQPy5oC2aYZ7iuYMGaaWjkYtlGRLV8DDYpsBsslGJluN6DD9UWshnMlUr+GiT46 qRz6S4V4cxKRV194pGgln+7csRMK5yLhGzZKQSts= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , Heiner Kallweit Subject: [PATCH 4.19 093/101] r8169: fix potential skb double free in an error path Date: Tue, 17 Nov 2020 14:06:00 +0100 Message-Id: <20201117122117.666876711@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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: Greg Kroah-Hartman --- drivers/net/ethernet/realtek/r8169.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -6274,7 +6274,8 @@ static bool rtl8169_tso_csum_v2(struct r opts[1] |= transport_offset << TCPHO_SHIFT; } else { if (unlikely(rtl_test_hw_pad_bug(tp, skb))) - return !eth_skb_pad(skb); + /* eth_skb_pad would free the skb on error */ + return !__skb_put_padto(skb, ETH_ZLEN, false); } return true;