From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FD2BC43613 for ; Thu, 20 Jun 2019 18:24:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05353206BF for ; Thu, 20 Jun 2019 18:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561055097; bh=upEVnw1kzCasYRFExIc5e5hpkGiwl0rOpPec6g/Pr/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gw4pp1w9IZwEn+ZV3n9S1303Axhn2hnQHXxMPU/gw2/FYSwGvatPZ0S7by7V6uxLR HOBh/ZbaFdzIRFQv9JTqKbCB4PtRKvccXEMzRstOkb7n4hjj0eaxR6gg7pOfeU4dp+ FXcWtwlkxrBsgzxWzFk/BDVVSCifk/YxK/ip3VoM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbfFTSID (ORCPT ); Thu, 20 Jun 2019 14:08:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:35040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfFTSIA (ORCPT ); Thu, 20 Jun 2019 14:08:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 0BE9B21670; Thu, 20 Jun 2019 18:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054080; bh=upEVnw1kzCasYRFExIc5e5hpkGiwl0rOpPec6g/Pr/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L6xW5WjiPPVxq8wHi3L/Jdi50zOZi1t69WhWvrQPAqcKZ1ZZ3NuPp+AsSFeLKOmft ZEwxbCK9CzUyafeRJ9wgOSVcBcTK8dOo3duoLZponzbBy+enmWQ88gmAfgGEf+wJ10 SfNukt2dPSXNfyEWbYVToLiJAq6S4pme3M0+ADzs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jagdish Motwani , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.14 12/45] netfilter: nf_queue: fix reinject verdict handling Date: Thu, 20 Jun 2019 19:57:14 +0200 Message-Id: <20190620174333.723645570@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174328.608036501@linuxfoundation.org> References: <20190620174328.608036501@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 946c0d8e6ed43dae6527e878d0077c1e11015db0 ] This patch fixes netfilter hook traversal when there are more than 1 hooks returning NF_QUEUE verdict. When the first queue reinjects the packet, 'nf_reinject' starts traversing hooks with a proper hook_index. However, if it again receives a NF_QUEUE verdict (by some other netfilter hook), it queues the packet with a wrong hook_index. So, when the second queue reinjects the packet, it re-executes hooks in between. Fixes: 960632ece694 ("netfilter: convert hook list to an array") Signed-off-by: Jagdish Motwani Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_queue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c index f7e21953b1de..8260b1e73bbd 100644 --- a/net/netfilter/nf_queue.c +++ b/net/netfilter/nf_queue.c @@ -193,6 +193,7 @@ static unsigned int nf_iterate(struct sk_buff *skb, repeat: verdict = nf_hook_entry_hookfn(hook, skb, state); if (verdict != NF_ACCEPT) { + *index = i; if (verdict != NF_REPEAT) return verdict; goto repeat; -- 2.20.1