Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp404231pxu; Tue, 1 Dec 2020 14:24:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8BR4K4MKhRFsHsVTYMKwyybzeYXSXyyuq+boh7RA/Civ4K0nkX9k+yHcIi//82+wa7CZM X-Received: by 2002:a17:906:8354:: with SMTP id b20mr5081083ejy.397.1606861469894; Tue, 01 Dec 2020 14:24:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861469; cv=none; d=google.com; s=arc-20160816; b=ENkLt9TW4l8/y59RDxq2VjRchD82WKYEsKDrwZ/FJx/jReYecMOSYMJfIu84avn9y0 FB9ucswlseVP0SmLMTLZRok4Eixsp9MeZyXy/tSYSR6b99QbGT8SMPpL3f5S14gTtPvL B8On2sBqiBxg8f6ZwfSV43w1+VZyYs3b5rXqH5p+kNf6N5ERc8stkJGV6QBMbLHLN51z RRDbUYwXj9Zr/r+rI8EUMF5NjI60Ru279EnKIO3kjJFM+1HpwyRv70GVrZEaNOZkaojH jjFumJnhzlBdjRP40pwX71dYMpeQ0cfun/m2AK0dnk11JJFPJqcWwNTZ+RFZnmaZsvSA XF+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=rt50D4tcMhlAQF/VJDVf+/kz3lB5YmttjOsN99EloYc=; b=E6qmBV9lvSVQc3L9LL8Mchp7l8U0oxlJ3WF8M0ypZfKO89gLKdRc6O7H8cM+rGbmNO fxgDbfOudqphMiWIwPUq1SOWYpuX9TP4i+X+td1ZAaHafHWJTm5dkaXzEOx6JUaeCz58 UTHUL7bEHDViMjgxwZ8ayIbP8PU98nAloPUawrcVUigd98/RFeXXdicOcUsRZcGnjP7v ged45FKJVsP0EJ5MO+fpkRt9RSzf/9HS40pw0wMWw0cPJTgsTFD0iCIPep368zh24cYm D4Pkcya+CvAPJMgWwfDnPAuswO9SiQCRP0vuySRPiDgQ/UuoHV5dpKeoh7WHCXhIG+RZ jy/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BMLSTeo/"; 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 b1si791579edy.429.2020.12.01.14.24.07; Tue, 01 Dec 2020 14:24:29 -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="BMLSTeo/"; 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 S2388981AbgLAJHa (ORCPT + 99 others); Tue, 1 Dec 2020 04:07:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:41038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388191AbgLAJDz (ORCPT ); Tue, 1 Dec 2020 04:03:55 -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 9E40A21D7F; Tue, 1 Dec 2020 09:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813395; bh=ZfyxbyXJNsR7Ox478lYb9kMLqF/gdHTamP66YJE3i8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BMLSTeo/UY4hf6kWMcGnfEXNHPpFO6VLtAnY7M934w28oX+BdsadMly5EeyCOLq6j 65LyEH3LPPPfpTUo7STqhsox2xRVXA9OlPEMjdaam5FXYUC8mIkWtDEAhGJyiiN/lq 0hNc+UbyLbiESzINkxL/Z0/oRv9Ar6T+UtdAhhjg= 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 5.4 04/98] netfilter: clear skb->next in NF_HOOK_LIST() Date: Tue, 1 Dec 2020 09:52:41 +0100 Message-Id: <20201201084653.262544594@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084652.827177826@linuxfoundation.org> References: <20201201084652.827177826@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 @@ -316,7 +316,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); }