Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3848903pxb; Tue, 17 Nov 2020 05:19:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxh8PEq4c30JocLFacmn7lC7MJ/lvqdiklIrmfe6aRA4NJE3Z99hdwwPMLg3EcMSDriQWFo X-Received: by 2002:a17:906:fa1b:: with SMTP id lo27mr18822808ejb.216.1605619196635; Tue, 17 Nov 2020 05:19:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619196; cv=none; d=google.com; s=arc-20160816; b=dT788Lt3yPT4PooefumZLKIgrzHJq8wpqHN57eESOQeY51JvB43sLG+lCg3lqCJBcG i3SNd5R/JVlAty/ExrRs5TNUW0hy5fUx8r6WcsXdZyVQYpM/t+x4YyzGKn4eTVCSL2fU EzAfbuxsUXSj4mKwwxlL4uo0qJPbbSRAFwwHeqlaO+32UkwU2G7nR4Y1135Xm9NQRE+l 1kNCfiHul9uvdB2oi7DMtsUjiev/v48/94e29pLxmvL8+pu4FtbKGXiFWxXrGrE5VmOA GQKoopKlk4o37kfwMgyQhkmzyFZ9X8AZaHfIw4SncPXfhx5MuNJpzd8Ga5FnLwgx0B2m 7xBw== 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=gU78FV0QeLYoJHfcCCEO58W952rNzoYoI3tybfIC9Dk=; b=PLIh0LVLbP2J/mQJWjfnffV5jd2QsFnwnDzQ82BDdnvSLkdLvwIulAftIZt5izeium 5F+3WkaT4uytdjK2UOQmJrBcmM1zaO5vGBP31+CI8GfWOZVt7oFmVCH4mC3jq2x4ahk3 dJ+DgNE8Kih6zo6JiA1D95Q/s3B2GAnU2/vZhRGUhQTMyIzNaniHDKUfWtczFfQG4jvA xQEr6sGeS6nwnWJcUA980+WPcKQmHd6r96MrVJj2RbeOQ/Lt4VoTKgPTyzT7IIifCl4x p9dvzLeO0k/5C0QeOTE2H/iqoZnLLKEgkbGeYuuUl05HSarTrcpDn7VlSKKGqqCWylii Ge0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gSelzmst; 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 ce10si16499118edb.515.2020.11.17.05.19.33; Tue, 17 Nov 2020 05:19:56 -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=gSelzmst; 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 S1730259AbgKQNP4 (ORCPT + 99 others); Tue, 17 Nov 2020 08:15:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:47440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730245AbgKQNPw (ORCPT ); Tue, 17 Nov 2020 08:15:52 -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 919542225B; Tue, 17 Nov 2020 13:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618952; bh=h5VWCUOtijWFwdnCAgQlgw+aocOp9uhPcWoUd1h7kP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gSelzmst5hox4dPzgaZBftgrbWgTBNGGZaSITBcdBqp2CofatBs2GcsPPa7ntvlyz PhNKBbkWTbbVesWxr89vcSYWxzzmxmuO/7QjoGkTGIpWE1HGa1w574dMWYMmtxJMpu QMZklgxcwjwN7vv6+pjC+inW5aC/DjK1Oi8gjKX8= 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.14 62/85] r8169: fix potential skb double free in an error path Date: Tue, 17 Nov 2020 14:05:31 +0100 Message-Id: <20201117122114.082163959@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@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 @@ -7143,7 +7143,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;