Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1345671 > unrolled thread

unused code in net/netfilter/ipset/ip_set_bitmap_ipmac.c

Started byJulia Lawall <julia.lawall@lip6.fr>
First post2016-02-29 12:20 +0100
Last post2016-02-29 13:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  unused code in net/netfilter/ipset/ip_set_bitmap_ipmac.c Julia Lawall <julia.lawall@lip6.fr> - 2016-02-29 12:20 +0100
    Re: unused code in net/netfilter/ipset/ip_set_bitmap_ipmac.c Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> - 2016-02-29 12:40 +0100
      Re: unused code in net/netfilter/ipset/ip_set_bitmap_ipmac.c Julia Lawall <julia.lawall@lip6.fr> - 2016-02-29 13:30 +0100

#1345671 — unused code in net/netfilter/ipset/ip_set_bitmap_ipmac.c

FromJulia Lawall <julia.lawall@lip6.fr>
Date2016-02-29 12:20 +0100
Subjectunused code in net/netfilter/ipset/ip_set_bitmap_ipmac.c
Message-ID<r7u1Q-2ia-3@gated-at.bofh.it>
The file net/netfilter/ipset/ip_set_bitmap_ipmac.c seems to contain a lot
of static functions that are not used in the file:

bitmap_ipmac_add_timeout
bitmap_ipmac_do_add
bitmap_ipmac_do_del
bitmap_ipmac_do_head
bitmap_ipmac_do_list
bitmap_ipmac_do_test
bitmap_ipmac_gc_test
bitmap_ipmac_is_filled
bitmap_ipmac_kadt
bitmap_ipmac_same_set
bitmap_ipmac_uadt

Have I overooked something?

I was looking at this code, with Daniel Borkmann, because there seems to
be a bug in the function bitmap_ipmac_uadt:

	if (tb[IPSET_ATTR_ETHER]) {
                memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN);
                e.add_mac = 1;
        }

Later in the same file, there is:

static struct ip_set_type bitmap_ipmac_type = {
	...
        .adt_policy     = {
		...
		[IPSET_ATTR_ETHER]      = { .type = NLA_BINARY,
                                            .len  = ETH_ALEN },
		...},
	...
};

The type NLA_BINARY indicates that the length is a maximum possible
length, and thus a check of the actual length is needed before the memcpy.

The file net/netfilter/ipset/ip_set_hash_mac.c seems to have a similar
problem.  The following static functions are not used:

hash_mac4_data_equal
hash_mac4_data_list
hash_mac4_data_next
hash_mac4_kadt
hash_mac4_uadt

And the following code:

ether_addr_copy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]));

in hash_mac4_uadt does not seem to have a check on the length, and the
field is defined in the same way as above.

julia

[toc] | [next] | [standalone]


#1345721

FromJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Date2016-02-29 12:40 +0100
Message-ID<r7ulb-2qo-5@gated-at.bofh.it>
In reply to#1345671
Hi,

On Mon, 29 Feb 2016, Julia Lawall wrote:

> The file net/netfilter/ipset/ip_set_bitmap_ipmac.c seems to contain a lot
> of static functions that are not used in the file:
> 
> bitmap_ipmac_add_timeout
> bitmap_ipmac_do_add
> bitmap_ipmac_do_del
> bitmap_ipmac_do_head
> bitmap_ipmac_do_list
> bitmap_ipmac_do_test
> bitmap_ipmac_gc_test
> bitmap_ipmac_is_filled
> bitmap_ipmac_kadt
> bitmap_ipmac_same_set
> bitmap_ipmac_uadt
> 
> Have I overooked something?

Yes: the file includes ip_set_bitmap_gen.h in which all those functions 
are used.
 
> I was looking at this code, with Daniel Borkmann, because there seems to
> be a bug in the function bitmap_ipmac_uadt:
> 
> 	if (tb[IPSET_ATTR_ETHER]) {
>                 memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN);
>                 e.add_mac = 1;
>         }
> 
> Later in the same file, there is:
> 
> static struct ip_set_type bitmap_ipmac_type = {
> 	...
>         .adt_policy     = {
> 		...
> 		[IPSET_ATTR_ETHER]      = { .type = NLA_BINARY,
>                                             .len  = ETH_ALEN },
> 		...},
> 	...
> };
> 
> The type NLA_BINARY indicates that the length is a maximum possible
> length, and thus a check of the actual length is needed before the memcpy.

You are right here (and the similar spotting in ip_set_hash_mac.c) - I'll 
prepare a patch and submit it.

Best regards,
Jozsef
-
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
          H-1525 Budapest 114, POB. 49, Hungary

[toc] | [prev] | [next] | [standalone]


#1345745

FromJulia Lawall <julia.lawall@lip6.fr>
Date2016-02-29 13:30 +0100
Message-ID<r7v7B-2Wa-19@gated-at.bofh.it>
In reply to#1345721

On Mon, 29 Feb 2016, Jozsef Kadlecsik wrote:

> Hi,
>
> On Mon, 29 Feb 2016, Julia Lawall wrote:
>
> > The file net/netfilter/ipset/ip_set_bitmap_ipmac.c seems to contain a lot
> > of static functions that are not used in the file:
> >
> > bitmap_ipmac_add_timeout
> > bitmap_ipmac_do_add
> > bitmap_ipmac_do_del
> > bitmap_ipmac_do_head
> > bitmap_ipmac_do_list
> > bitmap_ipmac_do_test
> > bitmap_ipmac_gc_test
> > bitmap_ipmac_is_filled
> > bitmap_ipmac_kadt
> > bitmap_ipmac_same_set
> > bitmap_ipmac_uadt
> >
> > Have I overooked something?
>
> Yes: the file includes ip_set_bitmap_gen.h in which all those functions
> are used.

OK, thanks.  I saw the incude, but I didn't sufficiently appreciate the
#defines at the beginning.  Thanks.

> > I was looking at this code, with Daniel Borkmann, because there seems to
> > be a bug in the function bitmap_ipmac_uadt:
> >
> > 	if (tb[IPSET_ATTR_ETHER]) {
> >                 memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN);
> >                 e.add_mac = 1;
> >         }
> >
> > Later in the same file, there is:
> >
> > static struct ip_set_type bitmap_ipmac_type = {
> > 	...
> >         .adt_policy     = {
> > 		...
> > 		[IPSET_ATTR_ETHER]      = { .type = NLA_BINARY,
> >                                             .len  = ETH_ALEN },
> > 		...},
> > 	...
> > };
> >
> > The type NLA_BINARY indicates that the length is a maximum possible
> > length, and thus a check of the actual length is needed before the memcpy.
>
> You are right here (and the similar spotting in ip_set_hash_mac.c) - I'll
> prepare a patch and submit it.

Great.  Thanks.

julia

>
> Best regards,
> Jozsef
> -
> E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
> PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
> Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
>           H-1525 Budapest 114, POB. 49, Hungary
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web