From patchwork Sat Jan 26 18:38:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WU9TSElGVUpJIEhpZGVha2kgLyDlkInol6Toi7HmmI4=?= X-Patchwork-Id: 215924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E9CA72C0089 for ; Sun, 27 Jan 2013 05:38:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753397Ab3AZSiZ (ORCPT ); Sat, 26 Jan 2013 13:38:25 -0500 Received: from 94.43.138.210.xn.2iij.net ([210.138.43.94]:57823 "EHLO mail.st-paulia.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752343Ab3AZSiZ (ORCPT ); Sat, 26 Jan 2013 13:38:25 -0500 Received: from [192.168.2.183] (unknown [192.168.2.183]) by mail.st-paulia.net (Postfix) with ESMTPSA id 496771BDBF; Sun, 27 Jan 2013 03:38:24 +0900 (JST) Message-ID: <5104229F.9000501@linux-ipv6.org> Date: Sun, 27 Jan 2013 03:38:23 +0900 From: YOSHIFUJI Hideaki Organization: USAGI Project User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: netfilter-devel@vger.kernel.org CC: jm@dilly.me, fw@strlen.de, yoshfuji@linux-ipv6.org Subject: [RFC PATCH 3/4] netfilter ip6t_NPT: Ensure to check lower part of prefixes are zero. Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Signed-off-by: YOSHIFUJI Hideaki --- net/ipv6/netfilter/ip6t_NPT.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c index b1bf3ed..7d23d22 100644 --- a/net/ipv6/netfilter/ip6t_NPT.c +++ b/net/ipv6/netfilter/ip6t_NPT.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -18,10 +19,19 @@ static int ip6t_npt_checkentry(const struct xt_tgchk_param *par) { struct ip6t_npt_tginfo *npt = par->targinfo; __wsum src_sum, dst_sum; + struct in6_addr pfx; if (npt->src_pfx_len > 64 || npt->dst_pfx_len > 64) return -EINVAL; + /* Ensure that LSB of prefix is zero */ + ipv6_addr_prefix(&pfx, &npt->src_pfx.in6, npt->src_pfx_len); + if (!ipv6_addr_equal(&pfx, &npt->src_pfx.in6)) + return -EINVAL; + ipv6_addr_prefix(&pfx, &npt->dst_pfx.in6, npt->dst_pfx_len); + if (!ipv6_addr_equal(&pfx, &npt->dst_pfx.in6)) + return -EINVAL; + src_sum = csum_partial(&npt->src_pfx.in6, sizeof(npt->src_pfx.in6), 0); dst_sum = csum_partial(&npt->dst_pfx.in6, sizeof(npt->dst_pfx.in6), 0);