Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4310868pxu; Tue, 1 Dec 2020 01:35:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCPwfl/WjavARi0MuzmPSaI/ddeHAgkdn32G4U8lf/E3uSV9XtMei4Th7RTVZn2DA3soEs X-Received: by 2002:a05:6402:a58:: with SMTP id bt24mr2076896edb.95.1606815311658; Tue, 01 Dec 2020 01:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606815311; cv=none; d=google.com; s=arc-20160816; b=xmoQyqeovE8vx8wLqpPpUstzBKkZ8xmBgTfwC9Cv4mJXp5y+j9BxC0CfAPxnxn2Cgg TL40TXPs+qimt/o7UZNHIofNLDLuzlw/WZZbXC9PZaiwfXz8B0KImvlB2eWnBFRJdWGl OqAjBuRVw2i0DEaNiFj2FKZI+syGWYCafGgKwkf9SH3tIFWnJmKudH+JVjw3Bzf/j3sO blCyC0dOqa1FulH9D3k5UVHA4Q23r3mpTi9Mnj848OHLP6cFai3gUIlarEooIQcsLnbH g8PMtXyAPQESvyVqPLZxIPxGsQUkXM/EdsDqC0IilyY1NkFYh3b2q/uzMoGiniVOokM4 QSow== 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=kljYabG0QHzvC+8Gri7jynAe3Bp929DZ3qRjDzykhLk=; b=CKGSN6p5JEcqlnjru9ExfTKKxvKEbwktKEX618DnTWVRTQScbAQLPT4aCXB3Se7ic/ E2A6zU7b70+Fx9a/rHdGWhowZd+84uZwulHJ/RkZxTAt+KFg2IDPBt9qri2py6ts0By4 ce+ApZfxjwg0ohN6AyrCYSqYbTa0t604+lJbkPb/hii2zGWnmcSGu8MGNxQWj4d+1dkp GUvc1VsVEwPKTFO20eBDvt3/I9Xi8+4D+Nla4nAa8kL4BhRuHafX1Z1cZ6J1tdjwQ+NP Ixh1xt+QcRNPcjsKb8ltRGLeY7dk5sgsz1NTWfd3wcAngsRegt7U8UkOZPLvY2YfX6o5 wgAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZGTwODFX; 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=pass (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 lb19si566462ejb.672.2020.12.01.01.34.47; Tue, 01 Dec 2020 01:35:11 -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=@linuxfoundation.org header.s=korg header.b=ZGTwODFX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390737AbgLAJ2w (ORCPT + 99 others); Tue, 1 Dec 2020 04:28:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:36096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388330AbgLAJAc (ORCPT ); Tue, 1 Dec 2020 04:00:32 -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 F16832224C; Tue, 1 Dec 2020 09:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813210; bh=NQATGuLRhU93w/kDiUKvCju7GIzcSrj1MKQiUZVyn00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZGTwODFXcP58UKP3JlPLB2ljkP+WwjIo7CZcUyu+jDvSBV8jBaQLADilf+dBXklPm 0VNAEH0Sdqtrpm6hkhR1U6oO1g1LyoahpTyuoDjP8GmnSi5tLUAQt8FcIUfzzWAlDW QpN23IxiBawGmTiNyDScPgPY2erZ77xnC1R+9hCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, liuzx@knownsec.com, Florian Westphal , Edward Cree , Cong Wang Subject: [PATCH 4.19 02/57] netfilter: clear skb->next in NF_HOOK_LIST() Date: Tue, 1 Dec 2020 09:53:07 +0100 Message-Id: <20201201084648.007878659@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084647.751612010@linuxfoundation.org> References: <20201201084647.751612010@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: Cong Wang NF_HOOK_LIST() uses list_del() to remove skb from the linked list, however, it is not sufficient as skb->next still points to other skb. We should just call skb_list_del_init() to clear skb->next, like the rest places which using skb list. This has been fixed in upstream by commit ca58fbe06c54 ("netfilter: add and use nf_hook_slow_list()"). Fixes: 9f17dbf04ddf ("netfilter: fix use-after-free in NF_HOOK_LIST") Reported-by: liuzx@knownsec.com Tested-by: liuzx@knownsec.com Cc: Florian Westphal Cc: Edward Cree Cc: stable@vger.kernel.org # between 4.19 and 5.4 Signed-off-by: Cong Wang Signed-off-by: Greg Kroah-Hartman --- include/linux/netfilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h @@ -300,7 +300,7 @@ NF_HOOK_LIST(uint8_t pf, unsigned int ho INIT_LIST_HEAD(&sublist); list_for_each_entry_safe(skb, next, head, list) { - list_del(&skb->list); + skb_list_del_init(skb); if (nf_hook(pf, hook, net, sk, skb, in, out, okfn) == 1) list_add_tail(&skb->list, &sublist); }