From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo Neira Ayuso Subject: [PATCH 4/8] netfilter: xt_TEE: add missing code to get interface index in checkentry. Date: Mon, 22 Oct 2018 22:07:20 +0200 Message-ID: <20181022200724.25806-5-pablo@netfilter.org> References: <20181022200724.25806-1-pablo@netfilter.org> Cc: davem@davemloft.net, netdev@vger.kernel.org To: netfilter-devel@vger.kernel.org Return-path: Received: from mail.us.es ([193.147.175.20]:45086 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbeJWE1g (ORCPT ); Tue, 23 Oct 2018 00:27:36 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 3BF4B1E8F98 for ; Mon, 22 Oct 2018 22:07:38 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 1239DDA915 for ; Mon, 22 Oct 2018 22:07:38 +0200 (CEST) In-Reply-To: <20181022200724.25806-1-pablo@netfilter.org> Sender: netdev-owner@vger.kernel.org List-ID: From: Taehee Yoo checkentry(tee_tg_check) should initialize priv->oif from dev if possible. But only netdevice notifier handler can set that. Hence priv->oif is always -1 until notifier handler is called. Fixes: 9e2f6c5d78db ("netfilter: Rework xt_TEE netdevice notifier") Signed-off-by: Taehee Yoo Signed-off-by: Pablo Neira Ayuso --- net/netfilter/xt_TEE.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/netfilter/xt_TEE.c b/net/netfilter/xt_TEE.c index 673ad2099f97..1dae02a97ee3 100644 --- a/net/netfilter/xt_TEE.c +++ b/net/netfilter/xt_TEE.c @@ -104,6 +104,8 @@ static int tee_tg_check(const struct xt_tgchk_param *par) return -EINVAL; if (info->oif[0]) { + struct net_device *dev; + if (info->oif[sizeof(info->oif)-1] != '\0') return -EINVAL; @@ -115,6 +117,11 @@ static int tee_tg_check(const struct xt_tgchk_param *par) priv->oif = -1; info->priv = priv; + dev = dev_get_by_name(par->net, info->oif); + if (dev) { + priv->oif = dev->ifindex; + dev_put(dev); + } mutex_lock(&tn->lock); list_add(&priv->list, &tn->priv_list); mutex_unlock(&tn->lock); -- 2.11.0